@typeship-ax/cli 0.9.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/AGENTS.md +9 -4
  2. package/README.md +4 -4
  3. package/api.json +6257 -589
  4. package/api.md +475 -81
  5. package/dist/cli-agent.d.ts +5 -5
  6. package/dist/cli-agent.d.ts.map +1 -1
  7. package/dist/cli-agent.js +14 -10
  8. package/dist/cli.js +151 -75
  9. package/dist/core/http.d.ts +3 -2
  10. package/dist/core/http.d.ts.map +1 -1
  11. package/dist/core/http.js +18 -6
  12. package/dist/errors.d.ts +17 -10
  13. package/dist/errors.d.ts.map +1 -1
  14. package/dist/errors.js +24 -15
  15. package/dist/index.d.ts +7 -3
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +9 -5
  18. package/dist/ops.d.ts +4 -0
  19. package/dist/ops.d.ts.map +1 -1
  20. package/dist/ops.js +45 -31
  21. package/dist/polling-login.d.ts.map +1 -1
  22. package/dist/polling-login.js +11 -1
  23. package/dist/resources/account.d.ts +4 -4
  24. package/dist/resources/account.d.ts.map +1 -1
  25. package/dist/resources/account.js +10 -5
  26. package/dist/resources/api-keys.d.ts +40 -14
  27. package/dist/resources/api-keys.d.ts.map +1 -1
  28. package/dist/resources/api-keys.js +45 -13
  29. package/dist/resources/definition-revisions.d.ts +35 -18
  30. package/dist/resources/definition-revisions.d.ts.map +1 -1
  31. package/dist/resources/definition-revisions.js +43 -15
  32. package/dist/resources/definitions.d.ts +21 -6
  33. package/dist/resources/definitions.d.ts.map +1 -1
  34. package/dist/resources/definitions.js +16 -3
  35. package/dist/resources/generate.d.ts +44 -15
  36. package/dist/resources/generate.d.ts.map +1 -1
  37. package/dist/resources/generate.js +55 -13
  38. package/dist/resources/generations.d.ts +14 -6
  39. package/dist/resources/generations.d.ts.map +1 -1
  40. package/dist/resources/generations.js +26 -5
  41. package/dist/resources/projects.d.ts +106 -53
  42. package/dist/resources/projects.d.ts.map +1 -1
  43. package/dist/resources/projects.js +78 -31
  44. package/dist/resources/targets.d.ts +285 -22
  45. package/dist/resources/targets.d.ts.map +1 -1
  46. package/dist/resources/targets.js +408 -10
  47. package/dist/schemas.d.ts +1 -0
  48. package/dist/schemas.d.ts.map +1 -1
  49. package/dist/schemas.js +175 -102
  50. package/dist/types.d.ts +2162 -134
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/types.js +99 -2
  53. package/package.json +3 -3
  54. package/src/cli-agent.ts +17 -13
  55. package/src/cli.ts +138 -70
  56. package/src/core/http.ts +17 -6
  57. package/src/errors.ts +25 -15
  58. package/src/index.ts +9 -5
  59. package/src/ops.ts +49 -31
  60. package/src/polling-login.ts +10 -1
  61. package/src/resources/account.ts +11 -4
  62. package/src/resources/api-keys.ts +84 -13
  63. package/src/resources/definition-revisions.ts +74 -16
  64. package/src/resources/definitions.ts +28 -4
  65. package/src/resources/generate.ts +78 -13
  66. package/src/resources/generations.ts +31 -4
  67. package/src/resources/projects.ts +141 -39
  68. package/src/resources/targets.ts +756 -13
  69. package/src/schemas.ts +176 -103
  70. package/src/types.ts +2372 -189
