kassza 0.12.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 (177) hide show
  1. package/README.en.md +48 -0
  2. package/README.md +427 -32
  3. package/agents/README.md +26 -6
  4. package/agents/api.md +218 -3
  5. package/agents/pitfalls.md +27 -3
  6. package/agents/recipes.md +280 -51
  7. package/agents/skills/kassza/SKILL.md +14 -8
  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 +643 -0
  14. package/dist/cli.d.cts +1 -0
  15. package/dist/cli.d.ts +1 -0
  16. package/dist/cli.js +643 -0
  17. package/dist/client-CLFvJCVW.cjs +1452 -0
  18. package/dist/{client-CL3fuH6A.js → client-Cvf-hTz_.js} +306 -515
  19. package/dist/client-DeWWQ-RZ.d.ts +341 -0
  20. package/dist/client-SVZu25MB.d.cts +341 -0
  21. package/dist/context-CFNKzStE.d.cts +449 -0
  22. package/dist/context-kb33TgzE.d.ts +449 -0
  23. package/dist/cookie-stores/index.cjs +21 -150
  24. package/dist/cookie-stores/index.d.cts +4 -63
  25. package/dist/cookie-stores/index.d.ts +4 -63
  26. package/dist/cookie-stores/index.js +3 -144
  27. package/dist/create-CflXrPip.js +204 -0
  28. package/dist/create-CvUvLUaT.cjs +257 -0
  29. package/dist/{create-once-D0pwuenl.cjs → create-once-9yxR_Er_.cjs} +291 -33
  30. package/dist/create-once-Bh6fOWkW.d.cts +20 -0
  31. package/dist/{create-once-CqdYmQD8.js → create-once-Ca2gMk1h.js} +250 -34
  32. package/dist/create-once-VKp0tVow.d.ts +20 -0
  33. package/dist/{crypto-B8lERvR1.cjs → crypto-Dpn4FHQ6.cjs} +9 -0
  34. package/dist/{crypto-DK_osBVy.js → crypto-usDg8L2K.js} +4 -1
  35. package/dist/data-link/index.cjs +232 -0
  36. package/dist/data-link/index.d.cts +29 -0
  37. package/dist/data-link/index.d.ts +29 -0
  38. package/dist/data-link/index.js +224 -0
  39. package/dist/delegation/index.cjs +35 -34
  40. package/dist/delegation/index.d.cts +2 -1
  41. package/dist/delegation/index.d.ts +2 -1
  42. package/dist/delegation/index.js +4 -3
  43. package/dist/{errors-DLrb0g64.js → errors-DtN4g5Z9.js} +9 -1
  44. package/dist/{errors-DxeuTslP.cjs → errors-EE96_6D_.cjs} +20 -0
  45. package/dist/get-BdMTseh4.cjs +271 -0
  46. package/dist/get-Byc9T5WO.d.cts +151 -0
  47. package/dist/get-Byc9T5WO.d.ts +151 -0
  48. package/dist/get-CZEShCcj.js +260 -0
  49. package/dist/index-BhUPY_EH.d.cts +109 -0
  50. package/dist/index-BqGgQ4t3.d.ts +109 -0
  51. package/dist/{index-CYAGCdKJ.d.cts → index-C-7yWV7L.d.cts} +24 -1
  52. package/dist/{index-CYAGCdKJ.d.ts → index-C-7yWV7L.d.ts} +24 -1
  53. package/dist/index.cjs +19 -5
  54. package/dist/index.d.cts +11 -19
  55. package/dist/index.d.ts +11 -19
  56. package/dist/index.js +6 -6
  57. package/dist/ipn/index.cjs +26 -5
  58. package/dist/ipn/index.d.cts +12 -1
  59. package/dist/ipn/index.d.ts +12 -1
  60. package/dist/ipn/index.js +26 -6
  61. package/dist/issue-Bin4tKD_.cjs +988 -0
  62. package/dist/issue-DMA1Nbr1.js +905 -0
  63. package/dist/journal/index.cjs +454 -0
  64. package/dist/journal/index.d.cts +18 -0
  65. package/dist/journal/index.d.ts +18 -0
  66. package/dist/journal/index.js +445 -0
  67. package/dist/journal-DvI81Kt7.d.cts +114 -0
  68. package/dist/journal-Y9qrIB8G.d.ts +114 -0
  69. package/dist/mcp/index.cjs +10 -0
  70. package/dist/mcp/index.d.cts +71 -0
  71. package/dist/mcp/index.d.ts +71 -0
  72. package/dist/mcp/index.js +2 -0
  73. package/dist/money/index.cjs +2 -1
  74. package/dist/money/index.d.cts +2 -2
  75. package/dist/money/index.d.ts +2 -2
  76. package/dist/money/index.js +2 -2
  77. package/dist/{money-DAA7OwiO.js → money-Cw457SD6.js} +120 -12
  78. package/dist/{money-DrhGkWHW.cjs → money-K9j0wPit.cjs} +124 -10
  79. package/dist/nav/index.cjs +1046 -0
  80. package/dist/nav/index.d.cts +247 -0
  81. package/dist/nav/index.d.ts +247 -0
  82. package/dist/nav/index.js +1012 -0
  83. package/dist/nav-BNbc8U0R.cjs +203 -0
  84. package/dist/nav-BcCerwWS.js +156 -0
  85. package/dist/node/index.cjs +124 -0
  86. package/dist/node/index.d.cts +35 -0
  87. package/dist/node/index.d.ts +35 -0
  88. package/dist/node/index.js +120 -0
  89. package/dist/observe/index.cjs +311 -0
  90. package/dist/observe/index.d.cts +53 -0
  91. package/dist/observe/index.d.ts +53 -0
  92. package/dist/observe/index.js +303 -0
  93. package/dist/once-BN_3B5OF.cjs +103 -0
  94. package/dist/once-CqqZxsXG.js +74 -0
  95. package/dist/parse-Cr7yQ3_z.js +291 -0
  96. package/dist/parse-DOA2XQ3e.cjs +380 -0
  97. package/dist/payments/barion.cjs +26 -2
  98. package/dist/payments/barion.d.cts +2 -2
  99. package/dist/payments/barion.d.ts +2 -2
  100. package/dist/payments/barion.js +26 -2
  101. package/dist/payments/index.cjs +7 -2
  102. package/dist/payments/index.d.cts +4 -4
  103. package/dist/payments/index.d.ts +4 -4
  104. package/dist/payments/index.js +3 -3
  105. package/dist/payments/paypal.cjs +16 -2
  106. package/dist/payments/paypal.d.cts +2 -2
  107. package/dist/payments/paypal.d.ts +2 -2
  108. package/dist/payments/paypal.js +16 -2
  109. package/dist/payments/revolut.cjs +17 -3
  110. package/dist/payments/revolut.d.cts +2 -2
  111. package/dist/payments/revolut.d.ts +2 -2
  112. package/dist/payments/revolut.js +17 -3
  113. package/dist/payments/simplepay.cjs +37 -5
  114. package/dist/payments/simplepay.d.cts +2 -2
  115. package/dist/payments/simplepay.d.ts +2 -2
  116. package/dist/payments/simplepay.js +37 -5
  117. package/dist/payments/stripe.cjs +20 -3
  118. package/dist/payments/stripe.d.cts +2 -2
  119. package/dist/payments/stripe.d.ts +2 -2
  120. package/dist/payments/stripe.js +20 -3
  121. package/dist/push-BXj0Sf0Z.d.ts +52 -0
  122. package/dist/push-D4nNbCNV.d.cts +52 -0
  123. package/dist/reference-B5TATqb5.js +124 -0
  124. package/dist/reference-BIdYMK0t.cjs +183 -0
  125. package/dist/reports/index.cjs +11 -164
  126. package/dist/reports/index.d.cts +1 -1
  127. package/dist/reports/index.d.ts +1 -1
  128. package/dist/reports/index.js +1 -154
  129. package/dist/request-body-CH6ZGOrq.cjs +34 -0
  130. package/dist/request-body-uZHMRlQr.js +29 -0
  131. package/dist/serialize-B2eFh3D-.js +219 -0
  132. package/dist/serialize-CquIsxA-.cjs +290 -0
  133. package/dist/server-BrJUbXs7.js +1505 -0
  134. package/dist/server-Dw9j8Mnd.cjs +1558 -0
  135. package/dist/session-Ckl5eJhV.d.ts +7 -0
  136. package/dist/{session-CKOuE6Jc.cjs → session-DeM5vjvC.cjs} +69 -13
  137. package/dist/{session-rMKaJcmq.js → session-SaEEXu2N.js} +58 -14
  138. package/dist/session-YbChChx7.d.cts +7 -0
  139. package/dist/storage/fs.cjs +1 -1
  140. package/dist/storage/fs.js +1 -1
  141. package/dist/storage/index.cjs +1 -1
  142. package/dist/storage/index.js +1 -1
  143. package/dist/store-C1rHd9DB.d.cts +19 -0
  144. package/dist/store-C1rHd9DB.d.ts +19 -0
  145. package/dist/stores/index.cjs +24 -0
  146. package/dist/stores/index.d.cts +4 -0
  147. package/dist/stores/index.d.ts +4 -0
  148. package/dist/stores/index.js +3 -0
  149. package/dist/stores-BNrS0dWl.cjs +506 -0
  150. package/dist/stores-DhjGBrl_.js +441 -0
  151. package/dist/testing/index.cjs +1500 -15
  152. package/dist/testing/index.d.cts +198 -3
  153. package/dist/testing/index.d.ts +198 -3
  154. package/dist/testing/index.js +1498 -15
  155. package/dist/{types-COf1LAD-.d.ts → types-B1A8mUIE.d.cts} +14 -2
  156. package/dist/{types-COf1LAD-.d.cts → types-ByAEvGsZ.d.ts} +14 -2
  157. package/dist/{types-k--zHf4l.d.ts → types-D1zDOH_F.d.ts} +1 -1
  158. package/dist/{types-DH8QoNZK.d.cts → types-lnKkQdot.d.cts} +1 -1
  159. package/dist/warnings-B3DXnveC.d.cts +31 -0
  160. package/dist/warnings-B3DXnveC.d.ts +31 -0
  161. package/dist/warnings-DeIw5RFj.cjs +20 -0
  162. package/dist/warnings-DwTl5J-2.js +15 -0
  163. package/dist/{webhook-D4lvtex1.js → webhook-CQVShAfI.js} +47 -26
  164. package/dist/{webhook-C76bV-4R.cjs → webhook-Ckj-_hPD.cjs} +70 -25
  165. package/dist/webhook-CmdhGiH5.d.cts +11 -0
  166. package/dist/webhook-D6lEejob.d.ts +11 -0
  167. package/llms.txt +6 -5
  168. package/package.json +134 -4
  169. package/dist/client-CickRRFr.d.ts +0 -838
  170. package/dist/client-CsmGIFRS.cjs +0 -1637
  171. package/dist/client-DvWZoX_E.d.cts +0 -838
  172. package/dist/issue-BsyYdrIG.cjs +0 -1531
  173. package/dist/issue-C6Fcjvln.js +0 -1274
  174. package/dist/session-Dm_45x8K.d.cts +0 -11
  175. package/dist/session-Dm_45x8K.d.ts +0 -11
  176. package/dist/webhook-CfaDgcL0.d.cts +0 -6
  177. package/dist/webhook-q2OzNwd7.d.ts +0 -6
