primitive-admin 1.1.0-alpha.9 → 1.2.0-alpha.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 (609) hide show
  1. package/README.md +530 -116
  2. package/assets/skill/skills/primitive-platform/SKILL.md +295 -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 +1285 -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 +171 -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 +1868 -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 +81 -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 +13 -8
  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/settings.d.ts +18 -0
  112. package/dist/src/commands/settings.js +54 -0
  113. package/dist/src/commands/settings.js.map +1 -0
  114. package/dist/src/commands/skill.d.ts +2 -0
  115. package/dist/src/commands/skill.js +29 -0
  116. package/dist/src/commands/skill.js.map +1 -0
  117. package/dist/src/commands/sync-app-settings.d.ts +158 -0
  118. package/dist/src/commands/sync-app-settings.js +328 -0
  119. package/dist/src/commands/sync-app-settings.js.map +1 -0
  120. package/dist/src/commands/sync.d.ts +2667 -0
  121. package/dist/src/commands/sync.js +17141 -834
  122. package/dist/src/commands/sync.js.map +1 -1
  123. package/dist/src/commands/tokens.d.ts +2 -0
  124. package/dist/src/commands/tokens.js +132 -22
  125. package/dist/src/commands/tokens.js.map +1 -1
  126. package/dist/src/commands/users.d.ts +2 -0
  127. package/dist/src/commands/users.js +542 -24
  128. package/dist/src/commands/users.js.map +1 -1
  129. package/dist/src/commands/vars.d.ts +8 -0
  130. package/dist/src/commands/vars.js +97 -0
  131. package/dist/src/commands/vars.js.map +1 -0
  132. package/dist/src/commands/waitlist.d.ts +2 -0
  133. package/dist/src/commands/waitlist.js +12 -11
  134. package/dist/src/commands/waitlist.js.map +1 -1
  135. package/dist/src/commands/webhooks.d.ts +31 -0
  136. package/dist/src/commands/webhooks.js +633 -0
  137. package/dist/src/commands/webhooks.js.map +1 -0
  138. package/dist/src/commands/workflows.d.ts +88 -0
  139. package/dist/src/commands/workflows.js +1568 -742
  140. package/dist/src/commands/workflows.js.map +1 -1
  141. package/dist/src/lib/access-rule-display.d.ts +21 -0
  142. package/dist/src/lib/access-rule-display.js +34 -0
  143. package/dist/src/lib/access-rule-display.js.map +1 -0
  144. package/dist/src/lib/api-client.d.ts +2513 -0
  145. package/dist/src/lib/api-client.js +2456 -162
  146. package/dist/src/lib/api-client.js.map +1 -1
  147. package/dist/src/lib/app-match-guard.d.ts +44 -0
  148. package/dist/src/lib/app-match-guard.js +72 -0
  149. package/dist/src/lib/app-match-guard.js.map +1 -0
  150. package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
  151. package/dist/src/lib/app-settings-descriptor.js +583 -0
  152. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  153. package/dist/src/lib/auth-flow.d.ts +8 -0
  154. package/dist/src/lib/batch.d.ts +26 -0
  155. package/dist/src/lib/batch.js +32 -0
  156. package/dist/src/lib/batch.js.map +1 -0
  157. package/dist/src/lib/block-layout.d.ts +160 -0
  158. package/dist/src/lib/block-layout.js +451 -0
  159. package/dist/src/lib/block-layout.js.map +1 -0
  160. package/dist/src/lib/block-selector.d.ts +58 -0
  161. package/dist/src/lib/block-selector.js +92 -0
  162. package/dist/src/lib/block-selector.js.map +1 -0
  163. package/dist/src/lib/canonical-json.d.ts +12 -0
  164. package/dist/src/lib/canonical-json.js +35 -0
  165. package/dist/src/lib/canonical-json.js.map +1 -0
  166. package/dist/src/lib/channel.d.ts +30 -0
  167. package/dist/src/lib/channel.js +68 -0
  168. package/dist/src/lib/channel.js.map +1 -0
  169. package/dist/src/lib/cli-manifest.d.ts +68 -0
  170. package/dist/src/lib/cli-manifest.js +71 -0
  171. package/dist/src/lib/cli-manifest.js.map +1 -0
  172. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
  173. package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
  174. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  175. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  176. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  177. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  178. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +38 -0
  179. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +46 -0
  180. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  181. package/dist/src/lib/collection-export.d.ts +212 -0
  182. package/dist/src/lib/collection-export.js +288 -0
  183. package/dist/src/lib/collection-export.js.map +1 -0
  184. package/dist/src/lib/config-json-field.d.ts +28 -0
  185. package/dist/src/lib/config-json-field.js +56 -0
  186. package/dist/src/lib/config-json-field.js.map +1 -0
  187. package/dist/src/lib/config-object-descriptor.d.ts +127 -0
  188. package/dist/src/lib/config-object-descriptor.js +740 -0
  189. package/dist/src/lib/config-object-descriptor.js.map +1 -0
  190. package/dist/src/lib/config-payload.d.ts +92 -0
  191. package/dist/src/lib/config-payload.js +161 -0
  192. package/dist/src/lib/config-payload.js.map +1 -0
  193. package/dist/src/lib/config-surface.d.ts +141 -0
  194. package/dist/src/lib/config-surface.js +368 -0
  195. package/dist/src/lib/config-surface.js.map +1 -0
  196. package/dist/src/lib/config-toml.d.ts +10 -0
  197. package/dist/src/lib/config-toml.js +42 -0
  198. package/dist/src/lib/config-toml.js.map +1 -0
  199. package/dist/src/lib/config.d.ts +71 -0
  200. package/dist/src/lib/config.js +71 -68
  201. package/dist/src/lib/config.js.map +1 -1
  202. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  203. package/dist/src/lib/confirm-prompt.js +110 -0
  204. package/dist/src/lib/confirm-prompt.js.map +1 -0
  205. package/dist/src/lib/constants.d.ts +11 -0
  206. package/dist/src/lib/constants.js +12 -0
  207. package/dist/src/lib/constants.js.map +1 -0
  208. package/dist/src/lib/crash-handlers.d.ts +20 -0
  209. package/dist/src/lib/crash-handlers.js +49 -0
  210. package/dist/src/lib/crash-handlers.js.map +1 -0
  211. package/dist/src/lib/credentials-store.d.ts +104 -0
  212. package/dist/src/lib/credentials-store.js +336 -0
  213. package/dist/src/lib/credentials-store.js.map +1 -0
  214. package/dist/src/lib/csv.d.ts +47 -0
  215. package/dist/src/lib/csv.js +172 -0
  216. package/dist/src/lib/csv.js.map +1 -0
  217. package/dist/src/lib/data-input.d.ts +23 -0
  218. package/dist/src/lib/data-input.js +50 -0
  219. package/dist/src/lib/data-input.js.map +1 -0
  220. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  221. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  222. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  223. package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
  224. package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
  225. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  226. package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
  227. package/dist/src/lib/db-codegen/dbNaming.js +180 -0
  228. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  229. package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
  230. package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
  231. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  232. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
  233. package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
  234. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  235. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  236. package/dist/src/lib/db-codegen/dbTypeIR.js +525 -0
  237. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  238. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  239. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  240. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  241. package/dist/src/lib/deprecation.d.ts +22 -0
  242. package/dist/src/lib/deprecation.js +43 -0
  243. package/dist/src/lib/deprecation.js.map +1 -0
  244. package/dist/src/lib/document-export-permissions.d.ts +30 -0
  245. package/dist/src/lib/document-export-permissions.js +54 -0
  246. package/dist/src/lib/document-export-permissions.js.map +1 -0
  247. package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
  248. package/dist/src/lib/document-ingest-artifact.js +505 -0
  249. package/dist/src/lib/document-ingest-artifact.js.map +1 -0
  250. package/dist/src/lib/document-ingest-input.d.ts +51 -0
  251. package/dist/src/lib/document-ingest-input.js +132 -0
  252. package/dist/src/lib/document-ingest-input.js.map +1 -0
  253. package/dist/src/lib/document-ingest-rows.d.ts +137 -0
  254. package/dist/src/lib/document-ingest-rows.js +181 -0
  255. package/dist/src/lib/document-ingest-rows.js.map +1 -0
  256. package/dist/src/lib/document-ingest.d.ts +101 -0
  257. package/dist/src/lib/document-ingest.js +384 -0
  258. package/dist/src/lib/document-ingest.js.map +1 -0
  259. package/dist/src/lib/env-resolver-core.d.ts +258 -0
  260. package/dist/src/lib/env-resolver-core.js +447 -0
  261. package/dist/src/lib/env-resolver-core.js.map +1 -0
  262. package/dist/src/lib/env-resolver.d.ts +99 -0
  263. package/dist/src/lib/env-resolver.js +153 -0
  264. package/dist/src/lib/env-resolver.js.map +1 -0
  265. package/dist/src/lib/fetch.d.ts +5 -0
  266. package/dist/src/lib/function-bundle.d.ts +147 -0
  267. package/dist/src/lib/function-bundle.js +341 -0
  268. package/dist/src/lib/function-bundle.js.map +1 -0
  269. package/dist/src/lib/function-collect.d.ts +123 -0
  270. package/dist/src/lib/function-collect.js +610 -0
  271. package/dist/src/lib/function-collect.js.map +1 -0
  272. package/dist/src/lib/function-db-types.d.ts +202 -0
  273. package/dist/src/lib/function-db-types.js +870 -0
  274. package/dist/src/lib/function-db-types.js.map +1 -0
  275. package/dist/src/lib/function-document-types.d.ts +144 -0
  276. package/dist/src/lib/function-document-types.js +370 -0
  277. package/dist/src/lib/function-document-types.js.map +1 -0
  278. package/dist/src/lib/function-grants-preflight.d.ts +64 -0
  279. package/dist/src/lib/function-grants-preflight.js +105 -0
  280. package/dist/src/lib/function-grants-preflight.js.map +1 -0
  281. package/dist/src/lib/function-log-lines.d.ts +76 -0
  282. package/dist/src/lib/function-log-lines.js +160 -0
  283. package/dist/src/lib/function-log-lines.js.map +1 -0
  284. package/dist/src/lib/function-log-row.d.ts +29 -0
  285. package/dist/src/lib/function-log-row.js +73 -0
  286. package/dist/src/lib/function-log-row.js.map +1 -0
  287. package/dist/src/lib/function-log-tail.d.ts +132 -0
  288. package/dist/src/lib/function-log-tail.js +262 -0
  289. package/dist/src/lib/function-log-tail.js.map +1 -0
  290. package/dist/src/lib/function-run.d.ts +289 -0
  291. package/dist/src/lib/function-run.js +389 -0
  292. package/dist/src/lib/function-run.js.map +1 -0
  293. package/dist/src/lib/function-schema-codegen.d.ts +143 -0
  294. package/dist/src/lib/function-schema-codegen.js +420 -0
  295. package/dist/src/lib/function-schema-codegen.js.map +1 -0
  296. package/dist/src/lib/function-sync.d.ts +459 -0
  297. package/dist/src/lib/function-sync.js +1258 -0
  298. package/dist/src/lib/function-sync.js.map +1 -0
  299. package/dist/src/lib/function-trigger-listing.d.ts +27 -0
  300. package/dist/src/lib/function-trigger-listing.js +70 -0
  301. package/dist/src/lib/function-trigger-listing.js.map +1 -0
  302. package/dist/src/lib/function-triggers.d.ts +66 -0
  303. package/dist/src/lib/function-triggers.js +285 -0
  304. package/dist/src/lib/function-triggers.js.map +1 -0
  305. package/dist/src/lib/function-typecheck.d.ts +86 -0
  306. package/dist/src/lib/function-typecheck.js +370 -0
  307. package/dist/src/lib/function-typecheck.js.map +1 -0
  308. package/dist/src/lib/function-versions.d.ts +122 -0
  309. package/dist/src/lib/function-versions.js +182 -0
  310. package/dist/src/lib/function-versions.js.map +1 -0
  311. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  312. package/dist/src/lib/generated-allowlist.js +280 -0
  313. package/dist/src/lib/generated-allowlist.js.map +1 -0
  314. package/dist/src/lib/generated-config-surfaces.d.ts +2936 -0
  315. package/dist/src/lib/generated-config-surfaces.js +10593 -0
  316. package/dist/src/lib/generated-config-surfaces.js.map +1 -0
  317. package/dist/src/lib/generated-sdk-types.d.ts +12 -0
  318. package/dist/src/lib/generated-sdk-types.js +13 -0
  319. package/dist/src/lib/generated-sdk-types.js.map +1 -0
  320. package/dist/src/lib/generated-template-lint.d.ts +212 -0
  321. package/dist/src/lib/generated-template-lint.js +624 -0
  322. package/dist/src/lib/generated-template-lint.js.map +1 -0
  323. package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
  324. package/dist/src/lib/generated-workflow-model-fields.js +53 -0
  325. package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
  326. package/dist/src/lib/google-client-secret-status.d.ts +35 -0
  327. package/dist/src/lib/google-client-secret-status.js +56 -0
  328. package/dist/src/lib/google-client-secret-status.js.map +1 -0
  329. package/dist/src/lib/init-adopt.d.ts +16 -0
  330. package/dist/src/lib/init-adopt.js +34 -0
  331. package/dist/src/lib/init-adopt.js.map +1 -0
  332. package/dist/src/lib/init-assets.d.ts +39 -0
  333. package/dist/src/lib/init-assets.js +97 -0
  334. package/dist/src/lib/init-assets.js.map +1 -0
  335. package/dist/src/lib/init-client-platforms.d.ts +14 -0
  336. package/dist/src/lib/init-client-platforms.js +71 -0
  337. package/dist/src/lib/init-client-platforms.js.map +1 -0
  338. package/dist/src/lib/init-config.d.ts +98 -0
  339. package/dist/src/lib/init-config.js +186 -0
  340. package/dist/src/lib/init-config.js.map +1 -0
  341. package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
  342. package/dist/src/lib/init-email-redirect-uris.js +46 -0
  343. package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
  344. package/dist/src/lib/init-ios-links.d.ts +91 -0
  345. package/dist/src/lib/init-ios-links.js +219 -0
  346. package/dist/src/lib/init-ios-links.js.map +1 -0
  347. package/dist/src/lib/init-plan.d.ts +80 -0
  348. package/dist/src/lib/init-plan.js +95 -0
  349. package/dist/src/lib/init-plan.js.map +1 -0
  350. package/dist/src/lib/init-production-env.d.ts +48 -0
  351. package/dist/src/lib/init-production-env.js +59 -0
  352. package/dist/src/lib/init-production-env.js.map +1 -0
  353. package/dist/src/lib/init-schema.d.ts +74 -0
  354. package/dist/src/lib/init-schema.js +358 -0
  355. package/dist/src/lib/init-schema.js.map +1 -0
  356. package/dist/src/lib/init-xcode.d.ts +34 -0
  357. package/dist/src/lib/init-xcode.js +138 -0
  358. package/dist/src/lib/init-xcode.js.map +1 -0
  359. package/dist/src/lib/integration-request-config.d.ts +30 -0
  360. package/dist/src/lib/integration-request-config.js +145 -0
  361. package/dist/src/lib/integration-request-config.js.map +1 -0
  362. package/dist/src/lib/integration-selector.d.ts +42 -0
  363. package/dist/src/lib/integration-selector.js +46 -0
  364. package/dist/src/lib/integration-selector.js.map +1 -0
  365. package/dist/src/lib/ios-app-id.d.ts +34 -0
  366. package/dist/src/lib/ios-app-id.js +69 -0
  367. package/dist/src/lib/ios-app-id.js.map +1 -0
  368. package/dist/src/lib/list-options.d.ts +68 -0
  369. package/dist/src/lib/list-options.js +89 -0
  370. package/dist/src/lib/list-options.js.map +1 -0
  371. package/dist/src/lib/local-state.d.ts +55 -0
  372. package/dist/src/lib/local-state.js +167 -0
  373. package/dist/src/lib/local-state.js.map +1 -0
  374. package/dist/src/lib/local-test-cases.d.ts +63 -0
  375. package/dist/src/lib/local-test-cases.js +136 -0
  376. package/dist/src/lib/local-test-cases.js.map +1 -0
  377. package/dist/src/lib/log-inspection.d.ts +710 -0
  378. package/dist/src/lib/log-inspection.js +814 -0
  379. package/dist/src/lib/log-inspection.js.map +1 -0
  380. package/dist/src/lib/logout-admin-session.d.ts +33 -0
  381. package/dist/src/lib/logout-admin-session.js +70 -0
  382. package/dist/src/lib/logout-admin-session.js.map +1 -0
  383. package/dist/src/lib/migration-nag.d.ts +49 -0
  384. package/dist/src/lib/migration-nag.js +164 -0
  385. package/dist/src/lib/migration-nag.js.map +1 -0
  386. package/dist/src/lib/object-status-filter.d.ts +22 -0
  387. package/dist/src/lib/object-status-filter.js +45 -0
  388. package/dist/src/lib/object-status-filter.js.map +1 -0
  389. package/dist/src/lib/output.d.ts +124 -0
  390. package/dist/src/lib/output.js +219 -8
  391. package/dist/src/lib/output.js.map +1 -1
  392. package/dist/src/lib/package-manager.d.ts +140 -0
  393. package/dist/src/lib/package-manager.js +305 -0
  394. package/dist/src/lib/package-manager.js.map +1 -0
  395. package/dist/src/lib/paginate.d.ts +82 -0
  396. package/dist/src/lib/paginate.js +99 -0
  397. package/dist/src/lib/paginate.js.map +1 -0
  398. package/dist/src/lib/platform-owned.d.ts +63 -0
  399. package/dist/src/lib/platform-owned.js +85 -0
  400. package/dist/src/lib/platform-owned.js.map +1 -0
  401. package/dist/src/lib/project-config.d.ts +122 -0
  402. package/dist/src/lib/project-config.js +244 -0
  403. package/dist/src/lib/project-config.js.map +1 -0
  404. package/dist/src/lib/prompt-cost-format.d.ts +11 -0
  405. package/dist/src/lib/prompt-cost-format.js +41 -0
  406. package/dist/src/lib/prompt-cost-format.js.map +1 -0
  407. package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
  408. package/dist/src/lib/prompt-schema-codegen.js +462 -0
  409. package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
  410. package/dist/src/lib/query-operators.d.ts +43 -0
  411. package/dist/src/lib/query-operators.js +80 -0
  412. package/dist/src/lib/query-operators.js.map +1 -0
  413. package/dist/src/lib/record-filter.d.ts +18 -0
  414. package/dist/src/lib/record-filter.js +55 -0
  415. package/dist/src/lib/record-filter.js.map +1 -0
  416. package/dist/src/lib/refresh-admin-credentials.d.ts +73 -0
  417. package/dist/src/lib/refresh-admin-credentials.js +123 -0
  418. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  419. package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
  420. package/dist/src/lib/resolve-init-dev-port.js +55 -0
  421. package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
  422. package/dist/src/lib/resolve-init-server.d.ts +64 -0
  423. package/dist/src/lib/resolve-init-server.js +77 -0
  424. package/dist/src/lib/resolve-init-server.js.map +1 -0
  425. package/dist/src/lib/resolve-owner.d.ts +19 -0
  426. package/dist/src/lib/resolve-owner.js +20 -0
  427. package/dist/src/lib/resolve-owner.js.map +1 -0
  428. package/dist/src/lib/resolve-platform.d.ts +74 -0
  429. package/dist/src/lib/resolve-platform.js +105 -0
  430. package/dist/src/lib/resolve-platform.js.map +1 -0
  431. package/dist/src/lib/run-status.d.ts +19 -0
  432. package/dist/src/lib/run-status.generated.d.ts +39 -0
  433. package/dist/src/lib/run-status.generated.js +66 -0
  434. package/dist/src/lib/run-status.generated.js.map +1 -0
  435. package/dist/src/lib/run-status.js +19 -0
  436. package/dist/src/lib/run-status.js.map +1 -0
  437. package/dist/src/lib/server-text-normalization.d.ts +51 -0
  438. package/dist/src/lib/server-text-normalization.js +90 -0
  439. package/dist/src/lib/server-text-normalization.js.map +1 -0
  440. package/dist/src/lib/server-url.d.ts +22 -0
  441. package/dist/src/lib/server-url.js +33 -0
  442. package/dist/src/lib/server-url.js.map +1 -0
  443. package/dist/src/lib/signing-secret-status.d.ts +81 -0
  444. package/dist/src/lib/signing-secret-status.js +116 -0
  445. package/dist/src/lib/signing-secret-status.js.map +1 -0
  446. package/dist/src/lib/skill-installer.d.ts +71 -0
  447. package/dist/src/lib/skill-installer.js +441 -0
  448. package/dist/src/lib/skill-installer.js.map +1 -0
  449. package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
  450. package/dist/src/lib/snapshot-audit-source.js +58 -0
  451. package/dist/src/lib/snapshot-audit-source.js.map +1 -0
  452. package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
  453. package/dist/src/lib/snapshot-audit-store.js +196 -0
  454. package/dist/src/lib/snapshot-audit-store.js.map +1 -0
  455. package/dist/src/lib/snapshot-audit.d.ts +207 -0
  456. package/dist/src/lib/snapshot-audit.js +431 -0
  457. package/dist/src/lib/snapshot-audit.js.map +1 -0
  458. package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
  459. package/dist/src/lib/snapshot-build-rows.js +87 -0
  460. package/dist/src/lib/snapshot-build-rows.js.map +1 -0
  461. package/dist/src/lib/snapshot-build.d.ts +50 -0
  462. package/dist/src/lib/snapshot-build.js +111 -0
  463. package/dist/src/lib/snapshot-build.js.map +1 -0
  464. package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
  465. package/dist/src/lib/snapshot-manifest-layout.js +70 -0
  466. package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
  467. package/dist/src/lib/snapshots.d.ts +98 -0
  468. package/dist/src/lib/snapshots.js +294 -0
  469. package/dist/src/lib/snapshots.js.map +1 -0
  470. package/dist/src/lib/step-run-table.d.ts +43 -0
  471. package/dist/src/lib/step-run-table.js +129 -0
  472. package/dist/src/lib/step-run-table.js.map +1 -0
  473. package/dist/src/lib/storage-pending-retry.d.ts +26 -0
  474. package/dist/src/lib/storage-pending-retry.js +42 -0
  475. package/dist/src/lib/storage-pending-retry.js.map +1 -0
  476. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
  477. package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
  478. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
  479. package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
  480. package/dist/src/lib/swift-codegen/banners.js +25 -0
  481. package/dist/src/lib/swift-codegen/banners.js.map +1 -0
  482. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
  483. package/dist/src/lib/swift-codegen/dbGenerator.js +926 -0
  484. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  485. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  486. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  487. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  488. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
  489. package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
  490. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
  491. package/dist/src/lib/swift-codegen/generator.d.ts +100 -0
  492. package/dist/src/lib/swift-codegen/generator.js +457 -0
  493. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  494. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +87 -0
  495. package/dist/src/lib/swift-codegen/schemaToSwift.js +661 -0
  496. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  497. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
  498. package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
  499. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  500. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  501. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  502. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  503. package/dist/src/lib/sync-dir-selector.d.ts +21 -0
  504. package/dist/src/lib/sync-dir-selector.js +30 -0
  505. package/dist/src/lib/sync-dir-selector.js.map +1 -0
  506. package/dist/src/lib/sync-paths.d.ts +128 -0
  507. package/dist/src/lib/sync-paths.js +195 -0
  508. package/dist/src/lib/sync-paths.js.map +1 -0
  509. package/dist/src/lib/sync-resource-types.d.ts +563 -0
  510. package/dist/src/lib/sync-resource-types.js +1073 -0
  511. package/dist/src/lib/sync-resource-types.js.map +1 -0
  512. package/dist/src/lib/sync-selectors.d.ts +138 -0
  513. package/dist/src/lib/sync-selectors.js +289 -0
  514. package/dist/src/lib/sync-selectors.js.map +1 -0
  515. package/dist/src/lib/template.d.ts +170 -0
  516. package/dist/src/lib/template.js +484 -68
  517. package/dist/src/lib/template.js.map +1 -1
  518. package/dist/src/lib/test-case-file-names.d.ts +40 -0
  519. package/dist/src/lib/test-case-file-names.js +91 -0
  520. package/dist/src/lib/test-case-file-names.js.map +1 -0
  521. package/dist/src/lib/test-case-keys.d.ts +29 -0
  522. package/dist/src/lib/test-case-keys.js +55 -0
  523. package/dist/src/lib/test-case-keys.js.map +1 -0
  524. package/dist/src/lib/test-case-variables.d.ts +29 -0
  525. package/dist/src/lib/test-case-variables.js +71 -0
  526. package/dist/src/lib/test-case-variables.js.map +1 -0
  527. package/dist/src/lib/token-inject.d.ts +56 -0
  528. package/dist/src/lib/token-inject.js +204 -0
  529. package/dist/src/lib/token-inject.js.map +1 -0
  530. package/dist/src/lib/toml-database-config.d.ts +123 -0
  531. package/dist/src/lib/toml-database-config.js +544 -0
  532. package/dist/src/lib/toml-database-config.js.map +1 -0
  533. package/dist/src/lib/toml-metadata-config.d.ts +151 -0
  534. package/dist/src/lib/toml-metadata-config.js +476 -0
  535. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  536. package/dist/src/lib/toml-native-form.d.ts +46 -0
  537. package/dist/src/lib/toml-native-form.js +78 -0
  538. package/dist/src/lib/toml-native-form.js.map +1 -0
  539. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  540. package/dist/src/lib/toml-params-validator.js +298 -0
  541. package/dist/src/lib/toml-params-validator.js.map +1 -0
  542. package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
  543. package/dist/src/lib/toml-scalar-edit.js +283 -0
  544. package/dist/src/lib/toml-scalar-edit.js.map +1 -0
  545. package/dist/src/lib/user-selector.d.ts +24 -0
  546. package/dist/src/lib/user-selector.js +33 -0
  547. package/dist/src/lib/user-selector.js.map +1 -0
  548. package/dist/src/lib/version-check.d.ts +35 -0
  549. package/dist/src/lib/version-check.js +241 -0
  550. package/dist/src/lib/version-check.js.map +1 -0
  551. package/dist/src/lib/watch.d.ts +121 -0
  552. package/dist/src/lib/watch.js +169 -0
  553. package/dist/src/lib/watch.js.map +1 -0
  554. package/dist/src/lib/web-url.d.ts +40 -0
  555. package/dist/src/lib/web-url.js +76 -0
  556. package/dist/src/lib/web-url.js.map +1 -0
  557. package/dist/src/lib/webhook-deliver.d.ts +209 -0
  558. package/dist/src/lib/webhook-deliver.js +519 -0
  559. package/dist/src/lib/webhook-deliver.js.map +1 -0
  560. package/dist/src/lib/workflow-apply.d.ts +110 -0
  561. package/dist/src/lib/workflow-apply.js +164 -0
  562. package/dist/src/lib/workflow-apply.js.map +1 -0
  563. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  564. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  565. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  566. package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
  567. package/dist/src/lib/workflow-codegen/generator.js +361 -0
  568. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  569. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
  570. package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
  571. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  572. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  573. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  574. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  575. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
  576. package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
  577. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  578. package/dist/src/lib/workflow-config-apply.d.ts +70 -0
  579. package/dist/src/lib/workflow-config-apply.js +137 -0
  580. package/dist/src/lib/workflow-config-apply.js.map +1 -0
  581. package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
  582. package/dist/src/lib/workflow-config-sidecar.js +96 -0
  583. package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
  584. package/dist/src/lib/workflow-defaults.d.ts +29 -0
  585. package/dist/src/lib/workflow-defaults.js +41 -0
  586. package/dist/src/lib/workflow-defaults.js.map +1 -0
  587. package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
  588. package/dist/src/lib/workflow-field-descriptor.js +153 -0
  589. package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
  590. package/dist/src/lib/workflow-fragments.d.ts +64 -0
  591. package/dist/src/lib/workflow-fragments.js +342 -0
  592. package/dist/src/lib/workflow-fragments.js.map +1 -0
  593. package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
  594. package/dist/src/lib/workflow-include-preserve.js +286 -0
  595. package/dist/src/lib/workflow-include-preserve.js.map +1 -0
  596. package/dist/src/lib/workflow-payload.d.ts +98 -0
  597. package/dist/src/lib/workflow-payload.js +178 -0
  598. package/dist/src/lib/workflow-payload.js.map +1 -0
  599. package/dist/src/lib/workflow-toml-validator.d.ts +211 -0
  600. package/dist/src/lib/workflow-toml-validator.js +770 -0
  601. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  602. package/dist/src/lib/workflow-usage.d.ts +196 -0
  603. package/dist/src/lib/workflow-usage.js +310 -0
  604. package/dist/src/lib/workflow-usage.js.map +1 -0
  605. package/dist/src/types/index.d.ts +591 -0
  606. package/dist/src/validators.d.ts +65 -0
  607. package/dist/src/validators.js +64 -0
  608. package/dist/src/validators.js.map +1 -0
  609. package/package.json +34 -9
