@runlot/api 0.1.0-rc.17 → 0.1.0-rc.171
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 +1414 -118
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1716 -117
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +26909 -2978
- package/dist/schema.d.ts.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
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
|
+
/** base64url of the UTF-8 JSON, no padding — the `draft` parameter's encoding. */
|
|
4
|
+
export function base64urlJson(v) {
|
|
5
|
+
const bytes = new TextEncoder().encode(JSON.stringify(v));
|
|
6
|
+
let bin = "";
|
|
7
|
+
for (const b of bytes)
|
|
8
|
+
bin += String.fromCharCode(b);
|
|
9
|
+
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
10
|
+
}
|
|
11
|
+
function gitQuery(ref, path) {
|
|
12
|
+
const q = new URLSearchParams();
|
|
13
|
+
if (ref !== "")
|
|
14
|
+
q.set("ref", ref);
|
|
15
|
+
if (path !== "")
|
|
16
|
+
q.set("path", path);
|
|
17
|
+
return q.size > 0 ? `?${q.toString()}` : "";
|
|
18
|
+
}
|
|
19
|
+
function obsProfileQS(q = {}) {
|
|
20
|
+
const p = new URLSearchParams();
|
|
21
|
+
for (const [k, v] of Object.entries(q)) {
|
|
22
|
+
if (v !== undefined && v !== "")
|
|
23
|
+
p.set(k, String(v));
|
|
24
|
+
}
|
|
25
|
+
const s = p.toString();
|
|
26
|
+
return s ? `?${s}` : "";
|
|
27
|
+
}
|
|
28
|
+
export const API_SCOPES = [
|
|
29
|
+
"project:read",
|
|
30
|
+
"deploy",
|
|
31
|
+
"db:read",
|
|
32
|
+
"db:write",
|
|
33
|
+
"repo:read",
|
|
34
|
+
"repo:write",
|
|
35
|
+
"org:admin",
|
|
36
|
+
];
|
|
37
|
+
export const BUILTIN_AUTH_PROVIDERS = ["github", "google"];
|
|
38
|
+
export const RESERVED_AUTH_PROVIDER_IDS = ["github", "google", "runlot"];
|
|
39
|
+
/** The id pattern for an OIDC provider (`^[a-z][a-z0-9-]{1,30}$`). */
|
|
40
|
+
export const AUTH_PROVIDER_ID = /^[a-z][a-z0-9-]{1,30}$/;
|
|
41
|
+
export const AUTH_RUNLOT_METHODS = ["password", "google", "github", "passkey"];
|
|
42
|
+
/**
|
|
43
|
+
* A status the edge in front of cp-public can produce on its own: 502–504, and
|
|
44
|
+
* Cloudflare's 520–527 (524 is its 100 s origin timeout). With no JSON body these
|
|
45
|
+
* are the edge's words, not the server's, and are raised as `edge_<status>`.
|
|
46
|
+
*/
|
|
47
|
+
export function isEdgeStatus(status) {
|
|
48
|
+
return (status >= 502 && status <= 504) || (status >= 520 && status <= 527);
|
|
49
|
+
}
|
|
50
|
+
/** True for the `edge_<status>` ApiError `isEdgeStatus` produces. */
|
|
51
|
+
export function isEdgeError(err) {
|
|
52
|
+
return err instanceof ApiError && err.code.startsWith("edge_");
|
|
53
|
+
}
|
|
54
|
+
/** The exception that carries the server's error envelope unchanged. */
|
|
3
55
|
export class ApiError extends Error {
|
|
4
56
|
status;
|
|
5
57
|
code;
|
|
@@ -14,14 +66,25 @@ export class ApiError extends Error {
|
|
|
14
66
|
}
|
|
15
67
|
}
|
|
16
68
|
/**
|
|
17
|
-
* cp-public
|
|
69
|
+
* The cp-public client.
|
|
18
70
|
*
|
|
19
|
-
* CLI
|
|
20
|
-
*
|
|
71
|
+
* The CLI and the dashboard use the same one. If each called fetch itself, their
|
|
72
|
+
* error handling would drift a little, and that difference shows up during an
|
|
73
|
+
* incident.
|
|
21
74
|
*/
|
|
22
75
|
function dbPath(org, name) {
|
|
23
76
|
return `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`;
|
|
24
77
|
}
|
|
78
|
+
function previewQuery(opts) {
|
|
79
|
+
const q = new URLSearchParams({ preview: opts.preview });
|
|
80
|
+
// Empty values are not carried: the server reads "absent" as its default, and
|
|
81
|
+
// `?db=` would be neither absent nor a member of the enum.
|
|
82
|
+
if (opts.db)
|
|
83
|
+
q.set("db", opts.db);
|
|
84
|
+
if (opts.from)
|
|
85
|
+
q.set("from", opts.from);
|
|
86
|
+
return q.toString();
|
|
87
|
+
}
|
|
25
88
|
export class Client {
|
|
26
89
|
opts;
|
|
27
90
|
constructor(opts) {
|
|
@@ -45,8 +108,21 @@ export class Client {
|
|
|
45
108
|
body = (await res.json());
|
|
46
109
|
}
|
|
47
110
|
catch {
|
|
48
|
-
//
|
|
49
|
-
//
|
|
111
|
+
// An error response that is not JSON (a 502 made by a proxy, for instance)
|
|
112
|
+
// is raised as the same exception — so the caller does not have to handle
|
|
113
|
+
// two shapes of failure.
|
|
114
|
+
}
|
|
115
|
+
if (body === undefined && isEdgeStatus(res.status)) {
|
|
116
|
+
// The edge replaced the 5xx body with its own HTML. The code and reason
|
|
117
|
+
// the server wrote are not here — so say that, rather than "unknown". On
|
|
118
|
+
// 2026-09-10 a registrar rejection came out this way as
|
|
119
|
+
// "unknown: POST … → 502".
|
|
120
|
+
body = {
|
|
121
|
+
error: {
|
|
122
|
+
code: "edge_" + res.status,
|
|
123
|
+
message: "The server returned an error (" + res.status + "), and the error details could not be read. Try again shortly.",
|
|
124
|
+
},
|
|
125
|
+
};
|
|
50
126
|
}
|
|
51
127
|
throw new ApiError(res.status, body, `${method} ${path} → ${res.status}`);
|
|
52
128
|
}
|
|
@@ -54,6 +130,21 @@ export class Client {
|
|
|
54
130
|
return undefined;
|
|
55
131
|
return (await res.json());
|
|
56
132
|
}
|
|
133
|
+
/** A body that is not JSON (the raw mail). Error handling is the same as request. */
|
|
134
|
+
async text(method, path) {
|
|
135
|
+
const res = await fetch(new URL(path, this.opts.baseUrl), { method, headers: this.headers() });
|
|
136
|
+
if (!res.ok) {
|
|
137
|
+
let body;
|
|
138
|
+
try {
|
|
139
|
+
body = (await res.json());
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// The same reason as in request
|
|
143
|
+
}
|
|
144
|
+
throw new ApiError(res.status, body, `${method} ${path} → ${res.status}`);
|
|
145
|
+
}
|
|
146
|
+
return await res.text();
|
|
147
|
+
}
|
|
57
148
|
json(method, path, body) {
|
|
58
149
|
if (body === undefined)
|
|
59
150
|
return this.request(method, path);
|
|
@@ -65,38 +156,205 @@ export class Client {
|
|
|
65
156
|
devLogin(subject) {
|
|
66
157
|
return this.json("POST", "/v1/auth/dev/login", { subject });
|
|
67
158
|
}
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Takes the sign-up and sends the confirmation mail. Neither a session nor a
|
|
161
|
+
* password is created here — the password is chosen in `verifyEmail` by
|
|
162
|
+
* whoever opens the mailbox.
|
|
163
|
+
*/
|
|
164
|
+
passwordSignUp(email, name) {
|
|
165
|
+
return this.json("POST", "/v1/auth/password/sign-up", {
|
|
166
|
+
email,
|
|
167
|
+
...(name === undefined ? {} : { name }),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
passwordSignIn(email, password) {
|
|
171
|
+
return this.json("POST", "/v1/auth/password/sign-in", { email, password });
|
|
172
|
+
}
|
|
173
|
+
/** The same accepted response comes back whether or not the email exists. */
|
|
174
|
+
passwordForgot(email) {
|
|
175
|
+
return this.json("POST", "/v1/auth/password/forgot", { email });
|
|
176
|
+
}
|
|
177
|
+
passwordReset(token, password) {
|
|
178
|
+
return this.json("POST", "/v1/auth/password/reset", { token, password });
|
|
179
|
+
}
|
|
180
|
+
/** Uses the confirmation link and sets the account's first password. */
|
|
181
|
+
verifyEmail(token, password) {
|
|
182
|
+
return this.json("POST", "/v1/auth/email/verify", { token, password });
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Finishes a sign-in that came back `{mfa:"totp"}`.
|
|
186
|
+
*
|
|
187
|
+
* Callable without a token: `pending` is the credential, and it is not a
|
|
188
|
+
* session — no other endpoint accepts it.
|
|
189
|
+
*/
|
|
190
|
+
completeTotpLogin(pending, factor) {
|
|
191
|
+
return this.json("POST", "/v1/auth/totp", { pending, ...factor });
|
|
192
|
+
}
|
|
193
|
+
/** This account's two-factor state, including which orgs require it. */
|
|
194
|
+
getTotp() {
|
|
195
|
+
return this.json("GET", "/v1/me/totp");
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Draws a secret to scan. It does **not** turn the factor on — `confirmTotp`
|
|
199
|
+
* does, after the app has proved it can produce a code.
|
|
200
|
+
*/
|
|
201
|
+
enrollTotp() {
|
|
202
|
+
return this.json("POST", "/v1/me/totp/enroll");
|
|
203
|
+
}
|
|
204
|
+
/** Turns the factor on and hands back the ten recovery codes. They are shown once. */
|
|
205
|
+
confirmTotp(code) {
|
|
206
|
+
return this.json("POST", "/v1/me/totp/confirm", { code });
|
|
207
|
+
}
|
|
208
|
+
/** Turns it off. A code or a recovery code is required — the session alone is not. */
|
|
209
|
+
disableTotp(factor) {
|
|
210
|
+
return this.json("DELETE", "/v1/me/totp", factor);
|
|
71
211
|
}
|
|
72
212
|
/**
|
|
73
|
-
* GitHub OAuth
|
|
74
|
-
* `window.location`
|
|
213
|
+
* The GitHub OAuth start URL. It is a 302 the browser follows, so it goes into
|
|
214
|
+
* `window.location` rather than being called with fetch. `redirect` has to be
|
|
215
|
+
* on the server's allow-list.
|
|
75
216
|
*/
|
|
76
217
|
githubStartUrl(redirect) {
|
|
77
218
|
const u = new URL("/v1/auth/github/start", this.opts.baseUrl);
|
|
78
219
|
u.searchParams.set("redirect", redirect);
|
|
79
220
|
return u.toString();
|
|
80
221
|
}
|
|
222
|
+
/** The Google OAuth start URL. Uses the same dashboard callback shape as GitHub. */
|
|
223
|
+
googleStartUrl(redirect) {
|
|
224
|
+
const u = new URL("/v1/auth/google/start", this.opts.baseUrl);
|
|
225
|
+
u.searchParams.set("redirect", redirect);
|
|
226
|
+
return u.toString();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The generic OIDC start URL (docs/onprem-delivery.md §7.7). Same 302-and-fragment
|
|
230
|
+
* shape as the other two; which provider is behind it is the installation's choice.
|
|
231
|
+
*/
|
|
232
|
+
oidcStartUrl(redirect) {
|
|
233
|
+
const u = new URL("/v1/auth/oidc/start", this.opts.baseUrl);
|
|
234
|
+
u.searchParams.set("redirect", redirect);
|
|
235
|
+
return u.toString();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Does this deployment federate an identity provider?
|
|
239
|
+
*
|
|
240
|
+
* **There is no endpoint that answers "which logins are on"** — one existed and was
|
|
241
|
+
* deleted, because its only reader was the login screen and it put a round trip in
|
|
242
|
+
* front of every login button (cp/internal/public/public.go). This is not that
|
|
243
|
+
* endpoint coming back: cp-public **does not register** the two OIDC routes when no
|
|
244
|
+
* issuer is configured, so the mux's own 404 is the answer, and the probe is a HEAD
|
|
245
|
+
* that no handler runs.
|
|
246
|
+
*
|
|
247
|
+
* Any other status means the route is there — a 400 (this probe carries no
|
|
248
|
+
* `redirect`) or a 502 (the provider's discovery document could not be read) both say
|
|
249
|
+
* the handler exists, and a button that leads to a readable error beats no button.
|
|
250
|
+
* A network failure answers false: on SaaS, where the answer is false anyway, a dead
|
|
251
|
+
* API address must not draw a login that cannot work.
|
|
252
|
+
*/
|
|
253
|
+
async oidcAvailable() {
|
|
254
|
+
try {
|
|
255
|
+
const res = await fetch(new URL("/v1/auth/oidc/start", this.opts.baseUrl), { method: "HEAD" });
|
|
256
|
+
return res.status !== 404;
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* This installation's licence (docs/onprem-delivery.md §6.5). Readable by any
|
|
264
|
+
* signed-in user: the footer it feeds is on every page for everybody.
|
|
265
|
+
*
|
|
266
|
+
* On SaaS it answers `onPrem: false` rather than 404, so the caller has one shape to
|
|
267
|
+
* read and the surfaces draw nothing on the flag.
|
|
268
|
+
*/
|
|
269
|
+
license() {
|
|
270
|
+
return this.json("GET", "/v1/license");
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The names of this deployment (app domain, docs address). Callable without auth.
|
|
274
|
+
*
|
|
275
|
+
* This exists so the dashboard does not hard-code a domain into the screen
|
|
276
|
+
* (docs/environments.md §3.2) — hard-coded, the dev screen tells people a
|
|
277
|
+
* production address, and because that address opens, nobody ever says it is
|
|
278
|
+
* wrong.
|
|
279
|
+
*/
|
|
280
|
+
siteConfig() {
|
|
281
|
+
return this.json("GET", "/v1/config");
|
|
282
|
+
}
|
|
81
283
|
me() {
|
|
82
284
|
return this.json("GET", "/v1/me");
|
|
83
285
|
}
|
|
84
286
|
listOrgs() {
|
|
85
287
|
return this.json("GET", "/v1/orgs");
|
|
86
288
|
}
|
|
289
|
+
/** Changes the display name only (admin). The slug is the name that becomes an address, so it is not on this surface. */
|
|
290
|
+
/**
|
|
291
|
+
* `requireTotp` is left out when it is not given, on purpose: the server reads
|
|
292
|
+
* an absent field as "leave it alone". Sending `false` by default would mean a
|
|
293
|
+
* rename silently switched the org's second-factor requirement off.
|
|
294
|
+
*/
|
|
295
|
+
updateOrg(org, name, requireTotp) {
|
|
296
|
+
return this.json("PATCH", `/v1/orgs/${encodeURIComponent(org)}`, {
|
|
297
|
+
name,
|
|
298
|
+
...(requireTotp === undefined ? {} : { requireTotp }),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Deletes the organization (admin). **This cannot be undone.**
|
|
303
|
+
*
|
|
304
|
+
* `confirm` has to be the organization slug exactly — the confirmation lives on
|
|
305
|
+
* the server because three places call this surface (the screen, the CLI, and
|
|
306
|
+
* scripts). If a live project, domain, repository, or DNS zone is left, it is a
|
|
307
|
+
* 409 `org_not_empty` and `details.holdings` says what is left — **projects
|
|
308
|
+
* already deleted are not counted.**
|
|
309
|
+
*
|
|
310
|
+
* The `purgeAfter` in the answer is when the rows actually disappear. By the
|
|
311
|
+
* moment it returns the organization is already gone from every surface; what
|
|
312
|
+
* remains is retention until that time.
|
|
313
|
+
*/
|
|
314
|
+
deleteOrg(org, confirm) {
|
|
315
|
+
return this.json("DELETE", `/v1/orgs/${encodeURIComponent(org)}`, { confirm });
|
|
316
|
+
}
|
|
87
317
|
createOrg(slug, name) {
|
|
88
318
|
return this.json("POST", "/v1/orgs", { slug, name });
|
|
89
319
|
}
|
|
90
320
|
/**
|
|
91
|
-
*
|
|
321
|
+
* The organization's recent notifications (docs/limits.md §3.4).
|
|
92
322
|
*
|
|
93
|
-
* `sentAt`
|
|
94
|
-
*
|
|
323
|
+
* A row with no `sentAt` is either still queued or has no email address to
|
|
324
|
+
* reach — and for the second, this list is the only channel, so the screen
|
|
325
|
+
* draws both states the same way.
|
|
95
326
|
*/
|
|
96
327
|
listNotifications(org, limit) {
|
|
97
328
|
const q = limit === undefined ? "" : `?limit=${limit}`;
|
|
98
329
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/notifications${q}`);
|
|
99
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* The plan and billing state (docs/billing.md). If `enabled` is false, this
|
|
333
|
+
* deployment has no billing — the screen shows only a contact address.
|
|
334
|
+
*/
|
|
335
|
+
getBilling(org) {
|
|
336
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/billing`);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A Pro checkout session. Send the browser to the `url` that comes back. Even
|
|
340
|
+
* once payment finishes, the thing that changes the plan is the webhook, so
|
|
341
|
+
* read `getBilling` again after the browser returns.
|
|
342
|
+
*/
|
|
343
|
+
createBillingCheckout(org, returnTo) {
|
|
344
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/checkout`, { returnTo });
|
|
345
|
+
}
|
|
346
|
+
/** A one-time `url` for the customer portal (payment method, receipts, cancellation). */
|
|
347
|
+
createBillingPortal(org, returnTo) {
|
|
348
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/portal`, { returnTo });
|
|
349
|
+
}
|
|
350
|
+
/** The customer session token for the payment-method embed (1 hour). An org with no payment history gets a 404. */
|
|
351
|
+
createBillingSession(org) {
|
|
352
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/session`, {});
|
|
353
|
+
}
|
|
354
|
+
/** Schedules cancellation at the end of the period (`cancel: true`), or undoes it. There is no immediate revocation. */
|
|
355
|
+
cancelBilling(org, body) {
|
|
356
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/billing/cancel`, body);
|
|
357
|
+
}
|
|
100
358
|
listProjects(org) {
|
|
101
359
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects`);
|
|
102
360
|
}
|
|
@@ -106,17 +364,859 @@ export class Client {
|
|
|
106
364
|
getProject(org, name) {
|
|
107
365
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}`);
|
|
108
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Renames the project (admin). **The default address moves with it and there is
|
|
369
|
+
* no alias** — which is why the response carries the new address. Unlike the
|
|
370
|
+
* org slug, this name can change because it is the inner label of the org
|
|
371
|
+
* wildcard certificate.
|
|
372
|
+
*/
|
|
373
|
+
updateProject(org, name, next) {
|
|
374
|
+
return this.json("PATCH", this.projectPath(org, name), { name: next });
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Starts tearing the project down (admin). **This cannot be undone and leaves
|
|
378
|
+
* no recovery generation.** `confirm` has to be the project name exactly.
|
|
379
|
+
*/
|
|
380
|
+
deleteProject(org, name, confirm) {
|
|
381
|
+
return this.json("DELETE", this.projectPath(org, name), { confirm });
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Disables a project (admin): it stops serving and taking new backups, and
|
|
385
|
+
* keeps everything it has. A project disabled for a year is deleted for good.
|
|
386
|
+
*/
|
|
387
|
+
disableProject(org, name) {
|
|
388
|
+
return this.json("POST", `${this.projectPath(org, name)}/disable`);
|
|
389
|
+
}
|
|
390
|
+
/** Enables a disabled project (admin). 409 `project_limit` when there is no room for it. */
|
|
391
|
+
enableProject(org, name) {
|
|
392
|
+
return this.json("POST", `${this.projectPath(org, name)}/enable`);
|
|
393
|
+
}
|
|
394
|
+
/** Watches the teardown operation to its end even after the project is gone. */
|
|
395
|
+
getOrgOperation(org, opId) {
|
|
396
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/operations/${encodeURIComponent(opId)}`);
|
|
397
|
+
}
|
|
398
|
+
/** Everything the project's first screen takes in one call. Usage calls `getUsage` alongside it. */
|
|
399
|
+
getProjectOverview(org, name) {
|
|
400
|
+
return this.json("GET", `${this.projectPath(org, name)}/overview`);
|
|
401
|
+
}
|
|
109
402
|
listDeployments(org, name) {
|
|
110
403
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/deployments`);
|
|
111
404
|
}
|
|
112
|
-
/**
|
|
113
|
-
|
|
405
|
+
/**
|
|
406
|
+
* One deployment, with `migrations` when the control plane applied its
|
|
407
|
+
* `migrations/` — which today means a preview deployed with `db=branch`
|
|
408
|
+
* (docs/studio.md §6.6 step 2).
|
|
409
|
+
*
|
|
410
|
+
* A preview's deployment is read under **the parent project's name**, the name
|
|
411
|
+
* the caller deployed through: the preview is a project of its own, but the
|
|
412
|
+
* caller never learns its name.
|
|
413
|
+
*/
|
|
414
|
+
getDeployment(org, name, deploymentId) {
|
|
415
|
+
return this.json("GET", `${this.projectPath(org, name)}/deployments/${encodeURIComponent(deploymentId)}`);
|
|
416
|
+
}
|
|
417
|
+
/** Completed-front HTTP outcomes only; native crash-free health is unknown. */
|
|
418
|
+
getReleaseHealth(org, name) {
|
|
419
|
+
return this.json("GET", `${this.projectPath(org, name)}/error-releases`);
|
|
420
|
+
}
|
|
421
|
+
/** Historical first transition per issue; never substitutes a latest occurrence. */
|
|
422
|
+
listReleaseIssues(org, name, version, opts) {
|
|
423
|
+
const q = new URLSearchParams({ kind: opts.kind, windowStart: opts.windowStart, windowEnd: opts.windowEnd });
|
|
424
|
+
if (opts.cursor !== undefined)
|
|
425
|
+
q.set("cursor", opts.cursor);
|
|
426
|
+
return this.json("GET", `${this.projectPath(org, name)}/error-releases/${encodeURIComponent(String(version))}/issues?${q}`);
|
|
427
|
+
}
|
|
428
|
+
/** Runlot Errors: the issue stream (docs/customer-error-tracking.md). */
|
|
429
|
+
listErrorIssues(org, name, opts = {}) {
|
|
430
|
+
const q = new URLSearchParams();
|
|
431
|
+
if (opts.status)
|
|
432
|
+
q.set("status", opts.status);
|
|
433
|
+
if (opts.query)
|
|
434
|
+
q.set("query", opts.query);
|
|
435
|
+
if (opts.cursor)
|
|
436
|
+
q.set("cursor", opts.cursor);
|
|
437
|
+
if (opts.limit !== undefined)
|
|
438
|
+
q.set("limit", String(opts.limit));
|
|
439
|
+
const qs = q.size > 0 ? `?${q}` : "";
|
|
440
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors${qs}`);
|
|
441
|
+
}
|
|
442
|
+
getErrorIssue(org, name, issueId) {
|
|
443
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}`);
|
|
444
|
+
}
|
|
445
|
+
updateErrorIssue(org, name, issueId, update) {
|
|
446
|
+
return this.json("PATCH", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}`, update);
|
|
447
|
+
}
|
|
448
|
+
/** Source context, suspects and owners for the selected stored occurrence, or latest when omitted. */
|
|
449
|
+
async getErrorInsights(org, name, issueId, opts = {}) {
|
|
450
|
+
const eventId = opts.eventId;
|
|
451
|
+
const q = new URLSearchParams();
|
|
452
|
+
if (eventId !== undefined)
|
|
453
|
+
q.set("eventId", eventId);
|
|
454
|
+
const qs = q.size > 0 ? `?${q}` : "";
|
|
455
|
+
const out = await this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/insights${qs}`);
|
|
456
|
+
if (eventId !== undefined && (eventId === "" || out.eventId !== eventId)) {
|
|
457
|
+
throw new Error("Code insights did not identify the requested occurrence; this server may not support event selection.");
|
|
458
|
+
}
|
|
459
|
+
return out;
|
|
460
|
+
}
|
|
461
|
+
listErrorEvents(org, name, issueId, opts = {}) {
|
|
462
|
+
const q = new URLSearchParams();
|
|
463
|
+
if (opts.cursor)
|
|
464
|
+
q.set("cursor", opts.cursor);
|
|
465
|
+
if (opts.limit !== undefined)
|
|
466
|
+
q.set("limit", String(opts.limit));
|
|
467
|
+
const qs = q.size > 0 ? `?${q}` : "";
|
|
468
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/events${qs}`);
|
|
469
|
+
}
|
|
470
|
+
getErrorEvent(org, name, issueId, eventId) {
|
|
471
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/events/${encodeURIComponent(eventId)}`);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Other events of the project joined to this one by front's request ID or a
|
|
475
|
+
* browser-minted trace ID (§12). Correlation only: issues are never merged.
|
|
476
|
+
*/
|
|
477
|
+
getRelatedErrorEvents(org, name, issueId, eventId) {
|
|
478
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/events/${encodeURIComponent(eventId)}/related`);
|
|
479
|
+
}
|
|
480
|
+
/** An issue's hourly history from the ClickHouse store; `available: false` where there is none. */
|
|
481
|
+
getErrorHistory(org, name, issueId, days) {
|
|
482
|
+
const qs = days !== undefined ? `?days=${encodeURIComponent(String(days))}` : "";
|
|
483
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/history${qs}`);
|
|
484
|
+
}
|
|
485
|
+
/** Assign an issue to an org member, or clear it with null. */
|
|
486
|
+
assignErrorIssue(org, name, issueId, userId) {
|
|
487
|
+
return this.json("PUT", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/assignee`, { userId });
|
|
488
|
+
}
|
|
489
|
+
listErrorComments(org, name, issueId) {
|
|
490
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/comments`);
|
|
491
|
+
}
|
|
492
|
+
/** Plain text, at most 4000 characters; the author is the signed-in user. */
|
|
493
|
+
addErrorComment(org, name, issueId, body) {
|
|
494
|
+
return this.json("POST", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/comments`, { body });
|
|
495
|
+
}
|
|
496
|
+
/** Merge up to ten issues of the same origin into `targetIssueId`. */
|
|
497
|
+
mergeErrorIssues(org, name, targetIssueId, sourceIssueIds) {
|
|
498
|
+
return this.json("POST", `${this.projectPath(org, name)}/errors/${encodeURIComponent(targetIssueId)}/merge`, {
|
|
499
|
+
sourceIssueIds,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
/** Take a merged source back out of the issue it was merged into. */
|
|
503
|
+
unmergeErrorIssue(org, name, issueId) {
|
|
504
|
+
return this.json("POST", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/unmerge`);
|
|
505
|
+
}
|
|
506
|
+
/** Shared stack hints: frame overlap, never a merge or a causal claim. */
|
|
507
|
+
similarErrorIssues(org, name, issueId) {
|
|
508
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/similar`);
|
|
509
|
+
}
|
|
510
|
+
getErrorFingerprintRules(org, name) {
|
|
511
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors-fingerprint-rules`);
|
|
512
|
+
}
|
|
513
|
+
putErrorFingerprintRules(org, name, rules) {
|
|
514
|
+
return this.json("PUT", `${this.projectPath(org, name)}/errors-fingerprint-rules`, { rules });
|
|
515
|
+
}
|
|
516
|
+
getErrorAlerts(org, name) { return this.json("GET", `${this.projectPath(org, name)}/error-alerts`); }
|
|
517
|
+
putErrorAlertRule(org, name, id, rule) { return this.json("PUT", `${this.projectPath(org, name)}/error-alerts/rules/${encodeURIComponent(id)}`, rule); }
|
|
518
|
+
deleteErrorAlertRule(org, name, id) { return this.json("DELETE", `${this.projectPath(org, name)}/error-alerts/rules/${encodeURIComponent(id)}`); }
|
|
519
|
+
putErrorAlertDestination(org, name, id, input) { return this.json("PUT", `${this.projectPath(org, name)}/error-alerts/destinations/${encodeURIComponent(id)}`, input); }
|
|
520
|
+
deleteErrorAlertDestination(org, name, id) { return this.json("DELETE", `${this.projectPath(org, name)}/error-alerts/destinations/${encodeURIComponent(id)}`); }
|
|
521
|
+
getErrorAlertMail(org, name) { return this.json("GET", `${this.projectPath(org, name)}/error-alerts/mail`); }
|
|
522
|
+
putErrorAlertMail(org, name, preference) { return this.json("PUT", `${this.projectPath(org, name)}/error-alerts/mail`, preference); }
|
|
523
|
+
listErrorAlertDeliveries(org, name) { return this.json("GET", `${this.projectPath(org, name)}/error-alerts/deliveries`); }
|
|
524
|
+
// Monitors, downtimes and SLOs (docs/customer-observability.md §17.8, §17.9).
|
|
525
|
+
// Destinations are the error-alert destinations above, shared by both.
|
|
526
|
+
listMonitors(org, name) { return this.json("GET", `${this.projectPath(org, name)}/observability/monitors`); }
|
|
527
|
+
exportMonitors(org, name) { return this.json("GET", `${this.projectPath(org, name)}/observability/monitors/export`); }
|
|
528
|
+
getMonitor(org, name, id) { return this.json("GET", `${this.projectPath(org, name)}/observability/monitors/${encodeURIComponent(id)}`); }
|
|
529
|
+
putMonitor(org, name, id, monitor) { return this.json("PUT", `${this.projectPath(org, name)}/observability/monitors/${encodeURIComponent(id)}`, monitor); }
|
|
530
|
+
deleteMonitor(org, name, id) { return this.json("DELETE", `${this.projectPath(org, name)}/observability/monitors/${encodeURIComponent(id)}`); }
|
|
531
|
+
getMonitorHistory(org, name, id, limit) {
|
|
532
|
+
const q = limit ? `?limit=${encodeURIComponent(String(limit))}` : "";
|
|
533
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/monitors/${encodeURIComponent(id)}/history${q}`);
|
|
534
|
+
}
|
|
535
|
+
testMonitor(org, name, id) { return this.json("POST", `${this.projectPath(org, name)}/observability/monitors/${encodeURIComponent(id)}/test`); }
|
|
536
|
+
listDowntimes(org, name) { return this.json("GET", `${this.projectPath(org, name)}/observability/downtimes`); }
|
|
537
|
+
putDowntime(org, name, id, downtime) { return this.json("PUT", `${this.projectPath(org, name)}/observability/downtimes/${encodeURIComponent(id)}`, downtime); }
|
|
538
|
+
deleteDowntime(org, name, id) { return this.json("DELETE", `${this.projectPath(org, name)}/observability/downtimes/${encodeURIComponent(id)}`); }
|
|
539
|
+
listSLOs(org, name) { return this.json("GET", `${this.projectPath(org, name)}/observability/slos`); }
|
|
540
|
+
getSLO(org, name, id) { return this.json("GET", `${this.projectPath(org, name)}/observability/slos/${encodeURIComponent(id)}`); }
|
|
541
|
+
putSLO(org, name, id, slo) { return this.json("PUT", `${this.projectPath(org, name)}/observability/slos/${encodeURIComponent(id)}`, slo); }
|
|
542
|
+
deleteSLO(org, name, id) { return this.json("DELETE", `${this.projectPath(org, name)}/observability/slos/${encodeURIComponent(id)}`); }
|
|
543
|
+
/**
|
|
544
|
+
* Observability access and governance (customer-observability.md §12, §16, §17.15):
|
|
545
|
+
* the caller's grants, per-project role overrides, the audit trail, the data page,
|
|
546
|
+
* caps, export destinations and rehydration.
|
|
547
|
+
*/
|
|
548
|
+
getObservabilityPermissions(org, name) {
|
|
549
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/permissions`);
|
|
550
|
+
}
|
|
551
|
+
listObservabilityRoles(org, name) {
|
|
552
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/roles`);
|
|
553
|
+
}
|
|
554
|
+
putObservabilityRole(org, name, userId, grants) {
|
|
555
|
+
return this.json("PUT", `${this.projectPath(org, name)}/observability/roles/${encodeURIComponent(userId)}`, { grants });
|
|
556
|
+
}
|
|
557
|
+
deleteObservabilityRole(org, name, userId) {
|
|
558
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/observability/roles/${encodeURIComponent(userId)}`);
|
|
559
|
+
}
|
|
560
|
+
listObservabilityAudit(org, name, opts = {}) {
|
|
561
|
+
const q = new URLSearchParams();
|
|
562
|
+
if (opts.limit !== undefined)
|
|
563
|
+
q.set("limit", String(opts.limit));
|
|
564
|
+
if (opts.before !== undefined)
|
|
565
|
+
q.set("before", opts.before);
|
|
566
|
+
const qs = q.size > 0 ? `?${q.toString()}` : "";
|
|
567
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/audit${qs}`);
|
|
568
|
+
}
|
|
569
|
+
getObservabilityData(org, name) {
|
|
570
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/data`);
|
|
571
|
+
}
|
|
572
|
+
getObservabilityCaps(org, name) {
|
|
573
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/caps`);
|
|
574
|
+
}
|
|
575
|
+
/** Named meters only: a number, -1 (no cap, Pro) or null (the plan's included amount). */
|
|
576
|
+
putObservabilityCaps(org, name, caps) {
|
|
577
|
+
return this.json("PUT", `${this.projectPath(org, name)}/observability/caps`, caps);
|
|
578
|
+
}
|
|
579
|
+
listObservabilityExports(org, name) {
|
|
580
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/exports`);
|
|
581
|
+
}
|
|
582
|
+
getObservabilityExport(org, name, exportId) {
|
|
583
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/exports/${encodeURIComponent(exportId)}`);
|
|
584
|
+
}
|
|
585
|
+
createObservabilityExport(org, name, input) {
|
|
586
|
+
return this.json("POST", `${this.projectPath(org, name)}/observability/exports`, input);
|
|
587
|
+
}
|
|
588
|
+
updateObservabilityExport(org, name, exportId, input) {
|
|
589
|
+
return this.json("PATCH", `${this.projectPath(org, name)}/observability/exports/${encodeURIComponent(exportId)}`, input);
|
|
590
|
+
}
|
|
591
|
+
deleteObservabilityExport(org, name, exportId) {
|
|
592
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/observability/exports/${encodeURIComponent(exportId)}`);
|
|
593
|
+
}
|
|
594
|
+
listObservabilityRehydrations(org, name) {
|
|
595
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/rehydrations`);
|
|
596
|
+
}
|
|
597
|
+
getObservabilityRehydration(org, name, jobId) {
|
|
598
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/rehydrations/${encodeURIComponent(jobId)}`);
|
|
599
|
+
}
|
|
600
|
+
/** Loads an archived range back for seven days; the answer is the queued job. */
|
|
601
|
+
createObservabilityRehydration(org, name, input) {
|
|
602
|
+
return this.json("POST", `${this.projectPath(org, name)}/observability/rehydrations`, input);
|
|
603
|
+
}
|
|
604
|
+
/** `runlot bug-report` (customer-observability.md §14): the CP snapshots what the references name. */
|
|
605
|
+
createBugReport(org, input) {
|
|
606
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/bug-reports`, input);
|
|
607
|
+
}
|
|
608
|
+
listBugReports(org) {
|
|
609
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/bug-reports`);
|
|
610
|
+
}
|
|
611
|
+
getBugReport(org, reportId, opts = {}) {
|
|
612
|
+
const qs = opts.snapshot === false ? "?snapshot=0" : "";
|
|
613
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/bug-reports/${encodeURIComponent(reportId)}${qs}`);
|
|
614
|
+
}
|
|
615
|
+
deleteBugReport(org, reportId) {
|
|
616
|
+
return this.json("DELETE", `/v1/orgs/${encodeURIComponent(org)}/bug-reports/${encodeURIComponent(reportId)}`);
|
|
617
|
+
}
|
|
618
|
+
/** Synthetic HTTP checks of the project's own addresses (customer-observability.md §17.11). */
|
|
619
|
+
listUptimeChecks(org, name) {
|
|
620
|
+
return this.json("GET", `${this.projectPath(org, name)}/uptime-checks`);
|
|
621
|
+
}
|
|
622
|
+
putUptimeCheck(org, name, id, input) {
|
|
623
|
+
return this.json("PUT", `${this.projectPath(org, name)}/uptime-checks/${encodeURIComponent(id)}`, input);
|
|
624
|
+
}
|
|
625
|
+
deleteUptimeCheck(org, name, id) {
|
|
626
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/uptime-checks/${encodeURIComponent(id)}`);
|
|
627
|
+
}
|
|
628
|
+
listUptimeRuns(org, name, id, limit) {
|
|
629
|
+
const qs = limit !== undefined ? `?limit=${encodeURIComponent(String(limit))}` : "";
|
|
630
|
+
return this.json("GET", `${this.projectPath(org, name)}/uptime-checks/${encodeURIComponent(id)}/runs${qs}`);
|
|
631
|
+
}
|
|
632
|
+
/** Dashboards (customer-observability.md §17.7). A built-in's id is `builtin:<key>`. */
|
|
633
|
+
listDashboards(org, name) {
|
|
634
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/dashboards`);
|
|
635
|
+
}
|
|
636
|
+
createDashboard(org, name, input) {
|
|
637
|
+
return this.json("POST", `${this.projectPath(org, name)}/observability/dashboards`, input);
|
|
638
|
+
}
|
|
639
|
+
getDashboard(org, name, id) {
|
|
640
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/dashboards/${encodeURIComponent(id)}`);
|
|
641
|
+
}
|
|
642
|
+
putDashboard(org, name, id, input) {
|
|
643
|
+
return this.json("PUT", `${this.projectPath(org, name)}/observability/dashboards/${encodeURIComponent(id)}`, input);
|
|
644
|
+
}
|
|
645
|
+
deleteDashboard(org, name, id) {
|
|
646
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/observability/dashboards/${encodeURIComponent(id)}`);
|
|
647
|
+
}
|
|
648
|
+
/** The `.runlot/dashboards/<key>.json` form of a dashboard. */
|
|
649
|
+
exportDashboard(org, name, id) {
|
|
650
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/dashboards/${encodeURIComponent(id)}/export`);
|
|
651
|
+
}
|
|
652
|
+
/** Make (or rotate) the public link; the token is shown once. */
|
|
653
|
+
shareDashboard(org, name, id, isPublic = true) {
|
|
654
|
+
return this.json("POST", `${this.projectPath(org, name)}/observability/dashboards/${encodeURIComponent(id)}/share`, { public: isPublic });
|
|
655
|
+
}
|
|
656
|
+
unshareDashboard(org, name, id) {
|
|
657
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/observability/dashboards/${encodeURIComponent(id)}/share`);
|
|
658
|
+
}
|
|
659
|
+
getDashboardWidgetData(org, name, id, widgetId, req = {}) {
|
|
660
|
+
return this.json("POST", `${this.projectPath(org, name)}/observability/dashboards/${encodeURIComponent(id)}/widgets/${encodeURIComponent(widgetId)}/data`, req);
|
|
661
|
+
}
|
|
662
|
+
getDashboardSettings(org, name) {
|
|
663
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/dashboard-settings`);
|
|
664
|
+
}
|
|
665
|
+
putDashboardSettings(org, name, settings) {
|
|
666
|
+
return this.json("PUT", `${this.projectPath(org, name)}/observability/dashboard-settings`, settings);
|
|
667
|
+
}
|
|
668
|
+
/** Deploy and OOM markers for every time series. */
|
|
669
|
+
getObservabilityMarkers(org, name, range = {}) {
|
|
670
|
+
const q = new URLSearchParams();
|
|
671
|
+
if (range.from)
|
|
672
|
+
q.set("from", range.from);
|
|
673
|
+
if (range.to)
|
|
674
|
+
q.set("to", range.to);
|
|
675
|
+
const qs = q.toString();
|
|
676
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/markers${qs ? `?${qs}` : ""}`);
|
|
677
|
+
}
|
|
678
|
+
/** Watchdog insights (§17.10). Free: deploy regressions only. */
|
|
679
|
+
listInsights(org, name, opts = {}) {
|
|
680
|
+
const q = new URLSearchParams();
|
|
681
|
+
if (opts.state)
|
|
682
|
+
q.set("state", opts.state);
|
|
683
|
+
if (opts.limit !== undefined)
|
|
684
|
+
q.set("limit", String(opts.limit));
|
|
685
|
+
const qs = q.toString();
|
|
686
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/insights${qs ? `?${qs}` : ""}`);
|
|
687
|
+
}
|
|
688
|
+
resolveInsight(org, name, id) {
|
|
689
|
+
return this.json("POST", `${this.projectPath(org, name)}/observability/insights/${encodeURIComponent(id)}/resolve`);
|
|
690
|
+
}
|
|
691
|
+
/** Synthetic checks (§17.11): the uptime checks, including multi-step API checks. */
|
|
692
|
+
listSynthetics(org, name) {
|
|
693
|
+
return this.json("GET", `${this.projectPath(org, name)}/synthetics`);
|
|
694
|
+
}
|
|
695
|
+
putSynthetic(org, name, id, input) {
|
|
696
|
+
return this.json("PUT", `${this.projectPath(org, name)}/synthetics/${encodeURIComponent(id)}`, input);
|
|
697
|
+
}
|
|
698
|
+
deleteSynthetic(org, name, id) {
|
|
699
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/synthetics/${encodeURIComponent(id)}`);
|
|
700
|
+
}
|
|
701
|
+
listSyntheticRuns(org, name, id, limit) {
|
|
702
|
+
const qs = limit !== undefined ? `?limit=${encodeURIComponent(String(limit))}` : "";
|
|
703
|
+
return this.json("GET", `${this.projectPath(org, name)}/synthetics/${encodeURIComponent(id)}/runs${qs}`);
|
|
704
|
+
}
|
|
705
|
+
/** A public dashboard link. Needs no credential. */
|
|
706
|
+
getSharedDashboard(token) {
|
|
707
|
+
return this.json("GET", `/v1/shared/dashboards/${encodeURIComponent(token)}`);
|
|
708
|
+
}
|
|
709
|
+
getSharedDashboardWidgetData(token, widgetId, req = {}) {
|
|
710
|
+
return this.json("POST", `/v1/shared/dashboards/${encodeURIComponent(token)}/widgets/${encodeURIComponent(widgetId)}/data`, req);
|
|
711
|
+
}
|
|
712
|
+
// Customer observability, APM read side (docs/customer-observability.md §8, §17.2–§17.4,
|
|
713
|
+
// §17.6). Range options are RFC 3339 times; `step` is seconds or a duration ("5m").
|
|
714
|
+
obsApmPath(org, name, sub, q) {
|
|
715
|
+
const qs = new URLSearchParams();
|
|
716
|
+
for (const [k, v] of Object.entries(q ?? {}))
|
|
717
|
+
if (v !== undefined && v !== "")
|
|
718
|
+
qs.set(k, String(v));
|
|
719
|
+
const tail = qs.size > 0 ? `?${qs}` : "";
|
|
720
|
+
return `${this.projectPath(org, name)}/observability/${sub}${tail}`;
|
|
721
|
+
}
|
|
722
|
+
getObsMetricsOverview(org, name, opts = {}) {
|
|
723
|
+
return this.json("GET", this.obsApmPath(org, name, "metrics/overview", opts));
|
|
724
|
+
}
|
|
725
|
+
getObsMetricsMemory(org, name, opts = {}) {
|
|
726
|
+
return this.json("GET", this.obsApmPath(org, name, "metrics/memory", opts));
|
|
727
|
+
}
|
|
728
|
+
getObsMetricsInfrastructure(org, name, opts = {}) {
|
|
729
|
+
return this.json("GET", this.obsApmPath(org, name, "metrics/infrastructure", opts));
|
|
730
|
+
}
|
|
731
|
+
getObsMetricsCustom(org, name, opts) {
|
|
732
|
+
return this.json("GET", this.obsApmPath(org, name, "metrics/custom", opts));
|
|
733
|
+
}
|
|
734
|
+
getObsMetricsCustomNames(org, name) {
|
|
735
|
+
return this.json("GET", this.obsApmPath(org, name, "metrics/custom/names"));
|
|
736
|
+
}
|
|
737
|
+
listObsRoutes(org, name) {
|
|
738
|
+
return this.json("GET", this.obsApmPath(org, name, "routes"));
|
|
739
|
+
}
|
|
740
|
+
putObsRoute(org, name, input) {
|
|
741
|
+
return this.json("PUT", this.obsApmPath(org, name, "routes"), input);
|
|
742
|
+
}
|
|
743
|
+
getObsAPMRoutes(org, name, opts = {}) {
|
|
744
|
+
return this.json("GET", this.obsApmPath(org, name, "apm/routes", opts));
|
|
745
|
+
}
|
|
746
|
+
getObsAPMBreakdown(org, name, route, opts = {}) {
|
|
747
|
+
return this.json("GET", this.obsApmPath(org, name, `apm/routes/${encodeURIComponent(route)}/breakdown`, opts));
|
|
748
|
+
}
|
|
749
|
+
getObsAPMServiceMap(org, name, opts = {}) {
|
|
750
|
+
return this.json("GET", this.obsApmPath(org, name, "apm/service-map", opts));
|
|
751
|
+
}
|
|
752
|
+
getObsAPMCompare(org, name, a, b, opts = {}) {
|
|
753
|
+
return this.json("GET", this.obsApmPath(org, name, "apm/compare", { ...opts, a, b }));
|
|
754
|
+
}
|
|
755
|
+
listObsAPMTraces(org, name, opts = {}) {
|
|
756
|
+
return this.json("GET", this.obsApmPath(org, name, "apm/traces", opts));
|
|
757
|
+
}
|
|
758
|
+
getObsAPMTrace(org, name, traceId) {
|
|
759
|
+
return this.json("GET", this.obsApmPath(org, name, `apm/traces/${encodeURIComponent(traceId)}`));
|
|
760
|
+
}
|
|
761
|
+
listObsTraceFilters(org, name) {
|
|
762
|
+
return this.json("GET", this.obsApmPath(org, name, "trace-filters"));
|
|
763
|
+
}
|
|
764
|
+
createObsTraceFilter(org, name, input) {
|
|
765
|
+
return this.json("POST", this.obsApmPath(org, name, "trace-filters"), input);
|
|
766
|
+
}
|
|
767
|
+
updateObsTraceFilter(org, name, id, input) {
|
|
768
|
+
return this.json("PUT", this.obsApmPath(org, name, `trace-filters/${encodeURIComponent(id)}`), input);
|
|
769
|
+
}
|
|
770
|
+
deleteObsTraceFilter(org, name, id) {
|
|
771
|
+
return this.json("DELETE", this.obsApmPath(org, name, `trace-filters/${encodeURIComponent(id)}`));
|
|
772
|
+
}
|
|
773
|
+
listObsDBQueries(org, name, opts = {}) {
|
|
774
|
+
return this.json("GET", this.obsApmPath(org, name, "database/queries", opts));
|
|
775
|
+
}
|
|
776
|
+
getObsDBQuery(org, name, fingerprint, opts = {}) {
|
|
777
|
+
return this.json("GET", this.obsApmPath(org, name, `database/queries/${encodeURIComponent(fingerprint)}`, opts));
|
|
778
|
+
}
|
|
779
|
+
getObsDBHealth(org, name) {
|
|
780
|
+
return this.json("GET", this.obsApmPath(org, name, "database/health"));
|
|
781
|
+
}
|
|
782
|
+
/** The continuous profiler's switch (customer-observability.md §17.13). */
|
|
783
|
+
getObsProfilerSettings(org, name) {
|
|
784
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/profiler`);
|
|
785
|
+
}
|
|
786
|
+
/** On, off, or null for the default. Applies from the next deployment or restart. Admin. */
|
|
787
|
+
putObsProfilerSettings(org, name, enabled) {
|
|
788
|
+
return this.json("PUT", `${this.projectPath(org, name)}/observability/profiler`, { enabled });
|
|
789
|
+
}
|
|
790
|
+
/** The logs/traces sampling override; a null field is the manifest's. */
|
|
791
|
+
getObsSampling(org, name) {
|
|
792
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/sampling`);
|
|
793
|
+
}
|
|
794
|
+
/** Replaces the override (null = the manifest's). Admin. */
|
|
795
|
+
putObsSampling(org, name, body) {
|
|
796
|
+
return this.json("PUT", `${this.projectPath(org, name)}/observability/sampling`, body);
|
|
797
|
+
}
|
|
798
|
+
listObsProfiles(org, name, q = {}) {
|
|
799
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/profiles${obsProfileQS({ ...q })}`);
|
|
800
|
+
}
|
|
801
|
+
/** The windows within a minute of `ts` — the profile of a slow trace's minute. */
|
|
802
|
+
nearObsProfiles(org, name, ts) {
|
|
803
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/profiles/near${obsProfileQS({ ts })}`);
|
|
804
|
+
}
|
|
805
|
+
getObsFlamegraph(org, name, q = {}) {
|
|
806
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/profiles/flamegraph${obsProfileQS({ ...q })}`);
|
|
807
|
+
}
|
|
808
|
+
getObsProfileTop(org, name, q = {}) {
|
|
809
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/profiles/top${obsProfileQS({ ...q })}`);
|
|
810
|
+
}
|
|
811
|
+
/** Self-time share per function, version a against version b. */
|
|
812
|
+
compareObsProfiles(org, name, a, b, q = {}) {
|
|
813
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/profiles/compare${obsProfileQS({ a, b, ...q })}`);
|
|
814
|
+
}
|
|
815
|
+
/** RUM: page views, sessions and p75 vitals over time (Pro). */
|
|
816
|
+
getObsRUMOverview(org, name, q = {}) {
|
|
817
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/rum/overview${obsProfileQS({ ...q })}`);
|
|
818
|
+
}
|
|
819
|
+
/** RUM by page template, with vitals, long tasks and resource/fetch timings (Pro). */
|
|
820
|
+
listObsRUMPages(org, name, q = {}) {
|
|
821
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/rum/pages${obsProfileQS({ ...q })}`);
|
|
822
|
+
}
|
|
823
|
+
/** RUM by device class (Pro). */
|
|
824
|
+
listObsRUMDevices(org, name, q = {}) {
|
|
825
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/rum/devices${obsProfileQS({ ...q })}`);
|
|
826
|
+
}
|
|
827
|
+
/** RUM page views, newest (or slowest LCP) first (Pro). */
|
|
828
|
+
listObsRUMViews(org, name, q = {}) {
|
|
829
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/rum/views${obsProfileQS({ ...q })}`);
|
|
830
|
+
}
|
|
831
|
+
/** One page view and the server requests it caused (Pro). */
|
|
832
|
+
getObsRUMView(org, name, viewId) {
|
|
833
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/rum/views/${encodeURIComponent(viewId)}`);
|
|
834
|
+
}
|
|
835
|
+
/** Starts one heap snapshot (Pro, admin; pauses the app while taken). Poll the list. */
|
|
836
|
+
createObsHeapSnapshot(org, name) {
|
|
837
|
+
return this.json("POST", `${this.projectPath(org, name)}/observability/heap-snapshots`, {});
|
|
838
|
+
}
|
|
839
|
+
listObsHeapSnapshots(org, name) {
|
|
840
|
+
return this.json("GET", `${this.projectPath(org, name)}/observability/heap-snapshots`);
|
|
841
|
+
}
|
|
842
|
+
/** The download URL of a ready snapshot (a `.heapsnapshot` file). */
|
|
843
|
+
obsHeapSnapshotURL(org, name, snapshotId) {
|
|
844
|
+
return new URL(`${this.projectPath(org, name)}/observability/heap-snapshots/${encodeURIComponent(snapshotId)}`, this.opts.baseUrl).toString();
|
|
845
|
+
}
|
|
846
|
+
/** A ready snapshot's text (Chrome DevTools heap snapshot JSON). */
|
|
847
|
+
downloadObsHeapSnapshot(org, name, snapshotId) {
|
|
848
|
+
return this.text("GET", `${this.projectPath(org, name)}/observability/heap-snapshots/${encodeURIComponent(snapshotId)}`);
|
|
849
|
+
}
|
|
850
|
+
getErrorOwnership(org, name) {
|
|
851
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors-ownership`);
|
|
852
|
+
}
|
|
853
|
+
createErrorOwnershipPin(org, name, input) {
|
|
854
|
+
return this.json("POST", `${this.projectPath(org, name)}/errors-ownership/pins`, input);
|
|
855
|
+
}
|
|
856
|
+
revokeErrorOwnershipPin(org, name, deploymentId, selector) {
|
|
857
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/errors-ownership/pins/${encodeURIComponent(deploymentId)}/${encodeURIComponent(selector)}`);
|
|
858
|
+
}
|
|
859
|
+
getErrorCapturePolicy(org, name) {
|
|
860
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors-capture-policy`);
|
|
861
|
+
}
|
|
862
|
+
putErrorCapturePolicy(org, name, policy, acknowledgePII = false) {
|
|
863
|
+
return this.json("PUT", `${this.projectPath(org, name)}/errors-capture-policy`, { policy, acknowledgePII });
|
|
864
|
+
}
|
|
865
|
+
// ---- Observability (docs/customer-observability.md §7, §17.5) ----
|
|
866
|
+
obsPath(org, name) {
|
|
867
|
+
return `${this.projectPath(org, name)}/observability`;
|
|
868
|
+
}
|
|
869
|
+
getObservabilityCapabilities(org, name) {
|
|
870
|
+
return this.json("GET", `${this.obsPath(org, name)}/capabilities`);
|
|
871
|
+
}
|
|
872
|
+
/** Runs a query; `{ available: false }` where there is no event store. */
|
|
873
|
+
queryObservability(org, name, query) {
|
|
874
|
+
return this.json("POST", `${this.obsPath(org, name)}/query`, query);
|
|
875
|
+
}
|
|
876
|
+
listObservabilityKeys(org, name, opts = {}) {
|
|
877
|
+
return this.json("GET", `${this.obsPath(org, name)}/keys${obsQS(opts)}`);
|
|
878
|
+
}
|
|
879
|
+
listObservabilityValues(org, name, key, opts = {}) {
|
|
880
|
+
return this.json("GET", `${this.obsPath(org, name)}/values${obsQS({ ...opts, key })}`);
|
|
881
|
+
}
|
|
882
|
+
listObservabilityPatterns(org, name, opts = {}) {
|
|
883
|
+
return this.json("GET", `${this.obsPath(org, name)}/patterns${obsQS(opts)}`);
|
|
884
|
+
}
|
|
885
|
+
getObservabilityRequest(org, name, requestId) {
|
|
886
|
+
return this.json("GET", `${this.obsPath(org, name)}/requests/${encodeURIComponent(requestId)}`);
|
|
887
|
+
}
|
|
888
|
+
listSavedQueries(org, name) {
|
|
889
|
+
return this.json("GET", `${this.obsPath(org, name)}/saved-queries`);
|
|
890
|
+
}
|
|
891
|
+
getSavedQuery(org, name, queryId) {
|
|
892
|
+
return this.json("GET", `${this.obsPath(org, name)}/saved-queries/${encodeURIComponent(queryId)}`);
|
|
893
|
+
}
|
|
894
|
+
createSavedQuery(org, name, input) {
|
|
895
|
+
return this.json("POST", `${this.obsPath(org, name)}/saved-queries`, input);
|
|
896
|
+
}
|
|
897
|
+
updateSavedQuery(org, name, queryId, input) {
|
|
898
|
+
return this.json("PUT", `${this.obsPath(org, name)}/saved-queries/${encodeURIComponent(queryId)}`, input);
|
|
899
|
+
}
|
|
900
|
+
deleteSavedQuery(org, name, queryId) {
|
|
901
|
+
return this.json("DELETE", `${this.obsPath(org, name)}/saved-queries/${encodeURIComponent(queryId)}`);
|
|
902
|
+
}
|
|
903
|
+
starSavedQuery(org, name, queryId) {
|
|
904
|
+
return this.json("PUT", `${this.obsPath(org, name)}/saved-queries/${encodeURIComponent(queryId)}/star`);
|
|
905
|
+
}
|
|
906
|
+
unstarSavedQuery(org, name, queryId) {
|
|
907
|
+
return this.json("DELETE", `${this.obsPath(org, name)}/saved-queries/${encodeURIComponent(queryId)}/star`);
|
|
908
|
+
}
|
|
909
|
+
getObservabilityPipeline(org, name) {
|
|
910
|
+
return this.json("GET", `${this.obsPath(org, name)}/pipeline`);
|
|
911
|
+
}
|
|
912
|
+
putObservabilityPipeline(org, name, processors) {
|
|
913
|
+
return this.json("PUT", `${this.obsPath(org, name)}/pipeline`, { processors });
|
|
914
|
+
}
|
|
915
|
+
getObservabilityScanner(org, name) {
|
|
916
|
+
return this.json("GET", `${this.obsPath(org, name)}/scanner`);
|
|
917
|
+
}
|
|
918
|
+
putObservabilityScanner(org, name, scanner) {
|
|
919
|
+
return this.json("PUT", `${this.obsPath(org, name)}/scanner`, scanner);
|
|
920
|
+
}
|
|
921
|
+
/** Runs a scanner (the project's, or `scanner`) over a sample; nothing is stored. */
|
|
922
|
+
testObservabilityScanner(org, name, text, scanner) {
|
|
923
|
+
return this.json("POST", `${this.obsPath(org, name)}/scanner/test`, scanner ? { text, scanner } : { text });
|
|
924
|
+
}
|
|
925
|
+
/** The whole ingest configuration, shaped as `.runlot/logs.json`. */
|
|
926
|
+
exportObservabilityLogsConfig(org, name) {
|
|
927
|
+
return this.json("GET", `${this.obsPath(org, name)}/logs-config`);
|
|
928
|
+
}
|
|
929
|
+
listObservabilityLogMetrics(org, name) {
|
|
930
|
+
return this.json("GET", `${this.obsPath(org, name)}/log-metrics`);
|
|
931
|
+
}
|
|
932
|
+
putObservabilityLogMetric(org, name, metric, def) {
|
|
933
|
+
return this.json("PUT", `${this.obsPath(org, name)}/log-metrics/${encodeURIComponent(metric)}`, def);
|
|
934
|
+
}
|
|
935
|
+
deleteObservabilityLogMetric(org, name, metric) {
|
|
936
|
+
return this.json("DELETE", `${this.obsPath(org, name)}/log-metrics/${encodeURIComponent(metric)}`);
|
|
937
|
+
}
|
|
938
|
+
getErrorEventPII(org, name, issueId, eventId) {
|
|
939
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/events/${encodeURIComponent(eventId)}?includePII=true`);
|
|
940
|
+
}
|
|
941
|
+
getErrorSettings(org, name) {
|
|
942
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors-settings`);
|
|
943
|
+
}
|
|
944
|
+
putErrorSettings(org, name,
|
|
945
|
+
/** Omitted writable fields preserve their values; ownership assignment defaults off. */
|
|
946
|
+
settings) {
|
|
947
|
+
return this.json("PUT", `${this.projectPath(org, name)}/errors-settings`, settings);
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* One AI diagnosis of an issue, billed to the org's AI credit. There is no
|
|
951
|
+
* prompt to pass: the control plane builds it from the issue's stored event.
|
|
952
|
+
* The same `idempotencyKey` again returns the stored answer without a second
|
|
953
|
+
* charge, so a caller retrying after a timeout must reuse its key.
|
|
954
|
+
*/
|
|
955
|
+
diagnoseErrorIssue(org, name, issueId, body) {
|
|
956
|
+
return this.json("POST", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/diagnoses`, body);
|
|
957
|
+
}
|
|
958
|
+
listErrorDiagnoses(org, name, issueId) {
|
|
959
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/diagnoses`);
|
|
960
|
+
}
|
|
961
|
+
fixPath(org, name, issueId) {
|
|
962
|
+
return `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/fix-proposals`;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Ask a model to propose a fix for an issue. Billed to the org's AI credit and
|
|
966
|
+
* writes nothing: the repository, base commit and files are chosen by the control
|
|
967
|
+
* plane. Reuse `idempotencyKey` on a retry so it is not charged twice.
|
|
968
|
+
*/
|
|
969
|
+
proposeErrorFix(org, name, issueId, body) {
|
|
970
|
+
return this.json("POST", this.fixPath(org, name, issueId), body);
|
|
971
|
+
}
|
|
972
|
+
listErrorFixProposals(org, name, issueId) {
|
|
973
|
+
return this.json("GET", this.fixPath(org, name, issueId));
|
|
974
|
+
}
|
|
975
|
+
getErrorFixProposal(org, name, issueId, proposalId) {
|
|
976
|
+
return this.json("GET", `${this.fixPath(org, name, issueId)}/${encodeURIComponent(proposalId)}`);
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Write a ready proposal as one commit on its own `runlot/autofix/` branch. It
|
|
980
|
+
* builds, deploys and merges nothing. `proposalSha` must be the proposal's exactly.
|
|
981
|
+
*/
|
|
982
|
+
applyErrorFix(org, name, issueId, proposalId, proposalSha) {
|
|
983
|
+
return this.json("POST", `${this.fixPath(org, name, issueId)}/${encodeURIComponent(proposalId)}/apply`, {
|
|
984
|
+
proposalSha,
|
|
985
|
+
acknowledgeUnreviewedCode: true,
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
lookupErrorFixProposal(org, name, issueId, key) {
|
|
989
|
+
return this.request("GET", `${this.fixPath(org, name, issueId)}/lookup`, { headers: { "Idempotency-Key": key } });
|
|
990
|
+
}
|
|
991
|
+
lookupErrorFixPreview(org, name, issueId, proposalId, key) {
|
|
992
|
+
return this.request("GET", `${this.fixPath(org, name, issueId)}/${encodeURIComponent(proposalId)}/previews/lookup`, { headers: { "Idempotency-Key": key } });
|
|
993
|
+
}
|
|
994
|
+
lookupErrorFixVerification(org, name, issueId, proposalId, jobId, key) {
|
|
995
|
+
return this.request("GET", `${this.fixPath(org, name, issueId)}/${encodeURIComponent(proposalId)}/previews/${encodeURIComponent(jobId)}/verify/lookup`, { headers: { "Idempotency-Key": key } });
|
|
996
|
+
}
|
|
997
|
+
approveErrorFixPreview(org, name, issueId, proposalId, body) {
|
|
998
|
+
return this.json("POST", `${this.fixPath(org, name, issueId)}/${encodeURIComponent(proposalId)}/previews`, body);
|
|
999
|
+
}
|
|
1000
|
+
getErrorFixPreview(org, name, issueId, proposalId, jobId) {
|
|
1001
|
+
return this.json("GET", `${this.fixPath(org, name, issueId)}/${encodeURIComponent(proposalId)}/previews/${encodeURIComponent(jobId)}`);
|
|
1002
|
+
}
|
|
1003
|
+
approveErrorFixPreviewVerification(org, name, issueId, proposalId, jobId, body) {
|
|
1004
|
+
return this.json("POST", `${this.fixPath(org, name, issueId)}/${encodeURIComponent(proposalId)}/previews/${encodeURIComponent(jobId)}/verify`, body);
|
|
1005
|
+
}
|
|
1006
|
+
/** Erase captured issue data, after explicit review. Admin; unmerge first. */
|
|
1007
|
+
deleteErrorIssue(org, name, issueId) {
|
|
1008
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}`);
|
|
1009
|
+
}
|
|
1010
|
+
/** Erase an exact application user ID; anonymous aggregates remain. Admin. */
|
|
1011
|
+
eraseErrorUser(org, name, userId) {
|
|
1012
|
+
return this.json("POST", `${this.projectPath(org, name)}/errors-erasure`, { userId });
|
|
1013
|
+
}
|
|
1014
|
+
/** Untrusted browser histograms and technical-fuse counters, not billed usage. Viewer. */
|
|
1015
|
+
getBrowserTelemetry(org, name) {
|
|
1016
|
+
return this.json("GET", `${this.projectPath(org, name)}/browser-telemetry`);
|
|
1017
|
+
}
|
|
1018
|
+
/** Unverified feedback whose exact browser error anchor belongs to this issue. Never includes email. */
|
|
1019
|
+
listBrowserFeedback(org, name, issueId) {
|
|
1020
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/feedback`);
|
|
1021
|
+
}
|
|
1022
|
+
/** Explicit sensitive read. Admin + errors:pii; optional unverified email only while feedback-email retention is on. */
|
|
1023
|
+
listBrowserFeedbackWithPII(org, name, issueId) {
|
|
1024
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/feedback?includePII=true`);
|
|
1025
|
+
}
|
|
1026
|
+
/** The masked structural replay switch, cap and this month's count. Viewer. */
|
|
1027
|
+
getErrorReplaySettings(org, name) {
|
|
1028
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors-replay-settings`);
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Both fields are required: `monthlyCap` null is the plan's amount, `0` stops collection,
|
|
1032
|
+
* `-1` removes the cap (Pro). Admin.
|
|
1033
|
+
*/
|
|
1034
|
+
putErrorReplaySettings(org, name, settings) {
|
|
1035
|
+
return this.json("PUT", `${this.projectPath(org, name)}/errors-replay-settings`, settings);
|
|
1036
|
+
}
|
|
1037
|
+
/** An issue's complete masked structural replays. Admin, until a granular PII scope exists. */
|
|
1038
|
+
listErrorReplays(org, name, issueId) {
|
|
1039
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/replays`);
|
|
1040
|
+
}
|
|
1041
|
+
/** One replay and its re-validated batches, for the sandboxed player. Admin. */
|
|
1042
|
+
getErrorReplay(org, name, issueId, replayId) {
|
|
1043
|
+
return this.json("GET", `${this.projectPath(org, name)}/errors/${encodeURIComponent(issueId)}/replays/${encodeURIComponent(replayId)}`);
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Scheduled runs: what the live deployment declares, when each fires next, and
|
|
1047
|
+
* the recent history (docs/cron.md §8). `limit` bounds the history rows only —
|
|
1048
|
+
* the schedules and the per-schedule last run are never paged.
|
|
1049
|
+
*/
|
|
1050
|
+
getProjectCron(org, name, limit) {
|
|
1051
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
1052
|
+
return this.json("GET", `${this.projectPath(org, name)}/cron${qs}`);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Queues: what the live deployment declares, how deep each one is, and the
|
|
1056
|
+
* recent batch history (docs/queues.md §6). The depth is read from the
|
|
1057
|
+
* project's own database; `depthError` on the answer says when it could not be.
|
|
1058
|
+
*/
|
|
1059
|
+
getProjectQueues(org, name, limit) {
|
|
1060
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
1061
|
+
return this.json("GET", `${this.projectPath(org, name)}/queues${qs}`);
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Durable Objects: how many this project has placed, against the two caps
|
|
1065
|
+
* (docs/durable-objects.md).
|
|
1066
|
+
*
|
|
1067
|
+
* **It answers how much, never which.** There is no actor id in the response
|
|
1068
|
+
* and none is coming — those name individual objects, and a list of them would
|
|
1069
|
+
* be an object enumeration wearing a quota's name. `nodes` is keyed by node id
|
|
1070
|
+
* because `nodeLimit` is a separate bound that can refuse a placement while
|
|
1071
|
+
* the project-wide cap still has room.
|
|
1072
|
+
*/
|
|
1073
|
+
getProjectDurableObjects(org, name) {
|
|
1074
|
+
return this.json("GET", `${this.projectPath(org, name)}/durable-objects`);
|
|
1075
|
+
}
|
|
1076
|
+
queuePath(org, name, queue) {
|
|
1077
|
+
return `${this.projectPath(org, name)}/queues/${encodeURIComponent(queue)}`;
|
|
1078
|
+
}
|
|
1079
|
+
listQueueRuns(org, name, queue, limit) {
|
|
1080
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
1081
|
+
return this.json("GET", `${this.queuePath(org, name, queue)}/runs${qs}`);
|
|
1082
|
+
}
|
|
1083
|
+
/** The head of the queue without leasing it — looking cannot delay a delivery. */
|
|
1084
|
+
peekQueue(org, name, queue, limit) {
|
|
1085
|
+
const qs = limit ? `?limit=${limit}` : "";
|
|
1086
|
+
return this.json("GET", `${this.queuePath(org, name, queue)}/messages${qs}`);
|
|
1087
|
+
}
|
|
1088
|
+
/** Irreversible. The confirmation is the caller's — the server holds none. */
|
|
1089
|
+
purgeQueue(org, name, queue) {
|
|
1090
|
+
return this.json("DELETE", `${this.queuePath(org, name, queue)}/messages`);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Moves a dead-letter queue's messages back. `to` is required only when the
|
|
1094
|
+
* dead-letter queue belongs to more than one consumer, or to none.
|
|
1095
|
+
*/
|
|
1096
|
+
redriveQueue(org, name, queue, to) {
|
|
1097
|
+
return this.json("POST", `${this.queuePath(org, name, queue)}/redrive`, to === undefined ? {} : { to });
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* The vector store: every namespace with its count and width, and the plan's
|
|
1101
|
+
* bounds (docs/vectors.md §4). Read from the project's own database;
|
|
1102
|
+
* `readError` on the answer says when it could not be.
|
|
1103
|
+
*/
|
|
1104
|
+
getProjectVectors(org, name) {
|
|
1105
|
+
return this.json("GET", `${this.projectPath(org, name)}/vectors`);
|
|
1106
|
+
}
|
|
1107
|
+
/** Irreversible. The confirmation is the caller's — the server holds none. */
|
|
1108
|
+
deleteVectorNamespace(org, name, namespace) {
|
|
1109
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/vectors/${encodeURIComponent(namespace)}`);
|
|
1110
|
+
}
|
|
1111
|
+
/** The body is the bundle. One digest covers all of the code and the assets. */
|
|
1112
|
+
/**
|
|
1113
|
+
* Uploads the bundle. `headers` carries the provenance headers
|
|
1114
|
+
* (`X-Runlot-Git-*`, openapi createDeployment) — the body is the bundle
|
|
1115
|
+
* itself, so the metadata can only travel in headers.
|
|
1116
|
+
*/
|
|
1117
|
+
deploy(org, name, bundle, headers = {}) {
|
|
114
1118
|
return this.request("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/deployments`, {
|
|
115
1119
|
body: bundle,
|
|
1120
|
+
headers: { ...headers, "Content-Type": "application/gzip" },
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* The same upload, aimed at a preview (docs/preview.md). **It does not move
|
|
1125
|
+
* production's live pointer** — that is the whole difference, and it is why
|
|
1126
|
+
* this is a named method rather than an optional argument on `deploy`: a
|
|
1127
|
+
* caller that forgets the argument deploys to production.
|
|
1128
|
+
*
|
|
1129
|
+
* `db` picks what `env.db` points at (`branch` by default, `shared` at
|
|
1130
|
+
* production's own database, `none` for no database), and `from` pours the
|
|
1131
|
+
* branch from a named generation instead of the newest one.
|
|
1132
|
+
*/
|
|
1133
|
+
deployPreview(org, name, bundle,
|
|
1134
|
+
// `| undefined` spelled out: under exactOptionalPropertyTypes a caller that
|
|
1135
|
+
// forwards an unset flag is passing the property, not omitting it.
|
|
1136
|
+
opts, headers = {}) {
|
|
1137
|
+
return this.request("POST", `${this.projectPath(org, name)}/deployments?${previewQuery(opts)}`, {
|
|
1138
|
+
body: bundle,
|
|
1139
|
+
headers: { ...headers, "Content-Type": "application/gzip" },
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Opens an incremental upload (docs/incremental-deploy-upload.md §1.1). `files` is
|
|
1144
|
+
* the bundle's entry list in tar order; the answer names the hashes to upload.
|
|
1145
|
+
* An older CP answers 404 here — the caller falls back to `deploy`.
|
|
1146
|
+
*/
|
|
1147
|
+
createDeploymentUpload(org, name, files, preview) {
|
|
1148
|
+
let path = `${this.projectPath(org, name)}/deployments/uploads`;
|
|
1149
|
+
if (preview)
|
|
1150
|
+
path += `?${previewQuery(preview)}`;
|
|
1151
|
+
return this.json("POST", path, { files });
|
|
1152
|
+
}
|
|
1153
|
+
/** One batch: a gzip tar whose entries are named by their content's sha256 (§1.2). */
|
|
1154
|
+
uploadDeploymentBlobs(org, name, uploadId, batch) {
|
|
1155
|
+
return this.request("POST", `${this.projectPath(org, name)}/deployments/uploads/${encodeURIComponent(uploadId)}/blobs`, {
|
|
1156
|
+
body: batch,
|
|
116
1157
|
headers: { "Content-Type": "application/gzip" },
|
|
117
1158
|
});
|
|
118
1159
|
}
|
|
119
|
-
/**
|
|
1160
|
+
/**
|
|
1161
|
+
* Assembles and deploys the session (§1.3). The answer is `createDeployment`'s
|
|
1162
|
+
* (with `preview` for a preview session). Idempotent per session, so a retry
|
|
1163
|
+
* after an edge timeout returns the same deployment.
|
|
1164
|
+
*/
|
|
1165
|
+
commitDeploymentUpload(org, name, uploadId, headers = {}) {
|
|
1166
|
+
return this.request("POST", `${this.projectPath(org, name)}/deployments/uploads/${encodeURIComponent(uploadId)}/commit`, {
|
|
1167
|
+
headers,
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
/** The parent's live previews (viewer). A deleted preview is not listed. */
|
|
1171
|
+
listPreviews(org, name) {
|
|
1172
|
+
return this.json("GET", `${this.projectPath(org, name)}/previews`);
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Deletes a preview and its branch (member).
|
|
1176
|
+
*
|
|
1177
|
+
* No confirmation string, unlike `deleteProject`: a branch is a copy taken at a
|
|
1178
|
+
* moment and nothing in it is the only copy of anything.
|
|
1179
|
+
*/
|
|
1180
|
+
deletePreview(org, name, preview) {
|
|
1181
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/previews/${encodeURIComponent(preview)}`);
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Makes the preview's artifact the parent's live deployment (member).
|
|
1185
|
+
*
|
|
1186
|
+
* **The code, never the data** (docs/preview.md §7). The branch is not merged
|
|
1187
|
+
* and production's database is not replaced. The preview stays alive.
|
|
1188
|
+
*/
|
|
1189
|
+
promotePreview(org, name, preview) {
|
|
1190
|
+
return this.json("POST", `${this.projectPath(org, name)}/previews/${encodeURIComponent(preview)}/promote`);
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* The project's share link — `<label>.share.<app-domain>`, the one address
|
|
1194
|
+
* Studio hands to somebody who is not a developer (docs/studio.md §6.9).
|
|
1195
|
+
*
|
|
1196
|
+
* 404 when the project has never been shared: a link is minted by
|
|
1197
|
+
* `putShareLink`, never as a side effect of reading.
|
|
1198
|
+
*/
|
|
1199
|
+
getShareLink(org, name) {
|
|
1200
|
+
return this.json("GET", `${this.projectPath(org, name)}/share`);
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Points the share link at a preview, minting the label if there is none.
|
|
1204
|
+
*
|
|
1205
|
+
* Idempotent: the label is kept across shares, so somebody holding the link
|
|
1206
|
+
* keeps working. `rotate` mints a new label and retires the old name in the
|
|
1207
|
+
* same request ("링크 재발급"), so the project never has two live links.
|
|
1208
|
+
*/
|
|
1209
|
+
putShareLink(org, name, opts = {}) {
|
|
1210
|
+
return this.json("PUT", `${this.projectPath(org, name)}/share`, {
|
|
1211
|
+
...(opts.preview === undefined ? {} : { preview: opts.preview }),
|
|
1212
|
+
...(opts.rotate === undefined ? {} : { rotate: opts.rotate }),
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
/** Stops the link answering and forgets the label. The preview keeps running. */
|
|
1216
|
+
deleteShareLink(org, name) {
|
|
1217
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/share`);
|
|
1218
|
+
}
|
|
1219
|
+
/** Idempotent. Called twice, the password is not rolled and the same connection details come back. */
|
|
120
1220
|
createDatabase(org, name) {
|
|
121
1221
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`);
|
|
122
1222
|
}
|
|
@@ -124,17 +1224,18 @@ export class Client {
|
|
|
124
1224
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`);
|
|
125
1225
|
}
|
|
126
1226
|
/**
|
|
127
|
-
*
|
|
128
|
-
* viewer
|
|
1227
|
+
* The connection credentials as well. The route is split from `getDatabase`
|
|
1228
|
+
* because of roles — a viewer may know whether there is a database, but not
|
|
1229
|
+
* the password (proto/openapi.yaml).
|
|
129
1230
|
*/
|
|
130
1231
|
getDatabaseConnect(org, name) {
|
|
131
1232
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database/connect`);
|
|
132
1233
|
}
|
|
133
|
-
/**
|
|
1234
|
+
/** The endpoint only — no credentials. A viewer gets it too. Used by `runlot port-forward`. */
|
|
134
1235
|
getDatabaseEndpoint(org, name) {
|
|
135
1236
|
return this.json("GET", `${dbPath(org, name)}/endpoint`);
|
|
136
1237
|
}
|
|
137
|
-
/**
|
|
1238
|
+
/** Issues a short-lived machine credential. The password is carried in this response and nowhere else. */
|
|
138
1239
|
createDatabaseToken(org, name, ttlSeconds) {
|
|
139
1240
|
return this.json("POST", `${dbPath(org, name)}/tokens`, ttlSeconds === undefined ? {} : { ttlSeconds });
|
|
140
1241
|
}
|
|
@@ -145,59 +1246,111 @@ export class Client {
|
|
|
145
1246
|
return this.json("DELETE", `${dbPath(org, name)}/tokens/${encodeURIComponent(user)}`);
|
|
146
1247
|
}
|
|
147
1248
|
/**
|
|
148
|
-
*
|
|
1249
|
+
* Makes one diagnostic image.
|
|
149
1250
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* (proto/openapi.yaml).
|
|
1251
|
+
* **Not idempotent** — every call makes another image. And it is slow: the
|
|
1252
|
+
* response comes after the dump finishes, and that project's actor is held
|
|
1253
|
+
* for the whole of it (proto/openapi.yaml).
|
|
153
1254
|
*/
|
|
154
1255
|
exportDatabase(org, name) {
|
|
155
1256
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database/export`);
|
|
156
1257
|
}
|
|
157
1258
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
1259
|
+
* Every generation a restore can choose, newest first. `lastCheckedAt` is the
|
|
1260
|
+
* heartbeat of the no-change skip — it is what tells "no new generations"
|
|
1261
|
+
* apart from "the backup is dead".
|
|
160
1262
|
*/
|
|
161
1263
|
listGenerations(org, name) {
|
|
162
1264
|
return this.json("GET", `${this.dbPath(org, name)}/generations`);
|
|
163
1265
|
}
|
|
164
1266
|
/**
|
|
165
|
-
*
|
|
1267
|
+
* Runs one statement in the project's database (the dashboard console).
|
|
166
1268
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
1269
|
+
* `readOnly` is **omitted, not sent as false**, when the caller wants the safe
|
|
1270
|
+
* mode: the server treats an absent field as read-only, so leaving it out is the
|
|
1271
|
+
* one spelling that cannot be misread. Sending `false` is the explicit ask for
|
|
1272
|
+
* write mode, and only then does the server run outside a transaction.
|
|
1273
|
+
*
|
|
1274
|
+
* SQL failures arrive as an `ApiError` whose body carries `details.sqlstate` —
|
|
1275
|
+
* PostgreSQL's own code, which is what the error panel shows.
|
|
1276
|
+
*/
|
|
1277
|
+
executeSQL(org, name, sql, opts = {}) {
|
|
1278
|
+
const body = { sql };
|
|
1279
|
+
if (opts.readOnly === false)
|
|
1280
|
+
body.readOnly = false;
|
|
1281
|
+
if (opts.params !== undefined && opts.params.length > 0)
|
|
1282
|
+
body.params = opts.params;
|
|
1283
|
+
return this.json("POST", `${this.dbPath(org, name)}/execute`, body);
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Rolls back to a generation. **Writes made since then are lost.**
|
|
1287
|
+
*
|
|
1288
|
+
* It ends at 202 — what comes back is an operation id, and progress is read
|
|
1289
|
+
* through `getDatabaseOperation`. The server does not resolve `latest`: the
|
|
1290
|
+
* `(epoch, seq)` chosen from the list is carried as-is (proto/openapi.yaml).
|
|
170
1291
|
*/
|
|
171
1292
|
restoreDatabase(org, name, epoch, seq) {
|
|
172
1293
|
return this.json("POST", `${this.dbPath(org, name)}/restore`, { epoch, seq });
|
|
173
1294
|
}
|
|
174
1295
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
1296
|
+
* Rolls back to a restore point **inside** a backup (pg-feather docs/37):
|
|
1297
|
+
* `txnId` is that commit, `at` is the last commit at or before that time. One
|
|
1298
|
+
* backup carries the commits in between in order, so the place you can roll
|
|
1299
|
+
* back to is not tied to a backup boundary. Everything else is as in
|
|
1300
|
+
* restoreDatabase — 202, an operation id, and one safety backup before the
|
|
1301
|
+
* rollback.
|
|
1302
|
+
*/
|
|
1303
|
+
restoreDatabaseTo(org, name, target) {
|
|
1304
|
+
return this.json("POST", `${this.dbPath(org, name)}/restore`, target);
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Removes the database. `confirm` has to match the project name **exactly**;
|
|
1308
|
+
* if it does not, the server refuses with 400 `confirm_mismatch`.
|
|
177
1309
|
*/
|
|
178
1310
|
deleteDatabase(org, name, confirm) {
|
|
179
1311
|
return this.json("POST", `${this.dbPath(org, name)}/delete`, { confirm });
|
|
180
1312
|
}
|
|
181
|
-
/**
|
|
1313
|
+
/** The progress of one operation. The operation id is not a credential; it lives under the project path. */
|
|
182
1314
|
getDatabaseOperation(org, name, opId) {
|
|
183
1315
|
return this.json("GET", `${this.dbPath(org, name)}/operations/${encodeURIComponent(opId)}`);
|
|
184
1316
|
}
|
|
185
|
-
/**
|
|
1317
|
+
/** Aborts an operation that has not yet reached a phase it cannot come back from. */
|
|
186
1318
|
abortDatabaseOperation(org, name, opId) {
|
|
187
1319
|
return this.json("POST", `${this.dbPath(org, name)}/operations/${encodeURIComponent(opId)}/abort`);
|
|
188
1320
|
}
|
|
189
1321
|
// ---- Phase 6 (docs/phase6.md) ----
|
|
190
1322
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
1323
|
+
* A live tail of the logs. It is **a stream, not JSON**, so it does not go
|
|
1324
|
+
* through `request` — what comes back is an async iterable of line-by-line
|
|
1325
|
+
* `LogEvent`, and aborting `signal` closes the connection. An error response
|
|
1326
|
+
* (4xx/5xx) is the same `ApiError` as in every other method.
|
|
194
1327
|
*/
|
|
195
1328
|
async *tailLogs(org, name, opts = {}) {
|
|
1329
|
+
yield* this.tailStream(org, name, opts, undefined);
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* The live tail as `LogRecord`s — the stored event's shape (`--format json`).
|
|
1333
|
+
* Pings and the end event still arrive as `LogEvent`s.
|
|
1334
|
+
*/
|
|
1335
|
+
async *tailLogRecords(org, name, opts = {}) {
|
|
1336
|
+
yield* this.tailStream(org, name, opts, "json");
|
|
1337
|
+
}
|
|
1338
|
+
async *tailStream(org, name, opts, format) {
|
|
196
1339
|
const q = new URLSearchParams();
|
|
197
1340
|
if (opts.tail !== undefined)
|
|
198
1341
|
q.set("tail", String(opts.tail));
|
|
199
1342
|
if (opts.follow !== undefined)
|
|
200
1343
|
q.set("follow", String(opts.follow));
|
|
1344
|
+
if (opts.level)
|
|
1345
|
+
q.set("level", opts.level);
|
|
1346
|
+
if (opts.source)
|
|
1347
|
+
q.set("source", opts.source);
|
|
1348
|
+
if (opts.q)
|
|
1349
|
+
q.set("q", opts.q);
|
|
1350
|
+
if (opts.requestId)
|
|
1351
|
+
q.set("requestId", opts.requestId);
|
|
1352
|
+
if (format)
|
|
1353
|
+
q.set("format", format);
|
|
201
1354
|
const path = `${this.projectPath(org, name)}/logs${q.size ? `?${q}` : ""}`;
|
|
202
1355
|
const res = await fetch(new URL(path, this.opts.baseUrl), {
|
|
203
1356
|
method: "GET",
|
|
@@ -210,7 +1363,7 @@ export class Client {
|
|
|
210
1363
|
body = (await res.json());
|
|
211
1364
|
}
|
|
212
1365
|
catch {
|
|
213
|
-
//
|
|
1366
|
+
// The same reason as in request above.
|
|
214
1367
|
}
|
|
215
1368
|
throw new ApiError(res.status, body, `GET ${path} → ${res.status}`);
|
|
216
1369
|
}
|
|
@@ -238,14 +1391,35 @@ export class Client {
|
|
|
238
1391
|
yield JSON.parse(rest);
|
|
239
1392
|
}
|
|
240
1393
|
finally {
|
|
241
|
-
//
|
|
1394
|
+
// If the consumer ends early (break), the server's follow has to end too.
|
|
242
1395
|
await reader.cancel().catch(() => { });
|
|
243
1396
|
}
|
|
244
1397
|
}
|
|
1398
|
+
/**
|
|
1399
|
+
* The stored lane (0062). It is a plain JSON page, not a stream: the history
|
|
1400
|
+
* does not reach a node, so it answers for a project that is cold, parked, or
|
|
1401
|
+
* has moved since the lines were written — every one of which is a 409 on
|
|
1402
|
+
* `tailLogs`.
|
|
1403
|
+
*
|
|
1404
|
+
* `q` is a plain substring, matched case-insensitively. It is not a regular
|
|
1405
|
+
* expression — `%` and `_` match themselves.
|
|
1406
|
+
*
|
|
1407
|
+
* Paging is keyset: pass the `cursor` from a page back to get the next, older
|
|
1408
|
+
* one. A page with no `cursor` is the end of what is kept.
|
|
1409
|
+
*/
|
|
1410
|
+
getLogHistory(org, name, opts = {}) {
|
|
1411
|
+
const params = new URLSearchParams();
|
|
1412
|
+
for (const [k, v] of Object.entries(opts)) {
|
|
1413
|
+
if (v !== undefined && v !== "")
|
|
1414
|
+
params.set(k, String(v));
|
|
1415
|
+
}
|
|
1416
|
+
const qs = params.size ? `?${params}` : "";
|
|
1417
|
+
return this.json("GET", `${this.projectPath(org, name)}/logs/history${qs}`);
|
|
1418
|
+
}
|
|
245
1419
|
listSecrets(org, name) {
|
|
246
1420
|
return this.json("GET", `${this.projectPath(org, name)}/secrets`);
|
|
247
1421
|
}
|
|
248
|
-
/**
|
|
1422
|
+
/** The value travels in this call only. It is in no response at all. */
|
|
249
1423
|
setSecret(org, name, secret, value) {
|
|
250
1424
|
return this.json("PUT", `${this.projectPath(org, name)}/secrets/${encodeURIComponent(secret)}`, { value });
|
|
251
1425
|
}
|
|
@@ -256,111 +1430,389 @@ export class Client {
|
|
|
256
1430
|
const q = hours === undefined ? "" : `?hours=${hours}`;
|
|
257
1431
|
return this.json("GET", `${this.projectPath(org, name)}/usage${q}`);
|
|
258
1432
|
}
|
|
259
|
-
// ----
|
|
260
|
-
/**
|
|
1433
|
+
// ---- Object storage (docs/storage.md §8) ----
|
|
1434
|
+
/** Grant, prefix, quota, usage. `usedBytes` lags by the node's reporting interval. */
|
|
261
1435
|
getStorage(org, name) {
|
|
262
1436
|
return this.json("GET", `${this.projectPath(org, name)}/storage`);
|
|
263
1437
|
}
|
|
264
1438
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
1439
|
+
* Grants storage. It is idempotent, so pressing twice leaves the prefix as it
|
|
1440
|
+
* was. Taking neither the prefix nor the quota as an argument is the point —
|
|
1441
|
+
* the prefix is the isolation boundary and the quota is set by the plan
|
|
1442
|
+
* (proto/openapi.yaml).
|
|
268
1443
|
*/
|
|
269
1444
|
grantStorage(org, name) {
|
|
270
1445
|
return this.json("POST", `${this.projectPath(org, name)}/storage`);
|
|
271
1446
|
}
|
|
272
|
-
/**
|
|
1447
|
+
/** Removes the grant. **The objects are not deleted** (docs/storage.md §7). */
|
|
273
1448
|
revokeStorage(org, name) {
|
|
274
1449
|
return this.json("DELETE", `${this.projectPath(org, name)}/storage`);
|
|
275
1450
|
}
|
|
276
|
-
// ---- 최종 사용자 인증 (docs/auth.md §9) ----
|
|
277
1451
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
1452
|
+
* The key prefixes this project serves unsigned (docs/storage.md §4.7).
|
|
1453
|
+
*
|
|
1454
|
+
* A prefix is stored normalized — `assets` becomes `assets/`, and `/` becomes
|
|
1455
|
+
* the empty string, which means every key. The value that comes back is the
|
|
1456
|
+
* value that governs, so a screen must render the response rather than what
|
|
1457
|
+
* the user typed.
|
|
1458
|
+
*/
|
|
1459
|
+
listStoragePublic(org, name) {
|
|
1460
|
+
return this.json("GET", `${this.projectPath(org, name)}/storage/public`);
|
|
1461
|
+
}
|
|
1462
|
+
/** Publishes a prefix. Idempotent. All three verbs answer with the whole list. */
|
|
1463
|
+
addStoragePublic(org, name, prefix) {
|
|
1464
|
+
return this.json("POST", `${this.projectPath(org, name)}/storage/public`, { prefix });
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Unpublishes a prefix. Idempotent.
|
|
1468
|
+
*
|
|
1469
|
+
* **The world keeps reading for up to a minute.** The object front caches the
|
|
1470
|
+
* list, so this call is not a revocation that takes effect at the instant it
|
|
1471
|
+
* returns — a screen that says "no longer public" the moment this resolves is
|
|
1472
|
+
* telling a small lie.
|
|
1473
|
+
*/
|
|
1474
|
+
removeStoragePublic(org, name, prefix) {
|
|
1475
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/storage/public`, { prefix });
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* One page of objects grouped by `/` (`runlot storage ls`). `prefixes` are the
|
|
1479
|
+
* folders one level down; feed `cursor` back unchanged, its absence is the end.
|
|
1480
|
+
*/
|
|
1481
|
+
listStorageObjects(org, name, opts = {}) {
|
|
1482
|
+
const q = new URLSearchParams();
|
|
1483
|
+
if (opts.prefix)
|
|
1484
|
+
q.set("prefix", opts.prefix);
|
|
1485
|
+
if (opts.cursor)
|
|
1486
|
+
q.set("cursor", opts.cursor);
|
|
1487
|
+
if (opts.limit)
|
|
1488
|
+
q.set("limit", String(opts.limit));
|
|
1489
|
+
const qs = q.toString();
|
|
1490
|
+
return this.json("GET", `${this.projectPath(org, name)}/storage/objects${qs ? "?" + qs : ""}`);
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* A five-minute signed GET for one object (`runlot storage download`). The key's
|
|
1494
|
+
* `/` segments stay in the path; each segment is encoded on its own.
|
|
1495
|
+
*/
|
|
1496
|
+
signStorageObject(org, name, key) {
|
|
1497
|
+
const path = key.split("/").map(encodeURIComponent).join("/");
|
|
1498
|
+
return this.json("GET", `${this.projectPath(org, name)}/storage/objects/${path}`);
|
|
1499
|
+
}
|
|
1500
|
+
// ---- Email (docs/email.md §5) ----
|
|
1501
|
+
/** Grant, address, sender, limits, recent counts. The address comes back as a preview even without a grant. */
|
|
1502
|
+
getEmail(org, name) {
|
|
1503
|
+
return this.json("GET", `${this.projectPath(org, name)}/email`);
|
|
1504
|
+
}
|
|
1505
|
+
/** Turns it on. **Idempotent** — we choose the address. The deploy reads `"email": true` and calls this. */
|
|
1506
|
+
grantEmail(org, name) {
|
|
1507
|
+
return this.json("POST", `${this.projectPath(org, name)}/email`);
|
|
1508
|
+
}
|
|
1509
|
+
/** Turns it off. Mail arriving at that address now gets a 550. */
|
|
1510
|
+
revokeEmail(org, name) {
|
|
1511
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/email`);
|
|
1512
|
+
}
|
|
1513
|
+
// ---- Custom sending domains (docs/email.md §2.4) ----
|
|
1514
|
+
/** The project's own sending domains, each with the records to publish. */
|
|
1515
|
+
listEmailDomains(org, name) {
|
|
1516
|
+
return this.json("GET", `${this.projectPath(org, name)}/email/domains`);
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Creates the provider identity and answers with the records to publish.
|
|
1520
|
+
* `publish` writes them into the zone when we host one covering the domain.
|
|
1521
|
+
*/
|
|
1522
|
+
addEmailDomain(org, name, domain, publish = false) {
|
|
1523
|
+
return this.json("POST", `${this.projectPath(org, name)}/email/domains`, { domain, publish });
|
|
1524
|
+
}
|
|
1525
|
+
/** Re-checks now. The background loop does the same once a minute while pending. */
|
|
1526
|
+
verifyEmailDomain(org, name, domain) {
|
|
1527
|
+
return this.json("POST", `${this.projectPath(org, name)}/email/domains/${encodeURIComponent(domain)}/verify`);
|
|
1528
|
+
}
|
|
1529
|
+
/** Deletes the identity and the row. Sending from it is refused from the next convergence. */
|
|
1530
|
+
removeEmailDomain(org, name, domain) {
|
|
1531
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/email/domains/${encodeURIComponent(domain)}`);
|
|
1532
|
+
}
|
|
1533
|
+
// ---- AI (docs/ai.md §6) ----
|
|
1534
|
+
/**
|
|
1535
|
+
* The model catalogue. **Being logged in is enough to see it** — what you can
|
|
1536
|
+
* buy is not an organization's secret, and this list is the price table.
|
|
1537
|
+
*
|
|
1538
|
+
* Prices are integer **micro-cents** per million tokens (1 µ¢ = 1e-8 USD).
|
|
1539
|
+
* Not letting the server pick the decimal place is the point — a small call
|
|
1540
|
+
* rounded to cents becomes 0.
|
|
1541
|
+
*/
|
|
1542
|
+
listAIModels() {
|
|
1543
|
+
return this.json("GET", "/v1/ai/models");
|
|
1544
|
+
}
|
|
1545
|
+
/** Grant, limits, the org balance, 24 h usage. The limits come back as a preview even without a grant. */
|
|
1546
|
+
getAI(org, name) {
|
|
1547
|
+
return this.json("GET", `${this.projectPath(org, name)}/ai`);
|
|
1548
|
+
}
|
|
1549
|
+
/** Turns it on. **Idempotent.** The deploy reads `"ai": true` and calls this. */
|
|
1550
|
+
grantAI(org, name) {
|
|
1551
|
+
return this.json("POST", `${this.projectPath(org, name)}/ai`);
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Lends the org's own Claude/Codex subscriptions to this project's
|
|
1555
|
+
* `anthropic/*` and `openai/*` calls (docs/studio-byos-ai.md §3.1).
|
|
1556
|
+
*
|
|
1557
|
+
* **Omitting a field leaves it as it was**, so turning lending on does not
|
|
1558
|
+
* clear a fallback that was already set. Admin only: the subscription that
|
|
1559
|
+
* carries the vendor-terms risk belongs to a person, not to the org.
|
|
1560
|
+
*/
|
|
1561
|
+
patchAI(org, name, body) {
|
|
1562
|
+
return this.json("PATCH", `${this.projectPath(org, name)}/ai`, body);
|
|
1563
|
+
}
|
|
1564
|
+
/** Turns it off. **The ledger and the balance are untouched** — the balance belongs to the org and the grant belongs to the project. */
|
|
1565
|
+
revokeAI(org, name) {
|
|
1566
|
+
return this.json("DELETE", `${this.projectPath(org, name)}/ai`);
|
|
1567
|
+
}
|
|
1568
|
+
/** The org's credit balance and its automatic top-up settings. The balance is in micro-cents and can be negative. */
|
|
1569
|
+
getAICredit(org) {
|
|
1570
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/ai/credit`);
|
|
1571
|
+
}
|
|
1572
|
+
/** One page of the org ledger. The cursor is `ledger_id` — cutting on time splits the same millisecond. */
|
|
1573
|
+
listAILedger(org, opts = {}) {
|
|
1574
|
+
const q = new URLSearchParams();
|
|
1575
|
+
if (opts.limit)
|
|
1576
|
+
q.set("limit", String(opts.limit));
|
|
1577
|
+
if (opts.before)
|
|
1578
|
+
q.set("before", String(opts.before));
|
|
1579
|
+
if (opts.kind)
|
|
1580
|
+
q.set("kind", opts.kind);
|
|
1581
|
+
if (opts.since)
|
|
1582
|
+
q.set("since", opts.since);
|
|
1583
|
+
const qs = q.toString();
|
|
1584
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/ai/ledger${qs ? "?" + qs : ""}`);
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* The credit top-up checkout. **A browser coming back is not evidence** — the
|
|
1588
|
+
* one thing that raises the balance is the `order.paid` webhook, and the
|
|
1589
|
+
* screen polls the balance after the success event.
|
|
1590
|
+
*/
|
|
1591
|
+
createAICreditCheckout(org, microCents, returnTo) {
|
|
1592
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/ai/credit/checkout`, { microCents, returnTo });
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Turns automatic top-up on or off. **Turning it on is explicit consent**
|
|
1596
|
+
* (docs/ai.md §3.5) — the screen shows the charging terms verbatim and calls
|
|
1597
|
+
* this only after the box is checked.
|
|
1598
|
+
*/
|
|
1599
|
+
setAIAutoTopup(org, body) {
|
|
1600
|
+
return this.json("PUT", `/v1/orgs/${encodeURIComponent(org)}/ai/autotopup`, body);
|
|
1601
|
+
}
|
|
1602
|
+
/** One page of the mail log (docs/email.md §6.1). Newest first, cursor-paged. */
|
|
1603
|
+
listMailLog(org, name, opts = {}) {
|
|
1604
|
+
const q = new URLSearchParams();
|
|
1605
|
+
if (opts.direction)
|
|
1606
|
+
q.set("direction", opts.direction);
|
|
1607
|
+
if (opts.cursor)
|
|
1608
|
+
q.set("cursor", opts.cursor);
|
|
1609
|
+
if (opts.limit)
|
|
1610
|
+
q.set("limit", String(opts.limit));
|
|
1611
|
+
const qs = q.toString();
|
|
1612
|
+
return this.json("GET", `${this.projectPath(org, name)}/email/log${qs ? "?" + qs : ""}`);
|
|
1613
|
+
}
|
|
1614
|
+
/** The metadata of one message. */
|
|
1615
|
+
getMailLog(org, name, mailId) {
|
|
1616
|
+
return this.json("GET", `${this.projectPath(org, name)}/email/log/${encodeURIComponent(mailId)}`);
|
|
1617
|
+
}
|
|
1618
|
+
/** The URL of the raw message — the screen uses it as a download link (.eml). */
|
|
1619
|
+
mailLogRawURL(org, name, mailId) {
|
|
1620
|
+
return new URL(`${this.projectPath(org, name)}/email/log/${encodeURIComponent(mailId)}/raw`, this.opts.baseUrl).toString();
|
|
1621
|
+
}
|
|
1622
|
+
/** The raw text. What the detail view draws the headers and body from. */
|
|
1623
|
+
getMailLogRaw(org, name, mailId) {
|
|
1624
|
+
return this.text("GET", `${this.projectPath(org, name)}/email/log/${encodeURIComponent(mailId)}/raw`);
|
|
1625
|
+
}
|
|
1626
|
+
// ---- End-user authentication (docs/auth.md §9) ----
|
|
1627
|
+
/**
|
|
1628
|
+
* Grant, settings, providers, hosts. **The signed-up users do not come** —
|
|
1629
|
+
* that table is inside the project DB (docs/auth.md §6) and only the worker's
|
|
1630
|
+
* `env.auth` sees it.
|
|
280
1631
|
*
|
|
281
|
-
* `providers`
|
|
282
|
-
*
|
|
1632
|
+
* `providers` carries the client id only. The client secret is sealed and
|
|
1633
|
+
* appears in no response.
|
|
283
1634
|
*/
|
|
284
1635
|
getAuth(org, name) {
|
|
285
1636
|
return this.json("GET", `${this.projectPath(org, name)}/auth`);
|
|
286
1637
|
}
|
|
287
1638
|
/**
|
|
288
|
-
*
|
|
1639
|
+
* Turns auth on (member). Idempotent.
|
|
289
1640
|
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
1641
|
+
* **With no database it is 409 `database_required`** — the user table lives
|
|
1642
|
+
* inside the project DB, so standing up the grant alone leaves no table the
|
|
1643
|
+
* moment the worker starts. The caller catches that code and points at the
|
|
1644
|
+
* `"database": true` declaration — the deploy never sees this code, because
|
|
1645
|
+
* its ordering rules it out.
|
|
293
1646
|
*/
|
|
294
1647
|
grantAuth(org, name) {
|
|
295
1648
|
return this.json("POST", `${this.projectPath(org, name)}/auth`);
|
|
296
1649
|
}
|
|
297
1650
|
/**
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
1651
|
+
* The app's end users, newest first (`runlot auth users`). Read-only, and read
|
|
1652
|
+
* from the project's own database — a parked or unreachable one answers 502/504.
|
|
1653
|
+
* Feed `cursor` back unchanged; its absence is the end.
|
|
1654
|
+
*/
|
|
1655
|
+
listAppUsers(org, name, opts = {}) {
|
|
1656
|
+
const q = new URLSearchParams();
|
|
1657
|
+
if (opts.search)
|
|
1658
|
+
q.set("search", opts.search);
|
|
1659
|
+
if (opts.cursor)
|
|
1660
|
+
q.set("cursor", opts.cursor);
|
|
1661
|
+
if (opts.limit)
|
|
1662
|
+
q.set("limit", String(opts.limit));
|
|
1663
|
+
const qs = q.toString();
|
|
1664
|
+
return this.json("GET", `${this.projectPath(org, name)}/auth/users${qs ? "?" + qs : ""}`);
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* One `env.ai.run` on the development lane: catalog models, the free plan's caps,
|
|
1668
|
+
* the org's credit, recorded as `lane = dev`. One JSON answer, no streaming.
|
|
1669
|
+
*/
|
|
1670
|
+
devAIRun(org, name, body) {
|
|
1671
|
+
return this.json("POST", `${this.projectPath(org, name)}/ai/dev/run`, body);
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Changes the settings (member). **A partial update** — only the fields given
|
|
1675
|
+
* change. Sending the whole thing on one switch means that when two people
|
|
1676
|
+
* touch the same card, the later save overwrites the earlier one. With no
|
|
1677
|
+
* grant it is 404 `not_granted`.
|
|
301
1678
|
*/
|
|
302
1679
|
updateAuthSettings(org, name, settings) {
|
|
303
1680
|
return this.json("PATCH", `${this.projectPath(org, name)}/auth`, { settings });
|
|
304
1681
|
}
|
|
305
1682
|
/**
|
|
306
|
-
*
|
|
307
|
-
*
|
|
1683
|
+
* Turns auth off (admin). **The signed-up users are not deleted** — the
|
|
1684
|
+
* `runlot_auth` tables stay in the project DB, and turning it back on lets the
|
|
1685
|
+
* same people log in unchanged.
|
|
308
1686
|
*/
|
|
309
1687
|
revokeAuth(org, name) {
|
|
310
1688
|
return this.json("DELETE", `${this.projectPath(org, name)}/auth`);
|
|
311
1689
|
}
|
|
312
1690
|
/**
|
|
313
|
-
*
|
|
1691
|
+
* Registers or replaces a social provider (admin). It is the same PUT, so it
|
|
1692
|
+
* is idempotent.
|
|
314
1693
|
*
|
|
315
|
-
* **`clientSecret`
|
|
316
|
-
* `https://<host>/__runlot/auth/callback/<provider>`
|
|
317
|
-
*
|
|
1694
|
+
* **`clientSecret` cannot be read back.** The callback URL is
|
|
1695
|
+
* `https://<host>/__runlot/auth/callback/<provider>` for each host, and the
|
|
1696
|
+
* list of hosts is in the response's `hosts`.
|
|
1697
|
+
*
|
|
1698
|
+
* `issuer` is the base URL of your own GitHub Enterprise Server installation,
|
|
1699
|
+
* and only `github` takes one. **This PUT is the whole row** — the same reason
|
|
1700
|
+
* `clientSecret` has to be sent every time — so an empty string clears it and
|
|
1701
|
+
* puts that provider back on github.com. The key is left out entirely when the
|
|
1702
|
+
* argument is omitted, so a caller that does not know about issuers sends the
|
|
1703
|
+
* body it always sent.
|
|
1704
|
+
*/
|
|
1705
|
+
setAuthProvider(org, name, provider, clientId, clientSecret, issuer) {
|
|
1706
|
+
return this.json("PUT", `${this.projectPath(org, name)}/auth/providers/${encodeURIComponent(provider)}`, { clientId, clientSecret, ...(issuer === undefined ? {} : { issuer }) });
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Turns on the Runlot provider (admin): "Continue with Runlot", with email,
|
|
1710
|
+
* Google and GitHub at Runlot behind it and nothing to register. 409
|
|
1711
|
+
* `runlot_unavailable` when this deployment has no sign-in broker.
|
|
1712
|
+
*/
|
|
1713
|
+
setRunlotAuthProvider(org, name) {
|
|
1714
|
+
return this.json("PUT", `${this.projectPath(org, name)}/auth/providers/runlot`, { kind: "runlot" });
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Registers or replaces a generic OIDC provider under a project-chosen id
|
|
1718
|
+
* (admin). The CP reads `<issuer>/.well-known/openid-configuration` when
|
|
1719
|
+
* saving; a failure is 400 `oidc_discovery_failed` quoting the provider.
|
|
1720
|
+
*/
|
|
1721
|
+
setOidcAuthProvider(org, name, id, body) {
|
|
1722
|
+
return this.json("PUT", `${this.projectPath(org, name)}/auth/providers/${encodeURIComponent(id)}`, { kind: "oidc", ...body });
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* The statements that create the `runlot_auth` schema (member). 404 when
|
|
1726
|
+
* login is not turned on for the project.
|
|
1727
|
+
*/
|
|
1728
|
+
getAuthSchema(org, name) {
|
|
1729
|
+
return this.json("GET", `${this.projectPath(org, name)}/auth/schema`);
|
|
1730
|
+
}
|
|
1731
|
+
/** The project's sign-in branding with defaults filled (docs/custom-sign-in.md §12.3). */
|
|
1732
|
+
getAuthBranding(org, name) {
|
|
1733
|
+
return this.getAuthBrandingAnswer(org, name).then((a) => a.brand);
|
|
1734
|
+
}
|
|
1735
|
+
/** The GET answer whole: the filled brand plus the methods the chooser would draw now. */
|
|
1736
|
+
getAuthBrandingAnswer(org, name) {
|
|
1737
|
+
return this.json("GET", `${this.projectPath(org, name)}/auth/branding`);
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Replaces the whole branding object (member). Validated server-side; a bad
|
|
1741
|
+
* field is 400 `invalid_branding` with `fields: [{path, message}]`.
|
|
318
1742
|
*/
|
|
319
|
-
|
|
320
|
-
return this.json("PUT", `${this.projectPath(org, name)}/auth/
|
|
1743
|
+
putAuthBranding(org, name, branding) {
|
|
1744
|
+
return this.json("PUT", `${this.projectPath(org, name)}/auth/branding`, branding)
|
|
1745
|
+
.then((a) => a.brand);
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* The URL of the rendered chooser with (draft) branding (§12.4). A page, not
|
|
1749
|
+
* JSON: the dashboard puts it in an iframe and the CLI opens it in a browser.
|
|
1750
|
+
* `draft` travels as base64url JSON.
|
|
1751
|
+
*/
|
|
1752
|
+
authBrandingPreviewUrl(org, name, opts = {}) {
|
|
1753
|
+
const u = new URL(`${this.projectPath(org, name)}/auth/branding/preview`, this.opts.baseUrl);
|
|
1754
|
+
if (opts.lang)
|
|
1755
|
+
u.searchParams.set("lang", opts.lang);
|
|
1756
|
+
if (opts.theme)
|
|
1757
|
+
u.searchParams.set("theme", opts.theme);
|
|
1758
|
+
if (opts.state)
|
|
1759
|
+
u.searchParams.set("state", opts.state);
|
|
1760
|
+
if (opts.draft)
|
|
1761
|
+
u.searchParams.set("draft", base64urlJson(opts.draft));
|
|
1762
|
+
return u.toString();
|
|
1763
|
+
}
|
|
1764
|
+
/** Sign-in funnel counters for the last `days` days (§9.4). No per-person data. */
|
|
1765
|
+
getAuthFunnel(org, name, days = 30) {
|
|
1766
|
+
return this.json("GET", `${this.projectPath(org, name)}/auth/funnel?days=${encodeURIComponent(String(days))}`);
|
|
321
1767
|
}
|
|
322
1768
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
1769
|
+
* Removes a provider (admin). Someone who signed up only through that provider
|
|
1770
|
+
* loses their way in, but the user row stays — register it again and they come
|
|
1771
|
+
* back to the same account.
|
|
325
1772
|
*/
|
|
326
1773
|
deleteAuthProvider(org, name, provider) {
|
|
327
1774
|
return this.json("DELETE", `${this.projectPath(org, name)}/auth/providers/${encodeURIComponent(provider)}`);
|
|
328
1775
|
}
|
|
329
|
-
// ----
|
|
1776
|
+
// ---- Deployment access control (docs/access.md §7) ----
|
|
330
1777
|
/**
|
|
331
|
-
*
|
|
332
|
-
*
|
|
1778
|
+
* Who can reach this deployment. **No values** — both the password and the
|
|
1779
|
+
* bypass secret live only as hashes, and what comes back here is the fact that
|
|
1780
|
+
* there is one: `hasPassword` and `hasBypass`.
|
|
333
1781
|
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
1782
|
+
* A project that has never set a policy is `mode: "public"` with no
|
|
1783
|
+
* `updatedAt`. The screen tells those two apart for the reason in §7 — a
|
|
1784
|
+
* sentence about the state instead of an empty state.
|
|
336
1785
|
*/
|
|
337
1786
|
getAccess(org, name) {
|
|
338
1787
|
return this.json("GET", `${this.projectPath(org, name)}/access`);
|
|
339
1788
|
}
|
|
340
1789
|
/**
|
|
341
|
-
*
|
|
342
|
-
*
|
|
1790
|
+
* Changes the policy (admin). Without a `password`, **the existing password
|
|
1791
|
+
* stays** — if a save that only changes the mode wiped the password, coming
|
|
1792
|
+
* back to that mode would mean setting it again.
|
|
343
1793
|
*/
|
|
344
1794
|
setAccess(org, name, mode, password) {
|
|
345
1795
|
return this.json("PUT", `${this.projectPath(org, name)}/access`, { mode, password });
|
|
346
1796
|
}
|
|
347
1797
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
1798
|
+
* Makes a bypass secret for automation (admin). **The value is in this answer
|
|
1799
|
+
* and nowhere else** — the screen shows it once on arrival and can never fetch
|
|
1800
|
+
* it again. Calling again kills the old value.
|
|
350
1801
|
*/
|
|
351
1802
|
newAccessBypass(org, name) {
|
|
352
1803
|
return this.json("POST", `${this.projectPath(org, name)}/access/bypass`);
|
|
353
1804
|
}
|
|
354
|
-
/**
|
|
1805
|
+
/** Removes the bypass (admin). Removing one that does not exist also succeeds. */
|
|
355
1806
|
revokeAccessBypass(org, name) {
|
|
356
1807
|
return this.json("DELETE", `${this.projectPath(org, name)}/access/bypass`);
|
|
357
1808
|
}
|
|
358
1809
|
/**
|
|
359
|
-
*
|
|
1810
|
+
* Gets a one-time address back into a protected deployment (docs/access.md §3.4-3).
|
|
360
1811
|
*
|
|
361
|
-
*
|
|
362
|
-
* (
|
|
363
|
-
*
|
|
1812
|
+
* It is **not** under the project path: all the calling screen knows is the
|
|
1813
|
+
* hostname (the original request went there), and the server derives the org
|
|
1814
|
+
* and project names from it. Doing `location.replace` with the `redirect` that
|
|
1815
|
+
* comes back is the caller's job.
|
|
364
1816
|
*/
|
|
365
1817
|
authorizeAccess(to, next) {
|
|
366
1818
|
return this.json("POST", "/v1/access/authorize", { to, next });
|
|
@@ -368,44 +1820,79 @@ export class Client {
|
|
|
368
1820
|
listMembers(org) {
|
|
369
1821
|
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/members`);
|
|
370
1822
|
}
|
|
371
|
-
/**
|
|
1823
|
+
/** This is not an invite — the user must already have logged in once (404 `user_not_found`). */
|
|
372
1824
|
addMember(org, provider, subject, role) {
|
|
373
1825
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/members`, { provider, subject, role });
|
|
374
1826
|
}
|
|
375
1827
|
setMemberRole(org, userId, role) {
|
|
376
1828
|
return this.json("PUT", `/v1/orgs/${encodeURIComponent(org)}/members/${encodeURIComponent(userId)}`, { role });
|
|
377
1829
|
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Removing someone else is admin; **removing yourself is leaving**, which
|
|
1832
|
+
* anyone can do (docs/members.md). The last admin can do neither
|
|
1833
|
+
* (409 `last_admin`).
|
|
1834
|
+
*/
|
|
378
1835
|
removeMember(org, userId) {
|
|
379
1836
|
return this.json("DELETE", `/v1/orgs/${encodeURIComponent(org)}/members/${encodeURIComponent(userId)}`);
|
|
380
1837
|
}
|
|
1838
|
+
// --- Invites (docs/members.md) ---
|
|
1839
|
+
/** Pending and expired invites (admin). Accepted and revoked ones are history, so they do not come. */
|
|
1840
|
+
listInvites(org) {
|
|
1841
|
+
return this.json("GET", `/v1/orgs/${encodeURIComponent(org)}/invites`);
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Invites by email (admin). **Calling again with the same address is a
|
|
1845
|
+
* resend** — the same row is updated rather than a new one created, and the
|
|
1846
|
+
* server gives 200 instead of 201.
|
|
1847
|
+
*/
|
|
1848
|
+
createInvite(org, email, role) {
|
|
1849
|
+
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/invites`, { email, role });
|
|
1850
|
+
}
|
|
1851
|
+
/** Revokes an invite (admin). Mail that has not gone out yet does not go out. */
|
|
1852
|
+
revokeInvite(org, inviteId) {
|
|
1853
|
+
return this.json("DELETE", `/v1/orgs/${encodeURIComponent(org)}/invites/${encodeURIComponent(inviteId)}`);
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* A preview of the invite. **No session needed** — whoever got the link has
|
|
1857
|
+
* not logged in yet, and they need to know what they are accepting before
|
|
1858
|
+
* they do.
|
|
1859
|
+
*/
|
|
1860
|
+
getInvite(token) {
|
|
1861
|
+
return this.json("GET", `/v1/invites/${encodeURIComponent(token)}`);
|
|
1862
|
+
}
|
|
1863
|
+
/** Accepts (login required). If they are already a member the role does not change. */
|
|
1864
|
+
acceptInvite(token) {
|
|
1865
|
+
return this.json("POST", `/v1/invites/${encodeURIComponent(token)}/accept`);
|
|
1866
|
+
}
|
|
381
1867
|
// --- domains: D1 hostnames methods ---
|
|
382
|
-
/**
|
|
1868
|
+
/** The default hostname and the custom domains come together (viewer). */
|
|
383
1869
|
listHostnames(org, name) {
|
|
384
1870
|
return this.json("GET", `${this.projectPath(org, name)}/hostnames`);
|
|
385
1871
|
}
|
|
386
1872
|
/**
|
|
387
|
-
*
|
|
1873
|
+
* Attaches a custom domain (member).
|
|
388
1874
|
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
1875
|
+
* Idempotent — sending the same name again returns the existing row
|
|
1876
|
+
* unchanged. The response's `verify` is the CNAME and TXT the customer has to
|
|
1877
|
+
* add.
|
|
391
1878
|
*/
|
|
392
|
-
addHostname(org, name, hostname) {
|
|
393
|
-
return this.json("POST", `${this.projectPath(org, name)}/hostnames`, { hostname });
|
|
1879
|
+
addHostname(org, name, hostname, role) {
|
|
1880
|
+
return this.json("POST", `${this.projectPath(org, name)}/hostnames`, role === undefined ? { hostname } : { hostname, role });
|
|
394
1881
|
}
|
|
395
|
-
/**
|
|
1882
|
+
/** Runs the same check the background verifier makes, right now (member). */
|
|
396
1883
|
verifyHostname(org, name, host) {
|
|
397
1884
|
return this.json("POST", `${this.projectPath(org, name)}/hostnames/${encodeURIComponent(host)}/verify`);
|
|
398
1885
|
}
|
|
399
|
-
/**
|
|
1886
|
+
/** Detaches a custom domain (member). The default hostname gives a 400. */
|
|
400
1887
|
deleteHostname(org, name, host) {
|
|
401
1888
|
return this.json("DELETE", `${this.projectPath(org, name)}/hostnames/${encodeURIComponent(host)}`);
|
|
402
1889
|
}
|
|
403
1890
|
// --- domains: D2 dns methods ---
|
|
404
|
-
/**
|
|
1891
|
+
/** The organization's zones. No `rrsets` — those ride only on a single-zone lookup. */
|
|
405
1892
|
listZones(org) {
|
|
406
1893
|
return this.json("GET", this.dnsPath(org));
|
|
407
1894
|
}
|
|
408
|
-
/**
|
|
1895
|
+
/** Idempotent. A zone that already exists comes back unchanged. */
|
|
409
1896
|
createZone(org, name) {
|
|
410
1897
|
return this.json("POST", this.dnsPath(org), { name });
|
|
411
1898
|
}
|
|
@@ -416,8 +1903,9 @@ export class Client {
|
|
|
416
1903
|
return this.json("DELETE", `${this.dnsPath(org)}/${encodeURIComponent(zone)}`);
|
|
417
1904
|
}
|
|
418
1905
|
/**
|
|
419
|
-
*
|
|
420
|
-
*
|
|
1906
|
+
* Replaces one rrset **whole**. `records` is the complete new set for that
|
|
1907
|
+
* (name, type), so adding a single value means sending the current ones with
|
|
1908
|
+
* it.
|
|
421
1909
|
*/
|
|
422
1910
|
putRRset(org, zone, name, type, ttl, records) {
|
|
423
1911
|
return this.json("PUT", this.rrsetPath(org, zone, name, type), { ttl, records });
|
|
@@ -433,39 +1921,40 @@ export class Client {
|
|
|
433
1921
|
setZoneDS(org, zone, ds) {
|
|
434
1922
|
return this.json("PUT", `${this.dnsPath(org)}/${encodeURIComponent(zone)}/dnssec/ds`, { ds });
|
|
435
1923
|
}
|
|
436
|
-
/**
|
|
1924
|
+
/** The shared prefix of the DNS surface. */
|
|
437
1925
|
dnsPath(org) {
|
|
438
1926
|
return `/v1/orgs/${encodeURIComponent(org)}/dns/zones`;
|
|
439
1927
|
}
|
|
440
|
-
/** `@`
|
|
1928
|
+
/** Both `@` and `*` arrive as a name. Keeps the same string out of four places. */
|
|
441
1929
|
rrsetPath(org, zone, name, type) {
|
|
442
1930
|
return (`${this.dnsPath(org)}/${encodeURIComponent(zone)}` +
|
|
443
1931
|
`/rrsets/${encodeURIComponent(name)}/${encodeURIComponent(type)}`);
|
|
444
1932
|
}
|
|
445
1933
|
// --- domains: D3 domains methods ---
|
|
446
1934
|
/**
|
|
447
|
-
*
|
|
1935
|
+
* Looks a name up (member or above).
|
|
448
1936
|
*
|
|
449
|
-
* `priceCents`
|
|
450
|
-
*
|
|
451
|
-
*
|
|
1937
|
+
* `priceCents` is the first year of registration; `renewalCents` is one year
|
|
1938
|
+
* of renewal. They are separate because a first-year discount is common —
|
|
1939
|
+
* folded into one, the screen cannot say "buy it for $1, then $15 next year".
|
|
452
1940
|
*/
|
|
453
1941
|
checkDomains(org, names) {
|
|
454
1942
|
return this.json("POST", `${this.domainsPath(org)}/check`, { names });
|
|
455
1943
|
}
|
|
456
1944
|
/**
|
|
457
|
-
*
|
|
1945
|
+
* Buys a domain (admin — this spends money).
|
|
458
1946
|
*
|
|
459
|
-
* **ICANN
|
|
460
|
-
*
|
|
1947
|
+
* **The ICANN verification mail goes to `contact.email`.** The screen has to
|
|
1948
|
+
* say so before the purchase (docs/domains.md §5.5).
|
|
461
1949
|
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
1950
|
+
* Sending the same request again is safe — a finished domain comes back
|
|
1951
|
+
* unchanged, and a purchase that stopped part way resumes from where it
|
|
1952
|
+
* stopped.
|
|
464
1953
|
*/
|
|
465
1954
|
purchaseDomain(org, body) {
|
|
466
1955
|
return this.json("POST", this.domainsPath(org), body);
|
|
467
1956
|
}
|
|
468
|
-
/**
|
|
1957
|
+
/** Imports a domain you already own (admin). Creates the zone only; the registrar is not called. */
|
|
469
1958
|
importDomain(org, name) {
|
|
470
1959
|
return this.json("POST", `${this.domainsPath(org)}/import`, { name });
|
|
471
1960
|
}
|
|
@@ -479,11 +1968,11 @@ export class Client {
|
|
|
479
1968
|
return this.json("POST", `${this.domainPath(org, name)}/renew`, { years });
|
|
480
1969
|
}
|
|
481
1970
|
/**
|
|
482
|
-
*
|
|
1971
|
+
* Changes only the **intent** to auto-renew.
|
|
483
1972
|
*
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
1973
|
+
* Auto-renew at the registrar stays on — a domain is an asset you lose if you
|
|
1974
|
+
* are a day late, so we renew first and bill afterwards. The screen has to say
|
|
1975
|
+
* this alongside.
|
|
487
1976
|
*/
|
|
488
1977
|
setDomainAutoRenew(org, name, enabled) {
|
|
489
1978
|
return this.json("POST", `${this.domainPath(org, name)}/auto-renew`, { enabled });
|
|
@@ -491,31 +1980,141 @@ export class Client {
|
|
|
491
1980
|
setDomainLock(org, name, locked) {
|
|
492
1981
|
return this.json("POST", `${this.domainPath(org, name)}/lock`, { locked });
|
|
493
1982
|
}
|
|
494
|
-
/**
|
|
1983
|
+
/** The transfer auth code. The audit records that one was issued and **not the code itself**. */
|
|
495
1984
|
domainAuthCode(org, name) {
|
|
496
1985
|
return this.json("POST", `${this.domainPath(org, name)}/auth-code`);
|
|
497
1986
|
}
|
|
498
|
-
/**
|
|
1987
|
+
/** Re-reads from the registrar right now (member). */
|
|
499
1988
|
syncDomain(org, name) {
|
|
500
1989
|
return this.json("POST", `${this.domainPath(org, name)}/sync`);
|
|
501
1990
|
}
|
|
502
|
-
/**
|
|
1991
|
+
/** The shared prefix of the domain surface. Keeps the same string out of ten places. */
|
|
503
1992
|
domainsPath(org) {
|
|
504
1993
|
return `/v1/orgs/${encodeURIComponent(org)}/domains`;
|
|
505
1994
|
}
|
|
506
1995
|
domainPath(org, name) {
|
|
507
1996
|
return `${this.domainsPath(org)}/${encodeURIComponent(name)}`;
|
|
508
1997
|
}
|
|
509
|
-
/**
|
|
1998
|
+
/** The shared prefix of the project surface. */
|
|
510
1999
|
projectPath(org, name) {
|
|
511
2000
|
return `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}`;
|
|
512
2001
|
}
|
|
513
|
-
/**
|
|
2002
|
+
/** The shared prefix of the database surface. Keeps the same string out of five places. */
|
|
514
2003
|
dbPath(org, name) {
|
|
515
2004
|
return `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/database`;
|
|
516
2005
|
}
|
|
2006
|
+
// ---- Self-hosted Git (docs/git-hosting.md §12.1, §19) ----
|
|
2007
|
+
//
|
|
2008
|
+
// **git does the repository work and we handle only the metadata.** That is
|
|
2009
|
+
// why there is nothing like `pushRepo` here — an API that wraps git either
|
|
2010
|
+
// reimplements every one of git's flags or boxes the user in.
|
|
2011
|
+
//
|
|
2012
|
+
// A repository **belongs to a project**. That is why every method starts with
|
|
2013
|
+
// (org, project) — the same shape as the database and the secrets.
|
|
2014
|
+
listRepos(org, project) {
|
|
2015
|
+
return this.json("GET", this.repoPath(org, project));
|
|
2016
|
+
}
|
|
2017
|
+
createRepo(org, project, body) {
|
|
2018
|
+
return this.json("POST", this.repoPath(org, project), body);
|
|
2019
|
+
}
|
|
2020
|
+
getRepo(org, project, name) {
|
|
2021
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}`);
|
|
2022
|
+
}
|
|
2023
|
+
updateRepo(org, project, name, body) {
|
|
2024
|
+
return this.json("PATCH", `${this.repoPath(org, project)}/${encodeURIComponent(name)}`, body);
|
|
2025
|
+
}
|
|
2026
|
+
deleteRepo(org, project, name) {
|
|
2027
|
+
return this.json("DELETE", `${this.repoPath(org, project)}/${encodeURIComponent(name)}`);
|
|
2028
|
+
}
|
|
2029
|
+
/** The ref history. The lead for recovering a commit lost to a force-push is here. */
|
|
2030
|
+
listRefUpdates(org, project, name) {
|
|
2031
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/ref-updates`);
|
|
2032
|
+
}
|
|
2033
|
+
// Push-to-deploy (docs/code/push-to-deploy). The hook hangs off the
|
|
2034
|
+
// repository and the builds off the **project**, because a build outlives the
|
|
2035
|
+
// repository it came from.
|
|
2036
|
+
getDeployHook(org, project, name) {
|
|
2037
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy-hook`);
|
|
2038
|
+
}
|
|
2039
|
+
setDeployHook(org, project, name, body) {
|
|
2040
|
+
return this.json("PUT", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy-hook`, body);
|
|
2041
|
+
}
|
|
2042
|
+
deleteDeployHook(org, project, name) {
|
|
2043
|
+
return this.json("DELETE", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy-hook`);
|
|
2044
|
+
}
|
|
2045
|
+
/** Build a commit without pushing. Omit `commitSha` for the hooked branch's tip. */
|
|
2046
|
+
deployRepoNow(org, project, name, commitSha) {
|
|
2047
|
+
return this.json("POST", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/deploy`, commitSha === undefined ? {} : { commitSha });
|
|
2048
|
+
}
|
|
2049
|
+
listBuilds(org, project, limit) {
|
|
2050
|
+
const q = limit === undefined ? "" : `?limit=${limit}`;
|
|
2051
|
+
return this.json("GET", `${this.projectPath(org, project)}/builds${q}`);
|
|
2052
|
+
}
|
|
2053
|
+
getBuild(org, project, buildId) {
|
|
2054
|
+
return this.json("GET", `${this.projectPath(org, project)}/builds/${encodeURIComponent(buildId)}`);
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* A build's output. It comes back as **text**, not JSON — see the endpoint's
|
|
2058
|
+
* description. `json()` would try to parse it and fail on the first line.
|
|
2059
|
+
*/
|
|
2060
|
+
getBuildLog(org, project, buildId) {
|
|
2061
|
+
return this.text("GET", `${this.projectPath(org, project)}/builds/${encodeURIComponent(buildId)}/log`);
|
|
2062
|
+
}
|
|
2063
|
+
cancelBuild(org, project, buildId) {
|
|
2064
|
+
return this.json("POST", `${this.projectPath(org, project)}/builds/${encodeURIComponent(buildId)}/cancel`);
|
|
2065
|
+
}
|
|
2066
|
+
listSSHKeys() {
|
|
2067
|
+
return this.json("GET", "/v1/me/ssh-keys");
|
|
2068
|
+
}
|
|
2069
|
+
addSSHKey(publicKey, name) {
|
|
2070
|
+
return this.json("POST", "/v1/me/ssh-keys", { publicKey, name });
|
|
2071
|
+
}
|
|
2072
|
+
deleteSSHKey(keyId) {
|
|
2073
|
+
return this.json("DELETE", `/v1/me/ssh-keys/${encodeURIComponent(keyId)}`);
|
|
2074
|
+
}
|
|
2075
|
+
listAccessTokens() {
|
|
2076
|
+
return this.json("GET", "/v1/me/tokens");
|
|
2077
|
+
}
|
|
2078
|
+
/** The plaintext is carried in this response **once** and never again. */
|
|
2079
|
+
createAccessToken(body) {
|
|
2080
|
+
return this.json("POST", "/v1/me/tokens", body);
|
|
2081
|
+
}
|
|
2082
|
+
revokeAccessToken(tokenId) {
|
|
2083
|
+
return this.json("DELETE", `/v1/me/tokens/${encodeURIComponent(tokenId)}`);
|
|
2084
|
+
}
|
|
2085
|
+
// ---- Browsing (docs/git-hosting.md §12.2) ----
|
|
2086
|
+
getRepoRefs(org, project, name) {
|
|
2087
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/refs`);
|
|
2088
|
+
}
|
|
2089
|
+
getRepoTree(org, project, name, ref = "", path = "") {
|
|
2090
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/tree${gitQuery(ref, path)}`);
|
|
2091
|
+
}
|
|
2092
|
+
getRepoBlob(org, project, name, ref = "", path = "") {
|
|
2093
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/blob${gitQuery(ref, path)}`);
|
|
2094
|
+
}
|
|
2095
|
+
getRepoCommits(org, project, name, ref = "", limit) {
|
|
2096
|
+
const q = new URLSearchParams();
|
|
2097
|
+
if (ref !== "")
|
|
2098
|
+
q.set("ref", ref);
|
|
2099
|
+
if (limit !== undefined)
|
|
2100
|
+
q.set("limit", String(limit));
|
|
2101
|
+
const qs = q.size > 0 ? `?${q.toString()}` : "";
|
|
2102
|
+
return this.json("GET", `${this.repoPath(org, project)}/${encodeURIComponent(name)}/commits${qs}`);
|
|
2103
|
+
}
|
|
2104
|
+
/** The shared prefix of the repository surface. It sits under the project (§19). */
|
|
2105
|
+
repoPath(org, project) {
|
|
2106
|
+
return `${this.projectPath(org, project)}/repos`;
|
|
2107
|
+
}
|
|
517
2108
|
rollback(org, name, version) {
|
|
518
2109
|
return this.json("POST", `/v1/orgs/${encodeURIComponent(org)}/projects/${encodeURIComponent(name)}/rollback`, { version });
|
|
519
2110
|
}
|
|
520
2111
|
}
|
|
2112
|
+
/** A query string from the defined, non-empty options. */
|
|
2113
|
+
function obsQS(opts) {
|
|
2114
|
+
const q = new URLSearchParams();
|
|
2115
|
+
for (const [k, v] of Object.entries(opts))
|
|
2116
|
+
if (v)
|
|
2117
|
+
q.set(k, v);
|
|
2118
|
+
return q.size ? `?${q}` : "";
|
|
2119
|
+
}
|
|
521
2120
|
//# sourceMappingURL=index.js.map
|