primitive-admin 1.2.0-alpha.9 → 1.3.0-alpha.1

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 (590) hide show
  1. package/README.md +303 -186
  2. package/assets/skill/skills/primitive-platform/SKILL.md +93 -27
  3. package/dist/bin/primitive.js +15 -89
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +80 -17
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/agent-sessions.d.ts +129 -0
  8. package/dist/src/commands/agent-sessions.js +532 -20
  9. package/dist/src/commands/agent-sessions.js.map +1 -1
  10. package/dist/src/commands/analytics.js +207 -155
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps-children.js +3 -0
  13. package/dist/src/commands/apps-children.js.map +1 -1
  14. package/dist/src/commands/apps-transitions.d.ts +39 -0
  15. package/dist/src/commands/apps-transitions.js +198 -0
  16. package/dist/src/commands/apps-transitions.js.map +1 -0
  17. package/dist/src/commands/apps.d.ts +17 -0
  18. package/dist/src/commands/apps.js +108 -3
  19. package/dist/src/commands/apps.js.map +1 -1
  20. package/dist/src/commands/auth-sessions.js +2 -0
  21. package/dist/src/commands/auth-sessions.js.map +1 -1
  22. package/dist/src/commands/auth.js +170 -50
  23. package/dist/src/commands/auth.js.map +1 -1
  24. package/dist/src/commands/blob-buckets.js +2 -0
  25. package/dist/src/commands/blob-buckets.js.map +1 -1
  26. package/dist/src/commands/collections.js +318 -256
  27. package/dist/src/commands/collections.js.map +1 -1
  28. package/dist/src/commands/comparisons.js +2 -0
  29. package/dist/src/commands/comparisons.js.map +1 -1
  30. package/dist/src/commands/config.d.ts +2 -2
  31. package/dist/src/commands/config.js +59 -33
  32. package/dist/src/commands/config.js.map +1 -1
  33. package/dist/src/commands/connections.js +2 -0
  34. package/dist/src/commands/connections.js.map +1 -1
  35. package/dist/src/commands/database-type-configs.js +5 -3
  36. package/dist/src/commands/database-type-configs.js.map +1 -1
  37. package/dist/src/commands/databases.js +6 -4
  38. package/dist/src/commands/databases.js.map +1 -1
  39. package/dist/src/commands/db3-types.d.ts +42 -0
  40. package/dist/src/commands/db3-types.js +445 -0
  41. package/dist/src/commands/db3-types.js.map +1 -0
  42. package/dist/src/commands/db3.d.ts +38 -0
  43. package/dist/src/commands/db3.js +2053 -0
  44. package/dist/src/commands/db3.js.map +1 -0
  45. package/dist/src/commands/documents.d.ts +110 -10
  46. package/dist/src/commands/documents.js +1019 -748
  47. package/dist/src/commands/documents.js.map +1 -1
  48. package/dist/src/commands/email-templates.js +74 -0
  49. package/dist/src/commands/email-templates.js.map +1 -1
  50. package/dist/src/commands/env.js +8 -4
  51. package/dist/src/commands/env.js.map +1 -1
  52. package/dist/src/commands/function-trigger-commands.d.ts +28 -0
  53. package/dist/src/commands/function-trigger-commands.js +341 -0
  54. package/dist/src/commands/function-trigger-commands.js.map +1 -0
  55. package/dist/src/commands/functions.js +383 -32
  56. package/dist/src/commands/functions.js.map +1 -1
  57. package/dist/src/commands/groups.js +168 -50
  58. package/dist/src/commands/groups.js.map +1 -1
  59. package/dist/src/commands/guides.js +7 -5
  60. package/dist/src/commands/guides.js.map +1 -1
  61. package/dist/src/commands/hosting.d.ts +8 -0
  62. package/dist/src/commands/hosting.js +509 -0
  63. package/dist/src/commands/hosting.js.map +1 -0
  64. package/dist/src/commands/init.js +129 -38
  65. package/dist/src/commands/init.js.map +1 -1
  66. package/dist/src/commands/integrations.js +82 -53
  67. package/dist/src/commands/integrations.js.map +1 -1
  68. package/dist/src/commands/locks.d.ts +5 -3
  69. package/dist/src/commands/locks.js +19 -61
  70. package/dist/src/commands/locks.js.map +1 -1
  71. package/dist/src/commands/metadata-category-configs.d.ts +2 -2
  72. package/dist/src/commands/metadata-category-configs.js +4 -2
  73. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  74. package/dist/src/commands/metadata.js +55 -6
  75. package/dist/src/commands/metadata.js.map +1 -1
  76. package/dist/src/commands/prompts.js +75 -52
  77. package/dist/src/commands/prompts.js.map +1 -1
  78. package/dist/src/commands/rate-counters.d.ts +19 -0
  79. package/dist/src/commands/rate-counters.js +104 -0
  80. package/dist/src/commands/rate-counters.js.map +1 -0
  81. package/dist/src/commands/rule-sets.d.ts +1 -1
  82. package/dist/src/commands/rule-sets.js +2 -1
  83. package/dist/src/commands/rule-sets.js.map +1 -1
  84. package/dist/src/commands/schemas.d.ts +15 -0
  85. package/dist/src/commands/schemas.js +122 -0
  86. package/dist/src/commands/schemas.js.map +1 -0
  87. package/dist/src/commands/scripts.d.ts +9 -17
  88. package/dist/src/commands/scripts.js +24 -479
  89. package/dist/src/commands/scripts.js.map +1 -1
  90. package/dist/src/commands/secrets.d.ts +38 -0
  91. package/dist/src/commands/secrets.js +148 -6
  92. package/dist/src/commands/secrets.js.map +1 -1
  93. package/dist/src/commands/sessions.js +2 -0
  94. package/dist/src/commands/sessions.js.map +1 -1
  95. package/dist/src/commands/skill.js +2 -0
  96. package/dist/src/commands/skill.js.map +1 -1
  97. package/dist/src/commands/spent-tokens.d.ts +19 -0
  98. package/dist/src/commands/spent-tokens.js +79 -0
  99. package/dist/src/commands/spent-tokens.js.map +1 -0
  100. package/dist/src/commands/sync-app-settings.d.ts +58 -0
  101. package/dist/src/commands/sync-app-settings.js +119 -2
  102. package/dist/src/commands/sync-app-settings.js.map +1 -1
  103. package/dist/src/commands/sync-schemas.d.ts +202 -0
  104. package/dist/src/commands/sync-schemas.js +629 -0
  105. package/dist/src/commands/sync-schemas.js.map +1 -0
  106. package/dist/src/commands/sync-user-properties.d.ts +118 -0
  107. package/dist/src/commands/sync-user-properties.js +276 -0
  108. package/dist/src/commands/sync-user-properties.js.map +1 -0
  109. package/dist/src/commands/sync.d.ts +578 -546
  110. package/dist/src/commands/sync.js +3516 -5134
  111. package/dist/src/commands/sync.js.map +1 -1
  112. package/dist/src/commands/tokens.js +5 -3
  113. package/dist/src/commands/tokens.js.map +1 -1
  114. package/dist/src/commands/transitions.d.ts +54 -0
  115. package/dist/src/commands/transitions.js +418 -0
  116. package/dist/src/commands/transitions.js.map +1 -0
  117. package/dist/src/commands/usage.d.ts +42 -0
  118. package/dist/src/commands/usage.js +397 -0
  119. package/dist/src/commands/usage.js.map +1 -0
  120. package/dist/src/commands/user-properties.d.ts +14 -0
  121. package/dist/src/commands/user-properties.js +79 -0
  122. package/dist/src/commands/user-properties.js.map +1 -0
  123. package/dist/src/commands/users.js +951 -18
  124. package/dist/src/commands/users.js.map +1 -1
  125. package/dist/src/commands/vars.js +2 -0
  126. package/dist/src/commands/vars.js.map +1 -1
  127. package/dist/src/commands/waitlist.js +39 -4
  128. package/dist/src/commands/waitlist.js.map +1 -1
  129. package/dist/src/commands/workflows.d.ts +5 -83
  130. package/dist/src/commands/workflows.js +57 -2282
  131. package/dist/src/commands/workflows.js.map +1 -1
  132. package/dist/src/lib/analytics-query.d.ts +58 -0
  133. package/dist/src/lib/analytics-query.js +134 -0
  134. package/dist/src/lib/analytics-query.js.map +1 -0
  135. package/dist/src/lib/api-client.d.ts +1976 -431
  136. package/dist/src/lib/api-client.js +1095 -550
  137. package/dist/src/lib/api-client.js.map +1 -1
  138. package/dist/src/lib/app-settings-descriptor.d.ts +14 -2
  139. package/dist/src/lib/app-settings-descriptor.js +55 -1
  140. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  141. package/dist/src/lib/auth-fixtures.d.ts +44 -0
  142. package/dist/src/lib/auth-fixtures.js +61 -0
  143. package/dist/src/lib/auth-fixtures.js.map +1 -0
  144. package/dist/src/lib/auth-flow.d.ts +47 -1
  145. package/dist/src/lib/auth-flow.js +451 -14
  146. package/dist/src/lib/auth-flow.js.map +1 -1
  147. package/dist/src/lib/block-layout.d.ts +12 -23
  148. package/dist/src/lib/block-layout.js +26 -92
  149. package/dist/src/lib/block-layout.js.map +1 -1
  150. package/dist/src/lib/block-selector.d.ts +8 -14
  151. package/dist/src/lib/block-selector.js +8 -19
  152. package/dist/src/lib/block-selector.js.map +1 -1
  153. package/dist/src/lib/child-apps-local.d.ts +3 -1
  154. package/dist/src/lib/child-apps-local.js +9 -1
  155. package/dist/src/lib/child-apps-local.js.map +1 -1
  156. package/dist/src/lib/cli-manifest.d.ts +9 -0
  157. package/dist/src/lib/cli-manifest.js +10 -1
  158. package/dist/src/lib/cli-manifest.js.map +1 -1
  159. package/dist/src/lib/cli-version.d.ts +14 -0
  160. package/dist/src/lib/cli-version.js +38 -0
  161. package/dist/src/lib/cli-version.js.map +1 -0
  162. package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
  163. package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
  164. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
  165. package/dist/src/lib/collection-export.d.ts +76 -15
  166. package/dist/src/lib/collection-export.js +116 -23
  167. package/dist/src/lib/collection-export.js.map +1 -1
  168. package/dist/src/lib/collection-principal.d.ts +22 -0
  169. package/dist/src/lib/collection-principal.js +35 -0
  170. package/dist/src/lib/collection-principal.js.map +1 -0
  171. package/dist/src/lib/command-groups.d.ts +30 -0
  172. package/dist/src/lib/command-groups.js +111 -0
  173. package/dist/src/lib/command-groups.js.map +1 -0
  174. package/dist/src/lib/command-status.d.ts +147 -0
  175. package/dist/src/lib/command-status.js +266 -0
  176. package/dist/src/lib/command-status.js.map +1 -0
  177. package/dist/src/lib/config-object-descriptor.d.ts +9 -22
  178. package/dist/src/lib/config-object-descriptor.js +113 -277
  179. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  180. package/dist/src/lib/config-surface.d.ts +3 -7
  181. package/dist/src/lib/config-surface.js +9 -13
  182. package/dist/src/lib/config-surface.js.map +1 -1
  183. package/dist/src/lib/config-toml.d.ts +11 -2
  184. package/dist/src/lib/config-toml.js +25 -2
  185. package/dist/src/lib/config-toml.js.map +1 -1
  186. package/dist/src/lib/credentials-home.d.ts +7 -0
  187. package/dist/src/lib/credentials-home.js +45 -10
  188. package/dist/src/lib/credentials-home.js.map +1 -1
  189. package/dist/src/lib/credentials-lock.d.ts +14 -6
  190. package/dist/src/lib/credentials-lock.js +90 -10
  191. package/dist/src/lib/credentials-lock.js.map +1 -1
  192. package/dist/src/lib/credentials-store.d.ts +142 -70
  193. package/dist/src/lib/credentials-store.js +420 -111
  194. package/dist/src/lib/credentials-store.js.map +1 -1
  195. package/dist/src/lib/custodian.d.ts +8 -0
  196. package/dist/src/lib/custodian.js +18 -0
  197. package/dist/src/lib/custodian.js.map +1 -0
  198. package/dist/src/lib/data-input.d.ts +1 -1
  199. package/dist/src/lib/data-input.js +1 -1
  200. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
  201. package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
  202. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  203. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +40 -1
  204. package/dist/src/lib/db-codegen/dbTypeIR.js +32 -8
  205. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  206. package/dist/src/lib/db-type-records.d.ts +125 -0
  207. package/dist/src/lib/db-type-records.js +237 -0
  208. package/dist/src/lib/db-type-records.js.map +1 -0
  209. package/dist/src/lib/db3-export.d.ts +322 -0
  210. package/dist/src/lib/db3-export.js +767 -0
  211. package/dist/src/lib/db3-export.js.map +1 -0
  212. package/dist/src/lib/db3-index-output.d.ts +116 -0
  213. package/dist/src/lib/db3-index-output.js +223 -0
  214. package/dist/src/lib/db3-index-output.js.map +1 -0
  215. package/dist/src/lib/db3-json-fields.d.ts +49 -0
  216. package/dist/src/lib/db3-json-fields.js +195 -0
  217. package/dist/src/lib/db3-json-fields.js.map +1 -0
  218. package/dist/src/lib/db3-type-archive.d.ts +59 -0
  219. package/dist/src/lib/db3-type-archive.js +95 -0
  220. package/dist/src/lib/db3-type-archive.js.map +1 -0
  221. package/dist/src/lib/db3-type-models.d.ts +148 -0
  222. package/dist/src/lib/db3-type-models.js +583 -0
  223. package/dist/src/lib/db3-type-models.js.map +1 -0
  224. package/dist/src/lib/deprecation.d.ts +2 -2
  225. package/dist/src/lib/deprecation.js +2 -2
  226. package/dist/src/lib/document-export-record-log.d.ts +7 -0
  227. package/dist/src/lib/document-export-record-log.js +9 -0
  228. package/dist/src/lib/document-export-record-log.js.map +1 -1
  229. package/dist/src/lib/document-ingest-artifact.d.ts +19 -0
  230. package/dist/src/lib/document-ingest-artifact.js +55 -6
  231. package/dist/src/lib/document-ingest-artifact.js.map +1 -1
  232. package/dist/src/lib/document-ingest-format2.d.ts +36 -0
  233. package/dist/src/lib/document-ingest-format2.js +78 -0
  234. package/dist/src/lib/document-ingest-format2.js.map +1 -0
  235. package/dist/src/lib/document-ingest-input.d.ts +9 -0
  236. package/dist/src/lib/document-ingest-input.js +28 -1
  237. package/dist/src/lib/document-ingest-input.js.map +1 -1
  238. package/dist/src/lib/document-ingest.d.ts +11 -1
  239. package/dist/src/lib/document-ingest.js +16 -0
  240. package/dist/src/lib/document-ingest.js.map +1 -1
  241. package/dist/src/lib/document-schema-rows.d.ts +42 -0
  242. package/dist/src/lib/document-schema-rows.js +53 -0
  243. package/dist/src/lib/document-schema-rows.js.map +1 -0
  244. package/dist/src/lib/experimental-apis.d.ts +36 -0
  245. package/dist/src/lib/experimental-apis.js +46 -0
  246. package/dist/src/lib/experimental-apis.js.map +1 -0
  247. package/dist/src/lib/file-attachment.d.ts +24 -0
  248. package/dist/src/lib/file-attachment.js +31 -0
  249. package/dist/src/lib/file-attachment.js.map +1 -0
  250. package/dist/src/lib/function-authorize-check.d.ts +142 -0
  251. package/dist/src/lib/function-authorize-check.js +311 -0
  252. package/dist/src/lib/function-authorize-check.js.map +1 -0
  253. package/dist/src/lib/function-authorize-view.d.ts +36 -0
  254. package/dist/src/lib/function-authorize-view.js +110 -0
  255. package/dist/src/lib/function-authorize-view.js.map +1 -0
  256. package/dist/src/lib/function-bundle.d.ts +27 -5
  257. package/dist/src/lib/function-bundle.js +142 -7
  258. package/dist/src/lib/function-bundle.js.map +1 -1
  259. package/dist/src/lib/function-collect.d.ts +112 -12
  260. package/dist/src/lib/function-collect.js +601 -12
  261. package/dist/src/lib/function-collect.js.map +1 -1
  262. package/dist/src/lib/function-db-types.d.ts +65 -11
  263. package/dist/src/lib/function-db-types.js +326 -157
  264. package/dist/src/lib/function-db-types.js.map +1 -1
  265. package/dist/src/lib/function-document-types.d.ts +19 -7
  266. package/dist/src/lib/function-document-types.js +24 -12
  267. package/dist/src/lib/function-document-types.js.map +1 -1
  268. package/dist/src/lib/function-grants-preflight.d.ts +99 -0
  269. package/dist/src/lib/function-grants-preflight.js +154 -2
  270. package/dist/src/lib/function-grants-preflight.js.map +1 -1
  271. package/dist/src/lib/function-lint.d.ts +85 -0
  272. package/dist/src/lib/function-lint.js +442 -0
  273. package/dist/src/lib/function-lint.js.map +1 -0
  274. package/dist/src/lib/function-log-row.js +21 -2
  275. package/dist/src/lib/function-log-row.js.map +1 -1
  276. package/dist/src/lib/function-run.d.ts +13 -21
  277. package/dist/src/lib/function-run.js +14 -27
  278. package/dist/src/lib/function-run.js.map +1 -1
  279. package/dist/src/lib/function-schema-codegen.d.ts +86 -22
  280. package/dist/src/lib/function-schema-codegen.js +194 -88
  281. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  282. package/dist/src/lib/function-schema-refs.d.ts +98 -0
  283. package/dist/src/lib/function-schema-refs.js +177 -0
  284. package/dist/src/lib/function-schema-refs.js.map +1 -0
  285. package/dist/src/lib/function-sync.d.ts +120 -6
  286. package/dist/src/lib/function-sync.js +217 -26
  287. package/dist/src/lib/function-sync.js.map +1 -1
  288. package/dist/src/lib/function-trigger-listing.d.ts +11 -6
  289. package/dist/src/lib/function-trigger-listing.js +32 -11
  290. package/dist/src/lib/function-trigger-listing.js.map +1 -1
  291. package/dist/src/lib/function-typecheck.d.ts +52 -0
  292. package/dist/src/lib/function-typecheck.js +174 -54
  293. package/dist/src/lib/function-typecheck.js.map +1 -1
  294. package/dist/src/lib/function-versions.d.ts +2 -0
  295. package/dist/src/lib/function-versions.js +1 -0
  296. package/dist/src/lib/function-versions.js.map +1 -1
  297. package/dist/src/lib/generated-build-flags.d.ts +13 -0
  298. package/dist/src/lib/generated-build-flags.js +14 -0
  299. package/dist/src/lib/generated-build-flags.js.map +1 -0
  300. package/dist/src/lib/generated-command-status.d.ts +6 -0
  301. package/dist/src/lib/generated-command-status.js +502 -0
  302. package/dist/src/lib/generated-command-status.js.map +1 -0
  303. package/dist/src/lib/generated-config-surfaces.d.ts +804 -140
  304. package/dist/src/lib/generated-config-surfaces.js +2491 -1806
  305. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  306. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  307. package/dist/src/lib/generated-sdk-types.js +1 -1
  308. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  309. package/dist/src/lib/hosting-build.d.ts +97 -0
  310. package/dist/src/lib/hosting-build.js +204 -0
  311. package/dist/src/lib/hosting-build.js.map +1 -0
  312. package/dist/src/lib/hosting-client.d.ts +167 -0
  313. package/dist/src/lib/hosting-client.js +340 -0
  314. package/dist/src/lib/hosting-client.js.map +1 -0
  315. package/dist/src/lib/hosting-environments.d.ts +32 -0
  316. package/dist/src/lib/hosting-environments.js +74 -0
  317. package/dist/src/lib/hosting-environments.js.map +1 -0
  318. package/dist/src/lib/hosting-errors.d.ts +30 -0
  319. package/dist/src/lib/hosting-errors.js +43 -0
  320. package/dist/src/lib/hosting-errors.js.map +1 -0
  321. package/dist/src/lib/hosting-token.d.ts +46 -0
  322. package/dist/src/lib/hosting-token.js +60 -0
  323. package/dist/src/lib/hosting-token.js.map +1 -0
  324. package/dist/src/lib/hosting-trust-step.d.ts +67 -0
  325. package/dist/src/lib/hosting-trust-step.js +279 -0
  326. package/dist/src/lib/hosting-trust-step.js.map +1 -0
  327. package/dist/src/lib/hosting-trust.d.ts +77 -0
  328. package/dist/src/lib/hosting-trust.js +194 -0
  329. package/dist/src/lib/hosting-trust.js.map +1 -0
  330. package/dist/src/lib/hosting-wait.d.ts +42 -0
  331. package/dist/src/lib/hosting-wait.js +84 -0
  332. package/dist/src/lib/hosting-wait.js.map +1 -0
  333. package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
  334. package/dist/src/lib/hosting-wfp-upload.js +149 -0
  335. package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
  336. package/dist/src/lib/init-assets.d.ts +2 -6
  337. package/dist/src/lib/init-assets.js +11 -27
  338. package/dist/src/lib/init-assets.js.map +1 -1
  339. package/dist/src/lib/init-ios-links.d.ts +11 -7
  340. package/dist/src/lib/init-ios-links.js +28 -22
  341. package/dist/src/lib/init-ios-links.js.map +1 -1
  342. package/dist/src/lib/init-login-note.d.ts +13 -0
  343. package/dist/src/lib/init-login-note.js +22 -0
  344. package/dist/src/lib/init-login-note.js.map +1 -0
  345. package/dist/src/lib/init-schema.d.ts +15 -0
  346. package/dist/src/lib/init-schema.js +54 -0
  347. package/dist/src/lib/init-schema.js.map +1 -1
  348. package/dist/src/lib/integration-test-request.d.ts +54 -0
  349. package/dist/src/lib/integration-test-request.js +207 -0
  350. package/dist/src/lib/integration-test-request.js.map +1 -0
  351. package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
  352. package/dist/src/lib/invoker-shared-enums.js +98 -0
  353. package/dist/src/lib/invoker-shared-enums.js.map +1 -0
  354. package/dist/src/lib/json-value.d.ts +6 -0
  355. package/dist/src/lib/json-value.js +13 -0
  356. package/dist/src/lib/json-value.js.map +1 -0
  357. package/dist/src/lib/load-routes.d.ts +33 -0
  358. package/dist/src/lib/load-routes.js +35 -0
  359. package/dist/src/lib/load-routes.js.map +1 -0
  360. package/dist/src/lib/log-inspection.d.ts +23 -4
  361. package/dist/src/lib/log-inspection.js +14 -5
  362. package/dist/src/lib/log-inspection.js.map +1 -1
  363. package/dist/src/lib/login-exchange-check.d.ts +18 -0
  364. package/dist/src/lib/login-exchange-check.js +27 -0
  365. package/dist/src/lib/login-exchange-check.js.map +1 -0
  366. package/dist/src/lib/login-scope-lines.d.ts +17 -7
  367. package/dist/src/lib/login-scope-lines.js +33 -10
  368. package/dist/src/lib/login-scope-lines.js.map +1 -1
  369. package/dist/src/lib/metadata-report.d.ts +85 -0
  370. package/dist/src/lib/metadata-report.js +81 -0
  371. package/dist/src/lib/metadata-report.js.map +1 -0
  372. package/dist/src/lib/object-status-filter.d.ts +9 -1
  373. package/dist/src/lib/object-status-filter.js +9 -1
  374. package/dist/src/lib/object-status-filter.js.map +1 -1
  375. package/dist/src/lib/output.d.ts +1 -1
  376. package/dist/src/lib/output.js +3 -1
  377. package/dist/src/lib/output.js.map +1 -1
  378. package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
  379. package/dist/src/lib/pin-refusal-hint.js +35 -0
  380. package/dist/src/lib/pin-refusal-hint.js.map +1 -0
  381. package/dist/src/lib/platform-owned.js +5 -0
  382. package/dist/src/lib/platform-owned.js.map +1 -1
  383. package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
  384. package/dist/src/lib/primitive-declaration-names.js +22 -0
  385. package/dist/src/lib/primitive-declaration-names.js.map +1 -0
  386. package/dist/src/lib/primitive-declaration.d.ts +174 -0
  387. package/dist/src/lib/primitive-declaration.js +871 -0
  388. package/dist/src/lib/primitive-declaration.js.map +1 -0
  389. package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
  390. package/dist/src/lib/primitive-env-plugin.js +408 -0
  391. package/dist/src/lib/primitive-env-plugin.js.map +1 -0
  392. package/dist/src/lib/project-login-apps.d.ts +8 -0
  393. package/dist/src/lib/project-login-apps.js +27 -0
  394. package/dist/src/lib/project-login-apps.js.map +1 -0
  395. package/dist/src/lib/prompt-schema-codegen.d.ts +36 -12
  396. package/dist/src/lib/prompt-schema-codegen.js +96 -100
  397. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  398. package/dist/src/lib/prompt-schema-document.d.ts +35 -0
  399. package/dist/src/lib/prompt-schema-document.js +92 -0
  400. package/dist/src/lib/prompt-schema-document.js.map +1 -0
  401. package/dist/src/lib/prompt-schema-refs.d.ts +173 -0
  402. package/dist/src/lib/prompt-schema-refs.js +478 -0
  403. package/dist/src/lib/prompt-schema-refs.js.map +1 -0
  404. package/dist/src/lib/records-verbs.d.ts +79 -0
  405. package/dist/src/lib/records-verbs.js +45 -0
  406. package/dist/src/lib/records-verbs.js.map +1 -0
  407. package/dist/src/lib/refresh-admin-credentials.d.ts +34 -4
  408. package/dist/src/lib/refresh-admin-credentials.js +85 -29
  409. package/dist/src/lib/refresh-admin-credentials.js.map +1 -1
  410. package/dist/src/lib/refresh-stored-login.d.ts +85 -0
  411. package/dist/src/lib/refresh-stored-login.js +233 -0
  412. package/dist/src/lib/refresh-stored-login.js.map +1 -0
  413. package/dist/src/lib/register-commands.d.ts +36 -0
  414. package/dist/src/lib/register-commands.js +37 -0
  415. package/dist/src/lib/register-commands.js.map +1 -0
  416. package/dist/src/lib/retired-imports.d.ts +53 -0
  417. package/dist/src/lib/retired-imports.js +120 -0
  418. package/dist/src/lib/retired-imports.js.map +1 -0
  419. package/dist/src/lib/row-field-rename.d.ts +18 -0
  420. package/dist/src/lib/row-field-rename.js +32 -0
  421. package/dist/src/lib/row-field-rename.js.map +1 -0
  422. package/dist/src/lib/run-status.d.ts +1 -1
  423. package/dist/src/lib/run-status.generated.d.ts +2 -2
  424. package/dist/src/lib/run-status.generated.js +3 -1
  425. package/dist/src/lib/run-status.generated.js.map +1 -1
  426. package/dist/src/lib/run-status.js +1 -1
  427. package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
  428. package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
  429. package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
  430. package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
  431. package/dist/src/lib/schema-codegen/generated-db3-bridge.js +227 -0
  432. package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
  433. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
  434. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
  435. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
  436. package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +229 -0
  437. package/dist/src/lib/schema-codegen/generated-field-grammar.js +420 -0
  438. package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
  439. package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
  440. package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
  441. package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
  442. package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
  443. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
  444. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
  445. package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +258 -0
  446. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +422 -0
  447. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
  448. package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
  449. package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
  450. package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
  451. package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
  452. package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
  453. package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
  454. package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
  455. package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
  456. package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
  457. package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
  458. package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
  459. package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
  460. package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
  461. package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
  462. package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
  463. package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
  464. package/dist/src/lib/schema-codegen/naming.js +83 -0
  465. package/dist/src/lib/schema-codegen/naming.js.map +1 -0
  466. package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
  467. package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
  468. package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
  469. package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
  470. package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
  471. package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
  472. package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
  473. package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
  474. package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
  475. package/dist/src/lib/schema-codegen/schemaToTs.d.ts +109 -0
  476. package/dist/src/lib/schema-codegen/schemaToTs.js +269 -0
  477. package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
  478. package/dist/src/lib/schema-codegen/valuesLists.d.ts +48 -0
  479. package/dist/src/lib/schema-codegen/valuesLists.js +144 -0
  480. package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
  481. package/dist/src/lib/schema-defs-module.d.ts +29 -0
  482. package/dist/src/lib/schema-defs-module.js +103 -0
  483. package/dist/src/lib/schema-defs-module.js.map +1 -0
  484. package/dist/src/lib/schema-family-index.d.ts +228 -0
  485. package/dist/src/lib/schema-family-index.js +813 -0
  486. package/dist/src/lib/schema-family-index.js.map +1 -0
  487. package/dist/src/lib/schema-pins.d.ts +82 -0
  488. package/dist/src/lib/schema-pins.js +198 -0
  489. package/dist/src/lib/schema-pins.js.map +1 -0
  490. package/dist/src/lib/schema-preview.d.ts +244 -0
  491. package/dist/src/lib/schema-preview.js +498 -0
  492. package/dist/src/lib/schema-preview.js.map +1 -0
  493. package/dist/src/lib/scope-request.d.ts +23 -11
  494. package/dist/src/lib/scope-request.js +69 -31
  495. package/dist/src/lib/scope-request.js.map +1 -1
  496. package/dist/src/lib/session-scope.d.ts +26 -0
  497. package/dist/src/lib/session-scope.js +58 -0
  498. package/dist/src/lib/session-scope.js.map +1 -0
  499. package/dist/src/lib/skill-installer.d.ts +2 -2
  500. package/dist/src/lib/skill-installer.js +2 -21
  501. package/dist/src/lib/skill-installer.js.map +1 -1
  502. package/dist/src/lib/step-run-table.d.ts +1 -2
  503. package/dist/src/lib/step-run-table.js +1 -2
  504. package/dist/src/lib/step-run-table.js.map +1 -1
  505. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +2 -1
  506. package/dist/src/lib/swift-codegen/agentGenerator.js +25 -23
  507. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
  508. package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
  509. package/dist/src/lib/swift-codegen/banners.js +12 -0
  510. package/dist/src/lib/swift-codegen/banners.js.map +1 -1
  511. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
  512. package/dist/src/lib/swift-codegen/functionGenerator.js +169 -51
  513. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  514. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +33 -9
  515. package/dist/src/lib/swift-codegen/schemaToSwift.js +215 -179
  516. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  517. package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +51 -0
  518. package/dist/src/lib/swift-codegen/sharedGenerator.js +239 -0
  519. package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
  520. package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
  521. package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
  522. package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
  523. package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
  524. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
  525. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
  526. package/dist/src/lib/sync-resource-types.d.ts +117 -31
  527. package/dist/src/lib/sync-resource-types.js +197 -189
  528. package/dist/src/lib/sync-resource-types.js.map +1 -1
  529. package/dist/src/lib/sync-selectors.d.ts +7 -0
  530. package/dist/src/lib/sync-selectors.js +22 -2
  531. package/dist/src/lib/sync-selectors.js.map +1 -1
  532. package/dist/src/lib/template.d.ts +39 -3
  533. package/dist/src/lib/template.js +103 -14
  534. package/dist/src/lib/template.js.map +1 -1
  535. package/dist/src/lib/test-case-file-names.d.ts +3 -5
  536. package/dist/src/lib/test-case-file-names.js +3 -5
  537. package/dist/src/lib/test-case-file-names.js.map +1 -1
  538. package/dist/src/lib/test-runs.d.ts +45 -0
  539. package/dist/src/lib/test-runs.js +150 -0
  540. package/dist/src/lib/test-runs.js.map +1 -0
  541. package/dist/src/lib/test-users.d.ts +25 -0
  542. package/dist/src/lib/test-users.js +36 -0
  543. package/dist/src/lib/test-users.js.map +1 -0
  544. package/dist/src/lib/toml-database-config.d.ts +4 -2
  545. package/dist/src/lib/toml-database-config.js +11 -6
  546. package/dist/src/lib/toml-database-config.js.map +1 -1
  547. package/dist/src/lib/toml-list-edit.d.ts +33 -0
  548. package/dist/src/lib/toml-list-edit.js +481 -0
  549. package/dist/src/lib/toml-list-edit.js.map +1 -0
  550. package/dist/src/lib/toml-scalar-edit.d.ts +9 -0
  551. package/dist/src/lib/toml-scalar-edit.js +73 -5
  552. package/dist/src/lib/toml-scalar-edit.js.map +1 -1
  553. package/dist/src/lib/transition-warnings.d.ts +21 -0
  554. package/dist/src/lib/transition-warnings.js +49 -0
  555. package/dist/src/lib/transition-warnings.js.map +1 -0
  556. package/dist/src/lib/usage-meters.d.ts +16 -0
  557. package/dist/src/lib/usage-meters.js +52 -0
  558. package/dist/src/lib/usage-meters.js.map +1 -0
  559. package/dist/src/lib/user-index.d.ts +80 -0
  560. package/dist/src/lib/user-index.js +166 -0
  561. package/dist/src/lib/user-index.js.map +1 -0
  562. package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
  563. package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
  564. package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
  565. package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
  566. package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
  567. package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
  568. package/dist/src/lib/user-walk.d.ts +31 -0
  569. package/dist/src/lib/user-walk.js +102 -0
  570. package/dist/src/lib/user-walk.js.map +1 -0
  571. package/dist/src/lib/webhook-capture.d.ts +43 -0
  572. package/dist/src/lib/webhook-capture.js +91 -0
  573. package/dist/src/lib/webhook-capture.js.map +1 -0
  574. package/dist/src/lib/webhook-deliver.d.ts +18 -20
  575. package/dist/src/lib/webhook-deliver.js +34 -89
  576. package/dist/src/lib/webhook-deliver.js.map +1 -1
  577. package/dist/src/lib/webhook-test-run.d.ts +32 -0
  578. package/dist/src/lib/webhook-test-run.js +108 -0
  579. package/dist/src/lib/webhook-test-run.js.map +1 -0
  580. package/dist/src/lib/worker-perf-format.d.ts +22 -0
  581. package/dist/src/lib/worker-perf-format.js +27 -0
  582. package/dist/src/lib/worker-perf-format.js.map +1 -0
  583. package/dist/src/types/index.d.ts +20 -65
  584. package/dist/src/validators.d.ts +7 -55
  585. package/dist/src/validators.js +7 -53
  586. package/dist/src/validators.js.map +1 -1
  587. package/dist/src/vite.d.ts +17 -0
  588. package/dist/src/vite.js +18 -0
  589. package/dist/src/vite.js.map +1 -0
  590. package/package.json +20 -9
