@endevops/peppol-schema 0.1.2 → 0.1.4

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 (174) hide show
  1. package/README.md +5 -5
  2. package/dist/constants.d.ts +131 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +114 -1
  5. package/dist/constants.js.map +1 -1
  6. package/dist/{index-BBzPjq7o.d.ts → index-CILtZytZ.d.ts} +1710 -669
  7. package/dist/index-CILtZytZ.d.ts.map +1 -0
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.js +1234 -187
  10. package/dist/index.js.map +1 -1
  11. package/dist/invoice-response-code-not-needs-schema-DNrfKYLh.js +36 -0
  12. package/dist/invoice-response-code-not-needs-schema-DNrfKYLh.js.map +1 -0
  13. package/dist/invoice-response-codes.d.ts +28 -0
  14. package/dist/invoice-response-codes.d.ts.map +1 -1
  15. package/dist/invoice-response-codes.js +11 -1
  16. package/dist/invoice-response-codes.js.map +1 -1
  17. package/dist/{is-valid-abn-160i38PG.js → is-valid-abn-D7eSygBG.js} +115 -2
  18. package/dist/is-valid-abn-D7eSygBG.js.map +1 -0
  19. package/dist/{is-valid-mod97-0208-CzMOXMO-.js → is-valid-mod97-0208-CjR324eG.js} +11 -1
  20. package/dist/is-valid-mod97-0208-CjR324eG.js.map +1 -0
  21. package/dist/message-level-response-profile-id-B9c0A7S_.js +27 -0
  22. package/dist/message-level-response-profile-id-B9c0A7S_.js.map +1 -0
  23. package/dist/{nodable-parser-CyDZtLCK.js → nodable-parser-CupS2H55.js} +31 -1
  24. package/dist/nodable-parser-CupS2H55.js.map +1 -0
  25. package/dist/schematron.d.ts +57 -1
  26. package/dist/schematron.d.ts.map +1 -1
  27. package/dist/schematron.js +453 -2
  28. package/dist/schematron.js.map +1 -1
  29. package/dist/validations.d.ts +132 -0
  30. package/dist/validations.d.ts.map +1 -1
  31. package/dist/validations.js +11 -2
  32. package/dist/validations.js.map +1 -1
  33. package/dist/values.d.ts +67 -2
  34. package/dist/values.d.ts.map +1 -1
  35. package/dist/xml.d.ts +30 -0
  36. package/dist/xml.d.ts.map +1 -1
  37. package/dist/xml.js +10 -1
  38. package/dist/xml.js.map +1 -1
  39. package/package.json +3 -2
  40. package/src/constants/credit-note-doctype-id.ts +9 -0
  41. package/src/constants/credit-note-process-id.ts +9 -0
  42. package/src/constants/document-scheme.ts +9 -0
  43. package/src/constants/invoice-doctype-id.ts +9 -0
  44. package/src/constants/invoice-process-id.ts +10 -0
  45. package/src/constants/invoice-response-doctype-id.ts +10 -0
  46. package/src/constants/invoice-response-process-id.ts +9 -0
  47. package/src/constants/invoice-response-profile-id.ts +9 -0
  48. package/src/constants/message-level-response-doctype-id.ts +10 -0
  49. package/src/constants/message-level-response-process-id.ts +9 -0
  50. package/src/constants/message-level-response-profile-id.ts +9 -0
  51. package/src/constants/participant-scheme.ts +10 -0
  52. package/src/constants/process-scheme.ts +9 -0
  53. package/src/constants/transport-profile.ts +10 -0
  54. package/src/invoice-response-codes/invoice-response-code-needs-schema.ts +9 -0
  55. package/src/invoice-response-codes/invoice-response-code-not-needs-schema.ts +9 -0
  56. package/src/invoice-response-codes/invoice-response-codes-order.ts +10 -0
  57. package/src/peppol-validations/add-piva.ts +12 -0
  58. package/src/peppol-validations/check-cf.ts +11 -0
  59. package/src/peppol-validations/check-cf16.ts +12 -0
  60. package/src/peppol-validations/check-piva-se-it.ts +11 -0
  61. package/src/peppol-validations/check-piva.ts +11 -0
  62. package/src/peppol-validations/check-se-orgnr.ts +9 -0
  63. package/src/peppol-validations/greek-tin-verification.ts +9 -0
  64. package/src/peppol-validations/is-valid-abn.ts +9 -0
  65. package/src/peppol-validations/is-valid-gln.ts +10 -0
  66. package/src/peppol-validations/is-valid-iban.ts +10 -0
  67. package/src/peppol-validations/is-valid-mod11.ts +9 -0
  68. package/src/peppol-validations/is-valid-mod97-0208.ts +10 -0
  69. package/src/peppol-validations/luhn-check.ts +9 -0
  70. package/src/schemas/fields/default-customization-id.ts +9 -0
  71. package/src/schemas/fields/default-profile-id.ts +9 -0
  72. package/src/schemas/fields/peppol-additional-document-reference-schema.ts +41 -2
  73. package/src/schemas/fields/peppol-address-schema.ts +25 -2
  74. package/src/schemas/fields/peppol-allowance-charge-schema.ts +65 -9
  75. package/src/schemas/fields/peppol-amount-schema.ts +15 -2
  76. package/src/schemas/fields/peppol-base-line-schema.ts +12 -2
  77. package/src/schemas/fields/peppol-billing-reference-schema.ts +13 -0
  78. package/src/schemas/fields/peppol-binary-object-schema.ts +12 -4
  79. package/src/schemas/fields/peppol-contact-schema.ts +11 -0
  80. package/src/schemas/fields/peppol-credit-note-line-schema.ts +7 -2
  81. package/src/schemas/fields/peppol-delivery-schema.ts +44 -2
  82. package/src/schemas/fields/peppol-identifier-schema.ts +8 -0
  83. package/src/schemas/fields/peppol-invoice-line-period-schema.ts +11 -0
  84. package/src/schemas/fields/peppol-invoice-line-schema.ts +9 -2
  85. package/src/schemas/fields/peppol-invoice-period-schema.ts +2 -2
  86. package/src/schemas/fields/peppol-item-classification-schema.ts +2 -2
  87. package/src/schemas/fields/peppol-line-allowance-charge-schema.ts +57 -9
  88. package/src/schemas/fields/peppol-line-item-schema.ts +69 -4
  89. package/src/schemas/fields/peppol-line-price-allowance-charge-schema.ts +20 -0
  90. package/src/schemas/fields/peppol-line-price-schema.ts +2 -0
  91. package/src/schemas/fields/peppol-order-reference-schema.ts +2 -0
  92. package/src/schemas/fields/peppol-party-base-schema.ts +36 -4
  93. package/src/schemas/fields/peppol-party-legal-entity-schema.ts +13 -0
  94. package/src/schemas/fields/peppol-party-tax-scheme-schema.ts +5 -0
  95. package/src/schemas/fields/peppol-payee-party-schema.ts +2 -2
  96. package/src/schemas/fields/peppol-payment-means-schema.ts +62 -2
  97. package/src/schemas/fields/peppol-payment-terms-schema.ts +2 -0
  98. package/src/schemas/fields/peppol-quantity-schema.ts +4 -2
  99. package/src/schemas/fields/peppol-reference-schema.ts +20 -1
  100. package/src/schemas/fields/peppol-tax-category-schema.ts +12 -2
  101. package/src/schemas/fields/peppol-tax-representative-schema.ts +5 -0
  102. package/src/schemas/fields/peppol-tax-subtotal-category-schema.ts +3 -0
  103. package/src/schemas/fields/peppol-tax-subtotal-schema.ts +2 -0
  104. package/src/schemas/fields/peppol-tax-totals-base-schema.ts +5 -0
  105. package/src/schemas/peppol-billing-base-schema.ts +47 -7
  106. package/src/schemas/peppol-credit-note-schema.ts +2 -2
  107. package/src/schemas/peppol-document-response-document-reference-schema.ts +15 -2
  108. package/src/schemas/peppol-document-response-document-schema.ts +8 -3
  109. package/src/schemas/peppol-document-response-line-response-content-schema.ts +22 -2
  110. package/src/schemas/peppol-document-response-line-response-schema.ts +26 -0
  111. package/src/schemas/peppol-document-schema.ts +74 -9
  112. package/src/schemas/peppol-invoice-response-document-actual-response-schema.ts +58 -5
  113. package/src/schemas/peppol-invoice-response-document-actual-response-status-schema.ts +25 -2
  114. package/src/schemas/peppol-invoice-response-schema.ts +57 -4
  115. package/src/schemas/peppol-invoice-response-status-reason-code-schema.ts +37 -10
  116. package/src/schemas/peppol-invoice-schema.ts +30 -2
  117. package/src/schemas/peppol-message-level-response-document-response-schema.ts +10 -0
  118. package/src/schemas/peppol-message-level-response-party-schema.ts +10 -0
  119. package/src/schemas/peppol-message-level-response-schema.ts +18 -0
  120. package/src/schemas/utils/format-quantity-with-unit.ts +19 -0
  121. package/src/schemas/utils/get-credit-note-type-code-description.ts +12 -0
  122. package/src/schemas/utils/get-invoice-type-code-description.ts +12 -0
  123. package/src/schemas/utils/is-valid-credit-note-type-code.ts +13 -0
  124. package/src/schemas/utils/is-valid-invoice-type-code.ts +13 -0
  125. package/src/schemas/utils/is-valid-process.ts +13 -0
  126. package/src/schemas/utils/peppol-base-64-schema.ts +14 -4
  127. package/src/schemas/utils/peppol-vat-regex-schema.ts +38 -30
  128. package/src/schemas/utils/peppol-xsd-time-schema.ts +12 -2
  129. package/src/schemas/utils/quantity-unit-code-to-intl-unit.ts +34 -0
  130. package/src/schemas/values/additional-document-reference-code-schema.ts +9 -15
  131. package/src/schemas/values/allowance-charge-reason-code-schema.ts +12 -14
  132. package/src/schemas/values/application-response-type-code-schema.ts +10 -14
  133. package/src/schemas/values/charge-reason-code-schema.ts +12 -14
  134. package/src/schemas/values/credit-note-type-code-schema.ts +8 -14
  135. package/src/schemas/values/currency-code-schema.ts +13 -16
  136. package/src/schemas/values/document-type-schemes-schema.ts +9 -5
  137. package/src/schemas/values/document-type-values-schema.ts +5 -6
  138. package/src/schemas/values/duty-tax-fee-category-schema.ts +15 -13
  139. package/src/schemas/values/electronic-codes-schema.ts +10 -12
  140. package/src/schemas/values/icd-codes-schema.ts +8 -12
  141. package/src/schemas/values/invoice-status-code-schema.ts +10 -12
  142. package/src/schemas/values/invoice-type-code-schema.ts +10 -12
  143. package/src/schemas/values/item-classification-codes-schema.ts +10 -12
  144. package/src/schemas/values/mime-codes-schema.ts +12 -14
  145. package/src/schemas/values/op-status-action-schema.ts +10 -12
  146. package/src/schemas/values/op-status-reason-schema.ts +10 -12
  147. package/src/schemas/values/participant-identifier-code-schema.ts +10 -13
  148. package/src/schemas/values/payment-means-code-schema.ts +10 -12
  149. package/src/schemas/values/peppol-country-code-schema.ts +10 -9
  150. package/src/schemas/values/peppol-document-type-code-schema.ts +10 -12
  151. package/src/schemas/values/peppol-document-type-schema.ts +12 -21
  152. package/src/schemas/values/peppol-process-schema.ts +19 -15
  153. package/src/schemas/values/process-from-document-type-schema.ts +3 -3
  154. package/src/schemas/values/quantity-unit-codes-schema.ts +10 -12
  155. package/src/schemas/values/vat-date-code-schema.ts +12 -5
  156. package/src/schemas/values/vatex-code-schema.ts +8 -12
  157. package/src/schematron/errors.ts +14 -0
  158. package/src/schematron/helpers.ts +451 -0
  159. package/src/schematron/run-all-rules.ts +10 -0
  160. package/src/schematron/schematron.ts +25 -0
  161. package/src/xml/builder-options.ts +9 -0
  162. package/src/xml/common-xml-options.ts +9 -0
  163. package/src/xml/nodable-parser.ts +12 -0
  164. package/src/xml/parser-options.ts +9 -0
  165. package/dist/index-BBzPjq7o.d.ts.map +0 -1
  166. package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js +0 -18
  167. package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js.map +0 -1
  168. package/dist/is-valid-abn-160i38PG.js.map +0 -1
  169. package/dist/is-valid-mod97-0208-CzMOXMO-.js.map +0 -1
  170. package/dist/message-level-response-profile-id-DBpOW91B.js +0 -9
  171. package/dist/message-level-response-profile-id-DBpOW91B.js.map +0 -1
  172. package/dist/nodable-parser-CyDZtLCK.js.map +0 -1
  173. package/dist/vat-dates.generated-CxFvt7m3.d.ts +0 -68
  174. package/dist/vat-dates.generated-CxFvt7m3.d.ts.map +0 -1
