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.
Files changed (164) hide show
  1. package/README.en.md +48 -0
  2. package/README.md +152 -22
  3. package/agents/README.md +6 -1
  4. package/agents/api.md +64 -12
  5. package/agents/pitfalls.md +12 -1
  6. package/agents/recipes.md +67 -8
  7. package/agents/skills/kassza/SKILL.md +3 -0
  8. package/agents/skills/migrate-from-szamlazz-js/SKILL.md +39 -0
  9. package/dist/batch/index.cjs +346 -0
  10. package/dist/batch/index.d.cts +91 -0
  11. package/dist/batch/index.d.ts +91 -0
  12. package/dist/batch/index.js +339 -0
  13. package/dist/cli.cjs +105 -14
  14. package/dist/cli.js +104 -13
  15. package/dist/{client-C-PdfL_P.cjs → client-CLFvJCVW.cjs} +358 -181
  16. package/dist/{client-CfaS1-Jx.js → client-Cvf-hTz_.js} +311 -152
  17. package/dist/{client-6MkeuFqD.d.ts → client-DeWWQ-RZ.d.ts} +99 -26
  18. package/dist/{client-B5FryKxJ.d.cts → client-SVZu25MB.d.cts} +99 -26
  19. package/dist/{context-DXNbTPwz.d.cts → context-CFNKzStE.d.cts} +82 -58
  20. package/dist/{context-BxQlIlug.d.ts → context-kb33TgzE.d.ts} +82 -58
  21. package/dist/cookie-stores/index.cjs +21 -150
  22. package/dist/cookie-stores/index.d.cts +4 -63
  23. package/dist/cookie-stores/index.d.ts +4 -63
  24. package/dist/cookie-stores/index.js +3 -144
  25. package/dist/create-CflXrPip.js +204 -0
  26. package/dist/create-CvUvLUaT.cjs +257 -0
  27. package/dist/{create-once-DgMtKKcG.cjs → create-once-9yxR_Er_.cjs} +285 -33
  28. package/dist/create-once-Bh6fOWkW.d.cts +20 -0
  29. package/dist/{create-once-Cz621l8r.js → create-once-Ca2gMk1h.js} +250 -34
  30. package/dist/create-once-VKp0tVow.d.ts +20 -0
  31. package/dist/data-link/index.cjs +4 -4
  32. package/dist/data-link/index.d.cts +2 -52
  33. package/dist/data-link/index.d.ts +2 -52
  34. package/dist/data-link/index.js +4 -4
  35. package/dist/delegation/index.cjs +4 -4
  36. package/dist/delegation/index.d.cts +2 -2
  37. package/dist/delegation/index.d.ts +2 -2
  38. package/dist/delegation/index.js +4 -4
  39. package/dist/{errors-DLrb0g64.js → errors-DtN4g5Z9.js} +9 -1
  40. package/dist/{errors-DxeuTslP.cjs → errors-EE96_6D_.cjs} +20 -0
  41. package/dist/{get-Csm2n0rZ.cjs → get-BdMTseh4.cjs} +9 -183
  42. package/dist/{get-DT3JEgQ6.js → get-CZEShCcj.js} +4 -124
  43. package/dist/index-BhUPY_EH.d.cts +109 -0
  44. package/dist/index-BqGgQ4t3.d.ts +109 -0
  45. package/dist/{index-CYAGCdKJ.d.cts → index-C-7yWV7L.d.cts} +24 -1
  46. package/dist/{index-CYAGCdKJ.d.ts → index-C-7yWV7L.d.ts} +24 -1
  47. package/dist/index.cjs +19 -5
  48. package/dist/index.d.cts +10 -20
  49. package/dist/index.d.ts +10 -20
  50. package/dist/index.js +6 -6
  51. package/dist/ipn/index.cjs +26 -5
  52. package/dist/ipn/index.d.cts +12 -1
  53. package/dist/ipn/index.d.ts +12 -1
  54. package/dist/ipn/index.js +26 -6
  55. package/dist/{issue-AGRohSm7.cjs → issue-Bin4tKD_.cjs} +416 -342
  56. package/dist/{issue-DtSLpVdJ.js → issue-DMA1Nbr1.js} +394 -266
  57. package/dist/journal/index.cjs +454 -0
  58. package/dist/journal/index.d.cts +18 -0
  59. package/dist/journal/index.d.ts +18 -0
  60. package/dist/journal/index.js +445 -0
  61. package/dist/journal-DvI81Kt7.d.cts +114 -0
  62. package/dist/journal-Y9qrIB8G.d.ts +114 -0
  63. package/dist/mcp/index.cjs +1 -1
  64. package/dist/mcp/index.d.cts +1 -1
  65. package/dist/mcp/index.d.ts +1 -1
  66. package/dist/mcp/index.js +1 -1
  67. package/dist/money/index.cjs +2 -1
  68. package/dist/money/index.d.cts +2 -2
  69. package/dist/money/index.d.ts +2 -2
  70. package/dist/money/index.js +2 -2
  71. package/dist/{money-t7uy1n91.js → money-Cw457SD6.js} +95 -3
  72. package/dist/{money-BxytJW6f.cjs → money-K9j0wPit.cjs} +99 -1
  73. package/dist/nav/index.cjs +2 -2
  74. package/dist/nav/index.d.cts +1 -1
  75. package/dist/nav/index.d.ts +1 -1
  76. package/dist/nav/index.js +2 -2
  77. package/dist/{nav-BEwcX7-N.cjs → nav-BNbc8U0R.cjs} +1 -1
  78. package/dist/{nav-CK1WgYo7.js → nav-BcCerwWS.js} +1 -1
  79. package/dist/node/index.cjs +124 -0
  80. package/dist/node/index.d.cts +35 -0
  81. package/dist/node/index.d.ts +35 -0
  82. package/dist/node/index.js +120 -0
  83. package/dist/observe/index.cjs +311 -0
  84. package/dist/observe/index.d.cts +53 -0
  85. package/dist/observe/index.d.ts +53 -0
  86. package/dist/observe/index.js +303 -0
  87. package/dist/once-BN_3B5OF.cjs +103 -0
  88. package/dist/once-CqqZxsXG.js +74 -0
  89. package/dist/{parse-C608ehqM.js → parse-Cr7yQ3_z.js} +2 -2
  90. package/dist/{parse-BJj-aqKy.cjs → parse-DOA2XQ3e.cjs} +2 -2
  91. package/dist/payments/barion.cjs +26 -2
  92. package/dist/payments/barion.d.cts +2 -2
  93. package/dist/payments/barion.d.ts +2 -2
  94. package/dist/payments/barion.js +26 -2
  95. package/dist/payments/index.cjs +7 -2
  96. package/dist/payments/index.d.cts +4 -4
  97. package/dist/payments/index.d.ts +4 -4
  98. package/dist/payments/index.js +3 -3
  99. package/dist/payments/paypal.cjs +16 -2
  100. package/dist/payments/paypal.d.cts +2 -2
  101. package/dist/payments/paypal.d.ts +2 -2
  102. package/dist/payments/paypal.js +16 -2
  103. package/dist/payments/revolut.cjs +16 -2
  104. package/dist/payments/revolut.d.cts +2 -2
  105. package/dist/payments/revolut.d.ts +2 -2
  106. package/dist/payments/revolut.js +16 -2
  107. package/dist/payments/simplepay.cjs +36 -4
  108. package/dist/payments/simplepay.d.cts +2 -2
  109. package/dist/payments/simplepay.d.ts +2 -2
  110. package/dist/payments/simplepay.js +36 -4
  111. package/dist/payments/stripe.cjs +19 -2
  112. package/dist/payments/stripe.d.cts +2 -2
  113. package/dist/payments/stripe.d.ts +2 -2
  114. package/dist/payments/stripe.js +19 -2
  115. package/dist/push-BXj0Sf0Z.d.ts +52 -0
  116. package/dist/push-D4nNbCNV.d.cts +52 -0
  117. package/dist/reference-B5TATqb5.js +124 -0
  118. package/dist/reference-BIdYMK0t.cjs +183 -0
  119. package/dist/reports/index.cjs +1 -1
  120. package/dist/reports/index.d.cts +1 -1
  121. package/dist/reports/index.d.ts +1 -1
  122. package/dist/reports/index.js +1 -1
  123. package/dist/{serialize-DSE_o9RK.js → serialize-B2eFh3D-.js} +5 -1
  124. package/dist/{serialize-BXOww1Uq.cjs → serialize-CquIsxA-.cjs} +5 -1
  125. package/dist/{server-Cd8HB661.js → server-BrJUbXs7.js} +8 -7
  126. package/dist/{server-C6PoNkdD.cjs → server-Dw9j8Mnd.cjs} +17 -16
  127. package/dist/session-Ckl5eJhV.d.ts +7 -0
  128. package/dist/{session-CKOuE6Jc.cjs → session-DeM5vjvC.cjs} +69 -13
  129. package/dist/{session-rMKaJcmq.js → session-SaEEXu2N.js} +58 -14
  130. package/dist/session-YbChChx7.d.cts +7 -0
  131. package/dist/storage/fs.cjs +1 -1
  132. package/dist/storage/fs.js +1 -1
  133. package/dist/storage/index.cjs +1 -1
  134. package/dist/storage/index.js +1 -1
  135. package/dist/store-C1rHd9DB.d.cts +19 -0
  136. package/dist/store-C1rHd9DB.d.ts +19 -0
  137. package/dist/stores/index.cjs +24 -0
  138. package/dist/stores/index.d.cts +4 -0
  139. package/dist/stores/index.d.ts +4 -0
  140. package/dist/stores/index.js +3 -0
  141. package/dist/stores-BNrS0dWl.cjs +506 -0
  142. package/dist/stores-DhjGBrl_.js +441 -0
  143. package/dist/testing/index.cjs +28 -16
  144. package/dist/testing/index.d.cts +6 -3
  145. package/dist/testing/index.d.ts +6 -3
  146. package/dist/testing/index.js +26 -14
  147. package/dist/{types-BVeR7KyU.d.ts → types-B1A8mUIE.d.cts} +13 -1
  148. package/dist/{types-BVeR7KyU.d.cts → types-ByAEvGsZ.d.ts} +13 -1
  149. package/dist/{types-k--zHf4l.d.ts → types-D1zDOH_F.d.ts} +1 -1
  150. package/dist/{types-DH8QoNZK.d.cts → types-lnKkQdot.d.cts} +1 -1
  151. package/dist/warnings-B3DXnveC.d.cts +31 -0
  152. package/dist/warnings-B3DXnveC.d.ts +31 -0
  153. package/dist/warnings-DeIw5RFj.cjs +20 -0
  154. package/dist/warnings-DwTl5J-2.js +15 -0
  155. package/dist/{webhook-CrEGohbg.js → webhook-CQVShAfI.js} +44 -1
  156. package/dist/{webhook-81giRMdQ.cjs → webhook-Ckj-_hPD.cjs} +67 -0
  157. package/dist/webhook-CmdhGiH5.d.cts +11 -0
  158. package/dist/webhook-D6lEejob.d.ts +11 -0
  159. package/llms.txt +4 -3
  160. package/package.json +92 -4
  161. package/dist/session-Dm_45x8K.d.cts +0 -11
  162. package/dist/session-Dm_45x8K.d.ts +0 -11
  163. package/dist/webhook-CpCMHhn2.d.ts +0 -6
  164. package/dist/webhook-CpMJuP6c.d.cts +0 -6
