@cosmicdrift/kumiko-framework 0.387.0 → 0.389.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/AGENTS.md +9 -1
  2. package/agents/examples/anonymous-access.md +1 -1
  3. package/agents/examples/apex-landing.md +204 -0
  4. package/agents/examples/api-worker-split.md +64 -0
  5. package/agents/examples/app-config.md +14 -0
  6. package/agents/examples/auth-mfa.md +115 -0
  7. package/agents/examples/env-composition.md +28 -1
  8. package/agents/examples/golden-path.md +13 -1
  9. package/agents/examples/legal-pages.md +1 -1
  10. package/agents/examples/lifecycle-hooks.md +55 -2
  11. package/agents/examples/list-table-options.md +466 -0
  12. package/agents/examples/pdf-audit-export.md +4 -2
  13. package/agents/examples/prod-boot-options.md +16 -0
  14. package/agents/examples/rate-limiting.md +48 -0
  15. package/agents/examples/record-detail-layout.md +692 -0
  16. package/agents/examples/seed-migration.md +212 -0
  17. package/agents/examples/state-machine.md +3 -2
  18. package/agents/examples/tenant-isolation.md +73 -1
  19. package/agents/examples/wizard-form.md +941 -0
  20. package/agents/examples/writeform-section.md +548 -0
  21. package/agents/examples.md +1 -0
  22. package/agents/features.md +19 -2
  23. package/agents/widgets.md +2 -0
  24. package/dist/api/api-constants.d.ts +1 -0
  25. package/dist/api/api-constants.js +2 -0
  26. package/dist/api/auth-routes-shared.d.ts +2 -0
  27. package/dist/api/auth-routes-shared.js +5 -0
  28. package/dist/api/client-error-route.js +10 -5
  29. package/dist/api/entity-read-access.d.ts +2 -1
  30. package/dist/api/entity-read-access.js +14 -0
  31. package/dist/api/export/export-cells-reference.d.ts +9 -0
  32. package/dist/api/export/export-cells-reference.js +21 -0
  33. package/dist/api/export/export-cells.d.ts +11 -0
  34. package/dist/api/export/export-cells.js +136 -0
  35. package/dist/api/export/export-ciphertext-guard.d.ts +2 -0
  36. package/dist/api/export/export-ciphertext-guard.js +27 -0
  37. package/dist/api/export/export-columns.d.ts +29 -0
  38. package/dist/api/export/export-columns.js +85 -0
  39. package/dist/api/export/export-errors.d.ts +4 -0
  40. package/dist/api/export/export-errors.js +14 -0
  41. package/dist/api/export/export-route.d.ts +4 -0
  42. package/dist/api/export/export-route.js +74 -0
  43. package/dist/api/export/export-rows.d.ts +13 -0
  44. package/dist/api/export/export-rows.js +62 -0
  45. package/dist/api/export/export-screen.d.ts +12 -0
  46. package/dist/api/export/export-screen.js +47 -0
  47. package/dist/api/export/export-xlsx-writer.d.ts +4 -0
  48. package/dist/api/export/export-xlsx-writer.js +21 -0
  49. package/dist/api/extra-route.d.ts +4 -0
  50. package/dist/api/index.d.ts +3 -1
  51. package/dist/api/index.js +3 -1
  52. package/dist/api/pii-leak-guard.d.ts +3 -0
  53. package/dist/api/pii-leak-guard.js +3 -2
  54. package/dist/api/request-context.d.ts +1 -1
  55. package/dist/api/request-context.js +1 -1
  56. package/dist/api/routes.d.ts +16 -0
  57. package/dist/api/routes.js +2 -2
  58. package/dist/api/server-boot-checks.d.ts +10 -0
  59. package/dist/api/server-boot-checks.js +157 -0
  60. package/dist/api/server-event-dispatcher.d.ts +26 -0
  61. package/dist/api/server-event-dispatcher.js +208 -0
  62. package/dist/api/server-extra-routes.d.ts +11 -0
  63. package/dist/api/server-extra-routes.js +206 -0
  64. package/dist/api/server-middleware.d.ts +20 -0
  65. package/dist/api/server-middleware.js +211 -0
  66. package/dist/api/server-routes.d.ts +19 -0
  67. package/dist/api/server-routes.js +299 -0
  68. package/dist/api/server-websocket-routes.d.ts +4 -0
  69. package/dist/api/server-websocket-routes.js +108 -0
  70. package/dist/api/server-wiring.d.ts +32 -0
  71. package/dist/api/server-wiring.js +238 -0
  72. package/dist/api/server.d.ts +10 -15
  73. package/dist/api/server.js +48 -1251
  74. package/dist/api/session-cookies.js +4 -4
  75. package/dist/api/sse-route.d.ts +2 -1
  76. package/dist/api/sse-route.js +27 -13
  77. package/dist/config/index.d.ts +3 -1
  78. package/dist/crypto/owner-transition-rekey.d.ts +5 -1
  79. package/dist/crypto/owner-transition-rekey.js +1 -1
  80. package/dist/crypto/pg-kms-adapter.d.ts +1 -0
  81. package/dist/crypto/pg-kms-adapter.js +12 -18
  82. package/dist/crypto/pii-field-encryption.d.ts +5 -1
  83. package/dist/crypto/pii-field-encryption.js +3 -1
  84. package/dist/db/aggregate-sql.d.ts +23 -0
  85. package/dist/db/aggregate-sql.js +165 -0
  86. package/dist/db/closed-connection.d.ts +9 -0
  87. package/dist/db/closed-connection.js +88 -0
  88. package/dist/db/connection.d.ts +4 -5
  89. package/dist/db/connection.js +29 -20
  90. package/dist/db/dialect.js +1 -1
  91. package/dist/db/distinct-on.d.ts +1 -1
  92. package/dist/db/driver-row-coercion.d.ts +2 -0
  93. package/dist/db/driver-row-coercion.js +186 -0
  94. package/dist/db/driver-value-preparation.d.ts +16 -0
  95. package/dist/db/driver-value-preparation.js +101 -0
  96. package/dist/db/entity-field-encryption.d.ts +1 -0
  97. package/dist/db/entity-field-encryption.js +1 -1
  98. package/dist/db/entity-table-meta.js +103 -110
  99. package/dist/db/event-store-executor-context.d.ts +2 -1
  100. package/dist/db/event-store-executor-read-aggregate-currencies.d.ts +17 -0
  101. package/dist/db/event-store-executor-read-aggregate-currencies.js +40 -0
  102. package/dist/db/event-store-executor-read-aggregate.d.ts +8 -0
  103. package/dist/db/event-store-executor-read-aggregate.js +143 -0
  104. package/dist/db/event-store-executor-read-filter.d.ts +31 -0
  105. package/dist/db/event-store-executor-read-filter.js +206 -0
  106. package/dist/db/event-store-executor-read-paging.d.ts +14 -0
  107. package/dist/db/event-store-executor-read-paging.js +99 -0
  108. package/dist/db/event-store-executor-read-rows.d.ts +6 -0
  109. package/dist/db/event-store-executor-read-rows.js +32 -0
  110. package/dist/db/event-store-executor-read-search.d.ts +28 -0
  111. package/dist/db/event-store-executor-read-search.js +221 -0
  112. package/dist/db/event-store-executor-read-sort.d.ts +41 -0
  113. package/dist/db/event-store-executor-read-sort.js +130 -0
  114. package/dist/db/event-store-executor-read-where.d.ts +24 -0
  115. package/dist/db/event-store-executor-read-where.js +81 -0
  116. package/dist/db/event-store-executor-read.d.ts +2 -9
  117. package/dist/db/event-store-executor-read.js +48 -701
  118. package/dist/db/event-store-executor-write-atomic.d.ts +4 -0
  119. package/dist/db/event-store-executor-write-atomic.js +41 -0
  120. package/dist/db/event-store-executor-write-steps.d.ts +17 -0
  121. package/dist/db/event-store-executor-write-steps.js +95 -0
  122. package/dist/db/event-store-executor-write.js +405 -509
  123. package/dist/db/event-store-executor.js +2 -1
  124. package/dist/db/executor-managed-tables.js +1 -1
  125. package/dist/db/index.d.ts +7 -3
  126. package/dist/db/index.js +6 -2
  127. package/dist/db/list-aggregate-labels.d.ts +14 -0
  128. package/dist/db/list-aggregate-labels.js +26 -0
  129. package/dist/db/migrate-generator.js +71 -86
  130. package/dist/db/migrate-runner.js +7 -4
  131. package/dist/db/pg-error.js +26 -21
  132. package/dist/db/queries/backfill-pii.js +3 -6
  133. package/dist/db/queries/database-now.js +2 -1
  134. package/dist/db/queries/shadow-swap.js +2 -3
  135. package/dist/db/query.d.ts +16 -15
  136. package/dist/db/query.js +76 -804
  137. package/dist/db/reference-data.js +19 -2
  138. package/dist/db/statement-timeout.js +2 -1
  139. package/dist/db/table-builder.js +113 -166
  140. package/dist/db/table-info.d.ts +10 -0
  141. package/dist/db/table-info.js +45 -0
  142. package/dist/db/temporal-value-guards.d.ts +6 -0
  143. package/dist/db/temporal-value-guards.js +15 -0
  144. package/dist/db/tenant-db-runner.d.ts +1 -0
  145. package/dist/db/tenant-db-runner.js +3 -0
  146. package/dist/db/tenant-db-upsert.d.ts +5 -0
  147. package/dist/db/tenant-db-upsert.js +91 -0
  148. package/dist/db/tenant-db.js +50 -10
  149. package/dist/db/where-clause.d.ts +6 -0
  150. package/dist/db/where-clause.js +236 -0
  151. package/dist/derivatives/delete-stored-file.js +2 -1
  152. package/dist/engine/boot-validator/boot-check.js +1 -1
  153. package/dist/engine/boot-validator/bundled-lists-table.d.ts +2 -0
  154. package/dist/engine/boot-validator/bundled-lists-table.js +36 -0
  155. package/dist/engine/boot-validator/detail-screens.js +2 -2
  156. package/dist/engine/boot-validator/entity-handler.d.ts +1 -0
  157. package/dist/engine/boot-validator/entity-handler.js +17 -0
  158. package/dist/engine/boot-validator/entity-list-aggregate-options.d.ts +3 -0
  159. package/dist/engine/boot-validator/entity-list-aggregate-options.js +23 -0
  160. package/dist/engine/boot-validator/form-derivations.js +35 -1
  161. package/dist/engine/boot-validator/i18n-keys.js +5 -3
  162. package/dist/engine/boot-validator/index.js +2 -0
  163. package/dist/engine/boot-validator/list-bulk-actions.d.ts +3 -0
  164. package/dist/engine/boot-validator/list-bulk-actions.js +49 -0
  165. package/dist/engine/boot-validator/list-column-layout.d.ts +8 -0
  166. package/dist/engine/boot-validator/list-column-layout.js +41 -0
  167. package/dist/engine/boot-validator/list-table-aggregate-options.d.ts +24 -0
  168. package/dist/engine/boot-validator/list-table-aggregate-options.js +145 -0
  169. package/dist/engine/boot-validator/list-table-aggregate-query.d.ts +10 -0
  170. package/dist/engine/boot-validator/list-table-aggregate-query.js +31 -0
  171. package/dist/engine/boot-validator/list-table-export-options.d.ts +1 -0
  172. package/dist/engine/boot-validator/list-table-export-options.js +27 -0
  173. package/dist/engine/boot-validator/list-table-options.d.ts +3 -0
  174. package/dist/engine/boot-validator/list-table-options.js +77 -0
  175. package/dist/engine/boot-validator/list-table-reject-unknown-keys.d.ts +1 -0
  176. package/dist/engine/boot-validator/list-table-reject-unknown-keys.js +7 -0
  177. package/dist/engine/boot-validator/pii-retention.js +233 -155
  178. package/dist/engine/boot-validator/projection-list-screens.d.ts +1 -1
  179. package/dist/engine/boot-validator/projection-list-screens.js +3 -13
  180. package/dist/engine/boot-validator/related-list-table-rules.d.ts +4 -0
  181. package/dist/engine/boot-validator/related-list-table-rules.js +42 -0
  182. package/dist/engine/boot-validator/screens-actions.d.ts +1 -0
  183. package/dist/engine/boot-validator/screens-actions.js +8 -1
  184. package/dist/engine/boot-validator/screens-dashboard.js +2 -5
  185. package/dist/engine/boot-validator/screens-forms.js +2 -6
  186. package/dist/engine/boot-validator/screens-kind-config-edit.d.ts +3 -0
  187. package/dist/engine/boot-validator/screens-kind-config-edit.js +88 -0
  188. package/dist/engine/boot-validator/screens-kind-entity-edit.d.ts +3 -0
  189. package/dist/engine/boot-validator/screens-kind-entity-edit.js +55 -0
  190. package/dist/engine/boot-validator/screens-kind-entity-list.d.ts +3 -0
  191. package/dist/engine/boot-validator/screens-kind-entity-list.js +235 -0
  192. package/dist/engine/boot-validator/screens-kind-projection-detail.d.ts +3 -0
  193. package/dist/engine/boot-validator/screens-kind-projection-detail.js +235 -0
  194. package/dist/engine/boot-validator/screens-kind-projection-list.d.ts +3 -0
  195. package/dist/engine/boot-validator/screens-kind-projection-list.js +56 -0
  196. package/dist/engine/boot-validator/screens-kind-secret-mint.d.ts +3 -0
  197. package/dist/engine/boot-validator/screens-kind-secret-mint.js +28 -0
  198. package/dist/engine/boot-validator/screens-kind-shared.d.ts +37 -0
  199. package/dist/engine/boot-validator/screens-kind-shared.js +142 -0
  200. package/dist/engine/boot-validator/screens-lists.d.ts +2 -1
  201. package/dist/engine/boot-validator/screens-lists.js +24 -11
  202. package/dist/engine/boot-validator/screens.d.ts +0 -2
  203. package/dist/engine/boot-validator/screens.js +99 -860
  204. package/dist/engine/build-app-schema.d.ts +2 -1
  205. package/dist/engine/build-app-schema.js +65 -97
  206. package/dist/engine/build-config-feature-schema.js +6 -1
  207. package/dist/engine/define-feature.js +13 -2
  208. package/dist/engine/define-handler.js +1 -0
  209. package/dist/engine/entity-handlers.d.ts +13 -0
  210. package/dist/engine/entity-handlers.js +10 -21
  211. package/dist/engine/entity-list-runtime-options.d.ts +8 -0
  212. package/dist/engine/entity-list-runtime-options.js +18 -0
  213. package/dist/engine/feature-ast/extractors/handlers.js +1 -0
  214. package/dist/engine/feature-ast/extractors/index.d.ts +1 -1
  215. package/dist/engine/feature-ast/extractors/index.js +1 -1
  216. package/dist/engine/feature-ast/extractors/round1.d.ts +2 -1
  217. package/dist/engine/feature-ast/extractors/round1.js +6 -0
  218. package/dist/engine/feature-ast/extractors/round2.js +25 -6
  219. package/dist/engine/feature-ast/index.d.ts +1 -1
  220. package/dist/engine/feature-ast/parse.js +3 -1
  221. package/dist/engine/feature-ast/patch.d.ts +2 -0
  222. package/dist/engine/feature-ast/patch.js +5 -182
  223. package/dist/engine/feature-ast/pattern-change-schema.d.ts +10 -245
  224. package/dist/engine/feature-ast/pattern-change-schema.js +10 -163
  225. package/dist/engine/feature-ast/pattern-id-matchers.d.ts +7 -0
  226. package/dist/engine/feature-ast/pattern-id-matchers.js +211 -0
  227. package/dist/engine/feature-ast/pattern-id-schema.d.ts +251 -0
  228. package/dist/engine/feature-ast/pattern-id-schema.js +166 -0
  229. package/dist/engine/feature-ast/patterns.d.ts +14 -1
  230. package/dist/engine/feature-ast/patterns.js +44 -51
  231. package/dist/engine/feature-ast/render.js +52 -87
  232. package/dist/engine/feature-builder-state.d.ts +1 -0
  233. package/dist/engine/feature-builder-state.js +1 -0
  234. package/dist/engine/feature-entity-handlers.js +3 -0
  235. package/dist/engine/feature-manifest.d.ts +1 -0
  236. package/dist/engine/feature-manifest.js +1 -0
  237. package/dist/engine/field-access.d.ts +1 -0
  238. package/dist/engine/field-access.js +12 -0
  239. package/dist/engine/form-derivations.js +18 -7
  240. package/dist/engine/handler-field-references.js +1 -1
  241. package/dist/engine/index.d.ts +2 -2
  242. package/dist/engine/index.js +1 -1
  243. package/dist/engine/pattern-library/library.js +2 -1
  244. package/dist/engine/pattern-library/static-schemas.d.ts +1 -0
  245. package/dist/engine/pattern-library/static-schemas.js +9 -0
  246. package/dist/engine/project-app-schema-for-roles.d.ts +2 -0
  247. package/dist/engine/project-app-schema-for-roles.js +6 -4
  248. package/dist/engine/registry-ingest.js +1 -1
  249. package/dist/engine/schema-builder.js +228 -212
  250. package/dist/engine/screen-filter-ops.js +2 -0
  251. package/dist/engine/screen-helpers.js +1 -1
  252. package/dist/engine/screen-kind.d.ts +7 -0
  253. package/dist/engine/screen-kind.js +1 -0
  254. package/dist/engine/strip-disabled-features-from-app-schema.js +58 -17
  255. package/dist/engine/types/feature.d.ts +1 -0
  256. package/dist/engine/types/index.d.ts +4 -3
  257. package/dist/engine/types/screen.d.ts +1 -1
  258. package/dist/engine/types/screen.js +1 -1
  259. package/dist/engine/validate-projection-allowlist.js +2 -1
  260. package/dist/entrypoint/index.d.ts +6 -1
  261. package/dist/entrypoint/index.js +10 -1
  262. package/dist/errors/docs-url.d.ts +1 -1
  263. package/dist/errors/docs-url.js +22 -2
  264. package/dist/es-ops/context.js +1 -1
  265. package/dist/event-store/admin-api.js +1 -1
  266. package/dist/event-store/event-store.d.ts +1 -0
  267. package/dist/event-store/event-store.js +17 -8
  268. package/dist/event-store/provenance-append.js +1 -1
  269. package/dist/files/bind-pending-file-refs.js +3 -3
  270. package/dist/files/create-file-ref-from-bytes.js +7 -1
  271. package/dist/files/create-file-ref.d.ts +3 -0
  272. package/dist/files/create-file-ref.js +11 -2
  273. package/dist/files/file-handle.js +2 -3
  274. package/dist/files/file-routes.d.ts +2 -0
  275. package/dist/files/file-routes.js +40 -10
  276. package/dist/files/provider-resolver.d.ts +1 -0
  277. package/dist/files/provider-resolver.js +1 -1
  278. package/dist/files/record-write-check.d.ts +6 -0
  279. package/dist/files/record-write-check.js +13 -0
  280. package/dist/files/resolve-content-type.js +43 -0
  281. package/dist/files/upload-ledger.d.ts +2 -2
  282. package/dist/files/upload-ledger.js +11 -4
  283. package/dist/i18n/required-surface-keys.js +189 -208
  284. package/dist/internal/stack-support.d.ts +2 -1
  285. package/dist/internal/stack-support.js +1 -1
  286. package/dist/internal/testing.js +1 -1
  287. package/dist/jobs/job-runner-context.d.ts +32 -0
  288. package/dist/jobs/job-runner-context.js +305 -0
  289. package/dist/jobs/job-runner-execution.d.ts +7 -0
  290. package/dist/jobs/job-runner-execution.js +160 -0
  291. package/dist/jobs/job-runner-gates.d.ts +19 -0
  292. package/dist/jobs/job-runner-gates.js +198 -0
  293. package/dist/jobs/job-runner-helpers.d.ts +17 -3
  294. package/dist/jobs/job-runner-helpers.js +61 -2
  295. package/dist/jobs/job-runner-scope.d.ts +44 -0
  296. package/dist/jobs/job-runner-scope.js +102 -0
  297. package/dist/jobs/job-runner-types.d.ts +12 -0
  298. package/dist/jobs/job-runner.d.ts +0 -1
  299. package/dist/jobs/job-runner.js +50 -657
  300. package/dist/observability/escape-hatch-report.d.ts +3 -0
  301. package/dist/observability/escape-hatch-report.js +21 -3
  302. package/dist/pipeline/after-rollback-sink.d.ts +6 -0
  303. package/dist/pipeline/after-rollback-sink.js +32 -0
  304. package/dist/pipeline/cascade-handler.js +165 -138
  305. package/dist/pipeline/dispatch-batch.js +8 -1
  306. package/dist/pipeline/dispatch-query.js +10 -3
  307. package/dist/pipeline/dispatch-shared.d.ts +13 -3
  308. package/dist/pipeline/dispatch-shared.js +62 -710
  309. package/dist/pipeline/dispatch-write.js +296 -189
  310. package/dist/pipeline/event-dispatcher-admin.js +2 -1
  311. package/dist/pipeline/event-dispatcher-delivery.js +6 -6
  312. package/dist/pipeline/event-dispatcher.d.ts +1 -0
  313. package/dist/pipeline/event-dispatcher.js +6 -9
  314. package/dist/pipeline/handler-context-auth.d.ts +9 -0
  315. package/dist/pipeline/handler-context-auth.js +54 -0
  316. package/dist/pipeline/handler-context-config.d.ts +14 -0
  317. package/dist/pipeline/handler-context-config.js +113 -0
  318. package/dist/pipeline/handler-context-db.d.ts +24 -0
  319. package/dist/pipeline/handler-context-db.js +149 -0
  320. package/dist/pipeline/handler-context-dispatch.d.ts +23 -0
  321. package/dist/pipeline/handler-context-dispatch.js +101 -0
  322. package/dist/pipeline/handler-context-events.d.ts +41 -0
  323. package/dist/pipeline/handler-context-events.js +239 -0
  324. package/dist/pipeline/handler-context-notify.d.ts +12 -0
  325. package/dist/pipeline/handler-context-notify.js +55 -0
  326. package/dist/pipeline/handler-context-observability.d.ts +7 -0
  327. package/dist/pipeline/handler-context-observability.js +21 -0
  328. package/dist/pipeline/handler-context-scope.d.ts +48 -0
  329. package/dist/pipeline/handler-context-scope.js +88 -0
  330. package/dist/pipeline/notify-scope.js +12 -1
  331. package/dist/pipeline/pre-handler-gates.js +20 -4
  332. package/dist/pipeline/pre-transaction-reservations.d.ts +1 -0
  333. package/dist/pipeline/pre-transaction-reservations.js +9 -3
  334. package/dist/pipeline/projection-rebuild.js +2 -1
  335. package/dist/pipeline/system-hooks.d.ts +3 -1
  336. package/dist/pipeline/system-hooks.js +55 -6
  337. package/dist/pipeline/write-result-masking.js +13 -10
  338. package/dist/schema-cli/apply-command.d.ts +2 -0
  339. package/dist/schema-cli/apply-command.js +97 -0
  340. package/dist/schema-cli/baseline-command.d.ts +2 -0
  341. package/dist/schema-cli/baseline-command.js +33 -0
  342. package/dist/schema-cli/generate-command.d.ts +2 -0
  343. package/dist/schema-cli/generate-command.js +90 -0
  344. package/dist/schema-cli/shared.d.ts +39 -0
  345. package/dist/schema-cli/shared.js +95 -0
  346. package/dist/schema-cli/status-command.d.ts +2 -0
  347. package/dist/schema-cli/status-command.js +73 -0
  348. package/dist/schema-cli/validate-boot-input.d.ts +5 -0
  349. package/dist/schema-cli/validate-boot-input.js +130 -0
  350. package/dist/schema-cli/validate-command.d.ts +2 -0
  351. package/dist/schema-cli/validate-command.js +130 -0
  352. package/dist/schema-cli.d.ts +2 -18
  353. package/dist/schema-cli.js +47 -604
  354. package/dist/search/meilisearch-adapter.js +2 -1
  355. package/dist/search/reindex-entity.js +15 -5
  356. package/dist/ui-types/index.d.ts +2 -2
  357. package/dist/ui-types/index.js +1 -1
  358. package/dist/upgrade-changelog.d.ts +2 -0
  359. package/dist/upgrade-changelog.js +14 -0
  360. package/dist/upgrade-cli.d.ts +3 -12
  361. package/dist/upgrade-cli.js +171 -197
  362. package/dist/upgrade-marker-parse.d.ts +32 -0
  363. package/dist/upgrade-marker-parse.js +73 -0
  364. package/package.json +9 -6
  365. package/src/changes.json +555 -0
  366. package/src/scripts/codemod/codemod-support.ts +1 -1
  367. package/src/scripts/codemod/db-factory.ts +1 -1
  368. package/src/scripts/codemod/feature-layout.ts +10 -2
  369. package/src/scripts/codemod/object-form.ts +41 -4
  370. package/src/scripts/codemod/package-merge.ts +58 -8
  371. package/src/scripts/codemod/pii-personal-migration.ts +175 -145
  372. package/src/scripts/codemod/testing-injection.ts +122 -42
  373. package/src/scripts/codemod/testing-move.ts +29 -7
  374. package/dist/engine/provider-plugin-context.d.ts +0 -3
  375. package/dist/engine/provider-plugin-context.js +0 -28
