@timbro/invoices 0.8.2 → 0.9.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +95 -258
  2. package/dist/admin.d.ts +44 -0
  3. package/dist/admin.d.ts.map +1 -0
  4. package/dist/admin.js +16 -0
  5. package/dist/certificate-custody-import.d.ts +4 -2
  6. package/dist/certificate-custody-import.d.ts.map +1 -1
  7. package/dist/certificate-custody-import.js +1 -1
  8. package/dist/collection.d.ts +1 -1
  9. package/dist/collection.js +4 -4
  10. package/dist/fiscal-engine-runtime.manifest.json +16 -16
  11. package/dist/fiscal-engine-runtime.provenance.json +17 -17
  12. package/dist/generated/hosted/index.d.ts +4 -0
  13. package/dist/generated/hosted/index.d.ts.map +1 -0
  14. package/dist/generated/hosted/index.js +3 -0
  15. package/dist/generated/hosted/sdk.gen.d.ts +106 -0
  16. package/dist/generated/hosted/sdk.gen.d.ts.map +1 -0
  17. package/dist/generated/hosted/sdk.gen.js +1049 -0
  18. package/dist/generated/hosted/types.gen.d.ts +2425 -0
  19. package/dist/generated/hosted/types.gen.d.ts.map +1 -0
  20. package/dist/generated/hosted/types.gen.js +2 -0
  21. package/dist/generated/hosted/zod.gen.d.ts +1772 -0
  22. package/dist/generated/hosted/zod.gen.d.ts.map +1 -0
  23. package/dist/generated/hosted/zod.gen.js +2269 -0
  24. package/dist/generated/index.d.ts +3 -3
  25. package/dist/generated/index.d.ts.map +1 -1
  26. package/dist/generated/index.js +2 -2
  27. package/dist/generated/invoice-api-contract.d.ts +6348 -0
  28. package/dist/generated/invoice-api-contract.d.ts.map +1 -0
  29. package/dist/generated/invoice-api-contract.js +11004 -0
  30. package/dist/generated/problem-catalog.d.ts.map +1 -1
  31. package/dist/generated/problem-catalog.js +9 -3
  32. package/dist/generated/sdk.gen.d.ts +70 -38
  33. package/dist/generated/sdk.gen.d.ts.map +1 -1
  34. package/dist/generated/sdk.gen.js +1261 -251
  35. package/dist/generated/types.gen.d.ts +4349 -2686
  36. package/dist/generated/types.gen.d.ts.map +1 -1
  37. package/dist/generated/zod.gen.d.ts +53878 -22744
  38. package/dist/generated/zod.gen.d.ts.map +1 -1
  39. package/dist/generated/zod.gen.js +5733 -665
  40. package/dist/generated-operation-client.d.ts +1 -0
  41. package/dist/generated-operation-client.d.ts.map +1 -1
  42. package/dist/generated-operation-client.js +3 -2
  43. package/dist/generated-problem.d.ts +1 -1
  44. package/dist/generated-problem.d.ts.map +1 -1
  45. package/dist/generated-problem.js +4 -4
  46. package/dist/index.d.ts +8 -37
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +2 -12
  49. package/dist/{fiscal-error.d.ts → invoice-error.d.ts} +10 -9
  50. package/dist/invoice-error.d.ts.map +1 -0
  51. package/dist/{fiscal-error.js → invoice-error.js} +7 -4
  52. package/dist/invoice-hosted-controls.d.ts +62 -0
  53. package/dist/invoice-hosted-controls.d.ts.map +1 -0
  54. package/dist/invoice-hosted-controls.js +188 -0
  55. package/dist/invoice-receipt.d.ts +10 -0
  56. package/dist/invoice-receipt.d.ts.map +1 -0
  57. package/dist/invoice-receipt.js +49 -0
  58. package/dist/invoice-replacement.d.ts +8 -0
  59. package/dist/invoice-replacement.d.ts.map +1 -0
  60. package/dist/invoice-replacement.js +18 -0
  61. package/dist/invoice.d.ts +94 -0
  62. package/dist/invoice.d.ts.map +1 -0
  63. package/dist/invoice.js +251 -0
  64. package/dist/printed-representation.d.ts +0 -1
  65. package/dist/printed-representation.d.ts.map +1 -1
  66. package/dist/printed-representation.js +3 -3
  67. package/dist/problem-contract.d.ts +17 -114
  68. package/dist/problem-contract.d.ts.map +1 -1
  69. package/dist/public-case.d.ts +1 -1
  70. package/dist/received-documents.d.ts +13 -12
  71. package/dist/received-documents.d.ts.map +1 -1
  72. package/dist/received-documents.js +26 -20
  73. package/dist/source-connection.d.ts +5 -5
  74. package/dist/source-connection.d.ts.map +1 -1
  75. package/dist/source-connection.js +8 -9
  76. package/dist/stamp-server-http-transport.js +6 -6
  77. package/dist/timbro-client.d.ts +5 -37
  78. package/dist/timbro-client.d.ts.map +1 -1
  79. package/dist/timbro-client.js +4 -20
  80. package/dist/timbro_fiscal_engine_bg.wasm +0 -0
  81. package/dist/transport-contract.d.ts +1 -1
  82. package/dist/transport-contract.d.ts.map +1 -1
  83. package/dist/webhook-delivery.js +1 -1
  84. package/dist/webhook-event.d.ts +124 -842
  85. package/dist/webhook-event.d.ts.map +1 -1
  86. package/dist/webhook-event.js +3 -1
  87. package/dist/webhook-registration.d.ts +1 -2
  88. package/dist/webhook-registration.d.ts.map +1 -1
  89. package/dist/webhook-registration.js +1 -2
  90. package/dist/webhook-replay.d.ts +1 -2
  91. package/dist/webhook-replay.d.ts.map +1 -1
  92. package/dist/webhook-replay.js +3 -4
  93. package/dist/workspace.d.ts.map +1 -1
  94. package/dist/workspace.js +2 -2
  95. package/package.json +26 -16
  96. package/dist/fiscal-delivery.d.ts +0 -12
  97. package/dist/fiscal-delivery.d.ts.map +0 -1
  98. package/dist/fiscal-delivery.js +0 -45
  99. package/dist/fiscal-error.d.ts.map +0 -1
  100. package/dist/fiscal-receipt.d.ts +0 -19
  101. package/dist/fiscal-receipt.d.ts.map +0 -1
  102. package/dist/fiscal-receipt.js +0 -66