@@ -0,0 +1,36 @@
1
+ //#region src/invoice-response-codes/invoice-response-code-needs-schema.ts
2
+ /**
3
+ * @description Invoice response status codes that require a clarification. The codes are Under query (UQ), Rejected (RE), and Conditionally accepted (CA).
4
+ * Consumed by {@link withStatusCodes}, where the `status` array must contain at least one entry.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * invoiceResponseCodeNeedsSchema; // ['UQ', 'RE', 'CA']
9
+ * ```;
10
+ */
11
+ const invoiceResponseCodeNeedsSchema = [
12
+ "UQ",
13
+ "RE",
14
+ "CA"
15
+ ];
16
+ //#endregion
17
+ //#region src/invoice-response-codes/invoice-response-code-not-needs-schema.ts
18
+ /**
19
+ * @description Invoice response status codes that do not require a clarification. The codes are Message acknowledgement (AB), Accepted (AP), In process (IP), and
20
+ * Paid (PD). Consumed by {@link withoutStatusCodes}, where `status` is optional.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * invoiceResponseCodeNotNeedsSchema; // ['AB', 'AP', 'IP', 'PD']
25
+ * ```;
26
+ */
27
+ const invoiceResponseCodeNotNeedsSchema = [
28
+ "AB",
29
+ "AP",
30
+ "IP",
31
+ "PD"
32
+ ];
33
+ //#endregion
34
+ export { invoiceResponseCodeNeedsSchema as n, invoiceResponseCodeNotNeedsSchema as t };
35
+
36
+ //# sourceMappingURL=invoice-response-code-not-needs-schema-DNrfKYLh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice-response-code-not-needs-schema-DNrfKYLh.js","names":[],"sources":["../src/invoice-response-codes/invoice-response-code-needs-schema.ts","../src/invoice-response-codes/invoice-response-code-not-needs-schema.ts"],"sourcesContent":["/**\n * @description Invoice response status codes that require a clarification. The codes are Under query (UQ), Rejected (RE), and Conditionally accepted (CA).\n * Consumed by {@link withStatusCodes}, where the `status` array must contain at least one entry.\n *\n * @example\n * ```ts\n * invoiceResponseCodeNeedsSchema; // ['UQ', 'RE', 'CA']\n * ```;\n */\nexport const invoiceResponseCodeNeedsSchema = ['UQ', 'RE', 'CA'] as const;\n","/**\n * @description Invoice response status codes that do not require a clarification. The codes are Message acknowledgement (AB), Accepted (AP), In process (IP), and\n * Paid (PD). Consumed by {@link withoutStatusCodes}, where `status` is optional.\n *\n * @example\n * ```ts\n * invoiceResponseCodeNotNeedsSchema; // ['AB', 'AP', 'IP', 'PD']\n * ```;\n */\nexport const invoiceResponseCodeNotNeedsSchema = ['AB', 'AP', 'IP', 'PD'] as const;\n"],"mappings":";;;;;;;;;;AASA,MAAa,iCAAiC;CAAC;CAAM;CAAM;AAAI;;;;;;;;;;;;ACA/D,MAAa,oCAAoC;CAAC;CAAM;CAAM;CAAM;AAAI"}
@@ -1,11 +1,39 @@
1
1
  import { t as InvoiceStatusCodesKeys } from "./invoice-status-codes.generated-DL-agLdx.js";
