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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/CHANGELOG.md +169 -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-PQKG5AHH.js → chunk-6X6SEMEE.js} +4 -2
  20. package/dist/{chunk-PQKG5AHH.js.map → chunk-6X6SEMEE.js.map} +1 -1
  21. package/dist/{chunk-E2MYJGSG.js → chunk-AMODH7AU.js} +2 -2
  22. package/dist/{chunk-B2ZSGYSF.js → chunk-B2KCRDJM.js} +3 -3
  23. package/dist/{chunk-TO3EQ7HF.js → chunk-BLN54W3L.js} +2 -2
  24. package/dist/{chunk-IHFXR2VQ.js → chunk-BOBFL5TW.js} +2 -2
  25. package/dist/{chunk-ZR2YMODS.js → chunk-EKZ6VZYF.js} +2 -2
  26. package/dist/{chunk-RTYJRFQO.js → chunk-EWPRPP3M.js} +1 -1
  27. package/dist/{chunk-VGICZPVE.js → chunk-FUJSIP4K.js} +2 -2
  28. package/dist/{chunk-BWXGSSFX.js → chunk-NJXX55QX.js} +79 -16
  29. package/dist/chunk-NJXX55QX.js.map +1 -0
  30. package/dist/{chunk-PKJ43CMD.js → chunk-NLOLF6LD.js} +2 -2
  31. package/dist/{chunk-COTPDJR5.js → chunk-OMB2ZKIT.js} +8 -8
  32. package/dist/{chunk-BMELYFHU.js → chunk-P3KOF624.js} +3 -3
  33. package/dist/{chunk-Y4MJQ2UG.js → chunk-QQ2YMQZU.js} +2 -2
  34. package/dist/{chunk-URHRIAV6.js → chunk-REDOOY2Q.js} +2 -2
  35. package/dist/chunk-REDOOY2Q.js.map +1 -0
  36. package/dist/{chunk-YCXICMOY.js → chunk-RJ7NN2UR.js} +2 -2
  37. package/dist/{chunk-PDD75NUZ.js → chunk-SMH6SRX7.js} +2 -2
  38. package/dist/{chunk-QHW35ZON.js → chunk-TGPST6FK.js} +2 -2
  39. package/dist/{chunk-BERJ4AWW.js → chunk-VGXZT72I.js} +2 -2
  40. package/dist/{chunk-ZVCC36XQ.js → chunk-WL36WA3O.js} +55 -55
  41. package/dist/{chunk-2Z47NMFK.js → chunk-WZW37ZHL.js} +2 -2
  42. package/dist/{chunk-SXCYYMVS.js → chunk-YINEDONN.js} +5 -5
  43. package/dist/{chunk-AJQY44CE.js → chunk-ZXLZ62R5.js} +3 -20
  44. package/dist/chunk-ZXLZ62R5.js.map +1 -0
  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-F5CABCU4.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-BOHIKFWG.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-ZR2YMODS.js.map → chunk-EKZ6VZYF.js.map} +0 -0
  190. /package/dist/{chunk-RTYJRFQO.js.map → chunk-EWPRPP3M.js.map} +0 -0
  191. /package/dist/{chunk-VGICZPVE.js.map → chunk-FUJSIP4K.js.map} +0 -0
  192. /package/dist/{chunk-PKJ43CMD.js.map → chunk-NLOLF6LD.js.map} +0 -0
  193. /package/dist/{chunk-COTPDJR5.js.map → chunk-OMB2ZKIT.js.map} +0 -0
  194. /package/dist/{chunk-BMELYFHU.js.map → chunk-P3KOF624.js.map} +0 -0
  195. /package/dist/{chunk-Y4MJQ2UG.js.map → chunk-QQ2YMQZU.js.map} +0 -0
  196. /package/dist/{chunk-YCXICMOY.js.map → chunk-RJ7NN2UR.js.map} +0 -0
  197. /package/dist/{chunk-PDD75NUZ.js.map → chunk-SMH6SRX7.js.map} +0 -0
  198. /package/dist/{chunk-QHW35ZON.js.map → chunk-TGPST6FK.js.map} +0 -0
  199. /package/dist/{chunk-BERJ4AWW.js.map → chunk-VGXZT72I.js.map} +0 -0
  200. /package/dist/{chunk-ZVCC36XQ.js.map → chunk-WL36WA3O.js.map} +0 -0
  201. /package/dist/{chunk-2Z47NMFK.js.map → chunk-WZW37ZHL.js.map} +0 -0
  202. /package/dist/{chunk-SXCYYMVS.js.map → chunk-YINEDONN.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-F5CABCU4.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-BOHIKFWG.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
package/dist/by/index.js CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  runDrainBarrier
4
4
  } from "../chunk-VTFVLCUH.js";
