@typeship-ax/mcp 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/AGENTS.md +15 -11
  2. package/README.md +22 -53
  3. package/api.json +9998 -10118
  4. package/api.md +8983 -9120
  5. package/dist/arguments.d.ts +47 -0
  6. package/dist/arguments.d.ts.map +1 -0
  7. package/dist/arguments.js +254 -0
  8. package/dist/core/http.d.ts +162 -19
  9. package/dist/core/http.d.ts.map +1 -1
  10. package/dist/core/http.js +381 -48
  11. package/dist/core/pagination.d.ts +42 -6
  12. package/dist/core/pagination.d.ts.map +1 -1
  13. package/dist/core/pagination.js +111 -17
  14. package/dist/credential-storage.d.ts +10 -3
  15. package/dist/credential-storage.d.ts.map +1 -1
  16. package/dist/credential-storage.js +15 -6
  17. package/dist/dates.d.ts +1 -1
  18. package/dist/dates.js +1 -1
  19. package/dist/errors.d.ts +20 -84
  20. package/dist/errors.d.ts.map +1 -1
  21. package/dist/errors.js +20 -108
  22. package/dist/fields.d.ts +29 -0
  23. package/dist/fields.d.ts.map +1 -0
  24. package/dist/fields.js +101 -0
  25. package/dist/index.d.ts +28 -18
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +35 -25
  28. package/dist/mcp-authorization.d.ts.map +1 -1
  29. package/dist/mcp-authorization.js +34 -10
  30. package/dist/mcp-protocol.d.ts +87 -44
  31. package/dist/mcp-protocol.d.ts.map +1 -1
  32. package/dist/mcp-protocol.js +552 -478
  33. package/dist/mcp.d.ts.map +1 -1
  34. package/dist/mcp.js +127 -28
  35. package/dist/named-credentials.d.ts +19 -0
  36. package/dist/named-credentials.d.ts.map +1 -1
  37. package/dist/named-credentials.js +81 -1
  38. package/dist/oauth-request.d.ts +7 -1
  39. package/dist/oauth-request.d.ts.map +1 -1
  40. package/dist/oauth-request.js +26 -4
  41. package/dist/oauth-session.d.ts +13 -1
  42. package/dist/oauth-session.d.ts.map +1 -1
  43. package/dist/oauth-session.js +34 -18
  44. package/dist/ops.d.ts +53 -5
  45. package/dist/ops.d.ts.map +1 -1
  46. package/dist/ops.js +49 -40
  47. package/dist/resources/api-keys.d.ts +10 -7
  48. package/dist/resources/api-keys.d.ts.map +1 -1
  49. package/dist/resources/api-keys.js +10 -31
  50. package/dist/resources/deliveries.d.ts +88 -4
  51. package/dist/resources/deliveries.d.ts.map +1 -1
  52. package/dist/resources/deliveries.js +95 -18
  53. package/dist/resources/drafts.d.ts +15 -15
  54. package/dist/resources/drafts.d.ts.map +1 -1
  55. package/dist/resources/drafts.js +11 -64
  56. package/dist/resources/files.d.ts +4 -4
  57. package/dist/resources/files.d.ts.map +1 -1
  58. package/dist/resources/files.js +3 -12
  59. package/dist/resources/generations.d.ts +14 -14
  60. package/dist/resources/generations.d.ts.map +1 -1
  61. package/dist/resources/generations.js +21 -45
  62. package/dist/resources/organization.d.ts +4 -4
  63. package/dist/resources/organization.d.ts.map +1 -1
  64. package/dist/resources/organization.js +3 -10
  65. package/dist/resources/{generate.d.ts → packages.d.ts} +16 -16
  66. package/dist/resources/packages.d.ts.map +1 -0
  67. package/dist/resources/{generate.js → packages.js} +13 -29
  68. package/dist/resources/projects.d.ts +50 -50
  69. package/dist/resources/projects.d.ts.map +1 -1
  70. package/dist/resources/projects.js +60 -116
  71. package/dist/resources/releases.d.ts +21 -16
  72. package/dist/resources/releases.d.ts.map +1 -1
  73. package/dist/resources/releases.js +18 -39
  74. package/dist/resources/spec-revisions.d.ts +15 -6
  75. package/dist/resources/spec-revisions.d.ts.map +1 -1
  76. package/dist/resources/spec-revisions.js +6 -28
  77. package/dist/resources/specs.d.ts +7 -7
  78. package/dist/resources/specs.d.ts.map +1 -1
  79. package/dist/resources/specs.js +6 -34
  80. package/dist/resources/targets.d.ts +48 -48
  81. package/dist/resources/targets.d.ts.map +1 -1
  82. package/dist/resources/targets.js +58 -114
  83. package/dist/schemas.d.ts.map +1 -1
  84. package/dist/schemas.js +78 -76
  85. package/dist/search.d.ts +54 -0
  86. package/dist/search.d.ts.map +1 -0
  87. package/dist/search.js +421 -0
  88. package/dist/types.d.ts +499 -339
  89. package/dist/types.d.ts.map +1 -1
  90. package/dist/types.js +18 -18
  91. package/dist/worker.js +2 -2
  92. package/package.json +5 -2
  93. package/server.json +5 -5
  94. package/src/arguments.ts +242 -0
  95. package/src/core/http.ts +457 -58
  96. package/src/core/pagination.ts +129 -18
  97. package/src/credential-storage.ts +16 -6
  98. package/src/dates.ts +1 -1
  99. package/src/errors.ts +46 -115
  100. package/src/fields.ts +91 -0
  101. package/src/index.ts +45 -28
  102. package/src/mcp-authorization.ts +29 -9
  103. package/src/mcp-protocol.ts +580 -428
  104. package/src/mcp.ts +113 -26
  105. package/src/named-credentials.ts +66 -1
  106. package/src/oauth-request.ts +32 -6
  107. package/src/oauth-session.ts +37 -19
  108. package/src/ops.ts +82 -44
  109. package/src/resources/api-keys.ts +34 -48
  110. package/src/resources/deliveries.ts +211 -30
  111. package/src/resources/drafts.ts +60 -107
  112. package/src/resources/files.ts +19 -20
  113. package/src/resources/generations.ts +57 -75
  114. package/src/resources/organization.ts +11 -16
  115. package/src/resources/{generate.ts → packages.ts} +43 -51
  116. package/src/resources/projects.ts +145 -200
  117. package/src/resources/releases.ts +48 -65
  118. package/src/resources/spec-revisions.ts +38 -47
  119. package/src/resources/specs.ts +39 -59
  120. package/src/resources/targets.ts +143 -193
  121. package/src/schemas.ts +78 -76
  122. package/src/search.ts +434 -0
  123. package/src/types.ts +538 -357
  124. package/src/worker.ts +2 -2
  125. package/dist/resources/generate.d.ts.map +0 -1
  126. package/dist/resources/publications.d.ts +0 -47
  127. package/dist/resources/publications.d.ts.map +0 -1
  128. package/dist/resources/publications.js +0 -70
  129. package/src/resources/publications.ts +0 -140
