primitive-admin 1.2.0-alpha.14 → 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 (400) hide show
  1. package/README.md +181 -73
  2. package/assets/skill/skills/primitive-platform/SKILL.md +87 -23
  3. package/dist/bin/primitive.js +11 -82
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +80 -17
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/agent-sessions.js +2 -0
  8. package/dist/src/commands/agent-sessions.js.map +1 -1
  9. package/dist/src/commands/analytics.js +181 -12
  10. package/dist/src/commands/analytics.js.map +1 -1
  11. package/dist/src/commands/apps-children.js +2 -0
  12. package/dist/src/commands/apps-children.js.map +1 -1
  13. package/dist/src/commands/apps-transitions.d.ts +39 -0
  14. package/dist/src/commands/apps-transitions.js +198 -0
  15. package/dist/src/commands/apps-transitions.js.map +1 -0
  16. package/dist/src/commands/apps.d.ts +11 -0
  17. package/dist/src/commands/apps.js +65 -3
  18. package/dist/src/commands/apps.js.map +1 -1
  19. package/dist/src/commands/auth-sessions.js +2 -0
  20. package/dist/src/commands/auth-sessions.js.map +1 -1
  21. package/dist/src/commands/auth.js +16 -1
  22. package/dist/src/commands/auth.js.map +1 -1
  23. package/dist/src/commands/blob-buckets.js +2 -0
  24. package/dist/src/commands/blob-buckets.js.map +1 -1
  25. package/dist/src/commands/collections.js +2 -0
  26. package/dist/src/commands/collections.js.map +1 -1
  27. package/dist/src/commands/comparisons.js +2 -0
  28. package/dist/src/commands/comparisons.js.map +1 -1
  29. package/dist/src/commands/config.d.ts +1 -1
  30. package/dist/src/commands/config.js +42 -9
  31. package/dist/src/commands/config.js.map +1 -1
  32. package/dist/src/commands/connections.js +2 -0
  33. package/dist/src/commands/connections.js.map +1 -1
  34. package/dist/src/commands/database-type-configs.js +5 -3
  35. package/dist/src/commands/database-type-configs.js.map +1 -1
  36. package/dist/src/commands/databases.js +6 -4
  37. package/dist/src/commands/databases.js.map +1 -1
  38. package/dist/src/commands/db3-types.js +2 -0
  39. package/dist/src/commands/db3-types.js.map +1 -1
  40. package/dist/src/commands/db3.d.ts +12 -0
  41. package/dist/src/commands/db3.js +408 -31
  42. package/dist/src/commands/db3.js.map +1 -1
  43. package/dist/src/commands/documents.d.ts +52 -12
  44. package/dist/src/commands/documents.js +120 -29
  45. package/dist/src/commands/documents.js.map +1 -1
  46. package/dist/src/commands/email-templates.js +74 -0
  47. package/dist/src/commands/email-templates.js.map +1 -1
  48. package/dist/src/commands/env.js +2 -0
  49. package/dist/src/commands/env.js.map +1 -1
  50. package/dist/src/commands/functions.js +90 -11
  51. package/dist/src/commands/functions.js.map +1 -1
  52. package/dist/src/commands/groups.js +20 -3
  53. package/dist/src/commands/groups.js.map +1 -1
  54. package/dist/src/commands/guides.js +2 -0
  55. package/dist/src/commands/guides.js.map +1 -1
  56. package/dist/src/commands/hosting.d.ts +8 -0
  57. package/dist/src/commands/hosting.js +346 -0
  58. package/dist/src/commands/hosting.js.map +1 -0
  59. package/dist/src/commands/init.js +9 -1
  60. package/dist/src/commands/init.js.map +1 -1
  61. package/dist/src/commands/integrations.js +82 -47
  62. package/dist/src/commands/integrations.js.map +1 -1
  63. package/dist/src/commands/locks.js +2 -0
  64. package/dist/src/commands/locks.js.map +1 -1
  65. package/dist/src/commands/metadata-category-configs.js +2 -0
  66. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  67. package/dist/src/commands/metadata.js +41 -0
  68. package/dist/src/commands/metadata.js.map +1 -1
  69. package/dist/src/commands/prompts.js +75 -47
  70. package/dist/src/commands/prompts.js.map +1 -1
  71. package/dist/src/commands/rate-counters.d.ts +19 -0
  72. package/dist/src/commands/rate-counters.js +104 -0
  73. package/dist/src/commands/rate-counters.js.map +1 -0
  74. package/dist/src/commands/rule-sets.js +2 -0
  75. package/dist/src/commands/rule-sets.js.map +1 -1
  76. package/dist/src/commands/schemas.d.ts +15 -0
  77. package/dist/src/commands/schemas.js +122 -0
  78. package/dist/src/commands/schemas.js.map +1 -0
  79. package/dist/src/commands/secrets.js +47 -3
  80. package/dist/src/commands/secrets.js.map +1 -1
  81. package/dist/src/commands/sessions.js +2 -0
  82. package/dist/src/commands/sessions.js.map +1 -1
  83. package/dist/src/commands/skill.js +2 -0
  84. package/dist/src/commands/skill.js.map +1 -1
  85. package/dist/src/commands/sync-schemas.d.ts +202 -0
  86. package/dist/src/commands/sync-schemas.js +629 -0
  87. package/dist/src/commands/sync-schemas.js.map +1 -0
  88. package/dist/src/commands/sync-user-properties.d.ts +118 -0
  89. package/dist/src/commands/sync-user-properties.js +276 -0
  90. package/dist/src/commands/sync-user-properties.js.map +1 -0
  91. package/dist/src/commands/sync.d.ts +344 -14
  92. package/dist/src/commands/sync.js +1834 -345
  93. package/dist/src/commands/sync.js.map +1 -1
  94. package/dist/src/commands/tokens.js +2 -0
  95. package/dist/src/commands/tokens.js.map +1 -1
  96. package/dist/src/commands/transitions.d.ts +54 -0
  97. package/dist/src/commands/transitions.js +418 -0
  98. package/dist/src/commands/transitions.js.map +1 -0
  99. package/dist/src/commands/usage.d.ts +18 -0
  100. package/dist/src/commands/usage.js +343 -0
  101. package/dist/src/commands/usage.js.map +1 -0
  102. package/dist/src/commands/user-properties.d.ts +14 -0
  103. package/dist/src/commands/user-properties.js +79 -0
  104. package/dist/src/commands/user-properties.js.map +1 -0
  105. package/dist/src/commands/users.js +878 -16
  106. package/dist/src/commands/users.js.map +1 -1
  107. package/dist/src/commands/vars.js +2 -0
  108. package/dist/src/commands/vars.js.map +1 -1
  109. package/dist/src/commands/waitlist.js +39 -4
  110. package/dist/src/commands/waitlist.js.map +1 -1
  111. package/dist/src/lib/analytics-query.d.ts +58 -0
  112. package/dist/src/lib/analytics-query.js +134 -0
  113. package/dist/src/lib/analytics-query.js.map +1 -0
  114. package/dist/src/lib/api-client.d.ts +1354 -97
  115. package/dist/src/lib/api-client.js +513 -164
  116. package/dist/src/lib/api-client.js.map +1 -1
  117. package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
  118. package/dist/src/lib/app-settings-descriptor.js +6 -0
  119. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  120. package/dist/src/lib/auth-flow.d.ts +33 -0
  121. package/dist/src/lib/auth-flow.js +404 -13
  122. package/dist/src/lib/auth-flow.js.map +1 -1
  123. package/dist/src/lib/block-selector.d.ts +9 -15
  124. package/dist/src/lib/block-selector.js +9 -20
  125. package/dist/src/lib/block-selector.js.map +1 -1
  126. package/dist/src/lib/cli-manifest.d.ts +9 -0
  127. package/dist/src/lib/cli-manifest.js +10 -1
  128. package/dist/src/lib/cli-manifest.js.map +1 -1
  129. package/dist/src/lib/cli-version.d.ts +14 -0
  130. package/dist/src/lib/cli-version.js +38 -0
  131. package/dist/src/lib/cli-version.js.map +1 -0
  132. package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
  133. package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
  134. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
  135. package/dist/src/lib/command-groups.d.ts +30 -0
  136. package/dist/src/lib/command-groups.js +109 -0
  137. package/dist/src/lib/command-groups.js.map +1 -0
  138. package/dist/src/lib/command-status.d.ts +147 -0
  139. package/dist/src/lib/command-status.js +266 -0
  140. package/dist/src/lib/command-status.js.map +1 -0
  141. package/dist/src/lib/config-object-descriptor.d.ts +6 -0
  142. package/dist/src/lib/config-object-descriptor.js +71 -1
  143. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  144. package/dist/src/lib/config-toml.d.ts +11 -2
  145. package/dist/src/lib/config-toml.js +25 -2
  146. package/dist/src/lib/config-toml.js.map +1 -1
  147. package/dist/src/lib/data-input.d.ts +1 -1
  148. package/dist/src/lib/data-input.js +1 -1
  149. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
  150. package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
  151. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  152. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +18 -1
  153. package/dist/src/lib/db-codegen/dbTypeIR.js +14 -5
  154. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  155. package/dist/src/lib/db-type-records.d.ts +106 -0
  156. package/dist/src/lib/db-type-records.js +224 -0
  157. package/dist/src/lib/db-type-records.js.map +1 -0
  158. package/dist/src/lib/db3-export.d.ts +51 -14
  159. package/dist/src/lib/db3-export.js +136 -28
  160. package/dist/src/lib/db3-export.js.map +1 -1
  161. package/dist/src/lib/db3-index-output.d.ts +92 -4
  162. package/dist/src/lib/db3-index-output.js +183 -11
  163. package/dist/src/lib/db3-index-output.js.map +1 -1
  164. package/dist/src/lib/db3-type-models.d.ts +49 -7
  165. package/dist/src/lib/db3-type-models.js +159 -28
  166. package/dist/src/lib/db3-type-models.js.map +1 -1
  167. package/dist/src/lib/deprecation.d.ts +2 -2
  168. package/dist/src/lib/deprecation.js +2 -2
  169. package/dist/src/lib/experimental-apis.d.ts +36 -0
  170. package/dist/src/lib/experimental-apis.js +46 -0
  171. package/dist/src/lib/experimental-apis.js.map +1 -0
  172. package/dist/src/lib/file-attachment.d.ts +24 -0
  173. package/dist/src/lib/file-attachment.js +31 -0
  174. package/dist/src/lib/file-attachment.js.map +1 -0
  175. package/dist/src/lib/function-authorize-check.d.ts +1 -1
  176. package/dist/src/lib/function-authorize-check.js +2 -1
  177. package/dist/src/lib/function-authorize-check.js.map +1 -1
  178. package/dist/src/lib/function-authorize-view.d.ts +12 -0
  179. package/dist/src/lib/function-authorize-view.js +38 -0
  180. package/dist/src/lib/function-authorize-view.js.map +1 -1
  181. package/dist/src/lib/function-bundle.d.ts +27 -5
  182. package/dist/src/lib/function-bundle.js +106 -7
  183. package/dist/src/lib/function-bundle.js.map +1 -1
  184. package/dist/src/lib/function-collect.d.ts +15 -0
  185. package/dist/src/lib/function-collect.js +73 -14
  186. package/dist/src/lib/function-collect.js.map +1 -1
  187. package/dist/src/lib/function-db-types.d.ts +63 -40
  188. package/dist/src/lib/function-db-types.js +289 -293
  189. package/dist/src/lib/function-db-types.js.map +1 -1
  190. package/dist/src/lib/function-document-types.d.ts +19 -7
  191. package/dist/src/lib/function-document-types.js +24 -12
  192. package/dist/src/lib/function-document-types.js.map +1 -1
  193. package/dist/src/lib/function-lint.d.ts +24 -1
  194. package/dist/src/lib/function-lint.js +123 -1
  195. package/dist/src/lib/function-lint.js.map +1 -1
  196. package/dist/src/lib/function-run.d.ts +1 -1
  197. package/dist/src/lib/function-run.js +1 -1
  198. package/dist/src/lib/function-run.js.map +1 -1
  199. package/dist/src/lib/function-schema-codegen.d.ts +85 -21
  200. package/dist/src/lib/function-schema-codegen.js +191 -85
  201. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  202. package/dist/src/lib/function-schema-refs.d.ts +98 -0
  203. package/dist/src/lib/function-schema-refs.js +177 -0
  204. package/dist/src/lib/function-schema-refs.js.map +1 -0
  205. package/dist/src/lib/function-sync.d.ts +38 -4
  206. package/dist/src/lib/function-sync.js +91 -14
  207. package/dist/src/lib/function-sync.js.map +1 -1
  208. package/dist/src/lib/function-typecheck.d.ts +52 -0
  209. package/dist/src/lib/function-typecheck.js +171 -54
  210. package/dist/src/lib/function-typecheck.js.map +1 -1
  211. package/dist/src/lib/generated-build-flags.d.ts +13 -0
  212. package/dist/src/lib/generated-build-flags.js +14 -0
  213. package/dist/src/lib/generated-build-flags.js.map +1 -0
  214. package/dist/src/lib/generated-command-status.d.ts +6 -0
  215. package/dist/src/lib/generated-command-status.js +469 -0
  216. package/dist/src/lib/generated-command-status.js.map +1 -0
  217. package/dist/src/lib/generated-config-surfaces.d.ts +239 -14
  218. package/dist/src/lib/generated-config-surfaces.js +670 -85
  219. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  220. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  221. package/dist/src/lib/generated-sdk-types.js +1 -1
  222. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  223. package/dist/src/lib/hosting-build.d.ts +97 -0
  224. package/dist/src/lib/hosting-build.js +204 -0
  225. package/dist/src/lib/hosting-build.js.map +1 -0
  226. package/dist/src/lib/hosting-client.d.ts +167 -0
  227. package/dist/src/lib/hosting-client.js +340 -0
  228. package/dist/src/lib/hosting-client.js.map +1 -0
  229. package/dist/src/lib/hosting-environments.d.ts +32 -0
  230. package/dist/src/lib/hosting-environments.js +74 -0
  231. package/dist/src/lib/hosting-environments.js.map +1 -0
  232. package/dist/src/lib/hosting-errors.d.ts +30 -0
  233. package/dist/src/lib/hosting-errors.js +43 -0
  234. package/dist/src/lib/hosting-errors.js.map +1 -0
  235. package/dist/src/lib/hosting-token.d.ts +46 -0
  236. package/dist/src/lib/hosting-token.js +60 -0
  237. package/dist/src/lib/hosting-token.js.map +1 -0
  238. package/dist/src/lib/hosting-wait.d.ts +42 -0
  239. package/dist/src/lib/hosting-wait.js +84 -0
  240. package/dist/src/lib/hosting-wait.js.map +1 -0
  241. package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
  242. package/dist/src/lib/hosting-wfp-upload.js +149 -0
  243. package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
  244. package/dist/src/lib/integration-test-request.d.ts +54 -0
  245. package/dist/src/lib/integration-test-request.js +207 -0
  246. package/dist/src/lib/integration-test-request.js.map +1 -0
  247. package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
  248. package/dist/src/lib/invoker-shared-enums.js +98 -0
  249. package/dist/src/lib/invoker-shared-enums.js.map +1 -0
  250. package/dist/src/lib/log-inspection.d.ts +4 -1
  251. package/dist/src/lib/log-inspection.js.map +1 -1
  252. package/dist/src/lib/metadata-report.d.ts +85 -0
  253. package/dist/src/lib/metadata-report.js +81 -0
  254. package/dist/src/lib/metadata-report.js.map +1 -0
  255. package/dist/src/lib/output.d.ts +1 -1
  256. package/dist/src/lib/output.js +1 -1
  257. package/dist/src/lib/platform-owned.js +5 -0
  258. package/dist/src/lib/platform-owned.js.map +1 -1
  259. package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
  260. package/dist/src/lib/primitive-declaration-names.js +22 -0
  261. package/dist/src/lib/primitive-declaration-names.js.map +1 -0
  262. package/dist/src/lib/primitive-declaration.d.ts +174 -0
  263. package/dist/src/lib/primitive-declaration.js +792 -0
  264. package/dist/src/lib/primitive-declaration.js.map +1 -0
  265. package/dist/src/lib/prompt-schema-codegen.d.ts +36 -12
  266. package/dist/src/lib/prompt-schema-codegen.js +94 -98
  267. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  268. package/dist/src/lib/prompt-schema-document.d.ts +35 -0
  269. package/dist/src/lib/prompt-schema-document.js +92 -0
  270. package/dist/src/lib/prompt-schema-document.js.map +1 -0
  271. package/dist/src/lib/prompt-schema-refs.d.ts +173 -0
  272. package/dist/src/lib/prompt-schema-refs.js +478 -0
  273. package/dist/src/lib/prompt-schema-refs.js.map +1 -0
  274. package/dist/src/lib/records-verbs.d.ts +12 -2
  275. package/dist/src/lib/records-verbs.js +7 -2
  276. package/dist/src/lib/records-verbs.js.map +1 -1
  277. package/dist/src/lib/register-commands.d.ts +36 -0
  278. package/dist/src/lib/register-commands.js +37 -0
  279. package/dist/src/lib/register-commands.js.map +1 -0
  280. package/dist/src/lib/retired-imports.d.ts +53 -0
  281. package/dist/src/lib/retired-imports.js +120 -0
  282. package/dist/src/lib/retired-imports.js.map +1 -0
  283. package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
  284. package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
  285. package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
  286. package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
  287. package/dist/src/lib/schema-codegen/generated-db3-bridge.js +227 -0
  288. package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
  289. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
  290. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
  291. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
  292. package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +218 -0
  293. package/dist/src/lib/schema-codegen/generated-field-grammar.js +397 -0
  294. package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
  295. package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
  296. package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
  297. package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
  298. package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
  299. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
  300. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
  301. package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +129 -0
  302. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +154 -1
  303. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -1
  304. package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
  305. package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
  306. package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
  307. package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
  308. package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
  309. package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
  310. package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
  311. package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
  312. package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
  313. package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
  314. package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
  315. package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
  316. package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
  317. package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
  318. package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
  319. package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
  320. package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
  321. package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
  322. package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
  323. package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
  324. package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
  325. package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
  326. package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
  327. package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
  328. package/dist/src/lib/schema-codegen/schemaToTs.d.ts +40 -13
  329. package/dist/src/lib/schema-codegen/schemaToTs.js +124 -160
  330. package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -1
  331. package/dist/src/lib/schema-codegen/valuesLists.d.ts +48 -0
  332. package/dist/src/lib/schema-codegen/valuesLists.js +144 -0
  333. package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
  334. package/dist/src/lib/schema-family-index.d.ts +228 -0
  335. package/dist/src/lib/schema-family-index.js +813 -0
  336. package/dist/src/lib/schema-family-index.js.map +1 -0
  337. package/dist/src/lib/schema-pins.d.ts +82 -0
  338. package/dist/src/lib/schema-pins.js +198 -0
  339. package/dist/src/lib/schema-pins.js.map +1 -0
  340. package/dist/src/lib/schema-preview.d.ts +244 -0
  341. package/dist/src/lib/schema-preview.js +498 -0
  342. package/dist/src/lib/schema-preview.js.map +1 -0
  343. package/dist/src/lib/skill-installer.d.ts +2 -2
  344. package/dist/src/lib/skill-installer.js +2 -21
  345. package/dist/src/lib/skill-installer.js.map +1 -1
  346. package/dist/src/lib/step-run-table.d.ts +1 -2
  347. package/dist/src/lib/step-run-table.js +1 -2
  348. package/dist/src/lib/step-run-table.js.map +1 -1
  349. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +2 -1
  350. package/dist/src/lib/swift-codegen/agentGenerator.js +24 -22
  351. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
  352. package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
  353. package/dist/src/lib/swift-codegen/banners.js +12 -0
  354. package/dist/src/lib/swift-codegen/banners.js.map +1 -1
  355. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
  356. package/dist/src/lib/swift-codegen/functionGenerator.js +168 -50
  357. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  358. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +31 -7
  359. package/dist/src/lib/swift-codegen/schemaToSwift.js +213 -177
  360. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  361. package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
  362. package/dist/src/lib/swift-codegen/sharedGenerator.js +165 -0
  363. package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
  364. package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
  365. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
  366. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
  367. package/dist/src/lib/sync-resource-types.d.ts +37 -5
  368. package/dist/src/lib/sync-resource-types.js +50 -5
  369. package/dist/src/lib/sync-resource-types.js.map +1 -1
  370. package/dist/src/lib/sync-selectors.d.ts +7 -0
  371. package/dist/src/lib/sync-selectors.js +22 -2
  372. package/dist/src/lib/sync-selectors.js.map +1 -1
  373. package/dist/src/lib/test-runs.d.ts +45 -0
  374. package/dist/src/lib/test-runs.js +150 -0
  375. package/dist/src/lib/test-runs.js.map +1 -0
  376. package/dist/src/lib/toml-database-config.d.ts +2 -1
  377. package/dist/src/lib/toml-database-config.js +7 -4
  378. package/dist/src/lib/toml-database-config.js.map +1 -1
  379. package/dist/src/lib/toml-scalar-edit.js +6 -4
  380. package/dist/src/lib/toml-scalar-edit.js.map +1 -1
  381. package/dist/src/lib/transition-warnings.d.ts +21 -0
  382. package/dist/src/lib/transition-warnings.js +49 -0
  383. package/dist/src/lib/transition-warnings.js.map +1 -0
  384. package/dist/src/lib/user-index.d.ts +80 -0
  385. package/dist/src/lib/user-index.js +166 -0
  386. package/dist/src/lib/user-index.js.map +1 -0
  387. package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
  388. package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
  389. package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
  390. package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
  391. package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
  392. package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
  393. package/dist/src/lib/user-walk.d.ts +31 -0
  394. package/dist/src/lib/user-walk.js +102 -0
  395. package/dist/src/lib/user-walk.js.map +1 -0
  396. package/dist/src/lib/worker-perf-format.d.ts +22 -0
  397. package/dist/src/lib/worker-perf-format.js +27 -0
  398. package/dist/src/lib/worker-perf-format.js.map +1 -0
  399. package/dist/src/types/index.d.ts +13 -34
  400. package/package.json +5 -3
