primitive-admin 1.1.0-alpha.9 → 1.1.0

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 (591) hide show
  1. package/README.md +523 -109
  2. package/assets/skill/skills/primitive-platform/SKILL.md +289 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +372 -21
  5. package/dist/bin/primitive.js.map +1 -1
  6. package/dist/src/commands/admins.d.ts +2 -0
  7. package/dist/src/commands/admins.js +136 -30
  8. package/dist/src/commands/admins.js.map +1 -1
  9. package/dist/src/commands/analytics.d.ts +2 -0
  10. package/dist/src/commands/analytics.js +713 -55
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps.d.ts +2 -0
  13. package/dist/src/commands/apps.js +65 -100
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth-sessions.d.ts +7 -0
  16. package/dist/src/commands/auth-sessions.js +144 -0
  17. package/dist/src/commands/auth-sessions.js.map +1 -0
  18. package/dist/src/commands/auth.d.ts +2 -0
  19. package/dist/src/commands/auth.js +238 -108
  20. package/dist/src/commands/auth.js.map +1 -1
  21. package/dist/src/commands/blob-buckets.d.ts +2 -0
  22. package/dist/src/commands/blob-buckets.js +331 -0
  23. package/dist/src/commands/blob-buckets.js.map +1 -0
  24. package/dist/src/commands/catalog.d.ts +2 -0
  25. package/dist/src/commands/catalog.js +63 -48
  26. package/dist/src/commands/catalog.js.map +1 -1
  27. package/dist/src/commands/collection-type-configs.d.ts +2 -0
  28. package/dist/src/commands/collection-type-configs.js +85 -0
  29. package/dist/src/commands/collection-type-configs.js.map +1 -0
  30. package/dist/src/commands/collections.d.ts +2 -0
  31. package/dist/src/commands/collections.js +1282 -0
  32. package/dist/src/commands/collections.js.map +1 -0
  33. package/dist/src/commands/comparisons.d.ts +2 -0
  34. package/dist/src/commands/comparisons.js +6 -6
  35. package/dist/src/commands/comparisons.js.map +1 -1
  36. package/dist/src/commands/config.d.ts +46 -0
  37. package/dist/src/commands/config.js +465 -0
  38. package/dist/src/commands/config.js.map +1 -0
  39. package/dist/src/commands/connections.d.ts +2 -0
  40. package/dist/src/commands/connections.js +99 -0
  41. package/dist/src/commands/connections.js.map +1 -0
  42. package/dist/src/commands/cron-triggers.d.ts +2 -0
  43. package/dist/src/commands/cron-triggers.js +266 -0
  44. package/dist/src/commands/cron-triggers.js.map +1 -0
  45. package/dist/src/commands/database-type-configs.d.ts +2 -0
  46. package/dist/src/commands/database-type-configs.js +164 -0
  47. package/dist/src/commands/database-type-configs.js.map +1 -0
  48. package/dist/src/commands/database-types.d.ts +2 -0
  49. package/dist/src/commands/database-types.js +471 -0
  50. package/dist/src/commands/database-types.js.map +1 -0
  51. package/dist/src/commands/databases.d.ts +65 -0
  52. package/dist/src/commands/databases.js +1887 -243
  53. package/dist/src/commands/databases.js.map +1 -1
  54. package/dist/src/commands/documents.d.ts +60 -0
  55. package/dist/src/commands/documents.js +2888 -22
  56. package/dist/src/commands/documents.js.map +1 -1
  57. package/dist/src/commands/email-templates.d.ts +2 -0
  58. package/dist/src/commands/email-templates.js +175 -0
  59. package/dist/src/commands/email-templates.js.map +1 -0
  60. package/dist/src/commands/env.d.ts +23 -0
  61. package/dist/src/commands/env.js +395 -0
  62. package/dist/src/commands/env.js.map +1 -0
  63. package/dist/src/commands/feature-flags.d.ts +14 -0
  64. package/dist/src/commands/feature-flags.js +117 -0
  65. package/dist/src/commands/feature-flags.js.map +1 -0
  66. package/dist/src/commands/functions.d.ts +20 -0
  67. package/dist/src/commands/functions.js +1630 -0
  68. package/dist/src/commands/functions.js.map +1 -0
  69. package/dist/src/commands/group-type-configs.d.ts +2 -0
  70. package/dist/src/commands/group-type-configs.js +87 -0
  71. package/dist/src/commands/group-type-configs.js.map +1 -0
  72. package/dist/src/commands/groups.d.ts +2 -0
  73. package/dist/src/commands/groups.js +65 -113
  74. package/dist/src/commands/groups.js.map +1 -1
  75. package/dist/src/commands/guides.d.ts +223 -0
  76. package/dist/src/commands/guides.js +627 -69
  77. package/dist/src/commands/guides.js.map +1 -1
  78. package/dist/src/commands/init.d.ts +37 -0
  79. package/dist/src/commands/init.js +1693 -208
  80. package/dist/src/commands/init.js.map +1 -1
  81. package/dist/src/commands/integrations.d.ts +2 -0
  82. package/dist/src/commands/integrations.js +428 -187
  83. package/dist/src/commands/integrations.js.map +1 -1
  84. package/dist/src/commands/llm.d.ts +2 -0
  85. package/dist/src/commands/llm.js +4 -2
  86. package/dist/src/commands/llm.js.map +1 -1
  87. package/dist/src/commands/locks.d.ts +8 -0
  88. package/dist/src/commands/locks.js +175 -0
  89. package/dist/src/commands/locks.js.map +1 -0
  90. package/dist/src/commands/metadata-category-configs.d.ts +12 -0
  91. package/dist/src/commands/metadata-category-configs.js +113 -0
  92. package/dist/src/commands/metadata-category-configs.js.map +1 -0
  93. package/dist/src/commands/metadata.d.ts +2 -0
  94. package/dist/src/commands/metadata.js +288 -0
  95. package/dist/src/commands/metadata.js.map +1 -0
  96. package/dist/src/commands/prompts.d.ts +2 -0
  97. package/dist/src/commands/prompts.js +322 -634
  98. package/dist/src/commands/prompts.js.map +1 -1
  99. package/dist/src/commands/rule-sets.d.ts +3 -0
  100. package/dist/src/commands/rule-sets.js +139 -148
  101. package/dist/src/commands/rule-sets.js.map +1 -1
  102. package/dist/src/commands/scripts.d.ts +30 -0
  103. package/dist/src/commands/scripts.js +688 -0
  104. package/dist/src/commands/scripts.js.map +1 -0
  105. package/dist/src/commands/secrets.d.ts +2 -0
  106. package/dist/src/commands/secrets.js +109 -0
  107. package/dist/src/commands/secrets.js.map +1 -0
  108. package/dist/src/commands/sessions.d.ts +2 -0
  109. package/dist/src/commands/sessions.js +76 -0
  110. package/dist/src/commands/sessions.js.map +1 -0
  111. package/dist/src/commands/skill.d.ts +2 -0
  112. package/dist/src/commands/skill.js +29 -0
  113. package/dist/src/commands/skill.js.map +1 -0
  114. package/dist/src/commands/sync-app-settings.d.ts +158 -0
  115. package/dist/src/commands/sync-app-settings.js +328 -0
  116. package/dist/src/commands/sync-app-settings.js.map +1 -0
  117. package/dist/src/commands/sync.d.ts +2670 -0
  118. package/dist/src/commands/sync.js +17144 -834
  119. package/dist/src/commands/sync.js.map +1 -1
  120. package/dist/src/commands/tokens.d.ts +2 -0
  121. package/dist/src/commands/tokens.js +132 -22
  122. package/dist/src/commands/tokens.js.map +1 -1
  123. package/dist/src/commands/users.d.ts +2 -0
  124. package/dist/src/commands/users.js +542 -24
  125. package/dist/src/commands/users.js.map +1 -1
  126. package/dist/src/commands/vars.d.ts +8 -0
  127. package/dist/src/commands/vars.js +97 -0
  128. package/dist/src/commands/vars.js.map +1 -0
  129. package/dist/src/commands/waitlist.d.ts +2 -0
  130. package/dist/src/commands/waitlist.js +12 -11
  131. package/dist/src/commands/waitlist.js.map +1 -1
  132. package/dist/src/commands/webhooks.d.ts +31 -0
  133. package/dist/src/commands/webhooks.js +633 -0
  134. package/dist/src/commands/webhooks.js.map +1 -0
  135. package/dist/src/commands/workflows.d.ts +88 -0
  136. package/dist/src/commands/workflows.js +1568 -742
  137. package/dist/src/commands/workflows.js.map +1 -1
  138. package/dist/src/lib/access-rule-display.d.ts +21 -0
  139. package/dist/src/lib/access-rule-display.js +34 -0
  140. package/dist/src/lib/access-rule-display.js.map +1 -0
  141. package/dist/src/lib/api-client.d.ts +2550 -0
  142. package/dist/src/lib/api-client.js +2503 -160
  143. package/dist/src/lib/api-client.js.map +1 -1
  144. package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
  145. package/dist/src/lib/app-settings-descriptor.js +583 -0
  146. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  147. package/dist/src/lib/auth-flow.d.ts +8 -0
  148. package/dist/src/lib/batch.d.ts +26 -0
  149. package/dist/src/lib/batch.js +32 -0
  150. package/dist/src/lib/batch.js.map +1 -0
  151. package/dist/src/lib/block-layout.d.ts +160 -0
  152. package/dist/src/lib/block-layout.js +451 -0
  153. package/dist/src/lib/block-layout.js.map +1 -0
  154. package/dist/src/lib/block-selector.d.ts +58 -0
  155. package/dist/src/lib/block-selector.js +92 -0
  156. package/dist/src/lib/block-selector.js.map +1 -0
  157. package/dist/src/lib/canonical-json.d.ts +12 -0
  158. package/dist/src/lib/canonical-json.js +35 -0
  159. package/dist/src/lib/canonical-json.js.map +1 -0
  160. package/dist/src/lib/channel.d.ts +30 -0
  161. package/dist/src/lib/channel.js +68 -0
  162. package/dist/src/lib/channel.js.map +1 -0
  163. package/dist/src/lib/cli-manifest.d.ts +68 -0
  164. package/dist/src/lib/cli-manifest.js +71 -0
  165. package/dist/src/lib/cli-manifest.js.map +1 -0
  166. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
  167. package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
  168. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  169. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  170. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  171. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  172. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +38 -0
  173. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +46 -0
  174. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  175. package/dist/src/lib/collection-export.d.ts +184 -0
  176. package/dist/src/lib/collection-export.js +252 -0
  177. package/dist/src/lib/collection-export.js.map +1 -0
  178. package/dist/src/lib/config-json-field.d.ts +28 -0
  179. package/dist/src/lib/config-json-field.js +56 -0
  180. package/dist/src/lib/config-json-field.js.map +1 -0
  181. package/dist/src/lib/config-object-descriptor.d.ts +127 -0
  182. package/dist/src/lib/config-object-descriptor.js +740 -0
  183. package/dist/src/lib/config-object-descriptor.js.map +1 -0
  184. package/dist/src/lib/config-payload.d.ts +92 -0
  185. package/dist/src/lib/config-payload.js +161 -0
  186. package/dist/src/lib/config-payload.js.map +1 -0
  187. package/dist/src/lib/config-surface.d.ts +141 -0
  188. package/dist/src/lib/config-surface.js +368 -0
  189. package/dist/src/lib/config-surface.js.map +1 -0
  190. package/dist/src/lib/config-toml.d.ts +10 -0
  191. package/dist/src/lib/config-toml.js +42 -0
  192. package/dist/src/lib/config-toml.js.map +1 -0
  193. package/dist/src/lib/config.d.ts +71 -0
  194. package/dist/src/lib/config.js +71 -68
  195. package/dist/src/lib/config.js.map +1 -1
  196. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  197. package/dist/src/lib/confirm-prompt.js +110 -0
  198. package/dist/src/lib/confirm-prompt.js.map +1 -0
  199. package/dist/src/lib/constants.d.ts +11 -0
  200. package/dist/src/lib/constants.js +12 -0
  201. package/dist/src/lib/constants.js.map +1 -0
  202. package/dist/src/lib/crash-handlers.d.ts +20 -0
  203. package/dist/src/lib/crash-handlers.js +49 -0
  204. package/dist/src/lib/crash-handlers.js.map +1 -0
  205. package/dist/src/lib/credentials-store.d.ts +104 -0
  206. package/dist/src/lib/credentials-store.js +336 -0
  207. package/dist/src/lib/credentials-store.js.map +1 -0
  208. package/dist/src/lib/csv.d.ts +47 -0
  209. package/dist/src/lib/csv.js +172 -0
  210. package/dist/src/lib/csv.js.map +1 -0
  211. package/dist/src/lib/data-input.d.ts +23 -0
  212. package/dist/src/lib/data-input.js +50 -0
  213. package/dist/src/lib/data-input.js.map +1 -0
  214. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  215. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  216. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  217. package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
  218. package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
  219. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  220. package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
  221. package/dist/src/lib/db-codegen/dbNaming.js +180 -0
  222. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  223. package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
  224. package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
  225. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  226. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
  227. package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
  228. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  229. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  230. package/dist/src/lib/db-codegen/dbTypeIR.js +525 -0
  231. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  232. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  233. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  234. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  235. package/dist/src/lib/deprecation.d.ts +22 -0
  236. package/dist/src/lib/deprecation.js +43 -0
  237. package/dist/src/lib/deprecation.js.map +1 -0
  238. package/dist/src/lib/document-export-permissions.d.ts +30 -0
  239. package/dist/src/lib/document-export-permissions.js +54 -0
  240. package/dist/src/lib/document-export-permissions.js.map +1 -0
  241. package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
  242. package/dist/src/lib/document-ingest-artifact.js +505 -0
  243. package/dist/src/lib/document-ingest-artifact.js.map +1 -0
  244. package/dist/src/lib/document-ingest-input.d.ts +51 -0
  245. package/dist/src/lib/document-ingest-input.js +132 -0
  246. package/dist/src/lib/document-ingest-input.js.map +1 -0
  247. package/dist/src/lib/document-ingest-rows.d.ts +137 -0
  248. package/dist/src/lib/document-ingest-rows.js +181 -0
  249. package/dist/src/lib/document-ingest-rows.js.map +1 -0
  250. package/dist/src/lib/document-ingest.d.ts +101 -0
  251. package/dist/src/lib/document-ingest.js +384 -0
  252. package/dist/src/lib/document-ingest.js.map +1 -0
  253. package/dist/src/lib/env-resolver-core.d.ts +258 -0
  254. package/dist/src/lib/env-resolver-core.js +447 -0
  255. package/dist/src/lib/env-resolver-core.js.map +1 -0
  256. package/dist/src/lib/env-resolver.d.ts +99 -0
  257. package/dist/src/lib/env-resolver.js +153 -0
  258. package/dist/src/lib/env-resolver.js.map +1 -0
  259. package/dist/src/lib/fetch.d.ts +5 -0
  260. package/dist/src/lib/function-bundle.d.ts +147 -0
  261. package/dist/src/lib/function-bundle.js +341 -0
  262. package/dist/src/lib/function-bundle.js.map +1 -0
  263. package/dist/src/lib/function-collect.d.ts +123 -0
  264. package/dist/src/lib/function-collect.js +610 -0
  265. package/dist/src/lib/function-collect.js.map +1 -0
  266. package/dist/src/lib/function-db-types.d.ts +202 -0
  267. package/dist/src/lib/function-db-types.js +870 -0
  268. package/dist/src/lib/function-db-types.js.map +1 -0
  269. package/dist/src/lib/function-document-types.d.ts +144 -0
  270. package/dist/src/lib/function-document-types.js +370 -0
  271. package/dist/src/lib/function-document-types.js.map +1 -0
  272. package/dist/src/lib/function-grants-preflight.d.ts +64 -0
  273. package/dist/src/lib/function-grants-preflight.js +105 -0
  274. package/dist/src/lib/function-grants-preflight.js.map +1 -0
  275. package/dist/src/lib/function-log-lines.d.ts +76 -0
  276. package/dist/src/lib/function-log-lines.js +160 -0
  277. package/dist/src/lib/function-log-lines.js.map +1 -0
  278. package/dist/src/lib/function-log-row.d.ts +29 -0
  279. package/dist/src/lib/function-log-row.js +73 -0
  280. package/dist/src/lib/function-log-row.js.map +1 -0
  281. package/dist/src/lib/function-log-tail.d.ts +132 -0
  282. package/dist/src/lib/function-log-tail.js +262 -0
  283. package/dist/src/lib/function-log-tail.js.map +1 -0
  284. package/dist/src/lib/function-run.d.ts +289 -0
  285. package/dist/src/lib/function-run.js +389 -0
  286. package/dist/src/lib/function-run.js.map +1 -0
  287. package/dist/src/lib/function-schema-codegen.d.ts +143 -0
  288. package/dist/src/lib/function-schema-codegen.js +420 -0
  289. package/dist/src/lib/function-schema-codegen.js.map +1 -0
  290. package/dist/src/lib/function-sync.d.ts +459 -0
  291. package/dist/src/lib/function-sync.js +1258 -0
  292. package/dist/src/lib/function-sync.js.map +1 -0
  293. package/dist/src/lib/function-trigger-listing.d.ts +27 -0
  294. package/dist/src/lib/function-trigger-listing.js +70 -0
  295. package/dist/src/lib/function-trigger-listing.js.map +1 -0
  296. package/dist/src/lib/function-typecheck.d.ts +86 -0
  297. package/dist/src/lib/function-typecheck.js +370 -0
  298. package/dist/src/lib/function-typecheck.js.map +1 -0
  299. package/dist/src/lib/function-versions.d.ts +122 -0
  300. package/dist/src/lib/function-versions.js +182 -0
  301. package/dist/src/lib/function-versions.js.map +1 -0
  302. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  303. package/dist/src/lib/generated-allowlist.js +281 -0
  304. package/dist/src/lib/generated-allowlist.js.map +1 -0
  305. package/dist/src/lib/generated-config-surfaces.d.ts +2936 -0
  306. package/dist/src/lib/generated-config-surfaces.js +10569 -0
  307. package/dist/src/lib/generated-config-surfaces.js.map +1 -0
  308. package/dist/src/lib/generated-sdk-types.d.ts +12 -0
  309. package/dist/src/lib/generated-sdk-types.js +13 -0
  310. package/dist/src/lib/generated-sdk-types.js.map +1 -0
  311. package/dist/src/lib/generated-template-lint.d.ts +212 -0
  312. package/dist/src/lib/generated-template-lint.js +624 -0
  313. package/dist/src/lib/generated-template-lint.js.map +1 -0
  314. package/dist/src/lib/init-adopt.d.ts +16 -0
  315. package/dist/src/lib/init-adopt.js +34 -0
  316. package/dist/src/lib/init-adopt.js.map +1 -0
  317. package/dist/src/lib/init-assets.d.ts +39 -0
  318. package/dist/src/lib/init-assets.js +97 -0
  319. package/dist/src/lib/init-assets.js.map +1 -0
  320. package/dist/src/lib/init-client-platforms.d.ts +14 -0
  321. package/dist/src/lib/init-client-platforms.js +71 -0
  322. package/dist/src/lib/init-client-platforms.js.map +1 -0
  323. package/dist/src/lib/init-config.d.ts +98 -0
  324. package/dist/src/lib/init-config.js +186 -0
  325. package/dist/src/lib/init-config.js.map +1 -0
  326. package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
  327. package/dist/src/lib/init-email-redirect-uris.js +46 -0
  328. package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
  329. package/dist/src/lib/init-ios-links.d.ts +91 -0
  330. package/dist/src/lib/init-ios-links.js +219 -0
  331. package/dist/src/lib/init-ios-links.js.map +1 -0
  332. package/dist/src/lib/init-plan.d.ts +80 -0
  333. package/dist/src/lib/init-plan.js +95 -0
  334. package/dist/src/lib/init-plan.js.map +1 -0
  335. package/dist/src/lib/init-production-env.d.ts +48 -0
  336. package/dist/src/lib/init-production-env.js +59 -0
  337. package/dist/src/lib/init-production-env.js.map +1 -0
  338. package/dist/src/lib/init-schema.d.ts +74 -0
  339. package/dist/src/lib/init-schema.js +358 -0
  340. package/dist/src/lib/init-schema.js.map +1 -0
  341. package/dist/src/lib/init-xcode.d.ts +34 -0
  342. package/dist/src/lib/init-xcode.js +138 -0
  343. package/dist/src/lib/init-xcode.js.map +1 -0
  344. package/dist/src/lib/integration-request-config.d.ts +30 -0
  345. package/dist/src/lib/integration-request-config.js +145 -0
  346. package/dist/src/lib/integration-request-config.js.map +1 -0
  347. package/dist/src/lib/integration-selector.d.ts +42 -0
  348. package/dist/src/lib/integration-selector.js +46 -0
  349. package/dist/src/lib/integration-selector.js.map +1 -0
  350. package/dist/src/lib/ios-app-id.d.ts +34 -0
  351. package/dist/src/lib/ios-app-id.js +69 -0
  352. package/dist/src/lib/ios-app-id.js.map +1 -0
  353. package/dist/src/lib/list-options.d.ts +68 -0
  354. package/dist/src/lib/list-options.js +89 -0
  355. package/dist/src/lib/list-options.js.map +1 -0
  356. package/dist/src/lib/local-state.d.ts +55 -0
  357. package/dist/src/lib/local-state.js +167 -0
  358. package/dist/src/lib/local-state.js.map +1 -0
  359. package/dist/src/lib/local-test-cases.d.ts +63 -0
  360. package/dist/src/lib/local-test-cases.js +136 -0
  361. package/dist/src/lib/local-test-cases.js.map +1 -0
  362. package/dist/src/lib/log-inspection.d.ts +715 -0
  363. package/dist/src/lib/log-inspection.js +816 -0
  364. package/dist/src/lib/log-inspection.js.map +1 -0
  365. package/dist/src/lib/logout-admin-session.d.ts +33 -0
  366. package/dist/src/lib/logout-admin-session.js +70 -0
  367. package/dist/src/lib/logout-admin-session.js.map +1 -0
  368. package/dist/src/lib/migration-nag.d.ts +49 -0
  369. package/dist/src/lib/migration-nag.js +163 -0
  370. package/dist/src/lib/migration-nag.js.map +1 -0
  371. package/dist/src/lib/object-status-filter.d.ts +22 -0
  372. package/dist/src/lib/object-status-filter.js +45 -0
  373. package/dist/src/lib/object-status-filter.js.map +1 -0
  374. package/dist/src/lib/output.d.ts +124 -0
  375. package/dist/src/lib/output.js +219 -8
  376. package/dist/src/lib/output.js.map +1 -1
  377. package/dist/src/lib/package-manager.d.ts +140 -0
  378. package/dist/src/lib/package-manager.js +305 -0
  379. package/dist/src/lib/package-manager.js.map +1 -0
  380. package/dist/src/lib/paginate.d.ts +98 -0
  381. package/dist/src/lib/paginate.js +112 -0
  382. package/dist/src/lib/paginate.js.map +1 -0
  383. package/dist/src/lib/platform-owned.d.ts +63 -0
  384. package/dist/src/lib/platform-owned.js +85 -0
  385. package/dist/src/lib/platform-owned.js.map +1 -0
  386. package/dist/src/lib/project-config.d.ts +122 -0
  387. package/dist/src/lib/project-config.js +244 -0
  388. package/dist/src/lib/project-config.js.map +1 -0
  389. package/dist/src/lib/prompt-cost-format.d.ts +11 -0
  390. package/dist/src/lib/prompt-cost-format.js +41 -0
  391. package/dist/src/lib/prompt-cost-format.js.map +1 -0
  392. package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
  393. package/dist/src/lib/prompt-schema-codegen.js +462 -0
  394. package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
  395. package/dist/src/lib/query-operators.d.ts +43 -0
  396. package/dist/src/lib/query-operators.js +80 -0
  397. package/dist/src/lib/query-operators.js.map +1 -0
  398. package/dist/src/lib/record-filter.d.ts +18 -0
  399. package/dist/src/lib/record-filter.js +55 -0
  400. package/dist/src/lib/record-filter.js.map +1 -0
  401. package/dist/src/lib/refresh-admin-credentials.d.ts +73 -0
  402. package/dist/src/lib/refresh-admin-credentials.js +123 -0
  403. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  404. package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
  405. package/dist/src/lib/resolve-init-dev-port.js +55 -0
  406. package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
  407. package/dist/src/lib/resolve-init-server.d.ts +64 -0
  408. package/dist/src/lib/resolve-init-server.js +77 -0
  409. package/dist/src/lib/resolve-init-server.js.map +1 -0
  410. package/dist/src/lib/resolve-owner.d.ts +19 -0
  411. package/dist/src/lib/resolve-owner.js +20 -0
  412. package/dist/src/lib/resolve-owner.js.map +1 -0
  413. package/dist/src/lib/resolve-platform.d.ts +74 -0
  414. package/dist/src/lib/resolve-platform.js +105 -0
  415. package/dist/src/lib/resolve-platform.js.map +1 -0
  416. package/dist/src/lib/run-status.d.ts +19 -0
  417. package/dist/src/lib/run-status.generated.d.ts +39 -0
  418. package/dist/src/lib/run-status.generated.js +66 -0
  419. package/dist/src/lib/run-status.generated.js.map +1 -0
  420. package/dist/src/lib/run-status.js +19 -0
  421. package/dist/src/lib/run-status.js.map +1 -0
  422. package/dist/src/lib/server-text-normalization.d.ts +51 -0
  423. package/dist/src/lib/server-text-normalization.js +90 -0
  424. package/dist/src/lib/server-text-normalization.js.map +1 -0
  425. package/dist/src/lib/server-url.d.ts +22 -0
  426. package/dist/src/lib/server-url.js +33 -0
  427. package/dist/src/lib/server-url.js.map +1 -0
  428. package/dist/src/lib/signing-secret-status.d.ts +81 -0
  429. package/dist/src/lib/signing-secret-status.js +116 -0
  430. package/dist/src/lib/signing-secret-status.js.map +1 -0
  431. package/dist/src/lib/skill-installer.d.ts +71 -0
  432. package/dist/src/lib/skill-installer.js +441 -0
  433. package/dist/src/lib/skill-installer.js.map +1 -0
  434. package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
  435. package/dist/src/lib/snapshot-audit-source.js +58 -0
  436. package/dist/src/lib/snapshot-audit-source.js.map +1 -0
  437. package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
  438. package/dist/src/lib/snapshot-audit-store.js +196 -0
  439. package/dist/src/lib/snapshot-audit-store.js.map +1 -0
  440. package/dist/src/lib/snapshot-audit.d.ts +207 -0
  441. package/dist/src/lib/snapshot-audit.js +431 -0
  442. package/dist/src/lib/snapshot-audit.js.map +1 -0
  443. package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
  444. package/dist/src/lib/snapshot-build-rows.js +87 -0
  445. package/dist/src/lib/snapshot-build-rows.js.map +1 -0
  446. package/dist/src/lib/snapshot-build.d.ts +50 -0
  447. package/dist/src/lib/snapshot-build.js +111 -0
  448. package/dist/src/lib/snapshot-build.js.map +1 -0
  449. package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
  450. package/dist/src/lib/snapshot-manifest-layout.js +70 -0
  451. package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
  452. package/dist/src/lib/snapshots.d.ts +98 -0
  453. package/dist/src/lib/snapshots.js +294 -0
  454. package/dist/src/lib/snapshots.js.map +1 -0
  455. package/dist/src/lib/step-run-table.d.ts +43 -0
  456. package/dist/src/lib/step-run-table.js +129 -0
  457. package/dist/src/lib/step-run-table.js.map +1 -0
  458. package/dist/src/lib/storage-pending-retry.d.ts +26 -0
  459. package/dist/src/lib/storage-pending-retry.js +42 -0
  460. package/dist/src/lib/storage-pending-retry.js.map +1 -0
  461. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
  462. package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
  463. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
  464. package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
  465. package/dist/src/lib/swift-codegen/banners.js +25 -0
  466. package/dist/src/lib/swift-codegen/banners.js.map +1 -0
  467. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
  468. package/dist/src/lib/swift-codegen/dbGenerator.js +926 -0
  469. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  470. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  471. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  472. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  473. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
  474. package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
  475. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
  476. package/dist/src/lib/swift-codegen/generator.d.ts +100 -0
  477. package/dist/src/lib/swift-codegen/generator.js +457 -0
  478. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  479. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +87 -0
  480. package/dist/src/lib/swift-codegen/schemaToSwift.js +661 -0
  481. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  482. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
  483. package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
  484. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  485. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  486. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  487. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  488. package/dist/src/lib/sync-dir-selector.d.ts +21 -0
  489. package/dist/src/lib/sync-dir-selector.js +30 -0
  490. package/dist/src/lib/sync-dir-selector.js.map +1 -0
  491. package/dist/src/lib/sync-paths.d.ts +128 -0
  492. package/dist/src/lib/sync-paths.js +195 -0
  493. package/dist/src/lib/sync-paths.js.map +1 -0
  494. package/dist/src/lib/sync-resource-types.d.ts +563 -0
  495. package/dist/src/lib/sync-resource-types.js +1073 -0
  496. package/dist/src/lib/sync-resource-types.js.map +1 -0
  497. package/dist/src/lib/sync-selectors.d.ts +138 -0
  498. package/dist/src/lib/sync-selectors.js +289 -0
  499. package/dist/src/lib/sync-selectors.js.map +1 -0
  500. package/dist/src/lib/template.d.ts +170 -0
  501. package/dist/src/lib/template.js +484 -68
  502. package/dist/src/lib/template.js.map +1 -1
  503. package/dist/src/lib/test-case-file-names.d.ts +40 -0
  504. package/dist/src/lib/test-case-file-names.js +91 -0
  505. package/dist/src/lib/test-case-file-names.js.map +1 -0
  506. package/dist/src/lib/test-case-keys.d.ts +29 -0
  507. package/dist/src/lib/test-case-keys.js +55 -0
  508. package/dist/src/lib/test-case-keys.js.map +1 -0
  509. package/dist/src/lib/test-case-variables.d.ts +29 -0
  510. package/dist/src/lib/test-case-variables.js +71 -0
  511. package/dist/src/lib/test-case-variables.js.map +1 -0
  512. package/dist/src/lib/token-inject.d.ts +56 -0
  513. package/dist/src/lib/token-inject.js +204 -0
  514. package/dist/src/lib/token-inject.js.map +1 -0
  515. package/dist/src/lib/toml-database-config.d.ts +123 -0
  516. package/dist/src/lib/toml-database-config.js +544 -0
  517. package/dist/src/lib/toml-database-config.js.map +1 -0
  518. package/dist/src/lib/toml-metadata-config.d.ts +151 -0
  519. package/dist/src/lib/toml-metadata-config.js +476 -0
  520. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  521. package/dist/src/lib/toml-native-form.d.ts +46 -0
  522. package/dist/src/lib/toml-native-form.js +78 -0
  523. package/dist/src/lib/toml-native-form.js.map +1 -0
  524. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  525. package/dist/src/lib/toml-params-validator.js +298 -0
  526. package/dist/src/lib/toml-params-validator.js.map +1 -0
  527. package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
  528. package/dist/src/lib/toml-scalar-edit.js +283 -0
  529. package/dist/src/lib/toml-scalar-edit.js.map +1 -0
  530. package/dist/src/lib/user-selector.d.ts +24 -0
  531. package/dist/src/lib/user-selector.js +33 -0
  532. package/dist/src/lib/user-selector.js.map +1 -0
  533. package/dist/src/lib/version-check.d.ts +35 -0
  534. package/dist/src/lib/version-check.js +241 -0
  535. package/dist/src/lib/version-check.js.map +1 -0
  536. package/dist/src/lib/watch.d.ts +121 -0
  537. package/dist/src/lib/watch.js +169 -0
  538. package/dist/src/lib/watch.js.map +1 -0
  539. package/dist/src/lib/web-url.d.ts +40 -0
  540. package/dist/src/lib/web-url.js +76 -0
  541. package/dist/src/lib/web-url.js.map +1 -0
  542. package/dist/src/lib/webhook-deliver.d.ts +209 -0
  543. package/dist/src/lib/webhook-deliver.js +519 -0
  544. package/dist/src/lib/webhook-deliver.js.map +1 -0
  545. package/dist/src/lib/workflow-apply.d.ts +110 -0
  546. package/dist/src/lib/workflow-apply.js +164 -0
  547. package/dist/src/lib/workflow-apply.js.map +1 -0
  548. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  549. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  550. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  551. package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
  552. package/dist/src/lib/workflow-codegen/generator.js +361 -0
  553. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  554. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
  555. package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
  556. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  557. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  558. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  559. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  560. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
  561. package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
  562. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  563. package/dist/src/lib/workflow-config-apply.d.ts +70 -0
  564. package/dist/src/lib/workflow-config-apply.js +137 -0
  565. package/dist/src/lib/workflow-config-apply.js.map +1 -0
  566. package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
  567. package/dist/src/lib/workflow-config-sidecar.js +96 -0
  568. package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
  569. package/dist/src/lib/workflow-defaults.d.ts +29 -0
  570. package/dist/src/lib/workflow-defaults.js +41 -0
  571. package/dist/src/lib/workflow-defaults.js.map +1 -0
  572. package/dist/src/lib/workflow-fragments.d.ts +64 -0
  573. package/dist/src/lib/workflow-fragments.js +342 -0
  574. package/dist/src/lib/workflow-fragments.js.map +1 -0
  575. package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
  576. package/dist/src/lib/workflow-include-preserve.js +286 -0
  577. package/dist/src/lib/workflow-include-preserve.js.map +1 -0
  578. package/dist/src/lib/workflow-payload.d.ts +98 -0
  579. package/dist/src/lib/workflow-payload.js +178 -0
  580. package/dist/src/lib/workflow-payload.js.map +1 -0
  581. package/dist/src/lib/workflow-toml-validator.d.ts +211 -0
  582. package/dist/src/lib/workflow-toml-validator.js +770 -0
  583. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  584. package/dist/src/lib/workflow-usage.d.ts +196 -0
  585. package/dist/src/lib/workflow-usage.js +310 -0
  586. package/dist/src/lib/workflow-usage.js.map +1 -0
  587. package/dist/src/types/index.d.ts +591 -0
  588. package/dist/src/validators.d.ts +65 -0
  589. package/dist/src/validators.js +64 -0
  590. package/dist/src/validators.js.map +1 -0
  591. package/package.json +34 -9
