primitive-admin 1.2.0-alpha.13 → 1.2.0-alpha.15

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 (324) hide show
  1. package/README.md +102 -78
  2. package/assets/skill/skills/primitive-platform/SKILL.md +87 -23
  3. package/dist/bin/primitive.js +11 -82
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +79 -17
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/agent-sessions.js +2 -0
  8. package/dist/src/commands/agent-sessions.js.map +1 -1
  9. package/dist/src/commands/analytics.js +220 -18
  10. package/dist/src/commands/analytics.js.map +1 -1
  11. package/dist/src/commands/apps-children.js +2 -0
  12. package/dist/src/commands/apps-children.js.map +1 -1
  13. package/dist/src/commands/apps.js +19 -2
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth.js +11 -1
  16. package/dist/src/commands/auth.js.map +1 -1
  17. package/dist/src/commands/collections.js +13 -0
  18. package/dist/src/commands/collections.js.map +1 -1
  19. package/dist/src/commands/config.d.ts +1 -1
  20. package/dist/src/commands/config.js +40 -9
  21. package/dist/src/commands/config.js.map +1 -1
  22. package/dist/src/commands/connections.js +2 -0
  23. package/dist/src/commands/connections.js.map +1 -1
  24. package/dist/src/commands/database-type-configs.js +5 -3
  25. package/dist/src/commands/database-type-configs.js.map +1 -1
  26. package/dist/src/commands/databases.js +6 -4
  27. package/dist/src/commands/databases.js.map +1 -1
  28. package/dist/src/commands/db3-types.js +2 -0
  29. package/dist/src/commands/db3-types.js.map +1 -1
  30. package/dist/src/commands/db3.d.ts +12 -0
  31. package/dist/src/commands/db3.js +345 -11
  32. package/dist/src/commands/db3.js.map +1 -1
  33. package/dist/src/commands/documents.d.ts +52 -12
  34. package/dist/src/commands/documents.js +120 -29
  35. package/dist/src/commands/documents.js.map +1 -1
  36. package/dist/src/commands/email-templates.js +72 -0
  37. package/dist/src/commands/email-templates.js.map +1 -1
  38. package/dist/src/commands/functions.js +47 -10
  39. package/dist/src/commands/functions.js.map +1 -1
  40. package/dist/src/commands/groups.js +18 -3
  41. package/dist/src/commands/groups.js.map +1 -1
  42. package/dist/src/commands/init.js +7 -1
  43. package/dist/src/commands/init.js.map +1 -1
  44. package/dist/src/commands/integrations.js +80 -47
  45. package/dist/src/commands/integrations.js.map +1 -1
  46. package/dist/src/commands/metadata-category-configs.js +2 -0
  47. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  48. package/dist/src/commands/metadata.js +41 -0
  49. package/dist/src/commands/metadata.js.map +1 -1
  50. package/dist/src/commands/prompts.js +73 -47
  51. package/dist/src/commands/prompts.js.map +1 -1
  52. package/dist/src/commands/rule-sets.js +2 -0
  53. package/dist/src/commands/rule-sets.js.map +1 -1
  54. package/dist/src/commands/schemas.d.ts +15 -0
  55. package/dist/src/commands/schemas.js +122 -0
  56. package/dist/src/commands/schemas.js.map +1 -0
  57. package/dist/src/commands/secrets.js +45 -3
  58. package/dist/src/commands/secrets.js.map +1 -1
  59. package/dist/src/commands/sessions.js +2 -0
  60. package/dist/src/commands/sessions.js.map +1 -1
  61. package/dist/src/commands/sync-schemas.d.ts +202 -0
  62. package/dist/src/commands/sync-schemas.js +629 -0
  63. package/dist/src/commands/sync-schemas.js.map +1 -0
  64. package/dist/src/commands/sync-user-properties.d.ts +118 -0
  65. package/dist/src/commands/sync-user-properties.js +276 -0
  66. package/dist/src/commands/sync-user-properties.js.map +1 -0
  67. package/dist/src/commands/sync.d.ts +243 -12
  68. package/dist/src/commands/sync.js +1474 -314
  69. package/dist/src/commands/sync.js.map +1 -1
  70. package/dist/src/commands/user-properties.d.ts +14 -0
  71. package/dist/src/commands/user-properties.js +79 -0
  72. package/dist/src/commands/user-properties.js.map +1 -0
  73. package/dist/src/commands/users.js +912 -18
  74. package/dist/src/commands/users.js.map +1 -1
  75. package/dist/src/commands/waitlist.js +39 -4
  76. package/dist/src/commands/waitlist.js.map +1 -1
  77. package/dist/src/lib/analytics-query.d.ts +58 -0
  78. package/dist/src/lib/analytics-query.js +134 -0
  79. package/dist/src/lib/analytics-query.js.map +1 -0
  80. package/dist/src/lib/api-client.d.ts +779 -95
  81. package/dist/src/lib/api-client.js +369 -166
  82. package/dist/src/lib/api-client.js.map +1 -1
  83. package/dist/src/lib/block-selector.d.ts +9 -15
  84. package/dist/src/lib/block-selector.js +9 -20
  85. package/dist/src/lib/block-selector.js.map +1 -1
  86. package/dist/src/lib/cli-manifest.d.ts +8 -0
  87. package/dist/src/lib/cli-manifest.js +10 -1
  88. package/dist/src/lib/cli-manifest.js.map +1 -1
  89. package/dist/src/lib/cli-version.d.ts +14 -0
  90. package/dist/src/lib/cli-version.js +38 -0
  91. package/dist/src/lib/cli-version.js.map +1 -0
  92. package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
  93. package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
  94. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
  95. package/dist/src/lib/command-status.d.ts +110 -0
  96. package/dist/src/lib/command-status.js +184 -0
  97. package/dist/src/lib/command-status.js.map +1 -0
  98. package/dist/src/lib/config-object-descriptor.d.ts +6 -0
  99. package/dist/src/lib/config-object-descriptor.js +71 -0
  100. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  101. package/dist/src/lib/config-toml.d.ts +11 -2
  102. package/dist/src/lib/config-toml.js +25 -2
  103. package/dist/src/lib/config-toml.js.map +1 -1
  104. package/dist/src/lib/data-input.d.ts +1 -1
  105. package/dist/src/lib/data-input.js +1 -1
  106. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
  107. package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
  108. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  109. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +11 -1
  110. package/dist/src/lib/db-codegen/dbTypeIR.js +11 -5
  111. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  112. package/dist/src/lib/db-type-records.d.ts +95 -0
  113. package/dist/src/lib/db-type-records.js +219 -0
  114. package/dist/src/lib/db-type-records.js.map +1 -0
  115. package/dist/src/lib/db3-export.d.ts +65 -9
  116. package/dist/src/lib/db3-export.js +159 -22
  117. package/dist/src/lib/db3-export.js.map +1 -1
  118. package/dist/src/lib/db3-index-output.d.ts +69 -3
  119. package/dist/src/lib/db3-index-output.js +142 -4
  120. package/dist/src/lib/db3-index-output.js.map +1 -1
  121. package/dist/src/lib/db3-type-models.d.ts +39 -7
  122. package/dist/src/lib/db3-type-models.js +138 -27
  123. package/dist/src/lib/db3-type-models.js.map +1 -1
  124. package/dist/src/lib/deprecation.d.ts +2 -2
  125. package/dist/src/lib/deprecation.js +2 -2
  126. package/dist/src/lib/experimental-apis.d.ts +36 -0
  127. package/dist/src/lib/experimental-apis.js +46 -0
  128. package/dist/src/lib/experimental-apis.js.map +1 -0
  129. package/dist/src/lib/file-attachment.d.ts +24 -0
  130. package/dist/src/lib/file-attachment.js +31 -0
  131. package/dist/src/lib/file-attachment.js.map +1 -0
  132. package/dist/src/lib/function-authorize-check.d.ts +1 -1
  133. package/dist/src/lib/function-authorize-check.js +2 -1
  134. package/dist/src/lib/function-authorize-check.js.map +1 -1
  135. package/dist/src/lib/function-authorize-view.js +4 -0
  136. package/dist/src/lib/function-authorize-view.js.map +1 -1
  137. package/dist/src/lib/function-bundle.d.ts +27 -5
  138. package/dist/src/lib/function-bundle.js +106 -7
  139. package/dist/src/lib/function-bundle.js.map +1 -1
  140. package/dist/src/lib/function-collect.d.ts +2 -0
  141. package/dist/src/lib/function-collect.js +36 -7
  142. package/dist/src/lib/function-collect.js.map +1 -1
  143. package/dist/src/lib/function-db-types.d.ts +57 -40
  144. package/dist/src/lib/function-db-types.js +246 -285
  145. package/dist/src/lib/function-db-types.js.map +1 -1
  146. package/dist/src/lib/function-document-types.d.ts +19 -7
  147. package/dist/src/lib/function-document-types.js +24 -12
  148. package/dist/src/lib/function-document-types.js.map +1 -1
  149. package/dist/src/lib/function-run.d.ts +1 -1
  150. package/dist/src/lib/function-run.js +1 -1
  151. package/dist/src/lib/function-run.js.map +1 -1
  152. package/dist/src/lib/function-schema-codegen.d.ts +58 -18
  153. package/dist/src/lib/function-schema-codegen.js +85 -74
  154. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  155. package/dist/src/lib/function-schema-refs.d.ts +98 -0
  156. package/dist/src/lib/function-schema-refs.js +177 -0
  157. package/dist/src/lib/function-schema-refs.js.map +1 -0
  158. package/dist/src/lib/function-sync.d.ts +38 -4
  159. package/dist/src/lib/function-sync.js +83 -14
  160. package/dist/src/lib/function-sync.js.map +1 -1
  161. package/dist/src/lib/function-typecheck.d.ts +52 -0
  162. package/dist/src/lib/function-typecheck.js +171 -54
  163. package/dist/src/lib/function-typecheck.js.map +1 -1
  164. package/dist/src/lib/generated-build-flags.d.ts +13 -0
  165. package/dist/src/lib/generated-build-flags.js +14 -0
  166. package/dist/src/lib/generated-build-flags.js.map +1 -0
  167. package/dist/src/lib/generated-config-surfaces.d.ts +211 -11
  168. package/dist/src/lib/generated-config-surfaces.js +579 -69
  169. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  170. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  171. package/dist/src/lib/generated-sdk-types.js +1 -1
  172. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  173. package/dist/src/lib/integration-test-request.d.ts +54 -0
  174. package/dist/src/lib/integration-test-request.js +207 -0
  175. package/dist/src/lib/integration-test-request.js.map +1 -0
  176. package/dist/src/lib/log-inspection.d.ts +3 -0
  177. package/dist/src/lib/log-inspection.js +1 -0
  178. package/dist/src/lib/log-inspection.js.map +1 -1
  179. package/dist/src/lib/metadata-report.d.ts +85 -0
  180. package/dist/src/lib/metadata-report.js +81 -0
  181. package/dist/src/lib/metadata-report.js.map +1 -0
  182. package/dist/src/lib/output.d.ts +1 -1
  183. package/dist/src/lib/output.js +1 -1
  184. package/dist/src/lib/platform-owned.js +5 -0
  185. package/dist/src/lib/platform-owned.js.map +1 -1
  186. package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
  187. package/dist/src/lib/primitive-declaration-names.js +22 -0
  188. package/dist/src/lib/primitive-declaration-names.js.map +1 -0
  189. package/dist/src/lib/primitive-declaration.d.ts +143 -0
  190. package/dist/src/lib/primitive-declaration.js +658 -0
  191. package/dist/src/lib/primitive-declaration.js.map +1 -0
  192. package/dist/src/lib/prompt-schema-codegen.d.ts +36 -12
  193. package/dist/src/lib/prompt-schema-codegen.js +82 -98
  194. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  195. package/dist/src/lib/prompt-schema-document.d.ts +35 -0
  196. package/dist/src/lib/prompt-schema-document.js +92 -0
  197. package/dist/src/lib/prompt-schema-document.js.map +1 -0
  198. package/dist/src/lib/prompt-schema-refs.d.ts +164 -0
  199. package/dist/src/lib/prompt-schema-refs.js +452 -0
  200. package/dist/src/lib/prompt-schema-refs.js.map +1 -0
  201. package/dist/src/lib/records-verbs.d.ts +12 -2
  202. package/dist/src/lib/records-verbs.js +7 -2
  203. package/dist/src/lib/records-verbs.js.map +1 -1
  204. package/dist/src/lib/register-commands.d.ts +28 -0
  205. package/dist/src/lib/register-commands.js +101 -0
  206. package/dist/src/lib/register-commands.js.map +1 -0
  207. package/dist/src/lib/retired-imports.d.ts +53 -0
  208. package/dist/src/lib/retired-imports.js +120 -0
  209. package/dist/src/lib/retired-imports.js.map +1 -0
  210. package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
  211. package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
  212. package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
  213. package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
  214. package/dist/src/lib/schema-codegen/generated-db3-bridge.js +221 -0
  215. package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
  216. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
  217. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
  218. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
  219. package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +209 -0
  220. package/dist/src/lib/schema-codegen/generated-field-grammar.js +379 -0
  221. package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
  222. package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
  223. package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
  224. package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
  225. package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
  226. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
  227. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
  228. package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +129 -0
  229. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +154 -1
  230. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -1
  231. package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
  232. package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
  233. package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
  234. package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
  235. package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
  236. package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
  237. package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
  238. package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
  239. package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
  240. package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
  241. package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
  242. package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
  243. package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
  244. package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
  245. package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
  246. package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
  247. package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
  248. package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
  249. package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
  250. package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
  251. package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
  252. package/dist/src/lib/schema-codegen/schemaToTs.d.ts +40 -13
  253. package/dist/src/lib/schema-codegen/schemaToTs.js +124 -160
  254. package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -1
  255. package/dist/src/lib/schema-codegen/valuesLists.d.ts +35 -0
  256. package/dist/src/lib/schema-codegen/valuesLists.js +128 -0
  257. package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
  258. package/dist/src/lib/schema-family-index.d.ts +228 -0
  259. package/dist/src/lib/schema-family-index.js +813 -0
  260. package/dist/src/lib/schema-family-index.js.map +1 -0
  261. package/dist/src/lib/schema-pins.d.ts +82 -0
  262. package/dist/src/lib/schema-pins.js +198 -0
  263. package/dist/src/lib/schema-pins.js.map +1 -0
  264. package/dist/src/lib/schema-preview.d.ts +244 -0
  265. package/dist/src/lib/schema-preview.js +498 -0
  266. package/dist/src/lib/schema-preview.js.map +1 -0
  267. package/dist/src/lib/skill-installer.d.ts +2 -2
  268. package/dist/src/lib/skill-installer.js +2 -21
  269. package/dist/src/lib/skill-installer.js.map +1 -1
  270. package/dist/src/lib/step-run-table.d.ts +1 -2
  271. package/dist/src/lib/step-run-table.js +1 -2
  272. package/dist/src/lib/step-run-table.js.map +1 -1
  273. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +2 -1
  274. package/dist/src/lib/swift-codegen/agentGenerator.js +24 -22
  275. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
  276. package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
  277. package/dist/src/lib/swift-codegen/banners.js +12 -0
  278. package/dist/src/lib/swift-codegen/banners.js.map +1 -1
  279. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
  280. package/dist/src/lib/swift-codegen/functionGenerator.js +167 -50
  281. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  282. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +31 -7
  283. package/dist/src/lib/swift-codegen/schemaToSwift.js +213 -177
  284. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  285. package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
  286. package/dist/src/lib/swift-codegen/sharedGenerator.js +120 -0
  287. package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
  288. package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
  289. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
  290. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
  291. package/dist/src/lib/sync-resource-types.d.ts +37 -5
  292. package/dist/src/lib/sync-resource-types.js +53 -5
  293. package/dist/src/lib/sync-resource-types.js.map +1 -1
  294. package/dist/src/lib/sync-selectors.d.ts +7 -0
  295. package/dist/src/lib/sync-selectors.js +22 -2
  296. package/dist/src/lib/sync-selectors.js.map +1 -1
  297. package/dist/src/lib/test-runs.d.ts +45 -0
  298. package/dist/src/lib/test-runs.js +150 -0
  299. package/dist/src/lib/test-runs.js.map +1 -0
  300. package/dist/src/lib/test-users.d.ts +25 -0
  301. package/dist/src/lib/test-users.js +36 -0
  302. package/dist/src/lib/test-users.js.map +1 -0
  303. package/dist/src/lib/toml-database-config.d.ts +2 -1
  304. package/dist/src/lib/toml-database-config.js +4 -3
  305. package/dist/src/lib/toml-database-config.js.map +1 -1
  306. package/dist/src/lib/toml-scalar-edit.js +6 -4
  307. package/dist/src/lib/toml-scalar-edit.js.map +1 -1
  308. package/dist/src/lib/user-index.d.ts +80 -0
  309. package/dist/src/lib/user-index.js +166 -0
  310. package/dist/src/lib/user-index.js.map +1 -0
  311. package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
  312. package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
  313. package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
  314. package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
  315. package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
  316. package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
  317. package/dist/src/lib/user-walk.d.ts +31 -0
  318. package/dist/src/lib/user-walk.js +102 -0
  319. package/dist/src/lib/user-walk.js.map +1 -0
  320. package/dist/src/lib/worker-perf-format.d.ts +22 -0
  321. package/dist/src/lib/worker-perf-format.js +27 -0
  322. package/dist/src/lib/worker-perf-format.js.map +1 -0
  323. package/dist/src/types/index.d.ts +13 -34
  324. package/package.json +5 -3