@@ -1,5 +1,7 @@
1
+ import { t as KasszaWarning } from "./warnings-B3DXnveC.cjs";
2
+ import { n as KeyValueStore } from "./store-C1rHd9DB.cjs";
1
3
  //#region src/payments/types.d.ts
2
- type PaymentProvider = "stripe" | "simplepay" | "barion" | "revolut" | "paypal";
4
+ type PaymentProvider = "stripe" | "simplepay" | "barion" | "revolut" | "paypal" | (string & {});
3
5
  type PaymentEventKind = "paid" | "refunded" | "partially-refunded" | "failed" | "other";
4
6
  interface PaymentAmount {
5
7
  readonly value: number;
@@ -29,6 +31,12 @@ interface PaymentLineItem {
29
31
  readonly sku?: string | undefined;
30
32
  readonly vatPercent?: number | undefined;
31
33
  }
34
+ interface PaymentRefund {
35
+ readonly id: string;
36
+ readonly amount: PaymentAmount;
37
+ readonly refundedBefore?: number | undefined;
38
+ readonly createdAt?: string | undefined;
39
+ }
32
40
  interface PaymentEvent {
33
41
  readonly provider: PaymentProvider;
34
42
  readonly kind: PaymentEventKind;
@@ -38,6 +46,7 @@ interface PaymentEvent {
38
46
  readonly orderRef?: string | undefined;
39
47
  readonly amount?: PaymentAmount | undefined;
40
48
  readonly refundedAmount?: PaymentAmount | undefined;
49
+ readonly refunds?: readonly PaymentRefund[] | undefined;
41
50
  readonly paidAt?: string | undefined;
42
51
  readonly method: string;
43
52
  readonly customer?: PaymentCustomer | undefined;
@@ -48,9 +57,12 @@ type PaymentHandler = (payment: PaymentEvent) => unknown;
48
57
  interface PaymentWebhookBaseOptions {
49
58
  readonly onPayment: PaymentHandler;
50
59
  readonly onError?: ((error: unknown) => void) | undefined;
60
+ readonly onWarning?: ((warning: KasszaWarning) => void) | undefined;
61
+ readonly dedupe?: KeyValueStore | undefined;
62
+ readonly dedupeTtlSeconds?: number | undefined;
51
63
  readonly maxBodyBytes?: number | undefined;
52
64
  readonly method?: string | undefined;
53
65
  readonly fetch?: typeof globalThis.fetch | undefined;
54
66
  }
55
67
  //#endregion
56
- export { PaymentEventKind as a, PaymentProvider as c, PaymentEvent as i, PaymentWebhookBaseOptions as l, PaymentAmount as n, PaymentHandler as o, PaymentCustomer as r, PaymentLineItem as s, PaymentAddress as t };
68
+ export { PaymentEventKind as a, PaymentProvider as c, PaymentEvent as i, PaymentRefund as l, PaymentAmount as n, PaymentHandler as o, PaymentCustomer as r, PaymentLineItem as s, PaymentAddress as t, PaymentWebhookBaseOptions as u };
@@ -1,5 +1,7 @@
1
+ import { t as KasszaWarning } from "./warnings-B3DXnveC.js";
2
+ import { n as KeyValueStore } from "./store-C1rHd9DB.js";
1
3
  //#region src/payments/types.d.ts
2
- type PaymentProvider = "stripe" | "simplepay" | "barion" | "revolut" | "paypal";
4
+ type PaymentProvider = "stripe" | "simplepay" | "barion" | "revolut" | "paypal" | (string & {});
3
5
  type PaymentEventKind = "paid" | "refunded" | "partially-refunded" | "failed" | "other";
4
6
  interface PaymentAmount {
5
7
  readonly value: number;
@@ -29,6 +31,12 @@ interface PaymentLineItem {
29
31
  readonly sku?: string | undefined;
30
32
  readonly vatPercent?: number | undefined;
31
33
  }
34
+ interface PaymentRefund {
35
+ readonly id: string;
36
+ readonly amount: PaymentAmount;
37
+ readonly refundedBefore?: number | undefined;
38
+ readonly createdAt?: string | undefined;
39
+ }
32
40
  interface PaymentEvent {
33
41
  readonly provider: PaymentProvider;
34
42
  readonly kind: PaymentEventKind;
@@ -38,6 +46,7 @@ interface PaymentEvent {
38
46
  readonly orderRef?: string | undefined;
39
47
  readonly amount?: PaymentAmount | undefined;
40
48
  readonly refundedAmount?: PaymentAmount | undefined;
49
+ readonly refunds?: readonly PaymentRefund[] | undefined;
41
50
  readonly paidAt?: string | undefined;
42
51
  readonly method: string;
43
52
  readonly customer?: PaymentCustomer | undefined;
@@ -48,9 +57,12 @@ type PaymentHandler = (payment: PaymentEvent) => unknown;
48
57
  interface PaymentWebhookBaseOptions {
49
58
  readonly onPayment: PaymentHandler;
50
59
  readonly onError?: ((error: unknown) => void) | undefined;
60
+ readonly onWarning?: ((warning: KasszaWarning) => void) | undefined;
61
+ readonly dedupe?: KeyValueStore | undefined;
62
+ readonly dedupeTtlSeconds?: number | undefined;
51
63
  readonly maxBodyBytes?: number | undefined;
52
64
  readonly method?: string | undefined;
53
65
  readonly fetch?: typeof globalThis.fetch | undefined;
54
66
  }
55
67
  //#endregion
56
- export { PaymentEventKind as a, PaymentProvider as c, PaymentEvent as i, PaymentWebhookBaseOptions as l, PaymentAmount as n, PaymentHandler as o, PaymentCustomer as r, PaymentLineItem as s, PaymentAddress as t };
68
+ export { PaymentEventKind as a, PaymentProvider as c, PaymentEvent as i, PaymentRefund as l, PaymentAmount as n, PaymentHandler as o, PaymentCustomer as r, PaymentLineItem as s, PaymentAddress as t, PaymentWebhookBaseOptions as u };
@@ -1,4 +1,4 @@
1
- import { _ as VatRate, s as ItemPriceInput } from "./index-CYAGCdKJ.js";
1
+ import { S as VatRate, f as ItemPriceInput } from "./index-C-7yWV7L.js";
2
2
  //#region src/receipts/types.d.ts
3
3
  declare const RECEIPT_ONLY_VAT_CODES: readonly ["ÁKK", "MAA", "EU", "EUK"];
4
4
  type ReceiptOnlyVatCode = (typeof RECEIPT_ONLY_VAT_CODES)[number];
@@ -1,4 +1,4 @@
1
- import { _ as VatRate, s as ItemPriceInput } from "./index-CYAGCdKJ.cjs";
1
+ import { S as VatRate, f as ItemPriceInput } from "./index-C-7yWV7L.cjs";
2
2
  //#region src/receipts/types.d.ts
3
3
  declare const RECEIPT_ONLY_VAT_CODES: readonly ["ÁKK", "MAA", "EU", "EUK"];
4
4
  type ReceiptOnlyVatCode = (typeof RECEIPT_ONLY_VAT_CODES)[number];
@@ -0,0 +1,31 @@
1
+ //#region src/core/actions.d.ts
2
+ declare const SZAMLAZZ_AGENT_URL = "https://www.szamlazz.hu/szamla/";
3
+ declare const AGENT_ACTIONS: {
4
+ readonly createInvoice: "action-xmlagentxmlfile";
5
+ readonly reverseInvoice: "action-szamla_agent_st";
6
+ readonly registerPayment: "action-szamla_agent_kifiz";
7
+ readonly getInvoicePdf: "action-szamla_agent_pdf";
8
+ readonly getInvoiceXml: "action-szamla_agent_xml";
9
+ readonly deleteProforma: "action-szamla_agent_dijbekero_torlese";
10
+ readonly createReceipt: "action-szamla_agent_nyugta_create";
11
+ readonly reverseReceipt: "action-szamla_agent_nyugta_storno";
12
+ readonly getReceipt: "action-szamla_agent_nyugta_get";
13
+ readonly sendReceipt: "action-szamla_agent_nyugta_send";
14
+ readonly queryTaxpayer: "action-szamla_agent_taxpayer";
15
+ readonly connectPrincipal: "action-agent_ceg_mb";
16
+ };
17
+ type AgentAction = keyof typeof AGENT_ACTIONS;
18
+ declare const MAX_INVOICE_ATTACHMENTS = 5;
19
+ //#endregion
20
+ //#region src/core/warnings.d.ts
21
+ type KasszaWarningKind = "session" | "ledger" | "hook" | "document" | "lock" | "dedupe" | "cache";
22
+ interface KasszaWarning {
23
+ readonly kind: KasszaWarningKind;
24
+ readonly message: string;
25
+ readonly error: unknown;
26
+ readonly action?: AgentAction | undefined;
27
+ readonly operation?: string | undefined;
28
+ }
29
+ type WarningHook = (warning: KasszaWarning) => void;
30
+ //#endregion
31
+ export { AgentAction as a, AGENT_ACTIONS as i, KasszaWarningKind as n, MAX_INVOICE_ATTACHMENTS as o, WarningHook as r, SZAMLAZZ_AGENT_URL as s, KasszaWarning as t };
@@ -0,0 +1,31 @@
1
+ //#region src/core/actions.d.ts
2
+ declare const SZAMLAZZ_AGENT_URL = "https://www.szamlazz.hu/szamla/";
3
+ declare const AGENT_ACTIONS: {
4
+ readonly createInvoice: "action-xmlagentxmlfile";
5
+ readonly reverseInvoice: "action-szamla_agent_st";
6
+ readonly registerPayment: "action-szamla_agent_kifiz";
7
+ readonly getInvoicePdf: "action-szamla_agent_pdf";
8
+ readonly getInvoiceXml: "action-szamla_agent_xml";
9
+ readonly deleteProforma: "action-szamla_agent_dijbekero_torlese";
10
+ readonly createReceipt: "action-szamla_agent_nyugta_create";
11
+ readonly reverseReceipt: "action-szamla_agent_nyugta_storno";
12
+ readonly getReceipt: "action-szamla_agent_nyugta_get";
13
+ readonly sendReceipt: "action-szamla_agent_nyugta_send";
14
+ readonly queryTaxpayer: "action-szamla_agent_taxpayer";
15
+ readonly connectPrincipal: "action-agent_ceg_mb";
16
+ };
17
+ type AgentAction = keyof typeof AGENT_ACTIONS;
18
+ declare const MAX_INVOICE_ATTACHMENTS = 5;
19
+ //#endregion
20
+ //#region src/core/warnings.d.ts
21
+ type KasszaWarningKind = "session" | "ledger" | "hook" | "document" | "lock" | "dedupe" | "cache";
22
+ interface KasszaWarning {
23
+ readonly kind: KasszaWarningKind;
24
+ readonly message: string;
25
+ readonly error: unknown;
26
+ readonly action?: AgentAction | undefined;
27
+ readonly operation?: string | undefined;
28
+ }
29
+ type WarningHook = (warning: KasszaWarning) => void;
30
+ //#endregion
31
+ export { AgentAction as a, AGENT_ACTIONS as i, KasszaWarningKind as n, MAX_INVOICE_ATTACHMENTS as o, WarningHook as r, SZAMLAZZ_AGENT_URL as s, KasszaWarning as t };
@@ -0,0 +1,20 @@
1
+ //#region src/core/warnings.ts
2
+ function emitWarning(hook, warning, fallback = "silent") {
3
+ if (!hook) {
4
+ if (fallback === "console") console.warn(`[szamlazz] ${warning.message}`, warning.error);
5
+ return;
6
+ }
7
+ try {
8
+ const result = hook(warning);
9
+ if (result instanceof Promise) result.catch(() => void 0);
10
+ } catch {
11
+ return;
12
+ }
13
+ }
14
+ //#endregion
15
+ Object.defineProperty(exports, "emitWarning", {
16
+ enumerable: true,
17
+ get: function() {
18
+ return emitWarning;
19
+ }
20
+ });
@@ -0,0 +1,15 @@
1
+ //#region src/core/warnings.ts
2
+ function emitWarning(hook, warning, fallback = "silent") {
3
+ if (!hook) {
4
+ if (fallback === "console") console.warn(`[szamlazz] ${warning.message}`, warning.error);
5
+ return;
6
+ }
7
+ try {
8
+ const result = hook(warning);
9
+ if (result instanceof Promise) result.catch(() => void 0);
10
+ } catch {
11
+ return;
12
+ }
13
+ }
14
+ //#endregion
15
+ export { emitWarning as t };
@@ -1,5 +1,6 @@
1
- import { r as decodeUtf8 } from "./binary-D0M9U2MD.js";
1
+ import { t as emitWarning } from "./warnings-DwTl5J-2.js";
2
2
  import { r as roundMoney } from "./rounding-BLyHjjI5.js";
3
+ import { t as readRequestText } from "./request-body-uZHMRlQr.js";
3
4
  //#region src/payments/amounts.ts
4
5
  const ISO_ZERO_DECIMAL = /* @__PURE__ */ new Set([
5
6
  "BIF",
@@ -110,30 +111,8 @@ const DEFAULT_MAX_WEBHOOK_BYTES = 1048576;
110
111
  function tooLarge(provider, maxBytes) {
111
112
  return new WebhookVerificationError(provider, "payload_too_large", `A webhook törzse nagyobb a megengedett ${maxBytes} bájtnál.`);
112
113
  }
113
- async function readRawBody(request, provider, maxBytes = DEFAULT_MAX_WEBHOOK_BYTES) {
114
- const declared = Number(request.headers.get("content-length"));
115
- if (Number.isFinite(declared) && declared > maxBytes) throw tooLarge(provider, maxBytes);
116
- if (!request.body) return "";
117
- const reader = request.body.getReader();
118
- const chunks = [];
119
- let total = 0;
120
- for (;;) {
121
- const chunk = await reader.read();
122
- if (chunk.done) break;
123
- total += chunk.value.byteLength;
124
- if (total > maxBytes) {
125
- await reader.cancel().catch(() => void 0);
126
- throw tooLarge(provider, maxBytes);
127
- }
128
- chunks.push(chunk.value);
129
- }
130
- const bytes = new Uint8Array(total);
131
- let offset = 0;
132
- for (const chunk of chunks) {
133
- bytes.set(chunk, offset);
134
- offset += chunk.byteLength;
135
- }
136
- return decodeUtf8(bytes);
114
+ function readRawBody(request, provider, maxBytes = DEFAULT_MAX_WEBHOOK_BYTES) {
115
+ return readRequestText(request, maxBytes, () => tooLarge(provider, maxBytes));
137
116
  }
138
117
  function parseJsonObject(provider, payload) {
139
118
  let parsed;
@@ -153,6 +132,8 @@ function plainResponse(status, body) {
153
132
  }
154
133
  //#endregion
155
134
  //#region src/payments/webhook.ts
135
+ const WEBHOOK_DEDUPE_KEY_PREFIX = "szamlazz:evt:";
136
+ const DEFAULT_DEDUPE_TTL_SECONDS = 604800;
156
137
  function reportError(onError, error) {
157
138
  try {
158
139
  if (onError) onError(error);
@@ -170,5 +151,45 @@ async function respondToWebhook(options, run) {
170
151
  return plainResponse(500, "A webhook feldolgozása nem sikerült.");
171
152
  }
172
153
  }
154
+ function webhookDedupeKey(payment) {
155
+ return `${WEBHOOK_DEDUPE_KEY_PREFIX}${payment.provider}:${payment.eventId ?? ""}`;
156
+ }
157
+ function resolveDedupeTtl(value) {
158
+ if (value === void 0) return DEFAULT_DEDUPE_TTL_SECONDS;
159
+ if (!Number.isFinite(value) || value < 1) throw new TypeError(`A dedupeTtlSeconds legalább 1 másodperc legyen, kapott: ${String(value)}`);
160
+ return Math.ceil(value);
161
+ }
162
+ function dedupeWarning(options, operation, key, error) {
163
+ const message = operation === "get" ? `A webhook ismétlés-szűrő tárolója nem olvasható (${key}), a kassza feldolgozza az eseményt; a createOnce így is megakadályozza a dupla bizonylatot.` : `A webhook ismétlés-szűrő nem tudta megjelölni a feldolgozott eseményt (${key}); egy újraküldés ismét feldolgozásra kerül, de a createOnce nem állít ki duplát.`;
164
+ emitWarning(options.onWarning, {
165
+ kind: "dedupe",
166
+ message,
167
+ error,
168
+ operation
169
+ }, "console");
170
+ }
171
+ async function deliverPayment(options, payment, prepare = (value) => value) {
172
+ const store = options.dedupe;
173
+ if (!store || !payment.eventId) {
174
+ await options.onPayment(await prepare(payment));
175
+ return true;
176
+ }
177
+ const ttlSeconds = resolveDedupeTtl(options.dedupeTtlSeconds);
178
+ const key = webhookDedupeKey(payment);
179
+ let seen = false;
180
+ try {
181
+ seen = Boolean(await store.get(key));
182
+ } catch (error) {
183
+ dedupeWarning(options, "get", key, error);
184
+ }
185
+ if (seen) return false;
186
+ await options.onPayment(await prepare(payment));
187
+ try {
188
+ await store.set(key, "1", ttlSeconds);
189
+ } catch (error) {
190
+ dedupeWarning(options, "set", key, error);
191
+ }
192
+ return true;
193
+ }
173
194
  //#endregion
174
- export { readRawBody as a, isWebhookVerificationError as c, normalizeCurrency as d, parseDecimalAmount as f, plainResponse as i, currencyExponent as l, DEFAULT_MAX_WEBHOOK_BYTES as n, PaymentProviderError as o, parseJsonObject as r, WebhookVerificationError as s, respondToWebhook as t, fromMinorUnits as u };
195
+ export { webhookDedupeKey as a, plainResponse as c, WebhookVerificationError as d, isWebhookVerificationError as f, parseDecimalAmount as g, normalizeCurrency as h, respondToWebhook as i, readRawBody as l, fromMinorUnits as m, WEBHOOK_DEDUPE_KEY_PREFIX as n, DEFAULT_MAX_WEBHOOK_BYTES as o, currencyExponent as p, deliverPayment as r, parseJsonObject as s, DEFAULT_DEDUPE_TTL_SECONDS as t, PaymentProviderError as u };
@@ -1,5 +1,6 @@
1
- const require_binary = require("./binary-B89HM03_.cjs");
1
+ const require_warnings = require("./warnings-DeIw5RFj.cjs");
2
2
  const require_rounding = require("./rounding-TxoWy2ww.cjs");
3
+ const require_request_body = require("./request-body-CH6ZGOrq.cjs");
3
4
  //#region src/payments/amounts.ts
4
5
  const ISO_ZERO_DECIMAL = /* @__PURE__ */ new Set([
5
6
  "BIF",
@@ -110,30 +111,8 @@ const DEFAULT_MAX_WEBHOOK_BYTES = 1048576;
110
111
  function tooLarge(provider, maxBytes) {
111
112
  return new WebhookVerificationError(provider, "payload_too_large", `A webhook törzse nagyobb a megengedett ${maxBytes} bájtnál.`);
112
113
  }
113
- async function readRawBody(request, provider, maxBytes = DEFAULT_MAX_WEBHOOK_BYTES) {
114
- const declared = Number(request.headers.get("content-length"));
115
- if (Number.isFinite(declared) && declared > maxBytes) throw tooLarge(provider, maxBytes);
116
- if (!request.body) return "";
117
- const reader = request.body.getReader();
118
- const chunks = [];
119
- let total = 0;
120
- for (;;) {
121
- const chunk = await reader.read();
122
- if (chunk.done) break;
123
- total += chunk.value.byteLength;
124
- if (total > maxBytes) {
125
- await reader.cancel().catch(() => void 0);
126
- throw tooLarge(provider, maxBytes);
127
- }
128
- chunks.push(chunk.value);
129
- }
130
- const bytes = new Uint8Array(total);
131
- let offset = 0;
132
- for (const chunk of chunks) {
133
- bytes.set(chunk, offset);
134
- offset += chunk.byteLength;
135
- }
136
- return require_binary.decodeUtf8(bytes);
114
+ function readRawBody(request, provider, maxBytes = DEFAULT_MAX_WEBHOOK_BYTES) {
115
+ return require_request_body.readRequestText(request, maxBytes, () => tooLarge(provider, maxBytes));
137
116
  }
138
117
  function parseJsonObject(provider, payload) {
139
118
  let parsed;
@@ -153,6 +132,8 @@ function plainResponse(status, body) {
153
132
  }
154
133
  //#endregion
155
134
  //#region src/payments/webhook.ts
135
+ const WEBHOOK_DEDUPE_KEY_PREFIX = "szamlazz:evt:";
136
+ const DEFAULT_DEDUPE_TTL_SECONDS = 604800;
156
137
  function reportError(onError, error) {
157
138
  try {
158
139
  if (onError) onError(error);
@@ -170,7 +151,53 @@ async function respondToWebhook(options, run) {
170
151
  return plainResponse(500, "A webhook feldolgozása nem sikerült.");
171
152
  }
172
153
  }
154
+ function webhookDedupeKey(payment) {
155
+ return `${WEBHOOK_DEDUPE_KEY_PREFIX}${payment.provider}:${payment.eventId ?? ""}`;
156
+ }
157
+ function resolveDedupeTtl(value) {
158
+ if (value === void 0) return DEFAULT_DEDUPE_TTL_SECONDS;
159
+ if (!Number.isFinite(value) || value < 1) throw new TypeError(`A dedupeTtlSeconds legalább 1 másodperc legyen, kapott: ${String(value)}`);
160
+ return Math.ceil(value);
161
+ }
162
+ function dedupeWarning(options, operation, key, error) {
163
+ const message = operation === "get" ? `A webhook ismétlés-szűrő tárolója nem olvasható (${key}), a kassza feldolgozza az eseményt; a createOnce így is megakadályozza a dupla bizonylatot.` : `A webhook ismétlés-szűrő nem tudta megjelölni a feldolgozott eseményt (${key}); egy újraküldés ismét feldolgozásra kerül, de a createOnce nem állít ki duplát.`;
164
+ require_warnings.emitWarning(options.onWarning, {
165
+ kind: "dedupe",
166
+ message,
167
+ error,
168
+ operation
169
+ }, "console");
170
+ }
171
+ async function deliverPayment(options, payment, prepare = (value) => value) {
172
+ const store = options.dedupe;
173
+ if (!store || !payment.eventId) {
174
+ await options.onPayment(await prepare(payment));
175
+ return true;
176
+ }
177
+ const ttlSeconds = resolveDedupeTtl(options.dedupeTtlSeconds);
178
+ const key = webhookDedupeKey(payment);
179
+ let seen = false;
180
+ try {
181
+ seen = Boolean(await store.get(key));
182
+ } catch (error) {
183
+ dedupeWarning(options, "get", key, error);
184
+ }
185
+ if (seen) return false;
186
+ await options.onPayment(await prepare(payment));
187
+ try {
188
+ await store.set(key, "1", ttlSeconds);
189
+ } catch (error) {
190
+ dedupeWarning(options, "set", key, error);
191
+ }
192
+ return true;
193
+ }
173
194
  //#endregion
195
+ Object.defineProperty(exports, "DEFAULT_DEDUPE_TTL_SECONDS", {
196
+ enumerable: true,
197
+ get: function() {
198
+ return DEFAULT_DEDUPE_TTL_SECONDS;
199
+ }
200
+ });
174
201
  Object.defineProperty(exports, "DEFAULT_MAX_WEBHOOK_BYTES", {
175
202
  enumerable: true,
176
203
  get: function() {
@@ -183,6 +210,12 @@ Object.defineProperty(exports, "PaymentProviderError", {
183
210
  return PaymentProviderError;
184
211
  }
185
212
  });
213
+ Object.defineProperty(exports, "WEBHOOK_DEDUPE_KEY_PREFIX", {
214
+ enumerable: true,
215
+ get: function() {
216
+ return WEBHOOK_DEDUPE_KEY_PREFIX;
217
+ }
218
+ });
186
219
  Object.defineProperty(exports, "WebhookVerificationError", {
187
220
  enumerable: true,
188
221
  get: function() {
@@ -195,6 +228,12 @@ Object.defineProperty(exports, "currencyExponent", {
195
228
  return currencyExponent;
196
229
  }
197
230
  });
231
+ Object.defineProperty(exports, "deliverPayment", {
232
+ enumerable: true,
233
+ get: function() {
234
+ return deliverPayment;
235
+ }
236
+ });
198
237
  Object.defineProperty(exports, "fromMinorUnits", {
199
238
  enumerable: true,
200
239
  get: function() {
@@ -243,3 +282,9 @@ Object.defineProperty(exports, "respondToWebhook", {
243
282
  return respondToWebhook;
244
283
  }
245
284
  });
285
+ Object.defineProperty(exports, "webhookDedupeKey", {
286
+ enumerable: true,
287
+ get: function() {
288
+ return webhookDedupeKey;
289
+ }
290
+ });
@@ -0,0 +1,11 @@
1
+ import { i as PaymentEvent, u as PaymentWebhookBaseOptions } from "./types-B1A8mUIE.cjs";
2
+ //#region src/payments/webhook.d.ts
3
+ declare const WEBHOOK_DEDUPE_KEY_PREFIX = "szamlazz:evt:";
4
+ declare const DEFAULT_DEDUPE_TTL_SECONDS: number;
5
+ type WebhookHandler = (request: Request) => Promise<Response>;
6
+ declare function respondToWebhook(options: Pick<PaymentWebhookBaseOptions, "onError">, run: () => Promise<Response>): Promise<Response>;
7
+ type DedupeOptions = Pick<PaymentWebhookBaseOptions, "onPayment" | "onWarning" | "dedupe" | "dedupeTtlSeconds">;
8
+ declare function webhookDedupeKey(payment: Pick<PaymentEvent, "provider" | "eventId">): string;
9
+ declare function deliverPayment(options: DedupeOptions, payment: PaymentEvent, prepare?: (payment: PaymentEvent) => PaymentEvent | Promise<PaymentEvent>): Promise<boolean>;
10
+ //#endregion
11
+ export { respondToWebhook as a, deliverPayment as i, WEBHOOK_DEDUPE_KEY_PREFIX as n, webhookDedupeKey as o, WebhookHandler as r, DEFAULT_DEDUPE_TTL_SECONDS as t };
@@ -0,0 +1,11 @@
1
+ import { i as PaymentEvent, u as PaymentWebhookBaseOptions } from "./types-ByAEvGsZ.js";
2
+ //#region src/payments/webhook.d.ts
3
+ declare const WEBHOOK_DEDUPE_KEY_PREFIX = "szamlazz:evt:";
4
+ declare const DEFAULT_DEDUPE_TTL_SECONDS: number;
5
+ type WebhookHandler = (request: Request) => Promise<Response>;
6
+ declare function respondToWebhook(options: Pick<PaymentWebhookBaseOptions, "onError">, run: () => Promise<Response>): Promise<Response>;
7
+ type DedupeOptions = Pick<PaymentWebhookBaseOptions, "onPayment" | "onWarning" | "dedupe" | "dedupeTtlSeconds">;
8
+ declare function webhookDedupeKey(payment: Pick<PaymentEvent, "provider" | "eventId">): string;
9
+ declare function deliverPayment(options: DedupeOptions, payment: PaymentEvent, prepare?: (payment: PaymentEvent) => PaymentEvent | Promise<PaymentEvent>): Promise<boolean>;
10
+ //#endregion
11
+ export { respondToWebhook as a, deliverPayment as i, WEBHOOK_DEDUPE_KEY_PREFIX as n, webhookDedupeKey as o, WebhookHandler as r, DEFAULT_DEDUPE_TTL_SECONDS as t };
package/llms.txt CHANGED
@@ -1,16 +1,17 @@
1
1
  # kassza
2
2
 
3
- > Zero-dependency TypeScript client for the Számlázz.hu Számla Agent API (Hungarian invoicing): invoices, proformas, receipts, reversals, payments, PDFs, NAV taxpayer lookup, IPN webhooks. Unofficial.
3
+ > Zero-dependency TypeScript client for the Számlázz.hu Számla Agent API (Hungarian invoicing): invoices, proformas, receipts, reversals, payments, PDFs, NAV taxpayer lookup, IPN webhooks. Also: exactly-once documents from Stripe, SimplePay, Barion, Revolut and PayPal payments, NAV daily receipt reports, delegated invoicing, the Számlázz.hu data link, a fake Számla Agent for tests, a CLI and an MCP server. Also: cross-process exactly-once locks, a receipt journal for NAV reports, partial refunds as corrective invoices, bulk/recurring invoicing, Express adapter, observability without telemetry. Unofficial.
4
4
 
5
5
  ## Docs for coding agents
6
6
 
7
7
  - [Start here](agents/README.md): overview, the five rules, vocabulary
8
- - [Pitfalls](agents/pitfalls.md): hard rules and error categories
9
- - [API reference](agents/api.md): every method, input and output
10
- - [Recipes](agents/recipes.md): webhooks, idempotency, receipts, IPN, storage, serverless, tests
8
+ - [Pitfalls](agents/pitfalls.md): hard rules, legal rules for receipts, error categories
9
+ - [API reference](agents/api.md): every method, input and output, all subpath modules
10
+ - [Recipes](agents/recipes.md): webhooks, exactly-once invoicing, receipts, IPN, storage, serverless, tests, payment providers, NAV reports, delegated invoicing, data link, MCP, receipt journal, monthly invoicing, observability
11
11
  - [Claude Code skill](agents/skills/kassza/SKILL.md)
12
+ - [Migration skill from szamlazz.js](agents/skills/migrate-from-szamlazz-js/SKILL.md)
12
13
 
13
14
  ## Human docs
14
15
 
15
16
  - [README](README.md): short Hungarian quick start
16
- - [Official Számlázz.hu Agent docs](https://docs.szamlazz.hu/hu/agent/)
17
+ - [Official Számlázz.hu Agent docs](https://docs.szamlazz.hu/hu/agent/)