@typeship-ax/cli 0.10.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/AGENTS.md +10 -5
  2. package/README.md +5 -5
  3. package/api.json +9773 -4501
  4. package/api.md +501 -271
  5. package/dist/api-identity.d.ts.map +1 -1
  6. package/dist/api-identity.js +6 -1
  7. package/dist/cli-agent.d.ts +5 -5
  8. package/dist/cli-agent.d.ts.map +1 -1
  9. package/dist/cli-agent.js +14 -10
  10. package/dist/cli.js +158 -82
  11. package/dist/core/http.d.ts +29 -16
  12. package/dist/core/http.d.ts.map +1 -1
  13. package/dist/core/http.js +108 -25
  14. package/dist/core/pagination.d.ts +8 -8
  15. package/dist/core/pagination.d.ts.map +1 -1
  16. package/dist/core/pagination.js +7 -16
  17. package/dist/errors.d.ts +20 -13
  18. package/dist/errors.d.ts.map +1 -1
  19. package/dist/errors.js +29 -20
  20. package/dist/index.d.ts +37 -19
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +42 -18
  23. package/dist/ops.d.ts +5 -1
  24. package/dist/ops.d.ts.map +1 -1
  25. package/dist/ops.js +42 -35
  26. package/dist/polling-login.d.ts.map +1 -1
  27. package/dist/polling-login.js +11 -1
  28. package/dist/resources/api-keys.d.ts +44 -18
  29. package/dist/resources/api-keys.d.ts.map +1 -1
  30. package/dist/resources/api-keys.js +46 -14
  31. package/dist/resources/deliveries.d.ts +46 -0
  32. package/dist/resources/deliveries.d.ts.map +1 -0
  33. package/dist/resources/deliveries.js +70 -0
  34. package/dist/resources/drafts.d.ts +155 -0
  35. package/dist/resources/drafts.d.ts.map +1 -0
  36. package/dist/resources/drafts.js +230 -0
  37. package/dist/resources/files.d.ts +23 -0
  38. package/dist/resources/files.d.ts.map +1 -0
  39. package/dist/resources/files.js +38 -0
  40. package/dist/resources/generate.d.ts +49 -20
  41. package/dist/resources/generate.d.ts.map +1 -1
  42. package/dist/resources/generate.js +56 -14
  43. package/dist/resources/generations.d.ts +70 -18
  44. package/dist/resources/generations.d.ts.map +1 -1
  45. package/dist/resources/generations.js +84 -16
  46. package/dist/resources/organization.d.ts +18 -0
  47. package/dist/resources/organization.d.ts.map +1 -0
  48. package/dist/resources/organization.js +32 -0
  49. package/dist/resources/projects.d.ts +87 -124
  50. package/dist/resources/projects.d.ts.map +1 -1
  51. package/dist/resources/projects.js +70 -173
  52. package/dist/resources/publications.d.ts +46 -0
  53. package/dist/resources/publications.d.ts.map +1 -0
  54. package/dist/resources/publications.js +70 -0
  55. package/dist/resources/releases.d.ts +66 -0
  56. package/dist/resources/releases.d.ts.map +1 -0
  57. package/dist/resources/releases.js +101 -0
  58. package/dist/resources/spec-revisions.d.ts +85 -0
  59. package/dist/resources/spec-revisions.d.ts.map +1 -0
  60. package/dist/resources/spec-revisions.js +116 -0
  61. package/dist/resources/specs.d.ts +72 -0
  62. package/dist/resources/specs.d.ts.map +1 -0
  63. package/dist/resources/specs.js +107 -0
  64. package/dist/resources/targets.d.ts +85 -105
  65. package/dist/resources/targets.d.ts.map +1 -1
  66. package/dist/resources/targets.js +70 -163
  67. package/dist/schemas.d.ts +1 -0
  68. package/dist/schemas.d.ts.map +1 -1
  69. package/dist/schemas.js +194 -139
  70. package/dist/types.d.ts +2626 -1141
  71. package/dist/types.d.ts.map +1 -1
  72. package/dist/types.js +90 -11
  73. package/package.json +3 -3
  74. package/src/api-identity.ts +6 -2
  75. package/src/cli-agent.ts +17 -13
  76. package/src/cli.ts +145 -77
  77. package/src/core/http.ts +106 -30
  78. package/src/core/pagination.ts +13 -23
  79. package/src/errors.ts +30 -20
  80. package/src/index.ts +46 -24
  81. package/src/ops.ts +47 -36
  82. package/src/polling-login.ts +10 -1
  83. package/src/resources/api-keys.ts +87 -19
  84. package/src/resources/deliveries.ts +139 -0
  85. package/src/resources/drafts.ts +422 -0
  86. package/src/resources/files.ts +68 -0
  87. package/src/resources/generate.ts +81 -19
  88. package/src/resources/generations.ts +167 -29
  89. package/src/resources/organization.ts +53 -0
  90. package/src/resources/projects.ts +129 -322
  91. package/src/resources/publications.ts +139 -0
  92. package/src/resources/releases.ts +199 -0
  93. package/src/resources/spec-revisions.ts +237 -0
  94. package/src/resources/specs.ts +200 -0
  95. package/src/resources/targets.ts +135 -304
  96. package/src/schemas.ts +195 -140
  97. package/src/types.ts +2793 -1177
  98. package/dist/resources/account.d.ts +0 -18
  99. package/dist/resources/account.d.ts.map +0 -1
  100. package/dist/resources/account.js +0 -27
  101. package/dist/resources/definition-revisions.d.ts +0 -58
  102. package/dist/resources/definition-revisions.d.ts.map +0 -1
  103. package/dist/resources/definition-revisions.js +0 -114
  104. package/dist/resources/definitions.d.ts +0 -35
  105. package/dist/resources/definitions.d.ts.map +0 -1
  106. package/dist/resources/definitions.js +0 -60
  107. package/src/resources/account.ts +0 -46
  108. package/src/resources/definition-revisions.ts +0 -207
  109. package/src/resources/definitions.ts +0 -122
