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.
Files changed (202) hide show
  1. package/README.md +84 -0
  2. package/dist/src/commands/admins.js +1 -0
  3. package/dist/src/commands/admins.js.map +1 -1
  4. package/dist/src/commands/analytics.js +2 -4
  5. package/dist/src/commands/analytics.js.map +1 -1
  6. package/dist/src/commands/apps-transitions.d.ts +39 -0
  7. package/dist/src/commands/apps-transitions.js +198 -0
  8. package/dist/src/commands/apps-transitions.js.map +1 -0
  9. package/dist/src/commands/apps.d.ts +11 -0
  10. package/dist/src/commands/apps.js +50 -5
  11. package/dist/src/commands/apps.js.map +1 -1
  12. package/dist/src/commands/auth-sessions.js +2 -0
  13. package/dist/src/commands/auth-sessions.js.map +1 -1
  14. package/dist/src/commands/auth.js +5 -0
  15. package/dist/src/commands/auth.js.map +1 -1
  16. package/dist/src/commands/blob-buckets.js +2 -0
  17. package/dist/src/commands/blob-buckets.js.map +1 -1
  18. package/dist/src/commands/collections.js +2 -13
  19. package/dist/src/commands/collections.js.map +1 -1
  20. package/dist/src/commands/comparisons.js +2 -0
  21. package/dist/src/commands/comparisons.js.map +1 -1
  22. package/dist/src/commands/config.js +2 -0
  23. package/dist/src/commands/config.js.map +1 -1
  24. package/dist/src/commands/connections.js +2 -2
  25. package/dist/src/commands/connections.js.map +1 -1
  26. package/dist/src/commands/db3.js +79 -21
  27. package/dist/src/commands/db3.js.map +1 -1
  28. package/dist/src/commands/email-templates.js +2 -0
  29. package/dist/src/commands/email-templates.js.map +1 -1
  30. package/dist/src/commands/env.js +2 -0
  31. package/dist/src/commands/env.js.map +1 -1
  32. package/dist/src/commands/functions.js +45 -3
  33. package/dist/src/commands/functions.js.map +1 -1
  34. package/dist/src/commands/groups.js +2 -0
  35. package/dist/src/commands/groups.js.map +1 -1
  36. package/dist/src/commands/guides.js +2 -0
  37. package/dist/src/commands/guides.js.map +1 -1
  38. package/dist/src/commands/hosting.d.ts +8 -0
  39. package/dist/src/commands/hosting.js +346 -0
  40. package/dist/src/commands/hosting.js.map +1 -0
  41. package/dist/src/commands/init.js +2 -0
  42. package/dist/src/commands/init.js.map +1 -1
  43. package/dist/src/commands/integrations.js +2 -0
  44. package/dist/src/commands/integrations.js.map +1 -1
  45. package/dist/src/commands/locks.js +2 -0
  46. package/dist/src/commands/locks.js.map +1 -1
  47. package/dist/src/commands/metadata-category-configs.js +1 -1
  48. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  49. package/dist/src/commands/metadata.js +2 -2
  50. package/dist/src/commands/metadata.js.map +1 -1
  51. package/dist/src/commands/prompts.js +2 -0
  52. package/dist/src/commands/prompts.js.map +1 -1
  53. package/dist/src/commands/rate-counters.d.ts +19 -0
  54. package/dist/src/commands/rate-counters.js +104 -0
  55. package/dist/src/commands/rate-counters.js.map +1 -0
  56. package/dist/src/commands/rule-sets.js +2 -2
  57. package/dist/src/commands/rule-sets.js.map +1 -1
  58. package/dist/src/commands/schemas.js +4 -4
  59. package/dist/src/commands/schemas.js.map +1 -1
  60. package/dist/src/commands/secrets.js +2 -0
  61. package/dist/src/commands/secrets.js.map +1 -1
  62. package/dist/src/commands/skill.js +2 -0
  63. package/dist/src/commands/skill.js.map +1 -1
  64. package/dist/src/commands/sync.d.ts +101 -2
  65. package/dist/src/commands/sync.js +391 -62
  66. package/dist/src/commands/sync.js.map +1 -1
  67. package/dist/src/commands/tokens.js +2 -0
  68. package/dist/src/commands/tokens.js.map +1 -1
  69. package/dist/src/commands/transitions.d.ts +54 -0
  70. package/dist/src/commands/transitions.js +418 -0
  71. package/dist/src/commands/transitions.js.map +1 -0
  72. package/dist/src/commands/usage.d.ts +18 -0
  73. package/dist/src/commands/usage.js +343 -0
  74. package/dist/src/commands/usage.js.map +1 -0
  75. package/dist/src/commands/user-properties.js +2 -2
  76. package/dist/src/commands/user-properties.js.map +1 -1
  77. package/dist/src/commands/users.js +28 -29
  78. package/dist/src/commands/users.js.map +1 -1
  79. package/dist/src/commands/vars.js +2 -0
  80. package/dist/src/commands/vars.js.map +1 -1
  81. package/dist/src/commands/waitlist.js +2 -2
  82. package/dist/src/commands/waitlist.js.map +1 -1
  83. package/dist/src/lib/api-client.d.ts +606 -2
  84. package/dist/src/lib/api-client.js +157 -6
  85. package/dist/src/lib/api-client.js.map +1 -1
  86. package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
  87. package/dist/src/lib/app-settings-descriptor.js +6 -0
  88. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  89. package/dist/src/lib/auth-flow.d.ts +33 -0
  90. package/dist/src/lib/auth-flow.js +404 -13
  91. package/dist/src/lib/auth-flow.js.map +1 -1
  92. package/dist/src/lib/cli-manifest.d.ts +5 -4
  93. package/dist/src/lib/cli-manifest.js.map +1 -1
  94. package/dist/src/lib/command-groups.d.ts +30 -0
  95. package/dist/src/lib/command-groups.js +109 -0
  96. package/dist/src/lib/command-groups.js.map +1 -0
  97. package/dist/src/lib/command-status.d.ts +56 -19
  98. package/dist/src/lib/command-status.js +101 -19
  99. package/dist/src/lib/command-status.js.map +1 -1
  100. package/dist/src/lib/config-object-descriptor.js +0 -1
  101. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  102. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +7 -0
  103. package/dist/src/lib/db-codegen/dbTypeIR.js +3 -0
  104. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  105. package/dist/src/lib/db-type-records.d.ts +12 -1
  106. package/dist/src/lib/db-type-records.js +8 -3
  107. package/dist/src/lib/db-type-records.js.map +1 -1
  108. package/dist/src/lib/db3-export.js +2 -2
  109. package/dist/src/lib/db3-export.js.map +1 -1
  110. package/dist/src/lib/db3-index-output.d.ts +26 -3
  111. package/dist/src/lib/db3-index-output.js +48 -12
  112. package/dist/src/lib/db3-index-output.js.map +1 -1
  113. package/dist/src/lib/db3-type-models.d.ts +11 -1
  114. package/dist/src/lib/db3-type-models.js +22 -2
  115. package/dist/src/lib/db3-type-models.js.map +1 -1
  116. package/dist/src/lib/function-authorize-view.d.ts +12 -0
  117. package/dist/src/lib/function-authorize-view.js +34 -0
  118. package/dist/src/lib/function-authorize-view.js.map +1 -1
  119. package/dist/src/lib/function-collect.d.ts +13 -0
  120. package/dist/src/lib/function-collect.js +37 -7
  121. package/dist/src/lib/function-collect.js.map +1 -1
  122. package/dist/src/lib/function-db-types.d.ts +14 -8
  123. package/dist/src/lib/function-db-types.js +56 -21
  124. package/dist/src/lib/function-db-types.js.map +1 -1
  125. package/dist/src/lib/function-lint.d.ts +24 -1
  126. package/dist/src/lib/function-lint.js +123 -1
  127. package/dist/src/lib/function-lint.js.map +1 -1
  128. package/dist/src/lib/function-schema-codegen.d.ts +31 -7
  129. package/dist/src/lib/function-schema-codegen.js +131 -36
  130. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  131. package/dist/src/lib/function-sync.js +9 -1
  132. package/dist/src/lib/function-sync.js.map +1 -1
  133. package/dist/src/lib/generated-command-status.d.ts +6 -0
  134. package/dist/src/lib/generated-command-status.js +469 -0
  135. package/dist/src/lib/generated-command-status.js.map +1 -0
  136. package/dist/src/lib/generated-config-surfaces.d.ts +28 -3
  137. package/dist/src/lib/generated-config-surfaces.js +91 -16
  138. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  139. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  140. package/dist/src/lib/generated-sdk-types.js +1 -1
  141. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  142. package/dist/src/lib/hosting-build.d.ts +97 -0
  143. package/dist/src/lib/hosting-build.js +204 -0
  144. package/dist/src/lib/hosting-build.js.map +1 -0
  145. package/dist/src/lib/hosting-client.d.ts +167 -0
  146. package/dist/src/lib/hosting-client.js +340 -0
  147. package/dist/src/lib/hosting-client.js.map +1 -0
  148. package/dist/src/lib/hosting-environments.d.ts +32 -0
  149. package/dist/src/lib/hosting-environments.js +74 -0
  150. package/dist/src/lib/hosting-environments.js.map +1 -0
  151. package/dist/src/lib/hosting-errors.d.ts +30 -0
  152. package/dist/src/lib/hosting-errors.js +43 -0
  153. package/dist/src/lib/hosting-errors.js.map +1 -0
  154. package/dist/src/lib/hosting-token.d.ts +46 -0
  155. package/dist/src/lib/hosting-token.js +60 -0
  156. package/dist/src/lib/hosting-token.js.map +1 -0
  157. package/dist/src/lib/hosting-wait.d.ts +42 -0
  158. package/dist/src/lib/hosting-wait.js +84 -0
  159. package/dist/src/lib/hosting-wait.js.map +1 -0
  160. package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
  161. package/dist/src/lib/hosting-wfp-upload.js +149 -0
  162. package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
  163. package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
  164. package/dist/src/lib/invoker-shared-enums.js +98 -0
  165. package/dist/src/lib/invoker-shared-enums.js.map +1 -0
  166. package/dist/src/lib/log-inspection.d.ts +4 -1
  167. package/dist/src/lib/log-inspection.js.map +1 -1
  168. package/dist/src/lib/primitive-declaration.d.ts +32 -1
  169. package/dist/src/lib/primitive-declaration.js +153 -19
  170. package/dist/src/lib/primitive-declaration.js.map +1 -1
  171. package/dist/src/lib/prompt-schema-codegen.d.ts +1 -1
  172. package/dist/src/lib/prompt-schema-codegen.js +31 -19
  173. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  174. package/dist/src/lib/prompt-schema-refs.d.ts +9 -0
  175. package/dist/src/lib/prompt-schema-refs.js +28 -2
  176. package/dist/src/lib/prompt-schema-refs.js.map +1 -1
  177. package/dist/src/lib/register-commands.d.ts +14 -6
  178. package/dist/src/lib/register-commands.js +19 -83
  179. package/dist/src/lib/register-commands.js.map +1 -1
  180. package/dist/src/lib/schema-codegen/generated-db3-bridge.js +10 -4
  181. package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -1
  182. package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +11 -2
  183. package/dist/src/lib/schema-codegen/generated-field-grammar.js +22 -4
  184. package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -1
  185. package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
  186. package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
  187. package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
  188. package/dist/src/lib/schema-codegen/valuesLists.d.ts +15 -2
  189. package/dist/src/lib/schema-codegen/valuesLists.js +19 -3
  190. package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -1
  191. package/dist/src/lib/swift-codegen/functionGenerator.js +4 -3
  192. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  193. package/dist/src/lib/swift-codegen/sharedGenerator.js +50 -5
  194. package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -1
  195. package/dist/src/lib/sync-resource-types.js +0 -3
  196. package/dist/src/lib/sync-resource-types.js.map +1 -1
  197. package/dist/src/lib/toml-database-config.js +3 -1
  198. package/dist/src/lib/toml-database-config.js.map +1 -1
  199. package/dist/src/lib/transition-warnings.d.ts +21 -0
  200. package/dist/src/lib/transition-warnings.js +49 -0
  201. package/dist/src/lib/transition-warnings.js.map +1 -0
  202. 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 retried.text ? JSON.parse(retried.text) : null;
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 text ? JSON.parse(text) : null;
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, options) {
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
- return this.put(`${this.db3TypePath(appId, name)}${options?.dryRun ? "?dryRun=true" : ""}`, data);
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) {