@typeship-ax/cli 0.20.0 → 0.21.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.
Files changed (99) hide show
  1. package/AGENTS.md +3 -3
  2. package/README.md +2 -2
  3. package/api.json +7355 -6233
  4. package/api.md +332 -398
  5. package/dist/api-identity.d.ts.map +1 -1
  6. package/dist/api-identity.js +6 -1
  7. package/dist/cli.js +15 -15
  8. package/dist/core/http.d.ts +26 -14
  9. package/dist/core/http.d.ts.map +1 -1
  10. package/dist/core/http.js +90 -19
  11. package/dist/core/pagination.d.ts +8 -8
  12. package/dist/core/pagination.d.ts.map +1 -1
  13. package/dist/core/pagination.js +7 -16
  14. package/dist/errors.d.ts +4 -4
  15. package/dist/errors.d.ts.map +1 -1
  16. package/dist/errors.js +7 -7
  17. package/dist/index.d.ts +33 -19
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +37 -17
  20. package/dist/ops.d.ts +1 -1
  21. package/dist/ops.d.ts.map +1 -1
  22. package/dist/ops.js +39 -42
  23. package/dist/resources/api-keys.d.ts +10 -10
  24. package/dist/resources/api-keys.d.ts.map +1 -1
  25. package/dist/resources/api-keys.js +6 -6
  26. package/dist/resources/deliveries.d.ts +46 -0
  27. package/dist/resources/deliveries.d.ts.map +1 -0
  28. package/dist/resources/deliveries.js +70 -0
  29. package/dist/resources/drafts.d.ts +155 -0
  30. package/dist/resources/drafts.d.ts.map +1 -0
  31. package/dist/resources/drafts.js +230 -0
  32. package/dist/resources/files.d.ts +23 -0
  33. package/dist/resources/files.d.ts.map +1 -0
  34. package/dist/resources/files.js +38 -0
  35. package/dist/resources/generate.d.ts +14 -14
  36. package/dist/resources/generate.d.ts.map +1 -1
  37. package/dist/resources/generate.js +7 -7
  38. package/dist/resources/generations.d.ts +65 -21
  39. package/dist/resources/generations.d.ts.map +1 -1
  40. package/dist/resources/generations.js +67 -20
  41. package/dist/resources/organization.d.ts +18 -0
  42. package/dist/resources/organization.d.ts.map +1 -0
  43. package/dist/resources/{account.js → organization.js} +10 -10
  44. package/dist/resources/projects.d.ts +36 -126
  45. package/dist/resources/projects.d.ts.map +1 -1
  46. package/dist/resources/projects.js +21 -171
  47. package/dist/resources/publications.d.ts +46 -0
  48. package/dist/resources/publications.d.ts.map +1 -0
  49. package/dist/resources/publications.js +70 -0
  50. package/dist/resources/releases.d.ts +66 -0
  51. package/dist/resources/releases.d.ts.map +1 -0
  52. package/dist/resources/releases.js +101 -0
  53. package/dist/resources/spec-revisions.d.ts +85 -0
  54. package/dist/resources/spec-revisions.d.ts.map +1 -0
  55. package/dist/resources/spec-revisions.js +116 -0
  56. package/dist/resources/specs.d.ts +72 -0
  57. package/dist/resources/specs.d.ts.map +1 -0
  58. package/dist/resources/specs.js +107 -0
  59. package/dist/resources/targets.d.ts +42 -262
  60. package/dist/resources/targets.d.ts.map +1 -1
  61. package/dist/resources/targets.js +28 -407
  62. package/dist/schemas.d.ts.map +1 -1
  63. package/dist/schemas.js +149 -154
  64. package/dist/types.d.ts +1281 -1611
  65. package/dist/types.d.ts.map +1 -1
  66. package/dist/types.js +44 -49
  67. package/package.json +1 -1
  68. package/src/api-identity.ts +6 -2
  69. package/src/cli.ts +16 -16
  70. package/src/core/http.ts +89 -24
  71. package/src/core/pagination.ts +13 -23
  72. package/src/errors.ts +7 -7
  73. package/src/index.ts +41 -23
  74. package/src/ops.ts +40 -43
  75. package/src/resources/api-keys.ts +13 -16
  76. package/src/resources/deliveries.ts +139 -0
  77. package/src/resources/drafts.ts +422 -0
  78. package/src/resources/files.ts +68 -0
  79. package/src/resources/generate.ts +16 -19
  80. package/src/resources/generations.ts +146 -35
  81. package/src/resources/{account.ts → organization.ts} +14 -14
  82. package/src/resources/projects.ts +42 -337
  83. package/src/resources/publications.ts +139 -0
  84. package/src/resources/releases.ts +199 -0
  85. package/src/resources/spec-revisions.ts +237 -0
  86. package/src/resources/specs.ts +200 -0
  87. package/src/resources/targets.ts +57 -760
  88. package/src/schemas.ts +149 -154
  89. package/src/types.ts +1357 -1692
  90. package/dist/resources/account.d.ts +0 -18
  91. package/dist/resources/account.d.ts.map +0 -1
  92. package/dist/resources/definition-revisions.d.ts +0 -75
  93. package/dist/resources/definition-revisions.d.ts.map +0 -1
  94. package/dist/resources/definition-revisions.js +0 -142
  95. package/dist/resources/definitions.d.ts +0 -50
  96. package/dist/resources/definitions.d.ts.map +0 -1
  97. package/dist/resources/definitions.js +0 -73
  98. package/src/resources/definition-revisions.ts +0 -265
  99. package/src/resources/definitions.ts +0 -146
