@endevops/peppol-schema 0.1.3 → 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 +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/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
@@ -1,21 +1,19 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { invoiceTypeCodesKeys } from '#/values/invoice-type-codes.generated';
4
5
 
5
6
  /**
6
- * @description An invoice type code as defined by the PEPPOL subset of UNCL 1001 (invoice).
7
+ * @description An invoice type code from the PEPPOL subset of UNCL 1001.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1001-inv/
9
- */
10
- export type PeppolInvoiceTypeCode = typeof invoiceTypeCodeSchema.Type;
11
-
12
- /**
13
- * @description Validates an invoice type code against the PEPPOL subset of UNCL 1001 (invoice).
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid invoice type codes.
9
+ * @example
10
+ * ```ts
11
+ * '71';
12
+ * ```;
18
13
  *
19
14
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1001-inv/
15
+ * @see {@link invoiceTypeCodesKeys}
20
16
  */
21
- export const invoiceTypeCodeSchema = Schema.Literals(invoiceTypeCodesKeys).pipe(Schema.brand('PeppolInvoiceTypeCode'));
17
+ export class PeppolInvoiceTypeCode extends opaque<PeppolInvoiceTypeCode>()(
18
+ Schema.Literals(invoiceTypeCodesKeys).pipe(Schema.brand('PeppolInvoiceTypeCode'))
19
+ ) {}
@@ -1,24 +1,22 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { itemClassificationCodesKeys } from '#/values/item-classification-code.generated';
4
5
 
5
6
  /**
6
- * @description An item classification code as defined by the PEPPOL subset of UNCL 7143.
7
+ * @description An item classification code from the PEPPOL subset of UNCL 7143.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL7143/
9
- */
10
- export type PeppolItemClassificationCode = typeof itemClassificationCodesSchema.Type;
11
-
12
- /**
13
- * @description Validates an item classification code against the PEPPOL subset of UNCL 7143.
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid item classification codes.
9
+ * @example
10
+ * ```ts
11
+ * 'AA';
12
+ * ```;
18
13
  *
19
14
  * @validations
20
15
  * - BR-CL-13: Item classification scheme MUST be a valid UNTDID 7143 code.
21
16
  *
22
17
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL7143/
18
+ * @see {@link itemClassificationCodesKeys}
23
19
  */
24
- export const itemClassificationCodesSchema = Schema.Literals(itemClassificationCodesKeys).pipe(Schema.brand('PeppolItemClassificationCode'));
20
+ export class PeppolItemClassificationCode extends opaque<PeppolItemClassificationCode>()(
21
+ Schema.Literals(itemClassificationCodesKeys).pipe(Schema.brand('PeppolItemClassificationCode'))
22
+ ) {}
@@ -1,26 +1,24 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { mimeCodesKeys } from '#/values/mime-codes.generated';
4
5
 
5
6
  /**
6
- * @description A MIME media type code (e.g. `application/pdf`) as used for attached documents.
7
+ * @description A MIME media type from the PEPPOL MIME code list.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/MimeCode/
9
- */
10
- export type PeppolMimeCode = typeof mimeCodesSchema.Type;
11
-
12
- /**
13
- * @description Validates a MIME media type against the PEPPOL MIME code list.
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid MIME types.
9
+ * @example
10
+ * ```ts
11
+ * 'text/csv';
12
+ * ```;
18
13
  *
19
14
  * @validations
20
15
  * - PEPPOL-EN16931-CL001: Attachment (MIME) type MUST come from the allowed list.
21
16
  *
22
17
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/MimeCode/
18
+ * @see {@link mimeCodesKeys}
23
19
  */
24
- export const mimeCodesSchema = Schema.Literals(mimeCodesKeys)
25
- .pipe(Schema.brand('PeppolMimeCode'))
26
- .annotate({ documentation: 'PEPPOL-EN16931-CL001: Mime code must be according to subset of IANA code list.' });
20
+ export class PeppolMimeCode extends opaque<PeppolMimeCode>()(
21
+ Schema.Literals(mimeCodesKeys)
22
+ .pipe(Schema.brand('PeppolMimeCode'))
23
+ .annotate({ documentation: 'PEPPOL-EN16931-CL001: Mime code must be according to subset of IANA code list.' })
24
+ ) {}
@@ -1,21 +1,19 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { opStatusActionKeys } from '#/values/op-status-action.generated';
4
5
 
