@warmhub/cli 0.44.1 → 0.45.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.
Files changed (2) hide show
  1. package/dist/wh.js +33 -19
  2. package/package.json +1 -1
package/dist/wh.js CHANGED
@@ -19358,7 +19358,7 @@ function findSystemComponent(componentId) {
19358
19358
  // ../../packages/sdk-ts/package.json
19359
19359
  var package_default = {
19360
19360
  name: "@warmhub/sdk-ts",
19361
- version: "0.44.0",
19361
+ version: "0.44.1",
19362
19362
  private: false,
19363
19363
  type: "module",
19364
19364
  homepage: "https://docs.warmhub.ai",
@@ -19852,13 +19852,15 @@ class WarmHubError extends Error {
19852
19852
  status;
19853
19853
  hint;
19854
19854
  retryAfter;
19855
- constructor(code, message, status, hint, retryAfter) {
19855
+ backendCode;
19856
+ constructor(code, message, status, hint, retryAfter, backendCode) {
19856
19857
  super(message);
19857
19858
  this.name = "WarmHubError";
19858
19859
  this.code = code;
19859
19860
  this.status = status;
19860
19861
  this.hint = hint;
19861
19862
  this.retryAfter = retryAfter;
19863
+ this.backendCode = backendCode;
19862
19864
  }
19863
19865
  get kind() {
19864
19866
  return this.code;
@@ -19881,13 +19883,14 @@ function toWarmHubError(error) {
19881
19883
  return error.cause;
19882
19884
  }
19883
19885
  const data = error.data;
19886
+ const wireCode = data?.warmhub?.code;
19884
19887
  const message = data?.warmhub?.message ?? sanitizeErrorMessage(error.message);
19885
- return new WarmHubError(data?.warmhub?.code ?? "BACKEND", message, data?.warmhub?.status, data?.warmhub?.hint, data?.warmhub?.retryAfter);
19888
+ return new WarmHubError(wireCode ?? "BACKEND", message, data?.warmhub?.status, data?.warmhub?.hint, data?.warmhub?.retryAfter, wireCode);
19886
19889
  }
19887
19890
  if (error instanceof Error) {
19888
19891
  const warmhubLike = error;
19889
19892
  if (error.name === "WarmHubError" && typeof warmhubLike.code === "string") {
19890
- return new WarmHubError(warmhubLike.code, sanitizeErrorMessage(error.message), typeof warmhubLike.status === "number" ? warmhubLike.status : undefined, typeof warmhubLike.hint === "string" ? warmhubLike.hint : undefined, typeof warmhubLike.retryAfter === "number" ? warmhubLike.retryAfter : undefined);
19893
+ return new WarmHubError(warmhubLike.code, sanitizeErrorMessage(error.message), typeof warmhubLike.status === "number" ? warmhubLike.status : undefined, typeof warmhubLike.hint === "string" ? warmhubLike.hint : undefined, typeof warmhubLike.retryAfter === "number" ? warmhubLike.retryAfter : undefined, typeof warmhubLike.backendCode === "string" ? warmhubLike.backendCode : undefined);
19891
19894
  }
19892
19895
  if (error.name === "AbortError") {
19893
19896
  return new WarmHubError("CANCELLED", error.message);
@@ -21474,6 +21477,7 @@ class WarmHubClient {
21474
21477
  if (!response.ok) {
21475
21478
  let message = `Request failed with status ${response.status}`;
21476
21479
  let code = httpStatusToWarmHubCode(response.status);
21480
+ let backendCode;
21477
21481
  let hint;
21478
21482
  let retryAfter;
21479
21483
  try {
@@ -21483,6 +21487,7 @@ class WarmHubClient {
21483
21487
  }
21484
21488
  if (typeof body.error?.code === "string") {
21485
21489
  code = body.error.code;
21490
+ backendCode = body.error.code;
21486
21491
  }
21487
21492
  if (typeof body.error?.hint === "string") {
21488
21493
  hint = body.error.hint;
@@ -21491,7 +21496,7 @@ class WarmHubClient {
21491
21496
  retryAfter = body.error.retryAfter;
21492
21497
  }
21493
21498
  } catch {}
21494
- throw new WarmHubError(code, message, response.status, hint, retryAfter);
21499
+ throw new WarmHubError(code, message, response.status, hint, retryAfter, backendCode);
21495
21500
  }
21496
21501
  return response;
21497
21502
  }
@@ -21609,13 +21614,15 @@ class CliError extends Error {
21609
21614
  kind;
21610
21615
  cause;
21611
21616
  hint;
21617
+ backendCode;
21612
21618
  context;
21613
- constructor(code, kind, message, cause, hint, context) {
21619
+ constructor(code, kind, message, cause, hint, context, backendCode) {
21614
21620
  super(message);
21615
21621
  this.code = code;
21616
21622
  this.kind = kind;
21617
21623
  this.cause = cause;
21618
21624
  this.hint = hint;
21625
+ this.backendCode = backendCode;
21619
21626
  this.context = context;
21620
21627
  }
21621
21628
  }
@@ -21644,27 +21651,30 @@ function conflictHint(message) {
21644
21651
  function isFieldIndexErrorCode(code) {
21645
21652
  return code === "FIELD_INDEX_UNAVAILABLE" || code === "FIELD_NOT_INDEXABLE" || code === "FIELD_TYPE_AMBIGUOUS";
21646
21653
  }
21654
+ function fromWh(exit, kind, err, hint = err.hint) {
21655
+ return new CliError(exit, kind, err.message, err, hint, undefined, err.backendCode);
21656
+ }
21647
21657
  function toCliError(err) {
21648
21658
  if (err instanceof CliError)
21649
21659
  return err;
21650
21660
  if (err instanceof WarmHubError) {
21651
21661
  if (err.kind === "VALIDATION_ERROR" || err.kind === "SHAPE_MISMATCH" || err.kind === "NOT_FOUND") {
21652
- return new CliError(2 /* UserInput */, "USER_INPUT", err.message, err, err.hint);
21662
+ return fromWh(2 /* UserInput */, "USER_INPUT", err);
21653
21663
  }
21654
21664
  if (err.kind === "UNAUTHENTICATED" || err.kind === "FORBIDDEN") {
21655
- const hint = err.hint ?? unauthenticatedHint(err.message);
21656
- return new CliError(3 /* Config */, "AUTH", err.message, err, hint);
21665
+ return fromWh(3 /* Config */, "AUTH", err, err.hint ?? unauthenticatedHint(err.message));
21657
21666
  }
21658
21667
  if (isFieldIndexErrorCode(err.code)) {
21659
- return new CliError(err.code === "FIELD_NOT_INDEXABLE" ? 2 /* UserInput */ : 4 /* Backend */, err.code, err.message, err, err.hint);
21668
+ const exit = err.code === "FIELD_NOT_INDEXABLE" ? 2 /* UserInput */ : 4 /* Backend */;
21669
+ return fromWh(exit, err.code, err);
21660
21670
  }
21661
21671
  if ((err.code === "CONFLICT" || err.code === "ARCHIVED") && err.status === undefined) {
21662
- return new CliError(2 /* UserInput */, "CONFLICT", err.message, err, err.hint ?? conflictHint(err.message));
21672
+ return fromWh(2 /* UserInput */, "CONFLICT", err, err.hint ?? conflictHint(err.message));
21663
21673
  }
21664
21674
  if (err.status) {
21665
- return new CliError(4 /* Backend */, "BACKEND", err.message, err, err.hint);
21675
+ return fromWh(4 /* Backend */, "BACKEND", err);
21666
21676
  }
21667
- return new CliError(4 /* Backend */, "BACKEND", err.message, err, err.hint ?? "Check that the API URL and backend are reachable.");
21677
+ return fromWh(4 /* Backend */, "BACKEND", err, err.hint ?? "Check that the API URL and backend are reachable.");
21668
21678
  }
21669
21679
  if (err instanceof TypeError && err.message.includes("fetch")) {
21670
21680
  return new CliError(4 /* Backend */, "BACKEND", "Network error connecting to backend", err, "Check WARMHUB_API_URL or --api-url.");
@@ -21839,7 +21849,7 @@ function cliErrorFromOpFailure(failure) {
21839
21849
  const message = failure.error?.message ?? `Operation on "${failure.name}" failed`;
21840
21850
  const exit = code === "FORBIDDEN" || code === "UNAUTHENTICATED" ? 5 /* Auth */ : code === "VALIDATION_ERROR" || code === "SHAPE_MISMATCH" || code === "NOT_FOUND" || code === "KIND_MISMATCH" || code === "ALREADY_RETRACTED" || code === "CONFLICT" ? 2 /* UserInput */ : 4 /* Backend */;
21841
21851
  const kind = exit === 5 /* Auth */ ? "AUTH" : exit === 2 /* UserInput */ ? code === "CONFLICT" ? "CONFLICT" : "USER_INPUT" : "BACKEND";
21842
- return new CliError(exit, kind, message);
21852
+ return new CliError(exit, kind, message, undefined, undefined, undefined, failure.error?.code);
21843
21853
  }
21844
21854
  function cliErrorFromAllFailed(failures) {
21845
21855
  const exitPriority = (failure) => {
@@ -21878,6 +21888,7 @@ function printCliError(err, errWriter, opts = {}) {
21878
21888
  const envelope = {
21879
21889
  error: {
21880
21890
  code: err.kind,
21891
+ ...err.backendCode ? { backendCode: err.backendCode } : {},
21881
21892
  message: err.message,
21882
21893
  ...err.hint ? { hint: err.hint } : {},
21883
21894
  ...suggestions.length > 0 ? { suggestions } : {},
@@ -36056,7 +36067,7 @@ function resolveLogLevel(flags, env) {
36056
36067
  // package.json
36057
36068
  var package_default3 = {
36058
36069
  name: "@warmhub/cli",
36059
- version: "0.44.1",
36070
+ version: "0.45.0",
36060
36071
  private: false,
36061
36072
  type: "module",
36062
36073
  homepage: "https://docs.warmhub.ai",
@@ -36290,8 +36301,11 @@ async function resolveRegisteredInstall(args) {
36290
36301
  try {
36291
36302
  return await args.client.component.registry.resolve(ownerOrg, componentName, args.installRepo);
36292
36303
  } catch (error) {
36293
- if (error instanceof WarmHubError && error.kind === "NOT_FOUND") {
36294
- throw new CliError(2 /* UserInput */, "USER_INPUT", `No component registered as ${args.componentRef}`, undefined, `If you meant a local path, prefix it with ./${args.componentRef}`);
36304
+ if (error instanceof WarmHubError && error.backendCode === "NOT_FOUND") {
36305
+ throw new CliError(2 /* UserInput */, "USER_INPUT", `No component registered as ${args.componentRef}`, undefined, `If you meant a local path, prefix it with ./${args.componentRef}`, undefined, error.backendCode);
36306
+ }
36307
+ if (error instanceof WarmHubError && error.status === 404 && error.backendCode === undefined) {
36308
+ throw new CliError(4 /* Backend */, "BACKEND", error.message, error, "The backend may not expose the component-registry routes. Confirm the API URL points at a deployment that supports `wh component install`, or check for a proxy/path mismatch.");
36295
36309
  }
36296
36310
  throw toCliError2(error);
36297
36311
  }
@@ -36382,7 +36396,7 @@ async function handleRegisteredInstall(args) {
36382
36396
  });
36383
36397
  } catch (error) {
36384
36398
  if (isMissingManifestPermissionError(error)) {
36385
- throw new CliError(2 /* UserInput */, "USER_INPUT", error.message, undefined, "Ask an org owner/admin to grant the missing permissions on the install repo, then re-run install.");
36399
+ throw new CliError(2 /* UserInput */, "USER_INPUT", error.message, undefined, "Ask an org owner/admin to grant the missing permissions on the install repo, then re-run install.", undefined, error.backendCode);
36386
36400
  }
36387
36401
  throw error;
36388
36402
  }
@@ -37001,4 +37015,4 @@ if (!updateCheckSuppressedByArgv && shouldRunUpdateCheck(updateEligibility)) {
37001
37015
  var interceptedExitCode = await maybeHandleComponentShellBoundary(dispatchArgv);
37002
37016
  process.exitCode = interceptedExitCode === undefined ? await runCli(dispatchArgv, { version: package_default3.version }) : interceptedExitCode;
37003
37017
 
37004
- //# debugId=8244220EBED83FEF64756E2164756E21
37018
+ //# debugId=3F3232411E7711A864756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmhub/cli",
3
- "version": "0.44.1",
3
+ "version": "0.45.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "homepage": "https://docs.warmhub.ai",