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,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_webhook = require("../webhook-C76bV-4R.cjs");
3
- const require_crypto = require("../crypto-B8lERvR1.cjs");
2
+ const require_crypto = require("../crypto-Dpn4FHQ6.cjs");
3
+ const require_webhook = require("../webhook-Ckj-_hPD.cjs");
4
4
  const require_json = require("../json-4y4E2xxS.cjs");
5
5
  //#region src/payments/stripe.ts
6
6
  const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
@@ -145,6 +145,22 @@ function refundKind(event) {
145
145
  const previouslyRefunded = require_json.numeric(event.previousAttributes?.amount_refunded) ?? 0;
146
146
  return (charge.refunded === true || amount > 0 && refunded >= amount) && previouslyRefunded === 0 ? "refunded" : "partially-refunded";
147
147
  }
148
+ function refundsOf(event) {
149
+ const charge = event.object;
150
+ const currency = require_json.text(charge.currency);
151
+ const refunded = require_json.numeric(charge.amount_refunded);
152
+ const previous = require_json.numeric(event.previousAttributes?.amount_refunded);
153
+ if (!currency || refunded === void 0 || previous === void 0 || refunded <= previous) return;
154
+ return [{
155
+ id: event.id,
156
+ amount: {
157
+ value: require_webhook.fromMinorUnits(refunded - previous, currency, "stripe"),
158
+ currency: require_webhook.normalizeCurrency(currency)
159
+ },
160
+ refundedBefore: require_webhook.fromMinorUnits(previous, currency, "stripe"),
161
+ createdAt: paidAtOf(event)
162
+ }];
163
+ }
148
164
  function fromRefundedCharge(event, options) {
149
165
  const charge = event.object;
150
166
  return {
@@ -156,6 +172,7 @@ function fromRefundedCharge(event, options) {
156
172
  orderRef: orderRefOf(charge),
157
173
  amount: amountOf(charge, "amount"),
158
174
  refundedAmount: amountOf(charge, "amount_refunded"),
175
+ refunds: refundsOf(event),
159
176
  paidAt: paidAtOf(event),
160
177
  method: options.method ?? "bankkártya",
161
178
  customer: customerOf(require_json.record(charge.billing_details)),
@@ -296,7 +313,7 @@ function stripeWebhook(options) {
296
313
  });
297
314
  const event = parseStripeEvent(payload);
298
315
  const payment = stripePaymentEvent(event, { method: options.method });
299
- if (payment) await options.onPayment(await enrich(payment, event, options));
316
+ if (payment) await require_webhook.deliverPayment(options, payment, (value) => enrich(value, event, options));
300
317
  return require_webhook.plainResponse(200, "OK");
301
318
  });
302
319
  }
@@ -1,6 +1,6 @@
1
- import { i as PaymentEvent, l as PaymentWebhookBaseOptions, s as PaymentLineItem } from "../types-COf1LAD-.cjs";
1
+ import { i as PaymentEvent, s as PaymentLineItem, u as PaymentWebhookBaseOptions } from "../types-B1A8mUIE.cjs";
2
2
  import { t as JsonRecord } from "../json-B70TwoX1.cjs";
3
- import { t as WebhookHandler } from "../webhook-CfaDgcL0.cjs";
3
+ import { r as WebhookHandler } from "../webhook-CmdhGiH5.cjs";
4
4
  //#region src/payments/stripe.d.ts
5
5
  export declare const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
6
6
  export declare const STRIPE_API_URL = "https://api.stripe.com";
@@ -1,6 +1,6 @@
1
- import { i as PaymentEvent, l as PaymentWebhookBaseOptions, s as PaymentLineItem } from "../types-COf1LAD-.js";
1
+ import { i as PaymentEvent, s as PaymentLineItem, u as PaymentWebhookBaseOptions } from "../types-ByAEvGsZ.js";
2
2
  import { t as JsonRecord } from "../json-B70TwoX1.js";
