kassza 0.13.0 → 0.14.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.en.md +48 -0
- package/README.md +152 -22
- package/agents/README.md +6 -1
- package/agents/api.md +64 -12
- package/agents/pitfalls.md +12 -1
- package/agents/recipes.md +67 -8
- package/agents/skills/kassza/SKILL.md +3 -0
- package/agents/skills/migrate-from-szamlazz-js/SKILL.md +39 -0
- package/dist/batch/index.cjs +346 -0
- package/dist/batch/index.d.cts +91 -0
- package/dist/batch/index.d.ts +91 -0
- package/dist/batch/index.js +339 -0
- package/dist/cli.cjs +105 -14
- package/dist/cli.js +104 -13
- package/dist/{client-C-PdfL_P.cjs → client-CLFvJCVW.cjs} +358 -181
- package/dist/{client-CfaS1-Jx.js → client-Cvf-hTz_.js} +311 -152
- package/dist/{client-6MkeuFqD.d.ts → client-DeWWQ-RZ.d.ts} +99 -26
- package/dist/{client-B5FryKxJ.d.cts → client-SVZu25MB.d.cts} +99 -26
- package/dist/{context-DXNbTPwz.d.cts → context-CFNKzStE.d.cts} +82 -58
- package/dist/{context-BxQlIlug.d.ts → context-kb33TgzE.d.ts} +82 -58
- package/dist/cookie-stores/index.cjs +21 -150
- package/dist/cookie-stores/index.d.cts +4 -63
- package/dist/cookie-stores/index.d.ts +4 -63
- package/dist/cookie-stores/index.js +3 -144
- package/dist/create-CflXrPip.js +204 -0
- package/dist/create-CvUvLUaT.cjs +257 -0
- package/dist/{create-once-DgMtKKcG.cjs → create-once-9yxR_Er_.cjs} +285 -33
- package/dist/create-once-Bh6fOWkW.d.cts +20 -0
- package/dist/{create-once-Cz621l8r.js → create-once-Ca2gMk1h.js} +250 -34
- package/dist/create-once-VKp0tVow.d.ts +20 -0
- package/dist/data-link/index.cjs +4 -4
- package/dist/data-link/index.d.cts +2 -52
- package/dist/data-link/index.d.ts +2 -52
- package/dist/data-link/index.js +4 -4
- package/dist/delegation/index.cjs +4 -4
- package/dist/delegation/index.d.cts +2 -2
- package/dist/delegation/index.d.ts +2 -2
- package/dist/delegation/index.js +4 -4
- package/dist/{errors-DLrb0g64.js → errors-DtN4g5Z9.js} +9 -1
- package/dist/{errors-DxeuTslP.cjs → errors-EE96_6D_.cjs} +20 -0
- package/dist/{get-Csm2n0rZ.cjs → get-BdMTseh4.cjs} +9 -183
- package/dist/{get-DT3JEgQ6.js → get-CZEShCcj.js} +4 -124
- package/dist/index-BhUPY_EH.d.cts +109 -0
- package/dist/index-BqGgQ4t3.d.ts +109 -0
- package/dist/{index-CYAGCdKJ.d.cts → index-C-7yWV7L.d.cts} +24 -1
- package/dist/{index-CYAGCdKJ.d.ts → index-C-7yWV7L.d.ts} +24 -1
- package/dist/index.cjs +19 -5
- package/dist/index.d.cts +10 -20
- package/dist/index.d.ts +10 -20
- package/dist/index.js +6 -6
- package/dist/ipn/index.cjs +26 -5
- package/dist/ipn/index.d.cts +12 -1
- package/dist/ipn/index.d.ts +12 -1
- package/dist/ipn/index.js +26 -6
- package/dist/{issue-AGRohSm7.cjs → issue-Bin4tKD_.cjs} +416 -342
- package/dist/{issue-DtSLpVdJ.js → issue-DMA1Nbr1.js} +394 -266
- package/dist/journal/index.cjs +454 -0
- package/dist/journal/index.d.cts +18 -0
- package/dist/journal/index.d.ts +18 -0
- package/dist/journal/index.js +445 -0
- package/dist/journal-DvI81Kt7.d.cts +114 -0
- package/dist/journal-Y9qrIB8G.d.ts +114 -0
- package/dist/mcp/index.cjs +1 -1
- package/dist/mcp/index.d.cts +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/money/index.cjs +2 -1
- package/dist/money/index.d.cts +2 -2
- package/dist/money/index.d.ts +2 -2
- package/dist/money/index.js +2 -2
- package/dist/{money-t7uy1n91.js → money-Cw457SD6.js} +95 -3
- package/dist/{money-BxytJW6f.cjs → money-K9j0wPit.cjs} +99 -1
- package/dist/nav/index.cjs +2 -2
- package/dist/nav/index.d.cts +1 -1
- package/dist/nav/index.d.ts +1 -1
- package/dist/nav/index.js +2 -2
- package/dist/{nav-BEwcX7-N.cjs → nav-BNbc8U0R.cjs} +1 -1
- package/dist/{nav-CK1WgYo7.js → nav-BcCerwWS.js} +1 -1
- package/dist/node/index.cjs +124 -0
- package/dist/node/index.d.cts +35 -0
- package/dist/node/index.d.ts +35 -0
- package/dist/node/index.js +120 -0
- package/dist/observe/index.cjs +311 -0
- package/dist/observe/index.d.cts +53 -0
- package/dist/observe/index.d.ts +53 -0
- package/dist/observe/index.js +303 -0
- package/dist/once-BN_3B5OF.cjs +103 -0
- package/dist/once-CqqZxsXG.js +74 -0
- package/dist/{parse-C608ehqM.js → parse-Cr7yQ3_z.js} +2 -2
- package/dist/{parse-BJj-aqKy.cjs → parse-DOA2XQ3e.cjs} +2 -2
- package/dist/payments/barion.cjs +26 -2
- package/dist/payments/barion.d.cts +2 -2
- package/dist/payments/barion.d.ts +2 -2
- package/dist/payments/barion.js +26 -2
- package/dist/payments/index.cjs +7 -2
- package/dist/payments/index.d.cts +4 -4
- package/dist/payments/index.d.ts +4 -4
- package/dist/payments/index.js +3 -3
- package/dist/payments/paypal.cjs +16 -2
- package/dist/payments/paypal.d.cts +2 -2
- package/dist/payments/paypal.d.ts +2 -2
- package/dist/payments/paypal.js +16 -2
- package/dist/payments/revolut.cjs +16 -2
- package/dist/payments/revolut.d.cts +2 -2
- package/dist/payments/revolut.d.ts +2 -2
- package/dist/payments/revolut.js +16 -2
- package/dist/payments/simplepay.cjs +36 -4
- package/dist/payments/simplepay.d.cts +2 -2
- package/dist/payments/simplepay.d.ts +2 -2
- package/dist/payments/simplepay.js +36 -4
- package/dist/payments/stripe.cjs +19 -2
- package/dist/payments/stripe.d.cts +2 -2
- package/dist/payments/stripe.d.ts +2 -2
- package/dist/payments/stripe.js +19 -2
- package/dist/push-BXj0Sf0Z.d.ts +52 -0
- package/dist/push-D4nNbCNV.d.cts +52 -0
- package/dist/reference-B5TATqb5.js +124 -0
- package/dist/reference-BIdYMK0t.cjs +183 -0
- package/dist/reports/index.cjs +1 -1
- package/dist/reports/index.d.cts +1 -1
- package/dist/reports/index.d.ts +1 -1
- package/dist/reports/index.js +1 -1
- package/dist/{serialize-DSE_o9RK.js → serialize-B2eFh3D-.js} +5 -1
- package/dist/{serialize-BXOww1Uq.cjs → serialize-CquIsxA-.cjs} +5 -1
- package/dist/{server-Cd8HB661.js → server-BrJUbXs7.js} +8 -7
- package/dist/{server-C6PoNkdD.cjs → server-Dw9j8Mnd.cjs} +17 -16
- package/dist/session-Ckl5eJhV.d.ts +7 -0
- package/dist/{session-CKOuE6Jc.cjs → session-DeM5vjvC.cjs} +69 -13
- package/dist/{session-rMKaJcmq.js → session-SaEEXu2N.js} +58 -14
- package/dist/session-YbChChx7.d.cts +7 -0
- package/dist/storage/fs.cjs +1 -1
- package/dist/storage/fs.js +1 -1
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/store-C1rHd9DB.d.cts +19 -0
- package/dist/store-C1rHd9DB.d.ts +19 -0
- package/dist/stores/index.cjs +24 -0
- package/dist/stores/index.d.cts +4 -0
- package/dist/stores/index.d.ts +4 -0
- package/dist/stores/index.js +3 -0
- package/dist/stores-BNrS0dWl.cjs +506 -0
- package/dist/stores-DhjGBrl_.js +441 -0
- package/dist/testing/index.cjs +28 -16
- package/dist/testing/index.d.cts +6 -3
- package/dist/testing/index.d.ts +6 -3
- package/dist/testing/index.js +26 -14
- package/dist/{types-BVeR7KyU.d.ts → types-B1A8mUIE.d.cts} +13 -1
- package/dist/{types-BVeR7KyU.d.cts → types-ByAEvGsZ.d.ts} +13 -1
- package/dist/{types-k--zHf4l.d.ts → types-D1zDOH_F.d.ts} +1 -1
- package/dist/{types-DH8QoNZK.d.cts → types-lnKkQdot.d.cts} +1 -1
- package/dist/warnings-B3DXnveC.d.cts +31 -0
- package/dist/warnings-B3DXnveC.d.ts +31 -0
- package/dist/warnings-DeIw5RFj.cjs +20 -0
- package/dist/warnings-DwTl5J-2.js +15 -0
- package/dist/{webhook-CrEGohbg.js → webhook-CQVShAfI.js} +44 -1
- package/dist/{webhook-81giRMdQ.cjs → webhook-Ckj-_hPD.cjs} +67 -0
- package/dist/webhook-CmdhGiH5.d.cts +11 -0
- package/dist/webhook-D6lEejob.d.ts +11 -0
- package/llms.txt +4 -3
- package/package.json +92 -4
- package/dist/session-Dm_45x8K.d.cts +0 -11
- package/dist/session-Dm_45x8K.d.ts +0 -11
- package/dist/webhook-CpCMHhn2.d.ts +0 -6
- package/dist/webhook-CpMJuP6c.d.cts +0 -6
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
1
|
+
import { t as DateInput } from "./dates-9zvESP0i.js";
|
|
2
|
+
import { B as InvoiceLanguage, C as ClearPaymentsInput, E as RegisteredPayment, H as InvoicePreview, L as InvoiceBuyer, M as CreateInvoiceInput, N as CreatedInvoice, R as InvoiceDefaults, S as ReversedInvoice, T as RegisterPaymentInput, U as InvoiceSeller, W as InvoiceTemplate, X as StandardInvoiceInput, l as SzamlazzOptions, s as RequestOptions, st as SzamlazzError, x as ReverseInvoiceInput } from "./context-kb33TgzE.js";
|
|
3
|
+
import { n as KeyValueStore } from "./store-C1rHd9DB.js";
|
|
4
|
+
import { S as VatRate, a as RefundAllocation, s as RefundableItem } from "./index-C-7yWV7L.js";
|
|
5
|
+
import { h as SendReceiptInput, i as ReceiptDefaults, m as ReverseReceiptInput, n as GetReceiptInput, p as ReceiptVatRate, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput } from "./types-D1zDOH_F.js";
|
|
6
|
+
import { n as InvoiceDetails, o as InvoiceDetailsPayment, t as GetInvoiceOptions } from "./get-Byc9T5WO.js";
|
|
7
|
+
import { n as InvoiceOnceResult, t as ReceiptOnceResult } from "./create-once-VKp0tVow.js";
|
|
8
|
+
import { i as PaymentEvent, l as PaymentRefund, r as PaymentCustomer, s as PaymentLineItem } from "./types-ByAEvGsZ.js";
|
|
9
|
+
//#region src/core/once-guard.d.ts
|
|
10
|
+
declare const ONCE_LOCK_KEY_PREFIX = "szamlazz:once:";
|
|
11
|
+
declare const DEFAULT_LOCK_TTL_SECONDS = 600;
|
|
12
|
+
declare const DEFAULT_LOCK_WAIT_MS = 1e4;
|
|
13
|
+
type LockFailureMode = "throw" | "proceed";
|
|
14
|
+
interface OnceLockOptions {
|
|
15
|
+
readonly lock?: KeyValueStore | false | undefined;
|
|
16
|
+
readonly lockTtlSeconds?: number | undefined;
|
|
17
|
+
readonly lockWaitMs?: number | undefined;
|
|
18
|
+
readonly lockFailure?: LockFailureMode | undefined;
|
|
19
|
+
readonly signal?: AbortSignal | undefined;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/core/once.d.ts
|
|
23
|
+
interface CreateOnceOptions extends RequestOptions, OnceLockOptions {
|
|
24
|
+
readonly lookupFirst?: boolean | undefined;
|
|
25
|
+
readonly matchOrderNumber?: boolean | undefined;
|
|
26
|
+
readonly recoveryDelayMs?: number | undefined;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
6
29
|
//#region src/invoices/reference.d.ts
|
|
7
30
|
type InvoiceReference = string | {
|
|
8
31
|
readonly invoiceNumber: string;
|
|
@@ -12,22 +35,25 @@ type InvoiceReference = string | {
|
|
|
12
35
|
readonly externalId: string;
|
|
13
36
|
};
|
|
14
37
|
//#endregion
|
|
15
|
-
//#region src/
|
|
16
|
-
interface
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
38
|
+
//#region src/invoices/payment-once.d.ts
|
|
39
|
+
interface RegisterPaymentOnceInput {
|
|
40
|
+
readonly invoiceNumber: string;
|
|
41
|
+
readonly key: string;
|
|
42
|
+
readonly amount: number;
|
|
43
|
+
readonly method?: string | undefined;
|
|
44
|
+
readonly date?: DateInput | undefined;
|
|
45
|
+
readonly description?: string | undefined;
|
|
46
|
+
readonly taxNumber?: string | undefined;
|
|
20
47
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
readonly
|
|
48
|
+
interface RegisteredPaymentOnce {
|
|
49
|
+
readonly invoiceNumber: string;
|
|
50
|
+
readonly key: string;
|
|
51
|
+
readonly marker: string;
|
|
25
52
|
readonly created: boolean;
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
readonly details?: InvoiceDetails | undefined;
|
|
53
|
+
readonly payment?: RegisteredPayment | undefined;
|
|
54
|
+
readonly existing?: InvoiceDetailsPayment | undefined;
|
|
29
55
|
}
|
|
30
|
-
declare function
|
|
56
|
+
declare function paymentMarker(key: string): string;
|
|
31
57
|
//#endregion
|
|
32
58
|
//#region src/invoices/pdf.d.ts
|
|
33
59
|
interface InvoicePdf {
|
|
@@ -70,6 +96,44 @@ interface DocumentDecision {
|
|
|
70
96
|
}
|
|
71
97
|
declare function chooseDocument(input: ChooseDocumentInput): DocumentDecision;
|
|
72
98
|
//#endregion
|
|
99
|
+
//#region src/payments/partial-refund.d.ts
|
|
100
|
+
type PartialRefundMode = "auto" | "proportional" | "skip";
|
|
101
|
+
interface RefundItemsContext {
|
|
102
|
+
readonly refund: PaymentRefund;
|
|
103
|
+
readonly invoiceNumber: string;
|
|
104
|
+
readonly items: readonly RefundableItem[];
|
|
105
|
+
}
|
|
106
|
+
type RefundItemsResolver = (context: RefundItemsContext) => readonly PaymentDocumentItem[] | undefined | Promise<readonly PaymentDocumentItem[] | undefined>;
|
|
107
|
+
interface IssuedRefundCorrection {
|
|
108
|
+
readonly refundId: string;
|
|
109
|
+
readonly externalId: string;
|
|
110
|
+
readonly number: string;
|
|
111
|
+
readonly created: boolean;
|
|
112
|
+
readonly grossTotal: number;
|
|
113
|
+
readonly invoice: InvoiceOnceResult;
|
|
114
|
+
}
|
|
115
|
+
interface IssuedCorrection {
|
|
116
|
+
readonly kind: "correction";
|
|
117
|
+
readonly orderNumber: string;
|
|
118
|
+
readonly correctedNumber: string;
|
|
119
|
+
readonly created: boolean;
|
|
120
|
+
readonly corrections: readonly IssuedRefundCorrection[];
|
|
121
|
+
}
|
|
122
|
+
interface RefundProposalLine {
|
|
123
|
+
readonly refundId: string;
|
|
124
|
+
readonly grossTotal: number;
|
|
125
|
+
readonly items: readonly RefundAllocation<ReceiptVatRate>[];
|
|
126
|
+
}
|
|
127
|
+
interface IssuedRefundProposal {
|
|
128
|
+
readonly kind: "refund-proposal";
|
|
129
|
+
readonly orderNumber: string;
|
|
130
|
+
readonly document: "receipt" | "invoice";
|
|
131
|
+
readonly documentNumber: string;
|
|
132
|
+
readonly refunds: readonly RefundProposalLine[];
|
|
133
|
+
readonly reason: string;
|
|
134
|
+
}
|
|
135
|
+
declare function correctionExternalId(orderNumber: string, refundId: string): Promise<string>;
|
|
136
|
+
//#endregion
|
|
73
137
|
//#region src/payments/issue.d.ts
|
|
74
138
|
interface PaymentDocumentItem {
|
|
75
139
|
readonly name: string;
|
|
@@ -96,6 +160,8 @@ interface IssueForPaymentOptions {
|
|
|
96
160
|
readonly exchangeRate?: number | undefined;
|
|
97
161
|
readonly exchangeBank?: string | undefined;
|
|
98
162
|
readonly allowAmountMismatch?: boolean | undefined;
|
|
163
|
+
readonly partialRefund?: PartialRefundMode | undefined;
|
|
164
|
+
readonly refundItems?: RefundItemsResolver | undefined;
|
|
99
165
|
readonly receipt?: Partial<Omit<CreateReceiptInput, "items" | "orderNumber" | "callId" | "currency" | "exchangeRate" | "exchangeBank">> | undefined;
|
|
100
166
|
readonly invoice?: Partial<Omit<StandardInvoiceInput, "items" | "buyer" | "type" | "orderNumber" | "paid" | "currency" | "exchangeRate" | "exchangeBank" | "externalId">> | undefined;
|
|
101
167
|
readonly recoveryDelayMs?: number | undefined;
|
|
@@ -130,7 +196,7 @@ interface SkippedPayment {
|
|
|
130
196
|
readonly orderNumber: string;
|
|
131
197
|
readonly reason: string;
|
|
132
198
|
}
|
|
133
|
-
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | SkippedPayment;
|
|
199
|
+
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | IssuedCorrection | IssuedRefundProposal | SkippedPayment;
|
|
134
200
|
interface PaymentDocumentsApi {
|
|
135
201
|
readonly invoices: Pick<InvoicesApi, "createOnce" | "find" | "reverse">;
|
|
136
202
|
readonly receipts: Pick<ReceiptsApi, "createOnce" | "find" | "reverse">;
|
|
@@ -161,12 +227,6 @@ interface ConvertedReceipt {
|
|
|
161
227
|
}
|
|
162
228
|
declare function conversionExternalId(receiptNumber: string): string;
|
|
163
229
|
//#endregion
|
|
164
|
-
//#region src/receipts/create-once.d.ts
|
|
165
|
-
interface ReceiptOnceResult {
|
|
166
|
-
readonly receipt: Receipt;
|
|
167
|
-
readonly created: boolean;
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
230
|
//#region src/taxpayer/address.d.ts
|
|
171
231
|
type TaxpayerAddressType = "HQ" | "SITE" | "BRANCH" | (string & {});
|
|
172
232
|
interface NavDetailedAddress {
|
|
@@ -222,6 +282,16 @@ interface TaxpayerInfo {
|
|
|
222
282
|
readonly requestId?: string | undefined;
|
|
223
283
|
}
|
|
224
284
|
//#endregion
|
|
285
|
+
//#region src/taxpayer/cache.d.ts
|
|
286
|
+
declare const TAXPAYER_CACHE_KEY_PREFIX = "szamlazz:taxpayer:";
|
|
287
|
+
declare const DEFAULT_TAXPAYER_TTL_SECONDS = 86400;
|
|
288
|
+
declare const DEFAULT_TAXPAYER_INVALID_TTL_SECONDS = 600;
|
|
289
|
+
interface TaxpayerCacheOptions {
|
|
290
|
+
readonly store: KeyValueStore;
|
|
291
|
+
readonly ttlSeconds?: number | undefined;
|
|
292
|
+
readonly invalidTtlSeconds?: number | undefined;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
225
295
|
//#region src/client.d.ts
|
|
226
296
|
interface KasszaDefaults {
|
|
227
297
|
readonly invoice?: InvoiceDefaults;
|
|
@@ -229,6 +299,8 @@ interface KasszaDefaults {
|
|
|
229
299
|
}
|
|
230
300
|
interface KasszaOptions extends SzamlazzOptions {
|
|
231
301
|
readonly defaults?: KasszaDefaults;
|
|
302
|
+
readonly createOnceLock?: KeyValueStore | undefined;
|
|
303
|
+
readonly taxpayerCache?: TaxpayerCacheOptions | undefined;
|
|
232
304
|
}
|
|
233
305
|
interface InvoicesApi {
|
|
234
306
|
create(input: CreateInvoiceInput, options?: RequestOptions): Promise<CreatedInvoice>;
|
|
@@ -236,6 +308,7 @@ interface InvoicesApi {
|
|
|
236
308
|
preview(input: CreateInvoiceInput, options?: RequestOptions): Promise<InvoicePreview>;
|
|
237
309
|
reverse(input: ReverseInvoiceInput, options?: RequestOptions): Promise<ReversedInvoice>;
|
|
238
310
|
registerPayment(input: RegisterPaymentInput, options?: RequestOptions): Promise<RegisteredPayment>;
|
|
311
|
+
registerPaymentOnce(input: RegisterPaymentOnceInput, options?: CreateOnceOptions): Promise<RegisteredPaymentOnce>;
|
|
239
312
|
clearPayments(input: ClearPaymentsInput, options?: RequestOptions): Promise<RegisteredPayment>;
|
|
240
313
|
getPdf(reference: InvoiceReference, options?: RequestOptions): Promise<InvoicePdf>;
|
|
241
314
|
get(reference: InvoiceReference, query?: GetInvoiceOptions, options?: RequestOptions): Promise<InvoiceDetails>;
|
|
@@ -265,4 +338,4 @@ interface Kassza {
|
|
|
265
338
|
}
|
|
266
339
|
declare function createKassza(options?: KasszaOptions): Kassza;
|
|
267
340
|
//#endregion
|
|
268
|
-
export {
|
|
341
|
+
export { ONCE_LOCK_KEY_PREFIX as $, IssuedRefundCorrection as A, DocumentDecision as B, PaymentDocumentItem as C, issueForPayment as D, buyerFromCustomer as E, RefundProposalLine as F, RegisterPaymentOnceInput as G, chooseDocument as H, correctionExternalId as I, InvoiceReference as J, RegisteredPaymentOnce as K, ChooseDocumentBuyer as L, PartialRefundMode as M, RefundItemsContext as N, paymentOrderNumber as O, RefundItemsResolver as P, LockFailureMode as Q, ChooseDocumentInput as R, IssuedReversal as S, SkippedPayment as T, ProformaReference as U, RECEIPT_MAX_GROSS_HUF as V, InvoicePdf as W, DEFAULT_LOCK_TTL_SECONDS as X, CreateOnceOptions as Y, DEFAULT_LOCK_WAIT_MS as Z, conversionExternalId as _, ReceiptsApi as a, IssuedInvoice as b, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS as c, TaxpayerCacheOptions as d, OnceLockOptions as et, TaxpayerInfo as f, ConvertedReceipt as g, ConvertReceiptInput as h, KasszaOptions as i, IssuedRefundProposal as j, IssuedCorrection as k, DEFAULT_TAXPAYER_TTL_SECONDS as l, TaxpayerAddress as m, Kassza as n, TaxpayerApi as o, TaxpayerTaxNumber as p, paymentMarker as q, KasszaDefaults as r, createKassza as s, InvoicesApi as t, TAXPAYER_CACHE_KEY_PREFIX as u, IssueForPaymentOptions as v, PaymentDocumentsApi as w, IssuedReceipt as x, IssuedDocument as y, DocumentChoice as z };
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
1
|
+
import { t as DateInput } from "./dates-9zvESP0i.cjs";
|
|
2
|
+
import { B as InvoiceLanguage, C as ClearPaymentsInput, E as RegisteredPayment, H as InvoicePreview, L as InvoiceBuyer, M as CreateInvoiceInput, N as CreatedInvoice, R as InvoiceDefaults, S as ReversedInvoice, T as RegisterPaymentInput, U as InvoiceSeller, W as InvoiceTemplate, X as StandardInvoiceInput, l as SzamlazzOptions, s as RequestOptions, st as SzamlazzError, x as ReverseInvoiceInput } from "./context-CFNKzStE.cjs";
|
|
3
|
+
import { n as KeyValueStore } from "./store-C1rHd9DB.cjs";
|
|
4
|
+
import { S as VatRate, a as RefundAllocation, s as RefundableItem } from "./index-C-7yWV7L.cjs";
|
|
5
|
+
import { h as SendReceiptInput, i as ReceiptDefaults, m as ReverseReceiptInput, n as GetReceiptInput, p as ReceiptVatRate, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput } from "./types-lnKkQdot.cjs";
|
|
6
|
+
import { n as InvoiceDetails, o as InvoiceDetailsPayment, t as GetInvoiceOptions } from "./get-Byc9T5WO.cjs";
|
|
7
|
+
import { n as InvoiceOnceResult, t as ReceiptOnceResult } from "./create-once-Bh6fOWkW.cjs";
|
|
8
|
+
import { i as PaymentEvent, l as PaymentRefund, r as PaymentCustomer, s as PaymentLineItem } from "./types-B1A8mUIE.cjs";
|
|
9
|
+
//#region src/core/once-guard.d.ts
|
|
10
|
+
declare const ONCE_LOCK_KEY_PREFIX = "szamlazz:once:";
|
|
11
|
+
declare const DEFAULT_LOCK_TTL_SECONDS = 600;
|
|
12
|
+
declare const DEFAULT_LOCK_WAIT_MS = 1e4;
|
|
13
|
+
type LockFailureMode = "throw" | "proceed";
|
|
14
|
+
interface OnceLockOptions {
|
|
15
|
+
readonly lock?: KeyValueStore | false | undefined;
|
|
16
|
+
readonly lockTtlSeconds?: number | undefined;
|
|
17
|
+
readonly lockWaitMs?: number | undefined;
|
|
18
|
+
readonly lockFailure?: LockFailureMode | undefined;
|
|
19
|
+
readonly signal?: AbortSignal | undefined;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/core/once.d.ts
|
|
23
|
+
interface CreateOnceOptions extends RequestOptions, OnceLockOptions {
|
|
24
|
+
readonly lookupFirst?: boolean | undefined;
|
|
25
|
+
readonly matchOrderNumber?: boolean | undefined;
|
|
26
|
+
readonly recoveryDelayMs?: number | undefined;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
6
29
|
//#region src/invoices/reference.d.ts
|
|
7
30
|
type InvoiceReference = string | {
|
|
8
31
|
readonly invoiceNumber: string;
|
|
@@ -12,22 +35,25 @@ type InvoiceReference = string | {
|
|
|
12
35
|
readonly externalId: string;
|
|
13
36
|
};
|
|
14
37
|
//#endregion
|
|
15
|
-
//#region src/
|
|
16
|
-
interface
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
38
|
+
//#region src/invoices/payment-once.d.ts
|
|
39
|
+
interface RegisterPaymentOnceInput {
|
|
40
|
+
readonly invoiceNumber: string;
|
|
41
|
+
readonly key: string;
|
|
42
|
+
readonly amount: number;
|
|
43
|
+
readonly method?: string | undefined;
|
|
44
|
+
readonly date?: DateInput | undefined;
|
|
45
|
+
readonly description?: string | undefined;
|
|
46
|
+
readonly taxNumber?: string | undefined;
|
|
20
47
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
readonly
|
|
48
|
+
interface RegisteredPaymentOnce {
|
|
49
|
+
readonly invoiceNumber: string;
|
|
50
|
+
readonly key: string;
|
|
51
|
+
readonly marker: string;
|
|
25
52
|
readonly created: boolean;
|
|
26
|
-
readonly
|
|
27
|
-
readonly
|
|
28
|
-
readonly details?: InvoiceDetails | undefined;
|
|
53
|
+
readonly payment?: RegisteredPayment | undefined;
|
|
54
|
+
readonly existing?: InvoiceDetailsPayment | undefined;
|
|
29
55
|
}
|
|
30
|
-
declare function
|
|
56
|
+
declare function paymentMarker(key: string): string;
|
|
31
57
|
//#endregion
|
|
32
58
|
//#region src/invoices/pdf.d.ts
|
|
33
59
|
interface InvoicePdf {
|
|
@@ -70,6 +96,44 @@ interface DocumentDecision {
|
|
|
70
96
|
}
|
|
71
97
|
declare function chooseDocument(input: ChooseDocumentInput): DocumentDecision;
|
|
72
98
|
//#endregion
|
|
99
|
+
//#region src/payments/partial-refund.d.ts
|
|
100
|
+
type PartialRefundMode = "auto" | "proportional" | "skip";
|
|
101
|
+
interface RefundItemsContext {
|
|
102
|
+
readonly refund: PaymentRefund;
|
|
103
|
+
readonly invoiceNumber: string;
|
|
104
|
+
readonly items: readonly RefundableItem[];
|
|
105
|
+
}
|
|
106
|
+
type RefundItemsResolver = (context: RefundItemsContext) => readonly PaymentDocumentItem[] | undefined | Promise<readonly PaymentDocumentItem[] | undefined>;
|
|
107
|
+
interface IssuedRefundCorrection {
|
|
108
|
+
readonly refundId: string;
|
|
109
|
+
readonly externalId: string;
|
|
110
|
+
readonly number: string;
|
|
111
|
+
readonly created: boolean;
|
|
112
|
+
readonly grossTotal: number;
|
|
113
|
+
readonly invoice: InvoiceOnceResult;
|
|
114
|
+
}
|
|
115
|
+
interface IssuedCorrection {
|
|
116
|
+
readonly kind: "correction";
|
|
117
|
+
readonly orderNumber: string;
|
|
118
|
+
readonly correctedNumber: string;
|
|
119
|
+
readonly created: boolean;
|
|
120
|
+
readonly corrections: readonly IssuedRefundCorrection[];
|
|
121
|
+
}
|
|
122
|
+
interface RefundProposalLine {
|
|
123
|
+
readonly refundId: string;
|
|
124
|
+
readonly grossTotal: number;
|
|
125
|
+
readonly items: readonly RefundAllocation<ReceiptVatRate>[];
|
|
126
|
+
}
|
|
127
|
+
interface IssuedRefundProposal {
|
|
128
|
+
readonly kind: "refund-proposal";
|
|
129
|
+
readonly orderNumber: string;
|
|
130
|
+
readonly document: "receipt" | "invoice";
|
|
131
|
+
readonly documentNumber: string;
|
|
132
|
+
readonly refunds: readonly RefundProposalLine[];
|
|
133
|
+
readonly reason: string;
|
|
134
|
+
}
|
|
135
|
+
declare function correctionExternalId(orderNumber: string, refundId: string): Promise<string>;
|
|
136
|
+
//#endregion
|
|
73
137
|
//#region src/payments/issue.d.ts
|
|
74
138
|
interface PaymentDocumentItem {
|
|
75
139
|
readonly name: string;
|
|
@@ -96,6 +160,8 @@ interface IssueForPaymentOptions {
|
|
|
96
160
|
readonly exchangeRate?: number | undefined;
|
|
97
161
|
readonly exchangeBank?: string | undefined;
|
|
98
162
|
readonly allowAmountMismatch?: boolean | undefined;
|
|
163
|
+
readonly partialRefund?: PartialRefundMode | undefined;
|
|
164
|
+
readonly refundItems?: RefundItemsResolver | undefined;
|
|
99
165
|
readonly receipt?: Partial<Omit<CreateReceiptInput, "items" | "orderNumber" | "callId" | "currency" | "exchangeRate" | "exchangeBank">> | undefined;
|
|
100
166
|
readonly invoice?: Partial<Omit<StandardInvoiceInput, "items" | "buyer" | "type" | "orderNumber" | "paid" | "currency" | "exchangeRate" | "exchangeBank" | "externalId">> | undefined;
|
|
101
167
|
readonly recoveryDelayMs?: number | undefined;
|
|
@@ -130,7 +196,7 @@ interface SkippedPayment {
|
|
|
130
196
|
readonly orderNumber: string;
|
|
131
197
|
readonly reason: string;
|
|
132
198
|
}
|
|
133
|
-
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | SkippedPayment;
|
|
199
|
+
type IssuedDocument = IssuedReceipt | IssuedInvoice | IssuedReversal | IssuedCorrection | IssuedRefundProposal | SkippedPayment;
|
|
134
200
|
interface PaymentDocumentsApi {
|
|
135
201
|
readonly invoices: Pick<InvoicesApi, "createOnce" | "find" | "reverse">;
|
|
136
202
|
readonly receipts: Pick<ReceiptsApi, "createOnce" | "find" | "reverse">;
|
|
@@ -161,12 +227,6 @@ interface ConvertedReceipt {
|
|
|
161
227
|
}
|
|
162
228
|
declare function conversionExternalId(receiptNumber: string): string;
|
|
163
229
|
//#endregion
|
|
164
|
-
//#region src/receipts/create-once.d.ts
|
|
165
|
-
interface ReceiptOnceResult {
|
|
166
|
-
readonly receipt: Receipt;
|
|
167
|
-
readonly created: boolean;
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
230
|
//#region src/taxpayer/address.d.ts
|
|
171
231
|
type TaxpayerAddressType = "HQ" | "SITE" | "BRANCH" | (string & {});
|
|
172
232
|
interface NavDetailedAddress {
|
|
@@ -222,6 +282,16 @@ interface TaxpayerInfo {
|
|
|
222
282
|
readonly requestId?: string | undefined;
|
|
223
283
|
}
|
|
224
284
|
//#endregion
|
|
285
|
+
//#region src/taxpayer/cache.d.ts
|
|
286
|
+
declare const TAXPAYER_CACHE_KEY_PREFIX = "szamlazz:taxpayer:";
|
|
287
|
+
declare const DEFAULT_TAXPAYER_TTL_SECONDS = 86400;
|
|
288
|
+
declare const DEFAULT_TAXPAYER_INVALID_TTL_SECONDS = 600;
|
|
289
|
+
interface TaxpayerCacheOptions {
|
|
290
|
+
readonly store: KeyValueStore;
|
|
291
|
+
readonly ttlSeconds?: number | undefined;
|
|
292
|
+
readonly invalidTtlSeconds?: number | undefined;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
225
295
|
//#region src/client.d.ts
|
|
226
296
|
interface KasszaDefaults {
|
|
227
297
|
readonly invoice?: InvoiceDefaults;
|
|
@@ -229,6 +299,8 @@ interface KasszaDefaults {
|
|
|
229
299
|
}
|
|
230
300
|
interface KasszaOptions extends SzamlazzOptions {
|
|
231
301
|
readonly defaults?: KasszaDefaults;
|
|
302
|
+
readonly createOnceLock?: KeyValueStore | undefined;
|
|
303
|
+
readonly taxpayerCache?: TaxpayerCacheOptions | undefined;
|
|
232
304
|
}
|
|
233
305
|
interface InvoicesApi {
|
|
234
306
|
create(input: CreateInvoiceInput, options?: RequestOptions): Promise<CreatedInvoice>;
|
|
@@ -236,6 +308,7 @@ interface InvoicesApi {
|
|
|
236
308
|
preview(input: CreateInvoiceInput, options?: RequestOptions): Promise<InvoicePreview>;
|
|
237
309
|
reverse(input: ReverseInvoiceInput, options?: RequestOptions): Promise<ReversedInvoice>;
|
|
238
310
|
registerPayment(input: RegisterPaymentInput, options?: RequestOptions): Promise<RegisteredPayment>;
|
|
311
|
+
registerPaymentOnce(input: RegisterPaymentOnceInput, options?: CreateOnceOptions): Promise<RegisteredPaymentOnce>;
|
|
239
312
|
clearPayments(input: ClearPaymentsInput, options?: RequestOptions): Promise<RegisteredPayment>;
|
|
240
313
|
getPdf(reference: InvoiceReference, options?: RequestOptions): Promise<InvoicePdf>;
|
|
241
314
|
get(reference: InvoiceReference, query?: GetInvoiceOptions, options?: RequestOptions): Promise<InvoiceDetails>;
|
|
@@ -265,4 +338,4 @@ interface Kassza {
|
|
|
265
338
|
}
|
|
266
339
|
declare function createKassza(options?: KasszaOptions): Kassza;
|
|
267
340
|
//#endregion
|
|
268
|
-
export {
|
|
341
|
+
export { ONCE_LOCK_KEY_PREFIX as $, IssuedRefundCorrection as A, DocumentDecision as B, PaymentDocumentItem as C, issueForPayment as D, buyerFromCustomer as E, RefundProposalLine as F, RegisterPaymentOnceInput as G, chooseDocument as H, correctionExternalId as I, InvoiceReference as J, RegisteredPaymentOnce as K, ChooseDocumentBuyer as L, PartialRefundMode as M, RefundItemsContext as N, paymentOrderNumber as O, RefundItemsResolver as P, LockFailureMode as Q, ChooseDocumentInput as R, IssuedReversal as S, SkippedPayment as T, ProformaReference as U, RECEIPT_MAX_GROSS_HUF as V, InvoicePdf as W, DEFAULT_LOCK_TTL_SECONDS as X, CreateOnceOptions as Y, DEFAULT_LOCK_WAIT_MS as Z, conversionExternalId as _, ReceiptsApi as a, IssuedInvoice as b, DEFAULT_TAXPAYER_INVALID_TTL_SECONDS as c, TaxpayerCacheOptions as d, OnceLockOptions as et, TaxpayerInfo as f, ConvertedReceipt as g, ConvertReceiptInput as h, KasszaOptions as i, IssuedRefundProposal as j, IssuedCorrection as k, DEFAULT_TAXPAYER_TTL_SECONDS as l, TaxpayerAddress as m, Kassza as n, TaxpayerApi as o, TaxpayerTaxNumber as p, paymentMarker as q, KasszaDefaults as r, createKassza as s, InvoicesApi as t, TAXPAYER_CACHE_KEY_PREFIX as u, IssueForPaymentOptions as v, PaymentDocumentsApi as w, IssuedReceipt as x, IssuedDocument as y, DocumentChoice as z };
|
|
@@ -1,25 +1,60 @@
|
|
|
1
|
-
import { t as CookieStore } from "./session-Dm_45x8K.cjs";
|
|
2
1
|
import { t as DateInput } from "./dates-9zvESP0i.cjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
import { a as AgentAction, r as WarningHook, t as KasszaWarning } from "./warnings-B3DXnveC.cjs";
|
|
3
|
+
import { n as KeyValueStore } from "./store-C1rHd9DB.cjs";
|
|
4
|
+
import { d as ItemAmounts, f as ItemPriceInput } from "./index-C-7yWV7L.cjs";
|
|
5
|
+
import { r as Receipt } from "./types-lnKkQdot.cjs";
|
|
6
|
+
import { t as CookieStore } from "./session-YbChChx7.cjs";
|
|
7
|
+
//#region src/core/errors.d.ts
|
|
8
|
+
type SzamlazzErrorCategory = "auth" | "account" | "validation" | "duplicate" | "partial_success" | "not_found" | "maintenance" | "rate_limit" | "attempt_limit" | "in_progress" | "store_unavailable" | "network" | "timeout" | "configuration" | "unexpected_response" | "unknown";
|
|
9
|
+
interface AgentErrorCodeInfo {
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly category: SzamlazzErrorCategory;
|
|
12
|
+
readonly hint?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const AGENT_ERROR_CODES: Readonly<Record<number, AgentErrorCodeInfo>>;
|
|
15
|
+
declare const KASSZA_ERROR_DOCS_URL = "https://kasszajs.hu/docs/hibakodok";
|
|
16
|
+
declare function errorCodeDocsUrl(code: number | undefined): string | undefined;
|
|
17
|
+
interface SzamlazzErrorOptions {
|
|
18
|
+
readonly category: SzamlazzErrorCategory;
|
|
19
|
+
readonly code?: number | undefined;
|
|
20
|
+
readonly hint?: string | undefined;
|
|
21
|
+
readonly action?: AgentAction | undefined;
|
|
22
|
+
readonly httpStatus?: number | undefined;
|
|
23
|
+
readonly rawResponse?: string | undefined;
|
|
24
|
+
readonly details?: Readonly<Record<string, string>> | undefined;
|
|
25
|
+
readonly cause?: unknown;
|
|
26
|
+
}
|
|
27
|
+
declare class SzamlazzError extends Error {
|
|
28
|
+
override readonly name: string;
|
|
29
|
+
readonly code: number | undefined;
|
|
30
|
+
readonly category: SzamlazzErrorCategory;
|
|
31
|
+
readonly retryable: boolean;
|
|
32
|
+
readonly hint: string | undefined;
|
|
33
|
+
readonly action: AgentAction | undefined;
|
|
34
|
+
readonly httpStatus: number | undefined;
|
|
35
|
+
readonly rawResponse: string | undefined;
|
|
36
|
+
readonly details: Readonly<Record<string, string>> | undefined;
|
|
37
|
+
constructor(message: string, options: SzamlazzErrorOptions);
|
|
38
|
+
get docsUrl(): string | undefined;
|
|
39
|
+
get isDuplicate(): boolean;
|
|
40
|
+
get isNotFound(): boolean;
|
|
41
|
+
}
|
|
42
|
+
declare function isSzamlazzError(error: unknown): error is SzamlazzError;
|
|
43
|
+
declare function suggestedPrefix(error: unknown): string | undefined;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/core/attempt-ledger.d.ts
|
|
46
|
+
declare const ATTEMPT_LEDGER_TTL_SECONDS = 86400;
|
|
47
|
+
declare const ATTEMPT_LEDGER_KEY_PREFIX = "szamlazz:attempts:";
|
|
48
|
+
interface AttemptLedgerRequest {
|
|
49
|
+
readonly action: AgentAction;
|
|
50
|
+
readonly xml: string;
|
|
51
|
+
readonly attachments?: readonly {
|
|
52
|
+
readonly filename: string;
|
|
53
|
+
readonly size: number;
|
|
54
|
+
}[];
|
|
55
|
+
}
|
|
56
|
+
declare function attemptLedgerKey(request: AttemptLedgerRequest): Promise<string>;
|
|
57
|
+
type AttemptLedgerMode = "fail-open" | "fail-closed";
|
|
23
58
|
//#endregion
|
|
24
59
|
//#region src/invoices/create-types.d.ts
|
|
25
60
|
type InvoiceType = "invoice" | "proforma" | "advance" | "final" | "corrective" | "deliveryNote";
|
|
@@ -209,41 +244,6 @@ interface InvoicePreview {
|
|
|
209
244
|
readonly items: readonly CreatedInvoiceItem[];
|
|
210
245
|
}
|
|
211
246
|
//#endregion
|
|
212
|
-
//#region src/core/errors.d.ts
|
|
213
|
-
type SzamlazzErrorCategory = "auth" | "account" | "validation" | "duplicate" | "partial_success" | "not_found" | "maintenance" | "rate_limit" | "attempt_limit" | "network" | "timeout" | "configuration" | "unexpected_response" | "unknown";
|
|
214
|
-
interface AgentErrorCodeInfo {
|
|
215
|
-
readonly message: string;
|
|
216
|
-
readonly category: SzamlazzErrorCategory;
|
|
217
|
-
readonly hint?: string;
|
|
218
|
-
}
|
|
219
|
-
declare const AGENT_ERROR_CODES: Readonly<Record<number, AgentErrorCodeInfo>>;
|
|
220
|
-
interface SzamlazzErrorOptions {
|
|
221
|
-
readonly category: SzamlazzErrorCategory;
|
|
222
|
-
readonly code?: number | undefined;
|
|
223
|
-
readonly hint?: string | undefined;
|
|
224
|
-
readonly action?: AgentAction | undefined;
|
|
225
|
-
readonly httpStatus?: number | undefined;
|
|
226
|
-
readonly rawResponse?: string | undefined;
|
|
227
|
-
readonly details?: Readonly<Record<string, string>> | undefined;
|
|
228
|
-
readonly cause?: unknown;
|
|
229
|
-
}
|
|
230
|
-
declare class SzamlazzError extends Error {
|
|
231
|
-
override readonly name: string;
|
|
232
|
-
readonly code: number | undefined;
|
|
233
|
-
readonly category: SzamlazzErrorCategory;
|
|
234
|
-
readonly retryable: boolean;
|
|
235
|
-
readonly hint: string | undefined;
|
|
236
|
-
readonly action: AgentAction | undefined;
|
|
237
|
-
readonly httpStatus: number | undefined;
|
|
238
|
-
readonly rawResponse: string | undefined;
|
|
239
|
-
readonly details: Readonly<Record<string, string>> | undefined;
|
|
240
|
-
constructor(message: string, options: SzamlazzErrorOptions);
|
|
241
|
-
get isDuplicate(): boolean;
|
|
242
|
-
get isNotFound(): boolean;
|
|
243
|
-
}
|
|
244
|
-
declare function isSzamlazzError(error: unknown): error is SzamlazzError;
|
|
245
|
-
declare function suggestedPrefix(error: unknown): string | undefined;
|
|
246
|
-
//#endregion
|
|
247
247
|
//#region src/core/response.d.ts
|
|
248
248
|
interface AgentResponse {
|
|
249
249
|
readonly action: AgentAction;
|
|
@@ -366,6 +366,16 @@ interface ReceiptReversedEvent {
|
|
|
366
366
|
}
|
|
367
367
|
type DocumentEvent = InvoiceCreatedEvent | InvoiceReversedEvent | InvoicePaymentEvent | ReceiptCreatedEvent | ReceiptReversedEvent;
|
|
368
368
|
type DocumentHook = (event: DocumentEvent) => void | Promise<void>;
|
|
369
|
+
type DocumentErrorHandler = (error: unknown, event: DocumentEvent) => void | Promise<void>;
|
|
370
|
+
type DocumentErrorMode = "warn" | "throw" | DocumentErrorHandler;
|
|
371
|
+
declare class DocumentHookError extends Error {
|
|
372
|
+
override readonly name: string;
|
|
373
|
+
readonly event: DocumentEvent;
|
|
374
|
+
constructor(event: DocumentEvent, cause: unknown);
|
|
375
|
+
get number(): string;
|
|
376
|
+
get document(): DocumentEvent["document"];
|
|
377
|
+
}
|
|
378
|
+
declare function isDocumentHookError(error: unknown): error is DocumentHookError;
|
|
369
379
|
//#endregion
|
|
370
380
|
//#region src/core/context.d.ts
|
|
371
381
|
interface AgentAttachment {
|
|
@@ -376,20 +386,32 @@ interface AgentAttachment {
|
|
|
376
386
|
interface AgentRequestEvent {
|
|
377
387
|
readonly action: AgentAction;
|
|
378
388
|
readonly attempt: number;
|
|
389
|
+
readonly requestId: string;
|
|
379
390
|
}
|
|
380
391
|
interface AgentResponseEvent extends AgentRequestEvent {
|
|
381
392
|
readonly status: number;
|
|
382
393
|
readonly durationMs: number;
|
|
394
|
+
readonly responseBytes: number;
|
|
395
|
+
readonly sessionReused: boolean;
|
|
383
396
|
}
|
|
384
397
|
interface AgentErrorEvent extends AgentRequestEvent {
|
|
385
398
|
readonly error: SzamlazzError;
|
|
386
399
|
readonly willRetry: boolean;
|
|
387
400
|
}
|
|
401
|
+
interface AgentCompleteEvent extends AgentRequestEvent {
|
|
402
|
+
readonly outcome: "success" | "error";
|
|
403
|
+
readonly durationMs: number;
|
|
404
|
+
readonly error?: SzamlazzError | undefined;
|
|
405
|
+
readonly willRetry: boolean;
|
|
406
|
+
}
|
|
388
407
|
interface SzamlazzHooks {
|
|
389
408
|
readonly onRequest?: (event: AgentRequestEvent) => void;
|
|
390
409
|
readonly onResponse?: (event: AgentResponseEvent) => void;
|
|
391
410
|
readonly onError?: (event: AgentErrorEvent) => void;
|
|
411
|
+
readonly onComplete?: (event: AgentCompleteEvent) => void;
|
|
392
412
|
readonly onDocument?: DocumentHook;
|
|
413
|
+
readonly onDocumentError?: DocumentErrorMode;
|
|
414
|
+
readonly onWarning?: (warning: KasszaWarning) => void;
|
|
393
415
|
}
|
|
394
416
|
interface SzamlazzOptions {
|
|
395
417
|
readonly agentKey?: string;
|
|
@@ -401,7 +423,8 @@ interface SzamlazzOptions {
|
|
|
401
423
|
readonly maxAttempts?: number;
|
|
402
424
|
readonly retryDelayMs?: number;
|
|
403
425
|
readonly cookieStore?: CookieStore | false;
|
|
404
|
-
readonly attemptLedger?:
|
|
426
|
+
readonly attemptLedger?: KeyValueStore | undefined;
|
|
427
|
+
readonly attemptLedgerMode?: AttemptLedgerMode | undefined;
|
|
405
428
|
readonly maintenanceCooldownMs?: number | undefined;
|
|
406
429
|
readonly hooks?: SzamlazzHooks;
|
|
407
430
|
}
|
|
@@ -417,9 +440,10 @@ interface AgentRequest {
|
|
|
417
440
|
}
|
|
418
441
|
interface AgentContext {
|
|
419
442
|
readonly credentials: readonly XmlNode[];
|
|
443
|
+
readonly warn?: WarningHook | undefined;
|
|
420
444
|
execute<T>(request: AgentRequest, parse: (response: AgentResponse) => T | Promise<T>): Promise<T>;
|
|
421
445
|
resetSession(): Promise<void>;
|
|
422
446
|
resetAttempts(key: string): Promise<void>;
|
|
423
447
|
}
|
|
424
448
|
//#endregion
|
|
425
|
-
export {
|
|
449
|
+
export { Waybill as $, CorrectiveInvoiceInput as A, InvoiceLanguage as B, ClearPaymentsInput as C, XmlNode as D, RegisteredPayment as E, Currency as F, InvoiceType as G, InvoicePreview as H, FinalInvoiceInput as I, PickPackPointWaybill as J, ItemLedger as K, InvoiceBuyer as L, CreateInvoiceInput as M, CreatedInvoice as N, AgentResponse as O, CreatedInvoiceItem as P, TransOFlexWaybill as Q, InvoiceDefaults as R, ReversedInvoice as S, RegisterPaymentInput as T, InvoiceSeller as U, InvoicePostalAddress as V, InvoiceTemplate as W, StandardInvoiceInput as X, SprinterWaybill as Y, TaxpayerType as Z, InvoiceReversedEvent as _, AgentRequestEvent as a, AgentErrorCodeInfo as at, isDocumentHookError as b, SzamlazzHooks as c, SzamlazzErrorCategory as ct, DocumentErrorMode as d, suggestedPrefix as dt, ATTEMPT_LEDGER_KEY_PREFIX as et, DocumentEvent as f, InvoicePaymentEvent as g, InvoiceCreatedEvent as h, AgentErrorEvent as i, AGENT_ERROR_CODES as it, CourierService as j, BuyerLedger as k, SzamlazzOptions as l, errorCodeDocsUrl as lt, DocumentHookError as m, AgentCompleteEvent as n, AttemptLedgerMode as nt, AgentResponseEvent as o, KASSZA_ERROR_DOCS_URL as ot, DocumentHook as p, MplWaybill as q, AgentContext as r, attemptLedgerKey as rt, RequestOptions as s, SzamlazzError as st, AgentAttachment as t, ATTEMPT_LEDGER_TTL_SECONDS as tt, DocumentErrorHandler as u, isSzamlazzError as ut, ReceiptCreatedEvent as v, PaymentEntry as w, ReverseInvoiceInput as x, ReceiptReversedEvent as y, InvoiceItemInput as z };
|