@@ -1,8 +1,31 @@
1
- import { E as SzamlazzError, G as InvoiceTemplate, K as InvoiceType, N as CreateInvoiceInput, P as CreatedInvoice, R as InvoiceBuyer, U as InvoicePreview, V as InvoiceLanguage, W as InvoiceSeller, Z as StandardInvoiceInput, _ as ReversedInvoice, b as RegisterPaymentInput, c as SzamlazzOptions, g as ReverseInvoiceInput, o as RequestOptions, v as ClearPaymentsInput, x as RegisteredPayment, z as InvoiceDefaults } from "./context-BxQlIlug.js";
2
- import { _ as VatRate } from "./index-CYAGCdKJ.js";
3
- import { h as SendReceiptInput, i as ReceiptDefaults, m as ReverseReceiptInput, n as GetReceiptInput, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput } from "./types-k--zHf4l.js";
4
- import { n as InvoiceDetails, t as GetInvoiceOptions } from "./get-Byc9T5WO.js";
5
- import { i as PaymentEvent, r as PaymentCustomer, s as PaymentLineItem } from "./types-BVeR7KyU.js";
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/core/once.d.ts
16
- interface CreateOnceOptions extends RequestOptions {
17
- readonly lookupFirst?: boolean | undefined;
18
- readonly matchOrderNumber?: boolean | undefined;
19
- readonly recoveryDelayMs?: number | undefined;
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
- //#endregion
22
- //#region src/invoices/create-once.d.ts
23
- interface InvoiceOnceResult {
24
- readonly number: string;
48
+ interface RegisteredPaymentOnce {
49
+ readonly invoiceNumber: string;
50
+ readonly key: string;
51
+ readonly marker: string;
25
52
  readonly created: boolean;
26
- readonly externalId: string;
27
- readonly invoice?: CreatedInvoice | undefined;
28
- readonly details?: InvoiceDetails | undefined;
53
+ readonly payment?: RegisteredPayment | undefined;
54
+ readonly existing?: InvoiceDetailsPayment | undefined;
29
55
  }
30
- declare function invoiceOnceExternalId(type: InvoiceType, orderNumber: string): string;
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 { RECEIPT_MAX_GROSS_HUF as A, buyerFromCustomer as C, ChooseDocumentInput as D, ChooseDocumentBuyer as E, invoiceOnceExternalId as F, CreateOnceOptions as I, InvoiceReference as L, ProformaReference as M, InvoicePdf as N, DocumentChoice as O, InvoiceOnceResult as P, SkippedPayment as S, paymentOrderNumber as T, IssuedInvoice as _, ReceiptsApi as a, PaymentDocumentItem as b, TaxpayerInfo as c, ReceiptOnceResult as d, ConvertReceiptInput as f, IssuedDocument as g, IssueForPaymentOptions as h, KasszaOptions as i, chooseDocument as j, DocumentDecision as k, TaxpayerTaxNumber as l, conversionExternalId as m, Kassza as n, TaxpayerApi as o, ConvertedReceipt as p, KasszaDefaults as r, createKassza as s, InvoicesApi as t, TaxpayerAddress as u, IssuedReceipt as v, issueForPayment as w, PaymentDocumentsApi as x, IssuedReversal as y };
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 { E as SzamlazzError, G as InvoiceTemplate, K as InvoiceType, N as CreateInvoiceInput, P as CreatedInvoice, R as InvoiceBuyer, U as InvoicePreview, V as InvoiceLanguage, W as InvoiceSeller, Z as StandardInvoiceInput, _ as ReversedInvoice, b as RegisterPaymentInput, c as SzamlazzOptions, g as ReverseInvoiceInput, o as RequestOptions, v as ClearPaymentsInput, x as RegisteredPayment, z as InvoiceDefaults } from "./context-DXNbTPwz.cjs";
2
- import { _ as VatRate } from "./index-CYAGCdKJ.cjs";
3
- import { h as SendReceiptInput, i as ReceiptDefaults, m as ReverseReceiptInput, n as GetReceiptInput, r as Receipt, s as ReceiptOnlyVatCode, t as CreateReceiptInput } from "./types-DH8QoNZK.cjs";
4
- import { n as InvoiceDetails, t as GetInvoiceOptions } from "./get-Byc9T5WO.cjs";
5
- import { i as PaymentEvent, r as PaymentCustomer, s as PaymentLineItem } from "./types-BVeR7KyU.cjs";
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/core/once.d.ts
16
- interface CreateOnceOptions extends RequestOptions {
17
- readonly lookupFirst?: boolean | undefined;
18
- readonly matchOrderNumber?: boolean | undefined;
19
- readonly recoveryDelayMs?: number | undefined;
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
- //#endregion
22
- //#region src/invoices/create-once.d.ts
23
- interface InvoiceOnceResult {
24
- readonly number: string;
48
+ interface RegisteredPaymentOnce {
49
+ readonly invoiceNumber: string;
50
+ readonly key: string;
51
+ readonly marker: string;
25
52
  readonly created: boolean;
26
- readonly externalId: string;
27
- readonly invoice?: CreatedInvoice | undefined;
28
- readonly details?: InvoiceDetails | undefined;
53
+ readonly payment?: RegisteredPayment | undefined;
54
+ readonly existing?: InvoiceDetailsPayment | undefined;
29
55
  }
30
- declare function invoiceOnceExternalId(type: InvoiceType, orderNumber: string): string;
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 { RECEIPT_MAX_GROSS_HUF as A, buyerFromCustomer as C, ChooseDocumentInput as D, ChooseDocumentBuyer as E, invoiceOnceExternalId as F, CreateOnceOptions as I, InvoiceReference as L, ProformaReference as M, InvoicePdf as N, DocumentChoice as O, InvoiceOnceResult as P, SkippedPayment as S, paymentOrderNumber as T, IssuedInvoice as _, ReceiptsApi as a, PaymentDocumentItem as b, TaxpayerInfo as c, ReceiptOnceResult as d, ConvertReceiptInput as f, IssuedDocument as g, IssueForPaymentOptions as h, KasszaOptions as i, chooseDocument as j, DocumentDecision as k, TaxpayerTaxNumber as l, conversionExternalId as m, Kassza as n, TaxpayerApi as o, ConvertedReceipt as p, KasszaDefaults as r, createKassza as s, InvoicesApi as t, TaxpayerAddress as u, IssuedReceipt as v, issueForPayment as w, PaymentDocumentsApi as x, IssuedReversal as y };
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 { o as ItemAmounts, s as ItemPriceInput } from "./index-CYAGCdKJ.cjs";
4
- import { r as Receipt } from "./types-DH8QoNZK.cjs";
5
- //#region src/core/actions.d.ts
6
- declare const SZAMLAZZ_AGENT_URL = "https://www.szamlazz.hu/szamla/";
7
- declare const AGENT_ACTIONS: {
8
- readonly createInvoice: "action-xmlagentxmlfile";
9
- readonly reverseInvoice: "action-szamla_agent_st";
10
- readonly registerPayment: "action-szamla_agent_kifiz";
11
- readonly getInvoicePdf: "action-szamla_agent_pdf";
12
- readonly getInvoiceXml: "action-szamla_agent_xml";
13
- readonly deleteProforma: "action-szamla_agent_dijbekero_torlese";
14
- readonly createReceipt: "action-szamla_agent_nyugta_create";
15
- readonly reverseReceipt: "action-szamla_agent_nyugta_storno";
16
- readonly getReceipt: "action-szamla_agent_nyugta_get";
17
- readonly sendReceipt: "action-szamla_agent_nyugta_send";
18
- readonly queryTaxpayer: "action-szamla_agent_taxpayer";
19
- readonly connectPrincipal: "action-agent_ceg_mb";
20
- };
21
- type AgentAction = keyof typeof AGENT_ACTIONS;
22
- declare const MAX_INVOICE_ATTACHMENTS = 5;
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?: CookieStore | undefined;
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 { TransOFlexWaybill as $, BuyerLedger as A, InvoiceItemInput as B, AgentResponse as C, SzamlazzErrorCategory as D, SzamlazzError as E, CreatedInvoiceItem as F, InvoiceTemplate as G, InvoicePostalAddress as H, Currency as I, MplWaybill as J, InvoiceType as K, FinalInvoiceInput as L, CourierService as M, CreateInvoiceInput as N, isSzamlazzError as O, CreatedInvoice as P, TaxpayerType as Q, InvoiceBuyer as R, XmlNode as S, AgentErrorCodeInfo as T, InvoicePreview as U, InvoiceLanguage as V, InvoiceSeller as W, SprinterWaybill as X, PickPackPointWaybill as Y, StandardInvoiceInput as Z, ReversedInvoice as _, AgentResponseEvent as a, RegisterPaymentInput as b, SzamlazzOptions as c, InvoiceCreatedEvent as d, Waybill as et, InvoicePaymentEvent as f, ReverseInvoiceInput as g, ReceiptReversedEvent as h, AgentRequestEvent as i, SZAMLAZZ_AGENT_URL as it, CorrectiveInvoiceInput as j, suggestedPrefix as k, DocumentEvent as l, ReceiptCreatedEvent as m, AgentContext as n, AgentAction as nt, RequestOptions as o, InvoiceReversedEvent as p, ItemLedger as q, AgentErrorEvent as r, MAX_INVOICE_ATTACHMENTS as rt, SzamlazzHooks as s, AgentAttachment as t, AGENT_ACTIONS as tt, DocumentHook as u, ClearPaymentsInput as v, AGENT_ERROR_CODES as w, RegisteredPayment as x, PaymentEntry as y, InvoiceDefaults as z };
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 };