3
- import { t as WebhookHandler } from "../webhook-q2OzNwd7.js";
3
+ import { r as WebhookHandler } from "../webhook-D6lEejob.js";
4
4
  //#region src/payments/stripe.d.ts
5
5
  export declare const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
6
6
  export declare const STRIPE_API_URL = "https://api.stripe.com";
@@ -1,5 +1,5 @@
1
- import { a as readRawBody, d as normalizeCurrency, i as plainResponse, o as PaymentProviderError, r as parseJsonObject, s as WebhookVerificationError, t as respondToWebhook, u as fromMinorUnits } from "../webhook-D4lvtex1.js";
2
- import { i as timingSafeEqual, r as hmacHex } from "../crypto-DK_osBVy.js";
1
+ import { a as timingSafeEqual, i as hmacHex } from "../crypto-usDg8L2K.js";
2
+ import { c as plainResponse, d as WebhookVerificationError, h as normalizeCurrency, i as respondToWebhook, l as readRawBody, m as fromMinorUnits, r as deliverPayment, s as parseJsonObject, u as PaymentProviderError } from "../webhook-CQVShAfI.js";
3
3
  import { a as text, i as records, n as path, r as record, t as numeric } from "../json-DjnqnaJK.js";
4
4
  //#region src/payments/stripe.ts
5
5
  const STRIPE_DEFAULT_TOLERANCE_SECONDS = 300;
@@ -144,6 +144,22 @@ function refundKind(event) {
144
144
  const previouslyRefunded = numeric(event.previousAttributes?.amount_refunded) ?? 0;
145
145
  return (charge.refunded === true || amount > 0 && refunded >= amount) && previouslyRefunded === 0 ? "refunded" : "partially-refunded";
146
146
  }
147
+ function refundsOf(event) {
148
+ const charge = event.object;
149
+ const currency = text(charge.currency);
150
+ const refunded = numeric(charge.amount_refunded);
151
+ const previous = numeric(event.previousAttributes?.amount_refunded);
152
+ if (!currency || refunded === void 0 || previous === void 0 || refunded <= previous) return;
153
+ return [{
154
+ id: event.id,
155
+ amount: {
156
+ value: fromMinorUnits(refunded - previous, currency, "stripe"),
157
+ currency: normalizeCurrency(currency)
158
+ },
159
+ refundedBefore: fromMinorUnits(previous, currency, "stripe"),
160
+ createdAt: paidAtOf(event)
161
+ }];
162
+ }
147
163
  function fromRefundedCharge(event, options) {
148
164
  const charge = event.object;
149
165
  return {
@@ -155,6 +171,7 @@ function fromRefundedCharge(event, options) {
155
171
  orderRef: orderRefOf(charge),
156
172
  amount: amountOf(charge, "amount"),
157
173
  refundedAmount: amountOf(charge, "amount_refunded"),
174
+ refunds: refundsOf(event),
158
175
  paidAt: paidAtOf(event),
159
176
  method: options.method ?? "bankkártya",
160
177
  customer: customerOf(record(charge.billing_details)),
@@ -295,7 +312,7 @@ function stripeWebhook(options) {
295
312
  });
296
313
  const event = parseStripeEvent(payload);
297
314
  const payment = stripePaymentEvent(event, { method: options.method });
298
- if (payment) await options.onPayment(await enrich(payment, event, options));
315
+ if (payment) await deliverPayment(options, payment, (value) => enrich(value, event, options));
299
316
  return plainResponse(200, "OK");
300
317
  });
301
318
  }