@@ -0,0 +1,166 @@
1
+ import * as z from "zod";
2
+ const patternIdEntitySchema = z
3
+ .object({ kind: z.literal("entity"), entityName: z.string() })
4
+ .strict();
5
+ const patternIdRelationSchema = z
6
+ .object({ kind: z.literal("relation"), entityName: z.string(), relationName: z.string() })
7
+ .strict();
8
+ const patternIdNavSchema = z.object({ kind: z.literal("nav"), id: z.string() }).strict();
9
+ const patternIdWorkspaceSchema = z
10
+ .object({ kind: z.literal("workspace"), id: z.string() })
11
+ .strict();
12
+ const patternIdScreenSchema = z.object({ kind: z.literal("screen"), id: z.string() }).strict();
13
+ const patternIdWriteHandlerSchema = z
14
+ .object({ kind: z.literal("writeHandler"), handlerName: z.string() })
15
+ .strict();
16
+ const patternIdQueryHandlerSchema = z
17
+ .object({ kind: z.literal("queryHandler"), handlerName: z.string() })
18
+ .strict();
19
+ const patternIdStreamHandlerSchema = z
20
+ .object({ kind: z.literal("streamHandler"), handlerName: z.string() })
21
+ .strict();
22
+ const patternIdHookSchema = z
23
+ .object({
24
+ kind: z.literal("hook"),
25
+ hookType: z.string(),
26
+ target: z.union([z.string(), z.object({ allOf: z.string() }).strict()]),
27
+ })
28
+ .strict();
29
+ const patternIdMetricSchema = z
30
+ .object({ kind: z.literal("metric"), shortName: z.string() })
31
+ .strict();
32
+ const patternIdSecretSchema = z
33
+ .object({ kind: z.literal("secret"), shortName: z.string() })
34
+ .strict();
35
+ const patternIdSecretNamespaceSchema = z
36
+ .object({ kind: z.literal("secretNamespace"), shortName: z.string() })
37
+ .strict();
38
+ const patternIdClaimKeySchema = z
39
+ .object({ kind: z.literal("claimKey"), shortName: z.string() })
40
+ .strict();
41
+ const patternIdReferenceDataSchema = z
42
+ .object({ kind: z.literal("referenceData"), entityName: z.string() })
43
+ .strict();
44
+ const patternIdUseExtensionSchema = z
45
+ .object({ kind: z.literal("useExtension"), extensionName: z.string(), entityName: z.string() })
46
+ .strict();
47
+ const patternIdJobSchema = z.object({ kind: z.literal("job"), jobName: z.string() }).strict();
48
+ const patternIdNotificationSchema = z
49
+ .object({ kind: z.literal("notification"), notificationName: z.string() })
50
+ .strict();
51
+ const patternIdHttpRouteSchema = z
52
+ .object({ kind: z.literal("httpRoute"), method: z.string(), path: z.string() })
53
+ .strict();
54
+ const patternIdProjectionSchema = z
55
+ .object({ kind: z.literal("projection"), name: z.string() })
56
+ .strict();
57
+ const patternIdMultiStreamProjectionSchema = z
58
+ .object({ kind: z.literal("multiStreamProjection"), name: z.string() })
59
+ .strict();
60
+ const patternIdDefineEventSchema = z
61
+ .object({ kind: z.literal("defineEvent"), eventName: z.string() })
62
+ .strict();
63
+ const patternIdExtendsRegistrarSchema = z
64
+ .object({ kind: z.literal("extendsRegistrar"), extensionName: z.string() })
65
+ .strict();
66
+ const patternIdAiGenerateSchema = z
67
+ .object({ kind: z.literal("ai.generate"), stepKey: z.string() })
68
+ .strict();
69
+ const patternIdAiExtractSchema = z
70
+ .object({ kind: z.literal("ai.extract"), stepKey: z.string() })
71
+ .strict();
72
+ const patternIdAiClassifySchema = z
73
+ .object({ kind: z.literal("ai.classify"), stepKey: z.string() })
74
+ .strict();
75
+ const patternIdRequiresSchema = z.object({ kind: z.literal("requires") }).strict();
76
+ const patternIdOptionalRequiresSchema = z.object({ kind: z.literal("optionalRequires") }).strict();
77
+ const patternIdReadsConfigSchema = z.object({ kind: z.literal("readsConfig") }).strict();
78
+ const patternIdSystemScopeSchema = z.object({ kind: z.literal("systemScope") }).strict();
79
+ const patternIdToggleableSchema = z.object({ kind: z.literal("toggleable") }).strict();
80
+ const patternIdDescribeSchema = z.object({ kind: z.literal("describe") }).strict();
81
+ const patternIdUiHintsSchema = z.object({ kind: z.literal("uiHints") }).strict();
82
+ const patternIdAdoptsBundledListsSchema = z
83
+ .object({ kind: z.literal("adoptsBundledLists") })
84
+ .strict();
85
+ const patternIdConfigSchema = z.object({ kind: z.literal("config") }).strict();
86
+ const patternIdTranslationsSchema = z.object({ kind: z.literal("translations") }).strict();
87
+ const patternIdAuthClaimsSchema = z.object({ kind: z.literal("authClaims") }).strict();
88
+ const patternIdTreeActionsSchema = z.object({ kind: z.literal("treeActions") }).strict();
89
+ export const PATTERN_ID_SCHEMAS_BY_KIND = {
90
+ entity: patternIdEntitySchema,
91
+ relation: patternIdRelationSchema,
92
+ nav: patternIdNavSchema,
93
+ workspace: patternIdWorkspaceSchema,
94
+ screen: patternIdScreenSchema,
95
+ writeHandler: patternIdWriteHandlerSchema,
96
+ queryHandler: patternIdQueryHandlerSchema,
97
+ streamHandler: patternIdStreamHandlerSchema,
98
+ hook: patternIdHookSchema,
99
+ metric: patternIdMetricSchema,
100
+ secret: patternIdSecretSchema,
101
+ secretNamespace: patternIdSecretNamespaceSchema,
102
+ claimKey: patternIdClaimKeySchema,
103
+ referenceData: patternIdReferenceDataSchema,
104
+ useExtension: patternIdUseExtensionSchema,
105
+ job: patternIdJobSchema,
106
+ notification: patternIdNotificationSchema,
107
+ httpRoute: patternIdHttpRouteSchema,
108
+ projection: patternIdProjectionSchema,
109
+ multiStreamProjection: patternIdMultiStreamProjectionSchema,
110
+ defineEvent: patternIdDefineEventSchema,
111
+ extendsRegistrar: patternIdExtendsRegistrarSchema,
112
+ "ai.generate": patternIdAiGenerateSchema,
113
+ "ai.extract": patternIdAiExtractSchema,
114
+ "ai.classify": patternIdAiClassifySchema,
115
+ requires: patternIdRequiresSchema,
116
+ optionalRequires: patternIdOptionalRequiresSchema,
117
+ readsConfig: patternIdReadsConfigSchema,
118
+ systemScope: patternIdSystemScopeSchema,
119
+ toggleable: patternIdToggleableSchema,
120
+ describe: patternIdDescribeSchema,
121
+ uiHints: patternIdUiHintsSchema,
122
+ adoptsBundledLists: patternIdAdoptsBundledListsSchema,
123
+ config: patternIdConfigSchema,
124
+ translations: patternIdTranslationsSchema,
125
+ authClaims: patternIdAuthClaimsSchema,
126
+ treeActions: patternIdTreeActionsSchema,
127
+ };
128
+ export const patternIdSchema = z.discriminatedUnion("kind", [
129
+ patternIdEntitySchema,
130
+ patternIdRelationSchema,
131
+ patternIdNavSchema,
132
+ patternIdWorkspaceSchema,
133
+ patternIdScreenSchema,
134
+ patternIdWriteHandlerSchema,
135
+ patternIdQueryHandlerSchema,
136
+ patternIdStreamHandlerSchema,
137
+ patternIdHookSchema,
138
+ patternIdMetricSchema,
139
+ patternIdSecretSchema,
140
+ patternIdSecretNamespaceSchema,
141
+ patternIdClaimKeySchema,
142
+ patternIdReferenceDataSchema,
143
+ patternIdUseExtensionSchema,
144
+ patternIdJobSchema,
145
+ patternIdNotificationSchema,
146
+ patternIdHttpRouteSchema,
147
+ patternIdProjectionSchema,
148
+ patternIdMultiStreamProjectionSchema,
149
+ patternIdDefineEventSchema,
150
+ patternIdExtendsRegistrarSchema,
151
+ patternIdAiGenerateSchema,
152
+ patternIdAiExtractSchema,
153
+ patternIdAiClassifySchema,
154
+ patternIdRequiresSchema,
155
+ patternIdOptionalRequiresSchema,
156
+ patternIdReadsConfigSchema,
157
+ patternIdSystemScopeSchema,
158
+ patternIdAdoptsBundledListsSchema,
159
+ patternIdToggleableSchema,
160
+ patternIdDescribeSchema,
161
+ patternIdUiHintsSchema,
162
+ patternIdConfigSchema,
163
+ patternIdTranslationsSchema,
164
+ patternIdAuthClaimsSchema,
165
+ patternIdTreeActionsSchema,
166
+ ]);
@@ -18,6 +18,7 @@ export type EntityPattern = {
18
18
  readonly source: SourceLocation;
19
19
  readonly entityName: string;
20
20
  readonly definition: EntityDefinition;
21
+ readonly backingTable?: RawRefSentinel;
21
22
  };
