@typeship-ax/mcp 0.6.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/AGENTS.md +31 -0
  2. package/README.md +67 -10
  3. package/api.json +6735 -3243
  4. package/api.md +8537 -248
  5. package/dist/api-identity.d.ts +40 -0
  6. package/dist/api-identity.d.ts.map +1 -0
  7. package/dist/api-identity.js +128 -0
  8. package/dist/auth-profiles.d.ts +30 -0
  9. package/dist/auth-profiles.d.ts.map +1 -0
  10. package/dist/auth-profiles.js +138 -0
  11. package/dist/core/http.d.ts +21 -92
  12. package/dist/core/http.d.ts.map +1 -1
  13. package/dist/core/http.js +143 -221
  14. package/dist/core/pagination.d.ts.map +1 -1
  15. package/dist/core/pagination.js +6 -34
  16. package/dist/credential-storage.d.ts +24 -0
  17. package/dist/credential-storage.d.ts.map +1 -0
  18. package/dist/credential-storage.js +207 -0
  19. package/dist/dates.d.ts +0 -2
  20. package/dist/dates.d.ts.map +1 -1
  21. package/dist/dates.js +0 -1
  22. package/dist/docs.d.ts +36 -0
  23. package/dist/docs.d.ts.map +1 -0
  24. package/dist/docs.js +258 -0
  25. package/dist/errors.d.ts +42 -34
  26. package/dist/errors.d.ts.map +1 -1
  27. package/dist/errors.js +30 -20
  28. package/dist/index.d.ts +27 -12
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +40 -14
  31. package/dist/mcp-authorization.d.ts +52 -0
  32. package/dist/mcp-authorization.d.ts.map +1 -0
  33. package/dist/mcp-authorization.js +232 -0
  34. package/dist/mcp-protocol.d.ts +69 -25
  35. package/dist/mcp-protocol.d.ts.map +1 -1
  36. package/dist/mcp-protocol.js +386 -138
  37. package/dist/mcp.d.ts +21 -3
  38. package/dist/mcp.d.ts.map +1 -1
  39. package/dist/mcp.js +199 -85
  40. package/dist/named-credentials.d.ts +21 -0
  41. package/dist/named-credentials.d.ts.map +1 -0
  42. package/dist/named-credentials.js +86 -0
  43. package/dist/oauth-request.d.ts +21 -0
  44. package/dist/oauth-request.d.ts.map +1 -0
  45. package/dist/oauth-request.js +119 -0
  46. package/dist/oauth-session.d.ts +106 -0
  47. package/dist/oauth-session.d.ts.map +1 -0
  48. package/dist/oauth-session.js +244 -0
  49. package/dist/ops.d.ts +18 -0
  50. package/dist/ops.d.ts.map +1 -1
  51. package/dist/ops.js +31 -17
  52. package/dist/resources/account.d.ts +4 -4
  53. package/dist/resources/account.d.ts.map +1 -1
  54. package/dist/resources/account.js +1 -0
  55. package/dist/resources/api-keys.d.ts +13 -8
  56. package/dist/resources/api-keys.d.ts.map +1 -1
  57. package/dist/resources/api-keys.js +5 -1
  58. package/dist/resources/definition-revisions.d.ts +58 -0
  59. package/dist/resources/definition-revisions.d.ts.map +1 -0
  60. package/dist/resources/definition-revisions.js +114 -0
  61. package/dist/resources/definitions.d.ts +35 -0
  62. package/dist/resources/definitions.d.ts.map +1 -0
  63. package/dist/resources/definitions.js +60 -0
  64. package/dist/resources/generate.d.ts +18 -7
  65. package/dist/resources/generate.d.ts.map +1 -1
  66. package/dist/resources/generate.js +13 -5
  67. package/dist/resources/generations.d.ts +6 -6
  68. package/dist/resources/generations.d.ts.map +1 -1
  69. package/dist/resources/generations.js +3 -1
  70. package/dist/resources/projects.d.ts +111 -35
  71. package/dist/resources/projects.d.ts.map +1 -1
  72. package/dist/resources/projects.js +125 -15
  73. package/dist/resources/targets.d.ts +97 -0
  74. package/dist/resources/targets.d.ts.map +1 -0
  75. package/dist/resources/targets.js +197 -0
  76. package/dist/schemas.d.ts.map +1 -1
  77. package/dist/schemas.js +135 -62
  78. package/dist/types.d.ts +2072 -267
  79. package/dist/types.d.ts.map +1 -1
  80. package/dist/types.js +20 -3
  81. package/dist/worker.js +4 -4
  82. package/package.json +11 -1
  83. package/server.json +42 -0
  84. package/src/api-identity.ts +98 -0
  85. package/src/auth-profiles.ts +114 -0
  86. package/src/core/http.ts +156 -305
  87. package/src/core/pagination.ts +6 -30
  88. package/src/credential-storage.ts +183 -0
  89. package/src/dates.ts +0 -1
  90. package/src/docs.ts +239 -0
  91. package/src/errors.ts +52 -41
  92. package/src/index.ts +49 -14
  93. package/src/mcp-authorization.ts +211 -0
  94. package/src/mcp-protocol.ts +432 -133
  95. package/src/mcp.ts +204 -90
  96. package/src/named-credentials.ts +74 -0
  97. package/src/oauth-request.ts +90 -0
  98. package/src/oauth-session.ts +258 -0
  99. package/src/ops.ts +56 -17
  100. package/src/resources/account.ts +6 -3
  101. package/src/resources/api-keys.ts +27 -7
  102. package/src/resources/definition-revisions.ts +207 -0
  103. package/src/resources/definitions.ts +122 -0
  104. package/src/resources/generate.ts +29 -6
  105. package/src/resources/generations.ts +9 -4
  106. package/src/resources/projects.ts +274 -41
  107. package/src/resources/targets.ts +378 -0
  108. package/src/schemas.ts +135 -62
  109. package/src/types.ts +2273 -322
  110. package/src/worker.ts +4 -4
  111. package/dist/resources/spec-revisions.d.ts +0 -47
  112. package/dist/resources/spec-revisions.d.ts.map +0 -1
  113. package/dist/resources/spec-revisions.js +0 -90
  114. package/src/resources/spec-revisions.ts +0 -150
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
5
  import {
6
+ ResponseParseError,
6
7
  TransportError,
7
8
  UnexpectedApiError,
8
9
  ValidationError,
@@ -10,7 +11,7 @@ import {
10
11
  RateLimitedError,
11
12
  UnauthorizedError,
12
13
  } from "../errors.js";
13
- import type { Account } from "../types.js";
14
+ import type { Account, AccountRead } from "../types.js";
14
15
 
15
16
  export class AccountResource {
16
17
  constructor(private readonly _core: HttpCore) {}
@@ -21,10 +22,11 @@ export class AccountResource {
21
22
  * identity endpoint the generated typeship CLI's `whoami` calls.
22
23
  * `GET /me`
23
24
  */
24
- async retrieve(options?: RequestOptions): Promise<ApiResult<Account, AccountRetrieveError>> {
25
- return this._core.request<Account, AccountRetrieveError>({
25
+ async retrieve(options?: RequestOptions): Promise<ApiResult<AccountRead, AccountRetrieveError>> {
26
+ return this._core.request<AccountRead, AccountRetrieveError>({
26
27
  method: "GET",
27
28
  path: "/me",
29
+ security: [{"apiKey":[]}],
28
30
  errors: { "401": UnauthorizedError, "403": ForbiddenError, "429": RateLimitedError },
29
31
  idempotent: true,
30
32
  schemaKey: "account.retrieve",
@@ -39,5 +41,6 @@ export type AccountRetrieveError =
39
41
  | ForbiddenError
40
42
  | RateLimitedError
41
43
  | UnexpectedApiError
44
+ | ResponseParseError
42
45
  | TransportError
43
46
  | ValidationError;
@@ -4,6 +4,7 @@
4
4
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
5
  import { paginate, PagePromise } from "../core/pagination.js";
6
6
  import {
7
+ ResponseParseError,
7
8
  TransportError,
8
9
  UnexpectedApiError,
9
10
  ValidationError,
@@ -13,7 +14,14 @@ import {
13
14
  RateLimitedError,
14
15
  UnauthorizedError,
15
16
  } from "../errors.js";
16
- import type { ApiKey, ApiKeyList } from "../types.js";
17
+ import type {
18
+ ApiKey,
19
+ ApiKeyList,
20
+ ApiKeyListRead,
21
+ ApiKeyRead,
22
+ ApiKeyResponse,
23
+ ApiKeyResponseRead,
24
+ } from "../types.js";
17
25
 
18
26
  export class ApiKeysResource {
19
27
  constructor(private readonly _core: HttpCore) {}
@@ -26,10 +34,11 @@ export class ApiKeysResource {
26
34
  * Auto-paginates: `for await (const item of …)` walks every page.
27
35
  * `GET /api_keys`
28
36
  */
29
- list(params?: ApiKeysListParams, options?: RequestOptions): PagePromise<ApiKey, ApiKeysListError> {
30
- return paginate<ApiKey, ApiKeysListError>(this._core, {
37
+ list(params?: ApiKeysListParams, options?: RequestOptions): PagePromise<ApiKeyRead, ApiKeysListError> {
38
+ return paginate<ApiKeyRead, ApiKeysListError>(this._core, {
31
39
  method: "GET",
32
40
  path: "/api_keys",
41
+ security: [{"apiKey":[]}],
33
42
  query: {
34
43
  limit: params?.limit,
35
44
  cursor: params?.cursor,
@@ -57,13 +66,19 @@ export class ApiKeysResource {
57
66
  * Revoke an API key
58
67
  *
59
68
  * Idempotent: revoking an already-revoked key returns the same body, so a rotation script that
60
- * re-runs does not have to special-case having already succeeded.
69
+ * re-runs does not have to special-case having already succeeded. An OAuth member may revoke a
70
+ * key they created; an organization admin may revoke any key. Organization API keys retain
71
+ * account-wide authority.
61
72
  * `DELETE /api_keys/{api_key_id}`
62
73
  */
63
- async revoke(apiKeyId: string, options?: RequestOptions): Promise<ApiResult<ApiKey, ApiKeysRevokeError>> {
64
- return this._core.request<ApiKey, ApiKeysRevokeError>({
74
+ async revoke(
75
+ apiKeyId: string,
76
+ options?: RequestOptions,
77
+ ): Promise<ApiResult<ApiKeyResponseRead, ApiKeysRevokeError>> {
78
+ return this._core.request<ApiKeyResponseRead, ApiKeysRevokeError>({
65
79
  method: "DELETE",
66
80
  path: `/api_keys/${encodeURIComponent(String(apiKeyId))}`,
81
+ security: [{"apiKey":[]}],
67
82
  errors: {
68
83
  "401": UnauthorizedError,
69
84
  "403": ForbiddenError,
@@ -80,7 +95,10 @@ export class ApiKeysResource {
80
95
  export interface ApiKeysListParams {
81
96
  /** Maximum number of resources to return. */
82
97
  limit?: number;
83
- /** Opaque cursor from the preceding page's next_cursor. */
98
+ /**
99
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same account,
100
+ * operation, filters, and ordering that issued it.
101
+ */
84
102
  cursor?: string;
85
103
  }
86
104
 
@@ -91,6 +109,7 @@ export type ApiKeysListError =
91
109
  | ForbiddenError
92
110
  | RateLimitedError
93
111
  | UnexpectedApiError
112
+ | ResponseParseError
94
113
  | TransportError
95
114
  | ValidationError;
96
115
 
@@ -101,5 +120,6 @@ export type ApiKeysRevokeError =
101
120
  | NotFoundError
102
121
  | RateLimitedError
103
122
  | UnexpectedApiError
123
+ | ResponseParseError
104
124
  | TransportError
105
125
  | ValidationError;
@@ -0,0 +1,207 @@
1
+ // typeship — definitionRevisions resource.
2
+ // Generated by typeship — https://typeship.dev — do not edit by hand.
3
+
4
+ import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
+ import { paginate, PagePromise } from "../core/pagination.js";
6
+ import {
7
+ ResponseParseError,
8
+ TransportError,
9
+ UnexpectedApiError,
10
+ ValidationError,
11
+ BadRequestError,
12
+ ForbiddenError,
13
+ NotFoundError,
14
+ RateLimitedError,
15
+ UnauthorizedError,
16
+ } from "../errors.js";
17
+ import type {
18
+ DefinitionDocumentId,
19
+ DefinitionId,
20
+ DefinitionRevision,
21
+ DefinitionRevisionId,
22
+ DefinitionRevisionList,
23
+ DefinitionRevisionListRead,
24
+ DefinitionRevisionRead,
25
+ DefinitionRevisionResponse,
26
+ DefinitionRevisionResponseRead,
27
+ } from "../types.js";
28
+
29
+ export class DefinitionRevisionsResource {
30
+ constructor(private readonly _core: HttpCore) {}
31
+ /**
32
+ * List Definition Revisions
33
+ *
34
+ * Immutable snapshots of the complete resolved document graph this Definition observed, newest
35
+ * first. Content is available from the revision and document endpoints and is never embedded in a
36
+ * list response.
37
+ *
38
+ * Auto-paginates: `for await (const item of …)` walks every page.
39
+ * `GET /definitions/{definition_id}/revisions`
40
+ */
41
+ list(
42
+ definitionId: DefinitionId,
43
+ params?: DefinitionRevisionsListParams,
44
+ options?: RequestOptions,
45
+ ): PagePromise<DefinitionRevisionRead, DefinitionRevisionsListError> {
46
+ return paginate<DefinitionRevisionRead, DefinitionRevisionsListError>(this._core, {
47
+ method: "GET",
48
+ path: `/definitions/${encodeURIComponent(String(definitionId))}/revisions`,
49
+ security: [{"apiKey":[]}],
50
+ query: {
51
+ limit: params?.limit,
52
+ cursor: params?.cursor,
53
+ },
54
+ errors: {
55
+ "400": BadRequestError,
56
+ "401": UnauthorizedError,
57
+ "403": ForbiddenError,
58
+ "404": NotFoundError,
59
+ "429": RateLimitedError,
60
+ },
61
+ idempotent: true,
62
+ schemaKey: "definitionRevisions.list",
63
+ options,
64
+ }, {
65
+ style: "cursor",
66
+ itemsField: "data",
67
+ cursorParam: "cursor",
68
+ nextCursorField: "next_cursor",
69
+ hasMoreField: "has_more",
70
+ limitParam: "limit",
71
+ });
72
+ }
73
+
74
+ /**
75
+ * Retrieve a Definition Revision
76
+ *
77
+ * Metadata for one immutable resolved document graph. Fetch its canonical content or individual
78
+ * source documents from the content endpoints.
79
+ * `GET /definition_revisions/{definition_revision_id}`
80
+ */
81
+ async retrieve(
82
+ definitionRevisionId: DefinitionRevisionId,
83
+ options?: RequestOptions,
84
+ ): Promise<ApiResult<DefinitionRevisionResponseRead, DefinitionRevisionsRetrieveError>> {
85
+ return this._core.request<DefinitionRevisionResponseRead, DefinitionRevisionsRetrieveError>({
86
+ method: "GET",
87
+ path: `/definition_revisions/${encodeURIComponent(String(definitionRevisionId))}`,
88
+ security: [{"apiKey":[]}],
89
+ errors: {
90
+ "401": UnauthorizedError,
91
+ "403": ForbiddenError,
92
+ "404": NotFoundError,
93
+ "429": RateLimitedError,
94
+ },
95
+ idempotent: true,
96
+ schemaKey: "definitionRevisions.retrieve",
97
+ options,
98
+ });
99
+ }
100
+
101
+ /**
102
+ * Retrieve a Definition Revision's canonical content
103
+ *
104
+ * Returns the exact canonical resolved content identified by the revision's graph digest,
105
+ * suitable for saving or piping into a diff.
106
+ * `GET /definition_revisions/{definition_revision_id}/content`
107
+ */
108
+ async retrieveContent(
109
+ definitionRevisionId: DefinitionRevisionId,
110
+ options?: RequestOptions,
111
+ ): Promise<ApiResult<string, DefinitionRevisionsRetrieveContentError>> {
112
+ return this._core.request<string, DefinitionRevisionsRetrieveContentError>({
113
+ method: "GET",
114
+ path: `/definition_revisions/${encodeURIComponent(String(definitionRevisionId))}/content`,
115
+ security: [{"apiKey":[]}],
116
+ errors: {
117
+ "401": UnauthorizedError,
118
+ "403": ForbiddenError,
119
+ "404": NotFoundError,
120
+ "429": RateLimitedError,
121
+ },
122
+ idempotent: true,
123
+ schemaKey: "definitionRevisions.retrieveContent",
124
+ options,
125
+ });
126
+ }
127
+
128
+ /**
129
+ * Retrieve one source document from a Definition Revision
130
+ * `GET /definition_revisions/{definition_revision_id}/documents/{document_id}/content`
131
+ */
132
+ async retrieveDocumentContent(
133
+ definitionRevisionId: DefinitionRevisionId,
134
+ documentId: DefinitionDocumentId,
135
+ options?: RequestOptions,
136
+ ): Promise<ApiResult<string, DefinitionRevisionsRetrieveDocumentContentError>> {
137
+ return this._core.request<string, DefinitionRevisionsRetrieveDocumentContentError>({
138
+ method: "GET",
139
+ path: `/definition_revisions/${encodeURIComponent(String(definitionRevisionId))}/documents/${encodeURIComponent(String(documentId))}/content`,
140
+ security: [{"apiKey":[]}],
141
+ errors: {
142
+ "401": UnauthorizedError,
143
+ "403": ForbiddenError,
144
+ "404": NotFoundError,
145
+ "429": RateLimitedError,
146
+ },
147
+ idempotent: true,
148
+ schemaKey: "definitionRevisions.retrieveDocumentContent",
149
+ options,
150
+ });
151
+ }
152
+ }
153
+
154
+ export interface DefinitionRevisionsListParams {
155
+ /** Maximum number of resources to return. */
156
+ limit?: number;
157
+ /**
158
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same account,
159
+ * operation, filters, and ordering that issued it.
160
+ */
161
+ cursor?: string;
162
+ }
163
+
164
+ /** Every error `list` can produce, as a discriminated union. */
165
+ export type DefinitionRevisionsListError =
166
+ | BadRequestError
167
+ | UnauthorizedError
168
+ | ForbiddenError
169
+ | NotFoundError
170
+ | RateLimitedError
171
+ | UnexpectedApiError
172
+ | ResponseParseError
173
+ | TransportError
174
+ | ValidationError;
175
+
176
+ /** Every error `retrieve` can produce, as a discriminated union. */
177
+ export type DefinitionRevisionsRetrieveError =
178
+ | UnauthorizedError
179
+ | ForbiddenError
180
+ | NotFoundError
181
+ | RateLimitedError
182
+ | UnexpectedApiError
183
+ | ResponseParseError
184
+ | TransportError
185
+ | ValidationError;
186
+
187
+ /** Every error `retrieveContent` can produce, as a discriminated union. */
188
+ export type DefinitionRevisionsRetrieveContentError =
189
+ | UnauthorizedError
190
+ | ForbiddenError
191
+ | NotFoundError
192
+ | RateLimitedError
193
+ | UnexpectedApiError
194
+ | ResponseParseError
195
+ | TransportError
196
+ | ValidationError;
197
+
198
+ /** Every error `retrieveDocumentContent` can produce, as a discriminated union. */
199
+ export type DefinitionRevisionsRetrieveDocumentContentError =
200
+ | UnauthorizedError
201
+ | ForbiddenError
202
+ | NotFoundError
203
+ | RateLimitedError
204
+ | UnexpectedApiError
205
+ | ResponseParseError
206
+ | TransportError
207
+ | ValidationError;
@@ -0,0 +1,122 @@
1
+ // typeship — definitions resource.
2
+ // Generated by typeship — https://typeship.dev — do not edit by hand.
3
+
4
+ import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
+ import {
6
+ ResponseParseError,
7
+ TransportError,
8
+ UnexpectedApiError,
9
+ ValidationError,
10
+ BadRequestError,
11
+ ConflictError,
12
+ ForbiddenError,
13
+ NotFoundError,
14
+ RateLimitedError,
15
+ UnauthorizedError,
16
+ UnprocessableEntityError,
17
+ } from "../errors.js";
18
+ import type {
19
+ Definition,
20
+ DefinitionId,
21
+ DefinitionRead,
22
+ DefinitionUpdateRequest,
23
+ } from "../types.js";
24
+
25
+ export class DefinitionsResource {
26
+ constructor(private readonly _core: HttpCore) {}
27
+ /**
28
+ * Retrieve a Definition
29
+ * `GET /definitions/{definition_id}`
30
+ */
31
+ async retrieve(
32
+ definitionId: DefinitionId,
33
+ options?: RequestOptions,
34
+ ): Promise<ApiResult<DefinitionRead, DefinitionsRetrieveError>> {
35
+ return this._core.request<DefinitionRead, DefinitionsRetrieveError>({
36
+ method: "GET",
37
+ path: `/definitions/${encodeURIComponent(String(definitionId))}`,
38
+ security: [{"apiKey":[]}],
39
+ errors: {
40
+ "401": UnauthorizedError,
41
+ "403": ForbiddenError,
42
+ "404": NotFoundError,
43
+ "429": RateLimitedError,
44
+ },
45
+ idempotent: true,
46
+ schemaKey: "definitions.retrieve",
47
+ options,
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Update and resolve a Definition
53
+ *
54
+ * Resolves the complete document graph and records a new immutable revision before saving.
55
+ *
56
+ * A `Idempotency-Key` UUID is generated per call (stable across retries) unless you pass one.
57
+ * `PATCH /definitions/{definition_id}`
58
+ */
59
+ async update(
60
+ definitionId: DefinitionId,
61
+ body: DefinitionUpdateRequest,
62
+ params?: DefinitionsUpdateParams,
63
+ options?: RequestOptions,
64
+ ): Promise<ApiResult<DefinitionRead, DefinitionsUpdateError>> {
65
+ return this._core.request<DefinitionRead, DefinitionsUpdateError>({
66
+ method: "PATCH",
67
+ path: `/definitions/${encodeURIComponent(String(definitionId))}`,
68
+ security: [{"apiKey":[]}],
69
+ headers: {
70
+ "Idempotency-Key": params?.idempotencyKey === undefined ? undefined : String(params?.idempotencyKey),
71
+ },
72
+ body,
73
+ errors: {
74
+ "400": BadRequestError,
75
+ "401": UnauthorizedError,
76
+ "403": ForbiddenError,
77
+ "404": NotFoundError,
78
+ "409": ConflictError,
79
+ "422": UnprocessableEntityError,
80
+ "429": RateLimitedError,
81
+ },
82
+ idempotencyKey: "Idempotency-Key",
83
+ schemaKey: "definitions.update",
84
+ options,
85
+ });
86
+ }
87
+ }
88
+
89
+ /** Every error `retrieve` can produce, as a discriminated union. */
90
+ export type DefinitionsRetrieveError =
91
+ | UnauthorizedError
92
+ | ForbiddenError
93
+ | NotFoundError
94
+ | RateLimitedError
95
+ | UnexpectedApiError
96
+ | ResponseParseError
97
+ | TransportError
98
+ | ValidationError;
99
+
100
+ export interface DefinitionsUpdateParams {
101
+ /**
102
+ * Identifies one logical write for 24 hours. The key is scoped to the authenticated account and
103
+ * operation; account-less generation uses a hashed network identity. Retrying the same method,
104
+ * path, query, and JSON body replays the original response. Reusing the key with changed intent
105
+ * returns 409. After expiry the key starts a new write.
106
+ */
107
+ idempotencyKey?: string;
108
+ }
109
+
110
+ /** Every error `update` can produce, as a discriminated union. */
111
+ export type DefinitionsUpdateError =
112
+ | BadRequestError
113
+ | UnauthorizedError
114
+ | ForbiddenError
115
+ | NotFoundError
116
+ | ConflictError
117
+ | UnprocessableEntityError
118
+ | RateLimitedError
119
+ | UnexpectedApiError
120
+ | ResponseParseError
121
+ | TransportError
122
+ | ValidationError;
@@ -3,67 +3,90 @@
3
3
 
4
4
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
5
  import {
6
+ ResponseParseError,
6
7
  TransportError,
7
8
  UnexpectedApiError,
8
9
  ValidationError,
9
10
  ApiResponseError,
10
11
  BadRequestError,
12
+ ConflictError,
11
13
  ForbiddenError,
12
14
  PayloadTooLargeError,
13
15
  RateLimitedError,
14
16
  UnauthorizedError,
15
17
  UnprocessableEntityError,
16
18
  } from "../errors.js";
17
- import type { GenerateRequest, GenerationResult } from "../types.js";
19
+ import type { GenerateRequest, GenerationResult, GenerationResultRead } from "../types.js";
18
20
 
19
21
  export class GenerateResource {
20
22
  constructor(private readonly _core: HttpCore) {}
21
23
  /**
22
- * Generate a package from a spec
24
+ * Generate one Target from a Definition
23
25
  *
24
26
  * Stateless generation: nothing is stored. Returns the full generated
25
27
  * package as files. Works without an API key: anonymous calls generate
26
28
  * the first 25 operations, rate limited per IP address, and the
27
29
  * response's `limits` object says what was held back and where to lift
28
- * it; anonymous calls from a spec URL also carry `claim.url`, a link
30
+ * it; anonymous calls from a Definition URL also carry `claim.url`, a link
29
31
  * that turns the run into a project once a person signs in. With a key, the free plan generates
30
32
  * the first 25 operations and
31
- * paid plans generate the whole spec. A present but invalid key is a
33
+ * paid plans generate the complete Definition. A present but invalid key is a
32
34
  * 401, not a downgrade to anonymous.
35
+ *
36
+ * A `Idempotency-Key` UUID is generated per call (stable across retries) unless you pass one.
33
37
  * `POST /generate`
34
38
  */
35
39
  async run(
36
40
  body: GenerateRequest,
41
+ params?: GenerateRunParams,
37
42
  options?: RequestOptions,
38
- ): Promise<ApiResult<GenerationResult, GenerateRunError>> {
39
- return this._core.request<GenerationResult, GenerateRunError>({
43
+ ): Promise<ApiResult<GenerationResultRead, GenerateRunError>> {
44
+ return this._core.request<GenerationResultRead, GenerateRunError>({
40
45
  method: "POST",
41
46
  path: "/generate",
47
+ security: [{},{"apiKey":[]}],
48
+ headers: {
49
+ "Idempotency-Key": params?.idempotencyKey === undefined ? undefined : String(params?.idempotencyKey),
50
+ },
42
51
  body,
43
52
  errors: {
44
53
  "400": BadRequestError,
45
54
  "401": UnauthorizedError,
46
55
  "403": ForbiddenError,
56
+ "409": ConflictError,
47
57
  "413": PayloadTooLargeError,
48
58
  "422": UnprocessableEntityError,
49
59
  "429": RateLimitedError,
50
60
  default: ApiResponseError,
51
61
  },
62
+ idempotencyKey: "Idempotency-Key",
52
63
  schemaKey: "generate.run",
53
64
  options,
54
65
  });
55
66
  }
56
67
  }
57
68
 
69
+ export interface GenerateRunParams {
70
+ /**
71
+ * Identifies one logical write for 24 hours. The key is scoped to the authenticated account and
72
+ * operation; account-less generation uses a hashed network identity. Retrying the same method,
73
+ * path, query, and JSON body replays the original response. Reusing the key with changed intent
74
+ * returns 409. After expiry the key starts a new write.
75
+ */
76
+ idempotencyKey?: string;
77
+ }
78
+
58
79
  /** Every error `run` can produce, as a discriminated union. */
59
80
  export type GenerateRunError =
60
81
  | BadRequestError
61
82
  | UnauthorizedError
62
83
  | ForbiddenError
84
+ | ConflictError
63
85
  | PayloadTooLargeError
64
86
  | UnprocessableEntityError
65
87
  | RateLimitedError
66
88
  | ApiResponseError
67
89
  | UnexpectedApiError
90
+ | ResponseParseError
68
91
  | TransportError
69
92
  | ValidationError;
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
5
  import {
6
+ ResponseParseError,
6
7
  TransportError,
7
8
  UnexpectedApiError,
8
9
  ValidationError,
@@ -12,7 +13,7 @@ import {
12
13
  RateLimitedError,
13
14
  UnauthorizedError,
14
15
  } from "../errors.js";
15
- import type { Generation, GenerationId } from "../types.js";
16
+ import type { GenerationId, GenerationResponse, GenerationResponseRead } from "../types.js";
16
17
 
17
18
  export class GenerationsResource {
18
19
  constructor(private readonly _core: HttpCore) {}
@@ -25,10 +26,11 @@ export class GenerationsResource {
25
26
  async retrieve(
26
27
  generationId: GenerationId,
27
28
  options?: RequestOptions,
28
- ): Promise<ApiResult<Generation, GenerationsRetrieveError>> {
29
- return this._core.request<Generation, GenerationsRetrieveError>({
29
+ ): Promise<ApiResult<GenerationResponseRead, GenerationsRetrieveError>> {
30
+ return this._core.request<GenerationResponseRead, GenerationsRetrieveError>({
30
31
  method: "GET",
31
32
  path: `/generations/${encodeURIComponent(String(generationId))}`,
33
+ security: [{"apiKey":[]}],
32
34
  errors: {
33
35
  "401": UnauthorizedError,
34
36
  "403": ForbiddenError,
@@ -44,7 +46,7 @@ export class GenerationsResource {
44
46
  /**
45
47
  * Fetch one file from a generation
46
48
  *
47
- * Raw file content, for generations whose output was too large to inline (files_omitted true).
49
+ * Raw file content, for generations whose target was too large to inline (files_omitted true).
48
50
  * The generation's files_index lists valid paths.
49
51
  * `GET /generations/{generation_id}/file`
50
52
  */
@@ -56,6 +58,7 @@ export class GenerationsResource {
56
58
  return this._core.request<string, GenerationsRetrieveFileError>({
57
59
  method: "GET",
58
60
  path: `/generations/${encodeURIComponent(String(generationId))}/file`,
61
+ security: [{"apiKey":[]}],
59
62
  query: {
60
63
  path: params.path,
61
64
  },
@@ -80,6 +83,7 @@ export type GenerationsRetrieveError =
80
83
  | NotFoundError
81
84
  | RateLimitedError
82
85
  | UnexpectedApiError
86
+ | ResponseParseError
83
87
  | TransportError
84
88
  | ValidationError;
85
89
 
@@ -96,5 +100,6 @@ export type GenerationsRetrieveFileError =
96
100
  | NotFoundError
97
101
  | RateLimitedError
98
102
  | UnexpectedApiError
103
+ | ResponseParseError
99
104
  | TransportError
100
105
  | ValidationError;