2
2
  //#region src/invoice-response-codes/invoice-response-code-needs-schema.d.ts
3
+ /**
4
+ * @description Invoice response status codes that require a clarification. The codes are Under query (UQ), Rejected (RE), and Conditionally accepted (CA).
5
+ * Consumed by {@link withStatusCodes}, where the `status` array must contain at least one entry.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * invoiceResponseCodeNeedsSchema; // ['UQ', 'RE', 'CA']
10
+ * ```;
11
+ */
3
12
  export declare const invoiceResponseCodeNeedsSchema: readonly ['UQ', 'RE', 'CA'];
4
13
  //#endregion
5
14
  //#region src/invoice-response-codes/invoice-response-code-not-needs-schema.d.ts
15
+ /**
16
+ * @description Invoice response status codes that do not require a clarification. The codes are Message acknowledgement (AB), Accepted (AP), In process (IP), and
17
+ * Paid (PD). Consumed by {@link withoutStatusCodes}, where `status` is optional.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * invoiceResponseCodeNotNeedsSchema; // ['AB', 'AP', 'IP', 'PD']
22
+ * ```;
23
+ */
6
24
  export declare const invoiceResponseCodeNotNeedsSchema: readonly ['AB', 'AP', 'IP', 'PD'];
7
25
  //#endregion
8
26
  //#region src/invoice-response-codes/invoice-response-codes-order.d.ts
27
+ /**
28
+ * @description Map of allowed status transitions for an invoice response, keyed by the current status code. Each value lists the status codes that may follow the
29
+ * key. Keys and values are {@link InvoiceStatusCodesKeys}. The terminal statuses PD and RE map to empty arrays.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * invoiceResponseCodesOrder.UQ; // ['CA', 'AP', 'RE']
34
+ * invoiceResponseCodesOrder.PD; // []
35
+ * ```;
36
+ */
9
37
  export declare const invoiceResponseCodesOrder: Record<InvoiceStatusCodesKeys, Array<InvoiceStatusCodesKeys>>;
10
38
  //#endregion
11
39
  //# sourceMappingURL=invoice-response-codes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invoice-response-codes.d.ts","names":[],"sources":["../src/invoice-response-codes/invoice-response-code-needs-schema.ts","../src/invoice-response-codes/invoice-response-code-not-needs-schema.ts","../src/invoice-response-codes/invoice-response-codes-order.ts"],"mappings":";;qBAAa;;;qBCAA;;;qBCEA,2BAA2B,OAAO,wBAAwB,MAAM"}
1
+ {"version":3,"file":"invoice-response-codes.d.ts","names":[],"sources":["../src/invoice-response-codes/invoice-response-code-needs-schema.ts","../src/invoice-response-codes/invoice-response-code-not-needs-schema.ts","../src/invoice-response-codes/invoice-response-codes-order.ts"],"mappings":";;;;;;;;;;;qBASa;;;;;;;;;;;;qBCAA;;;;;;;;;;;;;qBCGA,2BAA2B,OAAO,wBAAwB,MAAM"}
@@ -1,5 +1,15 @@
1
- import { n as invoiceResponseCodeNeedsSchema, t as invoiceResponseCodeNotNeedsSchema } from "./invoice-response-code-not-needs-schema-p_RKKNLc.js";
1
+ import { n as invoiceResponseCodeNeedsSchema, t as invoiceResponseCodeNotNeedsSchema } from "./invoice-response-code-not-needs-schema-DNrfKYLh.js";
2
2
  //#region src/invoice-response-codes/invoice-response-codes-order.ts