5
6
  /**
6
- * @description An OpenPeppol operation status action code (e.g. the outcome of a message response).
7
+ * @description An OpenPeppol operation status action code from the OPStatusAction codelist.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/OPStatusAction/
9
- */
10
- export type PeppolOpStatusAction = typeof opStatusActionSchema.Type;
11
-
12
- /**
13
- * @description Validates an OpenPeppol operation status action code against the OPStatusAction codelist.
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid operation status action codes.
9
+ * @example
10
+ * ```ts
11
+ * 'NOA';
12
+ * ```;
18
13
  *
19
14
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/OPStatusAction/
15
+ * @see {@link opStatusActionKeys}
20
16
  */
21
- export const opStatusActionSchema = Schema.Literals(opStatusActionKeys).pipe(Schema.brand('PeppolOpStatusAction'));
17
+ export class PeppolOpStatusAction extends opaque<PeppolOpStatusAction>()(
18
+ Schema.Literals(opStatusActionKeys).pipe(Schema.brand('PeppolOpStatusAction'))
19
+ ) {}
@@ -1,21 +1,19 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { opStatusReasonKeys } from '#/values/op-status-reason.generated';
4
5
 
5
6
  /**
6
- * @description An OpenPeppol operation status reason code (e.g. the reason for a message response outcome).
7
+ * @description An OpenPeppol operation status reason code from the OPStatusReason codelist.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/OPStatusReason/
9
- */
10
- export type PeppolOpStatusReason = typeof opStatusReasonSchema.Type;
11
-
12
- /**
13
- * @description Validates an OpenPeppol operation status reason code against the OPStatusReason codelist.
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid operation status reason codes.
9
+ * @example
10
+ * ```ts
11
+ * 'NON';
12
+ * ```;
18
13
  *
19
14
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/OPStatusReason/
15
+ * @see {@link opStatusReasonKeys}
20
16
  */
21
- export const opStatusReasonSchema = Schema.Literals(opStatusReasonKeys).pipe(Schema.brand('PeppolOpStatusReason'));
17
+ export class PeppolOpStatusReason extends opaque<PeppolOpStatusReason>()(
18
+ Schema.Literals(opStatusReasonKeys).pipe(Schema.brand('PeppolOpStatusReason'))
19
+ ) {}
@@ -1,21 +1,18 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { participantIdentifierSchemesKeys } from '#/values/participant-identifier-schemes.generated';
4
5
 
5
6
  /**
6
- * @description A PEPPOL participant identifier scheme, identifying the scheme of a participant identifier (e.g. EAS codes).
7
+ * @description A PEPPOL participant identifier scheme from the participant identifier schemes codelist.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/
9
- */
10
- export type PeppolParticipantIdentifierCode = typeof participantIdentifierCodeSchema.Type;
11
-
12
- /**
13
- * @description Validates a PEPPOL participant identifier scheme against the participant identifier schemes list.
14
- *
15
- * @param error - The custom error message to use when validation fails.
9
+ * @example
10
+ * ```ts
11
+ * '0002';
12
+ * ```;
16
13
  *
17
- * @returns An Effect schema that accepts only valid participant identifier schemes.
14
+ * @see {@link participantIdentifierSchemesKeys}
18
15
  */
19
- export const participantIdentifierCodeSchema = Schema.Literals(participantIdentifierSchemesKeys).pipe(
20
- Schema.brand('PeppolParticipantIdentifierCode')
21
- );
16
+ export class PeppolParticipantIdentifierCode extends opaque<PeppolParticipantIdentifierCode>()(
17
+ Schema.Literals(participantIdentifierSchemesKeys).pipe(Schema.brand('PeppolParticipantIdentifierCode'))
18
+ ) {}
@@ -8,25 +8,23 @@
8
8
 
