@typeship-ax/mcp 0.10.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 +11 -5
- package/README.md +16 -5
- package/api.json +8824 -3777
- package/api.md +8359 -3987
- package/dist/api-identity.d.ts.map +1 -1
- package/dist/api-identity.js +6 -1
- 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/mcp-protocol.d.ts +10 -6
- package/dist/mcp-protocol.d.ts.map +1 -1
- package/dist/mcp-protocol.js +110 -39
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +38 -18
- package/dist/ops.d.ts +5 -1
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +42 -35
- 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.map +1 -1
- package/dist/schemas.js +175 -129
- 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/server.json +3 -3
- package/src/api-identity.ts +6 -2
- 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/mcp-protocol.ts +95 -38
- package/src/mcp.ts +34 -16
- package/src/ops.ts +47 -36
- 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 +175 -129
- 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
|
@@ -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,i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"}
|
package/dist/api-identity.js
CHANGED
|
@@ -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
|
-
|
|
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
|
@@ -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
|
export interface RequestOptions {
|
|
6
6
|
/** Abort the request (composed with the per-attempt timeout). */
|
|
@@ -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,13 +87,12 @@ 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";
|
|
93
|
+
readonly target: "body" | "parameters";
|
|
84
94
|
readonly violations: Violation[];
|
|
85
|
-
constructor(direction: "request" | "response", violations: Violation[]);
|
|
95
|
+
constructor(direction: "request" | "response", violations: Violation[], target?: "body" | "parameters");
|
|
86
96
|
}
|
|
87
97
|
/**
|
|
88
98
|
* Validates against the depth-capped JSON Schema subset emitted in
|
|
@@ -91,9 +101,10 @@ export declare class ValidationError extends Error {
|
|
|
91
101
|
*/
|
|
92
102
|
export declare function validateAgainstSchema(value: unknown, schema: unknown, path: string, out: Violation[], defs?: Record<string, unknown>): void;
|
|
93
103
|
/** The request failed before a complete HTTP response arrived (network failure, timeout, abort, or truncated body). */
|
|
94
|
-
export declare class TransportError extends
|
|
104
|
+
export declare class TransportError extends SdkError {
|
|
95
105
|
readonly cause?: unknown;
|
|
96
|
-
|
|
106
|
+
readonly response?: ResponseMeta;
|
|
107
|
+
constructor(message: string, cause?: unknown, response?: ResponseMeta);
|
|
97
108
|
}
|
|
98
109
|
type ErrorCtor = new (body: any, response: ResponseMeta) => ApiError<number, unknown>;
|
|
99
110
|
export interface CoreRequest {
|
|
@@ -206,6 +217,8 @@ export declare class HttpCore {
|
|
|
206
217
|
/** The client-level value for an x-typeship-globals parameter. */
|
|
207
218
|
globalValue(name: string): unknown;
|
|
208
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>;
|
|
209
222
|
private send;
|
|
210
223
|
/**
|
|
211
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,EAAE,OAAO,CAAC;IAClB;qCACiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAElE;8CAC8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD
|
|
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,wEAA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
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
|
/** Collapse a result into its data, throwing the typed error when !ok. */
|
|
6
6
|
export function unwrap(result) {
|
|
@@ -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,31 @@ 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;
|
|
118
|
+
target;
|
|
52
119
|
violations;
|
|
53
|
-
constructor(direction, violations) {
|
|
120
|
+
constructor(direction, violations, target = "body") {
|
|
54
121
|
const shown = violations.slice(0, 3).map((v) => v.path + " " + v.message).join("; ");
|
|
55
|
-
super(direction + "
|
|
56
|
-
+ (violations.length > 3 ? " (+" + (violations.length - 3) + " more)" : "")
|
|
57
|
-
|
|
122
|
+
super(direction + " " + target + " failed schema validation: " + shown
|
|
123
|
+
+ (violations.length > 3 ? " (+" + (violations.length - 3) + " more)" : "")
|
|
124
|
+
+ ". Correct the " + (direction === "request" ? "request" : "API response or update the spec") + ".", "validation_error");
|
|
58
125
|
this.direction = direction;
|
|
126
|
+
this.target = target;
|
|
59
127
|
this.violations = violations;
|
|
60
128
|
}
|
|
61
129
|
}
|
|
@@ -93,7 +161,17 @@ export function validateAgainstSchema(value, schema, path, out, defs) {
|
|
|
93
161
|
for (const sub of s.allOf)
|
|
94
162
|
validateAgainstSchema(value, sub, path, out, defs);
|
|
95
163
|
const variants = s.anyOf ?? s.oneOf;
|
|
96
|
-
|
|
164
|
+
const discriminator = s.responseDiscriminator;
|
|
165
|
+
const tag = typeof discriminator?.propertyName === "string" && value && typeof value === "object" && !Array.isArray(value)
|
|
166
|
+
? value[discriminator.propertyName] : undefined;
|
|
167
|
+
if (typeof tag === "string") {
|
|
168
|
+
if (Object.hasOwn(discriminator.mapping, tag)) {
|
|
169
|
+
validateAgainstSchema(value, discriminator.mapping[tag], path, out, defs);
|
|
170
|
+
}
|
|
171
|
+
// Unknown variants remain raw data. Callers must handle their tag before
|
|
172
|
+
// interpreting fields or taking an action based on workflow state.
|
|
173
|
+
}
|
|
174
|
+
else if (Array.isArray(variants) && variants.length > 0) {
|
|
97
175
|
const matched = variants.some((sub) => {
|
|
98
176
|
const scratch = [];
|
|
99
177
|
validateAgainstSchema(value, sub, path, scratch, defs);
|
|
@@ -190,12 +268,13 @@ function transportFailureMessage(method, url, cause) {
|
|
|
190
268
|
return method + " " + url + " failed: " + detail;
|
|
191
269
|
}
|
|
192
270
|
/** The request failed before a complete HTTP response arrived (network failure, timeout, abort, or truncated body). */
|
|
193
|
-
export class TransportError extends
|
|
271
|
+
export class TransportError extends SdkError {
|
|
194
272
|
cause;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
273
|
+
response;
|
|
274
|
+
constructor(message, cause, response) {
|
|
275
|
+
super(message + ". Check the connection and retry.", "transport_error", response?.status ?? null, undefined, response?.requestId);
|
|
198
276
|
this.cause = cause;
|
|
277
|
+
this.response = response;
|
|
199
278
|
}
|
|
200
279
|
}
|
|
201
280
|
/** Resolve one complete alternative in spec order. Missing or incompatible
|
|
@@ -348,7 +427,7 @@ export class HttpCore {
|
|
|
348
427
|
catch (cause) {
|
|
349
428
|
const parseError = cause instanceof ResponseParseError ? cause : undefined;
|
|
350
429
|
emitResponseDebug(response, parseError?.body);
|
|
351
|
-
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)));
|
|
352
431
|
await this.config.onError?.(error, { method: req.method, path: req.path });
|
|
353
432
|
return { ok: false, error, response: parseError?.response ?? meta(response) };
|
|
354
433
|
}
|
|
@@ -394,8 +473,8 @@ export class HttpCore {
|
|
|
394
473
|
try {
|
|
395
474
|
body = await parseBody(response, req.method);
|
|
396
475
|
}
|
|
397
|
-
catch {
|
|
398
|
-
body =
|
|
476
|
+
catch (cause) {
|
|
477
|
+
body = cause instanceof ResponseParseError ? cause.body : undefined;
|
|
399
478
|
}
|
|
400
479
|
emitResponseDebug(response, body);
|
|
401
480
|
const responseMeta = meta(response, body);
|
|
@@ -413,6 +492,10 @@ export class HttpCore {
|
|
|
413
492
|
await this.config.onError?.(error, { method: req.method, path: req.path });
|
|
414
493
|
return { ok: false, error };
|
|
415
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
|
+
}
|
|
416
499
|
async send(req, timeoutMs, attempt, autoIdempotencyKey) {
|
|
417
500
|
const selected = req.security && this.config.credentials ? selectSecurity(req.security, this.config.credentials) : {};
|
|
418
501
|
const headers = {};
|
|
@@ -637,8 +720,8 @@ function meta(response, body) {
|
|
|
637
720
|
undefined,
|
|
638
721
|
};
|
|
639
722
|
}
|
|
640
|
-
/** AbortSignal.any
|
|
641
|
-
*
|
|
723
|
+
/** AbortSignal.any is missing from some web and edge runtimes; compose the
|
|
724
|
+
* signals by hand there. */
|
|
642
725
|
function composeSignals(signals) {
|
|
643
726
|
const nativeAny = AbortSignal.any;
|
|
644
727
|
if (nativeAny)
|
|
@@ -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,CAAC;IACrB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC,IAAI,CACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC3B,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAE5B,qBAAa,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CA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,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> {
|
|
@@ -51,6 +51,13 @@ export declare class UnprocessableEntityError extends ApiError<422, ErrorModelRe
|
|
|
51
51
|
export declare class RateLimitedError extends ApiError<429, ErrorModelRead> {
|
|
52
52
|
constructor(body: ErrorModelRead, response: ResponseMeta);
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* An unexpected error prevented the request from completing.
|
|
56
|
+
* Raised for HTTP 500 responses.
|
|
57
|
+
*/
|
|
58
|
+
export declare class InternalServerError extends ApiError<500, ErrorModelRead> {
|
|
59
|
+
constructor(body: ErrorModelRead, response: ResponseMeta);
|
|
60
|
+
}
|
|
54
61
|
/**
|
|
55
62
|
* Unexpected error.
|
|
56
63
|
* Raised for "default" responses.
|
|
@@ -59,28 +66,28 @@ export declare class ApiResponseError extends ApiError<number, ErrorModelRead> {
|
|
|
59
66
|
constructor(body: ErrorModelRead, response: ResponseMeta);
|
|
60
67
|
}
|
|
61
68
|
/**
|
|
62
|
-
*
|
|
63
|
-
* Raised for HTTP
|
|
69
|
+
* No such resource in this organization.
|
|
70
|
+
* Raised for HTTP 404 responses.
|
|
64
71
|
*/
|
|
65
|
-
export declare class
|
|
72
|
+
export declare class NotFoundError extends ApiError<404, ErrorModelRead> {
|
|
66
73
|
constructor(body: ErrorModelRead, response: ResponseMeta);
|
|
67
74
|
}
|
|
68
75
|
/**
|
|
69
|
-
*
|
|
70
|
-
* Raised for HTTP
|
|
76
|
+
* The plan does not include another project or the requested target configuration.
|
|
77
|
+
* Raised for HTTP 402 responses.
|
|
71
78
|
*/
|
|
72
|
-
export declare class
|
|
79
|
+
export declare class PaymentRequiredError extends ApiError<402, ErrorModelRead> {
|
|
73
80
|
constructor(body: ErrorModelRead, response: ResponseMeta);
|
|
74
81
|
}
|
|
75
82
|
/**
|
|
76
|
-
*
|
|
77
|
-
* Raised for HTTP
|
|
83
|
+
* The resource changed since the ETag supplied in If-Match. No write was applied.
|
|
84
|
+
* Raised for HTTP 412 responses.
|
|
78
85
|
*/
|
|
79
|
-
export declare class
|
|
86
|
+
export declare class PreconditionFailedError extends ApiError<412, ErrorModelRead> {
|
|
80
87
|
constructor(body: ErrorModelRead, response: ResponseMeta);
|
|
81
88
|
}
|
|
82
89
|
/**
|
|
83
|
-
*
|
|
90
|
+
* Dependent work failed while completing the request.
|
|
84
91
|
* Raised for HTTP 502 responses.
|
|
85
92
|
*/
|
|
86
93
|
export declare class BadGatewayError extends ApiError<502, 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,YAAY,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,
|
|
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,QAAQ,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7I;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBACpD,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY;CAGzD;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;gBACtD,IA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