primitive-admin 1.0.63 → 1.0.64

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 (328) hide show
  1. package/README.md +132 -42
  2. package/assets/skill/skills/primitive-platform/SKILL.md +142 -661
  3. package/dist/bin/primitive.js +121 -41
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +37 -50
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/analytics.js +178 -9
  8. package/dist/src/commands/analytics.js.map +1 -1
  9. package/dist/src/commands/apps.js +12 -5
  10. package/dist/src/commands/apps.js.map +1 -1
  11. package/dist/src/commands/auth-sessions.d.ts +7 -0
  12. package/dist/src/commands/auth-sessions.js +144 -0
  13. package/dist/src/commands/auth-sessions.js.map +1 -0
  14. package/dist/src/commands/auth.js +76 -116
  15. package/dist/src/commands/auth.js.map +1 -1
  16. package/dist/src/commands/blob-buckets.js +2 -1
  17. package/dist/src/commands/blob-buckets.js.map +1 -1
  18. package/dist/src/commands/catalog.js +26 -10
  19. package/dist/src/commands/catalog.js.map +1 -1
  20. package/dist/src/commands/collection-type-configs.js +3 -10
  21. package/dist/src/commands/collection-type-configs.js.map +1 -1
  22. package/dist/src/commands/collections.js +736 -19
  23. package/dist/src/commands/collections.js.map +1 -1
  24. package/dist/src/commands/config.js +13 -27
  25. package/dist/src/commands/config.js.map +1 -1
  26. package/dist/src/commands/connections.js +8 -9
  27. package/dist/src/commands/connections.js.map +1 -1
  28. package/dist/src/commands/cron-triggers.js +2 -1
  29. package/dist/src/commands/cron-triggers.js.map +1 -1
  30. package/dist/src/commands/database-type-configs.js +5 -12
  31. package/dist/src/commands/database-type-configs.js.map +1 -1
  32. package/dist/src/commands/databases.js +59 -72
  33. package/dist/src/commands/databases.js.map +1 -1
  34. package/dist/src/commands/documents.d.ts +58 -0
  35. package/dist/src/commands/documents.js +1623 -95
  36. package/dist/src/commands/documents.js.map +1 -1
  37. package/dist/src/commands/email-templates.js +2 -1
  38. package/dist/src/commands/email-templates.js.map +1 -1
  39. package/dist/src/commands/env.d.ts +1 -1
  40. package/dist/src/commands/env.js +89 -43
  41. package/dist/src/commands/env.js.map +1 -1
  42. package/dist/src/commands/feature-flags.js +2 -1
  43. package/dist/src/commands/feature-flags.js.map +1 -1
  44. package/dist/src/commands/functions.d.ts +20 -0
  45. package/dist/src/commands/functions.js +1630 -0
  46. package/dist/src/commands/functions.js.map +1 -0
  47. package/dist/src/commands/group-type-configs.js +2 -1
  48. package/dist/src/commands/group-type-configs.js.map +1 -1
  49. package/dist/src/commands/groups.js +30 -17
  50. package/dist/src/commands/groups.js.map +1 -1
  51. package/dist/src/commands/guides.js +17 -11
  52. package/dist/src/commands/guides.js.map +1 -1
  53. package/dist/src/commands/init.d.ts +12 -15
  54. package/dist/src/commands/init.js +44 -92
  55. package/dist/src/commands/init.js.map +1 -1
  56. package/dist/src/commands/integrations.js +35 -12
  57. package/dist/src/commands/integrations.js.map +1 -1
  58. package/dist/src/commands/locks.js +17 -2
  59. package/dist/src/commands/locks.js.map +1 -1
  60. package/dist/src/commands/metadata-category-configs.js +2 -1
  61. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  62. package/dist/src/commands/metadata.js +8 -1
  63. package/dist/src/commands/metadata.js.map +1 -1
  64. package/dist/src/commands/prompts.js +106 -59
  65. package/dist/src/commands/prompts.js.map +1 -1
  66. package/dist/src/commands/rule-sets.js +3 -10
  67. package/dist/src/commands/rule-sets.js.map +1 -1
  68. package/dist/src/commands/scripts.js +33 -28
  69. package/dist/src/commands/scripts.js.map +1 -1
  70. package/dist/src/commands/secrets.js +2 -1
  71. package/dist/src/commands/secrets.js.map +1 -1
  72. package/dist/src/commands/sessions.js +10 -9
  73. package/dist/src/commands/sessions.js.map +1 -1
  74. package/dist/src/commands/sync-app-settings.js +3 -5
  75. package/dist/src/commands/sync-app-settings.js.map +1 -1
  76. package/dist/src/commands/sync.d.ts +390 -13
  77. package/dist/src/commands/sync.js +2613 -451
  78. package/dist/src/commands/sync.js.map +1 -1
  79. package/dist/src/commands/tokens.js +2 -1
  80. package/dist/src/commands/tokens.js.map +1 -1
  81. package/dist/src/commands/users.js +19 -10
  82. package/dist/src/commands/users.js.map +1 -1
  83. package/dist/src/commands/vars.js +2 -1
  84. package/dist/src/commands/vars.js.map +1 -1
  85. package/dist/src/commands/waitlist.js +2 -1
  86. package/dist/src/commands/waitlist.js.map +1 -1
  87. package/dist/src/commands/webhooks.d.ts +29 -0
  88. package/dist/src/commands/webhooks.js +135 -64
  89. package/dist/src/commands/webhooks.js.map +1 -1
  90. package/dist/src/commands/workflows.d.ts +1 -29
  91. package/dist/src/commands/workflows.js +113 -179
  92. package/dist/src/commands/workflows.js.map +1 -1
  93. package/dist/src/lib/api-client.d.ts +628 -14
  94. package/dist/src/lib/api-client.js +776 -70
  95. package/dist/src/lib/api-client.js.map +1 -1
  96. package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
  97. package/dist/src/lib/app-settings-descriptor.js +9 -1
  98. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  99. package/dist/src/lib/block-selector.d.ts +58 -0
  100. package/dist/src/lib/block-selector.js +92 -0
  101. package/dist/src/lib/block-selector.js.map +1 -0
  102. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +24 -54
  103. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +31 -153
  104. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -1
  105. package/dist/src/lib/collection-export.d.ts +184 -0
  106. package/dist/src/lib/collection-export.js +252 -0
  107. package/dist/src/lib/collection-export.js.map +1 -0
  108. package/dist/src/lib/config-json-field.d.ts +28 -0
  109. package/dist/src/lib/config-json-field.js +56 -0
  110. package/dist/src/lib/config-json-field.js.map +1 -0
  111. package/dist/src/lib/config-object-descriptor.js +88 -6
  112. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  113. package/dist/src/lib/config-payload.d.ts +8 -1
  114. package/dist/src/lib/config-payload.js +49 -4
  115. package/dist/src/lib/config-payload.js.map +1 -1
  116. package/dist/src/lib/config-surface.d.ts +12 -1
  117. package/dist/src/lib/config-surface.js +71 -3
  118. package/dist/src/lib/config-surface.js.map +1 -1
  119. package/dist/src/lib/config.d.ts +31 -13
  120. package/dist/src/lib/config.js +34 -70
  121. package/dist/src/lib/config.js.map +1 -1
  122. package/dist/src/lib/credentials-store.d.ts +37 -22
  123. package/dist/src/lib/credentials-store.js +103 -97
  124. package/dist/src/lib/credentials-store.js.map +1 -1
  125. package/dist/src/lib/db-codegen/dbTypeIR.js +8 -0
  126. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  127. package/dist/src/lib/deprecation.d.ts +22 -0
  128. package/dist/src/lib/deprecation.js +43 -0
  129. package/dist/src/lib/deprecation.js.map +1 -0
  130. package/dist/src/lib/document-export-permissions.d.ts +30 -0
  131. package/dist/src/lib/document-export-permissions.js +54 -0
  132. package/dist/src/lib/document-export-permissions.js.map +1 -0
  133. package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
  134. package/dist/src/lib/document-ingest-artifact.js +505 -0
  135. package/dist/src/lib/document-ingest-artifact.js.map +1 -0
  136. package/dist/src/lib/document-ingest-input.d.ts +51 -0
  137. package/dist/src/lib/document-ingest-input.js +132 -0
  138. package/dist/src/lib/document-ingest-input.js.map +1 -0
  139. package/dist/src/lib/document-ingest-rows.d.ts +137 -0
  140. package/dist/src/lib/document-ingest-rows.js +181 -0
  141. package/dist/src/lib/document-ingest-rows.js.map +1 -0
  142. package/dist/src/lib/document-ingest.d.ts +101 -0
  143. package/dist/src/lib/document-ingest.js +384 -0
  144. package/dist/src/lib/document-ingest.js.map +1 -0
  145. package/dist/src/lib/env-resolver-core.d.ts +89 -18
  146. package/dist/src/lib/env-resolver-core.js +145 -23
  147. package/dist/src/lib/env-resolver-core.js.map +1 -1
  148. package/dist/src/lib/env-resolver.d.ts +18 -3
  149. package/dist/src/lib/env-resolver.js +23 -3
  150. package/dist/src/lib/env-resolver.js.map +1 -1
  151. package/dist/src/lib/function-bundle.d.ts +147 -0
  152. package/dist/src/lib/function-bundle.js +341 -0
  153. package/dist/src/lib/function-bundle.js.map +1 -0
  154. package/dist/src/lib/function-collect.d.ts +123 -0
  155. package/dist/src/lib/function-collect.js +610 -0
  156. package/dist/src/lib/function-collect.js.map +1 -0
  157. package/dist/src/lib/function-db-types.d.ts +202 -0
  158. package/dist/src/lib/function-db-types.js +870 -0
  159. package/dist/src/lib/function-db-types.js.map +1 -0
  160. package/dist/src/lib/function-document-types.d.ts +144 -0
  161. package/dist/src/lib/function-document-types.js +370 -0
  162. package/dist/src/lib/function-document-types.js.map +1 -0
  163. package/dist/src/lib/function-grants-preflight.d.ts +64 -0
  164. package/dist/src/lib/function-grants-preflight.js +105 -0
  165. package/dist/src/lib/function-grants-preflight.js.map +1 -0
  166. package/dist/src/lib/function-log-lines.d.ts +76 -0
  167. package/dist/src/lib/function-log-lines.js +160 -0
  168. package/dist/src/lib/function-log-lines.js.map +1 -0
  169. package/dist/src/lib/function-log-row.d.ts +29 -0
  170. package/dist/src/lib/function-log-row.js +73 -0
  171. package/dist/src/lib/function-log-row.js.map +1 -0
  172. package/dist/src/lib/function-log-tail.d.ts +132 -0
  173. package/dist/src/lib/function-log-tail.js +262 -0
  174. package/dist/src/lib/function-log-tail.js.map +1 -0
  175. package/dist/src/lib/function-run.d.ts +289 -0
  176. package/dist/src/lib/function-run.js +389 -0
  177. package/dist/src/lib/function-run.js.map +1 -0
  178. package/dist/src/lib/function-schema-codegen.d.ts +143 -0
  179. package/dist/src/lib/function-schema-codegen.js +420 -0
  180. package/dist/src/lib/function-schema-codegen.js.map +1 -0
  181. package/dist/src/lib/function-sync.d.ts +459 -0
  182. package/dist/src/lib/function-sync.js +1258 -0
  183. package/dist/src/lib/function-sync.js.map +1 -0
  184. package/dist/src/lib/function-trigger-listing.d.ts +27 -0
  185. package/dist/src/lib/function-trigger-listing.js +70 -0
  186. package/dist/src/lib/function-trigger-listing.js.map +1 -0
  187. package/dist/src/lib/function-typecheck.d.ts +86 -0
  188. package/dist/src/lib/function-typecheck.js +370 -0
  189. package/dist/src/lib/function-typecheck.js.map +1 -0
  190. package/dist/src/lib/function-versions.d.ts +122 -0
  191. package/dist/src/lib/function-versions.js +182 -0
  192. package/dist/src/lib/function-versions.js.map +1 -0
  193. package/dist/src/lib/generated-allowlist.js +4 -0
  194. package/dist/src/lib/generated-allowlist.js.map +1 -1
  195. package/dist/src/lib/generated-config-surfaces.d.ts +2332 -78
  196. package/dist/src/lib/generated-config-surfaces.js +6979 -468
  197. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  198. package/dist/src/lib/generated-sdk-types.d.ts +12 -0
  199. package/dist/src/lib/generated-sdk-types.js +13 -0
  200. package/dist/src/lib/generated-sdk-types.js.map +1 -0
  201. package/dist/src/lib/init-adopt.js +2 -2
  202. package/dist/src/lib/init-adopt.js.map +1 -1
  203. package/dist/src/lib/init-assets.js +3 -3
  204. package/dist/src/lib/init-config.d.ts +1 -1
  205. package/dist/src/lib/init-ios-links.d.ts +6 -5
  206. package/dist/src/lib/init-ios-links.js +9 -8
  207. package/dist/src/lib/init-ios-links.js.map +1 -1
  208. package/dist/src/lib/init-plan.d.ts +1 -1
  209. package/dist/src/lib/init-plan.js +1 -1
  210. package/dist/src/lib/init-xcode.d.ts +6 -5
  211. package/dist/src/lib/init-xcode.js +34 -10
  212. package/dist/src/lib/init-xcode.js.map +1 -1
  213. package/dist/src/lib/ios-app-id.d.ts +34 -0
  214. package/dist/src/lib/ios-app-id.js +69 -0
  215. package/dist/src/lib/ios-app-id.js.map +1 -0
  216. package/dist/src/lib/list-options.d.ts +68 -0
  217. package/dist/src/lib/list-options.js +89 -0
  218. package/dist/src/lib/list-options.js.map +1 -0
  219. package/dist/src/lib/local-state.d.ts +1 -1
  220. package/dist/src/lib/local-state.js +1 -1
  221. package/dist/src/lib/local-test-cases.d.ts +1 -1
  222. package/dist/src/lib/local-test-cases.js +2 -1
  223. package/dist/src/lib/local-test-cases.js.map +1 -1
  224. package/dist/src/lib/log-inspection.d.ts +152 -5
  225. package/dist/src/lib/log-inspection.js +179 -2
  226. package/dist/src/lib/log-inspection.js.map +1 -1
  227. package/dist/src/lib/logout-admin-session.d.ts +33 -0
  228. package/dist/src/lib/logout-admin-session.js +70 -0
  229. package/dist/src/lib/logout-admin-session.js.map +1 -0
  230. package/dist/src/lib/output.d.ts +15 -0
  231. package/dist/src/lib/output.js +28 -0
  232. package/dist/src/lib/output.js.map +1 -1
  233. package/dist/src/lib/paginate.d.ts +15 -0
  234. package/dist/src/lib/paginate.js +17 -0
  235. package/dist/src/lib/paginate.js.map +1 -1
  236. package/dist/src/lib/project-config.d.ts +38 -21
  237. package/dist/src/lib/project-config.js +57 -47
  238. package/dist/src/lib/project-config.js.map +1 -1
  239. package/dist/src/lib/prompt-cost-format.d.ts +11 -0
  240. package/dist/src/lib/prompt-cost-format.js +41 -0
  241. package/dist/src/lib/prompt-cost-format.js.map +1 -0
  242. package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
  243. package/dist/src/lib/prompt-schema-codegen.js +462 -0
  244. package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
  245. package/dist/src/lib/refresh-admin-credentials.d.ts +9 -1
  246. package/dist/src/lib/refresh-admin-credentials.js +22 -2
  247. package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
  248. package/dist/src/lib/resolve-owner.d.ts +19 -0
  249. package/dist/src/lib/resolve-owner.js +20 -0
  250. package/dist/src/lib/resolve-owner.js.map +1 -0
  251. package/dist/src/lib/skill-installer.d.ts +49 -3
  252. package/dist/src/lib/skill-installer.js +275 -100
  253. package/dist/src/lib/skill-installer.js.map +1 -1
  254. package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
  255. package/dist/src/lib/snapshot-audit-source.js +58 -0
  256. package/dist/src/lib/snapshot-audit-source.js.map +1 -0
  257. package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
  258. package/dist/src/lib/snapshot-audit-store.js +196 -0
  259. package/dist/src/lib/snapshot-audit-store.js.map +1 -0
  260. package/dist/src/lib/snapshot-audit.d.ts +207 -0
  261. package/dist/src/lib/snapshot-audit.js +431 -0
  262. package/dist/src/lib/snapshot-audit.js.map +1 -0
  263. package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
  264. package/dist/src/lib/snapshot-build-rows.js +87 -0
  265. package/dist/src/lib/snapshot-build-rows.js.map +1 -0
  266. package/dist/src/lib/snapshot-build.d.ts +50 -0
  267. package/dist/src/lib/snapshot-build.js +111 -0
  268. package/dist/src/lib/snapshot-build.js.map +1 -0
  269. package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
  270. package/dist/src/lib/snapshot-manifest-layout.js +70 -0
  271. package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
  272. package/dist/src/lib/snapshots.d.ts +8 -9
  273. package/dist/src/lib/snapshots.js +20 -83
  274. package/dist/src/lib/snapshots.js.map +1 -1
  275. package/dist/src/lib/step-run-table.d.ts +43 -0
  276. package/dist/src/lib/step-run-table.js +129 -0
  277. package/dist/src/lib/step-run-table.js.map +1 -0
  278. package/dist/src/lib/storage-pending-retry.d.ts +26 -0
  279. package/dist/src/lib/storage-pending-retry.js +42 -0
  280. package/dist/src/lib/storage-pending-retry.js.map +1 -0
  281. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
  282. package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
  283. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
  284. package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
  285. package/dist/src/lib/swift-codegen/banners.js +25 -0
  286. package/dist/src/lib/swift-codegen/banners.js.map +1 -0
  287. package/dist/src/lib/swift-codegen/dbGenerator.js +19 -7
  288. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
  289. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
  290. package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
  291. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
  292. package/dist/src/lib/swift-codegen/generator.d.ts +7 -1
  293. package/dist/src/lib/swift-codegen/generator.js +28 -11
  294. package/dist/src/lib/swift-codegen/generator.js.map +1 -1
  295. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +15 -0
  296. package/dist/src/lib/swift-codegen/schemaToSwift.js +21 -4
  297. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  298. package/dist/src/lib/sync-paths.d.ts +72 -55
  299. package/dist/src/lib/sync-paths.js +97 -100
  300. package/dist/src/lib/sync-paths.js.map +1 -1
  301. package/dist/src/lib/sync-resource-types.d.ts +23 -4
  302. package/dist/src/lib/sync-resource-types.js +106 -8
  303. package/dist/src/lib/sync-resource-types.js.map +1 -1
  304. package/dist/src/lib/sync-selectors.d.ts +45 -2
  305. package/dist/src/lib/sync-selectors.js +66 -5
  306. package/dist/src/lib/sync-selectors.js.map +1 -1
  307. package/dist/src/lib/template.d.ts +2 -2
  308. package/dist/src/lib/template.js +2 -2
  309. package/dist/src/lib/test-case-keys.d.ts +1 -1
  310. package/dist/src/lib/test-case-keys.js +1 -1
  311. package/dist/src/lib/test-case-variables.d.ts +14 -0
  312. package/dist/src/lib/test-case-variables.js +42 -0
  313. package/dist/src/lib/test-case-variables.js.map +1 -1
  314. package/dist/src/lib/toml-database-config.js +19 -2
  315. package/dist/src/lib/toml-database-config.js.map +1 -1
  316. package/dist/src/lib/webhook-deliver.d.ts +209 -0
  317. package/dist/src/lib/webhook-deliver.js +519 -0
  318. package/dist/src/lib/webhook-deliver.js.map +1 -0
  319. package/dist/src/lib/workflow-codegen/generator.d.ts +1 -1
  320. package/dist/src/lib/workflow-codegen/generator.js +1 -1
  321. package/dist/src/lib/workflow-toml-validator.d.ts +17 -8
  322. package/dist/src/lib/workflow-toml-validator.js +25 -12
  323. package/dist/src/lib/workflow-toml-validator.js.map +1 -1
  324. package/dist/src/lib/workflow-usage.d.ts +196 -0
  325. package/dist/src/lib/workflow-usage.js +310 -0
  326. package/dist/src/lib/workflow-usage.js.map +1 -0
  327. package/dist/src/types/index.d.ts +12 -2
  328. package/package.json +5 -4