@@ -0,0 +1,2513 @@
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
+ }>;
659
+ createInvitation(appId: string, data: {
660
+ email: string;
661
+ role: "admin" | "member";
662
+ expiresInDays?: number;
663
+ sendEmail?: boolean;
664
+ note?: string;
665
+ }): Promise<any>;
666
+ deleteInvitation(appId: string, invitationId: string): Promise<void>;
667
+ listWaitlist(appId: string): Promise<any[]>;
668
+ inviteWaitlistEntry(appId: string, waitlistId: string, options?: {
669
+ sendEmail?: boolean;
670
+ signupUrl?: string;
671
+ }): Promise<any>;
672
+ bulkInviteWaitlist(appId: string, payload: {
673
+ waitlistIds?: string[];
674
+ count?: number;
675
+ sendEmail?: boolean;
676
+ signupUrl?: string;
677
+ }): Promise<any>;
678
+ removeWaitlistEntry(appId: string, waitlistId: string): Promise<void>;
679
+ listDeferredGrants(appId: string, params?: {
680
+ type?: string;
681
+ email?: string;
682
+ limit?: number;
683
+ cursor?: string;
684
+ }): Promise<{
685
+ items: any[];
686
+ nextCursor?: string | null;
687
+ hasMore?: boolean;
688
+ }>;
689
+ revokeDeferredGrant(appId: string, deferredId: string, type: string): Promise<any>;
690
+ listIntegrations(appId: string, params?: {
691
+ status?: string;
692
+ cursor?: string;
693
+ limit?: number;
694
+ }): Promise<{
695
+ items: any[];
696
+ hasMore?: boolean;
697
+ nextCursor?: string | null;
698
+ }>;
699
+ /** Integration detail (#2631: `accessRule` is on the detail, not the list summary). */
700
+ getIntegration(appId: string, integrationId: string): Promise<IntegrationDetail>;
701
+ /**
702
+ * An integration's named configs. Test cases pin a config by NAME so the
703
+ * sidecar is portable across apps (#2769); this is the map pull and push
704
+ * resolve that name through, the same way prompts/workflows/scripts do.
705
+ */
706
+ listIntegrationConfigs(appId: string, integrationId: string): Promise<{
707
+ items: any[];
708
+ }>;
709
+ createIntegration(appId: string, payload: IntegrationWritePayload): Promise<any>;
710
+ updateIntegration(appId: string, integrationId: string, payload: IntegrationWritePayload, expectedModifiedAt?: string): Promise<any>;
711
+ /**
712
+ * Delete an integration. Archives it by default; `{ hard: true }` destroys
713
+ * the row instead, which is what `config push --prune` passes (#2803) so a
714
+ * pruned integration stops holding its key. The positional boolean is still
715
+ * accepted for the existing callers.
716
+ */
717
+ deleteIntegration(appId: string, integrationId: string, hard?: boolean | {
718
+ hard?: boolean;
719
+ }): Promise<ArchiveEnvelope>;
720
+ testIntegration(appId: string, integrationId: string, payload: any): Promise<any>;
721
+ listIntegrationLogs(appId: string, integrationId: string, params?: {
722
+ limit?: number;
723
+ status?: string;
724
+ from?: string;
725
+ to?: string;
726
+ source?: "user" | "admin" | "test" | "workflow" | "function";
727
+ /** #3691 — only the calls this run made, workflow run or function run. */
728
+ runId?: string;
729
+ }): Promise<any[]>;
730
+ listWorkflowRunIntegrationLogs(appId: string, runId: string, params?: {
731
+ limit?: number;
732
+ }): Promise<any[]>;
733
+ listAppSecrets(appId: string): Promise<any[]>;
734
+ createAppSecret(appId: string, payload: {
735
+ key: string;
736
+ value: string;
737
+ summary?: string;
738
+ }): Promise<any>;
739
+ updateAppSecret(appId: string, secretId: string, payload: {
740
+ value?: string;
741
+ summary?: string;
742
+ }): Promise<any>;
743
+ upsertAppSecret(appId: string, key: string, payload: {
744
+ value: string;
745
+ summary?: string;
746
+ }): Promise<any>;
747
+ deleteAppSecret(appId: string, secretId: string): Promise<any>;
748
+ listAppConfigVars(appId: string): Promise<any[]>;
749
+ upsertAppConfigVar(appId: string, key: string, payload: {
750
+ value: string;
751
+ summary?: string;
752
+ }, expectedModifiedAt?: string, options?: {
753
+ expectNotExists?: boolean;
754
+ }): Promise<any>;
755
+ deleteAppConfigVar(appId: string, key: string, expectedModifiedAt?: string): Promise<any>;
756
+ listWebhooks(appId: string, params?: {
757
+ status?: string;
758
+ cursor?: string;
759
+ limit?: number;
760
+ }): Promise<{
761
+ items: any[];
762
+ hasMore?: boolean;
763
+ nextCursor?: string | null;
764
+ }>;
765
+ getWebhook(appId: string, webhookId: string): Promise<any>;
766
+ createWebhook(appId: string, payload: any): Promise<any>;
767
+ updateWebhook(appId: string, webhookId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
768
+ /**
769
+ * Delete a webhook. Archives it by default; `hard` hard-deletes the row
770
+ * instead (#2232), which is what frees a slot under the per-app webhook cap
771
+ * and releases the webhook key for reuse. Same `?hard=true` verb the admin
772
+ * integrations delete uses.
773
+ */
774
+ deleteWebhook(appId: string, webhookId: string, options?: {
775
+ hard?: boolean;
776
+ }): Promise<ArchiveEnvelope>;
777
+ /**
778
+ * #2803 — the operational verb pair for a webhook. It posts to the
779
+ * enable/disable route rather than PATCHing `status`, which is server-owned
780
+ * and refused on every configuration write path.
781
+ */
782
+ setWebhookAvailability(appId: string, webhookId: string, action: "enable" | "disable"): Promise<any>;
783
+ listFunctions(appId: string): Promise<{
784
+ items: any[];
785
+ }>;
786
+ getFunction(appId: string, functionId: string): Promise<any>;
787
+ createFunction(appId: string, payload: any): Promise<any>;
788
+ updateFunction(appId: string, functionId: string, payload: any): Promise<any>;
789
+ /**
790
+ * Archive a function, or destroy it with `hard`. Archiving KEEPS the key
791
+ * reserved in the app's single key namespace; the hard delete is what
792
+ * releases it, destroys every config version and removes the R2 objects.
793
+ */
794
+ deleteFunction(appId: string, functionId: string, options?: {
795
+ hard?: boolean;
796
+ }): Promise<ArchiveEnvelope>;
797
+ /** #2803 — the operational verb pair for a server function. */
798
+ setFunctionAvailability(appId: string, functionId: string, action: "enable" | "disable"): Promise<any>;
799
+ /** Every config version of a function, oldest first. */
800
+ /**
801
+ * A function's runs, newest first (#3181).
802
+ *
803
+ * A function run has no `workflowId`, so no workflow runs listing can see
804
+ * it — this is the only surface that lists one. Cursor-paginated like the
805
+ * other admin listings.
806
+ */
807
+ listFunctionRuns(appId: string, functionId: string, params?: {
808
+ limit?: number;
809
+ cursor?: string;
810
+ }): Promise<{
811
+ items: any[];
812
+ nextCursor?: string | null;
813
+ }>;
814
+ /**
815
+ * A function run's step trace — #3348.
816
+ *
817
+ * The function-scoped twin of `getWorkflowStepRuns`, and it answers with the
818
+ * same rows in the same shape: `workflows/:idOrKey/runs/...` resolves its
819
+ * first argument to a workflow DEFINITION, which a function id and a function
820
+ * key alike miss, so a durable run's steps needed a route that addresses the
821
+ * run by the function that owns it.
822
+ */
823
+ getFunctionStepRuns(appId: string, functionId: string, runId: string): Promise<{
824
+ items: any[];
825
+ }>;
826
+ /**
827
+ * End a function run that will not settle — #3348.
828
+ *
829
+ * `terminated: false` means the run had already settled and the route
830
+ * reported its outcome instead of overwriting it.
831
+ */
832
+ terminateFunctionRun(appId: string, functionId: string, runId: string): Promise<{
833
+ runId: string;
834
+ status: string;
835
+ terminated: boolean;
836
+ endedAt?: string | null;
837
+ instanceTerminated?: boolean;
838
+ }>;
839
+ /**
840
+ * A function's invocation records, newest first — #3287.
841
+ *
842
+ * The ADMIN route, beside the runs listing above and for the same reason:
843
+ * the CLI acts as an operator, not as a member of the app. The app-API twin
844
+ * (`functions.logs`) is what a FUNCTION reads through the SDK profile.
845
+ */
846
+ listFunctionLogs(appId: string, functionId: string, params?: {
847
+ limit?: number;
848
+ cursor?: string;
849
+ runId?: string;
850
+ }): Promise<{
851
+ items: any[];
852
+ nextCursor?: string | null;
853
+ }>;
854
+ /**
855
+ * One invocation record by its id — #3448, behind `functions logs
856
+ * --invocation <id>`.
857
+ *
858
+ * The id the invoke envelope answered with. A record that never existed,
859
+ * one of ANOTHER function, and one the seven-day TTL has expired all answer
860
+ * the same 404, which is what the listing's own filter promises.
861
+ */
862
+ getFunctionLog(appId: string, functionId: string, invocationId: string): Promise<any>;
863
+ /**
864
+ * One function run, RECONCILED against the engine — #3448, what
865
+ * `functions runs wait` polls.
866
+ *
867
+ * NOT the runs listing: that reports the STORED status, and a durable run's
868
+ * row stays `running` until something asks the engine, so a wait built on it
869
+ * would never settle.
870
+ */
871
+ getFunctionRun(appId: string, functionId: string, runId: string): Promise<{
872
+ status: any;
873
+ run: any;
874
+ slice?: any;
875
+ }>;
876
+ /**
877
+ * The operator's own APP user — #3448 D3448-009.
878
+ *
879
+ * `getMe()` reads the ADMIN profile (`/admin/api/me`); this is the
880
+ * app-scoped route, which answers the app user `requireAppPermission`
881
+ * provisions for an admin and the `appRole` it gave them. That is the
882
+ * identity a `functions invoke` runs under by default, and printing it is
883
+ * how an operator knows their call bypassed the function's `access` gate.
884
+ */
885
+ getAppProfile(appId: string): Promise<{
886
+ userId: string;
887
+ email: string | null;
888
+ name?: string | null;
889
+ appRole: string;
890
+ appId: string;
891
+ }>;
892
+ /**
893
+ * Invoke a function and hand back the ANSWER, whatever its HTTP status —
894
+ * #3448 D3448-010.
895
+ *
896
+ * `request` throws an `ApiError` on any non-2xx, which is right for every
897
+ * other verb and wrong for this one: a 429 carries a `Retry-After` an
898
+ * operator needs to see, and a 409 mode mismatch carries the version's real
899
+ * mode. Rendering those from an exception means re-deriving what the server
900
+ * already said. So this returns the envelope with its status and its retry
901
+ * hint, and throws only when the request did not complete at all.
902
+ *
903
+ * `bearer` is the `--user` path's minted token; absent, the CLI's own
904
+ * credentials. `mode` is ALWAYS sent (D3448-012): it is what makes the
905
+ * server, not the CLI, the authority on a wrong verb.
906
+ */
907
+ invokeFunction(appId: string, functionKey: string, body: Record<string, unknown>, options?: {
908
+ bearer?: string;
909
+ asSystem?: boolean;
910
+ /**
911
+ * Which runtime this call means — #3482. The ROUTE is the selector:
912
+ * `POST functions/{key}` runs the function inside the request and
913
+ * `POST functions/{key}/start` runs it as a task. The admin-only system
914
+ * door is ONE route for both, so `--as system` keeps naming its runtime
915
+ * in the body (F-3482-007); phase 7's rename may fold it.
916
+ */
917
+ runtime?: "request" | "task";
918
+ }): Promise<{
919
+ httpStatus: number;
920
+ retryAfterSeconds: number | null;
921
+ body: any;
922
+ }>;
923
+ /**
924
+ * A function's versions, newest first (#3462).
925
+ *
926
+ * Paging is opt-in on the server: with no `limit` and no `cursor` every
927
+ * version comes back, which is what this method did before paging existed and
928
+ * what an already-installed CLI still asks for. A caller that passes either
929
+ * gets the shared `{ items, hasMore, nextCursor }` page.
930
+ */
931
+ listFunctionConfigs(appId: string, functionId: string, options?: {
932
+ limit?: number;
933
+ cursor?: string;
934
+ }): Promise<{
935
+ items: any[];
936
+ hasMore: boolean;
937
+ nextCursor?: string | null;
938
+ }>;
939
+ /**
940
+ * Point the function at one of its OWN existing versions (#3462). Creates no
941
+ * version; the activated version's capabilities, limits and triggers apply
942
+ * from the next call.
943
+ */
944
+ activateFunctionConfig(appId: string, functionId: string, configId: string): Promise<any>;
945
+ getFunctionConfig(appId: string, functionId: string, configId: string): Promise<any>;
946
+ /**
947
+ * The stored envelope: the authored TOML bytes, every source file and the
948
+ * built bundle, all base64. This is what `config pull` writes back verbatim.
949
+ */
950
+ getFunctionConfigEnvelope(appId: string, functionId: string, configId: string): Promise<any>;
951
+ /** Push a config version. The server verifies `contentHash` itself. */
952
+ pushFunctionConfig(appId: string, functionId: string, payload: any): Promise<any>;
953
+ /** #2803 — the operational verb pair for a prompt (admin API). */
954
+ setPromptAvailability(appId: string, promptId: string, action: "enable" | "disable"): Promise<any>;
955
+ /** #2803 — the operational verb pair for an integration (admin API). */
956
+ setIntegrationAvailability(appId: string, integrationId: string, action: "enable" | "disable"): Promise<any>;
957
+ rotateWebhookSecret(appId: string, webhookId: string, payload: {
958
+ signingSecret: string;
959
+ }): Promise<any>;
960
+ listWebhookEvents(appId: string, webhookId: string, params?: {
961
+ limit?: number;
962
+ cursor?: string;
963
+ }): Promise<{
964
+ items: any[];
965
+ hasMore?: boolean;
966
+ nextCursor?: string | null;
967
+ }>;
968
+ /**
969
+ * List the live connections the server believes exist for exactly one of a
970
+ * document, user, or database. Read-only inspection over admin-api. Rows are
971
+ * per-connection-×-subscription bindings, so `connectionId` is not unique
972
+ * across rows. `params` on a database-subscription row is caller-defined
973
+ * bound CEL input — typed `unknown`.
974
+ */
975
+ listConnections(appId: string, selector: {
976
+ documentId?: string;
977
+ userId?: string;
978
+ databaseId?: string;
979
+ }, params?: {
980
+ limit?: number;
981
+ cursor?: string;
982
+ }): Promise<{
983
+ items: unknown[];
984
+ hasMore?: boolean;
985
+ nextCursor?: string | null;
986
+ }>;
987
+ listSessions(appId: string, userId: string, params?: {
988
+ limit?: number;
989
+ cursor?: string;
990
+ }): Promise<{
991
+ items: unknown[];
992
+ hasMore?: boolean;
993
+ nextCursor?: string | null;
994
+ }>;
995
+ /**
996
+ * One page of admin sessions (#3885): the caller's own, or — for a
997
+ * super-admin — the admin `adminId` names.
998
+ */
999
+ listAdminSessions(params?: {
1000
+ adminId?: string;
1001
+ limit?: number;
1002
+ cursor?: string;
1003
+ }): Promise<{
1004
+ items: unknown[];
1005
+ hasMore?: boolean;
1006
+ nextCursor?: string | null;
1007
+ }>;
1008
+ /** Revoke an admin session (idempotent). */
1009
+ revokeAdminSession(sessionId: string): Promise<{
1010
+ sessionId: string;
1011
+ revokedAt: string;
1012
+ }>;
1013
+ testWebhook(appId: string, webhookId: string, payload?: any): Promise<any>;
1014
+ /**
1015
+ * Run a webhook's configured verifier over headers and a body captured from
1016
+ * a real delivery, and report whether that signature checks out (#2445).
1017
+ *
1018
+ * `headers` is sent as ordered `[name, value]` pairs so a capture carrying a
1019
+ * field name on more than one line survives the round trip. Nothing is
1020
+ * delivered: no delivery record, no workflow run.
1021
+ */
1022
+ verifyWebhook(appId: string, webhookId: string, payload: {
1023
+ headers: Array<[string, string]>;
1024
+ rawBody?: string;
1025
+ bodyBase64?: string;
1026
+ }): Promise<any>;
1027
+ listLocks(appId: string): Promise<{
1028
+ locks: any[];
1029
+ }>;
1030
+ getLockStatus(appId: string, key: string): Promise<any>;
1031
+ /**
1032
+ * #3562 — `owner` is sent only when one was given, so a call that names none
1033
+ * composes byte for byte the body it always did.
1034
+ */
1035
+ acquireLock(appId: string, key: string, ttlMs: number, owner?: string): Promise<any>;
1036
+ releaseLock(appId: string, key: string, handleId: string): Promise<any>;
1037
+ listCronTriggers(appId: string): Promise<{
1038
+ items: any[];
1039
+ }>;
1040
+ getCronTrigger(appId: string, triggerId: string): Promise<any>;
1041
+ createCronTrigger(appId: string, payload: any): Promise<any>;
1042
+ updateCronTrigger(appId: string, triggerId: string, payload: any): Promise<any>;
1043
+ /**
1044
+ * Retire a cron trigger. The default soft-deletes (writes the `archived`
1045
+ * tombstone); `{ hard: true }` destroys the row, which is what
1046
+ * `config push --prune` passes (#2803) so a pruned trigger stops consuming
1047
+ * the per-app cap and holding its key.
1048
+ */
1049
+ deleteCronTrigger(appId: string, triggerId: string, options?: {
1050
+ hard?: boolean;
1051
+ }): Promise<ArchiveEnvelope>;
1052
+ disableCronTrigger(appId: string, triggerId: string): Promise<any>;
1053
+ enableCronTrigger(appId: string, triggerId: string): Promise<any>;
1054
+ testCronTrigger(appId: string, triggerId: string): Promise<any>;
1055
+ listIterations(appId: string): Promise<{
1056
+ items: any[];
1057
+ }>;
1058
+ getIteration(appId: string, iterationName: string): Promise<any>;
1059
+ resetIteration(appId: string, iterationName: string): Promise<any>;
1060
+ readResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string): Promise<any>;
1061
+ writeResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string, data: Record<string, any>): Promise<any>;
1062
+ batchReadResourceMetadata(appId: string, requests: Array<{
1063
+ resourceType: string;
1064
+ resourceId: string;
1065
+ categories: string[];
1066
+ }>): Promise<{
1067
+ results: any[];
1068
+ }>;
1069
+ /**
1070
+ * List every stored metadata category on one resource (issue #1402 — debug
1071
+ * tooling). The CLI authenticates as a console admin, so the app-level
1072
+ * owner/admin bypass returns every category regardless of its readRule.
1073
+ */
1074
+ listResourceMetadata(appId: string, resourceType: string, resourceId: string): Promise<{
1075
+ resourceType: string;
1076
+ resourceId: string;
1077
+ categories: Array<{
1078
+ category: string;
1079
+ data: Record<string, any>;
1080
+ schemaVersion: number | null;
1081
+ }>;
1082
+ }>;
1083
+ /**
1084
+ * Delete one resource's metadata for one category (issue #1402 — debug
1085
+ * tooling). Idempotent: deleting an absent item succeeds with
1086
+ * `deleted: false` rather than a 404.
1087
+ */
1088
+ deleteResourceMetadata(appId: string, resourceType: string, resourceId: string, category: string): Promise<{
1089
+ resourceType: string;
1090
+ resourceId: string;
1091
+ category: string;
1092
+ deleted: boolean;
1093
+ }>;
1094
+ /**
1095
+ * Reverse-resolve a resource by a category's unique metadata value (issue
1096
+ * #2137). A miss is a success with `resourceId: null`, never an error. The
1097
+ * CLI authenticates as a console admin, so the app-level owner/admin bypass
1098
+ * skips readRule evaluation.
1099
+ */
1100
+ resolveResourceMetadata(appId: string, resourceType: string, category: string, key: string, value: string): Promise<{
1101
+ resourceId: string | null;
1102
+ resourceType?: string;
1103
+ }>;
1104
+ listPrompts(appId: string, params?: {
1105
+ status?: string;
1106
+ limit?: number;
1107
+ cursor?: string;
1108
+ }): Promise<{
1109
+ items: any[];
1110
+ hasMore?: boolean;
1111
+ nextCursor?: string | null;
1112
+ }>;
1113
+ getPrompt(appId: string, promptId: string): Promise<any>;
1114
+ createPrompt(appId: string, payload: any): Promise<any>;
1115
+ updatePrompt(appId: string, promptId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
1116
+ /**
1117
+ * Retire a prompt, or destroy it.
1118
+ *
1119
+ * `hard` was always sent by both first-party clients and always ignored by
1120
+ * the server; #2887 made it mean something — the plain call now archives.
1121
+ */
1122
+ deletePrompt(appId: string, promptId: string, hard?: boolean): Promise<ArchiveEnvelope>;
1123
+ executePrompt(appId: string, promptId: string, payload: {
1124
+ variables: Record<string, any>;
1125
+ modelOverride?: string;
1126
+ configId?: string;
1127
+ }): Promise<any>;
1128
+ previewPrompt(appId: string, promptId: string, payload: {
1129
+ variables: Record<string, any>;
1130
+ configId?: string;
1131
+ }): Promise<any>;
1132
+ listPromptConfigs(appId: string, promptId: string): Promise<{
1133
+ items: any[];
1134
+ }>;
1135
+ getPromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
1136
+ createPromptConfig(appId: string, promptId: string, payload: any): Promise<any>;
1137
+ updatePromptConfig(appId: string, promptId: string, configId: string, payload: any): Promise<any>;
1138
+ activatePromptConfig(appId: string, promptId: string, configId: string): Promise<any>;
1139
+ duplicatePromptConfig(appId: string, promptId: string, configId: string, payload?: {
1140
+ configName?: string;
1141
+ description?: string;
1142
+ }): Promise<any>;
1143
+ listScripts(appId: string): Promise<{
1144
+ items: any[];
1145
+ }>;
1146
+ getScript(appId: string, scriptId: string): Promise<any>;
1147
+ /**
1148
+ * List a script's versioned configs (the `ScriptConfig` rows). Each config
1149
+ * is a distinct block version: `configId` is the stable version selector,
1150
+ * `contentHash` is its content identity, and `status` reports whether it is
1151
+ * `active`/`draft`/`archived`. The script header's `activeConfigId` names
1152
+ * the live version. Used by `scripts configs list` and by the script test
1153
+ * commands to run against a specific pinned version.
1154
+ */
1155
+ listScriptConfigs(appId: string, scriptId: string): Promise<{
1156
+ items: any[];
1157
+ }>;
1158
+ createScript(appId: string, payload: {
1159
+ name: string;
1160
+ body: string;
1161
+ description?: string;
1162
+ }): Promise<any>;
1163
+ /**
1164
+ * Push a new body for an existing script by creating a new `ScriptConfig`
1165
+ * and activating it (the prompt-model "edit → activate" flow). Referencing
1166
+ * workflows pick up the new body on their next run with no fan-out. The
1167
+ * config name is unique per script, so we mint a timestamped name.
1168
+ */
1169
+ pushScriptBody(appId: string, scriptId: string, body: string,
1170
+ /**
1171
+ * The active state the caller believes holds right now (#2731 B10).
1172
+ * Creating an inactive config races nothing, so the guard sits on the
1173
+ * ACTIVATION step: if the active config has moved since the caller read it,
1174
+ * the server rejects with a 409 instead of overwriting a concurrent script
1175
+ * change. It takes BOTH halves of "what is active", because a config's body
1176
+ * can be edited in place without the active id changing — the id alone
1177
+ * would let such an edit through. Omitted (e.g. `--force`) means activate
1178
+ * unconditionally.
1179
+ */
1180
+ expectedActive?: {
1181
+ configId?: string;
1182
+ modifiedAt?: string;
1183
+ }): Promise<any>;
1184
+ /**
1185
+ * Delete a script header (cascades its configs). `force` overrides the
1186
+ * server's guard against deleting a script that an active workflow still
1187
+ * references by name — without it the server answers 409.
1188
+ */
1189
+ deleteScript(appId: string, scriptId: string, force?: boolean): Promise<void>;
1190
+ getPromptSchema(appId: string, promptId: string): Promise<{
1191
+ promptId: string;
1192
+ promptKey: string;
1193
+ displayName: string;
1194
+ inputSchema: any;
1195
+ inputVariables: string[];
1196
+ outputSchema: any;
1197
+ activeConfigId: string | null;
1198
+ activeConfigName: string | null;
1199
+ }>;
1200
+ /**
1201
+ * One page of a block's test cases. The endpoint paginates (default 50, cap
1202
+ * 100) and reports `nextCursor`; callers that reconcile the sync tree must
1203
+ * drain every page before deleting or classifying anything (#2769).
1204
+ */
1205
+ listTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, params?: {
1206
+ limit?: number;
1207
+ cursor?: string;
1208
+ }): Promise<{
1209
+ items: any[];
1210
+ hasMore?: boolean;
1211
+ nextCursor?: string;
1212
+ }>;
1213
+ getTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<any>;
1214
+ createTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
1215
+ name: string;
1216
+ description?: string | null;
1217
+ inputVariables: Record<string, any>;
1218
+ expectedOutputPattern?: string;
1219
+ expectedOutputContains?: string[];
1220
+ expectedJsonSubset?: Record<string, any>;
1221
+ configId?: string;
1222
+ evaluatorPromptId?: string;
1223
+ evaluatorConfigId?: string;
1224
+ /** The sidecar's file name — the case's identity (#2896). */
1225
+ key?: string;
1226
+ }): Promise<any>;
1227
+ updateTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, payload: {
1228
+ name?: string;
1229
+ description?: string | null;
1230
+ inputVariables?: Record<string, any>;
1231
+ expectedOutputPattern?: string | null;
1232
+ expectedOutputContains?: string[] | null;
1233
+ expectedJsonSubset?: Record<string, any> | null;
1234
+ configId?: string | null;
1235
+ evaluatorPromptId?: string | null;
1236
+ evaluatorConfigId?: string | null;
1237
+ /** The sidecar's file name, on a create-or-rename backfill (#2896). */
1238
+ key?: string;
1239
+ }): Promise<any>;
1240
+ deleteTestCase(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<void>;
1241
+ listTestCaseAttachments(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string): Promise<{
1242
+ attachments: Array<{
1243
+ filename: string;
1244
+ contentType: string;
1245
+ size: number;
1246
+ r2Key: string;
1247
+ }>;
1248
+ }>;
1249
+ uploadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string, data: Buffer, contentType: string): Promise<{
1250
+ success: boolean;
1251
+ attachment: {
1252
+ filename: string;
1253
+ contentType: string;
1254
+ size: number;
1255
+ r2Key: string;
1256
+ };
1257
+ }>;
1258
+ downloadTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
1259
+ data: Buffer;
1260
+ contentType: string;
1261
+ }>;
1262
+ deleteTestCaseAttachment(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, testCaseId: string, filename: string): Promise<{
1263
+ success: boolean;
1264
+ deleted: boolean;
1265
+ }>;
1266
+ executeBlockTest(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload: {
1267
+ variables?: Record<string, any>;
1268
+ testCaseId?: string;
1269
+ configId?: string;
1270
+ comparisonGroup?: string;
1271
+ }): Promise<any>;
1272
+ runAllTestCases(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
1273
+ overrideConfigId?: string;
1274
+ comparisonGroup?: string;
1275
+ testCaseIds?: string[];
1276
+ }): Promise<any>;
1277
+ listTestRuns(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, params?: {
1278
+ limit?: number;
1279
+ comparisonGroup?: string;
1280
+ }): Promise<{
1281
+ items: any[];
1282
+ }>;
1283
+ listWorkflows(appId: string, params?: {
1284
+ status?: string;
1285
+ limit?: number;
1286
+ cursor?: string;
1287
+ }): Promise<{
1288
+ items: any[];
1289
+ hasMore?: boolean;
1290
+ nextCursor?: string | null;
1291
+ }>;
1292
+ getWorkflow(appId: string, workflowId: string): Promise<any>;
1293
+ /**
1294
+ * One app's workflow step usage report (#3132).
1295
+ *
1296
+ * `windowDays` is omitted from the query when the caller did not ask for a
1297
+ * window, so the server applies its own default rather than the CLI
1298
+ * restating it on the wire.
1299
+ */
1300
+ getWorkflowUsage(appId: string, params?: {
1301
+ windowDays?: number;
1302
+ }): Promise<WorkflowUsageReport>;
1303
+ createWorkflow(appId: string, payload: any): Promise<any>;
1304
+ updateWorkflow(appId: string, workflowId: string, payload: any, expectedModifiedAt?: string): Promise<any>;
1305
+ /**
1306
+ * Retire a workflow, or destroy it (#2887).
1307
+ *
1308
+ * The plain call ARCHIVES: the definition row stays, so its runs, revisions
1309
+ * and test cases keep resolving. `{ hard: true }` performs the full cascade
1310
+ * and is what releases the `workflowKey` — the flag `config push --prune`
1311
+ * sends, for the same reason it sends it for webhooks and integrations.
1312
+ */
1313
+ deleteWorkflow(appId: string, workflowId: string, options?: {
1314
+ hard?: boolean;
1315
+ }): Promise<ArchiveEnvelope>;
1316
+ /**
1317
+ * #2645 criterion 9 — the operational toggle. Deliberately NOT the config
1318
+ * PATCH: `config push` owns every configuration field, and taking a workflow
1319
+ * out of service must not touch one, or an operator's action would show up as
1320
+ * drift against the repo. Same route shape as `cron-triggers pause|resume`.
1321
+ */
1322
+ disableWorkflow(appId: string, workflowId: string): Promise<any>;
1323
+ enableWorkflow(appId: string, workflowId: string): Promise<any>;
1324
+ updateWorkflowDraft(appId: string, workflowId: string, payload: any): Promise<any>;
1325
+ previewWorkflow(appId: string, workflowId: string, payload: {
1326
+ rootInput?: object;
1327
+ meta?: object;
1328
+ configId?: string;
1329
+ useDraft?: boolean;
1330
+ preferActive?: boolean;
1331
+ }): Promise<{
1332
+ instanceId: string;
1333
+ usingDraft?: boolean;
1334
+ source?: "config" | "active" | "draft" | null;
1335
+ configName?: string | null;
1336
+ configId?: string | null;
1337
+ warning?: string;
1338
+ }>;
1339
+ getPreviewStatus(appId: string, workflowId: string, instanceId: string): Promise<any>;
1340
+ listWorkflowRuns(appId: string, workflowId: string, params?: {
1341
+ status?: string;
1342
+ limit?: number;
1343
+ cursor?: string;
1344
+ forward?: boolean;
1345
+ follow?: boolean;
1346
+ after?: string;
1347
+ }): Promise<{
1348
+ items: any[];
1349
+ hasMore?: boolean;
1350
+ nextCursor?: string | null;
1351
+ /** #1969 — opaque follow checkpoint; present on `follow=true` responses. */
1352
+ resumeAfter?: string;
1353
+ /**
1354
+ * #2237 — index rows the server examined for this request. Filtered reads
1355
+ * only, and only on a server new enough to report it; `undefined`
1356
+ * otherwise, which callers must treat as "unknown", not zero.
1357
+ */
1358
+ scanned?: number;
1359
+ }>;
1360
+ /**
1361
+ * Workflow runs started by one app user, across every workflow (#1967).
1362
+ * Backed by `GET /admin/api/apps/{appId}/users/{userId}/workflow-runs`,
1363
+ * which resolves the app user before querying the `runsByUser` index.
1364
+ */
1365
+ listUserWorkflowRuns(appId: string, userId: string, params?: {
1366
+ status?: string;
1367
+ limit?: number;
1368
+ cursor?: string;
1369
+ forward?: boolean;
1370
+ workflowId?: string;
1371
+ }): Promise<{
1372
+ items: any[];
1373
+ hasMore?: boolean;
1374
+ nextCursor?: string | null;
1375
+ /** #2237 — index rows examined; filtered reads only, `undefined` if unknown. */
1376
+ scanned?: number;
1377
+ }>;
1378
+ getWorkflowRunStatus(appId: string, workflowId: string, runId: string): Promise<any>;
1379
+ getWorkflowStepRuns(appId: string, workflowId: string, runId: string): Promise<{
1380
+ items: any[];
1381
+ }>;
1382
+ listWorkflowConfigs(appId: string, workflowId: string): Promise<{
1383
+ items: any[];
1384
+ }>;
1385
+ getWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
1386
+ createWorkflowConfig(appId: string, workflowId: string, payload: {
1387
+ configName: string;
1388
+ description?: string;
1389
+ steps: any[];
1390
+ expressions?: {
1391
+ cel?: Record<string, string>;
1392
+ };
1393
+ }): Promise<any>;
1394
+ updateWorkflowConfig(appId: string, workflowId: string, configId: string, payload: {
1395
+ configName?: string;
1396
+ description?: string;
1397
+ steps?: any[];
1398
+ status?: string;
1399
+ expressions?: {
1400
+ cel?: Record<string, string>;
1401
+ };
1402
+ }): Promise<any>;
1403
+ archiveWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
1404
+ activateWorkflowConfig(appId: string, workflowId: string, configId: string): Promise<any>;
1405
+ duplicateWorkflowConfig(appId: string, workflowId: string, configId: string, payload?: {
1406
+ configName?: string;
1407
+ }): Promise<any>;
1408
+ getAnalyticsTopUsers(appId: string, params?: {
1409
+ windowDays?: number;
1410
+ limit?: number;
1411
+ }): Promise<AnalyticsTopUsersResponse>;
1412
+ getAnalyticsIntegrationMetrics(appId: string, params?: {
1413
+ windowDays?: number;
1414
+ }): Promise<AnalyticsIntegrationMetricsResponse>;
1415
+ getAnalyticsOverviewDau(appId: string): Promise<AnalyticsMetricResponse>;
1416
+ getAnalyticsOverviewWau(appId: string): Promise<AnalyticsMetricResponse>;
1417
+ getAnalyticsOverviewMau(appId: string): Promise<AnalyticsMetricResponse>;
1418
+ getAnalyticsOverviewGrowth(appId: string, params?: {
1419
+ windowDays?: number;
1420
+ }): Promise<AnalyticsGrowthResponse>;
1421
+ getAnalyticsDailyActive(appId: string, params?: {
1422
+ windowDays?: number;
1423
+ }): Promise<AnalyticsDailyActiveResponse>;
1424
+ getAnalyticsRollingActive(appId: string, params?: {
1425
+ windowDays?: number;
1426
+ }): Promise<AnalyticsDailyActiveResponse>;
1427
+ getAnalyticsCohortRetention(appId: string): Promise<AnalyticsCohortResponse>;
1428
+ getAnalyticsUserSearch(appId: string, params: {
1429
+ q?: string;
1430
+ limit?: number;
1431
+ /** #3127 — one UTC calendar day, `YYYY-MM-DD`. */
1432
+ signupDay?: string;
1433
+ /** #3127 — an inclusive range of at most 90 UTC calendar days. */
1434
+ signupStartDay?: string;
1435
+ signupEndDay?: string;
1436
+ /** #3127 — row offset, accepted only with a signup filter. */
1437
+ offset?: number;
1438
+ }): Promise<AnalyticsUserSearchResponse>;
1439
+ getAnalyticsUserDetail(appId: string, userUlid: string): Promise<AnalyticsUserDetailResponse>;
1440
+ getAnalyticsUserSnapshot(appId: string, userUlid: string): Promise<AnalyticsUserSnapshotResponse>;
1441
+ getAnalyticsEvents(appId: string, params?: {
1442
+ windowDays?: number;
1443
+ page?: number;
1444
+ [key: string]: any;
1445
+ }): Promise<AnalyticsEventsResponse>;
1446
+ getAnalyticsEventsGrouped(appId: string, params?: {
1447
+ groupBy?: string;
1448
+ windowDays?: number;
1449
+ [key: string]: any;
1450
+ }): Promise<AnalyticsEventsGroupedResponse>;
1451
+ getAnalyticsErrorsGroups(appId: string, params?: {
1452
+ windowDays?: number;
1453
+ limit?: number;
1454
+ [key: string]: any;
1455
+ }): Promise<AnalyticsErrorsGroupsResponse>;
1456
+ getAnalyticsTopWorkflows(appId: string, params?: {
1457
+ windowDays?: number;
1458
+ limit?: number;
1459
+ }): Promise<TopWorkflowsResponse>;
1460
+ getAnalyticsTopPrompts(appId: string, params?: {
1461
+ windowDays?: number;
1462
+ limit?: number;
1463
+ }): Promise<TopPromptsResponse>;
1464
+ /**
1465
+ * The signed-in admin's own profile, `role` included.
1466
+ *
1467
+ * The role is read from the server rather than from the cached credentials
1468
+ * file: a role changed after login would otherwise let a stale local record
1469
+ * decide an authorization question.
1470
+ */
1471
+ getMe(): Promise<{
1472
+ adminId: string;
1473
+ email: string;
1474
+ name: string;
1475
+ role: string;
1476
+ createdAt?: string;
1477
+ }>;
1478
+ listAllAdmins(params?: {
1479
+ limit?: number;
1480
+ cursor?: string;
1481
+ }): Promise<{
1482
+ items: any[];
1483
+ hasMore?: boolean;
1484
+ nextCursor: string | null;
1485
+ }>;
1486
+ searchAdminByEmail(email: string): Promise<any>;
1487
+ getAdminApps(email: string): Promise<any>;
1488
+ updateAdminSettings(adminId: string, data: {
1489
+ appCreationLimit?: number;
1490
+ disabled?: boolean;
1491
+ role?: "admin" | "super-admin";
1492
+ }): Promise<any>;
1493
+ reindexAdmin(adminId: string): Promise<void>;
1494
+ listAllAdminInvitations(): Promise<any[]>;
1495
+ createGlobalAdminInvitation(data: {
1496
+ email: string;
1497
+ appCreationLimit?: number;
1498
+ expiresInDays?: number;
1499
+ }): Promise<any>;
1500
+ deleteGlobalAdminInvitation(invitationId: string): Promise<void>;
1501
+ listPromptCatalog(params?: {
1502
+ status?: string;
1503
+ limit?: number;
1504
+ cursor?: string;
1505
+ }): Promise<any>;
1506
+ getPromptCatalogItem(catalogId: string): Promise<any>;
1507
+ createPromptCatalogItem(payload: any): Promise<any>;
1508
+ updatePromptCatalogItem(catalogId: string, payload: any): Promise<any>;
1509
+ deletePromptCatalogItem(catalogId: string): Promise<void>;
1510
+ listIntegrationCatalog(params?: {
1511
+ status?: string;
1512
+ limit?: number;
1513
+ cursor?: string;
1514
+ }): Promise<any>;
1515
+ getIntegrationCatalogItem(catalogId: string): Promise<any>;
1516
+ createIntegrationCatalogItem(payload: any): Promise<any>;
1517
+ updateIntegrationCatalogItem(catalogId: string, payload: any): Promise<any>;
1518
+ deleteIntegrationCatalogItem(catalogId: string): Promise<void>;
1519
+ startBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, payload?: {
1520
+ comparisonGroup?: string;
1521
+ overrideConfigId?: string;
1522
+ testCaseIds?: string[];
1523
+ }): Promise<{
1524
+ batchId: string;
1525
+ totalTests: number;
1526
+ instanceIds: string[];
1527
+ errors?: any[];
1528
+ }>;
1529
+ getBatchTestStatus(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string): Promise<{
1530
+ status: string;
1531
+ batchId: string;
1532
+ completed: number;
1533
+ passed: number;
1534
+ failed: number;
1535
+ results: Array<{
1536
+ testCaseId: string;
1537
+ runId: string;
1538
+ status: string;
1539
+ verificationPassed: boolean;
1540
+ durationMs?: number;
1541
+ verificationDetails?: any;
1542
+ startedAt?: string;
1543
+ endedAt?: string;
1544
+ }>;
1545
+ }>;
1546
+ cancelBatchTests(appId: string, blockType: "prompt" | "integration" | "workflow" | "script", blockId: string, batchId: string, instanceIds: string[]): Promise<{
1547
+ batchId: string;
1548
+ terminated: string[];
1549
+ errors?: any[];
1550
+ }>;
1551
+ getComparisonGroup(appId: string, group: string): Promise<{
1552
+ comparisonGroup: string;
1553
+ runs: any[];
1554
+ }>;
1555
+ listEmailTemplates(appId: string): Promise<{
1556
+ templates: EmailTemplateSummary[];
1557
+ }>;
1558
+ getEmailTemplate(appId: string, emailType: string): Promise<EmailTemplateDetail>;
1559
+ /**
1560
+ * Create or replace an email-template override.
1561
+ *
1562
+ * `expectedModifiedAt` is the optimistic-concurrency token every sibling
1563
+ * config endpoint already takes (#2731 B10). Optional and additive: when
1564
+ * omitted the write is unconditional, which is how `--force` and every
1565
+ * pre-existing caller keep working; when supplied and stale, the server
1566
+ * answers 409 rather than silently overwriting a concurrent edit.
1567
+ */
1568
+ upsertEmailTemplate(appId: string, emailType: string, payload: {
1569
+ subject: string;
1570
+ htmlBody: string;
1571
+ textBody: string;
1572
+ }, expectedModifiedAt?: string): Promise<EmailTemplateUpsertResult>;
1573
+ deleteEmailTemplate(appId: string, emailType: string): Promise<{
1574
+ success: boolean;
1575
+ }>;
1576
+ testEmailTemplate(appId: string, emailType: string, payload?: {
1577
+ subject: string;
1578
+ htmlBody: string;
1579
+ textBody: string;
1580
+ }): Promise<{
1581
+ success: boolean;
1582
+ sentTo: string;
1583
+ error?: string;
1584
+ }>;
1585
+ createToken(appId: string, data: {
1586
+ name: string;
1587
+ ttl?: string;
1588
+ userId?: string;
1589
+ }): Promise<{
1590
+ token: string;
1591
+ tokenId: string;
1592
+ name: string;
1593
+ expiresAt: string | null;
1594
+ createdAt: string;
1595
+ warning: string;
1596
+ }>;
1597
+ listTokens(appId: string, params?: {
1598
+ userId?: string;
1599
+ }): Promise<Array<{
1600
+ tokenId: string;
1601
+ name: string;
1602
+ userId: string;
1603
+ expiresAt: string | null;
1604
+ lastUsedAt: string | null;
1605
+ createdAt: string;
1606
+ createdBy: string;
1607
+ }>>;
1608
+ getToken(appId: string, tokenId: string): Promise<{
1609
+ tokenId: string;
1610
+ name: string;
1611
+ userId: string;
1612
+ expiresAt: string | null;
1613
+ lastUsedAt: string | null;
1614
+ createdAt: string;
1615
+ createdBy: string;
1616
+ revokedAt: string | null;
1617
+ }>;
1618
+ revokeToken(appId: string, tokenId: string): Promise<{
1619
+ success: boolean;
1620
+ message: string;
1621
+ }>;
1622
+ /**
1623
+ * List an app's databases, following the cursor to the end.
1624
+ *
1625
+ * The endpoint returns the `{ items, hasMore, nextCursor }` envelope and
1626
+ * caps a page at 100 (#1958), so `databases list` needs the follow-up pages
1627
+ * to show every database. `paginateAll` carries the repeat-cursor and
1628
+ * max-page guards, so a server that hands out a non-advancing cursor fails
1629
+ * loudly instead of looping forever.
1630
+ *
1631
+ * `options.owner` narrows the result to the databases that user created; the
1632
+ * server resolves it through the `databasesByCreator` index (#1965).
1633
+ */
1634
+ /**
1635
+ * One page of an app's databases (#3646).
1636
+ *
1637
+ * `databases list` used to walk the chain here. The route pages, so the page
1638
+ * boundary belongs to the caller: the verb declares `--limit`/`--cursor` and
1639
+ * prints what came back.
1640
+ */
1641
+ listDatabases(appId: string, options?: {
1642
+ owner?: string;
1643
+ limit?: number;
1644
+ cursor?: string;
1645
+ }): Promise<{
1646
+ items: any[];
1647
+ hasMore?: boolean;
1648
+ nextCursor?: string | null;
1649
+ }>;
1650
+ createDatabase(appId: string, data: {
1651
+ title: string;
1652
+ databaseType?: string;
1653
+ metadata?: Record<string, any> | string;
1654
+ initialMetadata?: Record<string, Record<string, unknown>>;
1655
+ }): Promise<any>;
1656
+ getDatabase(appId: string, databaseId: string): Promise<any>;
1657
+ updateDatabase(appId: string, databaseId: string, data: Record<string, any>): Promise<any>;
1658
+ deleteDatabase(appId: string, databaseId: string): Promise<void>;
1659
+ /**
1660
+ * Read a database's CEL context dict.
1661
+ *
1662
+ * The HTTP path stays `/metadata` because the wire field name is still
1663
+ * `metadata`; only the client/CLI-facing helper names were reframed.
1664
+ *
1665
+ * @deprecated Use resource metadata categories instead (`primitive metadata
1666
+ * get database <id> <category>`, #1420, #1815).
1667
+ */
1668
+ getDatabaseCelContext(appId: string, databaseId: string): Promise<any>;
1669
+ /**
1670
+ * Update a database's CEL context dict (merge with existing).
1671
+ *
1672
+ * @deprecated Use resource metadata categories instead (`primitive metadata
1673
+ * set database <id> <category>`, #1420, #1815).
1674
+ */
1675
+ updateDatabaseCelContext(appId: string, databaseId: string, celContext: Record<string, any>): Promise<any>;
1676
+ /**
1677
+ * @deprecated Database CEL context is deprecated; use resource metadata
1678
+ * categories instead (`primitive metadata get database <id> <category>`,
1679
+ * #1420, #1815).
1680
+ */
1681
+ getDatabaseMetadata(appId: string, databaseId: string): Promise<any>;
1682
+ /**
1683
+ * @deprecated Database CEL context is deprecated; use resource metadata
1684
+ * categories instead (`primitive metadata set database <id> <category>`,
1685
+ * #1420, #1815).
1686
+ */
1687
+ updateDatabaseMetadata(appId: string, databaseId: string, metadata: Record<string, any>): Promise<any>;
1688
+ listDatabasePermissions(appId: string, databaseId: string): Promise<any[]>;
1689
+ addDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
1690
+ removeDatabaseManager(appId: string, databaseId: string, userId: string): Promise<any>;
1691
+ listDatabaseModels(appId: string, databaseId: string): Promise<any>;
1692
+ describeDatabaseModel(appId: string, databaseId: string, modelName: string): Promise<any>;
1693
+ /**
1694
+ * Query records in a database model. The Durable Object answers with its own
1695
+ * `{ data, hasMore, nextCursor?, prevCursor? }` envelope; that wire shape is
1696
+ * shared with the JS client, the Swift client and web-admin, so the CLI
1697
+ * normalizes it at its own boundary instead (issue #2357) and hands callers
1698
+ * the same `{ items, hasMore, nextCursor? }` envelope as
1699
+ * {@link queryDocumentRecords}.
1700
+ */
1701
+ queryDatabaseRecords(appId: string, databaseId: string, modelName: string, queryOptions?: {
1702
+ filter?: Record<string, any>;
1703
+ limit?: number;
1704
+ cursor?: string;
1705
+ }): Promise<ListEnvelope>;
1706
+ countDatabaseRecords(appId: string, databaseId: string, modelName: string, filter?: Record<string, any>): Promise<{
1707
+ count: number;
1708
+ }>;
1709
+ aggregateDatabaseRecords(appId: string, databaseId: string, modelName: string, options: {
1710
+ operations: {
1711
+ type: string;
1712
+ field?: string;
1713
+ }[];
1714
+ groupBy: (string | {
1715
+ field: string;
1716
+ contains: string;
1717
+ })[];
1718
+ filter?: Record<string, any>;
1719
+ }): Promise<{
1720
+ result: unknown;
1721
+ }>;
1722
+ /**
1723
+ * Upsert one record via `records/save`: creates the record when the id is
1724
+ * new, and merges the supplied fields into it when it already exists (the DO
1725
+ * writes with `ON CONFLICT … json_patch`, so fields you leave out survive).
1726
+ * `patchDatabaseRecord` is the same merge but requires the record to exist.
1727
+ *
1728
+ * `id` is optional: when omitted the body carries no `id`, which the
1729
+ * DatabaseDO only accepts alongside an `upsertOn` field — callers that want a
1730
+ * plain create must supply an id themselves (`databases records save` mints a
1731
+ * ULID, matching the CSV import path).
1732
+ *
1733
+ * Returns the endpoint's flat `{ success, id, appliedFields }` — not the
1734
+ * saved record.
1735
+ */
1736
+ saveDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string | undefined, data: any): Promise<any>;
1737
+ /**
1738
+ * Merge the supplied fields into an existing record via `records/patch`.
1739
+ *
1740
+ * Fields absent from `data` are left as they are. Unlike `saveDatabaseRecord`
1741
+ * the record must already exist — the DatabaseDO answers 404 for an unknown
1742
+ * id rather than creating one. Returns the flat
1743
+ * `{ success, id, appliedFields }`.
1744
+ */
1745
+ patchDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string, data: any): Promise<any>;
1746
+ listDatabaseOperations(appId: string, databaseId: string): Promise<any[]>;
1747
+ /**
1748
+ * Execute a registered operation and, when the result is a query page,
1749
+ * normalize it to the CLI's one list envelope (issue #2440).
1750
+ *
1751
+ * The registered operation decides the response shape, so the normalization
1752
+ * is conditional — see {@link normalizeDatabaseOperationResult}. Everything
1753
+ * else (a `count`, an `aggregate`, a mutation, a `returnField: "all"`
1754
+ * pipeline) is returned exactly as the server sent it.
1755
+ */
1756
+ executeDatabaseOperation(appId: string, databaseId: string, operationName: string, data?: {
1757
+ params?: Record<string, any>;
1758
+ limit?: number;
1759
+ cursor?: string;
1760
+ direction?: number;
1761
+ }, token?: string, options?: {
1762
+ timing?: boolean;
1763
+ }): Promise<any>;
1764
+ /**
1765
+ * Execute a registered batch (bulk) database operation. Posts a chunk of
1766
+ * items to the canonical `operations/:name/batch` endpoint (the same one the
1767
+ * client library's `executeBatch` uses — NOT the deprecated `import-bulk`
1768
+ * alias). Used by `databases import-csv`.
1769
+ *
1770
+ * @returns `{ imported, failed }` — DO-level write outcome counts. Per-item
1771
+ * validation/access failures abort the whole chunk with a 4xx (thrown).
1772
+ */
1773
+ executeBatch(appId: string, databaseId: string, operationName: string, batch: Array<{
1774
+ params: Record<string, any>;
1775
+ }>): Promise<{
1776
+ imported: number;
1777
+ failed: number;
1778
+ }>;
1779
+ /**
1780
+ * Make a request using a specific JWT token instead of the CLI's credentials.
1781
+ * Used for executing operations as a different user.
1782
+ */
1783
+ requestWithToken<T = any>(path: string, token: string, options?: RequestInit): Promise<T>;
1784
+ listDatabaseIndexes(appId: string, databaseId: string, modelName?: string): Promise<any>;
1785
+ registerDatabaseIndex(appId: string, databaseId: string, data: {
1786
+ modelName: string;
1787
+ fieldName: string;
1788
+ fieldType: string;
1789
+ unique?: boolean;
1790
+ }): Promise<any>;
1791
+ dropDatabaseIndex(appId: string, databaseId: string, data: {
1792
+ modelName: string;
1793
+ fieldName: string;
1794
+ }): Promise<any>;
1795
+ /**
1796
+ * Issue #974: back-provision an existing database instance's schema-declared
1797
+ * unique indexes by reading its type schema and registering any declared-but-
1798
+ * missing unique index. Idempotent.
1799
+ */
1800
+ reindexDatabaseFromSchema(appId: string, databaseId: string): Promise<{
1801
+ ok: boolean;
1802
+ registered: number;
1803
+ skipped?: boolean;
1804
+ reason?: string;
1805
+ databaseType?: string;
1806
+ }>;
1807
+ listDatabaseTypeConfigs(appId: string): Promise<any[]>;
1808
+ getDatabaseTypeConfig(appId: string, databaseType: string): Promise<any>;
1809
+ createDatabaseTypeConfig(appId: string, data: {
1810
+ databaseType: string;
1811
+ ruleSetId?: string | null;
1812
+ triggers?: Record<string, any> | null;
1813
+ /**
1814
+ * @deprecated The TOML `type.celContextAccess` expression. Use resource
1815
+ * metadata categories instead (#1420, #1815).
1816
+ */
1817
+ metadataAccess?: string | null;
1818
+ defaultAccess?: string | null;
1819
+ autoPopulatedFields?: Record<string, any> | null;
1820
+ timestamps?: Record<string, any> | null;
1821
+ schema?: string | null;
1822
+ metadataManifest?: any;
1823
+ }, options?: {
1824
+ dryRun?: boolean;
1825
+ }): Promise<any>;
1826
+ updateDatabaseTypeConfig(appId: string, databaseType: string, data: {
1827
+ ruleSetId?: string | null;
1828
+ triggers?: Record<string, any> | null;
1829
+ /**
1830
+ * @deprecated The TOML `type.celContextAccess` expression. Use resource
1831
+ * metadata categories instead (#1420, #1815).
1832
+ */
1833
+ metadataAccess?: string | null;
1834
+ defaultAccess?: string | null;
1835
+ autoPopulatedFields?: Record<string, any> | null;
1836
+ timestamps?: Record<string, any> | null;
1837
+ schema?: string | null;
1838
+ pendingOpDeletes?: string[];
1839
+ finalOpNames?: string[];
1840
+ metadataManifest?: any;
1841
+ pendingOpUpdates?: Array<{
1842
+ name: string;
1843
+ access?: string | null;
1844
+ params?: Record<string, any> | null;
1845
+ }>;
1846
+ pendingOpUpserts?: Array<Record<string, any>>;
1847
+ }, expectedModifiedAt?: string, options?: {
1848
+ dryRun?: boolean;
1849
+ acceptWarnings?: boolean;
1850
+ }): Promise<any>;
1851
+ deleteDatabaseTypeConfig(appId: string, databaseType: string, options?: {
1852
+ force?: boolean;
1853
+ }): Promise<any>;
1854
+ /**
1855
+ * Issue #666 Phase 3: ask the server to scaffold a TOML schema from
1856
+ * existing ops + DO field introspection. Read-only — does NOT persist.
1857
+ */
1858
+ scaffoldDatabaseTypeSchema(appId: string, databaseType: string): Promise<{
1859
+ schema: string;
1860
+ }>;
1861
+ listDatabaseTypeOperations(appId: string, databaseType: string): Promise<any[]>;
1862
+ getDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1863
+ createDatabaseTypeOperation(appId: string, databaseType: string, data: {
1864
+ name: string;
1865
+ type: string;
1866
+ modelName: string;
1867
+ access?: string | null;
1868
+ definition: Record<string, any>;
1869
+ params?: Record<string, any> | null;
1870
+ }, options?: {
1871
+ dryRun?: boolean;
1872
+ schemaOverride?: string | null;
1873
+ defaultAccess?: string | null;
1874
+ metadataManifestOverride?: Record<string, any> | null;
1875
+ }): Promise<any>;
1876
+ updateDatabaseTypeOperation(appId: string, databaseType: string, name: string, data: Record<string, any>, expectedModifiedAt?: string, options?: {
1877
+ dryRun?: boolean;
1878
+ schemaOverride?: string | null;
1879
+ metadataManifestOverride?: Record<string, any> | null;
1880
+ }): Promise<any>;
1881
+ deleteDatabaseTypeOperation(appId: string, databaseType: string, name: string): Promise<any>;
1882
+ listDatabaseTypeSubscriptions(appId: string, databaseType: string): Promise<any[]>;
1883
+ getDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1884
+ createDatabaseTypeSubscription(appId: string, databaseType: string, data: {
1885
+ subscriptionKey: string;
1886
+ displayName: string;
1887
+ modelName: string;
1888
+ filter: string;
1889
+ access: string;
1890
+ description?: string | null;
1891
+ select?: string[] | null;
1892
+ emit?: string[] | null;
1893
+ params?: Record<string, any> | null;
1894
+ status?: string;
1895
+ }): Promise<any>;
1896
+ updateDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string, data: Record<string, any>, expectedModifiedAt?: string): Promise<any>;
1897
+ deleteDatabaseTypeSubscription(appId: string, databaseType: string, subscriptionKey: string): Promise<any>;
1898
+ listGroups(appId: string, params?: {
1899
+ type?: string;
1900
+ limit?: number;
1901
+ cursor?: string;
1902
+ }): Promise<{
1903
+ items: any[];
1904
+ nextCursor?: string;
1905
+ hasMore?: boolean;
1906
+ }>;
1907
+ createGroup(appId: string, data: {
1908
+ groupType: string;
1909
+ groupId?: string;
1910
+ name: string;
1911
+ description?: string;
1912
+ initialMetadata?: Record<string, Record<string, unknown>>;
1913
+ }): Promise<any>;
1914
+ getGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1915
+ updateGroup(appId: string, groupType: string, groupId: string, data: {
1916
+ name?: string;
1917
+ description?: string;
1918
+ }): Promise<any>;
1919
+ deleteGroup(appId: string, groupType: string, groupId: string): Promise<any>;
1920
+ /**
1921
+ * One page of a group's members.
1922
+ *
1923
+ * The route paginates cursor-style (no default limit, cap 200) and reports
1924
+ * the boundary, so `groups members list` carries `--limit`/`--cursor` and
1925
+ * forwards them (#3646) rather than printing a first page that claims to be
1926
+ * the whole membership.
1927
+ */
1928
+ listGroupMembers(appId: string, groupType: string, groupId: string, options?: {
1929
+ include?: "profiles";
1930
+ limit?: number;
1931
+ cursor?: string;
1932
+ }): Promise<{
1933
+ items: any[];
1934
+ nextCursor?: string;
1935
+ hasMore?: boolean;
1936
+ }>;
1937
+ addGroupMember(appId: string, groupType: string, groupId: string, data: {
1938
+ userId: string;
1939
+ }): Promise<any>;
1940
+ removeGroupMember(appId: string, groupType: string, groupId: string, userId: string): Promise<any>;
1941
+ listGroupDocuments(appId: string, groupType: string, groupId: string): Promise<any[]>;
1942
+ listUserMemberships(appId: string, userId: string): Promise<any[]>;
1943
+ listDocumentGroupPermissions(appId: string, documentId: string): Promise<any[]>;
1944
+ grantDocumentGroupPermission(appId: string, documentId: string, data: {
1945
+ groupType: string;
1946
+ groupId: string;
1947
+ permission: string;
1948
+ }): Promise<any>;
1949
+ revokeDocumentGroupPermission(appId: string, documentId: string, groupType: string, groupId: string): Promise<any>;
1950
+ listCollections(appId: string, params?: {
1951
+ limit?: number;
1952
+ cursor?: string;
1953
+ }): Promise<{
1954
+ items: any[];
1955
+ hasMore?: boolean;
1956
+ nextCursor?: string | null;
1957
+ }>;
1958
+ listAllCollections(appId: string, params?: {
1959
+ limit?: number;
1960
+ cursor?: string;
1961
+ }): Promise<{
1962
+ items: any[];
1963
+ hasMore?: boolean;
1964
+ nextCursor?: string | null;
1965
+ }>;
1966
+ createCollection(appId: string, data: {
1967
+ name: string;
1968
+ description?: string;
1969
+ /**
1970
+ * Which rule set governs the collection. Immutable after creation, so a
1971
+ * migration has to send it with the create or never (#3643).
1972
+ */
1973
+ collectionType?: string;
1974
+ initialMetadata?: Record<string, Record<string, unknown>>;
1975
+ /**
1976
+ * The app user to create the collection FOR (#3641). Honored only for
1977
+ * admin-token callers; an app-user token has it ignored and creates as
1978
+ * itself, exactly as `createDocument`'s does.
1979
+ */
1980
+ createdBy?: string;
1981
+ }): Promise<any>;
1982
+ getCollection(appId: string, collectionId: string): Promise<any>;
1983
+ updateCollection(appId: string, collectionId: string, data: {
1984
+ name?: string;
1985
+ description?: string;
1986
+ }): Promise<any>;
1987
+ deleteCollection(appId: string, collectionId: string): Promise<any>;
1988
+ listCollectionDocuments(appId: string, collectionId: string, params?: {
1989
+ limit?: number;
1990
+ cursor?: string;
1991
+ }): Promise<{
1992
+ items: any[];
1993
+ hasMore?: boolean;
1994
+ nextCursor?: string | null;
1995
+ }>;
1996
+ addCollectionDocument(appId: string, collectionId: string, data: {
1997
+ documentId: string;
1998
+ }): Promise<any>;
1999
+ removeCollectionDocument(appId: string, collectionId: string, documentId: string): Promise<any>;
2000
+ listCollectionsForDocument(appId: string, documentId: string, params?: {
2001
+ limit?: number;
2002
+ cursor?: string;
2003
+ }): Promise<{
2004
+ items: any[];
2005
+ nextCursor?: string | null;
2006
+ }>;
2007
+ getCollectionAccess(appId: string, collectionId: string): Promise<any>;
2008
+ grantCollectionGroupPermission(appId: string, collectionId: string, data: {
2009
+ groupType: string;
2010
+ groupId: string;
2011
+ permission: string;
2012
+ }): Promise<any>;
2013
+ revokeCollectionGroupPermission(appId: string, collectionId: string, groupType: string, groupId: string): Promise<any>;
2014
+ addCollectionMember(appId: string, collectionId: string, data: {
2015
+ userId: string;
2016
+ permission: string;
2017
+ }): Promise<any>;
2018
+ removeCollectionMember(appId: string, collectionId: string, userId: string): Promise<any>;
2019
+ listCollectionTypeConfigs(appId: string): Promise<any[]>;
2020
+ getCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
2021
+ createCollectionTypeConfig(appId: string, data: {
2022
+ collectionType: string;
2023
+ ruleSetId?: string;
2024
+ metadataManifest?: any;
2025
+ }): Promise<any>;
2026
+ updateCollectionTypeConfig(appId: string, collectionType: string, data: {
2027
+ ruleSetId?: string | null;
2028
+ metadataManifest?: any;
2029
+ }, expectedModifiedAt?: string): Promise<any>;
2030
+ deleteCollectionTypeConfig(appId: string, collectionType: string): Promise<any>;
2031
+ /**
2032
+ * List all metadata category configs for an app. The route returns
2033
+ * `{ configs: [...] }`; unwrap to a bare array to match the other
2034
+ * `list*Configs` helpers.
2035
+ */
2036
+ listMetadataCategoryConfigs(appId: string): Promise<any[]>;
2037
+ getMetadataCategoryConfig(appId: string, resourceType: string, category: string): Promise<any>;
2038
+ /**
2039
+ * Create or replace a metadata category config (idempotent upsert via the
2040
+ * path-addressed PUT route). `resourceType` / `category` identify the config;
2041
+ * the body carries `schema` / `readRule` / `writeRule` / `description`.
2042
+ */
2043
+ upsertMetadataCategoryConfig(appId: string, resourceType: string, category: string, data: {
2044
+ schema: unknown;
2045
+ readRule?: string | null;
2046
+ writeRule?: string | null;
2047
+ description?: string | null;
2048
+ metadataManifest?: unknown;
2049
+ },
2050
+ /** Optimistic-concurrency token; see `upsertEmailTemplate` (#2731 B10). */
2051
+ expectedModifiedAt?: string): Promise<any>;
2052
+ /**
2053
+ * Delete a metadata category config (issue #1426, admin-gated route shipped
2054
+ * in #1364). Orphan semantics: the config row is hard-deleted; any stored
2055
+ * `ResourceMetadata` value rows for the category are left behind and become
2056
+ * unreachable (no query path from a category to its values). Delete the
2057
+ * values first if you need them gone — an orphaned value row can't be
2058
+ * removed through any surface once its config is gone. Returns
2059
+ * `{ resourceType, category, deleted }`; a missing config is a 404.
2060
+ */
2061
+ deleteMetadataCategoryConfig(appId: string, resourceType: string, category: string): Promise<{
2062
+ resourceType: string;
2063
+ category: string;
2064
+ deleted: boolean;
2065
+ }>;
2066
+ listRuleSets(appId: string, params?: {
2067
+ resourceType?: string;
2068
+ }): Promise<any[]>;
2069
+ createRuleSet(appId: string, data: {
2070
+ name: string;
2071
+ resourceType: string;
2072
+ rules: Record<string, any>;
2073
+ description?: string;
2074
+ }): Promise<any>;
2075
+ getRuleSet(appId: string, ruleSetId: string): Promise<any>;
2076
+ updateRuleSet(appId: string, ruleSetId: string, data: {
2077
+ name?: string;
2078
+ description?: string;
2079
+ rules?: Record<string, any>;
2080
+ }, expectedModifiedAt?: string): Promise<any>;
2081
+ deleteRuleSet(appId: string, ruleSetId: string): Promise<any>;
2082
+ getRuleSetSchema(appId: string): Promise<any>;
2083
+ getRuleSetResourceTypes(appId: string): Promise<{
2084
+ resourceTypes: string[];
2085
+ }>;
2086
+ testRuleSet(appId: string, ruleSetId: string, data: any): Promise<any>;
2087
+ debugRuleSet(appId: string, data: any): Promise<any>;
2088
+ listGroupTypeConfigs(appId: string): Promise<any[]>;
2089
+ getGroupTypeConfig(appId: string, groupType: string): Promise<any>;
2090
+ createGroupTypeConfig(appId: string, data: {
2091
+ groupType: string;
2092
+ ruleSetId?: string;
2093
+ autoAddCreator?: boolean;
2094
+ metadataManifest?: any;
2095
+ }): Promise<any>;
2096
+ updateGroupTypeConfig(appId: string, groupType: string, data: {
2097
+ ruleSetId?: string | null;
2098
+ autoAddCreator?: boolean;
2099
+ metadataManifest?: any;
2100
+ }, expectedModifiedAt?: string): Promise<any>;
2101
+ deleteGroupTypeConfig(appId: string, groupType: string): Promise<any>;
2102
+ exportDocumentState(appId: string, documentId: string): Promise<{
2103
+ state: string;
2104
+ byteLength: number;
2105
+ documentId: string;
2106
+ }>;
2107
+ /**
2108
+ * The export chain of a large document (#2816, behavior 20): the latest
2109
+ * completed snapshot, the sealed overlays after its epoch, and the open
2110
+ * epoch's overlay inline. Every other artifact arrives as an expiring
2111
+ * signature, read through {@link downloadDocumentArtifact}.
2112
+ */
2113
+ exportDocumentChain(appId: string, documentId: string): Promise<any>;
2114
+ /**
2115
+ * Read one granted artifact of a large document.
2116
+ *
2117
+ * The path comes from the chain and is origin-relative — the room is a
2118
+ * Durable Object and has no reliable idea which host the caller reached it
2119
+ * through — and the signature in it is the whole authorization, so no key is
2120
+ * ever composed here.
2121
+ */
2122
+ downloadDocumentArtifact(_appId: string, grantedPath: string): Promise<Buffer>;
2123
+ importDocumentState(appId: string, documentId: string, stateBase64: string): Promise<any>;
2124
+ /**
2125
+ * Upload one artifact of a large document's import chain (#2816,
2126
+ * behavior 20).
2127
+ *
2128
+ * The bytes travel raw and unmodified: the manifest's digest is over the
2129
+ * STORED bytes, so re-encoding a chunk here would fail its own verification
2130
+ * on install. The query says which artifact it is — the server derives the
2131
+ * key from the document it belongs to, so nothing here composes one.
2132
+ */
2133
+ uploadDocumentChainArtifact(appId: string, documentId: string, query: Record<string, string | number>, body: Buffer): Promise<any>;
2134
+ /** Start installing an uploaded chain (#2816, behavior 20). */
2135
+ installDocumentChain(appId: string, documentId: string, plan: {
2136
+ installId?: string;
2137
+ base: {
2138
+ epoch: number;
2139
+ buildId: string;
2140
+ } | null;
2141
+ overlays: number[];
2142
+ currentEpoch: number;
2143
+ }): Promise<any>;
2144
+ /** How far a document's chain install has got (#2816, behavior 20). */
2145
+ getDocumentChainInstall(appId: string, documentId: string): Promise<any>;
2146
+ getDocument(appId: string, documentId: string): Promise<any>;
2147
+ /**
2148
+ * Delete a document and everything hanging off it (#2756). The server route
2149
+ * runs the same cascade the client SDK's `documents.delete()` triggers —
2150
+ * Yjs state and update history, blob rows and objects, aliases, user/group
2151
+ * permissions, invitations, collection memberships — and returns
2152
+ * `{ success, message }`, which callers pass through under `--json`.
2153
+ */
2154
+ deleteDocument(appId: string, documentId: string): Promise<any>;
2155
+ /**
2156
+ * Introspect a document's Yjs schema (model names, per-model fields and
2157
+ * indexes). Backs `documents records models` and `documents records
2158
+ * describe`. Reuses the existing `GET documents/:id/schema` endpoint.
2159
+ */
2160
+ getDocumentSchema(appId: string, documentId: string): Promise<any>;
2161
+ /**
2162
+ * The `documentFormat` a records call states, as a query string to APPEND to
2163
+ * a path (#3764).
2164
+ *
2165
+ * `post`, `patch` and `delete` take no params object — only `get` does — so
2166
+ * for every verb but the reads the parameter rides the path. Empty when the
2167
+ * caller states nothing, so an unparameterised call's URL is byte-identical
2168
+ * to what it was.
2169
+ */
2170
+ private documentFormatQuery;
2171
+ /**
2172
+ * Query records in a document model (issue #1964 Phase 3). Reuses the
2173
+ * server-side `GET documents/:id/records/:model` endpoint, which runs
2174
+ * through the caller's document permission (reader+) or the app-admin arm.
2175
+ * Returns the unified `{ items, hasMore, nextCursor? }` envelope. The cursor
2176
+ * is an opaque token — feed `nextCursor` back as `cursor` for the next page.
2177
+ */
2178
+ queryDocumentRecords(appId: string, documentId: string, modelName: string, queryOptions?: {
2179
+ filter?: Record<string, any>;
2180
+ limit?: number;
2181
+ cursor?: string;
2182
+ /** #3764 — the format the caller believes this document has. */
2183
+ documentFormat?: 1 | 2;
2184
+ }): Promise<ListEnvelope>;
2185
+ /**
2186
+ * Count records in a document model (issue #1964 Phase 3). Returns `{ count }`.
2187
+ */
2188
+ countDocumentRecords(appId: string, documentId: string, modelName: string, queryOptions?: {
2189
+ filter?: Record<string, any>;
2190
+ documentFormat?: 1 | 2;
2191
+ }): Promise<{
2192
+ count: number;
2193
+ }>;
2194
+ /**
2195
+ * Aggregate records in a document model (issue #2437) — the documents twin
2196
+ * of {@link aggregateDatabaseRecords}. `POST documents/:id/records/:model/aggregate`
2197
+ * with `{ options: { operations, groupBy?, filter? } }`, answering `{ result }`
2198
+ * in the same shape as the database endpoint.
2199
+ *
2200
+ * `groupBy` takes plain field names only: StringSet facet grouping and
2201
+ * `{ field, contains }` membership grouping are database-only, which is why
2202
+ * this signature is narrower than the databases one.
2203
+ */
2204
+ aggregateDocumentRecords(appId: string, documentId: string, modelName: string, options: {
2205
+ operations: {
2206
+ type: string;
2207
+ field?: string;
2208
+ }[];
2209
+ groupBy?: string[];
2210
+ filter?: Record<string, any>;
2211
+ }, extra?: {
2212
+ documentFormat?: 1 | 2;
2213
+ }): Promise<{
2214
+ result: unknown;
2215
+ }>;
2216
+ /**
2217
+ * Fetch platform-vocabulary document statistics (issue #1964 Phase 3):
2218
+ * record/model/blob counts, approximate size, and last-modified timestamp.
2219
+ */
2220
+ getDocumentStats(appId: string, documentId: string): Promise<any>;
2221
+ /**
2222
+ * A large document's snapshot builds, newest first, one page (#3432).
2223
+ * `GET documents/:id/snapshots` → `{ items, hasMore, nextCursor? }`.
2224
+ */
2225
+ listDocumentSnapshots(appId: string, documentId: string, options?: {
2226
+ limit?: number;
2227
+ cursor?: string;
2228
+ }): Promise<{
2229
+ items: any[];
2230
+ hasMore: boolean;
2231
+ nextCursor?: string;
2232
+ }>;
2233
+ /**
2234
+ * A large document's bulk-load sessions, newest first (#3434, criterion 9).
2235
+ *
2236
+ * Read-only, through the document read helper's app-admin arm — the same
2237
+ * door the snapshot readers use. The action verb `documents ingest` is
2238
+ * #3435's; these two are the operator's window onto what a session did.
2239
+ */
2240
+ listDocumentIngests(appId: string, documentId: string, options?: {
2241
+ limit?: number;
2242
+ cursor?: string;
2243
+ }): Promise<{
2244
+ items: any[];
2245
+ hasMore: boolean;
2246
+ nextCursor?: string;
2247
+ }>;
2248
+ /** One bulk-load session's status (#3434). */
2249
+ getDocumentIngest(appId: string, documentId: string, sessionId: string): Promise<any>;
2250
+ /** Open a bulk-load session on a large document (#3435, criterion 9). */
2251
+ createDocumentIngest(appId: string, documentId: string): Promise<any>;
2252
+ /**
2253
+ * Upload one chunk of a bulk-load session's artifact (#3435).
2254
+ *
2255
+ * `multipart/form-data`: the eight descriptor fields as text parts and the
2256
+ * gzipped bytes as one file part named `chunk`. No `Content-Type` is set on
2257
+ * the request — fetch supplies the boundary, and a header written by hand
2258
+ * would name one the body does not use.
2259
+ */
2260
+ uploadDocumentIngestChunk(appId: string, documentId: string, sessionId: string, chunk: {
2261
+ model: string;
2262
+ index: number;
2263
+ rows: number;
2264
+ bytes: number;
2265
+ rawBytes: number;
2266
+ sha256: string;
2267
+ firstId: string;
2268
+ lastId: string;
2269
+ body: Buffer;
2270
+ }): Promise<any>;
2271
+ /** Freeze a session's manifest and hand it to the pipeline (#3435). */
2272
+ commitDocumentIngest(appId: string, documentId: string, sessionId: string): Promise<any>;
2273
+ /** Give a session up; allowed until the swap (#3435). */
2274
+ abortDocumentIngest(appId: string, documentId: string, sessionId: string): Promise<any>;
2275
+ /** One snapshot build with its verification result (#3432). */
2276
+ getDocumentSnapshot(appId: string, documentId: string, buildId: string): Promise<any>;
2277
+ /**
2278
+ * Snapshot a large document now (#3666): seal the open epoch and start the
2279
+ * base build that seal arms.
2280
+ *
2281
+ * Answers either the epoch that was sealed with the build it armed, or
2282
+ * `{ sealed: false, reason: "empty" }` for an epoch that carried nothing.
2283
+ */
2284
+ requestDocumentSnapshot(appId: string, documentId: string): Promise<any>;
2285
+ /**
2286
+ * Create or replace a record in a document model (issue #1964 Phase 4).
2287
+ * `POST documents/:id/records/:model` with `{ id, data, options? }` —
2288
+ * server-side write through the document facade (Yjs-first, CRDT-safe,
2289
+ * broadcasts to connected clients). Requires read-write+ on the document
2290
+ * or the app-admin arm. Returns `{ record }`.
2291
+ */
2292
+ saveDocumentRecord(appId: string, documentId: string, modelName: string, body: {
2293
+ id: string;
2294
+ data: Record<string, unknown>;
2295
+ options?: Record<string, unknown>;
2296
+ }, extra?: {
2297
+ documentFormat?: 1 | 2;
2298
+ }): Promise<{
2299
+ record: unknown;
2300
+ }>;
2301
+ /**
2302
+ * Merge fields into an existing record (issue #1964 Phase 4).
2303
+ * `PATCH documents/:id/records/:model/:recordId` with `{ data, options? }`.
2304
+ * Returns `{ record }`.
2305
+ */
2306
+ patchDocumentRecord(appId: string, documentId: string, modelName: string, recordId: string, body: {
2307
+ data: Record<string, unknown>;
2308
+ options?: Record<string, unknown>;
2309
+ }, extra?: {
2310
+ documentFormat?: 1 | 2;
2311
+ }): Promise<{
2312
+ record: unknown;
2313
+ }>;
2314
+ /**
2315
+ * Delete a record from a document model (issue #1964 Phase 4).
2316
+ * `DELETE documents/:id/records/:model/:recordId`. A missing record id is
2317
+ * a silent no-op per the facade contract. Returns `{ deleted: true }`.
2318
+ */
2319
+ deleteDocumentRecord(appId: string, documentId: string, modelName: string, recordId: string, extra?: {
2320
+ documentFormat?: 1 | 2;
2321
+ }): Promise<{
2322
+ deleted: boolean;
2323
+ }>;
2324
+ /**
2325
+ * Apply an ordered multi-model create/patch/delete blob atomically (issue
2326
+ * #1964 Phase 4, wrapping the #1517 `bulkUpdate` facade). All-or-nothing:
2327
+ * a validation failure commits nothing. Returns the facade's
2328
+ * `{ applied, added, updated, deleted }`.
2329
+ */
2330
+ bulkDocumentRecords(appId: string, documentId: string, operations: Array<Record<string, unknown>>, extra?: {
2331
+ documentFormat?: 1 | 2;
2332
+ }): Promise<{
2333
+ applied: number;
2334
+ added: Array<{
2335
+ model: string;
2336
+ id: string;
2337
+ }>;
2338
+ updated: Array<{
2339
+ model: string;
2340
+ id: string;
2341
+ }>;
2342
+ deleted: number;
2343
+ }>;
2344
+ createDocument(appId: string, data: {
2345
+ title: string;
2346
+ documentId?: string;
2347
+ tags?: string[];
2348
+ createdBy?: string;
2349
+ documentFormat?: 1 | 2;
2350
+ }): Promise<any>;
2351
+ listDocumentPermissions(appId: string, documentId: string): Promise<any[]>;
2352
+ grantDocumentPermission(appId: string, documentId: string, permissions: Array<{
2353
+ userId?: string;
2354
+ email?: string;
2355
+ permission: string;
2356
+ }>): Promise<any>;
2357
+ /**
2358
+ * Revoke a user's permission on a document. Mirrors the published client's
2359
+ * `documents.removePermission` wire behavior (`src/client/api/documentsApi.ts`):
2360
+ * a userId targets the path route `DELETE .../permissions/:userId`, while an
2361
+ * email targets the query-param route `DELETE .../permissions?email=...`
2362
+ * (unified email removal, #452). This duplication of the client's wire shape
2363
+ * is deliberate and parity-tested (issue #1964 amendment 8).
2364
+ */
2365
+ revokeDocumentPermission(appId: string, documentId: string, target: {
2366
+ userId?: string;
2367
+ email?: string;
2368
+ }): Promise<any>;
2369
+ /**
2370
+ * Resolve a NAMED user's effective access to a document (#3658).
2371
+ *
2372
+ * The admin token is admitted to name a subject (it can already read every
2373
+ * grant, group permission and membership the answer derives from), which is
2374
+ * what makes this an operator read rather than a per-user one.
2375
+ */
2376
+ validateDocumentAccessForUser(appId: string, documentId: string, userId: string): Promise<any>;
2377
+ getDocumentLinkAccess(appId: string, documentId: string): Promise<any>;
2378
+ setDocumentLinkAccess(appId: string, documentId: string, level: "reader" | "read-write"): Promise<any>;
2379
+ clearDocumentLinkAccess(appId: string, documentId: string): Promise<any>;
2380
+ /**
2381
+ * Pending deferred grants for a document (#2951 — replaces the removed
2382
+ * legacy `GET /documents/:id/invitations`). Returns the `{ items }`
2383
+ * envelope; rows are already filtered server-side to unresolved, unexpired
2384
+ * grants whose app invitation is still outstanding.
2385
+ */
2386
+ listDocumentPendingInvitations(appId: string, documentId: string): Promise<any>;
2387
+ listDocumentBlobs(appId: string, documentId: string): Promise<any[]>;
2388
+ downloadBlob(appId: string, documentId: string, blobId: string): Promise<Buffer>;
2389
+ uploadBlob(appId: string, documentId: string, blobId: string, data: Buffer, meta: {
2390
+ filename: string;
2391
+ contentType: string;
2392
+ sha256: string;
2393
+ }): Promise<any>;
2394
+ listDocumentAliases(appId: string, documentId: string): Promise<any[]>;
2395
+ setDocumentAlias(appId: string, aliasScope: string, aliasKey: string, documentId: string, ownerUserId?: string, mustNotExist?: boolean): Promise<any>;
2396
+ /**
2397
+ * Resolve an app user by exact email — the single email → userId lookup in
2398
+ * the CLI (issue #2763). It reads the member-accessible `users/lookup`
2399
+ * endpoint rather than the admin-only `GET /users` list, and returns the
2400
+ * server's `{ exists, user? }` envelope as-is: a 403 or a transport failure
2401
+ * rejects instead of being flattened into "no such user", which is exactly
2402
+ * how the deleted admin-list helper misreported permission problems.
2403
+ */
2404
+ lookupUserByEmail(appId: string, email: string): Promise<{
2405
+ exists: boolean;
2406
+ user?: {
2407
+ userId: string;
2408
+ name?: string;
2409
+ email?: string;
2410
+ };
2411
+ }>;
2412
+ /**
2413
+ * The admin inventory of one user's documents, followed to the end (#3399).
2414
+ *
2415
+ * The endpoint speaks the standard list contract (`{ items, hasMore,
2416
+ * nextCursor }`) and caps a page, so one request reads one page: reading it
2417
+ * would truncate a heavy user's inventory at the page size, which is the
2418
+ * bug this issue is about with a smaller number on it. `documents list
2419
+ * --user-id` and `documents export-all` both read this, and both mean "all
2420
+ * of them". `paginateAll` carries the repeat-cursor and max-page guards, so
2421
+ * a server handing out a non-advancing cursor fails loudly instead of
2422
+ * looping forever.
2423
+ */
2424
+ listAdminDocuments(appId: string, userId: string): Promise<any[]>;
2425
+ /**
2426
+ * One page of the admin inventory of a user's documents (#3646).
2427
+ *
2428
+ * `documents list --user-id` prints exactly this — the page the caller's
2429
+ * `--limit`/`--cursor` asked for, with the server's own page boundary
2430
+ * beside it. `documents export-all`, which really does mean every document,
2431
+ * keeps the walking `listAdminDocuments()` above.
2432
+ */
2433
+ listAdminDocumentsPage(appId: string, userId: string, options?: {
2434
+ limit?: number;
2435
+ cursor?: string;
2436
+ }): Promise<{
2437
+ items: any[];
2438
+ hasMore?: boolean;
2439
+ nextCursor?: string | null;
2440
+ }>;
2441
+ /**
2442
+ * The document `AppUser.rootDocId` points at, or null when the user has none
2443
+ * yet (#3135). A user who is not a member of the app is a 404, which
2444
+ * `documents import` reads as "this export has no target here" — distinct
2445
+ * from "this user has no root document yet".
2446
+ */
2447
+ getUserRootDocument(appId: string, userId: string): Promise<{
2448
+ rootDocId: string | null;
2449
+ }>;
2450
+ /**
2451
+ * Get or create the user's root document (#3135).
2452
+ *
2453
+ * The server runs the same idempotent get-or-create sign-in uses, so this
2454
+ * never mints a second root. `created` is true only when this call's claim
2455
+ * won — an import must not report "created", or merge without `--overwrite`,
2456
+ * for a root a concurrent sign-in minted first.
2457
+ */
2458
+ ensureUserRootDocument(appId: string, userId: string): Promise<{
2459
+ rootDocId: string;
2460
+ created: boolean;
2461
+ }>;
2462
+ /**
2463
+ * Apply an ordered batch of record operations via `records/batch`.
2464
+ *
2465
+ * `atomic` (default off, matching the DatabaseDO) makes the whole batch
2466
+ * all-or-nothing: the DO rolls every write back at the first failed
2467
+ * operation and answers with that operation's status. `databases records
2468
+ * bulk` sends `atomic: true` so it matches the documents twin's
2469
+ * all-or-nothing contract (#2437); the CSV/import paths keep the default
2470
+ * partial-success behavior.
2471
+ */
2472
+ batchDatabaseRecords(appId: string, databaseId: string, operations: DatabaseBatchOperation[], options?: {
2473
+ atomic?: boolean;
2474
+ }): Promise<any>;
2475
+ deleteDatabaseRecord(appId: string, databaseId: string, modelName: string, id: string): Promise<any>;
2476
+ batchDeleteDatabaseRecords(appId: string, databaseId: string, operations: {
2477
+ op: "delete";
2478
+ modelName: string;
2479
+ id: string;
2480
+ }[]): Promise<any>;
2481
+ listDatabaseUniqueConstraints(appId: string, databaseId: string): Promise<any[]>;
2482
+ registerDatabaseUniqueConstraint(appId: string, databaseId: string, constraint: {
2483
+ modelName: string;
2484
+ constraintName: string;
2485
+ fields: string[];
2486
+ }): Promise<any>;
2487
+ listBlobBuckets(appId: string): Promise<{
2488
+ items: any[];
2489
+ }>;
2490
+ createBlobBucket(appId: string, payload: any): Promise<any>;
2491
+ getBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
2492
+ updateBlobBucket(appId: string, bucketIdOrKey: string, payload: any): Promise<any>;
2493
+ deleteBlobBucket(appId: string, bucketIdOrKey: string): Promise<any>;
2494
+ listBucketBlobs(appId: string, bucketIdOrKey: string, params?: {
2495
+ cursor?: string;
2496
+ limit?: number;
2497
+ }): Promise<{
2498
+ items: any[];
2499
+ nextCursor?: string;
2500
+ hasMore?: boolean;
2501
+ }>;
2502
+ uploadBucketBlob(appId: string, bucketIdOrKey: string, data: Buffer, meta: {
2503
+ filename: string;
2504
+ contentType: string;
2505
+ tags?: string[];
2506
+ }): Promise<any>;
2507
+ downloadBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<Buffer>;
2508
+ deleteBucketBlob(appId: string, bucketIdOrKey: string, blobId: string): Promise<any>;
2509
+ deleteBucketBlobs(appId: string, bucketIdOrKey: string, blobIds: string[]): Promise<any>;
2510
+ getBucketBlobSignedUrl(appId: string, bucketIdOrKey: string, blobId: string, expiresInSeconds?: number): Promise<any>;
2511
+ getBucketBlobMetadata(appId: string, bucketIdOrKey: string, blobId: string): Promise<BlobInfo>;
2512
+ }
2513
+ export {};