@@ -1,5 +1,5 @@
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
4
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
5
  import {
@@ -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 Definition
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","meta","warnings","limits","claim"]` to keep the MCP result compact; files
37
+ * can exceed the response limit. Download the ZIP instead of repeating generation to retrieve
38
+ * omitted 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 `limits` 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`
@@ -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,14 +76,50 @@ 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(
94
+ params: GenerateDownloadPackageParams,
95
+ options?: RequestOptions,
96
+ ): Promise<ApiResult<Blob, GenerateDownloadPackageError>> {
97
+ return this._core.request<Blob, GenerateDownloadPackageError>({
98
+ method: "GET",
99
+ path: "/generate/download",
100
+ security: [{}],
101
+ query: {
102
+ token: params.token,
103
+ },
104
+ errors: {
105
+ "400": BadRequestError,
106
+ "404": NotFoundError,
107
+ "429": RateLimitedError,
108
+ "500": InternalServerError,
109
+ },
110
+ idempotent: true,
111
+ schemaKey: "generate.downloadPackage",
112
+ options,
113
+ });
114
+ }
67
115
  }
68
116
 
69
117
  export interface GenerateRunParams {
70
118
  /**
71
119
  * Identifies one logical write for 24 hours. The key is scoped to the authenticated account and
72
120
  * 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.
121
+ * path, query, If-Match header, and JSON body replays the original response. Reusing the key with
122
+ * changed intent returns 409. After expiry the key starts a new write.
75
123
  */
76
124
  idempotencyKey?: string;
77
125
  }
@@ -85,8 +133,25 @@ export type GenerateRunError =
85
133
  | PayloadTooLargeError
86
134
  | UnprocessableEntityError
87
135
  | RateLimitedError
136
+ | InternalServerError
88
137
  | ApiResponseError
89
138
  | UnexpectedApiError
90
139
  | ResponseParseError
91
140
  | TransportError
92
141
  | ValidationError;
142
+
143
+ export interface GenerateDownloadPackageParams {
144
+ /** Private download token from download.url in the generation result. */
145
+ token: string;
146
+ }
147
+
148
+ /** Every error `downloadPackage` can produce, as a discriminated union. */
149
+ export type GenerateDownloadPackageError =
150
+ | BadRequestError
151
+ | NotFoundError
152
+ | RateLimitedError
153
+ | InternalServerError
154
+ | UnexpectedApiError
155
+ | ResponseParseError
156
+ | TransportError
157
+ | ValidationError;
@@ -1,5 +1,5 @@
1
1
  // typeship — generations resource.
2
- // Generated by typeship — https://typeship.dev — do not edit by hand.
2
+ // Generated by typeship — https://typeship.dev
3
3
 
4
4
  import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
5
5
  import {
@@ -9,6 +9,7 @@ import {
9
9
  ValidationError,
10
10
  BadRequestError,
11
11
  ForbiddenError,
12
+ InternalServerError,
12
13
  NotFoundError,
13
14
  RateLimitedError,
14
15
  UnauthorizedError,
@@ -20,7 +21,10 @@ export class GenerationsResource {
20
21
  /**
21
22
  * Retrieve a generation
22
23
  *
23
- * Includes the generated files when the generation succeeded.
24
+ * Returns the current Generation status. `queued` and `running` mean generation is still in
25
+ * progress. `succeeded` means generated files are saved, not that repository delivery or a Draft
26
+ * is complete. Successful results include files, or a file index when the package is too large to
27
+ * inline.
24
28
  * `GET /generations/{generation_id}`
25
29
  */
26
30
  async retrieve(
@@ -36,6 +40,7 @@ export class GenerationsResource {
36
40
  "403": ForbiddenError,
37
41
  "404": NotFoundError,
38
42
  "429": RateLimitedError,
43
+ "500": InternalServerError,
39
44
  },
40
45
  idempotent: true,
41
46
  schemaKey: "generations.retrieve",
@@ -46,8 +51,8 @@ export class GenerationsResource {
46
51
  /**
47
52
  * Fetch one file from a generation
48
53
  *
49
- * Raw file content, for generations whose target was too large to inline (files_omitted true).
50
- * The generation's files_index lists valid paths.
54
+ * Returns one file's raw content. Use a path from `files_index` when the Generation reports
55
+ * `files_omitted: true`.
51
56
  * `GET /generations/{generation_id}/file`
52
57
  */
53
58
  async retrieveFile(
@@ -68,12 +73,32 @@ export class GenerationsResource {
68
73
  "403": ForbiddenError,
69
74
  "404": NotFoundError,
70
75
  "429": RateLimitedError,
76
+ "500": InternalServerError,
71
77
  },
72
78
  idempotent: true,
73
79
  schemaKey: "generations.retrieveFile",
74
80
  options,
75
81
  });
76
82
  }
83
+
84
+ /** Poll until files are generated or the Generation fails. */
85
+ async wait(
86
+ generationId: GenerationId,
87
+ options: RequestOptions & { intervalMs?: number; waitTimeoutMs?: number } = {},
88
+ ): Promise<ApiResult<GenerationResponseRead, GenerationsRetrieveError>> {
89
+ const { intervalMs = 1_000, waitTimeoutMs = 600_000, ...requestOptions } = options;
90
+ const deadline = Date.now() + waitTimeoutMs;
91
+ while (true) {
92
+ if (requestOptions.signal?.aborted) {
93
+ throw requestOptions.signal.reason ?? new Error("Generation wait aborted.");
94
+ }
95
+ const result = await this.retrieve(generationId, requestOptions);
96
+ if (!result.ok || (result.data.status !== "queued" && result.data.status !== "running")) return result;
97
+ if (Date.now() >= deadline) throw new Error("Timed out waiting for Generation " + generationId + ".");
98
+ await new Promise<void>((resolve) =>
99
+ setTimeout(resolve, Math.min(intervalMs, deadline - Date.now())));
100
+ }
101
+ }
77
102
  }
78
103
 
79
104
  /** Every error `retrieve` can produce, as a discriminated union. */
@@ -82,6 +107,7 @@ export type GenerationsRetrieveError =
82
107
  | ForbiddenError
83
108
  | NotFoundError
84
109
  | RateLimitedError
110
+ | InternalServerError
85
111
  | UnexpectedApiError
86
112
  | ResponseParseError
87
113
  | TransportError
@@ -99,6 +125,7 @@ export type GenerationsRetrieveFileError =
99
125
  | ForbiddenError
100
126
  | NotFoundError
101
127
  | RateLimitedError
128
+ | InternalServerError
102
129
  | UnexpectedApiError
103
130
  | ResponseParseError
104
131
  | TransportError