@@ -0,0 +1,52 @@
1
+ import { r as Receipt } from "./types-D1zDOH_F.js";
2
+ import { n as InvoiceDetails } from "./get-Byc9T5WO.js";
3
+ //#region src/data-link/push.d.ts
4
+ type DataLinkPushKind = "invoice" | "incoming-invoice" | "bank-transaction" | "receipts";
5
+ type DataLinkErrorReason = "invalid_payload" | "payload_too_large" | "unknown_document" | "missing_key";
6
+ declare class DataLinkError extends Error {
7
+ override readonly name: string;
8
+ readonly reason: DataLinkErrorReason;
9
+ constructor(reason: DataLinkErrorReason, message: string, cause?: unknown);
10
+ }
11
+ interface DataLinkPushBase {
12
+ readonly key: string | undefined;
13
+ readonly raw: string;
14
+ }
15
+ interface DataLinkInvoicePush extends DataLinkPushBase {
16
+ readonly kind: "invoice" | "incoming-invoice";
17
+ readonly id: number;
18
+ readonly invoice: InvoiceDetails;
19
+ readonly deleted: boolean;
20
+ }
21
+ interface DataLinkBankTransactionPartner {
22
+ readonly name?: string | undefined;
23
+ readonly accountNumber?: string | undefined;
24
+ }
25
+ interface DataLinkBankTransaction {
26
+ readonly id: number;
27
+ readonly accountNumber: string;
28
+ readonly valueDate: string;
29
+ readonly direction: "in" | "out";
30
+ readonly type?: string | undefined;
31
+ readonly technical: boolean;
32
+ readonly amount: number;
33
+ readonly currency: string;
34
+ readonly partner?: DataLinkBankTransactionPartner | undefined;
35
+ readonly reference?: string | undefined;
36
+ }
37
+ interface DataLinkBankTransactionPush extends DataLinkPushBase {
38
+ readonly kind: "bank-transaction";
39
+ readonly transaction: DataLinkBankTransaction;
40
+ }
41
+ interface DataLinkArchivedReceipt {
42
+ readonly receipt: Receipt;
43
+ readonly issuerTaxNumber?: string | undefined;
44
+ }
45
+ interface DataLinkReceiptsPush extends DataLinkPushBase {
46
+ readonly kind: "receipts";
47
+ readonly receipts: readonly DataLinkArchivedReceipt[];
48
+ }
49
+ type DataLinkPush = DataLinkInvoicePush | DataLinkBankTransactionPush | DataLinkReceiptsPush;
50
+ declare function parseDataLinkPush(xml: string, key?: string | undefined): DataLinkPush;
51
+ //#endregion
52
+ export { DataLinkError as a, DataLinkPush as c, parseDataLinkPush as d, DataLinkBankTransactionPush as i, DataLinkPushKind as l, DataLinkBankTransaction as n, DataLinkErrorReason as o, DataLinkBankTransactionPartner as r, DataLinkInvoicePush as s, DataLinkArchivedReceipt as t, DataLinkReceiptsPush as u };
@@ -0,0 +1,52 @@
1
+ import { r as Receipt } from "./types-lnKkQdot.cjs";
2
+ import { n as InvoiceDetails } from "./get-Byc9T5WO.cjs";
3
+ //#region src/data-link/push.d.ts
4
+ type DataLinkPushKind = "invoice" | "incoming-invoice" | "bank-transaction" | "receipts";
5
+ type DataLinkErrorReason = "invalid_payload" | "payload_too_large" | "unknown_document" | "missing_key";
6
+ declare class DataLinkError extends Error {
7
+ override readonly name: string;
8
+ readonly reason: DataLinkErrorReason;
9
+ constructor(reason: DataLinkErrorReason, message: string, cause?: unknown);
10
+ }
11
+ interface DataLinkPushBase {
12
+ readonly key: string | undefined;
13
+ readonly raw: string;
14
+ }
15
+ interface DataLinkInvoicePush extends DataLinkPushBase {
16
+ readonly kind: "invoice" | "incoming-invoice";
17
+ readonly id: number;
18
+ readonly invoice: InvoiceDetails;
19
+ readonly deleted: boolean;
20
+ }
21
+ interface DataLinkBankTransactionPartner {
22
+ readonly name?: string | undefined;
23
+ readonly accountNumber?: string | undefined;
24
+ }
25
+ interface DataLinkBankTransaction {
26
+ readonly id: number;
27
+ readonly accountNumber: string;
28
+ readonly valueDate: string;
29
+ readonly direction: "in" | "out";
30
+ readonly type?: string | undefined;
31
+ readonly technical: boolean;
32
+ readonly amount: number;
33
+ readonly currency: string;
34
+ readonly partner?: DataLinkBankTransactionPartner | undefined;
35
+ readonly reference?: string | undefined;
36
+ }
37
+ interface DataLinkBankTransactionPush extends DataLinkPushBase {
38
+ readonly kind: "bank-transaction";
39
+ readonly transaction: DataLinkBankTransaction;
40
+ }
41
+ interface DataLinkArchivedReceipt {
42
+ readonly receipt: Receipt;
43
+ readonly issuerTaxNumber?: string | undefined;
44
+ }
45
+ interface DataLinkReceiptsPush extends DataLinkPushBase {
46
+ readonly kind: "receipts";
47
+ readonly receipts: readonly DataLinkArchivedReceipt[];
48
+ }
49
+ type DataLinkPush = DataLinkInvoicePush | DataLinkBankTransactionPush | DataLinkReceiptsPush;
50
+ declare function parseDataLinkPush(xml: string, key?: string | undefined): DataLinkPush;
51
+ //#endregion
52
+ export { DataLinkError as a, DataLinkPush as c, parseDataLinkPush as d, DataLinkBankTransactionPush as i, DataLinkPushKind as l, DataLinkBankTransaction as n, DataLinkErrorReason as o, DataLinkBankTransactionPartner as r, DataLinkInvoicePush as s, DataLinkArchivedReceipt as t, DataLinkReceiptsPush as u };
@@ -0,0 +1,124 @@
1
+ import { r as SzamlazzError } from "./errors-DtN4g5Z9.js";
2
+ import { t as base64ToBytes } from "./binary-D0M9U2MD.js";
3
+ import { c as childNumber, l as childText } from "./serialize-B2eFh3D-.js";
4
+ import { a as looksLikeXml, c as readDocumentHeaders, d as throwIfHeaderError, f as throwIfHttpError, h as unexpectedResponse, l as readHeader, m as throwIfXmlFailure, o as parseDoneText, p as throwIfTextError, s as parseResponseXml } from "./parse-Cr7yQ3_z.js";
5
+ import { n as toAgentDate } from "./dates-CXyj7Azy.js";
6
+ //#region src/invoices/reference.ts
7
+ const AGENT_XSD_BASE_URL = "https://www.szamlazz.hu/szamla/docs/xsds/";
8
+ function validationError(message) {
9
+ return new SzamlazzError(message, { category: "validation" });
10
+ }
11
+ function requireText(value, message) {
12
+ const trimmed = typeof value === "string" ? value.trim() : "";
13
+ if (trimmed === "") throw validationError(message);
14
+ return trimmed;
15
+ }
16
+ function optionalText(value) {
17
+ const trimmed = value?.trim();
18
+ return trimmed ? trimmed : void 0;
19
+ }
20
+ function agentDate(input, field) {
21
+ try {
22
+ return toAgentDate(input);
23
+ } catch (error) {
24
+ const detail = error instanceof Error ? error.message : String(error);
25
+ throw new SzamlazzError(`Érvénytelen dátum (${field}): ${detail}`, {
26
+ category: "validation",
27
+ cause: error
28
+ });
29
+ }
30
+ }
31
+ function optionalAgentDate(input, field) {
32
+ return input === void 0 ? void 0 : agentDate(input, field);
33
+ }
34
+ const REFERENCE_KEYS = [
35
+ "invoiceNumber",
36
+ "orderNumber",
37
+ "externalId"
38
+ ];
39
+ const REFERENCE_HINT = "Add meg a számlaszámot szövegként, vagy pontosan egyet ezek közül: { invoiceNumber }, { orderNumber }, { externalId }.";
40
+ function resolveInvoiceReference(reference) {
41
+ if (typeof reference === "string") return {
42
+ kind: "invoiceNumber",
43
+ value: requireText(reference, `Üres számlaszám. ${REFERENCE_HINT}`)
44
+ };
45
+ if (typeof reference !== "object" || reference === null) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT}`);
46
+ const record = reference;
47
+ const present = REFERENCE_KEYS.filter((key) => record[key] !== void 0);
48
+ const [kind] = present;
49
+ if (kind === void 0 || present.length > 1) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT}`);
50
+ return {
51
+ kind,
52
+ value: requireText(record[kind], `Üres ${kind} érték. ${REFERENCE_HINT}`)
53
+ };
54
+ }
55
+ function referenceValue(reference, kind) {
56
+ return reference.kind === kind ? reference.value : void 0;
57
+ }
58
+ function readNumericHeader(headers, name) {
59
+ const value = readHeader(headers, name);
60
+ if (value === void 0) return void 0;
61
+ const parsed = Number(value.replace(",", "."));
62
+ return Number.isFinite(parsed) ? parsed : void 0;
63
+ }
64
+ function headerSummary(response) {
65
+ const headers = readDocumentHeaders(response.headers);
66
+ return {
67
+ number: headers.number,
68
+ netTotal: headers.netTotal,
69
+ grossTotal: headers.grossTotal,
70
+ outstanding: readNumericHeader(response.headers, "szlahu_kintlevoseg"),
71
+ buyerAccountUrl: headers.buyerAccountUrl
72
+ };
73
+ }
74
+ function decodeResponsePdf(root, response) {
75
+ const encoded = childText(root, "pdf");
76
+ if (encoded === void 0) return void 0;
77
+ try {
78
+ return base64ToBytes(encoded);
79
+ } catch (error) {
80
+ throw new SzamlazzError("A válaszban kapott PDF nem érvényes base64.", {
81
+ category: "unexpected_response",
82
+ action: response.action,
83
+ httpStatus: response.status,
84
+ cause: error
85
+ });
86
+ }
87
+ }
88
+ function readInvoiceResultXml(root, response) {
89
+ const headers = headerSummary(response);
90
+ return {
91
+ number: childText(root, "szamlaszam") ?? headers.number,
92
+ netTotal: childNumber(root, "szamlanetto") ?? headers.netTotal,
93
+ grossTotal: childNumber(root, "szamlabrutto") ?? headers.grossTotal,
94
+ outstanding: childNumber(root, "kintlevoseg") ?? headers.outstanding,
95
+ buyerAccountUrl: childText(root, "vevoifiokurl") ?? headers.buyerAccountUrl,
96
+ pdf: decodeResponsePdf(root, response)
97
+ };
98
+ }
99
+ const INVOICE_RESULT_ROOT = "xmlszamlavalasz";
100
+ function parseInvoiceResult(response) {
101
+ throwIfHeaderError(response);
102
+ if (response.isPdf) return {
103
+ ...headerSummary(response),
104
+ pdf: response.body
105
+ };
106
+ throwIfTextError(response);
107
+ throwIfHttpError(response);
108
+ if (looksLikeXml(response)) {
109
+ const root = parseResponseXml(response);
110
+ throwIfXmlFailure(root, response);
111
+ if (root.name !== INVOICE_RESULT_ROOT || childText(root, "sikeres")?.toLowerCase() !== "true") throw unexpectedResponse(response, `${INVOICE_RESULT_ROOT} XML választ vártunk.`);
112
+ return readInvoiceResultXml(root, response);
113
+ }
114
+ const headers = headerSummary(response);
115
+ const done = parseDoneText(response.text());
116
+ if (done) return {
117
+ ...headers,
118
+ number: done.number ?? headers.number
119
+ };
120
+ if (headers.number !== void 0) return headers;
121
+ throw unexpectedResponse(response);
122
+ }
123
+ //#endregion
124
+ export { optionalText as a, requireText as c, optionalAgentDate as i, resolveInvoiceReference as l, agentDate as n, parseInvoiceResult as o, decodeResponsePdf as r, referenceValue as s, AGENT_XSD_BASE_URL as t, validationError as u };
@@ -0,0 +1,183 @@
1
+ const require_errors = require("./errors-EE96_6D_.cjs");
2
+ const require_binary = require("./binary-B89HM03_.cjs");
3
+ const require_serialize = require("./serialize-CquIsxA-.cjs");
4
+ const require_parse = require("./parse-DOA2XQ3e.cjs");
5
+ const require_dates = require("./dates-CPgBodkP.cjs");
6
+ //#region src/invoices/reference.ts
7
+ const AGENT_XSD_BASE_URL = "https://www.szamlazz.hu/szamla/docs/xsds/";
8
+ function validationError(message) {
9
+ return new require_errors.SzamlazzError(message, { category: "validation" });
10
+ }
11
+ function requireText(value, message) {
12
+ const trimmed = typeof value === "string" ? value.trim() : "";
13
+ if (trimmed === "") throw validationError(message);
14
+ return trimmed;
15
+ }
16
+ function optionalText(value) {
17
+ const trimmed = value?.trim();
18
+ return trimmed ? trimmed : void 0;
19
+ }
20
+ function agentDate(input, field) {
21
+ try {
22
+ return require_dates.toAgentDate(input);
23
+ } catch (error) {
24
+ const detail = error instanceof Error ? error.message : String(error);
25
+ throw new require_errors.SzamlazzError(`Érvénytelen dátum (${field}): ${detail}`, {
26
+ category: "validation",
27
+ cause: error
28
+ });
29
+ }
30
+ }
31
+ function optionalAgentDate(input, field) {
32
+ return input === void 0 ? void 0 : agentDate(input, field);
33
+ }
34
+ const REFERENCE_KEYS = [
35
+ "invoiceNumber",
36
+ "orderNumber",
37
+ "externalId"
38
+ ];
39
+ const REFERENCE_HINT = "Add meg a számlaszámot szövegként, vagy pontosan egyet ezek közül: { invoiceNumber }, { orderNumber }, { externalId }.";
40
+ function resolveInvoiceReference(reference) {
41
+ if (typeof reference === "string") return {
42
+ kind: "invoiceNumber",
43
+ value: requireText(reference, `Üres számlaszám. ${REFERENCE_HINT}`)
44
+ };
45
+ if (typeof reference !== "object" || reference === null) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT}`);
46
+ const record = reference;
47
+ const present = REFERENCE_KEYS.filter((key) => record[key] !== void 0);
48
+ const [kind] = present;
49
+ if (kind === void 0 || present.length > 1) throw validationError(`Érvénytelen bizonylat-hivatkozás. ${REFERENCE_HINT}`);
50
+ return {
51
+ kind,
52
+ value: requireText(record[kind], `Üres ${kind} érték. ${REFERENCE_HINT}`)
53
+ };
54
+ }
55
+ function referenceValue(reference, kind) {
56
+ return reference.kind === kind ? reference.value : void 0;
57
+ }
58
+ function readNumericHeader(headers, name) {
59
+ const value = require_parse.readHeader(headers, name);
60
+ if (value === void 0) return void 0;
61
+ const parsed = Number(value.replace(",", "."));
62
+ return Number.isFinite(parsed) ? parsed : void 0;
63
+ }
64
+ function headerSummary(response) {
65
+ const headers = require_parse.readDocumentHeaders(response.headers);
66
+ return {
67
+ number: headers.number,
68
+ netTotal: headers.netTotal,
69
+ grossTotal: headers.grossTotal,
70
+ outstanding: readNumericHeader(response.headers, "szlahu_kintlevoseg"),
71
+ buyerAccountUrl: headers.buyerAccountUrl
72
+ };
73
+ }
74
+ function decodeResponsePdf(root, response) {
75
+ const encoded = require_serialize.childText(root, "pdf");
76
+ if (encoded === void 0) return void 0;
77
+ try {
78
+ return require_binary.base64ToBytes(encoded);
79
+ } catch (error) {
80
+ throw new require_errors.SzamlazzError("A válaszban kapott PDF nem érvényes base64.", {
81
+ category: "unexpected_response",
82
+ action: response.action,
83
+ httpStatus: response.status,
84
+ cause: error
85
+ });
86
+ }
87
+ }
88
+ function readInvoiceResultXml(root, response) {
89
+ const headers = headerSummary(response);
90
+ return {
91
+ number: require_serialize.childText(root, "szamlaszam") ?? headers.number,
92
+ netTotal: require_serialize.childNumber(root, "szamlanetto") ?? headers.netTotal,
93
+ grossTotal: require_serialize.childNumber(root, "szamlabrutto") ?? headers.grossTotal,
94
+ outstanding: require_serialize.childNumber(root, "kintlevoseg") ?? headers.outstanding,
95
+ buyerAccountUrl: require_serialize.childText(root, "vevoifiokurl") ?? headers.buyerAccountUrl,
96
+ pdf: decodeResponsePdf(root, response)
97
+ };
98
+ }
99
+ const INVOICE_RESULT_ROOT = "xmlszamlavalasz";
100
+ function parseInvoiceResult(response) {
101
+ require_parse.throwIfHeaderError(response);
102
+ if (response.isPdf) return {
103
+ ...headerSummary(response),
104
+ pdf: response.body
105
+ };
106
+ require_parse.throwIfTextError(response);
107
+ require_parse.throwIfHttpError(response);
108
+ if (require_parse.looksLikeXml(response)) {
109
+ const root = require_parse.parseResponseXml(response);
110
+ require_parse.throwIfXmlFailure(root, response);
111
+ if (root.name !== INVOICE_RESULT_ROOT || require_serialize.childText(root, "sikeres")?.toLowerCase() !== "true") throw require_parse.unexpectedResponse(response, `${INVOICE_RESULT_ROOT} XML választ vártunk.`);
112
+ return readInvoiceResultXml(root, response);
113
+ }
114
+ const headers = headerSummary(response);
115
+ const done = require_parse.parseDoneText(response.text());
116
+ if (done) return {
117
+ ...headers,
118
+ number: done.number ?? headers.number
119
+ };
120
+ if (headers.number !== void 0) return headers;
121
+ throw require_parse.unexpectedResponse(response);
122
+ }
123
+ //#endregion
124
+ Object.defineProperty(exports, "AGENT_XSD_BASE_URL", {
125
+ enumerable: true,
126
+ get: function() {
127
+ return AGENT_XSD_BASE_URL;
128
+ }
129
+ });
130
+ Object.defineProperty(exports, "agentDate", {
131
+ enumerable: true,
132
+ get: function() {
133
+ return agentDate;
134
+ }
135
+ });
136
+ Object.defineProperty(exports, "decodeResponsePdf", {
137
+ enumerable: true,
138
+ get: function() {
139
+ return decodeResponsePdf;
140
+ }
141
+ });
142
+ Object.defineProperty(exports, "optionalAgentDate", {
143
+ enumerable: true,
144
+ get: function() {
145
+ return optionalAgentDate;
146
+ }
147
+ });
148
+ Object.defineProperty(exports, "optionalText", {
149
+ enumerable: true,
150
+ get: function() {
151
+ return optionalText;
152
+ }
153
+ });
154
+ Object.defineProperty(exports, "parseInvoiceResult", {
155
+ enumerable: true,
156
+ get: function() {
157
+ return parseInvoiceResult;
158
+ }
159
+ });
160
+ Object.defineProperty(exports, "referenceValue", {
161
+ enumerable: true,
162
+ get: function() {
163
+ return referenceValue;
164
+ }
165
+ });
166
+ Object.defineProperty(exports, "requireText", {
167
+ enumerable: true,
168
+ get: function() {
169
+ return requireText;
170
+ }
171
+ });
172
+ Object.defineProperty(exports, "resolveInvoiceReference", {
173
+ enumerable: true,
174
+ get: function() {
175
+ return resolveInvoiceReference;
176
+ }
177
+ });
178
+ Object.defineProperty(exports, "validationError", {
179
+ enumerable: true,
180
+ get: function() {
181
+ return validationError;
182
+ }
183
+ });