@endevops/peppol-schema 0.1.3 → 0.1.5

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 (185) 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-XG-N6PcG.d.ts} +1702 -724
  7. package/dist/index-XG-N6PcG.d.ts.map +1 -0
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.js +1247 -200
  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 +458 -7
  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 +1 -1
  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/decoders/fields/decode-invoice-message-document-party.ts +2 -2
  55. package/src/decoders/fields/decode-parties-tax-scheme.ts +2 -2
  56. package/src/decoders/fields/decode-party-legal-entity.ts +2 -2
  57. package/src/decoders/fields/decode-party-tax-scheme.ts +2 -2
  58. package/src/decoders/fields/decode-tax-category.ts +1 -1
  59. package/src/decoders/fields/decode-tax-representative-party.ts +2 -2
  60. package/src/decoders/fields/encode-message-party.ts +2 -2
  61. package/src/decoders/fields/encode-parties-tax-scheme.ts +3 -3
  62. package/src/decoders/fields/encode-party-legal-entity.ts +1 -1
  63. package/src/decoders/fields/encode-party-tax-scheme.ts +2 -2
  64. package/src/decoders/fields/encode-tax-representative-party.ts +2 -2
  65. package/src/invoice-response-codes/invoice-response-code-needs-schema.ts +9 -0
  66. package/src/invoice-response-codes/invoice-response-code-not-needs-schema.ts +9 -0
  67. package/src/invoice-response-codes/invoice-response-codes-order.ts +10 -0
  68. package/src/peppol-validations/add-piva.ts +12 -0
  69. package/src/peppol-validations/check-cf.ts +11 -0
  70. package/src/peppol-validations/check-cf16.ts +12 -0
  71. package/src/peppol-validations/check-piva-se-it.ts +11 -0
  72. package/src/peppol-validations/check-piva.ts +11 -0
  73. package/src/peppol-validations/check-se-orgnr.ts +9 -0
  74. package/src/peppol-validations/greek-tin-verification.ts +9 -0
  75. package/src/peppol-validations/is-valid-abn.ts +9 -0
  76. package/src/peppol-validations/is-valid-gln.ts +10 -0
  77. package/src/peppol-validations/is-valid-iban.ts +10 -0
  78. package/src/peppol-validations/is-valid-mod11.ts +9 -0
  79. package/src/peppol-validations/is-valid-mod97-0208.ts +10 -0
  80. package/src/peppol-validations/luhn-check.ts +9 -0
  81. package/src/schemas/fields/default-customization-id.ts +9 -0
  82. package/src/schemas/fields/default-profile-id.ts +9 -0
  83. package/src/schemas/fields/peppol-additional-document-reference-schema.ts +61 -20
  84. package/src/schemas/fields/peppol-address-schema.ts +25 -2
  85. package/src/schemas/fields/peppol-allowance-charge-schema.ts +63 -9
  86. package/src/schemas/fields/peppol-amount-schema.ts +15 -2
  87. package/src/schemas/fields/peppol-base-line-schema.ts +12 -2
  88. package/src/schemas/fields/peppol-billing-reference-schema.ts +13 -0
  89. package/src/schemas/fields/peppol-binary-object-schema.ts +12 -4
  90. package/src/schemas/fields/peppol-contact-schema.ts +11 -0
  91. package/src/schemas/fields/peppol-credit-note-line-schema.ts +7 -2
  92. package/src/schemas/fields/peppol-delivery-schema.ts +44 -2
  93. package/src/schemas/fields/peppol-identifier-schema.ts +8 -0
  94. package/src/schemas/fields/peppol-invoice-line-period-schema.ts +11 -0
  95. package/src/schemas/fields/peppol-invoice-line-schema.ts +9 -2
  96. package/src/schemas/fields/peppol-invoice-period-schema.ts +2 -2
  97. package/src/schemas/fields/peppol-item-classification-schema.ts +2 -2
  98. package/src/schemas/fields/peppol-line-allowance-charge-schema.ts +56 -8
  99. package/src/schemas/fields/peppol-line-item-schema.ts +66 -6
  100. package/src/schemas/fields/peppol-line-price-allowance-charge-schema.ts +20 -0
  101. package/src/schemas/fields/peppol-line-price-schema.ts +2 -0
  102. package/src/schemas/fields/peppol-order-reference-schema.ts +2 -0
  103. package/src/schemas/fields/peppol-party-base-schema.ts +36 -4
  104. package/src/schemas/fields/peppol-party-legal-entity-schema.ts +10 -2
  105. package/src/schemas/fields/peppol-party-tax-scheme-schema.ts +4 -4
  106. package/src/schemas/fields/peppol-payee-party-schema.ts +8 -8
  107. package/src/schemas/fields/peppol-payment-means-schema.ts +62 -2
  108. package/src/schemas/fields/peppol-payment-terms-schema.ts +2 -0
  109. package/src/schemas/fields/peppol-quantity-schema.ts +4 -2
  110. package/src/schemas/fields/peppol-reference-schema.ts +20 -1
  111. package/src/schemas/fields/peppol-tax-category-schema.ts +12 -2
  112. package/src/schemas/fields/peppol-tax-representative-schema.ts +2 -2
  113. package/src/schemas/fields/peppol-tax-subtotal-category-schema.ts +3 -0
  114. package/src/schemas/fields/peppol-tax-subtotal-schema.ts +2 -0
  115. package/src/schemas/fields/peppol-tax-totals-base-schema.ts +3 -3
  116. package/src/schemas/peppol-billing-base-schema.ts +49 -9
  117. package/src/schemas/peppol-credit-note-schema.ts +2 -2
  118. package/src/schemas/peppol-document-response-document-reference-schema.ts +12 -4
  119. package/src/schemas/peppol-document-response-document-schema.ts +5 -5
  120. package/src/schemas/peppol-document-response-line-response-content-schema.ts +22 -2
  121. package/src/schemas/peppol-document-response-line-response-schema.ts +23 -2
  122. package/src/schemas/peppol-document-schema.ts +69 -6
  123. package/src/schemas/peppol-invoice-response-document-actual-response-schema.ts +53 -4
  124. package/src/schemas/peppol-invoice-response-document-actual-response-status-schema.ts +22 -4
  125. package/src/schemas/peppol-invoice-response-schema.ts +54 -6
  126. package/src/schemas/peppol-invoice-response-status-reason-code-schema.ts +36 -8
  127. package/src/schemas/peppol-invoice-schema.ts +30 -2
  128. package/src/schemas/peppol-message-level-response-document-response-schema.ts +10 -0
  129. package/src/schemas/peppol-message-level-response-party-schema.ts +10 -0
  130. package/src/schemas/peppol-message-level-response-schema.ts +18 -0
  131. package/src/schemas/utils/format-quantity-with-unit.ts +19 -0
  132. package/src/schemas/utils/get-credit-note-type-code-description.ts +12 -0
  133. package/src/schemas/utils/get-invoice-type-code-description.ts +12 -0
  134. package/src/schemas/utils/is-valid-credit-note-type-code.ts +13 -0
  135. package/src/schemas/utils/is-valid-invoice-type-code.ts +13 -0
  136. package/src/schemas/utils/is-valid-process.ts +13 -0
  137. package/src/schemas/utils/peppol-base-64-schema.ts +7 -4
  138. package/src/schemas/utils/peppol-vat-regex-schema.ts +38 -30
  139. package/src/schemas/utils/peppol-xsd-time-schema.ts +12 -2
  140. package/src/schemas/utils/quantity-unit-code-to-intl-unit.ts +34 -0
  141. package/src/schemas/values/additional-document-reference-code-schema.ts +9 -15
  142. package/src/schemas/values/allowance-charge-reason-code-schema.ts +12 -14
  143. package/src/schemas/values/application-response-type-code-schema.ts +10 -14
  144. package/src/schemas/values/charge-reason-code-schema.ts +12 -14
  145. package/src/schemas/values/credit-note-type-code-schema.ts +8 -14
  146. package/src/schemas/values/currency-code-schema.ts +13 -16
  147. package/src/schemas/values/document-type-schemes-schema.ts +9 -5
  148. package/src/schemas/values/document-type-values-schema.ts +5 -6
  149. package/src/schemas/values/duty-tax-fee-category-schema.ts +15 -13
  150. package/src/schemas/values/electronic-codes-schema.ts +10 -12
  151. package/src/schemas/values/icd-codes-schema.ts +8 -12
  152. package/src/schemas/values/invoice-status-code-schema.ts +10 -12
  153. package/src/schemas/values/invoice-type-code-schema.ts +10 -12
  154. package/src/schemas/values/item-classification-codes-schema.ts +10 -12
  155. package/src/schemas/values/mime-codes-schema.ts +12 -14
  156. package/src/schemas/values/op-status-action-schema.ts +10 -12
  157. package/src/schemas/values/op-status-reason-schema.ts +10 -12
  158. package/src/schemas/values/participant-identifier-code-schema.ts +10 -13
  159. package/src/schemas/values/payment-means-code-schema.ts +10 -12
  160. package/src/schemas/values/peppol-country-code-schema.ts +7 -9
  161. package/src/schemas/values/peppol-document-type-code-schema.ts +10 -12
  162. package/src/schemas/values/peppol-document-type-schema.ts +12 -21
  163. package/src/schemas/values/peppol-process-schema.ts +19 -15
  164. package/src/schemas/values/process-from-document-type-schema.ts +3 -3
  165. package/src/schemas/values/quantity-unit-codes-schema.ts +10 -12
  166. package/src/schemas/values/vat-date-code-schema.ts +12 -5
  167. package/src/schemas/values/vatex-code-schema.ts +8 -12
  168. package/src/schematron/errors.ts +14 -0
  169. package/src/schematron/helpers.ts +457 -11
  170. package/src/schematron/run-all-rules.ts +10 -0
  171. package/src/schematron/schematron.ts +25 -0
  172. package/src/xml/builder-options.ts +9 -0
  173. package/src/xml/common-xml-options.ts +9 -0
  174. package/src/xml/nodable-parser.ts +12 -0
  175. package/src/xml/parser-options.ts +9 -0
  176. package/dist/index-BBzPjq7o.d.ts.map +0 -1
  177. package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js +0 -18
  178. package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js.map +0 -1
  179. package/dist/is-valid-abn-160i38PG.js.map +0 -1
  180. package/dist/is-valid-mod97-0208-CzMOXMO-.js.map +0 -1
  181. package/dist/message-level-response-profile-id-DBpOW91B.js +0 -9
  182. package/dist/message-level-response-profile-id-DBpOW91B.js.map +0 -1
  183. package/dist/nodable-parser-CyDZtLCK.js.map +0 -1
  184. package/dist/vat-dates.generated-CxFvt7m3.d.ts +0 -68
  185. package/dist/vat-dates.generated-CxFvt7m3.d.ts.map +0 -1