package/dist/errors.js CHANGED
@@ -1,122 +1,34 @@
1
- // typeship — typed error classes.
2
- // Generated by typeship — https://typeship.dev
3
- import { ApiError } from "./core/http.js";
4
- export { ApiError, SdkError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError } from "./core/http.js";
5
- /**
6
- * The request body, Spec source, target selection, or package name is invalid.
7
- * Raised for HTTP 400 responses.
8
- */
9
- export class BadRequestError extends ApiError {
10
- constructor(body, response) {
11
- super("The request body, Spec source, target selection, or package name is invalid.", 400, body, response);
12
- }
13
- }
14
- /**
15
- * Missing, invalid, expired, or revoked credentials.
16
- * Raised for HTTP 401 responses.
17
- */
18
- export class UnauthorizedError extends ApiError {
19
- constructor(body, response) {
20
- super("Missing, invalid, expired, or revoked credentials.", 401, body, response);
21
- }
22
- }
23
- /**
24
- * The credentials are valid but cannot act on the requested organization.
25
- * Raised for HTTP 403 responses.
26
- */
27
- export class ForbiddenError extends ApiError {
1
+ // Typeship — typed error classes.
2
+ // Generated by Typeship — https://typeship.dev
3
+ import { ApiError, RateLimitError, ServerError } from "./core/http.js";
4
+ export { ApiError, SdkError, PayloadError, ResponseParseError, TransportError, UnexpectedApiError, ValidationError, BadRequestError, ConflictError, ForbiddenError, NotFoundError, NotModifiedError, RateLimitError, ServerError, UnauthorizedError, UnprocessableEntityError, } from "./core/http.js";
5
+ /** Raised for HTTP 402 responses. */
6
+ export class PaymentRequiredError extends ApiError {
28
7
  constructor(body, response) {
29
- super("The credentials are valid but cannot act on the requested organization.", 403, body, response);
8
+ super("HTTP 402", 402, body, response);
30
9
  }
31
10
  }
32
- /**
33
- * The key identifies changed intent.
34
- * Raised for HTTP 409 responses.
35
- */
36
- export class ConflictError extends ApiError {
11
+ /** @deprecated Use RateLimitError, raised for every 429 response. */
12
+ export const RateLimitedError = RateLimitError;
13
+ /** @deprecated Use ServerError, raised for every 5xx response. */
14
+ export const InternalServerError = ServerError;
15
+ /** Raised for HTTP 412 responses. */
16
+ export class PreconditionFailedError extends ApiError {
37
17
  constructor(body, response) {
38
- super("The key identifies changed intent.", 409, body, response);
18
+ super("HTTP 412", 412, body, response);
39
19
  }
40
20
  }
41
- /**
42
- * Spec exceeds the 10MB limit.
43
- * Raised for HTTP 413 responses.
44
- */
21
+ /** @deprecated Use ServerError, raised for every 5xx response. */
22
+ export const BadGatewayError = ServerError;
23
+ /** Raised for HTTP 413 responses. */
45
24
  export class PayloadTooLargeError extends ApiError {
46
25
  constructor(body, response) {
47
- super("Spec exceeds the 10MB limit.", 413, body, response);
26
+ super("HTTP 413", 413, body, response);
48
27
  }
49
28
  }
50
- /**
51
- * The Spec could not be resolved or understood.
52
- * Raised for HTTP 422 responses.
53
- */
54
- export class UnprocessableEntityError extends ApiError {
55
- constructor(body, response) {
56
- super("The Spec could not be resolved or understood.", 422, body, response);
57
- }
58
- }
59
- /**
60
- * Too many requests, or an identical write is still in progress. Wait for Retry-After before
61
- * retrying.
62
- * Raised for HTTP 429 responses.
63
- */
64
- export class RateLimitedError extends ApiError {
65
- constructor(body, response) {
66
- super("Too many requests, or an identical write is still in progress. Wait for Retry-After before retrying.", 429, body, response);
67
- }
68
- }
69
- /**
70
- * An unexpected error prevented the request from completing.
71
- * Raised for HTTP 500 responses.
72
- */
73
- export class InternalServerError extends ApiError {
74
- constructor(body, response) {
75
- super("An unexpected error prevented the request from completing.", 500, body, response);
76
- }
77
- }
78
- /**
79
- * Unexpected error.
80
- * Raised for "default" responses.
81
- */
29
+ /** Raised for "default" responses. */
82
30
  export class ApiResponseError extends ApiError {
83
31
  constructor(body, response) {
84
- super("Unexpected error.", response.status, body, response);
85
- }
86
- }
87
- /**
88
- * No such resource in this organization.
89
- * Raised for HTTP 404 responses.
90
- */
91
- export class NotFoundError extends ApiError {
92
- constructor(body, response) {
93
- super("No such resource in this organization.", 404, body, response);
94
- }
95
- }
96
- /**
97
- * The plan does not include another project or the requested target configuration.
98
- * Raised for HTTP 402 responses.
99
- */
100
- export class PaymentRequiredError extends ApiError {
101
- constructor(body, response) {
102
- super("The plan does not include another project or the requested target configuration.", 402, body, response);
103
- }
104
- }
105
- /**
106
- * The resource changed since the ETag supplied in If-Match. No write was applied.
107
- * Raised for HTTP 412 responses.
108
- */
109
- export class PreconditionFailedError extends ApiError {
110
- constructor(body, response) {
111
- super("The resource changed since the ETag supplied in If-Match. No write was applied.", 412, body, response);
112
- }
113
- }
114
- /**
115
- * Dependent work failed while completing the request.
116
- * Raised for HTTP 502 responses.
117
- */
118
- export class BadGatewayError extends ApiError {
119
- constructor(body, response) {
120
- super("Dependent work failed while completing the request.", 502, body, response);
32
+ super("HTTP " + response.status, response.status, body, response);
121
33
  }
122
34
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Result projection shared by the generated CLI (--fields) and MCP server
3
+ * (the fields argument). Generated by Typeship — https://typeship.dev
4
+ */
5
+ /** Keep only `paths` of a value: arrays item by item, objects by dotted
6
+ * path, including paths through arrays (`items.id` keeps each item's id);
7
+ * scalars untouched. */
8
+ export declare function projectFields(value: unknown, paths: string[][] | null): unknown;
9
+ /** A requested path that selected nothing, with the keys that exist where
10
+ * it stopped matching. */
11
+ export interface UnmatchedField {
12
+ path: string;
13
+ /** Keys present at the level where the path failed, first 40. */
14
+ available: string[];
15
+ /** The path segment that is not a key there, or null when the path runs
16
+ * into a scalar or the result is not an object. */
17
+ missing: string | null;
18
+ }
19
+ /**
20
+ * The paths that match nothing in any item of `value`. A path matches when
21
+ * at least one item has it; reaching null or an empty array counts as a
22
+ * match, because the path may be right and the values merely empty. An
23
+ * empty result matches everything.
24
+ */
25
+ export declare function unmatchedFields(value: unknown, paths: string[][]): UnmatchedField[];
26
+ /** The error message: the call went through, and for each unmatched path,
27
+ * what exists instead. */
28
+ export declare function unmatchedFieldsMessage(unmatched: UnmatchedField[], perItem: boolean): string;
29
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;wBAEwB;AACxB,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,GAAG,OAAO,CAkB/E;AAED;0BAC0B;AAC1B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB;uDACmD;IACnD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,cAAc,EAAE,CASnF;AAyBD;0BAC0B;AAC1B,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAS5F"}
package/dist/fields.js ADDED
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Result projection shared by the generated CLI (--fields) and MCP server
3
+ * (the fields argument). Generated by Typeship — https://typeship.dev
4
+ */
5
+ /** Keep only `paths` of a value: arrays item by item, objects by dotted
6
+ * path, including paths through arrays (`items.id` keeps each item's id);
7
+ * scalars untouched. */
8
+ export function projectFields(value, paths) {
9
+ if (paths === null)
10
+ return value;
11
+ if (Array.isArray(value))
12
+ return value.map((v) => projectFields(v, paths));
13
+ if (value === null || typeof value !== "object")
14
+ return value;
15
+ const groups = new Map();
16
+ for (const [key, ...rest] of paths) {
17
+ if (key === undefined)
18
+ continue;
19
+ const group = groups.get(key);
20
+ if (group)
21
+ group.push(rest);
22
+ else
23
+ groups.set(key, [rest]);
24
+ }
25
+ const out = {};
26
+ for (const [key, rests] of groups) {
27
+ const child = value[key];
28
+ if (child === undefined)
29
+ continue;
30
+ if (rests.some((rest) => rest.length === 0))
31
+ out[key] = child;
32
+ else if (child !== null && typeof child === "object")
33
+ out[key] = projectFields(child, rests);
34
+ }
35
+ return out;
36
+ }
37
+ /**
38
+ * The paths that match nothing in any item of `value`. A path matches when
39
+ * at least one item has it; reaching null or an empty array counts as a
40
+ * match, because the path may be right and the values merely empty. An
41
+ * empty result matches everything.
42
+ */
43
+ export function unmatchedFields(value, paths) {
44
+ const out = [];
45
+ for (const path of paths) {
46
+ const miss = { depth: -1, keys: new Set(), segment: null };
47
+ if (!pathMatches(value, path, 0, miss)) {
48
+ out.push({ path: path.join("."), available: [...miss.keys].slice(0, 40), missing: miss.segment });
49
+ }
50
+ }
51
+ return out;
52
+ }
53
+ function pathMatches(value, path, index, miss) {
54
+ if (value === null || value === undefined)
55
+ return true;
56
+ if (Array.isArray(value)) {
57
+ if (value.length === 0)
58
+ return true;
59
+ let any = false;
60
+ for (const item of value)
61
+ if (pathMatches(item, path, index, miss))
62
+ any = true;
63
+ return any;
64
+ }
65
+ if (index === path.length)
66
+ return true;
67
+ if (typeof value !== "object") {
68
+ if (miss.depth < index) {
69
+ miss.depth = index;
70
+ miss.keys = new Set();
71
+ miss.segment = null;
72
+ }
73
+ return false;
74
+ }
75
+ const key = path[index];
76
+ const record = value;
77
+ if (!Object.hasOwn(record, key)) {
78
+ if (miss.depth < index) {
79
+ miss.depth = index;
80
+ miss.keys = new Set();
81
+ miss.segment = key;
82
+ }
83
+ if (miss.depth === index)
84
+ for (const k of Object.keys(record))
85
+ miss.keys.add(k);
86
+ return false;
87
+ }
88
+ return pathMatches(record[key], path, index + 1, miss);
89
+ }
90
+ /** The error message: the call went through, and for each unmatched path,
91
+ * what exists instead. */
92
+ export function unmatchedFieldsMessage(unmatched, perItem) {
93
+ return "The API call succeeded, but " + unmatched.map((u, index) => {
94
+ const where = perItem ? " in any item" : " in the result";
95
+ const why = u.missing !== null
96
+ ? " (\"" + u.missing + "\" is not a key there)"
97
+ : " (it runs into a value that is not an object)";
98
+ const keys = u.available.length > 0 ? " Available keys: " + u.available.join(", ") + "." : "";
99
+ return (index === 0 ? "the" : "The") + " field path \"" + u.path + "\" matched nothing" + where + why + "." + keys;
100
+ }).join(" ");
101
+ }
package/dist/index.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  import { type AuthValue, type DebugEvent, type RequestContext } from "./core/http.js";
2
- import { GenerateResource } from "./resources/generate.js";
3
2
  import { ProjectsResource } from "./resources/projects.js";
4
3
  import { SpecsResource } from "./resources/specs.js";
5
4
  import { SpecRevisionsResource } from "./resources/spec-revisions.js";
6
5
  import { TargetsResource } from "./resources/targets.js";
7
- import { DraftsResource } from "./resources/drafts.js";
8
- import { ReleasesResource } from "./resources/releases.js";
9
6
  import { DeliveriesResource } from "./resources/deliveries.js";
10
- import { PublicationsResource } from "./resources/publications.js";
11
7
  import { GenerationsResource } from "./resources/generations.js";
8
+ import { DraftsResource } from "./resources/drafts.js";
9
+ import { ReleasesResource } from "./resources/releases.js";
12
10
  import { FilesResource } from "./resources/files.js";
11
+ import { PackagesResource } from "./resources/packages.js";
13
12
  import { OrganizationResource } from "./resources/organization.js";
14
13
  import { ApiKeysResource } from "./resources/api-keys.js";
15
14
  /** This package's version, also sent as the `User-Agent`. */
16
- export declare const VERSION = "0.21.0";
15
+ export declare const VERSION = "0.22.0";
17
16
  export interface ClientOptions {
18
17
  /** Override the server URL. Default: `https://typeship.dev/api/v1` */
19
18
  baseUrl?: string;
20
19
  /**
21
20
  * Sent as `Authorization: Bearer <token>`. Pass a callback for tokens that expire; it is resolved
22
- * before every attempt.
21
+ * before every attempt, and after a 401 it is called once more with `{ rejected: true }` so it
22
+ * can refresh instead of returning the rejected token.
23
23
  */
24
- bearerToken?: string | (() => string | Promise<string>);
24
+ bearerToken?: AuthValue;
25
25
  /**
26
26
  * Credentials keyed by the Spec's security scheme names. Only one complete alternative is sent
27
27
  * for each operation. Named values take precedence over convenience options.
@@ -29,10 +29,15 @@ export interface ClientOptions {
29
29
  credentials?: {
30
30
  "apiKey"?: AuthValue;
31
31
  };
32
- /** Per-attempt timeout in milliseconds. Default: 30000. */
32
+ /** Per-attempt timeout in milliseconds. Default: 60000. */
33
33
  timeoutMs?: number;
34
34
  /** Retries after the first attempt (retryable failures only). Default: 2. */
35
35
  maxRetries?: number;
36
+ /**
37
+ * The longest wait a server may request (Retry-After, x-ratelimit-reset) that a retry honors; a
38
+ * longer one fails the call with the reset time. Default: 60000.
39
+ */
40
+ maxRetryWaitMs?: number;
36
41
  /** Custom fetch implementation (proxies, testing, instrumentation). */
37
42
  fetch?: typeof fetch;
38
43
  /** Headers sent with every request. */
@@ -73,7 +78,7 @@ export interface ClientOptions {
73
78
  };
74
79
  }
75
80
  /**
76
- * typeship — v0.21.0
81
+ * Typeship — v0.22.0
77
82
  *
78
83
  * Resolve an OpenAPI or GraphQL Spec, diagnose it, and keep every
79
84
  * selected CLI, MCP, and SDK Target current.
@@ -90,36 +95,41 @@ export interface ClientOptions {
90
95
  * petstore Spec is a runnable sample.
91
96
  */
92
97
  export declare class TypeshipClient {
93
- readonly generate: GenerateResource;
94
98
  readonly projects: ProjectsResource;
95
99
  readonly specs: SpecsResource;
96
100
  readonly specRevisions: SpecRevisionsResource;
97
101
  readonly targets: TargetsResource;
98
- readonly drafts: DraftsResource;
99
- readonly releases: ReleasesResource;
100
102
  readonly deliveries: DeliveriesResource;
101
- readonly publications: PublicationsResource;
102
103
  readonly generations: GenerationsResource;
104
+ readonly drafts: DraftsResource;
105
+ readonly releases: ReleasesResource;
103
106
  readonly files: FilesResource;
107
+ readonly packages: PackagesResource;
104
108
  readonly organization: OrganizationResource;
105
109
  readonly apiKeys: ApiKeysResource;
110
+ private readonly _options;
106
111
  constructor(options?: ClientOptions);
112
+ /**
113
+ * A client with this client's configuration and only these credentials,
114
+ * for a server acting on behalf of many users. Nothing is inherited from
115
+ * this client's credentials. The copy shares the configured fetch.
116
+ */
117
+ withCredentials(credentials: Pick<ClientOptions, "bearerToken" | "credentials">): TypeshipClient;
107
118
  }
108
119
  export * from "./types.js";
109
120
  export * from "./errors.js";
110
- export { formatDebugEvent, type AuthValue, type DebugEvent, type RequestContext, type RequestOptions, type ResponseMeta, } from "./core/http.js";
121
+ export { formatDebugEvent, type AuthValue, type CredentialContext, type DebugEvent, type RequestContext, type RequestOptions, type ResponseMeta, } from "./core/http.js";
111
122
  export { Page, PagePromise } from "./core/pagination.js";
112
- export * from "./resources/generate.js";
113
123
  export * from "./resources/projects.js";
114
124
  export * from "./resources/specs.js";
115
125
  export * from "./resources/spec-revisions.js";
116
126
  export * from "./resources/targets.js";
117
- export * from "./resources/drafts.js";
118
- export * from "./resources/releases.js";
119
127
  export * from "./resources/deliveries.js";
120
- export * from "./resources/publications.js";
121
128
  export * from "./resources/generations.js";
129
+ export * from "./resources/drafts.js";
130
+ export * from "./resources/releases.js";
122
131
  export * from "./resources/files.js";
132
+ export * from "./resources/packages.js";
123
133
  export * from "./resources/organization.js";
124
134
  export * from "./resources/api-keys.js";
125
135
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,SAAS,EAEd,KAAK,UAAU,EACf,KAAK,cAAc,EAEpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,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AAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;gBAE7B,OAAO,GAAE,aAAkB;IAsEvC;;;;OAIG;IACH,eAAe,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,CAAC,GAAG,cAAc;CAKjG;AAED,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEzD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,25 +1,23 @@
1
- // typeship — client entry point.
2
- // Generated by typeship — https://typeship.dev
1
+ // Typeship — client entry point.
2
+ // Generated by Typeship — https://typeship.dev
3
3
  import { HttpCore, formatDebugEvent, bearerAuth, } from "./core/http.js";
4
- import { DEFS, SCHEMAS } from "./schemas.js";
5
- import { GenerateResource } from "./resources/generate.js";
6
4
  import { ProjectsResource } from "./resources/projects.js";
7
5
  import { SpecsResource } from "./resources/specs.js";
8
6
  import { SpecRevisionsResource } from "./resources/spec-revisions.js";
9
7
  import { TargetsResource } from "./resources/targets.js";
10
- import { DraftsResource } from "./resources/drafts.js";
11
- import { ReleasesResource } from "./resources/releases.js";
12
8
  import { DeliveriesResource } from "./resources/deliveries.js";
13
- import { PublicationsResource } from "./resources/publications.js";
14
9
  import { GenerationsResource } from "./resources/generations.js";
10
+ import { DraftsResource } from "./resources/drafts.js";
11
+ import { ReleasesResource } from "./resources/releases.js";
15
12
  import { FilesResource } from "./resources/files.js";
13
+ import { PackagesResource } from "./resources/packages.js";
16
14
  import { OrganizationResource } from "./resources/organization.js";
17
15
  import { ApiKeysResource } from "./resources/api-keys.js";
18
16
  /** This package's version, also sent as the `User-Agent`. */
19
- export const VERSION = "0.21.0";
20
- const USER_AGENT = "@typeship-ax/mcp/0.21.0";
17
+ export const VERSION = "0.22.0";
18
+ const USER_AGENT = "@typeship-ax/mcp/0.22.0";
21
19
  /**
22
- * typeship — v0.21.0
20
+ * Typeship — v0.22.0
23
21
  *
24
22
  * Resolve an OpenAPI or GraphQL Spec, diagnose it, and keep every
25
23
  * selected CLI, MCP, and SDK Target current.
@@ -36,20 +34,21 @@ const USER_AGENT = "@typeship-ax/mcp/0.21.0";
36
34
  * petstore Spec is a runnable sample.
37
35
  */
38
36
  export class TypeshipClient {
39
- generate;
40
37
  projects;
41
38
  specs;
42
39
  specRevisions;
43
40
  targets;
44
- drafts;
45
- releases;
46
41
  deliveries;
47
- publications;
48
42
  generations;
43
+ drafts;
44
+ releases;
49
45
  files;
46
+ packages;
50
47
  organization;
51
48
  apiKeys;
49
+ _options;
52
50
  constructor(options = {}) {
51
+ this._options = options;
53
52
  // Identifies this package to the API (ignored by browsers, which
54
53
  // control their own User-Agent); override via defaultHeaders.
55
54
  const headers = { "User-Agent": USER_AGENT, ...options.defaultHeaders };
@@ -92,45 +91,56 @@ export class TypeshipClient {
92
91
  query,
93
92
  credentials,
94
93
  fetch: options.fetch ?? fetch,
95
- timeoutMs: options.timeoutMs ?? 30_000,
94
+ timeoutMs: options.timeoutMs ?? 60_000,
96
95
  maxRetries: options.maxRetries ?? 2,
96
+ maxRetryWaitMs: options.maxRetryWaitMs,
97
97
  onRequest: options.onRequest,
98
98
  onResponse: options.onResponse,
99
99
  onError: options.onError,
100
100
  debug,
101
101
  validate,
102
- schemas: validate ? SCHEMAS : undefined,
103
- schemaDefs: validate ? DEFS : undefined,
102
+ // Loaded on the first validated request, so the schema table costs
103
+ // nothing when validation is off.
104
+ loadSchemas: validate ? () => import("./schemas.js") : undefined,
104
105
  });
105
- this.generate = new GenerateResource(core);
106
106
  this.projects = new ProjectsResource(core);
107
107
  this.specs = new SpecsResource(core);
108
108
  this.specRevisions = new SpecRevisionsResource(core);
109
109
  this.targets = new TargetsResource(core);
110
- this.drafts = new DraftsResource(core);
111
- this.releases = new ReleasesResource(core);
112
110
  this.deliveries = new DeliveriesResource(core);
113
- this.publications = new PublicationsResource(core);
114
111
  this.generations = new GenerationsResource(core);
112
+ this.drafts = new DraftsResource(core);
113
+ this.releases = new ReleasesResource(core);
115
114
  this.files = new FilesResource(core);
115
+ this.packages = new PackagesResource(core);
116
116
  this.organization = new OrganizationResource(core);
117
117
  this.apiKeys = new ApiKeysResource(core);
118
118
  }
119
+ /**
120
+ * A client with this client's configuration and only these credentials,
121
+ * for a server acting on behalf of many users. Nothing is inherited from
122
+ * this client's credentials. The copy shares the configured fetch.
123
+ */
124
+ withCredentials(credentials) {
125
+ const options = { ...this._options };
126
+ for (const key of ["bearerToken", "credentials"])
127
+ delete options[key];
128
+ return new TypeshipClient({ ...options, ...credentials });
129
+ }
119
130
  }
120
131
  export * from "./types.js";
121
132
  export * from "./errors.js";
122
133
  export { formatDebugEvent, } from "./core/http.js";
123
134
  export { Page, PagePromise } from "./core/pagination.js";
124
- export * from "./resources/generate.js";
125
135
  export * from "./resources/projects.js";
126
136
  export * from "./resources/specs.js";
127
137
  export * from "./resources/spec-revisions.js";
128
138
  export * from "./resources/targets.js";
129
- export * from "./resources/drafts.js";
130
- export * from "./resources/releases.js";
131
139
  export * from "./resources/deliveries.js";
132
- export * from "./resources/publications.js";
133
140
  export * from "./resources/generations.js";
141
+ export * from "./resources/drafts.js";
142
+ export * from "./resources/releases.js";
134
143
  export * from "./resources/files.js";
144
+ export * from "./resources/packages.js";
135
145
  export * from "./resources/organization.js";
136
146
  export * from "./resources/api-keys.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-authorization.d.ts","sourceRoot":"","sources":["../src/mcp-authorization.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,6BAA6B;IAC5C,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD;AAED,8EAA8E;AAC9E,MAAM,WAAW,kCAAkC;IACjD,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAA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C5E,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD;AAED,8EAA8E;AAC9E,MAAM,WAAW,kCAAkC;IACjD,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAAC;IAC1D,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAClC,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,oBAAoB,GAAG,2BAA2B;gBAA5G,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAW,IAAI,EAAE,eAAe,GAAG,oBAAoB,GAAG,2BAA2B;CAIlI;AAeD,2EAA2E;AAC3E,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,6BAA6B,GAAG,6BAA6B,CAMjH;AAmFD;;;;mFAImF;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,6BAA6B,EAAE,aAAa,CAAC,EAAE,kCAAkC;;;;;;;;sBA2DtG,eAAe,GAAG,oBAAoB;sBAKhC,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;EAkBhE"}
@@ -59,19 +59,41 @@ function decode(value) {
59
59
  throw invalid();
60
60
  }
61
61
  }
62
- function principalFor(claims, configuration) {
62
+ /** Providers name granted scopes in `scope` (RFC 8693/9068, a space-separated
63
+ * string) or `scp` (Okta and Entra: a string or an array of strings). */
64
+ function grantedScopes(claims) {
65
+ const scopes = [];
66
+ if (claims.scope !== undefined) {
67
+ if (typeof claims.scope !== "string" || claims.scope.length > 10_000)
68
+ throw invalid();
69
+ scopes.push(...claims.scope.split(" ").filter(Boolean));
70
+ }
71
+ if (claims.scp !== undefined) {
72
+ if (typeof claims.scp === "string") {
73
+ if (claims.scp.length > 10_000)
74
+ throw invalid();
75
+ scopes.push(...claims.scp.split(" ").filter(Boolean));
76
+ }
77
+ else if (Array.isArray(claims.scp) && claims.scp.length <= 100 && claims.scp.every(s => typeof s === "string" && s.length > 0 && s.length <= 500)) {
78
+ scopes.push(...claims.scp);
79
+ }
80
+ else
81
+ throw invalid();
82
+ }
83
+ if (scopes.some(s => !scopePattern.test(s)))
84
+ throw invalid();
85
+ return scopes;
86
+ }
87
+ function principalFor(claims, configuration, audience = claims.aud) {
63
88
  const now = Date.now() / 1000;
64
- const audiences = typeof claims.aud === "string" ? [claims.aud] : claims.aud;
89
+ const audiences = typeof audience === "string" ? [audience] : audience;
65
90
  if (claims.cnf !== undefined || claims.iss !== configuration.issuer || typeof claims.sub !== "string" || !claims.sub || claims.sub.length > 1000 ||
66
91
  !Array.isArray(audiences) || !audiences.every(a => typeof a === "string") || !audiences.includes(configuration.resource) ||
67
92
  typeof claims.exp !== "number" || !Number.isFinite(claims.exp) || claims.exp <= now ||
68
93
  (claims.nbf !== undefined && (typeof claims.nbf !== "number" || !Number.isFinite(claims.nbf) || claims.nbf > now)) ||
69
- (claims.iat !== undefined && (typeof claims.iat !== "number" || !Number.isFinite(claims.iat) || claims.iat > now + 60)) ||
70
- (claims.scope !== undefined && (typeof claims.scope !== "string" || claims.scope.length > 10_000)))
71
- throw invalid();
72
- const scopes = typeof claims.scope === "string" ? claims.scope.split(" ").filter(Boolean) : [];
73
- if (scopes.some(s => !scopePattern.test(s)))
94
+ (claims.iat !== undefined && (typeof claims.iat !== "number" || !Number.isFinite(claims.iat) || claims.iat > now + 60)))
74
95
  throw invalid();
96
+ const scopes = grantedScopes(claims);
75
97
  if (configuration.scopes.some(s => !scopes.includes(s)))
76
98
  throw new McpAuthorizationError(403, "insufficient_scope");
77
99
  return Object.freeze({ issuer: configuration.issuer, subject: claims.sub, resource: configuration.resource, scopes: Object.freeze([...new Set(scopes)]), claims: Object.freeze(claims) });
@@ -107,12 +129,14 @@ function introspector(input, configuration) {
107
129
  if (!data.active || (data.token_type !== undefined && (typeof data.token_type !== "string" || data.token_type.toLowerCase() !== "bearer")))
108
130
  throw invalid();
109
131
  // RFC 7662 permits omitted issuer: the owner-pinned authenticated endpoint
110
- // establishes it. Audience, subject and expiry are mandatory for this handler.
111
- // Never substitute client_id for the MCP resource audience.
132
+ // establishes it. Subject and expiry are mandatory for this handler. The
133
+ // audience is `aud`; a provider that omits it must name the exact MCP
134
+ // resource in `resource` instead. Never substitute client_id for it.
112
135
  const claims = { ...data, iss: data.iss === undefined ? configuration.issuer : data.iss };
113
136
  for (const key of ["token", "access_token", "refresh_token", "id_token", "client_secret"])
114
137
  delete claims[key];
115
- return principalFor(claims, configuration);
138
+ const audience = data.aud === undefined ? data.resource : data.aud;
139
+ return principalFor(claims, configuration, audience);
116
140
  };
117
141
  }
118
142
  /** Resource-server validation using platform crypto or explicit introspection. The caller supplies