@fayz-ai/plugin-fiscal-br

中文文档
0.17.3发布于 2026/11/11MITTypeScriptES Module近 30 天下载 1.1万

[preview] Brazilian fiscal addon for asynchronous NFC-e emission through PlugNotas

原始使用文档
文档目录5 节
  1. Ownership boundary
  2. Why the command is durable
  3. Credential and certificate boundary
  4. Runtime contract
  5. What this draft does not authorize

@fayz-ai/plugin-fiscal-br

Status: preview. Sandbox and SEFAZ homologation only; production emission is intentionally not exposed by this package.

plugin-fiscal-br is the Brazilian fiscal addon hosted by @fayz-ai/plugin-financial. Its first provider is TecnoSpeed PlugNotas and its first document journey is NFC-e (model 65) for a completed restaurant order.

npm install @fayz-ai/plugin-fiscal-br

Ownership boundary

  • plugin-financial owns plg_financial_nfe, the fiscal document shown to the operator. There is no second PlugNotas invoice table.
  • plugin-fiscal-br owns the provider connection contract, durable command, retry/recovery trail, webhook receipt and emitter claim.
  • The app owns the Edge Function implementation and the setup panel, because it owns deployment, origins and product-specific composition.
  • packages/db owns connections, orders and items. The addon consumes those canonical contracts; it does not recreate plg_connections or order_items from the pre-squash implementation.

Why the command is durable

Sending an NFC-e and losing the HTTP response is ambiguous: the provider may have accepted the document even though the caller timed out. Repeating the POST without first consulting the provider can create a duplicate fiscal effect.

The migration therefore creates plg_fiscalbr_nfce_jobs before any provider call. The job keeps a frozen order snapshot and a stable idempotency key. A timeout moves it to waiting; a recovery worker claims it with SKIP LOCKED, queries PlugNotas and only retries with the same integration id when the provider confirms the first request does not exist. Webhooks and recovery update the same job and the same plg_financial_nfe row.

Credential and certificate boundary

The browser stores no PlugNotas API key, A1 bytes, A1 password, CSC code or CSC token. The setup form uploads the A1 and its password to the app-owned server boundary over the authenticated request; the boundary forwards them to the provider and discards them. connections.settings receives only readiness and non-secret metadata such as expiry and an optional fingerprint.

CSC belongs to the emitter. It must be collected during that tenant's setup and sent to the server boundary. It is not a pool-wide PLUGNOTAS_CSC_CONFIG_JSON secret and cannot be shared between tenants. This package deliberately removed that old draft contract.

The PlugNotas software-house API key remains a server-only deployment secret. No secret value is committed here; the manifest contains names only so deploy and diagnostics can report missing configuration.

Runtime contract

import { createFinancialPlugin } from '@fayz-ai/plugin-financial'
import {
  createPlugNotasFinancialProvider,
  createPlugNotasPlugin,
} from '@fayz-ai/plugin-fiscal-br'

const fiscalProvider = createPlugNotasFinancialProvider({
  base: financialProvider,
  gateway: appOwnedPlugNotasGateway,
})

const plugins = [
  createFinancialPlugin({
    dataProvider: fiscalProvider,
    fiscalProvider: {
      label: 'PlugNotas',
      models: ['nfce'],
      requiresOrder: true,
    },
  }),
  createPlugNotasPlugin({ SetupPanel: AppOwnedSetupPanel }),
]

The decorator never trusts a transient provider response as the ledger. Issue, refresh and cancel always return the document read back from the database after the server operation. XML, DANFCE and cancellation XML use short-lived URLs resolved on demand instead of durable signed URLs stored on the fiscal row.

What this draft does not authorize

  • It does not apply the migration to a Supabase project.
  • It does not deploy the Edge Function.
  • It does not create or rotate any secret.
  • It does not enable production emission.
  • It does not claim homologation passed; that needs a real emitter, A1, CSC and an observed issue/status/artifact/cancel journey.

The companion NeoChef PR supplies the application Edge Function and composition. The full ownership map and rollout gates are documented in docs/integrations/PLUGNOTAS-NFCE.md.

版本与发布记录

@fayz-ai/plugin-fiscal-br 共发布 78 个版本,首次发布于 2026/09/11;过去 12 个月发布了 78 个版本。

版本发布日期距今
0.17.3latest2026/11/112 天前
0.17.22026/11/113 天前
0.17.12026/11/113 天前
0.17.02026/11/067 天前
0.16.52026/11/068 天前
0.16.42026/11/068 天前

其他发布通道:canary → 0.15.10-canary.20261028153856。

关于 @fayz-ai/plugin-fiscal-br 的常见问题

@fayz-ai/plugin-fiscal-br 是什么?

[preview] Brazilian fiscal addon for asynchronous NFC-e emission through PlugNotas

如何安装 @fayz-ai/plugin-fiscal-br?

在项目目录运行 npm install @fayz-ai/plugin-fiscal-br,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)、react-dom(^18.0.0 || ^19.0.0)、lucide-react(>=0.400.0 <1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fayz-ai/plugin-fiscal-br 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fayz-ai/plugin-fiscal-br 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fayz-ai/plugin-fiscal-br 可以商用吗?

@fayz-ai/plugin-fiscal-br 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fayz-ai/plugin-fiscal-br 的下载量有多少?

根据 npm 官方下载统计,@fayz-ai/plugin-fiscal-br 在 2026/10/15 – 2026/11/13 这 30 天内被下载 10,569 次,日均约 352 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fayz-ai/plugin-fiscal-br 还在维护吗?

最新版本 0.17.3 发布于 2026/11/11(2 天前);至今共发布 78 个版本,其中过去 12 个月发布了 78 个;首次发布于 2026/09/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。