primitive-admin 1.2.0-alpha.15 → 1.2.0-alpha.16
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/README.md +84 -0
- package/dist/src/commands/admins.js +1 -0
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/analytics.js +2 -4
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps-transitions.d.ts +39 -0
- package/dist/src/commands/apps-transitions.js +198 -0
- package/dist/src/commands/apps-transitions.js.map +1 -0
- package/dist/src/commands/apps.d.ts +11 -0
- package/dist/src/commands/apps.js +50 -5
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth-sessions.js +2 -0
- package/dist/src/commands/auth-sessions.js.map +1 -1
- package/dist/src/commands/auth.js +5 -0
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.js +2 -0
- package/dist/src/commands/blob-buckets.js.map +1 -1
- package/dist/src/commands/collections.js +2 -13
- package/dist/src/commands/collections.js.map +1 -1
- package/dist/src/commands/comparisons.js +2 -0
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/config.js +2 -0
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/connections.js +2 -2
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/db3.js +79 -21
- package/dist/src/commands/db3.js.map +1 -1
- package/dist/src/commands/email-templates.js +2 -0
- package/dist/src/commands/email-templates.js.map +1 -1
- package/dist/src/commands/env.js +2 -0
- package/dist/src/commands/env.js.map +1 -1
- package/dist/src/commands/functions.js +45 -3
- package/dist/src/commands/functions.js.map +1 -1
- package/dist/src/commands/groups.js +2 -0
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.js +2 -0
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/hosting.d.ts +8 -0
- package/dist/src/commands/hosting.js +346 -0
- package/dist/src/commands/hosting.js.map +1 -0
- package/dist/src/commands/init.js +2 -0
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.js +2 -0
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/locks.js +2 -0
- package/dist/src/commands/locks.js.map +1 -1
- package/dist/src/commands/metadata-category-configs.js +1 -1
- package/dist/src/commands/metadata-category-configs.js.map +1 -1
- package/dist/src/commands/metadata.js +2 -2
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/prompts.js +2 -0
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rate-counters.d.ts +19 -0
- package/dist/src/commands/rate-counters.js +104 -0
- package/dist/src/commands/rate-counters.js.map +1 -0
- package/dist/src/commands/rule-sets.js +2 -2
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/schemas.js +4 -4
- package/dist/src/commands/schemas.js.map +1 -1
- package/dist/src/commands/secrets.js +2 -0
- package/dist/src/commands/secrets.js.map +1 -1
- package/dist/src/commands/skill.js +2 -0
- package/dist/src/commands/skill.js.map +1 -1
- package/dist/src/commands/sync.d.ts +101 -2
- package/dist/src/commands/sync.js +391 -62
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.js +2 -0
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/transitions.d.ts +54 -0
- package/dist/src/commands/transitions.js +418 -0
- package/dist/src/commands/transitions.js.map +1 -0
- package/dist/src/commands/usage.d.ts +18 -0
- package/dist/src/commands/usage.js +343 -0
- package/dist/src/commands/usage.js.map +1 -0
- package/dist/src/commands/user-properties.js +2 -2
- package/dist/src/commands/user-properties.js.map +1 -1
- package/dist/src/commands/users.js +28 -29
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.js +2 -0
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/commands/waitlist.js +2 -2
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +606 -2
- package/dist/src/lib/api-client.js +157 -6
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
- package/dist/src/lib/app-settings-descriptor.js +6 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/auth-flow.d.ts +33 -0
- package/dist/src/lib/auth-flow.js +404 -13
- package/dist/src/lib/auth-flow.js.map +1 -1
- package/dist/src/lib/cli-manifest.d.ts +5 -4
- package/dist/src/lib/cli-manifest.js.map +1 -1
- package/dist/src/lib/command-groups.d.ts +30 -0
- package/dist/src/lib/command-groups.js +109 -0
- package/dist/src/lib/command-groups.js.map +1 -0
- package/dist/src/lib/command-status.d.ts +56 -19
- package/dist/src/lib/command-status.js +101 -19
- package/dist/src/lib/command-status.js.map +1 -1
- package/dist/src/lib/config-object-descriptor.js +0 -1
- package/dist/src/lib/config-object-descriptor.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +7 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js +3 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
- package/dist/src/lib/db-type-records.d.ts +12 -1
- package/dist/src/lib/db-type-records.js +8 -3
- package/dist/src/lib/db-type-records.js.map +1 -1
- package/dist/src/lib/db3-export.js +2 -2
- package/dist/src/lib/db3-export.js.map +1 -1
- package/dist/src/lib/db3-index-output.d.ts +26 -3
- package/dist/src/lib/db3-index-output.js +48 -12
- package/dist/src/lib/db3-index-output.js.map +1 -1
- package/dist/src/lib/db3-type-models.d.ts +11 -1
- package/dist/src/lib/db3-type-models.js +22 -2
- package/dist/src/lib/db3-type-models.js.map +1 -1
- package/dist/src/lib/function-authorize-view.d.ts +12 -0
- package/dist/src/lib/function-authorize-view.js +34 -0
- package/dist/src/lib/function-authorize-view.js.map +1 -1
- package/dist/src/lib/function-collect.d.ts +13 -0
- package/dist/src/lib/function-collect.js +37 -7
- package/dist/src/lib/function-collect.js.map +1 -1
- package/dist/src/lib/function-db-types.d.ts +14 -8
- package/dist/src/lib/function-db-types.js +56 -21
- package/dist/src/lib/function-db-types.js.map +1 -1
- package/dist/src/lib/function-lint.d.ts +24 -1
- package/dist/src/lib/function-lint.js +123 -1
- package/dist/src/lib/function-lint.js.map +1 -1
- package/dist/src/lib/function-schema-codegen.d.ts +31 -7
- package/dist/src/lib/function-schema-codegen.js +131 -36
- package/dist/src/lib/function-schema-codegen.js.map +1 -1
- package/dist/src/lib/function-sync.js +9 -1
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/generated-command-status.d.ts +6 -0
- package/dist/src/lib/generated-command-status.js +469 -0
- package/dist/src/lib/generated-command-status.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +28 -3
- package/dist/src/lib/generated-config-surfaces.js +91 -16
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/hosting-build.d.ts +97 -0
- package/dist/src/lib/hosting-build.js +204 -0
- package/dist/src/lib/hosting-build.js.map +1 -0
- package/dist/src/lib/hosting-client.d.ts +167 -0
- package/dist/src/lib/hosting-client.js +340 -0
- package/dist/src/lib/hosting-client.js.map +1 -0
- package/dist/src/lib/hosting-environments.d.ts +32 -0
- package/dist/src/lib/hosting-environments.js +74 -0
- package/dist/src/lib/hosting-environments.js.map +1 -0
- package/dist/src/lib/hosting-errors.d.ts +30 -0
- package/dist/src/lib/hosting-errors.js +43 -0
- package/dist/src/lib/hosting-errors.js.map +1 -0
- package/dist/src/lib/hosting-token.d.ts +46 -0
- package/dist/src/lib/hosting-token.js +60 -0
- package/dist/src/lib/hosting-token.js.map +1 -0
- package/dist/src/lib/hosting-wait.d.ts +42 -0
- package/dist/src/lib/hosting-wait.js +84 -0
- package/dist/src/lib/hosting-wait.js.map +1 -0
- package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
- package/dist/src/lib/hosting-wfp-upload.js +149 -0
- package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
- package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
- package/dist/src/lib/invoker-shared-enums.js +98 -0
- package/dist/src/lib/invoker-shared-enums.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +4 -1
- package/dist/src/lib/log-inspection.js.map +1 -1
- package/dist/src/lib/primitive-declaration.d.ts +32 -1
- package/dist/src/lib/primitive-declaration.js +153 -19
- package/dist/src/lib/primitive-declaration.js.map +1 -1
- package/dist/src/lib/prompt-schema-codegen.d.ts +1 -1
- package/dist/src/lib/prompt-schema-codegen.js +31 -19
- package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
- package/dist/src/lib/prompt-schema-refs.d.ts +9 -0
- package/dist/src/lib/prompt-schema-refs.js +28 -2
- package/dist/src/lib/prompt-schema-refs.js.map +1 -1
- package/dist/src/lib/register-commands.d.ts +14 -6
- package/dist/src/lib/register-commands.js +19 -83
- package/dist/src/lib/register-commands.js.map +1 -1
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js +10 -4
- package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -1
- package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +11 -2
- package/dist/src/lib/schema-codegen/generated-field-grammar.js +22 -4
- package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -1
- package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
- package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
- package/dist/src/lib/schema-codegen/valuesLists.d.ts +15 -2
- package/dist/src/lib/schema-codegen/valuesLists.js +19 -3
- package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -1
- package/dist/src/lib/swift-codegen/functionGenerator.js +4 -3
- package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/sharedGenerator.js +50 -5
- package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -1
- package/dist/src/lib/sync-resource-types.js +0 -3
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/toml-database-config.js +3 -1
- package/dist/src/lib/toml-database-config.js.map +1 -1
- package/dist/src/lib/transition-warnings.d.ts +21 -0
- package/dist/src/lib/transition-warnings.js +49 -0
- package/dist/src/lib/transition-warnings.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { loadCredentials, saveCredentials, isTokenExpiringSoon, } from "./config.js";
|
|
2
|
+
import { reportTransitionWarnings } from "./transition-warnings.js";
|
|
2
3
|
import { getCurrentEnvNameSafe, getProjectConfig } from "./env-resolver.js";
|
|
3
4
|
import { pinRefusalHint } from "./pin-refusal-hint.js";
|
|
4
5
|
import { fetchWithTLS } from "./fetch.js";
|
|
@@ -261,10 +262,16 @@ export class ApiClient {
|
|
|
261
262
|
// one. A retry refused 401 means the step-up is gone (revoked or expired
|
|
262
263
|
// early): drop it and show the original refusal. The retry's own refusal
|
|
263
264
|
// (say, a step-up without the scope this command needs) is shown as it is.
|
|
265
|
+
// #5822 — a successful write's platform transition warnings are printed.
|
|
266
|
+
const answered = (body) => {
|
|
267
|
+
const parsed = body ? JSON.parse(body) : null;
|
|
268
|
+
reportTransitionWarnings(options.method, parsed);
|
|
269
|
+
return parsed;
|
|
270
|
+
};
|
|
264
271
|
if (response.status === 403 && this.stepUpApplies(response, text, path)) {
|
|
265
272
|
const retried = await send(credentials.stepUp.accessToken);
|
|
266
273
|
if (retried.response.ok) {
|
|
267
|
-
return
|
|
274
|
+
return answered(retried.text);
|
|
268
275
|
}
|
|
269
276
|
if (retried.response.status === 401) {
|
|
270
277
|
this.dropStepUp();
|
|
@@ -276,7 +283,7 @@ export class ApiClient {
|
|
|
276
283
|
if (!response.ok) {
|
|
277
284
|
throw this.responseError(response, text, path);
|
|
278
285
|
}
|
|
279
|
-
return
|
|
286
|
+
return answered(text);
|
|
280
287
|
}
|
|
281
288
|
/**
|
|
282
289
|
* Whether a 403 should be retried with the stored step-up: it names
|
|
@@ -366,6 +373,60 @@ export class ApiClient {
|
|
|
366
373
|
async exchangeToken(body) {
|
|
367
374
|
return this.post("/admin/api/auth/token", body);
|
|
368
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* #5787 — what `primitive hosting` may send for the current credentials:
|
|
378
|
+
* a CI token as it is (it cannot derive), or else nothing until a token is
|
|
379
|
+
* derived; and whether an unexpired step-up that may reach `appId` is
|
|
380
|
+
* stored. Throws the usual not-logged-in refusal.
|
|
381
|
+
*/
|
|
382
|
+
async hostingCredentials(appId) {
|
|
383
|
+
const credentials = await this.ensureAuthenticated();
|
|
384
|
+
const stepUp = credentials.stepUp;
|
|
385
|
+
const usable = Boolean(stepUp?.accessToken) &&
|
|
386
|
+
new Date(stepUp.expiresAt).getTime() > Date.now() &&
|
|
387
|
+
(stepUp.apps.length === 0 || stepUp.apps.includes(appId));
|
|
388
|
+
// An opaque CI token (`primadm_…`, #3890) is no JWT and cannot derive.
|
|
389
|
+
const ci = credentials.accessToken.startsWith("primadm_");
|
|
390
|
+
return { ciToken: ci ? credentials.accessToken : null, stepUp: usable };
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* #5787 — `POST /admin/api/auth/token` for hosting: a `write`-only token of
|
|
394
|
+
* 15 minutes derived from the login, or from the stored step-up on a
|
|
395
|
+
* protected app, pinned to `appId` when that bearer is pinned and unpinned
|
|
396
|
+
* otherwise. Sent with exactly that bearer and never retried with another.
|
|
397
|
+
*/
|
|
398
|
+
async deriveHostingToken(input) {
|
|
399
|
+
const credentials = await this.ensureAuthenticated();
|
|
400
|
+
const bearer = input.from === "step-up" ? credentials.stepUp?.accessToken : credentials.accessToken;
|
|
401
|
+
if (!bearer)
|
|
402
|
+
throw new ApiError("No step-up is stored for this login.", 403, "PROTECTED_APP_STEP_UP_REQUIRED");
|
|
403
|
+
let pins;
|
|
404
|
+
try {
|
|
405
|
+
pins = JSON.parse(Buffer.from(bearer.split(".")[1] ?? "", "base64url").toString("utf-8"))?.apps;
|
|
406
|
+
}
|
|
407
|
+
catch {
|
|
408
|
+
pins = undefined;
|
|
409
|
+
}
|
|
410
|
+
const pinned = Array.isArray(pins) && pins.length > 0;
|
|
411
|
+
const path = "/admin/api/auth/token";
|
|
412
|
+
const headers = {
|
|
413
|
+
Authorization: `Bearer ${bearer}`,
|
|
414
|
+
"Content-Type": "application/json",
|
|
415
|
+
[CLI_VERSION_HEADER]: (cliVersion ??= cliVersionHeaderValue()),
|
|
416
|
+
};
|
|
417
|
+
if (credentials.globalAdminAppId)
|
|
418
|
+
headers["X-Global-Admin-App-Id"] = credentials.globalAdminAppId;
|
|
419
|
+
const response = await fetchWithTLS(`${credentials.serverUrl}${path}`, {
|
|
420
|
+
method: "POST",
|
|
421
|
+
headers,
|
|
422
|
+
body: JSON.stringify({ scope: ["write"], ...(pinned ? { apps: [input.appId] } : {}), ttl: "15m" }),
|
|
423
|
+
});
|
|
424
|
+
const text = await response.text();
|
|
425
|
+
if (!response.ok)
|
|
426
|
+
throw this.responseError(response, text, path);
|
|
427
|
+
const derived = JSON.parse(text);
|
|
428
|
+
return { accessToken: derived.accessToken, expiresAt: derived.expiresAt };
|
|
429
|
+
}
|
|
369
430
|
// Helper for GET requests with query params
|
|
370
431
|
async get(path, params) {
|
|
371
432
|
let fullPath = path;
|
|
@@ -604,6 +665,10 @@ export class ApiClient {
|
|
|
604
665
|
async getUserWalk(appId, runId) {
|
|
605
666
|
return this.get(`/admin/api/apps/${appId}/users/walks/${encodeURIComponent(runId)}`);
|
|
606
667
|
}
|
|
668
|
+
/** A rate counter's state by key (`GET /admin/api/apps/:appId/rate-counters/:key`). */
|
|
669
|
+
async getRateCounter(appId, key) {
|
|
670
|
+
return this.get(`/admin/api/apps/${appId}/rate-counters/${encodeURIComponent(key)}`);
|
|
671
|
+
}
|
|
607
672
|
/** Stop a users walk (`POST /admin/api/apps/:appId/users/walks/:runId/terminate`); batches in flight finish. */
|
|
608
673
|
async terminateUserWalk(appId, runId) {
|
|
609
674
|
return this.post(`/admin/api/apps/${appId}/users/walks/${encodeURIComponent(runId)}/terminate`, {});
|
|
@@ -957,10 +1022,12 @@ export class ApiClient {
|
|
|
957
1022
|
// append-only immutable config versions carrying the authored TOML bytes,
|
|
958
1023
|
// the sources and the built bundle. The listing drains server-side, so it
|
|
959
1024
|
// has no cursor.
|
|
1025
|
+
/** Every function of the app; each item carries {@link FunctionActiveInputFields}. */
|
|
960
1026
|
async listFunctions(appId) {
|
|
961
1027
|
const result = await this.get(`/admin/api/apps/${appId}/functions`);
|
|
962
1028
|
return { items: result?.items ?? [] };
|
|
963
1029
|
}
|
|
1030
|
+
/** One function; the answer carries {@link FunctionActiveInputFields}. */
|
|
964
1031
|
async getFunction(appId, functionId) {
|
|
965
1032
|
return this.get(`/admin/api/apps/${appId}/functions/${functionId}`);
|
|
966
1033
|
}
|
|
@@ -1203,7 +1270,8 @@ export class ApiClient {
|
|
|
1203
1270
|
* Paging is opt-in on the server: with no `limit` and no `cursor` every
|
|
1204
1271
|
* version comes back, which is what this method did before paging existed and
|
|
1205
1272
|
* what an already-installed CLI still asks for. A caller that passes either
|
|
1206
|
-
* gets the shared `{ items, hasMore, nextCursor }` page.
|
|
1273
|
+
* gets the shared `{ items, hasMore, nextCursor }` page. Each item carries
|
|
1274
|
+
* {@link FunctionVersionInputFields}.
|
|
1207
1275
|
*/
|
|
1208
1276
|
async listFunctionConfigs(appId, functionId, options = {}) {
|
|
1209
1277
|
const query = new URLSearchParams();
|
|
@@ -1227,6 +1295,7 @@ export class ApiClient {
|
|
|
1227
1295
|
async activateFunctionConfig(appId, functionId, configId) {
|
|
1228
1296
|
return this.post(`/admin/api/apps/${appId}/functions/${functionId}/configs/${configId}/activate`, {});
|
|
1229
1297
|
}
|
|
1298
|
+
/** One version; the answer carries {@link FunctionVersionInputFields}. */
|
|
1230
1299
|
async getFunctionConfig(appId, functionId, configId) {
|
|
1231
1300
|
return this.get(`/admin/api/apps/${appId}/functions/${functionId}/configs/${configId}`);
|
|
1232
1301
|
}
|
|
@@ -1719,6 +1788,68 @@ export class ApiClient {
|
|
|
1719
1788
|
return this.get(`/app/${appId}/api/analytics/prompts/top`, params);
|
|
1720
1789
|
}
|
|
1721
1790
|
// ============================================
|
|
1791
|
+
// PLATFORM TRANSITIONS (#5821)
|
|
1792
|
+
// ============================================
|
|
1793
|
+
/** An app's platform transitions: each one's value and where it came from. */
|
|
1794
|
+
async getAppTransitions(appId) {
|
|
1795
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/transitions`);
|
|
1796
|
+
}
|
|
1797
|
+
/** Set one platform transition on one app, with a reason (super-admin). */
|
|
1798
|
+
async setAppTransition(appId, transition, body) {
|
|
1799
|
+
return this.put(`/super-admin/api/apps/${encodeURIComponent(appId)}/transitions/${encodeURIComponent(transition)}`, body);
|
|
1800
|
+
}
|
|
1801
|
+
/** One page of an app's transition changes, newest first (super-admin). */
|
|
1802
|
+
async listAppTransitionChanges(appId, params) {
|
|
1803
|
+
return this.get(`/super-admin/api/apps/${encodeURIComponent(appId)}/transitions/changes`, params);
|
|
1804
|
+
}
|
|
1805
|
+
/** The registered transitions, with apps per value from one budgeted walk (super-admin). */
|
|
1806
|
+
async listTransitions(params) {
|
|
1807
|
+
return this.get(`/super-admin/api/transitions`, params);
|
|
1808
|
+
}
|
|
1809
|
+
/** One page of a transition's report: each app's state, use by call site and eligible date (super-admin). */
|
|
1810
|
+
async getTransitionReport(transition, params) {
|
|
1811
|
+
return this.get(`/super-admin/api/transitions/${encodeURIComponent(transition)}/report`, params);
|
|
1812
|
+
}
|
|
1813
|
+
/** One page of a transition's move plan: what the daily move step would do with each unit (super-admin, #5824). */
|
|
1814
|
+
async getTransitionMovePlan(transition, params) {
|
|
1815
|
+
return this.get(`/super-admin/api/transitions/${encodeURIComponent(transition)}/move-plan`, params);
|
|
1816
|
+
}
|
|
1817
|
+
/** Recent calls to deprecated operations, by app, operation, source and client (super-admin). */
|
|
1818
|
+
async getDeprecatedCalls(params) {
|
|
1819
|
+
return this.get(`/super-admin/api/transitions/deprecated-calls`, params);
|
|
1820
|
+
}
|
|
1821
|
+
// ============================================
|
|
1822
|
+
// USAGE (#5713)
|
|
1823
|
+
// ============================================
|
|
1824
|
+
/** An app's usage and estimated cost for `month` (`YYYY-MM`, default the current month). */
|
|
1825
|
+
async getAppUsage(appId, params) {
|
|
1826
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage`, params);
|
|
1827
|
+
}
|
|
1828
|
+
/** An app's top users over a window, by a meter's quantity or by cost. */
|
|
1829
|
+
async getAppUsageTopUsers(appId, params) {
|
|
1830
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage/users`, params);
|
|
1831
|
+
}
|
|
1832
|
+
/** One user's usage over a window and the bytes they own. */
|
|
1833
|
+
async getAppUsageUser(appId, userId, params) {
|
|
1834
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage/users/${encodeURIComponent(userId)}`, params);
|
|
1835
|
+
}
|
|
1836
|
+
/** An app's system usage over a window, by origin, source, resource and meter. */
|
|
1837
|
+
async getAppUsageSystem(appId, params) {
|
|
1838
|
+
return this.get(`/admin/api/apps/${encodeURIComponent(appId)}/usage/system`, params);
|
|
1839
|
+
}
|
|
1840
|
+
/** The top apps by estimated cost, month to date (super-admin). */
|
|
1841
|
+
async listUsageTopApps(params) {
|
|
1842
|
+
return this.get("/super-admin/api/maintenance/usage/apps", params);
|
|
1843
|
+
}
|
|
1844
|
+
/** The top developers by estimated cost, month to date (super-admin). */
|
|
1845
|
+
async listUsageTopDevelopers(params) {
|
|
1846
|
+
return this.get("/super-admin/api/maintenance/usage/developers", params);
|
|
1847
|
+
}
|
|
1848
|
+
/** The usage jobs' state (super-admin). */
|
|
1849
|
+
async getUsageJobs() {
|
|
1850
|
+
return this.get("/super-admin/api/maintenance/usage/jobs");
|
|
1851
|
+
}
|
|
1852
|
+
// ============================================
|
|
1722
1853
|
// SUPER ADMIN: ADMINS
|
|
1723
1854
|
// ============================================
|
|
1724
1855
|
/**
|
|
@@ -2034,13 +2165,18 @@ export class ApiClient {
|
|
|
2034
2165
|
const query = options?.dryRun ? "?dryRun=true" : "";
|
|
2035
2166
|
return this.post(`/app/${appId}/api/databases/types${query}`, data);
|
|
2036
2167
|
}
|
|
2037
|
-
async updateDatabaseTypeConfig(appId, databaseType, data, expectedModifiedAt,
|
|
2168
|
+
async updateDatabaseTypeConfig(appId, databaseType, data, expectedModifiedAt,
|
|
2169
|
+
// #6019: `allowFieldRemoval` asks for the append-only override, which the
|
|
2170
|
+
// server takes only on an app whose stored settings enable it.
|
|
2171
|
+
options) {
|
|
2038
2172
|
const body = expectedModifiedAt ? { ...data, expectedModifiedAt } : data;
|
|
2039
2173
|
const qs = new URLSearchParams();
|
|
2040
2174
|
if (options?.dryRun)
|
|
2041
2175
|
qs.set("dryRun", "true");
|
|
2042
2176
|
if (options?.acceptWarnings)
|
|
2043
2177
|
qs.set("acceptWarnings", "true");
|
|
2178
|
+
if (options?.allowFieldRemoval)
|
|
2179
|
+
qs.set("allowFieldRemoval", "true");
|
|
2044
2180
|
const query = qs.toString();
|
|
2045
2181
|
const path = `/app/${appId}/api/databases/types/${encodeURIComponent(databaseType)}${query ? `?${query}` : ""}`;
|
|
2046
2182
|
return this.patch(path, body);
|
|
@@ -2878,6 +3014,13 @@ export class ApiClient {
|
|
|
2878
3014
|
async getDb3(appId, db3Id) {
|
|
2879
3015
|
return this.get(this.db3Path(appId, db3Id));
|
|
2880
3016
|
}
|
|
3017
|
+
/**
|
|
3018
|
+
* `PUT db3/:id` (#5890): rename a db3, answered as `getDb3` answers it with
|
|
3019
|
+
* the new title.
|
|
3020
|
+
*/
|
|
3021
|
+
async updateDb3(appId, db3Id, body) {
|
|
3022
|
+
return this.put(this.db3Path(appId, db3Id), body);
|
|
3023
|
+
}
|
|
2881
3024
|
/** `DELETE db3/:id` (#4804): the documents delete for a db3. */
|
|
2882
3025
|
async deleteDb3(appId, db3Id) {
|
|
2883
3026
|
return this.delete(this.db3Path(appId, db3Id));
|
|
@@ -2959,10 +3102,18 @@ export class ApiClient {
|
|
|
2959
3102
|
}
|
|
2960
3103
|
/**
|
|
2961
3104
|
* `PUT db3-types/:name` (#4802): create or update the type, and push its new
|
|
2962
|
-
* revision to every db3 of it. `dryRun` judges the body and persists nothing
|
|
3105
|
+
* revision to every db3 of it. `dryRun` judges the body and persists nothing;
|
|
3106
|
+
* `allowFieldRemoval` asks for the append-only override (#6019), which the
|
|
3107
|
+
* server takes only on an app whose stored settings enable it.
|
|
2963
3108
|
*/
|
|
2964
3109
|
async pushDb3Type(appId, name, data, options) {
|
|
2965
|
-
|
|
3110
|
+
const qs = new URLSearchParams();
|
|
3111
|
+
if (options?.dryRun)
|
|
3112
|
+
qs.set("dryRun", "true");
|
|
3113
|
+
if (options?.allowFieldRemoval)
|
|
3114
|
+
qs.set("allowFieldRemoval", "true");
|
|
3115
|
+
const query = qs.toString();
|
|
3116
|
+
return this.put(`${this.db3TypePath(appId, name)}${query ? `?${query}` : ""}`, data);
|
|
2966
3117
|
}
|
|
2967
3118
|
/** `DELETE db3-types/:name` (#4802): refused while a db3 is of the type. */
|
|
2968
3119
|
async deleteDb3Type(appId, name) {
|