@getpeppr/cli 0.4.6 → 0.5.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.
package/dist/index.js CHANGED
@@ -1016,7 +1016,7 @@ function validateInvoice(input) {
1016
1016
  }
1017
1017
  if (input.roundingAmount !== void 0 && input.roundingAmount !== null) {
1018
1018
  if (input.roundingAmount < -0.99 || input.roundingAmount > 0.99) {
1019
- errors.push(error("roundingAmount", `Rounding amount must be between -0.99 and 0.99, got ${input.roundingAmount}`, void 0, "B2BRouter stores rounding as integer cents (\xB199). Use values like 0.50 or -0.25."));
1019
+ errors.push(error("roundingAmount", `Rounding amount must be between -0.99 and 0.99, got ${input.roundingAmount}`, void 0, "Rounding is stored as integer cents (\xB199). Use values like 0.50 or -0.25."));
1020
1020
  }
1021
1021
  }
1022
1022
  if (!input.buyerReference && !input.orderReference) {
@@ -1059,7 +1059,7 @@ function validateInvoice(input) {
1059
1059
  }
1060
1060
 
1061
1061
  // ../sdk/dist/version.js
1062
- var SDK_VERSION = "1.9.0";
1062
+ var SDK_VERSION = "2.0.0";
1063
1063
 
1064
1064
  // ../sdk/dist/core/client.js
1065
1065
  function findHeaderCaseInsensitive(headers, name) {
@@ -1403,22 +1403,24 @@ var GetpepprAdapter = class {
1403
1403
  params.set("dateTo", options.dateTo);
1404
1404
  const query = params.toString() ? `?${params.toString()}` : "";
1405
1405
  const result = await this.request("GET", `/events${query}`);
1406
- const events = result.events ?? result.data ?? [];
1406
+ const events = result.data ?? [];
1407
1407
  const meta = result.meta;
1408
1408
  return {
1409
1409
  data: events.map((evt) => ({
1410
- name: String(evt.name ?? ""),
1411
- text: String(evt.text ?? ""),
1412
- notes: evt.notes ? String(evt.notes) : void 0,
1413
- createdAt: String(evt.createdAt ?? evt.created_at ?? (/* @__PURE__ */ new Date()).toISOString()),
1414
- invoice: evt.invoice,
1415
- contact: evt.contact
1410
+ id: String(evt.id ?? ""),
1411
+ eventType: String(evt.eventType ?? evt.event_type ?? ""),
1412
+ documentId: evt.documentId ?? evt.document_id ?? null,
1413
+ metadata: evt.metadata ?? null,
1414
+ createdAt: String(evt.createdAt ?? evt.created_at ?? "")
1416
1415
  })),
1417
1416
  meta: {
1418
1417
  totalCount: Number(meta?.total_count ?? meta?.totalCount ?? events.length),
1419
1418
  offset: Number(meta?.offset ?? options?.offset ?? 0),
1420
1419
  limit: Number(meta?.limit ?? options?.limit ?? 25),
1421
- hasMore: meta ? Number(meta.total_count ?? meta.totalCount) > Number(meta.offset) + Number(meta.limit) : false,
1420
+ // Prefer the gateway's authoritative has_more; fall back to computing it
1421
+ // from total_count/offset/limit so listAll() paginates correctly even if
1422
+ // a response omits the flag.
1423
+ hasMore: meta?.has_more != null || meta?.hasMore != null ? Boolean(meta.has_more ?? meta.hasMore) : Number(meta?.total_count ?? meta?.totalCount ?? 0) > Number(meta?.offset ?? options?.offset ?? 0) + Number(meta?.limit ?? options?.limit ?? 0),
1422
1424
  truncated: Boolean(meta?.truncated ?? false)
1423
1425
  }
1424
1426
  };
@@ -1912,7 +1914,7 @@ var InvoiceOperations = class {
1912
1914
  }
1913
1915
  /**
1914
1916
  * Create a draft invoice without sending it.
1915
- * Validates input client-side, then creates the invoice on B2BRouter.
1917
+ * Validates input client-side, then creates the invoice via the gateway.
1916
1918
  * Use `sendById()` to send the draft when ready.
1917
1919
  *
1918
1920
  * @example
@@ -2031,7 +2033,7 @@ ${validation.errors.map((e) => ` - ${e.field}: ${e.message}${e.suggestion ? ` (
2031
2033
  /**
2032
2034
  * Import an invoice from a file (XML, PDF, JSON).
2033
2035
  * The file is base64-encoded and sent to the gateway, which forwards it
2034
- * as multipart/form-data to B2BRouter's import endpoint.
2036
+ * as multipart/form-data to the provider's import endpoint.
2035
2037
  *
2036
2038
  * @example
2037
2039
  * ```ts
@@ -2093,7 +2095,7 @@ ${validation.errors.map((e) => ` - ${e.field}: ${e.message}${e.suggestion ? ` (
2093
2095
  }
2094
2096
  /**
2095
2097
  * Transition an invoice to a new state.
2096
- * B2BRouter validates the state machine — invalid transitions return an error.
2098
+ * The gateway validates the state machine — invalid transitions return an error.
2097
2099
  *
2098
2100
  * @example
2099
2101
  * ```ts
@@ -2164,7 +2166,7 @@ ${validation.errors.map((e) => ` - ${e.field}: ${e.message}${e.suggestion ? ` (
2164
2166
  const timeout = options?.timeout ?? 12e4;
2165
2167
  const interval = options?.interval ?? 5e3;
2166
2168
  const targets = Array.isArray(targetStatus) ? targetStatus : [targetStatus];
2167
- const terminalFailures = ["failed", "rejected"];
2169
+ const terminalFailures = ["failed", "rejected", "no_action"];
2168
2170
  const startTime = Date.now();
2169
2171
  while (true) {
2170
2172
  const result = await this.getStatus(documentId);
@@ -3088,7 +3090,7 @@ function registerInitCommand(program2) {
3088
3090
  4. Send: getpeppr send ${filename}
3089
3091
 
3090
3092
  ${pc2.dim("Sandbox note:")} this template includes VAT. To send it on a sandbox
3091
- account, first register your VAT in Settings \u2192 Peppol Identity, or set each
3093
+ account, first register your VAT on the Peppol identity page, or set each
3092
3094
  line's "vatCategory" to "O" (outside the scope of VAT) for a no-VAT test send.
3093
3095
  `);
3094
3096
  process.exit(0);
@@ -3746,7 +3748,8 @@ var TERMINAL_STATES = /* @__PURE__ */ new Set([
3746
3748
  "delivered",
3747
3749
  "accepted",
3748
3750
  "rejected",
3749
- "failed"
3751
+ "failed",
3752
+ "no_action"
3750
3753
  ]);
3751
3754
  var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
3752
3755
  async function pollUntilTerminal(client, documentId, options = {}) {
@@ -3795,7 +3798,7 @@ var API_BASE = "https://api.getpeppr.dev/v1";
3795
3798
  var LOCAL_BASE = "http://localhost:3001/api/v1";
3796
3799
  var DASHBOARD_BASE = "https://console.getpeppr.dev/invoices";
3797
3800
  function registerSendCommand(program2) {
3798
- program2.command("send").description("Send an invoice to the Peppol network via getpeppr API").argument("[file]", "optional path to invoice JSON (mutex with --to/--amount/...)").option("--prod", "target production (live keys + confirmation)").option("--local", "target localhost:3001 dev server").option("--key <key>", "override API key \u2014 for CI/scripted use only; visible in `ps` and shell history. Prefer GETPEPPR_API_KEY env var.").option("--to <peppol-id>", "recipient peppol id (e.g., 9925:BE0314595348)").option("--country <iso>", "recipient ISO 3166-1 alpha-2 country override (e.g., BE)").option("--amount <number>", "line amount in major currency units (decimal allowed)").option("--currency <iso>", "ISO 4217 currency (default EUR)").option("--desc <text>", "line description").option("--attachment", "attach the test PDF").option("--watch", "poll status until delivered (60s timeout)").option("-y, --yes", "skip --prod confirmation prompt").option("--no-validate", "skip pre-validation locally").option("--json", "output JSON").option("--quiet", "exit code only, no output").action(async (file, flags) => {
3801
+ program2.command("send").description("Send an invoice to the Peppol network via getpeppr API").argument("[file]", "optional path to invoice JSON (mutex with --to/--amount/...)").option("--prod", "target production (live keys + confirmation)").option("--local", "target localhost:3001 dev server").option("--key <key>", "override API key \u2014 for CI/scripted use only; visible in `ps` and shell history. Prefer GETPEPPR_API_KEY env var.").option("--to <peppol-id>", "recipient peppol id (e.g., 9925:BE0314595348)").option("--country <iso>", "recipient ISO 3166-1 alpha-2 country override (e.g., BE)").option("--amount <number>", "line amount in major currency units (decimal allowed)").option("--currency <iso>", "ISO 4217 currency (default EUR)").option("--desc <text>", "line description").option("--attachment", "attach the test PDF").option("--watch", "poll status until a terminal state (60s timeout)").option("-y, --yes", "skip --prod confirmation prompt").option("--no-validate", "skip pre-validation locally").option("--json", "output JSON").option("--quiet", "exit code only, no output").action(async (file, flags) => {
3799
3802
  let auth;
3800
3803
  try {
3801
3804
  auth = resolveApiKey({
@@ -3905,7 +3908,7 @@ function registerSendCommand(program2) {
3905
3908
  mode
3906
3909
  );
3907
3910
  if (output) process.stdout.write(output + "\n");
3908
- if (finalStatus === "rejected" || finalStatus === "failed") {
3911
+ if (finalStatus === "rejected" || finalStatus === "failed" || finalStatus === "no_action") {
3909
3912
  process.exit(1);
3910
3913
  }
3911
3914
  process.exit(0);