@noy-db/hub 0.7.0-pre.13 → 0.7.0-pre.14

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 (233) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/README.md +4 -3
  3. package/dist/{api-UE2XQKDN.js → api-JPZT6BDD.js} +1 -2
  4. package/dist/as/index.js +3 -4
  5. package/dist/as/index.js.map +1 -1
  6. package/dist/at/index.js +0 -1
  7. package/dist/attestation/index.js +6 -7
  8. package/dist/attestation/index.js.map +1 -1
  9. package/dist/{backup-R6A4VZRX.js → backup-AKWIMYWU.js} +1 -2
  10. package/dist/{backup-R6A4VZRX.js.map → backup-AKWIMYWU.js.map} +1 -1
  11. package/dist/blobs/index.js +0 -1
  12. package/dist/blobs/index.js.map +1 -1
  13. package/dist/broker/index.js +3 -4
  14. package/dist/broker/index.js.map +1 -1
  15. package/dist/by/index.js +0 -1
  16. package/dist/cargo/index.js +10 -11
  17. package/dist/{chunk-5FUULQ6F.js → chunk-2HVILGVR.js} +6 -6
  18. package/dist/{chunk-DJ3LNNZQ.js → chunk-3LK2XZCW.js} +2 -2
  19. package/dist/{chunk-BWXGSSFX.js → chunk-4SZMZAYN.js} +79 -16
  20. package/dist/chunk-4SZMZAYN.js.map +1 -0
  21. package/dist/{chunk-PQKG5AHH.js → chunk-6X6SEMEE.js} +4 -2
  22. package/dist/{chunk-PQKG5AHH.js.map → chunk-6X6SEMEE.js.map} +1 -1
  23. package/dist/{chunk-E2MYJGSG.js → chunk-AMODH7AU.js} +2 -2
  24. package/dist/{chunk-B2ZSGYSF.js → chunk-B2KCRDJM.js} +3 -3
  25. package/dist/{chunk-TO3EQ7HF.js → chunk-BLN54W3L.js} +2 -2
  26. package/dist/{chunk-IHFXR2VQ.js → chunk-BOBFL5TW.js} +2 -2
  27. package/dist/{chunk-ZVCC36XQ.js → chunk-DRB6IHPS.js} +55 -55
  28. package/dist/{chunk-AJQY44CE.js → chunk-EKVNVJVV.js} +3 -20
  29. package/dist/chunk-EKVNVJVV.js.map +1 -0
  30. package/dist/{chunk-ZR2YMODS.js → chunk-EKZ6VZYF.js} +2 -2
  31. package/dist/{chunk-RTYJRFQO.js → chunk-EWPRPP3M.js} +1 -1
  32. package/dist/{chunk-VGICZPVE.js → chunk-FUJSIP4K.js} +2 -2
  33. package/dist/{chunk-PKJ43CMD.js → chunk-NLOLF6LD.js} +2 -2
  34. package/dist/{chunk-SXCYYMVS.js → chunk-NOSRK3ZZ.js} +5 -5
  35. package/dist/{chunk-COTPDJR5.js → chunk-OMB2ZKIT.js} +8 -8
  36. package/dist/{chunk-Y4MJQ2UG.js → chunk-QQ2YMQZU.js} +2 -2
  37. package/dist/{chunk-URHRIAV6.js → chunk-REDOOY2Q.js} +2 -2
  38. package/dist/chunk-REDOOY2Q.js.map +1 -0
  39. package/dist/{chunk-YCXICMOY.js → chunk-RJ7NN2UR.js} +2 -2
  40. package/dist/{chunk-PDD75NUZ.js → chunk-SMH6SRX7.js} +2 -2
  41. package/dist/{chunk-QHW35ZON.js → chunk-TGPST6FK.js} +2 -2
  42. package/dist/{chunk-BMELYFHU.js → chunk-V2PNPF6J.js} +3 -3
  43. package/dist/{chunk-BERJ4AWW.js → chunk-VGXZT72I.js} +2 -2
  44. package/dist/{chunk-2Z47NMFK.js → chunk-WZW37ZHL.js} +2 -2
  45. package/dist/classified/index.js +1 -2
  46. package/dist/{classified-marker-67HBIJMZ.js → classified-marker-OO65UYXN.js} +3 -5
  47. package/dist/{classified-marker-67HBIJMZ.js.map → classified-marker-OO65UYXN.js.map} +1 -1
  48. package/dist/{collection-facade-4ACKIDDY.js → collection-facade-VOWW732S.js} +3 -4
  49. package/dist/{computed-LSEZYRJS.js → computed-VPOKQK4N.js} +1 -2
  50. package/dist/consent/index.js +0 -1
  51. package/dist/consent/index.js.map +1 -1
  52. package/dist/cover/index.js +0 -1
  53. package/dist/crdt/index.js +0 -1
  54. package/dist/crdt/index.js.map +1 -1
  55. package/dist/custody/index.js +1 -2
  56. package/dist/{dead-filter-M3NZUWBZ.js → dead-filter-OMMVBAKZ.js} +2 -3
  57. package/dist/{dead-filter-M3NZUWBZ.js.map → dead-filter-OMMVBAKZ.js.map} +1 -1
  58. package/dist/debug/index.js +0 -1
  59. package/dist/debug/index.js.map +1 -1
  60. package/dist/{delegation-OLJUWTVA.js → delegation-VRYMQRCF.js} +1 -2
  61. package/dist/{delegation-OLJUWTVA.js.map → delegation-VRYMQRCF.js.map} +1 -1
  62. package/dist/derivations/index.js +3 -4
  63. package/dist/{derive-LY47HG7Q.js → derive-HHBRFS2U.js} +2 -3
  64. package/dist/directory/index.js +0 -1
  65. package/dist/{dispatch-MSTR5VBI.js → dispatch-DC3LQJ3S.js} +6 -7
  66. package/dist/{dispatch-MSTR5VBI.js.map → dispatch-DC3LQJ3S.js.map} +1 -1
  67. package/dist/{dispatch-PDP5TA73.js → dispatch-GGFBWQU7.js} +5 -7
  68. package/dist/{dispatch-PDP5TA73.js.map → dispatch-GGFBWQU7.js.map} +1 -1
  69. package/dist/{enclave-4YBQK77G.js → enclave-VM2YQONI.js} +1 -2
  70. package/dist/{executor-TOLPBHOC.js → executor-5NIMLSKZ.js} +1 -2
  71. package/dist/{executor-YDDC5XGY.js → executor-5XJNV5H5.js} +1 -2
  72. package/dist/{executor-MZJXBWNM.js → executor-AQVXV5GZ.js} +1 -2
  73. package/dist/{export-accessible-LGV6IAFX.js → export-accessible-2LOBM67T.js} +3 -4
  74. package/dist/{extract-partition-RYJZIKQZ.js → extract-partition-AZGSEMIF.js} +3 -4
  75. package/dist/{fanout-sidecar-TSFPXY5C.js → fanout-sidecar-HJIVUPTD.js} +1 -2
  76. package/dist/{fanout-sidecar-TSFPXY5C.js.map → fanout-sidecar-HJIVUPTD.js.map} +1 -1
  77. package/dist/{fence-watcher-ZVSMLKQD.js → fence-watcher-U2PW6JU5.js} +1 -3
  78. package/dist/{fence-watcher-ZVSMLKQD.js.map → fence-watcher-U2PW6JU5.js.map} +1 -1
  79. package/dist/{find-LC7P63MX.js → find-2ABFCZX4.js} +1 -2
  80. package/dist/forget/index.js +0 -1
  81. package/dist/forget/index.js.map +1 -1
  82. package/dist/guards/index.js +0 -1
  83. package/dist/history/index.js +0 -1
  84. package/dist/history/index.js.map +1 -1
  85. package/dist/i18n/index.js +0 -1
  86. package/dist/i18n/index.js.map +1 -1
  87. package/dist/index.js +26 -27
  88. package/dist/index.js.map +1 -1
  89. package/dist/indexing/index.js +0 -1
  90. package/dist/indexing/index.js.map +1 -1
  91. package/dist/introspection/index.js +2 -3
  92. package/dist/{issue-IOXM3RSJ.js → issue-RH4H733Z.js} +1 -2
  93. package/dist/{json-schema-I22JCYCG.js → json-schema-V3M5MUCM.js} +1 -3
  94. package/dist/{json-schema-I22JCYCG.js.map → json-schema-V3M5MUCM.js.map} +1 -1
  95. package/dist/kernel/collection-config.d.ts +34 -0
  96. package/dist/lazy/index.js +0 -1
  97. package/dist/{ledger-HXHIOD36.js → ledger-454SU3VE.js} +1 -2
  98. package/dist/{liberate-4APIV7FR.js → liberate-AAZSP2BT.js} +5 -6
  99. package/dist/{link-set-6RAHEKZN.js → link-set-67CAMUAL.js} +1 -2
  100. package/dist/{managed-secret-P3JQ7ZG4.js → managed-secret-NHRYG7CD.js} +1 -2
  101. package/dist/materialized-views/index.js +2 -3
  102. package/dist/{migrate-cek-25KNTS5U.js → migrate-cek-5ENH64AA.js} +1 -2
  103. package/dist/{migrate-cek-25KNTS5U.js.map → migrate-cek-5ENH64AA.js.map} +1 -1
  104. package/dist/money/index.js +0 -1
  105. package/dist/{noydb-2C6QQJ5S.js → noydb-Y53CQHZK.js} +11 -12
  106. package/dist/overlay-views/index.js +0 -1
  107. package/dist/periods/index.js +1 -2
  108. package/dist/pod/index.js +12 -13
  109. package/dist/{pod-handle-6II7KFBR.js → pod-handle-S7AMCJIF.js} +2 -3
  110. package/dist/{pod-handle-6II7KFBR.js.map → pod-handle-S7AMCJIF.js.map} +1 -1
  111. package/dist/policy/index.js +0 -1
  112. package/dist/portability/index.js +6 -7
  113. package/dist/portability/index.js.map +1 -1
  114. package/dist/{post-register-BPJ36A6D.js → post-register-HIYY4Y5S.js} +4 -5
  115. package/dist/{post-register-BPJ36A6D.js.map → post-register-HIYY4Y5S.js.map} +1 -1
  116. package/dist/{purge-scope-FGNNLWHD.js → purge-scope-4HEFPDOW.js} +1 -3
  117. package/dist/{purge-scope-FGNNLWHD.js.map → purge-scope-4HEFPDOW.js.map} +1 -1
  118. package/dist/query/index.js +0 -1
  119. package/dist/{read-only-facade-CHCKSEPD.js → read-only-facade-BIGO37U3.js} +1 -2
  120. package/dist/reduce/index.js +0 -1
  121. package/dist/reduce/index.js.map +1 -1
  122. package/dist/{register-AEOOGKNO.js → register-7OJWAWT5.js} +3 -4
  123. package/dist/{registry-SKSOUXNF.js → registry-23WF3TGH.js} +1 -2
  124. package/dist/{registry-SHMGHEK4.js → registry-4AYVUNXK.js} +1 -2
  125. package/dist/{registry-I6FP4677.js → registry-5MVJGPXW.js} +1 -2
  126. package/dist/{registry-D2YXKRYC.js → registry-HDINK5QW.js} +4 -5
  127. package/dist/{request-withdrawal-6HJT4ODF.js → request-withdrawal-P5EQATZ7.js} +5 -6
  128. package/dist/{reveal-DDQBDWPM.js → reveal-IMGQ2EE5.js} +1 -2
  129. package/dist/{reveal-DDQBDWPM.js.map → reveal-IMGQ2EE5.js.map} +1 -1
  130. package/dist/{revoke-U7U3FMXU.js → revoke-POHP4GPB.js} +1 -2
  131. package/dist/satellites/index.js +0 -1
  132. package/dist/schema-update/index.js +0 -1
  133. package/dist/sealed-record/index.js +3 -4
  134. package/dist/sealed-record/index.js.map +1 -1
  135. package/dist/search/index.js +1 -2
  136. package/dist/{seed-3RXT4VGN.js → seed-UYR6YG3V.js} +1 -2
  137. package/dist/{seed-3RXT4VGN.js.map → seed-UYR6YG3V.js.map} +1 -1
  138. package/dist/sequence/index.js +0 -1
  139. package/dist/session/index.js +0 -1
  140. package/dist/session/index.js.map +1 -1
  141. package/dist/shadow/index.js +0 -1
  142. package/dist/shadow/index.js.map +1 -1
  143. package/dist/share-link/index.js +0 -1
  144. package/dist/share-link/index.js.map +1 -1
  145. package/dist/{signer-7NK7TMWU.js → signer-5K3WDHOC.js} +1 -2
  146. package/dist/snapshots/index.js +1 -2
  147. package/dist/snapshots/index.js.map +1 -1
  148. package/dist/{stale-2CHKZTMK.js → stale-AU74OPUW.js} +2 -3
  149. package/dist/{storage-WP4M7IFO.js → storage-AVJA5BTW.js} +1 -2
  150. package/dist/store/index.js +0 -1
  151. package/dist/{store-coordination-provider-O2VUEMJH.js → store-coordination-provider-RX2CGWXV.js} +1 -2
  152. package/dist/{store-coordination-provider-O2VUEMJH.js.map → store-coordination-provider-RX2CGWXV.js.map} +1 -1
  153. package/dist/sync/index.js +0 -1
  154. package/dist/sync/index.js.map +1 -1
  155. package/dist/team/index.js +0 -1
  156. package/dist/tiers/index.js +1 -2
  157. package/dist/to/index.js +0 -1
  158. package/dist/to/index.js.map +1 -1
  159. package/dist/transactions/index.js +2 -3
  160. package/dist/transactions/index.js.map +1 -1
  161. package/dist/{ulid-VQW6ERQN.js → ulid-4MKXG325.js} +1 -2
  162. package/dist/util/index.js +0 -1
  163. package/dist/util/index.js.map +1 -1
  164. package/dist/{vault-diff-FE5J35NJ.js → vault-diff-C6WUJFNP.js} +1 -2
  165. package/dist/vault-head/index.js +0 -1
  166. package/dist/vault-head/index.js.map +1 -1
  167. package/dist/{verify-JBXCAGDL.js → verify-KOV2G5D6.js} +1 -2
  168. package/dist/{verify-JBXCAGDL.js.map → verify-KOV2G5D6.js.map} +1 -1
  169. package/dist/{walk-P3E6QSNC.js → walk-ERAJ5RHO.js} +3 -4
  170. package/dist/with-formula/derivations/registry.d.ts +6 -0
  171. package/dist/with-shape/introspection/describe.d.ts +2 -53
  172. package/dist/with-shape/introspection/field-meta.d.ts +86 -0
  173. package/dist/{withdraw-accessible-6Q7NE4EY.js → withdraw-accessible-42D32Z7G.js} +4 -5
  174. package/package.json +7 -3
  175. package/dist/chunk-AJQY44CE.js.map +0 -1
  176. package/dist/chunk-BWXGSSFX.js.map +0 -1
  177. package/dist/chunk-PZ5AY32C.js +0 -10
  178. package/dist/chunk-URHRIAV6.js.map +0 -1
  179. package/dist/withdraw-accessible-6Q7NE4EY.js.map +0 -1
  180. package/dist/zod-HAJM7LMS.js +0 -14763
  181. package/dist/zod-HAJM7LMS.js.map +0 -1
  182. /package/dist/{api-UE2XQKDN.js.map → api-JPZT6BDD.js.map} +0 -0
  183. /package/dist/{chunk-5FUULQ6F.js.map → chunk-2HVILGVR.js.map} +0 -0
  184. /package/dist/{chunk-DJ3LNNZQ.js.map → chunk-3LK2XZCW.js.map} +0 -0
  185. /package/dist/{chunk-E2MYJGSG.js.map → chunk-AMODH7AU.js.map} +0 -0
  186. /package/dist/{chunk-B2ZSGYSF.js.map → chunk-B2KCRDJM.js.map} +0 -0
  187. /package/dist/{chunk-TO3EQ7HF.js.map → chunk-BLN54W3L.js.map} +0 -0
  188. /package/dist/{chunk-IHFXR2VQ.js.map → chunk-BOBFL5TW.js.map} +0 -0
  189. /package/dist/{chunk-ZVCC36XQ.js.map → chunk-DRB6IHPS.js.map} +0 -0
  190. /package/dist/{chunk-ZR2YMODS.js.map → chunk-EKZ6VZYF.js.map} +0 -0
  191. /package/dist/{chunk-RTYJRFQO.js.map → chunk-EWPRPP3M.js.map} +0 -0
  192. /package/dist/{chunk-VGICZPVE.js.map → chunk-FUJSIP4K.js.map} +0 -0
  193. /package/dist/{chunk-PKJ43CMD.js.map → chunk-NLOLF6LD.js.map} +0 -0
  194. /package/dist/{chunk-SXCYYMVS.js.map → chunk-NOSRK3ZZ.js.map} +0 -0
  195. /package/dist/{chunk-COTPDJR5.js.map → chunk-OMB2ZKIT.js.map} +0 -0
  196. /package/dist/{chunk-Y4MJQ2UG.js.map → chunk-QQ2YMQZU.js.map} +0 -0
  197. /package/dist/{chunk-YCXICMOY.js.map → chunk-RJ7NN2UR.js.map} +0 -0
  198. /package/dist/{chunk-PDD75NUZ.js.map → chunk-SMH6SRX7.js.map} +0 -0
  199. /package/dist/{chunk-QHW35ZON.js.map → chunk-TGPST6FK.js.map} +0 -0
  200. /package/dist/{chunk-BMELYFHU.js.map → chunk-V2PNPF6J.js.map} +0 -0
  201. /package/dist/{chunk-BERJ4AWW.js.map → chunk-VGXZT72I.js.map} +0 -0
  202. /package/dist/{chunk-2Z47NMFK.js.map → chunk-WZW37ZHL.js.map} +0 -0
  203. /package/dist/{chunk-PZ5AY32C.js.map → collection-facade-VOWW732S.js.map} +0 -0
  204. /package/dist/{collection-facade-4ACKIDDY.js.map → computed-VPOKQK4N.js.map} +0 -0
  205. /package/dist/{computed-LSEZYRJS.js.map → derive-HHBRFS2U.js.map} +0 -0
  206. /package/dist/{derive-LY47HG7Q.js.map → enclave-VM2YQONI.js.map} +0 -0
  207. /package/dist/{enclave-4YBQK77G.js.map → executor-5NIMLSKZ.js.map} +0 -0
  208. /package/dist/{executor-MZJXBWNM.js.map → executor-5XJNV5H5.js.map} +0 -0
  209. /package/dist/{executor-TOLPBHOC.js.map → executor-AQVXV5GZ.js.map} +0 -0
  210. /package/dist/{executor-YDDC5XGY.js.map → export-accessible-2LOBM67T.js.map} +0 -0
  211. /package/dist/{export-accessible-LGV6IAFX.js.map → extract-partition-AZGSEMIF.js.map} +0 -0
  212. /package/dist/{extract-partition-RYJZIKQZ.js.map → find-2ABFCZX4.js.map} +0 -0
  213. /package/dist/{find-LC7P63MX.js.map → issue-RH4H733Z.js.map} +0 -0
  214. /package/dist/{issue-IOXM3RSJ.js.map → ledger-454SU3VE.js.map} +0 -0
  215. /package/dist/{ledger-HXHIOD36.js.map → liberate-AAZSP2BT.js.map} +0 -0
  216. /package/dist/{liberate-4APIV7FR.js.map → link-set-67CAMUAL.js.map} +0 -0
  217. /package/dist/{link-set-6RAHEKZN.js.map → managed-secret-NHRYG7CD.js.map} +0 -0
  218. /package/dist/{managed-secret-P3JQ7ZG4.js.map → noydb-Y53CQHZK.js.map} +0 -0
  219. /package/dist/{noydb-2C6QQJ5S.js.map → read-only-facade-BIGO37U3.js.map} +0 -0
  220. /package/dist/{read-only-facade-CHCKSEPD.js.map → register-7OJWAWT5.js.map} +0 -0
  221. /package/dist/{register-AEOOGKNO.js.map → registry-23WF3TGH.js.map} +0 -0
  222. /package/dist/{registry-D2YXKRYC.js.map → registry-4AYVUNXK.js.map} +0 -0
  223. /package/dist/{registry-I6FP4677.js.map → registry-5MVJGPXW.js.map} +0 -0
  224. /package/dist/{registry-SHMGHEK4.js.map → registry-HDINK5QW.js.map} +0 -0
  225. /package/dist/{registry-SKSOUXNF.js.map → request-withdrawal-P5EQATZ7.js.map} +0 -0
  226. /package/dist/{request-withdrawal-6HJT4ODF.js.map → revoke-POHP4GPB.js.map} +0 -0
  227. /package/dist/{revoke-U7U3FMXU.js.map → signer-5K3WDHOC.js.map} +0 -0
  228. /package/dist/{signer-7NK7TMWU.js.map → stale-AU74OPUW.js.map} +0 -0
  229. /package/dist/{stale-2CHKZTMK.js.map → storage-AVJA5BTW.js.map} +0 -0
  230. /package/dist/{storage-WP4M7IFO.js.map → ulid-4MKXG325.js.map} +0 -0
  231. /package/dist/{ulid-VQW6ERQN.js.map → vault-diff-C6WUJFNP.js.map} +0 -0
  232. /package/dist/{vault-diff-FE5J35NJ.js.map → walk-ERAJ5RHO.js.map} +0 -0
  233. /package/dist/{walk-P3E6QSNC.js.map → withdraw-accessible-42D32Z7G.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/with-formula/materialized-views/with-materialized-view.ts"],"sourcesContent":["import { MaterializedViewConfigError, ValidationError } from '../../kernel/errors.js'\nimport type { MaterializedViewSpec, MaterializedViewStrategy } from './types.js'\nimport { validateProjectionLegs } from './projection-legs.js' // #1140\n\n/**\n * Register a materialized view: a declared query whose result is\n * persisted as a queryable collection and kept fresh as sources\n * change. Writes go through the standard `Collection.put` pipeline;\n * refresh-driven deletes route through `Collection._internalDelete` so\n * user `onDelete` guards on the output collection aren't tripped by\n * housekeeping.\n *\n * Three registration modes:\n * - **single-source** — declare `query: (db) => Query<TRow>`; the\n * dependency analyzer derives source collections from the plan.\n * - **UNION** — declare `unionSources: [{ collection, map }, ...]`\n * plus optional `groupBy` + `aggregate`; the executor reads each\n * arm, maps to the unified row shape, concatenates, then groups\n * and aggregates.\n * - **projection** (#810) — declare `projection: { source, joins,\n * map }`; one output row per primary record, enriched with\n * forward FK legs and reverse \"collect\" legs before `map` runs.\n *\n * The three modes are mutually exclusive — exactly one of `query` /\n * `unionSources` / `projection` must be set at registration time.\n *\n * See design-history/2026-05-20-dim14-mv-v2-design.md (single-source v2),\n * design-history/2026-05-21-dim14-mv-multikey-and-union.md (UNION),\n * and design-history/2026-07-25-join-projection-mv-design.md (projection).\n */\nexport function withMaterializedView<TRow extends Record<string, unknown>>(\n spec: MaterializedViewSpec<TRow>,\n): MaterializedViewStrategy {\n if (!spec.name || spec.name.length === 0) {\n throw new ValidationError('withMaterializedView: name is required')\n }\n // Mutual exclusion: exactly one of the three forms must be declared.\n const declaredForms = [spec.query, spec.unionSources, spec.projection]\n .filter((f) => f !== undefined).length\n if (declaredForms > 1) {\n throw new MaterializedViewConfigError(\n 'query, unionSources, and projection are mutually exclusive — pick one',\n )\n }\n if (declaredForms === 0) {\n throw new MaterializedViewConfigError(\n 'strategy must declare exactly one of query, unionSources, or projection',\n )\n }\n if (spec.query !== undefined && typeof spec.query !== 'function') {\n throw new ValidationError('withMaterializedView: query must be a function returning a Query<T>')\n }\n // UNION-form invariants.\n if (spec.unionSources) {\n // A single arm is a deliberate shape: map→group→aggregate over\n // ONE collection with a COMPUTED bucket key (e.g. month sliced from a\n // date field) — something the query form's stored-field groupBy cannot\n // express. The executor and dependency analyzer are arm-count-agnostic.\n if (spec.unionSources.length < 1) {\n throw new MaterializedViewConfigError(\n 'unionSources requires at least 1 source collection',\n )\n }\n const seen = new Set<string>()\n for (const s of spec.unionSources) {\n if (typeof s?.collection !== 'string' || s.collection.length === 0) {\n throw new MaterializedViewConfigError(\n 'each unionSources entry must declare a non-empty `collection` string',\n )\n }\n if (typeof s.map !== 'function') {\n throw new MaterializedViewConfigError(\n `unionSources entry for \"${s.collection}\" is missing a \\`map\\` function`,\n )\n }\n if (seen.has(s.collection)) {\n throw new MaterializedViewConfigError(\n `unionSources must reference distinct collections (duplicate: \"${s.collection}\")`,\n )\n }\n seen.add(s.collection)\n }\n if (Array.isArray(spec.groupBy) && spec.groupBy.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": groupBy must not be an empty array — omit it or provide at least one field name`,\n )\n }\n if (spec.aggregate && !spec.groupBy) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": UNION strategy with aggregate requires groupBy — `\n + `use groupBy to declare the bucketing keys, or remove aggregate for a pure dedup MV`,\n )\n }\n // `moneyFields` only has meaning when there's an aggregate to\n // money-rewrite — it keys reducer outputs, so declaring it without\n // `aggregate` is a no-op config mistake.\n if (spec.moneyFields && !spec.aggregate) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": moneyFields requires aggregate — `\n + `moneyFields rewrites sum/min/max reducers over money output fields, `\n + `so it is meaningless without an aggregate spec`,\n )\n }\n // Per-arm joins resolve right-side collections that the union\n // dependency set (built from arm `collection`s alone) does NOT\n // include. The consumer must list those right-side collections in\n // `sources` so writes to them trigger MV refresh.\n if (spec.unionSources.some(s => s.join && s.join.length > 0) && (!spec.sources || spec.sources.length === 0)) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a unionSources arm declares join(s) but `\n + `no \\`sources\\` are listed — declare sources: [...] with the right-side `\n + `(join-target) collection names so writes to them trigger MV refresh`,\n )\n }\n if (spec.predicates) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": predicates are not supported on UNION strategies — `\n + `UNION mode does not use a Query<T> chain, so .wherePredicate() cannot fire. `\n + `Use the query() form, or open an issue if per-arm predicates are needed`,\n )\n }\n }\n // Projection-form invariants (#810). Shape checks only — the\n // semantic ref() check on collect legs (the `on` field must carry a\n // ref() targeting the projection source) runs at first\n // materialization, parity with join-time ref errors.\n if (spec.projection) {\n const projection = spec.projection\n if (typeof projection.source !== 'string' || projection.source.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection.source must be a non-empty collection name`,\n )\n }\n if (typeof projection.map !== 'function') {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection is missing a \\`map\\` function`,\n )\n }\n if (!Array.isArray(projection.joins) || projection.joins.length < 1) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection.joins must declare at least 1 leg — `\n + `a leg-less single-source MV is the query() form's job`,\n )\n }\n const seenAs = new Set<string>()\n for (const leg of projection.joins) {\n const l = leg as { field?: unknown; collect?: unknown; on?: unknown; as?: unknown }\n const isForward = l.field !== undefined\n const isCollect = l.collect !== undefined\n if (isForward && isCollect) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a projection leg cannot declare both \\`field\\` `\n + `(forward) and \\`collect\\` (reverse) — split it into two legs`,\n )\n }\n if (!isForward && !isCollect) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": each projection leg must declare either \\`field\\` `\n + `(forward FK) or \\`collect\\` (reverse one-to-many)`,\n )\n }\n if (isForward && (typeof l.field !== 'string' || l.field.length === 0)) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a forward projection leg must declare a non-empty \\`field\\``,\n )\n }\n if (isCollect) {\n if (typeof l.collect !== 'string' || l.collect.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a collect projection leg must declare a non-empty \\`collect\\` collection name`,\n )\n }\n if (typeof l.on !== 'string' || l.on.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": collect leg for \"${l.collect}\" must declare a non-empty \\`on\\` FK field`,\n )\n }\n }\n if (typeof l.as !== 'string' || l.as.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": each projection leg must declare a non-empty \\`as\\` alias`,\n )\n }\n if (seenAs.has(l.as)) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection legs must attach under distinct \\`as\\` aliases (duplicate: \"${l.as}\")`,\n )\n }\n seenAs.add(l.as)\n }\n // #1140 — `from` wiring, checked here with the rest of the leg shape rather\n // than at vault open: it is pure configuration, so the earliest failure is\n // the best one. Owned by `projection-legs.ts` because the executor and the\n // registry both walk the same graph.\n validateProjectionLegs(spec.name, spec.projection)\n // Post-map grouping invariants — same rules as UNION (the mapped\n // stream feeds the same shared groupAndReduce tail).\n if (Array.isArray(spec.groupBy) && spec.groupBy.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": groupBy must not be an empty array — omit it or provide at least one field name`,\n )\n }\n if (spec.aggregate && !spec.groupBy) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection strategy with aggregate requires groupBy — `\n + `use groupBy to declare the bucketing keys, or remove aggregate for a row-per-primary-record MV`,\n )\n }\n if (spec.moneyFields && !spec.aggregate) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": moneyFields requires aggregate — `\n + `moneyFields rewrites sum/min/max reducers over money output fields, `\n + `so it is meaningless without an aggregate spec`,\n )\n }\n if (spec.predicates) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": predicates are not supported on projection strategies — `\n + `projection mode does not use a Query<T> chain, so .wherePredicate() cannot fire. `\n + `Filter inside projection.map (return null to omit) instead`,\n )\n }\n }\n // i18nLocale + i18nFields drive compute-time i18n resolution of group-key\n // i18nText fields before bucketing — UNION mode (resolved on the unified rows)\n // AND query mode (resolved in GroupedReduction.run before groupAndReduce).\n // i18nLocale without i18nFields cannot resolve anything, so reject it early.\n if (spec.i18nLocale !== undefined && spec.i18nFields === undefined) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": i18nLocale requires i18nFields — `\n + `declare the i18nText descriptors of the group-key fields so they can be `\n + `resolved at the mv layer before bucketing.`,\n )\n }\n if (typeof spec.rowKey !== 'function') {\n throw new ValidationError('withMaterializedView: rowKey is required (no default; see spec § Type surface)')\n }\n if (spec.refresh !== 'eager' && spec.refresh !== 'lazy' && spec.refresh !== 'manual') {\n throw new ValidationError(\n `withMaterializedView: refresh must be 'eager' | 'lazy' | 'manual', got \"${String(spec.refresh)}\"`,\n )\n }\n return {\n __noydb_strategy: 'materialized-view',\n spec,\n }\n}\n"],"mappings":";;;;;;;;;AA8BO,SAAS,qBACd,MAC0B;AAC1B,MAAI,CAAC,KAAK,QAAQ,KAAK,KAAK,WAAW,GAAG;AACxC,UAAM,IAAI,gBAAgB,wCAAwC;AAAA,EACpE;AAEA,QAAM,gBAAgB,CAAC,KAAK,OAAO,KAAK,cAAc,KAAK,UAAU,EAClE,OAAO,CAAC,MAAM,MAAM,MAAS,EAAE;AAClC,MAAI,gBAAgB,GAAG;AACrB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,MAAI,kBAAkB,GAAG;AACvB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,MAAI,KAAK,UAAU,UAAa,OAAO,KAAK,UAAU,YAAY;AAChE,UAAM,IAAI,gBAAgB,qEAAqE;AAAA,EACjG;AAEA,MAAI,KAAK,cAAc;AAKrB,QAAI,KAAK,aAAa,SAAS,GAAG;AAChC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,UAAM,OAAO,oBAAI,IAAY;AAC7B,eAAW,KAAK,KAAK,cAAc;AACjC,UAAI,OAAO,GAAG,eAAe,YAAY,EAAE,WAAW,WAAW,GAAG;AAClE,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AACA,UAAI,OAAO,EAAE,QAAQ,YAAY;AAC/B,cAAM,IAAI;AAAA,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D,QAAI,MAAM,QAAQ,KAAK,OAAO,KAAK,KAAK,QAAQ,WAAW,GAAG;AAC5D,YAAM,IAAI;AAAA,QACR,yBAAyB,KAAK,IAAI;AAAA,MACpC;AAAA,IACF;AACA,QAAI,KAAK,aAAa,CAAC,KAAK,SAAS;AACnC,YAAM,IAAI;AAAA,QACR,yBAAyB,KAAK,IAAI;AAAA,MAEpC;AAAA,IACF;AACA,QAAI,KAAK,eAAe,CAAC,KAAK,WAAW;AACvC,YAAM,IAAI;AAAA,QACR,yBAAyB,KAAK,IAAI;AAAA,MAGpC;AAAA,IACF;AACA,QAAI,KAAK,YAAY;AACnB,YAAM,IAAI;AAAA,QACR,yBAAyB,KAAK,IAAI;AAAA,MAGpC;AAAA,IACF;AAAA,EACF;AAKA,MAAI,KAAK,eAAe,UAAa,KAAK,eAAe,QAAW;AAClE,UAAM,IAAI;AAAA,MACR,yBAAyB,KAAK,IAAI;AAAA,IAGpC;AAAA,EACF;AACA,MAAI,OAAO,KAAK,WAAW,YAAY;AACrC,UAAM,IAAI,gBAAgB,mFAAgF;AAAA,EAC5G;AACA,MAAI,KAAK,YAAY,WAAW,KAAK,YAAY,UAAU,KAAK,YAAY,UAAU;AACpF,UAAM,IAAI;AAAA,MACR,2EAA2E,OAAO,KAAK,OAAO,CAAC;AAAA,IACjG;AAAA,EACF;AACA,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/with-formula/materialized-views/with-materialized-view.ts"],"sourcesContent":["import { MaterializedViewConfigError, ValidationError } from '../../kernel/errors.js'\nimport type { MaterializedViewSpec, MaterializedViewStrategy } from './types.js'\nimport { validateProjectionLegs } from './projection-legs.js' // #1140\n\n/**\n * Register a materialized view: a declared query whose result is\n * persisted as a queryable collection and kept fresh as sources\n * change. Writes go through the standard `Collection.put` pipeline;\n * refresh-driven deletes route through `Collection._internalDelete` so\n * user `onDelete` guards on the output collection aren't tripped by\n * housekeeping.\n *\n * Three registration modes:\n * - **single-source** — declare `query: (db) => Query<TRow>`; the\n * dependency analyzer derives source collections from the plan.\n * - **UNION** — declare `unionSources: [{ collection, map }, ...]`\n * plus optional `groupBy` + `aggregate`; the executor reads each\n * arm, maps to the unified row shape, concatenates, then groups\n * and aggregates.\n * - **projection** (#810) — declare `projection: { source, joins,\n * map }`; one output row per primary record, enriched with\n * forward FK legs and reverse \"collect\" legs before `map` runs.\n *\n * The three modes are mutually exclusive — exactly one of `query` /\n * `unionSources` / `projection` must be set at registration time.\n *\n * See design-history/2026-05-20-dim14-mv-v2-design.md (single-source v2),\n * design-history/2026-05-21-dim14-mv-multikey-and-union.md (UNION),\n * and design-history/2026-07-25-join-projection-mv-design.md (projection).\n */\nexport function withMaterializedView<TRow extends Record<string, unknown>>(\n spec: MaterializedViewSpec<TRow>,\n): MaterializedViewStrategy {\n if (!spec.name || spec.name.length === 0) {\n throw new ValidationError('withMaterializedView: name is required')\n }\n // Mutual exclusion: exactly one of the three forms must be declared.\n const declaredForms = [spec.query, spec.unionSources, spec.projection]\n .filter((f) => f !== undefined).length\n if (declaredForms > 1) {\n throw new MaterializedViewConfigError(\n 'query, unionSources, and projection are mutually exclusive — pick one',\n )\n }\n if (declaredForms === 0) {\n throw new MaterializedViewConfigError(\n 'strategy must declare exactly one of query, unionSources, or projection',\n )\n }\n if (spec.query !== undefined && typeof spec.query !== 'function') {\n throw new ValidationError('withMaterializedView: query must be a function returning a Query<T>')\n }\n // UNION-form invariants.\n if (spec.unionSources) {\n // A single arm is a deliberate shape: map→group→aggregate over\n // ONE collection with a COMPUTED bucket key (e.g. month sliced from a\n // date field) — something the query form's stored-field groupBy cannot\n // express. The executor and dependency analyzer are arm-count-agnostic.\n if (spec.unionSources.length < 1) {\n throw new MaterializedViewConfigError(\n 'unionSources requires at least 1 source collection',\n )\n }\n const seen = new Set<string>()\n for (const s of spec.unionSources) {\n if (typeof s?.collection !== 'string' || s.collection.length === 0) {\n throw new MaterializedViewConfigError(\n 'each unionSources entry must declare a non-empty `collection` string',\n )\n }\n if (typeof s.map !== 'function') {\n throw new MaterializedViewConfigError(\n `unionSources entry for \"${s.collection}\" is missing a \\`map\\` function`,\n )\n }\n if (seen.has(s.collection)) {\n throw new MaterializedViewConfigError(\n `unionSources must reference distinct collections (duplicate: \"${s.collection}\")`,\n )\n }\n seen.add(s.collection)\n }\n if (Array.isArray(spec.groupBy) && spec.groupBy.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": groupBy must not be an empty array — omit it or provide at least one field name`,\n )\n }\n if (spec.aggregate && !spec.groupBy) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": UNION strategy with aggregate requires groupBy — `\n + `use groupBy to declare the bucketing keys, or remove aggregate for a pure dedup MV`,\n )\n }\n // `moneyFields` only has meaning when there's an aggregate to\n // money-rewrite — it keys reducer outputs, so declaring it without\n // `aggregate` is a no-op config mistake.\n if (spec.moneyFields && !spec.aggregate) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": moneyFields requires aggregate — `\n + `moneyFields rewrites sum/min/max reducers over money output fields, `\n + `so it is meaningless without an aggregate spec`,\n )\n }\n // Per-arm joins resolve right-side collections that the union\n // dependency set (built from arm `collection`s alone) does NOT\n // include. The consumer must list those right-side collections in\n // `sources` so writes to them trigger MV refresh.\n if (spec.unionSources.some(s => s.join && s.join.length > 0) && (!spec.sources || spec.sources.length === 0)) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a unionSources arm declares join(s) but `\n + `no \\`sources\\` are listed — declare sources: [...] with the right-side `\n + `(join-target) collection names so writes to them trigger MV refresh`,\n )\n }\n if (spec.predicates) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": predicates are not supported on UNION strategies — `\n + `UNION mode does not use a Query<T> chain, so .wherePredicate() cannot fire. `\n + `Use the query() form, or open an issue if per-arm predicates are needed`,\n )\n }\n }\n // Projection-form invariants (#810). Shape checks only — the\n // semantic ref() check on collect legs (the `on` field must carry a\n // ref() targeting the projection source) runs at first\n // materialization, parity with join-time ref errors.\n if (spec.projection) {\n const projection = spec.projection\n if (typeof projection.source !== 'string' || projection.source.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection.source must be a non-empty collection name`,\n )\n }\n if (typeof projection.map !== 'function') {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection is missing a \\`map\\` function`,\n )\n }\n if (!Array.isArray(projection.joins) || projection.joins.length < 1) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection.joins must declare at least 1 leg — `\n + `a leg-less single-source MV is the query() form's job`,\n )\n }\n const seenAs = new Set<string>()\n for (const leg of projection.joins) {\n const l = leg as { field?: unknown; collect?: unknown; on?: unknown; as?: unknown }\n const isForward = l.field !== undefined\n const isCollect = l.collect !== undefined\n if (isForward && isCollect) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a projection leg cannot declare both \\`field\\` `\n + `(forward) and \\`collect\\` (reverse) — split it into two legs`,\n )\n }\n if (!isForward && !isCollect) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": each projection leg must declare either \\`field\\` `\n + `(forward FK) or \\`collect\\` (reverse one-to-many)`,\n )\n }\n if (isForward && (typeof l.field !== 'string' || l.field.length === 0)) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a forward projection leg must declare a non-empty \\`field\\``,\n )\n }\n if (isCollect) {\n if (typeof l.collect !== 'string' || l.collect.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": a collect projection leg must declare a non-empty \\`collect\\` collection name`,\n )\n }\n if (typeof l.on !== 'string' || l.on.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": collect leg for \"${l.collect}\" must declare a non-empty \\`on\\` FK field`,\n )\n }\n }\n if (typeof l.as !== 'string' || l.as.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": each projection leg must declare a non-empty \\`as\\` alias`,\n )\n }\n if (seenAs.has(l.as)) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection legs must attach under distinct \\`as\\` aliases (duplicate: \"${l.as}\")`,\n )\n }\n seenAs.add(l.as)\n }\n // #1140 — `from` wiring, checked here with the rest of the leg shape rather\n // than at vault open: it is pure configuration, so the earliest failure is\n // the best one. Owned by `projection-legs.ts` because the executor and the\n // registry both walk the same graph.\n validateProjectionLegs(spec.name, spec.projection)\n // Post-map grouping invariants — same rules as UNION (the mapped\n // stream feeds the same shared groupAndReduce tail).\n if (Array.isArray(spec.groupBy) && spec.groupBy.length === 0) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": groupBy must not be an empty array — omit it or provide at least one field name`,\n )\n }\n if (spec.aggregate && !spec.groupBy) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": projection strategy with aggregate requires groupBy — `\n + `use groupBy to declare the bucketing keys, or remove aggregate for a row-per-primary-record MV`,\n )\n }\n if (spec.moneyFields && !spec.aggregate) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": moneyFields requires aggregate — `\n + `moneyFields rewrites sum/min/max reducers over money output fields, `\n + `so it is meaningless without an aggregate spec`,\n )\n }\n if (spec.predicates) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": predicates are not supported on projection strategies — `\n + `projection mode does not use a Query<T> chain, so .wherePredicate() cannot fire. `\n + `Filter inside projection.map (return null to omit) instead`,\n )\n }\n }\n // i18nLocale + i18nFields drive compute-time i18n resolution of group-key\n // i18nText fields before bucketing — UNION mode (resolved on the unified rows)\n // AND query mode (resolved in GroupedReduction.run before groupAndReduce).\n // i18nLocale without i18nFields cannot resolve anything, so reject it early.\n if (spec.i18nLocale !== undefined && spec.i18nFields === undefined) {\n throw new MaterializedViewConfigError(\n `withMaterializedView \"${spec.name}\": i18nLocale requires i18nFields — `\n + `declare the i18nText descriptors of the group-key fields so they can be `\n + `resolved at the mv layer before bucketing.`,\n )\n }\n if (typeof spec.rowKey !== 'function') {\n // Two states, two messages. The original text said \"required\" for BOTH,\n // so passing a field NAME — the shape every other option here takes —\n // reported the key as ABSENT. That collapse cost this author three\n // attempts and produced a probe that measured nothing.\n throw new ValidationError(\n spec.rowKey === undefined\n ? 'withMaterializedView: rowKey is required (no default; see spec § Type surface)'\n : `withMaterializedView: rowKey must be a FUNCTION (row) => string, not a ${typeof spec.rowKey}`\n + ` — it computes each output row's id from the grouped row, so a field NAME is not enough.`\n + ` Pass \\`rowKey: (r) => String(r.${typeof spec.rowKey === 'string' ? String(spec.rowKey) : 'someField'})\\`.`)\n }\n if (spec.refresh !== 'eager' && spec.refresh !== 'lazy' && spec.refresh !== 'manual') {\n throw new ValidationError(\n `withMaterializedView: refresh must be 'eager' | 'lazy' | 'manual', got \"${String(spec.refresh)}\"`,\n )\n }\n return {\n __noydb_strategy: 'materialized-view',\n spec,\n }\n}\n"],"mappings":";;;;;;;;;AA8BO,SAAS,qBACd,MAC0B;AAC1B,MAAI,CAAC,KAAK,QAAQ,KAAK,KAAK,WAAW,GAAG;AACxC,UAAM,IAAI,gBAAgB,wCAAwC;AAAA,EACpE;AAEA,QAAM,gBAAgB,CAAC,KAAK,OAAO,KAAK,cAAc,KAAK,UAAU,EAClE,OAAO,CAAC,MAAM,MAAM,MAAS,EAAE;AAClC,MAAI,gBAAgB,GAAG;AACrB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,MAAI,kBAAkB,GAAG;AACvB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,MAAI,KAAK,UAAU,UAAa,OAAO,KAAK,UAAU,YAAY;AAChE,UAAM,IAAI,gBAAgB,qEAAqE;AAAA,EACjG;AAEA,MAAI,KAAK,cAAc;AAKrB,QAAI,KAAK,aAAa,SAAS,GAAG;AAChC,YAAM,IAAI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ACL,kBAAkB;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-CIGAQBJR.js";
7
7
 
8
8
  // src/with-formula/materialized-views/stale.ts
9
- var loadMVExecutor = lazy(() => import("./executor-YDDC5XGY.js"));
9
+ var loadMVExecutor = lazy(() => import("./executor-5XJNV5H5.js"));
10
10
  var _staleByRegistry = /* @__PURE__ */ new WeakMap();
11
11
  function markMVStale(registry, mvName) {
12
12
  let set = _staleByRegistry.get(registry);
@@ -134,4 +134,4 @@ export {
134
134
  clearMVStale,
135
135
  clearMVStaleFully
136
136
  };
137
- //# sourceMappingURL=chunk-E2MYJGSG.js.map
137
+ //# sourceMappingURL=chunk-AMODH7AU.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  freezeAndDeleteClosure,
3
3
  randomId
4
- } from "./chunk-QHW35ZON.js";
4
+ } from "./chunk-TGPST6FK.js";
5
5
  import {
6
6
  buildAccessibleBundle,
7
7
  resolveAccessibleCollections
8
- } from "./chunk-ZR2YMODS.js";
8
+ } from "./chunk-EKZ6VZYF.js";
9
9
  import {
10
10
  buildRecordEnvelope
11
11
  } from "./chunk-4RUFYGWG.js";
