@hardfin/cli 0.1.0-dev.34 → 0.1.0-dev.35

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
@@ -60,7 +60,7 @@ Everything an endpoint takes becomes a flag or an argument. No command asks for
60
60
 
61
61
  ```sh
62
62
  hardfin asset ownership create ast_4f9xk2mq7plr8stz \
63
- --customer-id cst_a1 --date 2026-09-23 --sale-price 1500.00
63
+ --customer-id 0192f7d4-3b6a-7c1e-9f2d-5a8b4c6e7d73 --date 2026-09-23 --sale-price 1500.00
64
64
 
65
65
  hardfin asset move execute create \
66
66
  --move assetId=0192f7d4-3b6a-7c1e-9f2d-5a8b4c6e7d70,originId=0192f7d4-3b6a-7c1e-9f2d-5a8b4c6e7d71,destinationId=0192f7d4-3b6a-7c1e-9f2d-5a8b4c6e7d72,shipAt=2026-09-24T10:00:00Z
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f2529e6e-d7d4-5fe2-b460-7e86ca865c25")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e0ebce65-52b6-5732-b4b2-1becfe72bdef")}catch(e){}}();
4
4
  import module from "node:module";
5
5
  //#region src/cli.ts
6
6
  module.enableCompileCache?.();
7
- process.stdout.on("error", (error) => {
8
- if (error.code === "EPIPE") process.exit(0);
7
+ for (const stream of [process.stdout, process.stderr]) stream.on("error", (error) => {
8
+ if (error.code === "EPIPE") process.exit(process.exitCode ?? 0);
9
9
  throw error;
10
10
  });
11
11
  let isCrashing = false;
@@ -14,7 +14,7 @@ process.on("unhandledRejection", (error) => void toCrash(error));
14
14
  try {
15
15
  const answer = await toQuickAnswer(process.argv.slice(2));
16
16
  if (answer === void 0) {
17
- const { toCli, toParseExitCode, wasReportAttempted } = await import("./program-DTsxnjRj.js");
17
+ const { toCli, toParseExitCode, wasReportAttempted } = await import("./program-BdRDIa3u.js");
18
18
  try {
19
19
  await toCli().parseAsync(process.argv);
20
20
  } catch (error) {
@@ -33,7 +33,7 @@ async function toCrash(error) {
33
33
  isCrashing = true;
34
34
  process.stderr.write(`error: ${error instanceof Error ? error.message : String(error)}\n`);
35
35
  try {
36
- const { toReported } = await import("./program-DTsxnjRj.js");
36
+ const { toReported } = await import("./program-BdRDIa3u.js");
37
37
  await toReported(error, false, void 0, "fatal");
38
38
  } finally {
39
39
  process.exit(1);
@@ -51,4 +51,4 @@ async function toQuickAnswer(args) {
51
51
  export {};
52
52
 
53
53
  //# sourceMappingURL=cli.js.map
54
- //# debugId=f2529e6e-d7d4-5fe2-b460-7e86ca865c25
54
+ //# debugId=e0ebce65-52b6-5732-b4b2-1becfe72bdef
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c7f8ce05-d638-5d0f-a088-655ddade6f45")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6057a656-73c2-55b1-9f09-873e3b83b368")}catch(e){}}();
4
4
  import { a as defineCommand, i as GLOBAL_FLAGS, r as ExitCode, t as toInvocation } from "./scrub-BN3gyBpR.js";
5
5
  import { n as toCompletion, t as toAnswer$1 } from "./completion-tree-rR_Rmeij.js";
6
6
  import { createRequire } from "node:module";
@@ -1157,8 +1157,8 @@ async function runApi(input) {
1157
1157
  writeFailure("invalid_arguments", "a path is required, such as /customer", input.isJSON);
1158
1158
  return ExitCode.USAGE;
1159
1159
  }
1160
- if (path.split("/").includes("..")) {
1161
- writeFailure("invalid_arguments", "a path stays inside the API, so it cannot contain ..", input.isJSON);
1160
+ if (!isInsideApi(input.resolved.settings.apiUrl, path)) {
1161
+ writeFailure("invalid_arguments", "a path stays inside the API, so it cannot climb out of it with ..", input.isJSON);
1162
1162
  return ExitCode.USAGE;
1163
1163
  }
1164
1164
  const query = toQuery$1(input.flags["field"]);
@@ -1196,6 +1196,17 @@ async function runApi(input) {
1196
1196
  throw error;
1197
1197
  }
1198
1198
  }
1199
+ /** isInsideApi reports whether a path, once parsed, still lands under the API's own path. */
1200
+ function isInsideApi(apiUrl, path) {
1201
+ try {
1202
+ const base = new URL(apiUrl);
1203
+ const target = new URL(`${apiUrl}${path.startsWith("/") ? "" : "/"}${path}`);
1204
+ const root = base.pathname.replace(/\/+$/, "");
1205
+ return target.origin === base.origin && (target.pathname === root || target.pathname.startsWith(`${root}/`));
1206
+ } catch {
1207
+ return false;
1208
+ }
1209
+ }
1199
1210
  /** toQuery folds the repeated --field flags into query parameters. */
1200
1211
  function toQuery$1(fields) {
1201
1212
  const query = new URLSearchParams();
@@ -3493,7 +3504,9 @@ function toElements(flag, values) {
3493
3504
  const key = pair.slice(0, split).trim();
3494
3505
  if (flag.element && !flag.element.includes(key)) return /* @__PURE__ */ new Error(`--${flag.name} has no field ${key}. It takes ${flag.element.join(", ")}`);
3495
3506
  if (key in element) return /* @__PURE__ */ new Error(`--${flag.name} names ${key} twice in one element, so which one it takes is not clear`);
3496
- element[key] = pair.slice(split + 1).trim();
3507
+ const value = pair.slice(split + 1).trim();
3508
+ if (flag.elementUuids?.includes(key) && !z.uuid().safeParse(value).success) return /* @__PURE__ */ new Error(`--${flag.name} needs a UUID for ${key}, such as 3f2a9c1e-5b7d-4e8a-9c21-7d4e5f6a8b90, and ${value || "nothing"} is not one`);
3509
+ element[key] = value;
3497
3510
  }
3498
3511
  elements.push(element);
3499
3512
  }
@@ -3925,6 +3938,11 @@ const commands = [
3925
3938
  "shipAt",
3926
3939
  "shipAtTimezone"
3927
3940
  ],
3941
+ elementUuids: [
3942
+ "assetId",
3943
+ "destinationId",
3944
+ "originId"
3945
+ ],
3928
3946
  schema: z.array(z.string())
3929
3947
  }]
3930
3948
  })]
@@ -3954,6 +3972,7 @@ const commands = [
3954
3972
  "id",
3955
3973
  "shipAt"
3956
3974
  ],
3975
+ elementUuids: ["assetId"],
3957
3976
  schema: z.array(z.string())
3958
3977
  }]
3959
3978
  })]
@@ -4030,6 +4049,7 @@ const commands = [
4030
4049
  valueName: "fieldId=,value=",
4031
4050
  repeatable: true,
4032
4051
  element: ["fieldId", "value"],
4052
+ elementUuids: ["fieldId"],
4033
4053
  schema: z.array(z.string())
4034
4054
  },
4035
4055
  {
@@ -5373,6 +5393,7 @@ const commands = [
5373
5393
  "order",
5374
5394
  "section"
5375
5395
  ],
5396
+ elementUuids: ["fieldId"],
5376
5397
  schema: z.array(z.string())
5377
5398
  },
5378
5399
  {
@@ -6309,5 +6330,5 @@ async function toReported(error, isJSON, resolved, level = "error") {
6309
6330
  //#endregion
6310
6331
  export { toCli, toParseExitCode, toReported, wasReportAttempted };
6311
6332
 
6312
- //# sourceMappingURL=program-DTsxnjRj.js.map
6313
- //# debugId=c7f8ce05-d638-5d0f-a088-655ddade6f45
6333
+ //# sourceMappingURL=program-BdRDIa3u.js.map
6334
+ //# debugId=6057a656-73c2-55b1-9f09-873e3b83b368
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardfin/cli",
3
- "version": "0.1.0-dev.34",
3
+ "version": "0.1.0-dev.35",
4
4
  "description": "Command line interface for the Hardfin API",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hardfin, Inc.",