@@ -1,12 +1,22 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
3
  import { opaque } from '#/schemas/utils/opaque.ts';
4
- import { opStatusActionSchema } from '#/schemas/values/op-status-action-schema.ts';
5
- import { opStatusReasonSchema } from '#/schemas/values/op-status-reason-schema.ts';
4
+ import { PeppolOpStatusAction } from '#/schemas/values/op-status-action-schema.ts';
5
+ import { PeppolOpStatusReason } from '#/schemas/values/op-status-reason-schema.ts';
6
6
 
7
+ /**
8
+ * @description Status clarification reason (`cbc:StatusReasonCode` with `@listId="OPStatusReason"`), a value from the OPStatusReason code list.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * { value: 'REF', listId: 'OPStatusReason' }
13
+ * ```;
14
+ *
15
+ * @see {@link PeppolInvoiceResponseStatusReasonCode}
16
+ */
7
17
  export class PeppolInvoiceResponseStatusReasonCodeReason extends opaque<PeppolInvoiceResponseStatusReasonCodeReason>()(
8
18
  Schema.Struct({
9
- value: opStatusReasonSchema,
19
+ value: PeppolOpStatusReason,
10
20
  /**
11
21
  * @description List identifier for clarification.
12
22
  *
@@ -18,9 +28,19 @@ export class PeppolInvoiceResponseStatusReasonCodeReason extends opaque<PeppolIn
18
28
  })
19
29
  ) {}
20
30
 
31
+ /**
32
+ * @description Status clarification action (`cbc:StatusReasonCode` with `@listId="OPStatusAction"`), a value from the OPStatusAction code list.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * { value: 'PIN', listId: 'OPStatusAction' }
37
+ * ```;
38
+ *
39
+ * @see {@link PeppolInvoiceResponseStatusReasonCode}
40
+ */
21
41
  export class PeppolInvoiceResponseStatusReasonCodeAction extends opaque<PeppolInvoiceResponseStatusReasonCodeAction>()(
22
42
  Schema.Struct({
23
- value: opStatusActionSchema,
43
+ value: PeppolOpStatusAction,
24
44
  /**
25
45
  * @description List identifier for clarification.
26
46
  *
@@ -32,9 +52,17 @@ export class PeppolInvoiceResponseStatusReasonCodeAction extends opaque<PeppolIn
32
52
  })
33
53
  ) {}
34
54
 
35
- export const peppolInvoiceResponseStatusReasonCodeSchema = Schema.Union([
55
+ /**
56
+ * @description Union of the accepted status clarification reasons and actions on an invoice response.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * { value: 'REF', listId: 'OPStatusReason' }
61
+ * ```;
62
+ *
63
+ * @see {@link PeppolInvoiceResponseDocumentActualResponseStatus}
64
+ */
65
+ export class PeppolInvoiceResponseStatusReasonCode extends Schema.Union([
36
66
  PeppolInvoiceResponseStatusReasonCodeAction,
37
67
  PeppolInvoiceResponseStatusReasonCodeReason,
38
- ]);
39
-
40
- export type PeppolInvoiceResponseStatusReasonCode = typeof peppolInvoiceResponseStatusReasonCodeSchema.Type;
68
+ ]) {}
@@ -4,10 +4,38 @@ import { PeppolInvoiceLine } from '#/schemas/fields/peppol-invoice-line-schema.t
4
4
  import { PeppolBillingBase } from '#/schemas/peppol-billing-base-schema.ts';
5
5
  import { PeppolIsoDateString } from '#/schemas/peppol-iso-date-string.ts';
6
6
  import { opaque } from '#/schemas/utils/opaque.ts';
7
- import { invoiceTypeCodeSchema } from '#/schemas/values/invoice-type-code-schema.ts';
7
+ import { PeppolInvoiceTypeCode } from '#/schemas/values/invoice-type-code-schema.ts';
8
8
 
9
+ /**
10
+ * @description Wraps the `cac:ProjectReference` element on an invoice: an identifier of the project the invoice relates to.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * { id: 'project-123' }
15
+ * ```;
16
+ *
17
+ * @see {@link PeppolInvoice}
18
+ */
9
19
  export class PeppolProjectReference extends opaque<PeppolProjectReference>()(Schema.Struct({ id: Schema.String })) {}
10
20
 
21
+ /**
22
+ * @description UBL `Invoice` for PEPPOL BIS Billing 3.0. Extends {@link PeppolBillingBase} with the due date, type code, lines and project reference.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * {
27
+ * customizationId: 'urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0',
28
+ * profileId: 'urn:fdc:peppol.eu:2017:poacc:billing:01:1.0',
29
+ * id: '33445566',
30
+ * issueDate: '2017-11-01',
31
+ * documentCurrencyCode: 'EUR',
32
+ * invoiceTypeCode: '380'
33
+ * }
34
+ * ```;
35
+ *
36
+ * @see {@link PeppolBillingBase}
37
+ * @see {@link PeppolCreditNote}
38
+ */
11
39
  export class PeppolInvoice extends opaque<PeppolInvoice>()(
12
40
  Schema.Struct({
13
41
  ...PeppolBillingBase.fields,
@@ -34,7 +62,7 @@ export class PeppolInvoice extends opaque<PeppolInvoice>()(
34
62
  *
35
63
  * @name cbc:InvoiceTypeCode
36
64
  */
37
- invoiceTypeCode: invoiceTypeCodeSchema,
65
+ invoiceTypeCode: PeppolInvoiceTypeCode,
38
66
  /**
39
67
  * @summary PROJECT REFERENCE
40
68
  *
@@ -5,6 +5,16 @@ import { PeppolDocumentResponseDocument } from '#/schemas/peppol-document-respon
5
5
  import { PeppolDocumentResponseLineResponse } from '#/schemas/peppol-document-response-line-response-schema.ts';
6
6
  import { opaque } from '#/schemas/utils/opaque.ts';
7
7
 
8
+ /**
9
+ * @description Wraps `cac:DocumentResponse` inside a message level response: the response, the document reference and any per-line responses.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * { response: { responseCode: 'RE' }, documentReference: { id: 'EnvelopeID-12345' }, lineResponse: [] }
14
+ * ```;
15
+ *
16
+ * @see {@link PeppolMessageLevelResponse}
17
+ */
8
18
  export class PeppolMessageLevelResponseDocumentResponse extends opaque<PeppolMessageLevelResponseDocumentResponse>()(
9
19
  Schema.Struct({
10
20
  /**
@@ -3,6 +3,16 @@ import { Schema } from 'effect';
3
3
  import { PeppolIdentifier } from '#/schemas/fields/peppol-identifier-schema.ts';
4
4
  import { opaque } from '#/schemas/utils/opaque.ts';
5
5
 
6
+ /**
7
+ * @description Party used as `cac:SenderParty` or `cac:ReceiverParty` on a message level response, holding the party's electronic address.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * { endpointId: { id: '7300010000001', schemeId: '0088' } }
12
+ * ```;
13
+ *
14
+ * @see {@link PeppolMessageLevelResponse}
15
+ */
6
16
  export class PeppolMessageLevelResponseParty extends opaque<PeppolMessageLevelResponseParty>()(
7
17
  Schema.Struct({
8
18
  /**
@@ -7,6 +7,24 @@ import { PeppolMessageLevelResponseParty } from '#/schemas/peppol-message-level-
7
7
  import { opaque } from '#/schemas/utils/opaque.ts';
8
8
  import { PeppolXsdTime } from '#/schemas/utils/peppol-xsd-time-schema.ts';
9
9
 
10
+ /**
11
+ * @description UBL `ApplicationResponse` message level response for PEPPOL BIS Billing 3.0 (profile `urn:fdc:peppol.eu:poacc:bis:mlr:3`).
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * {
16
+ * customizationId: 'urn:fdc:peppol.eu:poacc:trns:mlr:3',
17
+ * profileId: 'urn:fdc:peppol.eu:poacc:bis:mlr:3',
18
+ * id: '23',
19
+ * issueDate: '2017-11-01',
20
+ * senderParty: {},
21
+ * receiverParty: {},
22
+ * documentResponse: { response: { responseCode: 'RE' }, documentReference: { id: 'EnvelopeID-12345' }, lineResponse: [] }
23
+ * }
24
+ * ```;
25
+ *
26
+ * @see {@link PeppolInvoiceResponse}
27
+ */
10
28
  export class PeppolMessageLevelResponse extends opaque<PeppolMessageLevelResponse>()(
11
29
  Schema.Struct({
12
30
  /**
@@ -1,6 +1,25 @@
1
1
  import { quantityToIntlUnitMap } from '#/schemas/utils/quantity-unit-code-to-intl-unit.ts';
2
2
  import { quantityUnitCodes } from '#/values/quantity-unit-codes.generated';
3
3
 
4
+ /**
5
+ * @description Formats a quantity and its unit code for a locale. Uses `Intl.NumberFormat` for mapped codes, otherwise the code list name.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * formatQuantityWithUnit(5, 'KGM', 'en-US', 'long'); // '5 kilograms'
10
+ * formatQuantityWithUnit(10, 'EA'); // '10 each'
11
+ * ```;
12
+ *
13
+ * @param value - The numeric quantity to format.
14
+ * @param code - The UN/ECE Rec 20 unit code to render, for example `KGM` or `MTR`.
15
+ * @param locale - BCP 47 locale tag passed to `Intl.NumberFormat`. Defaults to `'en-US'`.
16
+ * @param unitDisplay - `Intl` unit display style: `'short'`, `'narrow'`, or `'long'`. Defaults to `'short'`.
17
+ *
18
+ * @returns The formatted quantity and unit, for example `'5 kilograms'`. Falls back to `<number> <name>` when the code has no `Intl` unit or `Intl`
19
+ * rejects the unit.
20
+ *
21
+ * @see {@link quantityUnitCodeToIntlUnit}
22
+ */
4
23
  export function formatQuantityWithUnit(
5
24
  value: number,
6
25
  code: string,
@@ -2,6 +2,18 @@ import type { PeppolCreditNoteTypeCode } from '#/schemas/values/credit-note-type
2
2
 
3
3
  import { creditNoteTypeCodes } from '#/values/credit-notes-type-codes.generated';
4
4
 
5
+ /**
6
+ * @description Returns the human-readable description of a PEPPOL credit note type code (UNCL1001 subset).
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * getCreditNoteTypeCodeDescription('381'); // 'Credit note'
11
+ * ```;
12
+ *
13
+ * @param code - A valid {@link PeppolCreditNoteTypeCode}, for example `'381'`.
14
+ *
15
+ * @returns The description registered for the code, for example `'Credit note'`.
16
+ */
5
17
  export function getCreditNoteTypeCodeDescription(code: PeppolCreditNoteTypeCode): string {
6
18
  return (creditNoteTypeCodes as Record<string, string>)[code] as string;
7
19
  }
@@ -2,6 +2,18 @@ import type { PeppolInvoiceTypeCode } from '#/schemas/values/invoice-type-code-s
2
2
 
3
3
  import { invoiceTypeCodes } from '#/values/invoice-type-codes.generated';
4
4
 
5
+ /**
6
+ * @description Returns the human-readable description of a PEPPOL invoice type code (UNCL1001 subset).
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * getInvoiceTypeCodeDescription('380'); // 'Commercial invoice'
11
+ * ```;
12
+ *
13
+ * @param code - A valid {@link PeppolInvoiceTypeCode}, for example `'380'`.
14
+ *
15
+ * @returns The description registered for the code, for example `'Commercial invoice'`.
16
+ */
5
17
  export function getInvoiceTypeCodeDescription(code: PeppolInvoiceTypeCode): string {
6
18
  return (invoiceTypeCodes as Record<string, string>)[code] as string;
7
19
  }
@@ -2,6 +2,19 @@ import type { PeppolCreditNoteTypeCode } from '#/schemas/values/credit-note-type
2
2
 
3
3
  import { creditNoteTypeCodes } from '#/values/credit-notes-type-codes.generated';
4
4
 
5
+ /**
6
+ * @description Type guard for PEPPOL credit note type codes (UNCL1001 subset).
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isValidCreditNoteTypeCode('381'); // true
11
+ * isValidCreditNoteTypeCode('UNKNOWN'); // false
12
+ * ```;
13
+ *
14
+ * @param code - The string to test.
15
+ *
16
+ * @returns `true` when `code` is a known credit note type code, narrowing it to {@link PeppolCreditNoteTypeCode}; otherwise `false`.
17
+ */
5
18
  export function isValidCreditNoteTypeCode(code: string): code is PeppolCreditNoteTypeCode {
6
19
  return code in creditNoteTypeCodes;
7
20
  }
@@ -2,6 +2,19 @@ import type { PeppolInvoiceTypeCode } from '#/schemas/values/invoice-type-code-s
2
2
 
3
3
  import { invoiceTypeCodes } from '#/values/invoice-type-codes.generated';
4
4
 
5
+ /**
6
+ * @description Type guard for PEPPOL invoice type codes (UNCL1001 subset).
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isValidInvoiceTypeCode('380'); // true
11
+ * isValidInvoiceTypeCode('UNKNOWN'); // false
12
+ * ```;
13
+ *
14
+ * @param code - The string to test.
15
+ *
16
+ * @returns `true` when `code` is a known invoice type code, narrowing it to {@link PeppolInvoiceTypeCode}; otherwise `false`.
17
+ */
5
18
  export function isValidInvoiceTypeCode(code: string): code is PeppolInvoiceTypeCode {
6
19
  return code in invoiceTypeCodes;
7
20
  }
@@ -2,6 +2,19 @@ import type { PeppolProcesses } from '#/schemas/values/peppol-process-schema.ts'
2
2
 
3
3
  import { processesList } from '#/values/processes.generated';
4
4
 
5
+ /**
6
+ * @description Type guard for PEPPOL business process identifiers of the form `<scheme>::<value>`.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isValidProcess('cenbii-procid-ubl::urn:fdc:peppol.eu:2017:poacc:billing:01:1.0'); // true
11
+ * isValidProcess('cenbii-procid-ubl::urn:not:a:process'); // false
12
+ * ```;
13
+ *
14
+ * @param code - The process identifier to test.
15
+ *
16
+ * @returns `true` when `code` appears in {@link processesList}, narrowing it to {@link PeppolProcesses}; otherwise `false`.
17
+ */
5
18
  export function isValidProcess(code: string): code is PeppolProcesses {
6
19
  return processesList.includes(code);
7
20
  }
@@ -25,9 +25,12 @@ const BASE64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=
25
25
  /**
26
26
  * @description RFC 4648 base64 string (PEM / MIME / XML line endings tolerated). Effect port of `base64Schema` (`z.string().check(z.refine(...))`): strips CRLF /
27
27
  * LF line endings before testing the quantum regex.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const value = 'SGVsbG8=';
32
+ * ```;
28
33
  */
29
- export const peppolBase64Schema = Schema.String.check(Schema.makeFilter((val: string) => BASE64_RE.test(val.replace(/\r?\n/g, '')))).annotate({
34
+ export class PeppolBase64 extends Schema.String.check(Schema.makeFilter((val: string) => BASE64_RE.test(val.replace(/\r?\n/g, '')))).annotate({
30
35
  message: 'Invalid base64',
31
- });
32
-
33
- export type Base64 = typeof peppolBase64Schema.Type;
36
+ }) {}
@@ -1,6 +1,7 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
3
  import { isValidMod97_0208 } from '#/peppol-validations/is-valid-mod97-0208.ts';
4
+ import { opaque } from '#/schemas/utils/opaque.ts';
4
5
 
5
6
  /**
6
7
  * @description Belgian VAT number (`BE` + 10 digits with mod 97-0208 check digits). Effect port of the `BE` member of `vatRegexSchema`: prefix, exact length,
@@ -16,34 +17,41 @@ const belgianVat = Schema.String.check(
16
17
  /**
17
18
  * @description EU VAT identification number (one member per member-state prefix/pattern). Effect port of `vatRegexSchema` (`z.union([...])` of
18
19
  * `z.string().check(...)` members): each member keeps its original prefix + pattern checks as `Schema.String.check` filters.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const value = 'DE123456789';
24
+ * ```;
19
25
  */
20
- export const peppolVatRegexSchema = Schema.Union([
21
- belgianVat,
22
- Schema.String.check(Schema.isStartsWith('AT'), Schema.isPattern(/^ATU\d{8}$/)),
23
- Schema.String.check(Schema.isStartsWith('BG'), Schema.isPattern(/^BG\d{9,10}$/)),
24
- Schema.String.check(Schema.isStartsWith('CY'), Schema.isPattern(/^CY\d{8}L$/)),
25
- Schema.String.check(Schema.isStartsWith('CZ'), Schema.isPattern(/^CZ\d{8,10}$/)),
26
- Schema.String.check(Schema.isStartsWith('DE'), Schema.isPattern(/^DE\d{9}$/)),
27
- Schema.String.check(Schema.isStartsWith('DK'), Schema.isPattern(/^DK\d{8}$/)),
28
- Schema.String.check(Schema.isStartsWith('EE'), Schema.isPattern(/^EE\d{9}$/)),
29
- Schema.String.check(Schema.isStartsWith('EL'), Schema.isPattern(/^EL\d{9}$/)),
30
- Schema.String.check(Schema.isStartsWith('GR'), Schema.isPattern(/^GR\d{9}$/)),
31
- Schema.String.check(Schema.isStartsWith('ES'), Schema.isPattern(/^ES[0-9A-Z]\d{7}[0-9A-Z]$/)),
32
- Schema.String.check(Schema.isStartsWith('FI'), Schema.isPattern(/^FI\d{8}$/)),
33
- Schema.String.check(Schema.isStartsWith('FR'), Schema.isPattern(/^FR[0-9A-Z]{2}\d{9}$/)),
34
- Schema.String.check(Schema.isStartsWith('GB'), Schema.isPattern(/^GB(\d{9}(\d{3})?|[A-Z]{2}\d{3})$/)),
35
- Schema.String.check(Schema.isStartsWith('HU'), Schema.isPattern(/^HU\d{8}$/)),
36
- Schema.String.check(Schema.isStartsWith('IE'), Schema.isPattern(/^IE\dS\d{5}L$/)),
37
- Schema.String.check(Schema.isStartsWith('IT'), Schema.isPattern(/^IT\d{11}$/)),
38
- Schema.String.check(Schema.isStartsWith('LT'), Schema.isPattern(/^LT(\d{9}|\d{12})$/)),
39
- Schema.String.check(Schema.isStartsWith('LU'), Schema.isPattern(/^LU\d{8}$/)),
40
- Schema.String.check(Schema.isStartsWith('LV'), Schema.isPattern(/^LV\d{11}$/)),
41
- Schema.String.check(Schema.isStartsWith('MT'), Schema.isPattern(/^MT\d{8}$/)),
42
- Schema.String.check(Schema.isStartsWith('NL'), Schema.isPattern(/^NL\d{9}B\d{2}$/)),
43
- Schema.String.check(Schema.isStartsWith('PL'), Schema.isPattern(/^PL\d{10}$/)),
44
- Schema.String.check(Schema.isStartsWith('PT'), Schema.isPattern(/^PT\d{9}$/)),
45
- Schema.String.check(Schema.isStartsWith('RO'), Schema.isPattern(/^RO\d{2,10}$/)),
46
- Schema.String.check(Schema.isStartsWith('SE'), Schema.isPattern(/^SE\d{12}$/)),
47
- Schema.String.check(Schema.isStartsWith('SI'), Schema.isPattern(/^SI\d{8}$/)),
48
- Schema.String.check(Schema.isStartsWith('SK'), Schema.isPattern(/^SK\d{10}$/)),
49
- ]);
26
+ export class PeppolVatRegex extends opaque<PeppolVatRegex>()(
27
+ Schema.Union([
28
+ belgianVat,
29
+ Schema.String.check(Schema.isStartsWith('AT'), Schema.isPattern(/^ATU\d{8}$/)),
30
+ Schema.String.check(Schema.isStartsWith('BG'), Schema.isPattern(/^BG\d{9,10}$/)),
31
+ Schema.String.check(Schema.isStartsWith('CY'), Schema.isPattern(/^CY\d{8}L$/)),
32
+ Schema.String.check(Schema.isStartsWith('CZ'), Schema.isPattern(/^CZ\d{8,10}$/)),
33
+ Schema.String.check(Schema.isStartsWith('DE'), Schema.isPattern(/^DE\d{9}$/)),
34
+ Schema.String.check(Schema.isStartsWith('DK'), Schema.isPattern(/^DK\d{8}$/)),
35
+ Schema.String.check(Schema.isStartsWith('EE'), Schema.isPattern(/^EE\d{9}$/)),
36
+ Schema.String.check(Schema.isStartsWith('EL'), Schema.isPattern(/^EL\d{9}$/)),
37
+ Schema.String.check(Schema.isStartsWith('GR'), Schema.isPattern(/^GR\d{9}$/)),
38
+ Schema.String.check(Schema.isStartsWith('ES'), Schema.isPattern(/^ES[0-9A-Z]\d{7}[0-9A-Z]$/)),
39
+ Schema.String.check(Schema.isStartsWith('FI'), Schema.isPattern(/^FI\d{8}$/)),
40
+ Schema.String.check(Schema.isStartsWith('FR'), Schema.isPattern(/^FR[0-9A-Z]{2}\d{9}$/)),
41
+ Schema.String.check(Schema.isStartsWith('GB'), Schema.isPattern(/^GB(\d{9}(\d{3})?|[A-Z]{2}\d{3})$/)),
42
+ Schema.String.check(Schema.isStartsWith('HU'), Schema.isPattern(/^HU\d{8}$/)),
43
+ Schema.String.check(Schema.isStartsWith('IE'), Schema.isPattern(/^IE\dS\d{5}L$/)),
44
+ Schema.String.check(Schema.isStartsWith('IT'), Schema.isPattern(/^IT\d{11}$/)),
45
+ Schema.String.check(Schema.isStartsWith('LT'), Schema.isPattern(/^LT(\d{9}|\d{12})$/)),
46
+ Schema.String.check(Schema.isStartsWith('LU'), Schema.isPattern(/^LU\d{8}$/)),
47
+ Schema.String.check(Schema.isStartsWith('LV'), Schema.isPattern(/^LV\d{11}$/)),
48
+ Schema.String.check(Schema.isStartsWith('MT'), Schema.isPattern(/^MT\d{8}$/)),
49
+ Schema.String.check(Schema.isStartsWith('NL'), Schema.isPattern(/^NL\d{9}B\d{2}$/)),
50
+ Schema.String.check(Schema.isStartsWith('PL'), Schema.isPattern(/^PL\d{10}$/)),
51
+ Schema.String.check(Schema.isStartsWith('PT'), Schema.isPattern(/^PT\d{9}$/)),
52
+ Schema.String.check(Schema.isStartsWith('RO'), Schema.isPattern(/^RO\d{2,10}$/)),
53
+ Schema.String.check(Schema.isStartsWith('SE'), Schema.isPattern(/^SE\d{12}$/)),
54
+ Schema.String.check(Schema.isStartsWith('SI'), Schema.isPattern(/^SI\d{8}$/)),
55
+ Schema.String.check(Schema.isStartsWith('SK'), Schema.isPattern(/^SK\d{10}$/)),
56
+ ])
57
+ ) {}
@@ -17,9 +17,14 @@ const numberFromString = (value: string | undefined): number => {
17
17
  /**
18
18
  * @description Parse a timezone offset from a string. The string must be in the format `(+|-)HH:MM` where `HH` and `MM` are two digits.
19
19
  *
20
- * @param tz - The timzeone offset string.
20
+ * @example
21
+ * ```ts
22
+ * parseZoneOffsetFromString('+01:00'); // a +01:00 zone offset
23
+ * ```;
21
24
  *
22
- * @returns
25
+ * @param tz - The timezone offset string.
26
+ *
27
+ * @returns A `DateTime.Zone` offset built from the parsed hours and minutes, or `undefined` when `tz` does not match the offset pattern.
23
28
  *
24
29
  * @internal
25
30
  */
@@ -36,6 +41,11 @@ export const parseZoneOffsetFromString = (tz: `+${number}:${number}` | `-${numbe
36
41
  /**
37
42
  * @description XSD `time` lexical value (`HH:MM:SS` with optional fractional seconds and timezone). Effect port of `xsdTime` (`z.string().check(z.regex(...))`):
38
43
  * keeps the value as a plain string and only validates the shape.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const value = '12:30:45+01:00';
48
+ * ```;
39
49
  */
40
50
  export class PeppolXsdTime extends opaque<PeppolXsdTime>()(
41
51
  Schema.String.check(
@@ -1,5 +1,8 @@
1
1
  import type { PeppolQuantityUnitCode } from '#/schemas/values/quantity-unit-codes-schema.ts';
2
2
 
3
+ /**
4
+ * @description String union of `Intl.NumberFormat` unit identifiers for base units such as length, area, volume, mass, and temperature.
5
+ */
3
6
  export type BaseIntlUnit =
4
7
  | 'acre'
5
8
  | 'bit'
@@ -36,10 +39,26 @@ export type BaseIntlUnit =
36
39
  | 'terabit'
37
40
  | 'terabyte'
38
41
  | 'yard';
42
+ /**
43
+ * @description String union of `Intl.NumberFormat` unit identifiers for time units, used on their own and as the denominator of a rate.
44
+ */
39
45
  export type TimeIntlUnit = 'nanosecond' | 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
40
46
 
47
+ /**
48
+ * @description Any `Intl.NumberFormat` unit identifier supported by this module: a {@link BaseIntlUnit}, a {@link TimeIntlUnit}, or a rate such as
49
+ * `'kilometer-per-hour'`.
50
+ */
41
51
  export type IntlUnit = BaseIntlUnit | TimeIntlUnit | `${BaseIntlUnit}-per-${TimeIntlUnit}`;
42
52
 
53
+ /**
54
+ * @description Maps UN/ECE Rec 20 quantity unit codes to `Intl.NumberFormat` unit identifiers. Unmapped codes are omitted.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * quantityToIntlUnitMap.KGM; // 'kilogram'
59
+ * quantityToIntlUnitMap.KMH; // 'kilometer-per-hour'
60
+ * ```;
61
+ */
43
62
  export const quantityToIntlUnitMap = {
44
63
  CMT: 'centimeter',
45
64
  MTR: 'meter',
@@ -106,6 +125,21 @@ export const quantityToIntlUnitMap = {
106
125
  '4M': 'gram-per-hour' as IntlUnit,
107
126
  } satisfies Partial<Record<string, IntlUnit>>;
108
127
 
128
+ /**
129
+ * @description Looks up the `Intl.NumberFormat` unit identifier for a UN/ECE Rec 20 quantity unit code.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * quantityUnitCodeToIntlUnit('KGM'); // 'kilogram'
134
+ * quantityUnitCodeToIntlUnit('EA'); // undefined
135
+ * ```;
136
+ *
137
+ * @param code - A quantity unit code, typed as {@link PeppolQuantityUnitCode} but accepting any string.
138
+ *
139
+ * @returns The matching {@link IntlUnit}, or `undefined` when the code has no `Intl` unit mapping.
140
+ *
141
+ * @see {@link quantityToIntlUnitMap}
142
+ */
109
143
  export function quantityUnitCodeToIntlUnit(code: PeppolQuantityUnitCode | (string & {})): IntlUnit | undefined {
110
144
  return (quantityToIntlUnitMap as Record<string, IntlUnit>)[code];
111
145
  }
@@ -1,25 +1,19 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { additionalDocumentReferenceCodesKeys } from '#/values/additional-document-reference-codes.generated';
4
5
 
5
6
  /**
6
- * @description Additional document reference.
7
+ * @description An additional document reference code from the PEPPOL subset of UNCL 1153 (invoiced object identifier scheme).
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1153/
9
- * @see {@link additionalDocumentReferenceCodesKeys}
10
- */
11
- export type PeppolAdditionalDocumentReferenceCode = typeof additionalDocumentReferenceCodeSchema.Type;
12
-
13
- /**
14
- * @description Validates an additional document reference code against the PEPPOL subset of UNCL 1153 (reference qualifiers).
15
- *
16
- * @param error - The custom error message to use when validation fails. Defaults to the generic message.
17
- *
18
- * @returns An Effect schema that accepts only valid additional document reference codes.
9
+ * @example
10
+ * ```ts
11
+ * 'AAA';
12
+ * ```;
19
13
  *
20
14
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1153/
21
15
  * @see {@link additionalDocumentReferenceCodesKeys}
22
16
  */
23
- export const additionalDocumentReferenceCodeSchema = Schema.Literals(additionalDocumentReferenceCodesKeys).pipe(
24
- Schema.brand('PeppolAdditionalDocumentReferenceCode')
25
- );
17
+ export class PeppolAdditionalDocumentReferenceCode extends opaque<PeppolAdditionalDocumentReferenceCode>()(
18
+ Schema.Literals(additionalDocumentReferenceCodesKeys).pipe(Schema.brand('PeppolAdditionalDocumentReferenceCode'))
19
+ ) {}
@@ -1,26 +1,24 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { allowanceChargeReasonCodesKeys } from '#/values/allowance-charge-reason-codes.generated';
4
5
 
5
6
  /**
6
- * @description An allowance or charge reason code as defined by the PEPPOL subset of UNCL 5189.
7
+ * @description An allowance or charge reason code from the PEPPOL subset of UNCL 5189 (D.16B).
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5189/
9
- */
10
- export type PeppolAllowanceChargeReasonCode = typeof allowanceChargeReasonCodeSchema.Type;
11
-
12
- /**
13
- * @description Validates an allowance or charge reason code against the PEPPOL subset of UNCL 5189 (D.16B).
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid allowance/charge reason codes.
9
+ * @example
10
+ * ```ts
11
+ * '41';
12
+ * ```;
18
13
  *
19
14
  * @validations
20
15
  * - PEPPOL-EN16931-CL002: Document allowance reason code MUST be according to the subset of UNCL 5189 D.16B.
21
16
  *
22
17
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5189/
18
+ * @see {@link allowanceChargeReasonCodesKeys}
23
19
  */
24
- export const allowanceChargeReasonCodeSchema = Schema.Literals(allowanceChargeReasonCodesKeys)
25
- .pipe(Schema.brand('PeppolAllowanceChargeReasonCode'))
26
- .annotate({ documentation: 'PEPPOL-EN16931-CL002: Reason code MUST be according to subset of UNCL 5189 D.16B.' });
20
+ export class PeppolAllowanceChargeReasonCode extends opaque<PeppolAllowanceChargeReasonCode>()(
21
+ Schema.Literals(allowanceChargeReasonCodesKeys)
22
+ .pipe(Schema.brand('PeppolAllowanceChargeReasonCode'))
23
+ .annotate({ documentation: 'PEPPOL-EN16931-CL002: Reason code MUST be according to subset of UNCL 5189 D.16B.' })
24
+ ) {}
@@ -1,23 +1,19 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
- import type { ApplicationResponseTypeCodesKeys } from '#/values/application-response-type-codes.generated';
4
-
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
5
4
  import { applicationResponseTypeCodesKeys } from '#/values/application-response-type-codes.generated';
6
5
 
7
6
  /**
8
- * @description An application response type code as defined by the PEPPOL subset of UNCL 4343.
9
- *
10
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL4343/
11
- */
12
- export type PeppolApplicationResponseTypeCode = ApplicationResponseTypeCodesKeys;
13
-
14
- /**
15
- * @description Validates an application response type code against the PEPPOL subset of UNCL 4343.
16
- *
17
- * @param error - The custom error message to use when validation fails.
7
+ * @description An application response type code from the PEPPOL subset of UNCL 4343.
18
8
  *
19
- * @returns An Effect schema that accepts only valid application response type codes.
9
+ * @example
10
+ * ```ts
11
+ * 'AB';
12
+ * ```;
20
13
  *
21
14
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL4343/
15
+ * @see {@link applicationResponseTypeCodesKeys}
22
16
  */
23
- export const applicationResponseTypeCodeSchema = Schema.Literals(applicationResponseTypeCodesKeys);
17
+ export class PeppolApplicationResponseTypeCode extends opaque<PeppolApplicationResponseTypeCode>()(
18
+ Schema.Literals(applicationResponseTypeCodesKeys)
19
+ ) {}
@@ -1,26 +1,24 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { chargeReasonCodesKeys } from '#/values/charge-reason-codes.generated';
4
5
 
5
6
  /**
6
- * @description A charge reason code as defined by the PEPPOL subset of UNCL 7161.
7
+ * @description A charge reason code from the PEPPOL subset of UNCL 7161 (D.16B).
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL7161/
9
- */
10
- export type PeppolChargeReasonCode = typeof chargeReasonCodeSchema.Type;
11
-
12
- /**
13
- * @description Validates a charge reason code against the PEPPOL subset of UNCL 7161 (D.16B).
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid charge reason codes.
9
+ * @example
10
+ * ```ts
11
+ * 'AA';
12
+ * ```;
18
13
  *
19
14
  * @validations
20
15
  * - PEPPOL-EN16931-CL003: Charge reason code MUST be according to UNCL 7161 D.16B.
21
16
  *
22
17
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL7161/
18
+ * @see {@link chargeReasonCodesKeys}
23
19
  */
24
- export const chargeReasonCodeSchema = Schema.Literals(chargeReasonCodesKeys)
25
- .pipe(Schema.brand('PeppolChargeReasonCode'))
26
- .annotate({ documentation: 'PEPPOL-EN16931-CL003: Reason code MUST be according to UNCL 7161 D.16B.' });
20
+ export class PeppolChargeReasonCode extends opaque<PeppolChargeReasonCode>()(
21
+ Schema.Literals(chargeReasonCodesKeys)
22
+ .pipe(Schema.brand('PeppolChargeReasonCode'))
23
+ .annotate({ documentation: 'PEPPOL-EN16931-CL003: Reason code MUST be according to UNCL 7161 D.16B.' })
24
+ ) {}