@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.
- package/README.md +95 -258
- package/dist/admin.d.ts +44 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +16 -0
- package/dist/certificate-custody-import.d.ts +4 -2
- package/dist/certificate-custody-import.d.ts.map +1 -1
- package/dist/certificate-custody-import.js +1 -1
- package/dist/collection.d.ts +1 -1
- package/dist/collection.js +4 -4
- package/dist/fiscal-engine-runtime.manifest.json +16 -16
- package/dist/fiscal-engine-runtime.provenance.json +17 -17
- package/dist/generated/hosted/index.d.ts +4 -0
- package/dist/generated/hosted/index.d.ts.map +1 -0
- package/dist/generated/hosted/index.js +3 -0
- package/dist/generated/hosted/sdk.gen.d.ts +106 -0
- package/dist/generated/hosted/sdk.gen.d.ts.map +1 -0
- package/dist/generated/hosted/sdk.gen.js +1049 -0
- package/dist/generated/hosted/types.gen.d.ts +2425 -0
- package/dist/generated/hosted/types.gen.d.ts.map +1 -0
- package/dist/generated/hosted/types.gen.js +2 -0
- package/dist/generated/hosted/zod.gen.d.ts +1772 -0
- package/dist/generated/hosted/zod.gen.d.ts.map +1 -0
- package/dist/generated/hosted/zod.gen.js +2269 -0
- package/dist/generated/index.d.ts +3 -3
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +2 -2
- package/dist/generated/invoice-api-contract.d.ts +6348 -0
- package/dist/generated/invoice-api-contract.d.ts.map +1 -0
- package/dist/generated/invoice-api-contract.js +11004 -0
- package/dist/generated/problem-catalog.d.ts.map +1 -1
- package/dist/generated/problem-catalog.js +9 -3
- package/dist/generated/sdk.gen.d.ts +70 -38
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/sdk.gen.js +1261 -251
- package/dist/generated/types.gen.d.ts +4349 -2686
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/generated/zod.gen.d.ts +53878 -22744
- package/dist/generated/zod.gen.d.ts.map +1 -1
- package/dist/generated/zod.gen.js +5733 -665
- package/dist/generated-operation-client.d.ts +1 -0
- package/dist/generated-operation-client.d.ts.map +1 -1
- package/dist/generated-operation-client.js +3 -2
- package/dist/generated-problem.d.ts +1 -1
- package/dist/generated-problem.d.ts.map +1 -1
- package/dist/generated-problem.js +4 -4
- package/dist/index.d.ts +8 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -12
- package/dist/{fiscal-error.d.ts → invoice-error.d.ts} +10 -9
- package/dist/invoice-error.d.ts.map +1 -0
- package/dist/{fiscal-error.js → invoice-error.js} +7 -4
- package/dist/invoice-hosted-controls.d.ts +62 -0
- package/dist/invoice-hosted-controls.d.ts.map +1 -0
- package/dist/invoice-hosted-controls.js +188 -0
- package/dist/invoice-receipt.d.ts +10 -0
- package/dist/invoice-receipt.d.ts.map +1 -0
- package/dist/invoice-receipt.js +49 -0
- package/dist/invoice-replacement.d.ts +8 -0
- package/dist/invoice-replacement.d.ts.map +1 -0
- package/dist/invoice-replacement.js +18 -0
- package/dist/invoice.d.ts +94 -0
- package/dist/invoice.d.ts.map +1 -0
- package/dist/invoice.js +251 -0
- package/dist/printed-representation.d.ts +0 -1
- package/dist/printed-representation.d.ts.map +1 -1
- package/dist/printed-representation.js +3 -3
- package/dist/problem-contract.d.ts +17 -114
- package/dist/problem-contract.d.ts.map +1 -1
- package/dist/public-case.d.ts +1 -1
- package/dist/received-documents.d.ts +13 -12
- package/dist/received-documents.d.ts.map +1 -1
- package/dist/received-documents.js +26 -20
- package/dist/source-connection.d.ts +5 -5
- package/dist/source-connection.d.ts.map +1 -1
- package/dist/source-connection.js +8 -9
- package/dist/stamp-server-http-transport.js +6 -6
- package/dist/timbro-client.d.ts +5 -37
- package/dist/timbro-client.d.ts.map +1 -1
- package/dist/timbro-client.js +4 -20
- package/dist/timbro_fiscal_engine_bg.wasm +0 -0
- package/dist/transport-contract.d.ts +1 -1
- package/dist/transport-contract.d.ts.map +1 -1
- package/dist/webhook-delivery.js +1 -1
- package/dist/webhook-event.d.ts +124 -842
- package/dist/webhook-event.d.ts.map +1 -1
- package/dist/webhook-event.js +3 -1
- package/dist/webhook-registration.d.ts +1 -2
- package/dist/webhook-registration.d.ts.map +1 -1
- package/dist/webhook-registration.js +1 -2
- package/dist/webhook-replay.d.ts +1 -2
- package/dist/webhook-replay.d.ts.map +1 -1
- package/dist/webhook-replay.js +3 -4
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +2 -2
- package/package.json +26 -16
- package/dist/fiscal-delivery.d.ts +0 -12
- package/dist/fiscal-delivery.d.ts.map +0 -1
- package/dist/fiscal-delivery.js +0 -45
- package/dist/fiscal-error.d.ts.map +0 -1
- package/dist/fiscal-receipt.d.ts +0 -19
- package/dist/fiscal-receipt.d.ts.map +0 -1
- package/dist/fiscal-receipt.js +0 -66
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-event.d.ts","sourceRoot":"","sources":["../src/webhook-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook-event.d.ts","sourceRoot":"","sources":["../src/webhook-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAGtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAEhE;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,qBAAqB,CAIlF"}
|
package/dist/webhook-event.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { zReceptionWebhookEventEnvelope, zWebhookEventEnvelope } from "./generated/index.js";
|
|
2
|
+
import { zInvoiceWebhookEvent, zInvoiceWebhookEventEnvelope, zReceptionWebhookEventEnvelope, zWebhookEventEnvelope, } from "./generated/index.js";
|
|
3
3
|
export const webhookEventSchema = zWebhookEventEnvelope;
|
|
4
4
|
export const receptionWebhookEventSchema = zReceptionWebhookEventEnvelope;
|
|
5
|
+
export const invoiceWebhookEventSchema = zInvoiceWebhookEvent;
|
|
6
|
+
export const invoiceWebhookEventEnvelopeSchema = zInvoiceWebhookEventEnvelope;
|
|
5
7
|
/** Every notification an endpoint is delivered, told apart by its event type. */
|
|
6
8
|
export const deliveredWebhookEventSchema = z.union([
|
|
7
9
|
webhookEventSchema,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type WebhookEndpointRegistration as GeneratedWebhookEndpointRegistration } from "./generated/index.ts";
|
|
2
2
|
import type { Client } from "./generated-operation-client.ts";
|
|
3
|
-
import { type ReadonlyCamelCase } from "./public-case.ts";
|
|
4
3
|
export type WebhookRegistrationCommand = {
|
|
5
4
|
readonly url: string;
|
|
6
5
|
readonly idempotencyKey: string;
|
|
7
6
|
readonly description?: string;
|
|
8
7
|
readonly signal?: AbortSignal;
|
|
9
8
|
};
|
|
10
|
-
export type WebhookRegistration =
|
|
9
|
+
export type WebhookRegistration = GeneratedWebhookEndpointRegistration;
|
|
11
10
|
export declare function registerWebhookResource(client: Client, command: WebhookRegistrationCommand): Promise<WebhookRegistration>;
|
|
12
11
|
//# sourceMappingURL=webhook-registration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-registration.d.ts","sourceRoot":"","sources":["../src/webhook-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,IAAI,oCAAoC,EAEzE,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook-registration.d.ts","sourceRoot":"","sources":["../src/webhook-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,IAAI,oCAAoC,EAEzE,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAG9D,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AAEvE,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,mBAAmB,CAAC,CAyC9B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { registerWebhookEndpoint, } from "./generated/index.js";
|
|
2
2
|
import { throwGeneratedProblem } from "./generated-problem.js";
|
|
3
|
-
import { toPublicCase } from "./public-case.js";
|
|
4
3
|
export async function registerWebhookResource(client, command) {
|
|
5
4
|
if (!/^[A-Za-z0-9._:-]{16,255}$/u.test(command.idempotencyKey)) {
|
|
6
5
|
throw new TypeError("idempotencyKey must contain 16–255 letters, digits, dots, underscores, colons, or hyphens");
|
|
@@ -33,5 +32,5 @@ export async function registerWebhookResource(client, command) {
|
|
|
33
32
|
if (response.status !== 200 && response.status !== 201) {
|
|
34
33
|
throwGeneratedProblem(response, "Webhook registration failed");
|
|
35
34
|
}
|
|
36
|
-
return
|
|
35
|
+
return response.body;
|
|
37
36
|
}
|
package/dist/webhook-replay.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type WebhookReplayResource as GeneratedWebhookReplayResource } from "./generated/index.ts";
|
|
2
2
|
import type { Client } from "./generated-operation-client.ts";
|
|
3
|
-
import { type ReadonlyCamelCase } from "./public-case.ts";
|
|
4
3
|
export type WebhookReplayCommand = {
|
|
5
4
|
readonly webhookEndpointId: string;
|
|
6
5
|
readonly eventIds: readonly string[];
|
|
7
6
|
readonly idempotencyKey: string;
|
|
8
7
|
readonly signal?: AbortSignal;
|
|
9
8
|
};
|
|
10
|
-
export type WebhookReplay =
|
|
9
|
+
export type WebhookReplay = GeneratedWebhookReplayResource;
|
|
11
10
|
export declare function replayWebhookResource(client: Client, command: WebhookReplayCommand): Promise<WebhookReplay>;
|
|
12
11
|
//# sourceMappingURL=webhook-replay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-replay.d.ts","sourceRoot":"","sources":["../src/webhook-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,IAAI,8BAA8B,EAI7D,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook-replay.d.ts","sourceRoot":"","sources":["../src/webhook-replay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,IAAI,8BAA8B,EAI7D,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAI9D,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,8BAA8B,CAAC;AAE3D,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,aAAa,CAAC,CA4BxB"}
|
package/dist/webhook-replay.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { replayWebhookEvents, zRegisteredWebhookEndpoint, zReplayEventIdsScope, } from "./generated/index.js";
|
|
2
2
|
import { throwGeneratedProblem } from "./generated-problem.js";
|
|
3
3
|
import { isValidIdempotencyKey } from "./idempotency-key.js";
|
|
4
|
-
import { toPublicCase } from "./public-case.js";
|
|
5
4
|
export async function replayWebhookResource(client, command) {
|
|
6
5
|
if (!isValidIdempotencyKey(command.idempotencyKey)) {
|
|
7
6
|
throw new TypeError("idempotencyKey must contain 16–255 letters, digits, dots, underscores, colons, or hyphens");
|
|
8
7
|
}
|
|
9
8
|
const request = {
|
|
10
|
-
path: {
|
|
9
|
+
path: { webhookEndpointId: command.webhookEndpointId },
|
|
11
10
|
headers: { "Idempotency-Key": command.idempotencyKey },
|
|
12
|
-
body: {
|
|
11
|
+
body: { eventIds: [...command.eventIds] },
|
|
13
12
|
};
|
|
14
13
|
if (!(zRegisteredWebhookEndpoint.shape.id.safeParse(command.webhookEndpointId).success &&
|
|
15
14
|
zReplayEventIdsScope.safeParse(request.body).success)) {
|
|
@@ -23,5 +22,5 @@ export async function replayWebhookResource(client, command) {
|
|
|
23
22
|
if (response.status !== 200 && response.status !== 201) {
|
|
24
23
|
throwGeneratedProblem(response, "Webhook replay failed");
|
|
25
24
|
}
|
|
26
|
-
return
|
|
25
|
+
return response.body;
|
|
27
26
|
}
|
package/dist/workspace.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,mCAAmC,EACzC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,mCAAmC,EACzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EAEvB,KAAK,qCAAqC,EAC1C,KAAK,4BAA4B,EACjC,KAAK,0CAA0C,EAG/C,KAAK,4BAA4B,EACjC,KAAK,gCAAgC,EAEtC,MAAM,sBAAsB,CAAC;AAe9B,yFAAyF;AACzF,eAAO,MAAM,4BAA4B,QAAmB,CAAC;AAE7D,iFAAiF;AACjF,MAAM,MAAM,sBAAsB,GAAG;IACnC,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IAChD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MA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C,GACrC,0CAA0C,CAAC;QAC/C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,IAAI,EAAE,CACb,OAAO,EAAE,mCAAmC,KACzC,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,CAChB,OAAO,EAAE,mCAAmC,KACzC,aAAa,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,EAAE,CACZ,OAAO,EAAE,+BAA+B,KACrC,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE;QAClB,QAAQ,CAAC,QAAQ,EAAE,CACjB,OAAO,EAAE,8BAA8B,KACpC,OAAO,CAAC,uBAAuB,CAAC,CAAC;KACvC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,yBAAyB,CAAC;IACrD,QAAQ,CAAC,iBAAiB,EAAE,mCAAmC,CAAC;CACjE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAa3F"}
|
package/dist/workspace.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// biome-ignore-all lint/correctness/useQwikValidLexicalScope: this module is a plain SDK client, not a Qwik component.
|
|
2
2
|
import { walkCollectionPages } from "./collection.js";
|
|
3
3
|
import { createDirectConnectionWorkspaceOperations, } from "./direct-connection.js";
|
|
4
|
-
import { FiscalError } from "./fiscal-error.js";
|
|
5
4
|
import { listOrganizationFiscalOperations, readOrganizationFiscalOperation, retrieveWorkspaceFiscalArtifact, zElectronicFiscalDocumentType, } from "./generated/index.js";
|
|
6
5
|
import { createGeneratedOperationClient } from "./generated-operation-client.js";
|
|
7
6
|
import { throwGeneratedProblem } from "./generated-problem.js";
|
|
7
|
+
import { InvoiceError } from "./invoice-error.js";
|
|
8
8
|
import { isCanonicalRfc3339MillisecondUtc } from "./printed-representation.js";
|
|
9
9
|
import { digestSha256Hex } from "./sha256.js";
|
|
10
10
|
import { createWorkspaceSessionTransport } from "./workspace-session-transport.js";
|
|
@@ -274,5 +274,5 @@ function readBrowserOrigin() {
|
|
|
274
274
|
return typeof browserGlobal.location === "object" ? browserGlobal.location.origin : undefined;
|
|
275
275
|
}
|
|
276
276
|
function throwArtifactFailure(message) {
|
|
277
|
-
throw new
|
|
277
|
+
throw new InvoiceError(message, { failure: "server_processing" });
|
|
278
278
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timbro/invoices",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-next.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"import": "./dist/index.js"
|
|
19
19
|
},
|
|
20
|
-
"./generated": {
|
|
20
|
+
"./admin/generated": {
|
|
21
21
|
"types": "./dist/generated/index.d.ts",
|
|
22
22
|
"import": "./dist/generated/index.js"
|
|
23
23
|
},
|
|
@@ -29,33 +29,41 @@
|
|
|
29
29
|
"types": "./dist/document-node.d.ts",
|
|
30
30
|
"import": "./dist/document-node.js"
|
|
31
31
|
},
|
|
32
|
-
"./
|
|
32
|
+
"./webhook-event": {
|
|
33
|
+
"types": "./dist/webhook-event.d.ts",
|
|
34
|
+
"import": "./dist/webhook-event.js"
|
|
35
|
+
},
|
|
36
|
+
"./invoice-api-contract": {
|
|
37
|
+
"types": "./dist/generated/invoice-api-contract.d.ts",
|
|
38
|
+
"import": "./dist/generated/invoice-api-contract.js"
|
|
39
|
+
},
|
|
40
|
+
"./admin": {
|
|
41
|
+
"types": "./dist/admin.d.ts",
|
|
42
|
+
"import": "./dist/admin.js"
|
|
43
|
+
},
|
|
44
|
+
"./admin/source-connection-activation": {
|
|
33
45
|
"types": "./dist/source-connection-activation.d.ts",
|
|
34
46
|
"import": "./dist/source-connection-activation.js"
|
|
35
47
|
},
|
|
36
|
-
"./
|
|
37
|
-
"types": "./dist/hosted-tenant.d.ts",
|
|
38
|
-
"import": "./dist/hosted-tenant.js"
|
|
39
|
-
},
|
|
40
|
-
"./source-connection-transport": {
|
|
48
|
+
"./admin/source-connection-transport": {
|
|
41
49
|
"types": "./dist/source-connection-transport.d.ts",
|
|
42
50
|
"import": "./dist/source-connection-transport.js"
|
|
43
51
|
},
|
|
44
|
-
"./hosted-
|
|
52
|
+
"./admin/hosted-tenant": {
|
|
53
|
+
"types": "./dist/hosted-tenant.d.ts",
|
|
54
|
+
"import": "./dist/hosted-tenant.js"
|
|
55
|
+
},
|
|
56
|
+
"./admin/hosted-workspace-transport": {
|
|
45
57
|
"types": "./dist/hosted-workspace-transport.d.ts",
|
|
46
58
|
"import": "./dist/hosted-workspace-transport.js"
|
|
47
59
|
},
|
|
48
|
-
"./
|
|
49
|
-
"types": "./dist/webhook-event.d.ts",
|
|
50
|
-
"import": "./dist/webhook-event.js"
|
|
51
|
-
},
|
|
52
|
-
"./workspace": {
|
|
60
|
+
"./admin/workspace": {
|
|
53
61
|
"types": "./dist/workspace.d.ts",
|
|
54
62
|
"import": "./dist/workspace.js"
|
|
55
63
|
}
|
|
56
64
|
},
|
|
57
65
|
"dependencies": {
|
|
58
|
-
"@timbro/protocol": "0.
|
|
66
|
+
"@timbro/protocol": "0.2.0-next.0",
|
|
59
67
|
"zod": "4.4.3"
|
|
60
68
|
},
|
|
61
69
|
"devDependencies": {
|
|
@@ -65,7 +73,9 @@
|
|
|
65
73
|
"vitest": "4.1.10"
|
|
66
74
|
},
|
|
67
75
|
"scripts": {
|
|
68
|
-
"generate": "openapi-ts && node ../../scripts/finalize-sdk-operation-bindings.mjs && node ../../scripts/generate-sdk-problem-catalog.mjs && biome check --write src/generated && node ../../scripts/validate-generated-sdk-contract.mjs",
|
|
76
|
+
"generate": "openapi-ts && node ../../scripts/finalize-sdk-operation-bindings.mjs && node ../../scripts/generate-sdk-problem-catalog.mjs && node ../../scripts/generate-invoice-api-contract.mjs && biome check --write src/generated && node ../../scripts/validate-generated-sdk-contract.mjs && pnpm run generate:hosted-controls",
|
|
77
|
+
"generate:hosted-controls": "openapi-ts --file ./openapi-ts.config.ts --input ./openapi/gateway-controls.json --output ./src/generated/hosted && node ../../scripts/finalize-hosted-controls-operation-bindings.mjs",
|
|
78
|
+
"verify:hosted-controls-contract": "node ../../scripts/verify-gateway-hosted-controls-contract.mjs",
|
|
69
79
|
"typecheck": "tsc -p tsconfig.json --pretty false && tsc -p tsconfig.node.json --pretty false && tsc -p tsconfig.worker.json --pretty false && tsc -p tsconfig.receiver.json --pretty false && tsc -p tsconfig.tests.json --pretty false && tsc -p tsconfig.examples.json --pretty false",
|
|
70
80
|
"build": "node scripts/clean-dist.mjs && tsc -p tsconfig.build.json --pretty false && node scripts/stage-fiscal-engine-runtime.mjs",
|
|
71
81
|
"test:pack": "pnpm run build && node scripts/packed-consumer-compile.mjs"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type FiscalDeliveryResource } from "./generated/index.ts";
|
|
2
|
-
import type { Client } from "./generated-operation-client.ts";
|
|
3
|
-
export type FiscalDeliveryCreateCommand = {
|
|
4
|
-
readonly accountClaimUrl?: string;
|
|
5
|
-
readonly fiscalOperationId: string;
|
|
6
|
-
readonly idempotencyKey: string;
|
|
7
|
-
readonly recipientEmail: string;
|
|
8
|
-
readonly signal?: AbortSignal;
|
|
9
|
-
};
|
|
10
|
-
export declare function createFiscalDeliveryResource(client: Client, command: FiscalDeliveryCreateCommand): Promise<FiscalDeliveryResource>;
|
|
11
|
-
export declare function getFiscalDeliveryResource(client: Client, deliveryId: string, signal: AbortSignal | undefined): Promise<FiscalDeliveryResource | undefined>;
|
|
12
|
-
//# sourceMappingURL=fiscal-delivery.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fiscal-delivery.d.ts","sourceRoot":"","sources":["../src/fiscal-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAG5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAI9D,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,CAAC;AAEF,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAwBjC;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAsB7C"}
|
package/dist/fiscal-delivery.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { createFiscalDelivery, retrieveFiscalDelivery, zCreateFiscalDeliveryRequest, } from "./generated/index.js";
|
|
2
|
-
import { isExpectedNotFoundProblem, throwGeneratedProblem } from "./generated-problem.js";
|
|
3
|
-
import { isValidIdempotencyKey } from "./idempotency-key.js";
|
|
4
|
-
export async function createFiscalDeliveryResource(client, command) {
|
|
5
|
-
if (command.fiscalOperationId.trim() === "") {
|
|
6
|
-
throw new TypeError("fiscalOperationId must not be blank");
|
|
7
|
-
}
|
|
8
|
-
if (!isValidIdempotencyKey(command.idempotencyKey)) {
|
|
9
|
-
throw new TypeError("idempotencyKey must contain 16 to 255 allowed characters");
|
|
10
|
-
}
|
|
11
|
-
const body = zCreateFiscalDeliveryRequest.parse({
|
|
12
|
-
fiscal_operation_id: command.fiscalOperationId,
|
|
13
|
-
recipient_email: command.recipientEmail,
|
|
14
|
-
...(command.accountClaimUrl === undefined
|
|
15
|
-
? {}
|
|
16
|
-
: { account_claim_url: command.accountClaimUrl }),
|
|
17
|
-
});
|
|
18
|
-
const response = await createFiscalDelivery({
|
|
19
|
-
client,
|
|
20
|
-
body,
|
|
21
|
-
headers: { "idempotency-key": command.idempotencyKey },
|
|
22
|
-
...(command.signal === undefined ? {} : { signal: command.signal }),
|
|
23
|
-
});
|
|
24
|
-
if (response.status !== 200 && response.status !== 201) {
|
|
25
|
-
throwGeneratedProblem(response, "Fiscal delivery creation failed");
|
|
26
|
-
}
|
|
27
|
-
return response.body;
|
|
28
|
-
}
|
|
29
|
-
export async function getFiscalDeliveryResource(client, deliveryId, signal) {
|
|
30
|
-
if (deliveryId.trim() === "") {
|
|
31
|
-
throw new TypeError("deliveryId must not be blank");
|
|
32
|
-
}
|
|
33
|
-
const response = await retrieveFiscalDelivery({
|
|
34
|
-
client,
|
|
35
|
-
path: { fiscal_delivery_id: deliveryId },
|
|
36
|
-
...(signal === undefined ? {} : { signal }),
|
|
37
|
-
});
|
|
38
|
-
if (isExpectedNotFoundProblem(response, "fiscal_delivery_not_found", "Fiscal delivery lookup failed")) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (response.status !== 200) {
|
|
42
|
-
throwGeneratedProblem(response, "Fiscal delivery lookup failed");
|
|
43
|
-
}
|
|
44
|
-
return response.body;
|
|
45
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fiscal-error.d.ts","sourceRoot":"","sources":["../src/fiscal-error.ts"],"names":[],"mappings":"AAAA,OAAO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Resource } from "./generated/index.ts";
|
|
2
|
-
import { type Client } from "./generated-operation-client.ts";
|
|
3
|
-
import { type PrintedRepresentationDownload } from "./printed-representation.ts";
|
|
4
|
-
import { type ReadonlyCamelCase } from "./public-case.ts";
|
|
5
|
-
export type FiscalReceiptReference = ReadonlyCamelCase<WireReceiptReference>;
|
|
6
|
-
export type FiscalReceiptResource = ReadonlyCamelCase<WireReceiptResource>;
|
|
7
|
-
export type FiscalReceiptCommand = {
|
|
8
|
-
readonly receipt: FiscalReceiptReference;
|
|
9
|
-
readonly signal?: AbortSignal;
|
|
10
|
-
};
|
|
11
|
-
type ReceiptTransportOptions = {
|
|
12
|
-
readonly baseUrl: string;
|
|
13
|
-
readonly fetch?: typeof globalThis.fetch;
|
|
14
|
-
};
|
|
15
|
-
export declare function shareFiscalReceiptResource(client: Client, fiscalOperationId: string, signal: AbortSignal | undefined): Promise<FiscalReceiptReference>;
|
|
16
|
-
export declare function getFiscalReceiptResource(options: ReceiptTransportOptions, command: FiscalReceiptCommand): Promise<FiscalReceiptResource | undefined>;
|
|
17
|
-
export declare function downloadFiscalReceiptPrintedRepresentation(options: ReceiptTransportOptions, command: FiscalReceiptCommand): Promise<PrintedRepresentationDownload>;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=fiscal-receipt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fiscal-receipt.d.ts","sourceRoot":"","sources":["../src/fiscal-receipt.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,sBAAsB,IAAI,oBAAoB,EACnD,KAAK,qBAAqB,IAAI,mBAAmB,EAElD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,MAAM,EAAkC,MAAM,iCAAiC,CAAC;AAE9F,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,iBAAiB,EAA4B,MAAM,kBAAkB,CAAC;AAGpF,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AAC7E,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;AAC3E,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAC1C,CAAC;AAEF,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,sBAAsB,CAAC,CAkBjC;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAwB5C;AAED,wBAAsB,0CAA0C,CAC9D,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,6BAA6B,CAAC,CAUxC"}
|
package/dist/fiscal-receipt.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { FiscalError } from "./fiscal-error.js";
|
|
2
|
-
import { retrieveFiscalReceipt, retrieveFiscalReceiptPrintedRepresentation, shareFiscalReceipt, zFiscalReceiptReference, } from "./generated/index.js";
|
|
3
|
-
import { createGeneratedOperationClient } from "./generated-operation-client.js";
|
|
4
|
-
import { isExpectedNotFoundProblem, throwGeneratedProblem } from "./generated-problem.js";
|
|
5
|
-
import { decodePrintedRepresentation, } from "./printed-representation.js";
|
|
6
|
-
import { toPublicCase, toWireCase } from "./public-case.js";
|
|
7
|
-
import { createStampServerHttpTransport } from "./stamp-server-http-transport.js";
|
|
8
|
-
export async function shareFiscalReceiptResource(client, fiscalOperationId, signal) {
|
|
9
|
-
if (fiscalOperationId.trim() === "") {
|
|
10
|
-
throw new TypeError("fiscalOperationId must not be blank");
|
|
11
|
-
}
|
|
12
|
-
const response = await shareFiscalReceipt({
|
|
13
|
-
client,
|
|
14
|
-
path: { operation_id: fiscalOperationId },
|
|
15
|
-
...(signal === undefined ? {} : { signal }),
|
|
16
|
-
});
|
|
17
|
-
if (response.status !== 200) {
|
|
18
|
-
throwGeneratedProblem(response, "Fiscal receipt sharing failed");
|
|
19
|
-
}
|
|
20
|
-
if (response.body.fiscal_operation_id.toLowerCase() !== fiscalOperationId.toLowerCase()) {
|
|
21
|
-
throw new FiscalError("Timbro returned a receipt for another Fiscal operation", {
|
|
22
|
-
failure: "server_processing",
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return toPublicCase(response.body);
|
|
26
|
-
}
|
|
27
|
-
export async function getFiscalReceiptResource(options, command) {
|
|
28
|
-
const response = await retrieveFiscalReceipt({
|
|
29
|
-
client: receiptClient(options, command.receipt),
|
|
30
|
-
path: { receipt_id: command.receipt.id },
|
|
31
|
-
...(command.signal === undefined ? {} : { signal: command.signal }),
|
|
32
|
-
});
|
|
33
|
-
if (isExpectedNotFoundProblem(response, "fiscal_receipt_not_found", "Fiscal receipt lookup failed")) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (response.status !== 200) {
|
|
37
|
-
throwGeneratedProblem(response, "Fiscal receipt lookup failed");
|
|
38
|
-
}
|
|
39
|
-
if (response.body.id.toLowerCase() !== command.receipt.id.toLowerCase() ||
|
|
40
|
-
response.body.fiscal_operation_id.toLowerCase() !==
|
|
41
|
-
command.receipt.fiscalOperationId.toLowerCase()) {
|
|
42
|
-
throw new FiscalError("Timbro returned another shared receipt", {
|
|
43
|
-
failure: "server_processing",
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return toPublicCase(response.body);
|
|
47
|
-
}
|
|
48
|
-
export async function downloadFiscalReceiptPrintedRepresentation(options, command) {
|
|
49
|
-
const response = await retrieveFiscalReceiptPrintedRepresentation({
|
|
50
|
-
client: receiptClient(options, command.receipt),
|
|
51
|
-
path: { receipt_id: command.receipt.id },
|
|
52
|
-
...(command.signal === undefined ? {} : { signal: command.signal }),
|
|
53
|
-
});
|
|
54
|
-
if (response.status !== 200) {
|
|
55
|
-
throwGeneratedProblem(response, "Fiscal receipt PDF download failed");
|
|
56
|
-
}
|
|
57
|
-
return decodePrintedRepresentation(response, command.receipt.fiscalOperationId);
|
|
58
|
-
}
|
|
59
|
-
function receiptClient(options, receipt) {
|
|
60
|
-
const wire = zFiscalReceiptReference.parse(toWireCase(receipt));
|
|
61
|
-
return createGeneratedOperationClient(createStampServerHttpTransport({
|
|
62
|
-
stampServerOrigin: options.baseUrl,
|
|
63
|
-
authentication: { mode: "bearer", token: () => wire.access_token },
|
|
64
|
-
...(options.fetch === undefined ? {} : { fetch: options.fetch }),
|
|
65
|
-
}));
|
|
66
|
-
}
|