@typeship-ax/cli 0.10.0 → 0.21.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/AGENTS.md +10 -5
- package/README.md +5 -5
- package/api.json +9773 -4501
- package/api.md +501 -271
- package/dist/api-identity.d.ts.map +1 -1
- package/dist/api-identity.js +6 -1
- package/dist/cli-agent.d.ts +5 -5
- package/dist/cli-agent.d.ts.map +1 -1
- package/dist/cli-agent.js +14 -10
- package/dist/cli.js +158 -82
- package/dist/core/http.d.ts +29 -16
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +108 -25
- package/dist/core/pagination.d.ts +8 -8
- package/dist/core/pagination.d.ts.map +1 -1
- package/dist/core/pagination.js +7 -16
- package/dist/errors.d.ts +20 -13
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +29 -20
- package/dist/index.d.ts +37 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -18
- package/dist/ops.d.ts +5 -1
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +42 -35
- package/dist/polling-login.d.ts.map +1 -1
- package/dist/polling-login.js +11 -1
- package/dist/resources/api-keys.d.ts +44 -18
- package/dist/resources/api-keys.d.ts.map +1 -1
- package/dist/resources/api-keys.js +46 -14
- package/dist/resources/deliveries.d.ts +46 -0
- package/dist/resources/deliveries.d.ts.map +1 -0
- package/dist/resources/deliveries.js +70 -0
- package/dist/resources/drafts.d.ts +155 -0
- package/dist/resources/drafts.d.ts.map +1 -0
- package/dist/resources/drafts.js +230 -0
- package/dist/resources/files.d.ts +23 -0
- package/dist/resources/files.d.ts.map +1 -0
- package/dist/resources/files.js +38 -0
- package/dist/resources/generate.d.ts +49 -20
- package/dist/resources/generate.d.ts.map +1 -1
- package/dist/resources/generate.js +56 -14
- package/dist/resources/generations.d.ts +70 -18
- package/dist/resources/generations.d.ts.map +1 -1
- package/dist/resources/generations.js +84 -16
- package/dist/resources/organization.d.ts +18 -0
- package/dist/resources/organization.d.ts.map +1 -0
- package/dist/resources/organization.js +32 -0
- package/dist/resources/projects.d.ts +87 -124
- package/dist/resources/projects.d.ts.map +1 -1
- package/dist/resources/projects.js +70 -173
- package/dist/resources/publications.d.ts +46 -0
- package/dist/resources/publications.d.ts.map +1 -0
- package/dist/resources/publications.js +70 -0
- package/dist/resources/releases.d.ts +66 -0
- package/dist/resources/releases.d.ts.map +1 -0
- package/dist/resources/releases.js +101 -0
- package/dist/resources/spec-revisions.d.ts +85 -0
- package/dist/resources/spec-revisions.d.ts.map +1 -0
- package/dist/resources/spec-revisions.js +116 -0
- package/dist/resources/specs.d.ts +72 -0
- package/dist/resources/specs.d.ts.map +1 -0
- package/dist/resources/specs.js +107 -0
- package/dist/resources/targets.d.ts +85 -105
- package/dist/resources/targets.d.ts.map +1 -1
- package/dist/resources/targets.js +70 -163
- package/dist/schemas.d.ts +1 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +194 -139
- package/dist/types.d.ts +2626 -1141
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +90 -11
- package/package.json +3 -3
- package/src/api-identity.ts +6 -2
- package/src/cli-agent.ts +17 -13
- package/src/cli.ts +145 -77
- package/src/core/http.ts +106 -30
- package/src/core/pagination.ts +13 -23
- package/src/errors.ts +30 -20
- package/src/index.ts +46 -24
- package/src/ops.ts +47 -36
- package/src/polling-login.ts +10 -1
- package/src/resources/api-keys.ts +87 -19
- package/src/resources/deliveries.ts +139 -0
- package/src/resources/drafts.ts +422 -0
- package/src/resources/files.ts +68 -0
- package/src/resources/generate.ts +81 -19
- package/src/resources/generations.ts +167 -29
- package/src/resources/organization.ts +53 -0
- package/src/resources/projects.ts +129 -322
- package/src/resources/publications.ts +139 -0
- package/src/resources/releases.ts +199 -0
- package/src/resources/spec-revisions.ts +237 -0
- package/src/resources/specs.ts +200 -0
- package/src/resources/targets.ts +135 -304
- package/src/schemas.ts +195 -140
- package/src/types.ts +2793 -1177
- package/dist/resources/account.d.ts +0 -18
- package/dist/resources/account.d.ts.map +0 -1
- package/dist/resources/account.js +0 -27
- package/dist/resources/definition-revisions.d.ts +0 -58
- package/dist/resources/definition-revisions.d.ts.map +0 -1
- package/dist/resources/definition-revisions.js +0 -114
- package/dist/resources/definitions.d.ts +0 -35
- package/dist/resources/definitions.d.ts.map +0 -1
- package/dist/resources/definitions.js +0 -60
- package/src/resources/account.ts +0 -46
- package/src/resources/definition-revisions.ts +0 -207
- package/src/resources/definitions.ts +0 -122
package/src/core/http.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime core. Generated by typeship — https://typeship.dev
|
|
3
|
-
* Zero dependencies: built on the platform fetch API (Node
|
|
3
|
+
* Zero dependencies: built on the platform fetch API (Node 20+, browsers, edge).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export interface RequestOptions {
|
|
@@ -19,7 +19,7 @@ export interface ResponseMeta {
|
|
|
19
19
|
headers: Headers;
|
|
20
20
|
/** Parsed wire body before it is narrowed to the generated response type.
|
|
21
21
|
* Use this escape hatch for additive fields or variants introduced after
|
|
22
|
-
* this generator
|
|
22
|
+
* this generator version. */
|
|
23
23
|
rawBody?: unknown;
|
|
24
24
|
/** Request identifier from the JSON response body, or from headers for
|
|
25
25
|
* raw and bodyless responses. */
|
|
@@ -43,11 +43,7 @@ export interface RequestContext {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
/**
|
|
47
|
-
* Every SDK call returns a discriminated result instead of throwing.
|
|
48
|
-
* Narrow on `ok` and the error side is a typed union of the documented
|
|
49
|
-
* error responses for that exact operation.
|
|
50
|
-
*/
|
|
46
|
+
/** Internal result used by CLI and MCP consumers of the shared core. */
|
|
51
47
|
export type ApiResult<T, E> =
|
|
52
48
|
| { ok: true; data: T; response: ResponseMeta }
|
|
53
49
|
| { ok: false; error: E; response?: ResponseMeta };
|
|
@@ -59,15 +55,80 @@ export function unwrap<T, E>(result: ApiResult<T, E>): T {
|
|
|
59
55
|
throw new Error(String(result.error));
|
|
60
56
|
}
|
|
61
57
|
|
|
58
|
+
/** Adapter for generated CLI and MCP entry points that consume result objects. */
|
|
59
|
+
export async function asApiResult<T>(call: PromiseLike<T>): Promise<{ ok: boolean; data?: T; error?: unknown; response?: ResponseMeta }> {
|
|
60
|
+
try {
|
|
61
|
+
const data = await call;
|
|
62
|
+
const pageResponse = data && typeof data === "object" && "response" in data
|
|
63
|
+
? (data as { response?: ResponseMeta }).response : undefined;
|
|
64
|
+
const response = pageResponse ?? {
|
|
65
|
+
status: 0,
|
|
66
|
+
headers: new Headers(),
|
|
67
|
+
rawBody: data,
|
|
68
|
+
requestId: requestIdFromBody(data),
|
|
69
|
+
};
|
|
70
|
+
return { ok: true, data, response };
|
|
71
|
+
} catch (error) {
|
|
72
|
+
const response = error && typeof error === "object" && "response" in error
|
|
73
|
+
? (error as { response?: ResponseMeta }).response : undefined;
|
|
74
|
+
return { ok: false, error, response };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Common fields on every failure. A missing response has status null. */
|
|
79
|
+
export class SdkError extends Error {
|
|
80
|
+
readonly code: string;
|
|
81
|
+
readonly status: number | null;
|
|
82
|
+
readonly requestId?: string;
|
|
83
|
+
readonly body: unknown;
|
|
84
|
+
|
|
85
|
+
constructor(message: string, code: string, status: number | null = null, body?: unknown, requestId?: string) {
|
|
86
|
+
super(message);
|
|
87
|
+
this.name = new.target.name;
|
|
88
|
+
this.code = code;
|
|
89
|
+
this.status = status;
|
|
90
|
+
this.body = body;
|
|
91
|
+
this.requestId = requestId;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function errorCode(body: unknown, fallback: string): string {
|
|
96
|
+
if (body && typeof body === "object" && !Array.isArray(body)) {
|
|
97
|
+
const value = body as Record<string, unknown>;
|
|
98
|
+
const first = Array.isArray(value.errors) ? value.errors[0] as { code?: unknown } | undefined : undefined;
|
|
99
|
+
const code = value.code ?? first?.code;
|
|
100
|
+
if (typeof code === "string" && code.trim()) return code;
|
|
101
|
+
}
|
|
102
|
+
return fallback;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function errorDetail(body: unknown): string {
|
|
106
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return "";
|
|
107
|
+
const value = body as Record<string, unknown>;
|
|
108
|
+
const first = Array.isArray(value.errors) ? value.errors[0] as { message?: unknown } | undefined : undefined;
|
|
109
|
+
const detail = value.message ?? value.error ?? value.detail ?? first?.message;
|
|
110
|
+
return typeof detail === "string" && detail.trim() ? ": " + detail : "";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function nextStep(status: number): string {
|
|
114
|
+
if (status === 401) return "Check the credential and retry.";
|
|
115
|
+
if (status === 403) return "Check the credential's permissions and retry.";
|
|
116
|
+
if (status === 404) return "Check the requested identifier or path.";
|
|
117
|
+
if (status === 409) return "Refresh the resource and retry the change.";
|
|
118
|
+
if (status === 422 || status === 400) return "Correct the request and retry.";
|
|
119
|
+
if (status === 429) return "Wait before retrying the request.";
|
|
120
|
+
if (status >= 500) return "Retry later; contact the API provider if this continues.";
|
|
121
|
+
return "Inspect the error body and correct the request before retrying.";
|
|
122
|
+
}
|
|
123
|
+
|
|
62
124
|
/** Base class for every HTTP error response. */
|
|
63
|
-
export class ApiError<S extends number = number, B = unknown> extends
|
|
125
|
+
export class ApiError<S extends number = number, B = unknown> extends SdkError {
|
|
64
126
|
readonly status: S;
|
|
65
127
|
readonly body: B;
|
|
66
128
|
readonly response: ResponseMeta;
|
|
67
129
|
|
|
68
130
|
constructor(message: string, status: S, body: B, response: ResponseMeta) {
|
|
69
|
-
super(message);
|
|
70
|
-
this.name = new.target.name;
|
|
131
|
+
super(message + errorDetail(body) + ". " + nextStep(status), errorCode(body, "http_" + status), status, body, response.requestId);
|
|
71
132
|
this.status = status;
|
|
72
133
|
this.body = body;
|
|
73
134
|
this.response = response;
|
|
@@ -82,15 +143,14 @@ export class UnexpectedApiError extends ApiError<number, unknown> {
|
|
|
82
143
|
}
|
|
83
144
|
|
|
84
145
|
/** A successful response declared JSON but carried a body that could not be parsed. */
|
|
85
|
-
export class ResponseParseError extends
|
|
146
|
+
export class ResponseParseError extends SdkError {
|
|
86
147
|
readonly status: number;
|
|
87
148
|
readonly body: string;
|
|
88
149
|
readonly response: ResponseMeta;
|
|
89
150
|
override readonly cause?: unknown;
|
|
90
151
|
|
|
91
152
|
constructor(body: string, response: ResponseMeta, cause?: unknown) {
|
|
92
|
-
super("HTTP " + response.status + " response body was not valid JSON");
|
|
93
|
-
this.name = "ResponseParseError";
|
|
153
|
+
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);
|
|
94
154
|
this.status = response.status;
|
|
95
155
|
this.body = body;
|
|
96
156
|
this.response = response;
|
|
@@ -105,18 +165,18 @@ export class ResponseParseError extends Error {
|
|
|
105
165
|
|
|
106
166
|
export interface Violation { path: string; message: string }
|
|
107
167
|
|
|
108
|
-
/** Request or response data did not match the spec's schema
|
|
109
|
-
|
|
110
|
-
* ApiResult, like every other failure. */
|
|
111
|
-
export class ValidationError extends Error {
|
|
168
|
+
/** Request or response data did not match the spec's schema. */
|
|
169
|
+
export class ValidationError extends SdkError {
|
|
112
170
|
readonly direction: "request" | "response";
|
|
171
|
+
readonly target: "body" | "parameters";
|
|
113
172
|
readonly violations: Violation[];
|
|
114
|
-
constructor(direction: "request" | "response", violations: Violation[]) {
|
|
173
|
+
constructor(direction: "request" | "response", violations: Violation[], target: "body" | "parameters" = "body") {
|
|
115
174
|
const shown = violations.slice(0, 3).map((v) => v.path + " " + v.message).join("; ");
|
|
116
|
-
super(direction + "
|
|
117
|
-
+ (violations.length > 3 ? " (+" + (violations.length - 3) + " more)" : "")
|
|
118
|
-
|
|
175
|
+
super(direction + " " + target + " failed schema validation: " + shown
|
|
176
|
+
+ (violations.length > 3 ? " (+" + (violations.length - 3) + " more)" : "")
|
|
177
|
+
+ ". Correct the " + (direction === "request" ? "request" : "API response or update the spec") + ".", "validation_error");
|
|
119
178
|
this.direction = direction;
|
|
179
|
+
this.target = target;
|
|
120
180
|
this.violations = violations;
|
|
121
181
|
}
|
|
122
182
|
}
|
|
@@ -153,7 +213,16 @@ export function validateAgainstSchema(value: unknown, schema: unknown, path: str
|
|
|
153
213
|
|
|
154
214
|
if (Array.isArray(s.allOf)) for (const sub of s.allOf) validateAgainstSchema(value, sub, path, out, defs);
|
|
155
215
|
const variants = s.anyOf ?? s.oneOf;
|
|
156
|
-
|
|
216
|
+
const discriminator = s.responseDiscriminator;
|
|
217
|
+
const tag = typeof discriminator?.propertyName === "string" && value && typeof value === "object" && !Array.isArray(value)
|
|
218
|
+
? (value as Record<string, unknown>)[discriminator.propertyName] : undefined;
|
|
219
|
+
if (typeof tag === "string") {
|
|
220
|
+
if (Object.hasOwn(discriminator.mapping, tag)) {
|
|
221
|
+
validateAgainstSchema(value, discriminator.mapping[tag], path, out, defs);
|
|
222
|
+
}
|
|
223
|
+
// Unknown variants remain raw data. Callers must handle their tag before
|
|
224
|
+
// interpreting fields or taking an action based on workflow state.
|
|
225
|
+
} else if (Array.isArray(variants) && variants.length > 0) {
|
|
157
226
|
const matched = variants.some((sub: unknown) => {
|
|
158
227
|
const scratch: Violation[] = [];
|
|
159
228
|
validateAgainstSchema(value, sub, path, scratch, defs);
|
|
@@ -240,13 +309,14 @@ function transportFailureMessage(method: string, url: string, cause: unknown): s
|
|
|
240
309
|
}
|
|
241
310
|
|
|
242
311
|
/** The request failed before a complete HTTP response arrived (network failure, timeout, abort, or truncated body). */
|
|
243
|
-
export class TransportError extends
|
|
312
|
+
export class TransportError extends SdkError {
|
|
244
313
|
override readonly cause?: unknown;
|
|
314
|
+
readonly response?: ResponseMeta;
|
|
245
315
|
|
|
246
|
-
constructor(message: string, cause?: unknown) {
|
|
247
|
-
super(message);
|
|
248
|
-
this.name = "TransportError";
|
|
316
|
+
constructor(message: string, cause?: unknown, response?: ResponseMeta) {
|
|
317
|
+
super(message + ". Check the connection and retry.", "transport_error", response?.status ?? null, undefined, response?.requestId);
|
|
249
318
|
this.cause = cause;
|
|
319
|
+
this.response = response;
|
|
250
320
|
}
|
|
251
321
|
}
|
|
252
322
|
|
|
@@ -510,6 +580,7 @@ export class HttpCore {
|
|
|
510
580
|
const error = (parseError ?? new TransportError(
|
|
511
581
|
"The response body read failed before completing",
|
|
512
582
|
cause,
|
|
583
|
+
meta(response),
|
|
513
584
|
)) as unknown as E;
|
|
514
585
|
await this.config.onError?.(error, { method: req.method, path: req.path });
|
|
515
586
|
return { ok: false, error, response: parseError?.response ?? meta(response) };
|
|
@@ -556,8 +627,8 @@ export class HttpCore {
|
|
|
556
627
|
let body: unknown;
|
|
557
628
|
try {
|
|
558
629
|
body = await parseBody(response, req.method);
|
|
559
|
-
} catch {
|
|
560
|
-
body =
|
|
630
|
+
} catch (cause) {
|
|
631
|
+
body = cause instanceof ResponseParseError ? cause.body : undefined;
|
|
561
632
|
}
|
|
562
633
|
emitResponseDebug(response, body);
|
|
563
634
|
const responseMeta = meta(response, body);
|
|
@@ -578,6 +649,11 @@ export class HttpCore {
|
|
|
578
649
|
return { ok: false, error };
|
|
579
650
|
}
|
|
580
651
|
|
|
652
|
+
/** SDK-facing call: resolve to the payload or throw its typed error. */
|
|
653
|
+
async requestData<T, E>(req: CoreRequest): Promise<T> {
|
|
654
|
+
return unwrap(await this.request<T, E>(req));
|
|
655
|
+
}
|
|
656
|
+
|
|
581
657
|
private async send(
|
|
582
658
|
req: CoreRequest,
|
|
583
659
|
timeoutMs: number,
|
|
@@ -806,8 +882,8 @@ function meta(response: Response, body?: unknown): ResponseMeta {
|
|
|
806
882
|
};
|
|
807
883
|
}
|
|
808
884
|
|
|
809
|
-
/** AbortSignal.any
|
|
810
|
-
*
|
|
885
|
+
/** AbortSignal.any is missing from some web and edge runtimes; compose the
|
|
886
|
+
* signals by hand there. */
|
|
811
887
|
function composeSignals(signals: AbortSignal[]): AbortSignal {
|
|
812
888
|
const nativeAny = (AbortSignal as typeof AbortSignal & { any?: (items: AbortSignal[]) => AbortSignal }).any;
|
|
813
889
|
if (nativeAny) return nativeAny.call(AbortSignal, signals);
|
package/src/core/pagination.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
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
|
|
5
|
-
*
|
|
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
|
|
|
8
8
|
import {
|
|
9
9
|
HttpCore,
|
|
10
|
-
type ApiResult,
|
|
11
10
|
type CoreRequest,
|
|
12
11
|
type ResponseMeta,
|
|
13
12
|
} from "./http.js";
|
|
@@ -29,7 +28,7 @@ export interface PageConfig {
|
|
|
29
28
|
|
|
30
29
|
type FetchPage<Item, E> = (
|
|
31
30
|
query: Record<string, unknown>,
|
|
32
|
-
) => Promise<
|
|
31
|
+
) => Promise<Page<Item, E>>;
|
|
33
32
|
|
|
34
33
|
export class Page<Item, E = unknown> {
|
|
35
34
|
private readonly fetchPage: FetchPage<Item, E>;
|
|
@@ -85,11 +84,7 @@ export class Page<Item, E = unknown> {
|
|
|
85
84
|
async getNextPage(): Promise<Page<Item, E> | null> {
|
|
86
85
|
const next = this.nextPageParams();
|
|
87
86
|
if (next === null) return null;
|
|
88
|
-
|
|
89
|
-
if (!result.ok) {
|
|
90
|
-
throw result.error instanceof Error ? result.error : new Error(String(result.error));
|
|
91
|
-
}
|
|
92
|
-
return result.data;
|
|
87
|
+
return this.fetchPage(next);
|
|
93
88
|
}
|
|
94
89
|
|
|
95
90
|
/** Iterate every item on this page and all following pages. */
|
|
@@ -114,28 +109,24 @@ export class Page<Item, E = unknown> {
|
|
|
114
109
|
}
|
|
115
110
|
|
|
116
111
|
/**
|
|
117
|
-
* Awaitable (one page
|
|
112
|
+
* Awaitable (one page) and async-iterable (all items,
|
|
118
113
|
* all pages). Iteration throws the operation's typed error union on failure.
|
|
119
114
|
*/
|
|
120
|
-
export class PagePromise<Item, E> implements PromiseLike<
|
|
121
|
-
private readonly first: Promise<
|
|
122
|
-
constructor(first: Promise<
|
|
115
|
+
export class PagePromise<Item, E> implements PromiseLike<Page<Item, E>>, AsyncIterable<Item> {
|
|
116
|
+
private readonly first: Promise<Page<Item, E>>;
|
|
117
|
+
constructor(first: Promise<Page<Item, E>>) {
|
|
123
118
|
this.first = first;
|
|
124
119
|
}
|
|
125
120
|
|
|
126
|
-
then<R1 =
|
|
127
|
-
onfulfilled?: ((value:
|
|
121
|
+
then<R1 = Page<Item, E>, R2 = never>(
|
|
122
|
+
onfulfilled?: ((value: Page<Item, E>) => R1 | PromiseLike<R1>) | null,
|
|
128
123
|
onrejected?: ((reason: unknown) => R2 | PromiseLike<R2>) | null,
|
|
129
124
|
): Promise<R1 | R2> {
|
|
130
125
|
return this.first.then(onfulfilled, onrejected);
|
|
131
126
|
}
|
|
132
127
|
|
|
133
128
|
async *[Symbol.asyncIterator](): AsyncIterator<Item, void, undefined> {
|
|
134
|
-
|
|
135
|
-
if (!result.ok) {
|
|
136
|
-
throw result.error instanceof Error ? result.error : new Error(String(result.error));
|
|
137
|
-
}
|
|
138
|
-
yield* result.data;
|
|
129
|
+
yield* await this.first;
|
|
139
130
|
}
|
|
140
131
|
}
|
|
141
132
|
|
|
@@ -149,9 +140,8 @@ export function paginate<Item, E>(
|
|
|
149
140
|
const fetchPage: FetchPage<Item, E> = async (params) => {
|
|
150
141
|
let nextReq: CoreRequest = { ...req, query: params };
|
|
151
142
|
const result = await core.request<unknown, E>(nextReq);
|
|
152
|
-
if (!result.ok)
|
|
153
|
-
|
|
154
|
-
return { ok: true, data: page, response: result.response };
|
|
143
|
+
if (!result.ok) throw result.error instanceof Error ? result.error : new Error(String(result.error));
|
|
144
|
+
return new Page<Item, E>(fetchPage, config, params, result.data, result.response);
|
|
155
145
|
};
|
|
156
146
|
const initial: Record<string, unknown> = {};
|
|
157
147
|
let seed = req.query ?? {};
|
package/src/errors.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// typeship — typed error classes.
|
|
2
|
-
// Generated by typeship — https://typeship.dev
|
|
2
|
+
// Generated by typeship — https://typeship.dev
|
|
3
3
|
|
|
4
4
|
import { ApiError, type ResponseMeta } from "./core/http.js";
|
|
5
5
|
import type { ErrorModel, ErrorModelRead } from "./types.js";
|
|
6
6
|
|
|
7
|
-
export { ApiError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError, type Violation
|
|
7
|
+
export { ApiError, SdkError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError, type Violation } from "./core/http.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* The request body,
|
|
10
|
+
* The request body, Spec source, target selection, or package name is invalid.
|
|
11
11
|
* Raised for HTTP 400 responses.
|
|
12
12
|
*/
|
|
13
13
|
export class BadRequestError extends ApiError<400, ErrorModelRead> {
|
|
14
14
|
constructor(body: ErrorModelRead, response: ResponseMeta) {
|
|
15
|
-
super("The request body,
|
|
15
|
+
super("The request body, Spec source, target selection, or package name is invalid.", 400, body, response);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -57,12 +57,12 @@ export class PayloadTooLargeError extends ApiError<413, ErrorModelRead> {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* The
|
|
60
|
+
* The Spec could not be resolved or understood.
|
|
61
61
|
* Raised for HTTP 422 responses.
|
|
62
62
|
*/
|
|
63
63
|
export class UnprocessableEntityError extends ApiError<422, ErrorModelRead> {
|
|
64
64
|
constructor(body: ErrorModelRead, response: ResponseMeta) {
|
|
65
|
-
super("The
|
|
65
|
+
super("The Spec could not be resolved or understood.", 422, body, response);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -77,6 +77,16 @@ export class RateLimitedError extends ApiError<429, ErrorModelRead> {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* An unexpected error prevented the request from completing.
|
|
82
|
+
* Raised for HTTP 500 responses.
|
|
83
|
+
*/
|
|
84
|
+
export class InternalServerError extends ApiError<500, ErrorModelRead> {
|
|
85
|
+
constructor(body: ErrorModelRead, response: ResponseMeta) {
|
|
86
|
+
super("An unexpected error prevented the request from completing.", 500, body, response);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
/**
|
|
81
91
|
* Unexpected error.
|
|
82
92
|
* Raised for "default" responses.
|
|
@@ -88,41 +98,41 @@ export class ApiResponseError extends ApiError<number, ErrorModelRead> {
|
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
/**
|
|
91
|
-
*
|
|
92
|
-
* Raised for HTTP
|
|
101
|
+
* No such resource in this organization.
|
|
102
|
+
* Raised for HTTP 404 responses.
|
|
93
103
|
*/
|
|
94
|
-
export class
|
|
104
|
+
export class NotFoundError extends ApiError<404, ErrorModelRead> {
|
|
95
105
|
constructor(body: ErrorModelRead, response: ResponseMeta) {
|
|
96
|
-
super("
|
|
106
|
+
super("No such resource in this organization.", 404, body, response);
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
|
|
100
110
|
/**
|
|
101
|
-
*
|
|
102
|
-
* Raised for HTTP
|
|
111
|
+
* The plan does not include another project or the requested target configuration.
|
|
112
|
+
* Raised for HTTP 402 responses.
|
|
103
113
|
*/
|
|
104
|
-
export class
|
|
114
|
+
export class PaymentRequiredError extends ApiError<402, ErrorModelRead> {
|
|
105
115
|
constructor(body: ErrorModelRead, response: ResponseMeta) {
|
|
106
|
-
super("
|
|
116
|
+
super("The plan does not include another project or the requested target configuration.", 402, body, response);
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
|
|
110
120
|
/**
|
|
111
|
-
*
|
|
112
|
-
* Raised for HTTP
|
|
121
|
+
* The resource changed since the ETag supplied in If-Match. No write was applied.
|
|
122
|
+
* Raised for HTTP 412 responses.
|
|
113
123
|
*/
|
|
114
|
-
export class
|
|
124
|
+
export class PreconditionFailedError extends ApiError<412, ErrorModelRead> {
|
|
115
125
|
constructor(body: ErrorModelRead, response: ResponseMeta) {
|
|
116
|
-
super("
|
|
126
|
+
super("The resource changed since the ETag supplied in If-Match. No write was applied.", 412, body, response);
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
|
|
120
130
|
/**
|
|
121
|
-
*
|
|
131
|
+
* Dependent work failed while completing the request.
|
|
122
132
|
* Raised for HTTP 502 responses.
|
|
123
133
|
*/
|
|
124
134
|
export class BadGatewayError extends ApiError<502, ErrorModelRead> {
|
|
125
135
|
constructor(body: ErrorModelRead, response: ResponseMeta) {
|
|
126
|
-
super("
|
|
136
|
+
super("Dependent work failed while completing the request.", 502, body, response);
|
|
127
137
|
}
|
|
128
138
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// typeship — client entry point.
|
|
2
|
-
// Generated by typeship — https://typeship.dev
|
|
2
|
+
// Generated by typeship — https://typeship.dev
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
HttpCore,
|
|
@@ -14,16 +14,21 @@ import { DEFS, SCHEMAS } from "./schemas.js";
|
|
|
14
14
|
|
|
15
15
|
import { GenerateResource } from "./resources/generate.js";
|
|
16
16
|
import { ProjectsResource } from "./resources/projects.js";
|
|
17
|
-
import {
|
|
17
|
+
import { SpecsResource } from "./resources/specs.js";
|
|
18
|
+
import { SpecRevisionsResource } from "./resources/spec-revisions.js";
|
|
18
19
|
import { TargetsResource } from "./resources/targets.js";
|
|
20
|
+
import { DraftsResource } from "./resources/drafts.js";
|
|
21
|
+
import { ReleasesResource } from "./resources/releases.js";
|
|
22
|
+
import { DeliveriesResource } from "./resources/deliveries.js";
|
|
23
|
+
import { PublicationsResource } from "./resources/publications.js";
|
|
19
24
|
import { GenerationsResource } from "./resources/generations.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
25
|
+
import { FilesResource } from "./resources/files.js";
|
|
26
|
+
import { OrganizationResource } from "./resources/organization.js";
|
|
22
27
|
import { ApiKeysResource } from "./resources/api-keys.js";
|
|
23
28
|
|
|
24
29
|
/** This package's version, also sent as the `User-Agent`. */
|
|
25
|
-
export const VERSION = "0.
|
|
26
|
-
const USER_AGENT = "@typeship-ax/cli/0.
|
|
30
|
+
export const VERSION = "0.21.0";
|
|
31
|
+
const USER_AGENT = "@typeship-ax/cli/0.21.0";
|
|
27
32
|
|
|
28
33
|
export interface ClientOptions {
|
|
29
34
|
/** Override the server URL. Default: `https://typeship.dev/api/v1` */
|
|
@@ -34,8 +39,8 @@ export interface ClientOptions {
|
|
|
34
39
|
*/
|
|
35
40
|
bearerToken?: string | (() => string | Promise<string>);
|
|
36
41
|
/**
|
|
37
|
-
* Credentials keyed by the
|
|
38
|
-
*
|
|
42
|
+
* Credentials keyed by the Spec's security scheme names. Only one complete alternative is sent
|
|
43
|
+
* for each operation. Named values take precedence over convenience options.
|
|
39
44
|
*/
|
|
40
45
|
credentials?: {
|
|
41
46
|
"apiKey"?: AuthValue;
|
|
@@ -71,18 +76,17 @@ export interface ClientOptions {
|
|
|
71
76
|
debug?: boolean | ((event: DebugEvent) => void);
|
|
72
77
|
/**
|
|
73
78
|
* Opt-in zero-dependency runtime validation of JSON bodies against the spec's schemas: true
|
|
74
|
-
* checks requests and responses and
|
|
75
|
-
*
|
|
76
|
-
* drift the type system can't see.
|
|
79
|
+
* checks requests and responses and throws ValidationError on mismatch; mode "warn" logs via
|
|
80
|
+
* console.warn and lets the call proceed. Catches spec drift the type system can't see.
|
|
77
81
|
*/
|
|
78
82
|
validate?: boolean | { requests?: boolean; responses?: boolean; mode?: "throw" | "warn" };
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
/**
|
|
82
|
-
* typeship — v0.
|
|
86
|
+
* typeship — v0.21.0
|
|
83
87
|
*
|
|
84
|
-
* Resolve an OpenAPI or GraphQL
|
|
85
|
-
* selected
|
|
88
|
+
* Resolve an OpenAPI or GraphQL Spec, diagnose it, and keep every
|
|
89
|
+
* selected CLI, MCP, and SDK Target current.
|
|
86
90
|
*
|
|
87
91
|
* Every operation but one requires a bearer credential: an organization
|
|
88
92
|
* API key from the console, or an OAuth access token carrying the operation's
|
|
@@ -90,15 +94,24 @@ export interface ClientOptions {
|
|
|
90
94
|
* consent. OAuth grants cannot switch organizations after consent. A browser
|
|
91
95
|
* session is not a credential for this API. The exception is POST /generate,
|
|
92
96
|
* which works anonymously with the free plan's limits.
|
|
97
|
+
*
|
|
98
|
+
* Examples use Parcel, a fictional delivery service. Replace its domains,
|
|
99
|
+
* repository names, and resource identifiers with your own. The hosted
|
|
100
|
+
* petstore Spec is a runnable sample.
|
|
93
101
|
*/
|
|
94
102
|
export class TypeshipClient {
|
|
95
103
|
readonly generate: GenerateResource;
|
|
96
104
|
readonly projects: ProjectsResource;
|
|
97
|
-
readonly
|
|
105
|
+
readonly specs: SpecsResource;
|
|
106
|
+
readonly specRevisions: SpecRevisionsResource;
|
|
98
107
|
readonly targets: TargetsResource;
|
|
108
|
+
readonly drafts: DraftsResource;
|
|
109
|
+
readonly releases: ReleasesResource;
|
|
110
|
+
readonly deliveries: DeliveriesResource;
|
|
111
|
+
readonly publications: PublicationsResource;
|
|
99
112
|
readonly generations: GenerationsResource;
|
|
100
|
-
readonly
|
|
101
|
-
readonly
|
|
113
|
+
readonly files: FilesResource;
|
|
114
|
+
readonly organization: OrganizationResource;
|
|
102
115
|
readonly apiKeys: ApiKeysResource;
|
|
103
116
|
|
|
104
117
|
constructor(options: ClientOptions = {}) {
|
|
@@ -156,11 +169,16 @@ export class TypeshipClient {
|
|
|
156
169
|
});
|
|
157
170
|
this.generate = new GenerateResource(core);
|
|
158
171
|
this.projects = new ProjectsResource(core);
|
|
159
|
-
this.
|
|
172
|
+
this.specs = new SpecsResource(core);
|
|
173
|
+
this.specRevisions = new SpecRevisionsResource(core);
|
|
160
174
|
this.targets = new TargetsResource(core);
|
|
175
|
+
this.drafts = new DraftsResource(core);
|
|
176
|
+
this.releases = new ReleasesResource(core);
|
|
177
|
+
this.deliveries = new DeliveriesResource(core);
|
|
178
|
+
this.publications = new PublicationsResource(core);
|
|
161
179
|
this.generations = new GenerationsResource(core);
|
|
162
|
-
this.
|
|
163
|
-
this.
|
|
180
|
+
this.files = new FilesResource(core);
|
|
181
|
+
this.organization = new OrganizationResource(core);
|
|
164
182
|
this.apiKeys = new ApiKeysResource(core);
|
|
165
183
|
}
|
|
166
184
|
}
|
|
@@ -169,7 +187,6 @@ export * from "./types.js";
|
|
|
169
187
|
export * from "./errors.js";
|
|
170
188
|
export {
|
|
171
189
|
formatDebugEvent,
|
|
172
|
-
type ApiResult,
|
|
173
190
|
type AuthValue,
|
|
174
191
|
type DebugEvent,
|
|
175
192
|
type RequestContext,
|
|
@@ -180,9 +197,14 @@ export { Page, PagePromise } from "./core/pagination.js";
|
|
|
180
197
|
|
|
181
198
|
export * from "./resources/generate.js";
|
|
182
199
|
export * from "./resources/projects.js";
|
|
183
|
-
export * from "./resources/
|
|
200
|
+
export * from "./resources/specs.js";
|
|
201
|
+
export * from "./resources/spec-revisions.js";
|
|
184
202
|
export * from "./resources/targets.js";
|
|
203
|
+
export * from "./resources/drafts.js";
|
|
204
|
+
export * from "./resources/releases.js";
|
|
205
|
+
export * from "./resources/deliveries.js";
|
|
206
|
+
export * from "./resources/publications.js";
|
|
185
207
|
export * from "./resources/generations.js";
|
|
186
|
-
export * from "./resources/
|
|
187
|
-
export * from "./resources/
|
|
208
|
+
export * from "./resources/files.js";
|
|
209
|
+
export * from "./resources/organization.js";
|
|
188
210
|
export * from "./resources/api-keys.js";
|