@@ -1,18 +1,40 @@
1
+ import { commandStatus } from "../lib/command-status.js";
1
2
  import { ApiClient } from "../lib/api-client.js";
2
3
  import { resolveAppId } from "../lib/config.js";
3
4
  import { error, flushOutput, formatDate, formatTable, info, json, result as printResult, success } from "../lib/output.js";
4
5
  import { confirmPrompt } from "../lib/confirm-prompt.js";
5
6
  import { normalizeCliListEnvelope, wholeListEnvelope } from "../lib/paginate.js";
6
7
  import { parseDataOption } from "../lib/data-input.js";
7
- import { DB3_ROUTES } from "../lib/records-verbs.js";
8
+ import { parseFilterOptions } from "../lib/record-filter.js";
9
+ import { DB3_BATCH_OPERATION_CAP, DB3_ROUTES } from "../lib/records-verbs.js";
8
10
  import { DB3_LOAD_ROUTES } from "../lib/load-routes.js";
9
11
  import { declarationOfSchemaAnswer, declaredModelNames, exportDb3, loadDb3Rows, pendingRegistrations, planDb3Import, readDb3Manifest, readExportedBlobs, resolvedTypeName, } from "../lib/db3-export.js";
10
12
  import fs from "fs";
11
13
  import path from "path";