9
9
  import { Schema } from 'effect';
10
10
 
11
+ import { opaque } from '#/schemas/utils/opaque.ts';
11
12
  import { paymentMeansCodesKeys } from '#/values/payment-means-codes.generated';
12
13
 
13
14
  /**
14
- * @description A payment means code as defined by the PEPPOL subset of UNCL 4461.
15
+ * @description A payment means code from the PEPPOL subset of UNCL 4461.
15
16
  *
16
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL4461/
17
- */
18
- export type PeppolPaymentMeansCode = typeof paymentMeansCodeSchema.Type;
19
-
20
- /**
21
- * @description Validates a payment means code against the PEPPOL subset of UNCL 4461.
22
- *
23
- * @param error - The custom error message to use when validation fails.
24
- *
25
- * @returns An Effect schema that accepts only valid payment means codes.
17
+ * @example
18
+ * ```ts
19
+ * '1';
20
+ * ```;
26
21
  *
27
22
  * @validations
28
23
  * - BR-CL-16: Payment means code MUST be a valid UNCL 4461 code.
29
24
  *
30
25
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL4461/
26
+ * @see {@link paymentMeansCodesKeys}
31
27
  */
32
- export const paymentMeansCodeSchema = Schema.Literals(paymentMeansCodesKeys).pipe(Schema.brand('PeppolPaymentMeansCode'));
28
+ export class PeppolPaymentMeansCodeValue extends opaque<PeppolPaymentMeansCodeValue>()(
29
+ Schema.Literals(paymentMeansCodesKeys).pipe(Schema.brand('PeppolPaymentMeansCodeValue'))
30
+ ) {}
@@ -9,22 +9,23 @@
9
9
 
10
10
  import { Schema } from 'effect';
11
11
 
12
+ import { opaque } from '#/schemas/utils/opaque.ts';
12
13
  import { countryCodesKeys } from '#/values/country-code.generated';
13
14
 
14
15
  /**
15
- * @description An ISO 3166-1 alpha-2 country code as defined by the PEPPOL subset.
16
+ * @description A two character ISO 3166-1 alpha-2 country code from the PEPPOL codelist. The literal union enforces the length.
16
17
  *
17
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/ISO3166/
18
- */
19
- export type PeppolCountryCode = typeof peppolCountryCodeSchema.Type;
20
-
21
- /**
22
- * @description Validates a two character ISO 3166-1 alpha-2 country code against the PEPPOL codelist. All codes in the codelist are exactly 2 characters, so the
23
- * literals union implies the length check.
18
+ * @example
19
+ * ```ts
20
+ * 'AD';
21
+ * ```;
24
22
  *
25
23
  * @validations
26
24
  * - BR-CL-14 / BR-CL-15: Country code MUST be a valid ISO 3166-1 alpha-2 code.
27
25
  *
28
26
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/ISO3166/
27
+ * @see {@link countryCodesKeys}
29
28
  */
30
- export const peppolCountryCodeSchema = Schema.Literals(countryCodesKeys).pipe(Schema.brand('PeppolCountryCode'));
29
+ export class PeppolCountryCodeValue extends opaque<PeppolCountryCodeValue>()(
30
+ Schema.Literals(countryCodesKeys).pipe(Schema.brand('PeppolCountryCodeValue'))
31
+ ) {}
@@ -1,21 +1,19 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { documentTypeCodesKeys } from '#/values/document-type-codes.generated';
4
5
 
5
6
  /**
6
- * @description A document type code as defined by the PEPPOL subset of UNCL 1001 (document/message name code).
7
+ * @description A document type code from the PEPPOL subset of UNCL 1001.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1001/
9
- */
10
- export type PeppolDocumentTypeCode = typeof peppolDocumentTypeCodeSchema.Type;
11
-
12
- /**
13
- * @description Validates a document type code against the PEPPOL subset of UNCL 1001.
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid document type codes.
9
+ * @example
10
+ * ```ts
11
+ * '1';
12
+ * ```;
18
13
  *
19
14
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1001/
15
+ * @see {@link documentTypeCodesKeys}
20
16
  */