package/README.md CHANGED
@@ -1,308 +1,145 @@
1
1
  # @timbro/invoices
2
2
 
3
- Issue Dominican electronic invoices (e-CF) from your application, ERP, or POS with one configured client. Invoice issuance and payment collection have separate lifecycles. Use `@timbro/payments` when you also need Timbro to collect money through Checkout.
3
+ Create, retrieve, and download Dominican electronic invoices from your application, ERP, or POS. Invoice issuance and payment collection have separate lifecycles. Use `@timbro/payments` when you also need to collect money through Checkout.
4
4
 
5
- Rust owns the fiscal wire contract. This SDK uses generated operation bindings and validators at every HTTP boundary.
5
+ Use a server-side key with the Invoices capability. The client defaults to `https://api.timbro.do`; a dedicated Invoice installation uses the same document calls with its own `baseUrl` and Source key. The credential selects the business and environment.
6
6
 
7
7
  ```ts
8
- import { createTimbroClient } from "@timbro/invoices";
9
- import type { FiscalDocument } from "@timbro/invoices";
8
+ import { createTimbroInvoices, type InvoiceRequest } from "@timbro/invoices";
10
9
 
11
- const credential = process.env.TIMBRO_CREDENTIAL;
12
- if (credential === undefined || credential.trim() === "") {
13
- throw new Error("TIMBRO_CREDENTIAL is required");
10
+ const apiKey = process.env.TIMBRO_API_KEY;
11
+ if (apiKey === undefined || apiKey.trim() === "") {
12
+ throw new Error("TIMBRO_API_KEY is required");
14
13
  }
15
-
16
- const document: FiscalDocument = {
17
- kind: "type31",
18
- snapshot: {
19
- currency: "DOP",
20
- incomeType: "01",
21
- paymentType: "1",
22
- buyer: { taxId: "101234567", legalName: "Example Buyer" },
23
- lines: [{
24
- sourceLineId: "line-1",
25
- name: "Example product",
26
- quantity: "1.00",
27
- measurementUnit: "31",
28
- unitPrice: "118.00",
29
- billingIndicator: "1",
30
- goodsOrServiceIndicator: "1",
31
- }],
32
- paymentAllocations: [{ method: "1", amount: "118.00" }],
33
- },
34
- };
35
-
36
- const timbro = createTimbroClient({
37
- baseUrl: "https://stamp.example.test",
38
- authentication: { mode: "source_connection", credential },
39
- });
40
-
41
- const operation = await timbro.fiscalDocuments.issue({
42
- source: {
43
- id: "checkout-order-1001",
44
- version: "v1",
45
- },
46
- document,
47
- numberingInstruction: { kind: "centralAssignment" },
48
- printedRepresentation: { profile: "receipt_80mm" },
49
- });
50
-
51
- const page = await timbro.fiscalDocuments.list({ limit: 20 });
52
-
53
- const numbering = await timbro.fiscalNumbering.getReadiness();
54
- const type31 = numbering.documents.e31;
55
- const custody = await timbro.certificateCustody.getReadiness();
56
- ```
57
-
58
- The repository includes complete, runnable issuance examples for both supported integration styles:
59
-
60
- - [`examples/fiscal-document.ts`](examples/fiscal-document.ts) uses the typed SDK
61
- - [`examples/fiscal_document.py`](examples/fiscal_document.py) uses Python's standard-library HTTP client and the raw snake-case wire contract
62
-
63
- Set `TIMBRO_BASE_URL`, `TIMBRO_CREDENTIAL`, and a unique `TIMBRO_SOURCE_ID` before running either
64
- example. `TIMBRO_SOURCE_VERSION` defaults to `v1`. Run the TypeScript example with
65
- `node packages/sdk/examples/fiscal-document.ts` on the repository's Node 24 runtime, or run the
66
- Python example with `python3 packages/sdk/examples/fiscal_document.py`. Use a Source connection in
67
- the intended fiscal environment because either command submits an issuance task.
68
-
69
- The immutable Source identity is the `{ id, version }` tuple; `version` is an opaque trimmed string chosen by the Source system. Timbro computes and retains the canonical digest internally. The caller does not send a digest or an idempotency header. Repeating an older tuple recovers its original operation even after another version becomes current.
70
-
71
- To replace a request rejected before numbering, submit corrected content with a new Source version and `predecessorOperationId` set to the rejected operation's `fiscalOperationId`. The predecessor must still be current. An accepted document requires a separate legal correction; an unknown outcome requires reconciliation. After authority rejection, replacement also requires the existing administrator authorization. A missing or stale predecessor returns `source_predecessor_conflict` without issuing again.
72
-
73
- Inspect `operation.outcome.outcome`, `operation.signedDocument.status` and `operation.printedRepresentation.status` independently. Authority acceptance can precede XML/PDF availability. The SDK preserves these owning-contract facts and exposes no derived top-level `status` or `issued` shortcut. Both immediate and pending admission responses return the resource. [Spanish retry and recovery guide](../../docs/integrations/source-submission-recovery.md)
74
-
75
- `fiscalDocuments.issue` is the one issuance task for ordinary documents and corrections. A
76
- correction names both the affected Timbro operation and the original Source identity explicitly:
77
-
78
- ```ts
79
- await timbro.fiscalDocuments.issue({
80
- source: { id: "odoo-credit-1002", version: "v1" },
81
- action: {
82
- kind: "creditNote",
83
- correction: "correctAmounts",
84
- affectedFiscalOperationId: original.fiscalOperationId,
85
- originalSource: { id: "odoo-invoice-1001", version: "v3" },
86
- reason: "The taxable amount was corrected",
87
- },
88
- document,
89
- numberingInstruction: { kind: "centralAssignment" },
90
- printedRepresentation: { profile: "a4" },
91
- });
92
- ```
93
-
94
- All issuance task boundaries return a retained operation when fiscal evaluation rejects it; inspect `operation.outcome` and its diagnostics just as you would after `get` or a webhook. Exceptions remain reserved for malformed or unsupported input, authentication and authorization failures, conflicts, transport failures, and other cases where no modeled result can be returned.
95
-
96
- `fiscalDocuments.get({ fiscalOperationId })` recovers an operation and its actor-facing outcome, returning `undefined` for a typed not-found response. `fiscalDocuments.findBySource({ source: { id, version } })` arbitrates by the caller's source identity. Public resources use camelCase, keep every amount as an exact decimal string, and expose `fiscalOperationId` separately from the fiscal authority identity (`outcome.fiscalIdentity`) and its fiscal number. The status vocabulary preserves `requested`, `processing`, `delayed`, `unavailable`, `verifying`, `issued`, `rejected`, and `actionRequired`. Fiscal numbering and certificate-custody readiness are separate tasks from issuance, and artifact retrieval is exposed through `fiscalArtifacts`.
97
-
98
- `fiscalDocuments.getTiming({ fiscalOperationId })` returns the bounded diagnostic projection of timing contract version 4. `stages` names each step of the operation as a `TimingStageId` occurrence with its clock, bound, duration, and exclusive time; `TIMING_STAGE_IDS` lists every published id. `workClaims` lists each executing claim on the operation's work, `drainRuns` the drains that made those claims, and `readAt` is Timbro's database clock at the read, so a reader on another clock can measure its skew. These fields are optional in the types: a version 3 report still parses and carries none of them, so branch on `timingContractVersion`. The row lists name work `dueToSettlementMs` and Webhook `queuedToSettlementMs` by their endpoints, and expose `fiscalDeliveries`, `fiscalDeliveryAttempts`, and `fiscalDeliveryEvents` so `submitted`, `delivered`, and `bounced` remain distinct. `attemptDurationMs` measures the stamp-side interval from delivery claim through recorded settlement, including local preparation; it does not isolate provider time. Event rows correlate through `fiscalDeliveryId`, and their provider-created and stamp-received times remain separate. The report omits recipient addresses and provider identifiers.
99
-
100
- When `operation.signedDocument.status` is `ready`, its `artifactKind` is `signed_complete_document` and its `artifactId` identifies the immutable artifact. Retrieve and verify it with `fiscalArtifacts.downloadSignedDocument({ fiscalOperationId: operation.fiscalOperationId })`.
101
-
102
- An `outcome_unknown` submission remains `pending` while Timbro reconciles the same fiscal identity with DGII. Continue observing it without resubmitting the document. Only `intervention_required` means automatic reconciliation exhausted its bounded budget and an operator must take over.
103
-
104
- `fiscalArtifacts.downloadPrintedRepresentation({ fiscalOperationId })` retrieves the operation-addressed immutable PDF and verifies every published identity header, profile/version, renderer identity, digest, signed-source digest, pagination-plan digest, length, page count, creation time, media type, and the actual bytes. The result exposes one content digest as `contentSha256`; storage keys and compatibility aliases are not exposed.
105
-
106
- ### Share an already-issued receipt
107
-
108
- An issuing Source can share an accepted operation without issuing another invoice or sending email. Keep the returned reference in protected server-side storage and pass it through an authenticated service handoff:
109
-
110
- ```ts
111
- const receipt = await issuer.fiscalDocuments.shareReceipt({ fiscalOperationId });
112
- const metadata = await receiver.fiscalReceipts.get({ receipt });
113
- if (metadata?.printedRepresentation.status === "ready") {
114
- const pdf = await receiver.fiscalReceipts.downloadPrintedRepresentation({ receipt });
115
- // Deliver pdf.bytes through the receiving service's authorized receipt route.
14
+ const timbro = createTimbroInvoices({ apiKey });
15
+ const request = {
16
+ invoiceReference: "sale-123",
17
+ type: "E32",
18
+ currency: "DOP",
19
+ incomeType: "01",
20
+ paymentTerms: { type: "immediate" },
21
+ items: [{
22
+ description: "Servicio",
23
+ quantity: "1",
24
+ unit: "unit",
25
+ kind: "service",
26
+ unitPrice: "1250.00",
27
+ tax: { kind: "itbis_18", included: true },
28
+ }],
29
+ } satisfies InvoiceRequest;
30
+
31
+ const invoice = await timbro.invoices.create(request);
32
+ const current = await timbro.invoices.retrieve(invoice.id);
33
+ if (current?.files.pdf.status === "ready") {
34
+ const pdf = await timbro.invoices.downloadPdf(current.id);
35
+ // Send pdf.bytes through your application's authorized download route.
116
36
  }
117
37
  ```