@@ -0,0 +1,422 @@
1
+ // typeship — drafts resource.
2
+ // Generated by typeship — https://typeship.dev
3
+
4
+ import { HttpCore, 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
+ BadGatewayError,
12
+ BadRequestError,
13
+ ConflictError,
14
+ ForbiddenError,
15
+ InternalServerError,
16
+ NotFoundError,
17
+ PreconditionFailedError,
18
+ RateLimitedError,
19
+ UnauthorizedError,
20
+ UnprocessableEntityError,
21
+ } from "../errors.js";
22
+ import type {
23
+ Draft,
24
+ DraftFile,
25
+ DraftFileList,
26
+ DraftFileListRead,
27
+ DraftFileRead,
28
+ DraftId,
29
+ DraftList,
30
+ DraftListRead,
31
+ DraftRead,
32
+ DraftRecoverRequest,
33
+ DraftResolveRequest,
34
+ DraftResponse,
35
+ DraftResponseRead,
36
+ DraftStatus,
37
+ DraftUpdateRequest,
38
+ TargetId,
39
+ } from "../types.js";
40
+
41
+ export class DraftsResource {
42
+ constructor(private readonly _core: HttpCore) {}
43
+ /**
44
+ * List Drafts
45
+ *
46
+ * Lists open and merged Drafts, newest first. Each Target has one open Draft; each merge adds a
47
+ * merged Draft.
48
+ *
49
+ * Auto-paginates: `for await (const item of …)` walks every page.
50
+ * `GET /drafts`
51
+ */
52
+ list(params?: DraftsListParams, options?: RequestOptions): PagePromise<DraftRead, DraftsListError> {
53
+ return paginate<DraftRead, DraftsListError>(this._core, {
54
+ method: "GET",
55
+ path: "/drafts",
56
+ security: [{"apiKey":[]}],
57
+ query: {
58
+ limit: params?.limit,
59
+ cursor: params?.cursor,
60
+ target_id: params?.targetId,
61
+ status: params?.status,
62
+ },
63
+ errors: {
64
+ "400": BadRequestError,
65
+ "401": UnauthorizedError,
66
+ "403": ForbiddenError,
67
+ "404": NotFoundError,
68
+ "429": RateLimitedError,
69
+ "500": InternalServerError,
70
+ },
71
+ idempotent: true,
72
+ schemaKey: "drafts.list",
73
+ options,
74
+ }, {
75
+ style: "cursor",
76
+ itemsField: "data",
77
+ cursorParam: "cursor",
78
+ nextCursorField: "next_cursor",
79
+ hasMoreField: "has_more",
80
+ limitParam: "limit",
81
+ });
82
+ }
83
+
84
+ /**
85
+ * Get a Draft
86
+ *
87
+ * Returns the Draft's status. An open Draft also reports its typed reason when action is
88
+ * required, next version and its source, readiness, checks, and conflict counts. The response
89
+ * carries an `ETag`; send it in `If-Match` when updating the Draft to avoid changing a newer
90
+ * version selection.
91
+ * `GET /drafts/{draft_id}`
92
+ */
93
+ async get(draftId: DraftId, options?: RequestOptions): Promise<DraftResponseRead> {
94
+ return this._core.requestData<DraftResponseRead, DraftsGetError>({
95
+ method: "GET",
96
+ path: `/drafts/${encodeURIComponent(String(draftId))}`,
97
+ security: [{"apiKey":[]}],
98
+ errors: {
99
+ "401": UnauthorizedError,
100
+ "403": ForbiddenError,
101
+ "404": NotFoundError,
102
+ "429": RateLimitedError,
103
+ "500": InternalServerError,
104
+ },
105
+ idempotent: true,
106
+ schemaKey: "drafts.get",
107
+ options,
108
+ });
109
+ }
110
+
111
+ /**
112
+ * Select an exact Draft version or return to automatic versioning
113
+ *
114
+ * Checks your version choice against the required version bump, then regenerates the existing
115
+ * Draft pull request.
116
+ *
117
+ * Send the Draft's `ETag` in `If-Match` to reject an intervening change with 412
118
+ * precondition_failed before saving or regenerating. Omitting `If-Match` applies the selection to
119
+ * the current Draft. version_next is required; null restores automatic selection.
120
+ *
121
+ * A `502` response means the selected version was saved, but regeneration failed. Follow the
122
+ * error's retryable and suggested_action fields. Repeating an unfinished selection resumes
123
+ * generation; repeating a completed selection starts no new work. If using If-Match, retrieve the
124
+ * Draft and confirm the saved selection before retrying with its current ETag.
125
+ * A `409 draft_merged` means the Draft merged; retrieve the Target and select a version on its
126
+ * `draft_id`. A `409 target_busy` means the Target is publishing; wait and retry. A `409
127
+ * version_occupied` means the version is already released; retrieve the Draft and releases,
128
+ * choose a new version, and retry.
129
+ * See [conditional writes](https://typeship.dev/docs/typeship-api#conditional-writes) for ETag
130
+ * and If-Match.
131
+ * `PATCH /drafts/{draft_id}`
132
+ */
133
+ async update(
134
+ draftId: DraftId,
135
+ body: DraftUpdateRequest,
136
+ params?: DraftsUpdateParams,
137
+ options?: RequestOptions,
138
+ ): Promise<DraftResponseRead> {
139
+ return this._core.requestData<DraftResponseRead, DraftsUpdateError>({
140
+ method: "PATCH",
141
+ path: `/drafts/${encodeURIComponent(String(draftId))}`,
142
+ security: [{"apiKey":[]}],
143
+ headers: {
144
+ "If-Match": params?.ifMatch === undefined ? undefined : String(params?.ifMatch),
145
+ },
146
+ body,
147
+ errors: {
148
+ "400": BadRequestError,
149
+ "401": UnauthorizedError,
150
+ "403": ForbiddenError,
151
+ "404": NotFoundError,
152
+ "409": ConflictError,
153
+ "412": PreconditionFailedError,
154
+ "422": UnprocessableEntityError,
155
+ "429": RateLimitedError,
156
+ "500": InternalServerError,
157
+ "502": BadGatewayError,
158
+ },
159
+ schemaKey: "drafts.update",
160
+ options,
161
+ });
162
+ }
163
+
164
+ /**
165
+ * List customized and conflicted files on a Draft
166
+ *
167
+ * Lists the Draft's files that differ from the last merged package or need a conflict decision,
168
+ * ordered by path, without file content. Each conflict names its kind, the saved decision, and
169
+ * the sides you can read with getFile. With `filter=history`, lists files affected by a
170
+ * default-branch history rewrite; the list is empty when none is pending.
171
+ *
172
+ * Returns `409 resource_changed` while Typeship is carrying the Draft's latest commit forward
173
+ * (status working), or when the Draft changes between pages.
174
+ *
175
+ * Auto-paginates: `for await (const item of …)` walks every page.
176
+ * `GET /drafts/{draft_id}/files`
177
+ */
178
+ listFiles(
179
+ draftId: DraftId,
180
+ params?: DraftsListFilesParams,
181
+ options?: RequestOptions,
182
+ ): PagePromise<DraftFileRead, DraftsListFilesError> {
183
+ return paginate<DraftFileRead, DraftsListFilesError>(this._core, {
184
+ method: "GET",
185
+ path: `/drafts/${encodeURIComponent(String(draftId))}/files`,
186
+ security: [{"apiKey":[]}],
187
+ query: {
188
+ filter: params?.filter,
189
+ limit: params?.limit,
190
+ cursor: params?.cursor,
191
+ },
192
+ errors: {
193
+ "400": BadRequestError,
194
+ "401": UnauthorizedError,
195
+ "403": ForbiddenError,
196
+ "404": NotFoundError,
197
+ "409": ConflictError,
198
+ "429": RateLimitedError,
199
+ "500": InternalServerError,
200
+ },
201
+ idempotent: true,
202
+ schemaKey: "drafts.listFiles",
203
+ options,
204
+ }, {
205
+ style: "cursor",
206
+ itemsField: "data",
207
+ cursorParam: "cursor",
208
+ nextCursorField: "next_cursor",
209
+ hasMoreField: "has_more",
210
+ limitParam: "limit",
211
+ });
212
+ }
213
+
214
+ /**
215
+ * Resolve selected Draft files
216
+ *
217
+ * Resolves conflicts on the Draft's head_sha: keep yours or generated, or supply final content as
218
+ * text or, for binary files, base64. Choosing generated for a customized path replaces it with
219
+ * the generated file, or deletes a Draft-only file.
220
+ *
221
+ * Conflict decisions are saved together and can be replaced until applied. Choosing generated for
222
+ * customized paths commits those changes together on the Draft branch. Returns the Draft. When
223
+ * every conflict has a decision, `conflicts.decided` equals `conflicts.total` and Typeship
224
+ * continues the Draft and runs checks. Paths that already match the Draft change nothing.
225
+ * `POST /drafts/{draft_id}/resolve`
226
+ */
227
+ async resolve(
228
+ draftId: DraftId,
229
+ body: DraftResolveRequest,
230
+ options?: RequestOptions,
231
+ ): Promise<DraftResponseRead> {
232
+ return this._core.requestData<DraftResponseRead, DraftsResolveError>({
233
+ method: "POST",
234
+ path: `/drafts/${encodeURIComponent(String(draftId))}/resolve`,
235
+ security: [{"apiKey":[]}],
236
+ body,
237
+ errors: {
238
+ "400": BadRequestError,
239
+ "401": UnauthorizedError,
240
+ "403": ForbiddenError,
241
+ "404": NotFoundError,
242
+ "409": ConflictError,
243
+ "429": RateLimitedError,
244
+ "500": InternalServerError,
245
+ },
246
+ schemaKey: "drafts.resolve",
247
+ options,
248
+ });
249
+ }
250
+
251
+ /**
252
+ * Approve recovery from rewritten default-branch history
253
+ *
254
+ * When the Draft has status `action_required` and reason `history_rewritten`, review affected
255
+ * files with `listDraftFiles` and `filter=history`, then approve with the Draft's
256
+ * `history_recovery` revisions. Approval saves the recovery without changing Git and returns the
257
+ * Draft; the next generation rebuilds it from the rewritten default branch. The previous Draft
258
+ * branch stays available, and overlapping code comes back as conflicts to resolve. A rewritten
259
+ * Draft branch alone needs no approval.
260
+ * `POST /drafts/{draft_id}/recover`
261
+ */
262
+ async recover(
263
+ draftId: DraftId,
264
+ body: DraftRecoverRequest,
265
+ options?: RequestOptions,
266
+ ): Promise<DraftResponseRead> {
267
+ return this._core.requestData<DraftResponseRead, DraftsRecoverError>({
268
+ method: "POST",
269
+ path: `/drafts/${encodeURIComponent(String(draftId))}/recover`,
270
+ security: [{"apiKey":[]}],
271
+ body,
272
+ errors: {
273
+ "400": BadRequestError,
274
+ "401": UnauthorizedError,
275
+ "403": ForbiddenError,
276
+ "404": NotFoundError,
277
+ "409": ConflictError,
278
+ "429": RateLimitedError,
279
+ "500": InternalServerError,
280
+ },
281
+ schemaKey: "drafts.recover",
282
+ options,
283
+ });
284
+ }
285
+ }
286
+
287
+ export interface DraftsListParams {
288
+ /**
289
+ * Maximum number of resources to return. Omit for 20; otherwise supply base-10 digits
290
+ * representing an integer from 1 to 100. Empty, malformed, or out-of-range values return 400
291
+ * invalid_request. List query parameters must appear only once; unrecognized parameters also
292
+ * return 400.
293
+ */
294
+ limit?: number;
295
+ /**
296
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same organization,
297
+ * operation, filters, and ordering that issued it. Omit to start at the first page. Empty,
298
+ * malformed, or repeated cursors return 400 invalid_request. The page limit may change between
299
+ * requests.
300
+ */
301
+ cursor?: string;
302
+ /** Only Drafts of this Target. */
303
+ targetId?: TargetId;
304
+ /** Only Drafts with this status. */
305
+ status?: DraftStatus;
306
+ }
307
+
308
+ /** Typed errors `list` can throw. */
309
+ export type DraftsListError =
310
+ | BadRequestError
311
+ | UnauthorizedError
312
+ | ForbiddenError
313
+ | NotFoundError
314
+ | RateLimitedError
315
+ | InternalServerError
316
+ | UnexpectedApiError
317
+ | ResponseParseError
318
+ | TransportError
319
+ | ValidationError;
320
+
321
+ /** Typed errors `get` can throw. */
322
+ export type DraftsGetError =
323
+ | UnauthorizedError
324
+ | ForbiddenError
325
+ | NotFoundError
326
+ | RateLimitedError
327
+ | InternalServerError
328
+ | UnexpectedApiError
329
+ | ResponseParseError
330
+ | TransportError
331
+ | ValidationError;
332
+
333
+ export interface DraftsUpdateParams {
334
+ /**
335
+ * ETag from a preceding response. The write applies only if the resource still has that version;
336
+ * otherwise it returns 412 precondition_failed without changes. Omit to write the current
337
+ * version. See https://typeship.dev/docs/typeship-api#conditional-writes.
338
+ */
339
+ ifMatch?: string;
340
+ }
341
+
342
+ /** Typed errors `update` can throw. */
343
+ export type DraftsUpdateError =
344
+ | BadRequestError
345
+ | UnauthorizedError
346
+ | ForbiddenError
347
+ | NotFoundError
348
+ | ConflictError
349
+ | PreconditionFailedError
350
+ | UnprocessableEntityError
351
+ | RateLimitedError
352
+ | InternalServerError
353
+ | BadGatewayError
354
+ | UnexpectedApiError
355
+ | ResponseParseError
356
+ | TransportError
357
+ | ValidationError;
358
+
359
+ export interface DraftsListFilesParams {
360
+ /**
361
+ * conflicted: conflicts only. customized: files that differ from the last merged package.
362
+ * history: files affected by a default-branch history rewrite. Omit for conflicted and customized
363
+ * files.
364
+ */
365
+ filter?: "conflicted" | "customized" | "history";
366
+ /**
367
+ * Maximum number of resources to return. Omit for 20; otherwise supply base-10 digits
368
+ * representing an integer from 1 to 100. Empty, malformed, or out-of-range values return 400
369
+ * invalid_request. List query parameters must appear only once; unrecognized parameters also
370
+ * return 400.
371
+ */
372
+ limit?: number;
373
+ /**
374
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same organization,
375
+ * operation, filters, and ordering that issued it. Omit to start at the first page. Empty,
376
+ * malformed, or repeated cursors return 400 invalid_request. The page limit may change between
377
+ * requests.
378
+ */
379
+ cursor?: string;
380
+ }
381
+
382
+ /** Typed errors `listFiles` can throw. */
383
+ export type DraftsListFilesError =
384
+ | BadRequestError
385
+ | UnauthorizedError
386
+ | ForbiddenError
387
+ | NotFoundError
388
+ | ConflictError
389
+ | RateLimitedError
390
+ | InternalServerError
391
+ | UnexpectedApiError
392
+ | ResponseParseError
393
+ | TransportError
394
+ | ValidationError;
395
+
396
+ /** Typed errors `resolve` can throw. */
397
+ export type DraftsResolveError =
398
+ | BadRequestError
399
+ | UnauthorizedError
400
+ | ForbiddenError
401
+ | NotFoundError
402
+ | ConflictError
403
+ | RateLimitedError
404
+ | InternalServerError
405
+ | UnexpectedApiError
406
+ | ResponseParseError
407
+ | TransportError
408
+ | ValidationError;
409
+
410
+ /** Typed errors `recover` can throw. */
411
+ export type DraftsRecoverError =
412
+ | BadRequestError
413
+ | UnauthorizedError
414
+ | ForbiddenError
415
+ | NotFoundError
416
+ | ConflictError
417
+ | RateLimitedError
418
+ | InternalServerError
419
+ | UnexpectedApiError
420
+ | ResponseParseError
421
+ | TransportError
422
+ | ValidationError;
@@ -0,0 +1,68 @@
1
+ // typeship — files resource.
2
+ // Generated by typeship — https://typeship.dev
3
+
4
+ import { HttpCore, type RequestOptions } from "../core/http.js";
5
+ import {
6
+ ResponseParseError,
7
+ TransportError,
8
+ UnexpectedApiError,
9
+ ValidationError,
10
+ BadRequestError,
11
+ ForbiddenError,
12
+ InternalServerError,
13
+ NotFoundError,
14
+ RateLimitedError,
15
+ UnauthorizedError,
16
+ } from "../errors.js";
17
+ import type { FileId, FileResponse, FileResponseRead } from "../types.js";
18
+
19
+ export class FilesResource {
20
+ constructor(private readonly _core: HttpCore) {}
21
+ /**
22
+ * Get a file
23
+ *
24
+ * Returns one bounded chunk of an immutable file: at most 24 KiB, as UTF-8 text or, for binary
25
+ * bytes, base64. When next_cursor is not null, repeat the request with cursor and concatenate the
26
+ * chunks in order. A file ID always returns the same bytes.
27
+ * `GET /files/{file_id}`
28
+ */
29
+ async get(fileId: FileId, params?: FilesGetParams, options?: RequestOptions): Promise<FileResponseRead> {
30
+ return this._core.requestData<FileResponseRead, FilesGetError>({
31
+ method: "GET",
32
+ path: `/files/${encodeURIComponent(String(fileId))}`,
33
+ security: [{"apiKey":[]}],
34
+ query: {
35
+ cursor: params?.cursor,
36
+ },
37
+ errors: {
38
+ "400": BadRequestError,
39
+ "401": UnauthorizedError,
40
+ "403": ForbiddenError,
41
+ "404": NotFoundError,
42
+ "429": RateLimitedError,
43
+ "500": InternalServerError,
44
+ },
45
+ idempotent: true,
46
+ schemaKey: "files.get",
47
+ options,
48
+ });
49
+ }
50
+ }
51
+
52
+ export interface FilesGetParams {
53
+ /** next_cursor from the preceding chunk of this file. */
54
+ cursor?: string;
55
+ }
56
+
57
+ /** Typed errors `get` can throw. */
58
+ export type FilesGetError =
59
+ | BadRequestError
60
+ | UnauthorizedError
61
+ | ForbiddenError
62
+ | NotFoundError
63
+ | RateLimitedError
64
+ | InternalServerError
65
+ | UnexpectedApiError
66
+ | ResponseParseError
67
+ | TransportError
68
+ | ValidationError;
@@ -1,7 +1,7 @@
1
1
  // typeship — generate resource.
