@endevops/peppol-schema 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-CILtZytZ.d.ts} +1710 -669
- package/dist/index-CILtZytZ.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1234 -187
- 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 +453 -2
- 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 +3 -2
- 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/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 +41 -2
- package/src/schemas/fields/peppol-address-schema.ts +25 -2
- package/src/schemas/fields/peppol-allowance-charge-schema.ts +65 -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 +57 -9
- package/src/schemas/fields/peppol-line-item-schema.ts +69 -4
- 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 +13 -0
- package/src/schemas/fields/peppol-party-tax-scheme-schema.ts +5 -0
- package/src/schemas/fields/peppol-payee-party-schema.ts +2 -2
- 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 +5 -0
- 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 +5 -0
- package/src/schemas/peppol-billing-base-schema.ts +47 -7
- package/src/schemas/peppol-credit-note-schema.ts +2 -2
- package/src/schemas/peppol-document-response-document-reference-schema.ts +15 -2
- package/src/schemas/peppol-document-response-document-schema.ts +8 -3
- package/src/schemas/peppol-document-response-line-response-content-schema.ts +22 -2
- package/src/schemas/peppol-document-response-line-response-schema.ts +26 -0
- package/src/schemas/peppol-document-schema.ts +74 -9
- package/src/schemas/peppol-invoice-response-document-actual-response-schema.ts +58 -5
- package/src/schemas/peppol-invoice-response-document-actual-response-status-schema.ts +25 -2
- package/src/schemas/peppol-invoice-response-schema.ts +57 -4
- package/src/schemas/peppol-invoice-response-status-reason-code-schema.ts +37 -10
- 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 +14 -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 +10 -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 +451 -0
- 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,5 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
4
|
+
|
|
3
5
|
// RFC 4648 §4 — Base 64 Encoding
|
|
4
6
|
//
|
|
5
7
|
// Alphabet: A-Z a-z 0-9 + / (pad: =)
|
|
@@ -25,9 +27,17 @@ const BASE64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=
|
|
|
25
27
|
/**
|
|
26
28
|
* @description RFC 4648 base64 string (PEM / MIME / XML line endings tolerated). Effect port of `base64Schema` (`z.string().check(z.refine(...))`): strips CRLF /
|
|
27
29
|
* LF line endings before testing the quantum regex.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const value = 'SGVsbG8=';
|
|
34
|
+
* ```;
|
|
28
35
|
*/
|
|
29
|
-
export
|
|
30
|
-
message: 'Invalid base64'
|
|
31
|
-
}
|
|
36
|
+
export class PeppolBase64 extends opaque<PeppolBase64>()(
|
|
37
|
+
Schema.String.check(Schema.makeFilter((val: string) => BASE64_RE.test(val.replace(/\r?\n/g, '')))).annotate({ message: 'Invalid base64' })
|
|
38
|
+
) {}
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @description Alias of {@link PeppolBase64} for callers that prefer the shorter name.
|
|
42
|
+
*/
|
|
43
|
+
export type Base64 = PeppolBase64;
|
|
@@ -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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
* @
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* parseZoneOffsetFromString('+01:00'); // a +01:00 zone offset
|
|
23
|
+
* ```;
|
|
21
24
|
*
|
|
22
|
-
* @
|
|
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
|
|
7
|
+
* @description An additional document reference code from the PEPPOL subset of UNCL 1153 (invoiced object identifier scheme).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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
|
|
7
|
+
* @description An allowance or charge reason code from the PEPPOL subset of UNCL 5189 (D.16B).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
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
|
|
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
|
-
* @
|
|
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
|
|
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
|
|
7
|
+
* @description A charge reason code from the PEPPOL subset of UNCL 7161 (D.16B).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
) {}
|
|
@@ -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
|
+
) {}
|