118
38
 
119
- Both clients use the existing `createTimbroClient` setup. Receipt reads apply only the reference's bearer token, even if the receiving client normally uses workload authentication. The receiver obtains the verified issuer RNC, environment, Source revision, fiscal identity, DOP totals, acceptance timestamp, and PDF readiness. It receives neither XML nor diagnostics. A missing or revoked receipt returns `undefined`; a pending PDF returns `fiscal_artifact_not_found`. Use the [Spanish receipt guide](../../docs/integrations/source-receipts.md) for handoff and payment checks.
120
-
121
- Source credentials can also operate the received-document namespace. The server infers the
122
- Organization, Legal issuer, and Fiscal environment from that credential, so the list cannot be
123
- widened with a tenant or issuer path parameter:
39
+ For a hosted Gateway deployment, the same configured origin and API key also expose Business setup and WebhookEndpoint operations. Use `mode: "test"` or `"live"` for environment-specific setup and key issuance; sending a TesteCF invoice is a separate test-only operation.
124
40
 
125
41
  ```ts
126
- const received = await timbro.receivedDocuments.list({ limit: 50, recovery: "pending" });
127
- const document = await timbro.receivedDocuments.get({
128
- fiscalReceptionId: received.data[0].fiscalReceptionId,
129
- });
130
- await timbro.receivedDocuments.respond({
131
- fiscalReceptionId: document.summary.fiscalReceptionId,
132
- response: { decision: "accepted" },
42
+ const business = await timbro.business.retrieve();
43
+ await timbro.business.configureInvoicing({
44
+ mode: "test",
45
+ idempotencyKey: "configure-invoicing-test-1",
133
46
  });
134
- const signedXml = await timbro.receivedDocuments.downloadSignedDocument({
135
- fiscalReceptionId: document.summary.fiscalReceptionId,
47
+ const testInvoice = await timbro.business.issueTestInvoice();
48
+ const invoiceKey = await timbro.business.issueInvoiceKey({
49
+ mode: "test",
50
+ idempotencyKey: "issue-invoice-key-test-1",
136
51
  });
137
- ```
138
-
139
- `receivedDocuments.respond` accepts `accepted` or `rejected` with a non-blank `motive` for a
140
- rejected response; an exact
141
- replay returns the recorded response and a changed decision or motive raises a conflict. The
142
- downloaded XML is retained inbound evidence and the SDK verifies its media type, length, and
143
- SHA-256 digest. If the Evidence Vault is unavailable, the download returns the typed
144
- `fiscal_artifact_unavailable` problem with HTTP 503.
145
52
 