22
23
  export type RelationPattern = {
23
24
  readonly kind: "relation";
@@ -60,6 +61,10 @@ export type SystemScopePattern = {
60
61
  readonly kind: "systemScope";
61
62
  readonly source: SourceLocation;
62
63
  };
64
+ export type AdoptsBundledListsPattern = {
65
+ readonly kind: "adoptsBundledLists";
66
+ readonly source: SourceLocation;
67
+ };
63
68
  export type ToggleablePattern = {
64
69
  readonly kind: "toggleable";
65
70
  readonly source: SourceLocation;
@@ -302,8 +307,16 @@ export type UnknownPattern = {
302
307
  readonly source: SourceLocation;
303
308
  readonly methodName: string;
304
309
  };
305
- export type FeaturePattern = EntityPattern | RelationPattern | NavPattern | WorkspacePattern | ConfigPattern | TranslationsPattern | RequiresPattern | OptionalRequiresPattern | SystemScopePattern | ToggleablePattern | DescribePattern | UiHintsPattern | MetricPattern | SecretPattern | SecretNamespacePattern | ClaimKeyPattern | ReferenceDataPattern | ReadsConfigPattern | UseExtensionPattern | UsesApiPattern | ExposesApiPattern | TreeActionsPattern | ScreenPattern | WriteHandlerPattern | QueryHandlerPattern | StreamHandlerPattern | HookPattern | JobPattern | NotificationPattern | AuthClaimsPattern | HttpRoutePattern | ProjectionPattern | MultiStreamProjectionPattern | DefineEventPattern | ExtendsRegistrarPattern | EnvSchemaPattern | AiGeneratePattern | AiExtractPattern | AiClassifyPattern | UnknownPattern;
310
+ export type FeaturePattern = EntityPattern | RelationPattern | NavPattern | WorkspacePattern | ConfigPattern | TranslationsPattern | RequiresPattern | OptionalRequiresPattern | SystemScopePattern | AdoptsBundledListsPattern | ToggleablePattern | DescribePattern | UiHintsPattern | MetricPattern | SecretPattern | SecretNamespacePattern | ClaimKeyPattern | ReferenceDataPattern | ReadsConfigPattern | UseExtensionPattern | UsesApiPattern | ExposesApiPattern | TreeActionsPattern | ScreenPattern | WriteHandlerPattern | QueryHandlerPattern | StreamHandlerPattern | HookPattern | JobPattern | NotificationPattern | AuthClaimsPattern | HttpRoutePattern | ProjectionPattern | MultiStreamProjectionPattern | DefineEventPattern | ExtendsRegistrarPattern | EnvSchemaPattern | AiGeneratePattern | AiExtractPattern | AiClassifyPattern | UnknownPattern;
306
311
  export type FeaturePatternKind = FeaturePattern["kind"];
312
+ export type MembersByKind<U extends {
313
+ readonly kind: string;
314
+ }> = {
315
+ readonly [K in U["kind"]]: Extract<U, {
316
+ readonly kind: K;
317
+ }>;
318
+ };
319
+ export type FeaturePatternOfKind = MembersByKind<FeaturePattern>;
307
320
  export type Editability = "static" | "mixed" | "opaque";
308
321
  export declare function getEditability(pattern: FeaturePattern): Editability;
309
322
  export {};
@@ -59,56 +59,49 @@
59
59
  // against this constant to decide "form vs read-only span" — the actual
60
60
  // SourceLocation lives at the matching path in `opaqueProps`.
61
61
  export const SCREEN_OPAQUE_MARKER = "$opaque";
62
+ const EDITABILITY_BY_KIND = {
63
+ entity: "static",
64
+ relation: "static",
65
+ nav: "static",
66
+ workspace: "static",
67
+ config: "static",
68
+ translations: "static",
69
+ requires: "static",
70
+ optionalRequires: "static",
71
+ systemScope: "static",
72
+ toggleable: "static",
73
+ describe: "static",
74
+ metric: "static",
75
+ secret: "static",
76
+ secretNamespace: "static",
77
+ claimKey: "static",
78
+ referenceData: "static",
79
+ readsConfig: "static",
80
+ useExtension: "static",
81
+ usesApi: "static",
82
+ exposesApi: "static",
83
+ treeActions: "static",
84
+ screen: "mixed",
85
+ writeHandler: "mixed",
86
+ queryHandler: "mixed",
87
+ streamHandler: "mixed",
88
+ hook: "mixed",
89
+ job: "mixed",
90
+ notification: "mixed",
91
+ httpRoute: "mixed",
92
+ projection: "mixed",
93
+ multiStreamProjection: "mixed",
94
+ defineEvent: "mixed",
95
+ "ai.generate": "mixed",
96
+ "ai.extract": "mixed",
97
+ "ai.classify": "mixed",
98
+ authClaims: "opaque",
99
+ extendsRegistrar: "opaque",
100
+ envSchema: "opaque",
101
+ uiHints: "opaque",
102
+ adoptsBundledLists: "opaque",
103
+ unknown: "opaque",
104
+ };
62
105
  export function getEditability(pattern) {
63
- switch (pattern.kind) {
64
- case "entity":
65
- case "relation":
66
- case "nav":
67
- case "workspace":
68
- case "config":
69
- case "translations":
70
- case "requires":
71
- case "optionalRequires":
72
- case "systemScope":
73
- case "toggleable":
74
- case "describe":
75
- case "metric":
76
- case "secret":
77
- case "secretNamespace":
78
- case "claimKey":
79
- case "referenceData":
80
- case "readsConfig":
81
- case "useExtension":
82
- case "usesApi":
83
- case "exposesApi":
84
- case "treeActions":
85
- return "static";
86
- case "screen":
87
- case "writeHandler":
88
- case "queryHandler":
89
- case "streamHandler":
90
- case "hook":
91
- case "job":
92
- case "notification":
93
- case "httpRoute":
94
- case "projection":
95
- case "multiStreamProjection":
96
- case "defineEvent":
97
- case "ai.generate":
98
- case "ai.extract":
99
- case "ai.classify":
100
- return "mixed";
101
- case "authClaims":
102
- case "extendsRegistrar":
103
- case "envSchema":
104
- case "uiHints":
105
- case "unknown":
106
- return "opaque";
107
- default: {
108
- // Exhaustiveness guard — adding a new pattern kind without
109
- // updating this switch produces a compile error here.
110
- const _exhaustive = pattern;
111
- return _exhaustive;
112
- }
113
- }
106
+ return EDITABILITY_BY_KIND[pattern.kind];
114
107
  }
@@ -30,92 +30,53 @@ export const VERSION_HEADER = `// kumiko-feature-version: ${FEATURE_FILE_VERSION
30
30
  * trailing newline; callers compose statements with their own joiner.
31
31
  */
32
32
  export function renderPattern(pattern) {
33
- switch (pattern.kind) {
34
- case "requires":
35
- return renderRequires(pattern);
36
- case "optionalRequires":
37
- return renderOptionalRequires(pattern);
38
- case "readsConfig":
39
- return renderReadsConfig(pattern);
40
- case "systemScope":
41
- return renderSystemScope(pattern);
42
- case "toggleable":
43
- return renderToggleable(pattern);
44
- case "describe":
45
- return renderDescribe(pattern);
46
- case "uiHints":
47
- return renderUiHints(pattern);
48
- case "entity":
49
- return renderEntity(pattern);
50
- case "relation":
51
- return renderRelation(pattern);
52
- case "nav":
53
- return renderNav(pattern);
54
- case "workspace":
55
- return renderWorkspace(pattern);
56
- case "config":
57
- return renderConfig(pattern);
58
- case "translations":
59
- return renderTranslations(pattern);
60
- case "metric":
61
- return renderMetric(pattern);
62
- case "secret":
63
- return renderSecret(pattern);
64
- case "secretNamespace":
65
- return renderSecretNamespace(pattern);
66
- case "claimKey":
67
- return renderClaimKey(pattern);
68
- case "referenceData":
69
- return renderReferenceData(pattern);
70
- case "useExtension":
71
- return renderUseExtension(pattern);
72
- case "screen":
73
- return renderScreen(pattern);
74
- case "writeHandler":
75
- return renderWriteHandler(pattern);
76
- case "queryHandler":
77
- return renderQueryHandler(pattern);
78
- case "streamHandler":
79
- return renderStreamHandler(pattern);
80
- case "hook":
81
- return renderHook(pattern);
82
- case "job":
83
- return renderJob(pattern);
84
- case "notification":
85
- return renderNotification(pattern);
86
- case "authClaims":
87
- return renderAuthClaims(pattern);
88
- case "httpRoute":
89
- return renderHttpRoute(pattern);
90
- case "projection":
91
- return renderProjection(pattern);
92
- case "multiStreamProjection":
93
- return renderMultiStreamProjection(pattern);
94
- case "defineEvent":
95
- return renderDefineEvent(pattern);
96
- case "extendsRegistrar":
97
- return renderExtendsRegistrar(pattern);
98
- case "usesApi":
99
- return renderUsesApi(pattern);
100
- case "exposesApi":
101
- return renderExposesApi(pattern);
102
- case "treeActions":
103
- return renderTreeActions(pattern);
104
- case "envSchema":
105
- return renderEnvSchema(pattern);
106
- case "ai.generate":
107
- return renderAiGenerate(pattern);
108
- case "ai.extract":
109
- return renderAiExtract(pattern);
110
- case "ai.classify":
111
- return renderAiClassify(pattern);
112
- case "unknown":
113
- return renderUnknown(pattern);
114
- default: {
115
- const _exhaustive = pattern;
116
- return _exhaustive;
117
- }
118
- }
33
+ return renderPatternOfKind(pattern.kind, pattern);
34
+ }
35
+ const PATTERN_RENDERERS = {
36
+ requires: renderRequires,
37
+ optionalRequires: renderOptionalRequires,
38
+ readsConfig: renderReadsConfig,
39
+ systemScope: renderSystemScope,
40
+ toggleable: renderToggleable,
41
+ describe: renderDescribe,
42
+ uiHints: renderUiHints,
43
+ adoptsBundledLists: renderAdoptsBundledLists,
44
+ entity: renderEntity,
45
+ relation: renderRelation,
46
+ nav: renderNav,
47
+ workspace: renderWorkspace,
48
+ config: renderConfig,
49
+ translations: renderTranslations,
50
+ metric: renderMetric,
51
+ secret: renderSecret,
52
+ secretNamespace: renderSecretNamespace,
53
+ claimKey: renderClaimKey,
54
+ referenceData: renderReferenceData,
55
+ useExtension: renderUseExtension,
56
+ screen: renderScreen,
57
+ writeHandler: renderWriteHandler,
58
+ queryHandler: renderQueryHandler,
59
+ streamHandler: renderStreamHandler,
60
+ hook: renderHook,
61
+ job: renderJob,
62
+ notification: renderNotification,
63
+ authClaims: renderAuthClaims,
64
+ httpRoute: renderHttpRoute,
65
+ projection: renderProjection,
66
+ multiStreamProjection: renderMultiStreamProjection,
67
+ defineEvent: renderDefineEvent,
68
+ extendsRegistrar: renderExtendsRegistrar,
69
+ usesApi: renderUsesApi,
70
+ exposesApi: renderExposesApi,
71
+ treeActions: renderTreeActions,
72
+ envSchema: renderEnvSchema,
73
+ "ai.generate": renderAiGenerate,
74
+ "ai.extract": renderAiExtract,
75
+ "ai.classify": renderAiClassify,
76
+ unknown: renderUnknown,
77
+ };
78
+ function renderPatternOfKind(kind, pattern) {
79
+ return PATTERN_RENDERERS[kind](pattern);
119
80
  }
120
81
  // =============================================================================
121
82
  // JSON-Like Value Renderer — emits TypeScript-source-compatible literals.
@@ -195,6 +156,9 @@ function renderReadsConfig(p) {
195
156
  function renderSystemScope(_p) {
196
157
  return "r.systemScope();";
197
158
  }
159
+ function renderAdoptsBundledLists(_p) {
160
+ return "r.adoptsBundledLists();";
161
+ }
198
162
  function renderToggleable(p) {
199
163
  return `r.toggleable({ default: ${p.default} });`;
200
164
  }
@@ -206,7 +170,8 @@ function renderEntity(p) {
206
170
  // losing `name` to the sentinel shortcut — spread the reference verbatim
207
171
  // next to the name instead.
208
172
  if (isRawRefSentinel(p.definition)) {
209
- return `r.entity({ name: ${JSON.stringify(p.entityName)}, ...${p.definition.__raw} });`;
173
+ const backingTable = p.backingTable ? `, backingTable: ${p.backingTable.__raw}` : "";
174
+ return `r.entity({ name: ${JSON.stringify(p.entityName)}, ...${p.definition.__raw}${backingTable} });`;
210
175
  }
211
176
  const merged = { name: p.entityName, ...p.definition };
212
177
  return `r.entity(${renderValue(merged)});`;
@@ -57,6 +57,7 @@ export type FeatureBuilderState = {
57
57
  translations: TranslationKeys;
58
58
  isSystemScoped: boolean;
59
59
  toggleableDefault: boolean | undefined;
60
+ adoptsBundledLists: boolean;
60
61
  description: string | undefined;
61
62
  uiHints: UiHints | undefined;
62
63
  treeActions: Readonly<Record<string, TreeActionDef>> | undefined;
@@ -57,6 +57,7 @@ export function createInitialFeatureBuilderState() {
57
57
  translations: {},
58
58
  isSystemScoped: false,
59
59
  toggleableDefault: undefined,
60
+ adoptsBundledLists: false,
60
61
  description: undefined,
61
62
  uiHints: undefined,
62
63
  treeActions: undefined,
@@ -130,6 +130,9 @@ export function buildEntityHandlerMethods(state, name) {
130
130
  ...(def.unsafeSkipTransitionGuard && { unsafeSkipTransitionGuard: true }),
131
131
  ...(def.rateLimit && { rateLimit: def.rateLimit }),
132
132
  ...(def.additionalRateLimits && { additionalRateLimits: def.additionalRateLimits }),
133
+ ...(def.rateLimitCost && {
134
+ rateLimitCost: def.rateLimitCost, // @cast-boundary engine-bridge
135
+ }),
133
136
  ...(def.escapeHatch && { escapeHatch: def.escapeHatch }),
134
137
  ...transactionPhaseSlots(def),
135
138
  ...(def.tenantlessAnonymous && { tenantlessAnonymous: true }),
@@ -40,6 +40,7 @@ export type ManifestFeature = {
40
40
  readonly name: string;
41
41
  readonly description: string | null;
42
42
  readonly toggleableDefault: boolean | null;
43
+ readonly adoptsBundledLists?: true;
43
44
  readonly requires: readonly string[];
44
45
  readonly optionalRequires: readonly string[];
45
46
  readonly configReads: readonly string[];
@@ -59,6 +59,7 @@ export function buildManifestFromRegistry(registry, options) {
59
59
  name: feature.name,
60
60
  description: feature.description ?? null,
61
61
  toggleableDefault: feature.toggleableDefault ?? null,
62
+ ...(feature.adoptsBundledLists && { adoptsBundledLists: true }),
62
63
  requires: [...feature.requires],
63
64
  optionalRequires: [...feature.optionalRequires],
64
65
  configReads: [...feature.configReads],
@@ -1,6 +1,7 @@
1
1
  import type { EntityDefinition, SessionUser } from "./types/index.ts";
2
2
  export declare function maskWriteOnlyFields<T extends Readonly<Record<string, unknown>>>(entity: EntityDefinition, row: T): T;
3
3
  export declare function dropEmptyWriteOnlyValues<T extends Readonly<Record<string, unknown>>>(entity: EntityDefinition, values: T): T;
4
+ export declare function userMayReadFieldInBulk(entity: EntityDefinition, fieldName: string, user: Pick<SessionUser, "roles">): boolean;
4
5
  export declare function filterReadFields(entity: EntityDefinition, data: Readonly<Record<string, unknown>>, user: SessionUser): Record<string, unknown>;
5
6
  export declare function checkWriteFieldRoles(entity: EntityDefinition, changes: Readonly<Record<string, unknown>>, user: SessionUser): string | null;
6
7
  export declare function checkWriteFieldOwnership(entity: EntityDefinition, submittedChanges: Readonly<Record<string, unknown>>, user: SessionUser, oldRow?: Readonly<Record<string, unknown>>, rowContext?: Readonly<Record<string, unknown>>): string | null;
@@ -35,6 +35,18 @@ export function dropEmptyWriteOnlyValues(entity, values) {
35
35
  delete kept[name];
36
36
  return kept; // @cast-boundary engine-payload
37
37
  }
38
+ // Role-level gate for bulk exports: false for writeOnly fields and for fields whose read-access
39
+ // map grants none of the user's roles. Per-row ownership rules are not evaluated here; those
40
+ // cells come back empty from the list query itself.
41
+ export function userMayReadFieldInBulk(entity, fieldName, user) {
42
+ const field = entity.fields[fieldName];
43
+ if (!field)
44
+ return false;
45
+ if (field.type === "text" && field.writeOnly === true)
46
+ return false;
47
+ const accessMap = normalizeAccessEntry(field.access?.read);
48
+ return accessMap === undefined || user.roles.some((role) => accessMap[role] !== undefined);
49
+ }
38
50
  // Field-level read filtering. Returns a copy of `data` with fields stripped
39
51
  // if the user's roles don't grant read access OR the ownership-rule for the
40
52
  // matching role doesn't accept this concrete row. Fields without access
@@ -101,17 +101,30 @@ function sumListCell(rows, listField, cell) {
101
101
  return sum;
102
102
  }
103
103
  function targetCurrency(field, current, sourceCurrency) {
104
+ // The client value is last: it must never override what the field or its sources dictate.
105
+ if (field.type === "money" && field.currency.kind === "literal")
106
+ return field.currency.code;
107
+ if (sourceCurrency !== undefined)
108
+ return sourceCurrency;
104
109
  if (isPlainObject(current) &&
105
110
  typeof current["currency"] === "string" &&
106
111
  current["currency"] !== "") {
107
112
  return current["currency"];
108
113
  }
109
- if (sourceCurrency !== undefined)
110
- return sourceCurrency;
111
- if (field.type === "money" && field.currency.kind === "literal")
112
- return field.currency.code;
113
114
  return undefined;
114
115
  }
116
+ function computeOrdinary(derivation, values, fields) {
117
+ const operands = derivation.from.map((name) => readOperand(values, fields, name));
118
+ const currencies = new Set(operands.flatMap((operand) => operand.currency ?? []));
119
+ const sourceCurrency = currencies.values().next().value;
120
+ // Operands in different currencies have no meaningful sum.
121
+ if (currencies.size > 1)
122
+ return { computed: undefined, sourceCurrency };
123
+ return {
124
+ computed: computeDerivedCellValue(derivation.op, operands.map((operand) => operand.value)),
125
+ sourceCurrency,
126
+ };
127
+ }
115
128
  /** Recomputes every derived head field of an action form from its inputs.
116
129
  * Pure and client-safe: the renderer runs it live, the server runs it
117
130
  * again (`withFormDerivations`) and overwrites whatever the client sent.
@@ -148,9 +161,7 @@ export function applyFormDerivations(values, screen) {
148
161
  ordinary = derivation;
149
162
  }
150
163
  if (ordinary !== undefined) {
151
- const operands = ordinary.from.map((name) => readOperand(result, screen.fields, name));
152
- sourceCurrency = operands.find((operand) => operand.currency !== undefined)?.currency;
153
- computed = computeDerivedCellValue(ordinary.op, operands.map((operand) => operand.value));
164
+ ({ computed, sourceCurrency } = computeOrdinary(ordinary, result, screen.fields));
154
165
  }
155
166
  if (computed === undefined) {
156
167
  delete result[target];
@@ -5,7 +5,7 @@ const MAX_WRAPPER_DEPTH = 8;
5
5
  const MAX_NESTING_DEPTH = 8;
6
6
  const referenceMetaSchema = z.union([
7
7
  z.string().min(1),
8
- z.object({ entity: z.string().min(1), by: z.string().min(1).optional() }),
8
+ z.strictObject({ entity: z.string().min(1), by: z.string().min(1).optional() }),
9
9
  ]);
10
10
  function rawReferenceMeta(field) {
11
11
  const meta = zodMeta(field);
@@ -1,6 +1,7 @@
1
1
  export { handlerFieldLabelKey, handlerTitleKey } from "../i18n/required-surface-keys.ts";
2
2
  export { hasAccess } from "./access.ts";
3
3
  export { isPrincipalStatusPlugin, isTenantLifecycleStatusPlugin, type PrincipalProfile, type PrincipalStatus, type PrincipalStatusPlugin, TENANT_TEARDOWN_STATUSES, type TenantLifecycleStatusPlugin, } from "./active-membership.ts";
4
+ export { validateBundledListsOptions } from "./boot-validator/bundled-lists-table.ts";
4
5
  export { PII_DIRECT_NAME_HINTS, PII_USER_OWNED_NAME_HINTS, PII_USER_REFERENCE_NAME_HINTS, } from "./boot-validator/entity-handler.ts";
5
6
  export { entityHasAnonymizableSubjectField } from "./boot-validator/pii-retention.ts";
6
7
  export { type CardMetaOverflow, collectCardMetaOverflow, collectWriteHandlerQns, MAX_TRANSFER_DEPTH, SECURITY_BASELINE_FEATURE_NAMES, type ValidateBootOptions, validateAppCustomScreenWriteQns, validateBoot, } from "./boot-validator.ts";
@@ -59,7 +60,6 @@ export { parseRefTarget, parseRefTargetEntityName } from "./parse-ref-target.ts"
59
60
  export { buildPipelineSteps, stepsPipeline } from "./pipeline.ts";
60
61
  export { projectAppSchemaForRoles } from "./project-app-schema-for-roles.ts";
61
62
  export { defineApply, defineMspApply, setFields } from "./projection-helpers.ts";
62
- export { providerPluginContextFromHandler, providerPluginContextFromJob, } from "./provider-plugin-context.ts";
63
63
  export type { BuiltinQnType, ParsedQn, QnType } from "./qualified-name.ts";
64
64
  export { isValidQn, parseQn, QnTypes, qn, toKebab } from "./qualified-name.ts";
65
65
  export { readClaim } from "./read-claim.ts";
@@ -87,7 +87,7 @@ export { assertNotificationVariables, templateVariable, templateVariablesToZod,
87
87
  export { type EffectiveFeaturesResolver, findTierResolverUsage, isTierResolverPlugin, requireTierResolverPlugin, TENANT_TIER_RESOLVER_EXT, type TierResolverPlugin, type TrialGate, } from "./tier-resolver-extension.ts";
88
88
  export { findOverDeepTransferChain, resolveTransferAdjacency as resolveEntityTransferAdjacency, type TransferAdjacency, type TransferEdge, type TransferEdgeLink, } from "./transfer-adjacency.ts";
89
89
  export { isSystemTenant, isUuid, parseTenantId, SYSTEM_TENANT_ID } from "./types/identifiers.ts";
90
- export type { AccessRule, ActionFormScreenDefinition, ActiveMembership, ActiveMembershipRejection, ActiveMembershipResult, AgentExposure, AgentHandlerHints, AgentRisk, AppContext, AppendEventArgs, AppendEventFn, AuthClaimsContext, AuthClaimsFn, AuthClaimsHookDef, BeforeTransactionPhase, BeforeTransactionResult, BelongsToRelation, BigIntFieldDef, BooleanFieldDef, BootOptionName, CamelToKebab, ChatSendFailureCode, ClaimKeyDefinition, ClaimKeyHandle, ClaimKeyJsType, ClaimKeyType, ConcurrencyMode, ConfigAccessor, ConfigAccessorFactory, ConfigBacking, ConfigCascade, ConfigCascadeLevel, ConfigDefinition, ConfigEditScreenDefinition, ConfigKeyAccess, ConfigKeyDefinition, ConfigKeyHandle, ConfigKeyType, ConfigMask, ConfigResolver, ConfigScope, ConfigSecretsReader, ConfigSeedDef, ConfigStoredRow, ConfigStoredRowWithSource, ConfigValidateContext, ConfigValidateFn, ConfigValue, ConfigValueSource, ConfigValueWithSource, ContentCollectionDefinition, CreateSeedOptions, CreateTenantSeedOptions, CreateUserSeedOptions, CustomScreenDefinition, CustomScreenRoute, DashboardChartPanel, DashboardCurrencyFormat, DashboardCustomPanel, DashboardDateParam, DashboardFeedPanel, DashboardFilterDefinition, DashboardI18nText, DashboardListPanel, DashboardMoneyParam, DashboardPanelDefinition, DashboardPanelVisibility, DashboardProgressListPanel, DashboardProgressTone, DashboardRecordBinding, DashboardRefresh, DashboardRelativeTimeFormat, DashboardRelativeTimeParam, DashboardScreenDefinition, DashboardScreenPanel, DashboardStatGroupPanel, DashboardStatPanel, DashboardText, DashboardTextBlock, DashboardTextPanel, DashboardTextParam, DashboardValueFormat, DateFieldDef, DecimalFieldDef, DeleteContext, DeliveryErrorCode, DeliveryFailureCode, DeliverySkipReason, DeriveContext, DerivedFieldDef, DerivedFieldsMap, DerivedValueType, EditExtensionSection, EditFieldPrefill, EditFieldSpec, EditFieldsSection, EditLayout, EditRelatedListSection, EditSectionSpec, EmbeddedListEditSpec, EntityDefinition, EntityEditAction, EntityEditActionPlacement, EntityEditScreenDefinition, EntityId, EntityListExpandableRow, EntityListScreenDefinition, EntityObjectDefinition, EntityRef, EntityRelations, EscapeHatchAuditSink, EscapeHatchDeclaration, EscapeHatchKind, EscapeHatchReporter, EscapeHatchTarget, EscapeHatchUseEvent, EventDef, ExtensionOptionsArgs, ExtensionOptionsFor, FeatureDefinition, FeatureRegistrar, FieldAccess, FieldCondition, FieldDefinition, FieldFormatRegistry, FieldIconKey, FieldRenderer, FileFieldDef, FilesFieldDef, Findability, FormatSpec, FormWidth, HandlerContext, HasManyRelation, HookDefinition, HookMap, ImageFieldDef, ImagesFieldDef, JobBackoff, JobBackoffStrategy, JobContext, JobDeferral, JobDefinition, JobHandlerFn, JobTrigger, JobTriggerEvent, JsonbFieldDef, KumikoEntityTypeMap, KumikoEventTypeMap, KumikoExtensionOptionsMap, KumikoHandlerPayloadMap, KumikoHandlerResultMap, LifecycleHookType, ListColumnSpec, ListFacetSpec, ListPaginationMode, ListSortDir, ListSortSpec, LongTextFindability, ManyToManyRelation, MaxPerTenantOptions, MemberReader, MetricNavigate, MetricSpec, MspErrorMode, MspErrorPolicy, MultiSelectFieldDef, MultiStreamApplyFn, MultiStreamProjectionDefinition, NameOrRef, NavDefinition, NavIconKey, NotificationDataFn, NotificationDefinition, NotificationLocalizedTemplate, NotificationRecipientFn, NotificationRecordMapping, NotificationTemplateBody, NotificationTemplateFn, NotificationTemplateMeta, NotifyDeferred, NotifyDelivery, NotifyDeliveryStatus, NotifyDispatched, NotifyFactory, NotifyFn, NotifyJobDispatcher, NotifyOptions, NotifyPriority, NotifyResult, NumberFieldDef, OnDeleteStrategy, OpenToAllAccessRule, OpenToAllDeclaration, OpenToAllPersonalData, ParentRefDef, PersonalAnnotations, PersonalAnnotationsLongText, PersonalAnnotationsNoFind, PersonalSubject, PlatformComponent, PluralForms, PostDeleteHookFn, PostSaveHookFn, PreDeleteHookFn, PreparedWriteEvent, PreQueryHookFn, PreSaveHookFn, ProjectionDefinition, ProjectionDetailScreenDefinition, ProjectionListScreenDefinition, ProjectionTable, ProviderPluginContext, QualifiedEventName, QueryEvent, QueryHandlerDef, QueryHandlerFn, RateLimitPer, RecordHeaderSpec, RecordHeaderSubtitlePart, ReferenceDataDef, Registry, RelationDefinition, ResolvedPiiFlags, RetentionDef, RoleAccessPersonalData, RoleAccessRule, RowAction, RowActionNavigate, RowActionNavigateBase, RowActionWriteHandler, RowFieldExtractor, SaveContext, ScreenDefinition, ScreenFilter, ScreenFilterOp, ScreenNavSugar, ScreenSlots, SecretKeyDefinition, SecretKeyHandle, SecretMintConfirmStep, SecretMintScreenDefinition, SecretNamespaceDefinition, SecretNamespaceHandle, SecretNamespaceOptions, SecretReveal, SecretRevealField, SecretsEditScreenDefinition, SecretsEditSection, SelectFieldDef, SessionUser, SessionUserOrigin, StackBootRequirement, StreamHandlerDef, StreamHandlerFn, Subscribe, TargetRef, TemplateImagesVariableDef, TemplateListVariableDef, TemplateScalarVariableDef, TemplateVariableDef, TemplateVariables, TenantId, TenantWriteTarget, TextFieldDef, ToolbarAction, TranslationEntry, TranslationKeys, TranslationsDef, TranslationValue, TreeAction, TreeActionDef, TreeActionsHandle, TreeChildrenSubscribe, TreeNode, TreeNodeState, UnitKey, UnsafeAppendEventFn, ValidationError, ValidationHookFn, WorkspaceDefinition, WriteEvent, WriteHandlerDef, WriteHandlerFn, WriteResult, } from "./types/index.ts";
90
+ export type { AccessRule, ActionFormScreenDefinition, ActiveMembership, ActiveMembershipRejection, ActiveMembershipResult, AgentExposure, AgentHandlerHints, AgentRisk, AppContext, AppendEventArgs, AppendEventFn, AuthClaimsContext, AuthClaimsFn, AuthClaimsHookDef, BeforeTransactionPhase, BeforeTransactionResult, BelongsToRelation, BigIntFieldDef, BooleanFieldDef, BootOptionName, BundledListsOptions, CamelToKebab, ChatSendFailureCode, ClaimKeyDefinition, ClaimKeyHandle, ClaimKeyJsType, ClaimKeyType, ConcurrencyMode, ConfigAccessor, ConfigAccessorFactory, ConfigBacking, ConfigCascade, ConfigCascadeLevel, ConfigDefinition, ConfigEditScreenDefinition, ConfigKeyAccess, ConfigKeyDefinition, ConfigKeyHandle, ConfigKeyType, ConfigMask, ConfigResolver, ConfigScope, ConfigSecretsReader, ConfigSeedDef, ConfigStoredRow, ConfigStoredRowWithSource, ConfigValidateContext, ConfigValidateFn, ConfigValue, ConfigValueSource, ConfigValueWithSource, ContentCollectionDefinition, CreateSeedOptions, CreateTenantSeedOptions, CreateUserSeedOptions, CustomScreenDefinition, CustomScreenRoute, DashboardChartPanel, DashboardCurrencyFormat, DashboardCustomPanel, DashboardDateParam, DashboardFeedPanel, DashboardFilterDefinition, DashboardI18nText, DashboardListPanel, DashboardMoneyParam, DashboardPanelDefinition, DashboardPanelVisibility, DashboardProgressListPanel, DashboardProgressTone, DashboardRecordBinding, DashboardRefresh, DashboardRelativeTimeFormat, DashboardRelativeTimeParam, DashboardScreenDefinition, DashboardScreenPanel, DashboardStatGroupPanel, DashboardStatPanel, DashboardText, DashboardTextBlock, DashboardTextPanel, DashboardTextParam, DashboardValueFormat, DateFieldDef, DecimalFieldDef, DeleteContext, DeliveryErrorCode, DeliveryFailureCode, DeliverySkipReason, DeriveContext, DerivedFieldDef, DerivedFieldsMap, DerivedValueType, EditExtensionSection, EditFieldPrefill, EditFieldSpec, EditFieldsSection, EditLayout, EditRelatedListSection, EditSectionSpec, EmbeddedListEditSpec, EntityDefinition, EntityEditAction, EntityEditActionPlacement, EntityEditScreenDefinition, EntityId, EntityListExpandableRow, EntityListScreenDefinition, EntityObjectDefinition, EntityRef, EntityRelations, EscapeHatchAuditSink, EscapeHatchDeclaration, EscapeHatchKind, EscapeHatchReporter, EscapeHatchTarget, EscapeHatchUseEvent, EventDef, ExpandableRowGrouping, ExtensionOptionsArgs, ExtensionOptionsFor, FeatureDefinition, FeatureRegistrar, FieldAccess, FieldCondition, FieldDefinition, FieldFormatRegistry, FieldIconKey, FieldRenderer, FileFieldDef, FilesFieldDef, Findability, FormatSpec, FormWidth, HandlerContext, HasManyRelation, HookDefinition, HookMap, ImageFieldDef, ImagesFieldDef, JobBackoff, JobBackoffStrategy, JobContext, JobDeferral, JobDefinition, JobHandlerFn, JobTrigger, JobTriggerEvent, JsonbFieldDef, KumikoEntityTypeMap, KumikoEventTypeMap, KumikoExtensionOptionsMap, KumikoHandlerPayloadMap, KumikoHandlerResultMap, LifecycleHookType, ListColumnSpec, ListFacetSpec, ListPaginationMode, ListSortDir, ListSortSpec, ListTableOptions, LongTextFindability, ManyToManyRelation, MaxPerTenantOptions, MemberReader, MetricNavigate, MetricSpec, MspErrorMode, MspErrorPolicy, MultiSelectFieldDef, MultiStreamApplyFn, MultiStreamProjectionDefinition, NameOrRef, NavDefinition, NavIconKey, NotificationDataFn, NotificationDefinition, NotificationLocalizedTemplate, NotificationRecipientFn, NotificationRecordMapping, NotificationTemplateBody, NotificationTemplateFn, NotificationTemplateMeta, NotifyDeferred, NotifyDelivery, NotifyDeliveryStatus, NotifyDispatched, NotifyFactory, NotifyFn, NotifyJobDispatcher, NotifyOptions, NotifyPriority, NotifyResult, NumberFieldDef, OnDeleteStrategy, OpenToAllAccessRule, OpenToAllDeclaration, OpenToAllPersonalData, ParentRefDef, PersonalAnnotations, PersonalAnnotationsLongText, PersonalAnnotationsNoFind, PersonalSubject, PlatformComponent, PluralForms, PostDeleteHookFn, PostSaveHookFn, PreDeleteHookFn, PreparedWriteEvent, PreQueryHookFn, PreSaveHookFn, ProjectionDefinition, ProjectionDetailScreenDefinition, ProjectionListScreenDefinition, ProjectionTable, QualifiedEventName, QueryEvent, QueryHandlerDef, QueryHandlerFn, RateLimitPer, RecordHeaderSpec, RecordHeaderSubtitlePart, ReferenceDataDef, Registry, RelationDefinition, ResolvedPiiFlags, RetentionDef, RoleAccessPersonalData, RoleAccessRule, RowAction, RowActionNavigate, RowActionNavigateBase, RowActionWriteHandler, RowFieldExtractor, SaveContext, ScreenDefinition, ScreenFilter, ScreenFilterOp, ScreenNavSugar, ScreenSlots, SecretKeyDefinition, SecretKeyHandle, SecretMintConfirmStep, SecretMintScreenDefinition, SecretNamespaceDefinition, SecretNamespaceHandle, SecretNamespaceOptions, SecretReveal, SecretRevealField, SecretsEditScreenDefinition, SecretsEditSection, SelectFieldDef, SessionUser, SessionUserOrigin, StackBootRequirement, StreamHandlerDef, StreamHandlerFn, Subscribe, TargetRef, TemplateImagesVariableDef, TemplateListVariableDef, TemplateScalarVariableDef, TemplateVariableDef, TemplateVariables, TenantId, TenantWriteTarget, TextFieldDef, ToolbarAction, TranslationEntry, TranslationKeys, TranslationsDef, TranslationValue, TreeAction, TreeActionDef, TreeActionsHandle, TreeChildrenSubscribe, TreeNode, TreeNodeState, UnitKey, UnsafeAppendEventFn, ValidationError, ValidationHookFn, WorkspaceDefinition, WriteEvent, WriteHandlerDef, WriteHandlerFn, WriteResult, } from "./types/index.ts";
91
91
  export { DEFAULT_CURRENCIES, DEFAULT_LOCALES, DELIVERY_FAILURE_CODES, DELIVERY_SKIP_REASONS, HookPhases, HTTP_ERROR_CODE_PATTERN, isAgentVisibleScreen, isDeliveryErrorCode, isOpenToAllGranted, resolveAgentExposure, } from "./types/index.ts";
92
92
  export type { AwaitedEventType, PipelineBuildCtx, PipelineCtx, PipelineDef, StepBuilder, StepDef, StepFailureStrategy, StepInstance, StepKind, StepNamespace, StepResolver, } from "./types/step.ts";
93
93
  export { runValidation } from "./validation.ts";