@@ -1,4 +1,5 @@
1
1
  import { type ListEnvelope } from "./paginate.js";
2
+ import { type GlobalAppRef, type WorkflowUsageReport } from "./workflow-usage.js";
2
3
  /**
3
4
  * Metadata for a single bucket blob, as returned by the metadata endpoint
4
5
  * `GET blob-buckets/:bucketId/blobs/:blobId/metadata`. Mirrors the published
@@ -41,6 +42,20 @@ export declare class ConflictError extends ApiError {
41
42
  expectedModifiedAt: string;
42
43
  constructor(message: string, serverModifiedAt: string, expectedModifiedAt: string, details?: Record<string, any>);
43
44
  }
45
+ /**
46
+ * The `ApiError` for a non-OK response read by a raw `fetch` call (#3403).
47
+ *
48
+ * The blob methods and the two document-artifact transfers build their own
49
+ * `fetch` call, so they never reached `parseErrorResponse` and never carried a
50
+ * `code` — a download refusal surfaced as `response.statusText` and an upload
51
+ * refusal as the raw JSON body shown to the operator as the message. This
52
+ * routes them through the same parser every other call site uses while keeping
53
+ * their human prefixes.
54
+ *
55
+ * Named for the blob paths it was written for; every raw-`fetch` path in this
56
+ * file answers through it now.
57
+ */
58
+ export declare function blobFailure(response: Response, prefix: string): Promise<ApiError>;
44
59
  /**
45
60
  * Parsed shape of a non-OK HTTP response body.
46
61
  *
@@ -211,17 +226,40 @@ interface AnalyticsUserSummary {
211
226
  firstSeen: string;
212
227
  lastSeen: string;
213
228
  eventCount: number;
229
+ /**
230
+ * When the user joined this app (#3127) — an ISO timestamp, or `null` when
231
+ * no event of theirs carries a server-stamped join time yet.
232
+ */
233
+ signedUpAt?: string | null;
234
+ /** The same instant as a `YYYY-MM-DD` UTC day, or `null`. */
235
+ signupDay?: string | null;
236
+ }
237
+ /**
238
+ * A `users.top` row. `firstSeen` is the user's first event ever, invariant
239
+ * under `windowDays`; `firstSeenInWindow` is the window-relative one (#3126).
240
+ * `users.search` rows carry no `firstSeenInWindow`: it queries the full
241
+ * retained range, so its `firstSeen` is already the all-time value.
242
+ */
243
+ interface AnalyticsTopUserRow extends AnalyticsUserSummary {
244
+ firstSeenInWindow: string;
214
245
  }
