@openwop/cli 1.4.0 → 1.4.1

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/cli.js CHANGED
@@ -578,7 +578,7 @@ function errText(err) {
578
578
  // package.json
579
579
  var package_default = {
580
580
  name: "@openwop/cli",
581
- version: "1.4.0",
581
+ version: "1.4.1",
582
582
  description: "OpenWOP CLI for operating the workflow-engine demo app and OpenWOP-compatible hosts.",
583
583
  license: "Apache-2.0",
584
584
  type: "module",
@@ -4526,7 +4526,7 @@ async function runCatalogPacks(ctx, argv = []) {
4526
4526
  write(ctx.io.stdout, CATALOG_HELP);
4527
4527
  return 0;
4528
4528
  }
4529
- const res = await requestJson(ctx, "/v1/packs", { auth: false });
4529
+ const res = await catalogRead(ctx, "", { auth: false });
4530
4530
  if (ctx.json) {
4531
4531
  writeJson(ctx.io.stdout, res.body);
4532
4532
  return 0;
@@ -4535,6 +4535,14 @@ async function runCatalogPacks(ctx, argv = []) {
4535
4535
  writeLine(ctx.io.stdout, formatTable(rows, ["name", "nodes"]));
4536
4536
  return 0;
4537
4537
  }
4538
+ async function catalogRead(ctx, rest, options = {}) {
4539
+ try {
4540
+ return await requestJson(ctx, `/v1/host/openwop-app/packs${rest}`, options);
4541
+ } catch (err) {
4542
+ if (err instanceof HttpError && err.status === 404) return requestJson(ctx, `/v1/packs${rest}`, options);
4543
+ throw err;
4544
+ }
4545
+ }
4538
4546
  async function runCatalogPacksVerb(ctx, verb, argv) {
4539
4547
  const { options, positionals } = parseOptions(argv, { bool: ["--help"], value: ["--out"] });
4540
4548
  if (options.help) {
@@ -4543,7 +4551,7 @@ async function runCatalogPacksVerb(ctx, verb, argv) {
4543
4551
  }
4544
4552
  if (verb === "search") {
4545
4553
  const q = positionals[0] ?? "";
4546
- const res2 = await requestJson(ctx, `/v1/packs/-/search${q ? `?q=${encodeURIComponent(q)}` : ""}`);
4554
+ const res2 = await catalogRead(ctx, `/-/search${q ? `?q=${encodeURIComponent(q)}` : ""}`);
4547
4555
  if (ctx.json) {
4548
4556
  writeJson(ctx.io.stdout, res2.body);
4549
4557
  return 0;
@@ -4559,7 +4567,7 @@ async function runCatalogPacksVerb(ctx, verb, argv) {
4559
4567
  }
4560
4568
  if (verb === "get") {
4561
4569
  if (positionals.length !== 1) throw new CliError("Usage: openwop catalog packs get <packName> [--json]", 2);
4562
- const res2 = await requestJson(ctx, `/v1/packs/${encodeURIComponent(positionals[0])}`);
4570
+ const res2 = await catalogRead(ctx, `/${encodeURIComponent(positionals[0])}`);
4563
4571
  if (ctx.json) {
4564
4572
  writeJson(ctx.io.stdout, res2.body);
4565
4573
  return 0;
@@ -4570,7 +4578,7 @@ async function runCatalogPacksVerb(ctx, verb, argv) {
4570
4578
  for (const n of nodes) writeLine(ctx.io.stdout, ` ${n}`);
4571
4579
  return 0;
4572
4580
  }
4573
- const res = await requestJson(ctx, "/v1/packs/export");
4581
+ const res = await catalogRead(ctx, "/export");
4574
4582
  if (options.out) {
4575
4583
  writeFileSync4(String(options.out), `${JSON.stringify(res.body, null, 2)}
4576
4584
  `);
package/dist/openwop.js CHANGED
@@ -579,7 +579,7 @@ function errText(err) {
579
579
  // package.json
580
580
  var package_default = {
581
581
  name: "@openwop/cli",
582
- version: "1.4.0",
582
+ version: "1.4.1",
583
583
  description: "OpenWOP CLI for operating the workflow-engine demo app and OpenWOP-compatible hosts.",
584
584
  license: "Apache-2.0",
585
585
  type: "module",
@@ -4526,7 +4526,7 @@ async function runCatalogPacks(ctx, argv = []) {
4526
4526
  write(ctx.io.stdout, CATALOG_HELP);
4527
4527
  return 0;
4528
4528
  }
4529
- const res = await requestJson(ctx, "/v1/packs", { auth: false });
4529
+ const res = await catalogRead(ctx, "", { auth: false });
4530
4530
  if (ctx.json) {
4531
4531
  writeJson(ctx.io.stdout, res.body);
4532
4532
  return 0;
@@ -4535,6 +4535,14 @@ async function runCatalogPacks(ctx, argv = []) {
4535
4535
  writeLine(ctx.io.stdout, formatTable(rows, ["name", "nodes"]));
4536
4536
  return 0;
4537
4537
  }
4538
+ async function catalogRead(ctx, rest, options = {}) {
4539
+ try {
4540
+ return await requestJson(ctx, `/v1/host/openwop-app/packs${rest}`, options);
4541
+ } catch (err) {
4542
+ if (err instanceof HttpError && err.status === 404) return requestJson(ctx, `/v1/packs${rest}`, options);
4543
+ throw err;
4544
+ }
4545
+ }
4538
4546
  async function runCatalogPacksVerb(ctx, verb, argv) {
4539
4547
  const { options, positionals } = parseOptions(argv, { bool: ["--help"], value: ["--out"] });
4540
4548
  if (options.help) {
@@ -4543,7 +4551,7 @@ async function runCatalogPacksVerb(ctx, verb, argv) {
4543
4551
  }
4544
4552
  if (verb === "search") {
4545
4553
  const q = positionals[0] ?? "";
4546
- const res2 = await requestJson(ctx, `/v1/packs/-/search${q ? `?q=${encodeURIComponent(q)}` : ""}`);
4554
+ const res2 = await catalogRead(ctx, `/-/search${q ? `?q=${encodeURIComponent(q)}` : ""}`);
4547
4555
  if (ctx.json) {
4548
4556
  writeJson(ctx.io.stdout, res2.body);
4549
4557
  return 0;
@@ -4559,7 +4567,7 @@ async function runCatalogPacksVerb(ctx, verb, argv) {
4559
4567
  }
4560
4568
  if (verb === "get") {
4561
4569
  if (positionals.length !== 1) throw new CliError("Usage: openwop catalog packs get <packName> [--json]", 2);
4562
- const res2 = await requestJson(ctx, `/v1/packs/${encodeURIComponent(positionals[0])}`);
4570
+ const res2 = await catalogRead(ctx, `/${encodeURIComponent(positionals[0])}`);
4563
4571
  if (ctx.json) {
4564
4572
  writeJson(ctx.io.stdout, res2.body);
4565
4573
  return 0;
@@ -4570,7 +4578,7 @@ async function runCatalogPacksVerb(ctx, verb, argv) {
4570
4578
  for (const n of nodes) writeLine(ctx.io.stdout, ` ${n}`);
4571
4579
  return 0;
4572
4580
  }
4573
- const res = await requestJson(ctx, "/v1/packs/export");
4581
+ const res = await catalogRead(ctx, "/export");
4574
4582
  if (options.out) {
4575
4583
  writeFileSync4(String(options.out), `${JSON.stringify(res.body, null, 2)}
4576
4584
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openwop/cli",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "OpenWOP CLI for operating the workflow-engine demo app and OpenWOP-compatible hosts.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",