@antelopejs/cloud-sdk 0.1.1 → 0.1.3
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/README.md +2 -2
- package/dist/api.d.ts +21 -9
- package/dist/api.js +20 -16
- package/dist/deployments.d.ts +21 -0
- package/dist/deployments.js +17 -0
- package/dist/generated/cloud-api.d.ts +173 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/result.d.ts +3 -5
- package/dist/result.js +12 -5
- package/dist/sse.d.ts +5 -0
- package/dist/sse.js +15 -0
- package/openapi/cloud.openapi.yaml +7 -59
- package/openapi/deployments.yaml +150 -0
- package/openapi/projects.yaml +65 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@antelopejs/cloud-sdk`
|
|
2
2
|
|
|
3
|
-
A typed client for the AntelopeJS Cloud API: the client the `ajs
|
|
3
|
+
A typed client for the AntelopeJS Cloud API: the client the `ajs cloud` CLI
|
|
4
4
|
uses, without the CLI. Its only runtime dependency is `openapi-fetch`.
|
|
5
5
|
|
|
6
6
|
## Install
|
|
@@ -20,7 +20,7 @@ import { CloudApi, CloudApiError } from "@antelopejs/cloud-sdk";
|
|
|
20
20
|
|
|
21
21
|
const api = new CloudApi({ token: process.env.ANTELOPE_CLOUD_TOKEN! });
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
console.log(await api.listProjects());
|
|
24
24
|
} catch (error) {
|
|
25
25
|
if (error instanceof CloudApiError) console.error(error.status, error.code);
|
|
26
26
|
}
|
package/dist/api.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProjectDeploymentsApi } from "./deployments.js";
|
|
1
2
|
import { EnvironmentsApi, ProjectRepositoryApi } from "./environments.js";
|
|
2
3
|
import type { components } from "./generated/cloud-api.js";
|
|
3
4
|
import { type SseEvent } from "./sse.js";
|
|
@@ -30,6 +31,14 @@ export interface CloudApiOptions extends EndpointOptions {
|
|
|
30
31
|
/** The bearer token a device login or the console issued. */
|
|
31
32
|
token: string;
|
|
32
33
|
}
|
|
34
|
+
/** How a project create is sent. */
|
|
35
|
+
export interface CreateProjectOptions {
|
|
36
|
+
/**
|
|
37
|
+
* Identifies this create across retries, 1 to 255 visible ASCII characters.
|
|
38
|
+
* Scoped to the workspace and to the member who sends it.
|
|
39
|
+
*/
|
|
40
|
+
idempotencyKey?: string;
|
|
41
|
+
}
|
|
33
42
|
/** How a log read is shaped: one bounded page, or a tail from a cursor. */
|
|
34
43
|
export interface LogRequest {
|
|
35
44
|
follow: boolean;
|
|
@@ -47,6 +56,8 @@ export declare class CloudApi {
|
|
|
47
56
|
readonly environments: EnvironmentsApi;
|
|
48
57
|
/** The GitHub repository a project builds from. */
|
|
49
58
|
readonly projectRepository: ProjectRepositoryApi;
|
|
59
|
+
/** Every deployment of a project, newest first, one page at a time. */
|
|
60
|
+
readonly projectDeployments: ProjectDeploymentsApi;
|
|
50
61
|
constructor(options: CloudApiOptions);
|
|
51
62
|
listProjects(): Promise<{
|
|
52
63
|
projects: {
|
|
@@ -84,7 +95,15 @@ export declare class CloudApi {
|
|
|
84
95
|
regions: string[];
|
|
85
96
|
defaultRegion: string;
|
|
86
97
|
}>;
|
|
87
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Creates a project. A retry by the same member with the same
|
|
100
|
+
* `idempotencyKey` and the same body answers the project that key created
|
|
101
|
+
* instead of a second one; the same key with another body is refused with
|
|
102
|
+
* `cloud.errors.projects.idempotency_key_reused`, and
|
|
103
|
+
* `cloud.errors.projects.creation_in_progress` asks for a retry with the
|
|
104
|
+
* same key.
|
|
105
|
+
*/
|
|
106
|
+
createProject(body: NewProject, options?: CreateProjectOptions): Promise<{
|
|
88
107
|
projectId: string;
|
|
89
108
|
slug: string;
|
|
90
109
|
region: string;
|
|
@@ -156,14 +175,7 @@ export declare class CloudApi {
|
|
|
156
175
|
deploymentHistory(serviceId: string): Promise<{
|
|
157
176
|
activeBuilds?: components["schemas"]["ActiveBuild"][];
|
|
158
177
|
desiredRevisionId: string | null;
|
|
159
|
-
revisions:
|
|
160
|
-
id: string;
|
|
161
|
-
number: number;
|
|
162
|
-
isDesired: boolean;
|
|
163
|
-
canRollback: boolean;
|
|
164
|
-
state?: "preparing" | "pending" | "succeeded" | "failed";
|
|
165
|
-
deploymentId?: string | null;
|
|
166
|
-
}[];
|
|
178
|
+
revisions: components["schemas"]["RevisionSummary"][];
|
|
167
179
|
}>;
|
|
168
180
|
rollback(serviceId: string, revisionId: string): Promise<{
|
|
169
181
|
[key: string]: unknown;
|
package/dist/api.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import createClient from "openapi-fetch";
|
|
2
|
-
import {
|
|
2
|
+
import { InvalidApiResponseError } from "./api-error.js";
|
|
3
|
+
import { ProjectDeploymentsApi } from "./deployments.js";
|
|
3
4
|
import { EnvironmentsApi, ProjectRepositoryApi } from "./environments.js";
|
|
4
5
|
import { isRecord, isString } from "./guards.js";
|
|
5
|
-
import { acceptedOf, dataOf,
|
|
6
|
+
import { acceptedOf, dataOf, isApiErrorBody, refusal } from "./result.js";
|
|
6
7
|
import { parseSse } from "./sse.js";
|
|
7
8
|
/** The production Cloud API, used when no `baseUrl` is given. */
|
|
8
9
|
export const DEFAULT_API_URL = "https://api.antelopejs.cloud";
|
|
9
10
|
const SOURCE_MIME_TYPE = "application/x-tar";
|
|
10
11
|
const SOURCE_FILENAME = "source.tar";
|
|
11
|
-
const HTTP_TOO_MANY_REQUESTS = 429;
|
|
12
12
|
function isDeploymentReceipt(value) {
|
|
13
13
|
return (isRecord(value) &&
|
|
14
14
|
isString(value.deploymentId) &&
|
|
15
15
|
isString(value.buildId) &&
|
|
16
16
|
value.status === "queued");
|
|
17
17
|
}
|
|
18
|
-
/** `Retry-After` as delta-seconds; the HTTP-date form, or nothing usable, is no hint. */
|
|
19
|
-
function retryAfterSeconds(header) {
|
|
20
|
-
if (!header || !/^\d+$/.test(header.trim()))
|
|
21
|
-
return undefined;
|
|
22
|
-
return Number(header.trim());
|
|
23
|
-
}
|
|
24
18
|
function endpointClient(options = {}) {
|
|
25
19
|
return createClient({
|
|
26
20
|
baseUrl: options.baseUrl ?? DEFAULT_API_URL,
|
|
@@ -37,6 +31,8 @@ export class CloudApi {
|
|
|
37
31
|
environments;
|
|
38
32
|
/** The GitHub repository a project builds from. */
|
|
39
33
|
projectRepository;
|
|
34
|
+
/** Every deployment of a project, newest first, one page at a time. */
|
|
35
|
+
projectDeployments;
|
|
40
36
|
constructor(options) {
|
|
41
37
|
this.options = options;
|
|
42
38
|
this.baseUrl = (options.baseUrl ?? DEFAULT_API_URL).replace(/\/+$/, "");
|
|
@@ -48,6 +44,7 @@ export class CloudApi {
|
|
|
48
44
|
});
|
|
49
45
|
this.environments = new EnvironmentsApi(this.client);
|
|
50
46
|
this.projectRepository = new ProjectRepositoryApi(this.client);
|
|
47
|
+
this.projectDeployments = new ProjectDeploymentsApi(this.client);
|
|
51
48
|
}
|
|
52
49
|
async listProjects() {
|
|
53
50
|
const result = await this.client.GET("/api/cloud/projects/");
|
|
@@ -71,8 +68,19 @@ export class CloudApi {
|
|
|
71
68
|
const result = await this.client.GET("/api/cloud/onboarding/");
|
|
72
69
|
return dataOf(result);
|
|
73
70
|
}
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Creates a project. A retry by the same member with the same
|
|
73
|
+
* `idempotencyKey` and the same body answers the project that key created
|
|
74
|
+
* instead of a second one; the same key with another body is refused with
|
|
75
|
+
* `cloud.errors.projects.idempotency_key_reused`, and
|
|
76
|
+
* `cloud.errors.projects.creation_in_progress` asks for a retry with the
|
|
77
|
+
* same key.
|
|
78
|
+
*/
|
|
79
|
+
async createProject(body, options = {}) {
|
|
80
|
+
const result = await this.client.POST("/api/cloud/projects/", {
|
|
81
|
+
body,
|
|
82
|
+
params: { header: { "Idempotency-Key": options.idempotencyKey } },
|
|
83
|
+
});
|
|
76
84
|
return dataOf(result);
|
|
77
85
|
}
|
|
78
86
|
async createService(projectId, environmentId, body) {
|
|
@@ -187,7 +195,7 @@ export class CloudApi {
|
|
|
187
195
|
catch {
|
|
188
196
|
/** The response is already useful as plain text. */
|
|
189
197
|
}
|
|
190
|
-
throw refusal(response
|
|
198
|
+
throw refusal(response, isApiErrorBody(body) ? body : undefined, text);
|
|
191
199
|
}
|
|
192
200
|
async *stream(path, headers, signal, onOpen) {
|
|
193
201
|
const response = await this.raw(path, { headers, signal });
|
|
@@ -205,10 +213,6 @@ export async function createDevice(deviceName, options) {
|
|
|
205
213
|
const result = await endpointClient(options).POST("/api/cloud/cli/device", {
|
|
206
214
|
body: { device_name: deviceName },
|
|
207
215
|
});
|
|
208
|
-
if (result.response.status === HTTP_TOO_MANY_REQUESTS) {
|
|
209
|
-
const body = isApiErrorBody(result.error) ? result.error : undefined;
|
|
210
|
-
throw new CloudApiError(result.response.status, errorCode(body), undefined, errorParams(body), retryAfterSeconds(result.response.headers.get("retry-after")));
|
|
211
|
-
}
|
|
212
216
|
return dataOf(result);
|
|
213
217
|
}
|
|
214
218
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Client } from "openapi-fetch";
|
|
2
|
+
import type { components, operations, paths } from "./generated/cloud-api.js";
|
|
3
|
+
export type DeploymentHistory = components["schemas"]["DeploymentHistory"];
|
|
4
|
+
export type RevisionSummary = components["schemas"]["RevisionSummary"];
|
|
5
|
+
export type RevisionBuild = components["schemas"]["RevisionBuild"];
|
|
6
|
+
export type ActiveBuild = components["schemas"]["ActiveBuild"];
|
|
7
|
+
export type DeploymentStatus = components["schemas"]["DeploymentStatus"];
|
|
8
|
+
export type ProjectDeployment = components["schemas"]["ProjectDeployment"];
|
|
9
|
+
export type ProjectDeploymentPage = components["schemas"]["ProjectDeploymentPage"];
|
|
10
|
+
/** Which deployments a page holds, and where it starts. */
|
|
11
|
+
export type ProjectDeploymentQuery = NonNullable<operations["listProjectDeployments"]["parameters"]["query"]>;
|
|
12
|
+
/** Every deployment of a project, across its environments. */
|
|
13
|
+
export declare class ProjectDeploymentsApi {
|
|
14
|
+
private readonly client;
|
|
15
|
+
constructor(client: Client<paths>);
|
|
16
|
+
/**
|
|
17
|
+
* One page of the project's deployments, newest first. Pass the page's
|
|
18
|
+
* `nextCursor` as `cursor` to read the next, older one.
|
|
19
|
+
*/
|
|
20
|
+
list(projectId: string, query?: ProjectDeploymentQuery): Promise<ProjectDeploymentPage>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { dataOf } from "./result.js";
|
|
2
|
+
/** Every deployment of a project, across its environments. */
|
|
3
|
+
export class ProjectDeploymentsApi {
|
|
4
|
+
client;
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One page of the project's deployments, newest first. Pass the page's
|
|
10
|
+
* `nextCursor` as `cursor` to read the next, older one.
|
|
11
|
+
*/
|
|
12
|
+
async list(projectId, query = {}) {
|
|
13
|
+
const result = await this.client.GET("/api/cloud/projects/{projectId}/deployments", { params: { path: { projectId }, query } });
|
|
14
|
+
return dataOf(result);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=deployments.js.map
|
|
@@ -76,6 +76,25 @@ export interface paths {
|
|
|
76
76
|
};
|
|
77
77
|
get: operations["listProjects"];
|
|
78
78
|
put?: never;
|
|
79
|
+
/**
|
|
80
|
+
* @description Creates a project with its production environment and, from a repository, its first service.
|
|
81
|
+
*
|
|
82
|
+
* A client that may lose the answer sends an `Idempotency-Key` and retries with the same key and
|
|
83
|
+
* the same request: the same `slug`, `region`, `repository` and `branch`. Once the first create
|
|
84
|
+
* finished, the retry answers 200 with the project that key created, as a fresh create would:
|
|
85
|
+
* its `projectId`, current `slug` and `region`, and the original `environmentId` and
|
|
86
|
+
* `serviceId`. No second project is created, and the replay needs no GitHub call and no room
|
|
87
|
+
* under the plan's project ceiling.
|
|
88
|
+
*
|
|
89
|
+
* A key belongs to its workspace and to the member who sent it. Another member sending the
|
|
90
|
+
* same key and body is not given the project; on its taken slug they get 409
|
|
91
|
+
* `cloud.errors.projects.slug_taken`, as does a create with another key, or none.
|
|
92
|
+
*
|
|
93
|
+
* While another create holds the slug, a keyed request answers 409
|
|
94
|
+
* `cloud.errors.projects.creation_in_progress`: it may be its own first attempt still running,
|
|
95
|
+
* so the client retries with the same key. The same key from the same member with a different
|
|
96
|
+
* request answers 422 `cloud.errors.projects.idempotency_key_reused`.
|
|
97
|
+
*/
|
|
79
98
|
post: operations["createProject"];
|
|
80
99
|
delete?: never;
|
|
81
100
|
options?: never;
|
|
@@ -99,6 +118,23 @@ export interface paths {
|
|
|
99
118
|
patch?: never;
|
|
100
119
|
trace?: never;
|
|
101
120
|
};
|
|
121
|
+
"/api/cloud/projects/{projectId}/deployments": {
|
|
122
|
+
parameters: {
|
|
123
|
+
query?: never;
|
|
124
|
+
header?: never;
|
|
125
|
+
path?: never;
|
|
126
|
+
cookie?: never;
|
|
127
|
+
};
|
|
128
|
+
/** @description The project's deployments across its environments, newest first, one page at a time. */
|
|
129
|
+
get: operations["listProjectDeployments"];
|
|
130
|
+
put?: never;
|
|
131
|
+
post?: never;
|
|
132
|
+
delete?: never;
|
|
133
|
+
options?: never;
|
|
134
|
+
head?: never;
|
|
135
|
+
patch?: never;
|
|
136
|
+
trace?: never;
|
|
137
|
+
};
|
|
102
138
|
"/api/cloud/projects/{projectId}/repository": {
|
|
103
139
|
parameters: {
|
|
104
140
|
query?: never;
|
|
@@ -527,19 +563,8 @@ export interface components {
|
|
|
527
563
|
DeploymentHistory: {
|
|
528
564
|
activeBuilds?: components["schemas"]["ActiveBuild"][];
|
|
529
565
|
desiredRevisionId: string | null;
|
|
530
|
-
revisions
|
|
531
|
-
|
|
532
|
-
number: number;
|
|
533
|
-
isDesired: boolean;
|
|
534
|
-
canRollback: boolean;
|
|
535
|
-
/**
|
|
536
|
-
* @description Where the revision is; preparing and pending ones are still rolling out.
|
|
537
|
-
* @enum {string}
|
|
538
|
-
*/
|
|
539
|
-
state?: "preparing" | "pending" | "succeeded" | "failed";
|
|
540
|
-
/** @description The deployment that rolls the revision out; null when none of the recent ones links to it. */
|
|
541
|
-
deploymentId?: string | null;
|
|
542
|
-
}[];
|
|
566
|
+
/** @description The service's revisions, newest first. */
|
|
567
|
+
revisions: components["schemas"]["RevisionSummary"][];
|
|
543
568
|
};
|
|
544
569
|
DeploymentDetail: {
|
|
545
570
|
id: string;
|
|
@@ -584,6 +609,10 @@ export interface components {
|
|
|
584
609
|
NewProject: {
|
|
585
610
|
slug: string;
|
|
586
611
|
region?: string;
|
|
612
|
+
/** @description `owner/name` the first service builds */
|
|
613
|
+
repository?: string;
|
|
614
|
+
/** @description Branch the environment tracks */
|
|
615
|
+
branch?: string;
|
|
587
616
|
};
|
|
588
617
|
CreatedProject: {
|
|
589
618
|
projectId: string;
|
|
@@ -635,6 +664,43 @@ export interface components {
|
|
|
635
664
|
removedRetentionDays: number;
|
|
636
665
|
};
|
|
637
666
|
};
|
|
667
|
+
/**
|
|
668
|
+
* @description Sources build, the new revision is health-checked, then traffic switches to it.
|
|
669
|
+
* @enum {string}
|
|
670
|
+
*/
|
|
671
|
+
DeploymentStatus: "queued" | "building" | "checking" | "switching" | "succeeded" | "failed" | "cancelled";
|
|
672
|
+
/** @description One deployment of a project to one of its environments, and the revisions it rolled out. */
|
|
673
|
+
ProjectDeployment: {
|
|
674
|
+
id: string;
|
|
675
|
+
/** @description Counts up within its environment, so two environments of a project can share a number; order by createdAt and key by id. */
|
|
676
|
+
number: number;
|
|
677
|
+
environmentId: string;
|
|
678
|
+
status: components["schemas"]["DeploymentStatus"];
|
|
679
|
+
/** @description The commit deployed; null when the trigger carries none, such as a CLI upload. */
|
|
680
|
+
commit: string | null;
|
|
681
|
+
/** @description The branch the commit came from; null for a CLI upload or a rollback. */
|
|
682
|
+
branch: string | null;
|
|
683
|
+
/** Format: date-time */
|
|
684
|
+
createdAt: string;
|
|
685
|
+
/**
|
|
686
|
+
* Format: date-time
|
|
687
|
+
* @description When it succeeded, failed or was cancelled; null while it runs.
|
|
688
|
+
*/
|
|
689
|
+
finishedAt: string | null;
|
|
690
|
+
/**
|
|
691
|
+
* @description What started it. push is a push to the environment's branch, or an update to the pull request a preview environment mirrors. promotion is a commit, branch tip or image someone chose to deploy to the environment. rollback is a return to an earlier revision. upload is a source the CLI uploaded. restart is a redeploy of what the environment already runs, such as after a settings change.
|
|
692
|
+
* @enum {string}
|
|
693
|
+
*/
|
|
694
|
+
trigger: "push" | "promotion" | "rollback" | "upload" | "restart";
|
|
695
|
+
/** @description The service revisions it rolled out; empty until its builds produce them. */
|
|
696
|
+
revisionIds: string[];
|
|
697
|
+
};
|
|
698
|
+
/** @description One page of a project's deployments, newest first. */
|
|
699
|
+
ProjectDeploymentPage: {
|
|
700
|
+
deployments: components["schemas"]["ProjectDeployment"][];
|
|
701
|
+
/** @description Pass it as cursor to read the next, older page; null on the last page. */
|
|
702
|
+
nextCursor: string | null;
|
|
703
|
+
};
|
|
638
704
|
ProjectRepository: {
|
|
639
705
|
/** @description The GitHub repository the project builds from, as owner/name. It is the linked one, else the one most of its services build from; null when neither exists. */
|
|
640
706
|
repository: string | null;
|
|
@@ -890,6 +956,37 @@ export interface components {
|
|
|
890
956
|
/** @description The plan that remains once the databases are created. */
|
|
891
957
|
plan: components["schemas"]["ResourcePlan"];
|
|
892
958
|
};
|
|
959
|
+
/** @description What a built revision was built from. */
|
|
960
|
+
RevisionBuild: {
|
|
961
|
+
/** @description The branch built; null for a source the CLI uploaded. */
|
|
962
|
+
branch: string | null;
|
|
963
|
+
commit: string | null;
|
|
964
|
+
commitMessage: string | null;
|
|
965
|
+
/** @description Null until the build has both started and finished. */
|
|
966
|
+
durationSeconds: number | null;
|
|
967
|
+
};
|
|
968
|
+
RevisionSummary: {
|
|
969
|
+
id: string;
|
|
970
|
+
number: number;
|
|
971
|
+
isDesired: boolean;
|
|
972
|
+
canRollback: boolean;
|
|
973
|
+
/** Format: date-time */
|
|
974
|
+
createdAt: string;
|
|
975
|
+
/**
|
|
976
|
+
* @description build when Cloud built the revision from source; image when it pulled an image by reference.
|
|
977
|
+
* @enum {string}
|
|
978
|
+
*/
|
|
979
|
+
origin: "build" | "image";
|
|
980
|
+
/** @description The build that produced the revision; null for an image pulled by reference. */
|
|
981
|
+
build: components["schemas"]["RevisionBuild"] | null;
|
|
982
|
+
/**
|
|
983
|
+
* @description Where the revision is; preparing and pending ones are still rolling out.
|
|
984
|
+
* @enum {string}
|
|
985
|
+
*/
|
|
986
|
+
state?: "preparing" | "pending" | "succeeded" | "failed";
|
|
987
|
+
/** @description The deployment that rolls the revision out; null when none of the recent ones links to it. */
|
|
988
|
+
deploymentId?: string | null;
|
|
989
|
+
};
|
|
893
990
|
};
|
|
894
991
|
responses: {
|
|
895
992
|
/** @description Stable API error */
|
|
@@ -1024,7 +1121,10 @@ export interface operations {
|
|
|
1024
1121
|
createProject: {
|
|
1025
1122
|
parameters: {
|
|
1026
1123
|
query?: never;
|
|
1027
|
-
header?:
|
|
1124
|
+
header?: {
|
|
1125
|
+
/** @description Identifies one create across retries. 1 to 255 visible ASCII characters. */
|
|
1126
|
+
"Idempotency-Key"?: string;
|
|
1127
|
+
};
|
|
1028
1128
|
path?: never;
|
|
1029
1129
|
cookie?: never;
|
|
1030
1130
|
};
|
|
@@ -1034,6 +1134,7 @@ export interface operations {
|
|
|
1034
1134
|
};
|
|
1035
1135
|
};
|
|
1036
1136
|
responses: {
|
|
1137
|
+
/** @description The project created, or the one this `Idempotency-Key` already created. */
|
|
1037
1138
|
200: {
|
|
1038
1139
|
headers: {
|
|
1039
1140
|
[name: string]: unknown;
|
|
@@ -1042,6 +1143,33 @@ export interface operations {
|
|
|
1042
1143
|
"application/json": components["schemas"]["CreatedProject"];
|
|
1043
1144
|
};
|
|
1044
1145
|
};
|
|
1146
|
+
/** @description `cloud.errors.projects.invalid_idempotency_key`: the `Idempotency-Key` is empty, longer than 255 characters, or holds a character outside 0x21-0x7E. */
|
|
1147
|
+
400: {
|
|
1148
|
+
headers: {
|
|
1149
|
+
[name: string]: unknown;
|
|
1150
|
+
};
|
|
1151
|
+
content: {
|
|
1152
|
+
"application/json": components["schemas"]["Error"];
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
/** @description `cloud.errors.projects.slug_taken`: another project holds the slug. `cloud.errors.projects.creation_in_progress`: a keyed request met another create holding the slug; retry with the same key. */
|
|
1156
|
+
409: {
|
|
1157
|
+
headers: {
|
|
1158
|
+
[name: string]: unknown;
|
|
1159
|
+
};
|
|
1160
|
+
content: {
|
|
1161
|
+
"application/json": components["schemas"]["Error"];
|
|
1162
|
+
};
|
|
1163
|
+
};
|
|
1164
|
+
/** @description `cloud.errors.projects.idempotency_key_reused`: the same member's `Idempotency-Key` already created a project from a request with a different `slug`, `region`, `repository` or `branch`. */
|
|
1165
|
+
422: {
|
|
1166
|
+
headers: {
|
|
1167
|
+
[name: string]: unknown;
|
|
1168
|
+
};
|
|
1169
|
+
content: {
|
|
1170
|
+
"application/json": components["schemas"]["Error"];
|
|
1171
|
+
};
|
|
1172
|
+
};
|
|
1045
1173
|
default: components["responses"]["Error"];
|
|
1046
1174
|
};
|
|
1047
1175
|
};
|
|
@@ -1067,6 +1195,37 @@ export interface operations {
|
|
|
1067
1195
|
default: components["responses"]["Error"];
|
|
1068
1196
|
};
|
|
1069
1197
|
};
|
|
1198
|
+
listProjectDeployments: {
|
|
1199
|
+
parameters: {
|
|
1200
|
+
query?: {
|
|
1201
|
+
/** @description Only the deployments to this environment. */
|
|
1202
|
+
environmentId?: string;
|
|
1203
|
+
/** @description Only the deployments in one of these statuses. */
|
|
1204
|
+
status?: components["schemas"]["DeploymentStatus"][];
|
|
1205
|
+
/** @description The nextCursor of the previous page, sent with the same filters; absent for the first page. A cursor the API cannot read is refused. */
|
|
1206
|
+
cursor?: string;
|
|
1207
|
+
/** @description Deployments per page; a value outside 1 to 100 is refused. */
|
|
1208
|
+
limit?: number;
|
|
1209
|
+
};
|
|
1210
|
+
header?: never;
|
|
1211
|
+
path: {
|
|
1212
|
+
projectId: string;
|
|
1213
|
+
};
|
|
1214
|
+
cookie?: never;
|
|
1215
|
+
};
|
|
1216
|
+
requestBody?: never;
|
|
1217
|
+
responses: {
|
|
1218
|
+
200: {
|
|
1219
|
+
headers: {
|
|
1220
|
+
[name: string]: unknown;
|
|
1221
|
+
};
|
|
1222
|
+
content: {
|
|
1223
|
+
"application/json": components["schemas"]["ProjectDeploymentPage"];
|
|
1224
|
+
};
|
|
1225
|
+
};
|
|
1226
|
+
default: components["responses"]["Error"];
|
|
1227
|
+
};
|
|
1228
|
+
};
|
|
1070
1229
|
readProjectRepository: {
|
|
1071
1230
|
parameters: {
|
|
1072
1231
|
query?: never;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/result.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CloudApiError } from "./api-error.js";
|
|
2
2
|
interface ApiErrorFields {
|
|
3
3
|
code?: unknown;
|
|
4
4
|
error?: unknown;
|
|
@@ -14,10 +14,8 @@ export interface ApiResult<T> {
|
|
|
14
14
|
response: Response;
|
|
15
15
|
}
|
|
16
16
|
export declare function isApiErrorBody(value: unknown): value is ApiErrorBody;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export declare function errorParams(body: ApiErrorBody | undefined): ApiErrorParams;
|
|
20
|
-
export declare function refusal(status: number, body: ApiErrorBody | undefined, text?: string): CloudApiError;
|
|
17
|
+
/** The refusal a response carries, with the wait its `Retry-After` asks for. */
|
|
18
|
+
export declare function refusal(response: Response, body: ApiErrorBody | undefined, text?: string): CloudApiError;
|
|
21
19
|
/** The answer's body, or the refusal it carries. */
|
|
22
20
|
export declare function dataOf<T>(result: ApiResult<T>): T;
|
|
23
21
|
/** For an answer that has no body: it only has to be accepted. */
|
package/dist/result.js
CHANGED
|
@@ -3,23 +3,30 @@ import { isObject, isRecord, isString } from "./guards.js";
|
|
|
3
3
|
export function isApiErrorBody(value) {
|
|
4
4
|
return isString(value) || isRecord(value);
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
function errorCode(body) {
|
|
7
7
|
if (isString(body))
|
|
8
8
|
return body;
|
|
9
9
|
return [body?.code, body?.error, body?.message].find(isString) ?? "api_error";
|
|
10
10
|
}
|
|
11
11
|
/** The string values a `{ message, params }` refusal interpolates. */
|
|
12
|
-
|
|
12
|
+
function errorParams(body) {
|
|
13
13
|
const params = isString(body) ? undefined : body?.params;
|
|
14
14
|
if (!isObject(params))
|
|
15
15
|
return {};
|
|
16
16
|
return Object.fromEntries(Object.entries(params).filter((entry) => typeof entry[1] === "string"));
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
/** `Retry-After` as delta-seconds; the HTTP-date form, or nothing usable, is no hint. */
|
|
19
|
+
function retryAfterSeconds(header) {
|
|
20
|
+
if (!header || !/^\d+$/.test(header.trim()))
|
|
21
|
+
return undefined;
|
|
22
|
+
return Number(header.trim());
|
|
23
|
+
}
|
|
24
|
+
/** The refusal a response carries, with the wait its `Retry-After` asks for. */
|
|
25
|
+
export function refusal(response, body, text) {
|
|
26
|
+
return new CloudApiError(response.status, errorCode(body), text, errorParams(body), retryAfterSeconds(response.headers.get("retry-after")));
|
|
20
27
|
}
|
|
21
28
|
function refusalOf(result) {
|
|
22
|
-
return refusal(result.response
|
|
29
|
+
return refusal(result.response, isApiErrorBody(result.error) ? result.error : undefined);
|
|
23
30
|
}
|
|
24
31
|
/** The answer's body, or the refusal it carries. */
|
|
25
32
|
export function dataOf(result) {
|
package/dist/sse.d.ts
CHANGED
|
@@ -3,4 +3,9 @@ export interface SseEvent {
|
|
|
3
3
|
data: unknown;
|
|
4
4
|
id?: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads the events of a server-sent stream.
|
|
8
|
+
*
|
|
9
|
+
* @throws InvalidApiResponseError when one frame passes 1 MiB without ending.
|
|
10
|
+
*/
|
|
6
11
|
export declare function parseSse(response: Response): AsyncGenerator<SseEvent>;
|
package/dist/sse.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InvalidApiResponseError } from "./api-error.js";
|
|
1
2
|
function eventOf(lines) {
|
|
2
3
|
let event = "message";
|
|
3
4
|
let id;
|
|
@@ -23,6 +24,16 @@ function eventOf(lines) {
|
|
|
23
24
|
function fieldValue(value) {
|
|
24
25
|
return value.startsWith(" ") ? value.slice(1) : value;
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* The most text one frame may hold before its end. A stream that never ends
|
|
29
|
+
* a frame would otherwise grow the buffer for as long as it is read.
|
|
30
|
+
*/
|
|
31
|
+
const MAX_FRAME_LENGTH = 1_048_576;
|
|
32
|
+
/**
|
|
33
|
+
* Reads the events of a server-sent stream.
|
|
34
|
+
*
|
|
35
|
+
* @throws InvalidApiResponseError when one frame passes 1 MiB without ending.
|
|
36
|
+
*/
|
|
26
37
|
export async function* parseSse(response) {
|
|
27
38
|
if (!response.body)
|
|
28
39
|
return;
|
|
@@ -33,6 +44,10 @@ export async function* parseSse(response) {
|
|
|
33
44
|
buffer += value ?? "";
|
|
34
45
|
const frames = buffer.split(/\r?\n\r?\n/);
|
|
35
46
|
buffer = frames.pop() ?? "";
|
|
47
|
+
if (buffer.length > MAX_FRAME_LENGTH) {
|
|
48
|
+
await reader.cancel();
|
|
49
|
+
throw new InvalidApiResponseError();
|
|
50
|
+
}
|
|
36
51
|
for (const frame of frames) {
|
|
37
52
|
const event = eventOf(frame.split(/\r?\n/));
|
|
38
53
|
if (event)
|
|
@@ -117,41 +117,8 @@ components:
|
|
|
117
117
|
deploymentId: { type: string }
|
|
118
118
|
buildId: { type: string }
|
|
119
119
|
status: { type: string, const: queued }
|
|
120
|
-
ActiveBuild:
|
|
121
|
-
|
|
122
|
-
type: object
|
|
123
|
-
required: [id, deploymentId, status, queuePosition, createdAt]
|
|
124
|
-
properties:
|
|
125
|
-
id: { type: string }
|
|
126
|
-
deploymentId: { type: string }
|
|
127
|
-
status: { type: string, enum: [queued, starting, running] }
|
|
128
|
-
queuePosition: { type: [integer, "null"] }
|
|
129
|
-
createdAt: { type: string, format: date-time }
|
|
130
|
-
DeploymentHistory:
|
|
131
|
-
type: object
|
|
132
|
-
required: [revisions, desiredRevisionId]
|
|
133
|
-
properties:
|
|
134
|
-
activeBuilds:
|
|
135
|
-
type: array
|
|
136
|
-
items: { $ref: '#/components/schemas/ActiveBuild' }
|
|
137
|
-
desiredRevisionId: { type: [string, "null"] }
|
|
138
|
-
revisions:
|
|
139
|
-
type: array
|
|
140
|
-
items:
|
|
141
|
-
type: object
|
|
142
|
-
required: [id, number, isDesired, canRollback]
|
|
143
|
-
properties:
|
|
144
|
-
id: { type: string }
|
|
145
|
-
number: { type: integer }
|
|
146
|
-
isDesired: { type: boolean }
|
|
147
|
-
canRollback: { type: boolean }
|
|
148
|
-
state:
|
|
149
|
-
description: Where the revision is; preparing and pending ones are still rolling out.
|
|
150
|
-
type: string
|
|
151
|
-
enum: [preparing, pending, succeeded, failed]
|
|
152
|
-
deploymentId:
|
|
153
|
-
description: The deployment that rolls the revision out; null when none of the recent ones links to it.
|
|
154
|
-
type: [string, "null"]
|
|
120
|
+
ActiveBuild: { $ref: 'deployments.yaml#/components/schemas/ActiveBuild' }
|
|
121
|
+
DeploymentHistory: { $ref: 'deployments.yaml#/components/schemas/DeploymentHistory' }
|
|
155
122
|
DeploymentDetail:
|
|
156
123
|
type: object
|
|
157
124
|
required: [id, status, failure]
|
|
@@ -212,9 +179,12 @@ components:
|
|
|
212
179
|
NewProject:
|
|
213
180
|
type: object
|
|
214
181
|
required: [slug]
|
|
182
|
+
dependentRequired: { repository: [branch], branch: [repository] }
|
|
215
183
|
properties:
|
|
216
184
|
slug: { type: string }
|
|
217
185
|
region: { type: string }
|
|
186
|
+
repository: { type: string, description: "`owner/name` the first service builds" }
|
|
187
|
+
branch: { type: string, description: Branch the environment tracks }
|
|
218
188
|
CreatedProject:
|
|
219
189
|
type: object
|
|
220
190
|
required: [projectId, slug, region, environmentId]
|
|
@@ -343,30 +313,7 @@ paths:
|
|
|
343
313
|
application/json:
|
|
344
314
|
schema: { $ref: '#/components/schemas/DeviceToken' }
|
|
345
315
|
default: { $ref: '#/components/responses/Error' }
|
|
346
|
-
/api/cloud/projects/:
|
|
347
|
-
get:
|
|
348
|
-
operationId: listProjects
|
|
349
|
-
security: [{ bearerAuth: [] }]
|
|
350
|
-
responses:
|
|
351
|
-
'200':
|
|
352
|
-
content:
|
|
353
|
-
application/json:
|
|
354
|
-
schema: { $ref: '#/components/schemas/ProjectList' }
|
|
355
|
-
default: { $ref: '#/components/responses/Error' }
|
|
356
|
-
post:
|
|
357
|
-
operationId: createProject
|
|
358
|
-
security: [{ bearerAuth: [] }]
|
|
359
|
-
requestBody:
|
|
360
|
-
required: true
|
|
361
|
-
content:
|
|
362
|
-
application/json:
|
|
363
|
-
schema: { $ref: '#/components/schemas/NewProject' }
|
|
364
|
-
responses:
|
|
365
|
-
'200':
|
|
366
|
-
content:
|
|
367
|
-
application/json:
|
|
368
|
-
schema: { $ref: '#/components/schemas/CreatedProject' }
|
|
369
|
-
default: { $ref: '#/components/responses/Error' }
|
|
316
|
+
/api/cloud/projects/: { $ref: 'projects.yaml#/paths/projects' }
|
|
370
317
|
/api/cloud/projects/{projectId}:
|
|
371
318
|
get:
|
|
372
319
|
operationId: readProject
|
|
@@ -382,6 +329,7 @@ paths:
|
|
|
382
329
|
application/json:
|
|
383
330
|
schema: { $ref: '#/components/schemas/Project' }
|
|
384
331
|
default: { $ref: '#/components/responses/Error' }
|
|
332
|
+
/api/cloud/projects/{projectId}/deployments: { $ref: 'deployments.yaml#/paths/projectDeployments' }
|
|
385
333
|
/api/cloud/projects/{projectId}/repository: { $ref: 'environments.yaml#/paths/repository' }
|
|
386
334
|
/api/cloud/projects/{projectId}/environments: { $ref: 'environments.yaml#/paths/environments' }
|
|
387
335
|
/api/cloud/projects/{projectId}/environments/{environmentId}: { $ref: 'environments.yaml#/paths/environment' }
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
components:
|
|
2
|
+
schemas:
|
|
3
|
+
ActiveBuild:
|
|
4
|
+
description: A build of the service still queued or running, and the deployment it belongs to.
|
|
5
|
+
type: object
|
|
6
|
+
required: [id, deploymentId, status, queuePosition, createdAt]
|
|
7
|
+
properties:
|
|
8
|
+
id: { type: string }
|
|
9
|
+
deploymentId: { type: string }
|
|
10
|
+
status: { type: string, enum: [queued, starting, running] }
|
|
11
|
+
queuePosition: { type: [integer, "null"] }
|
|
12
|
+
createdAt: { type: string, format: date-time }
|
|
13
|
+
DeploymentHistory:
|
|
14
|
+
type: object
|
|
15
|
+
required: [revisions, desiredRevisionId]
|
|
16
|
+
properties:
|
|
17
|
+
activeBuilds:
|
|
18
|
+
type: array
|
|
19
|
+
items: { $ref: '#/components/schemas/ActiveBuild' }
|
|
20
|
+
desiredRevisionId: { type: [string, "null"] }
|
|
21
|
+
revisions:
|
|
22
|
+
description: The service's revisions, newest first.
|
|
23
|
+
type: array
|
|
24
|
+
items: { $ref: '#/components/schemas/RevisionSummary' }
|
|
25
|
+
RevisionSummary:
|
|
26
|
+
type: object
|
|
27
|
+
required: [id, number, isDesired, canRollback, createdAt, origin, build]
|
|
28
|
+
properties:
|
|
29
|
+
id: { type: string }
|
|
30
|
+
number: { type: integer }
|
|
31
|
+
isDesired: { type: boolean }
|
|
32
|
+
canRollback: { type: boolean }
|
|
33
|
+
createdAt: { type: string, format: date-time }
|
|
34
|
+
origin:
|
|
35
|
+
description: build when Cloud built the revision from source; image when it pulled an image by reference.
|
|
36
|
+
type: string
|
|
37
|
+
enum: [build, image]
|
|
38
|
+
build:
|
|
39
|
+
description: The build that produced the revision; null for an image pulled by reference.
|
|
40
|
+
oneOf:
|
|
41
|
+
- $ref: '#/components/schemas/RevisionBuild'
|
|
42
|
+
- type: "null"
|
|
43
|
+
state:
|
|
44
|
+
description: Where the revision is; preparing and pending ones are still rolling out.
|
|
45
|
+
type: string
|
|
46
|
+
enum: [preparing, pending, succeeded, failed]
|
|
47
|
+
deploymentId:
|
|
48
|
+
description: The deployment that rolls the revision out; null when none of the recent ones links to it.
|
|
49
|
+
type: [string, "null"]
|
|
50
|
+
RevisionBuild:
|
|
51
|
+
description: What a built revision was built from.
|
|
52
|
+
type: object
|
|
53
|
+
required: [branch, commit, commitMessage, durationSeconds]
|
|
54
|
+
properties:
|
|
55
|
+
branch:
|
|
56
|
+
description: The branch built; null for a source the CLI uploaded.
|
|
57
|
+
type: [string, "null"]
|
|
58
|
+
commit: { type: [string, "null"] }
|
|
59
|
+
commitMessage: { type: [string, "null"] }
|
|
60
|
+
durationSeconds:
|
|
61
|
+
description: Null until the build has both started and finished.
|
|
62
|
+
type: [integer, "null"]
|
|
63
|
+
ProjectDeploymentPage:
|
|
64
|
+
description: One page of a project's deployments, newest first.
|
|
65
|
+
type: object
|
|
66
|
+
required: [deployments, nextCursor]
|
|
67
|
+
properties:
|
|
68
|
+
deployments:
|
|
69
|
+
type: array
|
|
70
|
+
items: { $ref: '#/components/schemas/ProjectDeployment' }
|
|
71
|
+
nextCursor:
|
|
72
|
+
description: Pass it as cursor to read the next, older page; null on the last page.
|
|
73
|
+
type: [string, "null"]
|
|
74
|
+
ProjectDeployment:
|
|
75
|
+
description: One deployment of a project to one of its environments, and the revisions it rolled out.
|
|
76
|
+
type: object
|
|
77
|
+
required: [id, number, environmentId, status, commit, branch, createdAt, finishedAt, trigger, revisionIds]
|
|
78
|
+
properties:
|
|
79
|
+
id: { type: string }
|
|
80
|
+
number:
|
|
81
|
+
description: Counts up within its environment, so two environments of a project can share a number; order by createdAt and key by id.
|
|
82
|
+
type: integer
|
|
83
|
+
environmentId: { type: string }
|
|
84
|
+
status: { $ref: '#/components/schemas/DeploymentStatus' }
|
|
85
|
+
commit:
|
|
86
|
+
description: The commit deployed; null when the trigger carries none, such as a CLI upload.
|
|
87
|
+
type: [string, "null"]
|
|
88
|
+
branch:
|
|
89
|
+
description: The branch the commit came from; null for a CLI upload or a rollback.
|
|
90
|
+
type: [string, "null"]
|
|
91
|
+
createdAt: { type: string, format: date-time }
|
|
92
|
+
finishedAt:
|
|
93
|
+
description: When it succeeded, failed or was cancelled; null while it runs.
|
|
94
|
+
type: [string, "null"]
|
|
95
|
+
format: date-time
|
|
96
|
+
trigger:
|
|
97
|
+
description: >-
|
|
98
|
+
What started it.
|
|
99
|
+
push is a push to the environment's branch, or an update to the pull request a preview environment mirrors.
|
|
100
|
+
promotion is a commit, branch tip or image someone chose to deploy to the environment.
|
|
101
|
+
rollback is a return to an earlier revision.
|
|
102
|
+
upload is a source the CLI uploaded.
|
|
103
|
+
restart is a redeploy of what the environment already runs, such as after a settings change.
|
|
104
|
+
type: string
|
|
105
|
+
enum: [push, promotion, rollback, upload, restart]
|
|
106
|
+
revisionIds:
|
|
107
|
+
description: The service revisions it rolled out; empty until its builds produce them.
|
|
108
|
+
type: array
|
|
109
|
+
items: { type: string }
|
|
110
|
+
DeploymentStatus:
|
|
111
|
+
description: Sources build, the new revision is health-checked, then traffic switches to it.
|
|
112
|
+
type: string
|
|
113
|
+
enum: [queued, building, checking, switching, succeeded, failed, cancelled]
|
|
114
|
+
paths:
|
|
115
|
+
projectDeployments:
|
|
116
|
+
get:
|
|
117
|
+
operationId: listProjectDeployments
|
|
118
|
+
description: The project's deployments across its environments, newest first, one page at a time.
|
|
119
|
+
security: [{ bearerAuth: [] }]
|
|
120
|
+
parameters:
|
|
121
|
+
- in: path
|
|
122
|
+
name: projectId
|
|
123
|
+
required: true
|
|
124
|
+
schema: { type: string }
|
|
125
|
+
- in: query
|
|
126
|
+
name: environmentId
|
|
127
|
+
description: Only the deployments to this environment.
|
|
128
|
+
schema: { type: string }
|
|
129
|
+
- in: query
|
|
130
|
+
name: status
|
|
131
|
+
description: Only the deployments in one of these statuses.
|
|
132
|
+
style: form
|
|
133
|
+
explode: true
|
|
134
|
+
schema:
|
|
135
|
+
type: array
|
|
136
|
+
items: { $ref: '#/components/schemas/DeploymentStatus' }
|
|
137
|
+
- in: query
|
|
138
|
+
name: cursor
|
|
139
|
+
description: The nextCursor of the previous page, sent with the same filters; absent for the first page. A cursor the API cannot read is refused.
|
|
140
|
+
schema: { type: string }
|
|
141
|
+
- in: query
|
|
142
|
+
name: limit
|
|
143
|
+
description: Deployments per page; a value outside 1 to 100 is refused.
|
|
144
|
+
schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
|
|
145
|
+
responses:
|
|
146
|
+
'200':
|
|
147
|
+
content:
|
|
148
|
+
application/json:
|
|
149
|
+
schema: { $ref: '#/components/schemas/ProjectDeploymentPage' }
|
|
150
|
+
default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
paths:
|
|
2
|
+
projects:
|
|
3
|
+
get:
|
|
4
|
+
operationId: listProjects
|
|
5
|
+
security: [{ bearerAuth: [] }]
|
|
6
|
+
responses:
|
|
7
|
+
'200':
|
|
8
|
+
content:
|
|
9
|
+
application/json:
|
|
10
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/ProjectList' }
|
|
11
|
+
default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
|
|
12
|
+
post:
|
|
13
|
+
operationId: createProject
|
|
14
|
+
description: |
|
|
15
|
+
Creates a project with its production environment and, from a repository, its first service.
|
|
16
|
+
|
|
17
|
+
A client that may lose the answer sends an `Idempotency-Key` and retries with the same key and
|
|
18
|
+
the same request: the same `slug`, `region`, `repository` and `branch`. Once the first create
|
|
19
|
+
finished, the retry answers 200 with the project that key created, as a fresh create would:
|
|
20
|
+
its `projectId`, current `slug` and `region`, and the original `environmentId` and
|
|
21
|
+
`serviceId`. No second project is created, and the replay needs no GitHub call and no room
|
|
22
|
+
under the plan's project ceiling.
|
|
23
|
+
|
|
24
|
+
A key belongs to its workspace and to the member who sent it. Another member sending the
|
|
25
|
+
same key and body is not given the project; on its taken slug they get 409
|
|
26
|
+
`cloud.errors.projects.slug_taken`, as does a create with another key, or none.
|
|
27
|
+
|
|
28
|
+
While another create holds the slug, a keyed request answers 409
|
|
29
|
+
`cloud.errors.projects.creation_in_progress`: it may be its own first attempt still running,
|
|
30
|
+
so the client retries with the same key. The same key from the same member with a different
|
|
31
|
+
request answers 422 `cloud.errors.projects.idempotency_key_reused`.
|
|
32
|
+
security: [{ bearerAuth: [] }]
|
|
33
|
+
parameters:
|
|
34
|
+
- in: header
|
|
35
|
+
name: Idempotency-Key
|
|
36
|
+
required: false
|
|
37
|
+
description: Identifies one create across retries. 1 to 255 visible ASCII characters.
|
|
38
|
+
schema: { type: string, minLength: 1, maxLength: 255, pattern: '^[\x21-\x7E]+$' }
|
|
39
|
+
requestBody:
|
|
40
|
+
required: true
|
|
41
|
+
content:
|
|
42
|
+
application/json:
|
|
43
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/NewProject' }
|
|
44
|
+
responses:
|
|
45
|
+
'200':
|
|
46
|
+
description: The project created, or the one this `Idempotency-Key` already created.
|
|
47
|
+
content:
|
|
48
|
+
application/json:
|
|
49
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/CreatedProject' }
|
|
50
|
+
'400':
|
|
51
|
+
description: '`cloud.errors.projects.invalid_idempotency_key`: the `Idempotency-Key` is empty, longer than 255 characters, or holds a character outside 0x21-0x7E.'
|
|
52
|
+
content:
|
|
53
|
+
application/json:
|
|
54
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
55
|
+
'409':
|
|
56
|
+
description: '`cloud.errors.projects.slug_taken`: another project holds the slug. `cloud.errors.projects.creation_in_progress`: a keyed request met another create holding the slug; retry with the same key.'
|
|
57
|
+
content:
|
|
58
|
+
application/json:
|
|
59
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
60
|
+
'422':
|
|
61
|
+
description: '`cloud.errors.projects.idempotency_key_reused`: the same member''s `Idempotency-Key` already created a project from a request with a different `slug`, `region`, `repository` or `branch`.'
|
|
62
|
+
content:
|
|
63
|
+
application/json:
|
|
64
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
65
|
+
default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/cloud-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Typed client for the AntelopeJS Cloud API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"generate": "openapi-typescript openapi/cloud.openapi.yaml -o src/generated/cloud-api.ts",
|
|
41
41
|
"build": "pnpm run generate && rimraf dist && tsc",
|
|
42
42
|
"check:generated": "pnpm run generate && git diff --exit-code -- src/generated/cloud-api.ts",
|
|
43
|
-
"lint": "oxlint",
|
|
43
|
+
"lint": "oxlint --type-aware --max-warnings=0",
|
|
44
44
|
"prepack": "pnpm run build",
|
|
45
45
|
"test": "pnpm run build && rimraf dist-test && tsc -p test && node --test 'dist-test/test/**/*.test.js'",
|
|
46
46
|
"typecheck": "tsc --noEmit",
|
|
47
47
|
"release": "pnpm run typecheck && pnpm run lint && pnpm run format:check && pnpm test && release-it",
|
|
48
|
-
"lint:fix": "oxlint --fix && oxfmt .",
|
|
48
|
+
"lint:fix": "oxlint --type-aware --fix && oxfmt .",
|
|
49
49
|
"format": "oxfmt .",
|
|
50
50
|
"format:check": "oxfmt --check ."
|
|
51
51
|
},
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"openapi-fetch": "^0.14.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@antelopejs/tooling-configs": "^0.
|
|
56
|
+
"@antelopejs/tooling-configs": "^0.5.2",
|
|
57
57
|
"@types/node": "^22.19.15",
|
|
58
58
|
"openapi-typescript": "^7.9.1",
|
|
59
|
-
"oxfmt": "^0.
|
|
59
|
+
"oxfmt": "^0.77.0",
|
|
60
60
|
"oxlint": "1.81.0",
|
|
61
61
|
"oxlint-tsgolint": "^7.0.2001",
|
|
62
62
|
"release-it": "^19.2.4",
|