12
- import { db3IndexRefusalLines, db3IndexTableRows } from "../lib/db3-index-output.js";
14
+ import { DB3_INDEX_KINDS, DB3_INDEX_PLACEMENTS, VECTOR_DISTANCES, VECTOR_INDEX_MODES, VECTOR_QUANTIZERS, db3IndexRefusalLines, db3IndexTableRows, listsVectorIndex, db3TextOptionsOf, vectorIndexOptions, } from "../lib/db3-index-output.js";
13
15
  import { parseCustodianOrExit } from "../lib/custodian.js";
14
16
  import { pageCursorOption, pageLimitOption, parsePageLimit, printEmptyPage, printPageHint } from "../lib/list-options.js";
15
- import { BULK_DATA_FILE_HELP, aggregateRecordsAction, bulkRecordsAction, countRecordsAction, deleteRecordAction, describeAction, describeRecordsFailure, displayTags, inspectAction, modelsAction, patchRecordAction, queryRecordsAction, saveRecordAction, schemaAction, statsAction, ingestAction, listIngestsAction, getIngestAction, abortIngestAction, listSnapshotsAction, getSnapshotAction, buildSnapshotAction, } from "./documents.js";
17
+ import { aggregateReadOf, aggregateRecordsAction, batchReadRecordsAction, batchRecordsAction, countRecordsAction, deleteRecordAction, describeAction, describeRecordsFailure, displayTags, inspectAction, modelsAction, patchRecordAction, queryReadOf, queryRecordsAction, saveRecordAction, schemaAction, statsAction, ingestAction, listIngestsAction, getIngestAction, abortIngestAction, listSnapshotsAction, getSnapshotAction, buildSnapshotAction, } from "./documents.js";
18
+ /**
19
+ * The `--data-file` help of `db3 records batch`: the db3 operation shapes,
20
+ * reads among them (#5243), the cap, and the command for a larger load.
21
+ */
22
+ export const DB3_BATCH_DATA_FILE_HELP = "JSON file with { operations: [...] } or a bare operations array, " +
23
+ `at most ${DB3_BATCH_OPERATION_CAP} operations per call (atomic): all apply or none do, in order. ` +
24
+ "Each write is one of { model, action: create, data, id? } (the database assigns " +
25
+ "the id when none is given), { model, action: patch, id, data }, " +
26
+ "{ model, action: increment, id, fields } (each field's delta), " +
27
+ "{ model, action: delete, id } or { model, action: upsert, constraint, data, id? } " +
28
+ "(merged into the record holding that unique constraint's key, or created). " +
29
+ "Any write takes a condition, a query filter the record must match or the batch is refused. " +
30
+ "A read { model, action: query, filter?, sort?, limit?, cursor?, include? }, " +
31
+ "{ model, action: count, filter? } or { model, action: aggregate, options } is answered " +
32
+ "against the writes before it. For larger loads use `primitive db3 ingest`";
33
+ /** The `--data-file` help of `db3 records batch-read` (#5243): the read shapes and the cap. */
34
+ export const DB3_BATCH_READ_DATA_FILE_HELP = "JSON file with { operations: [...] } or a bare array of reads, " +
35
+ `at most ${DB3_BATCH_OPERATION_CAP} per call, all answered from one state of the db3. ` +
36
+ "Each read is { model, action: query, filter?, sort?, limit?, cursor?, include? }, " +
37
+ "{ model, action: count, filter? } or { model, action: aggregate, options }";
16
38
  /**
17
39
  * A refused index call: the server's sentence, its code and status, then one
18
40
  * line per detail the code names (the duplicate keys, the origins keeping
@@ -29,6 +51,83 @@ function fail(err) {
29
51
  error(describeRecordsFailure(err));
30
52
  process.exit(1);
31
53
  }
54
+ /** `--explain` on a records read verb (#5240). */
55
+ const EXPLAIN_FLAG = "Explain the read on the server instead of answering it: the indexes it used, what it scanned and the rows it read";
56
+ /** `--index` on a records read verb (#5240). */
57
+ const INDEX_FLAG = "Explain the read forced onto this index of the model, or 'none' to read with no index (implies --explain)";
58
+ /** Whether a records read verb was asked to explain: `--explain`, or `--index`, which implies it. */
59
+ const explaining = (options) => options.explain === true || options.index !== undefined;
60
+ /**
61
+ * A records read explained (#5240): sends `read` through `client`, with
62
+ * `--index` as its force, to `POST db3/:id/records/:model/explain` and prints the answer,
63
+ * or `--json` it. A refusal prints the server's sentence, code and status,
64
+ * and a force's reason.
65
+ */
66
+ async function explainReadAction(client, appId, db3Id, modelName, options, read) {
67
+ try {
68
+ const answer = await client.explainDb3Read(appId, db3Id, modelName, {
69
+ ...read,
70
+ ...(options.index !== undefined ? { index: options.index } : {}),
71
+ });
72
+ if (options.json) {
73
+ json(answer);
74
+ return;
75
+ }
76
+ printExplain(answer);
77
+ }
78
+ catch (err) {
79
+ refuse(err);
80
+ }
81
+ }
82
+ /** An explain's answer: the read and its force, what it used, scanned, read and answered, then each statement's plan. */
83
+ function printExplain(answer) {
84
+ const forced = answer.index === null ? "no" : answer.index === "none" ? "none (no index)" : answer.index;
85
+ printResult("Read", `${answer.op} ${answer.model}`);
86
+ printResult("Forced", forced);
87
+ printResult("Indexes", answer.indexes.length > 0 ? answer.indexes.join(", ") : "none");
88
+ printResult("Scanned", answer.scanned.length > 0 ? answer.scanned.join(", ") : "none");
89
+ printResult("Rows read", answer.cost?.rowsRead ?? "not reported");
90
+ printResult("Answered", answer.answered);
91
+ for (const statement of answer.statements) {
92
+ console.log("");
93
+ console.log(statement.runs > 1 ? `${statement.model} (${statement.runs} runs)` : statement.model);
94
+ if (statement.plan === null)
95
+ console.log(` (no plan: ${statement.planError ?? "refused"})`);
96
+ else
97
+ for (const line of statement.plan)
98
+ console.log(` ${line}`);
99
+ }
100
+ }
101
+ /** Print `message` and exit 1, before any request. */
102
+ function refuseList(message) {
103
+ error(message);
104
+ process.exit(1);
105
+ }
106
+ /** The ways `db3 list --user-id` reads, in listing order. */
107
+ const DB3_VIAS = ["held", "shared", "app"];
108
+ /**
109
+ * The columns of `db3 list --user-id`, in order: each a field of the client's
110
+ * `Db3Row` or `Db3ListEntry` (`src/client/api/db3Api.ts`).
111
+ */
112
+ export const USER_DB3_TABLE_FIELDS = ["id", "title", "via", "permission", "custodian", "sync", "type", "grantedAt"];
113
+ const USER_DB3_TABLE_HEADERS = {
114
+ id: "ID",
115
+ title: "TITLE",
116
+ via: "VIA",
117
+ permission: "PERMISSION",
118
+ custodian: "CUSTODIAN",
119
+ sync: "SYNC",
120
+ type: "TYPE",
121
+ grantedAt: "GRANTED",
122
+ };
123
+ /** `--via` as a list of ways, or exit 1 before any request when it names anything else. */
124
+ function parseVia(value) {
125
+ const ways = value.split(",");
126
+ if (!value || ways.some((way) => !DB3_VIAS.includes(way))) {
127
+ refuseList("--via lists some of held, shared and app, comma-separated.");
128
+ }
129
+ return ways;
130
+ }
32
131
  /** `on` or `off` as a boolean, or exit 1 naming `label` before any request. */
