@typeship-ax/mcp 0.19.0 → 0.20.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 +3 -3
- package/README.md +1 -1
- package/api.json +7440 -6316
- package/api.md +7856 -6638
- package/dist/api-identity.d.ts.map +1 -1
- package/dist/api-identity.js +6 -1
- package/dist/core/http.d.ts +26 -14
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +90 -19
- 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 +4 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -7
- package/dist/index.d.ts +33 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -17
- package/dist/mcp-protocol.js +2 -2
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +6 -5
- package/dist/ops.d.ts +1 -1
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +39 -42
- package/dist/resources/api-keys.d.ts +10 -10
- package/dist/resources/api-keys.d.ts.map +1 -1
- package/dist/resources/api-keys.js +6 -6
- 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 +14 -14
- package/dist/resources/generate.d.ts.map +1 -1
- package/dist/resources/generate.js +7 -7
- package/dist/resources/generations.d.ts +65 -21
- package/dist/resources/generations.d.ts.map +1 -1
- package/dist/resources/generations.js +67 -20
- package/dist/resources/organization.d.ts +18 -0
- package/dist/resources/organization.d.ts.map +1 -0
- package/dist/resources/{account.js → organization.js} +10 -10
- package/dist/resources/projects.d.ts +36 -126
- package/dist/resources/projects.d.ts.map +1 -1
- package/dist/resources/projects.js +21 -171
- 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 +42 -262
- package/dist/resources/targets.d.ts.map +1 -1
- package/dist/resources/targets.js +28 -407
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +143 -149
- package/dist/types.d.ts +1281 -1611
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +44 -49
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/api-identity.ts +6 -2
- package/src/core/http.ts +89 -24
- package/src/core/pagination.ts +13 -23
- package/src/errors.ts +7 -7
- package/src/index.ts +41 -23
- package/src/mcp-protocol.ts +2 -2
- package/src/mcp.ts +7 -6
- package/src/ops.ts +40 -43
- package/src/resources/api-keys.ts +13 -16
- 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 +16 -19
- package/src/resources/generations.ts +146 -35
- package/src/resources/{account.ts → organization.ts} +14 -14
- package/src/resources/projects.ts +42 -337
- 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 +57 -760
- package/src/schemas.ts +143 -149
- package/src/types.ts +1357 -1692
- package/dist/resources/account.d.ts +0 -18
- package/dist/resources/account.d.ts.map +0 -1
- package/dist/resources/definition-revisions.d.ts +0 -75
- package/dist/resources/definition-revisions.d.ts.map +0 -1
- package/dist/resources/definition-revisions.js +0 -142
- package/dist/resources/definitions.d.ts +0 -50
- package/dist/resources/definitions.d.ts.map +0 -1
- package/dist/resources/definitions.js +0 -73
- package/src/resources/definition-revisions.ts +0 -265
- 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,EAAE,MAAM,EAAE,cAAc,GAAG,WAAW,CAelF;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAIlF;AAED,qFAAqF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operation.resource];
|
|
96
96
|
if (!target?.[operation.method])
|
|
97
97
|
throw new Error("The configured identity operation is not available in this package.");
|
|
98
|
-
|
|
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/core/http.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
80
|
-
|
|
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
|
|
104
|
+
export declare class TransportError extends SdkError {
|
|
96
105
|
readonly cause?: unknown;
|
|
97
|
-
|
|
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
|
package/dist/core/http.d.ts.map
CHANGED
|
@@ -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,CAAC,EAAE,WAAW,CAAC;IACrB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB;;iCAE6B;IAC7B,OAAO,CAAC,E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a9B,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
|
|
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
|
|
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
|
|
48
|
-
|
|
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
|
-
|
|
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
|
|
271
|
+
export class TransportError extends SdkError {
|
|
206
272
|
cause;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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 =
|
|
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
|
|
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
|
-
import { HttpCore, type
|
|
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<
|
|
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
|
|
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<
|
|
43
|
+
export declare class PagePromise<Item, E> implements PromiseLike<Page<Item, E>>, AsyncIterable<Item> {
|
|
44
44
|
private readonly first;
|
|
45
|
-
constructor(first: Promise<
|
|
46
|
-
then<R1 =
|
|
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,
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/core/pagination.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,QAAQ,GAAG,kBAAkB,GAAG,MAAM,GAAG,QAAQ,CAAC;IACzD,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,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AQrE,OAAO,CAAC,aAAa;CAUtB;AAED;;;GAGG;AACH,qBAAa,WAAW,CAAC,IAAI,EAAE,CAAC,CAAE,YAAW,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC;IAC1F,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;gBACnC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAIzC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,KAAK,EACjC,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EACrE,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,GAC9D,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAIZ,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC;CAGtE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,CAAC,EAC9B,IAAI,EAAE,QAAQ,EACd,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,UAAU,GACjB,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAetB"}
|
package/dist/core/pagination.js
CHANGED
|
@@ -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
|
|
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
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
107
|
-
|
|
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
|
|
3
|
+
export { ApiError, SdkError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError, type Violation } from "./core/http.js";
|
|
4
4
|
/**
|
|
5
|
-
* The request body,
|
|
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
|
|
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
|
|
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> {
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -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,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E,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBACrD,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBACxD,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;gBACxD,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBAClD,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBACzD,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBAC5D,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBACpD,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD"}
|
package/dist/errors.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// typeship — typed error classes.
|
|
2
2
|
// Generated by typeship — https://typeship.dev
|
|
3
3
|
import { ApiError } from "./core/http.js";
|
|
4
|
-
export { ApiError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError
|
|
4
|
+
export { ApiError, SdkError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError } from "./core/http.js";
|
|
5
5
|
/**
|
|
6
|
-
* The request body,
|
|
6
|
+
* The request body, Spec source, target selection, or package name is invalid.
|
|
7
7
|
* Raised for HTTP 400 responses.
|
|
8
8
|
*/
|
|
9
9
|
export class BadRequestError extends ApiError {
|
|
10
10
|
constructor(body, response) {
|
|
11
|
-
super("The request body,
|
|
11
|
+
super("The request body, Spec source, target selection, or package name is invalid.", 400, body, response);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -48,12 +48,12 @@ export class PayloadTooLargeError extends ApiError {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* The
|
|
51
|
+
* The Spec could not be resolved or understood.
|
|
52
52
|
* Raised for HTTP 422 responses.
|
|
53
53
|
*/
|
|
54
54
|
export class UnprocessableEntityError extends ApiError {
|
|
55
55
|
constructor(body, response) {
|
|
56
|
-
super("The
|
|
56
|
+
super("The Spec could not be resolved or understood.", 422, body, response);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
@@ -85,12 +85,12 @@ export class ApiResponseError extends ApiError {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
* No such resource in this
|
|
88
|
+
* No such resource in this organization.
|
|
89
89
|
* Raised for HTTP 404 responses.
|
|
90
90
|
*/
|
|
91
91
|
export class NotFoundError extends ApiError {
|
|
92
92
|
constructor(body, response) {
|
|
93
|
-
super("No such resource in this
|
|
93
|
+
super("No such resource in this organization.", 404, body, response);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { type AuthValue, type DebugEvent, type RequestContext } from "./core/http.js";
|
|
2
2
|
import { GenerateResource } from "./resources/generate.js";
|
|
3
3
|
import { ProjectsResource } from "./resources/projects.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SpecsResource } from "./resources/specs.js";
|
|
5
|
+
import { SpecRevisionsResource } from "./resources/spec-revisions.js";
|
|
5
6
|
import { TargetsResource } from "./resources/targets.js";
|
|
7
|
+
import { DraftsResource } from "./resources/drafts.js";
|
|
8
|
+
import { ReleasesResource } from "./resources/releases.js";
|
|
9
|
+
import { DeliveriesResource } from "./resources/deliveries.js";
|
|
10
|
+
import { PublicationsResource } from "./resources/publications.js";
|
|
6
11
|
import { GenerationsResource } from "./resources/generations.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
12
|
+
import { FilesResource } from "./resources/files.js";
|
|
13
|
+
import { OrganizationResource } from "./resources/organization.js";
|
|
9
14
|
import { ApiKeysResource } from "./resources/api-keys.js";
|
|
10
15
|
/** This package's version, also sent as the `User-Agent`. */
|
|
11
|
-
export declare const VERSION = "0.
|
|
16
|
+
export declare const VERSION = "0.20.0";
|
|
12
17
|
export interface ClientOptions {
|
|
13
18
|
/** Override the server URL. Default: `https://typeship.dev/api/v1` */
|
|
14
19
|
baseUrl?: string;
|
|
@@ -18,8 +23,8 @@ export interface ClientOptions {
|
|
|
18
23
|
*/
|
|
19
24
|
bearerToken?: string | (() => string | Promise<string>);
|
|
20
25
|
/**
|
|
21
|
-
* Credentials keyed by the
|
|
22
|
-
*
|
|
26
|
+
* Credentials keyed by the Spec's security scheme names. Only one complete alternative is sent
|
|
27
|
+
* for each operation. Named values take precedence over convenience options.
|
|
23
28
|
*/
|
|
24
29
|
credentials?: {
|
|
25
30
|
"apiKey"?: AuthValue;
|
|
@@ -58,9 +63,8 @@ export interface ClientOptions {
|
|
|
58
63
|
debug?: boolean | ((event: DebugEvent) => void);
|
|
59
64
|
/**
|
|
60
65
|
* Opt-in zero-dependency runtime validation of JSON bodies against the spec's schemas: true
|
|
61
|
-
* checks requests and responses and
|
|
62
|
-
*
|
|
63
|
-
* drift the type system can't see.
|
|
66
|
+
* checks requests and responses and throws ValidationError on mismatch; mode "warn" logs via
|
|
67
|
+
* console.warn and lets the call proceed. Catches spec drift the type system can't see.
|
|
64
68
|
*/
|
|
65
69
|
validate?: boolean | {
|
|
66
70
|
requests?: boolean;
|
|
@@ -69,9 +73,9 @@ export interface ClientOptions {
|
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
75
|
/**
|
|
72
|
-
* typeship — v0.
|
|
76
|
+
* typeship — v0.20.0
|
|
73
77
|
*
|
|
74
|
-
* Resolve an OpenAPI or GraphQL
|
|
78
|
+
* Resolve an OpenAPI or GraphQL Spec, diagnose it, and keep every
|
|
75
79
|
* selected CLI, MCP, and SDK Target current.
|
|
76
80
|
*
|
|
77
81
|
* Every operation but one requires a bearer credential: an organization
|
|
@@ -83,29 +87,39 @@ export interface ClientOptions {
|
|
|
83
87
|
*
|
|
84
88
|
* Examples use Parcel, a fictional delivery service. Replace its domains,
|
|
85
89
|
* repository names, and resource identifiers with your own. The hosted
|
|
86
|
-
* petstore
|
|
90
|
+
* petstore Spec is a runnable sample.
|
|
87
91
|
*/
|
|
88
92
|
export declare class TypeshipClient {
|
|
89
93
|
readonly generate: GenerateResource;
|
|
90
94
|
readonly projects: ProjectsResource;
|
|
91
|
-
readonly
|
|
95
|
+
readonly specs: SpecsResource;
|
|
96
|
+
readonly specRevisions: SpecRevisionsResource;
|
|
92
97
|
readonly targets: TargetsResource;
|
|
98
|
+
readonly drafts: DraftsResource;
|
|
99
|
+
readonly releases: ReleasesResource;
|
|
100
|
+
readonly deliveries: DeliveriesResource;
|
|
101
|
+
readonly publications: PublicationsResource;
|
|
93
102
|
readonly generations: GenerationsResource;
|
|
94
|
-
readonly
|
|
95
|
-
readonly
|
|
103
|
+
readonly files: FilesResource;
|
|
104
|
+
readonly organization: OrganizationResource;
|
|
96
105
|
readonly apiKeys: ApiKeysResource;
|
|
97
106
|
constructor(options?: ClientOptions);
|
|
98
107
|
}
|
|
99
108
|
export * from "./types.js";
|
|
100
109
|
export * from "./errors.js";
|
|
101
|
-
export { formatDebugEvent, type
|
|
110
|
+
export { formatDebugEvent, type AuthValue, type DebugEvent, type RequestContext, type RequestOptions, type ResponseMeta, } from "./core/http.js";
|
|
102
111
|
export { Page, PagePromise } from "./core/pagination.js";
|
|
103
112
|
export * from "./resources/generate.js";
|
|
104
113
|
export * from "./resources/projects.js";
|
|
105
|
-
export * from "./resources/
|
|
114
|
+
export * from "./resources/specs.js";
|
|
115
|
+
export * from "./resources/spec-revisions.js";
|
|
106
116
|
export * from "./resources/targets.js";
|
|
117
|
+
export * from "./resources/drafts.js";
|
|
118
|
+
export * from "./resources/releases.js";
|
|
119
|
+
export * from "./resources/deliveries.js";
|
|
120
|
+
export * from "./resources/publications.js";
|
|
107
121
|
export * from "./resources/generations.js";
|
|
108
|
-
export * from "./resources/
|
|
109
|
-
export * from "./resources/
|
|
122
|
+
export * from "./resources/files.js";
|
|
123
|
+
export * from "./resources/organization.js";
|
|
110
124
|
export * from "./resources/api-keys.js";
|
|
111
125
|
//# sourceMappingURL=index.d.ts.map
|