@getpeppr/sdk 0.1.0

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.
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Invoice Validator
3
+ *
4
+ * Validates invoice data BEFORE conversion to XML.
5
+ * Implements key Peppol BIS 3.0 business rules with human-readable error messages.
6
+ *
7
+ * Design principle: Errors tell you WHAT's wrong, WHERE it is, and HOW to fix it.
8
+ * No developer should need to Google a Peppol rule ID.
9
+ */
10
+ import { validateCountryRules } from "./country-rules.js";
11
+ function error(field, message, ruleId, suggestion) {
12
+ return { field, message, ruleId, suggestion };
13
+ }
14
+ function warning(field, message, ruleId) {
15
+ return { field, message, ruleId };
16
+ }
17
+ const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}/;
18
+ function validateParty(party, path) {
19
+ const errors = [];
20
+ if (!party.name?.trim()) {
21
+ errors.push(error(`${path}.name`, "Business name is required", "BR-06"));
22
+ }
23
+ if (!party.peppolId) {
24
+ errors.push(error(`${path}.peppolId`, "Peppol participant ID is required", undefined, 'Format: "scheme:id", e.g. "0208:BE0123456789" for Belgian companies'));
25
+ }
26
+ else if (!party.peppolId.includes(":")) {
27
+ errors.push(error(`${path}.peppolId`, `Invalid Peppol ID format: "${party.peppolId}"`, undefined, 'Must be "scheme:id" format. Common schemes: 0208 (Belgium), 0009 (France SIRET), 0204 (Germany Leitweg)'));
28
+ }
29
+ if (!party.country) {
30
+ errors.push(error(`${path}.country`, "Country code is required", "BR-11"));
31
+ }
32
+ else if (party.country.length !== 2) {
33
+ errors.push(error(`${path}.country`, `Invalid country code: "${party.country}"`, undefined, "Must be ISO 3166-1 alpha-2 (e.g., BE, FR, DE, NL)"));
34
+ }
35
+ return errors;
36
+ }
37
+ function validateLine(line, index) {
38
+ const errors = [];
39
+ const path = `lines[${index}]`;
40
+ if (!line.description?.trim()) {
41
+ errors.push(error(`${path}.description`, "Line item description is required", "BR-25"));
42
+ }
43
+ if (line.quantity === undefined || line.quantity === null) {
44
+ errors.push(error(`${path}.quantity`, "Quantity is required", "BR-22"));
45
+ }
46
+ else if (line.quantity <= 0) {
47
+ errors.push(error(`${path}.quantity`, `Quantity must be positive, got ${line.quantity}`, undefined, "For returns/credits, use a credit note instead"));
48
+ }
49
+ if (line.unitPrice === undefined || line.unitPrice === null) {
50
+ errors.push(error(`${path}.unitPrice`, "Unit price is required", "BR-26"));
51
+ }
52
+ else if (line.unitPrice < 0) {
53
+ errors.push(error(`${path}.unitPrice`, `Unit price cannot be negative, got ${line.unitPrice}`, undefined, "For discounts, use a negative quantity or a separate discount line"));
54
+ }
55
+ if (line.vatRate === undefined || line.vatRate === null) {
56
+ errors.push(error(`${path}.vatRate`, "VAT rate is required", "BR-CO-17"));
57
+ }
58
+ else if (line.vatRate < 0 || line.vatRate > 100) {
59
+ errors.push(error(`${path}.vatRate`, `VAT rate must be between 0 and 100, got ${line.vatRate}`, undefined, "Use 0 for zero-rated, 21 for standard Belgian VAT, etc."));
60
+ }
61
+ return errors;
62
+ }
63
+ /**
64
+ * Validate an invoice input before sending.
65
+ * Returns human-readable errors with suggestions for fixes.
66
+ */
67
+ export function validateInvoice(input) {
68
+ const errors = [];
69
+ const warnings = [];
70
+ // ── Invoice-level validation ──
71
+ if (!input.number?.trim()) {
72
+ errors.push(error("number", "Invoice number is required", "BR-02", "Must be unique per supplier"));
73
+ }
74
+ // ── Invoice type code validation ──
75
+ const VALID_TYPE_CODES = [380, 381, 383, 384, 386, 389, 751];
76
+ if (input.invoiceTypeCode != null && !VALID_TYPE_CODES.includes(input.invoiceTypeCode)) {
77
+ errors.push(error("invoiceTypeCode", `Invalid invoice type code: ${input.invoiceTypeCode}`, undefined, "Valid codes: 380, 381, 383, 384, 386, 389, 751"));
78
+ }
79
+ // ── Credit note validation ──
80
+ if (input.isCreditNote && !input.invoiceReference?.trim()) {
81
+ errors.push(error("invoiceReference", "Reference to the original invoice is required for credit notes", undefined, 'Set invoiceReference to the original invoice number (e.g., "INV-001")'));
82
+ }
83
+ if (input.from) {
84
+ warnings.push(warning("from", "Seller info is determined by your API key. The 'from' field is deprecated and ignored."));
85
+ }
86
+ if (!input.to) {
87
+ errors.push(error("to", "Buyer (to) is required", "BR-07"));
88
+ }
89
+ else {
90
+ errors.push(...validateParty(input.to, "to"));
91
+ }
92
+ if (input.payeeParty) {
93
+ if (!input.payeeParty.name?.trim()) {
94
+ errors.push(error("payeeParty.name", "Payee party name is required", "BR-17"));
95
+ }
96
+ if (!input.payeeParty.peppolId) {
97
+ errors.push(error("payeeParty.peppolId", "Payee party Peppol ID is required", undefined, 'Format: "scheme:id", e.g. "0208:BE0123456789"'));
98
+ }
99
+ else if (!input.payeeParty.peppolId.includes(":")) {
100
+ errors.push(error("payeeParty.peppolId", `Invalid Peppol ID format: "${input.payeeParty.peppolId}"`, undefined, 'Must be "scheme:id" format'));
101
+ }
102
+ }
103
+ if (!input.lines || input.lines.length === 0) {
104
+ errors.push(error("lines", "At least one line item is required", "BR-16", "Add items to the lines array"));
105
+ }
106
+ else {
107
+ for (let i = 0; i < input.lines.length; i++) {
108
+ errors.push(...validateLine(input.lines[i], i));
109
+ }
110
+ }
111
+ // ── Date validation ──
112
+ if (input.date) {
113
+ if (!ISO_DATE_RE.test(input.date)) {
114
+ errors.push(error("date", `Invalid date format: "${input.date}"`, undefined, "Use ISO 8601: YYYY-MM-DD"));
115
+ }
116
+ }
117
+ if (input.dueDate) {
118
+ if (!ISO_DATE_RE.test(input.dueDate)) {
119
+ errors.push(error("dueDate", `Invalid due date format: "${input.dueDate}"`, undefined, "Use ISO 8601: YYYY-MM-DD"));
120
+ }
121
+ }
122
+ // ── TaxPointDate validation (BT-7) ──
123
+ if (input.taxPointDate) {
124
+ if (!ISO_DATE_RE.test(input.taxPointDate)) {
125
+ errors.push(error("taxPointDate", `Invalid tax point date format: "${input.taxPointDate}"`, undefined, "Use ISO 8601: YYYY-MM-DD"));
126
+ }
127
+ }
128
+ // ── RoundingAmount validation (BT-114) ──
129
+ if (input.roundingAmount !== undefined && input.roundingAmount !== null) {
130
+ if (input.roundingAmount < -0.99 || input.roundingAmount > 0.99) {
131
+ errors.push(error("roundingAmount", `Rounding amount must be between -0.99 and 0.99, got ${input.roundingAmount}`, undefined, "B2BRouter stores rounding as integer cents (±99). Use values like 0.50 or -0.25."));
132
+ }
133
+ }
134
+ // ── BuyerReference / OrderReference (BT-10) ──
135
+ if (!input.buyerReference && !input.orderReference) {
136
+ warnings.push(warning("buyerReference", "Either buyerReference or orderReference is required by Peppol BIS 3.0 (BT-10).", "BR-10"));
137
+ }
138
+ // ── TaxCurrencyCode validation ──
139
+ if (input.taxCurrency && input.taxCurrency !== (input.currency ?? "EUR") && !input.taxCurrencyRate) {
140
+ errors.push(error("taxCurrencyRate", "Tax currency rate is required when taxCurrency differs from document currency", "BR-53", "Set taxCurrencyRate to the exchange rate from document currency to tax currency"));
141
+ }
142
+ if (input.taxCurrency && input.taxCurrency === (input.currency ?? "EUR")) {
143
+ warnings.push(warning("taxCurrency", "Tax currency is the same as document currency — TaxCurrencyCode will be omitted"));
144
+ }
145
+ if (input.taxCurrencyRate !== undefined && input.taxCurrencyRate <= 0) {
146
+ errors.push(error("taxCurrencyRate", `Tax currency rate must be positive, got ${input.taxCurrencyRate}`, undefined, "Set to the exchange rate from document currency to tax currency"));
147
+ }
148
+ // ── Warnings (non-blocking) ──
149
+ if (!input.dueDate) {
150
+ warnings.push(warning("dueDate", "No due date specified. Recommended for payment terms.", "BR-09"));
151
+ }
152
+ if (!input.to?.vatNumber) {
153
+ warnings.push(warning("to.vatNumber", "Buyer VAT number not provided. May be required for B2B."));
154
+ }
155
+ if (input.paymentMeans === 30 && !input.paymentIban) {
156
+ warnings.push(warning("paymentIban", "Payment means is credit transfer but no IBAN provided. Buyer won't know where to pay."));
157
+ }
158
+ // ── Cross-field validation ──
159
+ if (input.from?.peppolId && input.to?.peppolId && input.from.peppolId === input.to.peppolId) {
160
+ errors.push(error("to.peppolId", "Buyer and seller cannot have the same Peppol ID", undefined, "Check that 'from' and 'to' are different parties"));
161
+ }
162
+ // ── Country-specific rules (advisory warnings) ──
163
+ const countryResult = validateCountryRules(input);
164
+ warnings.push(...countryResult.warnings);
165
+ return {
166
+ valid: errors.length === 0,
167
+ errors,
168
+ warnings,
169
+ };
170
+ }
171
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/core/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,SAAS,KAAK,CAAC,KAAa,EAAE,OAAe,EAAE,MAAe,EAAE,UAAmB;IACjF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,OAAe,EAAE,MAAe;IAC9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAEzC,SAAS,aAAa,CAAC,KAAY,EAAE,IAAY;IAC/C,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,OAAO,EAAE,2BAA2B,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CACT,KAAK,CACH,GAAG,IAAI,WAAW,EAClB,mCAAmC,EACnC,SAAS,EACT,qEAAqE,CACtE,CACF,CAAC;IACJ,CAAC;SAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC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AAI,CAAC,QAAQ,KAAK,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC5F,MAAM,CAAC,IAAI,CACT,KAAK,CACH,aAAa,EACb,iDAAiD,EACjD,SAAS,EACT,kDAAkD,CACnD,CACF,CAAC;IACJ,CAAC;IAED,mDAAmD;IAEnD,MAAM,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAClD,QAAQ,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEzC,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @getpeppr/sdk — Send Peppol invoices in 5 lines of code.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { Peppol } from "@getpeppr/sdk";
7
+ *
8
+ * const peppol = new Peppol({ apiKey: "your-api-key" });
9
+ *
10
+ * const result = await peppol.invoices.send({
11
+ * number: "INV-2026-001",
12
+ * to: { name: "Wayne Enterprises", peppolId: "0208:BE9876543210", country: "BE" },
13
+ * lines: [
14
+ * { description: "Arc Reactor Maintenance", quantity: 1, unitPrice: 50000, vatRate: 21 }
15
+ * ]
16
+ * });
17
+ *
18
+ * console.log(`Invoice sent! Status: ${result.status}`);
19
+ * ```
20
+ */
21
+ export { Peppol, PeppolError, PeppolValidationError, PeppolApiError, webhooks } from "./core/client.js";
22
+ export type { BackendAdapter } from "./core/client.js";
23
+ export { buildInvoiceXml, buildCreditNoteXml } from "./core/ubl-builder.js";
24
+ export { validateInvoice } from "./core/validator.js";
25
+ export { validateSchematron } from "./core/schematron.js";
26
+ export type { SchematronResult, SchematronViolation } from "./core/schematron.js";
27
+ export { validateCountryRules } from "./core/country-rules.js";
28
+ export type { CountryValidationResult } from "./core/country-rules.js";
29
+ export { getCountryName, getAllCountries, getEasScheme, getAllEasSchemes, resolveUnit, getAllUnits, getVatCategories, getPaymentMeansCodes, } from "./core/code-lists.js";
30
+ export type { EasScheme, VatCategory, PaymentMeansCode } from "./core/code-lists.js";
31
+ export type { PeppolConfig, PeppolId, CurrencyCode, CountryCode, Party, InvoiceLine, InvoiceInput, InvoiceTypeCode, CreditNoteInput, Attachment, AllowanceCharge, LineAllowanceCharge, ItemProperty, InvoicePeriod, Delivery, DeliveryAddress, SendResult, ReceivedInvoice, DocumentStatus, ValidationResult, ValidationError, ValidationWarning, WebhookEvent, WebhookEventType, RetryConfig, WaitForOptions, PaginatedResult, PaginationMeta, ListInvoicesOptions, InvoiceSummary, DirectoryEntry, DocumentFormat, ServerValidationResult, ServerValidationMessage, EventEntry, ListEventsOptions, BatchSendOptions, BatchSendResult, InvoiceOperationOptions, RequestLogEntry, ResponseLogEntry, Contact, ContactInput, ListContactsOptions, BankAccount, BankAccountInput, ListBankAccountsOptions, ImportInvoiceOptions, TransportType, Transport, } from "./types/invoice.js";
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxG,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAErF,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,eAAe,EACf,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,SAAS,GACV,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @getpeppr/sdk — Send Peppol invoices in 5 lines of code.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { Peppol } from "@getpeppr/sdk";
7
+ *
8
+ * const peppol = new Peppol({ apiKey: "your-api-key" });
9
+ *
10
+ * const result = await peppol.invoices.send({
11
+ * number: "INV-2026-001",
12
+ * to: { name: "Wayne Enterprises", peppolId: "0208:BE9876543210", country: "BE" },
13
+ * lines: [
14
+ * { description: "Arc Reactor Maintenance", quantity: 1, unitPrice: 50000, vatRate: 21 }
15
+ * ]
16
+ * });
17
+ *
18
+ * console.log(`Invoice sent! Status: ${result.status}`);
19
+ * ```
20
+ */
21
+ export { Peppol, PeppolError, PeppolValidationError, PeppolApiError, webhooks } from "./core/client.js";
22
+ export { buildInvoiceXml, buildCreditNoteXml } from "./core/ubl-builder.js";
23
+ export { validateInvoice } from "./core/validator.js";
24
+ export { validateSchematron } from "./core/schematron.js";
25
+ export { validateCountryRules } from "./core/country-rules.js";
26
+ export { getCountryName, getAllCountries, getEasScheme, getAllEasSchemes, resolveUnit, getAllUnits, getVatCategories, getPaymentMeansCodes, } from "./core/code-lists.js";
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAExG,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EACL,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC"}