@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.
- package/README.md +5 -5
- package/dist/constants.d.ts +131 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +114 -1
- package/dist/constants.js.map +1 -1
- package/dist/{index-BBzPjq7o.d.ts → index-XG-N6PcG.d.ts} +1702 -724
- package/dist/index-XG-N6PcG.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1247 -200
- package/dist/index.js.map +1 -1
- package/dist/invoice-response-code-not-needs-schema-DNrfKYLh.js +36 -0
- package/dist/invoice-response-code-not-needs-schema-DNrfKYLh.js.map +1 -0
- package/dist/invoice-response-codes.d.ts +28 -0
- package/dist/invoice-response-codes.d.ts.map +1 -1
- package/dist/invoice-response-codes.js +11 -1
- package/dist/invoice-response-codes.js.map +1 -1
- package/dist/{is-valid-abn-160i38PG.js → is-valid-abn-D7eSygBG.js} +115 -2
- package/dist/is-valid-abn-D7eSygBG.js.map +1 -0
- package/dist/{is-valid-mod97-0208-CzMOXMO-.js → is-valid-mod97-0208-CjR324eG.js} +11 -1
- package/dist/is-valid-mod97-0208-CjR324eG.js.map +1 -0
- package/dist/message-level-response-profile-id-B9c0A7S_.js +27 -0
- package/dist/message-level-response-profile-id-B9c0A7S_.js.map +1 -0
- package/dist/{nodable-parser-CyDZtLCK.js → nodable-parser-CupS2H55.js} +31 -1
- package/dist/nodable-parser-CupS2H55.js.map +1 -0
- package/dist/schematron.d.ts +57 -1
- package/dist/schematron.d.ts.map +1 -1
- package/dist/schematron.js +458 -7
- package/dist/schematron.js.map +1 -1
- package/dist/validations.d.ts +132 -0
- package/dist/validations.d.ts.map +1 -1
- package/dist/validations.js +11 -2
- package/dist/validations.js.map +1 -1
- package/dist/values.d.ts +67 -2
- package/dist/values.d.ts.map +1 -1
- package/dist/xml.d.ts +30 -0
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +10 -1
- package/dist/xml.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/credit-note-doctype-id.ts +9 -0
- package/src/constants/credit-note-process-id.ts +9 -0
- package/src/constants/document-scheme.ts +9 -0
- package/src/constants/invoice-doctype-id.ts +9 -0
- package/src/constants/invoice-process-id.ts +10 -0
- package/src/constants/invoice-response-doctype-id.ts +10 -0
- package/src/constants/invoice-response-process-id.ts +9 -0
- package/src/constants/invoice-response-profile-id.ts +9 -0
- package/src/constants/message-level-response-doctype-id.ts +10 -0
- package/src/constants/message-level-response-process-id.ts +9 -0
- package/src/constants/message-level-response-profile-id.ts +9 -0
- package/src/constants/participant-scheme.ts +10 -0
- package/src/constants/process-scheme.ts +9 -0
- package/src/constants/transport-profile.ts +10 -0
- package/src/decoders/fields/decode-invoice-message-document-party.ts +2 -2
- package/src/decoders/fields/decode-parties-tax-scheme.ts +2 -2
- package/src/decoders/fields/decode-party-legal-entity.ts +2 -2
- package/src/decoders/fields/decode-party-tax-scheme.ts +2 -2
- package/src/decoders/fields/decode-tax-category.ts +1 -1
- package/src/decoders/fields/decode-tax-representative-party.ts +2 -2
- package/src/decoders/fields/encode-message-party.ts +2 -2
- package/src/decoders/fields/encode-parties-tax-scheme.ts +3 -3
- package/src/decoders/fields/encode-party-legal-entity.ts +1 -1
- package/src/decoders/fields/encode-party-tax-scheme.ts +2 -2
- package/src/decoders/fields/encode-tax-representative-party.ts +2 -2
- package/src/invoice-response-codes/invoice-response-code-needs-schema.ts +9 -0
- package/src/invoice-response-codes/invoice-response-code-not-needs-schema.ts +9 -0
- package/src/invoice-response-codes/invoice-response-codes-order.ts +10 -0
- package/src/peppol-validations/add-piva.ts +12 -0
- package/src/peppol-validations/check-cf.ts +11 -0
- package/src/peppol-validations/check-cf16.ts +12 -0
- package/src/peppol-validations/check-piva-se-it.ts +11 -0
- package/src/peppol-validations/check-piva.ts +11 -0
- package/src/peppol-validations/check-se-orgnr.ts +9 -0
- package/src/peppol-validations/greek-tin-verification.ts +9 -0
- package/src/peppol-validations/is-valid-abn.ts +9 -0
- package/src/peppol-validations/is-valid-gln.ts +10 -0
- package/src/peppol-validations/is-valid-iban.ts +10 -0
- package/src/peppol-validations/is-valid-mod11.ts +9 -0
- package/src/peppol-validations/is-valid-mod97-0208.ts +10 -0
- package/src/peppol-validations/luhn-check.ts +9 -0
- package/src/schemas/fields/default-customization-id.ts +9 -0
- package/src/schemas/fields/default-profile-id.ts +9 -0
- package/src/schemas/fields/peppol-additional-document-reference-schema.ts +61 -20
- package/src/schemas/fields/peppol-address-schema.ts +25 -2
- package/src/schemas/fields/peppol-allowance-charge-schema.ts +63 -9
- package/src/schemas/fields/peppol-amount-schema.ts +15 -2
- package/src/schemas/fields/peppol-base-line-schema.ts +12 -2
- package/src/schemas/fields/peppol-billing-reference-schema.ts +13 -0
- package/src/schemas/fields/peppol-binary-object-schema.ts +12 -4
- package/src/schemas/fields/peppol-contact-schema.ts +11 -0
- package/src/schemas/fields/peppol-credit-note-line-schema.ts +7 -2
- package/src/schemas/fields/peppol-delivery-schema.ts +44 -2
- package/src/schemas/fields/peppol-identifier-schema.ts +8 -0
- package/src/schemas/fields/peppol-invoice-line-period-schema.ts +11 -0
- package/src/schemas/fields/peppol-invoice-line-schema.ts +9 -2
- package/src/schemas/fields/peppol-invoice-period-schema.ts +2 -2
- package/src/schemas/fields/peppol-item-classification-schema.ts +2 -2
- package/src/schemas/fields/peppol-line-allowance-charge-schema.ts +56 -8
- package/src/schemas/fields/peppol-line-item-schema.ts +66 -6
- package/src/schemas/fields/peppol-line-price-allowance-charge-schema.ts +20 -0
- package/src/schemas/fields/peppol-line-price-schema.ts +2 -0
- package/src/schemas/fields/peppol-order-reference-schema.ts +2 -0
- package/src/schemas/fields/peppol-party-base-schema.ts +36 -4
- package/src/schemas/fields/peppol-party-legal-entity-schema.ts +10 -2
- package/src/schemas/fields/peppol-party-tax-scheme-schema.ts +4 -4
- package/src/schemas/fields/peppol-payee-party-schema.ts +8 -8
- package/src/schemas/fields/peppol-payment-means-schema.ts +62 -2
- package/src/schemas/fields/peppol-payment-terms-schema.ts +2 -0
- package/src/schemas/fields/peppol-quantity-schema.ts +4 -2
- package/src/schemas/fields/peppol-reference-schema.ts +20 -1
- package/src/schemas/fields/peppol-tax-category-schema.ts +12 -2
- package/src/schemas/fields/peppol-tax-representative-schema.ts +2 -2
- package/src/schemas/fields/peppol-tax-subtotal-category-schema.ts +3 -0
- package/src/schemas/fields/peppol-tax-subtotal-schema.ts +2 -0
- package/src/schemas/fields/peppol-tax-totals-base-schema.ts +3 -3
- package/src/schemas/peppol-billing-base-schema.ts +49 -9
- package/src/schemas/peppol-credit-note-schema.ts +2 -2
- package/src/schemas/peppol-document-response-document-reference-schema.ts +12 -4
- package/src/schemas/peppol-document-response-document-schema.ts +5 -5
- package/src/schemas/peppol-document-response-line-response-content-schema.ts +22 -2
- package/src/schemas/peppol-document-response-line-response-schema.ts +23 -2
- package/src/schemas/peppol-document-schema.ts +69 -6
- package/src/schemas/peppol-invoice-response-document-actual-response-schema.ts +53 -4
- package/src/schemas/peppol-invoice-response-document-actual-response-status-schema.ts +22 -4
- package/src/schemas/peppol-invoice-response-schema.ts +54 -6
- package/src/schemas/peppol-invoice-response-status-reason-code-schema.ts +36 -8
- package/src/schemas/peppol-invoice-schema.ts +30 -2
- package/src/schemas/peppol-message-level-response-document-response-schema.ts +10 -0
- package/src/schemas/peppol-message-level-response-party-schema.ts +10 -0
- package/src/schemas/peppol-message-level-response-schema.ts +18 -0
- package/src/schemas/utils/format-quantity-with-unit.ts +19 -0
- package/src/schemas/utils/get-credit-note-type-code-description.ts +12 -0
- package/src/schemas/utils/get-invoice-type-code-description.ts +12 -0
- package/src/schemas/utils/is-valid-credit-note-type-code.ts +13 -0
- package/src/schemas/utils/is-valid-invoice-type-code.ts +13 -0
- package/src/schemas/utils/is-valid-process.ts +13 -0
- package/src/schemas/utils/peppol-base-64-schema.ts +7 -4
- package/src/schemas/utils/peppol-vat-regex-schema.ts +38 -30
- package/src/schemas/utils/peppol-xsd-time-schema.ts +12 -2
- package/src/schemas/utils/quantity-unit-code-to-intl-unit.ts +34 -0
- package/src/schemas/values/additional-document-reference-code-schema.ts +9 -15
- package/src/schemas/values/allowance-charge-reason-code-schema.ts +12 -14
- package/src/schemas/values/application-response-type-code-schema.ts +10 -14
- package/src/schemas/values/charge-reason-code-schema.ts +12 -14
- package/src/schemas/values/credit-note-type-code-schema.ts +8 -14
- package/src/schemas/values/currency-code-schema.ts +13 -16
- package/src/schemas/values/document-type-schemes-schema.ts +9 -5
- package/src/schemas/values/document-type-values-schema.ts +5 -6
- package/src/schemas/values/duty-tax-fee-category-schema.ts +15 -13
- package/src/schemas/values/electronic-codes-schema.ts +10 -12
- package/src/schemas/values/icd-codes-schema.ts +8 -12
- package/src/schemas/values/invoice-status-code-schema.ts +10 -12
- package/src/schemas/values/invoice-type-code-schema.ts +10 -12
- package/src/schemas/values/item-classification-codes-schema.ts +10 -12
- package/src/schemas/values/mime-codes-schema.ts +12 -14
- package/src/schemas/values/op-status-action-schema.ts +10 -12
- package/src/schemas/values/op-status-reason-schema.ts +10 -12
- package/src/schemas/values/participant-identifier-code-schema.ts +10 -13
- package/src/schemas/values/payment-means-code-schema.ts +10 -12
- package/src/schemas/values/peppol-country-code-schema.ts +7 -9
- package/src/schemas/values/peppol-document-type-code-schema.ts +10 -12
- package/src/schemas/values/peppol-document-type-schema.ts +12 -21
- package/src/schemas/values/peppol-process-schema.ts +19 -15
- package/src/schemas/values/process-from-document-type-schema.ts +3 -3
- package/src/schemas/values/quantity-unit-codes-schema.ts +10 -12
- package/src/schemas/values/vat-date-code-schema.ts +12 -5
- package/src/schemas/values/vatex-code-schema.ts +8 -12
- package/src/schematron/errors.ts +14 -0
- package/src/schematron/helpers.ts +457 -11
- package/src/schematron/run-all-rules.ts +10 -0
- package/src/schematron/schematron.ts +25 -0
- package/src/xml/builder-options.ts +9 -0
- package/src/xml/common-xml-options.ts +9 -0
- package/src/xml/nodable-parser.ts +12 -0
- package/src/xml/parser-options.ts +9 -0
- package/dist/index-BBzPjq7o.d.ts.map +0 -1
- package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js +0 -18
- package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js.map +0 -1
- package/dist/is-valid-abn-160i38PG.js.map +0 -1
- package/dist/is-valid-mod97-0208-CzMOXMO-.js.map +0 -1
- package/dist/message-level-response-profile-id-DBpOW91B.js +0 -9
- package/dist/message-level-response-profile-id-DBpOW91B.js.map +0 -1
- package/dist/nodable-parser-CyDZtLCK.js.map +0 -1
- package/dist/vat-dates.generated-CxFvt7m3.d.ts +0 -68
- package/dist/vat-dates.generated-CxFvt7m3.d.ts.map +0 -1
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
5
4
|
import { creditNoteTypeCodesKeys } from '#/values/credit-notes-type-codes.generated';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
* @description A credit note type code
|
|
9
|
-
*
|
|
10
|
-
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1001-cn/
|
|
11
|
-
*/
|
|
12
|
-
export type PeppolCreditNoteTypeCode = CreditNoteTypeCodesKeys;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @description Validates a credit note type code against the PEPPOL subset of UNCL 1001 (credit note).
|
|
16
|
-
*
|
|
17
|
-
* @param error - The custom error message to use when validation fails.
|
|
7
|
+
* @description A credit note type code from the PEPPOL subset of UNCL 1001 (credit note).
|
|
18
8
|
*
|
|
19
|
-
* @
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* '81';
|
|
12
|
+
* ```;
|
|
20
13
|
*
|
|
21
14
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1001-cn/
|
|
15
|
+
* @see {@link creditNoteTypeCodesKeys}
|
|
22
16
|
*/
|
|
23
|
-
export
|
|
17
|
+
export class PeppolCreditNoteTypeCode extends opaque<PeppolCreditNoteTypeCode>()(Schema.Literals(creditNoteTypeCodesKeys)) {}
|
|
@@ -7,31 +7,28 @@
|
|
|
7
7
|
|
|
8
8
|
import { Schema } from 'effect';
|
|
9
9
|
|
|
10
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
10
11
|
import { currencyCodesKeys } from '#/values/currency-code.generated';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @description An ISO 4217 currency code
|
|
14
|
+
* @description An ISO 4217 currency code from the PEPPOL codelist.
|
|
14
15
|
*
|
|
15
|
-
* @
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* 'AED';
|
|
19
|
+
* ```;
|
|
20
|
+
*
|
|
21
|
+
* @validations
|
|
22
|
+
* - PEPPOL-EN16931-CL007: Currency codes MUST be valid ISO 4217 codes.
|
|
20
23
|
*
|
|
21
24
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/ISO4217/
|
|
25
|
+
* @see {@link currencyCodesKeys}
|
|
22
26
|
*/
|
|
23
|
-
export
|
|
27
|
+
export class PeppolCurrencyCode extends opaque<PeppolCurrencyCode>()(Schema.Literals(currencyCodesKeys).pipe(Schema.brand('PeppolCurrencyCode'))) {}
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
|
-
* @description
|
|
27
|
-
*
|
|
28
|
-
* @param error - The custom error message to use when validation fails.
|
|
29
|
-
*
|
|
30
|
-
* @returns An Effect schema that accepts only valid currency codes.
|
|
31
|
-
*
|
|
32
|
-
* @validations
|
|
33
|
-
* - PEPPOL-EN16931-CL007: Currency codes MUST be valid ISO 4217 codes.
|
|
30
|
+
* @description An ISO 4217 currency code as defined by the PEPPOL subset.
|
|
34
31
|
*
|
|
35
32
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/ISO4217/
|
|
36
33
|
*/
|
|
37
|
-
export
|
|
34
|
+
export type PeppolCurrencyCodeEncoded = Schema.Codec.Encoded<typeof PeppolCurrencyCode>;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { documentTypesScheme } from '#/values/document-type.generated';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @description
|
|
7
|
+
* @description A PEPPOL document type scheme, for example `busdox-docid-qns` or `peppol-doctype-wildcard`.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* 'busdox-docid-qns';
|
|
12
|
+
* ```;
|
|
11
13
|
*
|
|
12
14
|
* @see {@link documentTypesScheme}
|
|
13
15
|
*/
|
|
14
|
-
export
|
|
16
|
+
export class PeppolDocumentTypeScheme extends opaque<PeppolDocumentTypeScheme>()(
|
|
17
|
+
Schema.Literals(documentTypesScheme as [string, ...Array<string>])
|
|
18
|
+
) {}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Record, Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { documentTypesTable } from '#/values/document-type.generated';
|
|
4
5
|
|
|
5
6
|
const values = Record.values(documentTypesTable).flat();
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
* @description
|
|
9
|
-
*
|
|
10
|
-
* @param error - The error message to use when validation fails. Defaults to `'invalid Peppol document type value'`.
|
|
11
|
-
*
|
|
12
|
-
* @returns An Effect schema that accepts only valid document type values.
|
|
9
|
+
* @description The value part of a PEPPOL document type identifier (the portion after the scheme prefix) from the known document type table.
|
|
13
10
|
*
|
|
14
11
|
* @see {@link documentTypesTable}
|
|
15
12
|
*/
|
|
16
|
-
export
|
|
13
|
+
export class PeppolDocumentTypeValue extends opaque<PeppolDocumentTypeValue>()(
|
|
14
|
+
Schema.String.check(Schema.makeFilter((val: string) => values.includes(val as never)))
|
|
15
|
+
) {}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { dutyTaxFeeCategoriesKeys } from '#/values/duty-tax-fee-categories.generated';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @description A duty, tax or fee category code
|
|
7
|
+
* @description A duty, tax or fee category code from the PEPPOL subset of UNCL 5305 (VAT category code).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @description Validates a duty, tax or fee category code against the PEPPOL subset of UNCL 5305 (VAT category code).
|
|
15
|
-
*
|
|
16
|
-
* @param error - The custom error message to use when validation fails.
|
|
17
|
-
*
|
|
18
|
-
* @returns An Effect schema that accepts only valid duty/tax/fee category codes.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* 'AE';
|
|
12
|
+
* ```;
|
|
19
13
|
*
|
|
20
14
|
* @validations
|
|
21
15
|
* - BR-CL-17 / BR-CL-18: VAT category code MUST be a valid UNCL 5305 code.
|
|
22
16
|
*
|
|
23
17
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5305/
|
|
18
|
+
* @see {@link dutyTaxFeeCategoriesKeys}
|
|
19
|
+
*/
|
|
20
|
+
export class PeppolDutyTaxFeeCategoryCode extends opaque<PeppolDutyTaxFeeCategoryCode>()(
|
|
21
|
+
Schema.Literals(dutyTaxFeeCategoriesKeys).pipe(Schema.brand('PeppolDutyTaxFeeCategoryCode'))
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @description The encoded form of {@link PeppolDutyTaxFeeCategoryCode}, a string literal union.
|
|
24
26
|
*/
|
|
25
|
-
export
|
|
27
|
+
export type PeppolDutyTaxFeeCategoryCodeEncoded = Schema.Codec.Encoded<typeof PeppolDutyTaxFeeCategoryCode>;
|
|
@@ -7,25 +7,23 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Schema } from 'effect';
|
|
9
9
|
|
|
10
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
10
11
|
import { electronicAddressCodesKeys } from '#/values/eas-codes.generated';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* @description An electronic address scheme (EAS) code
|
|
14
|
+
* @description An electronic address scheme (EAS) code from the PEPPOL Electronic Address Identifier Scheme codelist.
|
|
14
15
|
*
|
|
15
|
-
* @
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @description Validates an electronic address scheme (EAS) code against the PEPPOL Electronic Address Identifier Scheme codelist.
|
|
21
|
-
*
|
|
22
|
-
* @param error - The custom error message to use when validation fails.
|
|
23
|
-
*
|
|
24
|
-
* @returns An Effect schema that accepts only valid electronic address scheme codes.
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* '0002';
|
|
19
|
+
* ```;
|
|
25
20
|
*
|
|
26
21
|
* @validations
|
|
27
22
|
* - PEPPOL-EN16931-CL008: Electronic address identifier scheme MUST be from the codelist "Electronic Address Identifier Scheme".
|
|
28
23
|
*
|
|
29
24
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/eas/
|
|
25
|
+
* @see {@link electronicAddressCodesKeys}
|
|
30
26
|
*/
|
|
31
|
-
export
|
|
27
|
+
export class PeppolElectronicAddressCode extends opaque<PeppolElectronicAddressCode>()(
|
|
28
|
+
Schema.Literals(electronicAddressCodesKeys).pipe(Schema.brand('PeppolElectronicAddressCode'))
|
|
29
|
+
) {}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { icdCodesKeys } from '#/values/icd-codes.generated';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @description An ISO 6523 ICD
|
|
7
|
+
* @description An ISO 6523 ICD code from the PEPPOL codelist.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description Validates an ISO 6523 ICD code against the PEPPOL codelist.
|
|
14
|
-
*
|
|
15
|
-
* @param error - The custom error message to use when validation fails. Defaults to `'Invalid ICD code provided'`.
|
|
16
|
-
*
|
|
17
|
-
* @returns An Effect schema that accepts only valid ICD codes.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* '0002';
|
|
12
|
+
* ```;
|
|
18
13
|
*
|
|
19
14
|
* @validations
|
|
20
15
|
* - BR-CL-10 / BR-CL-11 / BR-CL-21: Identifier scheme MUST be a valid ISO 6523 ICD code.
|
|
21
16
|
*
|
|
22
17
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/ICD/
|
|
18
|
+
* @see {@link icdCodesKeys}
|
|
23
19
|
*/
|
|
24
|
-
export
|
|
20
|
+
export class PeppolIcdCode extends opaque<PeppolIcdCode>()(Schema.Literals(icdCodesKeys).pipe(Schema.brand('PeppolIcdCode'))) {}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { invoiceStatusCodesKeys } from '#/values/invoice-status-codes.generated';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @description An invoice status code
|
|
7
|
+
* @description An invoice status code from the PEPPOL subset of UNCL 4343 (T111).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description Validates an invoice status code against the PEPPOL subset of UNCL 4343 (T111).
|
|
14
|
-
*
|
|
15
|
-
* @param error - The custom error message to use when validation fails.
|
|
16
|
-
*
|
|
17
|
-
* @returns An Effect schema that accepts only valid invoice status codes.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* 'AB';
|
|
12
|
+
* ```;
|
|
18
13
|
*
|
|
19
14
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL4343-T111/
|
|
15
|
+
* @see {@link invoiceStatusCodesKeys}
|
|
20
16
|
*/
|
|
21
|
-
export
|
|
17
|
+
export class PeppolInvoiceStatusCodes extends opaque<PeppolInvoiceStatusCodes>()(
|
|
18
|
+
Schema.Literals(invoiceStatusCodesKeys).pipe(Schema.brand('PeppolInvoiceStatusCodes'))
|
|
19
|
+
) {}
|
|
@@ -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
|
|
7
|
+
* @description An invoice type code from the PEPPOL subset of UNCL 1001.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
7
|
+
* @description An item classification code from the PEPPOL subset of UNCL 7143.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
7
|
+
* @description A MIME media type from the PEPPOL MIME code list.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
7
|
+
* @description An OpenPeppol operation status action code from the OPStatusAction codelist.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
7
|
+
* @description An OpenPeppol operation status reason code from the OPStatusReason codelist.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
7
|
+
* @description A PEPPOL participant identifier scheme from the participant identifier schemes codelist.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
* @
|
|
14
|
+
* @see {@link participantIdentifierSchemesKeys}
|
|
18
15
|
*/
|
|
19
|
-
export
|
|
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
|
|
15
|
+
* @description A payment means code from the PEPPOL subset of UNCL 4461.
|
|
15
16
|
*
|
|
16
|
-
* @
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
28
|
+
export class PeppolPaymentMeansCodeValue extends opaque<PeppolPaymentMeansCodeValue>()(
|
|
29
|
+
Schema.Literals(paymentMeansCodesKeys).pipe(Schema.brand('PeppolPaymentMeansCodeValue'))
|
|
30
|
+
) {}
|
|
@@ -12,19 +12,17 @@ import { Schema } from 'effect';
|
|
|
12
12
|
import { countryCodesKeys } from '#/values/country-code.generated';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @description
|
|
15
|
+
* @description A two character ISO 3166-1 alpha-2 country code from the PEPPOL codelist. The literal union enforces the length.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
18
|
-
|
|
19
|
-
|
|
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.
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* 'AD';
|
|
20
|
+
* ```;
|
|
24
21
|
*
|
|
25
22
|
* @validations
|
|
26
23
|
* - BR-CL-14 / BR-CL-15: Country code MUST be a valid ISO 3166-1 alpha-2 code.
|
|
27
24
|
*
|
|
28
25
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/ISO3166/
|
|
26
|
+
* @see {@link countryCodesKeys}
|
|
29
27
|
*/
|
|
30
|
-
export
|
|
28
|
+
export class PeppolCountryCodeValue extends Schema.Literals(countryCodesKeys).pipe(Schema.brand('PeppolCountryCodeValue')) {}
|
|
@@ -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
|
|
7
|
+
* @description A document type code from the PEPPOL subset of UNCL 1001.
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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
|
|
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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
) {}
|