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