3
+ /**
4
+ * @description Map of allowed status transitions for an invoice response, keyed by the current status code. Each value lists the status codes that may follow the
5
+ * key. Keys and values are {@link InvoiceStatusCodesKeys}. The terminal statuses PD and RE map to empty arrays.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * invoiceResponseCodesOrder.UQ; // ['CA', 'AP', 'RE']
10
+ * invoiceResponseCodesOrder.PD; // []
11
+ * ```;
12
+ */
3
13
  const invoiceResponseCodesOrder = {
4
14
  AB: [
5
15
  "IP",
@@ -1 +1 @@
1
- {"version":3,"file":"invoice-response-codes.js","names":[],"sources":["../src/invoice-response-codes/invoice-response-codes-order.ts"],"sourcesContent":["import type { InvoiceStatusCodesKeys } from '#/values/invoice-status-codes.generated';\n\nexport const invoiceResponseCodesOrder: Record<InvoiceStatusCodesKeys, Array<InvoiceStatusCodesKeys>> = {\n AB: ['IP', 'UQ', 'AP', 'CA', 'PD', 'RE'],\n AP: ['PD'],\n CA: ['PD'],\n IP: ['UQ', 'CA', 'AP', 'PD', 'RE'],\n PD: [],\n RE: [],\n UQ: ['CA', 'AP', 'RE'],\n};\n"],"mappings":";;AAEA,MAAa,4BAA2F;CACtG,IAAI;EAAC;EAAM;EAAM;EAAM;EAAM;EAAM;CAAI;CACvC,IAAI,CAAC,IAAI;CACT,IAAI,CAAC,IAAI;CACT,IAAI;EAAC;EAAM;EAAM;EAAM;EAAM;CAAI;CACjC,IAAI,CAAC;CACL,IAAI,CAAC;CACL,IAAI;EAAC;EAAM;EAAM;CAAI;AACvB"}
1
+ {"version":3,"file":"invoice-response-codes.js","names":[],"sources":["../src/invoice-response-codes/invoice-response-codes-order.ts"],"sourcesContent":["import type { InvoiceStatusCodesKeys } from '#/values/invoice-status-codes.generated';\n\n/**\n * @description Map of allowed status transitions for an invoice response, keyed by the current status code. Each value lists the status codes that may follow the\n * key. Keys and values are {@link InvoiceStatusCodesKeys}. The terminal statuses PD and RE map to empty arrays.\n *\n * @example\n * ```ts\n * invoiceResponseCodesOrder.UQ; // ['CA', 'AP', 'RE']\n * invoiceResponseCodesOrder.PD; // []\n * ```;\n */\nexport const invoiceResponseCodesOrder: Record<InvoiceStatusCodesKeys, Array<InvoiceStatusCodesKeys>> = {\n AB: ['IP', 'UQ', 'AP', 'CA', 'PD', 'RE'],\n AP: ['PD'],\n CA: ['PD'],\n IP: ['UQ', 'CA', 'AP', 'PD', 'RE'],\n PD: [],\n RE: [],\n UQ: ['CA', 'AP', 'RE'],\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,4BAA2F;CACtG,IAAI;EAAC;EAAM;EAAM;EAAM;EAAM;EAAM;CAAI;CACvC,IAAI,CAAC,IAAI;CACT,IAAI,CAAC,IAAI;CACT,IAAI;EAAC;EAAM;EAAM;EAAM;EAAM;CAAI;CACjC,IAAI,CAAC;CACL,IAAI,CAAC;CACL,IAAI;EAAC;EAAM;EAAM;CAAI;AACvB"}
@@ -1,7 +1,17 @@
1
- import { n as normalizeSpace } from "./is-valid-mod97-0208-CzMOXMO-.js";
1
+ import { n as normalizeSpace } from "./is-valid-mod97-0208-CjR324eG.js";
2
2
  //#region src/peppol-validations/is-valid-iban.ts
3
3
  /**
4
4
  * @description IBAN validation using mod 97 algorithm.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * isValidIBAN('GB82 WEST 1234 5698 7654 32'); // true
9
+ * ```;
10
+ *
11
+ * @param iban - The IBAN to validate, with or without spaces.
12
+ *
13
+ * @returns `true` when the normalised value matches the `{2 letters}{2 digits}{up to 30 alphanumerics}` shape and its mod 97 remainder is 1,
14
+ * otherwise `false`.
5
15
  */
6
16
  function isValidIBAN(iban) {
7
17
  const s = normalizeSpace(iban).replace(/[ \t\r\n]/g, "");
@@ -18,6 +28,15 @@ function isValidIBAN(iban) {
18
28
  //#region src/peppol-validations/greek-tin-verification.ts
19
29
  /**
20
30
  * @description Greek TIN verification.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * greekTinVerification('123456783'); // true
35
+ * ```;
36
+ *
37
+ * @param val - The nine digit Greek tax identification number.
38
+ *
39
+ * @returns `true` when the value is nine digits and the computed checksum matches the last digit, otherwise `false`.
21
40
  */
22
41
  function greekTinVerification(val) {
23
42
  if (!/^\d{9}$/.test(val)) return false;
@@ -28,6 +47,15 @@ function greekTinVerification(val) {
28
47
  //#region src/peppol-validations/is-valid-mod11.ts
29
48
  /**
30
49
  * @description Validates Norwegian organization numbers using mod11 algorithm.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * isValidMod11('923609016'); // true
54
+ * ```;
55
+ *
56
+ * @param val - The organization number to validate. Whitespace is normalised first.
57
+ *
58
+ * @returns `true` when the normalised value is at least two digits and its mod 11 check digit matches, otherwise `false`.
31
59
  */
32
60
  function isValidMod11(val) {
33
61
  const s = normalizeSpace(val);
@@ -45,6 +73,16 @@ function isValidMod11(val) {
45
73
  //#region src/peppol-validations/is-valid-gln.ts
46
74
  /**
47
75
  * @description [GLN](https://en.wikipedia.org/wiki/Global_Location_Number) check (GS1)
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * isValidGLN('1234567890128'); // { success: true }
80
+ * ```;
81
+ *
82
+ * @param val - The GLN to validate. Whitespace is stripped first.
83
+ *
84
+ * @returns `{ success: true }` when the computed check digit matches the last digit, otherwise `{ success: false, expected, actual }` with the
85
+ * computed and supplied check digits.
48
86
  */
49
87
  function isValidGLN(val) {
50
88
  const value = (val ?? "").replace(/\s+/g, "");
@@ -61,6 +99,18 @@ function isValidGLN(val) {
61
99
  //#region src/peppol-validations/check-cf16.ts
62
100
  /**
63
101
  * @description Validates 16-character Italian fiscal codes.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * checkCF16('RSSMRA80A01H501U'); // true
106
+ * ```;
107
+ *
108
+ * @param arg - The fiscal code to validate. Whitespace is normalised first.
109
+ *
110
+ * @returns `true` when the normalised code is 16 characters and matches `{6 letters}{2 digits}{letter}{2 digits}{letter}{3 digits}{letter}`,
111
+ * otherwise `false`.
112
+ *
113
+ * @see {@link checkCF}
64
114
  */
65
115
  function checkCF16(arg) {
66
116
  const s = normalizeSpace(arg);
@@ -72,6 +122,17 @@ function checkCF16(arg) {
72
122
  //#region src/peppol-validations/check-cf.ts
73
123
  /**
74
124
  * @description Validates both 16 and 11 character Italian fiscal codes.
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * checkCF('RSSMRA80A01H501U'); // true
129
+ * ```;
130
+ *
131
+ * @param arg - The fiscal code to validate. Whitespace is normalised first.
132
+ *
133
+ * @returns `true` when the normalised code is a valid 16 character personal fiscal code or an 11 digit VAT code, otherwise `false`.
134
+ *
135
+ * @see {@link checkCF16}
75
136
  */
76
137
  function checkCF(arg) {
77
138
  const s = normalizeSpace(arg);
@@ -83,6 +144,18 @@ function checkCF(arg) {
83
144
  //#region src/peppol-validations/add-piva.ts
84
145
  /**
85
146
  * @description Helper function for calculating weighted sum for Italian PIVA validation.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * addPIVA('123', 0); // 8
151
+ * ```;
152
+ *
153
+ * @param arg - The digit string to sum, processed one character at a time.
154
+ * @param pari - Parity flag toggled at each recursion; `1` maps the digit through the `0246813579` table, `0` keeps it as is.
155
+ *
156
+ * @returns The weighted sum, or `0` when `arg` contains a non-digit.
157
+ *
158
+ * @see {@link checkPIVA}
86
159
  */
87
160
  function addPIVA(arg, pari) {
88
161
  if (!/^\d+$/.test(arg)) return 0;
@@ -95,6 +168,17 @@ function addPIVA(arg, pari) {
95
168
  //#region src/peppol-validations/check-piva.ts
96
169
  /**
97
170
  * @description Validates Italian VAT numbers (PIVA)
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * checkPIVA('00743110157'); // 0
175
+ * ```;
176
+ *
177
+ * @param arg - The Italian VAT number without the `IT` prefix.
178
+ *
179
+ * @returns `0` when valid, otherwise the non-zero remainder of {@link addPIVA}, or `1` when `arg` contains a non-digit.
180
+ *
181
+ * @see {@link addPIVA}
98
182
  */
99
183
  function checkPIVA(arg) {
100
184
  if (!/^\d+$/.test(arg)) return 1;
@@ -104,6 +188,17 @@ function checkPIVA(arg) {
104
188
  //#region src/peppol-validations/check-piva-se-it.ts
105
189
  /**
106
190
  * @description Validates Italian VAT numbers with IT prefix.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * checkPIVAseIT('IT00743110157'); // true
195
+ * ```;
196
+ *
197
+ * @param arg - The VAT identifier including its two letter country prefix.
198
+ *
199
+ * @returns `true` when the prefix is not `IT`, or when the 11 digit Italian part passes {@link checkPIVA}; otherwise `false`.
200
+ *
201
+ * @see {@link checkPIVA}
107
202
  */
108
203
  function checkPIVAseIT(arg) {
109
204
  const paese = arg.substring(0, 2);
@@ -115,6 +210,15 @@ function checkPIVAseIT(arg) {
115
210
  //#region src/peppol-validations/check-se-orgnr.ts
116
211
  /**
117
212
  * @description Validates Swedish organization numbers (0007)
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * checkSEOrgnr('5560160680'); // true
217
+ * ```;
218
+ *
219
+ * @param number - The organization number to validate. Whitespace is normalised first.
220
+ *
221
+ * @returns `true` when the normalised number is 10 digits and its Luhn check digit matches, otherwise `false`.
118
222
  */
119
223
  function checkSEOrgnr(number) {
120
224
  const s = normalizeSpace(number);
@@ -135,6 +239,15 @@ function checkSEOrgnr(number) {
135
239
  //#region src/peppol-validations/is-valid-abn.ts
136
240
  /**
137
241
  * @description Australian Business Number (ABN) validation.
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * isValidABN('51 824 753 556'); // true
246
+ * ```;
247
+ *
248
+ * @param val - The ABN to validate. Whitespace is normalised first.
249
+ *
250
+ * @returns `true` when the normalised value is 11 digits and the weighted checksum is divisible by 89, otherwise `false`.
138
251
  */
139
252
  function isValidABN(val) {
140
253
  const s = normalizeSpace(val);
@@ -159,4 +272,4 @@ function isValidABN(val) {
159
272
  //#endregion
160
273
  export { addPIVA as a, isValidGLN as c, isValidIBAN as d, checkPIVA as i, isValidMod11 as l, checkSEOrgnr as n, checkCF as o, checkPIVAseIT as r, checkCF16 as s, isValidABN as t, greekTinVerification as u };
161
274
 
162
- //# sourceMappingURL=is-valid-abn-160i38PG.js.map
275
+ //# sourceMappingURL=is-valid-abn-D7eSygBG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-valid-abn-D7eSygBG.js","names":[],"sources":["../src/peppol-validations/is-valid-iban.ts","../src/peppol-validations/greek-tin-verification.ts","../src/peppol-validations/is-valid-mod11.ts","../src/peppol-validations/is-valid-gln.ts","../src/peppol-validations/check-cf16.ts","../src/peppol-validations/check-cf.ts","../src/peppol-validations/add-piva.ts","../src/peppol-validations/check-piva.ts","../src/peppol-validations/check-piva-se-it.ts","../src/peppol-validations/check-se-orgnr.ts","../src/peppol-validations/is-valid-abn.ts"],"sourcesContent":["import { normalizeSpace } from './normalize-space.ts';\n\n/**\n * @description IBAN validation using mod 97 algorithm.\n *\n * @example\n * ```ts\n * isValidIBAN('GB82 WEST 1234 5698 7654 32'); // true\n * ```;\n *\n * @param iban - The IBAN to validate, with or without spaces.\n *\n * @returns `true` when the normalised value matches the `{2 letters}{2 digits}{up to 30 alphanumerics}` shape and its mod 97 remainder is 1,\n * otherwise `false`.\n */\nexport function isValidIBAN(iban: string): boolean {\n const s = normalizeSpace(iban).replace(/[ \\t\\r\\n]/g, '');\n if (!/^[A-Z]{2}\\d{2}[A-Za-z0-9]{0,30}$/.test(s)) return false;\n const rearranged = s.slice(4) + s.slice(0, 4);\n const converted = rearranged\n .split('')\n .map(ch => {\n const code = ch.charCodeAt(0);\n // A=10..Z=35, digits 0..9\n return code >= 65 && code <= 90 ? String(code - 55) : ch;\n })\n .join('');\n // mod 97 calculation on big integer string\n let remainder = 0;\n for (const c of converted) {\n remainder = (remainder * 10 + (c.charCodeAt(0) - 48)) % 97;\n }\n return remainder === 1;\n}\n","/**\n * @description Greek TIN verification.\n *\n * @example\n * ```ts\n * greekTinVerification('123456783'); // true\n * ```;\n *\n * @param val - The nine digit Greek tax identification number.\n *\n * @returns `true` when the value is nine digits and the computed checksum matches the last digit, otherwise `false`.\n */\nexport function greekTinVerification(val: string): boolean {\n if (!/^\\d{9}$/.test(val)) return false;\n const digits = val.split('').map(Number) as [number, number, number, number, number, number, number, number, number];\n const checksum =\n digits[7] * 2 + digits[6] * 4 + digits[5] * 8 + digits[4] * 16 + digits[3] * 32 + digits[2] * 64 + digits[1] * 128 + digits[0] * 256;\n\n return (checksum % 11) % 10 === digits[8];\n}\n","import { normalizeSpace } from './normalize-space.ts';\n\n/**\n * @description Validates Norwegian organization numbers using mod11 algorithm.\n *\n * @example\n * ```ts\n * isValidMod11('923609016'); // true\n * ```;\n *\n * @param val - The organization number to validate. Whitespace is normalised first.\n *\n * @returns `true` when the normalised value is at least two digits and its mod 11 check digit matches, otherwise `false`.\n */\nexport function isValidMod11(val: string): boolean {\n const s = normalizeSpace(val);\n if (!/^\\d+$/.test(s) || s.length < 2) return false;\n const length = s.length - 1;\n let weightedSum = 0;\n // weights 2..7 repeated\n for (let i = 0; i < length; i += 1) {\n const digit = s.charCodeAt(length - 1 - i) - 48; // reverse to match XSLT reverse\n const weight = (i % 6) + 2;\n weightedSum += digit * weight;\n }\n const check = (11 - (weightedSum % 11)) % 11;\n return check === Number(s[length]);\n}\n","/**\n * @description [GLN](https://en.wikipedia.org/wiki/Global_Location_Number) check (GS1)\n *\n * @example\n * ```ts\n * isValidGLN('1234567890128'); // { success: true }\n * ```;\n *\n * @param val - The GLN to validate. Whitespace is stripped first.\n *\n * @returns `{ success: true }` when the computed check digit matches the last digit, otherwise `{ success: false, expected, actual }` with the\n * computed and supplied check digits.\n */\nexport function isValidGLN(val: string): { success: true } | { success: false; expected: number; actual: number } {\n const value = (val ?? '').replace(/\\s+/g, '');\n const len = value.length - 1;\n\n const digits = value\n .slice(0, len)\n .split('')\n .map(c => c.charCodeAt(0) - 48)\n .reverse();\n\n const weightedSum = digits.reduce((sum, d, i) => sum + d * (1 + ((i + 1) % 2) * 2), 0);\n const check = (10 - (weightedSum % 10)) % 10;\n const success = check === Number(value[len]);\n if (success) {\n return { success: true };\n }\n return { actual: Number(value[len]), expected: check, success: false };\n}\n","import { normalizeSpace } from './normalize-space.ts';\n\n/**\n * @description Validates 16-character Italian fiscal codes.\n *\n * @example\n * ```ts\n * checkCF16('RSSMRA80A01H501U'); // true\n * ```;\n *\n * @param arg - The fiscal code to validate. Whitespace is normalised first.\n *\n * @returns `true` when the normalised code is 16 characters and matches `{6 letters}{2 digits}{letter}{2 digits}{letter}{3 digits}{letter}`,\n * otherwise `false`.\n *\n * @see {@link checkCF}\n */\nexport function checkCF16(arg: string): boolean {\n const s = normalizeSpace(arg);\n if (s.length !== 16) return false;\n if (!/^[A-Za-z]{6}\\d{2}[A-Za-z]\\d{2}[A-Za-z]\\d{3}[A-Za-z]$/.test(s)) return false;\n return true;\n}\n","import { checkCF16 } from './check-cf16.ts';\nimport { normalizeSpace } from './normalize-space.ts';\n\n/**\n * @description Validates both 16 and 11 character Italian fiscal codes.\n *\n * @example\n * ```ts\n * checkCF('RSSMRA80A01H501U'); // true\n * ```;\n *\n * @param arg - The fiscal code to validate. Whitespace is normalised first.\n *\n * @returns `true` when the normalised code is a valid 16 character personal fiscal code or an 11 digit VAT code, otherwise `false`.\n *\n * @see {@link checkCF16}\n */\nexport function checkCF(arg: string): boolean {\n const s = normalizeSpace(arg);\n if (s.length === 16) return checkCF16(s);\n if (s.length === 11) return /^\\d{11}$/.test(s);\n return false;\n}\n","// NOTE: check and add valid values for the tests in `add-piva.spec.ts`\n\n/**\n * @description Helper function for calculating weighted sum for Italian PIVA validation.\n *\n * @example\n * ```ts\n * addPIVA('123', 0); // 8\n * ```;\n *\n * @param arg - The digit string to sum, processed one character at a time.\n * @param pari - Parity flag toggled at each recursion; `1` maps the digit through the `0246813579` table, `0` keeps it as is.\n *\n * @returns The weighted sum, or `0` when `arg` contains a non-digit.\n *\n * @see {@link checkPIVA}\n */\nexport function addPIVA(arg: string, pari: number): number {\n if (!/^\\d+$/.test(arg)) return 0;\n const first = Number(arg[0]);\n const mapper = pari === 1 ? Number('0246813579'[first]) : first;\n if (arg.length === 1) return mapper;\n return mapper + addPIVA(arg.slice(1), pari === 0 ? 1 : 0);\n}\n","import { addPIVA } from './add-piva.ts';\n\n/**\n * @description Validates Italian VAT numbers (PIVA)\n *\n * @example\n * ```ts\n * checkPIVA('00743110157'); // 0\n * ```;\n *\n * @param arg - The Italian VAT number without the `IT` prefix.\n *\n * @returns `0` when valid, otherwise the non-zero remainder of {@link addPIVA}, or `1` when `arg` contains a non-digit.\n *\n * @see {@link addPIVA}\n */\nexport function checkPIVA(arg: string): number {\n if (!/^\\d+$/.test(arg)) return 1;\n return addPIVA(arg, 0) % 10;\n}\n","import { checkPIVA } from './check-piva.ts';\n\n/**\n * @description Validates Italian VAT numbers with IT prefix.\n *\n * @example\n * ```ts\n * checkPIVAseIT('IT00743110157'); // true\n * ```;\n *\n * @param arg - The VAT identifier including its two letter country prefix.\n *\n * @returns `true` when the prefix is not `IT`, or when the 11 digit Italian part passes {@link checkPIVA}; otherwise `false`.\n *\n * @see {@link checkPIVA}\n */\nexport function checkPIVAseIT(arg: string): boolean {\n const paese = arg.substring(0, 2);\n const codice = arg.substring(2);\n if (paese.toUpperCase() !== 'IT') return true;\n return codice.length === 11 && checkPIVA(codice) === 0;\n}\n","import { normalizeSpace } from './normalize-space.ts';\n\n/**\n * @description Validates Swedish organization numbers (0007)\n *\n * @example\n * ```ts\n * checkSEOrgnr('5560160680'); // true\n * ```;\n *\n * @param number - The organization number to validate. Whitespace is normalised first.\n *\n * @returns `true` when the normalised number is 10 digits and its Luhn check digit matches, otherwise `false`.\n */\nexport function checkSEOrgnr(number: string): boolean {\n const s = normalizeSpace(number);\n if (!/^\\d+$/.test(s) || s.length !== 10) return false;\n const main = s.substring(0, 9);\n const checkDigit = Number(s[9]);\n let sum = 0;\n for (let pos = 1; pos <= main.length; pos += 1) {\n const digit = Number(main[main.length - pos]);\n if (pos % 2 === 1) {\n const dbl = ((digit * 2) % 10) + Math.floor((digit * 2) / 10);\n sum += dbl;\n } else {\n sum += digit;\n }\n }\n const calculated = (10 - (sum % 10)) % 10;\n return calculated === checkDigit;\n}\n","import { normalizeSpace } from './normalize-space.ts';\n\n/**\n * @description Australian Business Number (ABN) validation.\n *\n * @example\n * ```ts\n * isValidABN('51 824 753 556'); // true\n * ```;\n *\n * @param val - The ABN to validate. Whitespace is normalised first.\n *\n * @returns `true` when the normalised value is 11 digits and the weighted checksum is divisible by 89, otherwise `false`.\n */\nexport function isValidABN(val: string): boolean {\n const s = normalizeSpace(val);\n if (!/^\\d{11}$/.test(s)) return false;\n const weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];\n let sum = (s.charCodeAt(0) - 49) * 10; // (first digit -1)*10\n for (let i = 1; i < 11; i += 1) {\n sum += (s.charCodeAt(i) - 48) * weights[i]!;\n }\n return sum % 89 === 0;\n}\n"],"mappings":"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"}
@@ -9,6 +9,16 @@ function normalizeSpace(input) {
9
9
  //#region src/peppol-validations/is-valid-mod97-0208.ts
10
10
  /**
11
11
  * @description Belgian enterprise number validation (mod 97-0208)
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * isValidMod97_0208('0123456749'); // { success: true }
16
+ * ```;
17
+ *
18
+ * @param val - The enterprise number to validate. Whitespace is normalised first.
19
+ *
20
+ * @returns `{ success: true }` when the last two digits equal `97 - (first eight digits % 97)`, otherwise `{ success: false, expected, actual }` with
21
+ * the computed and supplied check digits.
12
22
  */
13
23
  function isValidMod97_0208(val) {
14
24
  const s = normalizeSpace(val);
@@ -24,4 +34,4 @@ function isValidMod97_0208(val) {
24
34
  //#endregion
25
35
  export { normalizeSpace as n, isValidMod97_0208 as t };
26
36
 
27
- //# sourceMappingURL=is-valid-mod97-0208-CzMOXMO-.js.map
37
+ //# sourceMappingURL=is-valid-mod97-0208-CjR324eG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-valid-mod97-0208-CjR324eG.js","names":[],"sources":["../src/peppol-validations/normalize-space.ts","../src/peppol-validations/is-valid-mod97-0208.ts"],"sourcesContent":["/**\n * @description Normalize whitespace in a string by replacing multiple whitespace characters with a single space and trimming.\n */\nexport function normalizeSpace(input: string): string {\n const s = typeof input === 'string' ? input : input == null ? '' : String(input);\n return s.replace(/\\s+/g, ' ').trim();\n}\n","import { normalizeSpace } from './normalize-space.ts';\n\n/**\n * @description Belgian enterprise number validation (mod 97-0208)\n *\n * @example\n * ```ts\n * isValidMod97_0208('0123456749'); // { success: true }\n * ```;\n *\n * @param val - The enterprise number to validate. Whitespace is normalised first.\n *\n * @returns `{ success: true }` when the last two digits equal `97 - (first eight digits % 97)`, otherwise `{ success: false, expected, actual }` with\n * the computed and supplied check digits.\n */\nexport function isValidMod97_0208(val: string): { success: true } | { success: false; expected: number; actual: number } {\n const s = normalizeSpace(val);\n const checkdigits = Number(s.substring(8, 10));\n const main = Number(s.substring(0, 8));\n const calculated = 97 - (main % 97);\n const success = checkdigits === calculated;\n if (success) {\n return { success: true };\n }\n return { actual: checkdigits, expected: calculated, success: false };\n}\n"],"mappings":";;;;AAGA,SAAgB,eAAe,OAAuB;CAEpD,QADU,OAAO,UAAU,WAAW,QAAQ,SAAS,OAAO,KAAK,OAAO,KAAK,EAAA,CACtE,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK;AACrC;;;;;;;;;;;;;;;;ACSA,SAAgB,kBAAkB,KAAuF;CACvH,MAAM,IAAI,eAAe,GAAG;CAC5B,MAAM,cAAc,OAAO,EAAE,UAAU,GAAG,EAAE,CAAC;CAE7C,MAAM,aAAa,KADN,OAAO,EAAE,UAAU,GAAG,CAAC,CACR,IAAI;CAEhC,IADgB,gBAAgB,YAE9B,OAAO,EAAE,SAAS,KAAK;CAEzB,OAAO;EAAE,QAAQ;EAAa,UAAU;EAAY,SAAS;CAAM;AACrE"}
@@ -0,0 +1,27 @@
1
+ //#region src/constants/invoice-response-profile-id.ts
2
+ /**
3
+ * @description PEPPOL profile id for the invoice response, version 3. It is the `cbc:ProfileID` value fixed by {@link PeppolInvoiceResponse} and is matched when
4
+ * dispatching `ApplicationResponse` documents to that schema.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * INVOICE_RESPONSE_PROFILE_ID; // 'urn:fdc:peppol.eu:poacc:bis:invoice_response:3'
9
+ * ```;
10
+ */
11
+ const INVOICE_RESPONSE_PROFILE_ID = "urn:fdc:peppol.eu:poacc:bis:invoice_response:3";
12
+ //#endregion
13
+ //#region src/constants/message-level-response-profile-id.ts
14
+ /**
15
+ * @description PEPPOL profile id for the message level response, version 3. It is the `cbc:ProfileID` value fixed by {@link PeppolMessageLevelResponse} and is
16
+ * matched when dispatching `ApplicationResponse` documents to that schema.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * MESSAGE_LEVEL_RESPONSE_PROFILE_ID; // 'urn:fdc:peppol.eu:poacc:bis:mlr:3'
21
+ * ```;
22
+ */
23
+ const MESSAGE_LEVEL_RESPONSE_PROFILE_ID = "urn:fdc:peppol.eu:poacc:bis:mlr:3";
24
+ //#endregion
25
+ export { INVOICE_RESPONSE_PROFILE_ID as n, MESSAGE_LEVEL_RESPONSE_PROFILE_ID as t };
26
+
27
+ //# sourceMappingURL=message-level-response-profile-id-B9c0A7S_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-level-response-profile-id-B9c0A7S_.js","names":[],"sources":["../src/constants/invoice-response-profile-id.ts","../src/constants/message-level-response-profile-id.ts"],"sourcesContent":["/**\n * @description PEPPOL profile id for the invoice response, version 3. It is the `cbc:ProfileID` value fixed by {@link PeppolInvoiceResponse} and is matched when\n * dispatching `ApplicationResponse` documents to that schema.\n *\n * @example\n * ```ts\n * INVOICE_RESPONSE_PROFILE_ID; // 'urn:fdc:peppol.eu:poacc:bis:invoice_response:3'\n * ```;\n */\nexport const INVOICE_RESPONSE_PROFILE_ID = 'urn:fdc:peppol.eu:poacc:bis:invoice_response:3' as const;\n","/**\n * @description PEPPOL profile id for the message level response, version 3. It is the `cbc:ProfileID` value fixed by {@link PeppolMessageLevelResponse} and is\n * matched when dispatching `ApplicationResponse` documents to that schema.\n *\n * @example\n * ```ts\n * MESSAGE_LEVEL_RESPONSE_PROFILE_ID; // 'urn:fdc:peppol.eu:poacc:bis:mlr:3'\n * ```;\n */\nexport const MESSAGE_LEVEL_RESPONSE_PROFILE_ID = 'urn:fdc:peppol.eu:poacc:bis:mlr:3' as const;\n"],"mappings":";;;;;;;;;;AASA,MAAa,8BAA8B;;;;;;;;;;;;ACA3C,MAAa,oCAAoC"}
@@ -2,6 +2,15 @@ import { NumberValueParser } from "@nodable/base-output-builder";
2
2
  import { CompactBuilderFactory } from "@nodable/compact-builder";
3
3
  import { XMLParser } from "@nodable/flexible-xml-parser";
4
4
  //#region src/xml/common-xml-options.ts
5
+ /**
6
+ * @description Options shared by the XML parser and builder so documents round-trip: `@` attributes, coerced values, trimmed values.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * commonXmlOptions.attributeNamePrefix; // '@'
11
+ * commonXmlOptions.parseAttributeValue; // true
12
+ * ```;
13
+ */
5
14
  const commonXmlOptions = {
6
15
  attributeNamePrefix: "@",
7
16
  format: false,
@@ -17,6 +26,15 @@ const commonXmlOptions = {
17
26
  };
18
27
  //#endregion
19
28
  //#region src/xml/builder-options.ts
29
+ /**
30
+ * @description Default `fast-xml-builder` options for serialising PEPPOL documents: {@link commonXmlOptions} with `suppressEmptyNode` forced on.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * builderOptions.attributeNamePrefix; // '@'
35
+ * builderOptions.suppressEmptyNode; // true
36
+ * ```;
37
+ */
20
38
  const builderOptions = {
21
39
  ...commonXmlOptions,
22
40
  suppressEmptyNode: true
@@ -52,6 +70,18 @@ const nodableParser = new XMLParser({
52
70
  nsPrefix: true
53
71
  }
54
72
  });
73
+ /**
74
+ * @description Parses an XML string into an {@link XmlNode} tree with the nodable compact builder, coercing values and removing `@xmlns`.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * parseXmlNodable('<root xmlns="urn:x"><a>1</a></root>'); // { root: { a: 1 } }
79
+ * ```;
80
+ *
81
+ * @param value - The XML document to parse.
82
+ *
83
+ * @returns The parsed {@link XmlNode} tree with `@xmlns` stripped.
84
+ */
55
85
  function parseXmlNodable(value) {
56
86
  const parsed = nodableParser.parse(value);
57
87
  stripDefaultXmlns(parsed);
@@ -71,4 +101,4 @@ function stripDefaultXmlns(node) {
71
101
  //#endregion
72
102
  export { builderOptions as n, commonXmlOptions as r, parseXmlNodable as t };
73
103
 
74
- //# sourceMappingURL=nodable-parser-CyDZtLCK.js.map
104
+ //# sourceMappingURL=nodable-parser-CupS2H55.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodable-parser-CupS2H55.js","names":[],"sources":["../src/xml/common-xml-options.ts","../src/xml/builder-options.ts","../src/xml/nodable-parser.ts"],"sourcesContent":["import type { XmlBuilderOptions } from 'fast-xml-builder';\nimport type { X2jOptions } from 'fast-xml-parser';\n\n/**\n * @description Options shared by the XML parser and builder so documents round-trip: `@` attributes, coerced values, trimmed values.\n *\n * @example\n * ```ts\n * commonXmlOptions.attributeNamePrefix; // '@'\n * commonXmlOptions.parseAttributeValue; // true\n * ```;\n */\nexport const commonXmlOptions = {\n attributeNamePrefix: '@',\n format: false,\n ignoreAttributes: false,\n numberParseOptions: { hex: false, leadingZeros: false },\n parseAttributeValue: true,\n suppressBooleanAttributes: true,\n suppressEmptyNode: true,\n trimValues: true,\n} satisfies X2jOptions & XmlBuilderOptions;\n","import type { XmlBuilderOptions } from 'fast-xml-builder';\n\nimport { commonXmlOptions } from '#/xml/common-xml-options.ts';\n\n/**\n * @description Default `fast-xml-builder` options for serialising PEPPOL documents: {@link commonXmlOptions} with `suppressEmptyNode` forced on.\n *\n * @example\n * ```ts\n * builderOptions.attributeNamePrefix; // '@'\n * builderOptions.suppressEmptyNode; // true\n * ```;\n */\nexport const builderOptions = { ...commonXmlOptions, suppressEmptyNode: true } satisfies XmlBuilderOptions;\n","import { NumberValueParser } from '@nodable/base-output-builder';\nimport { CompactBuilderFactory } from '@nodable/compact-builder';\nimport { XMLParser } from '@nodable/flexible-xml-parser';\n\nimport type { XmlNode } from '#/helpers/get-prop.ts';\n\nexport type { XmlNode } from '#/helpers/get-prop.ts';\n\nconst numberParser = new NumberValueParser({ eNotation: true, hex: false, leadingZeros: false });\n\nconst compactFactory = new CompactBuilderFactory({\n attributes: { valueParsers: ['entity', numberParser, 'boolean'] },\n tags: { valueParsers: ['trim', 'entity', 'boolean', numberParser] },\n});\n\nconst nodableParser = new XMLParser({\n OutputBuilder: compactFactory,\n attributes: { booleanType: 'allow', prefix: '@' },\n skip: { attributes: false, nsPrefix: true },\n});\n\n/**\n * @description Parses an XML string into an {@link XmlNode} tree with the nodable compact builder, coercing values and removing `@xmlns`.\n *\n * @example\n * ```ts\n * parseXmlNodable('<root xmlns=\"urn:x\"><a>1</a></root>'); // { root: { a: 1 } }\n * ```;\n *\n * @param value - The XML document to parse.\n *\n * @returns The parsed {@link XmlNode} tree with `@xmlns` stripped.\n */\nexport function parseXmlNodable(value: string): XmlNode {\n const parsed = nodableParser.parse(value) as XmlNode;\n stripDefaultXmlns(parsed);\n return parsed;\n}\n\nfunction stripDefaultXmlns(node: unknown): void {\n if (Array.isArray(node)) {\n for (const item of node) stripDefaultXmlns(item);\n return;\n }\n if (typeof node === 'object' && node !== null) {\n const record = node as Record<string, unknown>;\n delete record['@xmlns'];\n for (const key of Object.keys(record)) stripDefaultXmlns(record[key]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,mBAAmB;CAC9B,qBAAqB;CACrB,QAAQ;CACR,kBAAkB;CAClB,oBAAoB;EAAE,KAAK;EAAO,cAAc;CAAM;CACtD,qBAAqB;CACrB,2BAA2B;CAC3B,mBAAmB;CACnB,YAAY;AACd;;;;;;;;;;;;ACRA,MAAa,iBAAiB;CAAE,GAAG;CAAkB,mBAAmB;AAAK;;;ACL7E,MAAM,eAAe,IAAI,kBAAkB;CAAE,WAAW;CAAM,KAAK;CAAO,cAAc;AAAM,CAAC;AAE/F,MAAM,iBAAiB,IAAI,sBAAsB;CAC/C,YAAY,EAAE,cAAc;EAAC;EAAU;EAAc;CAAS,EAAE;CAChE,MAAM,EAAE,cAAc;EAAC;EAAQ;EAAU;EAAW;CAAY,EAAE;AACpE,CAAC;AAED,MAAM,gBAAgB,IAAI,UAAU;CAClC,eAAe;CACf,YAAY;EAAE,aAAa;EAAS,QAAQ;CAAI;CAChD,MAAM;EAAE,YAAY;EAAO,UAAU;CAAK;AAC5C,CAAC;;;;;;;;;;;;;AAcD,SAAgB,gBAAgB,OAAwB;CACtD,MAAM,SAAS,cAAc,MAAM,KAAK;CACxC,kBAAkB,MAAM;CACxB,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAqB;CAC9C,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,QAAQ,MAAM,kBAAkB,IAAI;EAC/C;CACF;CACA,IAAI,OAAO,SAAS,YAAY,SAAS,MAAM;EAC7C,MAAM,SAAS;EACf,OAAO,OAAO;EACd,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG,kBAAkB,OAAO,IAAI;CACtE;AACF"}
@@ -1,4 +1,4 @@
1
- import { X as PeppolDocument } from "./index-BBzPjq7o.js";
1
+ import { s as PeppolDocument } from "./index-CILtZytZ.js";
2
2
  import { Context, Effect, Layer, Result, Schema } from "effect";
3
3
  //#region src/schematron/types.d.ts
4
4
  /**
@@ -35,6 +35,13 @@ declare const SchematronRuleError_base: Schema.Class<SchematronRuleError, Schema
35
35
  }>, import("effect/Cause").YieldableError>;
36
36
  /**
37
37
  * @description Failure of a single schematron rule against a document.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * new SchematronRuleError({ id: 'PEPPOL-EN16931-R001', level: 'fatal', message: 'The document must carry a number.' });
42
+ * ```;
43
+ *
44
+ * @see {@link SchematronValidationError}
38
45
  */
39
46
  export declare class SchematronRuleError extends SchematronRuleError_base {}
40
47
  declare const SchematronValidationError_base: Schema.Class<SchematronValidationError, Schema.TaggedStruct<"SchematronValidationError", {
@@ -42,12 +49,26 @@ declare const SchematronValidationError_base: Schema.Class<SchematronValidationE
42
49
  }>, import("effect/Cause").YieldableError>;
43
50
  /**
44
51
  * @description Failure of a schematron validation run, wrapping every rule that failed.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * new SchematronValidationError({ errors: [ruleError] });
56
+ * ```;
57
+ *
58
+ * @see {@link SchematronRuleError}
45
59
  */
46
60
  export declare class SchematronValidationError extends SchematronValidationError_base {}
47
61
  //#endregion
48
62
  //#region src/schematron/helpers.d.ts
49
63
  /**
50
64
  * @description An effectful schematron rule validator. Fails with a `SchematronRuleError` when the document does not satisfy the rule.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const validate: SchematronDocumentValidator = schematronRule(metadata, document => document.taxTotals.length > 0);
69
+ * ```;
70
+ *
71
+ * @see {@link schematronRule}
51
72
  */
52
73
  type SchematronDocumentValidator = (document: PeppolDocument) => Effect.Effect<void, SchematronRuleError>;
53
74
  //#endregion
@@ -1132,6 +1153,16 @@ export declare const validateSeR012: SchematronDocumentValidator;
1132
1153
  export declare const validateSeR013: SchematronDocumentValidator;
1133
1154
  //#endregion
1134
1155
  //#region src/schematron/run-all-rules.d.ts
1156
+ /**
1157
+ * @description Every schematron rule validator of this library, in evaluation order.
1158
+ *
1159
+ * @example
1160
+ * ```ts
1161
+ * ruleValidators.length; // 360
1162
+ * ```;
1163
+ *
1164
+ * @see {@link SchematronDocumentValidator}
1165
+ */
1135
1166
  export declare const ruleValidators: ReadonlyArray<SchematronDocumentValidator>;
1136
1167
  //#endregion
1137
1168
  //#region src/schematron/schematron.d.ts
@@ -1141,14 +1172,39 @@ export declare const ruleValidators: ReadonlyArray<SchematronDocumentValidator>;
1141
1172
  interface SchematronShape {
1142
1173
  /**
1143
1174
  * @description Runs every schematron rule against the document, failing with a single `SchematronValidationError` that wraps each failed rule.
1175
+ *
1176
+ * @example
1177
+ * ```ts
1178
+ * const program = Effect.gen(function* () {
1179
+ * const schematron = yield* Schematron;
1180
+ * return yield* schematron.run(document);
1181
+ * });
1182
+ * ```;
1183
+ *
1184
+ * @param document - The PEPPOL invoice or credit note to validate.
1185
+ *
1186
+ * @returns An `Effect` that succeeds with a `Result` holding `void`, or fails with the wrapped rule failures.
1144
1187
  */
1145
1188
  readonly run: (document: PeppolDocument) => Effect.Effect<Result.Result<void, SchematronValidationError>>;
1146
1189
  }
1147
1190
  declare const Schematron_base: Context.ServiceClass<Schematron, "@endevops/peppol-schema/schematron/Schematron", SchematronShape>;
1148
1191
  /**
1149
1192
  * @description Runs the schematron rules of this library against a PEPPOL document.
1193
+ *
1194
+ * @example
1195
+ * ```ts
1196
+ * const program = Effect.gen(function* () {
1197
+ * const schematron = yield* Schematron;
1198
+ * return yield* schematron.run(document);
1199
+ * });
1200
+ * ```;
1201
+ *
1202
+ * @see {@link SchematronShape}
1150
1203
  */
1151
1204
  export declare class Schematron extends Schematron_base {
1205
+ /**
1206
+ * @description Layer that builds the {@link Schematron} service from the rule validators in `ruleValidators`.
1207
+ */
1152
1208
  static readonly layer: Layer.Layer<Schematron, never, never>;
1153
1209
  }
1154
1210
  //#endregion