@@ -0,0 +1,2550 @@
1
+ import { type ListEnvelope } from "./paginate.js";
2
+ import { type GlobalAppRef, type WorkflowUsageReport } from "./workflow-usage.js";
3
+ /**
4
+ * Metadata for a single bucket blob, as returned by the metadata endpoint
5
+ * `GET blob-buckets/:bucketId/blobs/:blobId/metadata`. Mirrors the published
6
+ * JS client's `BlobInfo` shape.
7
+ */
8
+ export interface BlobInfo {
9
+ blobId: string;
10
+ bucketId: string;
11
+ filename: string | null;
12
+ contentType: string | null;
13
+ numBytes: number;
14
+ sha256: string | null;
15
+ tags: string[];
16
+ createdBy: string | null;
17
+ uploaded?: string | null;
18
+ etag?: string | null;
19
+ }
20
+ export declare class ApiError extends Error {
21
+ statusCode: number;
22
+ code?: string;
23
+ /**
24
+ * Structured `details` payload from `corsErrorResponse`.
25
+ *
26
+ * The server's error envelope can emit `details` as either:
27
+ * - an array of validation issues (e.g. `[{ path, message }, ...]`) —
28
+ * this is what most legacy endpoints produce, and what sync.ts walks
29
+ * via `Array.isArray(err.details)` / `for (const detail of ...)`.
30
+ * - a record of structured offender fields (e.g. `{ refs, operations,
31
+ * opCount, line, column, ... }`) — emitted by the issue #666 schema
32
+ * gate and consumed by the typed exception subclasses below.
33
+ *
34
+ * Callers must narrow before use: `Array.isArray(err.details)` for the
35
+ * legacy shape, otherwise treat as `Record<string, any>`.
36
+ */
37
+ details?: unknown[] | Record<string, any>;
38
+ constructor(message: string, statusCode: number, code?: string, details?: unknown[] | Record<string, any>);
39
+ }
40
+ export declare class ConflictError extends ApiError {
41
+ serverModifiedAt: string;
42
+ expectedModifiedAt: string;
43
+ constructor(message: string, serverModifiedAt: string, expectedModifiedAt: string, details?: Record<string, any>);
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>;
59
+ /**
60
+ * Parsed shape of a non-OK HTTP response body.
61
+ *
62
+ * The server's standard error envelope (corsErrorResponse, `src/utils.ts:348`)
63
+ * writes the message to `error`. A handful of bespoke endpoints (ConflictError,
64
+ * integrations proxy) use `message`. This helper reads both fields so all CLI
65
+ * call sites surface the real server message instead of `HTTP <status>`.
66
+ *
67
+ * `htmlNotFound` is set when the body looks like an HTML 404 page (typically
68
+ * served when an API path is wrong); callers can use it to throw a clearer
69
+ * "API endpoint not found" message regardless of the original status code.
70
+ *
71
+ * `details` can be either an array (legacy validation-issue list) or a
72
+ * structured record (issue #666 schema gate); the schema-feature errors
73
+ * below need the record shape, while the legacy `for (const detail of ...)`
74
+ * walkers in sync.ts assume the array shape.
75
+ */
76
+ export interface ParsedErrorResponse {
77
+ message: string;
78
+ code?: string;
79
+ details?: unknown[] | Record<string, any>;
80
+ /** True when the response body is an HTML error page (e.g. wrong API path). */
81
+ htmlNotFound?: boolean;
82
+ /** Raw parsed JSON envelope (or `undefined` for non-JSON bodies). */
83
+ raw?: any;
84
+ }
85
+ /**
86
+ * Extract a human-readable error message + structured fields from a non-OK
87
+ * HTTP response body. Single source of truth used by every error-handler call
88
+ * site in this file (see issue #684).
89
+ */
90
+ export declare function parseErrorResponse(response: {
91
+ status: number;
92
+ }, text: string, path?: string): ParsedErrorResponse;
93
+ /**
94
+ * Typed exception classes for the database-schema feature (issue #666).
95
+ * Each maps 1:1 to a server `code` value emitted from the op-edit or
96
+ * schema-edit gate. They all extend ApiError so existing catch-all paths
97
+ * continue to work; specialized catch blocks can branch on `instanceof`.
98
+ *
99
+ * Per round-2 addendum A1, `details` is always preserved so callers can
100
+ * extract structured offender lists (refs[], operations[], etc.).
101
+ */
102
+ export declare class SchemaRequiredError extends ApiError {
103
+ constructor(message: string, details?: Record<string, any>);
104
+ }
105
+ export declare class OperationRefError extends ApiError {
106
+ constructor(message: string, details?: Record<string, any>);
107
+ get refs(): Array<{
108
+ ref: string;
109
+ location: string;
110
+ }>;
111
+ }
112
+ export declare class SchemaBreaksOpsError extends ApiError {
113
+ constructor(message: string, details?: Record<string, any>);
114
+ get operations(): Array<{
115
+ operation: string;
116
+ refs: Array<{
117
+ ref: string;
118
+ location: string;
119
+ }>;
120
+ }>;
121
+ }
122
+ export declare class SchemaHasUncheckableOpsError extends ApiError {
123
+ constructor(message: string, details?: Record<string, any>);
124
+ get operations(): Array<{
125
+ operation: string;
126
+ locations: string[];
127
+ }>;
128
+ }
129
+ export declare class TomlParseError extends ApiError {
130
+ constructor(message: string, details?: Record<string, any>);
131
+ get line(): number | undefined;
132
+ get column(): number | undefined;
133
+ }
134
+ export declare class OpsExistError extends ApiError {
135
+ constructor(message: string, details?: Record<string, any>);
136
+ get opCount(): number;
137
+ }
138
+ interface EmailTemplateSummary {
139
+ emailType: string;
140
+ label: string;
141
+ description: string;
142
+ hasOverride: boolean;
143
+ modifiedAt: string | null;
144
+ }
145
+ interface EmailTemplateDetail {
146
+ emailType: string;
147
+ label: string;
148
+ description: string;
149
+ hasOverride: boolean;
150
+ override: {
151
+ templateId: string;
152
+ subject: string;
153
+ htmlBody: string;
154
+ textBody: string;
155
+ createdAt: string;
156
+ modifiedAt: string;
157
+ } | null;
158
+ default: {
159
+ subject: string;
160
+ htmlBody: string;
161
+ textBody: string;
162
+ };
163
+ variables: {
164
+ name: string;
165
+ required: boolean;
166
+ description: string;
167
+ }[];
168
+ }
169
+ interface EmailTemplateUpsertResult {
170
+ emailType: string;
171
+ templateId: string;
172
+ subject: string;
173
+ htmlBody: string;
174
+ textBody: string;
175
+ createdAt: string;
176
+ modifiedAt: string;
177
+ warnings: string[];
178
+ }
179
+ interface AnalyticsTiming {
180
+ total_ms: number;
181
+ wae_queries: number[];
182
+ }
183
+ interface AnalyticsMetricResponse {
184
+ value: number;
185
+ previous: number;
186
+ deltaPct: number;
187
+ _timing: AnalyticsTiming;
188
+ }
189
+ interface AnalyticsGrowthResponse {
190
+ window_days: number;
191
+ retained_users: number;
192
+ new_users: number;
193
+ reactivated_users: number;
194
+ churned_users: number;
195
+ current_active: number;
196
+ previous_active: number;
197
+ deltaPct: number;
198
+ _timing: AnalyticsTiming;
199
+ }
200
+ interface AnalyticsDailyActivePoint {
201
+ day_ts: number;
202
+ day_label: string;
203
+ active_users: number;
204
+ }
205
+ interface AnalyticsDailyActiveResponse {
206
+ window_days: number;
207
+ rows: AnalyticsDailyActivePoint[];
208
+ _timing: AnalyticsTiming;
209
+ }
210
+ interface AnalyticsCohortRow {
211
+ signup_week: number;
212
+ signup_week_label: string;
213
+ cohort_size: number;
214
+ retention: (number | null)[];
215
+ }
216
+ interface AnalyticsCohortResponse {
217
+ weeks: number[];
218
+ rows: AnalyticsCohortRow[];
219
+ averages: (number | null)[];
220
+ _timing: AnalyticsTiming;
221
+ }
222
+ interface AnalyticsUserSummary {
223
+ userUlid: string;
224
+ email: string | null;
225
+ name: string | null;
226
+ firstSeen: string;
227
+ lastSeen: string;
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;
245
+ }
246
+ interface AnalyticsTopUsersResponse {
247
+ windowDays: number;
248
+ limit: number;
249
+ results: AnalyticsTopUserRow[];
250
+ _timing: AnalyticsTiming;
251
+ }
252
+ interface AnalyticsUserSearchResponse {
253
+ query: string;
254
+ limit: number;
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;
263
+ }
264
+ interface AnalyticsUserDetailResponse {
265
+ user: {
266
+ user_ulid: string;
267
+ email: string | null;
268
+ name: string | null;
269
+ };
270
+ stats: {
271
+ first_seen: string | null;
272
+ last_active: string | null;
273
+ total_events: number;
274
+ days_active: number;
275
+ };
276
+ events_by_action: Array<{
277
+ action: string;
278
+ event_count: number;
279
+ last_occurred: string;
280
+ }>;
281
+ events_by_feature: Array<{
282
+ feature: string;
283
+ event_count: number;
284
+ pct: number;
285
+ }>;
286
+ _timing: AnalyticsTiming;
287
+ }
288
+ interface AnalyticsUserSnapshotResponse {
289
+ snapshot: {
290
+ timestamp: string;
291
+ values: unknown;
292
+ } | null;
293
+ _timing: AnalyticsTiming;
294
+ }
295
+ interface AnalyticsEventRow {
296
+ timestamp: string;
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;
301
+ action: string;
302
+ feature: string;
303
+ route: string;
304
+ country: string;
305
+ }
306
+ interface AnalyticsEventsResponse {
307
+ page: number;
308
+ page_size: number;
309
+ total_rows: number;
310
+ rows: AnalyticsEventRow[];
311
+ _timing: AnalyticsTiming;
312
+ }
313
+ interface AnalyticsGroupedRow {
314
+ group_value: string;
315
+ raw_group_value: string;
316
+ events: number;
317
+ unique_users: number;
318
+ }
319
+ interface AnalyticsEventsGroupedResponse {
320
+ group_by: string;
321
+ rows: AnalyticsGroupedRow[];
322
+ _timing: AnalyticsTiming;
323
+ }
324
+ interface AnalyticsErrorGroupExemplar {
325
+ message: string;
326
+ action: string;
327
+ scope_key: string;
328
+ step_id: string | null;
329
+ run_id: string | null;
330
+ at: string;
331
+ }
332
+ interface AnalyticsErrorGroupRow {
333
+ fingerprint: string;
334
+ normalized_title: string;
335
+ source: string;
336
+ status_class: string;
337
+ total: number;
338
+ daily: Array<{
339
+ day: string;
340
+ count: number;
341
+ }>;
342
+ /** First/last occurrence in the window (ISO-8601). */
343
+ first_seen: string | null;
344
+ last_seen: string | null;
345
+ /** A raw sample of the failure, or null when no sampled row carried one
346
+ * (events written before the exemplar shipped, or a starved group). */
347
+ exemplar: AnalyticsErrorGroupExemplar | null;
348
+ }
349
+ interface AnalyticsErrorsGroupsResponse {
350
+ window_days: number;
351
+ rows: AnalyticsErrorGroupRow[];
352
+ _timing: AnalyticsTiming;
353
+ }
354
+ /**
355
+ * What a `DELETE` on a status-carrying object answers (#2887, #2907).
356
+ *
357
+ * The plain call archives and `?hard=true` destroys, and the envelope says
358
+ * which happened. Four of the five methods below were declared `Promise<void>`
359
+ * while returning this at runtime, so `primitive <noun> archive --json` printed
360
+ * a value TypeScript believed did not exist. The fields are optional because
361
+ * the cron route answers the shorter `{ archived: true }` — no `success`, and
362
+ * no key — which is why the archive commands identify the object by the id the
363
+ * operator passed rather than by anything the envelope carries.
364
+ */
365
+ export interface ArchiveEnvelope {
366
+ success?: boolean;
367
+ hardDeleted?: boolean;
368
+ archived?: boolean;
369
+ [key: string]: unknown;
370
+ }
371
+ /**
372
+ * Body accepted by integration create and update (#2631).
373
+ *
374
+ * `accessRule` is the CEL expression gating who may invoke the integration
375
+ * through the proxy. The server REQUIRES it on create; on update, `null` or
376
+ * `""` clears it, and a cleared rule denies every non-admin call.
377
+ */
378
+ export interface IntegrationWritePayload {
379
+ integrationKey?: string;
380
+ displayName?: string;
381
+ description?: string | null;
382
+ requestConfig?: any;
383
+ timeoutMs?: number;
384
+ status?: string;
385
+ accessRule?: string | null;
386
+ }
387
+ /**
388
+ * Integration detail response. `accessRule` is only on the detail — the list
389
+ * summary does not carry it (#2631).
390
+ */
391
+ export interface IntegrationDetail {
392
+ integrationId: string;
393
+ integrationKey: string;
394
+ displayName?: string;
395
+ description?: string | null;
396
+ status?: string;
397
+ timeoutMs?: number;
398
+ requestConfig?: any;
399
+ accessRule?: string | null;
400
+ modifiedAt?: string;
401
+ [key: string]: any;
402
+ }
403
+ interface AnalyticsIntegrationMetric {
404
+ integrationKey: string;
405
+ invocations: number;
406
+ errorRate: number;
407
+ medianDurationMs: number;
408
+ p95DurationMs: number;
409
+ }
410
+ interface AnalyticsIntegrationMetricsResponse {
411
+ windowDays: number;
412
+ integrations: AnalyticsIntegrationMetric[];
413
+ _timing: AnalyticsTiming;
414
+ }
415
+ interface WorkflowAnalyticsSummary {
416
+ workflowKey: string;
417
+ runs: number;
418
+ successRate: number;
419
+ medianDurationMs: number;
420
+ p95: number;
421
+ totalTokens: number;
422
+ }
423
+ interface TopWorkflowsResponse {
424
+ windowDays: number;
425
+ limit: number;
426
+ workflows: WorkflowAnalyticsSummary[];
427
+ _timing: AnalyticsTiming;
428
+ }
429
+ interface PromptAnalyticsSummary {
430
+ promptKey: string;
431
+ executions: number;
432
+ medianDurationMs: number;
433
+ p95DurationMs: number;
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;
444
+ }
445
+ interface TopPromptsResponse {
446
+ windowDays: number;
447
+ limit: number;
448
+ prompts: PromptAnalyticsSummary[];
449
+ _timing: AnalyticsTiming;
450
+ }
451
+ /**
452
+ * One operation in a `records/batch` request. Mirrors the wire shape the
453
+ * DatabaseDO expects (`databases-controller.ts`): `{ op, modelName, id, data }`.
454
+ * `data` is required for `save`/`patch` and omitted for `delete`.
455
+ */
456
+ export interface DatabaseBatchOperation {
457
+ op: "save" | "patch" | "delete";
458
+ modelName: string;
459
+ id: string;
460
+ data?: any;
461
+ /**
462
+ * Strict create: the DatabaseDO fails the op with a 409 `ALREADY_EXISTS` when
463
+ * the id is already present, instead of `save`'s upsert merge. Checked inside
464
+ * the batch transaction, so under `atomic` it rolls the whole batch back.
465
+ */
466
+ ifNotExists?: boolean;
467
+ /**
468
+ * Per-op guard evaluated inside the batch transaction — a mismatch is a 409
469
+ * `CONDITION_NOT_MET`, and under `atomic` it rolls the whole batch back. This
470
+ * is what the documents surface calls a `precondition`.
471
+ */
472
+ condition?: Record<string, any>;
473
+ }
474
+ /**
475
+ * Normalize a `databases operations execute` result to the CLI's one list
476
+ * envelope — but only when the result is a Durable Object query page
477
+ * (issue #2440).
478
+ *
479
+ * A registered operation is a list only sometimes. Of the shapes the server's
480
+ * operation dispatch can return, exactly two carry a top-level `data` array: a
481
+ * bare `query` and a `pipeline` whose `returnField` names a query step. A
482
+ * `count` (`{ count }`), an `aggregate` (`{ result }`), a mutation
483
+ * (`{ results }`), an `applyToQuery` (`{ matched, affected, failed, … }`) and a
484
+ * `returnField: "all"` pipeline (`{ steps: { … } }`) do not, so blanket
485
+ * normalization would corrupt them. This helper therefore tests the shape
486
+ * first and passes everything else through byte-for-byte — including the
487
+ * nested steps of a `returnField: "all"` pipeline, which are operation-defined
488
+ * objects the CLI must not reach into.
489
+ *
490
+ * Deliberately narrow, not a general-purpose predicate: the contract is
491
+ * specifically "an operations-execute result may be a DO query page".
492
+ * `executeDatabaseOperation()` is the only caller.
493
+ *
494
+ * The conversion itself is delegated to `normalizeCliListEnvelope()` so cursor
495
+ * handling, `prevCursor` dropping and `hasMore` derivation have exactly one
496
+ * implementation. That helper throws on an unrecognized shape — correct when
497
+ * the payload is supposed to be a list, wrong here, where the payload is the
498
+ * caller's own result — which is why the shape test has to run first. `_timing`
499
+ * (`--timing`) is re-attached afterwards, since it rides alongside the envelope
500
+ * rather than inside it.
501
+ */
502
+ export declare function normalizeDatabaseOperationResult(raw: unknown): unknown;
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
+ */
521
+ private credentials;
522
+ private ensureAuthenticated;
523
+ private refreshToken;
524
+ request<T = any>(path: string, options?: RequestInit): Promise<T>;
525
+ get<T = any>(path: string, params?: Record<string, any>): Promise<T>;
526
+ post<T = any>(path: string, body?: any): Promise<T>;
527
+ put<T = any>(path: string, body?: any): Promise<T>;
528
+ patch<T = any>(path: string, body?: any): Promise<T>;
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
+ */
558
+ listApps(): Promise<{
559
+ apps: Array<{
560
+ id: string;
561
+ name: string;
562
+ role?: string;
563
+ }>;
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[]>;
581
+ createApp(data: {
582
+ name: string;
583
+ initialAdminEmail?: string;
584
+ }): Promise<any>;
585
+ getApp(appId: string): Promise<{
586
+ id: string;
587
+ name: string;
588
+ }>;
589
+ deleteApp(appId: string): Promise<void>;
590
+ getAppSettings(appId: string): Promise<any>;
591
+ updateAppSettings(appId: string, settings: any): Promise<any>;
592
+ addUserByEmail(appId: string, data: {
593
+ email: string;
594
+ role?: string;
595
+ }): Promise<any>;
596
+ mintTestJwt(appId: string, userId: string, role?: string): Promise<any>;
597
+ rebuildUserSearchText(appId: string): Promise<{
598
+ count: number;
599
+ }>;
600
+ listUsers(appId: string, params?: {
601
+ name?: string;
602
+ email?: string;
603
+ userId?: string;
604
+ limit?: number;
605
+ cursor?: string;
606
+ }): Promise<{
607
+ items: any[];
608
+ hasMore?: boolean;
609
+ nextCursor?: string | null;
610
+ }>;
611
+ /**
612
+ * @deprecated Use {@link setUserAvailability} with `"disable"`
613
+ * (`PUT /admin/api/apps/:appId/users/:userId/disable`) instead (#518).
614
+ */
615
+ removeUser(appId: string, userId: string): Promise<void>;
616
+ /**
617
+ * #2803 — take a user's access away, or give it back. Distinct from
618
+ * `removeUser`, which detaches the membership: this blocks the person's auth
619
+ * in the app, revokes their sessions and tokens, and is reversible. Both
620
+ * routes already existed; nothing on the CLI reached them.
621
+ */
622
+ setUserAvailability(appId: string, userId: string, action: "enable" | "disable"): Promise<void>;
623
+ /**
624
+ * #2803 — the platform's feature flags. A server-owned admin toggle with a
625
+ * console but, until now, no CLI: the same "one control, both surfaces" rule
626
+ * the carrying types get.
627
+ */
628
+ listFeatureFlags(): Promise<any>;
629
+ /**
630
+ * The flag itself, not the `{ flag }` envelope the route answers with —
631
+ * `feature-flags get` prints the key, the enabled state and the per-app
632
+ * overrides, and reading them off the envelope printed a blank row.
633
+ */
634
+ getFeatureFlag(flagKey: string): Promise<any>;
635
+ /** Same envelope, same unwrap: `enable`/`disable` print the updated flag. */
636
+ setFeatureFlagEnabled(flagKey: string, enabled: boolean): Promise<any>;
637
+ updateUserRole(appId: string, userId: string, role: "admin" | "member"): Promise<any>;
638
+ transferOwnership(appId: string, newOwnerEmail: string): Promise<void>;
639
+ transferAdminOwnership(appId: string, adminId: string): Promise<any>;
640
+ listAppAdmins(appId: string): Promise<any[]>;
641
+ addAppAdmin(appId: string, data: {
642
+ adminEmail: string;
643
+ role?: string;
644
+ sendEmail?: boolean;
645
+ loginUrl?: string;
646
+ }): Promise<any>;
647
+ removeAppAdmin(appId: string, adminId: string): Promise<any>;
648
+ listAppAdminInvitations(appId: string): Promise<any[]>;
649
+ deleteAppAdminInvitation(appId: string, invitationId: string): Promise<any>;
650
+ transferDocumentOwnership(appId: string, documentId: string, newOwnerId: string): Promise<void>;
651
+ listInvitations(appId: string, params?: {
652
+ limit?: number;
653
+ cursor?: string;
654
+ }): Promise<{
655
+ items: any[];
656
+ nextCursor?: string;
657
+ hasMore?: boolean;
658
+ /** @deprecated Alias of `nextCursor` (#1316). */
659
+ cursor?: string;
660
+ }>;
661
+ createInvitation(appId: string, data: {
662
+ email: string;
663
+ role: "admin" | "member";
664
+ expiresInDays?: number;
665
+ sendEmail?: boolean;
666
+ note?: string;
667
+ }): Promise<any>;
668
+ deleteInvitation(appId: string, invitationId: string): Promise<void>;
669
+ listWaitlist(appId: string): Promise<any[]>;
670
+ inviteWaitlistEntry(appId: string, waitlistId: string, options?: {
671
+ sendEmail?: boolean;
672
+ signupUrl?: string;
673
+ }): Promise<any>;
674
+ bulkInviteWaitlist(appId: string, payload: {
675
+ waitlistIds?: string[];
676
+ count?: number;
677
+ sendEmail?: boolean;
678
+ signupUrl?: string;
679
+ }): Promise<any>;
680
+ removeWaitlistEntry(appId: string, waitlistId: string): Promise<void>;
681
+ listDeferredGrants(appId: string, params?: {
682
+ type?: string;
683
+ email?: string;
684
+ limit?: number;
685
+ cursor?: string;
686
+ }): Promise<{
687
+ items: any[];
688
+ /** @deprecated Read `items`; `grants` is a legacy alias of it (#1982). */
689
+ grants: any[];
690
+ nextCursor?: string | null;
691
+ hasMore?: boolean;
692
+ }>;
693
+ revokeDeferredGrant(appId: string, deferredId: string, type: string): Promise<any>;
694
+ listIntegrations(appId: string, params?: {
695
+ status?: string;
696
+ cursor?: string;
697
+ limit?: number;
698
+ }): Promise<{
699
+ items: any[];
700
+ hasMore?: boolean;
701
+ nextCursor?: string | null;
702
+ }>;
703
+ /** Integration detail (#2631: `accessRule` is on the detail, not the list summary). */
704
+ getIntegration(appId: string, integrationId: string): Promise<IntegrationDetail>;
705
+ /**
706
+ * An integration's named configs. Test cases pin a config by NAME so the
707
+ * sidecar is portable across apps (#2769); this is the map pull and push
708
+ * resolve that name through, the same way prompts/workflows/scripts do.
709
+ */
710
+ listIntegrationConfigs(appId: string, integrationId: string): Promise<{
711
+ items: any[];
712
+ }>;
713
+ createIntegration(appId: string, payload: IntegrationWritePayload): Promise<any>;
714
+ updateIntegration(appId: string, integrationId: string, payload: IntegrationWritePayload, expectedModifiedAt?: string): Promise<any>;
715
+ /**
716
+ * Delete an integration. Archives it by default; `{ hard: true }` destroys
717
+ * the row instead, which is what `config push --prune` passes (#2803) so a
718
+ * pruned integration stops holding its key. The positional boolean is still
719
+ * accepted for the existing callers.
720
+ */
721
+ deleteIntegration(appId: string, integrationId: string, hard?: boolean | {
722
+ hard?: boolean;
723
+ }): Promise<ArchiveEnvelope>;
724
+ testIntegration(appId: string, integrationId: string, payload: any): Promise<any>;
725
+ listIntegrationLogs(appId: string, integrationId: string, params?: {
726
+ limit?: number;
727
+ status?: string;
728
+ from?: string;
729
+ to?: string;
730
+ source?: "user" | "admin" | "test" | "workflow" | "function";
731
+ /** #3691 — only the calls this run made, workflow run or function run. */
732
+ runId?: string;
733
+ }): Promise<any[]>;
734
+ listWorkflowRunIntegrationLogs(appId: string, runId: string, params?: {
735
+ limit?: number;
736
+ }): Promise<any[]>;
737
+ listAppSecrets(appId: string): Promise<any[]>;
738
+ createAppSecret(appId: string, payload: {
739
+ key: string;
740
+ value: string;
741
+ summary?: string;
742
+ }): Promise<any>;
743
+ updateAppSecret(appId: string, secretId: string, payload: {
744
+ value?: string;
745
+ summary?: string;
746
+ }): Promise<any>;
747
+ upsertAppSecret(appId: string, key: string, payload: {
748
+ value: string;
749
+ summary?: string;
750
+ }): Promise<any>;
751
+ deleteAppSecret(appId: string, secretId: string): Promise<any>;
752
+ listAppConfigVars(appId: string): Promise<any[]>;
753
+ upsertAppConfigVar(appId: string, key: string, payload: {
754
+ value: string;
755
+ summary?: string;
756
+ }, expectedModifiedAt?: string, options?: {
757
+ expectNotExists?: boolean;
758
+ }): Promise<any>;
759
+ deleteAppConfigVar(appId: string, key: string, expectedModifiedAt?: string): Promise<any>;
760
+ listWebhooks(appId: string, params?: {
761
+ status?: string;
762
+ cursor?: string;
763
+ limit?: number;
764
+ }): Promise<{
765
+ items: any[];
766
+ hasMore?: boolean;
767
+ nextCursor?: string | null;
768
+ }>;
769
+ getWebhook(appId: string, webhookId: string): Promise<any>;
770
+ createWebhook(appId: string, payload: any): Promise<any>;
771
+ updateWebhook(appId: string, webhookId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
772
+ /**
773
+ * Delete a webhook. Archives it by default; `hard` hard-deletes the row
774
+ * instead (#2232), which is what frees a slot under the per-app webhook cap
775
+ * and releases the webhook key for reuse. Same `?hard=true` verb the admin
776
+ * integrations delete uses.
777
+ */
778
+ deleteWebhook(appId: string, webhookId: string, options?: {
779
+ hard?: boolean;
780
+ }): Promise<ArchiveEnvelope>;
781
+ /**
782
+ * #2803 — the operational verb pair for a webhook. It posts to the
783
+ * enable/disable route rather than PATCHing `status`, which is server-owned
784
+ * and refused on every configuration write path.
785
+ */
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>;
957
+ /** #2803 — the operational verb pair for a prompt (admin API). */
958
+ setPromptAvailability(appId: string, promptId: string, action: "enable" | "disable"): Promise<any>;
959
+ /** #2803 — the operational verb pair for an integration (admin API). */
960
+ setIntegrationAvailability(appId: string, integrationId: string, action: "enable" | "disable"): Promise<any>;
961
+ rotateWebhookSecret(appId: string, webhookId: string, payload: {
962
+ signingSecret: string;
963
+ }): Promise<any>;
964
+ listWebhookEvents(appId: string, webhookId: string, params?: {
965
+ limit?: number;
966
+ cursor?: string;
967
+ }): Promise<{
968
+ items: any[];
969
+ hasMore?: boolean;
970
+ nextCursor?: string | null;
971
+ /** @deprecated Alias of `nextCursor` (#1316). */
972
+ cursor?: string | null;
973
+ }>;
974
+ /**
975
+ * List the live connections the server believes exist for exactly one of a
976
+ * document, user, or database. Read-only inspection over admin-api. Rows are
977
+ * per-connection-×-subscription bindings, so `connectionId` is not unique
978
+ * across rows. `params` on a database-subscription row is caller-defined
979
+ * bound CEL input — typed `unknown`.
980
+ */
981
+ listConnections(appId: string, selector: {
982
+ documentId?: string;
983
+ userId?: string;
984
+ databaseId?: string;
985
+ }, params?: {
986
+ limit?: number;
987
+ cursor?: string;
988
+ }): Promise<{
989
+ items: unknown[];
990
+ hasMore?: boolean;
991
+ nextCursor?: string | null;
992
+ }>;
993
+ listSessions(appId: string, userId: string, params?: {
994
+ limit?: number;
995
+ cursor?: string;
996
+ }): Promise<{
997
+ items: unknown[];
998
+ hasMore?: boolean;
999
+ nextCursor?: string | null;
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
+ }>;
1019
+ testWebhook(appId: string, webhookId: string, payload?: any): Promise<any>;
1020
+ /**
1021
+ * Run a webhook's configured verifier over headers and a body captured from
1022
+ * a real delivery, and report whether that signature checks out (#2445).
1023
+ *
1024
+ * `headers` is sent as ordered `[name, value]` pairs so a capture carrying a
1025
+ * field name on more than one line survives the round trip. Nothing is
1026
+ * delivered: no delivery record, no workflow run.
1027
+ */
1028
+ verifyWebhook(appId: string, webhookId: string, payload: {
1029
+ headers: Array<[string, string]>;
1030
+ rawBody?: string;
1031
+ bodyBase64?: string;
1032
+ }): Promise<any>;
1033
+ listLocks(appId: string): Promise<{
1034
+ locks: any[];
1035
+ }>;
1036
+ getLockStatus(appId: string, key: string): 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>;
1042
+ releaseLock(appId: string, key: string, handleId: string): Promise<any>;
1043
+ listCronTriggers(appId: string): Promise<{
1044
+ items: any[];
1045
+ }>;
1046
+ getCronTrigger(appId: string, triggerId: string): Promise<any>;
1047
+ createCronTrigger(appId: string, payload: any): Promise<any>;
1048
+ updateCronTrigger(appId: string, triggerId: string, payload: any): Promise<any>;
1049
+ /**
1050
+ * Retire a cron trigger. The default soft-deletes (writes the `archived`
1051
+ * tombstone); `{ hard: true }` destroys the row, which is what
1052
+ * `config push --prune` passes (#2803) so a pruned trigger stops consuming
1053
+ * the per-app cap and holding its key.
1054
+ */
1055
+ deleteCronTrigger(appId: string, triggerId: string, options?: {
1056
+ hard?: boolean;
1057
+ }): Promise<ArchiveEnvelope>;
1058
+ disableCronTrigger(appId: string, triggerId: string): Promise<any>;
1059
+ enableCronTrigger(appId: string, triggerId: string): Promise<any>;
1060
+ testCronTrigger(appId: string, triggerId: string): Promise<any>;
1061
+ listIterations(appId: string): Promise<{
1062
+ items: any[];
1063
+ }>;
1064
+ getIteration(appId: string, iterationName: string): Promise<any>;
1065
+ resetIteration(appId: string, iterationName: string): Promise<any>;
1066
+ readResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string): Promise<any>;
1067
+ writeResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string, data: Record<string, any>): Promise<any>;
1068
+ batchReadResourceMetadata(appId: string, requests: Array<{
1069
+ resourceType: string;
1070
+ resourceId: string;
1071
+ categories: string[];
1072
+ }>): Promise<{
1073
+ results: any[];
1074
+ }>;
1075
+ /**
1076
+ * List every stored metadata category on one resource (issue #1402 — debug
1077
+ * tooling). The CLI authenticates as a console admin, so the app-level
1078
+ * owner/admin bypass returns every category regardless of its readRule.
1079
+ */
1080
+ listResourceMetadata(appId: string, resourceType: string, resourceId: string): Promise<{
1081
+ resourceType: string;
1082
+ resourceId: string;
1083
+ categories: Array<{
1084
+ category: string;
1085
+ data: Record<string, any>;
1086
+ schemaVersion: number | null;
1087
+ }>;
1088
+ }>;
1089
+ /**
1090
+ * Delete one resource's metadata for one category (issue #1402 — debug
1091
+ * tooling). Idempotent: deleting an absent item succeeds with
1092
+ * `deleted: false` rather than a 404.
1093
+ */
1094
+ deleteResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string): Promise<{
1095
+ resourceType: string;
1096
+ resourceId: string;
1097
+ category: string;
1098
+ deleted: boolean;
1099
+ }>;
1100
+ /**
1101
+ * Reverse-resolve a resource by a category's unique metadata value (issue
1102
+ * #2137). A miss is a success with `resourceId: null`, never an error. The
1103
+ * CLI authenticates as a console admin, so the app-level owner/admin bypass
1104
+ * skips readRule evaluation.
1105
+ */
1106
+ resolveResourceMetadata(appId: string, resourceType: string, category: string, key: string, value: string): Promise<{
1107
+ resourceId: string | null;
1108
+ resourceType?: string;
1109
+ }>;
1110
+ listPrompts(appId: string, params?: {
1111
+ status?: string;
1112
+ limit?: number;
1113
+ cursor?: string;
1114
+ }): Promise<{
1115
+ items: any[];
1116
+ hasMore?: boolean;
1117
+ nextCursor?: string | null;
1118
+ }>;
1119
+ getPrompt(appId: string, promptId: string): Promise<any>;
1120
+ createPrompt(appId: string, payload: any): Promise<any>;
1121
+ updatePrompt(appId: string, promptId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
1122
+ /**
1123
+ * Retire a prompt, or destroy it.
1124
+ *
1125
+ * `hard` was always sent by both first-party clients and always ignored by
1126
+ * the server; #2887 made it mean something — the plain call now archives.
1127
+ */
1128
+ deletePrompt(appId: string, promptId: string, hard?: boolean): Promise<ArchiveEnvelope>;
1129
+ executePrompt(appId: string, promptId: string, payload: {
1130
+ variables: Record<string, any>;
1131
+ modelOverride?: string;
1132
+ configId?: string;
1133
+ }): Promise<any>;
1134
+ previewPrompt(appId: string, promptId: string, payload: {
1135
+ variables: Record<string, any>;
1136
+ configId?: string;
1137
+ }): Promise<any>;
1138
+ listPromptConfigs(appId: string, promptId: string): Promise<{
1139
+ items: any[];
1140
+ }>;
1141
+ getPromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
1142
+ createPromptConfig(appId: string, promptId: string, payload: any): Promise<any>;
1143
+ updatePromptConfig(appId: string, promptId: string, configId: string, payload: any): Promise<any>;
1144
+ activatePromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
1145
+ duplicatePromptConfig(appId: string, promptId: string, configId: string, payload?: {
1146
+ configName?: string;
1147
+ description?: string;
1148
+ }): Promise<any>;
1149
+ listScripts(appId: string): Promise<{
1150
+ items: any[];
1151
+ }>;
1152
+ getScript(appId: string, scriptId: string): Promise<any>;
1153
+ /**
1154
+ * List a script's versioned configs (the `ScriptConfig` rows). Each config
1155
+ * is a distinct block version: `configId` is the stable version selector,
1156
+ * `contentHash` is its content identity, and `status` reports whether it is
1157
+ * `active`/`draft`/`archived`. The script header's `activeConfigId` names
1158
+ * the live version. Used by `scripts configs list` and by the script test
1159
+ * commands to run against a specific pinned version.
1160
+ */
1161
+ listScriptConfigs(appId: string, scriptId: string): Promise<{
1162
+ items: any[];
1163
+ }>;
1164
+ createScript(appId: string, payload: {
1165
+ name: string;
1166
+ body: string;
1167
+ description?: string;
1168
+ }): Promise<any>;
1169
+ /**
1170
+ * Push a new body for an existing script by creating a new `ScriptConfig`
1171
+ * and activating it (the prompt-model "edit → activate" flow). Referencing
1172
+ * workflows pick up the new body on their next run with no fan-out. The
1173
+ * config name is unique per script, so we mint a timestamped name.
1174
+ */
1175
+ pushScriptBody(appId: string, scriptId: string, body: string,
1176
+ /**
1177
+ * The active state the caller believes holds right now (#2731 B10).
1178
+ * Creating an inactive config races nothing, so the guard sits on the
1179
+ * ACTIVATION step: if the active config has moved since the caller read it,
1180
+ * the server rejects with a 409 instead of overwriting a concurrent script
1181
+ * change. It takes BOTH halves of "what is active", because a config's body
1182
+ * can be edited in place without the active id changing — the id alone
1183
+ * would let such an edit through. Omitted (e.g. `--force`) means activate
1184
+ * unconditionally.
1185
+ */
1186
+ expectedActive?: {
1187
+ configId?: string;
1188
+ modifiedAt?: string;
1189
+ }): Promise<any>;
1190
+ /**
1191
+ * Delete a script header (cascades its configs). `force` overrides the
1192
+ * server's guard against deleting a script that an active workflow still
1193
+ * references by name — without it the server answers 409.
1194
+ */
1195
+ deleteScript(appId: string, scriptId: string, force?: boolean): Promise<void>;
1196
+ getPromptSchema(appId: string, promptId: string): Promise<{
1197
+ promptId: string;
1198
+ promptKey: string;
1199
+ displayName: string;
1200
+ inputSchema: any;
1201
+ inputVariables: string[];
1202
+ outputSchema: any;
1203
+ activeConfigId: string | null;
1204
+ activeConfigName: string | null;
1205
+ }>;
1206
+ /**
1207
+ * One page of a block's test cases. The endpoint paginates (default 50, cap
1208
+ * 100) and reports `nextCursor`; callers that reconcile the sync tree must
1209
+ * drain every page before deleting or classifying anything (#2769).
1210
+ */
1211
+ listTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, params?: {
1212
+ limit?: number;
1213
+ cursor?: string;
1214
+ }): Promise<{
1215
+ items: any[];
1216
+ hasMore?: boolean;
1217
+ nextCursor?: string;
1218
+ }>;
1219
+ getTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<any>;
1220
+ createTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
1221
+ name: string;
1222
+ description?: string | null;
1223
+ inputVariables: Record<string, any>;
1224
+ expectedOutputPattern?: string;
1225
+ expectedOutputContains?: string[];
1226
+ expectedJsonSubset?: Record<string, any>;
1227
+ configId?: string;
1228
+ evaluatorPromptId?: string;
1229
+ evaluatorConfigId?: string;
1230
+ /** The sidecar's file name — the case's identity (#2896). */
1231
+ key?: string;
1232
+ }): Promise<any>;
1233
+ updateTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, payload: {
1234
+ name?: string;
1235
+ description?: string | null;
1236
+ inputVariables?: Record<string, any>;
1237
+ expectedOutputPattern?: string | null;
1238
+ expectedOutputContains?: string[] | null;
1239
+ expectedJsonSubset?: Record<string, any> | null;
1240
+ configId?: string | null;
1241
+ evaluatorPromptId?: string | null;
1242
+ evaluatorConfigId?: string | null;
1243
+ /** The sidecar's file name, on a create-or-rename backfill (#2896). */
1244
+ key?: string;
1245
+ }): Promise<any>;
1246
+ deleteTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<void>;
1247
+ listTestCaseAttachments(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<{
1248
+ attachments: Array<{
1249
+ filename: string;
1250
+ contentType: string;
1251
+ size: number;
1252
+ r2Key: string;
1253
+ }>;
1254
+ }>;
1255
+ uploadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string, data: Buffer, contentType: string): Promise<{
1256
+ success: boolean;
1257
+ attachment: {
1258
+ filename: string;
1259
+ contentType: string;
1260
+ size: number;
1261
+ r2Key: string;
1262
+ };
1263
+ }>;
1264
+ downloadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
1265
+ data: Buffer;
1266
+ contentType: string;
1267
+ }>;
1268
+ deleteTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
1269
+ success: boolean;
1270
+ deleted: boolean;
1271
+ }>;
1272
+ executeBlockTest(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
1273
+ variables?: Record<string, any>;
1274
+ testCaseId?: string;
1275
+ configId?: string;
1276
+ comparisonGroup?: string;
1277
+ }): Promise<any>;
1278
+ runAllTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
1279
+ overrideConfigId?: string;
1280
+ comparisonGroup?: string;
1281
+ testCaseIds?: string[];
1282
+ }): Promise<any>;
1283
+ listTestRuns(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, params?: {
1284
+ limit?: number;
1285
+ comparisonGroup?: string;
1286
+ }): Promise<{
1287
+ items: any[];
1288
+ }>;
1289
+ listWorkflows(appId: string, params?: {
1290
+ status?: string;
1291
+ limit?: number;
1292
+ cursor?: string;
1293
+ }): Promise<{
1294
+ items: any[];
1295
+ hasMore?: boolean;
1296
+ nextCursor?: string | null;
1297
+ }>;
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>;
1309
+ createWorkflow(appId: string, payload: any): Promise<any>;
1310
+ updateWorkflow(appId: string, workflowId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
1311
+ /**
1312
+ * Retire a workflow, or destroy it (#2887).
1313
+ *
1314
+ * The plain call ARCHIVES: the definition row stays, so its runs, revisions
1315
+ * and test cases keep resolving. `{ hard: true }` performs the full cascade
1316
+ * and is what releases the `workflowKey` — the flag `config push --prune`
1317
+ * sends, for the same reason it sends it for webhooks and integrations.
1318
+ */
1319
+ deleteWorkflow(appId: string, workflowId: string, options?: {
1320
+ hard?: boolean;
1321
+ }): Promise<ArchiveEnvelope>;
1322
+ /**
1323
+ * #2645 criterion 9 — the operational toggle. Deliberately NOT the config
1324
+ * PATCH: `config push` owns every configuration field, and taking a workflow
1325
+ * out of service must not touch one, or an operator's action would show up as
1326
+ * drift against the repo. Same route shape as `cron-triggers pause|resume`.
1327
+ */
1328
+ disableWorkflow(appId: string, workflowId: string): Promise<any>;
1329
+ enableWorkflow(appId: string, workflowId: string): Promise<any>;
1330
+ updateWorkflowDraft(appId: string, workflowId: string, payload: any): Promise<any>;
1331
+ previewWorkflow(appId: string, workflowId: string, payload: {
1332
+ rootInput?: object;
1333
+ meta?: object;
1334
+ configId?: string;
1335
+ useDraft?: boolean;
1336
+ preferActive?: boolean;
1337
+ }): Promise<{
1338
+ instanceId: string;
1339
+ usingDraft?: boolean;
1340
+ source?: "config" | "active" | "draft" | null;
1341
+ configName?: string | null;
1342
+ configId?: string | null;
1343
+ warning?: string;
1344
+ }>;
1345
+ getPreviewStatus(appId: string, workflowId: string, instanceId: string): Promise<any>;
1346
+ listWorkflowRuns(appId: string, workflowId: string, params?: {
1347
+ status?: string;
1348
+ limit?: number;
1349
+ cursor?: string;
1350
+ forward?: boolean;
1351
+ follow?: boolean;
1352
+ after?: string;
1353
+ }): Promise<{
1354
+ items: any[];
1355
+ hasMore?: boolean;
1356
+ nextCursor?: string | null;
1357
+ /** @deprecated Alias of `nextCursor` (#1316). */
1358
+ cursor?: string | null;
1359
+ /** #1969 — opaque follow checkpoint; present on `follow=true` responses. */
1360
+ resumeAfter?: string;
1361
+ /**
1362
+ * #2237 — index rows the server examined for this request. Filtered reads
1363
+ * only, and only on a server new enough to report it; `undefined`
1364
+ * otherwise, which callers must treat as "unknown", not zero.
1365
+ */
1366
+ scanned?: number;
1367
+ }>;
1368
+ /**
1369
+ * Workflow runs started by one app user, across every workflow (#1967).
1370
+ * Backed by `GET /admin/api/apps/{appId}/users/{userId}/workflow-runs`,
1371
+ * which resolves the app user before querying the `runsByUser` index.
1372
+ */
1373
+ listUserWorkflowRuns(appId: string, userId: string, params?: {
1374
+ status?: string;
1375
+ limit?: number;
1376
+ cursor?: string;
1377
+ forward?: boolean;
1378
+ workflowId?: string;
1379
+ }): Promise<{
1380
+ items: any[];
1381
+ hasMore?: boolean;
1382
+ nextCursor?: string | null;
1383
+ /** @deprecated Alias of `nextCursor` (#1316). */
1384
+ cursor?: string | null;
1385
+ /** #2237 — index rows examined; filtered reads only, `undefined` if unknown. */
1386
+ scanned?: number;
1387
+ }>;
1388
+ getWorkflowRunStatus(appId: string, workflowId: string, runId: string): Promise<any>;
1389
+ getWorkflowStepRuns(appId: string, workflowId: string, runId: string): Promise<{
1390
+ items: any[];
1391
+ }>;
1392
+ listWorkflowConfigs(appId: string, workflowId: string): Promise<{
1393
+ items: any[];
1394
+ }>;
1395
+ getWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
1396
+ createWorkflowConfig(appId: string, workflowId: string, payload: {
1397
+ configName: string;
1398
+ description?: string;
1399
+ steps: any[];
1400
+ expressions?: {
1401
+ cel?: Record<string, string>;
1402
+ };
1403
+ }): Promise<any>;
1404
+ updateWorkflowConfig(appId: string, workflowId: string, configId: string, payload: {
1405
+ configName?: string;
1406
+ description?: string;
1407
+ steps?: any[];
1408
+ status?: string;
1409
+ expressions?: {
1410
+ cel?: Record<string, string>;
1411
+ };
1412
+ }): Promise<any>;
1413
+ archiveWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
1414
+ activateWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
1415
+ duplicateWorkflowConfig(appId: string, workflowId: string, configId: string, payload?: {
1416
+ configName?: string;
1417
+ }): Promise<any>;
1418
+ getAnalyticsTopUsers(appId: string, params?: {
1419
+ windowDays?: number;
1420
+ limit?: number;
1421
+ }): Promise<AnalyticsTopUsersResponse>;
1422
+ getAnalyticsIntegrationMetrics(appId: string, params?: {
1423
+ windowDays?: number;
1424
+ }): Promise<AnalyticsIntegrationMetricsResponse>;
1425
+ getAnalyticsOverviewDau(appId: string): Promise<AnalyticsMetricResponse>;
1426
+ getAnalyticsOverviewWau(appId: string): Promise<AnalyticsMetricResponse>;
1427
+ getAnalyticsOverviewMau(appId: string): Promise<AnalyticsMetricResponse>;
1428
+ getAnalyticsOverviewGrowth(appId: string, params?: {
1429
+ windowDays?: number;
1430
+ }): Promise<AnalyticsGrowthResponse>;
1431
+ getAnalyticsDailyActive(appId: string, params?: {
1432
+ windowDays?: number;
1433
+ }): Promise<AnalyticsDailyActiveResponse>;
1434
+ getAnalyticsRollingActive(appId: string, params?: {
1435
+ windowDays?: number;
1436
+ }): Promise<AnalyticsDailyActiveResponse>;
1437
+ getAnalyticsCohortRetention(appId: string): Promise<AnalyticsCohortResponse>;
1438
+ getAnalyticsUserSearch(appId: string, params: {
1439
+ q?: string;
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;
1448
+ }): Promise<AnalyticsUserSearchResponse>;
1449
+ getAnalyticsUserDetail(appId: string, userUlid: string): Promise<AnalyticsUserDetailResponse>;
1450
+ getAnalyticsUserSnapshot(appId: string, userUlid: string): Promise<AnalyticsUserSnapshotResponse>;
1451
+ getAnalyticsEvents(appId: string, params?: {
1452
+ windowDays?: number;
1453
+ page?: number;
1454
+ [key: string]: any;
1455
+ }): Promise<AnalyticsEventsResponse>;
1456
+ getAnalyticsEventsGrouped(appId: string, params?: {
1457
+ groupBy?: string;
1458
+ windowDays?: number;
1459
+ [key: string]: any;
1460
+ }): Promise<AnalyticsEventsGroupedResponse>;
1461
+ getAnalyticsErrorsGroups(appId: string, params?: {
1462
+ windowDays?: number;
1463
+ limit?: number;
1464
+ [key: string]: any;
1465
+ }): Promise<AnalyticsErrorsGroupsResponse>;
1466
+ getAnalyticsTopWorkflows(appId: string, params?: {
1467
+ windowDays?: number;
1468
+ limit?: number;
1469
+ }): Promise<TopWorkflowsResponse>;
1470
+ getAnalyticsTopPrompts(appId: string, params?: {
1471
+ windowDays?: number;
1472
+ limit?: number;
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
+ }>;
1488
+ listAllAdmins(params?: {
1489
+ limit?: number;
1490
+ cursor?: string;
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
+ }>;
1500
+ searchAdminByEmail(email: string): Promise<any>;
1501
+ getAdminApps(email: string): Promise<any>;
1502
+ updateAdminSettings(adminId: string, data: {
1503
+ appCreationLimit?: number;
1504
+ disabled?: boolean;
1505
+ role?: "admin" | "super-admin";
1506
+ }): Promise<any>;
1507
+ reindexAdmin(adminId: string): Promise<void>;
1508
+ listAllAdminInvitations(): Promise<any[]>;
1509
+ createGlobalAdminInvitation(data: {
1510
+ email: string;
1511
+ appCreationLimit?: number;
1512
+ expiresInDays?: number;
1513
+ }): Promise<any>;
1514
+ deleteGlobalAdminInvitation(invitationId: string): Promise<void>;
1515
+ listPromptCatalog(params?: {
1516
+ status?: string;
1517
+ limit?: number;
1518
+ cursor?: string;
1519
+ }): Promise<any>;
1520
+ getPromptCatalogItem(catalogId: string): Promise<any>;
1521
+ createPromptCatalogItem(payload: any): Promise<any>;
1522
+ updatePromptCatalogItem(catalogId: string, payload: any): Promise<any>;
1523
+ deletePromptCatalogItem(catalogId: string): Promise<void>;
1524
+ listIntegrationCatalog(params?: {
1525
+ status?: string;
1526
+ limit?: number;
1527
+ cursor?: string;
1528
+ }): Promise<any>;
1529
+ getIntegrationCatalogItem(catalogId: string): Promise<any>;
1530
+ createIntegrationCatalogItem(payload: any): Promise<any>;
1531
+ updateIntegrationCatalogItem(catalogId: string, payload: any): Promise<any>;
1532
+ deleteIntegrationCatalogItem(catalogId: string): Promise<void>;
1533
+ startBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
1534
+ comparisonGroup?: string;
1535
+ overrideConfigId?: string;
1536
+ testCaseIds?: string[];
1537
+ }): Promise<{
1538
+ batchId: string;
1539
+ totalTests: number;
1540
+ instanceIds: string[];
1541
+ errors?: any[];
1542
+ }>;
1543
+ getBatchTestStatus(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string): Promise<{
1544
+ status: string;
1545
+ batchId: string;
1546
+ completed: number;
1547
+ passed: number;
1548
+ failed: number;
1549
+ results: Array<{
1550
+ testCaseId: string;
1551
+ runId: string;
1552
+ status: string;
1553
+ verificationPassed: boolean;
1554
+ durationMs?: number;
1555
+ verificationDetails?: any;
1556
+ startedAt?: string;
1557
+ endedAt?: string;
1558
+ }>;
1559
+ }>;
1560
+ cancelBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string, instanceIds: string[]): Promise<{
1561
+ batchId: string;
1562
+ terminated: string[];
1563
+ errors?: any[];
1564
+ }>;
1565
+ getComparisonGroup(appId: string, group: string): Promise<{
1566
+ comparisonGroup: string;
1567
+ runs: any[];
1568
+ }>;
1569
+ listEmailTemplates(appId: string): Promise<{
1570
+ templates: EmailTemplateSummary[];
1571
+ }>;
1572
+ getEmailTemplate(appId: string, emailType: string): Promise<EmailTemplateDetail>;
1573
+ /**
1574
+ * Create or replace an email-template override.
1575
+ *
1576
+ * `expectedModifiedAt` is the optimistic-concurrency token every sibling
1577
+ * config endpoint already takes (#2731 B10). Optional and additive: when
1578
+ * omitted the write is unconditional, which is how `--force` and every
1579
+ * pre-existing caller keep working; when supplied and stale, the server
1580
+ * answers 409 rather than silently overwriting a concurrent edit.
1581
+ */
1582
+ upsertEmailTemplate(appId: string, emailType: string, payload: {
1583
+ subject: string;
1584
+ htmlBody: string;
1585
+ textBody: string;
1586
+ }, expectedModifiedAt?: string): Promise<EmailTemplateUpsertResult>;
1587
+ deleteEmailTemplate(appId: string, emailType: string): Promise<{
1588
+ success: boolean;
1589
+ }>;
1590
+ testEmailTemplate(appId: string, emailType: string, payload?: {
1591
+ subject: string;
1592
+ htmlBody: string;
1593
+ textBody: string;
1594
+ }): Promise<{
1595
+ success: boolean;
1596
+ sentTo: string;
1597
+ error?: string;
1598
+ }>;
1599
+ createToken(appId: string, data: {
1600
+ name: string;
1601
+ ttl?: string;
1602
+ userId?: string;
1603
+ }): Promise<{
1604
+ token: string;
1605
+ tokenId: string;
1606
+ name: string;
1607
+ expiresAt: string | null;
1608
+ createdAt: string;
1609
+ warning: string;
1610
+ }>;
1611
+ listTokens(appId: string, params?: {
1612
+ userId?: string;
1613
+ }): Promise<Array<{
1614
+ tokenId: string;
1615
+ name: string;
1616
+ userId: string;
1617
+ expiresAt: string | null;
1618
+ lastUsedAt: string | null;
1619
+ createdAt: string;
1620
+ createdBy: string;
1621
+ }>>;
1622
+ getToken(appId: string, tokenId: string): Promise<{
1623
+ tokenId: string;
1624
+ name: string;
1625
+ userId: string;
1626
+ expiresAt: string | null;
1627
+ lastUsedAt: string | null;
1628
+ createdAt: string;
1629
+ createdBy: string;
1630
+ revokedAt: string | null;
1631
+ }>;
1632
+ revokeToken(appId: string, tokenId: string): Promise<{
1633
+ success: boolean;
1634
+ message: string;
1635
+ }>;
1636
+ /**
1637
+ * List an app's databases, following the cursor to the end.
1638
+ *
1639
+ * The endpoint returns the `{ items, hasMore, nextCursor }` envelope and
1640
+ * caps a page at 100 (#1958), so `databases list` needs the follow-up pages
1641
+ * to show every database. `paginateAll` carries the repeat-cursor and
1642
+ * max-page guards, so a server that hands out a non-advancing cursor fails
1643
+ * loudly instead of looping forever.
1644
+ *
1645
+ * `options.owner` narrows the result to the databases that user created; the
1646
+ * server resolves it through the `databasesByCreator` index (#1965).
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
+ */
1655
+ listDatabases(appId: string, options?: {
1656
+ owner?: string;
1657
+ limit?: number;
1658
+ cursor?: string;
1659
+ }): Promise<{
1660
+ items: any[];
1661
+ hasMore?: boolean;
1662
+ nextCursor?: string | null;
1663
+ }>;
1664
+ createDatabase(appId: string, data: {
1665
+ title: string;
1666
+ databaseType?: string;
1667
+ metadata?: Record<string, any> | string;
1668
+ initialMetadata?: Record<string, Record<string, unknown>>;
1669
+ }): Promise<any>;
1670
+ getDatabase(appId: string, databaseId: string): Promise<any>;
1671
+ updateDatabase(appId: string, databaseId: string, data: Record<string, any>): Promise<any>;
1672
+ deleteDatabase(appId: string, databaseId: string): Promise<void>;
1673
+ /**
1674
+ * Read a database's CEL context dict.
1675
+ *
1676
+ * The HTTP path stays `/metadata` because the wire field name is still
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).
1681
+ */
1682
+ getDatabaseCelContext(appId: string, databaseId: string): Promise<any>;
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
+ */
1689
+ updateDatabaseCelContext(appId: string, databaseId: string, celContext: Record<string, any>): Promise<any>;
1690
+ /**
1691
+ * @deprecated Database CEL context is deprecated; use resource metadata
1692
+ * categories instead (`primitive metadata get database <id> <category>`,
1693
+ * #1420, #1815).
1694
+ */
1695
+ getDatabaseMetadata(appId: string, databaseId: string): Promise<any>;
1696
+ /**
1697
+ * @deprecated Database CEL context is deprecated; use resource metadata
1698
+ * categories instead (`primitive metadata set database <id> <category>`,
1699
+ * #1420, #1815).
1700
+ */
1701
+ updateDatabaseMetadata(appId: string, databaseId: string, metadata: Record<string, any>): Promise<any>;
1702
+ listDatabasePermissions(appId: string, databaseId: string): Promise<any[]>;
1703
+ addDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
1704
+ removeDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
1705
+ /** @deprecated Use {@link addDatabaseManager} instead. */
1706
+ grantDatabasePermission(appId: string, databaseId: string, data: {
1707
+ userId: string;
1708
+ permission: "manager";
1709
+ }): Promise<any>;
1710
+ /** @deprecated Use {@link removeDatabaseManager} instead. */
1711
+ revokeDatabasePermission(appId: string, databaseId: string, userId: string): Promise<any>;
1712
+ listDatabaseModels(appId: string, databaseId: string): Promise<any>;
1713
+ describeDatabaseModel(appId: string, databaseId: string, modelName: string): Promise<any>;
1714
+ /**
1715
+ * Query records in a database model. The Durable Object answers with its own
1716
+ * `{ data, hasMore, nextCursor?, prevCursor? }` envelope; that wire shape is
1717
+ * shared with the JS client, the Swift client and web-admin, so the CLI
1718
+ * normalizes it at its own boundary instead (issue #2357) and hands callers
1719
+ * the same `{ items, hasMore, nextCursor? }` envelope as
1720
+ * {@link queryDocumentRecords}.
1721
+ */
1722
+ queryDatabaseRecords(appId: string, databaseId: string, modelName: string, queryOptions?: {
1723
+ filter?: Record<string, any>;
1724
+ limit?: number;
1725
+ cursor?: string;
1726
+ }): Promise<ListEnvelope>;
1727
+ countDatabaseRecords(appId: string, databaseId: string, modelName: string, filter?: Record<string, any>): Promise<{
1728
+ count: number;
1729
+ }>;
1730
+ aggregateDatabaseRecords(appId: string, databaseId: string, modelName: string, options: {
1731
+ operations: {
1732
+ type: string;
1733
+ field?: string;
1734
+ }[];
1735
+ groupBy: (string | {
1736
+ field: string;
1737
+ contains: string;
1738
+ })[];
1739
+ filter?: Record<string, any>;
1740
+ }): Promise<{
1741
+ result: unknown;
1742
+ }>;
1743
+ /**
1744
+ * Upsert one record via `records/save`: creates the record when the id is
1745
+ * new, and merges the supplied fields into it when it already exists (the DO
1746
+ * writes with `ON CONFLICT … json_patch`, so fields you leave out survive).
1747
+ * `patchDatabaseRecord` is the same merge but requires the record to exist.
1748
+ *
1749
+ * `id` is optional: when omitted the body carries no `id`, which the
1750
+ * DatabaseDO only accepts alongside an `upsertOn` field — callers that want a
1751
+ * plain create must supply an id themselves (`databases records save` mints a
1752
+ * ULID, matching the CSV import path).
1753
+ *
1754
+ * Returns the endpoint's flat `{ success, id, appliedFields }` — not the
1755
+ * saved record.
1756
+ */
1757
+ saveDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string | undefined, data: any): Promise<any>;
1758
+ /**
1759
+ * Merge the supplied fields into an existing record via `records/patch`.
1760
+ *
1761
+ * Fields absent from `data` are left as they are. Unlike `saveDatabaseRecord`
1762
+ * the record must already exist — the DatabaseDO answers 404 for an unknown
1763
+ * id rather than creating one. Returns the flat
1764
+ * `{ success, id, appliedFields }`.
1765
+ */
1766
+ patchDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string, data: any): Promise<any>;
1767
+ listDatabaseOperations(appId: string, databaseId: string): Promise<any[]>;
1768
+ /**
1769
+ * Execute a registered operation and, when the result is a query page,
1770
+ * normalize it to the CLI's one list envelope (issue #2440).
1771
+ *
1772
+ * The registered operation decides the response shape, so the normalization
1773
+ * is conditional — see {@link normalizeDatabaseOperationResult}. Everything
1774
+ * else (a `count`, an `aggregate`, a mutation, a `returnField: "all"`
1775
+ * pipeline) is returned exactly as the server sent it.
1776
+ */
1777
+ executeDatabaseOperation(appId: string, databaseId: string, operationName: string, data?: {
1778
+ params?: Record<string, any>;
1779
+ limit?: number;
1780
+ cursor?: string;
1781
+ direction?: number;
1782
+ }, token?: string, options?: {
1783
+ timing?: boolean;
1784
+ }): Promise<any>;
1785
+ /**
1786
+ * Execute a registered batch (bulk) database operation. Posts a chunk of
1787
+ * items to the canonical `operations/:name/batch` endpoint (the same one the
1788
+ * client library's `executeBatch` uses — NOT the deprecated `import-bulk`
1789
+ * alias). Used by `databases import-csv`.
1790
+ *
1791
+ * @returns `{ imported, failed }` — DO-level write outcome counts. Per-item
1792
+ * validation/access failures abort the whole chunk with a 4xx (thrown).
1793
+ */
1794
+ executeBatch(appId: string, databaseId: string, operationName: string, batch: Array<{
1795
+ params: Record<string, any>;
1796
+ }>): Promise<{
1797
+ imported: number;
1798
+ failed: number;
1799
+ }>;
1800
+ /**
1801
+ * Make a request using a specific JWT token instead of the CLI's credentials.
1802
+ * Used for executing operations as a different user.
1803
+ */
1804
+ requestWithToken<T = any>(path: string, token: string, options?: RequestInit): Promise<T>;
1805
+ listDatabaseIndexes(appId: string, databaseId: string, modelName?: string): Promise<any>;
1806
+ registerDatabaseIndex(appId: string, databaseId: string, data: {
1807
+ modelName: string;
1808
+ fieldName: string;
1809
+ fieldType: string;
1810
+ unique?: boolean;
1811
+ }): Promise<any>;
1812
+ dropDatabaseIndex(appId: string, databaseId: string, data: {
1813
+ modelName: string;
1814
+ fieldName: string;
1815
+ }): Promise<any>;
1816
+ /**
1817
+ * Issue #974: back-provision an existing database instance's schema-declared
1818
+ * unique indexes by reading its type schema and registering any declared-but-
1819
+ * missing unique index. Idempotent.
1820
+ */
1821
+ reindexDatabaseFromSchema(appId: string, databaseId: string): Promise<{
1822
+ ok: boolean;
1823
+ registered: number;
1824
+ skipped?: boolean;
1825
+ reason?: string;
1826
+ databaseType?: string;
1827
+ }>;
1828
+ listDatabaseTypeConfigs(appId: string): Promise<any[]>;
1829
+ getDatabaseTypeConfig(appId: string, databaseType: string): Promise<any>;
1830
+ createDatabaseTypeConfig(appId: string, data: {
1831
+ databaseType: string;
1832
+ ruleSetId?: string | null;
1833
+ triggers?: Record<string, any> | null;
1834
+ /**
1835
+ * @deprecated The TOML `type.celContextAccess` expression. Use resource
1836
+ * metadata categories instead (#1420, #1815).
1837
+ */
1838
+ metadataAccess?: string | null;
1839
+ defaultAccess?: string | null;
1840
+ autoPopulatedFields?: Record<string, any> | null;
1841
+ timestamps?: Record<string, any> | null;
1842
+ schema?: string | null;
1843
+ metadataManifest?: any;
1844
+ }, options?: {
1845
+ dryRun?: boolean;
1846
+ }): Promise<any>;
1847
+ updateDatabaseTypeConfig(appId: string, databaseType: string, data: {
1848
+ ruleSetId?: string | null;
1849
+ triggers?: Record<string, any> | null;
1850
+ /**
1851
+ * @deprecated The TOML `type.celContextAccess` expression. Use resource
1852
+ * metadata categories instead (#1420, #1815).
1853
+ */
1854
+ metadataAccess?: string | null;
1855
+ defaultAccess?: string | null;
1856
+ autoPopulatedFields?: Record<string, any> | null;
1857
+ timestamps?: Record<string, any> | null;
1858
+ schema?: string | null;
1859
+ pendingOpDeletes?: string[];
1860
+ finalOpNames?: string[];
1861
+ metadataManifest?: any;
1862
+ pendingOpUpdates?: Array<{
1863
+ name: string;
1864
+ access?: string | null;
1865
+ params?: Record<string, any> | null;
1866
+ }>;
1867
+ pendingOpUpserts?: Array<Record<string, any>>;
1868
+ }, expectedModifiedAt?: string, options?: {
1869
+ dryRun?: boolean;
1870
+ acceptWarnings?: boolean;
1871
+ }): Promise<any>;
1872
+ deleteDatabaseTypeConfig(appId: string, databaseType: string, options?: {
1873
+ force?: boolean;
1874
+ }): Promise<any>;
1875
+ /**
1876
+ * Issue #666 Phase 3: ask the server to scaffold a TOML schema from
1877
+ * existing ops + DO field introspection. Read-only — does NOT persist.
1878
+ */
1879
+ scaffoldDatabaseTypeSchema(appId: string, databaseType: string): Promise<{
1880
+ schema: string;
1881
+ }>;
1882
+ listDatabaseTypeOperations(appId: string, databaseType: string): Promise<any[]>;
1883
+ getDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1884
+ createDatabaseTypeOperation(appId: string, databaseType: string, data: {
1885
+ name: string;
1886
+ type: string;
1887
+ modelName: string;
1888
+ access?: string | null;
1889
+ definition: Record<string, any>;
1890
+ params?: Record<string, any> | null;
1891
+ }, options?: {
1892
+ dryRun?: boolean;
1893
+ schemaOverride?: string | null;
1894
+ defaultAccess?: string | null;
1895
+ metadataManifestOverride?: Record<string, any> | null;
1896
+ }): Promise<any>;
1897
+ updateDatabaseTypeOperation(appId: string, databaseType: string, name: string, data: Record<string, any>, expectedModifiedAt?: string, options?: {
1898
+ dryRun?: boolean;
1899
+ schemaOverride?: string | null;
1900
+ metadataManifestOverride?: Record<string, any> | null;
1901
+ }): Promise<any>;
1902
+ deleteDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1903
+ listDatabaseTypeSubscriptions(appId: string, databaseType: string): Promise<any[]>;
1904
+ getDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1905
+ createDatabaseTypeSubscription(appId: string, databaseType: string, data: {
1906
+ subscriptionKey: string;
1907
+ displayName: string;
1908
+ modelName: string;
1909
+ filter: string;
1910
+ access: string;
1911
+ description?: string | null;
1912
+ select?: string[] | null;
1913
+ emit?: string[] | null;
1914
+ params?: Record<string, any> | null;
1915
+ status?: string;
1916
+ }): Promise<any>;
1917
+ updateDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string, data: Record<string, any>, expectedModifiedAt?: string): Promise<any>;
1918
+ deleteDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1919
+ listGroups(appId: string, params?: {
1920
+ type?: string;
1921
+ limit?: number;
1922
+ cursor?: string;
1923
+ }): Promise<{
1924
+ items: any[];
1925
+ nextCursor?: string;
1926
+ hasMore?: boolean;
1927
+ /** @deprecated Alias of `nextCursor` (#1316). */
1928
+ cursor?: string;
1929
+ }>;
1930
+ createGroup(appId: string, data: {
1931
+ groupType: string;
1932
+ groupId?: string;
1933
+ name: string;
1934
+ description?: string;
1935
+ }): Promise<any>;
1936
+ getGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1937
+ updateGroup(appId: string, groupType: string, groupId: string, data: {
1938
+ name?: string;
1939
+ description?: string;
1940
+ }): Promise<any>;
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
+ */
1950
+ listGroupMembers(appId: string, groupType: string, groupId: string, options?: {
1951
+ include?: "profiles";
1952
+ limit?: number;
1953
+ cursor?: string;
1954
+ }): Promise<{
1955
+ items: any[];
1956
+ nextCursor?: string;
1957
+ hasMore?: boolean;
1958
+ /** @deprecated Alias of `nextCursor` (#1316). */
1959
+ cursor?: string;
1960
+ }>;
1961
+ addGroupMember(appId: string, groupType: string, groupId: string, data: {
1962
+ userId: string;
1963
+ }): Promise<any>;
1964
+ removeGroupMember(appId: string, groupType: string, groupId: string, userId: string): Promise<any>;
1965
+ listGroupDocuments(appId: string, groupType: string, groupId: string): Promise<any[]>;
1966
+ listUserMemberships(appId: string, userId: string): Promise<any[]>;
1967
+ listDocumentGroupPermissions(appId: string, documentId: string): Promise<any[]>;
1968
+ grantDocumentGroupPermission(appId: string, documentId: string, data: {
1969
+ groupType: string;
1970
+ groupId: string;
1971
+ permission: string;
1972
+ }): Promise<any>;
1973
+ revokeDocumentGroupPermission(appId: string, documentId: string, groupType: string, groupId: string): Promise<any>;
1974
+ listCollections(appId: string, params?: {
1975
+ limit?: number;
1976
+ cursor?: string;
1977
+ }): Promise<{
1978
+ items: any[];
1979
+ hasMore?: boolean;
1980
+ nextCursor?: string | null;
1981
+ }>;
1982
+ listAllCollections(appId: string, params?: {
1983
+ limit?: number;
1984
+ cursor?: string;
1985
+ }): Promise<{
1986
+ items: any[];
1987
+ hasMore?: boolean;
1988
+ nextCursor?: string | null;
1989
+ }>;
1990
+ createCollection(appId: string, data: {
1991
+ name: string;
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;
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;
2007
+ }): Promise<any>;
2008
+ getCollection(appId: string, collectionId: string): Promise<any>;
2009
+ updateCollection(appId: string, collectionId: string, data: {
2010
+ name?: string;
2011
+ description?: string;
2012
+ }): Promise<any>;
2013
+ deleteCollection(appId: string, collectionId: string): Promise<any>;
2014
+ listCollectionDocuments(appId: string, collectionId: string, params?: {
2015
+ limit?: number;
2016
+ cursor?: string;
2017
+ }): Promise<{
2018
+ items: any[];
2019
+ hasMore?: boolean;
2020
+ nextCursor?: string | null;
2021
+ }>;
2022
+ addCollectionDocument(appId: string, collectionId: string, data: {
2023
+ documentId: string;
2024
+ }): Promise<any>;
2025
+ removeCollectionDocument(appId: string, collectionId: string, documentId: string): Promise<any>;
2026
+ listCollectionsForDocument(appId: string, documentId: string, params?: {
2027
+ limit?: number;
2028
+ cursor?: string;
2029
+ }): Promise<{
2030
+ items: any[];
2031
+ nextCursor?: string | null;
2032
+ }>;
2033
+ getCollectionAccess(appId: string, collectionId: string): Promise<any>;
2034
+ grantCollectionGroupPermission(appId: string, collectionId: string, data: {
2035
+ groupType: string;
2036
+ groupId: string;
2037
+ permission: string;
2038
+ }): Promise<any>;
2039
+ revokeCollectionGroupPermission(appId: string, collectionId: string, groupType: string, groupId: string): Promise<any>;
2040
+ addCollectionMember(appId: string, collectionId: string, data: {
2041
+ userId: string;
2042
+ permission: string;
2043
+ }): Promise<any>;
2044
+ removeCollectionMember(appId: string, collectionId: string, userId: string): Promise<any>;
2045
+ listCollectionTypeConfigs(appId: string): Promise<any[]>;
2046
+ getCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
2047
+ createCollectionTypeConfig(appId: string, data: {
2048
+ collectionType: string;
2049
+ ruleSetId?: string;
2050
+ metadataManifest?: any;
2051
+ }): Promise<any>;
2052
+ updateCollectionTypeConfig(appId: string, collectionType: string, data: {
2053
+ ruleSetId?: string | null;
2054
+ metadataManifest?: any;
2055
+ }, expectedModifiedAt?: string): Promise<any>;
2056
+ deleteCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
2057
+ /**
2058
+ * List all metadata category configs for an app. The route returns
2059
+ * `{ configs: [...] }`; unwrap to a bare array to match the other
2060
+ * `list*Configs` helpers.
2061
+ */
2062
+ listMetadataCategoryConfigs(appId: string): Promise<any[]>;
2063
+ getMetadataCategoryConfig(appId: string, resourceType: string, category: string): Promise<any>;
2064
+ /**
2065
+ * Create or replace a metadata category config (idempotent upsert via the
2066
+ * path-addressed PUT route). `resourceType` / `category` identify the config;
2067
+ * the body carries `schema` / `readRule` / `writeRule` / `description`.
2068
+ */
2069
+ upsertMetadataCategoryConfig(appId: string, resourceType: string, category: string, data: {
2070
+ schema: unknown;
2071
+ readRule?: string | null;
2072
+ writeRule?: string | null;
2073
+ description?: string | null;
2074
+ metadataManifest?: unknown;
2075
+ },
2076
+ /** Optimistic-concurrency token; see `upsertEmailTemplate` (#2731 B10). */
2077
+ expectedModifiedAt?: string): Promise<any>;
2078
+ /**
2079
+ * Delete a metadata category config (issue #1426, admin-gated route shipped
2080
+ * in #1364). Orphan semantics: the config row is hard-deleted; any stored
2081
+ * `ResourceMetadata` value rows for the category are left behind and become
2082
+ * unreachable (no query path from a category to its values). Delete the
2083
+ * values first if you need them gone — an orphaned value row can't be
2084
+ * removed through any surface once its config is gone. Returns
2085
+ * `{ resourceType, category, deleted }`; a missing config is a 404.
2086
+ */
2087
+ deleteMetadataCategoryConfig(appId: string, resourceType: string, category: string): Promise<{
2088
+ resourceType: string;
2089
+ category: string;
2090
+ deleted: boolean;
2091
+ }>;
2092
+ listRuleSets(appId: string, params?: {
2093
+ resourceType?: string;
2094
+ }): Promise<any[]>;
2095
+ createRuleSet(appId: string, data: {
2096
+ name: string;
2097
+ resourceType: string;
2098
+ rules: Record<string, any>;
2099
+ description?: string;
2100
+ }): Promise<any>;
2101
+ getRuleSet(appId: string, ruleSetId: string): Promise<any>;
2102
+ updateRuleSet(appId: string, ruleSetId: string, data: {
2103
+ name?: string;
2104
+ description?: string;
2105
+ rules?: Record<string, any>;
2106
+ }, expectedModifiedAt?: string): Promise<any>;
2107
+ deleteRuleSet(appId: string, ruleSetId: string): Promise<any>;
2108
+ getRuleSetSchema(appId: string): Promise<any>;
2109
+ getRuleSetResourceTypes(appId: string): Promise<{
2110
+ resourceTypes: string[];
2111
+ }>;
2112
+ testRuleSet(appId: string, ruleSetId: string, data: any): Promise<any>;
2113
+ debugRuleSet(appId: string, data: any): Promise<any>;
2114
+ listGroupTypeConfigs(appId: string): Promise<any[]>;
2115
+ getGroupTypeConfig(appId: string, groupType: string): Promise<any>;
2116
+ createGroupTypeConfig(appId: string, data: {
2117
+ groupType: string;
2118
+ ruleSetId?: string;
2119
+ autoAddCreator?: boolean;
2120
+ metadataManifest?: any;
2121
+ }): Promise<any>;
2122
+ updateGroupTypeConfig(appId: string, groupType: string, data: {
2123
+ ruleSetId?: string | null;
2124
+ autoAddCreator?: boolean;
2125
+ metadataManifest?: any;
2126
+ }, expectedModifiedAt?: string): Promise<any>;
2127
+ deleteGroupTypeConfig(appId: string, groupType: string): Promise<any>;
2128
+ exportDocumentState(appId: string, documentId: string): Promise<{
2129
+ state: string;
2130
+ byteLength: number;
2131
+ documentId: string;
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>;
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>;
2172
+ getDocument(appId: string, documentId: string): Promise<any>;
2173
+ /**
2174
+ * Delete a document and everything hanging off it (#2756). The server route
2175
+ * runs the same cascade the client SDK's `documents.delete()` triggers —
2176
+ * Yjs state and update history, blob rows and objects, aliases, user/group
2177
+ * permissions, invitations, collection memberships — and returns
2178
+ * `{ success, message }`, which callers pass through under `--json`.
2179
+ */
2180
+ deleteDocument(appId: string, documentId: string): Promise<any>;
2181
+ /**
2182
+ * Introspect a document's Yjs schema (model names, per-model fields and
2183
+ * indexes). Backs `documents records models` and `documents records
2184
+ * describe`. Reuses the existing `GET documents/:id/schema` endpoint.
2185
+ */
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;
2197
+ /**
2198
+ * Query records in a document model (issue #1964 Phase 3). Reuses the
2199
+ * server-side `GET documents/:id/records/:model` endpoint, which runs
2200
+ * through the caller's document permission (reader+) or the app-admin arm.
2201
+ * Returns the unified `{ items, hasMore, nextCursor? }` envelope. The cursor
2202
+ * is an opaque token — feed `nextCursor` back as `cursor` for the next page.
2203
+ * The server also dual-emits a deprecated `cursor` alias (#1316); the
2204
+ * normalizer drops it so CLI output is already on `nextCursor` when #1982
2205
+ * removes it.
2206
+ */
2207
+ queryDocumentRecords(appId: string, documentId: string, modelName: string, queryOptions?: {
2208
+ filter?: Record<string, any>;
2209
+ limit?: number;
2210
+ cursor?: string;
2211
+ /** #3764 — the format the caller believes this document has. */
2212
+ documentFormat?: 1 | 2;
2213
+ }): Promise<ListEnvelope>;
2214
+ /**
2215
+ * Count records in a document model (issue #1964 Phase 3). Returns `{ count }`.
2216
+ */
2217
+ countDocumentRecords(appId: string, documentId: string, modelName: string, queryOptions?: {
2218
+ filter?: Record<string, any>;
2219
+ documentFormat?: 1 | 2;
2220
+ }): Promise<{
2221
+ count: number;
2222
+ }>;
2223
+ /**
2224
+ * Aggregate records in a document model (issue #2437) — the documents twin
2225
+ * of {@link aggregateDatabaseRecords}. `POST documents/:id/records/:model/aggregate`
2226
+ * with `{ options: { operations, groupBy?, filter? } }`, answering `{ result }`
2227
+ * in the same shape as the database endpoint.
2228
+ *
2229
+ * `groupBy` takes plain field names only: StringSet facet grouping and
2230
+ * `{ field, contains }` membership grouping are database-only, which is why
2231
+ * this signature is narrower than the databases one.
2232
+ */
2233
+ aggregateDocumentRecords(appId: string, documentId: string, modelName: string, options: {
2234
+ operations: {
2235
+ type: string;
2236
+ field?: string;
2237
+ }[];
2238
+ groupBy?: string[];
2239
+ filter?: Record<string, any>;
2240
+ }, extra?: {
2241
+ documentFormat?: 1 | 2;
2242
+ }): Promise<{
2243
+ result: unknown;
2244
+ }>;
2245
+ /**
2246
+ * Fetch platform-vocabulary document statistics (issue #1964 Phase 3):
2247
+ * record/model/blob counts, approximate size, and last-modified timestamp.
2248
+ */
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>;
2314
+ /**
2315
+ * Create or replace a record in a document model (issue #1964 Phase 4).
2316
+ * `POST documents/:id/records/:model` with `{ id, data, options? }` —
2317
+ * server-side write through the document facade (Yjs-first, CRDT-safe,
2318
+ * broadcasts to connected clients). Requires read-write+ on the document
2319
+ * or the app-admin arm. Returns `{ record }`.
2320
+ */
2321
+ saveDocumentRecord(appId: string, documentId: string, modelName: string, body: {
2322
+ id: string;
2323
+ data: Record<string, unknown>;
2324
+ options?: Record<string, unknown>;
2325
+ }, extra?: {
2326
+ documentFormat?: 1 | 2;
2327
+ }): Promise<{
2328
+ record: unknown;
2329
+ }>;
2330
+ /**
2331
+ * Merge fields into an existing record (issue #1964 Phase 4).
2332
+ * `PATCH documents/:id/records/:model/:recordId` with `{ data, options? }`.
2333
+ * Returns `{ record }`.
2334
+ */
2335
+ patchDocumentRecord(appId: string, documentId: string, modelName: string, recordId: string, body: {
2336
+ data: Record<string, unknown>;
2337
+ options?: Record<string, unknown>;
2338
+ }, extra?: {
2339
+ documentFormat?: 1 | 2;
2340
+ }): Promise<{
2341
+ record: unknown;
2342
+ }>;
2343
+ /**
2344
+ * Delete a record from a document model (issue #1964 Phase 4).
2345
+ * `DELETE documents/:id/records/:model/:recordId`. A missing record id is
2346
+ * a silent no-op per the facade contract. Returns `{ deleted: true }`.
2347
+ */
2348
+ deleteDocumentRecord(appId: string, documentId: string, modelName: string, recordId: string, extra?: {
2349
+ documentFormat?: 1 | 2;
2350
+ }): Promise<{
2351
+ deleted: boolean;
2352
+ }>;
2353
+ /**
2354
+ * Apply an ordered multi-model create/patch/delete blob atomically (issue
2355
+ * #1964 Phase 4, wrapping the #1517 `bulkUpdate` facade). All-or-nothing:
2356
+ * a validation failure commits nothing. Returns the facade's
2357
+ * `{ applied, added, updated, deleted }`.
2358
+ */
2359
+ bulkDocumentRecords(appId: string, documentId: string, operations: Array<Record<string, unknown>>, extra?: {
2360
+ documentFormat?: 1 | 2;
2361
+ }): Promise<{
2362
+ applied: number;
2363
+ added: Array<{
2364
+ model: string;
2365
+ id: string;
2366
+ }>;
2367
+ updated: Array<{
2368
+ model: string;
2369
+ id: string;
2370
+ }>;
2371
+ deleted: number;
2372
+ }>;
2373
+ createDocument(appId: string, data: {
2374
+ title: string;
2375
+ documentId?: string;
2376
+ tags?: string[];
2377
+ createdBy?: string;
2378
+ documentFormat?: 1 | 2;
2379
+ }): Promise<any>;
2380
+ listDocumentPermissions(appId: string, documentId: string): Promise<any[]>;
2381
+ grantDocumentPermission(appId: string, documentId: string, permissions: Array<{
2382
+ userId?: string;
2383
+ email?: string;
2384
+ permission: string;
2385
+ }>): Promise<any>;
2386
+ /**
2387
+ * Revoke a user's permission on a document. Mirrors the published client's
2388
+ * `documents.removePermission` wire behavior (`src/client/api/documentsApi.ts`):
2389
+ * a userId targets the path route `DELETE .../permissions/:userId`, while an
2390
+ * email targets the query-param route `DELETE .../permissions?email=...`
2391
+ * (unified email removal, #452). This duplication of the client's wire shape
2392
+ * is deliberate and parity-tested (issue #1964 amendment 8).
2393
+ */
2394
+ revokeDocumentPermission(appId: string, documentId: string, target: {
2395
+ userId?: string;
2396
+ email?: string;
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>;
2406
+ getDocumentLinkAccess(appId: string, documentId: string): Promise<any>;
2407
+ setDocumentLinkAccess(appId: string, documentId: string, level: "reader" | "read-write"): Promise<any>;
2408
+ clearDocumentLinkAccess(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>;
2416
+ listDocumentBlobs(appId: string, documentId: string): Promise<any[]>;
2417
+ downloadBlob(appId: string, documentId: string, blobId: string): Promise<Buffer>;
2418
+ uploadBlob(appId: string, documentId: string, blobId: string, data: Buffer, meta: {
2419
+ filename: string;
2420
+ contentType: string;
2421
+ sha256: string;
2422
+ }): Promise<any>;
2423
+ listDocumentAliases(appId: string, documentId: string): Promise<any[]>;
2424
+ setDocumentAlias(appId: string, aliasScope: string, aliasKey: string, documentId: string, ownerUserId?: string, mustNotExist?: boolean): Promise<any>;
2425
+ /**
2426
+ * Resolve an app user by exact email — the single email → userId lookup in
2427
+ * the CLI (issue #2763). It reads the member-accessible `users/lookup`
2428
+ * endpoint rather than the admin-only `GET /users` list, and returns the
2429
+ * server's `{ exists, user? }` envelope as-is: a 403 or a transport failure
2430
+ * rejects instead of being flattened into "no such user", which is exactly
2431
+ * how the deleted admin-list helper misreported permission problems.
2432
+ */
2433
+ lookupUserByEmail(appId: string, email: string): Promise<{
2434
+ exists: boolean;
2435
+ user?: {
2436
+ userId: string;
2437
+ name?: string;
2438
+ email?: string;
2439
+ };
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
+ */
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
+ }>;
2497
+ /**
2498
+ * Apply an ordered batch of record operations via `records/batch`.
2499
+ *
2500
+ * `atomic` (default off, matching the DatabaseDO) makes the whole batch
2501
+ * all-or-nothing: the DO rolls every write back at the first failed
2502
+ * operation and answers with that operation's status. `databases records
2503
+ * bulk` sends `atomic: true` so it matches the documents twin's
2504
+ * all-or-nothing contract (#2437); the CSV/import paths keep the default
2505
+ * partial-success behavior.
2506
+ */
2507
+ batchDatabaseRecords(appId: string, databaseId: string, operations: DatabaseBatchOperation[], options?: {
2508
+ atomic?: boolean;
2509
+ }): Promise<any>;
2510
+ deleteDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string): Promise<any>;
2511
+ batchDeleteDatabaseRecords(appId: string, databaseId: string, operations: {
2512
+ op: "delete";
2513
+ modelName: string;
2514
+ id: string;
2515
+ }[]): Promise<any>;
2516
+ listDatabaseUniqueConstraints(appId: string, databaseId: string): Promise<any[]>;
2517
+ registerDatabaseUniqueConstraint(appId: string, databaseId: string, constraint: {
2518
+ modelName: string;
2519
+ constraintName: string;
2520
+ fields: string[];
2521
+ }): Promise<any>;
2522
+ listBlobBuckets(appId: string): Promise<{
2523
+ items: any[];
2524
+ }>;
2525
+ createBlobBucket(appId: string, payload: any): Promise<any>;
2526
+ getBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
2527
+ updateBlobBucket(appId: string, bucketIdOrKey: string, payload: any): Promise<any>;
2528
+ deleteBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
2529
+ listBucketBlobs(appId: string, bucketIdOrKey: string, params?: {
2530
+ cursor?: string;
2531
+ limit?: number;
2532
+ }): Promise<{
2533
+ items: any[];
2534
+ nextCursor?: string;
2535
+ hasMore?: boolean;
2536
+ /** @deprecated Alias of `nextCursor` (#1316). */
2537
+ cursor?: string;
2538
+ }>;
2539
+ uploadBucketBlob(appId: string, bucketIdOrKey: string, data: Buffer, meta: {
2540
+ filename: string;
2541
+ contentType: string;
2542
+ tags?: string[];
2543
+ }): Promise<any>;
2544
+ downloadBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<Buffer>;
2545
+ deleteBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<any>;
2546
+ deleteBucketBlobs(appId: string, bucketIdOrKey: string, blobIds: string[]): Promise<any>;
2547
+ getBucketBlobSignedUrl(appId: string, bucketIdOrKey: string, blobId: string, expiresInSeconds?: number): Promise<any>;
2548
+ getBucketBlobMetadata(appId: string, bucketIdOrKey: string, blobId: string): Promise<BlobInfo>;
2549
+ }
2550
+ export {};