5
5
  import "../chunk-7O3Y4PPD.js";
6
- import "../chunk-PZ5AY32C.js";
7
6
  export {
8
7
  isQuorum,
9
8
  runDrainBarrier
@@ -5,22 +5,22 @@ import {
5
5
  describeExtraction,
6
6
  unsealDeks,
7
7
  withCargo
8
- } from "../chunk-SXCYYMVS.js";
9
- import {
10
- extractPartition,
11
- walkClosure
12
- } from "../chunk-DJ3LNNZQ.js";
8
+ } from "../chunk-YINEDONN.js";
13
9
  import {
14
10
  diffVault
15
11
  } from "../chunk-LFUID7OW.js";
12
+ import {
13
+ extractPartition,
14
+ walkClosure
15
+ } from "../chunk-3LK2XZCW.js";
16
16
  import {
17
17
  createDeedOwner,
18
18
  isDeedVault,
19
19
  liberateVault,
20
20
  loadDeedMarker
21
- } from "../chunk-YCXICMOY.js";
22
- import "../chunk-QHW35ZON.js";
23
- import "../chunk-ZR2YMODS.js";
21
+ } from "../chunk-RJ7NN2UR.js";
22
+ import "../chunk-TGPST6FK.js";
23
+ import "../chunk-EKZ6VZYF.js";
24
24
  import {
25
25
  NO_CARGO
26
26
  } from "../chunk-NQKIUNW5.js";
@@ -31,9 +31,9 @@ import {
31
31
  } from "../chunk-VTFVLCUH.js";
32
32
  import {
33
33
  CustodyApi
34
- } from "../chunk-Y4MJQ2UG.js";
34
+ } from "../chunk-QQ2YMQZU.js";
35
35
  import "../chunk-WWNYSV7S.js";
36
- import "../chunk-PKJ43CMD.js";
36
+ import "../chunk-NLOLF6LD.js";
37
37
  import "../chunk-MLO75SFJ.js";
