@antelopejs/cloud-sdk 0.1.4 → 0.1.5
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/dist/api.d.ts +39 -9
- package/dist/api.js +32 -6
- package/dist/generated/cloud-api.d.ts +194 -6
- package/dist/index.d.ts +1 -0
- package/dist/logs.d.ts +25 -0
- package/dist/logs.js +17 -0
- package/openapi/builds.yaml +54 -0
- package/openapi/cloud.openapi.yaml +5 -14
- package/openapi/services.yaml +89 -0
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProjectDeploymentsApi } from "./deployments.js";
|
|
2
2
|
import { EnvironmentsApi, ProjectRepositoryApi } from "./environments.js";
|
|
3
3
|
import type { components } from "./generated/cloud-api.js";
|
|
4
|
+
import { type BuildLogRequest, type LogRequest } from "./logs.js";
|
|
4
5
|
import { type SseEvent } from "./sse.js";
|
|
5
6
|
/** What the API answers to an accepted source upload. */
|
|
6
7
|
export interface DeploymentReceipt {
|
|
@@ -13,7 +14,20 @@ export type DeviceToken = components["schemas"]["DeviceToken"];
|
|
|
13
14
|
export type EnvironmentVariable = components["schemas"]["EnvironmentVariable"];
|
|
14
15
|
export type EnvironmentVariableList = components["schemas"]["EnvironmentVariableList"];
|
|
15
16
|
export type NewProject = components["schemas"]["NewProject"];
|
|
16
|
-
|
|
17
|
+
/** A service to create: one each `ajs cloud deploy` uploads, or one built from a repository. */
|
|
18
|
+
export type NewService = components["schemas"]["NewService"];
|
|
19
|
+
/** A service whose deployments each carry their own uploaded source. */
|
|
20
|
+
export type NewUploadService = NewService & {
|
|
21
|
+
source: {
|
|
22
|
+
type: "upload";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/** A service AntelopeJS Cloud builds from a repository at each push. */
|
|
26
|
+
export type NewRepositoryService = NewService & {
|
|
27
|
+
source: {
|
|
28
|
+
type: "repository";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
17
31
|
export type VariableOrigin = components["schemas"]["VariableOrigin"];
|
|
18
32
|
export type VariableWrite = components["schemas"]["VariableWrite"];
|
|
19
33
|
export type WorkspaceProvisioning = components["schemas"]["WorkspaceProvisioning"];
|
|
@@ -46,13 +60,6 @@ export interface PublishedValue {
|
|
|
46
60
|
/** The key it publishes the value under. */
|
|
47
61
|
publishedKey: string;
|
|
48
62
|
}
|
|
49
|
-
/** How a log read is shaped: one bounded page, or a tail from a cursor. */
|
|
50
|
-
export interface LogRequest {
|
|
51
|
-
follow: boolean;
|
|
52
|
-
lastEventId?: string;
|
|
53
|
-
/** Called once the API accepted the read, before its first frame. */
|
|
54
|
-
onOpen?: () => void;
|
|
55
|
-
}
|
|
56
63
|
/** The Cloud API, signed in with one token. Every refusal is a {@link CloudApiError}. */
|
|
57
64
|
export declare class CloudApi {
|
|
58
65
|
private readonly options;
|
|
@@ -117,7 +124,14 @@ export declare class CloudApi {
|
|
|
117
124
|
environmentId: string;
|
|
118
125
|
serviceId?: string | null;
|
|
119
126
|
}>;
|
|
120
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Creates a service in an environment. With a `repository` source it builds
|
|
129
|
+
* that repository at each push to the environment's branch, with the
|
|
130
|
+
* Dockerfile its `dockerfilePath` names when it has one: that is how a
|
|
131
|
+
* second service, such as a dashboard built by `frontend.Dockerfile`, is
|
|
132
|
+
* built from the repository of the first.
|
|
133
|
+
*/
|
|
134
|
+
createService(projectId: string, environmentId: string, body: NewService): Promise<{
|
|
121
135
|
serviceId: string;
|
|
122
136
|
name: string;
|
|
123
137
|
appName: string;
|
|
@@ -168,6 +182,7 @@ export declare class CloudApi {
|
|
|
168
182
|
}>;
|
|
169
183
|
serviceSettings(serviceId: string): Promise<{
|
|
170
184
|
serviceId: string;
|
|
185
|
+
source?: components["schemas"]["ServiceSettingsSource"];
|
|
171
186
|
scaling: {
|
|
172
187
|
bounds: components["schemas"]["ServiceBounds"];
|
|
173
188
|
replicaLimit: number;
|
|
@@ -192,6 +207,14 @@ export declare class CloudApi {
|
|
|
192
207
|
* `cloud.errors.settings.public_needs_port`.
|
|
193
208
|
*/
|
|
194
209
|
setServiceExposure(serviceId: string, isPublic: boolean): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Names the Dockerfile, inside its repository, that builds the service, or
|
|
212
|
+
* goes back to the root `Dockerfile` or a recipe with `null`. The next
|
|
213
|
+
* build reads it. A path that is not a plain relative path is refused with
|
|
214
|
+
* `cloud.errors.settings.invalid_dockerfile_path`, a service that builds no
|
|
215
|
+
* repository with `cloud.errors.settings.not_a_repository_source`.
|
|
216
|
+
*/
|
|
217
|
+
setServiceDockerfile(serviceId: string, path: string | null): Promise<void>;
|
|
195
218
|
/**
|
|
196
219
|
* Adds a variable to the service that follows a value another service of
|
|
197
220
|
* its environment publishes, such as the `MONGO_URL` of a MongoDB resource.
|
|
@@ -219,6 +242,13 @@ export declare class CloudApi {
|
|
|
219
242
|
deploy(serviceId: string, archive: Uint8Array): Promise<DeploymentReceipt>;
|
|
220
243
|
progress(deploymentId: string, signal?: AbortSignal): AsyncGenerator<SseEvent>;
|
|
221
244
|
logs(serviceId: string, request: LogRequest): AsyncGenerator<SseEvent>;
|
|
245
|
+
/**
|
|
246
|
+
* The output of one build, as the `log` events of its stream, then `end`.
|
|
247
|
+
* Without `follow` it is the newest lines, oldest first. A build that is
|
|
248
|
+
* unknown, of another workspace, or whose service was removed answers 404
|
|
249
|
+
* `cloud.errors.builds.not_found`.
|
|
250
|
+
*/
|
|
251
|
+
buildLogs(buildId: string, request: BuildLogRequest): AsyncGenerator<SseEvent>;
|
|
222
252
|
private raw;
|
|
223
253
|
private stream;
|
|
224
254
|
}
|
package/dist/api.js
CHANGED
|
@@ -3,6 +3,7 @@ import { InvalidApiResponseError } from "./api-error.js";
|
|
|
3
3
|
import { ProjectDeploymentsApi } from "./deployments.js";
|
|
4
4
|
import { EnvironmentsApi, ProjectRepositoryApi } from "./environments.js";
|
|
5
5
|
import { isRecord, isString } from "./guards.js";
|
|
6
|
+
import { logReadOf } from "./logs.js";
|
|
6
7
|
import { acceptedOf, dataOf, isApiErrorBody, refusal } from "./result.js";
|
|
7
8
|
import { parseSse } from "./sse.js";
|
|
8
9
|
/** The production Cloud API, used when no `baseUrl` is given. */
|
|
@@ -83,6 +84,13 @@ export class CloudApi {
|
|
|
83
84
|
});
|
|
84
85
|
return dataOf(result);
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Creates a service in an environment. With a `repository` source it builds
|
|
89
|
+
* that repository at each push to the environment's branch, with the
|
|
90
|
+
* Dockerfile its `dockerfilePath` names when it has one: that is how a
|
|
91
|
+
* second service, such as a dashboard built by `frontend.Dockerfile`, is
|
|
92
|
+
* built from the repository of the first.
|
|
93
|
+
*/
|
|
86
94
|
async createService(projectId, environmentId, body) {
|
|
87
95
|
const result = await this.client.POST("/api/cloud/projects/{projectId}/environments/{environmentId}/services", { params: { path: { projectId, environmentId } }, body });
|
|
88
96
|
return dataOf(result);
|
|
@@ -162,6 +170,17 @@ export class CloudApi {
|
|
|
162
170
|
const result = await this.client.PUT("/api/cloud/services/{serviceId}/network", { params: { path: { serviceId } }, body: { isPublic }, parseAs: "text" });
|
|
163
171
|
acceptedOf(result);
|
|
164
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Names the Dockerfile, inside its repository, that builds the service, or
|
|
175
|
+
* goes back to the root `Dockerfile` or a recipe with `null`. The next
|
|
176
|
+
* build reads it. A path that is not a plain relative path is refused with
|
|
177
|
+
* `cloud.errors.settings.invalid_dockerfile_path`, a service that builds no
|
|
178
|
+
* repository with `cloud.errors.settings.not_a_repository_source`.
|
|
179
|
+
*/
|
|
180
|
+
async setServiceDockerfile(serviceId, path) {
|
|
181
|
+
const result = await this.client.PUT("/api/cloud/services/{serviceId}/source-dockerfile", { params: { path: { serviceId } }, body: { path }, parseAs: "text" });
|
|
182
|
+
acceptedOf(result);
|
|
183
|
+
}
|
|
165
184
|
/**
|
|
166
185
|
* Adds a variable to the service that follows a value another service of
|
|
167
186
|
* its environment publishes, such as the `MONGO_URL` of a MongoDB resource.
|
|
@@ -208,12 +227,19 @@ export class CloudApi {
|
|
|
208
227
|
return this.stream(`/api/cloud/deployments/${encodeURIComponent(deploymentId)}/progress`, { Accept: "text/event-stream" }, signal);
|
|
209
228
|
}
|
|
210
229
|
logs(serviceId, request) {
|
|
211
|
-
const
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
230
|
+
const { follow, lastEventId } = request;
|
|
231
|
+
const read = logReadOf({ follow, lastEventId });
|
|
232
|
+
return this.stream(`/api/cloud/services/${encodeURIComponent(serviceId)}/logs${read.query}`, read.headers, undefined, request.onOpen);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The output of one build, as the `log` events of its stream, then `end`.
|
|
236
|
+
* Without `follow` it is the newest lines, oldest first. A build that is
|
|
237
|
+
* unknown, of another workspace, or whose service was removed answers 404
|
|
238
|
+
* `cloud.errors.builds.not_found`.
|
|
239
|
+
*/
|
|
240
|
+
buildLogs(buildId, request) {
|
|
241
|
+
const read = logReadOf(request);
|
|
242
|
+
return this.stream(`/api/cloud/builds/${encodeURIComponent(buildId)}/logs${read.query}`, read.headers, undefined, request.onOpen);
|
|
217
243
|
}
|
|
218
244
|
async raw(path, init) {
|
|
219
245
|
const headers = new Headers(init?.headers);
|
|
@@ -399,6 +399,28 @@ export interface paths {
|
|
|
399
399
|
patch?: never;
|
|
400
400
|
trace?: never;
|
|
401
401
|
};
|
|
402
|
+
"/api/cloud/services/{serviceId}/source-dockerfile": {
|
|
403
|
+
parameters: {
|
|
404
|
+
query?: never;
|
|
405
|
+
header?: never;
|
|
406
|
+
path?: never;
|
|
407
|
+
cookie?: never;
|
|
408
|
+
};
|
|
409
|
+
get?: never;
|
|
410
|
+
/**
|
|
411
|
+
* @description Names the Dockerfile, inside its repository, that builds the service, or goes back
|
|
412
|
+
* to the root `Dockerfile` or a recipe with null. The next build reads it; the
|
|
413
|
+
* revisions already built keep their image. A build of a commit that holds no file at
|
|
414
|
+
* that path fails with `cloud.errors.builds.dockerfile_not_found`.
|
|
415
|
+
*/
|
|
416
|
+
put: operations["setServiceDockerfile"];
|
|
417
|
+
post?: never;
|
|
418
|
+
delete?: never;
|
|
419
|
+
options?: never;
|
|
420
|
+
head?: never;
|
|
421
|
+
patch?: never;
|
|
422
|
+
trace?: never;
|
|
423
|
+
};
|
|
402
424
|
"/api/cloud/services/{serviceId}/variables/references": {
|
|
403
425
|
parameters: {
|
|
404
426
|
query?: never;
|
|
@@ -485,6 +507,33 @@ export interface paths {
|
|
|
485
507
|
patch?: never;
|
|
486
508
|
trace?: never;
|
|
487
509
|
};
|
|
510
|
+
"/api/cloud/builds/{buildId}/logs": {
|
|
511
|
+
parameters: {
|
|
512
|
+
query?: never;
|
|
513
|
+
header?: never;
|
|
514
|
+
path?: never;
|
|
515
|
+
cookie?: never;
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* @description The output of one build as server-sent events, for a member who may observe the
|
|
519
|
+
* build's project. Same contract as a service's logs.
|
|
520
|
+
*
|
|
521
|
+
* Each line is a `log` event: its data is `{ at, level, message, instance }` and its id
|
|
522
|
+
* is the cursor to resume from. Without `follow` the read is a tail: the newest lines,
|
|
523
|
+
* oldest first, then an `end` event. A read from the start opens with one line naming
|
|
524
|
+
* how the build runs (`Build recipe: ...`), which has no cursor and does not count
|
|
525
|
+
* towards `limit`. An `error` event carrying a `code` ends a stream the platform could
|
|
526
|
+
* not serve.
|
|
527
|
+
*/
|
|
528
|
+
get: operations["streamBuildLogs"];
|
|
529
|
+
put?: never;
|
|
530
|
+
post?: never;
|
|
531
|
+
delete?: never;
|
|
532
|
+
options?: never;
|
|
533
|
+
head?: never;
|
|
534
|
+
patch?: never;
|
|
535
|
+
trace?: never;
|
|
536
|
+
};
|
|
488
537
|
"/api/cloud/deployments/{deploymentId}": {
|
|
489
538
|
parameters: {
|
|
490
539
|
query?: never;
|
|
@@ -687,13 +736,15 @@ export interface components {
|
|
|
687
736
|
environmentId: string;
|
|
688
737
|
serviceId?: string | null;
|
|
689
738
|
};
|
|
690
|
-
|
|
739
|
+
/**
|
|
740
|
+
* @description A service to create in an environment. Its source says where its deployments come
|
|
741
|
+
* from: an upload each `ajs cloud deploy` carries, or a repository AntelopeJS Cloud
|
|
742
|
+
* builds at each push.
|
|
743
|
+
*/
|
|
744
|
+
NewService: {
|
|
691
745
|
name: string;
|
|
692
746
|
appName: string;
|
|
693
|
-
source:
|
|
694
|
-
/** @constant */
|
|
695
|
-
type: "upload";
|
|
696
|
-
};
|
|
747
|
+
source: components["schemas"]["UploadSource"] | components["schemas"]["RepositorySource"];
|
|
697
748
|
port?: number | null;
|
|
698
749
|
isPublic?: boolean;
|
|
699
750
|
};
|
|
@@ -718,6 +769,7 @@ export interface components {
|
|
|
718
769
|
};
|
|
719
770
|
ServiceSettings: {
|
|
720
771
|
serviceId: string;
|
|
772
|
+
source?: components["schemas"]["ServiceSettingsSource"];
|
|
721
773
|
scaling: {
|
|
722
774
|
bounds: components["schemas"]["ServiceBounds"];
|
|
723
775
|
replicaLimit: number;
|
|
@@ -893,6 +945,31 @@ export interface components {
|
|
|
893
945
|
environmentId: string;
|
|
894
946
|
services: components["schemas"]["ServiceHealth"][];
|
|
895
947
|
};
|
|
948
|
+
UploadSource: {
|
|
949
|
+
/** @constant */
|
|
950
|
+
type: "upload";
|
|
951
|
+
};
|
|
952
|
+
/**
|
|
953
|
+
* @description Path, inside the repository, of the Dockerfile that builds the service, such as
|
|
954
|
+
* `frontend.Dockerfile` or `apps/web/Dockerfile`: plain segments of letters, digits,
|
|
955
|
+
* `.`, `_` and `-`, separated by `/`. Null or absent: the root `Dockerfile` when the
|
|
956
|
+
* repository has one, else a recipe.
|
|
957
|
+
*/
|
|
958
|
+
DockerfilePath: string | null;
|
|
959
|
+
/**
|
|
960
|
+
* @description A GitHub repository the workspace's GitHub installation grants. Two services of one
|
|
961
|
+
* repository differ by their Dockerfile: an API built by the AntelopeJS recipe next to
|
|
962
|
+
* a dashboard built by `frontend.Dockerfile`.
|
|
963
|
+
*/
|
|
964
|
+
RepositorySource: {
|
|
965
|
+
/** @constant */
|
|
966
|
+
type: "repository";
|
|
967
|
+
/** @description The repository, as `owner/name`. */
|
|
968
|
+
repository: string;
|
|
969
|
+
/** @description The branch this service builds; null or absent follows its environment's branch. */
|
|
970
|
+
branch?: string | null;
|
|
971
|
+
dockerfilePath?: components["schemas"]["DockerfilePath"];
|
|
972
|
+
};
|
|
896
973
|
/** @description A monthly amount in the plan's currency. A plan that rates nothing a database holds includes it, with no amount to show. */
|
|
897
974
|
MonthlyCost: {
|
|
898
975
|
/** @constant */
|
|
@@ -1022,6 +1099,14 @@ export interface components {
|
|
|
1022
1099
|
/** @description The plan that remains once the databases are created. */
|
|
1023
1100
|
plan: components["schemas"]["ResourcePlan"];
|
|
1024
1101
|
};
|
|
1102
|
+
/** @description Where the service's deployments come from. */
|
|
1103
|
+
ServiceSettingsSource: {
|
|
1104
|
+
/** @enum {string} */
|
|
1105
|
+
type: "repository" | "image" | "upload" | "database";
|
|
1106
|
+
/** @description `owner/name`, for a repository source. */
|
|
1107
|
+
repository?: string | null;
|
|
1108
|
+
dockerfilePath?: components["schemas"]["DockerfilePath"];
|
|
1109
|
+
};
|
|
1025
1110
|
/** @description What a built revision was built from. */
|
|
1026
1111
|
RevisionBuild: {
|
|
1027
1112
|
/** @description The branch built; null for a source the CLI uploaded. */
|
|
@@ -1495,7 +1580,7 @@ export interface operations {
|
|
|
1495
1580
|
};
|
|
1496
1581
|
requestBody: {
|
|
1497
1582
|
content: {
|
|
1498
|
-
"application/json": components["schemas"]["
|
|
1583
|
+
"application/json": components["schemas"]["NewService"];
|
|
1499
1584
|
};
|
|
1500
1585
|
};
|
|
1501
1586
|
responses: {
|
|
@@ -1768,6 +1853,51 @@ export interface operations {
|
|
|
1768
1853
|
default: components["responses"]["Error"];
|
|
1769
1854
|
};
|
|
1770
1855
|
};
|
|
1856
|
+
setServiceDockerfile: {
|
|
1857
|
+
parameters: {
|
|
1858
|
+
query?: never;
|
|
1859
|
+
header?: never;
|
|
1860
|
+
path: {
|
|
1861
|
+
serviceId: string;
|
|
1862
|
+
};
|
|
1863
|
+
cookie?: never;
|
|
1864
|
+
};
|
|
1865
|
+
requestBody: {
|
|
1866
|
+
content: {
|
|
1867
|
+
"application/json": {
|
|
1868
|
+
path: components["schemas"]["DockerfilePath"];
|
|
1869
|
+
};
|
|
1870
|
+
};
|
|
1871
|
+
};
|
|
1872
|
+
responses: {
|
|
1873
|
+
/** @description Done */
|
|
1874
|
+
200: {
|
|
1875
|
+
headers: {
|
|
1876
|
+
[name: string]: unknown;
|
|
1877
|
+
};
|
|
1878
|
+
content?: never;
|
|
1879
|
+
};
|
|
1880
|
+
/** @description `cloud.errors.settings.invalid_dockerfile_path`: not a plain relative path inside the repository. */
|
|
1881
|
+
400: {
|
|
1882
|
+
headers: {
|
|
1883
|
+
[name: string]: unknown;
|
|
1884
|
+
};
|
|
1885
|
+
content: {
|
|
1886
|
+
"application/json": components["schemas"]["Error"];
|
|
1887
|
+
};
|
|
1888
|
+
};
|
|
1889
|
+
/** @description `cloud.errors.settings.not_a_repository_source`: the service does not build a repository. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited. */
|
|
1890
|
+
409: {
|
|
1891
|
+
headers: {
|
|
1892
|
+
[name: string]: unknown;
|
|
1893
|
+
};
|
|
1894
|
+
content: {
|
|
1895
|
+
"application/json": components["schemas"]["Error"];
|
|
1896
|
+
};
|
|
1897
|
+
};
|
|
1898
|
+
default: components["responses"]["Error"];
|
|
1899
|
+
};
|
|
1900
|
+
};
|
|
1771
1901
|
followPublishedValue: {
|
|
1772
1902
|
parameters: {
|
|
1773
1903
|
query?: never;
|
|
@@ -1931,6 +2061,64 @@ export interface operations {
|
|
|
1931
2061
|
default: components["responses"]["Error"];
|
|
1932
2062
|
};
|
|
1933
2063
|
};
|
|
2064
|
+
streamBuildLogs: {
|
|
2065
|
+
parameters: {
|
|
2066
|
+
query?: {
|
|
2067
|
+
/** @description Keeps the stream open and delivers the lines the build writes next. */
|
|
2068
|
+
follow?: boolean;
|
|
2069
|
+
/** @description The most lines the read returns before it ends. A tail holds 500 at most. */
|
|
2070
|
+
limit?: number;
|
|
2071
|
+
};
|
|
2072
|
+
header?: {
|
|
2073
|
+
/** @description The id of the last event received. The read resumes after it, oldest first. */
|
|
2074
|
+
"Last-Event-ID"?: string;
|
|
2075
|
+
};
|
|
2076
|
+
path: {
|
|
2077
|
+
buildId: string;
|
|
2078
|
+
};
|
|
2079
|
+
cookie?: never;
|
|
2080
|
+
};
|
|
2081
|
+
requestBody?: never;
|
|
2082
|
+
responses: {
|
|
2083
|
+
/** @description Server-sent log events */
|
|
2084
|
+
200: {
|
|
2085
|
+
headers: {
|
|
2086
|
+
[name: string]: unknown;
|
|
2087
|
+
};
|
|
2088
|
+
content: {
|
|
2089
|
+
"text/event-stream": string;
|
|
2090
|
+
};
|
|
2091
|
+
};
|
|
2092
|
+
/** @description A parameter the API cannot read, such as a `limit` that is not a positive integer. */
|
|
2093
|
+
400: {
|
|
2094
|
+
headers: {
|
|
2095
|
+
[name: string]: unknown;
|
|
2096
|
+
};
|
|
2097
|
+
content: {
|
|
2098
|
+
"application/json": components["schemas"]["Error"];
|
|
2099
|
+
};
|
|
2100
|
+
};
|
|
2101
|
+
/** @description `cloud.errors.builds.not_found`: no such build, a build of another workspace or of a project the member may not observe, or one whose service was removed. */
|
|
2102
|
+
404: {
|
|
2103
|
+
headers: {
|
|
2104
|
+
[name: string]: unknown;
|
|
2105
|
+
};
|
|
2106
|
+
content: {
|
|
2107
|
+
"application/json": components["schemas"]["Error"];
|
|
2108
|
+
};
|
|
2109
|
+
};
|
|
2110
|
+
/** @description The member or the workspace already holds every live follow it may open. `Retry-After` says how long to wait. A read without `follow` is never refused this way. */
|
|
2111
|
+
429: {
|
|
2112
|
+
headers: {
|
|
2113
|
+
[name: string]: unknown;
|
|
2114
|
+
};
|
|
2115
|
+
content: {
|
|
2116
|
+
"application/json": components["schemas"]["Error"];
|
|
2117
|
+
};
|
|
2118
|
+
};
|
|
2119
|
+
default: components["responses"]["Error"];
|
|
2120
|
+
};
|
|
2121
|
+
};
|
|
1934
2122
|
readDeployment: {
|
|
1935
2123
|
parameters: {
|
|
1936
2124
|
query?: never;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export * from "./api.js";
|
|
|
3
3
|
export * from "./deployments.js";
|
|
4
4
|
export * from "./environments.js";
|
|
5
5
|
export type { components, operations, paths } from "./generated/cloud-api.js";
|
|
6
|
+
export type { BuildLogRequest, LogRequest } from "./logs.js";
|
|
6
7
|
export type * from "./resources.js";
|
|
7
8
|
export * from "./sse.js";
|
package/dist/logs.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** How a log read is shaped: one bounded page, or a tail from a cursor. */
|
|
2
|
+
export interface LogRequest {
|
|
3
|
+
follow: boolean;
|
|
4
|
+
lastEventId?: string;
|
|
5
|
+
/** Called once the API accepted the read, before its first frame. */
|
|
6
|
+
onOpen?: () => void;
|
|
7
|
+
}
|
|
8
|
+
/** How one build's log is read. */
|
|
9
|
+
export interface BuildLogRequest extends LogRequest {
|
|
10
|
+
/**
|
|
11
|
+
* The most lines the read returns before it ends. Without `follow` and
|
|
12
|
+
* without `lastEventId` the read is a tail, the newest lines oldest first,
|
|
13
|
+
* and the API returns 500 at most.
|
|
14
|
+
*/
|
|
15
|
+
limit?: number;
|
|
16
|
+
}
|
|
17
|
+
/** A log read as it goes on the wire. */
|
|
18
|
+
interface LogRead {
|
|
19
|
+
/** The query string, with its leading `?`, or empty. */
|
|
20
|
+
query: string;
|
|
21
|
+
headers: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
/** The query string and headers a log read is sent with. */
|
|
24
|
+
export declare function logReadOf(request: BuildLogRequest): LogRead;
|
|
25
|
+
export {};
|
package/dist/logs.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The query string and headers a log read is sent with. */
|
|
2
|
+
export function logReadOf(request) {
|
|
3
|
+
const query = new URLSearchParams();
|
|
4
|
+
if (request.follow)
|
|
5
|
+
query.set("follow", "true");
|
|
6
|
+
if (request.limit !== undefined)
|
|
7
|
+
query.set("limit", String(request.limit));
|
|
8
|
+
const text = query.toString();
|
|
9
|
+
const accept = { Accept: "text/event-stream" };
|
|
10
|
+
return {
|
|
11
|
+
query: text === "" ? "" : `?${text}`,
|
|
12
|
+
headers: request.lastEventId
|
|
13
|
+
? { ...accept, "Last-Event-ID": request.lastEventId }
|
|
14
|
+
: accept,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
paths:
|
|
2
|
+
logs:
|
|
3
|
+
get:
|
|
4
|
+
operationId: streamBuildLogs
|
|
5
|
+
description: |
|
|
6
|
+
The output of one build as server-sent events, for a member who may observe the
|
|
7
|
+
build's project. Same contract as a service's logs.
|
|
8
|
+
|
|
9
|
+
Each line is a `log` event: its data is `{ at, level, message, instance }` and its id
|
|
10
|
+
is the cursor to resume from. Without `follow` the read is a tail: the newest lines,
|
|
11
|
+
oldest first, then an `end` event. A read from the start opens with one line naming
|
|
12
|
+
how the build runs (`Build recipe: ...`), which has no cursor and does not count
|
|
13
|
+
towards `limit`. An `error` event carrying a `code` ends a stream the platform could
|
|
14
|
+
not serve.
|
|
15
|
+
security: [{ bearerAuth: [] }]
|
|
16
|
+
parameters:
|
|
17
|
+
- in: path
|
|
18
|
+
name: buildId
|
|
19
|
+
required: true
|
|
20
|
+
schema: { type: string }
|
|
21
|
+
- in: query
|
|
22
|
+
name: follow
|
|
23
|
+
description: Keeps the stream open and delivers the lines the build writes next.
|
|
24
|
+
schema: { type: boolean }
|
|
25
|
+
- in: query
|
|
26
|
+
name: limit
|
|
27
|
+
description: The most lines the read returns before it ends. A tail holds 500 at most.
|
|
28
|
+
schema: { type: integer, minimum: 1 }
|
|
29
|
+
- in: header
|
|
30
|
+
name: Last-Event-ID
|
|
31
|
+
description: The id of the last event received. The read resumes after it, oldest first.
|
|
32
|
+
schema: { type: string }
|
|
33
|
+
responses:
|
|
34
|
+
'200':
|
|
35
|
+
description: Server-sent log events
|
|
36
|
+
content:
|
|
37
|
+
text/event-stream:
|
|
38
|
+
schema: { type: string }
|
|
39
|
+
'400':
|
|
40
|
+
description: A parameter the API cannot read, such as a `limit` that is not a positive integer.
|
|
41
|
+
content:
|
|
42
|
+
application/json:
|
|
43
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
44
|
+
'404':
|
|
45
|
+
description: '`cloud.errors.builds.not_found`: no such build, a build of another workspace or of a project the member may not observe, or one whose service was removed.'
|
|
46
|
+
content:
|
|
47
|
+
application/json:
|
|
48
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
49
|
+
'429':
|
|
50
|
+
description: The member or the workspace already holds every live follow it may open. `Retry-After` says how long to wait. A read without `follow` is never refused this way.
|
|
51
|
+
content:
|
|
52
|
+
application/json:
|
|
53
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
54
|
+
default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
|
|
@@ -194,19 +194,7 @@ components:
|
|
|
194
194
|
region: { type: string }
|
|
195
195
|
environmentId: { type: string }
|
|
196
196
|
serviceId: { type: [string, "null"] }
|
|
197
|
-
|
|
198
|
-
type: object
|
|
199
|
-
required: [name, appName, source]
|
|
200
|
-
properties:
|
|
201
|
-
name: { type: string }
|
|
202
|
-
appName: { type: string }
|
|
203
|
-
source:
|
|
204
|
-
type: object
|
|
205
|
-
required: [type]
|
|
206
|
-
properties:
|
|
207
|
-
type: { type: string, const: upload }
|
|
208
|
-
port: { type: [integer, "null"] }
|
|
209
|
-
isPublic: { type: boolean }
|
|
197
|
+
NewService: { $ref: 'services.yaml#/schemas/NewService' }
|
|
210
198
|
CreatedService:
|
|
211
199
|
type: object
|
|
212
200
|
required: [serviceId, name, appName]
|
|
@@ -239,6 +227,7 @@ components:
|
|
|
239
227
|
required: [serviceId, scaling, volumeLimits]
|
|
240
228
|
properties:
|
|
241
229
|
serviceId: { type: string }
|
|
230
|
+
source: { $ref: 'services.yaml#/schemas/ServiceSettingsSource' }
|
|
242
231
|
scaling:
|
|
243
232
|
type: object
|
|
244
233
|
required: [bounds, replicaLimit, pricing]
|
|
@@ -353,7 +342,7 @@ paths:
|
|
|
353
342
|
required: true
|
|
354
343
|
content:
|
|
355
344
|
application/json:
|
|
356
|
-
schema: { $ref: '#/components/schemas/
|
|
345
|
+
schema: { $ref: '#/components/schemas/NewService' }
|
|
357
346
|
responses:
|
|
358
347
|
'200':
|
|
359
348
|
content:
|
|
@@ -387,6 +376,7 @@ paths:
|
|
|
387
376
|
default: { $ref: '#/components/responses/Error' }
|
|
388
377
|
/api/cloud/services/{serviceId}/port: { $ref: 'services.yaml#/paths/port' }
|
|
389
378
|
/api/cloud/services/{serviceId}/network: { $ref: 'services.yaml#/paths/network' }
|
|
379
|
+
/api/cloud/services/{serviceId}/source-dockerfile: { $ref: 'services.yaml#/paths/sourceDockerfile' }
|
|
390
380
|
/api/cloud/services/{serviceId}/variables/references: { $ref: 'services.yaml#/paths/variableReferences' }
|
|
391
381
|
/api/cloud/services/{serviceId}/source-deployments:
|
|
392
382
|
post:
|
|
@@ -474,6 +464,7 @@ paths:
|
|
|
474
464
|
text/event-stream:
|
|
475
465
|
schema: { type: string }
|
|
476
466
|
default: { $ref: '#/components/responses/Error' }
|
|
467
|
+
/api/cloud/builds/{buildId}/logs: { $ref: 'builds.yaml#/paths/logs' }
|
|
477
468
|
/api/cloud/deployments/{deploymentId}:
|
|
478
469
|
get:
|
|
479
470
|
operationId: readDeployment
|
package/openapi/services.yaml
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
schemas:
|
|
2
|
+
NewService:
|
|
3
|
+
description: |
|
|
4
|
+
A service to create in an environment. Its source says where its deployments come
|
|
5
|
+
from: an upload each `ajs cloud deploy` carries, or a repository AntelopeJS Cloud
|
|
6
|
+
builds at each push.
|
|
7
|
+
type: object
|
|
8
|
+
required: [name, appName, source]
|
|
9
|
+
properties:
|
|
10
|
+
name: { type: string }
|
|
11
|
+
appName: { type: string }
|
|
12
|
+
source:
|
|
13
|
+
oneOf:
|
|
14
|
+
- $ref: '#/schemas/UploadSource'
|
|
15
|
+
- $ref: '#/schemas/RepositorySource'
|
|
16
|
+
port: { type: [integer, "null"] }
|
|
17
|
+
isPublic: { type: boolean }
|
|
18
|
+
UploadSource:
|
|
19
|
+
type: object
|
|
20
|
+
required: [type]
|
|
21
|
+
properties:
|
|
22
|
+
type: { type: string, const: upload }
|
|
23
|
+
RepositorySource:
|
|
24
|
+
description: |
|
|
25
|
+
A GitHub repository the workspace's GitHub installation grants. Two services of one
|
|
26
|
+
repository differ by their Dockerfile: an API built by the AntelopeJS recipe next to
|
|
27
|
+
a dashboard built by `frontend.Dockerfile`.
|
|
28
|
+
type: object
|
|
29
|
+
required: [type, repository]
|
|
30
|
+
properties:
|
|
31
|
+
type: { type: string, const: repository }
|
|
32
|
+
repository: { type: string, description: "The repository, as `owner/name`." }
|
|
33
|
+
branch:
|
|
34
|
+
description: The branch this service builds; null or absent follows its environment's branch.
|
|
35
|
+
type: [string, "null"]
|
|
36
|
+
dockerfilePath: { $ref: '#/schemas/DockerfilePath' }
|
|
37
|
+
DockerfilePath:
|
|
38
|
+
description: |
|
|
39
|
+
Path, inside the repository, of the Dockerfile that builds the service, such as
|
|
40
|
+
`frontend.Dockerfile` or `apps/web/Dockerfile`: plain segments of letters, digits,
|
|
41
|
+
`.`, `_` and `-`, separated by `/`. Null or absent: the root `Dockerfile` when the
|
|
42
|
+
repository has one, else a recipe.
|
|
43
|
+
type: [string, "null"]
|
|
44
|
+
maxLength: 255
|
|
45
|
+
ServiceSettingsSource:
|
|
46
|
+
description: Where the service's deployments come from.
|
|
47
|
+
type: object
|
|
48
|
+
required: [type]
|
|
49
|
+
properties:
|
|
50
|
+
type: { type: string, enum: [repository, image, upload, database] }
|
|
51
|
+
repository: { type: [string, "null"], description: "`owner/name`, for a repository source." }
|
|
52
|
+
dockerfilePath: { $ref: '#/schemas/DockerfilePath' }
|
|
1
53
|
paths:
|
|
2
54
|
port:
|
|
3
55
|
put:
|
|
@@ -124,3 +176,40 @@ paths:
|
|
|
124
176
|
application/json:
|
|
125
177
|
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
126
178
|
default: { $ref: './cloud.openapi.yaml#/components/responses/Error' }
|
|
179
|
+
sourceDockerfile:
|
|
180
|
+
put:
|
|
181
|
+
operationId: setServiceDockerfile
|
|
182
|
+
description: |
|
|
183
|
+
Names the Dockerfile, inside its repository, that builds the service, or goes back
|
|
184
|
+
to the root `Dockerfile` or a recipe with null. The next build reads it; the
|
|
185
|
+
revisions already built keep their image. A build of a commit that holds no file at
|
|
186
|
+
that path fails with `cloud.errors.builds.dockerfile_not_found`.
|
|
187
|
+
security: [{ bearerAuth: [] }]
|
|
188
|
+
parameters:
|
|
189
|
+
- in: path
|
|
190
|
+
name: serviceId
|
|
191
|
+
required: true
|
|
192
|
+
schema: { type: string }
|
|
193
|
+
requestBody:
|
|
194
|
+
required: true
|
|
195
|
+
content:
|
|
196
|
+
application/json:
|
|
197
|
+
schema:
|
|
198
|
+
type: object
|
|
199
|
+
required: [path]
|
|
200
|
+
properties:
|
|
201
|
+
path: { $ref: '#/schemas/DockerfilePath' }
|
|
202
|
+
responses:
|
|
203
|
+
'200':
|
|
204
|
+
description: Done
|
|
205
|
+
'400':
|
|
206
|
+
description: '`cloud.errors.settings.invalid_dockerfile_path`: not a plain relative path inside the repository.'
|
|
207
|
+
content:
|
|
208
|
+
application/json:
|
|
209
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
210
|
+
'409':
|
|
211
|
+
description: '`cloud.errors.settings.not_a_repository_source`: the service does not build a repository. `cloud.errors.settings.preview_read_only`: a preview mirrors its environment and is not edited.'
|
|
212
|
+
content:
|
|
213
|
+
application/json:
|
|
214
|
+
schema: { $ref: './cloud.openapi.yaml#/components/schemas/Error' }
|
|
215
|
+
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.5",
|
|
4
4
|
"description": "Typed client for the AntelopeJS Cloud API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"openapi-fetch": "^0.14.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@antelopejs/tooling-configs": "^0.5.
|
|
56
|
+
"@antelopejs/tooling-configs": "^0.5.5",
|
|
57
57
|
"@types/node": "^22.19.15",
|
|
58
58
|
"openapi-typescript": "^7.9.1",
|
|
59
59
|
"oxfmt": "^0.77.0",
|