21
- export const peppolDocumentTypeCodeSchema = Schema.Literals(documentTypeCodesKeys).pipe(Schema.brand('PeppolDocumentTypeCode'));
17
+ export class PeppolDocumentTypeCode extends opaque<PeppolDocumentTypeCode>()(
18
+ Schema.Literals(documentTypeCodesKeys).pipe(Schema.brand('PeppolDocumentTypeCode'))
19
+ ) {}
@@ -2,30 +2,21 @@ import { Predicate, Schema } from 'effect';
2
2
 
3
3
  import type { DocumentTypesTableKeys } from '#/values/document-type.generated';
4
4
 
5
+ import { opaque } from '#/schemas/utils/opaque.ts';
5
6
  import { documentTypesTable, documentTypesTableKeys } from '#/values/document-type.generated';
6
7
 
7
8
  /**
8
- * @description One of the PEPPOL document type schemes (e.g. `busdox-docid-qns`, `peppol-doctype-wildcard`).
9
+ * @description A full PEPPOL document type identifier in `<scheme>::<value>` form. The scheme prefix and value must both be known.
9
10
  *
10
11
  * @see {@link documentTypesTable}
11
12
  */
12
- export type PeppolDocumentType = typeof peppolDocumentTypeSchema.Type;
13
-
14
- /**
15
- * @description Validates a full PEPPOL document type identifier (`<scheme>::<value>`) against the known document type table. The scheme prefix must be a known key
16
- * and the full identifier must exist in the document type table (checked via a filter).
17
- *
18
- * @param error - The custom error message to use when validation fails. Defaults to `'invalid peppol document type'`.
19
- *
20
- * @returns An Effect schema that matches a valid `scheme::value` document type identifier.
21
- *
22
- * @see {@link documentTypesTable}
23
- */
24
- export const peppolDocumentTypeSchema = Schema.TemplateLiteral([Schema.Literals(documentTypesTableKeys), Schema.Literal('::'), Schema.String]).check(
25
- Schema.makeFilter((val: string) => {
26
- const [prefix, ...suffix] = val.split('::');
27
- if (Predicate.isNullish(prefix) || !documentTypesTableKeys.includes(prefix as never)) return false;
28
- const info = documentTypesTable[prefix as DocumentTypesTableKeys];
29
- return Predicate.isNotNullish(info) && info.some(v => v === suffix.join('::'));
30
- })
31
- );
13
+ export class PeppolDocumentType extends opaque<PeppolDocumentType>()(
14
+ Schema.TemplateLiteral([Schema.Literals(documentTypesTableKeys), Schema.Literal('::'), Schema.String]).check(
15
+ Schema.makeFilter((val: string) => {
16
+ const [prefix, ...suffix] = val.split('::');
17
+ if (Predicate.isNullish(prefix) || !documentTypesTableKeys.includes(prefix as never)) return false;
18
+ const info = documentTypesTable[prefix as DocumentTypesTableKeys];
19
+ return Predicate.isNotNullish(info) && info.some(v => v === suffix.join('::'));
20
+ })
21
+ )
22
+ ) {}
@@ -2,29 +2,33 @@ import { Schema } from 'effect';
2
2
 
3
3
  import type { ProcessesKeys } from '#/values/processes.generated';
4
4
 
5
+ import { opaque } from '#/schemas/utils/opaque.ts';
5
6
  import { processes, processesKeys } from '#/values/processes.generated';
6
7
 
7
8
  /**
8
- * @description A PEPPOL business process identifier key as defined by the processes codelist.
9
+ * @description A full PEPPOL business process identifier in `<scheme>::<value>` form from the known processes table.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * 'cenbii-procid-ubl::urn:fdc:peppol.eu:2017:poacc:billing:01:1.0';
14
+ * ```;
9
15
  *
10
16
  * @see {@link processes}
11
17
  */
