@endevops/peppol-schema 0.1.4 → 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/dist/{index-CILtZytZ.d.ts → index-XG-N6PcG.d.ts} +35 -98
- package/dist/index-XG-N6PcG.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -22
- package/dist/index.js.map +1 -1
- package/dist/schematron.d.ts +1 -1
- package/dist/schematron.d.ts.map +1 -1
- package/dist/schematron.js +5 -5
- package/dist/schematron.js.map +1 -1
- package/package.json +1 -1
- 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/schemas/fields/peppol-additional-document-reference-schema.ts +21 -19
- package/src/schemas/fields/peppol-allowance-charge-schema.ts +1 -3
- package/src/schemas/fields/peppol-line-allowance-charge-schema.ts +3 -3
- package/src/schemas/fields/peppol-line-item-schema.ts +0 -5
- package/src/schemas/fields/peppol-party-legal-entity-schema.ts +0 -5
- package/src/schemas/fields/peppol-party-tax-scheme-schema.ts +2 -7
- package/src/schemas/fields/peppol-payee-party-schema.ts +6 -6
- package/src/schemas/fields/peppol-tax-representative-schema.ts +0 -5
- package/src/schemas/fields/peppol-tax-totals-base-schema.ts +1 -6
- package/src/schemas/peppol-billing-base-schema.ts +2 -2
- package/src/schemas/peppol-document-response-document-reference-schema.ts +0 -5
- package/src/schemas/peppol-document-response-document-schema.ts +0 -5
- package/src/schemas/peppol-document-response-line-response-schema.ts +0 -5
- package/src/schemas/peppol-document-schema.ts +7 -9
- package/src/schemas/peppol-invoice-response-document-actual-response-schema.ts +4 -8
- package/src/schemas/peppol-invoice-response-document-actual-response-status-schema.ts +0 -5
- package/src/schemas/peppol-invoice-response-schema.ts +0 -5
- package/src/schemas/peppol-invoice-response-status-reason-code-schema.ts +4 -3
- package/src/schemas/utils/peppol-base-64-schema.ts +3 -10
- package/src/schemas/values/peppol-country-code-schema.ts +1 -4
- package/src/schematron/helpers.ts +9 -14
- package/dist/index-CILtZytZ.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/package.json",
|
|
3
3
|
"name": "@endevops/peppol-schema",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"description": "TypeScript Effect Schema models for PEPPOL BIS Billing 3.0 — decode, validate and encode Invoice, Credit Note, Invoice Response and Message Level Response XML, with generated code lists, Schematron rules and identifier validations",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"bis-billing",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolInvoiceResponseDocumentResponseParty } from '#/schemas/peppol-invoice-response-schema.ts';
|
|
5
5
|
import type { RecursivePartial } from '#/types.ts';
|
|
6
6
|
|
|
7
7
|
import { decodeIdentifier } from '#/decoders/fields/decode-identifier.ts';
|
|
@@ -11,7 +11,7 @@ import { strOrUnd } from '#/helpers/str-or-und.ts';
|
|
|
11
11
|
export const decodeInvoiceMessageDocumentParty = Effect.fn(function* (
|
|
12
12
|
party: XmlNode,
|
|
13
13
|
...path: Array<string>
|
|
14
|
-
): Effect.fn.Return<RecursivePartial<
|
|
14
|
+
): Effect.fn.Return<RecursivePartial<PeppolInvoiceResponseDocumentResponseParty> | undefined> {
|
|
15
15
|
const val = yield* getProp(party, ...path);
|
|
16
16
|
if (Predicate.isNullish(val)) return undefined;
|
|
17
17
|
const partyName = yield* getProp(val, 'cac:PartyName');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolPartyTaxScheme } from '#/schemas/fields/peppol-party-tax-scheme-schema.ts';
|
|
5
5
|
import type { RecursivePartial } from '#/types.ts';
|
|
6
6
|
|
|
7
7
|
import { decodePartyTaxScheme } from '#/decoders/fields/decode-party-tax-scheme.ts';
|
|
@@ -10,7 +10,7 @@ import { getArray } from '#/helpers/get-array.ts';
|
|
|
10
10
|
export const decodePartiesTaxScheme = Effect.fn(function* (
|
|
11
11
|
doc: XmlNode,
|
|
12
12
|
...path: Array<string>
|
|
13
|
-
): Effect.fn.Return<RecursivePartial<Array<
|
|
13
|
+
): Effect.fn.Return<RecursivePartial<Array<PeppolPartyTaxScheme>> | undefined> {
|
|
14
14
|
const node = yield* getArray(doc, ...path);
|
|
15
15
|
if (node.length === 0) return undefined;
|
|
16
16
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolPartyLegalEntity } from '#/schemas/fields/peppol-party-legal-entity-schema.ts';
|
|
5
5
|
import type { RecursivePartial } from '#/types.ts';
|
|
6
6
|
|
|
7
7
|
import { decodeIdentifier } from '#/decoders/fields/decode-identifier.ts';
|
|
@@ -11,7 +11,7 @@ import { strOrUnd } from '#/helpers/str-or-und.ts';
|
|
|
11
11
|
export const decodePartyLegalEntity = Effect.fn(function* (
|
|
12
12
|
node: XmlNode,
|
|
13
13
|
...path: Array<string>
|
|
14
|
-
): Effect.fn.Return<RecursivePartial<
|
|
14
|
+
): Effect.fn.Return<RecursivePartial<PeppolPartyLegalEntity> | undefined> {
|
|
15
15
|
const partyLegalEntityNode = yield* getProp(node, ...path);
|
|
16
16
|
if (Predicate.isNullish(partyLegalEntityNode)) return undefined;
|
|
17
17
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolPartyTaxScheme } from '#/schemas/fields/peppol-party-tax-scheme-schema.ts';
|
|
5
5
|
import type { RecursivePartial } from '#/types.ts';
|
|
6
6
|
|
|
7
7
|
import { decodeSimpleIdentifer } from '#/decoders/fields/decode-simple-identifier.ts';
|
|
@@ -11,7 +11,7 @@ import { strOrUnd } from '#/helpers/str-or-und.ts';
|
|
|
11
11
|
export const decodePartyTaxScheme = Effect.fn(function* (
|
|
12
12
|
doc: XmlNode,
|
|
13
13
|
...path: Array<string>
|
|
14
|
-
): Effect.fn.Return<RecursivePartial<
|
|
14
|
+
): Effect.fn.Return<RecursivePartial<PeppolPartyTaxScheme> | undefined> {
|
|
15
15
|
const node = yield* getProp(doc, ...path);
|
|
16
16
|
if (Predicate.isNullish(node)) return undefined;
|
|
17
17
|
|
|
@@ -12,7 +12,7 @@ import { strOrUnd } from '#/helpers/str-or-und.ts';
|
|
|
12
12
|
export const decodeTaxCategory = Effect.fn(function* (
|
|
13
13
|
doc: XmlNode,
|
|
14
14
|
...path: Array<string>
|
|
15
|
-
): Effect.fn.Return<RecursivePartial<PeppolAllowanceCharge['taxCategory']> | undefined> {
|
|
15
|
+
): Effect.fn.Return<RecursivePartial<(typeof PeppolAllowanceCharge.Type)['taxCategory']> | undefined> {
|
|
16
16
|
const taxCategory = yield* getProp(doc, ...path);
|
|
17
17
|
if (Predicate.isNullish(taxCategory)) {
|
|
18
18
|
return undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolTaxRepresentative } from '#/schemas/fields/peppol-tax-representative-schema.ts';
|
|
5
5
|
import type { RecursivePartial } from '#/types.ts';
|
|
6
6
|
|
|
7
7
|
import { decodeAddress } from '#/decoders/fields/decode-address.ts';
|
|
@@ -12,7 +12,7 @@ import { strOrUnd } from '#/helpers/str-or-und.ts';
|
|
|
12
12
|
export const decodeTaxRepresentativeParty = Effect.fn(function* (
|
|
13
13
|
doc: XmlNode,
|
|
14
14
|
...path: Array<string>
|
|
15
|
-
): Effect.fn.Return<RecursivePartial<
|
|
15
|
+
): Effect.fn.Return<RecursivePartial<PeppolTaxRepresentative> | undefined> {
|
|
16
16
|
const taxRepresentative = yield* getProp(doc, ...path);
|
|
17
17
|
if (Predicate.isNullish(taxRepresentative)) return undefined;
|
|
18
18
|
|
|
@@ -2,14 +2,14 @@ import { Effect, Predicate } from 'effect';
|
|
|
2
2
|
|
|
3
3
|
import type { PeppolContact } from '#/schemas/fields/peppol-contact-schema.ts';
|
|
4
4
|
import type { PeppolIdentifier } from '#/schemas/fields/peppol-identifier-schema.ts';
|
|
5
|
-
import type {
|
|
5
|
+
import type { PeppolInvoiceResponseDocumentResponseParty, PeppolInvoiceResponseParty } from '#/schemas/peppol-invoice-response-schema.ts';
|
|
6
6
|
import type { PeppolMessageLevelResponseParty } from '#/schemas/peppol-message-level-response-party-schema.ts';
|
|
7
7
|
|
|
8
8
|
import { encodeContact } from '#/decoders/fields/encode-contact.ts';
|
|
9
9
|
import { encodeIdentifier } from '#/decoders/fields/encode-identifier.ts';
|
|
10
10
|
import { encodePartyLegalEntity } from '#/decoders/fields/encode-party-legal-entity.ts';
|
|
11
11
|
|
|
12
|
-
type ResponseParty = PeppolMessageLevelResponseParty | PeppolInvoiceResponseParty |
|
|
12
|
+
type ResponseParty = PeppolMessageLevelResponseParty | PeppolInvoiceResponseParty | PeppolInvoiceResponseDocumentResponseParty;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @description The response party union exposes different fields per variant; reading the optional ones through a shared view keeps the encoder branch-free.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolPartyTaxScheme } from '#/schemas/fields/peppol-party-tax-scheme-schema.ts';
|
|
5
5
|
|
|
6
6
|
import { encodePartyTaxScheme } from '#/decoders/fields/encode-party-tax-scheme.ts';
|
|
7
7
|
|
|
8
|
-
export const encodePartiesTaxScheme = Effect.fn(function* (partiesTaxScheme: Array<
|
|
8
|
+
export const encodePartiesTaxScheme = Effect.fn(function* (partiesTaxScheme: Array<PeppolPartyTaxScheme> | undefined): Effect.fn.Return<XmlNode> {
|
|
9
9
|
if (Predicate.isNullish(partiesTaxScheme) || partiesTaxScheme.length === 0) return undefined;
|
|
10
10
|
|
|
11
11
|
return yield* Effect.forEach(
|
|
12
12
|
partiesTaxScheme,
|
|
13
|
-
Effect.fn(function* (partyTaxScheme:
|
|
13
|
+
Effect.fn(function* (partyTaxScheme: PeppolPartyTaxScheme) {
|
|
14
14
|
return yield* encodePartyTaxScheme(partyTaxScheme);
|
|
15
15
|
})
|
|
16
16
|
);
|
|
@@ -3,7 +3,7 @@ import { Effect } from 'effect';
|
|
|
3
3
|
import { encodeIdentifier } from '#/decoders/fields/encode-identifier.ts';
|
|
4
4
|
|
|
5
5
|
export const encodePartyLegalEntity = Effect.fn(function* (legalEntity: {
|
|
6
|
-
registrationName?: string;
|
|
6
|
+
registrationName?: string | undefined;
|
|
7
7
|
companyId?: Parameters<typeof encodeIdentifier>[0];
|
|
8
8
|
companyLegalForm?: string | undefined;
|
|
9
9
|
}) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolPartyTaxScheme } from '#/schemas/fields/peppol-party-tax-scheme-schema.ts';
|
|
5
5
|
|
|
6
6
|
import { encodeSimpleIdentifier } from '#/decoders/fields/encode-simple-identifier.ts';
|
|
7
7
|
|
|
8
|
-
export const encodePartyTaxScheme = Effect.fn(function* (partyTaxScheme:
|
|
8
|
+
export const encodePartyTaxScheme = Effect.fn(function* (partyTaxScheme: PeppolPartyTaxScheme | undefined): Effect.fn.Return<XmlNode> {
|
|
9
9
|
if (Predicate.isNullish(partyTaxScheme)) return undefined;
|
|
10
10
|
|
|
11
11
|
return { 'cbc:CompanyID': partyTaxScheme.companyId, 'cac:TaxScheme': yield* encodeSimpleIdentifier(partyTaxScheme.taxSchemeId) };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Effect, Predicate } from 'effect';
|
|
2
2
|
|
|
3
3
|
import type { XmlNode } from '#/helpers/get-prop.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PeppolTaxRepresentative } from '#/schemas/fields/peppol-tax-representative-schema.ts';
|
|
5
5
|
|
|
6
6
|
import { encodeAddress } from '#/decoders/fields/encode-address.ts';
|
|
7
7
|
import { encodePartyTaxScheme } from '#/decoders/fields/encode-party-tax-scheme.ts';
|
|
8
8
|
|
|
9
9
|
export const encodeTaxRepresentativeParty = Effect.fn(function* (
|
|
10
|
-
taxRepresentativeParty:
|
|
10
|
+
taxRepresentativeParty: PeppolTaxRepresentative | undefined
|
|
11
11
|
): Effect.fn.Return<XmlNode> {
|
|
12
12
|
if (Predicate.isNullish(taxRepresentativeParty)) {
|
|
13
13
|
return undefined;
|
|
@@ -86,25 +86,27 @@ export class PeppolAttachment extends opaque<PeppolAttachment>()(
|
|
|
86
86
|
* @see {@link PeppolAdditionalDocumentReference}
|
|
87
87
|
*/
|
|
88
88
|
export class PeppolId extends opaque<PeppolId>()(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
PeppolIdentifier.pipe(
|
|
90
|
+
Schema.fieldsAssign({
|
|
91
|
+
/**
|
|
92
|
+
* @description An identifier for an object on which the invoice is based (with DocumentTypeCode=130), given by the Seller, the identifier for the supporting
|
|
93
|
+
* document or the project reference identifier (DocumentTypeCode=50).
|
|
94
|
+
*
|
|
95
|
+
* @summary Invoiced object identifier, Supporting document reference or project reference
|
|
96
|
+
*
|
|
97
|
+
* @name `#text`
|
|
98
|
+
*/
|
|
99
|
+
id: Schema.String,
|
|
100
|
+
/**
|
|
101
|
+
* @description The identification scheme identifier of the Invoiced object identifier.
|
|
102
|
+
*
|
|
103
|
+
* @summary Scheme identifier
|
|
104
|
+
*
|
|
105
|
+
* @name `@schemeID`
|
|
106
|
+
*/
|
|
107
|
+
schemeId: Schema.optional(PeppolAdditionalDocumentReferenceCode),
|
|
108
|
+
})
|
|
109
|
+
)
|
|
108
110
|
) {}
|
|
109
111
|
|
|
110
112
|
/**
|
|
@@ -148,9 +148,7 @@ export class PeppolCharge extends opaque<PeppolCharge>()(
|
|
|
148
148
|
*
|
|
149
149
|
* @name cac:AllowanceCharge
|
|
150
150
|
*/
|
|
151
|
-
export class PeppolAllowanceCharge extends
|
|
152
|
-
Schema.Union([PeppolAllowance, PeppolCharge]).annotate({ message: 'unable to decode allowance charge' })
|
|
153
|
-
) {}
|
|
151
|
+
export class PeppolAllowanceCharge extends Schema.Union([PeppolAllowance, PeppolCharge]).annotate({ message: 'unable to decode allowance charge' }) {}
|
|
154
152
|
|
|
155
153
|
/**
|
|
156
154
|
* @description Encoded form of {@link PeppolAllowanceCharge} produced by the Effect Schema codec.
|
|
@@ -104,9 +104,9 @@ export class PeppolLineCharge extends opaque<PeppolLineCharge>()(
|
|
|
104
104
|
*
|
|
105
105
|
* @see {@link PeppolLineAllowance}
|
|
106
106
|
*/
|
|
107
|
-
export class PeppolLineAllowanceCharge extends
|
|
108
|
-
|
|
109
|
-
) {}
|
|
107
|
+
export class PeppolLineAllowanceCharge extends Schema.Union([PeppolLineAllowance, PeppolLineCharge]).annotate({
|
|
108
|
+
message: 'unable to decode line allowance charge',
|
|
109
|
+
}) {}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* @description Encoded form of {@link PeppolLineAllowanceCharge} produced by the Effect Schema codec.
|
|
@@ -254,8 +254,3 @@ export class PeppolLineItem extends opaque<PeppolLineItem>()(
|
|
|
254
254
|
additionalItemProperties: Schema.optional(Schema.Array(PeppolAdditionalItemProperties)),
|
|
255
255
|
})
|
|
256
256
|
) {}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* @description Alias for {@link PeppolLineItem}.
|
|
260
|
-
*/
|
|
261
|
-
export type PeppolItem = PeppolLineItem;
|
|
@@ -38,8 +38,3 @@ export class PeppolPartyLegalEntity extends opaque<PeppolPartyLegalEntity>()(
|
|
|
38
38
|
registrationName: Schema.String,
|
|
39
39
|
})
|
|
40
40
|
) {}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @description Alias for {@link PeppolPartyLegalEntity}.
|
|
44
|
-
*/
|
|
45
|
-
export type PeppolPartyLegalEntitySchema = PeppolPartyLegalEntity;
|
|
@@ -2,7 +2,7 @@ import { Effect, Schema } from 'effect';
|
|
|
2
2
|
|
|
3
3
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
export class PeppolPartyTaxSchemeId extends opaque<PeppolPartyTaxSchemeId>()(
|
|
6
6
|
Schema.Struct({
|
|
7
7
|
/**
|
|
8
8
|
* @description Mandatory element. For Seller VAT identifier (BT-31), use value “VAT”, for the seller tax registration identifier (BT-32), use != "VAT"
|
|
@@ -36,11 +36,6 @@ export class PeppolPartyTaxScheme extends opaque<PeppolPartyTaxScheme>()(
|
|
|
36
36
|
*
|
|
37
37
|
* @name `cac:TaxScheme`
|
|
38
38
|
*/
|
|
39
|
-
taxSchemeId:
|
|
39
|
+
taxSchemeId: PeppolPartyTaxSchemeId,
|
|
40
40
|
})
|
|
41
41
|
) {}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @description Alias for {@link PeppolPartyTaxScheme}.
|
|
45
|
-
*/
|
|
46
|
-
export type PeppolPartyTaxSchema = PeppolPartyTaxScheme;
|
|
@@ -4,9 +4,9 @@ import { PeppolIdentifier } from '#/schemas/fields/peppol-identifier-schema.ts';
|
|
|
4
4
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
5
5
|
import { PeppolIcdCode } from '#/schemas/values/icd-codes-schema.ts';
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
export class PeppolPayeePartyName extends opaque<PeppolPayeePartyName>()(Schema.Struct({ name: Schema.String })) {}
|
|
8
8
|
|
|
9
|
-
class
|
|
9
|
+
export class PeppolPayeePartyLegalEntity extends opaque<PeppolPayeePartyLegalEntity>()(
|
|
10
10
|
Schema.Struct({
|
|
11
11
|
/**
|
|
12
12
|
* @description An identifier issued by an official registrar that identifies the payee as a legal entity or person.
|
|
@@ -46,7 +46,7 @@ class PeppolPartyLegalEntity extends opaque<PeppolPartyLegalEntity>()(
|
|
|
46
46
|
})
|
|
47
47
|
) {}
|
|
48
48
|
|
|
49
|
-
class
|
|
49
|
+
export class PeppolPayeePartyIdentification extends opaque<PeppolPayeePartyIdentification>()(
|
|
50
50
|
Schema.Struct({
|
|
51
51
|
/**
|
|
52
52
|
* @description This element is used for both the identification of the Payee, or the unique banking reference identifier of Payee (assigned by the Payee
|
|
@@ -97,13 +97,13 @@ export class PeppolPayeeParty extends opaque<PeppolPayeeParty>()(
|
|
|
97
97
|
*
|
|
98
98
|
* @name `cac:PartyIdentification`
|
|
99
99
|
*/
|
|
100
|
-
partyIdentification: Schema.optional(
|
|
100
|
+
partyIdentification: Schema.optional(PeppolPayeePartyIdentification),
|
|
101
101
|
/**
|
|
102
102
|
* @summary PARTY LEGAL ENTITY
|
|
103
103
|
*
|
|
104
104
|
* @name `cac:PartyLegalEntity`
|
|
105
105
|
*/
|
|
106
|
-
partyLegalEntity: Schema.optional(
|
|
106
|
+
partyLegalEntity: Schema.optional(PeppolPayeePartyLegalEntity),
|
|
107
107
|
/**
|
|
108
108
|
* @description The name of the payee.
|
|
109
109
|
*
|
|
@@ -114,6 +114,6 @@ export class PeppolPayeeParty extends opaque<PeppolPayeeParty>()(
|
|
|
114
114
|
*
|
|
115
115
|
* @name `cac:PartyName`
|
|
116
116
|
*/
|
|
117
|
-
partyName:
|
|
117
|
+
partyName: PeppolPayeePartyName,
|
|
118
118
|
})
|
|
119
119
|
) {}
|
|
@@ -24,8 +24,3 @@ export class PeppolTaxRepresentative extends opaque<PeppolTaxRepresentative>()(
|
|
|
24
24
|
partyTaxScheme: PeppolPartyTaxScheme,
|
|
25
25
|
})
|
|
26
26
|
) {}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @description Alias for {@link PeppolTaxRepresentative}.
|
|
30
|
-
*/
|
|
31
|
-
export type PeppolTaxRepresentativeParty = PeppolTaxRepresentative;
|
|
@@ -11,7 +11,7 @@ import { opaque } from '#/schemas/utils/opaque.ts';
|
|
|
11
11
|
*
|
|
12
12
|
* @name cac:TaxTotal (1..2)
|
|
13
13
|
*/
|
|
14
|
-
export class
|
|
14
|
+
export class PeppolTaxTotal extends opaque<PeppolTaxTotal>()(
|
|
15
15
|
Schema.Struct({
|
|
16
16
|
/**
|
|
17
17
|
* @example
|
|
@@ -26,8 +26,3 @@ export class PeppolTaxTotalsBase extends opaque<PeppolTaxTotalsBase>()(
|
|
|
26
26
|
taxSubtotals: Schema.optional(Schema.Array(PeppolTaxSubTotal)),
|
|
27
27
|
})
|
|
28
28
|
) {}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @description Alias for {@link PeppolTaxTotalsBase}.
|
|
32
|
-
*/
|
|
33
|
-
export type PeppolTaxTotal = PeppolTaxTotalsBase;
|
|
@@ -14,7 +14,7 @@ import { PeppolPayeeParty } from '#/schemas/fields/peppol-payee-party-schema.ts'
|
|
|
14
14
|
import { PeppolPaymentMeans } from '#/schemas/fields/peppol-payment-means-schema.ts';
|
|
15
15
|
import { PeppolPaymentTerms } from '#/schemas/fields/peppol-payment-terms-schema.ts';
|
|
16
16
|
import { PeppolTaxRepresentative } from '#/schemas/fields/peppol-tax-representative-schema.ts';
|
|
17
|
-
import {
|
|
17
|
+
import { PeppolTaxTotal } from '#/schemas/fields/peppol-tax-totals-base-schema.ts';
|
|
18
18
|
import { PeppolIsoDateString } from '#/schemas/peppol-iso-date-string.ts';
|
|
19
19
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
20
20
|
import { PeppolCurrencyCode } from '#/schemas/values/currency-code-schema.ts';
|
|
@@ -394,7 +394,7 @@ export class PeppolBillingBase extends opaque<PeppolBillingBase>()(
|
|
|
394
394
|
*
|
|
395
395
|
* @name cac:TaxTotal
|
|
396
396
|
*/
|
|
397
|
-
taxTotals: Schema.Array(
|
|
397
|
+
taxTotals: Schema.Array(PeppolTaxTotal).check(Schema.isMinLength(1), Schema.isMaxLength(2)),
|
|
398
398
|
|
|
399
399
|
/**
|
|
400
400
|
* @summary DOCUMENT TOTALS
|
|
@@ -47,8 +47,3 @@ export class PeppolDocumentResponseDocumentReference extends opaque<PeppolDocume
|
|
|
47
47
|
versionId: Schema.optional(Schema.String),
|
|
48
48
|
})
|
|
49
49
|
) {}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @description Alias of {@link PeppolDocumentResponseDocumentReference} under the message level response naming.
|
|
53
|
-
*/
|
|
54
|
-
export type PeppolMessageLevelDocumentResponseDocumentReference = PeppolDocumentResponseDocumentReference;
|
|
@@ -36,8 +36,3 @@ export class PeppolDocumentResponseDocument extends opaque<PeppolDocumentRespons
|
|
|
36
36
|
description: Schema.optional(Schema.String),
|
|
37
37
|
})
|
|
38
38
|
) {}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @description Alias of {@link PeppolDocumentResponseDocument} under the message level response naming.
|
|
42
|
-
*/
|
|
43
|
-
export type PeppolMessageLevelResponseDocumentResponseDocument = PeppolDocumentResponseDocument;
|
|
@@ -59,8 +59,3 @@ export class PeppolDocumentResponseLineResponse extends opaque<PeppolDocumentRes
|
|
|
59
59
|
response: PeppolDocumentResponseLineResponseContent,
|
|
60
60
|
})
|
|
61
61
|
) {}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @description Alias of {@link PeppolDocumentResponseLineResponse} under the message level response naming.
|
|
65
|
-
*/
|
|
66
|
-
export type PeppolMessageLevelDocumentResponseLineResponse = PeppolDocumentResponseLineResponse;
|
|
@@ -22,7 +22,6 @@ import { PeppolCreditNote } from '#/schemas/peppol-credit-note-schema.ts';
|
|
|
22
22
|
import { PeppolInvoiceResponse } from '#/schemas/peppol-invoice-response-schema.ts';
|
|
23
23
|
import { PeppolInvoice } from '#/schemas/peppol-invoice-schema.ts';
|
|
24
24
|
import { PeppolMessageLevelResponse } from '#/schemas/peppol-message-level-response-schema.ts';
|
|
25
|
-
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
26
25
|
import { builderOptions } from '#/xml/builder-options.ts';
|
|
27
26
|
import { parseXmlNodable } from '#/xml/nodable-parser.ts';
|
|
28
27
|
|
|
@@ -126,7 +125,8 @@ const encodeDocumentXml = Effect.fn('encode-peppol-document-xml')(function* (val
|
|
|
126
125
|
} else {
|
|
127
126
|
const rootNodes = Object.keys(value);
|
|
128
127
|
return yield* Effect.fail(
|
|
129
|
-
|
|
128
|
+
// oxlint-disable-next-line typescript/no-explicit-any this is safe since it is only for logging purposes
|
|
129
|
+
new SchemaIssue.InvalidValue({ message: `Unsupported document type: ${(value as any)?.profileId}\n${rootNodes.join(',')}` }, value, options)
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -146,13 +146,11 @@ const encodeDocumentXml = Effect.fn('encode-peppol-document-xml')(function* (val
|
|
|
146
146
|
* @see {@link PeppolDocumentDecoded}
|
|
147
147
|
* @see {@link PeppolDocumentEncoded}
|
|
148
148
|
*/
|
|
149
|
-
export class PeppolDocumentSchema extends
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
})
|
|
155
|
-
)
|
|
149
|
+
export class PeppolDocumentSchema extends peppolDocumentObjectSchema.pipe(
|
|
150
|
+
Schema.encodeTo(Schema.String, {
|
|
151
|
+
encode: SchemaGetter.transformEffect((value, options) => encodeDocumentXml(value, options)),
|
|
152
|
+
decode: SchemaGetter.transformEffect((value, options) => decodeDocumentXml(value, options)),
|
|
153
|
+
})
|
|
156
154
|
) {}
|
|
157
155
|
|
|
158
156
|
/**
|
|
@@ -125,11 +125,7 @@ export class PeppolInvoiceResponseDocumentActualResponseWithStatus extends opaqu
|
|
|
125
125
|
*
|
|
126
126
|
* @see {@link PeppolInvoiceResponseDocumentResponse}
|
|
127
127
|
*/
|
|
128
|
-
export class PeppolInvoiceResponseDocumentActualResponse extends
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @description Alias of {@link PeppolInvoiceResponseDocumentActualResponse}.
|
|
134
|
-
*/
|
|
135
|
-
export type InvoiceResponseDocumentActualResponse = PeppolInvoiceResponseDocumentActualResponse;
|
|
128
|
+
export class PeppolInvoiceResponseDocumentActualResponse extends Schema.Union([
|
|
129
|
+
PeppolInvoiceResponseDocumentActualResponseWithStatus,
|
|
130
|
+
PeppolInvoiceResponseDocumentActualResponseWithoutStatus,
|
|
131
|
+
]) {}
|
|
@@ -79,8 +79,3 @@ export class PeppolInvoiceResponseDocumentActualResponseStatus extends opaque<Pe
|
|
|
79
79
|
condition: Schema.optional(Schema.Array(PeppolInvoiceResponseCondition)),
|
|
80
80
|
})
|
|
81
81
|
) {}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @description Alias of {@link PeppolInvoiceResponseDocumentActualResponseStatus}.
|
|
85
|
-
*/
|
|
86
|
-
export type InvoiceResponseDocumentActualResponseStatus = PeppolInvoiceResponseDocumentActualResponseStatus;
|
|
@@ -99,11 +99,6 @@ export class PeppolInvoiceResponseDocumentResponseParty extends opaque<PeppolInv
|
|
|
99
99
|
})
|
|
100
100
|
) {}
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* @description Alias of {@link PeppolInvoiceResponseDocumentResponseParty}.
|
|
104
|
-
*/
|
|
105
|
-
export type PeppolInvoiceDocumentResponseParty = PeppolInvoiceResponseDocumentResponseParty;
|
|
106
|
-
|
|
107
102
|
/**
|
|
108
103
|
* @description Wraps `cac:DocumentReference` inside an invoice response: identifies the invoice the status applies to.
|
|
109
104
|
*
|
|
@@ -62,6 +62,7 @@ export class PeppolInvoiceResponseStatusReasonCodeAction extends opaque<PeppolIn
|
|
|
62
62
|
*
|
|
63
63
|
* @see {@link PeppolInvoiceResponseDocumentActualResponseStatus}
|
|
64
64
|
*/
|
|
65
|
-
export class PeppolInvoiceResponseStatusReasonCode extends
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
export class PeppolInvoiceResponseStatusReasonCode extends Schema.Union([
|
|
66
|
+
PeppolInvoiceResponseStatusReasonCodeAction,
|
|
67
|
+
PeppolInvoiceResponseStatusReasonCodeReason,
|
|
68
|
+
]) {}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
-
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
4
|
-
|
|
5
3
|
// RFC 4648 §4 — Base 64 Encoding
|
|
6
4
|
//
|
|
7
5
|
// Alphabet: A-Z a-z 0-9 + / (pad: =)
|
|
@@ -33,11 +31,6 @@ const BASE64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=
|
|
|
33
31
|
* const value = 'SGVsbG8=';
|
|
34
32
|
* ```;
|
|
35
33
|
*/
|
|
36
|
-
export class PeppolBase64 extends
|
|
37
|
-
|
|
38
|
-
) {}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @description Alias of {@link PeppolBase64} for callers that prefer the shorter name.
|
|
42
|
-
*/
|
|
43
|
-
export type Base64 = PeppolBase64;
|
|
34
|
+
export class PeppolBase64 extends Schema.String.check(Schema.makeFilter((val: string) => BASE64_RE.test(val.replace(/\r?\n/g, '')))).annotate({
|
|
35
|
+
message: 'Invalid base64',
|
|
36
|
+
}) {}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
import { Schema } from 'effect';
|
|
11
11
|
|
|
12
|
-
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
13
12
|
import { countryCodesKeys } from '#/values/country-code.generated';
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -26,6 +25,4 @@ import { countryCodesKeys } from '#/values/country-code.generated';
|
|
|
26
25
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/ISO3166/
|
|
27
26
|
* @see {@link countryCodesKeys}
|
|
28
27
|
*/
|
|
29
|
-
export class PeppolCountryCodeValue extends
|
|
30
|
-
Schema.Literals(countryCodesKeys).pipe(Schema.brand('PeppolCountryCodeValue'))
|
|
31
|
-
) {}
|
|
28
|
+
export class PeppolCountryCodeValue extends Schema.Literals(countryCodesKeys).pipe(Schema.brand('PeppolCountryCodeValue')) {}
|