146
- Buyer delivery is independent of representation readiness:
147
-
148
- ```ts
149
- const delivery = await timbro.fiscalDeliveries.create({
150
- fiscalOperationId: operation.fiscalOperationId,
151
- recipientEmail: "buyer@example.test",
152
- accountClaimUrl: "https://checkout.example.test/account?receipt=order-1001",
153
- idempotencyKey: "checkout-order-1001-email",
53
+ const endpoint = await timbro.webhookEndpoints.create({
54
+ url: "https://merchant.example/webhooks/timbro",
55
+ enabledEvents: ["invoice.accepted", "invoice.rejected", "invoice.operatorRequired", "invoice.ready"],
56
+ idempotencyKey: "create-invoice-webhook-1",
57
+ });
58
+ const deliveries = await timbro.webhookEndpoints.listDeliveries({
59
+ webhookEndpointId: endpoint.id,
60
+ limit: 50,
154
61
  });
62
+ if (deliveries.hasMore && deliveries.nextCursor !== null) {
63
+ const nextPage = await timbro.webhookEndpoints.listDeliveries({
64
+ webhookEndpointId: endpoint.id,
65
+ limit: 50,
66
+ cursor: deliveries.nextCursor,
67
+ });
68
+ }
155
69
  ```
156
70
 
157
- The email is in Spanish and names the Legal issuer and the e-NCF. `accountClaimUrl` is optional;
158
- when present, the email also offers "Guardar en Cuenta Timbro" with that `https` URL. The URL
159
- grants nothing by itself, because delivery emails are often forwarded.
71
+ `business.retrieve` returns current capabilities, setup status, and requirements. Update only the business members being replaced with `business.update`; import a signing certificate with `business.importSigningCertificate`; and read the business again to confirm retained state. `issueTestInvoice` always uses the test environment. Invoice API keys are issued for one explicit mode and returned once. The Gateway enforces credential authority for each task.
160
72
 
161
- ### Webhooks and recovery
73
+ Webhook endpoints support list, create, retrieve, delete, delivery listing, event replay, secret rotation, suspension, and reactivation. Lists return `data`, `hasMore`, and `nextCursor`; pass the cursor to the next page with the same filters. Delivery `eventType` remains a string so stored deliveries from earlier event contracts can still be read. Use a Gateway host for these hosted controls; native Source origins expose their Source operations separately.
162
74
 
163
- An approved direct Source registers its HTTPS callback with the same scoped credential:
75
+ Persist the request and its `invoiceReference` before submitting it. An equivalent retry returns the same retained Invoice ID and current state. Changed content under that reference returns `invoice_reference_conflict`. An optional `idempotencyKey` in the second argument binds a command independently of the reference. A timeout or lost response does not justify a new reference or a second invoice.
164
76
 
165
- ```ts
166
- const registration = await timbro.webhooks.register({
167
- url: "https://erp.example.com/timbro/webhook",
168
- idempotencyKey: "odoo-company-42-callback-v1",
169
- });
170
- ```
77
+ For ERP attribution, the optional `source: {id, version}` identifies the immutable accounting snapshot. When omitted, the reference supplies the source identity and the version is `initial`. Odoo keeps ownership of its posted accounting facts, prepared requests, and durable retry work.
171
78
 
172
- Persist that key before setup, and store `registration.signingSecret` in your server's secret
173
- store. The exact key and body recover the same endpoint and original secret for 24 hours while
174
- the endpoint remains active and unrotated. Later retries return the endpoint with a null secret;
175
- they never issue another secret. A different registration key or changed body returns a conflict.
176
- Hosted and provider-managed callbacks retain their own setup lifecycle.
79
+ Amounts are exact decimal strings. `unitPrice` is interpreted using the item's `tax.included` flag. `incomeType` is explicit when supplied; otherwise the issuer's configured default must exist. A create request may supply `expectedTotals` to assert accounting agreement. A mismatch refuses admission without consuming a fiscal number.
177
80
 
178
- The complete `node packages/sdk/examples/register-webhook.ts` example reads `TIMBRO_BASE_URL`,
179
- `TIMBRO_CREDENTIAL`, `TIMBRO_CALLBACK_URL`, `TIMBRO_CALLBACK_REGISTRATION_KEY`, and
180
- `TIMBRO_WEBHOOK_SECRET_FILE`. It saves the secret in a private file and prints only endpoint
181
- metadata. See [Recibe avisos del e-CF](../../docs/integrations/source-webhooks.md) for setup and recovery.
81
+ The request is discriminated by `type`. E31 and E32 have sales fields, E41 has supplier and withholding fields, and E45 has buyer and government eligibility fields. They use the same methods and Invoice identity.
182
82
 