2
- // Generated by typeship — https://typeship.dev — do not edit by hand.
2
+ // Generated by typeship — https://typeship.dev
3
3
 
4
- import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
4
+ import { HttpCore, type RequestOptions } from "../core/http.js";
5
5
  import {
6
6
  ResponseParseError,
7
7
  TransportError,
@@ -11,6 +11,8 @@ import {
11
11
  BadRequestError,
12
12
  ConflictError,
13
13
  ForbiddenError,
14
+ InternalServerError,
15
+ NotFoundError,
14
16
  PayloadTooLargeError,
15
17
  RateLimitedError,
16
18
  UnauthorizedError,
@@ -21,17 +23,26 @@ import type { GenerateRequest, GenerationResult, GenerationResultRead } from "..
21
23
  export class GenerateResource {
22
24
  constructor(private readonly _core: HttpCore) {}
23
25
  /**
24
- * Generate one Target from a Definition
26
+ * Generate one package from a Spec
25
27
  *
26
- * Stateless generation: nothing is stored. Returns the full generated
27
- * package as files. Works without an API key: anonymous calls generate
28
- * the first 25 operations, rate limited per IP address, and the
29
- * response's `limits` object says what was held back and where to lift
30
- * it; anonymous calls from a Definition URL also carry `claim.url`, a link
31
- * that turns the run into a project once a person signs in. With a key, the free plan generates
32
- * the first 25 operations and
33
- * paid plans generate the complete Definition. A present but invalid key is a
34
- * 401, not a downgrade to anonymous.
28
+ * Returns one generated package without creating a Project.
29
+ *
30
+ * Supports [idempotent retries](https://typeship.dev/docs/typeship-api/idempotency); keyed
31
+ * responses include generated files in the replay cache.
32
+ *
33
+ * Use `download.url` to save the complete ZIP, verify `download.sha256`, and extract it into an
34
+ * empty directory. The link expires at `download.expires_at` and grants access to anyone who has
35
+ * it. CLI, MCP, and SDK calls supply an idempotency key automatically. Agents should request
36
+ * `fields=["download","coverage","warnings","claim"]` to keep the MCP result compact; files can
37
+ * exceed the response limit. Download the ZIP instead of repeating generation to retrieve omitted
38
+ * files.
39
+ *
40
+ * Anonymous and Free requests include the first 25 operations. Paid plans include all operations.
41
+ * Anonymous requests are rate limited by IP address. Check `coverage` for omitted operations; an
42
+ * invalid API key returns `401`.
43
+ *
44
+ * An anonymous URL request without source headers may return `claim.url`. Sign in through that
45
+ * link within seven days to save the recipe as a Project.
35
46
  *
36
47
  * A `Idempotency-Key` UUID is generated per call (stable across retries) unless you pass one.
37
48
  * `POST /generate`
@@ -40,8 +51,8 @@ export class GenerateResource {
40
51
  body: GenerateRequest,
41
52
  params?: GenerateRunParams,
42
53
  options?: RequestOptions,
43
- ): Promise<ApiResult<GenerationResultRead, GenerateRunError>> {
44
- return this._core.request<GenerationResultRead, GenerateRunError>({
54
+ ): Promise<GenerationResultRead> {
55
+ return this._core.requestData<GenerationResultRead, GenerateRunError>({
45
56
  method: "POST",
46
57
  path: "/generate",
47
58
  security: [{},{"apiKey":[]}],
@@ -57,6 +68,7 @@ export class GenerateResource {
57
68
  "413": PayloadTooLargeError,
58
69
  "422": UnprocessableEntityError,
59
70
  "429": RateLimitedError,
71
+ "500": InternalServerError,
60
72
  default: ApiResponseError,
61
73
  },
62
74
  idempotencyKey: "Idempotency-Key",
@@ -64,19 +76,52 @@ export class GenerateResource {
64
76
  options,
65
77
  });
66
78
  }
79
+
80
+ /**
81
+ * Download a generated package
82
+ *
83
+ * Download the complete ZIP referenced by `generate_run`'s `download.url`. Pass the token from
84
+ * that URL. No API key is needed; the token grants access only to that exact package until its
85
+ * replay window expires. Keep the token private.
86
+ *
87
+ * The local MCP server saves this binary response to disk. On a hosted MCP connection, download
88
+ * the original URL directly to your workspace. Verify the ZIP against `download.sha256` before
89
+ * extracting it into an empty directory. Expired or invalid tokens return `404`; a new generation
90
+ * creates a new download.
91
+ * `GET /generate/download`
92
+ */
93
+ async downloadPackage(params: GenerateDownloadPackageParams, options?: RequestOptions): Promise<Blob> {
94
+ return this._core.requestData<Blob, GenerateDownloadPackageError>({
95
+ method: "GET",
96
+ path: "/generate/download",
97
+ security: [{}],
98
+ query: {
99
+ token: params.token,
100
+ },
101
+ errors: {
102
+ "400": BadRequestError,
103
+ "404": NotFoundError,
104
+ "429": RateLimitedError,
105
+ "500": InternalServerError,
106
+ },
107
+ idempotent: true,
108
+ schemaKey: "generate.downloadPackage",
109
+ options,
110
+ });
111
+ }
67
112
  }
68
113
 
69
114
  export interface GenerateRunParams {
70
115
  /**
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.
116
+ * Identifies one logical write for 24 hours. The key is scoped to the authenticated organization
117
+ * and operation; generation without an organization uses a hashed network identity. Retrying the
118
+ * same method, path, query, If-Match header, and JSON body replays the original response. Reusing
119
+ * the key with changed intent returns 409. After expiry the key starts a new write.
75
120
  */
76
121
  idempotencyKey?: string;
77
122
  }
78
123
 
79
- /** Every error `run` can produce, as a discriminated union. */
124
+ /** Typed errors `run` can throw. */
80
125
  export type GenerateRunError =
81
126
  | BadRequestError
82
127
  | UnauthorizedError
@@ -85,8 +130,25 @@ export type GenerateRunError =
85
130
  | PayloadTooLargeError
86
131
  | UnprocessableEntityError
87
132
  | RateLimitedError
133
+ | InternalServerError
88
134
  | ApiResponseError
89
135
  | UnexpectedApiError
90
136
  | ResponseParseError
91
137
  | TransportError
92
138
  | ValidationError;
139
+
140
+ export interface GenerateDownloadPackageParams {
141
+ /** Private download token from download.url in the generation result. */
142
+ token: string;
143
+ }
144
+
145
+ /** Typed errors `downloadPackage` can throw. */
146
+ export type GenerateDownloadPackageError =
147
+ | BadRequestError
148
+ | NotFoundError
149
+ | RateLimitedError
150
+ | InternalServerError
151
+ | UnexpectedApiError
152
+ | ResponseParseError
153
+ | TransportError
154
+ | ValidationError;