@@ -158,4 +158,4 @@ export {
158
158
  approveWithdrawal,
159
159
  rejectWithdrawal
160
160
  };
161
- //# sourceMappingURL=chunk-B2ZSGYSF.js.map
161
+ //# sourceMappingURL=chunk-B2KCRDJM.js.map
@@ -270,7 +270,7 @@ async function runTransaction(db, fn, options, txInvariants) {
270
270
  db._clearActiveTxContext(ctx);
271
271
  }
272
272
  if (ctx._amendment) {
273
- const { GuardExecutor } = await import("./executor-MZJXBWNM.js");
273
+ const { GuardExecutor } = await import("./executor-AQVXV5GZ.js");
274
274
  try {
275
275
  for (const [vaultName, v] of ctx._amendmentVaults) {
276
276
  const registry = v._getGuardRegistry();
@@ -447,4 +447,4 @@ export {
447
447
  TxCollection,
448
448
  runTransaction
449
449
  };
450
- //# sourceMappingURL=chunk-TO3EQ7HF.js.map
450
+ //# sourceMappingURL=chunk-BLN54W3L.js.map
@@ -11,7 +11,7 @@ import {
11
11
  buildStringFieldEntries,
12
12
  extractSnippet,
13
13
  searchScan
14
- } from "./chunk-COTPDJR5.js";
14
+ } from "./chunk-OMB2ZKIT.js";
15
15
  import {
16
16
  fuseRetrieval
17
17
  } from "./chunk-AURFOK3D.js";
@@ -324,4 +324,4 @@ export {
324
324
  rebuildEmbeddings,
325
325
  syncTierSearch
326
326
  };
327
- //# sourceMappingURL=chunk-IHFXR2VQ.js.map
327
+ //# sourceMappingURL=chunk-BOBFL5TW.js.map
@@ -1,6 +1,3 @@
1
- import {
2
- resolveStaleOnRead
3
- } from "./chunk-PDD75NUZ.js";
4
1
  import {
5
2
  isManifestReservedCollection
6
3
  } from "./chunk-EPFF7LOX.js";
@@ -15,13 +12,16 @@ import {
15
12
  hashFields,
16
13
  validateSatelliteDeclaration
17
14
  } from "./chunk-TUFM4UZP.js";
15
+ import {
16
+ resolveStaleOnRead
17
+ } from "./chunk-SMH6SRX7.js";
18
18
  import {
19
19
  loadFence
20
20
  } from "./chunk-GM4IM7TC.js";
21
21
  import {
22
22
  buildPersistedIndexCallbacks,
23
23
  syncTierSearch
24
- } from "./chunk-IHFXR2VQ.js";
24
+ } from "./chunk-BOBFL5TW.js";
25
25
  import {
26
26
  isBaseLive,
27
27
  liveBaseIdSet
@@ -36,7 +36,7 @@ import {
36
36
  NO_TIERS,
37
37
  classifySealedShred,
38
38
  syncDerivedOutputs
39
- } from "./chunk-RTYJRFQO.js";
39
+ } from "./chunk-EWPRPP3M.js";
40
40
  import {
41
41
  NO_PORTABILITY
42
42
  } from "./chunk-BZ3534YM.js";
@@ -61,7 +61,7 @@ import {
61
61
  import {
62
62
  CustodyApi,
63
63
  NO_CUSTODY
64
- } from "./chunk-Y4MJQ2UG.js";
64
+ } from "./chunk-QQ2YMQZU.js";
65
65
  import {
66
66
  DEFAULT_POSTURE,
67
67
  EXPORT_REDACTION_MARKER,
@@ -78,7 +78,7 @@ import {
78
78
  resolveComputedEdges,
79
79
  resolveDescribeFieldIds,
80
80
  resolveVirtualMoneyFields
81
- } from "./chunk-BWXGSSFX.js";
81
+ } from "./chunk-4SZMZAYN.js";
82
82
  import {
83
83
  findMatchingIdsByPairs
84
84
  } from "./chunk-TFMM5DBB.js";
@@ -92,7 +92,7 @@ import {
92
92
  } from "./chunk-KCUIMITG.js";
93
93
  import {
94
94
  derivePersistedSchema
95
- } from "./chunk-URHRIAV6.js";
95
+ } from "./chunk-REDOOY2Q.js";
96
96
  import {
97
97
  findRollupSpecForIntent,
98
98
  forgetDerivedFanout,
@@ -135,7 +135,7 @@ import {
135
135
  resolvePeriodKey,
136
136
  resolveReopenState,
137
137
  samePartition
138
- } from "./chunk-BERJ4AWW.js";
138
+ } from "./chunk-VGXZT72I.js";
139
139
  import {
140
140
  PERIODS_COLLECTION,
141
141
  PERIOD_ARCHIVES_COLLECTION,
@@ -153,7 +153,7 @@ import {
153
153
  import {
154
154
  TxContext,
155
155
  bestEffortRevert
156
- } from "./chunk-TO3EQ7HF.js";
156
+ } from "./chunk-BLN54W3L.js";
157
157
  import {
158
158
  lazy
159
159
  } from "./chunk-5D2ALSM5.js";
@@ -161,7 +161,7 @@ import {
161
161
  InvertedIndex,
162
162
  MemoryIndexStore,
163
163
  NO_SEARCH
164
- } from "./chunk-COTPDJR5.js";
164
+ } from "./chunk-OMB2ZKIT.js";
165
165
  import {
166
166
  NO_SEALED_RECORD
167
167
  } from "./chunk-6YXCPL4T.js";