@@ -1 +1 @@
1
- {"version":3,"file":"api-identity.d.ts","sourceRoot":"","sources":["../src/api-identity.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,CAAC;AAClE,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AACnE,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;AACvE,MAAM,WAAW,gBAAgB;IAAG,MAAM,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC5E,MAAM,WAAW,qBAAqB;IAAG,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE;AAEpF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,MAAM,CAInF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,GAAE;IAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,GAAG,cAAc,CAKtK;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,EAA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AAM,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAQ9H;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAI9P;AACD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CASxK"}
@@ -95,7 +95,12 @@ export async function identityResult(client, operation) {
95
95
  const target = client[operation.resource];
96
96
  if (!target?.[operation.method])
97
97
  throw new Error("The configured identity operation is not available in this package.");
98
- return target[operation.method]();
98
+ try {
99
+ return { ok: true, data: await target[operation.method]() };
100
+ }
101
+ catch (error) {
102
+ return { ok: false, error: error };
103
+ }
99
104
  }
100
105
  export function verifyClientIdentity(createClient, options, operation, policy, expected) {
101
106
  if (typeof options.baseUrl !== "string")
package/dist/cli.js CHANGED
@@ -20,7 +20,7 @@ import { homedir, hostname } from "node:os";
20
20
  import { basename, join } from "node:path";
21
21
  import { fileURLToPath } from "node:url";
22
22
  import { TypeshipClient, formatDebugEvent } from "./index.js";
23
- import { validateAgainstSchema, ValidationError } from "./core/http.js";
23
+ import { asApiResult, validateAgainstSchema, ValidationError } from "./core/http.js";
24
24
  import { SCHEMAS, DEFS } from "./schemas.js";
25
25
  import { GLOBALS, OMITTED_OPS, OPS, buildArgs, findOp, missingRequired } from "./ops.js";
26
26
  import { MCP_CLIENTS, agentGuide, agentBlock, agentInstructionsFile, agentMode, bundleProperty, claimProperty, classifyApiError, collectionProperty, detectHarness, envelope, exitCodeFor, findMcpClient, installSkills, mcpConfigured, pendingClaims, recordClaim, summarizeDoctor, upsertAgentBlock, writeBundle, writeMcpConfig, } from "./cli-agent.js";
@@ -35,17 +35,17 @@ const BASIC = null;
35
35
  const EXCLUDED_OPS = 0;
36
36
  /** Generated CLI operations that are intentionally unavailable to MCP. */
37
37
  const MCP_EXCLUDED_OPS = 0;
38
- const VERSION = "0.20.0";
38
+ const VERSION = "0.21.1";
39
39
  const API_VERSION = "1.0.0";
40
40
  const SPEC_FORMAT = "openapi";
41
41
  const IDENTITY_POLICY = {};
42
42
  let LOGIN_IDENTITY;
43
- const WHOAMI = { "resource": "account", "method": "retrieve" };
43
+ const WHOAMI = null;
44
44
  const ENVIRONMENTS = {};
45
45
  const HAS_MCP = false;
46
46
  const PKG_NAME = "@typeship-ax/cli";
47
47
  const UPDATE_NOTICE = false;
48
- const API_DESCRIPTION = "Resolve an OpenAPI or GraphQL Definition, diagnose it, and keep every\nselected CLI, MCP, and SDK Target current.\n\nEvery operation but one requires a bearer credential: an organization\nAPI key from the console, or an OAuth access token carrying the operation's\nread, generate, or write capability and the organization selected during\nconsent. OAuth grants cannot switch organizations after consent. A browser\nsession is not a credential for this API. The exception is POST /generate,\nwhich works anonymously with the free plan's limits.\n\nExamples use Parcel, a fictional delivery service. Replace its domains,\nrepository names, and resource identifiers with your own. The hosted\npetstore Definition is a runnable sample.\n";
48
+ const API_DESCRIPTION = "Resolve an OpenAPI or GraphQL Spec, diagnose it, and keep every\nselected CLI, MCP, and SDK Target current.\n\nEvery operation but one requires a bearer credential: an organization\nAPI key from the console, or an OAuth access token carrying the operation's\nread, generate, or write capability and the organization selected during\nconsent. OAuth grants cannot switch organizations after consent. A browser\nsession is not a credential for this API. The exception is POST /generate,\nwhich works anonymously with the free plan's limits.\n\nExamples use Parcel, a fictional delivery service. Replace its domains,\nrepository names, and resource identifiers with your own. The hosted\npetstore Spec is a runnable sample.\n";
49
49
  const DOCS_URL_DEFAULT = "https://typeship.dev";
50
50
  const DOCS_INDEX_URL_DEFAULT = null;
51
51
  const RELAY = null;
@@ -619,7 +619,7 @@ async function startOAuthBrowserSession(parsed, clientId, timeoutMs) {
619
619
  audience: OAUTH_TOKEN_PARAMS.audience, resource: OAUTH_TOKEN_PARAMS.resource,
620
620
  organization: requestedLoginOrganization(parsed.flags),
621
621
  }, { signal: controller.signal, timeoutMs, authorize(url) {
622
- process.stderr.write("Sign in to your existing account: " + url + "\n");
622
+ process.stderr.write("Sign in with your existing credentials: " + url + "\n");
623
623
  if (isAgentMode(parsed) || parsed.flags.get("no-browser") === true)
624
624
  process.stderr.write(JSON.stringify({ event: "oauth_browser", authorization_url: url, note: "Open this URL in a browser on the same computer as the CLI." }) + "\n");
625
625
  else
@@ -814,7 +814,7 @@ async function cmdWhoami(parsed) {
814
814
  if (op) {
815
815
  const client = await makeClient(parsed.flags, op);
816
816
  const target = client[op.resource];
817
- const result = await target[op.method]();
817
+ const result = await asApiResult(target[op.method]());
818
818
  if (result.ok) {
819
819
  out(result.data ?? { ok: true });
820
820
  await flushExit(0);
@@ -1203,7 +1203,7 @@ async function cmdAuth(parsed) {
1203
1203
  if (op) {
1204
1204
  const client = await makeClient(parsed.flags, op);
1205
1205
  const target = client[op.resource];
1206
- const result = await target[op.method]();
1206
+ const result = await asApiResult(target[op.method]());
1207
1207
  if (result.ok) {
1208
1208
  if (identityConfiguration() && savedIdentity?.identity)
1209
1209
  assertApiIdentity(savedIdentity.identity.values, readApiIdentity(result.data, IDENTITY_POLICY));
@@ -1258,7 +1258,7 @@ async function cmdDoctor(parsed) {
1258
1258
  try {
1259
1259
  const client = await makeClient(parsed.flags, op);
1260
1260
  const target = client[op.resource];
1261
- const result = await target[op.method]();
1261
+ const result = await asApiResult(target[op.method]());
1262
1262
  checks.push(result.ok ? { name: "identity", ok: true, detail: op.command.join(" ") + " ok" } : { name: "identity", ok: false, detail: classifyApiError(result.error, { bin: BIN, hadCredential: true, docsUrl: DOCS_URL_DEFAULT }).message, fix: "The credential was rejected; run '" + BIN + " login' with a current one." });
1263
1263
  }
1264
1264
  catch (e) {
@@ -2022,7 +2022,7 @@ function printRoot(stream = process.stdout) {
2022
2022
  }
2023
2023
  const width = termWidth();
2024
2024
  const lines = [];
2025
- lines.push(paintOut("bold", BIN) + ": " + "typeship API" + " (v" + "1.0.0" + "), package " + "0.20.0");
2025
+ lines.push(paintOut("bold", BIN) + ": " + "typeship API" + " (v" + "1.0.0" + "), package " + "0.21.1");
2026
2026
  lines.push("");
2027
2027
  lines.push(paintOut("bold", "Usage:") + " " + BIN + " <resource> <command> [args] [--flags]");
2028
2028
  lines.push("");
@@ -2055,7 +2055,7 @@ function printRoot(stream = process.stdout) {
2055
2055
  ...(BASIC ? [BASIC.envUser, BASIC.envPass] : []),
2056
2056
  ].join(", ") || "none", width, 21));
2057
2057
  lines.push(...labeled("Endpoint env var: ", "TYPESHIP_BASE_URL", width, 18));
2058
- lines.push(...labeled("Account: ", BIN + " login | logout | whoami | auth check (stored at " + credsPath() + ")", width, 9));
2058
+ lines.push(...labeled("Sign-in: ", BIN + " login | logout | whoami | auth check (stored at " + credsPath() + ")", width, 9));
2059
2059
  lines.push(...labeled("Setup: ", BIN + " init (connect this machine)" + " | " + BIN + " config (defaults)" + (HAS_MCP || MCP_URL ? " | " + BIN + " mcp install --all (agent clients)" : "") + " | " + BIN + " doctor | " + BIN + " upgrade | " + BIN + " completion <shell>", width, 7));
2060
2060
  lines.push(...labeled("Agents: ", BIN + " agent-guide | " + BIN + " help --json | --mode agent | -y/--yes/--force | --out <dir> (JSON errors: {status, issues[{code}], next_steps})", width, 8));
2061
2061
  lines.push(...labeled("Docs: ", BIN + " docs [<resource> <command> | search <term> | read <page> | --web]", width, 6));
@@ -2388,7 +2388,7 @@ function requireOperationCredentials(op, options) {
2388
2388
  ...relevant.map((a) => "Set " + a.env + " in the environment, pass --" + a.flag + " <value>, or run '" + BIN + " login'."),
2389
2389
  ...(needsBasic && BASIC ? ["Set " + BASIC.envUser + " and " + BASIC.envPass + ", or pass --username and --password."] : []),
2390
2390
  "Supply all schemes in one alternative through " + "TYPESHIP_CREDENTIALS" + " or --credentials @<JSON-file>: " + alternatives.map((alternative) => alternative.map((option) => option.slice("credentials.".length)).join(" + ")).join(" OR ") + ".",
2391
- ] : ["Check the operation's security schemes in the API definition and regenerate with a supported, compatible alternative."],
2391
+ ] : ["Check the operation's security schemes in the API Spec and regenerate with a supported, compatible alternative."],
2392
2392
  });
2393
2393
  }
2394
2394
  function validateCredentialsInput(flags) {
@@ -2576,7 +2576,7 @@ function failOmitted(op) {
2576
2576
  return failWith({
2577
2577
  status: "action_required",
2578
2578
  code: "PLAN_LIMIT",
2579
- message: "The command '" + BIN + " " + op.command.join(" ") + "' exists in the API Definition but was omitted from this generated package by its plan limit.",
2579
+ message: "The command '" + BIN + " " + op.command.join(" ") + "' exists in the API Spec but was omitted from this generated package by its plan limit.",
2580
2580
  detail: { operation: op.tool, method: op.httpMethod, path: op.path, generated_operations: OPS.length, total_operations: OPS.length + EXCLUDED_OPS },
2581
2581
  nextSteps: ["Upgrade at https://typeship.dev/pricing and regenerate the package without the operation cap.", "Do not invent or retry an omitted command against this generated package."],
2582
2582
  });
@@ -2816,13 +2816,13 @@ async function main() {
2816
2816
  failApi(e, LAST_CLIENT_HAD_CREDENTIAL);
2817
2817
  }
2818
2818
  }
2819
- let result = await callResult;
2820
- if (result.ok && op.httpMethod === "POST" && op.path === "/projects/{project_id}/generations") {
2819
+ let result = await asApiResult(callResult);
2820
+ if (result.ok && op.httpMethod === "POST" && op.path === "/projects/{project_id}/generate") {
2821
2821
  const batch = result.data;
2822
2822
  const generations = client.generations;
2823
2823
  const completed = [];
2824
2824
  for (const generation of batch.data) {
2825
- const waited = await generations.wait(generation.id);
2825
+ const waited = await asApiResult(generations.wait(generation.id));
2826
2826
  if (!waited.ok)
2827
2827
  failApi(waited.error, LAST_CLIENT_HAD_CREDENTIAL);
2828
2828
  completed.push(waited.data);
@@ -17,7 +17,7 @@ export interface ResponseMeta {
17
17
  headers: Headers;
18
18
  /** Parsed wire body before it is narrowed to the generated response type.
19
19
  * Use this escape hatch for additive fields or variants introduced after
20
- * this generator edition. */
20
+ * this generator version. */
21
21
  rawBody?: unknown;
22
22
  /** Request identifier from the JSON response body, or from headers for
23
23
  * raw and bodyless responses. */
@@ -37,11 +37,7 @@ export interface RequestContext {
37
37
  /** 0 on the first try, increments per retry. */
38
38
  attempt: number;
39
39
  }
40
- /**
41
- * Every SDK call returns a discriminated result instead of throwing.
42
- * Narrow on `ok` and the error side is a typed union of the documented
43
- * error responses for that exact operation.
44
- */
40
+ /** Internal result used by CLI and MCP consumers of the shared core. */
45
41
  export type ApiResult<T, E> = {
46
42
  ok: true;
47
43
  data: T;
@@ -53,8 +49,23 @@ export type ApiResult<T, E> = {
53
49
  };
54
50
  /** Collapse a result into its data, throwing the typed error when !ok. */
55
51
  export declare function unwrap<T, E>(result: ApiResult<T, E>): T;
52
+ /** Adapter for generated CLI and MCP entry points that consume result objects. */
53
+ export declare function asApiResult<T>(call: PromiseLike<T>): Promise<{
54
+ ok: boolean;
55
+ data?: T;
56
+ error?: unknown;
57
+ response?: ResponseMeta;
58
+ }>;
59
+ /** Common fields on every failure. A missing response has status null. */
60
+ export declare class SdkError extends Error {
61
+ readonly code: string;
62
+ readonly status: number | null;
63
+ readonly requestId?: string;
64
+ readonly body: unknown;
65
+ constructor(message: string, code: string, status?: number | null, body?: unknown, requestId?: string);
66
+ }
56
67
  /** Base class for every HTTP error response. */
57
- export declare class ApiError<S extends number = number, B = unknown> extends Error {
68
+ export declare class ApiError<S extends number = number, B = unknown> extends SdkError {
58
69
  readonly status: S;
59
70
  readonly body: B;
60
71
  readonly response: ResponseMeta;
@@ -65,7 +76,7 @@ export declare class UnexpectedApiError extends ApiError<number, unknown> {
65
76
  constructor(status: number, body: unknown, response: ResponseMeta);
66
77
  }
67
78
  /** A successful response declared JSON but carried a body that could not be parsed. */
68
- export declare class ResponseParseError extends Error {
79
+ export declare class ResponseParseError extends SdkError {
69
80
  readonly status: number;
70
81
  readonly body: string;
71
82
  readonly response: ResponseMeta;
@@ -76,10 +87,8 @@ export interface Violation {
76
87
  path: string;
77
88
  message: string;
78
89
  }
79
- /** Request or response data did not match the spec's schema (opt-in via the
80
- * client's validate option). Never thrown: returned as the error side of
81
- * ApiResult, like every other failure. */
82
- export declare class ValidationError extends Error {
90
+ /** Request or response data did not match the spec's schema. */
91
+ export declare class ValidationError extends SdkError {
83
92
  readonly direction: "request" | "response";
84
93
  readonly target: "body" | "parameters";
85
94
  readonly violations: Violation[];
@@ -92,9 +101,10 @@ export declare class ValidationError extends Error {
92
101
  */
93
102
  export declare function validateAgainstSchema(value: unknown, schema: unknown, path: string, out: Violation[], defs?: Record<string, unknown>): void;
94
103
  /** The request failed before a complete HTTP response arrived (network failure, timeout, abort, or truncated body). */
95
- export declare class TransportError extends Error {
104
+ export declare class TransportError extends SdkError {
96
105
  readonly cause?: unknown;
97
- constructor(message: string, cause?: unknown);
106
+ readonly response?: ResponseMeta;
107
+ constructor(message: string, cause?: unknown, response?: ResponseMeta);
98
108
  }
99
109
  type ErrorCtor = new (body: any, response: ResponseMeta) => ApiError<number, unknown>;
100
110
  export interface CoreRequest {
@@ -207,6 +217,8 @@ export declare class HttpCore {
207
217
  /** The client-level value for an x-typeship-globals parameter. */
208
218
  globalValue(name: string): unknown;
209
219
  request<T, E>(req: CoreRequest): Promise<ApiResult<T, E>>;
220
+ /** SDK-facing call: resolve to the payload or throw its typed error. */
221
+ requestData<T, E>(req: CoreRequest): Promise<T>;
210
222
  private send;
211
223
  /**
212
224
  * The redirect chain, walked here instead of inside fetch, so the header
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,MAAM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AAe,CAAU;gBAG9B,MAAM,EAAE,UAAU;IAa9B,kEAAkE;IAClE,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI5B,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IA6J/D,wEAAwE;IAClE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;YAIvC,IAAI;IAoDlB;;;;;;;;;;;;OAYG;YACW,eAAe;YA+Cf,QAAQ;CAiBvB;AAOD,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAOxE;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAKtD;AA0HD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9C"}
package/dist/core/http.js CHANGED
@@ -10,14 +10,83 @@ export function unwrap(result) {
10
10
  throw result.error;
11
11
  throw new Error(String(result.error));
12
12
  }
13
+ /** Adapter for generated CLI and MCP entry points that consume result objects. */
14
+ export async function asApiResult(call) {
15
+ try {
16
+ const data = await call;
17
+ const pageResponse = data && typeof data === "object" && "response" in data
18
+ ? data.response : undefined;
19
+ const response = pageResponse ?? {
20
+ status: 0,
21
+ headers: new Headers(),
22
+ rawBody: data,
23
+ requestId: requestIdFromBody(data),
24
+ };
25
+ return { ok: true, data, response };
26
+ }
27
+ catch (error) {
28
+ const response = error && typeof error === "object" && "response" in error
29
+ ? error.response : undefined;
30
+ return { ok: false, error, response };
31
+ }
32
+ }
33
+ /** Common fields on every failure. A missing response has status null. */
34
+ export class SdkError extends Error {
35
+ code;
36
+ status;
37
+ requestId;
38
+ body;
39
+ constructor(message, code, status = null, body, requestId) {
40
+ super(message);
41
+ this.name = new.target.name;
42
+ this.code = code;
43
+ this.status = status;
44
+ this.body = body;
45
+ this.requestId = requestId;
46
+ }
47
+ }
48
+ function errorCode(body, fallback) {
49
+ if (body && typeof body === "object" && !Array.isArray(body)) {
50
+ const value = body;
51
+ const first = Array.isArray(value.errors) ? value.errors[0] : undefined;
52
+ const code = value.code ?? first?.code;
53
+ if (typeof code === "string" && code.trim())
54
+ return code;
55
+ }
56
+ return fallback;
57
+ }
58
+ function errorDetail(body) {
59
+ if (!body || typeof body !== "object" || Array.isArray(body))
60
+ return "";
61
+ const value = body;
62
+ const first = Array.isArray(value.errors) ? value.errors[0] : undefined;
63
+ const detail = value.message ?? value.error ?? value.detail ?? first?.message;
64
+ return typeof detail === "string" && detail.trim() ? ": " + detail : "";
65
+ }
66
+ function nextStep(status) {
67
+ if (status === 401)
68
+ return "Check the credential and retry.";
69
+ if (status === 403)
70
+ return "Check the credential's permissions and retry.";
71
+ if (status === 404)
72
+ return "Check the requested identifier or path.";
73
+ if (status === 409)
74
+ return "Refresh the resource and retry the change.";
75
+ if (status === 422 || status === 400)
76
+ return "Correct the request and retry.";
77
+ if (status === 429)
78
+ return "Wait before retrying the request.";
79
+ if (status >= 500)
80
+ return "Retry later; contact the API provider if this continues.";
81
+ return "Inspect the error body and correct the request before retrying.";
82
+ }
13
83
  /** Base class for every HTTP error response. */
14
- export class ApiError extends Error {
84
+ export class ApiError extends SdkError {
15
85
  status;
16
86
  body;
17
87
  response;
18
88
  constructor(message, status, body, response) {
19
- super(message);
20
- this.name = new.target.name;
89
+ super(message + errorDetail(body) + ". " + nextStep(status), errorCode(body, "http_" + status), status, body, response.requestId);
21
90
  this.status = status;
22
91
  this.body = body;
23
92
  this.response = response;
@@ -30,32 +99,29 @@ export class UnexpectedApiError extends ApiError {
30
99
  }
31
100
  }
32
101
  /** A successful response declared JSON but carried a body that could not be parsed. */
33
- export class ResponseParseError extends Error {
102
+ export class ResponseParseError extends SdkError {
34
103
  status;
35
104
  body;
36
105
  response;
37
106
  cause;
38
107
  constructor(body, response, cause) {
39
- super("HTTP " + response.status + " response body was not valid JSON");
40
- this.name = "ResponseParseError";
108
+ super("HTTP " + response.status + " response body was not valid JSON. Check the API response or contact its provider.", "response_parse_error", response.status, body, response.requestId);
41
109
  this.status = response.status;
42
110
  this.body = body;
43
111
  this.response = response;
44
112
  this.cause = cause;
45
113
  }
46
114
  }
47
- /** Request or response data did not match the spec's schema (opt-in via the
48
- * client's validate option). Never thrown: returned as the error side of
49
- * ApiResult, like every other failure. */
50
- export class ValidationError extends Error {
115
+ /** Request or response data did not match the spec's schema. */
116
+ export class ValidationError extends SdkError {
51
117
  direction;
52
118
  target;
53
119
  violations;
54
120
  constructor(direction, violations, target = "body") {
55
121
  const shown = violations.slice(0, 3).map((v) => v.path + " " + v.message).join("; ");
56
122
  super(direction + " " + target + " failed schema validation: " + shown
57
- + (violations.length > 3 ? " (+" + (violations.length - 3) + " more)" : ""));
58
- this.name = "ValidationError";
123
+ + (violations.length > 3 ? " (+" + (violations.length - 3) + " more)" : "")
124
+ + ". Correct the " + (direction === "request" ? "request" : "API response or update the spec") + ".", "validation_error");
59
125
  this.direction = direction;
60
126
  this.target = target;
61
127
  this.violations = violations;
@@ -202,12 +268,13 @@ function transportFailureMessage(method, url, cause) {
202
268
  return method + " " + url + " failed: " + detail;
203
269
  }
204
270
  /** The request failed before a complete HTTP response arrived (network failure, timeout, abort, or truncated body). */
205
- export class TransportError extends Error {
271
+ export class TransportError extends SdkError {
206
272
  cause;
207
- constructor(message, cause) {
208
- super(message);
209
- this.name = "TransportError";
273
+ response;
274
+ constructor(message, cause, response) {
275
+ super(message + ". Check the connection and retry.", "transport_error", response?.status ?? null, undefined, response?.requestId);
210
276
  this.cause = cause;
277
+ this.response = response;
211
278
  }
212
279
  }
213
280
  /** Resolve one complete alternative in spec order. Missing or incompatible
@@ -360,7 +427,7 @@ export class HttpCore {
360
427
  catch (cause) {
361
428
  const parseError = cause instanceof ResponseParseError ? cause : undefined;
362
429
  emitResponseDebug(response, parseError?.body);
363
- const error = (parseError ?? new TransportError("The response body read failed before completing", cause));
430
+ const error = (parseError ?? new TransportError("The response body read failed before completing", cause, meta(response)));
364
431
  await this.config.onError?.(error, { method: req.method, path: req.path });
365
432
  return { ok: false, error, response: parseError?.response ?? meta(response) };
366
433
  }
@@ -406,8 +473,8 @@ export class HttpCore {
406
473
  try {
407
474
  body = await parseBody(response, req.method);
408
475
  }
409
- catch {
410
- body = undefined; // error responses keep their status even if the body read aborts
476
+ catch (cause) {
477
+ body = cause instanceof ResponseParseError ? cause.body : undefined;
411
478
  }
412
479
  emitResponseDebug(response, body);
413
480
  const responseMeta = meta(response, body);
@@ -425,6 +492,10 @@ export class HttpCore {
425
492
  await this.config.onError?.(error, { method: req.method, path: req.path });
426
493
  return { ok: false, error };
427
494
  }
495
+ /** SDK-facing call: resolve to the payload or throw its typed error. */
496
+ async requestData(req) {
497
+ return unwrap(await this.request(req));
498
+ }
428
499
  async send(req, timeoutMs, attempt, autoIdempotencyKey) {
429
500
  const selected = req.security && this.config.credentials ? selectSecurity(req.security, this.config.credentials) : {};
430
501
  const headers = {};
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Auto-pagination. Generated by typeship — https://typeship.dev
3
3
  *
4
- * List operations return a PagePromise: `await` it for one page (a typed
5
- * ApiResult), or `for await` it to stream every item across every page.
4
+ * List operations return a PagePromise: `await` it for one page, or
5
+ * `for await` it to stream every item across every page.
6
6
  */
7
- import { HttpCore, type ApiResult, type CoreRequest, type ResponseMeta } from "./http.js";
7
+ import { HttpCore, type CoreRequest, type ResponseMeta } from "./http.js";
8
8
  export interface PageConfig {
9
9
  style: "cursor" | "cursorFromLastId" | "page" | "offset";
10
10
  /** Response field holding the item array ("data", "items", …). */
@@ -19,7 +19,7 @@ export interface PageConfig {
19
19
  offsetParam?: string;
20
20
  limitParam?: string;
21
21
  }
22
- type FetchPage<Item, E> = (query: Record<string, unknown>) => Promise<ApiResult<Page<Item, E>, E>>;
22
+ type FetchPage<Item, E> = (query: Record<string, unknown>) => Promise<Page<Item, E>>;
23
23
  export declare class Page<Item, E = unknown> {
24
24
  private readonly fetchPage;
25
25
  private readonly config;
@@ -37,13 +37,13 @@ export declare class Page<Item, E = unknown> {
37
37
  private looksLikeMore;
38
38
  }
39
39
  /**
40
- * Awaitable (one page, as a typed ApiResult) and async-iterable (all items,
40
+ * Awaitable (one page) and async-iterable (all items,
41
41
  * all pages). Iteration throws the operation's typed error union on failure.
42
42
  */
43
- export declare class PagePromise<Item, E> implements PromiseLike<ApiResult<Page<Item, E>, E>>, AsyncIterable<Item> {
43
+ export declare class PagePromise<Item, E> implements PromiseLike<Page<Item, E>>, AsyncIterable<Item> {
44
44
  private readonly first;
45
- constructor(first: Promise<ApiResult<Page<Item, E>, E>>);
46
- then<R1 = ApiResult<Page<Item, E>, E>, R2 = never>(onfulfilled?: ((value: ApiResult<Page<Item, E>, E>) => R1 | PromiseLike<R1>) | null, onrejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null): Promise<R1 | R2>;
45
+ constructor(first: Promise<Page<Item, E>>);
46
+ then<R1 = Page<Item, E>, R2 = never>(onfulfilled?: ((value: Page<Item, E>) => R1 | PromiseLike<R1>) | null, onrejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null): Promise<R1 | R2>;
47
47
  [Symbol.asyncIterator](): AsyncIterator<Item, void, undefined>;
48
48
  }
49
49
  export declare function paginate<Item, E>(core: HttpCore, req: CoreRequest, config: PageConfig): PagePromise<Item, E>;
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/core/pagination.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,QAAQ,GAAG,kBAAkB,GAAG,MAAM,GAAG,QAAQ,CAA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C,IAAI,EAAE,CAAC,CAAC,CAetB"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Auto-pagination. Generated by typeship — https://typeship.dev
3
3
  *
4
- * List operations return a PagePromise: `await` it for one page (a typed
5
- * ApiResult), or `for await` it to stream every item across every page.
4
+ * List operations return a PagePromise: `await` it for one page, or
5
+ * `for await` it to stream every item across every page.
6
6
  */
7
7
  export class Page {
8
8
  fetchPage;
@@ -49,11 +49,7 @@ export class Page {
49
49
  const next = this.nextPageParams();
50
50
  if (next === null)
51
51
  return null;
52
- const result = await this.fetchPage(next);
53
- if (!result.ok) {
54
- throw result.error instanceof Error ? result.error : new Error(String(result.error));
55
- }
56
- return result.data;
52
+ return this.fetchPage(next);
57
53
  }
58
54
  /** Iterate every item on this page and all following pages. */
59
55
  async *[Symbol.asyncIterator]() {
@@ -78,7 +74,7 @@ export class Page {
78
74
  }
79
75
  }
80
76
  /**
81
- * Awaitable (one page, as a typed ApiResult) and async-iterable (all items,
77
+ * Awaitable (one page) and async-iterable (all items,
82
78
  * all pages). Iteration throws the operation's typed error union on failure.
83
79
  */
84
80
  export class PagePromise {
@@ -90,11 +86,7 @@ export class PagePromise {
90
86
  return this.first.then(onfulfilled, onrejected);
91
87
  }
92
88
  async *[Symbol.asyncIterator]() {
93
- const result = await this.first;
94
- if (!result.ok) {
95
- throw result.error instanceof Error ? result.error : new Error(String(result.error));
96
- }
97
- yield* result.data;
89
+ yield* await this.first;
98
90
  }
99
91
  }
100
92
  export function paginate(core, req, config) {
@@ -103,9 +95,8 @@ export function paginate(core, req, config) {
103
95
  let nextReq = { ...req, query: params };
104
96
  const result = await core.request(nextReq);
105
97
  if (!result.ok)
106
- return result;
107
- const page = new Page(fetchPage, config, params, result.data, result.response);
108
- return { ok: true, data: page, response: result.response };
98
+ throw result.error instanceof Error ? result.error : new Error(String(result.error));
99
+ return new Page(fetchPage, config, params, result.data, result.response);
109
100
  };
110
101
  const initial = {};
111
102
  let seed = req.query ?? {};
package/dist/errors.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ApiError, type ResponseMeta } from "./core/http.js";
2
2
  import type { ErrorModelRead } from "./types.js";
3
- export { ApiError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError, type Violation, unwrap } from "./core/http.js";
3
+ export { ApiError, SdkError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError, type Violation } from "./core/http.js";
4
4
  /**
5
- * The request body, Definition source, target selection, or package name is invalid.
5
+ * The request body, Spec source, target selection, or package name is invalid.
6
6
  * Raised for HTTP 400 responses.
7
7
  */
8
8
  export declare class BadRequestError extends ApiError<400, ErrorModelRead> {
@@ -37,7 +37,7 @@ export declare class PayloadTooLargeError extends ApiError<413, ErrorModelRead>
37
37
  constructor(body: ErrorModelRead, response: ResponseMeta);
38
38
  }
39
39
  /**
40
- * The Definition could not be resolved or understood.
40
+ * The Spec could not be resolved or understood.
41
41
  * Raised for HTTP 422 responses.
42
42
  */
43
43
  export declare class UnprocessableEntityError extends ApiError<422, ErrorModelRead> {
@@ -66,7 +66,7 @@ export declare class ApiResponseError extends ApiError<number, ErrorModelRead> {
66
66
  constructor(body: ErrorModelRead, response: ResponseMeta);
67
67
  }
68
68
  /**
69
- * No such resource in this account.
69
+ * No such resource in this organization.
70
70
  * Raised for HTTP 404 responses.
71
71
  */
72
72
  export declare class NotFoundError extends ApiError<404, ErrorModelRead> {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE3I;;;GAGG;AACH,qBAAa,eAAgB,S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