215
246
  interface AnalyticsTopUsersResponse {
216
247
  windowDays: number;
217
248
  limit: number;
218
- results: AnalyticsUserSummary[];
249
+ results: AnalyticsTopUserRow[];
219
250
  _timing: AnalyticsTiming;
220
251
  }
221
252
  interface AnalyticsUserSearchResponse {
222
253
  query: string;
223
254
  limit: number;
224
255
  results: AnalyticsUserSummary[];
256
+ /** #3127 — the signup window this answer was filtered to, `null` when none. */
257
+ signupStartDay?: string | null;
258
+ signupEndDay?: string | null;
259
+ /** The row offset this page started at. */
260
+ offset?: number;
261
+ /** True when more rows match than this page returned; page with `offset`. */
262
+ truncated?: boolean;
225
263
  }
226
264
  interface AnalyticsUserDetailResponse {
227
265
  user: {
@@ -257,6 +295,9 @@ interface AnalyticsUserSnapshotResponse {
257
295
  interface AnalyticsEventRow {
258
296
  timestamp: string;
259
297
  user_ulid: string;
298
+ /** Display name for `user_ulid` — the system principal's `System`, else
299
+ * null. The id itself is unchanged (#3168). */
300
+ user_name: string | null;
260
301
  action: string;
261
302
  feature: string;
262
303
  route: string;
@@ -391,6 +432,15 @@ interface PromptAnalyticsSummary {
391
432
  medianDurationMs: number;
392
433
  p95DurationMs: number;
393
434
  totalTokens: number;
435
+ /**
436
+ * #3787 — how many of the window's executions reported a cost, and what they
437
+ * spent. `totalCost` / `avgCost` are `null` (never `0`) when none did, and
438
+ * `executionsWithCost < executions` means the figures cover part of the
439
+ * window.
440
+ */
441
+ executionsWithCost?: number;
442
+ totalCost?: number | null;
443
+ avgCost?: number | null;
394
444
  }
395
445
  interface TopPromptsResponse {
396
446
  windowDays: number;
@@ -451,8 +501,24 @@ export interface DatabaseBatchOperation {
451
501
  */
452
502
  export declare function normalizeDatabaseOperationResult(raw: unknown): unknown;
453
503
  export declare class ApiClient {
504
+ /**
505
+ * Loaded on first use (`ensureAuthenticated`), never in a constructor.
506
+ *
507
+ * There used to be an `apiClient` singleton constructed at MODULE scope, so
508
+ * a constructor body ran while `bin/primitive.ts` was still being imported —
509
+ * before its first `try`, and before any command had said whether it needed
510
+ * the project at all. `loadCredentials()` resolves the environment, so on a
511
+ * project still holding the pre-#3153 layout that read threw the stale-layout
512
+ * refusal out of module evaluation, where not even the `uncaughtException`
513
+ * handler can reach it: the user got Node's raw stack trace, and `guides
514
+ * get` — which reads nothing from the project — died with it (#3273). The
515
+ * singleton is gone (#3154, it had no callers) and the read stays lazy,
516
+ * which is what keeps that shape from coming back.
517
+ *
518
+ * Nothing is lost by waiting, and one thing is gained: a `login` earlier in
519
+ * the same process is visible to a later request.
520
+ */
454
521
  private credentials;
455
- constructor();
456
522
  private ensureAuthenticated;
457
523
  private refreshToken;
458
524
  request<T = any>(path: string, options?: RequestInit): Promise<T>;
@@ -461,6 +527,34 @@ export declare class ApiClient {
461
527
  put<T = any>(path: string, body?: any): Promise<T>;
462
528
  patch<T = any>(path: string, body?: any): Promise<T>;
463
529
  delete<T = any>(path: string): Promise<T>;
530
+ /**
531
+ * One page of the apps the caller can reach.
532
+ *
533
+ * The route paginates cursor-style (default pageSize=25, cap=100). This
534
+ * method used to walk the whole chain so `primitive apps list` could not
535
+ * truncate at 25 (#436); since #3646 the page boundary belongs to the
536
+ * caller instead — `apps list` declares `--limit`/`--cursor` and prints the
537
+ * `hasMore`/`nextCursor` the server reported, and the aggregate readers that
538
+ * really do mean "every app" call `listAllApps()`.
539
+ */
540
+ listAppsPage(params?: {
541
+ limit?: number;
542
+ cursor?: string;
543
+ }): Promise<{
544
+ items: Array<{
545
+ id: string;
546
+ name: string;
547
+ role?: string;
548
+ }>;
549
+ hasMore?: boolean;
550
+ nextCursor?: string | null;
551
+ }>;
552
+ /**
553
+ * Every app the caller can reach, cursor chain walked (#436).
554
+ *
555
+ * For readers that genuinely need the whole set — an app picker, a sweep —
556
+ * rather than the one page `apps list` prints.
557
+ */
464
558
  listApps(): Promise<{
465
559
  apps: Array<{
466
560
  id: string;
@@ -468,6 +562,22 @@ export declare class ApiClient {
468
562
  role?: string;
469
563
  }>;
470
564
  }>;
565
+ /**
566
+ * Every app on the server, not just the caller's own.
567
+ *
568
+ * Deliberately separate from `listApps()`, whose contract is "apps assigned
569
+ * to me" (`GET /admin/api/admins/me/apps`, backed by `admin.queryApps()`) —
570
+ * the contract every other command depends on. `analytics workflow-usage
571
+ * --all-apps` has to reach apps nobody is assigned to, which is the global
572
+ * route `GET /admin/api/apps` (`App.iterateAll()`), and that route
573
+ * identifies an app as `appId` rather than `id` (D3130-001).
574
+ *
575
+ * One drain of that route is lossy — its cursor re-scans `App.iterateAll()`
576
+ * from the start of each page, so a list that changes under it both repeats
577
+ * and drops rows — so the walk is the union of repeated drains
578
+ * (`drainAppsUntilConverged`, which carries the measurement).
579
+ */
580
+ listAllAppsGlobal(): Promise<GlobalAppRef[]>;
471
581
  createApp(data: {
472
582
  name: string;
473
583
  initialAdminEmail?: string;
@@ -495,8 +605,13 @@ export declare class ApiClient {
495
605
  cursor?: string;
496
606
  }): Promise<{
497
607
  items: any[];
608
+ hasMore?: boolean;
498
609
  nextCursor?: string | null;
499
610
  }>;
611
+ /**
612
+ * @deprecated Use {@link setUserAvailability} with `"disable"`
613
+ * (`PUT /admin/api/apps/:appId/users/:userId/disable`) instead (#518).
614
+ */
500
615
  removeUser(appId: string, userId: string): Promise<void>;
501
616
  /**
502
617
  * #2803 — take a user's access away, or give it back. Distinct from
@@ -569,6 +684,8 @@ export declare class ApiClient {
569
684
  limit?: number;
570
685
  cursor?: string;
571
686
  }): Promise<{
687
+ items: any[];
688
+ /** @deprecated Read `items`; `grants` is a legacy alias of it (#1982). */
572
689
  grants: any[];
573
690
  nextCursor?: string | null;
574
691
  hasMore?: boolean;
@@ -580,6 +697,7 @@ export declare class ApiClient {
580
697
  limit?: number;
581
698
  }): Promise<{
582
699
  items: any[];
700
+ hasMore?: boolean;
583
701
  nextCursor?: string | null;
584
702
  }>;
585
703
  /** Integration detail (#2631: `accessRule` is on the detail, not the list summary). */
@@ -609,7 +727,9 @@ export declare class ApiClient {
609
727
  status?: string;
610
728
  from?: string;
611
729
  to?: string;
612
- source?: "user" | "admin" | "test" | "workflow";
730
+ source?: "user" | "admin" | "test" | "workflow" | "function";
731
+ /** #3691 — only the calls this run made, workflow run or function run. */
732
+ runId?: string;
613
733
  }): Promise<any[]>;
614
734
  listWorkflowRunIntegrationLogs(appId: string, runId: string, params?: {
615
735
  limit?: number;
@@ -643,6 +763,7 @@ export declare class ApiClient {
643
763
  limit?: number;
644
764
  }): Promise<{
645
765
  items: any[];
766
+ hasMore?: boolean;
646
767
  nextCursor?: string | null;
647
768
  }>;
648
769
  getWebhook(appId: string, webhookId: string): Promise<any>;
@@ -663,6 +784,176 @@ export declare class ApiClient {
663
784
  * and refused on every configuration write path.
664
785
  */
665
786
  setWebhookAvailability(appId: string, webhookId: string, action: "enable" | "disable"): Promise<any>;
787
+ listFunctions(appId: string): Promise<{
788
+ items: any[];
789
+ }>;
790
+ getFunction(appId: string, functionId: string): Promise<any>;
791
+ createFunction(appId: string, payload: any): Promise<any>;
792
+ updateFunction(appId: string, functionId: string, payload: any): Promise<any>;
793
+ /**
794
+ * Archive a function, or destroy it with `hard`. Archiving KEEPS the key
795
+ * reserved in the app's single key namespace; the hard delete is what
796
+ * releases it, destroys every config version and removes the R2 objects.
797
+ */
798
+ deleteFunction(appId: string, functionId: string, options?: {
799
+ hard?: boolean;
800
+ }): Promise<ArchiveEnvelope>;
801
+ /** #2803 — the operational verb pair for a server function. */
802
+ setFunctionAvailability(appId: string, functionId: string, action: "enable" | "disable"): Promise<any>;
803
+ /** Every config version of a function, oldest first. */
804
+ /**
805
+ * A function's runs, newest first (#3181).
806
+ *
807
+ * A function run has no `workflowId`, so no workflow runs listing can see
808
+ * it — this is the only surface that lists one. Cursor-paginated like the
809
+ * other admin listings.
810
+ */
811
+ listFunctionRuns(appId: string, functionId: string, params?: {
812
+ limit?: number;
813
+ cursor?: string;
814
+ }): Promise<{
815
+ items: any[];
816
+ nextCursor?: string | null;
817
+ }>;
818
+ /**
819
+ * A function run's step trace — #3348.
820
+ *
821
+ * The function-scoped twin of `getWorkflowStepRuns`, and it answers with the
822
+ * same rows in the same shape: `workflows/:idOrKey/runs/...` resolves its
823
+ * first argument to a workflow DEFINITION, which a function id and a function
824
+ * key alike miss, so a durable run's steps needed a route that addresses the
825
+ * run by the function that owns it.
826
+ */
827
+ getFunctionStepRuns(appId: string, functionId: string, runId: string): Promise<{
828
+ items: any[];
829
+ }>;
830
+ /**
831
+ * End a function run that will not settle — #3348.
832
+ *
833
+ * `terminated: false` means the run had already settled and the route
834
+ * reported its outcome instead of overwriting it.
835
+ */
836
+ terminateFunctionRun(appId: string, functionId: string, runId: string): Promise<{
837
+ runId: string;
838
+ status: string;
839
+ terminated: boolean;
840
+ endedAt?: string | null;
841
+ instanceTerminated?: boolean;
842
+ }>;
843
+ /**
844
+ * A function's invocation records, newest first — #3287.
845
+ *
846
+ * The ADMIN route, beside the runs listing above and for the same reason:
847
+ * the CLI acts as an operator, not as a member of the app. The app-API twin
848
+ * (`functions.logs`) is what a FUNCTION reads through the SDK profile.
849
+ */
850
+ listFunctionLogs(appId: string, functionId: string, params?: {
851
+ limit?: number;
852
+ cursor?: string;
853
+ runId?: string;
854
+ }): Promise<{
855
+ items: any[];
856
+ nextCursor?: string | null;
857
+ }>;
858
+ /**
859
+ * One invocation record by its id — #3448, behind `functions logs
860
+ * --invocation <id>`.
861
+ *
862
+ * The id the invoke envelope answered with. A record that never existed,
863
+ * one of ANOTHER function, and one the seven-day TTL has expired all answer
864
+ * the same 404, which is what the listing's own filter promises.
865
+ */
866
+ getFunctionLog(appId: string, functionId: string, invocationId: string): Promise<any>;
867
+ /**
868
+ * One function run, RECONCILED against the engine — #3448, what
869
+ * `functions runs wait` polls.
870
+ *
871
+ * NOT the runs listing: that reports the STORED status, and a durable run's
872
+ * row stays `running` until something asks the engine, so a wait built on it
873
+ * would never settle.
874
+ */
875
+ getFunctionRun(appId: string, functionId: string, runId: string): Promise<{
876
+ status: any;
877
+ run: any;
878
+ slice?: any;
879
+ }>;
880
+ /**
881
+ * The operator's own APP user — #3448 D3448-009.
882
+ *
883
+ * `getMe()` reads the ADMIN profile (`/admin/api/me`); this is the
884
+ * app-scoped route, which answers the app user `requireAppPermission`
885
+ * provisions for an admin and the `appRole` it gave them. That is the
886
+ * identity a `functions invoke` runs under by default, and printing it is
887
+ * how an operator knows their call bypassed the function's `access` gate.
888
+ */
889
+ getAppProfile(appId: string): Promise<{
890
+ userId: string;
891
+ email: string | null;
892
+ name?: string | null;
893
+ appRole: string;
894
+ appId: string;
895
+ }>;
896
+ /**
897
+ * Invoke a function and hand back the ANSWER, whatever its HTTP status —
898
+ * #3448 D3448-010.
899
+ *
900
+ * `request` throws an `ApiError` on any non-2xx, which is right for every
901
+ * other verb and wrong for this one: a 429 carries a `Retry-After` an
902
+ * operator needs to see, and a 409 mode mismatch carries the version's real
903
+ * mode. Rendering those from an exception means re-deriving what the server
904
+ * already said. So this returns the envelope with its status and its retry
905
+ * hint, and throws only when the request did not complete at all.
906
+ *
907
+ * `bearer` is the `--user` path's minted token; absent, the CLI's own
908
+ * credentials. `mode` is ALWAYS sent (D3448-012): it is what makes the
909
+ * server, not the CLI, the authority on a wrong verb.
910
+ */
911
+ invokeFunction(appId: string, functionKey: string, body: Record<string, unknown>, options?: {
912
+ bearer?: string;
913
+ asSystem?: boolean;
914
+ /**
915
+ * Which runtime this call means — #3482. The ROUTE is the selector:
916
+ * `POST functions/{key}` runs the function inside the request and
917
+ * `POST functions/{key}/start` runs it as a task. The admin-only system
918
+ * door is ONE route for both, so `--as system` keeps naming its runtime
919
+ * in the body (F-3482-007); phase 7's rename may fold it.
920
+ */
921
+ runtime?: "request" | "task";
922
+ }): Promise<{
923
+ httpStatus: number;
924
+ retryAfterSeconds: number | null;
925
+ body: any;
926
+ }>;
927
+ /**
928
+ * A function's versions, newest first (#3462).
929
+ *
930
+ * Paging is opt-in on the server: with no `limit` and no `cursor` every
931
+ * version comes back, which is what this method did before paging existed and
932
+ * what an already-installed CLI still asks for. A caller that passes either
933
+ * gets the shared `{ items, hasMore, nextCursor }` page.
934
+ */
935
+ listFunctionConfigs(appId: string, functionId: string, options?: {
936
+ limit?: number;
937
+ cursor?: string;
938
+ }): Promise<{
939
+ items: any[];
940
+ hasMore: boolean;
941
+ nextCursor?: string | null;
942
+ }>;
943
+ /**
944
+ * Point the function at one of its OWN existing versions (#3462). Creates no
945
+ * version; the activated version's capabilities, limits and triggers apply
946
+ * from the next call.
947
+ */
948
+ activateFunctionConfig(appId: string, functionId: string, configId: string): Promise<any>;
949
+ getFunctionConfig(appId: string, functionId: string, configId: string): Promise<any>;
950
+ /**
951
+ * The stored envelope: the authored TOML bytes, every source file and the
952
+ * built bundle, all base64. This is what `config pull` writes back verbatim.
953
+ */
954
+ getFunctionConfigEnvelope(appId: string, functionId: string, configId: string): Promise<any>;
955
+ /** Push a config version. The server verifies `contentHash` itself. */
956
+ pushFunctionConfig(appId: string, functionId: string, payload: any): Promise<any>;
666
957
  /** #2803 — the operational verb pair for a prompt (admin API). */
667
958
  setPromptAvailability(appId: string, promptId: string, action: "enable" | "disable"): Promise<any>;
668
959
  /** #2803 — the operational verb pair for an integration (admin API). */
@@ -696,6 +987,7 @@ export declare class ApiClient {
696
987
  cursor?: string;
697
988
  }): Promise<{
698
989
  items: unknown[];
990
+ hasMore?: boolean;
699
991
  nextCursor?: string | null;
700
992
  }>;
701
993
  listSessions(appId: string, userId: string, params?: {
@@ -703,8 +995,27 @@ export declare class ApiClient {
703
995
  cursor?: string;
704
996
  }): Promise<{
705
997
  items: unknown[];
998
+ hasMore?: boolean;
706
999
  nextCursor?: string | null;
707
1000
  }>;
1001
+ /**
1002
+ * One page of admin sessions (#3885): the caller's own, or — for a
1003
+ * super-admin — the admin `adminId` names.
1004
+ */
1005
+ listAdminSessions(params?: {
1006
+ adminId?: string;
1007
+ limit?: number;
1008
+ cursor?: string;
1009
+ }): Promise<{
1010
+ items: unknown[];
1011
+ hasMore?: boolean;
1012
+ nextCursor?: string | null;
1013
+ }>;
1014
+ /** Revoke an admin session (idempotent). */
1015
+ revokeAdminSession(sessionId: string): Promise<{
1016
+ sessionId: string;
1017
+ revokedAt: string;
1018
+ }>;
708
1019
  testWebhook(appId: string, webhookId: string, payload?: any): Promise<any>;
709
1020
  /**
710
1021
  * Run a webhook's configured verifier over headers and a body captured from
@@ -723,7 +1034,11 @@ export declare class ApiClient {
723
1034
  locks: any[];
724
1035
  }>;
725
1036
  getLockStatus(appId: string, key: string): Promise<any>;
726
- acquireLock(appId: string, key: string, ttlMs: number): Promise<any>;
1037
+ /**
1038
+ * #3562 — `owner` is sent only when one was given, so a call that names none
1039
+ * composes byte for byte the body it always did.
1040
+ */
1041
+ acquireLock(appId: string, key: string, ttlMs: number, owner?: string): Promise<any>;
727
1042
  releaseLock(appId: string, key: string, handleId: string): Promise<any>;
728
1043
  listCronTriggers(appId: string): Promise<{
729
1044
  items: any[];
@@ -798,6 +1113,7 @@ export declare class ApiClient {
798
1113
  cursor?: string;
799
1114
  }): Promise<{
800
1115
  items: any[];
1116
+ hasMore?: boolean;
801
1117
  nextCursor?: string | null;
802
1118
  }>;
803
1119
  getPrompt(appId: string, promptId: string): Promise<any>;
@@ -897,6 +1213,7 @@ export declare class ApiClient {
897
1213
  cursor?: string;
898
1214
  }): Promise<{
899
1215
  items: any[];
1216
+ hasMore?: boolean;
900
1217
  nextCursor?: string;
901
1218
  }>;
902
1219
  getTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<any>;
@@ -975,9 +1292,20 @@ export declare class ApiClient {
975
1292
  cursor?: string;
976
1293
  }): Promise<{
977
1294
  items: any[];
1295
+ hasMore?: boolean;
978
1296
  nextCursor?: string | null;
979
1297
  }>;
980
1298
  getWorkflow(appId: string, workflowId: string): Promise<any>;
1299
+ /**
1300
+ * One app's workflow step usage report (#3132).
1301
+ *
1302
+ * `windowDays` is omitted from the query when the caller did not ask for a
1303
+ * window, so the server applies its own default rather than the CLI
1304
+ * restating it on the wire.
1305
+ */
1306
+ getWorkflowUsage(appId: string, params?: {
1307
+ windowDays?: number;
1308
+ }): Promise<WorkflowUsageReport>;
981
1309
  createWorkflow(appId: string, payload: any): Promise<any>;
982
1310
  updateWorkflow(appId: string, workflowId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
983
1311
  /**
@@ -1108,8 +1436,15 @@ export declare class ApiClient {
1108
1436
  }): Promise<AnalyticsDailyActiveResponse>;
1109
1437
  getAnalyticsCohortRetention(appId: string): Promise<AnalyticsCohortResponse>;
1110
1438
  getAnalyticsUserSearch(appId: string, params: {
1111
- q: string;
1439
+ q?: string;
1112
1440
  limit?: number;
1441
+ /** #3127 — one UTC calendar day, `YYYY-MM-DD`. */
1442
+ signupDay?: string;
1443
+ /** #3127 — an inclusive range of at most 90 UTC calendar days. */
1444
+ signupStartDay?: string;
1445
+ signupEndDay?: string;
1446
+ /** #3127 — row offset, accepted only with a signup filter. */
1447
+ offset?: number;
1113
1448
  }): Promise<AnalyticsUserSearchResponse>;
1114
1449
  getAnalyticsUserDetail(appId: string, userUlid: string): Promise<AnalyticsUserDetailResponse>;
1115
1450
  getAnalyticsUserSnapshot(appId: string, userUlid: string): Promise<AnalyticsUserSnapshotResponse>;
@@ -1136,10 +1471,32 @@ export declare class ApiClient {
1136
1471
  windowDays?: number;
1137
1472
  limit?: number;
1138
1473
  }): Promise<TopPromptsResponse>;
1474
+ /**
1475
+ * The signed-in admin's own profile, `role` included.
1476
+ *
1477
+ * The role is read from the server rather than from the cached credentials
1478
+ * file: a role changed after login would otherwise let a stale local record
1479
+ * decide an authorization question.
1480
+ */
1481
+ getMe(): Promise<{
1482
+ adminId: string;
1483
+ email: string;
1484
+ name: string;
1485
+ role: string;
1486
+ createdAt?: string;
1487
+ }>;
1139
1488
  listAllAdmins(params?: {
1140
1489
  limit?: number;
1141
1490
  cursor?: string;
1142
- }): Promise<any>;
1491
+ }): Promise<{
1492
+ items: any[];
1493
+ /** @deprecated Read `items`; `admins` is a legacy alias of it (#1982). */
1494
+ admins: any[];
1495
+ hasMore?: boolean;
1496
+ nextCursor: string | null;
1497
+ /** @deprecated Read `nextCursor`; `cursor` is a legacy alias of it (#1316, #1982). */
1498
+ cursor: string | null;
1499
+ }>;
1143
1500
  searchAdminByEmail(email: string): Promise<any>;
1144
1501
  getAdminApps(email: string): Promise<any>;
1145
1502
  updateAdminSettings(adminId: string, data: {
@@ -1288,9 +1645,22 @@ export declare class ApiClient {
1288
1645
  * `options.owner` narrows the result to the databases that user created; the
1289
1646
  * server resolves it through the `databasesByCreator` index (#1965).
1290
1647
  */
1648
+ /**
1649
+ * One page of an app's databases (#3646).
1650
+ *
1651
+ * `databases list` used to walk the chain here. The route pages, so the page
1652
+ * boundary belongs to the caller: the verb declares `--limit`/`--cursor` and
1653
+ * prints what came back.
1654
+ */
1291
1655
  listDatabases(appId: string, options?: {
1292
1656
  owner?: string;
1293
- }): Promise<any[]>;
1657
+ limit?: number;
1658
+ cursor?: string;
1659
+ }): Promise<{
1660
+ items: any[];
1661
+ hasMore?: boolean;
1662
+ nextCursor?: string | null;
1663
+ }>;
1294
1664
  createDatabase(appId: string, data: {
1295
1665
  title: string;
1296
1666
  databaseType?: string;
@@ -1305,13 +1675,29 @@ export declare class ApiClient {
1305
1675
  *
1306
1676
  * The HTTP path stays `/metadata` because the wire field name is still
1307
1677
  * `metadata`; only the client/CLI-facing helper names were reframed.
1678
+ *
1679
+ * @deprecated Use resource metadata categories instead (`primitive metadata
1680
+ * get database <id> <category>`, #1420, #1815).
1308
1681
  */
1309
1682
  getDatabaseCelContext(appId: string, databaseId: string): Promise<any>;
1310
- /** Update a database's CEL context dict (merge with existing). */
1683
+ /**
1684
+ * Update a database's CEL context dict (merge with existing).
1685
+ *
1686
+ * @deprecated Use resource metadata categories instead (`primitive metadata
1687
+ * set database <id> <category>`, #1420, #1815).
1688
+ */
1311
1689
  updateDatabaseCelContext(appId: string, databaseId: string, celContext: Record<string, any>): Promise<any>;
1312
- /** @deprecated Use {@link getDatabaseCelContext} instead. */
1690
+ /**
1691
+ * @deprecated Database CEL context is deprecated; use resource metadata
1692
+ * categories instead (`primitive metadata get database <id> <category>`,
1693
+ * #1420, #1815).
1694
+ */
1313
1695
  getDatabaseMetadata(appId: string, databaseId: string): Promise<any>;
1314
- /** @deprecated Use {@link updateDatabaseCelContext} instead. */
1696
+ /**
1697
+ * @deprecated Database CEL context is deprecated; use resource metadata
1698
+ * categories instead (`primitive metadata set database <id> <category>`,
1699
+ * #1420, #1815).
1700
+ */
1315
1701
  updateDatabaseMetadata(appId: string, databaseId: string, metadata: Record<string, any>): Promise<any>;
1316
1702
  listDatabasePermissions(appId: string, databaseId: string): Promise<any[]>;
1317
1703
  addDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
@@ -1445,6 +1831,10 @@ export declare class ApiClient {
1445
1831
  databaseType: string;
1446
1832
  ruleSetId?: string | null;
1447
1833
  triggers?: Record<string, any> | null;
1834
+ /**
1835
+ * @deprecated The TOML `type.celContextAccess` expression. Use resource
1836
+ * metadata categories instead (#1420, #1815).
1837
+ */
1448
1838
  metadataAccess?: string | null;
1449
1839
  defaultAccess?: string | null;
1450
1840
  autoPopulatedFields?: Record<string, any> | null;
@@ -1457,6 +1847,10 @@ export declare class ApiClient {
1457
1847
  updateDatabaseTypeConfig(appId: string, databaseType: string, data: {
1458
1848
  ruleSetId?: string | null;
1459
1849
  triggers?: Record<string, any> | null;
1850
+ /**
1851
+ * @deprecated The TOML `type.celContextAccess` expression. Use resource
1852
+ * metadata categories instead (#1420, #1815).
1853
+ */
1460
1854
  metadataAccess?: string | null;
1461
1855
  defaultAccess?: string | null;
1462
1856
  autoPopulatedFields?: Record<string, any> | null;
@@ -1545,8 +1939,18 @@ export declare class ApiClient {
1545
1939
  description?: string;
1546
1940
  }): Promise<any>;
1547
1941
  deleteGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1942
+ /**
1943
+ * One page of a group's members.
1944
+ *
1945
+ * The route paginates cursor-style (no default limit, cap 200) and reports
1946
+ * the boundary, so `groups members list` carries `--limit`/`--cursor` and
1947
+ * forwards them (#3646) rather than printing a first page that claims to be
1948
+ * the whole membership.
1949
+ */
1548
1950
  listGroupMembers(appId: string, groupType: string, groupId: string, options?: {
1549
1951
  include?: "profiles";
1952
+ limit?: number;
1953
+ cursor?: string;
1550
1954
  }): Promise<{
1551
1955
  items: any[];
1552
1956
  nextCursor?: string;
@@ -1572,6 +1976,7 @@ export declare class ApiClient {
1572
1976
  cursor?: string;
1573
1977
  }): Promise<{
1574
1978
  items: any[];
1979
+ hasMore?: boolean;
1575
1980
  nextCursor?: string | null;
1576
1981
  }>;
1577
1982
  listAllCollections(appId: string, params?: {
@@ -1579,12 +1984,26 @@ export declare class ApiClient {
1579
1984
  cursor?: string;
1580
1985
  }): Promise<{
1581
1986
  items: any[];
1987
+ hasMore?: boolean;
1582
1988
  nextCursor?: string | null;
1583
1989
  }>;
1584
1990
  createCollection(appId: string, data: {
1585
1991
  name: string;
1586
1992
  description?: string;
1993
+ /**
1994
+ * Which rule set governs the collection, and which context it belongs
1995
+ * to. Both are immutable after creation, so a migration has to send them
1996
+ * with the create or never (#3643).
1997
+ */
1998
+ collectionType?: string;
1999
+ contextId?: string;
1587
2000
  initialMetadata?: Record<string, Record<string, unknown>>;
2001
+ /**
2002
+ * The app user to create the collection FOR (#3641). Honored only for
2003
+ * admin-token callers; an app-user token has it ignored and creates as
2004
+ * itself, exactly as `createDocument`'s does.
2005
+ */
2006
+ createdBy?: string;
1588
2007
  }): Promise<any>;
1589
2008
  getCollection(appId: string, collectionId: string): Promise<any>;
1590
2009
  updateCollection(appId: string, collectionId: string, data: {
@@ -1597,6 +2016,7 @@ export declare class ApiClient {
1597
2016
  cursor?: string;
1598
2017
  }): Promise<{
1599
2018
  items: any[];
2019
+ hasMore?: boolean;
1600
2020
  nextCursor?: string | null;
1601
2021
  }>;
1602
2022
  addCollectionDocument(appId: string, collectionId: string, data: {
@@ -1710,7 +2130,45 @@ export declare class ApiClient {
1710
2130
  byteLength: number;
1711
2131
  documentId: string;
1712
2132
  }>;
2133
+ /**
2134
+ * The export chain of a large document (#2816, behavior 20): the latest
2135
+ * completed snapshot, the sealed overlays after its epoch, and the open
2136
+ * epoch's overlay inline. Every other artifact arrives as an expiring
2137
+ * signature, read through {@link downloadDocumentArtifact}.
2138
+ */
2139
+ exportDocumentChain(appId: string, documentId: string): Promise<any>;
2140
+ /**
2141
+ * Read one granted artifact of a large document.
2142
+ *
2143
+ * The path comes from the chain and is origin-relative — the room is a
2144
+ * Durable Object and has no reliable idea which host the caller reached it
2145
+ * through — and the signature in it is the whole authorization, so no key is
2146
+ * ever composed here.
2147
+ */
2148
+ downloadDocumentArtifact(_appId: string, grantedPath: string): Promise<Buffer>;
1713
2149
  importDocumentState(appId: string, documentId: string, stateBase64: string): Promise<any>;
2150
+ /**
2151
+ * Upload one artifact of a large document's import chain (#2816,
2152
+ * behavior 20).
2153
+ *
2154
+ * The bytes travel raw and unmodified: the manifest's digest is over the
2155
+ * STORED bytes, so re-encoding a chunk here would fail its own verification
2156
+ * on install. The query says which artifact it is — the server derives the
2157
+ * key from the document it belongs to, so nothing here composes one.
2158
+ */
2159
+ uploadDocumentChainArtifact(appId: string, documentId: string, query: Record<string, string | number>, body: Buffer): Promise<any>;
2160
+ /** Start installing an uploaded chain (#2816, behavior 20). */
2161
+ installDocumentChain(appId: string, documentId: string, plan: {
2162
+ installId?: string;
2163
+ base: {
2164
+ epoch: number;
2165
+ buildId: string;
2166
+ } | null;
2167
+ overlays: number[];
2168
+ currentEpoch: number;
2169
+ }): Promise<any>;
2170
+ /** How far a document's chain install has got (#2816, behavior 20). */
2171
+ getDocumentChainInstall(appId: string, documentId: string): Promise<any>;
1714
2172
  getDocument(appId: string, documentId: string): Promise<any>;
1715
2173
  /**
1716
2174
  * Delete a document and everything hanging off it (#2756). The server route
@@ -1726,6 +2184,16 @@ export declare class ApiClient {
1726
2184
  * describe`. Reuses the existing `GET documents/:id/schema` endpoint.
1727
2185
  */
1728
2186
  getDocumentSchema(appId: string, documentId: string): Promise<any>;
2187
+ /**
2188
+ * The `documentFormat` a records call states, as a query string to APPEND to
2189
+ * a path (#3764).
2190
+ *
2191
+ * `post`, `patch` and `delete` take no params object — only `get` does — so
2192
+ * for every verb but the reads the parameter rides the path. Empty when the
2193
+ * caller states nothing, so an unparameterised call's URL is byte-identical
2194
+ * to what it was.
2195
+ */
2196
+ private documentFormatQuery;
1729
2197
  /**
1730
2198
  * Query records in a document model (issue #1964 Phase 3). Reuses the
1731
2199
  * server-side `GET documents/:id/records/:model` endpoint, which runs
@@ -1740,12 +2208,15 @@ export declare class ApiClient {
1740
2208
  filter?: Record<string, any>;
1741
2209
  limit?: number;
1742
2210
  cursor?: string;
2211
+ /** #3764 — the format the caller believes this document has. */
2212
+ documentFormat?: 1 | 2;
1743
2213
  }): Promise<ListEnvelope>;
1744
2214
  /**
1745
2215
  * Count records in a document model (issue #1964 Phase 3). Returns `{ count }`.
1746
2216
  */
1747
2217
  countDocumentRecords(appId: string, documentId: string, modelName: string, queryOptions?: {
1748
2218
  filter?: Record<string, any>;
2219
+ documentFormat?: 1 | 2;
1749
2220
  }): Promise<{
1750
2221
  count: number;
1751
2222
  }>;
@@ -1766,6 +2237,8 @@ export declare class ApiClient {
1766
2237
  }[];
1767
2238
  groupBy?: string[];
1768
2239
  filter?: Record<string, any>;
2240
+ }, extra?: {
2241
+ documentFormat?: 1 | 2;
1769
2242
  }): Promise<{
1770
2243
  result: unknown;
1771
2244
  }>;
@@ -1774,6 +2247,70 @@ export declare class ApiClient {
1774
2247
  * record/model/blob counts, approximate size, and last-modified timestamp.
1775
2248
  */
1776
2249
  getDocumentStats(appId: string, documentId: string): Promise<any>;
2250
+ /**
2251
+ * A large document's snapshot builds, newest first, one page (#3432).
2252
+ * `GET documents/:id/snapshots` → `{ items, hasMore, nextCursor? }`.
2253
+ */
2254
+ listDocumentSnapshots(appId: string, documentId: string, options?: {
2255
+ limit?: number;
2256
+ cursor?: string;
2257
+ }): Promise<{
2258
+ items: any[];
2259
+ hasMore: boolean;
2260
+ nextCursor?: string;
2261
+ }>;
2262
+ /**
2263
+ * A large document's bulk-load sessions, newest first (#3434, criterion 9).
2264
+ *
2265
+ * Read-only, through the document read helper's app-admin arm — the same
2266
+ * door the snapshot readers use. The action verb `documents ingest` is
2267
+ * #3435's; these two are the operator's window onto what a session did.
2268
+ */
2269
+ listDocumentIngests(appId: string, documentId: string, options?: {
2270
+ limit?: number;
2271
+ cursor?: string;
2272
+ }): Promise<{
2273
+ items: any[];
2274
+ hasMore: boolean;
2275
+ nextCursor?: string;
2276
+ }>;
2277
+ /** One bulk-load session's status (#3434). */
2278
+ getDocumentIngest(appId: string, documentId: string, sessionId: string): Promise<any>;
2279
+ /** Open a bulk-load session on a large document (#3435, criterion 9). */
2280
+ createDocumentIngest(appId: string, documentId: string): Promise<any>;
2281
+ /**
2282
+ * Upload one chunk of a bulk-load session's artifact (#3435).
2283
+ *
2284
+ * `multipart/form-data`: the eight descriptor fields as text parts and the
2285
+ * gzipped bytes as one file part named `chunk`. No `Content-Type` is set on
2286
+ * the request — fetch supplies the boundary, and a header written by hand
2287
+ * would name one the body does not use.
2288
+ */
2289
+ uploadDocumentIngestChunk(appId: string, documentId: string, sessionId: string, chunk: {
2290
+ model: string;
2291
+ index: number;
2292
+ rows: number;
2293
+ bytes: number;
2294
+ rawBytes: number;
2295
+ sha256: string;
2296
+ firstId: string;
2297
+ lastId: string;
2298
+ body: Buffer;
2299
+ }): Promise<any>;
2300
+ /** Freeze a session's manifest and hand it to the pipeline (#3435). */
2301
+ commitDocumentIngest(appId: string, documentId: string, sessionId: string): Promise<any>;
2302
+ /** Give a session up; allowed until the swap (#3435). */
2303
+ abortDocumentIngest(appId: string, documentId: string, sessionId: string): Promise<any>;
2304
+ /** One snapshot build with its verification result (#3432). */
2305
+ getDocumentSnapshot(appId: string, documentId: string, buildId: string): Promise<any>;
2306
+ /**
2307
+ * Snapshot a large document now (#3666): seal the open epoch and start the
2308
+ * base build that seal arms.
2309
+ *
2310
+ * Answers either the epoch that was sealed with the build it armed, or
2311
+ * `{ sealed: false, reason: "empty" }` for an epoch that carried nothing.
2312
+ */
2313
+ requestDocumentSnapshot(appId: string, documentId: string): Promise<any>;
1777
2314
  /**
1778
2315
  * Create or replace a record in a document model (issue #1964 Phase 4).
1779
2316
  * `POST documents/:id/records/:model` with `{ id, data, options? }` —
@@ -1785,6 +2322,8 @@ export declare class ApiClient {
1785
2322
  id: string;
1786
2323
  data: Record<string, unknown>;
1787
2324
  options?: Record<string, unknown>;
2325
+ }, extra?: {
2326
+ documentFormat?: 1 | 2;
1788
2327
  }): Promise<{
1789
2328
  record: unknown;
1790
2329
  }>;
@@ -1796,6 +2335,8 @@ export declare class ApiClient {
1796
2335
  patchDocumentRecord(appId: string, documentId: string, modelName: string, recordId: string, body: {
1797
2336
  data: Record<string, unknown>;
1798
2337
  options?: Record<string, unknown>;
2338
+ }, extra?: {
2339
+ documentFormat?: 1 | 2;
1799
2340
  }): Promise<{
1800
2341
  record: unknown;
1801
2342
  }>;
@@ -1804,7 +2345,9 @@ export declare class ApiClient {
1804
2345
  * `DELETE documents/:id/records/:model/:recordId`. A missing record id is
1805
2346
  * a silent no-op per the facade contract. Returns `{ deleted: true }`.
1806
2347
  */
1807
- deleteDocumentRecord(appId: string, documentId: string, modelName: string, recordId: string): Promise<{
2348
+ deleteDocumentRecord(appId: string, documentId: string, modelName: string, recordId: string, extra?: {
2349
+ documentFormat?: 1 | 2;
2350
+ }): Promise<{
1808
2351
  deleted: boolean;
1809
2352
  }>;
1810
2353
  /**
@@ -1813,7 +2356,9 @@ export declare class ApiClient {
1813
2356
  * a validation failure commits nothing. Returns the facade's
1814
2357
  * `{ applied, added, updated, deleted }`.
1815
2358
  */
1816
- bulkDocumentRecords(appId: string, documentId: string, operations: Array<Record<string, unknown>>): Promise<{
2359
+ bulkDocumentRecords(appId: string, documentId: string, operations: Array<Record<string, unknown>>, extra?: {
2360
+ documentFormat?: 1 | 2;
2361
+ }): Promise<{
1817
2362
  applied: number;
1818
2363
  added: Array<{
1819
2364
  model: string;
@@ -1830,6 +2375,7 @@ export declare class ApiClient {
1830
2375
  documentId?: string;
1831
2376
  tags?: string[];
1832
2377
  createdBy?: string;
2378
+ documentFormat?: 1 | 2;
1833
2379
  }): Promise<any>;
1834
2380
  listDocumentPermissions(appId: string, documentId: string): Promise<any[]>;
1835
2381
  grantDocumentPermission(appId: string, documentId: string, permissions: Array<{
@@ -1849,10 +2395,24 @@ export declare class ApiClient {
1849
2395
  userId?: string;
1850
2396
  email?: string;
1851
2397
  }): Promise<any>;
2398
+ /**
2399
+ * Resolve a NAMED user's effective access to a document (#3658).
2400
+ *
2401
+ * The admin token is admitted to name a subject (it can already read every
2402
+ * grant, group permission and membership the answer derives from), which is
2403
+ * what makes this an operator read rather than a per-user one.
2404
+ */
2405
+ validateDocumentAccessForUser(appId: string, documentId: string, userId: string): Promise<any>;
1852
2406
  getDocumentLinkAccess(appId: string, documentId: string): Promise<any>;
1853
2407
  setDocumentLinkAccess(appId: string, documentId: string, level: "reader" | "read-write"): Promise<any>;
1854
2408
  clearDocumentLinkAccess(appId: string, documentId: string): Promise<any>;
1855
- listDocumentInvitations(appId: string, documentId: string): Promise<any[]>;
2409
+ /**
2410
+ * Pending deferred grants for a document (#2951 — replaces the removed
2411
+ * legacy `GET /documents/:id/invitations`). Returns the `{ items }`
2412
+ * envelope; rows are already filtered server-side to unresolved, unexpired
2413
+ * grants whose app invitation is still outstanding.
2414
+ */
2415
+ listDocumentPendingInvitations(appId: string, documentId: string): Promise<any>;
1856
2416
  listDocumentBlobs(appId: string, documentId: string): Promise<any[]>;
1857
2417
  downloadBlob(appId: string, documentId: string, blobId: string): Promise<Buffer>;
1858
2418
  uploadBlob(appId: string, documentId: string, blobId: string, data: Buffer, meta: {
@@ -1878,7 +2438,62 @@ export declare class ApiClient {
1878
2438
  email?: string;
1879
2439
  };
1880
2440
  }>;
2441
+ /**
2442
+ * The admin inventory of one user's documents, followed to the end (#3399).
2443
+ *
2444
+ * The endpoint speaks the standard list contract (`{ items, hasMore,
2445
+ * nextCursor }`) and caps a page, so one request reads one page: reading it
2446
+ * would truncate a heavy user's inventory at the page size, which is the
2447
+ * bug this issue is about with a smaller number on it. `documents list
2448
+ * --user-id` and `documents export-all` both read this, and both mean "all
2449
+ * of them". `paginateAll` carries the repeat-cursor and max-page guards, so
2450
+ * a server handing out a non-advancing cursor fails loudly instead of
2451
+ * looping forever.
2452
+ *
2453
+ * Tolerant of a pre-contract server, which answers with a bare
2454
+ * `{ documents }` array and no cursor: that reads as a single page.
2455
+ */
1881
2456
  listAdminDocuments(appId: string, userId: string): Promise<any[]>;
2457
+ /**
2458
+ * One page of the admin inventory of a user's documents (#3646).
2459
+ *
2460
+ * `documents list --user-id` prints exactly this — the page the caller's
2461
+ * `--limit`/`--cursor` asked for, with the server's own page boundary
2462
+ * beside it. `documents export-all`, which really does mean every document,
2463
+ * keeps the walking `listAdminDocuments()` above.
2464
+ *
2465
+ * Tolerant of a pre-contract server, which answers with a bare
2466
+ * `{ documents }` array and no cursor: that reads as a single page.
2467
+ */
2468
+ listAdminDocumentsPage(appId: string, userId: string, options?: {
2469
+ limit?: number;
2470
+ cursor?: string;
2471
+ }): Promise<{
2472
+ items: any[];
2473
+ hasMore?: boolean;
2474
+ nextCursor?: string | null;
2475
+ }>;
2476
+ /**
2477
+ * The document `AppUser.rootDocId` points at, or null when the user has none
2478
+ * yet (#3135). A user who is not a member of the app is a 404, which
2479
+ * `documents import` reads as "this export has no target here" — distinct
2480
+ * from "this user has no root document yet".
2481
+ */
2482
+ getUserRootDocument(appId: string, userId: string): Promise<{
2483
+ rootDocId: string | null;
2484
+ }>;
2485
+ /**
2486
+ * Get or create the user's root document (#3135).
2487
+ *
2488
+ * The server runs the same idempotent get-or-create sign-in uses, so this
2489
+ * never mints a second root. `created` is true only when this call's claim
2490
+ * won — an import must not report "created", or merge without `--overwrite`,
2491
+ * for a root a concurrent sign-in minted first.
2492
+ */
2493
+ ensureUserRootDocument(appId: string, userId: string): Promise<{
2494
+ rootDocId: string;
2495
+ created: boolean;
2496
+ }>;
1882
2497
  /**
1883
2498
  * Apply an ordered batch of record operations via `records/batch`.
1884
2499
  *
@@ -1932,5 +2547,4 @@ export declare class ApiClient {
1932
2547
  getBucketBlobSignedUrl(appId: string, bucketIdOrKey: string, blobId: string, expiresInSeconds?: number): Promise<any>;
1933
2548
  getBucketBlobMetadata(appId: string, bucketIdOrKey: string, blobId: string): Promise<BlobInfo>;
1934
2549
  }
1935
- export declare const apiClient: ApiClient;
1936
2550
  export {};