primitive-admin 1.1.0-alpha.8 → 1.1.0-alpha.80

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