38
38
  import {
39
39
  fuseRetrieval
@@ -88,7 +88,6 @@ import {
88
88
  ValidationError,
89
89
  VaultTemplateNotFoundError
90
90
  } from "../chunk-7O3Y4PPD.js";
91
- import "../chunk-PZ5AY32C.js";
92
91
  export {
93
92
  AdoptionStateError,
94
93
  CargoNotEnabledError,
@@ -201,7 +201,7 @@ var engineCtx = (ctx) => ({
201
201
  function withClassified() {
202
202
  return {
203
203
  async reveal(ctx, id, field) {
204
- const { revealSealedField } = await import("./reveal-DDQBDWPM.js");
204
+ const { revealSealedField } = await import("./reveal-IMGQ2EE5.js");
205
205
  const value = await revealSealedField({
206
206
  collection: ctx.collection,
207
207
  encrypted: ctx.encrypted,
@@ -213,26 +213,26 @@ function withClassified() {
213
213
  return value;
214
214
  },
215
215
  async verify(ctx, id, field, candidate) {
216
- const { verifyDigestField } = await import("./verify-JBXCAGDL.js");
216
+ const { verifyDigestField } = await import("./verify-KOV2G5D6.js");
217
217
  const verdict = await verifyDigestField(engineCtx(ctx), id, field, candidate, policyOf(ctx.spec));
218
218
  await ctx.onAccess?.("verify", id);
219
219
  return verdict;
220
220
  },
221
221
  async verifyText(ctx, id, field, candidate) {
222
- const { verifyTextField } = await import("./verify-JBXCAGDL.js");
222
+ const { verifyTextField } = await import("./verify-KOV2G5D6.js");
223
223
  const verdict = await verifyTextField(engineCtx(ctx), id, field, candidate, ctx.spec.verifyNormalize ?? "password");
224
224
  await ctx.onAccess?.("verify", id);
225
225
  return verdict;
226
226
  },
227
227
  async matchGroup(ctx, id, answers, opts) {
228
- const { matchGroupFields } = await import("./verify-JBXCAGDL.js");
228
+ const { matchGroupFields } = await import("./verify-KOV2G5D6.js");
229
229
  const members = (ctx.groupMembers ?? []).map((m) => ({ field: m.field, policy: policyOf(m.spec) }));
230
230
  const result = await matchGroupFields(engineCtx(ctx), id, answers, members, opts);
231
231
  await ctx.onAccess?.("verify", id);
232
232
  return result;
233
233
  },
234
234
  async computeTarget(ctx, field, candidate, costByte) {
235
- const { computeBidxTarget } = await import("./find-LC7P63MX.js");
235
+ const { computeBidxTarget } = await import("./find-2ABFCZX4.js");
236
236
  const dek = await ctx.getDEK();
237
237
  return computeBidxTarget(candidate, policyOf(ctx.spec).normalize, dek, ctx.collection, field, costByte);
238
238
  }
@@ -244,4 +244,4 @@ export {
244
244
  classified,
245
245
  withClassified
246
246
  };
247
- //# sourceMappingURL=chunk-5FUULQ6F.js.map
247
+ //# sourceMappingURL=chunk-2HVILGVR.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  assemblePodContainer,
6
6
  buildExtractedPartitionWrapper
7
- } from "./chunk-PKJ43CMD.js";
7
+ } from "./chunk-NLOLF6LD.js";
8
8
  import {
9
9
  BLOB_CHUNKS_COLLECTION,
10
10
  BLOB_COLLECTION,
@@ -494,4 +494,4 @@ export {
494
494
  extractPartition,
495
495
  extractPartitionCore
496
496
  };
497
- //# sourceMappingURL=chunk-DJ3LNNZQ.js.map
497
+ //# sourceMappingURL=chunk-3LK2XZCW.js.map
@@ -165,7 +165,9 @@ function withMaterializedView(spec) {
165
165
  );
166
166
  }
167
167
  if (typeof spec.rowKey !== "function") {
168
- throw new ValidationError("withMaterializedView: rowKey is required (no default; see spec \xA7 Type surface)");
168
+ throw new ValidationError(
169
+ spec.rowKey === void 0 ? "withMaterializedView: rowKey is required (no default; see spec \xA7 Type surface)" : `withMaterializedView: rowKey must be a FUNCTION (row) => string, not a ${typeof spec.rowKey} \u2014 it computes each output row's id from the grouped row, so a field NAME is not enough. Pass \`rowKey: (r) => String(r.${typeof spec.rowKey === "string" ? String(spec.rowKey) : "someField"})\`.`
170
+ );
169
171
  }
170
172
  if (spec.refresh !== "eager" && spec.refresh !== "lazy" && spec.refresh !== "manual") {
171
173
  throw new ValidationError(
@@ -181,4 +183,4 @@ function withMaterializedView(spec) {
181
183
  export {
182
184
  withMaterializedView
183
185
  };
184
- //# sourceMappingURL=chunk-PQKG5AHH.js.map
186
+ //# sourceMappingURL=chunk-6X6SEMEE.js.map
@@ -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,UACR,2BAA2B,EAAE,UAAU;AAAA,QACzC;AAAA,MACF;AACA,UAAI,KAAK,IAAI,EAAE,UAAU,GAAG;AAC1B,cAAM,IAAI;AAAA,UACR,iEAAiE,EAAE,UAAU;AAAA,QAC/E;AAAA,MACF;AACA,WAAK,IAAI,EAAE,UAAU;AAAA,IACvB;AACA,QAAI,MAAM,QAAQ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I;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;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,EAA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KA,2BAAuB,KAAK,MAAM,KAAK,UAAU;AAGjD,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;AAKrC,UAAM,IAAI;AAAA,MACR,KAAK,WAAW,SACZ,sFACA,0EAA0E,OAAO,KAAK,MAAM,gIAEvD,OAAO,KAAK,WAAW,WAAW,OAAO,KAAK,MAAM,IAAI,WAAW;AAAA,IAAM;AAAA,EACtH;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":[]}
@@ -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,6 @@
1
1
  import {
2
2
  writePod
3
- } from "./chunk-PKJ43CMD.js";
3
+ } from "./chunk-NLOLF6LD.js";
4
4
 
5
5
  // src/with-audit/portability/export-accessible.ts
6
6
  function resolveAccessibleCollections(keyring, scope, writableOnly = false) {
@@ -42,4 +42,4 @@ export {
42
42
  buildAccessibleBundle,
43
43
  exportAccessibleData
44
44
  };
45
- //# sourceMappingURL=chunk-ZR2YMODS.js.map
45
+ //# sourceMappingURL=chunk-EKZ6VZYF.js.map
@@ -435,4 +435,4 @@ export {
435
435
  demote,
436
436
  classifySealedShred
437
437
  };
438
- //# sourceMappingURL=chunk-RTYJRFQO.js.map
438
+ //# sourceMappingURL=chunk-EWPRPP3M.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-VYYM3MEN.js";
7
7
  import {
8
8
  derivePersistedSchema
9
- } from "./chunk-URHRIAV6.js";
9
+ } from "./chunk-REDOOY2Q.js";
10
10
  import {
11
11
  loadPersistedSchema
12
12
  } from "./chunk-WWNYSV7S.js";
@@ -240,4 +240,4 @@ function summariseAggregateOp(value) {
240
240
  export {
241
241
  dumpVaultSchema
242
242
  };
243
- //# sourceMappingURL=chunk-VGICZPVE.js.map
243
+ //# sourceMappingURL=chunk-FUJSIP4K.js.map
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  derivePersistedSchema,
13
13
  isZod4Schema
14
- } from "./chunk-URHRIAV6.js";
14
+ } from "./chunk-REDOOY2Q.js";
15
15
  import {
16
16
  loadPersistedSchema
17
17
  } from "./chunk-WWNYSV7S.js";
@@ -85,20 +85,6 @@ function resolveFieldMeta(key, inputs) {
85
85
  ...order !== void 0 ? { order } : {}
86
86
  };
87
87
  }
88
-
89
- // src/with-shape/introspection/describe.ts
90
- var ZOD_META_KEYS = /* @__PURE__ */ new Set([
91
- "label",
92
- "description",
93
- "unit",
94
- "semanticType",
95
- "sensitivity",
96
- "aggregate",
97
- "aliases",
98
- "displayFor",
99
- "group",
100
- "order"
101
- ]);
102
88
  function schemaFieldKeys(schema) {
103
89
  let s = schema;
104
90
  for (let depth = 0; depth < 10; depth++) {
@@ -122,6 +108,30 @@ function schemaFieldKeys(schema) {
122
108
  }
123
109
  return void 0;
124
110
  }
111
+ function validateFieldMetaAtRegistration(input) {
112
+ if (input.fieldMeta === void 0) return;
113
+ const validatorKeys = schemaFieldKeys(input.schema);
114
+ if (validatorKeys === void 0) return;
115
+ validateFieldMetaKeys(
116
+ input.collection,
117
+ input.fieldMeta,
118
+ /* @__PURE__ */ new Set([...validatorKeys, ...input.configKeys])
119
+ );
120
+ }
121
+
122
+ // src/with-shape/introspection/describe.ts
123
+ var ZOD_META_KEYS = /* @__PURE__ */ new Set([
124
+ "label",
125
+ "description",
126
+ "unit",
127
+ "semanticType",
128
+ "sensitivity",
129
+ "aggregate",
130
+ "aliases",
131
+ "displayFor",
132
+ "group",
133
+ "order"
134
+ ]);
125
135
  async function deriveZodFields(schema) {
126
136
  const envelope = await derivePersistedSchema(schema);
127
137
  if (!envelope.jsonSchema) return {};
@@ -896,6 +906,23 @@ function computedEntryParts(entry) {
896
906
  if (typeof entry === "function") return { fn: entry, mode: "materialized" };
897
907
  return { fn: entry.fn, ...entry.deps !== void 0 ? { deps: entry.deps } : {}, mode: entry.mode ?? "materialized" };
898
908
  }
909
+ function matchTargetFieldNames(opts) {
910
+ const declared = [];
911
+ const virtual = [];
912
+ for (const [field, entry] of Object.entries(opts.computed ?? {})) {
913
+ declared.push(field);
914
+ const parts = computedEntryParts(entry);
915
+ if (parts.mode === "virtual") virtual.push(field);
916
+ }
917
+ for (const [field, spec] of Object.entries(opts.viaFields ?? {})) {
918
+ declared.push(field);
919
+ const descriptors = spec.descriptors ?? [];
920
+ for (const d of descriptors) {
921
+ if (d._viaBrand === "computed" && d.mode === "virtual") virtual.push(field);
922
+ }
923
+ }
924
+ return { declared, virtual };
925
+ }
899
926
  function unifyComputedFields(opts, viaComputedFields) {
900
927
  return { ...opts.computed ?? {}, ...viaComputedFields ?? {} };
901
928
  }
@@ -1046,6 +1073,41 @@ function resolveCollectionConfig(opts) {
1046
1073
  `Collection "${opts.name}": embeddings are not supported on CRDT collections (L2). Use a non-CRDT collection for semantic search.`
1047
1074
  );
1048
1075
  }
1076
+ {
1077
+ const virtualFieldNames = matchTargetFieldNames({
1078
+ computed: opts.computed,
1079
+ viaFields: opts.viaFields
1080
+ }).virtual;
1081
+ if (virtualFieldNames.length > 0) {
1082
+ const virtualSet = new Set(virtualFieldNames);
1083
+ for (const reg of opts.materializedViewSource?.registry().mvsForSource(opts.name) ?? []) {
1084
+ const spec = reg.spec;
1085
+ const fields = spec.groupBy === void 0 ? [] : typeof spec.groupBy === "string" ? [spec.groupBy] : spec.groupBy;
1086
+ for (const f of fields) {
1087
+ if (!virtualSet.has(f)) continue;
1088
+ throw new ValidationError(
1089
+ `materialized view "${spec.name ?? reg.outputCollection}": groupBy names "${f}", which "${opts.name}" declares as a VIRTUAL computed field. Virtual fields are evaluated on read and never stored, so every row would bucket under an undefined key and the aggregate would be silently WRONG rather than an error. Declare it as \`mode: 'materialized'\` (stored) or group on a stored field.`
1090
+ );
1091
+ }
1092
+ }
1093
+ }
1094
+ }
1095
+ validateFieldMetaAtRegistration({
1096
+ collection: opts.name,
1097
+ schema: opts.schema,
1098
+ fieldMeta: opts.fieldMeta,
1099
+ configKeys: Object.keys({
1100
+ ...opts.moneyFields,
1101
+ ...opts.dictKeyFields,
1102
+ ...opts.declaredRefs,
1103
+ ...opts.computed,
1104
+ ...opts.i18nFields,
1105
+ ...opts.lookupFields,
1106
+ ...opts.blobFields,
1107
+ ...opts.classifiedFields,
1108
+ ...opts.viaFields
1109
+ })
1110
+ });
1049
1111
  if (opts.sensitive && opts.sensitive.length > 0 && opts.crdt) {
1050
1112
  throw new Error(
1051
1113
  `Collection "${opts.name}": sensitive (structural group-encryption) is not supported on CRDT collections \u2014 the CRDT write path bypasses per-field sealing, so the fields would be stored in the ordinary encrypted body with no \`_sealed\` slot and no per-field key. Use a non-CRDT collection for sealed fields.`
@@ -1579,6 +1641,7 @@ export {
1579
1641
  mergeViaFields,
1580
1642
  guardReconcileCollisions,
1581
1643
  computedEntryParts,
1644
+ matchTargetFieldNames,
1582
1645
  resolveVirtualMoneyFields,
1583
1646
  collectKnownFieldNames,
1584
1647
  resolveComputedEdges,
@@ -1586,4 +1649,4 @@ export {
1586
1649
  DEFAULT_POSTURE,
1587
1650
  ViaGraph
1588
1651
  };
1589
- //# sourceMappingURL=chunk-BWXGSSFX.js.map
1652
+ //# sourceMappingURL=chunk-NJXX55QX.js.map