183
- After a receiver outage, inspect `webhookDeliveries.list` for pending or dead-letter deliveries
184
- and replay selected retained fiscal events:
83
+ An optional preview evaluates the request without creating an Invoice, reserving a number, or producing files:
185
84
 
186
85
  ```ts
187
- const replay = await timbro.webhooks.replay({
188
- webhookEndpointId: registration.webhookEndpoint.id,
189
- eventIds: [delivery.webhook_event_id],
190
- idempotencyKey: "odoo-company-42-replay-20261001",
191
- });
86
+ const preview = await timbro.invoices.preview(request);
87
+ if (preview.status === "invalid") {
88
+ for (const problem of preview.problems) {
89
+ console.error(problem.path, problem.message);
90
+ }
91
+ }
192
92
  ```
193
93
 
194
- Persist the key and selection first. An exact retry returns the same `webhookReplayId` without
195
- creating another delivery. Replay preserves the original event ID, sequence, and payload;
196
- deduplicate it alongside automatic retries. Select 1–100 outbound fiscal events from your Source.
197
- Supplier reception events are outside this method's scope.
94
+ `status` describes fiscal progress. `processing` and `verifying` retain the same identity while work continues. Acceptance, file readiness, buyer delivery readiness, and payment success are separate facts. `latestEvent` is null until a real notification has been retained. Do not use file availability or the latest notification timestamp as authority acceptance evidence.
198
95
 