12
- export type PeppolProcesses = typeof peppolProcessSchema.Encoded;
18
+ export class PeppolProcess extends opaque<PeppolProcess>()(
19
+ Schema.TemplateLiteral([Schema.Literals(processesKeys), Schema.Literal('::'), Schema.String]).check(
20
+ Schema.makeFilter((val: string) => {
21
+ const [prefix, suffix] = val.split('::');
22
+ if (prefix === undefined || suffix === undefined) return false;
23
+ const info = processes[prefix as ProcessesKeys];
24
+ return info !== undefined && info.some(v => v === suffix);
25
+ })
26
+ )
27
+ ) {}
13
28
 
14
29
  /**
15
- * @description Validates a full PEPPOL business process identifier (`<scheme>::<value>`) against the known processes.
16
- *
17
- * @param error - The custom error message to use when validation fails. Defaults to `'invalid peppol process identifier'`.
18
- *
19
- * @returns An Effect schema that matches a valid `scheme::value` process identifier.
30
+ * @description A PEPPOL business process identifier key as defined by the processes codelist.
20
31
  *
21
32
  * @see {@link processes}
22
33
  */
23
- export const peppolProcessSchema = Schema.TemplateLiteral([Schema.Literals(processesKeys), Schema.Literal('::'), Schema.String]).check(
24
- Schema.makeFilter((val: string) => {
25
- const [prefix, suffix] = val.split('::');
26
- if (prefix === undefined || suffix === undefined) return false;
27
- const info = processes[prefix as ProcessesKeys];
28
- return info !== undefined && info.some(v => v === suffix);
29
- })
30
- );
34
+ export type PeppolProcesses = Schema.Codec.Encoded<typeof PeppolProcess>;
@@ -2,7 +2,7 @@ import { Schema } from 'effect';
2
2
 
3
3
  import type { PeppolDocumentType } from '#/schemas/values/peppol-document-type-schema.ts';
4
4
 
5
- import { peppolProcessSchema } from '#/schemas/values/peppol-process-schema.ts';
5
+ import { PeppolProcess } from '#/schemas/values/peppol-process-schema.ts';
6
6
  import { documentTypesProcessIds } from '#/values/document-type.generated';
7
7
 
8
8
  /**
@@ -13,13 +13,13 @@ import { documentTypesProcessIds } from '#/values/document-type.generated';
13
13
  *
14
14
  * @returns An Effect schema that matches only processes allowed for the given document type.
15
15
  *
16
- * @see {@link peppolProcessSchema}
16
+ * @see {@link PeppolProcess}
17
17
  * @see {@link documentTypesProcessIds}
18
18
  */
