@runlot/api 0.1.0-rc.11 → 0.1.0-rc.111
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/index.d.ts +658 -111
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +820 -114
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +11755 -2758
- package/dist/schema.d.ts.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
export const API_VERSION = "v1";
|
|
2
|
-
/**
|
|
2
|
+
/** The shared query for browsing. Empty values are not carried — the server reads "empty means default". */
|
|
3
|
+
function gitQuery(ref, path) {
|
|
4
|
+
const q = new URLSearchParams();
|
|
5
|
+
if (ref !== "")
|
|
6
|
+
q.set("ref", ref);
|
|
7
|
+
if (path !== "")
|
|
8
|
+
q.set("path", path);
|
|
9
|
+
return q.size > 0 ? `?${q.toString()}` : "";
|
|
10
|
+
}
|
|
11
|
+
export const API_SCOPES = [
|
|
12
|
+
"project:read",
|
|
13
|
+
"deploy",
|
|
14
|
+
"db:read",
|
|
15
|
+
"db:write",
|
|
16
|
+
"repo:read",
|
|
17
|
+
"repo:write",
|
|
18
|
+
"org:admin",
|
|
19
|
+
];
|
|
20
|
+
/** The exception that carries the server's error envelope unchanged. */
|
|
3
21
|
export class ApiError extends Error {
|
|
4
22
|
status;
|
|
5
23
|
code;
|
|
@@ -14,10 +32,11 @@ export class ApiError extends Error {
|
|
|
14
32
|
}
|
|
15
33
|
}
|
|
16
34
|
/**
|
|
17
|
-
* cp-public
|
|
35
|
+
* The cp-public client.
|
|
18
36
|
*
|
|
19
|
-
* CLI
|
|
20
|
-
*
|
|
37
|
+
* The CLI and the dashboard use the same one. If each called fetch itself, their
|
|
38
|
+
* error handling would drift a little, and that difference shows up during an
|
|
39
|
+
* incident.
|
|
21
40
|
*/
|
|
22
41
|
function dbPath(org, name) {
|
|
23
42
|
return `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`;
|
|
@@ -45,8 +64,21 @@ export class Client {
|
|
|
45
64
|
body = (await res.json());
|
|
46
65
|
}
|
|
47
66
|
catch {
|
|
48
|
-
//
|
|
49
|
-
//
|
|
67
|
+
// An error response that is not JSON (a 502 made by a proxy, for instance)
|
|
68
|
+
// is raised as the same exception — so the caller does not have to handle
|
|
69
|
+
// two shapes of failure.
|
|
70
|
+
}
|
|
71
|
+
if (body === undefined && res.status >= 502 && res.status <= 504) {
|
|
72
|
+
// The edge replaced the 5xx body with its own HTML. The code and reason
|
|
73
|
+
// the server wrote are not here — so say that, rather than "unknown". On
|
|
74
|
+
// 2026-09-10 a registrar rejection came out this way as
|
|
75
|
+
// "unknown: POST … → 502".
|
|
76
|
+
body = {
|
|
77
|
+
error: {
|
|
78
|
+
code: "edge_" + res.status,
|
|
79
|
+
message: "The server returned an error (" + res.status + "), and the error details could not be read. Try again shortly.",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
50
82
|
}
|
|
51
83
|
throw new ApiError(res.status, body, `${method} ${path} → ${res.status}`);
|
|
52
84
|
}
|
|
@@ -54,6 +86,21 @@ export class Client {
|
|
|
54
86
|
return undefined;
|
|
55
87
|
return (await res.json());
|
|
56
88
|
}
|
|
89
|
+
/** A body that is not JSON (the raw mail). Error handling is the same as request. */
|
|
90
|
+
async text(method, path) {
|
|
91
|
+
const res = await fetch(new URL(path, this.opts.baseUrl), { method, headers: this.headers() });
|
|
92
|
+
if (!res.ok) {
|
|
93
|
+
let body;
|
|
94
|
+
try {
|
|
95
|
+
body = (await res.json());
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// The same reason as in request
|
|
99
|
+
}
|
|
100
|
+
throw new ApiError(res.status, body, `${method} ${path} → ${res.status}`);
|
|
101
|
+
}
|
|
102
|
+
return await res.text();
|
|
103
|
+
}
|
|
57
104
|
json(method, path, body) {
|
|
58
105
|
if (body === undefined)
|
|
59
106
|
return this.request(method, path);
|
|
@@ -65,38 +112,161 @@ export class Client {
|
|
|
65
112
|
devLogin(subject) {
|
|
66
113
|
return this.json("POST", "/v1/auth/dev/login", { subject });
|
|
67
114
|
}
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Takes the sign-up and sends the confirmation mail. Neither a session nor a
|
|
117
|
+
* password is created here — the password is chosen in `verifyEmail` by
|
|
118
|
+
* whoever opens the mailbox.
|
|
119
|
+
*/
|
|
120
|
+
passwordSignUp(email, name) {
|
|
121
|
+
return this.json("POST", "/v1/auth/password/sign-up", {
|
|
122
|
+
email,
|
|
123
|
+
...(name === undefined ? {} : { name }),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
passwordSignIn(email, password) {
|
|
127
|
+
return this.json("POST", "/v1/auth/password/sign-in", { email, password });
|
|
128
|
+
}
|
|
129
|
+
/** The same accepted response comes back whether or not the email exists. */
|
|
130
|
+
passwordForgot(email) {
|
|
131
|
+
return this.json("POST", "/v1/auth/password/forgot", { email });
|
|
132
|
+
}
|
|
133
|
+
passwordReset(token, password) {
|
|
134
|
+
return this.json("POST", "/v1/auth/password/reset", { token, password });
|
|
135
|
+
}
|
|
136
|
+
/** Uses the confirmation link and sets the account's first password. */
|
|
137
|
+
verifyEmail(token, password) {
|
|
138
|
+
return this.json("POST", "/v1/auth/email/verify", { token, password });
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Finishes a sign-in that came back `{mfa:"totp"}`.
|
|
142
|
+
*
|
|
143
|
+
* Callable without a token: `pending` is the credential, and it is not a
|
|
144
|
+
* session — no other endpoint accepts it.
|
|
145
|
+
*/
|
|
146
|
+
completeTotpLogin(pending, factor) {
|
|
147
|
+
return this.json("POST", "/v1/auth/totp", { pending, ...factor });
|
|
148
|
+
}
|
|
149
|
+
/** This account's two-factor state, including which orgs require it. */
|
|
150
|
+
getTotp() {
|
|
151
|
+
return this.json("GET", "/v1/me/totp");
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Draws a secret to scan. It does **not** turn the factor on — `confirmTotp`
|
|
155
|
+
* does, after the app has proved it can produce a code.
|
|
156
|
+
*/
|
|
157
|
+
enrollTotp() {
|
|
158
|
+
return this.json("POST", "/v1/me/totp/enroll");
|
|
159
|
+
}
|
|
160
|
+
/** Turns the factor on and hands back the ten recovery codes. They are shown once. */
|
|
161
|
+
confirmTotp(code) {
|
|
162
|
+
return this.json("POST", "/v1/me/totp/confirm", { code });
|
|
163
|
+
}
|
|
164
|
+
/** Turns it off. A code or a recovery code is required — the session alone is not. */
|
|
165
|
+
disableTotp(factor) {
|
|
166
|
+
return this.json("DELETE", "/v1/me/totp", factor);
|
|
71
167
|
}
|
|
72
168
|
/**
|
|
73
|
-
* GitHub OAuth
|
|
74
|
-
* `window.location`
|
|
169
|
+
* The GitHub OAuth start URL. It is a 302 the browser follows, so it goes into
|
|
170
|
+
* `window.location` rather than being called with fetch. `redirect` has to be
|
|
171
|
+
* on the server's allow-list.
|
|
75
172
|
*/
|
|
76
173
|
githubStartUrl(redirect) {
|
|
77
174
|
const u = new URL("/v1/auth/github/start", this.opts.baseUrl);
|
|
78
175
|
u.searchParams.set("redirect", redirect);
|
|
79
176
|
return u.toString();
|
|
80
177
|
}
|
|
178
|
+
/** The Google OAuth start URL. Uses the same dashboard callback shape as GitHub. */
|
|
179
|
+
googleStartUrl(redirect) {
|
|
180
|
+
const u = new URL("/v1/auth/google/start", this.opts.baseUrl);
|
|
181
|
+
u.searchParams.set("redirect", redirect);
|
|
182
|
+
return u.toString();
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The names of this deployment (app domain, docs address). Callable without auth.
|
|
186
|
+
*
|
|
187
|
+
* This exists so the dashboard does not hard-code a domain into the screen
|
|
188
|
+
* (docs/environments.md §3.2) — hard-coded, the dev screen tells people a
|
|
189
|
+
* production address, and because that address opens, nobody ever says it is
|
|
190
|
+
* wrong.
|
|
191
|
+
*/
|
|
192
|
+
siteConfig() {
|
|
193
|
+
return this.json("GET", "/v1/config");
|
|
194
|
+
}
|
|
81
195
|
me() {
|
|
82
196
|
return this.json("GET", "/v1/me");
|
|
83
197
|
}
|
|
84
198
|
listOrgs() {
|
|
85
199
|
return this.json("GET", "/v1/orgs");
|
|
86
200
|
}
|
|
201
|
+
/** Changes the display name only (admin). The slug is the name that becomes an address, so it is not on this surface. */
|
|
202
|
+
/**
|
|
203
|
+
* `requireTotp` is left out when it is not given, on purpose: the server reads
|
|
204
|
+
* an absent field as "leave it alone". Sending `false` by default would mean a
|
|
205
|
+
* rename silently switched the org's second-factor requirement off.
|
|
206
|
+
*/
|
|
207
|
+
updateOrg(org, name, requireTotp) {
|
|
208
|
+
return this.json("PATCH", `/v1/orgs/${encodeURIComponent(org)}`, {
|
|
209
|
+
name,
|
|
210
|
+
...(requireTotp === undefined ? {} : { requireTotp }),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Deletes the organization (admin). **This cannot be undone.**
|
|
215
|
+
*
|
|
216
|
+
* `confirm` has to be the organization slug exactly — the confirmation lives on
|
|
217
|
+
* the server because three places call this surface (the screen, the CLI, and
|
|
218
|
+
* scripts). If a live project, domain, repository, or DNS zone is left, it is a
|
|
219
|
+
* 409 `org_not_empty` and `details.holdings` says what is left — **projects
|
|
220
|
+
* already deleted are not counted.**
|
|
221
|
+
*
|
|
222
|
+
* The `purgeAfter` in the answer is when the rows actually disappear. By the
|
|
223
|
+
* moment it returns the organization is already gone from every surface; what
|
|
224
|
+
* remains is retention until that time.
|
|
225
|
+
*/
|
|
226
|
+
deleteOrg(org, confirm) {
|
|
227
|
+
return this.json("DELETE", `/v1/orgs/${encodeURIComponent(org)}`, { confirm });
|
|
228
|
+
}
|
|
87
229
|
createOrg(slug, name) {
|
|
88
230
|
return this.json("POST", "/v1/orgs", { slug, name });
|
|
89
231
|
}
|
|
90
232
|
/**
|
|
91
|
-
*
|
|
233
|
+
* The organization's recent notifications (docs/limits.md §3.4).
|
|
92
234
|
*
|
|
93
|
-
* `sentAt`
|
|
94
|
-
*
|
|
235
|
+
* A row with no `sentAt` is either still queued or has no email address to
|
|
236
|
+
* reach — and for the second, this list is the only channel, so the screen
|
|
237
|
+
* draws both states the same way.
|
|
95
238
|
*/
|
|
96
239
|
listNotifications(org, limit) {
|
|
97
240
|
const q = limit === undefined ? "" : `?limit=${limit}`;
|
|
98
241
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/notifications${q}`);
|
|
99
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* The plan and billing state (docs/billing.md). If `enabled` is false, this
|
|
245
|
+
* deployment has no billing — the screen shows only a contact address.
|
|
246
|
+
*/
|
|
247
|
+
getBilling(org) {
|
|
248
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/billing`);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* A Pro checkout session. Send the browser to the `url` that comes back. Even
|
|
252
|
+
* once payment finishes, the thing that changes the plan is the webhook, so
|
|
253
|
+
* read `getBilling` again after the browser returns.
|
|
254
|
+
*/
|
|
255
|
+
createBillingCheckout(org, returnTo) {
|
|
256
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/checkout`, { returnTo });
|
|
257
|
+
}
|
|
258
|
+
/** A one-time `url` for the customer portal (payment method, receipts, cancellation). */
|
|
259
|
+
createBillingPortal(org, returnTo) {
|
|
260
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/portal`, { returnTo });
|
|
261
|
+
}
|
|
262
|
+
/** The customer session token for the payment-method embed (1 hour). An org with no payment history gets a 404. */
|
|
263
|
+
createBillingSession(org) {
|
|
264
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/session`, {});
|
|
265
|
+
}
|
|
266
|
+
/** Schedules cancellation at the end of the period (`cancel: true`), or undoes it. There is no immediate revocation. */
|
|
267
|
+
cancelBilling(org, body) {
|
|
268
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/cancel`, body);
|
|
269
|
+
}
|
|
100
270
|
listProjects(org) {
|
|
101
271
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects`);
|
|
102
272
|
}
|
|
@@ -106,17 +276,210 @@ export class Client {
|
|
|
106
276
|
getProject(org, name) {
|
|
107
277
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}`);
|
|
108
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Renames the project (admin). **The default address moves with it and there is
|
|
281
|
+
* no alias** — which is why the response carries the new address. Unlike the
|
|
282
|
+
* org slug, this name can change because it is the inner label of the org
|
|
283
|
+
* wildcard certificate.
|
|
284
|
+
*/
|
|
285
|
+
updateProject(org, name, next) {
|
|
286
|
+
return this.json("PATCH", this.projectPath(org, name), { name: next });
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Starts tearing the project down (admin). **This cannot be undone and leaves
|
|
290
|
+
* no recovery generation.** `confirm` has to be the project name exactly.
|
|
291
|
+
*/
|
|
292
|
+
deleteProject(org, name, confirm) {
|
|
293
|
+
return this.json("DELETE", this.projectPath(org, name), { confirm });
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Disables a project (admin): it stops serving and taking new backups, and
|
|
297
|
+
* keeps everything it has. A project disabled for a year is deleted for good.
|
|
298
|
+
*/
|
|
299
|
+
disableProject(org, name) {
|
|
300
|
+
return this.json("POST", `${this.projectPath(org, name)}/disable`);
|
|
301
|
+
}
|
|
302
|
+
/** Enables a disabled project (admin). 409 `project_limit` when there is no room for it. */
|
|
303
|
+
enableProject(org, name) {
|
|
304
|
+
return this.json("POST", `${this.projectPath(org, name)}/enable`);
|
|
305
|
+
}
|
|
306
|
+
/** Watches the teardown operation to its end even after the project is gone. */
|
|
307
|
+
getOrgOperation(org, opId) {
|
|
308
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/operations/${encodeURIComponent(opId)}`);
|
|
309
|
+
}
|
|
310
|
+
/** Everything the project's first screen takes in one call. Usage calls `getUsage` alongside it. */
|
|
311
|
+
getProjectOverview(org, name) {
|
|
312
|
+
return this.json("GET", `${this.projectPath(org, name)}/overview`);
|
|
313
|
+
}
|
|
109
314
|
listDeployments(org, name) {
|
|
110
315
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/deployments`);
|
|
111
316
|
}
|
|
112
|
-
/**
|
|
113
|
-
|
|
317
|
+
/**
|
|
318
|
+
* One deployment, with `migrations` when the control plane applied its
|
|
319
|
+
* `migrations/` — which today means a preview deployed with `db=branch`
|
|
320
|
+
* (docs/studio.md §6.6 step 2).
|
|
321
|
+
*
|
|
322
|
+
* A preview's deployment is read under **the parent project's name**, the name
|
|
323
|
+
* the caller deployed through: the preview is a project of its own, but the
|
|
324
|
+
* caller never learns its name.
|
|
325
|
+
*/
|
|
326
|
+
getDeployment(org, name, deploymentId) {
|
|
327
|
+
return this.json("GET", `${this.projectPath(org, name)}/deployments/${encodeURIComponent(deploymentId)}`);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Scheduled runs: what the live deployment declares, when each fires next, and
|
|
331
|
+
* the recent history (docs/cron.md §8). `limit` bounds the history rows only —
|
|
332
|
+
* the schedules and the per-schedule last run are never paged.
|
|
333
|
+
*/
|
|
334
|
+
getProjectCron(org, name, limit) {
|
|
335
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
336
|
+
return this.json("GET", `${this.projectPath(org, name)}/cron${qs}`);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Queues: what the live deployment declares, how deep each one is, and the
|
|
340
|
+
* recent batch history (docs/queues.md §6). The depth is read from the
|
|
341
|
+
* project's own database; `depthError` on the answer says when it could not be.
|
|
342
|
+
*/
|
|
343
|
+
getProjectQueues(org, name, limit) {
|
|
344
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
345
|
+
return this.json("GET", `${this.projectPath(org, name)}/queues${qs}`);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Durable Objects: how many this project has placed, against the two caps
|
|
349
|
+
* (docs/durable-objects.md).
|
|
350
|
+
*
|
|
351
|
+
* **It answers how much, never which.** There is no actor id in the response
|
|
352
|
+
* and none is coming — those name individual objects, and a list of them would
|
|
353
|
+
* be an object enumeration wearing a quota's name. `nodes` is keyed by node id
|
|
354
|
+
* because `nodeLimit` is a separate bound that can refuse a placement while
|
|
355
|
+
* the project-wide cap still has room.
|
|
356
|
+
*/
|
|
357
|
+
getProjectDurableObjects(org, name) {
|
|
358
|
+
return this.json("GET", `${this.projectPath(org, name)}/durable-objects`);
|
|
359
|
+
}
|
|
360
|
+
queuePath(org, name, queue) {
|
|
361
|
+
return `${this.projectPath(org, name)}/queues/${encodeURIComponent(queue)}`;
|
|
362
|
+
}
|
|
363
|
+
listQueueRuns(org, name, queue, limit) {
|
|
364
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
365
|
+
return this.json("GET", `${this.queuePath(org, name, queue)}/runs${qs}`);
|
|
366
|
+
}
|
|
367
|
+
/** The head of the queue without leasing it — looking cannot delay a delivery. */
|
|
368
|
+
peekQueue(org, name, queue, limit) {
|
|
369
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
370
|
+
return this.json("GET", `${this.queuePath(org, name, queue)}/messages${qs}`);
|
|
371
|
+
}
|
|
372
|
+
/** Irreversible. The confirmation is the caller's — the server holds none. */
|
|
373
|
+
purgeQueue(org, name, queue) {
|
|
374
|
+
return this.json("DELETE", `${this.queuePath(org, name, queue)}/messages`);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Moves a dead-letter queue's messages back. `to` is required only when the
|
|
378
|
+
* dead-letter queue belongs to more than one consumer, or to none.
|
|
379
|
+
*/
|
|
380
|
+
redriveQueue(org, name, queue, to) {
|
|
381
|
+
return this.json("POST", `${this.queuePath(org, name, queue)}/redrive`, to === undefined ? {} : { to });
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* The vector store: every namespace with its count and width, and the plan's
|
|
385
|
+
* bounds (docs/vectors.md §4). Read from the project's own database;
|
|
386
|
+
* `readError` on the answer says when it could not be.
|
|
387
|
+
*/
|
|
388
|
+
getProjectVectors(org, name) {
|
|
389
|
+
return this.json("GET", `${this.projectPath(org, name)}/vectors`);
|
|
390
|
+
}
|
|
391
|
+
/** Irreversible. The confirmation is the caller's — the server holds none. */
|
|
392
|
+
deleteVectorNamespace(org, name, namespace) {
|
|
393
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/vectors/${encodeURIComponent(namespace)}`);
|
|
394
|
+
}
|
|
395
|
+
/** The body is the bundle. One digest covers all of the code and the assets. */
|
|
396
|
+
/**
|
|
397
|
+
* Uploads the bundle. `headers` carries the provenance headers
|
|
398
|
+
* (`X-Runlot-Git-*`, openapi createDeployment) — the body is the bundle
|
|
399
|
+
* itself, so the metadata can only travel in headers.
|
|
400
|
+
*/
|
|
401
|
+
deploy(org, name, bundle, headers = {}) {
|
|
114
402
|
return this.request("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/deployments`, {
|
|
115
403
|
body: bundle,
|
|
116
|
-
headers: { "Content-Type": "application/gzip" },
|
|
404
|
+
headers: { ...headers, "Content-Type": "application/gzip" },
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* The same upload, aimed at a preview (docs/preview.md). **It does not move
|
|
409
|
+
* production's live pointer** — that is the whole difference, and it is why
|
|
410
|
+
* this is a named method rather than an optional argument on `deploy`: a
|
|
411
|
+
* caller that forgets the argument deploys to production.
|
|
412
|
+
*
|
|
413
|
+
* `db` picks what `env.db` points at (`branch` by default, `shared` at
|
|
414
|
+
* production's own database, `none` for no database), and `from` pours the
|
|
415
|
+
* branch from a named generation instead of the newest one.
|
|
416
|
+
*/
|
|
417
|
+
deployPreview(org, name, bundle,
|
|
418
|
+
// `| undefined` spelled out: under exactOptionalPropertyTypes a caller that
|
|
419
|
+
// forwards an unset flag is passing the property, not omitting it.
|
|
420
|
+
opts, headers = {}) {
|
|
421
|
+
const q = new URLSearchParams({ preview: opts.preview });
|
|
422
|
+
// Empty values are not carried: the server reads "absent" as its default, and
|
|
423
|
+
// `?db=` would be neither absent nor a member of the enum.
|
|
424
|
+
if (opts.db)
|
|
425
|
+
q.set("db", opts.db);
|
|
426
|
+
if (opts.from)
|
|
427
|
+
q.set("from", opts.from);
|
|
428
|
+
return this.request("POST", `${this.projectPath(org, name)}/deployments?${q.toString()}`, {
|
|
429
|
+
body: bundle,
|
|
430
|
+
headers: { ...headers, "Content-Type": "application/gzip" },
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
/** The parent's live previews (viewer). A deleted preview is not listed. */
|
|
434
|
+
listPreviews(org, name) {
|
|
435
|
+
return this.json("GET", `${this.projectPath(org, name)}/previews`);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Deletes a preview and its branch (member).
|
|
439
|
+
*
|
|
440
|
+
* No confirmation string, unlike `deleteProject`: a branch is a copy taken at a
|
|
441
|
+
* moment and nothing in it is the only copy of anything.
|
|
442
|
+
*/
|
|
443
|
+
deletePreview(org, name, preview) {
|
|
444
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/previews/${encodeURIComponent(preview)}`);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Makes the preview's artifact the parent's live deployment (member).
|
|
448
|
+
*
|
|
449
|
+
* **The code, never the data** (docs/preview.md §7). The branch is not merged
|
|
450
|
+
* and production's database is not replaced. The preview stays alive.
|
|
451
|
+
*/
|
|
452
|
+
promotePreview(org, name, preview) {
|
|
453
|
+
return this.json("POST", `${this.projectPath(org, name)}/previews/${encodeURIComponent(preview)}/promote`);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* The project's share link — `<label>.share.<app-domain>`, the one address
|
|
457
|
+
* Studio hands to somebody who is not a developer (docs/studio.md §6.9).
|
|
458
|
+
*
|
|
459
|
+
* 404 when the project has never been shared: a link is minted by
|
|
460
|
+
* `putShareLink`, never as a side effect of reading.
|
|
461
|
+
*/
|
|
462
|
+
getShareLink(org, name) {
|
|
463
|
+
return this.json("GET", `${this.projectPath(org, name)}/share`);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Points the share link at a preview, minting the label if there is none.
|
|
467
|
+
*
|
|
468
|
+
* Idempotent: the label is kept across shares, so somebody holding the link
|
|
469
|
+
* keeps working. `rotate` mints a new label and retires the old name in the
|
|
470
|
+
* same request ("링크 재발급"), so the project never has two live links.
|
|
471
|
+
*/
|
|
472
|
+
putShareLink(org, name, opts = {}) {
|
|
473
|
+
return this.json("PUT", `${this.projectPath(org, name)}/share`, {
|
|
474
|
+
...(opts.preview === undefined ? {} : { preview: opts.preview }),
|
|
475
|
+
...(opts.rotate === undefined ? {} : { rotate: opts.rotate }),
|
|
117
476
|
});
|
|
118
477
|
}
|
|
119
|
-
/**
|
|
478
|
+
/** Stops the link answering and forgets the label. The preview keeps running. */
|
|
479
|
+
deleteShareLink(org, name) {
|
|
480
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/share`);
|
|
481
|
+
}
|
|
482
|
+
/** Idempotent. Called twice, the password is not rolled and the same connection details come back. */
|
|
120
483
|
createDatabase(org, name) {
|
|
121
484
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`);
|
|
122
485
|
}
|
|
@@ -124,17 +487,18 @@ export class Client {
|
|
|
124
487
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`);
|
|
125
488
|
}
|
|
126
489
|
/**
|
|
127
|
-
*
|
|
128
|
-
* viewer
|
|
490
|
+
* The connection credentials as well. The route is split from `getDatabase`
|
|
491
|
+
* because of roles — a viewer may know whether there is a database, but not
|
|
492
|
+
* the password (proto/openapi.yaml).
|
|
129
493
|
*/
|
|
130
494
|
getDatabaseConnect(org, name) {
|
|
131
495
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database/connect`);
|
|
132
496
|
}
|
|
133
|
-
/**
|
|
497
|
+
/** The endpoint only — no credentials. A viewer gets it too. Used by `runlot port-forward`. */
|
|
134
498
|
getDatabaseEndpoint(org, name) {
|
|
135
499
|
return this.json("GET", `${dbPath(org, name)}/endpoint`);
|
|
136
500
|
}
|
|
137
|
-
/**
|
|
501
|
+
/** Issues a short-lived machine credential. The password is carried in this response and nowhere else. */
|
|
138
502
|
createDatabaseToken(org, name, ttlSeconds) {
|
|
139
503
|
return this.json("POST", `${dbPath(org, name)}/tokens`, ttlSeconds === undefined ? {} : { ttlSeconds });
|
|
140
504
|
}
|
|
@@ -145,52 +509,84 @@ export class Client {
|
|
|
145
509
|
return this.json("DELETE", `${dbPath(org, name)}/tokens/${encodeURIComponent(user)}`);
|
|
146
510
|
}
|
|
147
511
|
/**
|
|
148
|
-
*
|
|
512
|
+
* Makes one diagnostic image.
|
|
149
513
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* (proto/openapi.yaml).
|
|
514
|
+
* **Not idempotent** — every call makes another image. And it is slow: the
|
|
515
|
+
* response comes after the dump finishes, and that project's actor is held
|
|
516
|
+
* for the whole of it (proto/openapi.yaml).
|
|
153
517
|
*/
|
|
154
518
|
exportDatabase(org, name) {
|
|
155
519
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database/export`);
|
|
156
520
|
}
|
|
157
521
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
522
|
+
* Every generation a restore can choose, newest first. `lastCheckedAt` is the
|
|
523
|
+
* heartbeat of the no-change skip — it is what tells "no new generations"
|
|
524
|
+
* apart from "the backup is dead".
|
|
160
525
|
*/
|
|
161
526
|
listGenerations(org, name) {
|
|
162
527
|
return this.json("GET", `${this.dbPath(org, name)}/generations`);
|
|
163
528
|
}
|
|
164
529
|
/**
|
|
165
|
-
*
|
|
530
|
+
* Runs one statement in the project's database (the dashboard console).
|
|
531
|
+
*
|
|
532
|
+
* `readOnly` is **omitted, not sent as false**, when the caller wants the safe
|
|
533
|
+
* mode: the server treats an absent field as read-only, so leaving it out is the
|
|
534
|
+
* one spelling that cannot be misread. Sending `false` is the explicit ask for
|
|
535
|
+
* write mode, and only then does the server run outside a transaction.
|
|
536
|
+
*
|
|
537
|
+
* SQL failures arrive as an `ApiError` whose body carries `details.sqlstate` —
|
|
538
|
+
* PostgreSQL's own code, which is what the error panel shows.
|
|
539
|
+
*/
|
|
540
|
+
executeSQL(org, name, sql, opts = {}) {
|
|
541
|
+
const body = { sql };
|
|
542
|
+
if (opts.readOnly === false)
|
|
543
|
+
body.readOnly = false;
|
|
544
|
+
if (opts.params !== undefined && opts.params.length > 0)
|
|
545
|
+
body.params = opts.params;
|
|
546
|
+
return this.json("POST", `${this.dbPath(org, name)}/execute`, body);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Rolls back to a generation. **Writes made since then are lost.**
|
|
166
550
|
*
|
|
167
|
-
*
|
|
168
|
-
* `getDatabaseOperation
|
|
169
|
-
*
|
|
551
|
+
* It ends at 202 — what comes back is an operation id, and progress is read
|
|
552
|
+
* through `getDatabaseOperation`. The server does not resolve `latest`: the
|
|
553
|
+
* `(epoch, seq)` chosen from the list is carried as-is (proto/openapi.yaml).
|
|
170
554
|
*/
|
|
171
555
|
restoreDatabase(org, name, epoch, seq) {
|
|
172
556
|
return this.json("POST", `${this.dbPath(org, name)}/restore`, { epoch, seq });
|
|
173
557
|
}
|
|
174
558
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
559
|
+
* Rolls back to a restore point **inside** a backup (pg-feather docs/37):
|
|
560
|
+
* `txnId` is that commit, `at` is the last commit at or before that time. One
|
|
561
|
+
* backup carries the commits in between in order, so the place you can roll
|
|
562
|
+
* back to is not tied to a backup boundary. Everything else is as in
|
|
563
|
+
* restoreDatabase — 202, an operation id, and one safety backup before the
|
|
564
|
+
* rollback.
|
|
565
|
+
*/
|
|
566
|
+
restoreDatabaseTo(org, name, target) {
|
|
567
|
+
return this.json("POST", `${this.dbPath(org, name)}/restore`, target);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Removes the database. `confirm` has to match the project name **exactly**;
|
|
571
|
+
* if it does not, the server refuses with 400 `confirm_mismatch`.
|
|
177
572
|
*/
|
|
178
573
|
deleteDatabase(org, name, confirm) {
|
|
179
574
|
return this.json("POST", `${this.dbPath(org, name)}/delete`, { confirm });
|
|
180
575
|
}
|
|
181
|
-
/**
|
|
576
|
+
/** The progress of one operation. The operation id is not a credential; it lives under the project path. */
|
|
182
577
|
getDatabaseOperation(org, name, opId) {
|
|
183
578
|
return this.json("GET", `${this.dbPath(org, name)}/operations/${encodeURIComponent(opId)}`);
|
|
184
579
|
}
|
|
185
|
-
/**
|
|
580
|
+
/** Aborts an operation that has not yet reached a phase it cannot come back from. */
|
|
186
581
|
abortDatabaseOperation(org, name, opId) {
|
|
187
582
|
return this.json("POST", `${this.dbPath(org, name)}/operations/${encodeURIComponent(opId)}/abort`);
|
|
188
583
|
}
|
|
189
584
|
// ---- Phase 6 (docs/phase6.md) ----
|
|
190
585
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
586
|
+
* A live tail of the logs. It is **a stream, not JSON**, so it does not go
|
|
587
|
+
* through `request` — what comes back is an async iterable of line-by-line
|
|
588
|
+
* `LogEvent`, and aborting `signal` closes the connection. An error response
|
|
589
|
+
* (4xx/5xx) is the same `ApiError` as in every other method.
|
|
194
590
|
*/
|
|
195
591
|
async *tailLogs(org, name, opts = {}) {
|
|
196
592
|
const q = new URLSearchParams();
|
|
@@ -210,7 +606,7 @@ export class Client {
|
|
|
210
606
|
body = (await res.json());
|
|
211
607
|
}
|
|
212
608
|
catch {
|
|
213
|
-
//
|
|
609
|
+
// The same reason as in request above.
|
|
214
610
|
}
|
|
215
611
|
throw new ApiError(res.status, body, `GET ${path} → ${res.status}`);
|
|
216
612
|
}
|
|
@@ -238,14 +634,35 @@ export class Client {
|
|
|
238
634
|
yield JSON.parse(rest);
|
|
239
635
|
}
|
|
240
636
|
finally {
|
|
241
|
-
//
|
|
637
|
+
// If the consumer ends early (break), the server's follow has to end too.
|
|
242
638
|
await reader.cancel().catch(() => { });
|
|
243
639
|
}
|
|
244
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* The stored lane (0062). It is a plain JSON page, not a stream: the history
|
|
643
|
+
* does not reach a node, so it answers for a project that is cold, parked, or
|
|
644
|
+
* has moved since the lines were written — every one of which is a 409 on
|
|
645
|
+
* `tailLogs`.
|
|
646
|
+
*
|
|
647
|
+
* `q` is a plain substring, matched case-insensitively. It is not a regular
|
|
648
|
+
* expression — `%` and `_` match themselves.
|
|
649
|
+
*
|
|
650
|
+
* Paging is keyset: pass the `cursor` from a page back to get the next, older
|
|
651
|
+
* one. A page with no `cursor` is the end of what is kept.
|
|
652
|
+
*/
|
|
653
|
+
getLogHistory(org, name, opts = {}) {
|
|
654
|
+
const params = new URLSearchParams();
|
|
655
|
+
for (const [k, v] of Object.entries(opts)) {
|
|
656
|
+
if (v !== undefined && v !== "")
|
|
657
|
+
params.set(k, String(v));
|
|
658
|
+
}
|
|
659
|
+
const qs = params.size ? `?${params}` : "";
|
|
660
|
+
return this.json("GET", `${this.projectPath(org, name)}/logs/history${qs}`);
|
|
661
|
+
}
|
|
245
662
|
listSecrets(org, name) {
|
|
246
663
|
return this.json("GET", `${this.projectPath(org, name)}/secrets`);
|
|
247
664
|
}
|
|
248
|
-
/**
|
|
665
|
+
/** The value travels in this call only. It is in no response at all. */
|
|
249
666
|
setSecret(org, name, secret, value) {
|
|
250
667
|
return this.json("PUT", `${this.projectPath(org, name)}/secrets/${encodeURIComponent(secret)}`, { value });
|
|
251
668
|
}
|
|
@@ -256,111 +673,261 @@ export class Client {
|
|
|
256
673
|
const q = hours === undefined ? "" : `?hours=${hours}`;
|
|
257
674
|
return this.json("GET", `${this.projectPath(org, name)}/usage${q}`);
|
|
258
675
|
}
|
|
259
|
-
// ----
|
|
260
|
-
/**
|
|
676
|
+
// ---- Object storage (docs/storage.md §8) ----
|
|
677
|
+
/** Grant, prefix, quota, usage. `usedBytes` lags by the node's reporting interval. */
|
|
261
678
|
getStorage(org, name) {
|
|
262
679
|
return this.json("GET", `${this.projectPath(org, name)}/storage`);
|
|
263
680
|
}
|
|
264
681
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
682
|
+
* Grants storage. It is idempotent, so pressing twice leaves the prefix as it
|
|
683
|
+
* was. Taking neither the prefix nor the quota as an argument is the point —
|
|
684
|
+
* the prefix is the isolation boundary and the quota is set by the plan
|
|
685
|
+
* (proto/openapi.yaml).
|
|
268
686
|
*/
|
|
269
687
|
grantStorage(org, name) {
|
|
270
688
|
return this.json("POST", `${this.projectPath(org, name)}/storage`);
|
|
271
689
|
}
|
|
272
|
-
/**
|
|
690
|
+
/** Removes the grant. **The objects are not deleted** (docs/storage.md §7). */
|
|
273
691
|
revokeStorage(org, name) {
|
|
274
692
|
return this.json("DELETE", `${this.projectPath(org, name)}/storage`);
|
|
275
693
|
}
|
|
276
|
-
// ---- 최종 사용자 인증 (docs/auth.md §9) ----
|
|
277
694
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
695
|
+
* The key prefixes this project serves unsigned (docs/storage.md §4.7).
|
|
696
|
+
*
|
|
697
|
+
* A prefix is stored normalized — `assets` becomes `assets/`, and `/` becomes
|
|
698
|
+
* the empty string, which means every key. The value that comes back is the
|
|
699
|
+
* value that governs, so a screen must render the response rather than what
|
|
700
|
+
* the user typed.
|
|
701
|
+
*/
|
|
702
|
+
listStoragePublic(org, name) {
|
|
703
|
+
return this.json("GET", `${this.projectPath(org, name)}/storage/public`);
|
|
704
|
+
}
|
|
705
|
+
/** Publishes a prefix. Idempotent. All three verbs answer with the whole list. */
|
|
706
|
+
addStoragePublic(org, name, prefix) {
|
|
707
|
+
return this.json("POST", `${this.projectPath(org, name)}/storage/public`, { prefix });
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Unpublishes a prefix. Idempotent.
|
|
711
|
+
*
|
|
712
|
+
* **The world keeps reading for up to a minute.** The object front caches the
|
|
713
|
+
* list, so this call is not a revocation that takes effect at the instant it
|
|
714
|
+
* returns — a screen that says "no longer public" the moment this resolves is
|
|
715
|
+
* telling a small lie.
|
|
716
|
+
*/
|
|
717
|
+
removeStoragePublic(org, name, prefix) {
|
|
718
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/storage/public`, { prefix });
|
|
719
|
+
}
|
|
720
|
+
// ---- Email (docs/email.md §5) ----
|
|
721
|
+
/** Grant, address, sender, limits, recent counts. The address comes back as a preview even without a grant. */
|
|
722
|
+
getEmail(org, name) {
|
|
723
|
+
return this.json("GET", `${this.projectPath(org, name)}/email`);
|
|
724
|
+
}
|
|
725
|
+
/** Turns it on. **Idempotent** — we choose the address. The deploy reads `"email": true` and calls this. */
|
|
726
|
+
grantEmail(org, name) {
|
|
727
|
+
return this.json("POST", `${this.projectPath(org, name)}/email`);
|
|
728
|
+
}
|
|
729
|
+
/** Turns it off. Mail arriving at that address now gets a 550. */
|
|
730
|
+
revokeEmail(org, name) {
|
|
731
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/email`);
|
|
732
|
+
}
|
|
733
|
+
// ---- Custom sending domains (docs/email.md §2.4) ----
|
|
734
|
+
/** The project's own sending domains, each with the records to publish. */
|
|
735
|
+
listEmailDomains(org, name) {
|
|
736
|
+
return this.json("GET", `${this.projectPath(org, name)}/email/domains`);
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Creates the provider identity and answers with the records to publish.
|
|
740
|
+
* `publish` writes them into the zone when we host one covering the domain.
|
|
741
|
+
*/
|
|
742
|
+
addEmailDomain(org, name, domain, publish = false) {
|
|
743
|
+
return this.json("POST", `${this.projectPath(org, name)}/email/domains`, { domain, publish });
|
|
744
|
+
}
|
|
745
|
+
/** Re-checks now. The background loop does the same once a minute while pending. */
|
|
746
|
+
verifyEmailDomain(org, name, domain) {
|
|
747
|
+
return this.json("POST", `${this.projectPath(org, name)}/email/domains/${encodeURIComponent(domain)}/verify`);
|
|
748
|
+
}
|
|
749
|
+
/** Deletes the identity and the row. Sending from it is refused from the next convergence. */
|
|
750
|
+
removeEmailDomain(org, name, domain) {
|
|
751
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/email/domains/${encodeURIComponent(domain)}`);
|
|
752
|
+
}
|
|
753
|
+
// ---- AI (docs/ai.md §6) ----
|
|
754
|
+
/**
|
|
755
|
+
* The model catalogue. **Being logged in is enough to see it** — what you can
|
|
756
|
+
* buy is not an organization's secret, and this list is the price table.
|
|
757
|
+
*
|
|
758
|
+
* Prices are integer **micro-cents** per million tokens (1 µ¢ = 1e-8 USD).
|
|
759
|
+
* Not letting the server pick the decimal place is the point — a small call
|
|
760
|
+
* rounded to cents becomes 0.
|
|
761
|
+
*/
|
|
762
|
+
listAIModels() {
|
|
763
|
+
return this.json("GET", "/v1/ai/models");
|
|
764
|
+
}
|
|
765
|
+
/** Grant, limits, the org balance, 24 h usage. The limits come back as a preview even without a grant. */
|
|
766
|
+
getAI(org, name) {
|
|
767
|
+
return this.json("GET", `${this.projectPath(org, name)}/ai`);
|
|
768
|
+
}
|
|
769
|
+
/** Turns it on. **Idempotent.** The deploy reads `"ai": true` and calls this. */
|
|
770
|
+
grantAI(org, name) {
|
|
771
|
+
return this.json("POST", `${this.projectPath(org, name)}/ai`);
|
|
772
|
+
}
|
|
773
|
+
/** Turns it off. **The ledger and the balance are untouched** — the balance belongs to the org and the grant belongs to the project. */
|
|
774
|
+
revokeAI(org, name) {
|
|
775
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/ai`);
|
|
776
|
+
}
|
|
777
|
+
/** The org's credit balance and its automatic top-up settings. The balance is in micro-cents and can be negative. */
|
|
778
|
+
getAICredit(org) {
|
|
779
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/ai/credit`);
|
|
780
|
+
}
|
|
781
|
+
/** One page of the org ledger. The cursor is `ledger_id` — cutting on time splits the same millisecond. */
|
|
782
|
+
listAILedger(org, opts = {}) {
|
|
783
|
+
const q = new URLSearchParams();
|
|
784
|
+
if (opts.limit)
|
|
785
|
+
q.set("limit", String(opts.limit));
|
|
786
|
+
if (opts.before)
|
|
787
|
+
q.set("before", String(opts.before));
|
|
788
|
+
const qs = q.toString();
|
|
789
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/ai/ledger${qs ? "?" + qs : ""}`);
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* The credit top-up checkout. **A browser coming back is not evidence** — the
|
|
793
|
+
* one thing that raises the balance is the `order.paid` webhook, and the
|
|
794
|
+
* screen polls the balance after the success event.
|
|
795
|
+
*/
|
|
796
|
+
createAICreditCheckout(org, microCents, returnTo) {
|
|
797
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/ai/credit/checkout`, { microCents, returnTo });
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Turns automatic top-up on or off. **Turning it on is explicit consent**
|
|
801
|
+
* (docs/ai.md §3.5) — the screen shows the charging terms verbatim and calls
|
|
802
|
+
* this only after the box is checked.
|
|
803
|
+
*/
|
|
804
|
+
setAIAutoTopup(org, body) {
|
|
805
|
+
return this.json("PUT", `/v1/orgs/${encodeURIComponent(org)}/ai/autotopup`, body);
|
|
806
|
+
}
|
|
807
|
+
/** One page of the mail log (docs/email.md §6.1). Newest first, cursor-paged. */
|
|
808
|
+
listMailLog(org, name, opts = {}) {
|
|
809
|
+
const q = new URLSearchParams();
|
|
810
|
+
if (opts.direction)
|
|
811
|
+
q.set("direction", opts.direction);
|
|
812
|
+
if (opts.cursor)
|
|
813
|
+
q.set("cursor", opts.cursor);
|
|
814
|
+
if (opts.limit)
|
|
815
|
+
q.set("limit", String(opts.limit));
|
|
816
|
+
const qs = q.toString();
|
|
817
|
+
return this.json("GET", `${this.projectPath(org, name)}/email/log${qs ? "?" + qs : ""}`);
|
|
818
|
+
}
|
|
819
|
+
/** The metadata of one message. */
|
|
820
|
+
getMailLog(org, name, mailId) {
|
|
821
|
+
return this.json("GET", `${this.projectPath(org, name)}/email/log/${encodeURIComponent(mailId)}`);
|
|
822
|
+
}
|
|
823
|
+
/** The URL of the raw message — the screen uses it as a download link (.eml). */
|
|
824
|
+
mailLogRawURL(org, name, mailId) {
|
|
825
|
+
return new URL(`${this.projectPath(org, name)}/email/log/${encodeURIComponent(mailId)}/raw`, this.opts.baseUrl).toString();
|
|
826
|
+
}
|
|
827
|
+
/** The raw text. What the detail view draws the headers and body from. */
|
|
828
|
+
getMailLogRaw(org, name, mailId) {
|
|
829
|
+
return this.text("GET", `${this.projectPath(org, name)}/email/log/${encodeURIComponent(mailId)}/raw`);
|
|
830
|
+
}
|
|
831
|
+
// ---- End-user authentication (docs/auth.md §9) ----
|
|
832
|
+
/**
|
|
833
|
+
* Grant, settings, providers, hosts. **The signed-up users do not come** —
|
|
834
|
+
* that table is inside the project DB (docs/auth.md §6) and only the worker's
|
|
835
|
+
* `env.auth` sees it.
|
|
280
836
|
*
|
|
281
|
-
* `providers`
|
|
282
|
-
*
|
|
837
|
+
* `providers` carries the client id only. The client secret is sealed and
|
|
838
|
+
* appears in no response.
|
|
283
839
|
*/
|
|
284
840
|
getAuth(org, name) {
|
|
285
841
|
return this.json("GET", `${this.projectPath(org, name)}/auth`);
|
|
286
842
|
}
|
|
287
843
|
/**
|
|
288
|
-
*
|
|
844
|
+
* Turns auth on (member). Idempotent.
|
|
289
845
|
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
846
|
+
* **With no database it is 409 `database_required`** — the user table lives
|
|
847
|
+
* inside the project DB, so standing up the grant alone leaves no table the
|
|
848
|
+
* moment the worker starts. The caller catches that code and points at the
|
|
849
|
+
* `"database": true` declaration — the deploy never sees this code, because
|
|
850
|
+
* its ordering rules it out.
|
|
293
851
|
*/
|
|
294
852
|
grantAuth(org, name) {
|
|
295
853
|
return this.json("POST", `${this.projectPath(org, name)}/auth`);
|
|
296
854
|
}
|
|
297
855
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
856
|
+
* Changes the settings (member). **A partial update** — only the fields given
|
|
857
|
+
* change. Sending the whole thing on one switch means that when two people
|
|
858
|
+
* touch the same card, the later save overwrites the earlier one. With no
|
|
859
|
+
* grant it is 404 `not_granted`.
|
|
301
860
|
*/
|
|
302
861
|
updateAuthSettings(org, name, settings) {
|
|
303
862
|
return this.json("PATCH", `${this.projectPath(org, name)}/auth`, { settings });
|
|
304
863
|
}
|
|
305
864
|
/**
|
|
306
|
-
*
|
|
307
|
-
*
|
|
865
|
+
* Turns auth off (admin). **The signed-up users are not deleted** — the
|
|
866
|
+
* `runlot_auth` tables stay in the project DB, and turning it back on lets the
|
|
867
|
+
* same people log in unchanged.
|
|
308
868
|
*/
|
|
309
869
|
revokeAuth(org, name) {
|
|
310
870
|
return this.json("DELETE", `${this.projectPath(org, name)}/auth`);
|
|
311
871
|
}
|
|
312
872
|
/**
|
|
313
|
-
*
|
|
873
|
+
* Registers or replaces a social provider (admin). It is the same PUT, so it
|
|
874
|
+
* is idempotent.
|
|
314
875
|
*
|
|
315
|
-
* **`clientSecret`
|
|
316
|
-
* `https://<host>/__runlot/auth/callback/<provider>`
|
|
317
|
-
*
|
|
876
|
+
* **`clientSecret` cannot be read back.** The callback URL is
|
|
877
|
+
* `https://<host>/__runlot/auth/callback/<provider>` for each host, and the
|
|
878
|
+
* list of hosts is in the response's `hosts`.
|
|
318
879
|
*/
|
|
319
880
|
setAuthProvider(org, name, provider, clientId, clientSecret) {
|
|
320
881
|
return this.json("PUT", `${this.projectPath(org, name)}/auth/providers/${encodeURIComponent(provider)}`, { clientId, clientSecret });
|
|
321
882
|
}
|
|
322
883
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
884
|
+
* Removes a provider (admin). Someone who signed up only through that provider
|
|
885
|
+
* loses their way in, but the user row stays — register it again and they come
|
|
886
|
+
* back to the same account.
|
|
325
887
|
*/
|
|
326
888
|
deleteAuthProvider(org, name, provider) {
|
|
327
889
|
return this.json("DELETE", `${this.projectPath(org, name)}/auth/providers/${encodeURIComponent(provider)}`);
|
|
328
890
|
}
|
|
329
|
-
// ----
|
|
891
|
+
// ---- Deployment access control (docs/access.md §7) ----
|
|
330
892
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
893
|
+
* Who can reach this deployment. **No values** — both the password and the
|
|
894
|
+
* bypass secret live only as hashes, and what comes back here is the fact that
|
|
895
|
+
* there is one: `hasPassword` and `hasBypass`.
|
|
333
896
|
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
897
|
+
* A project that has never set a policy is `mode: "public"` with no
|
|
898
|
+
* `updatedAt`. The screen tells those two apart for the reason in §7 — a
|
|
899
|
+
* sentence about the state instead of an empty state.
|
|
336
900
|
*/
|
|
337
901
|
getAccess(org, name) {
|
|
338
902
|
return this.json("GET", `${this.projectPath(org, name)}/access`);
|
|
339
903
|
}
|
|
340
904
|
/**
|
|
341
|
-
*
|
|
342
|
-
*
|
|
905
|
+
* Changes the policy (admin). Without a `password`, **the existing password
|
|
906
|
+
* stays** — if a save that only changes the mode wiped the password, coming
|
|
907
|
+
* back to that mode would mean setting it again.
|
|
343
908
|
*/
|
|
344
909
|
setAccess(org, name, mode, password) {
|
|
345
910
|
return this.json("PUT", `${this.projectPath(org, name)}/access`, { mode, password });
|
|
346
911
|
}
|
|
347
912
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
913
|
+
* Makes a bypass secret for automation (admin). **The value is in this answer
|
|
914
|
+
* and nowhere else** — the screen shows it once on arrival and can never fetch
|
|
915
|
+
* it again. Calling again kills the old value.
|
|
350
916
|
*/
|
|
351
917
|
newAccessBypass(org, name) {
|
|
352
918
|
return this.json("POST", `${this.projectPath(org, name)}/access/bypass`);
|
|
353
919
|
}
|
|
354
|
-
/**
|
|
920
|
+
/** Removes the bypass (admin). Removing one that does not exist also succeeds. */
|
|
355
921
|
revokeAccessBypass(org, name) {
|
|
356
922
|
return this.json("DELETE", `${this.projectPath(org, name)}/access/bypass`);
|
|
357
923
|
}
|
|
358
924
|
/**
|
|
359
|
-
*
|
|
925
|
+
* Gets a one-time address back into a protected deployment (docs/access.md §3.4-3).
|
|
360
926
|
*
|
|
361
|
-
*
|
|
362
|
-
* (
|
|
363
|
-
*
|
|
927
|
+
* It is **not** under the project path: all the calling screen knows is the
|
|
928
|
+
* hostname (the original request went there), and the server derives the org
|
|
929
|
+
* and project names from it. Doing `location.replace` with the `redirect` that
|
|
930
|
+
* comes back is the caller's job.
|
|
364
931
|
*/
|
|
365
932
|
authorizeAccess(to, next) {
|
|
366
933
|
return this.json("POST", "/v1/access/authorize", { to, next });
|
|
@@ -368,44 +935,79 @@ export class Client {
|
|
|
368
935
|
listMembers(org) {
|
|
369
936
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/members`);
|
|
370
937
|
}
|
|
371
|
-
/**
|
|
938
|
+
/** This is not an invite — the user must already have logged in once (404 `user_not_found`). */
|
|
372
939
|
addMember(org, provider, subject, role) {
|
|
373
940
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/members`, { provider, subject, role });
|
|
374
941
|
}
|
|
375
942
|
setMemberRole(org, userId, role) {
|
|
376
943
|
return this.json("PUT", `/v1/orgs/${encodeURIComponent(org)}/members/${encodeURIComponent(userId)}`, { role });
|
|
377
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Removing someone else is admin; **removing yourself is leaving**, which
|
|
947
|
+
* anyone can do (docs/members.md). The last admin can do neither
|
|
948
|
+
* (409 `last_admin`).
|
|
949
|
+
*/
|
|
378
950
|
removeMember(org, userId) {
|
|
379
951
|
return this.json("DELETE", `/v1/orgs/${encodeURIComponent(org)}/members/${encodeURIComponent(userId)}`);
|
|
380
952
|
}
|
|
953
|
+
// --- Invites (docs/members.md) ---
|
|
954
|
+
/** Pending and expired invites (admin). Accepted and revoked ones are history, so they do not come. */
|
|
955
|
+
listInvites(org) {
|
|
956
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/invites`);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Invites by email (admin). **Calling again with the same address is a
|
|
960
|
+
* resend** — the same row is updated rather than a new one created, and the
|
|
961
|
+
* server gives 200 instead of 201.
|
|
962
|
+
*/
|
|
963
|
+
createInvite(org, email, role) {
|
|
964
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/invites`, { email, role });
|
|
965
|
+
}
|
|
966
|
+
/** Revokes an invite (admin). Mail that has not gone out yet does not go out. */
|
|
967
|
+
revokeInvite(org, inviteId) {
|
|
968
|
+
return this.json("DELETE", `/v1/orgs/${encodeURIComponent(org)}/invites/${encodeURIComponent(inviteId)}`);
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* A preview of the invite. **No session needed** — whoever got the link has
|
|
972
|
+
* not logged in yet, and they need to know what they are accepting before
|
|
973
|
+
* they do.
|
|
974
|
+
*/
|
|
975
|
+
getInvite(token) {
|
|
976
|
+
return this.json("GET", `/v1/invites/${encodeURIComponent(token)}`);
|
|
977
|
+
}
|
|
978
|
+
/** Accepts (login required). If they are already a member the role does not change. */
|
|
979
|
+
acceptInvite(token) {
|
|
980
|
+
return this.json("POST", `/v1/invites/${encodeURIComponent(token)}/accept`);
|
|
981
|
+
}
|
|
381
982
|
// --- domains: D1 hostnames methods ---
|
|
382
|
-
/**
|
|
983
|
+
/** The default hostname and the custom domains come together (viewer). */
|
|
383
984
|
listHostnames(org, name) {
|
|
384
985
|
return this.json("GET", `${this.projectPath(org, name)}/hostnames`);
|
|
385
986
|
}
|
|
386
987
|
/**
|
|
387
|
-
*
|
|
988
|
+
* Attaches a custom domain (member).
|
|
388
989
|
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
990
|
+
* Idempotent — sending the same name again returns the existing row
|
|
991
|
+
* unchanged. The response's `verify` is the CNAME and TXT the customer has to
|
|
992
|
+
* add.
|
|
391
993
|
*/
|
|
392
994
|
addHostname(org, name, hostname) {
|
|
393
995
|
return this.json("POST", `${this.projectPath(org, name)}/hostnames`, { hostname });
|
|
394
996
|
}
|
|
395
|
-
/**
|
|
997
|
+
/** Runs the same check the background verifier makes, right now (member). */
|
|
396
998
|
verifyHostname(org, name, host) {
|
|
397
999
|
return this.json("POST", `${this.projectPath(org, name)}/hostnames/${encodeURIComponent(host)}/verify`);
|
|
398
1000
|
}
|
|
399
|
-
/**
|
|
1001
|
+
/** Detaches a custom domain (member). The default hostname gives a 400. */
|
|
400
1002
|
deleteHostname(org, name, host) {
|
|
401
1003
|
return this.json("DELETE", `${this.projectPath(org, name)}/hostnames/${encodeURIComponent(host)}`);
|
|
402
1004
|
}
|
|
403
1005
|
// --- domains: D2 dns methods ---
|
|
404
|
-
/**
|
|
1006
|
+
/** The organization's zones. No `rrsets` — those ride only on a single-zone lookup. */
|
|
405
1007
|
listZones(org) {
|
|
406
1008
|
return this.json("GET", this.dnsPath(org));
|
|
407
1009
|
}
|
|
408
|
-
/**
|
|
1010
|
+
/** Idempotent. A zone that already exists comes back unchanged. */
|
|
409
1011
|
createZone(org, name) {
|
|
410
1012
|
return this.json("POST", this.dnsPath(org), { name });
|
|
411
1013
|
}
|
|
@@ -416,8 +1018,9 @@ export class Client {
|
|
|
416
1018
|
return this.json("DELETE", `${this.dnsPath(org)}/${encodeURIComponent(zone)}`);
|
|
417
1019
|
}
|
|
418
1020
|
/**
|
|
419
|
-
*
|
|
420
|
-
*
|
|
1021
|
+
* Replaces one rrset **whole**. `records` is the complete new set for that
|
|
1022
|
+
* (name, type), so adding a single value means sending the current ones with
|
|
1023
|
+
* it.
|
|
421
1024
|
*/
|
|
422
1025
|
putRRset(org, zone, name, type, ttl, records) {
|
|
423
1026
|
return this.json("PUT", this.rrsetPath(org, zone, name, type), { ttl, records });
|
|
@@ -433,39 +1036,40 @@ export class Client {
|
|
|
433
1036
|
setZoneDS(org, zone, ds) {
|
|
434
1037
|
return this.json("PUT", `${this.dnsPath(org)}/${encodeURIComponent(zone)}/dnssec/ds`, { ds });
|
|
435
1038
|
}
|
|
436
|
-
/**
|
|
1039
|
+
/** The shared prefix of the DNS surface. */
|
|
437
1040
|
dnsPath(org) {
|
|
438
1041
|
return `/v1/orgs/${encodeURIComponent(org)}/dns/zones`;
|
|
439
1042
|
}
|
|
440
|
-
/** `@`
|
|
1043
|
+
/** Both `@` and `*` arrive as a name. Keeps the same string out of four places. */
|
|
441
1044
|
rrsetPath(org, zone, name, type) {
|
|
442
1045
|
return (`${this.dnsPath(org)}/${encodeURIComponent(zone)}` +
|
|
443
1046
|
`/rrsets/${encodeURIComponent(name)}/${encodeURIComponent(type)}`);
|
|
444
1047
|
}
|
|
445
1048
|
// --- domains: D3 domains methods ---
|
|
446
1049
|
/**
|
|
447
|
-
*
|
|
1050
|
+
* Looks a name up (member or above).
|
|
448
1051
|
*
|
|
449
|
-
* `priceCents`
|
|
450
|
-
*
|
|
451
|
-
*
|
|
1052
|
+
* `priceCents` is the first year of registration; `renewalCents` is one year
|
|
1053
|
+
* of renewal. They are separate because a first-year discount is common —
|
|
1054
|
+
* folded into one, the screen cannot say "buy it for $1, then $15 next year".
|
|
452
1055
|
*/
|
|
453
1056
|
checkDomains(org, names) {
|
|
454
1057
|
return this.json("POST", `${this.domainsPath(org)}/check`, { names });
|
|
455
1058
|
}
|
|
456
1059
|
/**
|
|
457
|
-
*
|
|
1060
|
+
* Buys a domain (admin — this spends money).
|
|
458
1061
|
*
|
|
459
|
-
* **ICANN
|
|
460
|
-
*
|
|
1062
|
+
* **The ICANN verification mail goes to `contact.email`.** The screen has to
|
|
1063
|
+
* say so before the purchase (docs/domains.md §5.5).
|
|
461
1064
|
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
1065
|
+
* Sending the same request again is safe — a finished domain comes back
|
|
1066
|
+
* unchanged, and a purchase that stopped part way resumes from where it
|
|
1067
|
+
* stopped.
|
|
464
1068
|
*/
|
|
465
1069
|
purchaseDomain(org, body) {
|
|
466
1070
|
return this.json("POST", this.domainsPath(org), body);
|
|
467
1071
|
}
|
|
468
|
-
/**
|
|
1072
|
+
/** Imports a domain you already own (admin). Creates the zone only; the registrar is not called. */
|
|
469
1073
|
importDomain(org, name) {
|
|
470
1074
|
return this.json("POST", `${this.domainsPath(org)}/import`, { name });
|
|
471
1075
|
}
|
|
@@ -479,11 +1083,11 @@ export class Client {
|
|
|
479
1083
|
return this.json("POST", `${this.domainPath(org, name)}/renew`, { years });
|
|
480
1084
|
}
|
|
481
1085
|
/**
|
|
482
|
-
*
|
|
1086
|
+
* Changes only the **intent** to auto-renew.
|
|
483
1087
|
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
1088
|
+
* Auto-renew at the registrar stays on — a domain is an asset you lose if you
|
|
1089
|
+
* are a day late, so we renew first and bill afterwards. The screen has to say
|
|
1090
|
+
* this alongside.
|
|
487
1091
|
*/
|
|
488
1092
|
setDomainAutoRenew(org, name, enabled) {
|
|
489
1093
|
return this.json("POST", `${this.domainPath(org, name)}/auto-renew`, { enabled });
|
|
@@ -491,29 +1095,131 @@ export class Client {
|
|
|
491
1095
|
setDomainLock(org, name, locked) {
|
|
492
1096
|
return this.json("POST", `${this.domainPath(org, name)}/lock`, { locked });
|
|
493
1097
|
}
|
|
494
|
-
/**
|
|
1098
|
+
/** The transfer auth code. The audit records that one was issued and **not the code itself**. */
|
|
495
1099
|
domainAuthCode(org, name) {
|
|
496
1100
|
return this.json("POST", `${this.domainPath(org, name)}/auth-code`);
|
|
497
1101
|
}
|
|
498
|
-
/**
|
|
1102
|
+
/** Re-reads from the registrar right now (member). */
|
|
499
1103
|
syncDomain(org, name) {
|
|
500
1104
|
return this.json("POST", `${this.domainPath(org, name)}/sync`);
|
|
501
1105
|
}
|
|
502
|
-
/**
|
|
1106
|
+
/** The shared prefix of the domain surface. Keeps the same string out of ten places. */
|
|
503
1107
|
domainsPath(org) {
|
|
504
1108
|
return `/v1/orgs/${encodeURIComponent(org)}/domains`;
|
|
505
1109
|
}
|
|
506
1110
|
domainPath(org, name) {
|
|
507
1111
|
return `${this.domainsPath(org)}/${encodeURIComponent(name)}`;
|
|
508
1112
|
}
|
|
509
|
-
/**
|
|
1113
|
+
/** The shared prefix of the project surface. */
|
|
510
1114
|
projectPath(org, name) {
|
|
511
1115
|
return `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}`;
|
|
512
1116
|
}
|
|
513
|
-
/**
|
|
1117
|
+
/** The shared prefix of the database surface. Keeps the same string out of five places. */
|
|
514
1118
|
dbPath(org, name) {
|
|
515
1119
|
return `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`;
|
|
516
1120
|
}
|
|
1121
|
+
// ---- Self-hosted Git (docs/git-hosting.md §12.1, §19) ----
|
|
1122
|
+
//
|
|
1123
|
+
// **git does the repository work and we handle only the metadata.** That is
|
|
1124
|
+
// why there is nothing like `pushRepo` here — an API that wraps git either
|
|
1125
|
+
// reimplements every one of git's flags or boxes the user in.
|
|
1126
|
+
//
|
|
1127
|
+
// A repository **belongs to a project**. That is why every method starts with
|
|
1128
|
+
// (org, project) — the same shape as the database and the secrets.
|
|
1129
|
+
listRepos(org, project) {
|
|
1130
|
+
return this.json("GET", this.repoPath(org, project));
|
|
1131
|
+
}
|
|
1132
|
+
createRepo(org, project, body) {
|
|
1133
|
+
return this.json("POST", this.repoPath(org, project), body);
|
|
1134
|
+
}
|
|
1135
|
+
getRepo(org, project, name) {
|
|
1136
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}`);
|
|
1137
|
+
}
|
|
1138
|
+
updateRepo(org, project, name, body) {
|
|
1139
|
+
return this.json("PATCH", `${this.repoPath(org, project)}/${encodeURIComponent(name)}`, body);
|
|
1140
|
+
}
|
|
1141
|
+
deleteRepo(org, project, name) {
|
|
1142
|
+
return this.json("DELETE", `${this.repoPath(org, project)}/${encodeURIComponent(name)}`);
|
|
1143
|
+
}
|
|
1144
|
+
/** The ref history. The lead for recovering a commit lost to a force-push is here. */
|
|
1145
|
+
listRefUpdates(org, project, name) {
|
|
1146
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/ref-updates`);
|
|
1147
|
+
}
|
|
1148
|
+
// Push-to-deploy (docs/code/push-to-deploy). The hook hangs off the
|
|
1149
|
+
// repository and the builds off the **project**, because a build outlives the
|
|
1150
|
+
// repository it came from.
|
|
1151
|
+
getDeployHook(org, project, name) {
|
|
1152
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy-hook`);
|
|
1153
|
+
}
|
|
1154
|
+
setDeployHook(org, project, name, body) {
|
|
1155
|
+
return this.json("PUT", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy-hook`, body);
|
|
1156
|
+
}
|
|
1157
|
+
deleteDeployHook(org, project, name) {
|
|
1158
|
+
return this.json("DELETE", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy-hook`);
|
|
1159
|
+
}
|
|
1160
|
+
/** Build a commit without pushing. Omit `commitSha` for the hooked branch's tip. */
|
|
1161
|
+
deployRepoNow(org, project, name, commitSha) {
|
|
1162
|
+
return this.json("POST", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy`, commitSha === undefined ? {} : { commitSha });
|
|
1163
|
+
}
|
|
1164
|
+
listBuilds(org, project, limit) {
|
|
1165
|
+
const q = limit === undefined ? "" : `?limit=${limit}`;
|
|
1166
|
+
return this.json("GET", `${this.projectPath(org, project)}/builds${q}`);
|
|
1167
|
+
}
|
|
1168
|
+
getBuild(org, project, buildId) {
|
|
1169
|
+
return this.json("GET", `${this.projectPath(org, project)}/builds/${encodeURIComponent(buildId)}`);
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* A build's output. It comes back as **text**, not JSON — see the endpoint's
|
|
1173
|
+
* description. `json()` would try to parse it and fail on the first line.
|
|
1174
|
+
*/
|
|
1175
|
+
getBuildLog(org, project, buildId) {
|
|
1176
|
+
return this.text("GET", `${this.projectPath(org, project)}/builds/${encodeURIComponent(buildId)}/log`);
|
|
1177
|
+
}
|
|
1178
|
+
cancelBuild(org, project, buildId) {
|
|
1179
|
+
return this.json("POST", `${this.projectPath(org, project)}/builds/${encodeURIComponent(buildId)}/cancel`);
|
|
1180
|
+
}
|
|
1181
|
+
listSSHKeys() {
|
|
1182
|
+
return this.json("GET", "/v1/me/ssh-keys");
|
|
1183
|
+
}
|
|
1184
|
+
addSSHKey(publicKey, name) {
|
|
1185
|
+
return this.json("POST", "/v1/me/ssh-keys", { publicKey, name });
|
|
1186
|
+
}
|
|
1187
|
+
deleteSSHKey(keyId) {
|
|
1188
|
+
return this.json("DELETE", `/v1/me/ssh-keys/${encodeURIComponent(keyId)}`);
|
|
1189
|
+
}
|
|
1190
|
+
listAccessTokens() {
|
|
1191
|
+
return this.json("GET", "/v1/me/tokens");
|
|
1192
|
+
}
|
|
1193
|
+
/** The plaintext is carried in this response **once** and never again. */
|
|
1194
|
+
createAccessToken(body) {
|
|
1195
|
+
return this.json("POST", "/v1/me/tokens", body);
|
|
1196
|
+
}
|
|
1197
|
+
revokeAccessToken(tokenId) {
|
|
1198
|
+
return this.json("DELETE", `/v1/me/tokens/${encodeURIComponent(tokenId)}`);
|
|
1199
|
+
}
|
|
1200
|
+
// ---- Browsing (docs/git-hosting.md §12.2) ----
|
|
1201
|
+
getRepoRefs(org, project, name) {
|
|
1202
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/refs`);
|
|
1203
|
+
}
|
|
1204
|
+
getRepoTree(org, project, name, ref = "", path = "") {
|
|
1205
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/tree${gitQuery(ref, path)}`);
|
|
1206
|
+
}
|
|
1207
|
+
getRepoBlob(org, project, name, ref = "", path = "") {
|
|
1208
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/blob${gitQuery(ref, path)}`);
|
|
1209
|
+
}
|
|
1210
|
+
getRepoCommits(org, project, name, ref = "", limit) {
|
|
1211
|
+
const q = new URLSearchParams();
|
|
1212
|
+
if (ref !== "")
|
|
1213
|
+
q.set("ref", ref);
|
|
1214
|
+
if (limit !== undefined)
|
|
1215
|
+
q.set("limit", String(limit));
|
|
1216
|
+
const qs = q.size > 0 ? `?${q.toString()}` : "";
|
|
1217
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/commits${qs}`);
|
|
1218
|
+
}
|
|
1219
|
+
/** The shared prefix of the repository surface. It sits under the project (§19). */
|
|
1220
|
+
repoPath(org, project) {
|
|
1221
|
+
return `${this.projectPath(org, project)}/repos`;
|
|
1222
|
+
}
|
|
517
1223
|
rollback(org, name, version) {
|
|
518
1224
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/rollback`, { version });
|
|
519
1225
|
}
|