@typeship-ax/cli 0.10.0 → 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.
- package/AGENTS.md +9 -4
- package/README.md +4 -4
- package/api.json +4829 -679
- package/api.md +387 -91
- package/dist/cli-agent.d.ts +5 -5
- package/dist/cli-agent.d.ts.map +1 -1
- package/dist/cli-agent.js +14 -10
- package/dist/cli.js +151 -75
- package/dist/core/http.d.ts +3 -2
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +18 -6
- package/dist/errors.d.ts +17 -10
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +24 -15
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/ops.d.ts +4 -0
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +45 -35
- package/dist/polling-login.d.ts.map +1 -1
- package/dist/polling-login.js +11 -1
- package/dist/resources/account.d.ts +4 -4
- package/dist/resources/account.d.ts.map +1 -1
- package/dist/resources/account.js +10 -5
- package/dist/resources/api-keys.d.ts +40 -14
- package/dist/resources/api-keys.d.ts.map +1 -1
- package/dist/resources/api-keys.js +45 -13
- package/dist/resources/definition-revisions.d.ts +35 -18
- package/dist/resources/definition-revisions.d.ts.map +1 -1
- package/dist/resources/definition-revisions.js +43 -15
- package/dist/resources/definitions.d.ts +21 -6
- package/dist/resources/definitions.d.ts.map +1 -1
- package/dist/resources/definitions.js +16 -3
- package/dist/resources/generate.d.ts +44 -15
- package/dist/resources/generate.d.ts.map +1 -1
- package/dist/resources/generate.js +55 -13
- package/dist/resources/generations.d.ts +14 -6
- package/dist/resources/generations.d.ts.map +1 -1
- package/dist/resources/generations.js +26 -5
- package/dist/resources/projects.d.ts +106 -53
- package/dist/resources/projects.d.ts.map +1 -1
- package/dist/resources/projects.js +78 -31
- package/dist/resources/targets.d.ts +240 -40
- package/dist/resources/targets.d.ts.map +1 -1
- package/dist/resources/targets.js +307 -21
- package/dist/schemas.d.ts +1 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +171 -111
- package/dist/types.d.ts +1969 -154
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +87 -3
- package/package.json +3 -3
- package/src/cli-agent.ts +17 -13
- package/src/cli.ts +138 -70
- package/src/core/http.ts +17 -6
- package/src/errors.ts +25 -15
- package/src/index.ts +9 -5
- package/src/ops.ts +49 -35
- package/src/polling-login.ts +10 -1
- package/src/resources/account.ts +11 -4
- package/src/resources/api-keys.ts +84 -13
- package/src/resources/definition-revisions.ts +74 -16
- package/src/resources/definitions.ts +28 -4
- package/src/resources/generate.ts +78 -13
- package/src/resources/generations.ts +31 -4
- package/src/resources/projects.ts +141 -39
- package/src/resources/targets.ts +561 -27
- package/src/schemas.ts +172 -112
- package/src/types.ts +2105 -154
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// typeship — definitions resource.
|
|
2
|
-
// Generated by typeship — https://typeship.dev
|
|
3
|
-
import { BadRequestError, ConflictError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError, UnprocessableEntityError, } from "../errors.js";
|
|
2
|
+
// Generated by typeship — https://typeship.dev
|
|
3
|
+
import { BadRequestError, ConflictError, ForbiddenError, InternalServerError, NotFoundError, PreconditionFailedError, RateLimitedError, UnauthorizedError, UnprocessableEntityError, } from "../errors.js";
|
|
4
4
|
export class DefinitionsResource {
|
|
5
5
|
_core;
|
|
6
6
|
constructor(_core) {
|
|
@@ -20,6 +20,7 @@ export class DefinitionsResource {
|
|
|
20
20
|
"403": ForbiddenError,
|
|
21
21
|
"404": NotFoundError,
|
|
22
22
|
"429": RateLimitedError,
|
|
23
|
+
"500": InternalServerError,
|
|
23
24
|
},
|
|
24
25
|
idempotent: true,
|
|
25
26
|
schemaKey: "definitions.retrieve",
|
|
@@ -29,7 +30,16 @@ export class DefinitionsResource {
|
|
|
29
30
|
/**
|
|
30
31
|
* Update and resolve a Definition
|
|
31
32
|
*
|
|
32
|
-
* Resolves the
|
|
33
|
+
* Resolves the source documents before saving the update and records a new Definition Revision
|
|
34
|
+
* when the source changes.
|
|
35
|
+
* Omitted fields remain unchanged; supplied objects and arrays replace the whole field.
|
|
36
|
+
* If the Definition or its Project configuration changes during validation, returns 409
|
|
37
|
+
* definition_changed without saving the rejected update. Retrieve the current Definition and
|
|
38
|
+
* Project, reconcile your changes,
|
|
39
|
+
* and submit a new request with a new Idempotency-Key if using one.
|
|
40
|
+
*
|
|
41
|
+
* See [conditional writes](https://typeship.dev/docs/typeship-api#conditional-writes) for ETag
|
|
42
|
+
* and If-Match.
|
|
33
43
|
*
|
|
34
44
|
* A `Idempotency-Key` UUID is generated per call (stable across retries) unless you pass one.
|
|
35
45
|
* `PATCH /definitions/{definition_id}`
|
|
@@ -40,6 +50,7 @@ export class DefinitionsResource {
|
|
|
40
50
|
path: `/definitions/${encodeURIComponent(String(definitionId))}`,
|
|
41
51
|
security: [{ "apiKey": [] }],
|
|
42
52
|
headers: {
|
|
53
|
+
"If-Match": params?.ifMatch === undefined ? undefined : String(params?.ifMatch),
|
|
43
54
|
"Idempotency-Key": params?.idempotencyKey === undefined ? undefined : String(params?.idempotencyKey),
|
|
44
55
|
},
|
|
45
56
|
body,
|
|
@@ -49,8 +60,10 @@ export class DefinitionsResource {
|
|
|
49
60
|
"403": ForbiddenError,
|
|
50
61
|
"404": NotFoundError,
|
|
51
62
|
"409": ConflictError,
|
|
63
|
+
"412": PreconditionFailedError,
|
|
52
64
|
"422": UnprocessableEntityError,
|
|
53
65
|
"429": RateLimitedError,
|
|
66
|
+
"500": InternalServerError,
|
|
54
67
|
},
|
|
55
68
|
idempotencyKey: "Idempotency-Key",
|
|
56
69
|
schemaKey: "definitions.update",
|
|
@@ -1,36 +1,65 @@
|
|
|
1
1
|
import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
|
|
2
|
-
import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, ApiResponseError, BadRequestError, ConflictError, ForbiddenError, PayloadTooLargeError, RateLimitedError, UnauthorizedError, UnprocessableEntityError } from "../errors.js";
|
|
2
|
+
import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, ApiResponseError, BadRequestError, ConflictError, ForbiddenError, InternalServerError, NotFoundError, PayloadTooLargeError, RateLimitedError, UnauthorizedError, UnprocessableEntityError } from "../errors.js";
|
|
3
3
|
import type { GenerateRequest, GenerationResultRead } from "../types.js";
|
|
4
4
|
export declare class GenerateResource {
|
|
5
5
|
private readonly _core;
|
|
6
6
|
constructor(_core: HttpCore);
|
|
7
7
|
/**
|
|
8
|
-
* Generate one
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
8
|
+
* Generate one package from a Definition
|
|
9
|
+
*
|
|
10
|
+
* Returns one generated package without creating a Project.
|
|
11
|
+
*
|
|
12
|
+
* Supports [idempotent retries](https://typeship.dev/docs/typeship-api/idempotency); keyed
|
|
13
|
+
* responses include generated files in the replay cache.
|
|
14
|
+
*
|
|
15
|
+
* Use `download.url` to save the complete ZIP, verify `download.sha256`, and extract it into an
|
|
16
|
+
* empty directory. The link expires at `download.expires_at` and grants access to anyone who has
|
|
17
|
+
* it. CLI, MCP, and SDK calls supply an idempotency key automatically. Agents should request
|
|
18
|
+
* `fields=["download","meta","warnings","limits","claim"]` to keep the MCP result compact; files
|
|
19
|
+
* can exceed the response limit. Download the ZIP instead of repeating generation to retrieve
|
|
20
|
+
* omitted files.
|
|
21
|
+
*
|
|
22
|
+
* Anonymous and Free requests include the first 25 operations. Paid plans include all operations.
|
|
23
|
+
* Anonymous requests are rate limited by IP address. Check `limits` for omitted operations; an
|
|
24
|
+
* invalid API key returns `401`.
|
|
25
|
+
*
|
|
26
|
+
* An anonymous URL request without source headers may return `claim.url`. Sign in through that
|
|
27
|
+
* link within seven days to save the recipe as a Project.
|
|
19
28
|
*
|
|
20
29
|
* A `Idempotency-Key` UUID is generated per call (stable across retries) unless you pass one.
|
|
21
30
|
* `POST /generate`
|
|
22
31
|
*/
|
|
23
32
|
run(body: GenerateRequest, params?: GenerateRunParams, options?: RequestOptions): Promise<ApiResult<GenerationResultRead, GenerateRunError>>;
|
|
33
|
+
/**
|
|
34
|
+
* Download a generated package
|
|
35
|
+
*
|
|
36
|
+
* Download the complete ZIP referenced by `generate_run`'s `download.url`. Pass the token from
|
|
37
|
+
* that URL. No API key is needed; the token grants access only to that exact package until its
|
|
38
|
+
* replay window expires. Keep the token private.
|
|
39
|
+
*
|
|
40
|
+
* The local MCP server saves this binary response to disk. On a hosted MCP connection, download
|
|
41
|
+
* the original URL directly to your workspace. Verify the ZIP against `download.sha256` before
|
|
42
|
+
* extracting it into an empty directory. Expired or invalid tokens return `404`; a new generation
|
|
43
|
+
* creates a new download.
|
|
44
|
+
* `GET /generate/download`
|
|
45
|
+
*/
|
|
46
|
+
downloadPackage(params: GenerateDownloadPackageParams, options?: RequestOptions): Promise<ApiResult<Blob, GenerateDownloadPackageError>>;
|
|
24
47
|
}
|
|
25
48
|
export interface GenerateRunParams {
|
|
26
49
|
/**
|
|
27
50
|
* Identifies one logical write for 24 hours. The key is scoped to the authenticated account and
|
|
28
51
|
* operation; account-less generation uses a hashed network identity. Retrying the same method,
|
|
29
|
-
* path, query, and JSON body replays the original response. Reusing the key with
|
|
30
|
-
* returns 409. After expiry the key starts a new write.
|
|
52
|
+
* path, query, If-Match header, and JSON body replays the original response. Reusing the key with
|
|
53
|
+
* changed intent returns 409. After expiry the key starts a new write.
|
|
31
54
|
*/
|
|
32
55
|
idempotencyKey?: string;
|
|
33
56
|
}
|
|
34
57
|
/** Every error `run` can produce, as a discriminated union. */
|
|
35
|
-
export type GenerateRunError = BadRequestError | UnauthorizedError | ForbiddenError | ConflictError | PayloadTooLargeError | UnprocessableEntityError | RateLimitedError | ApiResponseError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
|
|
58
|
+
export type GenerateRunError = BadRequestError | UnauthorizedError | ForbiddenError | ConflictError | PayloadTooLargeError | UnprocessableEntityError | RateLimitedError | InternalServerError | ApiResponseError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
|
|
59
|
+
export interface GenerateDownloadPackageParams {
|
|
60
|
+
/** Private download token from download.url in the generation result. */
|
|
61
|
+
token: string;
|
|
62
|
+
}
|
|
63
|
+
/** Every error `downloadPackage` can produce, as a discriminated union. */
|
|
64
|
+
export type GenerateDownloadPackageError = BadRequestError | NotFoundError | RateLimitedError | InternalServerError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
|
|
36
65
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/resources/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAoB,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE3F,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,QAAQ;IAC5C
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/resources/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,gBAAgB,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|
// typeship — generate resource.
|
|
2
|
-
// Generated by typeship — https://typeship.dev
|
|
3
|
-
import { ApiResponseError, BadRequestError, ConflictError, ForbiddenError, PayloadTooLargeError, RateLimitedError, UnauthorizedError, UnprocessableEntityError, } from "../errors.js";
|
|
2
|
+
// Generated by typeship — https://typeship.dev
|
|
3
|
+
import { ApiResponseError, BadRequestError, ConflictError, ForbiddenError, InternalServerError, NotFoundError, PayloadTooLargeError, RateLimitedError, UnauthorizedError, UnprocessableEntityError, } from "../errors.js";
|
|
4
4
|
export class GenerateResource {
|
|
5
5
|
_core;
|
|
6
6
|
constructor(_core) {
|
|
7
7
|
this._core = _core;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Generate one
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
10
|
+
* Generate one package from a Definition
|
|
11
|
+
*
|
|
12
|
+
* Returns one generated package without creating a Project.
|
|
13
|
+
*
|
|
14
|
+
* Supports [idempotent retries](https://typeship.dev/docs/typeship-api/idempotency); keyed
|
|
15
|
+
* responses include generated files in the replay cache.
|
|
16
|
+
*
|
|
17
|
+
* Use `download.url` to save the complete ZIP, verify `download.sha256`, and extract it into an
|
|
18
|
+
* empty directory. The link expires at `download.expires_at` and grants access to anyone who has
|
|
19
|
+
* it. CLI, MCP, and SDK calls supply an idempotency key automatically. Agents should request
|
|
20
|
+
* `fields=["download","meta","warnings","limits","claim"]` to keep the MCP result compact; files
|
|
21
|
+
* can exceed the response limit. Download the ZIP instead of repeating generation to retrieve
|
|
22
|
+
* omitted files.
|
|
23
|
+
*
|
|
24
|
+
* Anonymous and Free requests include the first 25 operations. Paid plans include all operations.
|
|
25
|
+
* Anonymous requests are rate limited by IP address. Check `limits` for omitted operations; an
|
|
26
|
+
* invalid API key returns `401`.
|
|
27
|
+
*
|
|
28
|
+
* An anonymous URL request without source headers may return `claim.url`. Sign in through that
|
|
29
|
+
* link within seven days to save the recipe as a Project.
|
|
21
30
|
*
|
|
22
31
|
* A `Idempotency-Key` UUID is generated per call (stable across retries) unless you pass one.
|
|
23
32
|
* `POST /generate`
|
|
@@ -39,6 +48,7 @@ export class GenerateResource {
|
|
|
39
48
|
"413": PayloadTooLargeError,
|
|
40
49
|
"422": UnprocessableEntityError,
|
|
41
50
|
"429": RateLimitedError,
|
|
51
|
+
"500": InternalServerError,
|
|
42
52
|
default: ApiResponseError,
|
|
43
53
|
},
|
|
44
54
|
idempotencyKey: "Idempotency-Key",
|
|
@@ -46,4 +56,36 @@ export class GenerateResource {
|
|
|
46
56
|
options,
|
|
47
57
|
});
|
|
48
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Download a generated package
|
|
61
|
+
*
|
|
62
|
+
* Download the complete ZIP referenced by `generate_run`'s `download.url`. Pass the token from
|
|
63
|
+
* that URL. No API key is needed; the token grants access only to that exact package until its
|
|
64
|
+
* replay window expires. Keep the token private.
|
|
65
|
+
*
|
|
66
|
+
* The local MCP server saves this binary response to disk. On a hosted MCP connection, download
|
|
67
|
+
* the original URL directly to your workspace. Verify the ZIP against `download.sha256` before
|
|
68
|
+
* extracting it into an empty directory. Expired or invalid tokens return `404`; a new generation
|
|
69
|
+
* creates a new download.
|
|
70
|
+
* `GET /generate/download`
|
|
71
|
+
*/
|
|
72
|
+
async downloadPackage(params, options) {
|
|
73
|
+
return this._core.request({
|
|
74
|
+
method: "GET",
|
|
75
|
+
path: "/generate/download",
|
|
76
|
+
security: [{}],
|
|
77
|
+
query: {
|
|
78
|
+
token: params.token,
|
|
79
|
+
},
|
|
80
|
+
errors: {
|
|
81
|
+
"400": BadRequestError,
|
|
82
|
+
"404": NotFoundError,
|
|
83
|
+
"429": RateLimitedError,
|
|
84
|
+
"500": InternalServerError,
|
|
85
|
+
},
|
|
86
|
+
idempotent: true,
|
|
87
|
+
schemaKey: "generate.downloadPackage",
|
|
88
|
+
options,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
49
91
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpCore, type ApiResult, type RequestOptions } from "../core/http.js";
|
|
2
|
-
import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, BadRequestError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError } from "../errors.js";
|
|
2
|
+
import { ResponseParseError, TransportError, UnexpectedApiError, ValidationError, BadRequestError, ForbiddenError, InternalServerError, NotFoundError, RateLimitedError, UnauthorizedError } from "../errors.js";
|
|
3
3
|
import type { GenerationId, GenerationResponseRead } from "../types.js";
|
|
4
4
|
export declare class GenerationsResource {
|
|
5
5
|
private readonly _core;
|
|
@@ -7,25 +7,33 @@ export declare class GenerationsResource {
|
|
|
7
7
|
/**
|
|
8
8
|
* Retrieve a generation
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* Returns the current Generation status. `queued` and `running` mean generation is still in
|
|
11
|
+
* progress. `succeeded` means generated files are saved, not that repository delivery or a Draft
|
|
12
|
+
* is complete. Successful results include files, or a file index when the package is too large to
|
|
13
|
+
* inline.
|
|
11
14
|
* `GET /generations/{generation_id}`
|
|
12
15
|
*/
|
|
13
16
|
retrieve(generationId: GenerationId, options?: RequestOptions): Promise<ApiResult<GenerationResponseRead, GenerationsRetrieveError>>;
|
|
14
17
|
/**
|
|
15
18
|
* Fetch one file from a generation
|
|
16
19
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* Returns one file's raw content. Use a path from `files_index` when the Generation reports
|
|
21
|
+
* `files_omitted: true`.
|
|
19
22
|
* `GET /generations/{generation_id}/file`
|
|
20
23
|
*/
|
|
21
24
|
retrieveFile(generationId: GenerationId, params: GenerationsRetrieveFileParams, options?: RequestOptions): Promise<ApiResult<string, GenerationsRetrieveFileError>>;
|
|
25
|
+
/** Poll until files are generated or the Generation fails. */
|
|
26
|
+
wait(generationId: GenerationId, options?: RequestOptions & {
|
|
27
|
+
intervalMs?: number;
|
|
28
|
+
waitTimeoutMs?: number;
|
|
29
|
+
}): Promise<ApiResult<GenerationResponseRead, GenerationsRetrieveError>>;
|
|
22
30
|
}
|
|
23
31
|
/** Every error `retrieve` can produce, as a discriminated union. */
|
|
24
|
-
export type GenerationsRetrieveError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
|
|
32
|
+
export type GenerationsRetrieveError = UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | InternalServerError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
|
|
25
33
|
export interface GenerationsRetrieveFileParams {
|
|
26
34
|
/** Repo-relative path inside the generated package. */
|
|
27
35
|
path: string;
|
|
28
36
|
}
|
|
29
37
|
/** Every error `retrieveFile` can produce, as a discriminated union. */
|
|
30
|
-
export type GenerationsRetrieveFileError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
|
|
38
|
+
export type GenerationsRetrieveFileError = BadRequestError | UnauthorizedError | ForbiddenError | NotFoundError | RateLimitedError | InternalServerError | UnexpectedApiError | ResponseParseError | TransportError | ValidationError;
|
|
31
39
|
//# sourceMappingURL=generations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generations.d.ts","sourceRoot":"","sources":["../../src/resources/generations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAsB,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE5F,qBAAa,mBAAm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,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,WAAW,6BAA6B;IAC5C,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wEAAwE;AACxE,MAAM,MAAM,4BAA4B,GACpC,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,eAAe,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// typeship — generations resource.
|
|
2
|
-
// Generated by typeship — https://typeship.dev
|
|
3
|
-
import { BadRequestError, ForbiddenError, NotFoundError, RateLimitedError, UnauthorizedError, } from "../errors.js";
|
|
2
|
+
// Generated by typeship — https://typeship.dev
|
|
3
|
+
import { BadRequestError, ForbiddenError, InternalServerError, NotFoundError, RateLimitedError, UnauthorizedError, } from "../errors.js";
|
|
4
4
|
export class GenerationsResource {
|
|
5
5
|
_core;
|
|
6
6
|
constructor(_core) {
|
|
@@ -9,7 +9,10 @@ export class GenerationsResource {
|
|
|
9
9
|
/**
|
|
10
10
|
* Retrieve a generation
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Returns the current Generation status. `queued` and `running` mean generation is still in
|
|
13
|
+
* progress. `succeeded` means generated files are saved, not that repository delivery or a Draft
|
|
14
|
+
* is complete. Successful results include files, or a file index when the package is too large to
|
|
15
|
+
* inline.
|
|
13
16
|
* `GET /generations/{generation_id}`
|
|
14
17
|
*/
|
|
15
18
|
async retrieve(generationId, options) {
|
|
@@ -22,6 +25,7 @@ export class GenerationsResource {
|
|
|
22
25
|
"403": ForbiddenError,
|
|
23
26
|
"404": NotFoundError,
|
|
24
27
|
"429": RateLimitedError,
|
|
28
|
+
"500": InternalServerError,
|
|
25
29
|
},
|
|
26
30
|
idempotent: true,
|
|
27
31
|
schemaKey: "generations.retrieve",
|
|
@@ -31,8 +35,8 @@ export class GenerationsResource {
|
|
|
31
35
|
/**
|
|
32
36
|
* Fetch one file from a generation
|
|
33
37
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
38
|
+
* Returns one file's raw content. Use a path from `files_index` when the Generation reports
|
|
39
|
+
* `files_omitted: true`.
|
|
36
40
|
* `GET /generations/{generation_id}/file`
|
|
37
41
|
*/
|
|
38
42
|
async retrieveFile(generationId, params, options) {
|
|
@@ -49,10 +53,27 @@ export class GenerationsResource {
|
|
|
49
53
|
"403": ForbiddenError,
|
|
50
54
|
"404": NotFoundError,
|
|
51
55
|
"429": RateLimitedError,
|
|
56
|
+
"500": InternalServerError,
|
|
52
57
|
},
|
|
53
58
|
idempotent: true,
|
|
54
59
|
schemaKey: "generations.retrieveFile",
|
|
55
60
|
options,
|
|
56
61
|
});
|
|
57
62
|
}
|
|
63
|
+
/** Poll until files are generated or the Generation fails. */
|
|
64
|
+
async wait(generationId, options = {}) {
|
|
65
|
+
const { intervalMs = 1_000, waitTimeoutMs = 600_000, ...requestOptions } = options;
|
|
66
|
+
const deadline = Date.now() + waitTimeoutMs;
|
|
67
|
+
while (true) {
|
|
68
|
+
if (requestOptions.signal?.aborted) {
|
|
69
|
+
throw requestOptions.signal.reason ?? new Error("Generation wait aborted.");
|
|
70
|
+
}
|
|
71
|
+
const result = await this.retrieve(generationId, requestOptions);
|
|
72
|
+
if (!result.ok || (result.data.status !== "queued" && result.data.status !== "running"))
|
|
73
|
+
return result;
|
|
74
|
+
if (Date.now() >= deadline)
|
|
75
|
+
throw new Error("Timed out waiting for Generation " + generationId + ".");
|
|
76
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, deadline - Date.now())));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
58
79
|
}
|