@getpeppr/cli 0.4.4 → 0.4.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 CHANGED
@@ -211,7 +211,7 @@ The input file must be a JSON object matching the getpeppr `InvoiceInput` type.
211
211
  "buyerReference": "PO-2026-042",
212
212
  "from": {
213
213
  "name": "Dupont & Fils SPRL",
214
- "peppolId": "0208:0123456789",
214
+ "peppolId": "0208:0685660237",
215
215
  "street": "Avenue Louise 54",
216
216
  "city": "Bruxelles",
217
217
  "postalCode": "1050",
package/dist/index.js CHANGED
@@ -884,7 +884,7 @@ function validateParty(party, path) {
884
884
  errors.push(error(`${path}.name`, "Business name is required", "BR-06"));
885
885
  }
886
886
  if (party.peppolId === void 0 || party.peppolId === null || party.peppolId === "") {
887
- errors.push(error(`${path}.peppolId`, "Peppol participant ID is required", void 0, 'Format: "scheme:id", e.g. "0208:0123456789" for Belgian companies'));
887
+ errors.push(error(`${path}.peppolId`, "Peppol participant ID is required", void 0, 'Format: "scheme:id", e.g. "0208:0685660237" for Belgian companies'));
888
888
  } else if (!assertString(party.peppolId, `${path}.peppolId`, errors)) {
889
889
  } else if (!party.peppolId.includes(":")) {
890
890
  errors.push(error(`${path}.peppolId`, `Invalid Peppol ID format: "${party.peppolId}"`, void 0, 'Must be "scheme:id" format. Common schemes: 0208 (Belgium), 0009 (France SIRET), 0204 (Germany Leitweg)'));
@@ -986,7 +986,7 @@ function validateInvoice(input) {
986
986
  }
987
987
  const ppId = input.payeeParty.peppolId;
988
988
  if (ppId === void 0 || ppId === null || ppId === "") {
989
- errors.push(error("payeeParty.peppolId", "Payee party Peppol ID is required", void 0, 'Format: "scheme:id", e.g. "0208:0123456789"'));
989
+ errors.push(error("payeeParty.peppolId", "Payee party Peppol ID is required", void 0, 'Format: "scheme:id", e.g. "0208:0685660237"'));
990
990
  } else if (!assertString(ppId, "payeeParty.peppolId", errors)) {
991
991
  } else if (!ppId.includes(":")) {
992
992
  errors.push(error("payeeParty.peppolId", `Invalid Peppol ID format: "${ppId}"`, void 0, 'Must be "scheme:id" format'));
@@ -1059,7 +1059,7 @@ function validateInvoice(input) {
1059
1059
  }
1060
1060
 
1061
1061
  // ../sdk/dist/version.js
1062
- var SDK_VERSION = "1.5.1";
1062
+ var SDK_VERSION = "1.5.2";
1063
1063
 
1064
1064
  // ../sdk/dist/core/client.js
1065
1065
  function findHeaderCaseInsensitive(headers, name) {
@@ -1306,7 +1306,8 @@ var GetpepprAdapter = class {
1306
1306
  return parseSendResult(result);
1307
1307
  }
1308
1308
  async lookupDirectory(scheme, id) {
1309
- return this.request("GET", `/directory/${scheme}/${id}`);
1309
+ const result = await this.request("GET", `/directory/${scheme}/${id}`);
1310
+ return parseDirectoryEntry(result);
1310
1311
  }
1311
1312
  async searchDirectory(params) {
1312
1313
  const query = new URLSearchParams(params).toString();
@@ -1595,6 +1596,40 @@ function parseSendResult(result) {
1595
1596
  warnings: Array.isArray(result.warnings) ? result.warnings : void 0
1596
1597
  };
1597
1598
  }
1599
+ function parseDirectoryEntry(result) {
1600
+ const participant = isRecord(result.participant) ? result.participant : result;
1601
+ const scheme = participant.scheme == null ? void 0 : String(participant.scheme);
1602
+ const id = participant.id == null ? void 0 : String(participant.id);
1603
+ const peppolId = participant.peppolId == null ? formatPeppolId(scheme, id) : String(participant.peppolId);
1604
+ return {
1605
+ name: String(participant.name ?? ""),
1606
+ peppolId,
1607
+ country: String(participant.country ?? ""),
1608
+ capabilities: Array.isArray(participant.capabilities) ? participant.capabilities.map(String) : [],
1609
+ registrationDate: participant.registrationDate == null ? void 0 : String(participant.registrationDate),
1610
+ vatNumber: participant.vatNumber == null ? void 0 : String(participant.vatNumber),
1611
+ additionalIds: Array.isArray(participant.additionalIds) ? participant.additionalIds.filter(isRecord).map((entry) => ({
1612
+ scheme: String(entry.scheme ?? ""),
1613
+ value: String(entry.value ?? "")
1614
+ })) : void 0,
1615
+ contactInfo: isRecord(participant.contactInfo) ? {
1616
+ name: participant.contactInfo.name == null ? void 0 : String(participant.contactInfo.name),
1617
+ email: participant.contactInfo.email == null ? void 0 : String(participant.contactInfo.email),
1618
+ phone: participant.contactInfo.phone == null ? void 0 : String(participant.contactInfo.phone)
1619
+ } : void 0,
1620
+ website: participant.website == null ? void 0 : String(participant.website)
1621
+ };
1622
+ }
1623
+ function formatPeppolId(scheme, id) {
1624
+ if (!id)
1625
+ return scheme ? `${scheme}:` : "";
1626
+ if (id.includes(":"))
1627
+ return id;
1628
+ return scheme ? `${scheme}:${id}` : id;
1629
+ }
1630
+ function isRecord(value) {
1631
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1632
+ }
1598
1633
  function parseContact(raw) {
1599
1634
  const contact = {
1600
1635
  id: String(raw.id ?? ""),
@@ -1819,8 +1854,8 @@ ${validation.errors.map((e) => ` - ${e.field}: ${e.message}${e.suggestion ? ` (
1819
1854
  * ```ts
1820
1855
  * const result = await peppol.invoices.send({
1821
1856
  * number: "INV-001",
1822
- * from: { name: "My Company", peppolId: "0208:0123456789", country: "BE" },
1823
- * to: { name: "Client Co", peppolId: "0208:0987654321", country: "BE" },
1857
+ * from: { name: "My Company", peppolId: "0208:0685660237", country: "BE" },
1858
+ * to: { name: "Client Co", peppolId: "0208:0685660237", country: "BE" },
1824
1859
  * lines: [
1825
1860
  * { description: "Consulting", quantity: 10, unitPrice: 150, vatRate: 21 }
1826
1861
  * ]
@@ -1882,7 +1917,7 @@ ${validation.errors.map((e) => ` - ${e.field}: ${e.message}${e.suggestion ? ` (
1882
1917
  * ```ts
1883
1918
  * const result = await peppol.invoices.validateServer({
1884
1919
  * number: "INV-001",
1885
- * to: { name: "Acme", peppolId: "0208:0123456789", country: "BE" },
1920
+ * to: { name: "Acme", peppolId: "0208:0685660237", country: "BE" },
1886
1921
  * lines: [{ description: "Item", quantity: 1, unitPrice: 100, vatRate: 21 }]
1887
1922
  * });
1888
1923
  * console.log(result.valid, result.schematron.errors);
@@ -2079,14 +2114,14 @@ var DirectoryOperations = class {
2079
2114
  *
2080
2115
  * @example
2081
2116
  * ```ts
2082
- * const entry = await peppol.directory.lookup("0208:0123456789");
2117
+ * const entry = await peppol.directory.lookup("0208:0685660237");
2083
2118
  * console.log(entry.name, entry.capabilities);
2084
2119
  * ```
2085
2120
  */
2086
2121
  async lookup(peppolId) {
2087
2122
  const colonIndex = peppolId.indexOf(":");
2088
2123
  if (colonIndex === -1) {
2089
- throw new PeppolError('Invalid Peppol ID format. Expected "scheme:id" (e.g., "0208:0123456789")');
2124
+ throw new PeppolError('Invalid Peppol ID format. Expected "scheme:id" (e.g., "0208:0685660237")');
2090
2125
  }
2091
2126
  const scheme = peppolId.slice(0, colonIndex);
2092
2127
  const id = peppolId.slice(colonIndex + 1);
@@ -2131,7 +2166,7 @@ var DirectoryOperations = class {
2131
2166
  *
2132
2167
  * @example
2133
2168
  * ```ts
2134
- * const result = await peppol.directory.searchByVat("BE0123456789");
2169
+ * const result = await peppol.directory.searchByVat("BE0685660237");
2135
2170
  * ```
2136
2171
  */
2137
2172
  async searchByVat(vatNumber) {
@@ -2207,8 +2242,8 @@ var ContactOperations = class {
2207
2242
  * @example
2208
2243
  * ```ts
2209
2244
  * const contact = await peppol.contacts.create({
2210
- * name: "Acme Corp",
2211
- * peppolId: "0208:0123456789",
2245
+ * name: "ACMEDIA",
2246
+ * peppolId: "0208:0685660237",
2212
2247
  * country: "BE",
2213
2248
  * isClient: true,
2214
2249
  * });
@@ -2789,7 +2824,7 @@ var INVOICE_TEMPLATE = {
2789
2824
  buyerReference: "PO-2026-042",
2790
2825
  from: {
2791
2826
  name: "Dupont & Fils SPRL",
2792
- peppolId: "0208:0123456789",
2827
+ peppolId: "0208:0685660237",
2793
2828
  street: "Avenue Louise 54",
2794
2829
  city: "Bruxelles",
2795
2830
  postalCode: "1050",
@@ -2831,7 +2866,7 @@ var CREDIT_NOTE_TEMPLATE = {
2831
2866
  invoiceReference: "INV-2026-001",
2832
2867
  from: {
2833
2868
  name: "Dupont & Fils SPRL",
2834
- peppolId: "0208:0123456789",
2869
+ peppolId: "0208:0685660237",
2835
2870
  street: "Avenue Louise 54",
2836
2871
  city: "Bruxelles",
2837
2872
  postalCode: "1050",