@@ -1,9 +1,13 @@
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";
6
+ import { CLI_VERSION_HEADER, cliVersionHeaderValue } from "./cli-version.js";
5
7
  import { paginateAll, normalizeCliListEnvelope } from "./paginate.js";
6
8
  import { RefreshError, refreshAdminCredentials, } from "./refresh-admin-credentials.js";
9
+ /** The `X-Primitive-CLI-Version` value, read from the package file once per process. */
10
+ let cliVersion;
7
11
  /**
8
12
  * Page size the admin per-user inventories are asked for (#3399).
9
13
  *
@@ -239,6 +243,8 @@ export class ApiClient {
239
243
  Authorization: `Bearer ${accessToken}`,
240
244
  "Content-Type": "application/json",
241
245
  ...(options.headers || {}),
246
+ // #5532 — every request names the CLI version that sent it.
247
+ [CLI_VERSION_HEADER]: (cliVersion ??= cliVersionHeaderValue()),
242
248
  };
243
249
  // Include globalAdminAppId if available (required for admin API calls)
244
250
  if (credentials.globalAdminAppId) {
@@ -256,10 +262,16 @@ export class ApiClient {
256
262
  // one. A retry refused 401 means the step-up is gone (revoked or expired
257
263
  // early): drop it and show the original refusal. The retry's own refusal
258
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
+ };
259
271
  if (response.status === 403 && this.stepUpApplies(response, text, path)) {
260
272
  const retried = await send(credentials.stepUp.accessToken);
261
273
  if (retried.response.ok) {
262
- return retried.text ? JSON.parse(retried.text) : null;
274
+ return answered(retried.text);
263
275
  }
264
276
  if (retried.response.status === 401) {
265
277
  this.dropStepUp();
@@ -271,7 +283,7 @@ export class ApiClient {
271
283
  if (!response.ok) {
272
284
  throw this.responseError(response, text, path);
273
285
  }
274
- return text ? JSON.parse(text) : null;
286
+ return answered(text);
275
287
  }
276
288
  /**
277
289
  * Whether a 403 should be retried with the stored step-up: it names
@@ -361,6 +373,60 @@ export class ApiClient {
361
373
  async exchangeToken(body) {
362
374
  return this.post("/admin/api/auth/token", body);
363
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
+ }
364
430
  // Helper for GET requests with query params
365
431
  async get(path, params) {
366
432
  let fullPath = path;
@@ -516,6 +582,15 @@ export class ApiClient {
516
582
  async addUserByEmail(appId, data) {
517
583
  return this.post(`/admin/api/apps/${appId}/users/add-by-email`, data);
518
584
  }
585
+ /**
586
+ * Invite an email to the app as a console admin
587
+ * (`POST /admin/api/apps/:appId/users/invite`): the invitation, with its
588
+ * `inviteToken` and the `initialProperties` it gives the invitee at
589
+ * acceptance (filling only what they have not set).
590
+ */
591
+ async inviteUser(appId, data) {
592
+ return this.post(`/admin/api/apps/${appId}/users/invite`, data);
593
+ }
519
594
  /**
520
595
  * Set a member's display name and/or avatar URL
521
596
  * (`PATCH /admin/api/apps/:appId/users/:userId/profile`). An omitted field
@@ -530,6 +605,168 @@ export class ApiClient {
530
605
  async rebuildUserSearchText(appId) {
531
606
  return this.post(`/admin/api/apps/${appId}/users/rebuild-search-text`, {});
532
607
  }
608
+ /**
609
+ * One page of an app's users from the user index
610
+ * (`POST /admin/api/apps/:appId/users/query`): the records-query filter and
611
+ * sort over base fields and `properties.<name>`, at most 1,000 per page.
612
+ */
613
+ async queryUsers(appId, body) {
614
+ return this.post(`/admin/api/apps/${appId}/users/query`, body);
615
+ }
616
+ /** How many of an app's users match (`POST /admin/api/apps/:appId/users/count`). */
617
+ async countUsers(appId, body) {
618
+ return this.post(`/admin/api/apps/${appId}/users/count`, body);
619
+ }
620
+ /**
621
+ * The state of an app's user index (`GET /admin/api/apps/:appId/users/index`):
622
+ * the generation, each shard with its bound and counts, superseded
623
+ * generations, a rebuild in progress, queued applies, the last apply and
624
+ * reconciliation, the limits and whether the shard ceiling is reached.
625
+ */
626
+ async getUserIndexStatus(appId) {
627
+ return this.get(`/admin/api/apps/${appId}/users/index`);
628
+ }
629
+ /**
630
+ * Start a report of which user metadata categories still hold rows on the
631
+ * app's current members (`POST /admin/api/apps/:appId/users/metadata-report`).
632
+ */
633
+ async startUserMetadataReport(appId) {
634
+ return this.post(`/admin/api/apps/${appId}/users/metadata-report`, {});
635
+ }
636
+ /**
637
+ * Read a user metadata report run, or the app's newest when `runId` is
638
+ * absent (`GET /admin/api/apps/:appId/users/metadata-report`).
639
+ */
640
+ async getUserMetadataReport(appId, runId) {
641
+ const query = runId ? `?runId=${encodeURIComponent(runId)}` : "";
642
+ return this.get(`/admin/api/apps/${appId}/users/metadata-report${query}`);
643
+ }
644
+ /** Start building the next generation of an app's user index (`POST /admin/api/apps/:appId/users/index/rebuild`). */
645
+ async rebuildUserIndex(appId) {
646
+ return this.post(`/admin/api/apps/${appId}/users/index/rebuild`, {});
647
+ }
648
+ /**
649
+ * Run one revalidation slice of an app's user index now
650
+ * (`POST /admin/api/apps/:appId/users/index/reconcile`), answered when it is
651
+ * done; `started: false` while the app is being deleted.
652
+ */
653
+ async reconcileUserIndex(appId) {
654
+ return this.post(`/admin/api/apps/${appId}/users/index/reconcile`, {});
655
+ }
656
+ /**
657
+ * Start (or find) a walk over an app's users with the admin as its starter
658
+ * (`POST /admin/api/apps/:appId/users/walks`); `existing` says the key named
659
+ * a walk that already existed.
660
+ */
661
+ async startUserWalk(appId, body) {
662
+ return this.post(`/admin/api/apps/${appId}/users/walks`, body);
663
+ }
664
+ /** A users walk by its run id (`GET /admin/api/apps/:appId/users/walks/:runId`). */
665
+ async getUserWalk(appId, runId) {
666
+ return this.get(`/admin/api/apps/${appId}/users/walks/${encodeURIComponent(runId)}`);
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
+ }
672
+ /** Stop a users walk (`POST /admin/api/apps/:appId/users/walks/:runId/terminate`); batches in flight finish. */
673
+ async terminateUserWalk(appId, runId) {
674
+ return this.post(`/admin/api/apps/${appId}/users/walks/${encodeURIComponent(runId)}/terminate`, {});
675
+ }
676
+ /**
677
+ * An app's user index limit overrides and the limits in effect, with the
678
+ * property caps beside them (`GET /admin/api/apps/:appId/users/index/limits`).
679
+ */
680
+ async getUserIndexLimits(appId) {
681
+ return this.get(`/admin/api/apps/${appId}/users/index/limits`);
682
+ }
683
+ /**
684
+ * Set (a positive integer) or clear (`null`) an app's user index limit
685
+ * overrides (`PATCH /admin/api/apps/:appId/users/index/limits`).
686
+ */
687
+ async patchUserIndexLimits(appId, body) {
688
+ return this.patch(`/admin/api/apps/${appId}/users/index/limits`, body);
689
+ }
690
+ /**
691
+ * An app's user properties schema (`GET /admin/api/apps/:appId/users/properties`):
692
+ * the active version, a push being validated, the removed fields and the caps.
693
+ * While a push validates, this read also resumes its walk.
694
+ */
695
+ async getUserProperties(appId) {
696
+ return this.get(`/admin/api/apps/${appId}/users/properties`);
697
+ }
698
+ /**
699
+ * Push the text of `user-properties.toml` (`PUT /admin/api/apps/:appId/users/properties`):
700
+ * 200 `published` or `unchanged`, 400 when refused; `dryRun` judges it and
701
+ * writes nothing.
702
+ */
703
+ async pushUserProperties(appId, body, options = {}) {
704
+ return this.put(`/admin/api/apps/${appId}/users/properties${options.dryRun ? "?dryRun=true" : ""}`, body);
705
+ }
706
+ /**
707
+ * The current version of each of an app's `schemas/` files
708
+ * (`GET /admin/api/apps/:appId/schemas`); a tombstoned file only with
709
+ * `includeTombstoned`.
710
+ */
711
+ async listSchemaFiles(appId, options = {}) {
712
+ return this.get(`/admin/api/apps/${appId}/schemas${options.includeTombstoned ? "?includeTombstoned=true" : ""}`);
713
+ }
714
+ /**
715
+ * One version of a `schemas/` file, the current one unless `version` names
716
+ * another (`GET /admin/api/apps/:appId/schemas/:file`); 404
717
+ * `SCHEMA_FILE_NOT_FOUND` or `SCHEMA_VERSION_NOT_FOUND`.
718
+ */
719
+ async getSchemaFile(appId, file, options = {}) {
720
+ const query = options.version !== undefined ? `?version=${encodeURIComponent(String(options.version))}` : "";
721
+ return this.get(`/admin/api/apps/${appId}/schemas/${encodeURIComponent(file)}${query}`);
722
+ }
723
+ /**
724
+ * Push the text of `schemas/<file>.toml` with its compiled defs
725
+ * (`PUT /admin/api/apps/:appId/schemas/:file`): `created` or `unchanged`;
726
+ * 409 `CONFLICT` when the current version is not `expectedVersion`.
727
+ */
728
+ async pushSchemaFile(appId, file, body) {
729
+ return this.put(`/admin/api/apps/${appId}/schemas/${encodeURIComponent(file)}`, body);
730
+ }
731
+ /**
732
+ * Write a tombstone version of a `schemas/` file (`PUT
733
+ * /admin/api/apps/:appId/schemas/:file` with `{ tombstone: true }`), pinned
734
+ * to `expectedVersion` when given.
735
+ */
736
+ async tombstoneSchemaFile(appId, file, expectedVersion) {
737
+ return this.put(`/admin/api/apps/${appId}/schemas/${encodeURIComponent(file)}`, {
738
+ tombstone: true,
739
+ ...(expectedVersion !== undefined ? { expectedVersion } : {}),
740
+ });
741
+ }
742
+ /**
743
+ * The source of every live `schemas/` file, or of `files` only
744
+ * (`POST /admin/api/apps/:appId/schemas/pull`); a named file with no live
745
+ * version is listed under `missing`.
746
+ */
747
+ async pullSchemaFiles(appId, files) {
748
+ return this.post(`/admin/api/apps/${appId}/schemas/pull`, files ? { files } : {});
749
+ }
750
+ /** One member with their properties (`GET /admin/api/apps/:appId/users/:userId`); 404 `USER_NOT_FOUND` for a user who is no member. */
751
+ async getAppUser(appId, userId) {
752
+ return this.get(`/admin/api/apps/${appId}/users/${userId}`);
753
+ }
754
+ /**
755
+ * The member who holds a unique property value or a unique constraint's
756
+ * values (`POST /admin/api/apps/:appId/users/get-by`): `{ user }`, null when
757
+ * no member holds it.
758
+ */
759
+ async getAppUserBy(appId, selector) {
760
+ return this.post(`/admin/api/apps/${appId}/users/get-by`, selector);
761
+ }
762
+ /** Apply a property write to one member (`PATCH /admin/api/apps/:appId/users/:userId/properties`); answers the member after it. */
763
+ async setAppUserProperties(appId, userId, body) {
764
+ return this.patch(`/admin/api/apps/${appId}/users/${userId}/properties`, body);
765
+ }
766
+ /** An aggregate over an app's users (`POST /admin/api/apps/:appId/users/aggregate`). */
767
+ async aggregateUsers(appId, body) {
768
+ return this.post(`/admin/api/apps/${appId}/users/aggregate`, body);
769
+ }
533
770
  async listUsers(appId, params) {
534
771
  const query = new URLSearchParams();
535
772
  if (params?.name)
@@ -574,36 +811,21 @@ export class ApiClient {
574
811
  async setUserAvailability(appId, userId, action) {
575
812
  return this.put(`/admin/api/apps/${appId}/users/${userId}/${action}`, {});
576
813
  }
577
- // ============================================
578
- // FEATURE FLAGS (super-admin)
579
- // ============================================
580
- /**
581
- * #2803 — the platform's feature flags. A server-owned admin toggle with a
582
- * console but, until now, no CLI: the same "one control, both surfaces" rule
583
- * the carrying types get.
584
- */
585
- async listFeatureFlags() {
586
- return this.get(`/admin/api/flags`);
587
- }
588
- /**
589
- * The flag itself, not the `{ flag }` envelope the route answers with —
590
- * `feature-flags get` prints the key, the enabled state and the per-app
591
- * overrides, and reading them off the envelope printed a blank row.
592
- */
593
- async getFeatureFlag(flagKey) {
594
- const result = await this.get(`/admin/api/flags/${flagKey}`);
595
- return result?.flag ?? result;
596
- }
597
- /** Same envelope, same unwrap: `enable`/`disable` print the updated flag. */
598
- async setFeatureFlagEnabled(flagKey, enabled) {
599
- const result = await this.put(`/admin/api/flags/${flagKey}`, { enabled });
600
- return result?.flag ?? result;
601
- }
602
814
  async updateUserRole(appId, userId, role) {
603
815
  return this.put(`/app/${appId}/api/users/${userId}/role`, { role });
604
816
  }
817
+ /**
818
+ * Make the app user with `newOwnerEmail` the app's owner; the previous
819
+ * owner becomes an admin. The email resolves to a userId through
820
+ * {@link lookupUserByEmail}, and an email no user of the app has rejects
821
+ * with a message naming it.
822
+ */
605
823
  async transferOwnership(appId, newOwnerEmail) {
606
- return this.post(`/app/${appId}/api/ownership`, { newOwnerEmail });
824
+ const lookup = await this.lookupUserByEmail(appId, newOwnerEmail);
825
+ if (!lookup.exists || !lookup.user?.userId) {
826
+ throw new Error(`No user with email ${newOwnerEmail} in app ${appId}`);
827
+ }
828
+ return this.post(`/admin/api/apps/${appId}/users/${lookup.user.userId}/transfer-ownership`, {});
607
829
  }
608
830
  async transferAdminOwnership(appId, adminId) {
609
831
  return this.post(`/admin/api/apps/${appId}/admins/transfer-ownership`, { adminId });
@@ -639,6 +861,14 @@ export class ApiClient {
639
861
  hasMore: result?.hasMore ?? nextCursor != null,
640
862
  };
641
863
  }
864
+ /**
865
+ * `GET /app/{appId}/api/invitations/{invitationId}` — one invitation with
866
+ * its `inviteToken` (the bearer credential an accept link carries) and its
867
+ * `status`. Readable by an app admin/owner or the inviter.
868
+ */
869
+ async getInvitation(appId, invitationId) {
870
+ return this.get(`/app/${appId}/api/invitations/${encodeURIComponent(invitationId)}`);
871
+ }
642
872
  async createInvitation(appId, data) {
643
873
  return this.post(`/app/${appId}/api/invitations`, data);
644
874
  }
@@ -694,7 +924,7 @@ export class ApiClient {
694
924
  /**
695
925
  * An integration's named configs. Test cases pin a config by NAME so the
696
926
  * sidecar is portable across apps (#2769); this is the map pull and push
697
- * resolve that name through, the same way prompts/workflows/scripts do.
927
+ * resolve that name through, the same way prompts do.
698
928
  */
699
929
  async listIntegrationConfigs(appId, integrationId) {
700
930
  const result = await this.get(`/admin/api/apps/${appId}/integrations/${integrationId}/configs`);
@@ -788,14 +1018,16 @@ export class ApiClient {
788
1018
  // ============================================
789
1019
  // ── Server functions (#3179) ─────────────────────────────────────────
790
1020
  //
791
- // The `functions` family mirrors workflows and scripts: a header with the
792
- // gate and the entry, and append-only immutable config versions carrying the
793
- // authored TOML bytes, the sources and the built bundle. The listing drains
794
- // server-side, so it has no cursor.
1021
+ // The `functions` family is a header with the gate and the entry, and
1022
+ // append-only immutable config versions carrying the authored TOML bytes,
1023
+ // the sources and the built bundle. The listing drains server-side, so it
1024
+ // has no cursor.
1025
+ /** Every function of the app; each item carries {@link FunctionActiveInputFields}. */
795
1026
  async listFunctions(appId) {
796
1027
  const result = await this.get(`/admin/api/apps/${appId}/functions`);
797
1028
  return { items: result?.items ?? [] };
798
1029
  }
1030
+ /** One function; the answer carries {@link FunctionActiveInputFields}. */
799
1031
  async getFunction(appId, functionId) {
800
1032
  return this.get(`/admin/api/apps/${appId}/functions/${functionId}`);
801
1033
  }
@@ -1038,7 +1270,8 @@ export class ApiClient {
1038
1270
  * Paging is opt-in on the server: with no `limit` and no `cursor` every
1039
1271
  * version comes back, which is what this method did before paging existed and
1040
1272
  * what an already-installed CLI still asks for. A caller that passes either
1041
- * gets the shared `{ items, hasMore, nextCursor }` page.
1273
+ * gets the shared `{ items, hasMore, nextCursor }` page. Each item carries
1274
+ * {@link FunctionVersionInputFields}.
1042
1275
  */
1043
1276
  async listFunctionConfigs(appId, functionId, options = {}) {
1044
1277
  const query = new URLSearchParams();
@@ -1062,6 +1295,7 @@ export class ApiClient {
1062
1295
  async activateFunctionConfig(appId, functionId, configId) {
1063
1296
  return this.post(`/admin/api/apps/${appId}/functions/${functionId}/configs/${configId}/activate`, {});
1064
1297
  }
1298
+ /** One version; the answer carries {@link FunctionVersionInputFields}. */
1065
1299
  async getFunctionConfig(appId, functionId, configId) {
1066
1300
  return this.get(`/admin/api/apps/${appId}/functions/${functionId}/configs/${configId}`);
1067
1301
  }
@@ -1277,43 +1511,11 @@ export class ApiClient {
1277
1511
  async duplicatePromptConfig(appId, promptId, configId, payload) {
1278
1512
  return this.post(`/admin/api/apps/${appId}/prompts/${promptId}/configs/${configId}/duplicate`, payload || {});
1279
1513
  }
1280
- // ============================================
1281
- // SCRIPTS — retained history (#3190)
1282
- // ============================================
1283
- //
1284
- // Scripts retired with the Rhai runtime. A `Script` HEADER
1285
- // (name/description/activeConfigId) and its versioned `ScriptConfig` rows
1286
- // stay readable until their retention ends; nothing writes them.
1287
- async listScripts(appId) {
1288
- const result = await this.get(`/admin/api/apps/${appId}/scripts`);
1289
- return { items: result?.items ?? [] };
1290
- }
1291
- async getScript(appId, scriptId) {
1292
- return this.get(`/admin/api/apps/${appId}/scripts/${scriptId}`);
1293
- }
1294
- /**
1295
- * List a script's versioned configs (the `ScriptConfig` rows). Each config
1296
- * is a distinct block version: `configId` is the stable version selector,
1297
- * `contentHash` is its content identity, and `status` reports whether it is
1298
- * `active`/`draft`/`archived`. The script header's `activeConfigId` names
1299
- * the version that was live. Used by `scripts configs list`.
1300
- */
1301
- async listScriptConfigs(appId, scriptId) {
1302
- const result = await this.get(`/admin/api/apps/${appId}/scripts/${scriptId}/configs`);
1303
- return { items: result?.items ?? [] };
1304
- }
1305
- /**
1306
- * One version of a script, body included. A body the server cannot load
1307
- * answers a 404 naming the version rather than an empty body.
1308
- */
1309
- async getScriptConfig(appId, scriptId, configId) {
1310
- return this.get(`/admin/api/apps/${appId}/scripts/${scriptId}/configs/${configId}`);
1311
- }
1312
1514
  async getPromptSchema(appId, promptId) {
1313
1515
  return this.get(`/admin/api/apps/${appId}/prompts/${promptId}/schema`);
1314
1516
  }
1315
1517
  // ============================================
1316
- // BLOCK TEST CASES (Prompts, Integrations, Workflows)
1518
+ // BLOCK TEST CASES (Prompts, Integrations)
1317
1519
  // ============================================
1318
1520
  /**
1319
1521
  * One page of a block's test cases. The endpoint paginates (default 50, cap
@@ -1481,33 +1683,31 @@ export class ApiClient {
1481
1683
  async runAllTestCases(appId, blockType, blockId, payload) {
1482
1684
  return this.post(`/admin/api/apps/${appId}/blocks/${blockType}/${blockId}/test-all`, payload || {});
1483
1685
  }
1484
- async listTestRuns(appId, blockType, blockId, params) {
1485
- const result = await this.get(`/admin/api/apps/${appId}/blocks/${blockType}/${blockId}/runs`, params);
1486
- return { items: result?.items ?? result ?? [] };
1487
- }
1488
- // ============================================
1489
- // WORKFLOWS — retained history, read-only (#3190)
1490
- // ============================================
1491
- async listWorkflows(appId, params) {
1492
- const result = await this.get(`/admin/api/apps/${appId}/workflows`, params);
1686
+ /**
1687
+ * One page of a block's test runs, newest first. The endpoint paginates
1688
+ * (default 50, cap 100) and reports `nextCursor`.
1689
+ */
1690
+ async listTestRuns(appId, blockType, blockId, params = {}) {
1691
+ const query = new URLSearchParams();
1692
+ if (params.limit !== undefined)
1693
+ query.set("limit", String(params.limit));
1694
+ if (params.cursor)
1695
+ query.set("cursor", params.cursor);
1696
+ const suffix = query.toString() ? `?${query.toString()}` : "";
1697
+ const result = await this.get(`/admin/api/apps/${appId}/blocks/${blockType}/${blockId}/runs${suffix}`);
1493
1698
  return {
1494
1699
  items: result?.items ?? [],
1495
1700
  hasMore: result?.hasMore,
1496
- nextCursor: result?.nextCursor ?? null,
1701
+ nextCursor: result?.nextCursor ?? undefined,
1497
1702
  };
1498
1703
  }
1499
- async getWorkflow(appId, workflowId) {
1500
- return this.get(`/admin/api/apps/${appId}/workflows/${workflowId}`);
1501
- }
1502
- // ============================================
1503
- // WORKFLOW CONFIGURATIONS
1504
- // ============================================
1505
- async listWorkflowConfigs(appId, workflowId) {
1506
- const result = await this.get(`/admin/api/apps/${appId}/workflows/${workflowId}/configs`);
1507
- return { items: result?.items ?? [] };
1508
- }
1509
- async getWorkflowConfig(appId, workflowId, configId) {
1510
- return this.get(`/admin/api/apps/${appId}/workflows/${workflowId}/configs/${configId}`);
1704
+ /**
1705
+ * One of a block's test runs: the object `listTestRuns` lists for it. The
1706
+ * run id travels as one path segment, so a `/`, `?` or `#` in it can never
1707
+ * reach the listing or the query.
1708
+ */
1709
+ async getTestRun(appId, blockType, blockId, runId) {
1710
+ return this.get(`/admin/api/apps/${appId}/blocks/${blockType}/${blockId}/runs/${encodeURIComponent(runId)}`);
1511
1711
  }
1512
1712
  // ============================================
1513
1713
  // ANALYTICS
@@ -1542,25 +1742,114 @@ export class ApiClient {
1542
1742
  async getAnalyticsUserSearch(appId, params) {
1543
1743
  return this.get(`/app/${appId}/api/analytics/users/search`, params);
1544
1744
  }
1545
- async getAnalyticsUserDetail(appId, userUlid) {
1546
- return this.get(`/app/${appId}/api/analytics/users/${userUlid}/detail`);
1745
+ async getAnalyticsUserDetail(appId, userUlid, params) {
1746
+ return this.get(`/app/${appId}/api/analytics/users/${userUlid}/detail`, params);
1547
1747
  }
1548
- async getAnalyticsUserSnapshot(appId, userUlid) {
1549
- return this.get(`/app/${appId}/api/analytics/users/${userUlid}/snapshot`);
1748
+ async getAnalyticsUserSnapshot(appId, userUlid, params) {
1749
+ return this.get(`/app/${appId}/api/analytics/users/${userUlid}/snapshot`, params);
1750
+ }
1751
+ /**
1752
+ * #5251 — `path` with `params` set as `get` sets them, then one appended
1753
+ * `filter[<field>][<operator>]` entry per filter, in order. `get`'s record
1754
+ * cannot hold two entries under one key; the server ANDs them all.
1755
+ */
1756
+ analyticsFilteredGet(path, params, filters) {
1757
+ if (!filters || filters.length === 0)
1758
+ return this.get(path, params);
1759
+ const query = new URLSearchParams();
1760
+ for (const [key, value] of Object.entries(params ?? {})) {
1761
+ if (value !== undefined && value !== null) {
1762
+ query.set(key, String(value));
1763
+ }
1764
+ }
1765
+ for (const filter of filters) {
1766
+ query.append(`filter[${filter.field}][${filter.operator}]`, filter.value);
1767
+ }
1768
+ return this.get(`${path}?${query.toString()}`);
1550
1769
  }
1551
- async getAnalyticsEvents(appId, params) {
1552
- return this.get(`/app/${appId}/api/analytics/events`, params);
1770
+ async getAnalyticsEvents(appId, params, filters) {
1771
+ return this.analyticsFilteredGet(`/app/${appId}/api/analytics/events`, params, filters);
1553
1772
  }
1554
- async getAnalyticsEventsGrouped(appId, params) {
1555
- return this.get(`/app/${appId}/api/analytics/events/grouped`, params);
1773
+ async getAnalyticsEventsGrouped(appId, params, filters) {
1774
+ return this.analyticsFilteredGet(`/app/${appId}/api/analytics/events/grouped`, params, filters);
1556
1775
  }
1557
- async getAnalyticsErrorsGroups(appId, params) {
1558
- return this.get(`/app/${appId}/api/analytics/errors/groups`, params);
1776
+ async getAnalyticsErrorsGroups(appId, params, filters) {
1777
+ return this.analyticsFilteredGet(`/app/${appId}/api/analytics/errors/groups`, params, filters);
1778
+ }
1779
+ /** The app's db3 query shapes that read the most rows (#5244). */
1780
+ async getAnalyticsDb3Queries(appId, params) {
1781
+ return this.get(`/app/${appId}/api/analytics/db3/queries`, params);
1782
+ }
1783
+ /** The app's request wall time and DynamoDB round trips per endpoint and function (#5244). */
1784
+ async getAnalyticsRequests(appId, params) {
1785
+ return this.get(`/app/${appId}/api/analytics/requests`, params);
1559
1786
  }
1560
1787
  async getAnalyticsTopPrompts(appId, params) {
1561
1788
  return this.get(`/app/${appId}/api/analytics/prompts/top`, params);
1562
1789
  }
1563
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
+ // ============================================
1564
1853
  // SUPER ADMIN: ADMINS
1565
1854
  // ============================================
1566
1855
  /**
@@ -1574,7 +1863,7 @@ export class ApiClient {
1574
1863
  return this.get("/admin/api/me");
1575
1864
  }
1576
1865
  async listAllAdmins(params) {
1577
- const result = await this.get("/admin/api/admins", params);
1866
+ const result = await this.get("/super-admin/api/admins", params);
1578
1867
  const nextCursor = result?.nextCursor ?? null;
1579
1868
  const items = result?.items ?? [];
1580
1869
  return {
@@ -1584,70 +1873,32 @@ export class ApiClient {
1584
1873
  };
1585
1874
  }
1586
1875
  async searchAdminByEmail(email) {
1587
- return this.get("/admin/api/admins/search", { email });
1876
+ return this.get("/super-admin/api/admins/search", { email });
1588
1877
  }
1589
1878
  async getAdminApps(email) {
1590
- return this.get(`/admin/api/admins/${encodeURIComponent(email)}/apps`);
1879
+ return this.get(`/super-admin/api/admins/${encodeURIComponent(email)}/apps`);
1591
1880
  }
1592
1881
  async updateAdminSettings(adminId, data) {
1593
- return this.patch(`/admin/api/admins/${adminId}`, data);
1882
+ return this.patch(`/super-admin/api/admins/${adminId}`, data);
1594
1883
  }
1595
1884
  async reindexAdmin(adminId) {
1596
- return this.post(`/admin/api/admins/${adminId}/reindex`, {});
1885
+ return this.post(`/super-admin/api/admins/${adminId}/reindex`, {});
1886
+ }
1887
+ /** `reindexAdmin` with the route's answer, for callers that print it. */
1888
+ async reindexAdminWithResult(adminId) {
1889
+ return this.post(`/super-admin/api/admins/${adminId}/reindex`, {});
1597
1890
  }
1598
1891
  // Admin Invitations
1599
- async listAllAdminInvitations() {
1600
- const result = await this.get("/admin/api/admins/invitations");
1892
+ /** One address's pending admin invitations; the route requires the address. */
1893
+ async listAllAdminInvitations(email) {
1894
+ const result = await this.get("/super-admin/api/admins/invitations", { email });
1601
1895
  return result?.invitations ?? [];
1602
1896
  }
1603
1897
  async createGlobalAdminInvitation(data) {
1604
- return this.post("/admin/api/admins/invitations", data);
1898
+ return this.post("/super-admin/api/admins/invitations", data);
1605
1899
  }
1606
1900
  async deleteGlobalAdminInvitation(invitationId) {
1607
- return this.delete(`/admin/api/admins/invitations/${invitationId}`);
1608
- }
1609
- // ============================================
1610
- // SUPER ADMIN: CATALOG
1611
- // ============================================
1612
- async listPromptCatalog(params) {
1613
- const result = await this.get("/admin/api/catalog/prompts", params);
1614
- return {
1615
- items: result?.items ?? [],
1616
- hasMore: result?.hasMore,
1617
- nextCursor: result?.nextCursor ?? null,
1618
- };
1619
- }
1620
- async getPromptCatalogItem(catalogId) {
1621
- return this.get(`/admin/api/catalog/prompts/${catalogId}`);
1622
- }
1623
- async createPromptCatalogItem(payload) {
1624
- return this.post("/admin/api/catalog/prompts", payload);
1625
- }
1626
- async updatePromptCatalogItem(catalogId, payload) {
1627
- return this.patch(`/admin/api/catalog/prompts/${catalogId}`, payload);
1628
- }
1629
- async deletePromptCatalogItem(catalogId) {
1630
- return this.delete(`/admin/api/catalog/prompts/${catalogId}`);
1631
- }
1632
- async listIntegrationCatalog(params) {
1633
- const result = await this.get("/admin/api/catalog/integrations", params);
1634
- return {
1635
- items: result?.items ?? [],
1636
- hasMore: result?.hasMore,
1637
- nextCursor: result?.nextCursor ?? null,
1638
- };
1639
- }
1640
- async getIntegrationCatalogItem(catalogId) {
1641
- return this.get(`/admin/api/catalog/integrations/${catalogId}`);
1642
- }
1643
- async createIntegrationCatalogItem(payload) {
1644
- return this.post("/admin/api/catalog/integrations", payload);
1645
- }
1646
- async updateIntegrationCatalogItem(catalogId, payload) {
1647
- return this.patch(`/admin/api/catalog/integrations/${catalogId}`, payload);
1648
- }
1649
- async deleteIntegrationCatalogItem(catalogId) {
1650
- return this.delete(`/admin/api/catalog/integrations/${catalogId}`);
1901
+ return this.delete(`/super-admin/api/admins/invitations/${invitationId}`);
1651
1902
  }
1652
1903
  // ============================================
1653
1904
  // BATCH TEST EXECUTION
@@ -1694,6 +1945,15 @@ export class ApiClient {
1694
1945
  async testEmailTemplate(appId, emailType, payload) {
1695
1946
  return this.post(`/admin/api/apps/${appId}/email-templates/${emailType}/test`, payload || {});
1696
1947
  }
1948
+ /**
1949
+ * Render the saved template (or the built-in default) for an email type
1950
+ * without sending it. `variables` override the type's sample values. The
1951
+ * app id and the type are each encoded as one path segment, so no value of
1952
+ * either can select another route.
1953
+ */
1954
+ async previewEmailTemplate(appId, emailType, payload) {
1955
+ return this.post(`/admin/api/apps/${encodeURIComponent(appId)}/email-templates/${encodeURIComponent(emailType)}/preview`, payload || {});
1956
+ }
1697
1957
  // ============================================
1698
1958
  // ACCESS TOKENS
1699
1959
  // ============================================
@@ -1905,13 +2165,18 @@ export class ApiClient {
1905
2165
  const query = options?.dryRun ? "?dryRun=true" : "";
1906
2166
  return this.post(`/app/${appId}/api/databases/types${query}`, data);
1907
2167
  }
1908
- 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) {
1909
2172
  const body = expectedModifiedAt ? { ...data, expectedModifiedAt } : data;
1910
2173
  const qs = new URLSearchParams();
1911
2174
  if (options?.dryRun)
1912
2175
  qs.set("dryRun", "true");
1913
2176
  if (options?.acceptWarnings)
1914
2177
  qs.set("acceptWarnings", "true");
2178
+ if (options?.allowFieldRemoval)
2179
+ qs.set("allowFieldRemoval", "true");
1915
2180
  const query = qs.toString();
1916
2181
  const path = `/app/${appId}/api/databases/types/${encodeURIComponent(databaseType)}${query ? `?${query}` : ""}`;
1917
2182
  return this.patch(path, body);
@@ -2529,12 +2794,13 @@ export class ApiClient {
2529
2794
  }
2530
2795
  /**
2531
2796
  * Apply an ordered multi-model create/patch/delete blob atomically (issue
2532
- * #1964 Phase 4, wrapping the #1517 `bulkUpdate` facade). All-or-nothing:
2533
- * a validation failure commits nothing. Returns the facade's
2534
- * `{ applied, added, updated, deleted }`.
2797
+ * #1964 Phase 4, wrapping the #1517 `bulkUpdate` facade): `POST
2798
+ * records/batch`, at most 100 operations. All-or-nothing: a validation
2799
+ * failure commits nothing. Returns the facade's `{ applied, added,
2800
+ * updated, deleted }`, and on a db3 `reads` when the batch carried reads.
2535
2801
  */
2536
- async bulkDocumentRecords(appId, documentId, operations, extra) {
2537
- return this.post(`/app/${appId}/api/documents/${documentId}/records/bulk` +
2802
+ async batchDocumentRecords(appId, documentId, operations, extra) {
2803
+ return this.post(`/app/${appId}/api/documents/${documentId}/records/batch` +
2538
2804
  this.documentFormatQuery(extra?.documentFormat), { operations });
2539
2805
  }
2540
2806
  // ============================================
@@ -2550,8 +2816,9 @@ export class ApiClient {
2550
2816
  }
2551
2817
  /**
2552
2818
  * `POST db3/:id/indexes` with `{ model, field | fields, unique?, name? }`,
2553
- * or `{ model, field, members: true }` for a member index → `{ index }`.
2554
- * The route applies the registration rules.
2819
+ * `{ model, field, members: true }` for a member index, or `{ model, field
2820
+ * | fields, kind: "text", on, text? }` for a text index → `{ index }`. The
2821
+ * route applies the registration rules.
2555
2822
  */
2556
2823
  async registerDb3Index(appId, db3Id, body) {
2557
2824
  return this.post(`${this.db3Path(appId, db3Id)}/indexes`, body);
@@ -2560,6 +2827,40 @@ export class ApiClient {
2560
2827
  async dropDb3Index(appId, db3Id, name) {
2561
2828
  return this.delete(`${this.db3Path(appId, db3Id)}/indexes/${encodeURIComponent(name)}`);
2562
2829
  }
2830
+ /**
2831
+ * `GET db3/:id/indexes/:name/model` (#5229): a vector index's shared model,
2832
+ * its bytes as uploaded and the `X-Index-Model-*` headers it was uploaded
2833
+ * with.
2834
+ */
2835
+ async fetchDb3IndexModel(appId, db3Id, name) {
2836
+ const credentials = await this.ensureAuthenticated();
2837
+ const url = `${credentials.serverUrl}${this.db3Path(appId, db3Id)}/indexes/${encodeURIComponent(name)}/model`;
2838
+ const headers = { Authorization: `Bearer ${credentials.accessToken}` };
2839
+ if (credentials.globalAdminAppId)
2840
+ headers["X-Global-Admin-App-Id"] = credentials.globalAdminAppId;
2841
+ const response = await fetchWithTLS(url, { method: "GET", headers });
2842
+ if (!response.ok) {
2843
+ const text = await response.text();
2844
+ const parsed = parseErrorResponse(response, text, url);
2845
+ throw new ApiError(parsed.message, response.status, parsed.code, parsed.details);
2846
+ }
2847
+ const header = (key) => response.headers.get(`X-Index-Model-${key}`) ?? "";
2848
+ return {
2849
+ data: Buffer.from(await response.arrayBuffer()),
2850
+ generation: Number(header("Generation")),
2851
+ revision: Number(header("Revision")),
2852
+ rows: Number(header("Rows")),
2853
+ trainedAt: header("Trained-At"),
2854
+ format: header("Format"),
2855
+ };
2856
+ }
2857
+ /**
2858
+ * `DELETE db3/:id/indexes/:name/model` (#5229) → `{ ok, name, revision }`:
2859
+ * the model (or an upload under way) gone, `revision` the index's new one.
2860
+ */
2861
+ async deleteDb3IndexModel(appId, db3Id, name) {
2862
+ return this.delete(`${this.db3Path(appId, db3Id)}/indexes/${encodeURIComponent(name)}/model`);
2863
+ }
2563
2864
  /** The db3 mount of {@link queryDocumentRecords}: `GET db3/:id/records/:model`. */
2564
2865
  async queryDb3Records(appId, db3Id, modelName, queryOptions) {
2565
2866
  const query = {};
@@ -2587,6 +2888,14 @@ export class ApiClient {
2587
2888
  async aggregateDb3Records(appId, db3Id, modelName, options) {
2588
2889
  return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/aggregate`, { options });
2589
2890
  }
2891
+ /**
2892
+ * `POST db3/:id/records/:model/explain` (#5240): run a query, count or
2893
+ * aggregate on the server, forced onto `index` (or off indexes, `"none"`)
2894
+ * when given, and answer how it read.
2895
+ */
2896
+ async explainDb3Read(appId, db3Id, modelName, body) {
2897
+ return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/explain`, body);
2898
+ }
2590
2899
  /** The db3 mount of {@link saveDocumentRecord}: `POST db3/:id/records/:model`. */
2591
2900
  async saveDb3Record(appId, db3Id, modelName, body) {
2592
2901
  return this.post(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}`, body);
@@ -2599,9 +2908,20 @@ export class ApiClient {
2599
2908
  async deleteDb3Record(appId, db3Id, modelName, recordId) {
2600
2909
  return this.delete(`${this.db3Path(appId, db3Id)}/records/${encodeURIComponent(modelName)}/${encodeURIComponent(recordId)}`);
2601
2910
  }
2602
- /** The db3 mount of {@link bulkDocumentRecords}: `POST db3/:id/records/bulk`. */
2603
- async bulkDb3Records(appId, db3Id, operations) {
2604
- return this.post(`${this.db3Path(appId, db3Id)}/records/bulk`, { operations });
2911
+ /** The db3 mount of {@link batchDocumentRecords}: `POST db3/:id/records/batch`. */
2912
+ async batchDb3Records(appId, db3Id, operations) {
2913
+ return this.post(`${this.db3Path(appId, db3Id)}/records/batch`, { operations });
2914
+ }
2915
+ /**
2916
+ * Several reads of a db3 in one request (#5243): `POST db3/:id/records/batch-read`,
2917
+ * each answered at its index from one state of the db3. `atomic: false`
2918
+ * answers a refused read in its place rather than refusing the request.
2919
+ */
2920
+ async batchReadDb3Records(appId, db3Id, operations, options = {}) {
2921
+ return this.post(`${this.db3Path(appId, db3Id)}/records/batch-read`, {
2922
+ operations,
2923
+ ...(options.atomic === false ? { atomic: false } : {}),
2924
+ });
2605
2925
  }
2606
2926
  /** The db3 mount of {@link getDocumentSchema}: `GET db3/:id/schema`. */
2607
2927
  async getDb3Schema(appId, db3Id) {
@@ -2694,6 +3014,13 @@ export class ApiClient {
2694
3014
  async getDb3(appId, db3Id) {
2695
3015
  return this.get(this.db3Path(appId, db3Id));
2696
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
+ }
2697
3024
  /** `DELETE db3/:id` (#4804): the documents delete for a db3. */
2698
3025
  async deleteDb3(appId, db3Id) {
2699
3026
  return this.delete(this.db3Path(appId, db3Id));
@@ -2731,6 +3058,20 @@ export class ApiClient {
2731
3058
  const nextCursor = result?.nextCursor;
2732
3059
  return { items: result?.items ?? [], nextCursor, hasMore: result?.hasMore ?? nextCursor != null };
2733
3060
  }
3061
+ /**
3062
+ * Every db3 a member reaches through the admin API (#5253): held, shared
3063
+ * with them, then app access, each row with its `via`; `via` narrows to
3064
+ * some of the three ways.
3065
+ */
3066
+ async listDb3ForUser(appId, userId, params) {
3067
+ const result = await this.get(`/admin/api/apps/${appId}/users/${encodeURIComponent(userId)}/db3`, {
3068
+ ...(params?.via ? { via: params.via.join(",") } : {}),
3069
+ ...(params?.limit !== undefined ? { limit: params.limit } : {}),
3070
+ ...(params?.cursor ? { cursor: params.cursor } : {}),
3071
+ });
3072
+ const nextCursor = result?.nextCursor;
3073
+ return { items: result?.items ?? [], nextCursor, hasMore: result?.hasMore ?? nextCursor != null };
3074
+ }
2734
3075
  /** Transfer a db3 to `to` (`app` or `user:<userId>`) through the admin API (#4804). */
2735
3076
  async transferDb3(appId, db3Id, to) {
2736
3077
  return this.post(`/admin/api/apps/${appId}/db3/${encodeURIComponent(db3Id)}/transfer`, { to });
@@ -2761,10 +3102,18 @@ export class ApiClient {
2761
3102
  }
2762
3103
  /**
2763
3104
  * `PUT db3-types/:name` (#4802): create or update the type, and push its new
2764
- * 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.
2765
3108
  */
2766
3109
  async pushDb3Type(appId, name, data, options) {
2767
- 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);
2768
3117
  }
2769
3118
  /** `DELETE db3-types/:name` (#4802): refused while a db3 is of the type. */
2770
3119
  async deleteDb3Type(appId, name) {