@@ -55,10 +55,25 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
55
55
  import { tmpdir } from "node:os";
56
56
  import { join, resolve } from "node:path";
57
57
  import { PRIMITIVE_FUNCTIONS_MODULE } from "./function-bundle.js";
58
+ import { AUTH_FAMILIES, AUTHORIZE_HELPERS } from "./generated-config-surfaces.js";
58
59
  /** The manifest encoding, versioned with the envelope that carries it. */
59
60
  export const FUNCTION_MANIFEST_SCHEMA_VERSION = 2;
61
+ /**
62
+ * The version a FLAGGED build emits (#4730): version 2 plus the `authorize`
63
+ * block and `writeFamilies`. A bare-handler build keeps emitting version 2,
64
+ * byte for byte, so no legacy envelope hash moves.
65
+ */
66
+ export const FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION = 3;
67
+ /** How much of one authorize source text the families scan reads. */
68
+ export const AUTHORIZE_SOURCE_SCAN_CAP = 256 * 1024;
60
69
  /** How long a tree's module scope may run before collection gives up. */
61
70
  export const COLLECT_TIMEOUT_MS = 20_000;
71
+ /**
72
+ * #5904 — the most `input` entries the collect pass reports, and the most
73
+ * UTF-16 units of each: the push probe's own caps, one past the server's
74
+ * bounds, so a list the server refuses is still reported whole enough to lint.
75
+ */
76
+ const PROBE_INPUT_CAP = 65;
62
77
  /** A push that cannot proceed because its manifest could not be collected. */
