@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
@@ -1,7 +1,8 @@
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
- import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
4
+ import { HttpCore, type RequestOptions } from "../core/http.js";
5
+ import { paginate, PagePromise } from "../core/pagination.js";
5
6
  import {
6
7
  ResponseParseError,
7
8
  TransportError,
@@ -9,25 +10,82 @@ import {
9
10
  ValidationError,
10
11
  BadRequestError,
11
12
  ForbiddenError,
13
+ InternalServerError,
12
14
  NotFoundError,
13
15
  RateLimitedError,
14
16
  UnauthorizedError,
15
17
  } from "../errors.js";
16
- import type { GenerationId, GenerationResponse, GenerationResponseRead } from "../types.js";
18
+ import type {
19
+ FileList,
20
+ FileListRead,
21
+ FileModel,
22
+ FileModelRead,
23
+ GenerationId,
24
+ GenerationList,
25
+ GenerationListRead,
26
+ GenerationResponse,
27
+ GenerationResponseRead,
28
+ GenerationStatus,
29
+ GenerationSummary,
30
+ GenerationSummaryRead,
31
+ ProjectId,
32
+ TargetId,
33
+ } from "../types.js";
17
34
 
18
35
  export class GenerationsResource {
19
36
  constructor(private readonly _core: HttpCore) {}
20
37
  /**
21
- * Retrieve a generation
38
+ * List generations
22
39
  *
23
- * Includes the generated files when the generation succeeded.
24
- * `GET /generations/{generation_id}`
40
+ * Auto-paginates: `for await (const item of …)` walks every page.
41
+ * `GET /generations`
25
42
  */
26
- async retrieve(
27
- generationId: GenerationId,
43
+ list(
44
+ params?: GenerationsListParams,
28
45
  options?: RequestOptions,
29
- ): Promise<ApiResult<GenerationResponseRead, GenerationsRetrieveError>> {
30
- return this._core.request<GenerationResponseRead, GenerationsRetrieveError>({
46
+ ): PagePromise<GenerationSummaryRead, GenerationsListError> {
47
+ return paginate<GenerationSummaryRead, GenerationsListError>(this._core, {
48
+ method: "GET",
49
+ path: "/generations",
50
+ security: [{"apiKey":[]}],
51
+ query: {
52
+ limit: params?.limit,
53
+ cursor: params?.cursor,
54
+ project_id: params?.projectId,
55
+ target_id: params?.targetId,
56
+ status: params?.status,
57
+ },
58
+ errors: {
59
+ "400": BadRequestError,
60
+ "401": UnauthorizedError,
61
+ "403": ForbiddenError,
62
+ "404": NotFoundError,
63
+ "429": RateLimitedError,
64
+ "500": InternalServerError,
65
+ },
66
+ idempotent: true,
67
+ schemaKey: "generations.list",
68
+ options,
69
+ }, {
70
+ style: "cursor",
71
+ itemsField: "data",
72
+ cursorParam: "cursor",
73
+ nextCursorField: "next_cursor",
74
+ hasMoreField: "has_more",
75
+ limitParam: "limit",
76
+ });
77
+ }
78
+
79
+ /**
80
+ * Get a generation
81
+ *
82
+ * Returns the status of that Generation. `queued` and `running` mean generation is still in
83
+ * progress. `completed` means generated files are saved, not that repository delivery or a Draft
84
+ * is complete. List its files with listGenerationFiles and read each with getFile.
85
+ * `GET /generations/{generation_id}`
86
+ */
87
+ async get(generationId: GenerationId, options?: RequestOptions): Promise<GenerationResponseRead> {
88
+ return this._core.requestData<GenerationResponseRead, GenerationsGetError>({
31
89
  method: "GET",
32
90
  path: `/generations/${encodeURIComponent(String(generationId))}`,
33
91
  security: [{"apiKey":[]}],
@@ -36,31 +94,34 @@ export class GenerationsResource {
36
94
  "403": ForbiddenError,
37
95
  "404": NotFoundError,
38
96
  "429": RateLimitedError,
97
+ "500": InternalServerError,
39
98
  },
40
99
  idempotent: true,
41
- schemaKey: "generations.retrieve",
100
+ schemaKey: "generations.get",
42
101
  options,
43
102
  });
44
103
  }
45
104
 
46
105
  /**
47
- * Fetch one file from a generation
106
+ * List a Generation's files
107
+ *
108
+ * Lists the generated package's files, ordered by path. Read content with getFile.
48
109
  *
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.
51
- * `GET /generations/{generation_id}/file`
110
+ * Auto-paginates: `for await (const item of …)` walks every page.
111
+ * `GET /generations/{generation_id}/files`
52
112
  */
53
- async retrieveFile(
113
+ listFiles(
54
114
  generationId: GenerationId,
55
- params: GenerationsRetrieveFileParams,
115
+ params?: GenerationsListFilesParams,
56
116
  options?: RequestOptions,
57
- ): Promise<ApiResult<string, GenerationsRetrieveFileError>> {
58
- return this._core.request<string, GenerationsRetrieveFileError>({
117
+ ): PagePromise<FileModelRead, GenerationsListFilesError> {
118
+ return paginate<FileModelRead, GenerationsListFilesError>(this._core, {
59
119
  method: "GET",
60
- path: `/generations/${encodeURIComponent(String(generationId))}/file`,
120
+ path: `/generations/${encodeURIComponent(String(generationId))}/files`,
61
121
  security: [{"apiKey":[]}],
62
122
  query: {
63
- path: params.path,
123
+ limit: params?.limit,
124
+ cursor: params?.cursor,
64
125
  },
65
126
  errors: {
66
127
  "400": BadRequestError,
@@ -68,37 +129,114 @@ export class GenerationsResource {
68
129
  "403": ForbiddenError,
69
130
  "404": NotFoundError,
70
131
  "429": RateLimitedError,
132
+ "500": InternalServerError,
71
133
  },
72
134
  idempotent: true,
73
- schemaKey: "generations.retrieveFile",
135
+ schemaKey: "generations.listFiles",
74
136
  options,
137
+ }, {
138
+ style: "cursor",
139
+ itemsField: "data",
140
+ cursorParam: "cursor",
141
+ nextCursorField: "next_cursor",
142
+ hasMoreField: "has_more",
143
+ limitParam: "limit",
75
144
  });
76
145
  }
146
+
147
+ /** Poll until files are generated or the Generation fails. */
148
+ async wait(
149
+ generationId: GenerationId,
150
+ options: RequestOptions & { intervalMs?: number; waitTimeoutMs?: number } = {},
151
+ ): Promise<GenerationResponseRead> {
152
+ const { intervalMs = 3_000, waitTimeoutMs = 600_000, ...requestOptions } = options;
153
+ const deadline = Date.now() + waitTimeoutMs;
154
+ while (true) {
155
+ if (requestOptions.signal?.aborted) {
156
+ throw requestOptions.signal.reason ?? new Error("Generation wait aborted.");
157
+ }
158
+ const result = await this.get(generationId, requestOptions);
159
+ if (result.status !== "queued" && result.status !== "running") return result;
160
+ if (Date.now() >= deadline) throw new Error("Timed out waiting for Generation " + generationId + ".");
161
+ await new Promise<void>((resolve) =>
162
+ setTimeout(resolve, Math.min(intervalMs, deadline - Date.now())));
163
+ }
164
+ }
165
+ }
166
+
167
+ export interface GenerationsListParams {
168
+ /**
169
+ * Maximum number of resources to return. Omit for 20; otherwise supply base-10 digits
170
+ * representing an integer from 1 to 100. Empty, malformed, or out-of-range values return 400
171
+ * invalid_request. List query parameters must appear only once; unrecognized parameters also
172
+ * return 400.
173
+ */
174
+ limit?: number;
175
+ /**
176
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same organization,
177
+ * operation, filters, and ordering that issued it. Omit to start at the first page. Empty,
178
+ * malformed, or repeated cursors return 400 invalid_request. The page limit may change between
179
+ * requests.
180
+ */
181
+ cursor?: string;
182
+ /** Only Generations in this Project. */
183
+ projectId?: ProjectId;
184
+ /** Only Generations of this Target. */
185
+ targetId?: TargetId;
186
+ /** Only Generations with this status. */
187
+ status?: GenerationStatus;
77
188
  }
78
189
 
79
- /** Every error `retrieve` can produce, as a discriminated union. */
80
- export type GenerationsRetrieveError =
190
+ /** Typed errors `list` can throw. */
191
+ export type GenerationsListError =
192
+ | BadRequestError
81
193
  | UnauthorizedError
82
194
  | ForbiddenError
83
195
  | NotFoundError
84
196
  | RateLimitedError
197
+ | InternalServerError
85
198
  | UnexpectedApiError
86
199
  | ResponseParseError
87
200
  | TransportError
88
201
  | ValidationError;
89
202
 
90
- export interface GenerationsRetrieveFileParams {
91
- /** Repo-relative path inside the generated package. */
92
- path: string;
203
+ /** Typed errors `get` can throw. */
204
+ export type GenerationsGetError =
205
+ | UnauthorizedError
206
+ | ForbiddenError
207
+ | NotFoundError
208
+ | RateLimitedError
209
+ | InternalServerError
210
+ | UnexpectedApiError
211
+ | ResponseParseError
212
+ | TransportError
213
+ | ValidationError;
214
+
215
+ export interface GenerationsListFilesParams {
216
+ /**
217
+ * Maximum number of resources to return. Omit for 20; otherwise supply base-10 digits
218
+ * representing an integer from 1 to 100. Empty, malformed, or out-of-range values return 400
219
+ * invalid_request. List query parameters must appear only once; unrecognized parameters also
220
+ * return 400.
221
+ */
222
+ limit?: number;
223
+ /**
224
+ * Opaque cursor from the preceding page's next_cursor. Valid only for the same organization,
225
+ * operation, filters, and ordering that issued it. Omit to start at the first page. Empty,
226
+ * malformed, or repeated cursors return 400 invalid_request. The page limit may change between
227
+ * requests.
228
+ */
229
+ cursor?: string;
93
230
  }
94
231
 
95
- /** Every error `retrieveFile` can produce, as a discriminated union. */
96
- export type GenerationsRetrieveFileError =
232
+ /** Typed errors `listFiles` can throw. */
233
+ export type GenerationsListFilesError =
97
234
  | BadRequestError
98
235
  | UnauthorizedError
99
236
  | ForbiddenError
100
237
  | NotFoundError
101
238
  | RateLimitedError
239
+ | InternalServerError
102
240
  | UnexpectedApiError
103
241
  | ResponseParseError
104
242
  | TransportError
@@ -0,0 +1,53 @@
1
+ // typeship — organization 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
+ ForbiddenError,
11
+ InternalServerError,
12
+ RateLimitedError,
13
+ UnauthorizedError,
14
+ } from "../errors.js";
15
+ import type { Organization, OrganizationRead } from "../types.js";
16
+
17
+ export class OrganizationResource {
18
+ constructor(private readonly _core: HttpCore) {}
19
+ /**
20
+ * The organization behind the presented credentials
21
+ *
22
+ * Returns the organization associated with your credential. The Typeship CLI uses this endpoint
23
+ * for `whoami`.
24
+ * `GET /organization`
25
+ */
26
+ async get(options?: RequestOptions): Promise<OrganizationRead> {
27
+ return this._core.requestData<OrganizationRead, OrganizationGetError>({
28
+ method: "GET",
29
+ path: "/organization",
30
+ security: [{"apiKey":[]}],
31
+ errors: {
32
+ "401": UnauthorizedError,
33
+ "403": ForbiddenError,
34
+ "429": RateLimitedError,
35
+ "500": InternalServerError,
36
+ },
37
+ idempotent: true,
38
+ schemaKey: "organization.get",
39
+ options,
40
+ });
41
+ }
42
+ }
43
+
44
+ /** Typed errors `get` can throw. */
45
+ export type OrganizationGetError =
46
+ | UnauthorizedError
47
+ | ForbiddenError
48
+ | RateLimitedError
49
+ | InternalServerError
50
+ | UnexpectedApiError
51
+ | ResponseParseError
52
+ | TransportError
53
+ | ValidationError;