19
19
  export function processFromDocumentTypeSchema(documentType: PeppolDocumentType, error = 'invalid process type for document type') {
20
20
  const allowed = documentTypesProcessIds[documentType as keyof typeof documentTypesProcessIds];
21
21
  if (allowed === undefined) {
22
- return peppolProcessSchema;
22
+ return PeppolProcess;
23
23
  }
24
24
  const values = allowed.map(p => `${p.scheme}::${p.value}`);
25
25
  return Schema.String.check(Schema.makeFilter((val: string) => values.includes(val as never))).annotate({ message: error });
@@ -1,24 +1,22 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { quantityUnitCodesKeys } from '#/values/quantity-unit-codes.generated';
4
5
 
5
6
  /**
6
- * @description A unit of measure code as defined by the PEPPOL subset of UN/ECE Recommendation 20.
7
+ * @description A unit of measure code from the PEPPOL subset of UN/ECE Recommendation 20.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNECERec20/
9
- */
10
- export type PeppolQuantityUnitCode = typeof quantityUnitCodesSchema.Type;
11
-
12
- /**
13
- * @description Validates a unit of measure code against the PEPPOL subset of UN/ECE Recommendation 20.
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid quantity unit codes.
9
+ * @example
10
+ * ```ts
11
+ * '10';
12
+ * ```;
18
13
  *
19
14
  * @validations
20
15
  * - BR-CL-23: Unit of measure code MUST be a valid UN/ECE Rec 20 code.
21
16
  *
22
17
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNECERec20/
18
+ * @see {@link quantityUnitCodesKeys}
23
19
  */
24
- export const quantityUnitCodesSchema = Schema.Literals(quantityUnitCodesKeys).pipe(Schema.brand('PeppolQuantityUnitCode'));
20
+ export class PeppolQuantityUnitCode extends opaque<PeppolQuantityUnitCode>()(
21
+ Schema.Literals(quantityUnitCodesKeys).pipe(Schema.brand('PeppolQuantityUnitCode'))
22
+ ) {}
@@ -1,13 +1,20 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
- import type { VatDateCodesKeys } from '#/values/vat-dates.generated';
4
-
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
5
4
  import { vatDateCodesKeys } from '#/values/vat-dates.generated';
6
5
 
7
- export type PeppolVatDateCode = VatDateCodesKeys;
8
-
9
6
  /**
7
+ * @description A VAT date code from the PEPPOL subset of UNCL 2005 (invoice period description code).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * '3';
12
+ * ```;
13
+ *
10
14
  * @validations
11
15
  * - PEPPOL-EN16931-CL006: Invoice period description code must be according to UNCL 2005 D.16B.
16
+ *
17
+ * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL2005/
18
+ * @see {@link vatDateCodesKeys}
12
19
  */
13
- export const vatDateCodeSchema = Schema.Literals(vatDateCodesKeys);
20
+ export class PeppolVatDateCode extends opaque<PeppolVatDateCode>()(Schema.Literals(vatDateCodesKeys)) {}
@@ -1,24 +1,20 @@
1
1
  import { Schema } from 'effect';
2
2
 
3
+ import { opaque } from '#/schemas/utils/opaque.ts';
3
4
  import { vatexCodesKeys } from '#/values/vatex-codes.generated';
4
5
 
5
6
  /**
6
- * @description A VAT exemption reason code as defined by the CEF VATEX codelist.
7
+ * @description A VAT exemption reason code from the CEF VATEX codelist.
7
8
  *
8
- * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/vatex/
9
- */
10
- export type PeppolVatexCode = typeof vatexCodeSchema.Type;
11
-
12
- /**
13
- * @description Validates a VAT exemption reason code against the CEF VATEX codelist.
14
- *
15
- * @param error - The custom error message to use when validation fails.
16
- *
17
- * @returns An Effect schema that accepts only valid VAT exemption reason codes.
9
+ * @example
10
+ * ```ts
11
+ * 'VATEX-EU-79-C';
12
+ * ```;
18
13
  *
19
14
  * @validations
20
15
  * - BR-CL-22: VAT exemption reason code MUST be a valid CEF VATEX code.
21
16
  *
22
17
  * @see https://docs.peppol.eu/poacc/billing/3.0/codelist/vatex/
18
+ * @see {@link vatexCodesKeys}
23
19
  */
24
- export const vatexCodeSchema = Schema.Literals(vatexCodesKeys).pipe(Schema.brand('PeppolVatexCode'));
20
+ export class PeppolVatexCode extends opaque<PeppolVatexCode>()(Schema.Literals(vatexCodesKeys).pipe(Schema.brand('PeppolVatexCode'))) {}
@@ -2,6 +2,13 @@ import { Schema } from 'effect';
2
2
 
3
3
  /**
4
4
  * @description Failure of a single schematron rule against a document.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * new SchematronRuleError({ id: 'PEPPOL-EN16931-R001', level: 'fatal', message: 'The document must carry a number.' });
9
+ * ```;
10
+ *
11
+ * @see {@link SchematronValidationError}
5
12
  */
6
13
  export class SchematronRuleError extends Schema.TaggedError<SchematronRuleError>()('SchematronRuleError', {
7
14
  id: Schema.String,
@@ -11,6 +18,13 @@ export class SchematronRuleError extends Schema.TaggedError<SchematronRuleError>
11
18
 
12
19
  /**
13
20
  * @description Failure of a schematron validation run, wrapping every rule that failed.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * new SchematronValidationError({ errors: [ruleError] });
25
+ * ```;
26
+ *
27
+ * @see {@link SchematronRuleError}
14
28
  */
15
29
  export class SchematronValidationError extends Schema.TaggedError<SchematronValidationError>()('SchematronValidationError', {
16
30
  errors: Schema.Array(SchematronRuleError),