199
- The complete `node packages/sdk/examples/replay-webhook.ts` example reads `TIMBRO_BASE_URL`,
200
- `TIMBRO_CREDENTIAL`, `TIMBRO_WEBHOOK_ENDPOINT_ID`, comma-separated `TIMBRO_WEBHOOK_EVENT_IDS`,
201
- and `TIMBRO_WEBHOOK_REPLAY_KEY`. It prints replay metadata only.
202
-
203
- Deliveries follow the [Standard Webhooks](https://www.standardwebhooks.com) contract. Each request
204
- carries `webhook-id`, `webhook-timestamp`, and `webhook-signature`, and the signature covers
205
- `<webhook-id>.<webhook-timestamp>.<body>`. Verify it against the exact request body bytes before
206
- parsing. Do not parse, reserialize, or pretty-print the body first; the signed payload is the
207
- original UTF-8 text.
208
-
209
- `webhooks.verify` checks the headers and returns the typed event, so a receiver never parses an
210
- unverified body:
96
+ Replace a retained Invoice after authority rejection by sending a new canonical request. The replacement keeps the predecessor's Source ID, uses a new Source version and `invoiceReference`, and returns a new Invoice whose `replacesInvoiceId` identifies the predecessor. A `422` admission refusal has no retained Invoice ID, so correct the request and call `create`; `replace` applies only to a retained, replaceable Invoice. Authority-rejected numbering gaps still require the existing administrator authorization.
211
97
 
212
98
  ```ts
213
- const event = await timbro.webhooks.verify({
214
- body: requestBodyText,
215
- headers: Object.fromEntries(request.headers),
216
- secret: webhookSecret,
99
+ const replacement = await timbro.invoices.replace(rejectedInvoice.id, {
100
+ ...request,
101
+ invoiceReference: "sale-123-r1",
217
102
  });
218
- if (event.type === "source_connection.verification_requested") {
219
- // Build and submit the signed activation proof before acknowledging this event.
220
- // See examples/webhook-receiver.ts for the complete server-runtime flow.
221
- throw new Error("activation verification must complete before acknowledgement");
222
- }
223
- const recovered =
224
- event.type === "fiscal_reception.received" || event.type === "fiscal_reception.not_received"
225
- ? undefined
226
- : await timbro.fiscalDocuments.get({ fiscalOperationId: event.data.fiscal_operation_id });
227
103
  ```
228
104
 
229
- The operation's `source.id` and `source.version` identify the caller's retained invoice even if
230
- the callback arrives before the caller records the issuance response. Retrieve current state
231
- under the same Source credential, then apply it to that invoice through your existing processor.
105
+ `downloadXml` and `downloadPdf` return verified bytes, SHA-256, byte length, creation time, and Invoice identity. PDF downloads also verify the signed source, eNCF, type, layout, and page count. Both methods accept an optional `signal`; create, preview, retrieve, and list do too. A download refuses mismatched bytes or identity.
232
106
 
233
- A rejected delivery throws `WebhookVerificationError`, whose `rejection` names the cause:
234
- `invalid_secret`, `missing_header`, `malformed_header`, `stale_timestamp`, `future_timestamp`,
235
- `signature_mismatch`, `unreadable_envelope`, or `id_mismatch`. Answer a delivery you cannot trust
236
- with a 4xx and no side effect. `invalid_secret` is the one exception: the secret you configured is
237
- unusable, the delivery itself is intact, so answer 500 and let Timbro retry the event while you
238
- repair the secret.
107
+ Recover by ID or retained reference:
239
108
 
240
109
  ```ts
241
- import { WebhookVerificationError } from "@timbro/invoices";
242
-
243
- try {
244
- await timbro.webhooks.verify({ body, headers, secrets: [nextSecret, retiredSecret] });
245
- } catch (cause) {
246
- if (cause instanceof WebhookVerificationError) {
247
- return new Response(cause.rejection, {
248
- status: cause.rejection === "invalid_secret" ? 500 : 400,
249
- });
250
- }
251
- throw cause;
110
+ const page = await timbro.invoices.list({ invoiceReference: request.invoiceReference });
111
+ const retained = page.data[0];
112
+ if (retained !== undefined) {
113
+ const current = await timbro.invoices.retrieve(retained.id);
252
114
  }
253
115
  ```
254
116
 
255
- The signing secret is issued as `whsec_<base64>`; the HMAC key is the base64-decoded remainder, and
256
- a secret that is not that shape is rejected rather than used as literal bytes. `webhook-signature`
257
- carries one space-separated `v1,` entry per valid secret, and a delivery is verified when any entry
258
- matches any secret you hold. A timestamp more than five minutes from the receiver's clock is refused
259
- in both directions. `verify` refuses a delivery whose `webhook-id` is not the envelope `id`, and
260
- that id is the key you deduplicate on. `sequence` stays a decimal string so JavaScript cannot lose
261
- bigint precision. If an operation-event delivery is missed, recover the current actor-facing outcome
262
- with `fiscalDocuments.get` using its operation ID.
117
+ `retrieve` returns `undefined` only for `invoice_not_found`. Lists return one page with `data`, `hasMore`, and `nextCursor`. Pass the returned cursor to the next list call, with the same credential and filters. The default limit is 20, with a maximum of 100.
118
+
119
+ API refusals use `InvoiceError`, with `code`, `status`, `requestId`, `problems`, and `isRetryable`. Malformed input is validated against the generated contract before submission. Preserve the original request when retrying a transport failure; resolve permanent validation and conflict errors before submitting corrected work.
263
120
 
264
- Every public list returns one page: `object: list`, `data`, `hasMore`, and an opaque `nextCursor`
265
- bound to the Organization and the list that minted it, down to the Webhook endpoint for a
266
- delivery cursor.
267
- Presenting a cursor anywhere else answers 400 `invalid_collection_cursor`. `limit` accepts 1 to
268
- 100 and defaults to 20, and a multi-value filter repeats its parameter. `list` returns a single
269
- page, while `listAll` follows every cursor for you:
121
+ Verify webhook signatures over the exact request body, then retrieve current state:
270
122
 
271
123
  ```ts
272
- const page = await timbro.webhookDeliveries.list({
273
- webhookEndpointId,
274
- states: ["pending", "dead_lettered"],
275
- limit: 50,
124
+ const event = await timbro.webhooks.verify({
125
+ body: await httpRequest.text(),
126
+ headers: Object.fromEntries(httpRequest.headers),
127
+ secrets: [currentWebhookSecret, previousWebhookSecret],
276
128
  });
277
-
278
- for await (const delivery of timbro.webhookDeliveries.listAll({ webhookEndpointId })) {
279
- await reconcile(delivery);
129
+ if (
130
+ event.type === "invoice.accepted" ||
131
+ event.type === "invoice.rejected" ||
132
+ event.type === "invoice.operatorRequired" ||
133
+ event.type === "invoice.ready"
134
+ ) {
135
+ const current = await timbro.invoices.retrieve(event.data.id);
280
136
  }
281
137
  ```
282
138
 
283
- `webhookDeliveries`, `fiscalDocuments`, and `receivedDocuments` are the credential-scoped lists this
284
- client wraps. The operation timeline is read with a Workspace session instead of a credential,
285
- so a Workspace consumer reads those pages through its own session-authenticated request and walks
286
- them with the exported `walkCollectionPages`:
139
+ Register the receiving endpoint through the hosting service's webhook endpoint API. All invoice types share these four event types. `invoice.ready` means a positive authority outcome and retained XML/PDF files; it does not promise payment or email delivery. A notification can arrive before create returns. Match the recovered reference and source coordinates, and apply it through your existing durable processor.
287
140
 
288
- ```ts
289
- import { walkCollectionPages } from "@timbro/invoices";
290
- import { zWorkspaceFiscalOperationPage } from "@timbro/invoices/generated";
291
-
292
- for await (const operation of walkCollectionPages(async (cursor) => {
293
- const query = cursor === undefined ? "?limit=100" : `?limit=100&cursor=${cursor}`;
294
- const response = await fetch(
295
- `${stampServerOrigin}/v1/organizations/${organizationId}/fiscal-operations${query}`,
296
- { credentials: "include" },
297
- );
298
- return zWorkspaceFiscalOperationPage.parse(await response.json());
299
- })) {
300
- await render(operation);
301
- }
302
- ```
141
+ Deduplicate notifications by `event.id`. `data.id` identifies the Invoice, and `sequence` stays a decimal string. Verification accepts any configured rotation secret and rejects invalid signatures, stale timestamps, malformed envelopes, and mismatched event IDs. It throws `WebhookVerificationError` with a specific `rejection`. An unusable configured secret requires receiver recovery; no rejected delivery should cause an application side effect.
303
142
 
304
- The walk throws a `FiscalError` when a page reports more resources without a cursor to resume
305
- from, or returns the cursor it was read with, because neither page can be walked to the end of
306
- the list.
143
+ Rust owns the Invoice wire schemas, and the SDK generates its public types and boundary validators from them. The SDK does not persist business work or replace ERP accounting. Source registration, restricted receipt sharing, supplier reception, and operational diagnostics retain their own scoped tasks. Local SDK checks do not establish hosted behavior, DGII qualification, or provider certification.
307
144
 
308
- Credentials belong on a trusted application server or native-assisted client. The package does not establish DGII approval, printer compatibility or legibility, hosted Checkout cutover, production capacity, or certification.
145
+ Administration and installation tooling use `@timbro/invoices/admin`. Source snapshots, custody transports, workload bindings, and operation timing do not appear in the ordinary package root. The public `createTimbroInvoices` call accepts the API key and optional origin; Invoice creation does not require assembling those administrative clients.
@@ -0,0 +1,44 @@
1
+ export type { CertificateCustodyImportCommand, CertificateCustodyImportResult, } from "./certificate-custody-import.ts";
2
+ export type { CertificateCustodyReadiness } from "./certificate-custody-readiness.ts";
3
+ export type { CollectionPage } from "./collection.ts";
4
+ export { walkCollectionPages } from "./collection.ts";
5
+ export type { DirectConnectionApproval, DirectConnectionApprovalCommand, DirectConnectionClient, DirectConnectionClientOptions, DirectConnectionConfirmation, DirectConnectionCreateCommand, DirectConnectionEnvironment, DirectConnectionPoll, DirectConnectionPreview, DirectConnectionRequest, DirectConnectionRequestCommand, } from "./direct-connection.ts";
6
+ export { createDirectConnectionClient, generateDirectConnectionCredential, } from "./direct-connection.ts";
7
+ export type { FiscalNumberingReadiness } from "./fiscal-numbering-readiness.ts";
8
+ export type { FiscalDocument, FiscalDocumentAction, FiscalDocumentIssueCommand, FiscalDocumentListCommand, FiscalDocumentNumberingInstruction, FiscalDocumentPage, FiscalOperationResource, FiscalOriginalSource, FiscalSource, HostedFiscalTenant, SourceType31Snapshot, SourceType32Snapshot, SourceType33Snapshot, SourceType34Snapshot, SourceType41Snapshot, SourceType43Snapshot, SourceType44Snapshot, SourceType45Snapshot, SourceType46Snapshot, SourceType47Snapshot, } from "./fiscal-operation.ts";
9
+ export { toFiscalDocumentSnapshot } from "./fiscal-operation.ts";
10
+ export type { FiscalOperationTimingReport, TimingStageId } from "./fiscal-operation-timing.ts";
11
+ export { TIMING_STAGE_IDS } from "./fiscal-operation-timing.ts";
12
+ export type { FiscalOperationOutcomeResource, InvoiceDeliveryResource, InvoicePage, InvoicePreview, InvoiceReceipt, InvoiceReceiptAccess, InvoiceRequest, InvoiceResource, InvoiceType, PrintedRepresentationProfile, SourceCreditNoteCorrection, SourceDebitNoteCorrection, SourceFiscalAction, WebhookDelivery, WebhookDeliveryPage, WebhookDeliveryState, } from "./generated/index.ts";
13
+ export type { HostedTenant, HostedTenantClient, HostedTenantClientOptions, HostedTenantCreateCommand, HostedTenantEnvironment, HostedTenantRelease, HostedTenantReleaseCommand, HostedTenantWebhookSecretRotationCommand, HostedWebhookSecretRotation, } from "./hosted-tenant.ts";
14
+ export { createHostedTenantClient } from "./hosted-tenant.ts";
15
+ export type { HostedWorkspaceTransportOptions } from "./hosted-workspace-transport.ts";
16
+ export { createHostedWorkspaceTransport } from "./hosted-workspace-transport.ts";
17
+ export type { InvoiceCreateOptions, InvoiceDeliveryCommand, InvoiceDeliveryReadCommand, InvoiceListFilters, InvoicePdfDownload, InvoiceReplacement, InvoiceRequestOptions, InvoiceXmlDownload, TimbroInvoices, TimbroInvoicesOptions, } from "./invoice.ts";
18
+ export { createTimbroInvoices, verifyInvoicePdfDownload, verifyInvoiceXmlDownload, } from "./invoice.ts";
19
+ export type { InvoiceErrorDetail, InvoiceFailure } from "./invoice-error.ts";
20
+ export { InvoiceError } from "./invoice-error.ts";
21
+ export type { BusinessConfigureInvoicingCommand, BusinessImportSigningCertificateCommand, BusinessIssueInvoiceKeyCommand, BusinessIssueTestInvoiceCommand, BusinessIssueTestInvoiceOptions, BusinessUpdateCommand, InvoiceHostedControls, WebhookEndpointCreateCommand, WebhookEndpointListDeliveriesCommand, WebhookEndpointListFilters, WebhookEndpointReplayCommand, } from "./invoice-hosted-controls.ts";
22
+ export type { PrintedRepresentationDownload } from "./printed-representation.ts";
23
+ export type { ProblemBody, ProblemCatalogEntry, ProblemCode, ProblemFailure, PublicProblemCode, } from "./problem-contract.ts";
24
+ export { PROBLEM_CATALOG } from "./problem-contract.ts";
25
+ export { toWireCase } from "./public-case.ts";
26
+ export type { CommercialResponse, ReceivedDocumentDownload, ReceivedDocumentListCommand, ReceivedDocumentPage, ReceivedDocumentRecoveryFilter, ReceivedDocumentResource, ReceivedDocumentResponseFilter, ReceivedDocumentStateFilter, ReceivedDocumentSummary, } from "./received-documents.ts";
27
+ export { verifyReceivedDocumentXmlDownload } from "./received-documents.ts";
28
+ export { digestSha256Hex } from "./sha256.ts";
29
+ export type { SignedDocumentDownload } from "./signed-document.ts";
30
+ export type { HostedInvoiceCredential, HostedInvoiceCredentialIssueCommand, SourceConnectionActivationVerificationCommand, } from "./source-connection.ts";
31
+ export type { SourceConnectionTransportOptions } from "./source-connection-transport.ts";
32
+ export type { StampServerBearerTokenProvider, StampServerHttpAuthentication, } from "./stamp-server-http-transport.ts";
33
+ export type { TimbroClient, TimbroClientAuthentication, TimbroClientOptions, } from "./timbro-client.ts";
34
+ export { createTimbroClient } from "./timbro-client.ts";
35
+ export type { WebhookDeliveryListCommand } from "./webhook-delivery.ts";
36
+ export type { DeliveredWebhookEvent, InvoiceWebhookEvent, InvoiceWebhookEventEnvelope, ReceptionWebhookEvent, WebhookEvent, } from "./webhook-event.ts";
37
+ export { parseDeliveredWebhookEvent, parseWebhookEvent, } from "./webhook-event.ts";
38
+ export type { WebhookRegistration, WebhookRegistrationCommand } from "./webhook-registration.ts";
39
+ export type { WebhookReplay, WebhookReplayCommand } from "./webhook-replay.ts";
40
+ export type { WebhookDeliveryHeaders, WebhookVerificationCommand, WebhookVerificationRejection, } from "./webhook-verification.ts";
41
+ export { verifyWebhookDelivery, WebhookVerificationError } from "./webhook-verification.ts";
42
+ export type { WorkspaceClient, WorkspaceClientOptions } from "./workspace.ts";
43
+ export { createWorkspaceClient } from "./workspace.ts";
44
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACtF,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EACV,wBAAwB,EACxB,+BAA+B,EAC/B,sBAAsB,EACtB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC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,MAAM,kCAAkC,CAAC;AACzF,YAAY,EACV,8BAA8B,EAC9B,6BAA6B,GAC9B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACV,YAAY,EACZ,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACxE,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,EACrB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACjG,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/admin.js ADDED
@@ -0,0 +1,16 @@
1
+ export { walkCollectionPages } from "./collection.js";
2
+ export { createDirectConnectionClient, generateDirectConnectionCredential, } from "./direct-connection.js";
3
+ export { toFiscalDocumentSnapshot } from "./fiscal-operation.js";
4
+ export { TIMING_STAGE_IDS } from "./fiscal-operation-timing.js";
5
+ export { createHostedTenantClient } from "./hosted-tenant.js";
6
+ export { createHostedWorkspaceTransport } from "./hosted-workspace-transport.js";
7
+ export { createTimbroInvoices, verifyInvoicePdfDownload, verifyInvoiceXmlDownload, } from "./invoice.js";
8
+ export { InvoiceError } from "./invoice-error.js";
9
+ export { PROBLEM_CATALOG } from "./problem-contract.js";
10
+ export { toWireCase } from "./public-case.js";
11
+ export { verifyReceivedDocumentXmlDownload } from "./received-documents.js";
12
+ export { digestSha256Hex } from "./sha256.js";
13
+ export { createTimbroClient } from "./timbro-client.js";
14
+ export { parseDeliveredWebhookEvent, parseWebhookEvent, } from "./webhook-event.js";
15
+ export { verifyWebhookDelivery, WebhookVerificationError } from "./webhook-verification.js";
16
+ export { createWorkspaceClient } from "./workspace.js";
@@ -1,11 +1,13 @@
1
1
  import type { HostedFiscalTenant } from "./fiscal-operation.ts";
2
- import { type HostedImportResponse } from "./generated/index.ts";
2
+ import { type HostedImportRequest, type HostedImportResponse } from "./generated/index.ts";
3
3
  import type { Client } from "./generated-operation-client.ts";
4
4
  import { type ReadonlyCamelCase } from "./public-case.ts";
5
5
  export type CertificateCustodyImportCommand = {
6
6
  readonly certificateP12Base64: string;
7
7
  readonly password: string;
8
- readonly hosted: Pick<HostedFiscalTenant, "checkoutTenantId"> & Partial<Pick<HostedFiscalTenant, "environment">>;
8
+ readonly hosted: Pick<HostedFiscalTenant, "checkoutTenantId"> & {
9
+ readonly environment?: NonNullable<HostedImportRequest["environment"]>;
10
+ };
9
11
  readonly signal?: AbortSignal;
10
12
  };
11
13
  export type CertificateCustodyImportResult = ReadonlyCamelCase<HostedImportResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"certificate-custody-import.d.ts","sourceRoot":"","sources":["../src/certificate-custody-import.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAkC,MAAM,sBAAsB,CAAC;AACjG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,KAAK,iBAAiB,EAAgB,MAAM,kBAAkB,CAAC;AAExE,MAAM,MAAM,+BAA+B,GAAG;IAC5C,QAAQ,CAAC,oBAAo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,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,8BAA8B,CAAC,CA0BzC"}
@@ -1,4 +1,4 @@
1
- import { importHostedCertificateCustody } from "./generated/index.js";
1
+ import { importHostedCertificateCustody, } from "./generated/index.js";
2
2
  import { throwGeneratedProblem } from "./generated-problem.js";
3
3
  import { toPublicCase } from "./public-case.js";
4
4
  export async function importHostedCertificateCustodyResource(client, command) {
@@ -3,7 +3,7 @@ import { type CursorPage, type CursorPageWalkOptions } from "@timbro/protocol";
3
3
  export type CollectionPage<TResource> = CursorPage<TResource>;
4
4
  export type CollectionWalkOptions = CursorPageWalkOptions;
5
5
  /**
6
- * Yields every resource in a Collection, following `next_cursor` until `has_more` is false.
6
+ * Yields every resource in a Collection, following `nextCursor` until `hasMore` is false.
7
7
  *
8
8
  * A page that reports more resources without a cursor, or that returns the cursor it was read
9
9
  * with, cannot be walked to the end of the Collection, so the walk throws rather than stopping
@@ -1,7 +1,7 @@
1
1
  import { CursorPageWalkError, walkCursorPages, } from "@timbro/protocol";
2
- import { FiscalError } from "./fiscal-error.js";
2
+ import { InvoiceError } from "./invoice-error.js";
3
3
  /**
4
- * Yields every resource in a Collection, following `next_cursor` until `has_more` is false.
4
+ * Yields every resource in a Collection, following `nextCursor` until `hasMore` is false.
5
5
  *
6
6
  * A page that reports more resources without a cursor, or that returns the cursor it was read
7
7
  * with, cannot be walked to the end of the Collection, so the walk throws rather than stopping
@@ -15,7 +15,7 @@ export async function* walkCollectionPages(readPage, options) {
15
15
  if (!(cause instanceof CursorPageWalkError)) {
16
16
  throw cause;
17
17
  }
18
- // biome-ignore lint/style/useErrorCause: FiscalError already exposes the bounded protocol failure detail.
19
- throw new FiscalError(cause.message, { failure: cause.rejection === "aborted" ? "cancelled" : "server_processing" }, { cause });
18
+ // biome-ignore lint/style/useErrorCause: InvoiceError already exposes the bounded protocol failure detail.
19
+ throw new InvoiceError(cause.message, { failure: cause.rejection === "aborted" ? "cancelled" : "server_processing" }, { cause });
20
20
  }
21
21
  }