@@ -540,7 +540,7 @@ function validateSecretModeOptions(options) {
540
540
  }
541
541
  async function resolveEffectiveSecret(options, store, vault) {
542
542
  if (options.secretMode === "managed") {
543
- const { resolveManagedSecret } = await import("./managed-secret-P3JQ7ZG4.js");
543
+ const { resolveManagedSecret } = await import("./managed-secret-NHRYG7CD.js");
544
544
  return resolveManagedSecret(store, vault, options.sealingKey);
545
545
  }
546
546
  return options.secret;
@@ -558,7 +558,7 @@ function ownerKeyringOptions(options, secret) {
558
558
 
559
559
  // src/port/by/default-provider.ts
560
560
  async function createDefaultMesh(store) {
561
- const { StoreMesh } = await import("./store-coordination-provider-O2VUEMJH.js");
561
+ const { StoreMesh } = await import("./store-coordination-provider-RX2CGWXV.js");
562
562
  return new StoreMesh(store);
563
563
  }
564
564
 
@@ -1325,7 +1325,7 @@ async function commitSequentially(ctx, entries, priors) {
1325
1325
  }
1326
1326
 
1327
1327
  // src/with-formula/computed/lazy.ts
1328
- var loadComputed = lazy(() => import("./computed-LSEZYRJS.js"));
1328
+ var loadComputed = lazy(() => import("./computed-VPOKQK4N.js"));
1329
1329
  async function loadEvalComputedFields() {
1330
1330
  return (await loadComputed()).evalComputedFields;
1331
1331
  }
@@ -1994,7 +1994,7 @@ var Collection = class {
1994
1994
  }
1995
1995
  /** JSON Schema for this collection with describe() metadata as x- extensions. */
1996
1996
  async toJSONSchema() {
1997
- const { buildJsonSchema } = await import("./json-schema-I22JCYCG.js");
1997
+ const { buildJsonSchema } = await import("./json-schema-V3M5MUCM.js");
1998
1998
  const desc = await this.describe({});
1999
1999
  let base = null;
2000
2000
  if (this.schema !== void 0) {
@@ -2110,7 +2110,7 @@ var Collection = class {
2110
2110
  }
2111
2111
  await this.onAccess?.("find", "*");
2112
2112
  if (hits.length === 0) return [];
2113
- const { verifyDigestField } = await import("./verify-JBXCAGDL.js");
2113
+ const { verifyDigestField } = await import("./verify-KOV2G5D6.js");
2114
2114
  const policy = {
2115
2115
  normalize: spec.verifyNormalize ?? "password",
2116
2116
  notLastN: spec.notLastN ?? 0,
@@ -2322,7 +2322,7 @@ var Collection = class {
2322
2322
  }
2323
2323
  }
2324
2324
  if (this.materializedViewSource !== void 0) {
2325
- const { resolveStaleMVOnRead } = await import("./stale-2CHKZTMK.js");
2325
+ const { resolveStaleMVOnRead } = await import("./stale-AU74OPUW.js");
2326
2326
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
2327
2327
  }
2328
2328
  let record;
@@ -2854,7 +2854,7 @@ var Collection = class {
2854
2854
  */
2855
2855
  async dispatchMaterializedViews(id, record, wave) {
2856
2856
  if (this.materializedViewSource === void 0) return;
2857
- const { dispatchMaterializedViews } = await import("./dispatch-PDP5TA73.js");
2857
+ const { dispatchMaterializedViews } = await import("./dispatch-GGFBWQU7.js");
2858
2858
  return dispatchMaterializedViews(this.#mvDispatchCtx(this.materializedViewSource), id, record, wave);
2859
2859
  }
2860
2860
  /**
@@ -3020,13 +3020,13 @@ var Collection = class {
3020
3020
  * dispatch wave's per-target dedup; `undefined` on the local-write path (byte-identical). */
3021
3021
  async dispatchDerivations(id, record, version, wave, prior) {
3022
3022
  if (this.derivationSource === void 0) return;
3023
- const { dispatchDerivations } = await import("./dispatch-MSTR5VBI.js");
3023
+ const { dispatchDerivations } = await import("./dispatch-DC3LQJ3S.js");
3024
3024
  return dispatchDerivations(this.#derivationDispatchCtx(), id, record, version, wave, prior);
3025
3025
  }
3026
3026
  /** @internal — trigger fan-out for a deleted parent (#1249); see dispatch.ts. */
3027
3027
  async dispatchTriggerDerivationsOnDelete(id, deleted) {
3028
3028
  if (this.derivationSource === void 0) return;
3029
- const { dispatchTriggerDerivationsOnDelete } = await import("./dispatch-MSTR5VBI.js");
3029
+ const { dispatchTriggerDerivationsOnDelete } = await import("./dispatch-DC3LQJ3S.js");
3030
3030
  return dispatchTriggerDerivationsOnDelete(this.#derivationDispatchCtx(), id, deleted);
3031
3031
  }
3032
3032
  /**
@@ -3338,7 +3338,7 @@ var Collection = class {
3338
3338
  */
3339
3339
  async dispatchArrayDerivationsOnDelete(id, eraseRecordShapeToo = false) {
3340
3340
  if (this.derivationSource === void 0) return 0;
3341
- const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-MSTR5VBI.js");
3341
+ const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-DC3LQJ3S.js");
3342
3342
  return dispatchArrayDerivationsOnDelete(this.#derivationDeleteCtx(this.derivationSource), id, eraseRecordShapeToo);
3343
3343
  }
3344
3344
  /**
@@ -3352,7 +3352,7 @@ var Collection = class {
3352
3352
  */
3353
3353
  async dispatchMaterializedViewsOnDelete(id) {
3354
3354
  if (this.materializedViewSource === void 0) return { deleted: 0, residueUndecodable: [], residueDeclined: [] };
3355
- const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-PDP5TA73.js");
3355
+ const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-GGFBWQU7.js");
3356
3356
  return dispatchMaterializedViewsOnDelete(this.#mvDispatchCtx(this.materializedViewSource), id);
3357
3357
  }
3358
3358
  /**
@@ -3372,7 +3372,7 @@ var Collection = class {
3372
3372
  );
3373
3373
  }
3374
3374
  if (this.materializedViewSource !== void 0) {
3375
- const { resolveStaleMVOnRead } = await import("./stale-2CHKZTMK.js");
3375
+ const { resolveStaleMVOnRead } = await import("./stale-AU74OPUW.js");
3376
3376
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
3377
3377
  }
3378
3378
  await this.ensureHydrated();
@@ -4482,14 +4482,14 @@ var Collection = class {
4482
4482
  /** C-A/R10: persist the classified marker once per classified handle (store I/O in config-drift.ts). */
4483
4483
  async _ensureClassifiedMarker() {
4484
4484
  if (this._markerPersisted || this.vdigFields === null) return;
4485
- const { persistClassifiedMarkerForFields } = await import("./classified-marker-67HBIJMZ.js");
4485
+ const { persistClassifiedMarkerForFields } = await import("./classified-marker-OO65UYXN.js");
4486
4486
  await persistClassifiedMarkerForFields(this.adapter, this.vault, this.name, this.vdigFields, await this.getDEK(this.name));
4487
4487
  this._markerPersisted = true;
4488
4488
  }
4489
4489
  /** C-A/R10 drift signal — the marker's declared digest-only set, memoized to one store read per handle (see config-drift.ts). */
4490
4490
  async _classifiedMarkerDigestOnly() {
4491
4491
  if (this._markerDigestOnlyCache !== void 0) return this._markerDigestOnlyCache;
4492
- const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-67HBIJMZ.js");
4492
+ const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-OO65UYXN.js");
4493
4493
  this._markerDigestOnlyCache = await readClassifiedMarkerDigestOnly(this.adapter, this.vault, this.name, await this.getDEK(this.name));
4494
4494
  return this._markerDigestOnlyCache;
4495
4495
  }
@@ -6115,7 +6115,7 @@ var VaultLinks = class {
6115
6115
  // src/with-shape/links/lazy-handle.ts
6116
6116
  function makeLazyLinkSetHandle(d) {
6117
6117
  let engine = null;
6118
- const load = () => engine ??= import("./link-set-6RAHEKZN.js").then(
6118
+ const load = () => engine ??= import("./link-set-67CAMUAL.js").then(
6119
6119
  ({ LinkSet }) => new LinkSet(d.adapter, d.vault, d.name, d.spec, d.encrypted, d.getDEK, d.actor, d.emitter, d.endpointExists)
6120
6120
  );
6121
6121
  return {
@@ -6766,7 +6766,7 @@ function declareSatellite(ctx, collectionName, options, existingRegistry) {
6766
6766
  ctx.forEachSyncEngine((e) => e.remirrorPairResolvers([spec.base, spec.satellite]));
6767
6767
  const registry = reg;
6768
6768
  const baseSchema = ctx.getBaseSchema(spec.base);
6769
- void import("./post-register-BPJ36A6D.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
6769
+ void import("./post-register-HIYY4Y5S.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
6770
6770
  });
6771
6771
  return reg;
6772
6772
  }
@@ -7741,7 +7741,7 @@ var Vault = class {
7741
7741
  const strategies = options.schemaUpdate ?? [];
7742
7742
  const work = (async () => {
7743
7743
  const dek = await this.getDEK(collectionName);
7744
- const { persistSchemaIfNeeded } = await import("./register-AEOOGKNO.js");
7744
+ const { persistSchemaIfNeeded } = await import("./register-7OJWAWT5.js");
7745
7745
  const result = await persistSchemaIfNeeded({
7746
7746
  store: this.adapter,
7747
7747
  vault: this.name,
@@ -7891,7 +7891,7 @@ var Vault = class {
7891
7891
  const work = (async () => {
7892
7892
  try {
7893
7893
  const dek = await this.getDEK(collectionName);
7894
- await (await import("./register-AEOOGKNO.js")).persistSchemaIfNeeded({
7894
+ await (await import("./register-7OJWAWT5.js")).persistSchemaIfNeeded({
7895
7895
  store: this.adapter,
7896
7896
  vault: this.name,
7897
7897
  collectionName,
@@ -7937,7 +7937,7 @@ var Vault = class {
7937
7937
  * writes (unfenced walk — see `with-shape/satellites/migrate-cek.ts`); resumable.
7938
7938
  */
7939
7939
  async migrateSatellitePerRecordKeys(satelliteName) {
7940
- const { migrateSatelliteCek } = await import("./migrate-cek-25KNTS5U.js");
7940
+ const { migrateSatelliteCek } = await import("./migrate-cek-5ENH64AA.js");
7941
7941
  return migrateSatelliteCek(satelliteName, this.collection(satelliteName, { perRecordKeys: true }));
7942
7942
  }
7943
7943
  /**
@@ -8119,7 +8119,7 @@ var Vault = class {
8119
8119
  async _ensureFenceCoordination() {
8120
8120
  if (this.#fenceCoordinationStarted) return;
8121
8121
  this.#fenceCoordinationStarted = true;
8122
- const { FenceWatcher } = await import("./fence-watcher-ZVSMLKQD.js");
8122
+ const { FenceWatcher } = await import("./fence-watcher-U2PW6JU5.js");
8123
8123
  if (!this.#fenceCoordinationStarted) return;
8124
8124
  this.#fenceWatcher = new FenceWatcher({
8125
8125
  coordination: this.noydb.mesh,
@@ -8568,7 +8568,7 @@ var Vault = class {
8568
8568
  */
8569
8569
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
8570
8570
  async _loadPodSigner() {
8571
- const { loadSigner } = await import("./signer-7NK7TMWU.js");
8571
+ const { loadSigner } = await import("./signer-5K3WDHOC.js");
8572
8572
  return loadSigner(this.adapter, this.name, this.getDEK);
8573
8573
  }
8574
8574
  async writeExportAudit(entry) {
@@ -8797,7 +8797,7 @@ var Vault = class {
8797
8797
  const blobsEnabled = this.strategies.blobs !== NO_BLOBS;
8798
8798
  const actor = this.keyring.userId;
8799
8799
  const fanoutStats = { recordsErased: 0, aggregatesRecomputed: 0, residueFrozen: [], lookupReferencesCascaded: 0, lookupReferencesNullified: 0, lookupReferencesResidue: [], derivedResidueUndecodable: [], derivedResidueDeclined: [] };
8800
- const { partitionSealedCekKeys, shouldSkipBlobScan, bumpResidueCount, residueNoticesFromMap } = await import("./purge-scope-FGNNLWHD.js");
8800
+ const { partitionSealedCekKeys, shouldSkipBlobScan, bumpResidueCount, residueNoticesFromMap } = await import("./purge-scope-4HEFPDOW.js");
8801
8801
  const scopedPurge = this.strategies.forget.scopedPurge === true;
8802
8802
  const sealedCekScopedSkipped = /* @__PURE__ */ new Map();
8803
8803
  const blobScopedSkipped = /* @__PURE__ */ new Map();
@@ -9058,8 +9058,8 @@ var Vault = class {
9058
9058
  async _initGuards(handles) {
9059
9059
  if (handles.length === 0) return;
9060
9060
  const [{ GuardRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
9061
- import("./registry-SHMGHEK4.js"),
9062
- import("./read-only-facade-CHCKSEPD.js")
9061
+ import("./registry-4AYVUNXK.js"),
9062
+ import("./read-only-facade-BIGO37U3.js")
9063
9063
  ]);
9064
9064
  const registry = new GuardRegistry();
9065
9065
  for (const h of handles) registry.register(h.spec);
@@ -9086,8 +9086,8 @@ var Vault = class {
9086
9086
  async _initDerivations(handles) {
9087
9087
  if (handles.length === 0) return;
9088
9088
  const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
9089
- import("./registry-D2YXKRYC.js"),
9090
- import("./read-only-facade-CHCKSEPD.js")
9089
+ import("./registry-HDINK5QW.js"),
9090
+ import("./read-only-facade-BIGO37U3.js")
9091
9091
  ]);
9092
9092
  const registry = new DerivationRegistry();
9093
9093
  for (const h of handles) {
@@ -9118,7 +9118,7 @@ var Vault = class {
9118
9118
  */
9119
9119
  async _initMaterializedViews(handles) {
9120
9120
  if (handles.length === 0) return;
9121
- const { MaterializedViewRegistry } = await import("./registry-I6FP4677.js");
9121
+ const { MaterializedViewRegistry } = await import("./registry-5MVJGPXW.js");
9122
9122
  const registry = new MaterializedViewRegistry();
9123
9123
  this.materializedViewRegistry = registry;
9124
9124
  const db = this;
@@ -9143,7 +9143,7 @@ var Vault = class {
9143
9143
  */
9144
9144
  async _initOverlayedViews(handles) {
9145
9145
  if (handles.length === 0) return;
9146
- const { OverlayedViewRegistry } = await import("./registry-SKSOUXNF.js");
9146
+ const { OverlayedViewRegistry } = await import("./registry-23WF3TGH.js");
9147
9147
  const registry = new OverlayedViewRegistry();
9148
9148
  const mvRegistry = this.materializedViewRegistry;
9149
9149
  const overlayNames = /* @__PURE__ */ new Set();
@@ -9206,14 +9206,14 @@ var Vault = class {
9206
9206
  if (!reg) {
9207
9207
  throw new Error(`refreshView: no MV registered with name "${name}"`);
9208
9208
  }
9209
- const { MaterializedViewExecutor } = await import("./executor-YDDC5XGY.js");
9209
+ const { MaterializedViewExecutor } = await import("./executor-5XJNV5H5.js");
9210
9210
  const result = await MaterializedViewExecutor.refresh(reg, {
9211
9211
  getCollection: (n) => this.collection(n),
9212
9212
  getActiveTxContext: () => this.noydb._activeTxContextOrNull,
9213
9213
  getQueryContext: () => this,
9214
9214
  dispatchCtx: this._dispatchCtx({ collection: name, id: "refreshView" })
9215
9215
  });
9216
- const { clearMVStaleFully } = await import("./stale-2CHKZTMK.js");
9216
+ const { clearMVStaleFully } = await import("./stale-AU74OPUW.js");
9217
9217
  await clearMVStaleFully(this.adapter, this.name, registry, name);
9218
9218
  return result;
9219
9219
  }
@@ -9226,10 +9226,10 @@ var Vault = class {
9226
9226
  if (registry === null) return { derived: 0, failed: 0, skippedFrozen: 0 };
9227
9227
  const strategies = registry.strategiesForSource(sourceCollection);
9228
9228
  if (strategies.length === 0) return { derived: 0, failed: 0, skippedFrozen: 0 };
9229
- const { DerivationExecutor } = await import("./executor-TOLPBHOC.js");
9229
+ const { DerivationExecutor } = await import("./executor-5NIMLSKZ.js");
9230
9230
  const sourceColl = this.collection(sourceCollection);
9231
9231
  const records = await sourceColl.list();
9232
- const ctx = { vault: this.derivationFacade ?? new (await import("./read-only-facade-CHCKSEPD.js")).ReadOnlyVaultFacade(this, "derivation") };
9232
+ const ctx = { vault: this.derivationFacade ?? new (await import("./read-only-facade-BIGO37U3.js")).ReadOnlyVaultFacade(this, "derivation") };
9233
9233
  let derived = 0;
9234
9234
  let failed = 0;
9235
9235
  let skippedFrozen = 0;
@@ -9253,7 +9253,7 @@ var Vault = class {
9253
9253
  if (!outSpec) continue;
9254
9254
  const outputColl = this.collection(outSpec.collection);
9255
9255
  if (out.kind === "array") {
9256
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-TSFPXY5C.js");
9256
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-HJIVUPTD.js");
9257
9257
  const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key, this.getDEK, this.encrypted);
9258
9258
  const prevKeys = new Set(prior?.keys ?? []);
9259
9259
  const newKeysList = out.entries.map((e) => e.key);
@@ -9480,7 +9480,7 @@ var Vault = class {
9480
9480
  * collection.
9481
9481
  */
9482
9482
  async delegate(opts) {
9483
- const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-OLJUWTVA.js");
9483
+ const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-VRYMQRCF.js");
9484
9484
  if (!this.keyring.kek) {
9485
9485
  throw new ValidationError(
9486
9486
  "issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (secret) first."
@@ -9502,7 +9502,7 @@ var Vault = class {
9502
9502
  * if the id does not exist.
9503
9503
  */
9504
9504
  async revokeDelegation(id) {
9505
- const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-OLJUWTVA.js");
9505
+ const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-VRYMQRCF.js");
9506
9506
  await revokeDelegation(this.adapter, this.name, id);
9507
9507
  void DELEGATIONS_COLLECTION;
9508
9508
  }
@@ -9755,7 +9755,7 @@ var Vault = class {
9755
9755
  * @see design-history/2026-05-22-schema-dump-design.md
9756
9756
  */
9757
9757
  async dumpSchema(opts = {}) {
9758
- const { dumpVaultSchema } = await import("./walk-P3E6QSNC.js");
9758
+ const { dumpVaultSchema } = await import("./walk-ERAJ5RHO.js");
9759
9759
  return dumpVaultSchema(this, opts);
9760
9760
  }
9761
9761
  /**
@@ -9851,7 +9851,7 @@ var Vault = class {
9851
9851
  * separate vault instances now.
9852
9852
  */
9853
9853
  async getPodHandle() {
9854
- const { buildPodHandle } = await import("./pod-handle-6II7KFBR.js");
9854
+ const { buildPodHandle } = await import("./pod-handle-S7AMCJIF.js");
9855
9855
  return buildPodHandle(this.adapter, this.name);
9856
9856
  }
9857
9857
  /**
@@ -9883,7 +9883,7 @@ var Vault = class {
9883
9883
  * both modes round-trip cleanly.
9884
9884
  */
9885
9885
  async dump() {
9886
- const { dumpVault } = await import("./backup-R6A4VZRX.js");
9886
+ const { dumpVault } = await import("./backup-AKWIMYWU.js");
9887
9887
  return dumpVault(this.backupContext());
9888
9888
  }
9889
9889
  /**
@@ -9935,7 +9935,7 @@ var Vault = class {
9935
9935
  * — there's no chain to verify against.
9936
9936
  */
9937
9937
  async load(backupJson) {
9938
- const { loadVault } = await import("./backup-R6A4VZRX.js");
9938
+ const { loadVault } = await import("./backup-AKWIMYWU.js");
9939
9939
  return loadVault(this.backupContext(), backupJson);
9940
9940
  }
9941
9941
  /**
@@ -9967,7 +9967,7 @@ var Vault = class {
9967
9967
  * way to detect tampering of an in-place vault.
9968
9968
  */
9969
9969
  async verifyBackupIntegrity() {
9970
- const { verifyBackupIntegrity } = await import("./backup-R6A4VZRX.js");
9970
+ const { verifyBackupIntegrity } = await import("./backup-AKWIMYWU.js");
9971
9971
  return verifyBackupIntegrity(this.backupContext());
9972
9972
  }
9973
9973
  /**
@@ -10197,7 +10197,7 @@ var Vault = class {
10197
10197
  * is the live validator object, not a serialization of it).
10198
10198
  */
10199
10199
  async exportJSON(opts = {}) {
10200
- const { exportVaultJSON } = await import("./backup-R6A4VZRX.js");
10200
+ const { exportVaultJSON } = await import("./backup-AKWIMYWU.js");
10201
10201
  return exportVaultJSON(this.backupContext(), opts);
10202
10202
  }
10203
10203
  };
@@ -12125,7 +12125,7 @@ var Noydb = class {
12125
12125
  if (!facade) return;
12126
12126
  const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
12127
12127
  await registry.runChecks(e.collection, incoming, ctx);
12128
- const { GuardExecutor } = await import("./executor-MZJXBWNM.js");
12128
+ const { GuardExecutor } = await import("./executor-AQVXV5GZ.js");
12129
12129
  for (const g of guards) {
12130
12130
  await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
12131
12131
  }
@@ -13497,7 +13497,7 @@ async function createNoydb(options) {
13497
13497
  if (!options.store) options = { ...options, store: memoryStore() };
13498
13498
  validateSecretModeOptions(options);
13499
13499
  if (!options.mesh) options = { ...options, mesh: await createDefaultMesh(options.store) };
13500
- if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-UE2XQKDN.js")).createUserApi };
13500
+ if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-JPZT6BDD.js")).createUserApi };
13501
13501
  if (!options.policyFactory) {
13502
13502
  const policyModule = await import("./policy/index.js");
13503
13503
  options = { ...options, policyFactory: policyModule.createNoydbPolicy, policyCheckGateFn: policyModule.checkGate };
@@ -13530,4 +13530,4 @@ export {
13530
13530
  Noydb,
13531
13531
  createNoydb
13532
13532
  };
13533
- //# sourceMappingURL=chunk-ZVCC36XQ.js.map
13533
+ //# sourceMappingURL=chunk-DRB6IHPS.js.map
@@ -3,9 +3,9 @@ import {
3
3
  } from "./chunk-TPHAGLUH.js";
4
4
  import {
5
5
  ViaGraph,
6
- computedEntryParts,
6
+ matchTargetFieldNames,
7
7
  schemaFieldKeys
8
- } from "./chunk-BWXGSSFX.js";
8
+ } from "./chunk-4SZMZAYN.js";
9
9
  import {
10
10
  sha256Hex
11
11
  } from "./chunk-SL3JAAKN.js";
@@ -36,23 +36,6 @@ function stripArtifactSuffix(displayId) {
36
36
  const suffix = `.${WHOLE_RECORD}`;
37
37
  return displayId.endsWith(suffix) ? displayId.slice(0, -suffix.length) : displayId;
38
38
  }
39
- function matchTargetFieldNames(opts) {
40
- const declared = [];
41
- const virtual = [];
42
- for (const [field, entry] of Object.entries(opts.computed ?? {})) {
43
- declared.push(field);
44
- const parts = computedEntryParts(entry);
45
- if (parts.mode === "virtual") virtual.push(field);
46
- }
47
- for (const [field, spec] of Object.entries(opts.viaFields ?? {})) {
48
- declared.push(field);
49
- const descriptors = spec.descriptors ?? [];
50
- for (const d of descriptors) {
51
- if (d._viaBrand === "computed" && d.mode === "virtual") virtual.push(field);
52
- }
53
- }
54
- return { declared, virtual };
55
- }
56
39
  var DerivationRegistry = class {
57
40
  _bySource = /* @__PURE__ */ new Map();
58
41
  _byOutput = /* @__PURE__ */ new Map();
@@ -252,4 +235,4 @@ var DerivationRegistry = class {
252
235
  export {
253
236
  DerivationRegistry
254
237
  };
255
- //# sourceMappingURL=chunk-AJQY44CE.js.map
238
+ //# sourceMappingURL=chunk-EKVNVJVV.js.map