63
78
  export class FunctionCollectError extends Error {
64
79
  constructor(message) {
@@ -66,6 +81,74 @@ export class FunctionCollectError extends Error {
66
81
  this.name = "FunctionCollectError";
67
82
  }
68
83
  }
84
+ /** The manifest's `usersBatch` door from what the inert `allowCallers` recorded (#5393). */
85
+ function usersBatchDoor(raw) {
86
+ if (raw === true)
87
+ return { usersBatch: true };
88
+ if (!Array.isArray(raw))
89
+ return {};
90
+ const keys = [...new Set(raw.map(String))].sort();
91
+ return keys.length > 0 ? { usersBatch: keys } : {};
92
+ }
93
+ /** The `auth.*` families each SDK helper reads by construction (#4730). */
94
+ const HELPER_AUTH_FAMILIES = {
95
+ allowAnyone: [],
96
+ allowCallers: ["auth.trigger"],
97
+ requireSignedIn: ["auth.user"],
98
+ requireRole: ["auth.user"],
99
+ requireMember: ["auth.user", "auth.memberships"],
100
+ requireCollectionRole: ["auth.user", "auth.collections"],
101
+ requireDocumentOwner: ["auth.user", "auth.doc"],
102
+ // #5843 — the db3 helpers: a public-access read, and a level read first.
103
+ requirePublicDb3: ["auth.db3"],
104
+ requireDb3Level: ["auth.user", "auth.db3"],
105
+ // #5849 — the action-token redemption.
106
+ requireToken: ["auth.actionToken"],
107
+ // #5848 — the invitation read alone; no other existing helper reads it.
108
+ requireInvitation: ["auth.invitation"],
109
+ };
110
+ /**
111
+ * The `auth.*` families a hand-written authorize's source text reaches —
112
+ * #4730 behavior 4.
113
+ *
114
+ * A member-access scan, on whatever the author named the parameter, plus the
115
+ * families of any SDK helper the text calls by name (esbuild may suffix a
116
+ * renamed import, `requireRole2(`). `hasRole` compares `auth.user.role` and
117
+ * reads no membership. Imprecise by construction, as `families[]` is: a body
118
+ * that delegates to a function defined elsewhere records nothing, and an
119
+ * unrelated `.user` in the text counts. Each text is read to
120
+ * {@link AUTHORIZE_SOURCE_SCAN_CAP} only.
121
+ */
122
+ export function scanAuthorizeSources(sources) {
123
+ const families = new Set();
124
+ const members = [
125
+ [/\.user\b/, "auth.user"],
126
+ [/\.hasRole\s*\(/, "auth.user"],
127
+ [/\.trigger\b/, "auth.trigger"],
128
+ [/\.(?:memberships|isMemberOf|memberGroups|hasGroupRole)\s*\(/, "auth.memberships"],
129
+ [/\.collections\.resolveRole\s*\(/, "auth.collections"],
130
+ [/\.doc\s*\(/, "auth.doc"],
131
+ [/\.db\s*\(/, "auth.db"],
132
+ // #5843 — the public-access read alone. No \`.db3(\` pattern: a scan that
133
+ // matched an existing \`auth.db3(id).permissions()\` would change that
134
+ // function's manifest, and so its next unchanged push would be a new version.
135
+ [/\.publicAccess\s*\(/, "auth.db3"],
136
+ [/\.configVar\s*\(/, "auth.configVar"],
137
+ ];
138
+ const helperCall = new RegExp(`\\b(${Object.keys(HELPER_AUTH_FAMILIES).join("|")})\\d*\\s*\\(`, "g");
139
+ for (const source of sources) {
140
+ const text = String(source ?? "").slice(0, AUTHORIZE_SOURCE_SCAN_CAP);
141
+ for (const [pattern, family] of members) {
142
+ if (pattern.test(text))
143
+ families.add(family);
144
+ }
145
+ for (const match of text.matchAll(helperCall)) {
146
+ for (const family of HELPER_AUTH_FAMILIES[match[1]])
147
+ families.add(family);
148
+ }
149
+ }
150
+ return [...families].sort();
151
+ }
69
152
  /**
70
153
  * What the static scan reads out of a built bundle — #3279 behavior 10.
71
154
  *
@@ -149,6 +232,19 @@ export function scanBundleForManifest(bundle) {
149
232
  for (const call of bundle.matchAll(/\.documents\.records\.[A-Za-z_$][\w$]*\(/g)) {
150
233
  keyed(argumentText(bundle, call.index + call[0].length), "model");
151
234
  }
235
+ // #4803 — the db3 records' path parameter is `model` too, read the same way
236
+ // inside a `.db3.records.<verb>(` call; and a handle-level `.batch(` or
237
+ // `.batchRead(` (#5243) on a `.db3(…)` chain names each op's model.
238
+ for (const call of bundle.matchAll(/\.db3\.records\.[A-Za-z_$][\w$]*\(/g)) {
239
+ keyed(argumentText(bundle, call.index + call[0].length), "model");
240
+ }
241
+ for (const call of bundle.matchAll(/\.db3\(/g)) {
242
+ const start = call.index + call[0].length;
243
+ const at = start + argumentText(bundle, start).length + 1;
244
+ const batch = /^\s*\.batch(?:Read)?\(/.exec(bundle.slice(at, at + 200));
245
+ if (batch)
246
+ keyed(argumentText(bundle, at + batch[0].length), "model");
247
+ }
152
248
  // `<anything>.api.<family>` and the ctx helpers.
153
249
  for (const match of bundle.matchAll(/\.api\.([A-Za-z_$][\w$]*)/g)) {
154
250
  families.add(match[1]);
@@ -157,6 +253,8 @@ export function scanBundleForManifest(bundle) {
157
253
  [/\.db\(/, "databases"],
158
254
  // #3281 — the typed document handle, a binding over documents.records.*.
159
255
  [/\.doc\(/, "documents"],
256
+ // #4803 — the typed db3 handle, a binding over db3.records.*.
257
+ [/\.db3\(/, "db3"],
160
258
  [/\.integrations\.call\(/, "integrations"],
161
259
  [/\.prompts\.run\(/, "prompts"],
162
260
  [/\.secret\(/, "secrets"],
@@ -173,8 +271,63 @@ export function scanBundleForManifest(bundle) {
173
271
  models: [...models].sort(),
174
272
  families: [...families].sort(),
175
273
  dynamicModels,
274
+ writeFamilies: scanWriteFamilies(bundle),
176
275
  };
177
276
  }
277
+ /**
278
+ * The records write verbs; the SDK has no `create` (#4730, F4730-DESIGN-003).
279
+ * `increment` is the db3 records' (#4803); no database or document handle has
280
+ * one, so it counts on a db3 chain alone.
281
+ */
282
+ const RECORD_WRITE_VERBS = ["save", "patch", "delete", "batch", "bulk", "increment"];
283
+ /**
284
+ * The families on which the bundle calls a write or send verb — #4730
285
+ * behavior 5, version 3's `writeFamilies`.
286
+ *
287
+ * A records verb counts only on a chain that names its family: a direct
288
+ * `.api.<family>.records.<verb>(`, or a typed handle `.db(…)`/`.doc(…)`/
289
+ * `.db3(…)` (#4803), optionally through `.model(…)`, then `.<verb>(`. An
290
+ * unrelated object's `save` is not a write. The send and start verbs are read
291
+ * by their member path. A handle held in a variable is not followed:
292
+ * imprecise by construction, as the rest of the scan is.
293
+ */
294
+ function scanWriteFamilies(bundle) {
295
+ const families = new Set();
296
+ const verbs = RECORD_WRITE_VERBS.join("|");
297
+ for (const match of bundle.matchAll(new RegExp(`\\.api\\.([A-Za-z_$][\\w$]*)\\.records\\.(?:${verbs})\\(`, "g"))) {
298
+ families.add(match[1]);
299
+ }
300
+ // Past one call's argument list: the index just after its closing paren.
301
+ const pastCall = (from) => {
302
+ const args = argumentText(bundle, from);
303
+ return from + args.length + 1;
304
+ };
305
+ const verbAt = new RegExp(`^\\s*\\.(?:${verbs})\\(`);
306
+ const modelAt = /^\s*\.model\(/;
307
+ const handleFamily = { db: "databases", doc: "documents", db3: "db3" };
308
+ for (const call of bundle.matchAll(/\.(db3|db|doc)\(/g)) {
309
+ let at = pastCall(call.index + call[0].length);
310
+ const model = modelAt.exec(bundle.slice(at, at + 200));
311
+ if (model)
312
+ at = pastCall(at + model[0].length);
313
+ if (verbAt.test(bundle.slice(at, at + 200))) {
314
+ families.add(handleFamily[call[1]]);
315
+ }
316
+ }
317
+ const sends = [
318
+ [/\.users\.send\(/, "users"],
319
+ [/\.connections\.send\(/, "connections"],
320
+ [/\.channels\.publish\(/, "channels"],
321
+ [/\.email\.send\(/, "email"],
322
+ [/\.functions\.start\(/, "functions"],
323
+ [/\.locks\.(?:acquire|withLock)\(/, "locks"],
324
+ ];
325
+ for (const [pattern, family] of sends) {
326
+ if (pattern.test(bundle))
327
+ families.add(family);
328
+ }
329
+ return [...families].sort();
330
+ }
178
331
  /** The line prefix the child frames its result with. */
179
332
  const RESULT_SENTINEL = "__PRIMITIVE_COLLECT__";
180
333
  /**
@@ -298,18 +451,289 @@ export function defineFunction(keyOrHandler, maybeHandler) {
298
451
  // (D3281-SO-006). The registry entry is the child's report of what the
299
452
  // module scope did; it is not what the check consults, because a keyed
300
453
  // handler an entry merely imports for composition registers here too.
301
- if (typeof keyOrHandler === "string" || maybeHandler !== undefined) {
302
- registry.push({ kind: "function", name: String(keyOrHandler) });
303
- const wrapped = function (...args) {
304
- return maybeHandler(...args);
305
- };
306
- wrapped.functionKey = String(keyOrHandler);
307
- return wrapped;
454
+ const keyed = typeof keyOrHandler === "string" || maybeHandler !== undefined;
455
+ const target = keyed ? maybeHandler : keyOrHandler;
456
+ // #4717 — the OBJECT form, \`{ input, authorize, handler }\`, returns the
457
+ // same wrapper carrying \`authorize\`, which is what the runner reports. Its
458
+ // shape is checked as the baked SDK checks it, so a definition the sandbox
459
+ // would refuse at load is refused here, at push, with the same sentence. The
460
+ // \`input\` list (#5901) is carried as written; the server's probe reads it.
461
+ let authorize;
462
+ let input;
463
+ let handler = target;
464
+ if (target !== null && typeof target === "object") {
465
+ const signature = keyed
466
+ ? "defineFunction(key, { authorize, handler })"
467
+ : "defineFunction({ authorize, handler })";
468
+ for (const name of Object.keys(target)) {
469
+ if (name !== "input" && name !== "authorize" && name !== "handler") {
470
+ throw new TypeError(
471
+ signature + ": unknown key '" + name + "'; the object form takes input, authorize and handler"
472
+ );
473
+ }
474
+ }
475
+ if (typeof target.handler !== "function") {
476
+ throw new TypeError(signature + ": handler must be a function");
477
+ }
478
+ if (typeof target.authorize !== "function") {
479
+ throw new TypeError(signature + ": authorize must be a function");
480
+ }
481
+ authorize = target.authorize;
482
+ input = target.input;
483
+ handler = target.handler;
484
+ }
485
+ if (!keyed && authorize === undefined) return keyOrHandler;
486
+ if (keyed) registry.push({ kind: "function", name: String(keyOrHandler) });
487
+ const wrapped = function (...args) {
488
+ return handler(...args);
489
+ };
490
+ // #5843 — the author's handler, for the runner to report its text beside
491
+ // the manifest (the public-db3 lint reads it); not enumerable, so nothing
492
+ // that walks the wrapper sees it.
493
+ Object.defineProperty(wrapped, "__collectHandler", { value: handler });
494
+ if (keyed) wrapped.functionKey = String(keyOrHandler);
495
+ if (authorize !== undefined) wrapped.authorize = authorize;
496
+ if (input !== undefined) wrapped.input = input;
497
+ return wrapped;
498
+ }
499
+ // #4717 — inert decisions: collection runs no \`authorize\`, so nothing reads
500
+ // them, but a module scope that builds one must still collect.
501
+ export function allow(resolved) {
502
+ return Object.freeze({ decision: "allow", resolved: resolved === undefined ? null : resolved });
503
+ }
504
+ export function deny(code, message, options) {
505
+ return Object.freeze({
506
+ decision: "deny",
507
+ code,
508
+ message: typeof message === "string" ? message : null,
509
+ expose: !!(options && options.expose === true),
510
+ });
511
+ }
512
+ // #4721 — \`fail\` throws its real error, so a module scope that calls it
513
+ // is refused here as the push probe refuses it. The helpers check their
514
+ // arguments with the baked SDK's sentences (\`sdk-core.ts\`), so a tree
515
+ // collects exactly when the probe would load it, and each returns an inert
516
+ // \`authorize\`: collection runs none, and one called anyway says so.
517
+ export function fail(code, message) {
518
+ if (typeof code !== "string" || code.length === 0) {
519
+ throw new TypeError("fail(code, message): code must be a non-empty string");
520
+ }
521
+ if (message !== undefined && message !== null && typeof message !== "string") {
522
+ throw new TypeError("fail(code, message): message must be a string");
523
+ }
524
+ const detail = typeof message === "string" && message.length > 0 ? message : null;
525
+ const error = new Error(detail === null ? code : code + ": " + detail);
526
+ error.name = "FunctionFailure";
527
+ error.code = code;
528
+ error.detail = detail;
529
+ throw error;
530
+ }
531
+ const APP_ROLES = ["owner", "admin", "member"];
532
+ const GROUP_ROLES = ["owner", "manager", "member"];
533
+ const COLLECTION_ROLES = ["owner", "manager", "editor", "contributor", "viewer"];
534
+ const CALLER_KEYS = ["webhook", "cron", "manual", "functions", "agents", "users", "db3", "usersBatch"];
535
+ function requireRung(signature, name, ladder, role) {
536
+ if (!ladder.includes(role)) {
537
+ throw new TypeError(
538
+ signature + ": " + name + " must be one of " + ladder.join(", ") + ", not " + JSON.stringify(role)
539
+ );
540
+ }
541
+ }
542
+ function requireSelector(signature, name, what, selector) {
543
+ if (typeof selector !== "function") {
544
+ throw new TypeError(
545
+ signature + ": " + name + " must be a function that answers the " + what + " from the input"
546
+ );
547
+ }
548
+ }
549
+ // #4730 — each inert closure carries a \`__collect\` marker the runner reports
550
+ // for the manifest's \`authorize\` block: which helper built it, the
551
+ // \`auth.*\` families it reads by construction, and the source text of any
552
+ // hand-written rule it wraps, which the CLI scans.
553
+ const HELPER_FAMILIES = ${JSON.stringify(HELPER_AUTH_FAMILIES)};
554
+ function inertAuthorize(helper, extra) {
555
+ const inert = async () => {
556
+ throw new Error(
557
+ helper + "() was called during manifest collection; an authorize only runs inside a real invocation."
558
+ );
559
+ };
560
+ const marker = {
561
+ helper,
562
+ public: helper === "allowAnyone",
563
+ callers: null,
564
+ families: HELPER_FAMILIES[helper].slice(),
565
+ sources: [],
566
+ };
567
+ Object.defineProperty(inert, "__collect", { value: Object.assign(marker, extra || {}) });
568
+ return inert;
569
+ }
570
+ function sourceOf(fn) {
571
+ try {
572
+ return String(Function.prototype.toString.call(fn)).slice(0, ${AUTHORIZE_SOURCE_SCAN_CAP});
573
+ } catch {
574
+ return "";
575
+ }
576
+ }
577
+ function markerOf(fn) {
578
+ const marker = fn && fn.__collect;
579
+ if (marker && typeof marker === "object") return marker;
580
+ return { helper: null, public: false, callers: null, families: [], sources: [sourceOf(fn)] };
581
+ }
582
+ // #5843 — the rule a marker answers an HTTP call with: an \`allowCallers\`
583
+ // marker's own \`users\` rule (or none), else the marker's helper and the
584
+ // source text of a hand-written rule.
585
+ function httpRuleOf(marker) {
586
+ if (marker.helper === "allowCallers") return marker.http === undefined ? null : marker.http;
587
+ return { helper: marker.helper, sources: (marker.sources || []).slice() };
588
+ }
589
+ export function allowAnyone() { return inertAuthorize("allowAnyone"); }
590
+ export function requireSignedIn() { return inertAuthorize("requireSignedIn"); }
591
+ export function requireRole(role) {
592
+ requireRung("requireRole(role)", "role", APP_ROLES, role);
593
+ return inertAuthorize("requireRole");
594
+ }
595
+ export function requireMember(groupIdOf, role) {
596
+ const signature = "requireMember(groupIdOf, role)";
597
+ requireSelector(signature, "groupIdOf", "group id", groupIdOf);
598
+ if (role !== undefined) requireRung(signature, "role", GROUP_ROLES, role);
599
+ return inertAuthorize("requireMember");
600
+ }
601
+ export function requireCollectionRole(collectionIdOf, minRole) {
602
+ const signature = "requireCollectionRole(collectionIdOf, minRole)";
603
+ requireSelector(signature, "collectionIdOf", "collection id", collectionIdOf);
604
+ requireRung(signature, "minRole", COLLECTION_ROLES, minRole);
605
+ return inertAuthorize("requireCollectionRole");
606
+ }
607
+ export function requireDocumentOwner(documentIdOf) {
608
+ requireSelector("requireDocumentOwner(documentIdOf)", "documentIdOf", "document id", documentIdOf);
609
+ return inertAuthorize("requireDocumentOwner");
610
+ }
611
+ // #5843 — the db3 helpers, refused with the baked SDK's sentences.
612
+ const DB3_LEVELS = ["owner", "read-write", "reader"];
613
+ function requireDb3Type(signature, type) {
614
+ if (type !== undefined && (typeof type !== "string" || type.length === 0)) {
615
+ throw new TypeError(
616
+ signature + ": type must be a db3 type name (a non-empty string) or omitted, not " + JSON.stringify(type)
617
+ );
308
618
  }
309
- return keyOrHandler;
619
+ }
620
+ export function requirePublicDb3(db3IdOf, type) {
621
+ const signature = "requirePublicDb3(db3IdOf, type)";
622
+ requireSelector(signature, "db3IdOf", "db3 id", db3IdOf);
623
+ requireDb3Type(signature, type);
624
+ return inertAuthorize("requirePublicDb3");
625
+ }
626
+ // #5849 — the action-token helper, refused with the baked SDK's sentence.
627
+ export function requireToken(tokenOf) {
628
+ requireSelector("requireToken(tokenOf)", "tokenOf", "token", tokenOf);
629
+ return inertAuthorize("requireToken");
630
+ }
631
+ export function requireDb3Level(db3IdOf, type, minLevel, options) {
632
+ const signature = "requireDb3Level(db3IdOf, type, minLevel, options)";
633
+ requireSelector(signature, "db3IdOf", "db3 id", db3IdOf);
634
+ requireDb3Type(signature, type);
635
+ requireRung(signature, "minLevel", DB3_LEVELS, minLevel);
636
+ if (options !== undefined && (options === null || typeof options !== "object" || Array.isArray(options))) {
637
+ throw new TypeError(signature + ": options must be an object, such as { orPublic: true }");
638
+ }
639
+ for (const name of Object.keys(options || {})) {
640
+ if (name !== "orPublic") {
641
+ throw new TypeError(signature + ": unknown option '" + name + "'; the options take orPublic");
642
+ }
643
+ }
644
+ const orPublic = options ? options.orPublic : undefined;
645
+ if (orPublic !== undefined && typeof orPublic !== "boolean") {
646
+ throw new TypeError(signature + ": orPublic must be a boolean");
647
+ }
648
+ if (orPublic === true && minLevel !== "reader") {
649
+ throw new TypeError(
650
+ signature + ': orPublic: true needs minLevel "reader", because public access admits readers only, not ' +
651
+ JSON.stringify(minLevel)
652
+ );
653
+ }
654
+ return inertAuthorize("requireDb3Level");
655
+ }
656
+ // #5848 — refused with the baked SDK's sentence.
657
+ export function requireInvitation(tokenOf) {
658
+ requireSelector("requireInvitation(tokenOf)", "tokenOf", "invite token", tokenOf);
659
+ return inertAuthorize("requireInvitation");
660
+ }
661
+ export function allowCallers(rules) {
662
+ const signature = "allowCallers(rules)";
663
+ if (rules === null || typeof rules !== "object" || Array.isArray(rules)) {
664
+ throw new TypeError(signature + ": rules must be an object");
665
+ }
666
+ for (const name of Object.keys(rules)) {
667
+ if (!CALLER_KEYS.includes(name)) {
668
+ throw new TypeError(
669
+ signature + ": unknown key '" + name +
670
+ "'; the rules take webhook, cron, manual, functions, agents, users, db3 and usersBatch"
671
+ );
672
+ }
673
+ }
674
+ for (const name of ["webhook", "cron", "manual", "db3"]) {
675
+ if (rules[name] !== undefined && typeof rules[name] !== "boolean") {
676
+ throw new TypeError(signature + ": " + name + " must be a boolean");
677
+ }
678
+ }
679
+ const usersBatch = rules.usersBatch;
680
+ if (
681
+ usersBatch !== undefined &&
682
+ typeof usersBatch !== "boolean" &&
683
+ (!Array.isArray(usersBatch) || usersBatch.some((key) => typeof key !== "string" || key.length === 0))
684
+ ) {
685
+ throw new TypeError(signature + ": usersBatch must be true, false or an array of function keys");
686
+ }
687
+ const functions = rules.functions;
688
+ if (
689
+ functions !== undefined &&
690
+ (!Array.isArray(functions) || functions.some((key) => typeof key !== "string" || key.length === 0))
691
+ ) {
692
+ throw new TypeError(signature + ": functions must be an array of function keys");
693
+ }
694
+ if (rules.agents !== undefined && typeof rules.agents !== "boolean" && typeof rules.agents !== "function") {
695
+ throw new TypeError(signature + ": agents must be true, false or an authorize function");
696
+ }
697
+ if (rules.users !== undefined && typeof rules.users !== "function") {
698
+ throw new TypeError(signature + ": users must be an authorize function, such as requireSignedIn()");
699
+ }
700
+ // #5843 — the rule that answers an HTTP call: the \`users\` arm's own, or
701
+ // none. Kept on a field of its own; the merged families and sources below
702
+ // feed the manifest unchanged.
703
+ const http = typeof rules.users === "function" ? httpRuleOf(markerOf(rules.users)) : null;
704
+ const arms = [rules.users, rules.agents].filter((arm) => typeof arm === "function").map(markerOf);
705
+ const families = HELPER_FAMILIES.allowCallers.slice();
706
+ const sources = [];
707
+ for (const arm of arms) {
708
+ families.push(...(arm.families || []));
709
+ sources.push(...(arm.sources || []));
710
+ }
711
+ return inertAuthorize("allowCallers", {
712
+ public: arms.some((arm) => arm.helper === "allowAnyone"),
713
+ callers: {
714
+ webhook: rules.webhook === true,
715
+ cron: rules.cron === true,
716
+ manual: rules.manual === true,
717
+ functions: Array.isArray(functions) ? functions.map(String) : [],
718
+ agents: rules.agents === true ? true : typeof rules.agents === "function" ? "rule" : false,
719
+ users: typeof rules.users === "function" ? "rule" : false,
720
+ db3: rules.db3 === true,
721
+ usersBatch: Array.isArray(usersBatch) ? usersBatch.map(String) : usersBatch === true,
722
+ },
723
+ families,
724
+ sources,
725
+ http,
726
+ });
310
727
  }
311
728
  export function pMap(items, mapper) { return Promise.all((items || []).map(mapper)); }
312
729
  export function ulid() { return "00000000000000000000000000"; }
730
+ // #5225 — the vector codec is pure, but collection writes no record: inert like \`ulid\`.
731
+ export function encodeVector() { return ""; }
732
+ export function decodeVector() { return new Float32Array(0); }
733
+ export function vectorBytes() { return new Uint8Array(0); }
734
+ // #5899 — the JSON field codec is pure too, and inert here like the vector codec.
735
+ export function encodeDb3Json() { return "{}"; }
736
+ export function decodeDb3Json() { return {}; }
313
737
  export const stepPolicy = new Proxy({}, { get: () => ({}) });
314
738
  // #3482 — the runtime surface, and \`assertRuntime\` is INERT here on purpose.
315
739
  // Collection has no runtime: this child process exists to learn what a tree
@@ -331,10 +755,29 @@ export class FunctionRuntimeError extends Error {
331
755
  export default {
332
756
  SDK_STUB_VERSION,
333
757
  defineFunction,
758
+ allow,
759
+ deny,
760
+ fail,
761
+ allowAnyone,
762
+ allowCallers,
763
+ requireSignedIn,
764
+ requireRole,
765
+ requireMember,
766
+ requireCollectionRole,
767
+ requireDocumentOwner,
768
+ requirePublicDb3,
769
+ requireDb3Level,
770
+ requireToken,
771
+ requireInvitation,
334
772
  defineQuery,
335
773
  defineMutation,
336
774
  pMap,
337
775
  ulid,
776
+ encodeVector,
777
+ decodeVector,
778
+ vectorBytes,
779
+ encodeDb3Json,
780
+ decodeDb3Json,
338
781
  assertRuntime,
339
782
  assertTrigger,
340
783
  FunctionRuntimeError,
@@ -380,8 +823,61 @@ function handlerOf(mod) {
380
823
  const exported = handlerOf(entry);
381
824
  const exportedKey =
382
825
  exported && typeof exported.functionKey === "string" ? exported.functionKey : null;
826
+ // #4717 — whether that same callable carries \`authorize\`: the object
827
+ // form's wrapper does. Reported beside the key, never in the manifest.
828
+ const authorize = !!exported && typeof exported.authorize === "function";
829
+ // #4730 — what the manifest's \`authorize\` block records: the helper
830
+ // marker the stub attached, or the hand-written function's own text.
831
+ let authorizeCollect = null;
832
+ if (authorize) {
833
+ const marker = exported.authorize.__collect;
834
+ if (marker && typeof marker === "object") {
835
+ authorizeCollect = marker;
836
+ } else {
837
+ let text = "";
838
+ try {
839
+ text = String(Function.prototype.toString.call(exported.authorize));
840
+ } catch {}
841
+ authorizeCollect = {
842
+ helper: null,
843
+ public: false,
844
+ callers: null,
845
+ families: [],
846
+ sources: [text.slice(0, ${AUTHORIZE_SOURCE_SCAN_CAP})],
847
+ };
848
+ }
849
+ }
850
+ // #5843 — the rule that answers an HTTP call ({ helper, sources }, or
851
+ // null when none does), and the handler's own text, for the public-db3
852
+ // lint. Reported beside the manifest, never in it.
853
+ let httpAuthorize = null;
854
+ if (authorizeCollect) {
855
+ httpAuthorize =
856
+ authorizeCollect.helper === "allowCallers"
857
+ ? (authorizeCollect.http === undefined ? null : authorizeCollect.http)
858
+ : { helper: authorizeCollect.helper, sources: authorizeCollect.sources || [] };
859
+ }
860
+ let handlerSource = "";
861
+ try {
862
+ const handler = exported && typeof exported.__collectHandler === "function" ? exported.__collectHandler : exported;
863
+ if (typeof handler === "function") {
864
+ handlerSource = String(Function.prototype.toString.call(handler)).slice(0, ${AUTHORIZE_SOURCE_SCAN_CAP});
865
+ }
866
+ } catch {}
867
+ // #5904 — the object form's \`input\` list, for the overlap lint: an array
868
+ // of strings, bounded as the push probe bounds it, or null. Reported
869
+ // beside the manifest, never in it.
870
+ let input = null;
871
+ try {
872
+ const listed = authorize ? exported.input : undefined;
873
+ if (Array.isArray(listed) && listed.every((key) => typeof key === "string")) {
874
+ input = listed.slice(0, ${PROBE_INPUT_CAP}).map((key) => key.slice(0, ${PROBE_INPUT_CAP}));
875
+ }
876
+ } catch {}
383
877
  process.stdout.write(
384
- sentinel + JSON.stringify({ ok: true, registry, exportedKey }) + "\\n"
878
+ sentinel +
879
+ JSON.stringify({ ok: true, registry, exportedKey, authorize, authorizeCollect, input, httpAuthorize, handlerSource }) +
880
+ "\\n"
385
881
  );
386
882
  } catch (error) {
387
883
  process.stdout.write(
@@ -470,6 +966,14 @@ async function buildCollectBundle(options) {
470
966
  * of the envelope, so "later" would mean a different version).
471
967
  */
472
968
  export async function collectFunctionManifest(options) {
969
+ return (await collectFunction(options)).manifest;
970
+ }
971
+ /**
972
+ * Collect one function's manifest and its local `authorize` answer (#4717),
973
+ * from the one run of its module scope. Throws as `collectFunctionManifest`
974
+ * does.
975
+ */
976
+ export async function collectFunction(options) {
473
977
  const treeRoot = resolve(options.configDir);
474
978
  const timeoutMs = options.timeoutMs ?? COLLECT_TIMEOUT_MS;
475
979
  const code = await buildCollectBundle({
@@ -494,12 +998,41 @@ export async function collectFunctionManifest(options) {
494
998
  throw new FunctionCollectError(`function '${options.functionKey}': manifest collection failed while ` +
495
999
  `running the tree's module scope: ${framed.error}`);
496
1000
  }
497
- return manifestFrom(framed.registry ?? [], options.functionKey, scanBundleForManifest(options.bundle ?? code), framed.exportedKey ?? null);
1001
+ return {
1002
+ manifest: manifestFrom(framed.registry ?? [], options.functionKey, scanBundleForManifest(options.bundle ?? code), framed.exportedKey ?? null, framed.authorize === true ? framed.authorizeCollect ?? null : undefined),
1003
+ authorize: framed.authorize === true,
1004
+ input: framed.authorize === true ? inputListFrom(framed.input) : null,
1005
+ authorizeSources: framed.authorize === true && Array.isArray(framed.authorizeCollect?.sources)
1006
+ ? framed.authorizeCollect.sources.filter((text) => typeof text === "string" && text !== "")
1007
+ : [],
1008
+ httpAuthorize: framed.authorize === true ? httpAuthorizeFrom(framed.httpAuthorize) : null,
1009
+ handlerSource: typeof framed.handlerSource === "string" ? framed.handlerSource.slice(0, AUTHORIZE_SOURCE_SCAN_CAP) : "",
1010
+ };
498
1011
  }
499
1012
  finally {
500
1013
  rmSync(scratch, { recursive: true, force: true });
501
1014
  }
502
1015
  }
1016
+ /** The reported HTTP rule, normalized; null for anything that is not one (#5843). */
1017
+ function httpAuthorizeFrom(value) {
1018
+ if (!value || typeof value !== "object")
1019
+ return null;
1020
+ const raw = value;
1021
+ return {
1022
+ helper: typeof raw.helper === "string" ? raw.helper : null,
1023
+ sources: Array.isArray(raw.sources)
1024
+ ? raw.sources
1025
+ .filter((text) => typeof text === "string" && text !== "")
1026
+ .map((text) => text.slice(0, AUTHORIZE_SOURCE_SCAN_CAP))
1027
+ : [],
1028
+ };
1029
+ }
1030
+ /** The reported list when it is an array of strings, otherwise null. */
1031
+ function inputListFrom(value) {
1032
+ if (!Array.isArray(value) || !value.every((key) => typeof key === "string"))
1033
+ return null;
1034
+ return value.slice(0, PROBE_INPUT_CAP).map((key) => key.slice(0, PROBE_INPUT_CAP));
1035
+ }
503
1036
  function runCollectChild(options) {
504
1037
  return new Promise((resolvePromise, rejectPromise) => {
505
1038
  const child = spawn(process.execPath, [options.runnerPath, options.bundlePath], {
@@ -550,7 +1083,7 @@ function runCollectChild(options) {
550
1083
  });
551
1084
  }
552
1085
  /** Normalize and validate what the child recorded, and merge in the scan. */
553
- function manifestFrom(registry, functionKey, scanned, exportedKey) {
1086
+ function manifestFrom(registry, functionKey, scanned, exportedKey, authorizeCollect) {
554
1087
  // #3281 — the key the entry's EXPORTED handler carries. The compiler holds
555
1088
  // the key to the TREE (an undeclared key does not compile); this holds it to
556
1089
  // the FILE, before any request is made, with the runtime value — a key
@@ -603,12 +1136,68 @@ function manifestFrom(registry, functionKey, scanned, exportedKey) {
603
1136
  for (const query of queries)
604
1137
  for (const model of query.models)
605
1138
  models.add(model);
606
- return {
1139
+ const manifest = {
607
1140
  schemaVersion: FUNCTION_MANIFEST_SCHEMA_VERSION,
608
1141
  queries,
609
1142
  models: [...models].sort(),
610
1143
  families: scanned.families,
611
1144
  dynamicModels: scanned.dynamicModels,
612
1145
  };
1146
+ // #4730 — a flagged build's version 3. `undefined` is a bare handler, which
1147
+ // keeps the version-2 document above byte for byte.
1148
+ if (authorizeCollect === undefined)
1149
+ return manifest;
1150
+ return {
1151
+ ...manifest,
1152
+ schemaVersion: FUNCTION_MANIFEST_AUTHORIZE_SCHEMA_VERSION,
1153
+ writeFamilies: scanned.writeFamilies ?? [],
1154
+ authorize: authorizeBlockFrom(authorizeCollect),
1155
+ };
1156
+ }
1157
+ /**
1158
+ * Normalize what the child reported into the manifest's `authorize` block.
1159
+ *
1160
+ * The marker comes from the tenant's own module scope, so it is honest-code
1161
+ * evidence like the rest of the manifest: anything outside the grammar's
1162
+ * vocabulary is dropped here rather than refused at the server.
1163
+ */
1164
+ function authorizeBlockFrom(collected) {
1165
+ const helpers = AUTHORIZE_HELPERS;
1166
+ const helper = collected && typeof collected.helper === "string" && helpers.includes(collected.helper)
1167
+ ? collected.helper
1168
+ : null;
1169
+ const known = new Set(AUTH_FAMILIES);
1170
+ const families = new Set((Array.isArray(collected?.families) ? collected.families : []).filter((f) => known.has(String(f))));
1171
+ const sources = Array.isArray(collected?.sources) ? collected.sources.map(String) : [];
1172
+ for (const family of scanAuthorizeSources(sources))
1173
+ families.add(family);
1174
+ const raw = helper === "allowCallers" ? collected?.callers : null;
1175
+ const callers = raw && typeof raw === "object"
1176
+ ? {
1177
+ webhook: raw.webhook === true,
1178
+ cron: raw.cron === true,
1179
+ manual: raw.manual === true,
1180
+ functions: [
1181
+ ...new Set((Array.isArray(raw.functions) ? raw.functions : []).map(String)),
1182
+ ].sort(),
1183
+ agents: (raw.agents === true ? true : raw.agents === "rule" ? "rule" : false),
1184
+ users: (raw.users === "rule" ? "rule" : false),
1185
+ // #4803 — written only when the door is open, so a manifest that
1186
+ // admits no db3 flush is byte-identical to one built before the
1187
+ // door existed; a reader takes absent as closed.
1188
+ ...(raw.db3 === true ? { db3: true } : {}),
1189
+ // #5393 — the same rule for a users walk's batch door: `true`, or
1190
+ // the walks' starting functions, deduplicated and sorted; absent
1191
+ // when closed (no rule, `false`, or an empty list).
1192
+ ...usersBatchDoor(raw.usersBatch),
1193
+ }
1194
+ : null;
1195
+ return {
1196
+ present: true,
1197
+ public: helper !== null && collected?.public === true,
1198
+ helper,
1199
+ callers,
1200
+ families: [...families].sort(),
1201
+ };
613
1202
  }
614
1203
  //# sourceMappingURL=function-collect.js.map