@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
|
@@ -41,6 +41,7 @@ export type Client = {
|
|
|
41
41
|
readonly post: <Responses, Errors>(request: GeneratedRequest<TDataShape, Responses, Errors>) => RequestResult<Responses, Errors>;
|
|
42
42
|
readonly put: <Responses, Errors>(request: GeneratedRequest<TDataShape, Responses, Errors>) => RequestResult<Responses, Errors>;
|
|
43
43
|
readonly delete: <Responses, Errors>(request: GeneratedRequest<TDataShape, Responses, Errors>) => RequestResult<Responses, Errors>;
|
|
44
|
+
readonly patch: <Responses, Errors>(request: GeneratedRequest<TDataShape, Responses, Errors>) => RequestResult<Responses, Errors>;
|
|
44
45
|
};
|
|
45
46
|
export declare function createGeneratedOperationClient(transport: TimbroTransport): Client;
|
|
46
47
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-operation-client.d.ts","sourceRoot":"","sources":["../src/generated-operation-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAEf,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,O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AK,EAAE,CAAC,SAAS,EAAE,MAAM,EAChC,OAAO,EAAE,gBAAgB,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,KACrD,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAajF"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { FiscalError } from "./fiscal-error.js";
|
|
2
1
|
import { readRetryAfterSeconds } from "./generated-problem.js";
|
|
2
|
+
import { InvoiceError } from "./invoice-error.js";
|
|
3
3
|
export function createGeneratedOperationClient(transport) {
|
|
4
4
|
return {
|
|
5
5
|
get: (request) => sendGeneratedRequest(transport, "GET", request),
|
|
6
6
|
post: (request) => sendGeneratedRequest(transport, "POST", request),
|
|
7
7
|
put: (request) => sendGeneratedRequest(transport, "PUT", request),
|
|
8
8
|
delete: (request) => sendGeneratedRequest(transport, "DELETE", request),
|
|
9
|
+
patch: (request) => sendGeneratedRequest(transport, "PATCH", request),
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
function sendGeneratedRequest(transport, method, request) {
|
|
@@ -23,7 +24,7 @@ function sendGeneratedRequest(transport, method, request) {
|
|
|
23
24
|
}
|
|
24
25
|
catch (error) {
|
|
25
26
|
// biome-ignore lint/style/useErrorCause: the custom error keeps the generated failure detail in the second argument
|
|
26
|
-
throw new
|
|
27
|
+
throw new InvoiceError("Timbro returned a response outside the generated contract", {
|
|
27
28
|
failure: "server_processing",
|
|
28
29
|
status: response.status,
|
|
29
30
|
retryAfterSeconds: readRetryAfterSeconds(response.headers),
|
|
@@ -6,7 +6,7 @@ type GeneratedProblemResponse = {
|
|
|
6
6
|
readonly body: unknown;
|
|
7
7
|
};
|
|
8
8
|
export declare function throwGeneratedProblem(response: GeneratedProblemResponse, message: string): never;
|
|
9
|
-
export declare function isExpectedNotFoundProblem(response: GeneratedProblemResponse, expectedCode: Extract<PublicProblemCode, "fiscal_operation_not_found" | "fiscal_delivery_not_found" | "
|
|
9
|
+
export declare function isExpectedNotFoundProblem(response: GeneratedProblemResponse, expectedCode: Extract<PublicProblemCode, "fiscal_operation_not_found" | "fiscal_delivery_not_found" | "invoice_receipt_not_found" | "received_document_not_found">, message: string): boolean;
|
|
10
10
|
export declare function readRetryAfterSeconds(headers: ReadonlyMap<string, string> | undefined, nowMilliseconds?: number): number | undefined;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=generated-problem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-problem.d.ts","sourceRoot":"","sources":["../src/generated-problem.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generated-problem.d.ts","sourceRoot":"","sources":["../src/generated-problem.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAKlE,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAwBhG;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,wBAAwB,EAClC,YAAY,EAAE,OAAO,CACnB,iBAAiB,EACf,4BAA4B,GAC5B,2BAA2B,GAC3B,2BAA2B,GAC3B,6BAA6B,CAChC,EACD,OAAO,EAAE,MAAM,GACd,OAAO,CAST;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAChD,eAAe,GAAE,MAAmB,GACnC,MAAM,GAAG,SAAS,CAEpB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseProblemFields, parseRetryAfter } from "@timbro/protocol";
|
|
2
|
-
import { FiscalError } from "./fiscal-error.js";
|
|
3
2
|
import { zProblemBody } from "./generated/zod.gen.js";
|
|
3
|
+
import { InvoiceError } from "./invoice-error.js";
|
|
4
4
|
import { classifyProblemStatus } from "./problem-contract.js";
|
|
5
5
|
export function throwGeneratedProblem(response, message) {
|
|
6
6
|
const retryAfterSeconds = readRetryAfterSeconds(response.headers);
|
|
7
7
|
if (response.status === "unexpected") {
|
|
8
|
-
throw new
|
|
8
|
+
throw new InvoiceError(message, {
|
|
9
9
|
failure: "server_processing",
|
|
10
10
|
status: response.status_code,
|
|
11
11
|
retryAfterSeconds,
|
|
@@ -13,10 +13,10 @@ export function throwGeneratedProblem(response, message) {
|
|
|
13
13
|
}
|
|
14
14
|
const parsed = zProblemBody.safeParse(response.body);
|
|
15
15
|
if (!parsed.success) {
|
|
16
|
-
throw new
|
|
16
|
+
throw new InvoiceError(message, { failure: "server_processing", status: response.status, retryAfterSeconds }, { cause: parsed.error });
|
|
17
17
|
}
|
|
18
18
|
const problemFields = parseProblemFields(parsed.data.problems);
|
|
19
|
-
throw new
|
|
19
|
+
throw new InvoiceError(message, {
|
|
20
20
|
failure: classifyProblemStatus(parsed.data),
|
|
21
21
|
problem: problemFields === undefined ? parsed.data : { ...parsed.data, problems: [...problemFields] },
|
|
22
22
|
retryAfterSeconds,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,13 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type {
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
7
|
-
export type { FiscalDeliveryCreateCommand } from "./fiscal-delivery.ts";
|
|
8
|
-
export type { FiscalErrorDetail, FiscalFailure } from "./fiscal-error.ts";
|
|
9
|
-
export { FiscalError } from "./fiscal-error.ts";
|
|
10
|
-
export type { FiscalNumberingReadiness } from "./fiscal-numbering-readiness.ts";
|
|
11
|
-
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";
|
|
12
|
-
export { toFiscalDocumentSnapshot } from "./fiscal-operation.ts";
|
|
13
|
-
export type { FiscalOperationTimingReport, TimingStageId } from "./fiscal-operation-timing.ts";
|
|
14
|
-
export { TIMING_STAGE_IDS } from "./fiscal-operation-timing.ts";
|
|
15
|
-
export type { FiscalReceiptCommand, FiscalReceiptReference, FiscalReceiptResource, } from "./fiscal-receipt.ts";
|
|
16
|
-
export type { FiscalDeliveryResource, FiscalOperationOutcomeResource, PrintedRepresentationProfile, SourceCreditNoteCorrection, SourceDebitNoteCorrection, SourceFiscalAction, WebhookDelivery, WebhookDeliveryPage, WebhookDeliveryState, } from "./generated/index.ts";
|
|
17
|
-
export type { HostedTenant, HostedTenantClient, HostedTenantClientOptions, HostedTenantCreateCommand, HostedTenantEnvironment, HostedTenantRelease, HostedTenantReleaseCommand, HostedTenantWebhookSecretRotationCommand, HostedWebhookSecretRotation, } from "./hosted-tenant.ts";
|
|
18
|
-
export { createHostedTenantClient } from "./hosted-tenant.ts";
|
|
19
|
-
export type { HostedWorkspaceTransportOptions } from "./hosted-workspace-transport.ts";
|
|
20
|
-
export { createHostedWorkspaceTransport } from "./hosted-workspace-transport.ts";
|
|
21
|
-
export type { PrintedRepresentationDownload } from "./printed-representation.ts";
|
|
1
|
+
export type { InvoiceDeliveryResource, InvoicePage, InvoicePreview, InvoiceReceipt, InvoiceReceiptAccess, InvoiceRequest, InvoiceResource, InvoiceType, } from "./generated/index.ts";
|
|
2
|
+
export type { InvoiceCreateOptions, InvoiceDeliveryCommand, InvoiceDeliveryReadCommand, InvoiceListFilters, InvoicePdfDownload, InvoiceReplacement, InvoiceRequestOptions, InvoiceXmlDownload, TimbroInvoices, TimbroInvoicesOptions, } from "./invoice.ts";
|
|
3
|
+
export { createTimbroInvoices } from "./invoice.ts";
|
|
4
|
+
export type { InvoiceErrorDetail, InvoiceFailure } from "./invoice-error.ts";
|
|
5
|
+
export { InvoiceError } from "./invoice-error.ts";
|
|
6
|
+
export type { BusinessConfigureInvoicingCommand, BusinessImportSigningCertificateCommand, BusinessIssueInvoiceKeyCommand, BusinessIssueTestInvoiceCommand, BusinessIssueTestInvoiceOptions, BusinessUpdateCommand, InvoiceHostedControls, WebhookEndpointCreateCommand, WebhookEndpointListDeliveriesCommand, WebhookEndpointListFilters, WebhookEndpointReplayCommand, } from "./invoice-hosted-controls.ts";
|
|
22
7
|
export type { ProblemBody, ProblemCatalogEntry, ProblemCode, ProblemFailure, PublicProblemCode, } from "./problem-contract.ts";
|
|
23
8
|
export { PROBLEM_CATALOG } from "./problem-contract.ts";
|
|
24
|
-
export {
|
|
25
|
-
export type {
|
|
26
|
-
export { digestSha256Hex } from "./sha256.ts";
|
|
27
|
-
export type { SignedDocumentDownload } from "./signed-document.ts";
|
|
28
|
-
export type { HostedSandboxSourceCredential, HostedSandboxSourceCredentialIssueCommand, SourceConnectionActivationVerificationCommand, } from "./source-connection.ts";
|
|
29
|
-
export type { SourceConnectionTransportOptions } from "./source-connection-transport.ts";
|
|
30
|
-
export type { StampServerBearerTokenProvider, StampServerHttpAuthentication, } from "./stamp-server-http-transport.ts";
|
|
31
|
-
export type { TimbroClient, TimbroClientAuthentication, TimbroClientOptions, } from "./timbro-client.ts";
|
|
32
|
-
export { createTimbroClient } from "./timbro-client.ts";
|
|
33
|
-
export type { WebhookDeliveryListCommand } from "./webhook-delivery.ts";
|
|
34
|
-
export type { DeliveredWebhookEvent, ReceptionWebhookEvent, WebhookEvent, } from "./webhook-event.ts";
|
|
35
|
-
export { parseDeliveredWebhookEvent, parseWebhookEvent, } from "./webhook-event.ts";
|
|
36
|
-
export type { WebhookRegistration, WebhookRegistrationCommand } from "./webhook-registration.ts";
|
|
37
|
-
export type { WebhookReplay, WebhookReplayCommand } from "./webhook-replay.ts";
|
|
9
|
+
export type { CommercialResponse, ReceivedDocumentDownload, ReceivedDocumentListCommand, ReceivedDocumentPage, ReceivedDocumentRecoveryFilter, ReceivedDocumentResource, ReceivedDocumentResponseFilter, ReceivedDocumentStateFilter, ReceivedDocumentSummary, } from "./received-documents.ts";
|
|
10
|
+
export type { DeliveredWebhookEvent, InvoiceWebhookEvent, InvoiceWebhookEventEnvelope, ReceptionWebhookEvent, } from "./webhook-event.ts";
|
|
38
11
|
export type { WebhookDeliveryHeaders, WebhookVerificationCommand, WebhookVerificationRejection, } from "./webhook-verification.ts";
|
|
39
12
|
export { verifyWebhookDelivery, WebhookVerificationError } from "./webhook-verification.ts";
|
|
40
|
-
export type { WorkspaceClient, WorkspaceClientOptions } from "./workspace.ts";
|
|
41
|
-
export { createWorkspaceClient } from "./workspace.ts";
|
|
42
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,WAAW,EACX,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EACV,iCAAiC,EACjC,uCAAuC,EACvC,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,EAC5B,oCAAoC,EACpC,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EACV,kBAAkB,EAClB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,8BAA8B,EAC9B,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { FiscalError } from "./fiscal-error.js";
|
|
4
|
-
export { toFiscalDocumentSnapshot } from "./fiscal-operation.js";
|
|
5
|
-
export { TIMING_STAGE_IDS } from "./fiscal-operation-timing.js";
|
|
6
|
-
export { createHostedTenantClient } from "./hosted-tenant.js";
|
|
7
|
-
export { createHostedWorkspaceTransport } from "./hosted-workspace-transport.js";
|
|
1
|
+
export { createTimbroInvoices } from "./invoice.js";
|
|
2
|
+
export { InvoiceError } from "./invoice-error.js";
|
|
8
3
|
export { PROBLEM_CATALOG } from "./problem-contract.js";
|
|
9
|
-
export { toWireCase } from "./public-case.js";
|
|
10
|
-
export { digestSha256Hex } from "./sha256.js";
|
|
11
|
-
export { createTimbroClient } from "./timbro-client.js";
|
|
12
|
-
export { parseDeliveredWebhookEvent, parseWebhookEvent, } from "./webhook-event.js";
|
|
13
4
|
export { verifyWebhookDelivery, WebhookVerificationError } from "./webhook-verification.js";
|
|
14
|
-
export { createWorkspaceClient } from "./workspace.js";
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import type { FiscalAdmissionProblem, IssuanceBlocker, ProblemBody
|
|
1
|
+
import type { FiscalAdmissionProblem, IssuanceBlocker, ProblemBody } from "./generated/types.gen.ts";
|
|
2
2
|
import type { ProblemFailure } from "./problem-contract.ts";
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
5
|
-
readonly failure:
|
|
3
|
+
export type InvoiceFailure = ProblemFailure | "connectivity" | "timeout" | "cancelled";
|
|
4
|
+
export type InvoiceErrorDetail = {
|
|
5
|
+
readonly failure: InvoiceFailure;
|
|
6
6
|
readonly status?: number | undefined;
|
|
7
7
|
readonly problem?: ProblemBody;
|
|
8
8
|
readonly retryAfterSeconds?: number | undefined;
|
|
9
9
|
};
|
|
10
|
-
export declare class
|
|
11
|
-
readonly failure:
|
|
10
|
+
export declare class InvoiceError extends Error {
|
|
11
|
+
readonly failure: InvoiceFailure;
|
|
12
12
|
readonly status: number | undefined;
|
|
13
13
|
readonly problem: ProblemBody | undefined;
|
|
14
14
|
readonly retryAfterSeconds: number | undefined;
|
|
15
|
-
constructor(message: string, detail:
|
|
16
|
-
get code():
|
|
15
|
+
constructor(message: string, detail: InvoiceErrorDetail, options?: ErrorOptions);
|
|
16
|
+
get code(): ProblemBody["code"] | undefined;
|
|
17
17
|
get title(): string | undefined;
|
|
18
18
|
get requestId(): string | undefined;
|
|
19
|
+
get invoiceId(): string | undefined;
|
|
19
20
|
get problems(): readonly FiscalAdmissionProblem[];
|
|
20
21
|
get issuanceBlockers(): readonly IssuanceBlocker[];
|
|
21
22
|
get isRetryable(): boolean;
|
|
22
23
|
}
|
|
23
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=invoice-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-error.d.ts","sourceRoot":"","sources":["../src/invoice-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,SAAS,GAAG,WAAW,CAAC;AAEvF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjD,CAAC;AAIF,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/C,YAAY,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,YAAY,EAO9E;IAED,IAAI,IAAI,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAE1C;IAED,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,QAAQ,IAAI,SAAS,sBAAsB,EAAE,CAEhD;IAED,IAAI,gBAAgB,IAAI,SAAS,eAAe,EAAE,CAEjD;IAED,IAAI,WAAW,IAAI,OAAO,CAKzB;CACF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504]);
|
|
2
|
-
export class
|
|
2
|
+
export class InvoiceError extends Error {
|
|
3
3
|
failure;
|
|
4
4
|
status;
|
|
5
5
|
problem;
|
|
6
6
|
retryAfterSeconds;
|
|
7
7
|
constructor(message, detail, options) {
|
|
8
8
|
super(message, options);
|
|
9
|
-
this.name = "
|
|
9
|
+
this.name = "InvoiceError";
|
|
10
10
|
this.failure = detail.failure;
|
|
11
11
|
this.status = detail.problem?.status ?? detail.status;
|
|
12
12
|
this.problem = detail.problem;
|
|
@@ -19,13 +19,16 @@ export class FiscalError extends Error {
|
|
|
19
19
|
return this.problem?.title;
|
|
20
20
|
}
|
|
21
21
|
get requestId() {
|
|
22
|
-
return this.problem?.
|
|
22
|
+
return this.problem?.requestId;
|
|
23
|
+
}
|
|
24
|
+
get invoiceId() {
|
|
25
|
+
return this.problem?.invoiceId;
|
|
23
26
|
}
|
|
24
27
|
get problems() {
|
|
25
28
|
return this.problem?.problems ?? [];
|
|
26
29
|
}
|
|
27
30
|
get issuanceBlockers() {
|
|
28
|
-
return this.problem?.
|
|
31
|
+
return this.problem?.issuanceBlockers ?? [];
|
|
29
32
|
}
|
|
30
33
|
get isRetryable() {
|
|
31
34
|
if (this.failure === "connectivity" || this.failure === "timeout") {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ConfigureInvoicingData, CreateWebhookEndpointData, ImportSigningCertificateData, IssueInvoiceKeyData, IssueTestInvoiceData, ListWebhookDeliveriesData, ListWebhookEndpointsData, ReplayWebhookEventsData, UpdateBusinessData } from "./generated/hosted/index.ts";
|
|
2
|
+
import { configureInvoicing as configureInvoicingOperation, createWebhookEndpoint as createWebhookEndpointOperation, importSigningCertificate as importSigningCertificateOperation, issueInvoiceKey as issueInvoiceKeyOperation, issueTestInvoice as issueTestInvoiceOperation, listWebhookDeliveries as listWebhookDeliveriesOperation, listWebhookEndpoints as listWebhookEndpointsOperation, reactivateWebhookEndpoint as reactivateWebhookEndpointOperation, replayWebhookEvents as replayWebhookEventsOperation, retrieveBusiness as retrieveBusinessOperation, retrieveWebhookEndpoint as retrieveWebhookEndpointOperation, rotateWebhookEndpointSecret as rotateWebhookEndpointSecretOperation, suspendWebhookEndpoint as suspendWebhookEndpointOperation, updateBusiness as updateBusinessOperation } from "./generated/hosted/index.ts";
|
|
3
|
+
import type { Client } from "./generated-operation-client.ts";
|
|
4
|
+
import type { InvoiceRequestOptions } from "./invoice.ts";
|
|
5
|
+
type BodyOf<Data> = Data extends {
|
|
6
|
+
body: infer Body;
|
|
7
|
+
} ? Body : never;
|
|
8
|
+
type QueryOf<Data> = Data extends {
|
|
9
|
+
query?: infer Query;
|
|
10
|
+
} ? NonNullable<Query> : never;
|
|
11
|
+
type PathOf<Data> = Data extends {
|
|
12
|
+
path: infer Path;
|
|
13
|
+
} ? Path : never;
|
|
14
|
+
type SuccessBody<Response, Status extends number> = Extract<Awaited<Response>, {
|
|
15
|
+
readonly status: Status;
|
|
16
|
+
}> extends {
|
|
17
|
+
readonly body: infer Body;
|
|
18
|
+
} ? Body : undefined;
|
|
19
|
+
export type BusinessUpdateCommand = BodyOf<UpdateBusinessData> & {
|
|
20
|
+
readonly idempotencyKey?: string;
|
|
21
|
+
};
|
|
22
|
+
export type BusinessConfigureInvoicingCommand = BodyOf<ConfigureInvoicingData> & {
|
|
23
|
+
readonly idempotencyKey: string;
|
|
24
|
+
};
|
|
25
|
+
export type BusinessImportSigningCertificateCommand = BodyOf<ImportSigningCertificateData>;
|
|
26
|
+
export type BusinessIssueTestInvoiceCommand = Partial<BodyOf<IssueTestInvoiceData>>;
|
|
27
|
+
export type BusinessIssueTestInvoiceOptions = BusinessIssueTestInvoiceCommand & InvoiceRequestOptions;
|
|
28
|
+
export type BusinessIssueInvoiceKeyCommand = BodyOf<IssueInvoiceKeyData> & {
|
|
29
|
+
readonly idempotencyKey: string;
|
|
30
|
+
};
|
|
31
|
+
export type WebhookEndpointListFilters = QueryOf<ListWebhookEndpointsData>;
|
|
32
|
+
export type WebhookEndpointCreateCommand = BodyOf<CreateWebhookEndpointData> & {
|
|
33
|
+
readonly idempotencyKey: string;
|
|
34
|
+
};
|
|
35
|
+
export type WebhookEndpointListDeliveriesCommand = PathOf<ListWebhookDeliveriesData> & QueryOf<ListWebhookDeliveriesData>;
|
|
36
|
+
export type WebhookEndpointReplayCommand = PathOf<ReplayWebhookEventsData> & BodyOf<ReplayWebhookEventsData> & {
|
|
37
|
+
readonly idempotencyKey: string;
|
|
38
|
+
};
|
|
39
|
+
export type InvoiceHostedControls = {
|
|
40
|
+
readonly business: {
|
|
41
|
+
readonly retrieve: (options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof retrieveBusinessOperation>, 200>>;
|
|
42
|
+
readonly update: (command: BusinessUpdateCommand, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof updateBusinessOperation>, 200>>;
|
|
43
|
+
readonly configureInvoicing: (command: BusinessConfigureInvoicingCommand, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof configureInvoicingOperation>, 201>>;
|
|
44
|
+
readonly importSigningCertificate: (command: BusinessImportSigningCertificateCommand, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof importSigningCertificateOperation>, 200>>;
|
|
45
|
+
readonly issueTestInvoice: (options?: BusinessIssueTestInvoiceOptions) => Promise<SuccessBody<ReturnType<typeof issueTestInvoiceOperation>, 200>>;
|
|
46
|
+
readonly issueInvoiceKey: (command: BusinessIssueInvoiceKeyCommand, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof issueInvoiceKeyOperation>, 201>>;
|
|
47
|
+
};
|
|
48
|
+
readonly webhookEndpoints: {
|
|
49
|
+
readonly list: (filters?: WebhookEndpointListFilters, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof listWebhookEndpointsOperation>, 200>>;
|
|
50
|
+
readonly create: (command: WebhookEndpointCreateCommand, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof createWebhookEndpointOperation>, 201>>;
|
|
51
|
+
readonly retrieve: (webhookEndpointId: string, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof retrieveWebhookEndpointOperation>, 200>>;
|
|
52
|
+
readonly delete: (webhookEndpointId: string, options?: InvoiceRequestOptions) => Promise<void>;
|
|
53
|
+
readonly listDeliveries: (command: WebhookEndpointListDeliveriesCommand, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof listWebhookDeliveriesOperation>, 200>>;
|
|
54
|
+
readonly replay: (command: WebhookEndpointReplayCommand, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof replayWebhookEventsOperation>, 201>>;
|
|
55
|
+
readonly rotateSecret: (webhookEndpointId: string, idempotencyKey: string, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof rotateWebhookEndpointSecretOperation>, 200>>;
|
|
56
|
+
readonly suspend: (webhookEndpointId: string, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof suspendWebhookEndpointOperation>, 200>>;
|
|
57
|
+
readonly reactivate: (webhookEndpointId: string, options?: InvoiceRequestOptions) => Promise<SuccessBody<ReturnType<typeof reactivateWebhookEndpointOperation>, 200>>;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare function createInvoiceHostedControls(client: Client): InvoiceHostedControls;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=invoice-hosted-controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-hosted-controls.d.ts","sourceRoot":"","sources":["../src/invoice-hosted-controls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,IAAI,2BAA2B,EACjD,qBAAqB,IAAI,8BAA8B,EAEvD,wBAAwB,IAAI,iCAAiC,EAC7D,eAAe,IAAI,wBAAwB,EAC3C,gBAAgB,IAAI,yBAAyB,EAC7C,qBAAqB,IAAI,8BAA8B,EACvD,oBAAoB,IAAI,6BAA6B,EACrD,yBAAyB,IAAI,kCAAkC,EAC/D,mBAAmB,IAAI,4BAA4B,EACnD,gBAAgB,IAAI,yBAAyB,EAC7C,uBAAuB,IAAI,gCAAgC,EAC3D,2BAA2B,IAAI,oCAAoC,EACnE,sBAAsB,IAAI,+BAA+B,EACzD,cAAc,IAAI,uBAAuB,EAC1C,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,KAAK,MAAM,CAAC,IAAI,IAAI,IAAI,SAAS;IAAE,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,KAAK,CAAC;AACrE,KAAK,OAAO,CAAC,IAAI,IAAI,IAAI,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAA;CAAE,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;AACvF,KAAK,MAAM,CAAC,IAAI,IAA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B,KAC5B,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,oCAAoC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QACxF,QAAQ,CAAC,OAAO,EAAE,CAChB,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QACnF,QAAQ,CAAC,UAAU,EAAE,CACnB,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,kCAAkC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;KACvF,CAAC;CACH,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,CA0LjF"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { configureInvoicing as configureInvoicingOperation, createWebhookEndpoint as createWebhookEndpointOperation, deleteWebhookEndpoint as deleteWebhookEndpointOperation, importSigningCertificate as importSigningCertificateOperation, issueInvoiceKey as issueInvoiceKeyOperation, issueTestInvoice as issueTestInvoiceOperation, listWebhookDeliveries as listWebhookDeliveriesOperation, listWebhookEndpoints as listWebhookEndpointsOperation, reactivateWebhookEndpoint as reactivateWebhookEndpointOperation, replayWebhookEvents as replayWebhookEventsOperation, retrieveBusiness as retrieveBusinessOperation, retrieveWebhookEndpoint as retrieveWebhookEndpointOperation, rotateWebhookEndpointSecret as rotateWebhookEndpointSecretOperation, suspendWebhookEndpoint as suspendWebhookEndpointOperation, updateBusiness as updateBusinessOperation, } from "./generated/hosted/index.js";
|
|
2
|
+
import { throwGeneratedProblem } from "./generated-problem.js";
|
|
3
|
+
export function createInvoiceHostedControls(client) {
|
|
4
|
+
return {
|
|
5
|
+
business: {
|
|
6
|
+
retrieve: async (options) => {
|
|
7
|
+
const response = await retrieveBusinessOperation({ client, ...options });
|
|
8
|
+
if (response.status === 200) {
|
|
9
|
+
return response.body;
|
|
10
|
+
}
|
|
11
|
+
throwGeneratedProblem(response, "Business retrieval failed");
|
|
12
|
+
},
|
|
13
|
+
update: async (command, options) => {
|
|
14
|
+
const { idempotencyKey, ...body } = command;
|
|
15
|
+
const response = await updateBusinessOperation({
|
|
16
|
+
client,
|
|
17
|
+
body,
|
|
18
|
+
...(idempotencyKey === undefined
|
|
19
|
+
? {}
|
|
20
|
+
: { headers: { "Idempotency-Key": idempotencyKey } }),
|
|
21
|
+
...options,
|
|
22
|
+
});
|
|
23
|
+
if (response.status === 200) {
|
|
24
|
+
return response.body;
|
|
25
|
+
}
|
|
26
|
+
throwGeneratedProblem(response, "Business update failed");
|
|
27
|
+
},
|
|
28
|
+
configureInvoicing: async (command, options) => {
|
|
29
|
+
const { idempotencyKey, ...body } = command;
|
|
30
|
+
const response = await configureInvoicingOperation({
|
|
31
|
+
client,
|
|
32
|
+
body,
|
|
33
|
+
headers: { "Idempotency-Key": idempotencyKey },
|
|
34
|
+
...options,
|
|
35
|
+
});
|
|
36
|
+
if (response.status === 201) {
|
|
37
|
+
return response.body;
|
|
38
|
+
}
|
|
39
|
+
throwGeneratedProblem(response, "Invoice environment configuration failed");
|
|
40
|
+
},
|
|
41
|
+
importSigningCertificate: async (command, options) => {
|
|
42
|
+
const response = await importSigningCertificateOperation({
|
|
43
|
+
client,
|
|
44
|
+
body: command,
|
|
45
|
+
...options,
|
|
46
|
+
});
|
|
47
|
+
if (response.status === 200) {
|
|
48
|
+
return response.body;
|
|
49
|
+
}
|
|
50
|
+
throwGeneratedProblem(response, "Signing certificate import failed");
|
|
51
|
+
},
|
|
52
|
+
issueTestInvoice: async (options) => {
|
|
53
|
+
const body = options?.documentType === undefined ? {} : { documentType: options.documentType };
|
|
54
|
+
const response = await issueTestInvoiceOperation({
|
|
55
|
+
client,
|
|
56
|
+
body,
|
|
57
|
+
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
58
|
+
});
|
|
59
|
+
if (response.status === 200) {
|
|
60
|
+
return response.body;
|
|
61
|
+
}
|
|
62
|
+
throwGeneratedProblem(response, "Test invoice issuance failed");
|
|
63
|
+
},
|
|
64
|
+
issueInvoiceKey: async (command, options) => {
|
|
65
|
+
const { idempotencyKey, ...body } = command;
|
|
66
|
+
const response = await issueInvoiceKeyOperation({
|
|
67
|
+
client,
|
|
68
|
+
body,
|
|
69
|
+
headers: { "Idempotency-Key": idempotencyKey },
|
|
70
|
+
...options,
|
|
71
|
+
});
|
|
72
|
+
if (response.status === 201) {
|
|
73
|
+
return response.body;
|
|
74
|
+
}
|
|
75
|
+
throwGeneratedProblem(response, "Invoice API key issuance failed");
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
webhookEndpoints: {
|
|
79
|
+
list: async (filters, options) => {
|
|
80
|
+
const response = await listWebhookEndpointsOperation({
|
|
81
|
+
client,
|
|
82
|
+
...(filters === undefined ? {} : { query: filters }),
|
|
83
|
+
...options,
|
|
84
|
+
});
|
|
85
|
+
if (response.status === 200) {
|
|
86
|
+
return response.body;
|
|
87
|
+
}
|
|
88
|
+
throwGeneratedProblem(response, "Webhook endpoint listing failed");
|
|
89
|
+
},
|
|
90
|
+
create: async (command, options) => {
|
|
91
|
+
const { idempotencyKey, ...body } = command;
|
|
92
|
+
const response = await createWebhookEndpointOperation({
|
|
93
|
+
client,
|
|
94
|
+
body,
|
|
95
|
+
headers: { "Idempotency-Key": idempotencyKey },
|
|
96
|
+
...options,
|
|
97
|
+
});
|
|
98
|
+
if (response.status === 201) {
|
|
99
|
+
return response.body;
|
|
100
|
+
}
|
|
101
|
+
throwGeneratedProblem(response, "Webhook endpoint creation failed");
|
|
102
|
+
},
|
|
103
|
+
retrieve: async (webhookEndpointId, options) => {
|
|
104
|
+
const response = await retrieveWebhookEndpointOperation({
|
|
105
|
+
client,
|
|
106
|
+
path: { webhookEndpointId },
|
|
107
|
+
...options,
|
|
108
|
+
});
|
|
109
|
+
if (response.status === 200) {
|
|
110
|
+
return response.body;
|
|
111
|
+
}
|
|
112
|
+
throwGeneratedProblem(response, "Webhook endpoint retrieval failed");
|
|
113
|
+
},
|
|
114
|
+
delete: async (webhookEndpointId, options) => {
|
|
115
|
+
const response = await deleteWebhookEndpointOperation({
|
|
116
|
+
client,
|
|
117
|
+
path: { webhookEndpointId },
|
|
118
|
+
...options,
|
|
119
|
+
});
|
|
120
|
+
if (response.status === 204) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
throwGeneratedProblem(response, "Webhook endpoint deletion failed");
|
|
124
|
+
},
|
|
125
|
+
listDeliveries: async (command, options) => {
|
|
126
|
+
const { webhookEndpointId, ...query } = command;
|
|
127
|
+
const response = await listWebhookDeliveriesOperation({
|
|
128
|
+
client,
|
|
129
|
+
path: { webhookEndpointId },
|
|
130
|
+
query,
|
|
131
|
+
...options,
|
|
132
|
+
});
|
|
133
|
+
if (response.status === 200) {
|
|
134
|
+
return response.body;
|
|
135
|
+
}
|
|
136
|
+
throwGeneratedProblem(response, "Webhook delivery listing failed");
|
|
137
|
+
},
|
|
138
|
+
replay: async (command, options) => {
|
|
139
|
+
const { webhookEndpointId, idempotencyKey, ...body } = command;
|
|
140
|
+
const response = await replayWebhookEventsOperation({
|
|
141
|
+
client,
|
|
142
|
+
path: { webhookEndpointId },
|
|
143
|
+
body,
|
|
144
|
+
headers: { "Idempotency-Key": idempotencyKey },
|
|
145
|
+
...options,
|
|
146
|
+
});
|
|
147
|
+
if (response.status === 201) {
|
|
148
|
+
return response.body;
|
|
149
|
+
}
|
|
150
|
+
throwGeneratedProblem(response, "Webhook event replay failed");
|
|
151
|
+
},
|
|
152
|
+
rotateSecret: async (webhookEndpointId, idempotencyKey, options) => {
|
|
153
|
+
const response = await rotateWebhookEndpointSecretOperation({
|
|
154
|
+
client,
|
|
155
|
+
path: { webhookEndpointId },
|
|
156
|
+
headers: { "Idempotency-Key": idempotencyKey },
|
|
157
|
+
...options,
|
|
158
|
+
});
|
|
159
|
+
if (response.status === 200) {
|
|
160
|
+
return response.body;
|
|
161
|
+
}
|
|
162
|
+
throwGeneratedProblem(response, "Webhook signing secret rotation failed");
|
|
163
|
+
},
|
|
164
|
+
suspend: async (webhookEndpointId, options) => {
|
|
165
|
+
const response = await suspendWebhookEndpointOperation({
|
|
166
|
+
client,
|
|
167
|
+
path: { webhookEndpointId },
|
|
168
|
+
...options,
|
|
169
|
+
});
|
|
170
|
+
if (response.status === 200) {
|
|
171
|
+
return response.body;
|
|
172
|
+
}
|
|
173
|
+
throwGeneratedProblem(response, "Webhook endpoint suspension failed");
|
|
174
|
+
},
|
|
175
|
+
reactivate: async (webhookEndpointId, options) => {
|
|
176
|
+
const response = await reactivateWebhookEndpointOperation({
|
|
177
|
+
client,
|
|
178
|
+
path: { webhookEndpointId },
|
|
179
|
+
...options,
|
|
180
|
+
});
|
|
181
|
+
if (response.status === 200) {
|
|
182
|
+
return response.body;
|
|
183
|
+
}
|
|
184
|
+
throwGeneratedProblem(response, "Webhook endpoint reactivation failed");
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type InvoiceReceipt, type InvoiceReceiptAccess } from "./generated/index.ts";
|
|
2
|
+
import { type Client } from "./generated-operation-client.ts";
|
|
3
|
+
export type InvoiceReceiptTransportOptions = {
|
|
4
|
+
readonly baseUrl: string;
|
|
5
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
6
|
+
};
|
|
7
|
+
export declare function shareInvoiceReceiptResource(client: Client, invoiceId: string, signal: AbortSignal | undefined): Promise<InvoiceReceiptAccess>;
|
|
8
|
+
export declare function retrieveInvoiceReceiptResource(options: InvoiceReceiptTransportOptions, receipt: InvoiceReceiptAccess, signal: AbortSignal | undefined): Promise<InvoiceReceipt | undefined>;
|
|
9
|
+
export declare function createInvoiceReceiptClient(options: InvoiceReceiptTransportOptions, receipt: InvoiceReceiptAccess): Client;
|
|
10
|
+
//# sourceMappingURL=invoice-receipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-receipt.d.ts","sourceRoot":"","sources":["../src/invoice-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAI1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,MAAM,EAAkC,MAAM,iCAAiC,CAAC;AAK9F,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAC1C,CAAC;AAEF,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CAe/B;AAED,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,8BAA8B,EACvC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA2BrC;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,8BAA8B,EACvC,OAAO,EAAE,oBAAoB,GAC5B,MAAM,CASR"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { retrieveInvoiceReceipt, shareInvoiceReceipt, zInvoiceReceiptAccess, } from "./generated/index.js";
|
|
2
|
+
import { createGeneratedOperationClient } from "./generated-operation-client.js";
|
|
3
|
+
import { isExpectedNotFoundProblem, throwGeneratedProblem } from "./generated-problem.js";
|
|
4
|
+
import { InvoiceError } from "./invoice-error.js";
|
|
5
|
+
import { createStampServerHttpTransport } from "./stamp-server-http-transport.js";
|
|
6
|
+
export async function shareInvoiceReceiptResource(client, invoiceId, signal) {
|
|
7
|
+
const response = await shareInvoiceReceipt({
|
|
8
|
+
client,
|
|
9
|
+
path: { invoiceId },
|
|
10
|
+
...(signal === undefined ? {} : { signal }),
|
|
11
|
+
});
|
|
12
|
+
if (response.status !== 200) {
|
|
13
|
+
throwGeneratedProblem(response, "Invoice receipt sharing failed");
|
|
14
|
+
}
|
|
15
|
+
if (response.body.invoiceId.toLowerCase() !== invoiceId.toLowerCase()) {
|
|
16
|
+
throw new InvoiceError("Timbro returned a receipt for another Invoice", {
|
|
17
|
+
failure: "server_processing",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return response.body;
|
|
21
|
+
}
|
|
22
|
+
export async function retrieveInvoiceReceiptResource(options, receipt, signal) {
|
|
23
|
+
const response = await retrieveInvoiceReceipt({
|
|
24
|
+
client: createInvoiceReceiptClient(options, receipt),
|
|
25
|
+
path: { receiptId: receipt.id },
|
|
26
|
+
...(signal === undefined ? {} : { signal }),
|
|
27
|
+
});
|
|
28
|
+
if (isExpectedNotFoundProblem(response, "invoice_receipt_not_found", "Invoice receipt lookup failed")) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (response.status !== 200) {
|
|
32
|
+
throwGeneratedProblem(response, "Invoice receipt lookup failed");
|
|
33
|
+
}
|
|
34
|
+
if (response.body.id.toLowerCase() !== receipt.id.toLowerCase() ||
|
|
35
|
+
response.body.invoiceId.toLowerCase() !== receipt.invoiceId.toLowerCase()) {
|
|
36
|
+
throw new InvoiceError("Timbro returned another shared Invoice receipt", {
|
|
37
|
+
failure: "server_processing",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return response.body;
|
|
41
|
+
}
|
|
42
|
+
export function createInvoiceReceiptClient(options, receipt) {
|
|
43
|
+
const access = zInvoiceReceiptAccess.parse(receipt);
|
|
44
|
+
return createGeneratedOperationClient(createStampServerHttpTransport({
|
|
45
|
+
stampServerOrigin: options.baseUrl,
|
|
46
|
+
authentication: { mode: "bearer", token: () => access.accessToken },
|
|
47
|
+
...(options.fetch === undefined ? {} : { fetch: options.fetch }),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Client, InvoiceRequest, InvoiceResource } from "./generated/index.ts";
|
|
2
|
+
export type InvoiceReplacement = {
|
|
3
|
+
readonly replace: (invoiceId: string, request: InvoiceRequest, options?: {
|
|
4
|
+
readonly signal?: AbortSignal;
|
|
5
|
+
}) => Promise<InvoiceResource>;
|
|
6
|
+
};
|
|
7
|
+
export declare function createInvoiceReplacement(client: Client): InvoiceReplacement;
|
|
8
|
+
//# sourceMappingURL=invoice-replacement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-replacement.d.ts","sourceRoot":"","sources":["../src/invoice-replacement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIpF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,OAAO,EAAE,CAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,KACxC,OAAO,CAAC,eAAe,CAAC,CAAC;CAC/B,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAe3E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { replaceInvoice as replaceInvoiceOperation, zInvoiceRequest } from "./generated/index.js";
|
|
2
|
+
import { throwGeneratedProblem } from "./generated-problem.js";
|
|
3
|
+
export function createInvoiceReplacement(client) {
|
|
4
|
+
return {
|
|
5
|
+
replace: async (invoiceId, request, options) => {
|
|
6
|
+
const response = await replaceInvoiceOperation({
|
|
7
|
+
client,
|
|
8
|
+
path: { invoiceId },
|
|
9
|
+
body: zInvoiceRequest.parse(request),
|
|
10
|
+
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
11
|
+
});
|
|
12
|
+
if (response.status === 200 || response.status === 201) {
|
|
13
|
+
return response.body;
|
|
14
|
+
}
|
|
15
|
+
throwGeneratedProblem(response, "Invoice replacement failed");
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|