@antelopejs/cloud-sdk 0.1.8-next.40.g64ea6a7 → 0.1.8-next.43.g84dc2e2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +102 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -61,6 +61,108 @@ Until a person approves the code, `exchangeDevice` refuses with
61
61
  asks for five more seconds between polls. Both functions take the same
62
62
  `baseUrl` and `fetch` options as the client.
63
63
 
64
+ ## Create a project once
65
+
66
+ Pass an `idempotencyKey`, 1 to 255 visible ASCII characters, so that a retried create answers the project the first call made:
67
+
68
+ ```ts
69
+ import { CloudApi } from "@antelopejs/cloud-sdk";
70
+
71
+ const api = new CloudApi({ token: process.env.ANTELOPE_CLOUD_TOKEN! });
72
+
73
+ const project = await api.createProject(
74
+ { slug: "shop" },
75
+ { idempotencyKey: "shop-create-1" },
76
+ );
77
+ console.log(project);
78
+ ```
79
+
80
+ The key is scoped to the workspace and to the member who sends it. The same key with another body is refused with `cloud.errors.projects.idempotency_key_reused`, and `cloud.errors.projects.creation_in_progress` asks for a retry with the same key.
81
+
82
+ ## Create a service from a repository
83
+
84
+ A `repository` source builds a repository at each push to its branch, with the Dockerfile `dockerfilePath` names. Give the container's `port`, and set `isPublic` to serve it on its own address:
85
+
86
+ ```ts
87
+ import { CloudApi } from "@antelopejs/cloud-sdk";
88
+
89
+ const api = new CloudApi({ token: process.env.ANTELOPE_CLOUD_TOKEN! });
90
+ const projectId = "…";
91
+ const environmentId = "…";
92
+
93
+ const service = await api.createService(projectId, environmentId, {
94
+ name: "dashboard",
95
+ appName: "dashboard",
96
+ source: {
97
+ type: "repository",
98
+ repository: "acme/shop",
99
+ dockerfilePath: "frontend.Dockerfile",
100
+ },
101
+ port: 3000,
102
+ isPublic: true,
103
+ });
104
+ console.log(service);
105
+ ```
106
+
107
+ ## Port and exposure
108
+
109
+ A service built from a repository has no port, and is refused its deployments until it has one. Both setters take effect at the next deployment:
110
+
111
+ ```ts
112
+ import { CloudApi } from "@antelopejs/cloud-sdk";
113
+
114
+ const api = new CloudApi({ token: process.env.ANTELOPE_CLOUD_TOKEN! });
115
+ const serviceId = "…";
116
+
117
+ await api.setServicePort(serviceId, 8080); // 1024 to 65535, or null to clear
118
+ await api.setServiceExposure(serviceId, true); // false closes it again
119
+ ```
120
+
121
+ `setServiceExposure` refuses a service without a port with `cloud.errors.settings.public_needs_port`.
122
+
123
+ ## List a project's deployments
124
+
125
+ `api.projectDeployments.list` returns one page of deployments across all environments, newest first. Follow `nextCursor` while it is not `null`, with the same filters:
126
+
127
+ ```ts
128
+ import { CloudApi } from "@antelopejs/cloud-sdk";
129
+
130
+ const api = new CloudApi({ token: process.env.ANTELOPE_CLOUD_TOKEN! });
131
+ const projectId = "…";
132
+
133
+ let cursor: string | undefined;
134
+ do {
135
+ const page = await api.projectDeployments.list(projectId, {
136
+ status: ["failed"],
137
+ limit: 50,
138
+ cursor,
139
+ });
140
+ for (const deployment of page.deployments) {
141
+ console.log(deployment.number, deployment.status, deployment.commit);
142
+ }
143
+ cursor = page.nextCursor ?? undefined;
144
+ } while (cursor);
145
+ ```
146
+
147
+ `environmentId` restricts the list to one environment, and `limit` is 1 to 100.
148
+
149
+ ## Read a build's logs
150
+
151
+ `api.buildLogs` streams the output of one build as `log` events, then `end`. Without `follow` it is the newest `limit` lines (500 at most), oldest first; with `follow` it tails the build:
152
+
153
+ ```ts
154
+ import { CloudApi } from "@antelopejs/cloud-sdk";
155
+
156
+ const api = new CloudApi({ token: process.env.ANTELOPE_CLOUD_TOKEN! });
157
+ const buildId = "…";
158
+
159
+ for await (const event of api.buildLogs(buildId, { follow: false, limit: 200 })) {
160
+ if (event.event === "log") console.log(event.data);
161
+ }
162
+ ```
163
+
164
+ A build that is unknown, of another workspace, or whose service was removed is refused with 404 `cloud.errors.builds.not_found`. The `buildId` is the one `deploy` returns in its receipt.
165
+
64
166
  ## Types
65
167
 
66
168
  `paths`, `components` and `operations` are the types generated from
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/cloud-sdk",
3
- "version": "0.1.8-next.40.g64ea6a7",
3
+ "version": "0.1.8-next.43.g84dc2e2",
4
4
  "description": "Typed client for the AntelopeJS Cloud API",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -54,7 +54,7 @@
54
54
  "engines": {
55
55
  "node": ">=20.19"
56
56
  },
57
- "gitHead": "64ea6a79264b558aba6003138ed5fe34c5c848af",
57
+ "gitHead": "84dc2e20cdb063c098295e4e2cdf45b8492eb98c",
58
58
  "scripts": {
59
59
  "generate": "openapi-typescript openapi/cloud.openapi.yaml -o src/generated/cloud-api.ts",
60
60
  "build": "pnpm run generate && rimraf dist && tsc",