33
132
  function parseOnOff(value, label) {
34
133
  if (value === "on")
@@ -60,6 +159,7 @@ export function registerDb3Commands(program) {
60
159
  const db3 = program
61
160
  .command("db3")
62
161
  .description("Work with db3s: create, read, list and delete them, their sync, app access and custody, indexes, records, schema and room");
162
+ commandStatus(db3, { stability: "beta" });
63
163
  // ---- Indexes ----
64
164
  const indexes = db3.command("indexes").description("List, register and drop a db3's indexes");
65
165
  indexes
@@ -87,6 +187,10 @@ export function registerDb3Commands(program) {
87
187
  { header: "FIELDS", key: "fields" },
88
188
  { header: "UNIQUE", key: "unique" },
89
189
  { header: "ORIGINS", key: "origins" },
190
+ { header: "KIND", key: "kind" },
191
+ { header: "ON", key: "on" },
192
+ // #5229 — a vector index's shared model; a list with no vector index prints as before.
193
+ ...(listsVectorIndex(list) ? [{ header: "ANN MODEL", key: "annModel" }] : []),
90
194
  ]));
91
195
  }
92
196
  catch (err) {
@@ -101,16 +205,70 @@ export function registerDb3Commands(program) {
101
205
  .requiredOption("--field <field>", "Field to index (repeat it for a composite unique index, which also needs --unique and --name)", (value, previous = []) => previous.concat(value))
102
206
  .option("--unique", "Enforce that no two records share the key")
103
207
  .option("--name <name>", "Name the index (idx_named_<model>_<name>)")
208
+ .option("--members", "Index a string-set field's members (idx_members_<model>_<field>) for $contains, any-of and facets; one --field, no --unique or --name (the same as --kind members)")
209
+ .option("--kind <kind>", `What the index is: ${DB3_INDEX_KINDS.join(", ")} (default scalar, members with --members)`)
210
+ .option("--on <placement>", `Where the index lives: ${DB3_INDEX_PLACEMENTS.join(", ")} (default both, server for a member index, device for a vector index); change it by dropping and registering again`)
211
+ .option("--distance <distance>", `A vector index's distance: ${VECTOR_DISTANCES.join(", ")} (with --kind vector)`)
212
+ .option("--index <mode>", `A vector index's search: ${VECTOR_INDEX_MODES.join(", ")} (with --kind vector; default exact)`)
213
+ .option("--nbucket <n>", "An ann vector index's bucket count (with --index ann)")
214
+ .option("--codesize <n>", "An ann vector index's bytes per quantized vector (with --index ann)")
215
+ .option("--quantizer <quantizer>", `An ann vector index's quantizer: ${VECTOR_QUANTIZERS.join(", ")} (with --index ann)`)
216
+ .option("--tokenizer <tokenizer>", "A text index's tokenizer: unicode61 (the default, diacritics folded) or porter (English stems)")
217
+ .option("--prefix <lengths>", "A text index's prefix lengths to index, comma-separated (e.g. 2,3)")
218
+ .option("--weight <field=weight>", "A text index's weight for one of its fields (repeatable; 1 by default)", (value, previous = []) => previous.concat(value))
104
219
  .option("--app <app-id>", "App ID")
105
220
  .option("--json", "Output as JSON")
106
221
  .action(async (db3Id, options) => {
107
222
  const resolvedAppId = resolveAppId(undefined, options);
108
223
  const fields = options.field;
224
+ const kind = options.kind;
225
+ const vector = vectorIndexOptions(options, kind);
226
+ if ("problem" in vector) {
227
+ error(vector.problem);
228
+ process.exit(1);
229
+ }
230
+ const members = options.members === true || kind === "members";
231
+ const flag = options.members ? "--members" : "--kind members";
232
+ const textOptions = options.tokenizer !== undefined || options.prefix !== undefined || options.weight !== undefined;
233
+ const text = kind === "text" ? db3TextOptionsOf(options) : null;
234
+ const conflict = kind !== undefined && !DB3_INDEX_KINDS.includes(kind)
235
+ ? `--kind must be one of ${DB3_INDEX_KINDS.join(", ")}`
236
+ : options.on !== undefined && !DB3_INDEX_PLACEMENTS.includes(options.on)
237
+ ? `--on must be one of ${DB3_INDEX_PLACEMENTS.join(", ")}`
238
+ : options.members && kind !== undefined && kind !== "members"
239
+ ? `--members is --kind members: give --kind ${kind} without --members, or --kind members`
240
+ : textOptions && kind !== "text"
241
+ ? `--tokenizer, --prefix and --weight apply to --kind text`
242
+ : text && "refusal" in text
243
+ ? text.refusal
244
+ : kind === "text" && options.unique
245
+ ? `--kind text takes no --unique: a text index enforces nothing`
246
+ : kind === "text" && options.name !== undefined
247
+ ? `--kind text takes no --name: a model's text index is named idx_text_<model>`
248
+ : !members
249
+ ? null
250
+ : fields.length > 1
251
+ ? `${flag} takes one --field: a member index covers one string-set field`
252
+ : options.unique
253
+ ? `${flag} takes no --unique: a member index enforces nothing`
254
+ : options.name !== undefined
255
+ ? `${flag} takes no --name: a member index is named idx_members_<model>_<field>`
256
+ : null;
257
+ if (conflict) {
258
+ error(conflict);
259
+ process.exit(1);
260
+ }
261
+ const textBody = text && "text" in text && Object.keys(text.text).length > 0 ? { text: text.text } : {};
109
262
  const body = {
110
263
  model: options.model,
111
264
  ...(fields.length === 1 ? { field: fields[0] } : { fields }),
112
265
  ...(options.unique ? { unique: true } : {}),
113
266
  ...(options.name !== undefined ? { name: options.name } : {}),
267
+ ...(options.members ? { members: true } : {}),
268
+ ...(kind !== undefined ? { kind: kind } : {}),
269
+ ...(options.on !== undefined ? { on: options.on } : {}),
270
+ ...(vector.options ? { vector: vector.options } : {}),
271
+ ...textBody,
114
272
  };
115
273
  const client = new ApiClient();
116
274
  try {
@@ -119,7 +277,7 @@ export function registerDb3Commands(program) {
119
277
  json(index);
120
278
  return;
121
279
  }
122
- success(`Registered ${index.name} on ${index.model} (${index.fields.join(", ")}${index.unique ? ", unique" : ""}).`);
280
+ success(`Registered ${index.name} on ${index.model} (${index.fields.join(", ")}${index.unique ? ", unique" : ""}${index.members ? ", members" : ""}${index.kind === "text" ? ", text" : ""}).`);
123
281
  }
124
282
  catch (err) {
125
283
  refuse(err);
@@ -162,6 +320,80 @@ export function registerDb3Commands(program) {
162
320
  refuse(err);
163
321
  }
164
322
  });
323
+ // ---- A vector index's shared ANN model (#5229) ----
324
+ const model = indexes.command("model").description("Fetch or delete an ann vector index's shared model");
325
+ model
326
+ .command("get")
327
+ .description("Write an ann vector index's shared model to a file, as a device uploaded it")
328
+ .argument("<db3-id>", "db3 ID")
329
+ .argument("<name>", "Vector index name, as `db3 indexes list` prints it")
330
+ .option("--out <file>", "Where to write the model (default <name>-<generation>-<revision>.pvm1)")
331
+ .option("--app <app-id>", "App ID")
332
+ .option("--json", "Output as JSON")
333
+ .action(async (db3Id, name, options) => {
334
+ const resolvedAppId = resolveAppId(undefined, options);
335
+ const client = new ApiClient();
336
+ try {
337
+ const fetched = await client.fetchDb3IndexModel(resolvedAppId, db3Id, name);
338
+ const out = path.resolve(options.out ?? `${name}-${fetched.generation}-${fetched.revision}.pvm1`);
339
+ fs.writeFileSync(out, fetched.data);
340
+ const summary = {
341
+ name,
342
+ file: out,
343
+ bytes: fetched.data.byteLength,
344
+ generation: fetched.generation,
345
+ revision: fetched.revision,
346
+ rows: fetched.rows,
347
+ trainedAt: fetched.trainedAt,
348
+ format: fetched.format,
349
+ };
350
+ if (options.json) {
351
+ json(summary);
352
+ return;
353
+ }
354
+ success(`Wrote ${name}'s model (revision ${fetched.revision}, ${fetched.rows} rows, trained ${fetched.trainedAt}) to ${out}: ${fetched.data.byteLength} bytes.`);
355
+ }
356
+ catch (err) {
357
+ refuse(err);
358
+ }
359
+ });
360
+ model
361
+ .command("delete")
362
+ .description("Delete an ann vector index's shared model so a device trains it again (the db3's owner)")
363
+ .argument("<db3-id>", "db3 ID")
364
+ .argument("<name>", "Vector index name, as `db3 indexes list` prints it")
365
+ .option("--app <app-id>", "App ID")
366
+ .option("-y, --yes", "Skip confirmation prompt")
367
+ .option("--json", "Output as JSON")
368
+ .action(async (db3Id, name, options) => {
369
+ const resolvedAppId = resolveAppId(undefined, options);
370
+ if (!options.yes) {
371
+ let confirmed;
372
+ try {
373
+ confirmed = await confirmPrompt(`Delete ${name}'s shared model on db3 ${db3Id}? Every device answers exactly until one trains it again.`);
374
+ }
375
+ catch (err) {
376
+ error(err.message);
377
+ process.exit(1);
378
+ }
379
+ if (!confirmed) {
380
+ info("Cancelled.");
381
+ return;
382
+ }
383
+ }
384
+ const client = new ApiClient();
385
+ try {
386
+ const answer = await client.deleteDb3IndexModel(resolvedAppId, db3Id, name);
387
+ if (options.json) {
388
+ json(answer);
389
+ return;
390
+ }
391
+ success(`Deleted ${answer.name}'s model; its revision is now ${answer.revision}.`);
392
+ }
393
+ catch (err) {
394
+ refuse(err);
395
+ }
396
+ });
165
397
  // ---- Records: the `documents records` verbs' twins ----
166
398
  const records = db3.command("records").description("Query and write a db3's records");
167
399
  records
@@ -176,9 +408,26 @@ export function registerDb3Commands(program) {
176
408
  .option("--limit <n>", "Records per page (default 100, max 10000)")
177
409
  .option("--cursor <cursor>", "Pagination cursor from a previous query (valid only with the same --sort)")
178
410
  .option("--include <json>", "Related records as a JSON array of include specs, e.g. '[{\"model\":\"customer\",\"type\":\"refersTo\",\"sourceField\":\"customerId\"}]'; answered as _related")
411
+ .option("--explain", EXPLAIN_FLAG)
412
+ .option("--index <name>", INDEX_FLAG)
179
413
  .option("--json", "Output as JSON")
180
414
  .action(async (db3Id, modelName, options) => {
181
415
  const resolvedAppId = resolveAppId(undefined, options);
416
+ if (explaining(options)) {
417
+ const { filter, sort, include } = queryReadOf(options);
418
+ const limit = options.limit === undefined ? undefined : /^\d+$/.test(options.limit) ? Number(options.limit) : options.limit;
419
+ await explainReadAction(new ApiClient(), resolvedAppId, db3Id, modelName, options, {
420
+ op: "query",
421
+ ...(filter ? { filter } : {}),
422
+ options: {
423
+ ...(sort !== undefined ? { sort } : {}),
424
+ ...(limit !== undefined ? { limit } : {}),
425
+ ...(options.cursor !== undefined ? { cursor: options.cursor } : {}),
426
+ ...(include !== undefined ? { include } : {}),
427
+ },
428
+ });
429
+ return;
430
+ }
182
431
  await queryRecordsAction(DB3_ROUTES, resolvedAppId, db3Id, modelName, options);
183
432
  });
184
433
  records
@@ -189,9 +438,16 @@ export function registerDb3Commands(program) {
189
438
  .option("--app <app-id>", "App ID")
190
439
  .option("--filter <json>", "Filter as JSON (e.g. '{\"status\":\"open\"}')")
191
440
  .option("--filter-file <path>", "Read filter from a JSON or TOML file")
441
+ .option("--explain", EXPLAIN_FLAG)
442
+ .option("--index <name>", INDEX_FLAG)
192
443
  .option("--json", "Output as JSON")
193
444
  .action(async (db3Id, modelName, options) => {
194
445
  const resolvedAppId = resolveAppId(undefined, options);
446
+ if (explaining(options)) {
447
+ const filter = parseFilterOptions(options);
448
+ await explainReadAction(new ApiClient(), resolvedAppId, db3Id, modelName, options, { op: "count", ...(filter ? { filter } : {}) });
449
+ return;
450
+ }
195
451
  await countRecordsAction(DB3_ROUTES, resolvedAppId, db3Id, modelName, options);
196
452
  });
197
453
  records
@@ -205,9 +461,19 @@ export function registerDb3Commands(program) {
205
461
  .option("--group-by <field>", "Group results by this field (repeatable)", (value, previous = []) => previous.concat(value), [])
206
462
  .option("--filter <json>", "Filter as JSON")
207
463
  .option("--filter-file <path>", "Read filter from a JSON or TOML file")
464
+ .option("--explain", EXPLAIN_FLAG)
465
+ .option("--index <name>", INDEX_FLAG)
208
466
  .option("--json", "Output as JSON")
209
467
  .action(async (db3Id, modelName, options) => {
210
468
  const resolvedAppId = resolveAppId(undefined, options);
469
+ if (explaining(options)) {
470
+ const { operations, groupBy, filter } = aggregateReadOf(options);
471
+ await explainReadAction(new ApiClient(), resolvedAppId, db3Id, modelName, options, {
472
+ op: "aggregate",
473
+ aggregate: { operations, groupBy, ...(filter ? { filter } : {}) },
474
+ });
475
+ return;
476
+ }
211
477
  await aggregateRecordsAction(DB3_ROUTES, resolvedAppId, db3Id, modelName, options);
212
478
  });
213
479
  records
@@ -255,15 +521,29 @@ export function registerDb3Commands(program) {
255
521
  await deleteRecordAction(DB3_ROUTES, resolvedAppId, db3Id, modelName, recordId, options);
256
522
  });
257
523
  records
258
- .command("bulk")
259
- .description("Apply an atomic create/patch/delete/upsert operations blob to a db3")
524
+ .command("batch")
525
+ .description(`Apply create/patch/increment/delete/upsert operations to a db3, with reads among them, at most ${DB3_BATCH_OPERATION_CAP} ` +
526
+ "operations per call (atomic); use `primitive db3 ingest` for larger loads")
260
527
  .argument("<db3-id>", "db3 ID")
261
- .requiredOption("--data-file <file>", BULK_DATA_FILE_HELP)
528
+ .requiredOption("--data-file <file>", DB3_BATCH_DATA_FILE_HELP)
262
529
  .option("--app <app-id>", "App ID")
263
530
  .option("-y, --yes", "Skip confirmation prompt")
264
531
  .option("--json", "Output as JSON")
265
532
  .action(async (db3Id, options) => {
266
- await bulkRecordsAction(DB3_ROUTES, db3Id, options);
533
+ await batchRecordsAction(DB3_ROUTES, db3Id, options);
534
+ });
535
+ records
536
+ .command("batch-read")
537
+ .description(`Run several queries, counts and aggregates on a db3 in one request, at most ${DB3_BATCH_OPERATION_CAP} ` +
538
+ "per call, answered from one state of the db3")
539
+ .argument("<db3-id>", "db3 ID")
540
+ .requiredOption("--data-file <file>", DB3_BATCH_READ_DATA_FILE_HELP)
541
+ .option("--partial", "Answer a refused read in its place instead of refusing the request")
542
+ .option("--app <app-id>", "App ID")
543
+ .option("--json", "Output as JSON")
544
+ .action(async (db3Id, options) => {
545
+ const client = new ApiClient();
546
+ await batchReadRecordsAction(client, db3Id, options);
267
547
  });
268
548
  records
269
549
  .command("models")
@@ -616,14 +896,68 @@ Custody:
616
896
  });
617
897
  db3
618
898
  .command("list")
619
- .description("List one custodian's db3s, oldest first")
620
- .requiredOption("--custodian <custodian>", '"app" or "user:<user-id>"')
899
+ .description("List one custodian's db3s, oldest first, or every db3 a user reaches: held, shared with them, then app access")
900
+ .option("--custodian <custodian>", '"app" or "user:<user-id>"')
901
+ .option("--user-id <user-id>", "List every db3 this user reaches, one row per way, sync-off db3s included")
902
+ .option("--via <ways>", "With --user-id: some of held, shared and app, comma-separated")
621
903
  .option("--app <app-id>", "App ID")
622
904
  .addOption(pageLimitOption())
623
905
  .addOption(pageCursorOption())
624
906
  .option("--json", "Output as JSON")
625
907
  .allowExcessArguments(false)
626
908
  .action(async (options) => {
909
+ if ((options.custodian === undefined) === (options.userId === undefined)) {
910
+ refuseList("db3 list takes exactly one of --custodian and --user-id.");
911
+ }
912
+ if (options.userId === undefined) {
913
+ if (options.via !== undefined)
914
+ refuseList("--via is valid only with --user-id.");
915
+ return listByCustodian(options);
916
+ }
917
+ const userId = options.userId;
918
+ if (!userId.trim() || userId.startsWith("user:"))
919
+ refuseList("--user-id needs a bare user id.");
920
+ const via = options.via === undefined ? undefined : parseVia(options.via);
921
+ const limit = parsePageLimit(options.limit);
922
+ const resolvedAppId = resolveAppId(undefined, options);
923
+ try {
924
+ const page = normalizeCliListEnvelope(await new ApiClient().listDb3ForUser(resolvedAppId, userId, {
925
+ ...(via ? { via } : {}),
926
+ ...(limit !== undefined ? { limit } : {}),
927
+ ...(options.cursor ? { cursor: options.cursor } : {}),
928
+ }));
929
+ if (options.json) {
930
+ json(page);
931
+ return;
932
+ }
933
+ if (page.items.length === 0) {
934
+ printEmptyPage(page, "db3s");
935
+ return;
936
+ }
937
+ const rows = page.items.map((row) => ({
938
+ id: row.id,
939
+ title: row.title ?? "",
940
+ via: row.via,
941
+ permission: row.permission ?? "none",
942
+ custodian: row.custodian ?? "none",
943
+ sync: row.sync === false ? "off" : "on",
944
+ type: row.type ?? "none",
945
+ grantedAt: row.grantedAt,
946
+ }));
947
+ console.log(formatTable(rows, USER_DB3_TABLE_FIELDS.map((key) => ({
948
+ header: USER_DB3_TABLE_HEADERS[key],
949
+ key,
950
+ ...(key === "title" ? { flex: true } : {}),
951
+ ...(key === "grantedAt" ? { format: (value) => (value ? formatDate(value) : "—") } : {}),
952
+ }))));
953
+ printPageHint(page);
954
+ }
955
+ catch (err) {
956
+ fail(err);
957
+ }
958
+ });
959
+ /** `db3 list --custodian`: one custodian's db3s from the admin API (#4800). */
960
+ async function listByCustodian(options) {
627
961
  const limit = parsePageLimit(options.limit);
628
962
  const custodian = parseCustodianOrExit(options.custodian, "--custodian");
629
963
  const resolvedAppId = resolveAppId(undefined, options);
@@ -661,7 +995,7 @@ Custody:
661
995
  catch (err) {
662
996
  fail(err);
663
997
  }
664
- });
998
+ }
665
999
  db3
666
1000
  .command("delete")
667
1001
  .description("Delete a db3 and all its data (records, blobs, aliases, permissions)")