@noy-db/hub 0.3.0-pre.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate/index.js +9 -8
- package/dist/aggregate/index.js.map +1 -1
- package/dist/api-ZGS6LCOF.js +20 -0
- package/dist/as/index.js +11 -11
- package/dist/attestation/index.js +18 -18
- package/dist/backup-BJ57IKAO.js +242 -0
- package/dist/backup-BJ57IKAO.js.map +1 -0
- package/dist/blobs/index.js +13 -11
- package/dist/blobs/index.js.map +1 -1
- package/dist/broker/index.js +92 -0
- package/dist/broker/index.js.map +1 -0
- package/dist/bundle/index.js +25 -22
- package/dist/bundle/index.js.map +1 -1
- package/dist/by/index.js +2 -2
- package/dist/cargo/index.js +31 -31
- package/dist/chunk-2NVOWNI3.js +167 -0
- package/dist/chunk-2NVOWNI3.js.map +1 -0
- package/dist/chunk-3B5VVCNY.js +71 -0
- package/dist/chunk-3LQ2YKO4.js +230 -0
- package/dist/chunk-3QCRBHCY.js +54 -0
- package/dist/chunk-454JXE57.js +1697 -0
- package/dist/chunk-454JXE57.js.map +1 -0
- package/dist/chunk-4CTHCN4J.js +480 -0
- package/dist/chunk-4CTHCN4J.js.map +1 -0
- package/dist/chunk-4GPE63GU.js +111 -0
- package/dist/chunk-4GPE63GU.js.map +1 -0
- package/dist/chunk-4JBYV75E.js +150 -0
- package/dist/chunk-4NXKCLLQ.js +97 -0
- package/dist/chunk-4VNQOLML.js +29 -0
- package/dist/chunk-4VNQOLML.js.map +1 -0
- package/dist/chunk-5M5DVGV7.js +69 -0
- package/dist/chunk-5O3XF4DV.js +150 -0
- package/dist/chunk-5O3XF4DV.js.map +1 -0
- package/dist/chunk-5YOLBEQ6.js +30 -0
- package/dist/chunk-6CRIV7DE.js +129 -0
- package/dist/chunk-6JTIAGHD.js +621 -0
- package/dist/chunk-6JTIAGHD.js.map +1 -0
- package/dist/chunk-6QTNZJBS.js +255 -0
- package/dist/chunk-6T2SCQRU.js +86 -0
- package/dist/chunk-7DSTRQIJ.js +45 -0
- package/dist/chunk-AUSTCW2X.js +589 -0
- package/dist/chunk-B3HJYUOF.js +209 -0
- package/dist/chunk-BDVFPG6Y.js +164 -0
- package/dist/chunk-BIOUI4HL.js +1554 -0
- package/dist/chunk-BIOUI4HL.js.map +1 -0
- package/dist/chunk-CAF6WOK7.js +36 -0
- package/dist/chunk-CDUQTA3Z.js +381 -0
- package/dist/chunk-CDUQTA3Z.js.map +1 -0
- package/dist/chunk-CIE2BASH.js +404 -0
- package/dist/chunk-CRI4OUV4.js +42 -0
- package/dist/chunk-DLG74CNB.js +91 -0
- package/dist/chunk-E5ZQT5KX.js +30 -0
- package/dist/chunk-E5ZQT5KX.js.map +1 -0
- package/dist/chunk-EQO2UVP4.js +247 -0
- package/dist/chunk-EQO2UVP4.js.map +1 -0
- package/dist/chunk-ERJ7FU55.js +367 -0
- package/dist/chunk-EVVGJDRQ.js +205 -0
- package/dist/chunk-EVX47VBM.js +74 -0
- package/dist/chunk-EVX47VBM.js.map +1 -0
- package/dist/chunk-EXK7QRWF.js +59 -0
- package/dist/chunk-EYZ6IQ6X.js +202 -0
- package/dist/chunk-F64IRYG3.js +45 -0
- package/dist/chunk-FHS2HQSH.js +823 -0
- package/dist/chunk-FM3G3NOY.js +206 -0
- package/dist/chunk-FM3G3NOY.js.map +1 -0
- package/dist/chunk-FUG4SFN3.js +36 -0
- package/dist/chunk-FUG4SFN3.js.map +1 -0
- package/dist/chunk-GKEWXIV5.js +80 -0
- package/dist/chunk-GTGPO5KW.js +59 -0
- package/dist/chunk-HB3RFQSC.js +95 -0
- package/dist/chunk-HDMEGAQE.js +957 -0
- package/dist/chunk-HDMEGAQE.js.map +1 -0
- package/dist/chunk-HDQIIUPH.js +135 -0
- package/dist/chunk-HDQIIUPH.js.map +1 -0
- package/dist/chunk-HTJQYHZP.js +344 -0
- package/dist/chunk-HTJQYHZP.js.map +1 -0
- package/dist/chunk-I6GALP6E.js +99 -0
- package/dist/chunk-IGJCYUT5.js +99 -0
- package/dist/chunk-IGJCYUT5.js.map +1 -0
- package/dist/chunk-IL6POWCW.js +130 -0
- package/dist/chunk-IU6SNYX6.js +117 -0
- package/dist/chunk-J2ZX2XUV.js +778 -0
- package/dist/chunk-JIF24JPM.js +495 -0
- package/dist/chunk-JIF24JPM.js.map +1 -0
- package/dist/chunk-JK733I5V.js +23 -0
- package/dist/chunk-JK733I5V.js.map +1 -0
- package/dist/chunk-JKJOGPZN.js +29 -0
- package/dist/chunk-JNAI2HN2.js +32 -0
- package/dist/chunk-JNAI2HN2.js.map +1 -0
- package/dist/chunk-JZUV47FZ.js +41 -0
- package/dist/chunk-K5IMOGHB.js +30 -0
- package/dist/chunk-KPZS5QAQ.js +151 -0
- package/dist/chunk-KPZS5QAQ.js.map +1 -0
- package/dist/chunk-KSKBRKGJ.js +291 -0
- package/dist/chunk-KSKBRKGJ.js.map +1 -0
- package/dist/chunk-LASZKVMO.js +382 -0
- package/dist/chunk-LXEXBTKL.js +515 -0
- package/dist/chunk-LXEXBTKL.js.map +1 -0
- package/dist/chunk-M4CV6BRT.js +524 -0
- package/dist/chunk-M4CV6BRT.js.map +1 -0
- package/dist/chunk-MEFJPTZ4.js +371 -0
- package/dist/chunk-MEFJPTZ4.js.map +1 -0
- package/dist/chunk-MV43JSJF.js +265 -0
- package/dist/chunk-MV43JSJF.js.map +1 -0
- package/dist/chunk-NJ4EOKMB.js +392 -0
- package/dist/chunk-NJ4EOKMB.js.map +1 -0
- package/dist/chunk-NR5LT5RY.js +135 -0
- package/dist/chunk-NWSGI5C7.js +261 -0
- package/dist/chunk-NWSGI5C7.js.map +1 -0
- package/dist/chunk-OSDB5WW3.js +739 -0
- package/dist/chunk-OSDB5WW3.js.map +1 -0
- package/dist/chunk-PN2XMATY.js +37 -0
- package/dist/chunk-PN2XMATY.js.map +1 -0
- package/dist/chunk-Q5VNKNE5.js +70 -0
- package/dist/chunk-QLWMEXCT.js +21 -0
- package/dist/chunk-QRB7NAOJ.js +123 -0
- package/dist/chunk-R4ROFEYC.js +74 -0
- package/dist/chunk-RCVJZMFE.js +164 -0
- package/dist/chunk-RCVJZMFE.js.map +1 -0
- package/dist/chunk-RIX4V2TB.js +367 -0
- package/dist/chunk-RYCTDFUX.js +40 -0
- package/dist/chunk-RZ5SVOYR.js +155 -0
- package/dist/chunk-SLFHQTTW.js +99 -0
- package/dist/chunk-SNZ6URZZ.js +2782 -0
- package/dist/chunk-SNZ6URZZ.js.map +1 -0
- package/dist/chunk-T2FFWNPK.js +75 -0
- package/dist/chunk-T2FFWNPK.js.map +1 -0
- package/dist/chunk-UNFPPVNI.js +23 -0
- package/dist/chunk-VFUPHI2Z.js +333 -0
- package/dist/chunk-VFUPHI2Z.js.map +1 -0
- package/dist/chunk-VLFCJYTL.js +235 -0
- package/dist/chunk-VN3DBQAU.js +124 -0
- package/dist/chunk-VYYM3MEN.js +98 -0
- package/dist/chunk-VYYM3MEN.js.map +1 -0
- package/dist/chunk-VZRODIM3.js +49 -0
- package/dist/chunk-W22IKJE2.js +94 -0
- package/dist/chunk-X3YYQWOQ.js +155 -0
- package/dist/chunk-X7QBD67R.js +14405 -0
- package/dist/chunk-X7QBD67R.js.map +1 -0
- package/dist/chunk-XDYREZWE.js +1128 -0
- package/dist/chunk-XDYREZWE.js.map +1 -0
- package/dist/chunk-XWZVFISC.js +720 -0
- package/dist/chunk-XWZVFISC.js.map +1 -0
- package/dist/chunk-YFXZEAYK.js +85 -0
- package/dist/chunk-ZAJAVEXY.js +50 -0
- package/dist/chunk-ZICD77GM.js +34 -0
- package/dist/chunk-ZJ2AK4V7.js +38 -0
- package/dist/chunk-ZJ2AK4V7.js.map +1 -0
- package/dist/chunk-ZUODRVHY.js +14 -0
- package/dist/classified/index.js +5 -3
- package/dist/classified-marker-CZKA6ITE.js +28 -0
- package/dist/classified-marker-CZKA6ITE.js.map +1 -0
- package/dist/collection-facade-TLWIPI76.js +44 -0
- package/dist/computed-ZIQTYTDI.js +11 -0
- package/dist/consent/index.js +9 -9
- package/dist/crdt/index.js +1 -1
- package/dist/dead-filter-ESOBZZP5.js +28 -0
- package/dist/delegation-W7ZV2322.js +25 -0
- package/dist/derivations/index.js +12 -11
- package/dist/derive-H2BJTLUI.js +21 -0
- package/dist/enclave-AP3I5W7O.js +141 -0
- package/dist/executor-KGWTNEQD.js +9 -0
- package/dist/executor-OVEXR6RT.js +9 -0
- package/dist/executor-UNEH5ZYH.js +25 -0
- package/dist/export-accessible-PCMXSUZS.js +23 -0
- package/dist/extract-partition-SWHFSYJO.js +38 -0
- package/dist/fanout-sidecar-A765THMX.js +74 -0
- package/dist/find-N6345CNT.js +11 -0
- package/dist/forget/index.js +10 -10
- package/dist/forget/index.js.map +1 -1
- package/dist/guards/index.js +6 -6
- package/dist/history/index.js +14 -11
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.js +50 -37
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.d.ts +307 -1459
- package/dist/index.js +595 -198
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +7 -7
- package/dist/indexing/index.js.map +1 -1
- package/dist/issue-5OKB6I2R.js +19 -0
- package/dist/kernel/best-effort-revert.d.ts +52 -0
- package/dist/kernel/cache/index.d.ts +10 -0
- package/dist/kernel/cache/lru.d.ts +97 -0
- package/dist/kernel/cache/policy.d.ts +32 -0
- package/dist/kernel/collection-config.d.ts +809 -0
- package/dist/kernel/collection.d.ts +1522 -0
- package/dist/kernel/constants.d.ts +18 -0
- package/dist/kernel/debug.d.ts +25 -0
- package/dist/kernel/enclave/broker/proof.d.ts +154 -0
- package/dist/kernel/enclave/classify/bidx.d.ts +77 -0
- package/dist/kernel/enclave/classify/compare.d.ts +10 -0
- package/dist/kernel/enclave/classify/digest.d.ts +8 -0
- package/dist/kernel/enclave/classify/find.d.ts +36 -0
- package/dist/kernel/enclave/classify/kofn.d.ts +7 -0
- package/dist/kernel/enclave/classify/normalize.d.ts +7 -0
- package/dist/kernel/enclave/classify/reveal.d.ts +10 -0
- package/dist/kernel/enclave/classify/vdig.d.ts +39 -0
- package/dist/kernel/enclave/classify/verify.d.ts +36 -0
- package/dist/kernel/enclave/classify/write.d.ts +8 -0
- package/dist/kernel/enclave/crypto.d.ts +263 -0
- package/dist/kernel/enclave/index.d.ts +79 -0
- package/dist/kernel/enclave/record-keys/deterministic.d.ts +55 -0
- package/dist/kernel/enclave/record-keys/envelope-body.d.ts +79 -0
- package/dist/kernel/enclave/record-keys/lifecycle.d.ts +107 -0
- package/dist/kernel/enclave/record-keys/record-codec.d.ts +328 -0
- package/dist/kernel/enclave/record-keys/sealed-slot.d.ts +14 -0
- package/dist/kernel/enclave/record-keys/sealed-slots.d.ts +123 -0
- package/dist/kernel/enclave/record-keys/sealing.d.ts +70 -0
- package/dist/kernel/enclave/record-keys/tombstone.d.ts +57 -0
- package/dist/kernel/env-check.d.ts +1 -0
- package/dist/kernel/errors.d.ts +1922 -0
- package/dist/kernel/events.d.ts +11 -0
- package/dist/kernel/lazy-count.d.ts +13 -0
- package/dist/kernel/memory-store.d.ts +17 -0
- package/dist/kernel/mutation.d.ts +14 -0
- package/dist/kernel/noydb.d.ts +826 -0
- package/dist/kernel/paths.d.ts +25 -0
- package/dist/kernel/query/builder.d.ts +520 -0
- package/dist/kernel/query/index.d.ts +31 -0
- package/dist/kernel/query/join.d.ts +205 -0
- package/dist/kernel/query/live.d.ts +111 -0
- package/dist/kernel/query/predicate.d.ts +139 -0
- package/dist/kernel/query/scan-builder.d.ts +334 -0
- package/dist/kernel/refs.d.ts +205 -0
- package/dist/kernel/schema.d.ts +134 -0
- package/dist/kernel/sync-policy.d.ts +188 -0
- package/dist/kernel/tier-visibility.d.ts +54 -0
- package/dist/kernel/types.d.ts +3239 -0
- package/dist/kernel/util/discriminant.d.ts +58 -0
- package/dist/kernel/util/index.d.ts +14 -0
- package/dist/kernel/util/sanitize-filename.d.ts +75 -0
- package/dist/kernel/validation.d.ts +130 -0
- package/dist/kernel/vault.d.ts +1740 -0
- package/dist/kernel/via/compose.d.ts +144 -0
- package/dist/kernel/via/dispatch.d.ts +195 -0
- package/dist/kernel/via/graph-wiring.d.ts +145 -0
- package/dist/kernel/via/graph.d.ts +166 -0
- package/dist/kernel/via/index.d.ts +200 -0
- package/dist/kernel/via/pipeline.d.ts +266 -0
- package/dist/kernel/via/reconcile.d.ts +153 -0
- package/dist/kernel/via/taint-binding.d.ts +66 -0
- package/dist/kernel/write-queue.d.ts +46 -0
- package/dist/ledger-GFBKVPV4.js +42 -0
- package/dist/legacy/bundle.d.ts +30 -0
- package/dist/legacy/kernel.d.ts +33 -0
- package/dist/liberate-3VDOT4KO.js +24 -0
- package/dist/link-set-Z7Q2ASFX.js +31 -0
- package/dist/materialized-views/index.js +19 -15
- package/dist/noydb-ZCJOYBDI.js +68 -0
- package/dist/on/index.js +9 -9
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.js +12 -12
- package/dist/pod/index.js +11 -11
- package/dist/policy-Z3RUAIY2.js +41 -0
- package/dist/port/as/index.d.ts +26 -0
- package/dist/port/at/index.d.ts +18 -0
- package/dist/port/by/default-provider.d.ts +9 -0
- package/dist/port/by/index.d.ts +17 -0
- package/dist/port/by/types.d.ts +86 -0
- package/dist/port/in/index.d.ts +21 -0
- package/dist/port/on/index.d.ts +27 -0
- package/dist/port/to/index.d.ts +19 -0
- package/dist/port/ui/index.d.ts +21 -0
- package/dist/port/with/blob-strategy.d.ts +98 -0
- package/dist/port/with/broker-strategy.d.ts +84 -0
- package/dist/port/with/capabilities.d.ts +31 -0
- package/dist/port/with/classified-marker.d.ts +9 -0
- package/dist/port/with/classified-strategy.d.ts +62 -0
- package/dist/port/with/computed-strategy.d.ts +19 -0
- package/dist/port/with/i18n-strategy.d.ts +175 -0
- package/dist/port/with/index.d.ts +18 -0
- package/dist/port/with/lazy-strategy.d.ts +48 -0
- package/dist/port/with/lookup-strategy.d.ts +129 -0
- package/dist/port/with/service-bus.d.ts +156 -0
- package/dist/port/with/team-strategy.d.ts +36 -0
- package/dist/port/with/write-hooks.d.ts +34 -0
- package/dist/portability/index.js +8 -8
- package/dist/post-register-JTH76BLY.js +60 -0
- package/dist/post-register-JTH76BLY.js.map +1 -0
- package/dist/public-envelope-B4KNWVUA.js +32 -0
- package/dist/purge-scope-FGNNLWHD.js +24 -0
- package/dist/purge-scope-FGNNLWHD.js.map +1 -0
- package/dist/query/index.js +9 -6
- package/dist/read-only-facade-CHCKSEPD.js +8 -0
- package/dist/register-VAHONCID.js +23 -0
- package/dist/registry-7MLVD3VO.js +19 -0
- package/dist/registry-EPKPD5SM.js +18 -0
- package/dist/registry-P5T7PS2U.js +9 -0
- package/dist/request-withdrawal-TI3A5WPS.js +31 -0
- package/dist/reveal-DIBHLUZX.js +38 -0
- package/dist/reveal-DIBHLUZX.js.map +1 -0
- package/dist/revoke-FDRD6GRW.js +24 -0
- package/dist/satellites/index.js +1 -1
- package/dist/sealed-record/index.js +12 -12
- package/dist/seed-Q6M2IZFL.js +231 -0
- package/dist/seed-Q6M2IZFL.js.map +1 -0
- package/dist/session/index.js +9 -9
- package/dist/shadow/index.js +2 -2
- package/dist/signer-MUWEIUI6.js +25 -0
- package/dist/snapshots/index.js +10 -10
- package/dist/stale-OSQ7J3AA.js +29 -0
- package/dist/storage-MVFCGEQE.js +23 -0
- package/dist/store-coordination-provider-64OEZFGS.js +142 -0
- package/dist/sync/index.js +9 -9
- package/dist/team/index.js +15 -15
- package/dist/tiers/index.js +14 -10
- package/dist/to/index.js +1 -2
- package/dist/tx/index.js +3 -3
- package/dist/util/index.js +1 -1
- package/dist/verify-ZASTRNPR.js +140 -0
- package/dist/verify-ZASTRNPR.js.map +1 -0
- package/dist/via/blob/active.d.ts +34 -0
- package/dist/via/blob/binding.d.ts +86 -0
- package/dist/via/blob/index.d.ts +34 -0
- package/dist/via/classified/active.d.ts +3 -0
- package/dist/via/classified/binding.d.ts +83 -0
- package/dist/via/classified/config-drift.d.ts +34 -0
- package/dist/via/classified/descriptor.d.ts +66 -0
- package/dist/via/classified/errors.d.ts +19 -0
- package/dist/via/classified/guards.d.ts +23 -0
- package/dist/via/classified/index.d.ts +11 -0
- package/dist/via/classified/presets.d.ts +65 -0
- package/dist/via/classified/resolve.d.ts +9 -0
- package/dist/via/classified/strategy.d.ts +11 -0
- package/dist/via/classified/validators.d.ts +3 -0
- package/dist/via/classified/write.d.ts +4 -0
- package/dist/via/computed/binding.d.ts +34 -0
- package/dist/via/computed/descriptor.d.ts +35 -0
- package/dist/via/i18n/active.d.ts +28 -0
- package/dist/via/i18n/binding.d.ts +36 -0
- package/dist/via/i18n/core.d.ts +267 -0
- package/dist/via/i18n/densify.d.ts +24 -0
- package/dist/via/i18n/dictionary.d.ts +200 -0
- package/dist/via/i18n/index.d.ts +21 -0
- package/dist/via/i18n/policy.d.ts +44 -0
- package/dist/via/i18n/script.d.ts +26 -0
- package/dist/via/i18n/strategy.d.ts +13 -0
- package/dist/via/lookup/active.d.ts +19 -0
- package/dist/via/lookup/binding.d.ts +99 -0
- package/dist/via/lookup/descriptor.d.ts +123 -0
- package/dist/via/lookup/handle.d.ts +220 -0
- package/dist/via/lookup/index.d.ts +17 -0
- package/dist/via/lookup/registry.d.ts +228 -0
- package/dist/via/lookup/snapshot.d.ts +67 -0
- package/dist/via/money/arith.d.ts +68 -0
- package/dist/via/money/binding.d.ts +21 -0
- package/dist/via/money/branded.d.ts +61 -0
- package/dist/via/money/descriptor.d.ts +73 -0
- package/dist/via/money/fixed-point.d.ts +51 -0
- package/dist/via/money/index.d.ts +15 -0
- package/dist/via/money/iso4217.d.ts +6 -0
- package/dist/via/money/money-reducer.d.ts +33 -0
- package/dist/via/money/normalize.d.ts +105 -0
- package/dist/via/money/paths.d.ts +61 -0
- package/dist/via/money/where.d.ts +127 -0
- package/dist/walk-SVNDIZ62.js +241 -0
- package/dist/with/index.js +11 -11
- package/dist/with-audit/attestation/active.d.ts +10 -0
- package/dist/with-audit/attestation/index.d.ts +16 -0
- package/dist/with-audit/attestation/issue.d.ts +29 -0
- package/dist/with-audit/attestation/revoke.d.ts +15 -0
- package/dist/with-audit/attestation/signer.d.ts +33 -0
- package/dist/with-audit/attestation/strategy.d.ts +44 -0
- package/dist/with-audit/attestation/vault-facade.d.ts +62 -0
- package/dist/with-audit/consent/active.d.ts +14 -0
- package/dist/with-audit/consent/consent.d.ts +114 -0
- package/dist/with-audit/consent/index.d.ts +14 -0
- package/dist/with-audit/consent/strategy.d.ts +36 -0
- package/dist/with-audit/forget/active.d.ts +31 -0
- package/dist/with-audit/forget/index.d.ts +28 -0
- package/dist/with-audit/forget/purge-scope.d.ts +54 -0
- package/dist/with-audit/forget/strategy.d.ts +199 -0
- package/dist/with-audit/forget/subject-index.d.ts +83 -0
- package/dist/with-audit/guards/executor.d.ts +26 -0
- package/dist/with-audit/guards/immutable-guard.d.ts +63 -0
- package/dist/with-audit/guards/index.d.ts +10 -0
- package/dist/with-audit/guards/read-only-facade.d.ts +31 -0
- package/dist/with-audit/guards/registry.d.ts +83 -0
- package/dist/with-audit/guards/transition-guard.d.ts +82 -0
- package/dist/with-audit/guards/types.d.ts +134 -0
- package/dist/with-audit/guards/with-guard.d.ts +15 -0
- package/dist/with-audit/periods/active.d.ts +11 -0
- package/dist/with-audit/periods/index.d.ts +18 -0
- package/dist/with-audit/periods/periods.d.ts +417 -0
- package/dist/with-audit/periods/strategy.d.ts +32 -0
- package/dist/with-audit/periods/vault-facade.d.ts +95 -0
- package/dist/with-audit/portability/active.d.ts +11 -0
- package/dist/with-audit/portability/export-accessible.d.ts +46 -0
- package/dist/with-audit/portability/index.d.ts +18 -0
- package/dist/with-audit/portability/request-withdrawal.d.ts +85 -0
- package/dist/with-audit/portability/strategy.d.ts +31 -0
- package/dist/with-audit/portability/withdraw-accessible.d.ts +82 -0
- package/dist/with-audit/sealed-record/active.d.ts +9 -0
- package/dist/with-audit/sealed-record/index.d.ts +55 -0
- package/dist/with-audit/sealed-record/strategy.d.ts +34 -0
- package/dist/with-audit/sealed-record/types.d.ts +27 -0
- package/dist/with-audit/tiers/active.d.ts +9 -0
- package/dist/with-audit/tiers/index.d.ts +394 -0
- package/dist/with-audit/tiers/strategy.d.ts +36 -0
- package/dist/with-cargo/active.d.ts +11 -0
- package/dist/with-cargo/adopt-partition.d.ts +81 -0
- package/dist/with-cargo/decrypt-partition.d.ts +19 -0
- package/dist/with-cargo/describe-extraction.d.ts +41 -0
- package/dist/with-cargo/extract-partition.d.ts +155 -0
- package/dist/with-cargo/index.d.ts +33 -0
- package/dist/with-cargo/strategy.d.ts +30 -0
- package/dist/with-cargo/vault-diff.d.ts +144 -0
- package/dist/with-cargo/walk-closure.d.ts +67 -0
- package/dist/with-commit/crdt/active.d.ts +25 -0
- package/dist/with-commit/crdt/crdt.d.ts +42 -0
- package/dist/with-commit/crdt/index.d.ts +16 -0
- package/dist/with-commit/crdt/strategy.d.ts +25 -0
- package/dist/with-commit/history/active.d.ts +40 -0
- package/dist/with-commit/history/diff.d.ts +23 -0
- package/dist/with-commit/history/history.d.ts +73 -0
- package/dist/with-commit/history/index.d.ts +30 -0
- package/dist/with-commit/history/ledger/constants.d.ts +37 -0
- package/dist/with-commit/history/ledger/entry.d.ts +195 -0
- package/dist/with-commit/history/ledger/hash.d.ts +30 -0
- package/dist/with-commit/history/ledger/index.d.ts +19 -0
- package/dist/with-commit/history/ledger/patch.d.ts +99 -0
- package/dist/with-commit/history/ledger/store.d.ts +356 -0
- package/dist/with-commit/history/strategy.d.ts +136 -0
- package/dist/with-commit/history/time-machine.d.ts +202 -0
- package/dist/with-commit/numbering/descriptor.d.ts +27 -0
- package/dist/with-commit/numbering/index.d.ts +69 -0
- package/dist/with-commit/sequence/active.d.ts +10 -0
- package/dist/with-commit/sequence/index.d.ts +150 -0
- package/dist/with-commit/sequence/strategy.d.ts +26 -0
- package/dist/with-commit/tx/active.d.ts +27 -0
- package/dist/with-commit/tx/dry-run.d.ts +29 -0
- package/dist/with-commit/tx/elevated-handle.d.ts +59 -0
- package/dist/with-commit/tx/index.d.ts +13 -0
- package/dist/with-commit/tx/invariants.d.ts +68 -0
- package/dist/with-commit/tx/strategy.d.ts +23 -0
- package/dist/with-commit/tx/transaction.d.ts +212 -0
- package/dist/with-fork/archive/engine.d.ts +71 -0
- package/dist/with-fork/archive/index.d.ts +23 -0
- package/dist/with-fork/shadow/active.d.ts +6 -0
- package/dist/with-fork/shadow/index.d.ts +14 -0
- package/dist/with-fork/shadow/strategy.d.ts +28 -0
- package/dist/with-fork/shadow/vault-frame.d.ts +93 -0
- package/dist/with-fork/snapshots/active.d.ts +20 -0
- package/dist/with-fork/snapshots/engine.d.ts +36 -0
- package/dist/with-fork/snapshots/index.d.ts +5 -0
- package/dist/with-fork/snapshots/noydb-facade.d.ts +64 -0
- package/dist/with-fork/snapshots/policy.d.ts +23 -0
- package/dist/with-fork/snapshots/scheduler.d.ts +34 -0
- package/dist/with-fork/snapshots/strategy.d.ts +48 -0
- package/dist/with-formula/computed/index.d.ts +48 -0
- package/dist/with-formula/computed/lazy.d.ts +13 -0
- package/dist/with-formula/derivations/executor.d.ts +61 -0
- package/dist/with-formula/derivations/fanout-sidecar.d.ts +75 -0
- package/dist/with-formula/derivations/index.d.ts +6 -0
- package/dist/with-formula/derivations/registry.d.ts +67 -0
- package/dist/with-formula/derivations/stale.d.ts +39 -0
- package/dist/with-formula/derivations/strategy-hash.d.ts +1 -0
- package/dist/with-formula/derivations/types.d.ts +248 -0
- package/dist/with-formula/derivations/with-derivation.d.ts +10 -0
- package/dist/with-formula/derivations/with-rollup.d.ts +34 -0
- package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +58 -0
- package/dist/with-formula/materialized-views/executor.d.ts +80 -0
- package/dist/with-formula/materialized-views/index.d.ts +11 -0
- package/dist/with-formula/materialized-views/query-hash.d.ts +23 -0
- package/dist/with-formula/materialized-views/registry.d.ts +99 -0
- package/dist/with-formula/materialized-views/stale.d.ts +113 -0
- package/dist/with-formula/materialized-views/types.d.ts +318 -0
- package/dist/with-formula/materialized-views/with-materialized-view.d.ts +24 -0
- package/dist/with-formula/overlay-views/index.d.ts +5 -0
- package/dist/with-formula/overlay-views/registry.d.ts +42 -0
- package/dist/with-formula/overlay-views/types.d.ts +97 -0
- package/dist/with-formula/overlay-views/virtual-collection.d.ts +90 -0
- package/dist/with-formula/overlay-views/with-overlayed-view.d.ts +9 -0
- package/dist/with-lookup/aggregate/active.d.ts +33 -0
- package/dist/with-lookup/aggregate/aggregation.d.ts +166 -0
- package/dist/with-lookup/aggregate/canonical-key.d.ts +16 -0
- package/dist/with-lookup/aggregate/groupby.d.ts +280 -0
- package/dist/with-lookup/aggregate/index.d.ts +23 -0
- package/dist/with-lookup/aggregate/reducers.d.ts +257 -0
- package/dist/with-lookup/aggregate/strategy.d.ts +59 -0
- package/dist/with-lookup/embeddings/cosine.d.ts +2 -0
- package/dist/with-lookup/embeddings/descriptor.d.ts +8 -0
- package/dist/with-lookup/embeddings/index.d.ts +4 -0
- package/dist/with-lookup/embeddings/vec-id.d.ts +47 -0
- package/dist/with-lookup/embeddings/vector-set.d.ts +19 -0
- package/dist/with-lookup/indexing/active.d.ts +30 -0
- package/dist/with-lookup/indexing/collection-facade.d.ts +157 -0
- package/dist/with-lookup/indexing/eager-indexes.d.ts +122 -0
- package/dist/with-lookup/indexing/index.d.ts +27 -0
- package/dist/with-lookup/indexing/lazy-builder.d.ts +102 -0
- package/dist/with-lookup/indexing/persisted-indexes.d.ts +229 -0
- package/dist/with-lookup/indexing/strategy.d.ts +56 -0
- package/dist/with-lookup/indexing/unique-constraints.d.ts +74 -0
- package/dist/with-lookup/search/active.d.ts +10 -0
- package/dist/with-lookup/search/build-docs.d.ts +15 -0
- package/dist/with-lookup/search/collection-facade.d.ts +163 -0
- package/dist/with-lookup/search/fuse.d.ts +22 -0
- package/dist/with-lookup/search/index-store.d.ts +19 -0
- package/dist/with-lookup/search/index.d.ts +19 -0
- package/dist/with-lookup/search/inverted-index.d.ts +47 -0
- package/dist/with-lookup/search/persisted-index-store.d.ts +121 -0
- package/dist/with-lookup/search/retrieve-types.d.ts +29 -0
- package/dist/with-lookup/search/scan.d.ts +28 -0
- package/dist/with-lookup/search/segment.d.ts +15 -0
- package/dist/with-lookup/search/serialize.d.ts +4 -0
- package/dist/with-lookup/search/snippet.d.ts +5 -0
- package/dist/with-lookup/search/strategy.d.ts +41 -0
- package/dist/with-lookup/search/tokenize.d.ts +12 -0
- package/dist/with-party/auth-introspection/index.d.ts +44 -0
- package/dist/with-party/broker/active.d.ts +23 -0
- package/dist/with-party/broker/index.d.ts +28 -0
- package/dist/with-party/broker/seed.d.ts +77 -0
- package/dist/with-party/custody/active.d.ts +10 -0
- package/dist/with-party/custody/index.d.ts +69 -0
- package/dist/with-party/custody/liberate.d.ts +64 -0
- package/dist/with-party/custody/strategy.d.ts +48 -0
- package/dist/with-party/directory/index.d.ts +11 -0
- package/dist/with-party/directory/public-envelope/index.d.ts +12 -0
- package/dist/with-party/directory/public-envelope/schema.d.ts +24 -0
- package/dist/with-party/directory/public-envelope/storage.d.ts +59 -0
- package/dist/with-party/directory/public-envelope/types.d.ts +80 -0
- package/dist/with-party/directory/storage.d.ts +33 -0
- package/dist/with-party/directory/types.d.ts +43 -0
- package/dist/with-party/directory/user-envelope/api.d.ts +201 -0
- package/dist/with-party/directory/user-envelope/index.d.ts +12 -0
- package/dist/with-party/directory/user-envelope/storage.d.ts +54 -0
- package/dist/with-party/directory/visibility.d.ts +47 -0
- package/dist/with-party/policy/engine.d.ts +60 -0
- package/dist/with-party/policy/index.d.ts +15 -0
- package/dist/with-party/policy/noydb-facade.d.ts +39 -0
- package/dist/with-party/policy/presets.d.ts +38 -0
- package/dist/with-party/policy/storage.d.ts +31 -0
- package/dist/with-party/session/active.d.ts +34 -0
- package/dist/with-party/session/dev-unlock.d.ts +128 -0
- package/dist/with-party/session/index.d.ts +23 -0
- package/dist/with-party/session/session-policy.d.ts +92 -0
- package/dist/with-party/session/session.d.ts +131 -0
- package/dist/with-party/session/strategy.d.ts +42 -0
- package/dist/with-party/session/unlock-state.d.ts +47 -0
- package/dist/with-party/sync/index.d.ts +31 -0
- package/dist/with-party/tab-coordination.d.ts +73 -0
- package/dist/with-party/tab-write-relay.d.ts +39 -0
- package/dist/with-party/team/active.d.ts +13 -0
- package/dist/with-party/team/authenticators.d.ts +95 -0
- package/dist/with-party/team/deed.d.ts +97 -0
- package/dist/with-party/team/delegation.d.ts +88 -0
- package/dist/with-party/team/index.d.ts +38 -0
- package/dist/with-party/team/keyring.d.ts +318 -0
- package/dist/with-party/team/magic-link-grant.d.ts +152 -0
- package/dist/with-party/team/managed-passphrase.d.ts +280 -0
- package/dist/with-party/team/noydb-facade.d.ts +484 -0
- package/dist/with-party/team/peer-recover.d.ts +81 -0
- package/dist/with-party/team/presence.d.ts +81 -0
- package/dist/with-party/team/recovery.d.ts +191 -0
- package/dist/with-party/team/reserved-secret-collections.d.ts +41 -0
- package/dist/with-party/team/rotate-recover.d.ts +275 -0
- package/dist/with-party/team/shamir-recovery-provider.d.ts +15 -0
- package/dist/with-party/team/strategy.d.ts +9 -0
- package/dist/with-party/team/sync-active.d.ts +33 -0
- package/dist/with-party/team/sync-credentials.d.ts +113 -0
- package/dist/with-party/team/sync-strategy.d.ts +67 -0
- package/dist/with-party/team/sync-transaction.d.ts +39 -0
- package/dist/with-party/team/sync.d.ts +174 -0
- package/dist/with-party/team/tiers.d.ts +39 -0
- package/dist/with-party/team/wrapped-deks.d.ts +86 -0
- package/dist/with-pod/backup.d.ts +74 -0
- package/dist/with-pod/bundle.d.ts +414 -0
- package/dist/with-pod/format.d.ts +203 -0
- package/dist/with-pod/index.d.ts +20 -0
- package/dist/with-pod/pod-store.d.ts +54 -0
- package/dist/with-pod/ulid.d.ts +64 -0
- package/dist/with-shape/blobs/blob-compaction.d.ts +170 -0
- package/dist/with-shape/blobs/blob-intent.d.ts +153 -0
- package/dist/with-shape/blobs/blob-set.d.ts +1286 -0
- package/dist/with-shape/blobs/export-blobs.d.ts +110 -0
- package/dist/with-shape/blobs/import-external.d.ts +50 -0
- package/dist/with-shape/blobs/mime-magic.d.ts +48 -0
- package/dist/with-shape/blobs/object-projection.d.ts +70 -0
- package/dist/with-shape/introspection/describe.d.ts +237 -0
- package/dist/with-shape/introspection/field-meta.d.ts +61 -0
- package/dist/with-shape/introspection/fields.d.ts +14 -0
- package/dist/with-shape/introspection/index.d.ts +12 -0
- package/dist/with-shape/introspection/json-schema.d.ts +13 -0
- package/dist/with-shape/introspection/meta.d.ts +22 -0
- package/dist/with-shape/introspection/projection.d.ts +13 -0
- package/dist/with-shape/introspection/types.d.ts +154 -0
- package/dist/with-shape/introspection/walk.d.ts +50 -0
- package/dist/with-shape/links/lazy-handle.d.ts +36 -0
- package/dist/with-shape/links/link-set.d.ts +67 -0
- package/dist/with-shape/links/names.d.ts +65 -0
- package/dist/with-shape/links/vault-facade.d.ts +211 -0
- package/dist/with-shape/persisted-schemas/canonicalize.d.ts +11 -0
- package/dist/with-shape/persisted-schemas/derive.d.ts +29 -0
- package/dist/with-shape/persisted-schemas/index.d.ts +21 -0
- package/dist/with-shape/persisted-schemas/register.d.ts +66 -0
- package/dist/with-shape/persisted-schemas/storage.d.ts +61 -0
- package/dist/with-shape/persisted-schemas/types.d.ts +54 -0
- package/dist/with-shape/satellites/dead-filter.d.ts +21 -0
- package/dist/with-shape/satellites/declare.d.ts +60 -0
- package/dist/with-shape/satellites/existence.d.ts +5 -0
- package/dist/with-shape/satellites/fanout.d.ts +38 -0
- package/dist/with-shape/satellites/forget.d.ts +47 -0
- package/dist/with-shape/satellites/index.d.ts +3 -0
- package/dist/with-shape/satellites/joined.d.ts +19 -0
- package/dist/with-shape/satellites/marker.d.ts +10 -0
- package/dist/with-shape/satellites/migrate-cek.d.ts +26 -0
- package/dist/with-shape/satellites/post-register.d.ts +6 -0
- package/dist/with-shape/satellites/proxy.d.ts +37 -0
- package/dist/with-shape/satellites/raw-target.d.ts +14 -0
- package/dist/with-shape/satellites/registry.d.ts +19 -0
- package/dist/with-shape/satellites/types.d.ts +37 -0
- package/dist/with-shape/satellites/validate.d.ts +17 -0
- package/dist/with-shape/schema-update/client-registry.d.ts +35 -0
- package/dist/with-shape/schema-update/cutover.d.ts +5 -0
- package/dist/with-shape/schema-update/delta.d.ts +2 -0
- package/dist/with-shape/schema-update/dispatch.d.ts +3 -0
- package/dist/with-shape/schema-update/fence-controller.d.ts +62 -0
- package/dist/with-shape/schema-update/fence-watcher.d.ts +37 -0
- package/dist/with-shape/schema-update/fence.d.ts +15 -0
- package/dist/with-shape/schema-update/gate.d.ts +16 -0
- package/dist/with-shape/schema-update/index.d.ts +6 -0
- package/dist/with-shape/schema-update/store-coordination-provider.d.ts +29 -0
- package/dist/with-shape/schema-update/strategies.d.ts +12 -0
- package/dist/with-shape/schema-update/types.d.ts +53 -0
- package/dist/with-store/index.d.ts +15 -0
- package/dist/with-store/lazy/active.d.ts +12 -0
- package/dist/with-store/lazy/index.d.ts +14 -0
- package/dist/with-store/lazy/strategy.d.ts +9 -0
- package/dist/with-store/route-store.d.ts +259 -0
- package/dist/with-store/store-middleware.d.ts +189 -0
- package/dist/withdraw-accessible-WZIEVWSR.js +28 -0
- package/package.json +47 -55
- package/dist/adapter/index.d.ts +0 -5
- package/dist/adapter/index.js +0 -15
- package/dist/aggregate/index.d.ts +0 -42
- package/dist/api-JDWL67WL.js +0 -20
- package/dist/as/index.d.ts +0 -7
- package/dist/at/index.d.ts +0 -5
- package/dist/attestation/index.d.ts +0 -20
- package/dist/backup-WRGNTGJF.js +0 -225
- package/dist/backup-WRGNTGJF.js.map +0 -1
- package/dist/blobs/index.d.ts +0 -44
- package/dist/bundle/index.d.ts +0 -122
- package/dist/bundle-DzWtVw7w.d.ts +0 -548
- package/dist/by/index.d.ts +0 -1
- package/dist/cargo/index.d.ts +0 -9
- package/dist/chunk-25G7PUTA.js +0 -235
- package/dist/chunk-26FSVNBL.js +0 -34
- package/dist/chunk-2PJB6H3H.js +0 -167
- package/dist/chunk-2PJB6H3H.js.map +0 -1
- package/dist/chunk-37JZR7CY.js +0 -91
- package/dist/chunk-3KBK5LU4.js +0 -117
- package/dist/chunk-3YKBGS3I.js +0 -686
- package/dist/chunk-3YKBGS3I.js.map +0 -1
- package/dist/chunk-44DV37ZV.js +0 -75
- package/dist/chunk-44DV37ZV.js.map +0 -1
- package/dist/chunk-47C4CI7R.js +0 -108
- package/dist/chunk-47C4CI7R.js.map +0 -1
- package/dist/chunk-4VDFUBTS.js +0 -275
- package/dist/chunk-4VDFUBTS.js.map +0 -1
- package/dist/chunk-55LSDABW.js +0 -94
- package/dist/chunk-56JB2BGI.js +0 -13003
- package/dist/chunk-56JB2BGI.js.map +0 -1
- package/dist/chunk-5GQE5IDB.js +0 -513
- package/dist/chunk-5GQE5IDB.js.map +0 -1
- package/dist/chunk-5HRJQSKN.js +0 -202
- package/dist/chunk-5HZULLHE.js +0 -404
- package/dist/chunk-5JQMX2EH.js +0 -50
- package/dist/chunk-5UOPIPZC.js +0 -95
- package/dist/chunk-5YBUFCFF.js +0 -135
- package/dist/chunk-62APEMF3.js +0 -280
- package/dist/chunk-62APEMF3.js.map +0 -1
- package/dist/chunk-6P5AJ2ZS.js +0 -120
- package/dist/chunk-6P5AJ2ZS.js.map +0 -1
- package/dist/chunk-6PALJTC2.js +0 -430
- package/dist/chunk-6PALJTC2.js.map +0 -1
- package/dist/chunk-6S7T6WC4.js +0 -111
- package/dist/chunk-6S7T6WC4.js.map +0 -1
- package/dist/chunk-6Z435B6N.js +0 -1656
- package/dist/chunk-6Z435B6N.js.map +0 -1
- package/dist/chunk-723XB5NX.js +0 -86
- package/dist/chunk-7CZ6YXMO.js +0 -124
- package/dist/chunk-7KTL4RHZ.js +0 -120
- package/dist/chunk-7KTL4RHZ.js.map +0 -1
- package/dist/chunk-7TAV3BFQ.js +0 -766
- package/dist/chunk-7TAV3BFQ.js.map +0 -1
- package/dist/chunk-BASCPHNM.js +0 -380
- package/dist/chunk-BASCPHNM.js.map +0 -1
- package/dist/chunk-BGIZAFY7.js +0 -1
- package/dist/chunk-BJ2XF2RC.js +0 -823
- package/dist/chunk-BM6E4MUT.js +0 -881
- package/dist/chunk-BM6E4MUT.js.map +0 -1
- package/dist/chunk-BTFTHF6Q.js +0 -42
- package/dist/chunk-C4NOLA5X.js +0 -132
- package/dist/chunk-C4NOLA5X.js.map +0 -1
- package/dist/chunk-CHK5VVMI.js +0 -155
- package/dist/chunk-DCVVCJVB.js +0 -45
- package/dist/chunk-EU7HDMT3.js +0 -54
- package/dist/chunk-F3EKFGUS.js +0 -99
- package/dist/chunk-FCOZ7DEC.js +0 -355
- package/dist/chunk-FCOZ7DEC.js.map +0 -1
- package/dist/chunk-FWART3VA.js +0 -205
- package/dist/chunk-FZK3JJJK.js +0 -150
- package/dist/chunk-GDOOG5YQ.js +0 -382
- package/dist/chunk-GLVXQU3E.js +0 -155
- package/dist/chunk-HU55NPHZ.js +0 -80
- package/dist/chunk-I6JJ6VJS.js +0 -97
- package/dist/chunk-I6URUNTD.js +0 -59
- package/dist/chunk-IARAK3PK.js +0 -14
- package/dist/chunk-II6DLDZM.js +0 -30
- package/dist/chunk-J5YUA6JB.js +0 -23
- package/dist/chunk-J7OH6R4K.js +0 -49
- package/dist/chunk-K2WCO3NX.js +0 -1
- package/dist/chunk-L6Q5NA22.js +0 -40
- package/dist/chunk-LFGJG4XZ.js +0 -30
- package/dist/chunk-M3OYTM5Z.js +0 -85
- package/dist/chunk-MOQ5M46U.js +0 -209
- package/dist/chunk-NTPWQH4S.js +0 -589
- package/dist/chunk-OJ64XMPJ.js +0 -1434
- package/dist/chunk-OJ64XMPJ.js.map +0 -1
- package/dist/chunk-OWGAXPRE.js +0 -129
- package/dist/chunk-P2PEPSPK.js +0 -230
- package/dist/chunk-P6TZ3IVN.js +0 -453
- package/dist/chunk-P6TZ3IVN.js.map +0 -1
- package/dist/chunk-PAJCRV7O.js +0 -123
- package/dist/chunk-PMMV5SQC.js +0 -416
- package/dist/chunk-PMMV5SQC.js.map +0 -1
- package/dist/chunk-PPPZIBKY.js +0 -261
- package/dist/chunk-PPPZIBKY.js.map +0 -1
- package/dist/chunk-PVC2FBCQ.js +0 -45
- package/dist/chunk-PYIUDUGS.js +0 -36
- package/dist/chunk-QABECTNN.js +0 -255
- package/dist/chunk-QYMMMKOO.js +0 -164
- package/dist/chunk-R4IVPJHN.js +0 -130
- package/dist/chunk-REWTMYSF.js +0 -32
- package/dist/chunk-REWTMYSF.js.map +0 -1
- package/dist/chunk-RNYDHIQL.js +0 -367
- package/dist/chunk-RUIMKQTA.js +0 -23
- package/dist/chunk-RUIMKQTA.js.map +0 -1
- package/dist/chunk-TCGVRKOS.js +0 -367
- package/dist/chunk-TIAYXOEI.js +0 -99
- package/dist/chunk-TQ3REHVF.js +0 -95
- package/dist/chunk-TQ3REHVF.js.map +0 -1
- package/dist/chunk-TUL5YQWF.js +0 -777
- package/dist/chunk-U7LV2DUN.js +0 -74
- package/dist/chunk-UB3XHGFG.js +0 -181
- package/dist/chunk-UB3XHGFG.js.map +0 -1
- package/dist/chunk-UMH35AQV.js +0 -70
- package/dist/chunk-UWZ7O4NR.js +0 -29
- package/dist/chunk-V76PHWLE.js +0 -41
- package/dist/chunk-VFQOE76I.js +0 -69
- package/dist/chunk-VIWOGJ2O.js +0 -71
- package/dist/chunk-VK6OC22R.js +0 -37
- package/dist/chunk-VK6OC22R.js.map +0 -1
- package/dist/chunk-VVLOWY74.js +0 -150
- package/dist/chunk-VVLOWY74.js.map +0 -1
- package/dist/chunk-W3JABOVB.js +0 -53
- package/dist/chunk-W3JABOVB.js.map +0 -1
- package/dist/chunk-WPNP3NF5.js +0 -1221
- package/dist/chunk-WPNP3NF5.js.map +0 -1
- package/dist/chunk-X5QZAJDB.js +0 -59
- package/dist/chunk-X6VNIRHS.js +0 -239
- package/dist/chunk-X6VNIRHS.js.map +0 -1
- package/dist/chunk-XBPUVQDO.js +0 -664
- package/dist/chunk-XBPUVQDO.js.map +0 -1
- package/dist/chunk-XW5LZYV4.js +0 -21
- package/dist/chunk-YTCCC6NG.js +0 -320
- package/dist/chunk-YTCCC6NG.js.map +0 -1
- package/dist/classified/index.d.ts +0 -17
- package/dist/collection-facade-EJVIN2BY.js +0 -39
- package/dist/computed-6FOFXQPE.js +0 -11
- package/dist/config-drift-RFEVGBKR.js +0 -24
- package/dist/config-drift-RFEVGBKR.js.map +0 -1
- package/dist/consent/index.d.ts +0 -23
- package/dist/crdt/index.d.ts +0 -34
- package/dist/dead-filter-RHMNYOXP.js +0 -28
- package/dist/decrypt-partition-IHtxEnTi.d.ts +0 -21
- package/dist/delegation-IHXOASHV.js +0 -25
- package/dist/derivations/index.d.ts +0 -70
- package/dist/derive-CD3ZVIXK.js +0 -21
- package/dist/describe/index.d.ts +0 -1
- package/dist/describe/index.js +0 -1
- package/dist/describe-C6iHNlqJ.d.ts +0 -162
- package/dist/dev-unlock-wgQ7Ci5I.d.ts +0 -263
- package/dist/discriminant-BN9REW3o.d.ts +0 -60
- package/dist/enclave-KGEUW2GL.js +0 -123
- package/dist/executor-EUPYHCLU.js +0 -9
- package/dist/executor-KZ4B3PRT.js +0 -9
- package/dist/executor-MHUM2VZK.js +0 -21
- package/dist/export-accessible-Z3NSZZHN.js +0 -23
- package/dist/extract-partition-VSKT35JG.js +0 -36
- package/dist/fanout-sidecar-NBDKKCHT.js +0 -74
- package/dist/find-OH4BEULF.js +0 -11
- package/dist/forget/index.d.ts +0 -36
- package/dist/guards/index.d.ts +0 -35
- package/dist/hash-CwHnoKyW.d.ts +0 -72
- package/dist/history/index.d.ts +0 -61
- package/dist/i18n/index.d.ts +0 -37
- package/dist/in/index.d.ts +0 -5
- package/dist/index-B9QdHytu.d.ts +0 -123
- package/dist/index-CTvUp94-.d.ts +0 -123
- package/dist/index-Dn5GzPg_.d.ts +0 -22138
- package/dist/indexing/index.d.ts +0 -39
- package/dist/issue-AEOL6RXA.js +0 -19
- package/dist/kernel/index.d.ts +0 -32
- package/dist/kernel/index.js +0 -59
- package/dist/lazy/index.d.ts +0 -21
- package/dist/ledger-3LR3YO2W.js +0 -42
- package/dist/liberate-XSEPRWEA.js +0 -24
- package/dist/link-set-NSUIX6BR.js +0 -31
- package/dist/materialized-views/index.d.ts +0 -173
- package/dist/mime-magic-CYbFNQ4h.d.ts +0 -103
- package/dist/noydb-POVTIVQ6.js +0 -62
- package/dist/on/index.d.ts +0 -5
- package/dist/overlay-views/index.d.ts +0 -98
- package/dist/periods/index.d.ts +0 -20
- package/dist/pod/index.d.ts +0 -63
- package/dist/policy-Y7HL2KGA.js +0 -41
- package/dist/portability/index.d.ts +0 -20
- package/dist/post-register-KOFRTCDD.js +0 -55
- package/dist/post-register-KOFRTCDD.js.map +0 -1
- package/dist/public-envelope-NC7SPNMV.js +0 -32
- package/dist/query/index.d.ts +0 -5
- package/dist/read-only-facade-5ADRJVTM.js +0 -8
- package/dist/register-3D6R2MKN.js +0 -23
- package/dist/registry-AI4E46PD.js +0 -19
- package/dist/registry-HSNQ4NBP.js +0 -9
- package/dist/registry-WIX6QCV5.js +0 -17
- package/dist/request-withdrawal-GU4XS2R5.js +0 -31
- package/dist/reveal-5Y777N5Q.js +0 -38
- package/dist/reveal-5Y777N5Q.js.map +0 -1
- package/dist/revoke-ZFETCLYV.js +0 -24
- package/dist/revoke-ZFETCLYV.js.map +0 -1
- package/dist/satellites/index.d.ts +0 -5
- package/dist/sealed-record/index.d.ts +0 -69
- package/dist/session/index.d.ts +0 -44
- package/dist/shadow/index.d.ts +0 -15
- package/dist/signer-GAIMQQ2J.js +0 -25
- package/dist/signer-GAIMQQ2J.js.map +0 -1
- package/dist/snapshots/index.d.ts +0 -26
- package/dist/stale-77LP2EEF.js +0 -14
- package/dist/stale-77LP2EEF.js.map +0 -1
- package/dist/storage-KEXIXLGM.js +0 -23
- package/dist/storage-KEXIXLGM.js.map +0 -1
- package/dist/store-coordination-provider-NJDDZ264.js +0 -142
- package/dist/subject-index-O75wKshW.d.ts +0 -362
- package/dist/sync/index.d.ts +0 -41
- package/dist/team/index.d.ts +0 -155
- package/dist/tiers/index.d.ts +0 -5
- package/dist/to/index.d.ts +0 -5
- package/dist/transition-guard-D5RLJv8S.d.ts +0 -165
- package/dist/tx/index.d.ts +0 -35
- package/dist/ui/index.d.ts +0 -1
- package/dist/ulid-DRH25k3y.d.ts +0 -66
- package/dist/util/index.d.ts +0 -79
- package/dist/validators-C3lrVF-c.d.ts +0 -101
- package/dist/vault-diff-_LSIcOMv.d.ts +0 -147
- package/dist/verify-CAYGXYNO.js +0 -139
- package/dist/verify-CAYGXYNO.js.map +0 -1
- package/dist/walk-SMAE4IEI.js +0 -241
- package/dist/with/index.d.ts +0 -38
- package/dist/with-materialized-view-Xv1-9Bh0.d.ts +0 -27
- package/dist/with-overlayed-view-CuWhq_-C.d.ts +0 -12
- package/dist/with-rollup-K_iwal4b.d.ts +0 -47
- package/dist/withdraw-accessible-Q7BULAN5.js +0 -28
- package/dist/withdraw-accessible-Q7BULAN5.js.map +0 -1
- /package/dist/{adapter/index.js.map → api-ZGS6LCOF.js.map} +0 -0
- /package/dist/{chunk-VIWOGJ2O.js.map → chunk-3B5VVCNY.js.map} +0 -0
- /package/dist/{chunk-P2PEPSPK.js.map → chunk-3LQ2YKO4.js.map} +0 -0
- /package/dist/{chunk-EU7HDMT3.js.map → chunk-3QCRBHCY.js.map} +0 -0
- /package/dist/{chunk-FZK3JJJK.js.map → chunk-4JBYV75E.js.map} +0 -0
- /package/dist/{chunk-I6JJ6VJS.js.map → chunk-4NXKCLLQ.js.map} +0 -0
- /package/dist/{chunk-VFQOE76I.js.map → chunk-5M5DVGV7.js.map} +0 -0
- /package/dist/{chunk-LFGJG4XZ.js.map → chunk-5YOLBEQ6.js.map} +0 -0
- /package/dist/{chunk-OWGAXPRE.js.map → chunk-6CRIV7DE.js.map} +0 -0
- /package/dist/{chunk-QABECTNN.js.map → chunk-6QTNZJBS.js.map} +0 -0
- /package/dist/{chunk-723XB5NX.js.map → chunk-6T2SCQRU.js.map} +0 -0
- /package/dist/{chunk-PVC2FBCQ.js.map → chunk-7DSTRQIJ.js.map} +0 -0
- /package/dist/{chunk-NTPWQH4S.js.map → chunk-AUSTCW2X.js.map} +0 -0
- /package/dist/{chunk-MOQ5M46U.js.map → chunk-B3HJYUOF.js.map} +0 -0
- /package/dist/{chunk-QYMMMKOO.js.map → chunk-BDVFPG6Y.js.map} +0 -0
- /package/dist/{chunk-PYIUDUGS.js.map → chunk-CAF6WOK7.js.map} +0 -0
- /package/dist/{chunk-5HZULLHE.js.map → chunk-CIE2BASH.js.map} +0 -0
- /package/dist/{chunk-BTFTHF6Q.js.map → chunk-CRI4OUV4.js.map} +0 -0
- /package/dist/{chunk-37JZR7CY.js.map → chunk-DLG74CNB.js.map} +0 -0
- /package/dist/{chunk-TCGVRKOS.js.map → chunk-ERJ7FU55.js.map} +0 -0
- /package/dist/{chunk-FWART3VA.js.map → chunk-EVVGJDRQ.js.map} +0 -0
- /package/dist/{chunk-X5QZAJDB.js.map → chunk-EXK7QRWF.js.map} +0 -0
- /package/dist/{chunk-5HRJQSKN.js.map → chunk-EYZ6IQ6X.js.map} +0 -0
- /package/dist/{chunk-DCVVCJVB.js.map → chunk-F64IRYG3.js.map} +0 -0
- /package/dist/{chunk-BJ2XF2RC.js.map → chunk-FHS2HQSH.js.map} +0 -0
- /package/dist/{chunk-HU55NPHZ.js.map → chunk-GKEWXIV5.js.map} +0 -0
- /package/dist/{chunk-I6URUNTD.js.map → chunk-GTGPO5KW.js.map} +0 -0
- /package/dist/{chunk-5UOPIPZC.js.map → chunk-HB3RFQSC.js.map} +0 -0
- /package/dist/{chunk-F3EKFGUS.js.map → chunk-I6GALP6E.js.map} +0 -0
- /package/dist/{chunk-R4IVPJHN.js.map → chunk-IL6POWCW.js.map} +0 -0
- /package/dist/{chunk-3KBK5LU4.js.map → chunk-IU6SNYX6.js.map} +0 -0
- /package/dist/{chunk-TUL5YQWF.js.map → chunk-J2ZX2XUV.js.map} +0 -0
- /package/dist/{chunk-UWZ7O4NR.js.map → chunk-JKJOGPZN.js.map} +0 -0
- /package/dist/{chunk-V76PHWLE.js.map → chunk-JZUV47FZ.js.map} +0 -0
- /package/dist/{chunk-II6DLDZM.js.map → chunk-K5IMOGHB.js.map} +0 -0
- /package/dist/{chunk-GDOOG5YQ.js.map → chunk-LASZKVMO.js.map} +0 -0
- /package/dist/{chunk-5YBUFCFF.js.map → chunk-NR5LT5RY.js.map} +0 -0
- /package/dist/{chunk-UMH35AQV.js.map → chunk-Q5VNKNE5.js.map} +0 -0
- /package/dist/{chunk-XW5LZYV4.js.map → chunk-QLWMEXCT.js.map} +0 -0
- /package/dist/{chunk-PAJCRV7O.js.map → chunk-QRB7NAOJ.js.map} +0 -0
- /package/dist/{chunk-U7LV2DUN.js.map → chunk-R4ROFEYC.js.map} +0 -0
- /package/dist/{chunk-RNYDHIQL.js.map → chunk-RIX4V2TB.js.map} +0 -0
- /package/dist/{chunk-L6Q5NA22.js.map → chunk-RYCTDFUX.js.map} +0 -0
- /package/dist/{chunk-CHK5VVMI.js.map → chunk-RZ5SVOYR.js.map} +0 -0
- /package/dist/{chunk-TIAYXOEI.js.map → chunk-SLFHQTTW.js.map} +0 -0
- /package/dist/{chunk-J5YUA6JB.js.map → chunk-UNFPPVNI.js.map} +0 -0
- /package/dist/{chunk-25G7PUTA.js.map → chunk-VLFCJYTL.js.map} +0 -0
- /package/dist/{chunk-7CZ6YXMO.js.map → chunk-VN3DBQAU.js.map} +0 -0
- /package/dist/{chunk-J7OH6R4K.js.map → chunk-VZRODIM3.js.map} +0 -0
- /package/dist/{chunk-55LSDABW.js.map → chunk-W22IKJE2.js.map} +0 -0
- /package/dist/{chunk-GLVXQU3E.js.map → chunk-X3YYQWOQ.js.map} +0 -0
- /package/dist/{chunk-M3OYTM5Z.js.map → chunk-YFXZEAYK.js.map} +0 -0
- /package/dist/{chunk-5JQMX2EH.js.map → chunk-ZAJAVEXY.js.map} +0 -0
- /package/dist/{chunk-26FSVNBL.js.map → chunk-ZICD77GM.js.map} +0 -0
- /package/dist/{chunk-IARAK3PK.js.map → chunk-ZUODRVHY.js.map} +0 -0
- /package/dist/{api-JDWL67WL.js.map → collection-facade-TLWIPI76.js.map} +0 -0
- /package/dist/{chunk-BGIZAFY7.js.map → computed-ZIQTYTDI.js.map} +0 -0
- /package/dist/{dead-filter-RHMNYOXP.js.map → dead-filter-ESOBZZP5.js.map} +0 -0
- /package/dist/{chunk-K2WCO3NX.js.map → delegation-W7ZV2322.js.map} +0 -0
- /package/dist/{collection-facade-EJVIN2BY.js.map → derive-H2BJTLUI.js.map} +0 -0
- /package/dist/{computed-6FOFXQPE.js.map → enclave-AP3I5W7O.js.map} +0 -0
- /package/dist/{delegation-IHXOASHV.js.map → executor-KGWTNEQD.js.map} +0 -0
- /package/dist/{derive-CD3ZVIXK.js.map → executor-OVEXR6RT.js.map} +0 -0
- /package/dist/{describe/index.js.map → executor-UNEH5ZYH.js.map} +0 -0
- /package/dist/{enclave-KGEUW2GL.js.map → export-accessible-PCMXSUZS.js.map} +0 -0
- /package/dist/{executor-EUPYHCLU.js.map → extract-partition-SWHFSYJO.js.map} +0 -0
- /package/dist/{fanout-sidecar-NBDKKCHT.js.map → fanout-sidecar-A765THMX.js.map} +0 -0
- /package/dist/{executor-KZ4B3PRT.js.map → find-N6345CNT.js.map} +0 -0
- /package/dist/{executor-MHUM2VZK.js.map → issue-5OKB6I2R.js.map} +0 -0
- /package/dist/{export-accessible-Z3NSZZHN.js.map → ledger-GFBKVPV4.js.map} +0 -0
- /package/dist/{extract-partition-VSKT35JG.js.map → liberate-3VDOT4KO.js.map} +0 -0
- /package/dist/{find-OH4BEULF.js.map → link-set-Z7Q2ASFX.js.map} +0 -0
- /package/dist/{issue-AEOL6RXA.js.map → noydb-ZCJOYBDI.js.map} +0 -0
- /package/dist/{kernel/index.js.map → policy-Z3RUAIY2.js.map} +0 -0
- /package/dist/{ledger-3LR3YO2W.js.map → public-envelope-B4KNWVUA.js.map} +0 -0
- /package/dist/{liberate-XSEPRWEA.js.map → read-only-facade-CHCKSEPD.js.map} +0 -0
- /package/dist/{link-set-NSUIX6BR.js.map → register-VAHONCID.js.map} +0 -0
- /package/dist/{noydb-POVTIVQ6.js.map → registry-7MLVD3VO.js.map} +0 -0
- /package/dist/{policy-Y7HL2KGA.js.map → registry-EPKPD5SM.js.map} +0 -0
- /package/dist/{public-envelope-NC7SPNMV.js.map → registry-P5T7PS2U.js.map} +0 -0
- /package/dist/{read-only-facade-5ADRJVTM.js.map → request-withdrawal-TI3A5WPS.js.map} +0 -0
- /package/dist/{register-3D6R2MKN.js.map → revoke-FDRD6GRW.js.map} +0 -0
- /package/dist/{registry-AI4E46PD.js.map → signer-MUWEIUI6.js.map} +0 -0
- /package/dist/{registry-HSNQ4NBP.js.map → stale-OSQ7J3AA.js.map} +0 -0
- /package/dist/{registry-WIX6QCV5.js.map → storage-MVFCGEQE.js.map} +0 -0
- /package/dist/{store-coordination-provider-NJDDZ264.js.map → store-coordination-provider-64OEZFGS.js.map} +0 -0
- /package/dist/{walk-SMAE4IEI.js.map → walk-SVNDIZ62.js.map} +0 -0
- /package/dist/{request-withdrawal-GU4XS2R5.js.map → withdraw-accessible-WZIEVWSR.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/via/lookup/registry.ts","../src/via/lookup/snapshot.ts","../src/port/with/lookup-strategy.ts","../src/kernel/via/dispatch.ts"],"sourcesContent":["/**\n * Pure dict-registry helpers — extracted from `kernel/vault.ts`'s dict\n * bodies (#650 Task 1 — via-lookup extraction, phase D).\n *\n * These take the vault-resident registry Maps (and a couple of vault-bound\n * callbacks) as ARGUMENTS instead of closing over `this` — no `Vault`\n * import here, so this module stays a plain, testable function library.\n * `kernel/vault.ts` keeps the registry Maps themselves (they're populated\n * by `vault.collection()` and read by the backup path) and calls these\n * helpers through the `port/with/lookup-strategy.ts` seam.\n */\n\nimport { getAtPath } from '../../kernel/paths.js'\nimport { UnknownDictCodeError, ValidationError } from '../../kernel/errors.js'\nimport type { JoinableSource } from '../../kernel/query/index.js'\nimport type { FieldRef, ViaGraph } from '../../kernel/via/graph.js'\nimport type { StaticDictDescriptor } from '../../port/with/i18n-strategy.js'\nimport { dictCollectionName, type LookupHandle } from './handle.js'\nimport type { LookupDescriptor, OnDelete } from './descriptor.js'\n\n/**\n * Validate staticDict codes on a `put()`. For each `staticDict()` field,\n * every stored code must be a declared key of the descriptor's table, else\n * `UnknownDictCodeError`. Opt out per descriptor with `{ validateCodes:\n * false }`. Supports scalar, dotted, and `[].`-wildcard field paths via\n * `getAtPath` (same path support as i18n validation).\n *\n * `staticFields` is the collection's `field → StaticDictDescriptor` map\n * (`Vault#staticDescriptorByField.get(collectionName)`) — `undefined`/empty\n * is a no-op.\n */\nexport function enforceStaticDictOnPut(\n staticFields: Record<string, StaticDictDescriptor> | undefined,\n record: unknown,\n): void {\n if (!staticFields || Object.keys(staticFields).length === 0) return\n if (!record || typeof record !== 'object') return\n\n const obj = record as Record<string, unknown>\n for (const [field, desc] of Object.entries(staticFields)) {\n if (desc.validateCodes === false) continue\n const known = new Set<string>(desc.keys)\n const values = getAtPath(obj, field)\n for (const value of values) {\n if (value === undefined || value === null) continue\n const codes = Array.isArray(value) ? value : [value]\n for (const code of codes) {\n if (typeof code !== 'string') continue\n if (!known.has(code)) {\n throw new UnknownDictCodeError(desc.name, field, code)\n }\n }\n }\n }\n}\n\n/**\n * Build a `JoinableSource` for a dictKey field, for use in dict joins.\n * Returns a source whose snapshot contains `{ key, labels, ...labels }`\n * records — one per dictionary entry — keyed by the stable key.\n *\n * staticDict: a code-table-backed source — snapshot() materialises the\n * in-memory table into rows, mirroring `LookupHandle.snapshotEntries()`.\n * Carries `displayLocale` so a locale-less `{ by: 'label' }` query has a\n * default locale to resolve at.\n *\n * Plain dictKey: the snapshot is built synchronously from the\n * `LookupHandle`'s write-through cache, which is populated on every\n * `put()`, `rename()`, `delete()`, and `list()` call. For pre-existing\n * data not yet touched this session, call `await vault.dictionary(name).list()`\n * first to warm the cache.\n *\n * Returns `null` when `field` is not a dictKey in `leftCollection`.\n */\nexport function resolveDictSource(\n leftCollection: string,\n field: string,\n staticDescriptorByField: ReadonlyMap<string, Record<string, StaticDictDescriptor>>,\n dictKeyFieldRegistry: ReadonlyMap<string, Record<string, string>>,\n getDictionaryHandle: (name: string) => LookupHandle,\n): JoinableSource | null {\n const staticFields = staticDescriptorByField.get(leftCollection)\n if (staticFields && field in staticFields) {\n const desc = staticFields[field]!\n const rows: readonly Record<string, unknown>[] = Object.entries(desc.table).map(\n ([key, labels]) => ({ key, labels, ...(labels as Record<string, string>) }),\n )\n const source: JoinableSource = {\n snapshot(): readonly unknown[] {\n return rows\n },\n lookupById(id: string): unknown {\n return rows.find((e) => e['key'] === id)\n },\n }\n if (desc.displayLocale !== undefined) {\n ;(source as { displayLocale?: string }).displayLocale = desc.displayLocale\n }\n return source\n }\n\n const dictFields = dictKeyFieldRegistry.get(leftCollection)\n if (!dictFields || !(field in dictFields)) return null\n const dictName = dictFields[field]\n if (!dictName) return null\n const handle = getDictionaryHandle(dictName)\n return {\n snapshot(): readonly unknown[] {\n return handle.snapshotEntries()\n },\n lookupById(id: string): unknown {\n const entries = handle.snapshotEntries()\n return entries.find((e) => e['key'] === id)\n },\n }\n}\n\n/** The minimal collection surface `updateReferencingRecords` needs. */\nexport interface DictReferencingCollection {\n list(): Promise<Record<string, unknown>[]>\n put(id: string, record: Record<string, unknown>): Promise<unknown>\n}\n\n/**\n * Find and rewrite records in every registered collection whose\n * dictKeyField points at `name`, replacing `oldKey` with `newKey`. Used by\n * `LookupHandle.rename()` (the only sanctioned mass-mutation path for\n * dictKey fields) via the vault's `findAndUpdateReferences` callback.\n *\n * `registry` is `Vault#dictKeyFieldRegistry` (collection name → field name\n * → dictionary name); `getCollection` is the vault's collection accessor —\n * rewrites go through the public `coll.put()` choke point, same as before.\n */\nexport async function updateReferencingRecords(\n registry: ReadonlyMap<string, Record<string, string>>,\n getCollection: (collectionName: string) => DictReferencingCollection,\n name: string,\n oldKey: string,\n newKey: string,\n): Promise<void> {\n for (const [collectionName, dictFields] of registry) {\n // Find fields that point at this dictionary\n const fields = Object.entries(dictFields)\n .filter(([, dn]) => dn === name)\n .map(([field]) => field)\n if (fields.length === 0) continue\n\n const coll = getCollection(collectionName)\n const records = await coll.list()\n for (const record of records) {\n let changed = false\n const updated = { ...record }\n for (const field of fields) {\n if (updated[field] === oldKey) {\n updated[field] = newKey\n changed = true\n }\n }\n if (changed) {\n const id = record['id'] as string | undefined\n if (id !== undefined) {\n await coll.put(id, updated)\n }\n }\n }\n }\n}\n\n/**\n * Resolve a label from an in-memory `{ locale -> label }` map, walking the\n * same fallback chain semantics as `LookupHandle.resolveLabel` (#650 Task 2\n * — moved here from `kernel/vault.ts` so the SAME chain serves both the\n * i18n binding's `dictLabelResolver` and the lookup binding's\n * `lookupLabelResolver`, which #650 Task 2 wires to the identical closure).\n */\nexport function resolveLabelFromMap(\n labels: Readonly<Record<string, string>>,\n locale: string,\n fallback?: string | readonly string[],\n): string | undefined {\n if (labels[locale] !== undefined) return labels[locale]\n const chain = Array.isArray(fallback)\n ? (fallback as readonly string[])\n : fallback\n ? [fallback as string]\n : []\n for (const fb of chain) {\n if (fb === 'any') {\n const any = Object.values(labels)[0]\n if (any !== undefined) return any\n } else if (labels[fb] !== undefined) {\n return labels[fb]\n }\n }\n return undefined\n}\n\n/**\n * Project a native `lookup(dimension, { backing:'static', table, … })`\n * descriptor into the legacy `StaticDictDescriptor` shape — the\n * alias-equivalence compat seam (#650 Task 2) that lets a native\n * static-tier lookup field reuse the SAME vault registries\n * (`staticByName`/`staticDescriptorByField`) — and therefore the same\n * `dictLabelResolver`/`resolveDictSource` machinery — as its `staticDict()`\n * alias. `vocabulary:'closed'` maps to `validateCodes:true` (closed = only\n * declared codes are legal); `'open'` maps to `validateCodes:false`.\n * Returns `undefined` for non-static or table-less (bare `enumOf`)\n * descriptors — those have nothing to register.\n */\nexport function lookupToStaticDictCompat(desc: LookupDescriptor): StaticDictDescriptor | undefined {\n if (desc.backing !== 'static' || desc.table === undefined) return undefined\n return {\n _noydbStaticDict: true,\n _viaBrand: 'i18n',\n name: desc.dimension,\n table: desc.table,\n keys: desc.keys ?? Object.keys(desc.table),\n ...(desc.displayLocale !== undefined ? { displayLocale: desc.displayLocale } : {}),\n ...(desc.onMissing !== undefined ? { onMissing: desc.onMissing } : {}),\n ...(desc.substitute !== undefined ? { substitute: desc.substitute } : {}),\n validateCodes: desc.vocabulary === 'closed',\n }\n}\n\n/** The vault-registry entries a collection's `lookupFields` contribute — the alias-equivalence bridge (#650 Task 2). */\nexport interface LookupDictCompat {\n /** Reserved-tier fields: field name -> dimension (dictionary) name — merges into `dictKeyFieldRegistry`. */\n readonly dictFieldMap: Record<string, string>\n /** Static-tier (table-bearing) fields, projected — merges into `staticDescriptorByField`/`staticByName`. */\n readonly staticEntries: ReadonlyArray<readonly [string, StaticDictDescriptor]>\n}\n\n/**\n * Bridge a collection's `lookupFields` into the SAME shape the legacy dict\n * registries expect, so `resolveDictSource`/`dictLabelResolver` (and\n * therefore `.join()`/`orderBy({by:'label'})`) serve a native `dict()`/\n * `lookup(static)` field identically to its `dictKey()`/`staticDict()`\n * alias — the reserved-vs-first-class-backing \"matrix\" tier is NOT bridged\n * here (no vault registry backs it; Task 5/6 build its own graph edge /\n * snapshot seam).\n */\nexport function collectLookupDictCompat(\n lookupFields: Record<string, LookupDescriptor> | undefined,\n): LookupDictCompat {\n const dictFieldMap: Record<string, string> = {}\n const staticEntries: Array<readonly [string, StaticDictDescriptor]> = []\n for (const [field, desc] of Object.entries(lookupFields ?? {})) {\n if (desc.backing === 'reserved') {\n dictFieldMap[field] = desc.dimension\n } else {\n const compat = lookupToStaticDictCompat(desc)\n if (compat) staticEntries.push([field, compat])\n }\n }\n return { dictFieldMap, staticEntries }\n}\n\n/**\n * Reserved-dict deps of a set of named collections (#653) — the `_dict_*`\n * collections partial sync must auto-include alongside a `collections`\n * filter, mirroring `SyncEngine`'s existing satellite-pair expansion.\n * One hop is provably complete: `vault.collection()` refuses `_dict_*`\n * names, so a dict can never itself declare lookup fields — no\n * dict-of-dict chain to recurse through.\n */\nexport function reservedDictDepsOf(\n names: readonly string[],\n dictKeyFieldRegistry: ReadonlyMap<string, Record<string, string>>,\n): readonly string[] {\n const out = new Set<string>()\n for (const name of names) {\n const fieldMap = dictKeyFieldRegistry.get(name)\n if (!fieldMap) continue\n for (const dictName of Object.values(fieldMap)) out.add(dictCollectionName(dictName))\n }\n return [...out]\n}\n\n/**\n * A lookup dimension's sync membership/altKey table, materialized from its\n * backing rows (#650 Task 3). `keys` is every canonical key present;\n * `altIndex` maps an altKey candidate VALUE to its owning canonical key.\n */\nexport interface MaterializedBacking {\n /** Canonical key values present in the materialized rows. */\n readonly keys: ReadonlySet<string>\n /** altKey candidate value -> canonical key. */\n readonly altIndex: ReadonlyMap<string, string>\n}\n\n/**\n * Build a lookup dimension's altKey index from its backing rows, enforcing\n * declare/warm-time uniqueness across `key ∪ altKeys` values (#650 Task 3 —\n * the CHE/SWZ drift class: two different rows must never claim the same\n * candidate key). `rows` is keyed by canonical key (`row[descriptor.key]`\n * for the matrix tier; the dimension's own key for static/reserved).\n * An altKey candidate VALUE may be a string or number — both normalize via\n * `coerceLookupKey` (#651 Task 3); non-scalar/absent values are skipped.\n * Pure — no I/O. Throws `ValidationError` on collision.\n */\nexport function materializeBackingTable(\n descriptor: LookupDescriptor,\n rows: ReadonlyMap<string, Record<string, unknown>>,\n): MaterializedBacking {\n const keys = new Set<string>(rows.keys())\n // Every value that has claimed ownership so far (canonical keys seed it) —\n // the union `key ∪ altKeys` uniqueness set the spec requires.\n const owner = new Map<string, string>()\n for (const key of keys) owner.set(key, key)\n\n const altIndex = new Map<string, string>()\n const altFields = descriptor.altKeys ?? []\n for (const [canonicalKey, row] of rows) {\n for (const altField of altFields) {\n const value = coerceLookupKey(row[altField])\n if (value === undefined || value === '') continue\n const existingOwner = owner.get(value)\n if (existingOwner !== undefined && existingOwner !== canonicalKey) {\n throw new ValidationError(\n `lookup \"${descriptor.dimension}\": altKey field \"${altField}\" value \"${value}\" is claimed by ` +\n `both \"${existingOwner}\" and \"${canonicalKey}\" — key/altKey values must be unique across the dimension.`,\n )\n }\n owner.set(value, canonicalKey)\n altIndex.set(value, canonicalKey)\n }\n }\n return { keys, altIndex }\n}\n\n/**\n * Closed-vocabulary membership test for one candidate key (#650 Task 3).\n * Static tier: sync, against the in-config key set (declared `keys`, or the\n * table's own keys when table-bearing). Reserved tier: sync — the declared\n * `keys` union the reserved handle's live write-through snapshot (closes\n * #649 for the native `dict()` spelling: the declared-keys promise the old\n * `dictKey()` doc comment made falsely). Matrix (collection) tier: sync —\n * delegates to `buildLookupAltIndex` so membership is checked against the\n * SAME `row[descriptor.key]` keying the altKey index uses (review fix,\n * Important 1: an earlier PUT-id `.get(key)` scan disagreed with the\n * altIndex whenever `descriptor.key !== 'id'`, wrongly rejecting valid\n * non-id candidates and wrongly accepting an unrelated row's PUT-id).\n */\nexport function checkLookupMembership(\n descriptor: LookupDescriptor,\n key: string,\n getDictionary: (dimension: string) => LookupHandle,\n getCollection: (dimension: string) => { querySourceForJoin(): JoinableSource },\n): boolean {\n if (descriptor.backing === 'static') {\n const known = descriptor.keys ?? (descriptor.table ? Object.keys(descriptor.table) : [])\n return known.includes(key)\n }\n if (descriptor.backing === 'reserved') {\n if ((descriptor.keys ?? []).includes(key)) return true\n return getDictionary(descriptor.dimension).snapshotEntries().some((e) => e['key'] === key)\n }\n return buildLookupAltIndex(descriptor, getDictionary, getCollection).keys.has(key)\n}\n\n/**\n * The ONE guarded key coercion (#651 Task 3, dm12) — string/number values\n * coerce to their canonical `String()` form; everything else (`null`,\n * `undefined`, objects, …) coerces to `undefined`. Every consumer that turns\n * a raw record field into a lookup key routes through this, closing the\n * bare-`String()` `\"undefined\"`/`\"null\"`-key poisoning class (seam map\n * finding 6): a row whose key field is genuinely absent must never mint the\n * literal candidate string `\"undefined\"`.\n */\nexport function coerceLookupKey(raw: unknown): string | undefined {\n return typeof raw === 'string' || typeof raw === 'number' ? String(raw) : undefined\n}\n\n/**\n * Resolve a backing row's canonical key VALUE — `coerceLookupKey(row[descriptor.key])`\n * (#651 Task 3). The matrix tier's `row[descriptor.key]`, never the row's own PUT-id\n * when the two differ (`descriptor.key !== 'id'`).\n */\nexport function resolveBackingRowKey(\n descriptor: LookupDescriptor,\n row: Record<string, unknown>,\n): string | undefined {\n return coerceLookupKey(row[descriptor.key])\n}\n\n/**\n * The referencing-side match predicate — does `rec[field]` (coerced) equal an\n * already-coerced `compareKey` (#651 Task 3)? Shared by every site that scans a\n * referencing collection for rows pointing at a given backing key\n * (`with-shape/links/vault-facade.ts`'s ref-delete propagation, `kernel/via/dispatch.ts`'s\n * forget-fanout twin).\n */\nexport function matchesReferencingValue(\n rec: Record<string, unknown>,\n field: string,\n compareKey: string,\n): boolean {\n return coerceLookupKey(rec[field]) === compareKey\n}\n\n/**\n * Materialize a lookup dimension's altKey index from whatever backing data\n * is synchronously available (#650 Task 3 — the `ingest` source). Static:\n * the in-config table. Reserved: the reserved handle's live write-through\n * cache (the same warm-via-put()/list() cache `resolveDictSource` already\n * relies on). Matrix (collection): the backing collection's own in-memory\n * eager cache via `querySourceForJoin()` — already public, already the\n * mechanism `.join()` uses (`with-shape/links/vault-facade.ts`'s\n * `resolveSource`); no new I/O, no fire-and-forget warm step. Like that\n * existing join precedent, a dimension collection this vault session has\n * not yet opened/populated sees an empty snapshot (no altKey normalization\n * until it has rows) — open/populate it first for normalization to apply.\n * A matrix row whose `descriptor.key` field coerces to `undefined` (missing/\n * non-scalar) is SKIPPED — never enters the index under a poisoned\n * `\"undefined\"` key (#651 Task 3, dm12).\n */\nexport function buildLookupAltIndex(\n descriptor: LookupDescriptor,\n getDictionary: (dimension: string) => LookupHandle,\n getCollection: (dimension: string) => { querySourceForJoin(): JoinableSource },\n): MaterializedBacking {\n if (descriptor.backing === 'static') {\n return materializeBackingTable(descriptor, new Map(Object.entries(descriptor.table ?? {})))\n }\n if (descriptor.backing === 'reserved') {\n const entries = getDictionary(descriptor.dimension).snapshotEntries()\n return materializeBackingTable(descriptor, new Map(entries.map((e) => [String(e['key']), e])))\n }\n const rows = getCollection(descriptor.dimension).querySourceForJoin().snapshot()\n const keyed = new Map<string, Record<string, unknown>>()\n for (const r of rows) {\n const row = r as Record<string, unknown>\n const key = resolveBackingRowKey(descriptor, row)\n if (key !== undefined) keyed.set(key, row)\n }\n return materializeBackingTable(descriptor, keyed)\n}\n\n/** One cross-collection `'ref'` graph edge a lookup field declares (#650 Task 5). Module-private —\n * only `registerLookupRefEdges` below (the exported entry point) consumes it. */\ninterface LookupRefEdge {\n readonly referencing: FieldRef\n readonly sources: readonly FieldRef[]\n readonly onDelete: OnDelete\n /** The backing dimension's canonical-key FIELD NAME on its own row (`desc.key` — matrix tier\n * only varies this; reserved/static tiers are always `'id'`). A referencing field always\n * stores THIS field's value, never the backing row's PUT-id when the two differ. */\n readonly keyField: string\n}\n\n/**\n * Compute the cross-collection `'ref'` edges a collection's `lookupFields` declare (#650 Task 5,\n * spec §4) — one edge per non-static-backing field: target = the referencing field; sources =\n * the backing dimension's whole-collection node (`field:'*'`, the wildcard key\n * `ViaGraph.referencingEdgesOf` does its O(1) reverse lookup against) PLUS, when the descriptor\n * names a presentation field (`present.label`), that SPECIFIC field too. `foldPosture`'s\n * `DEFAULT_POSTURE` is the fold's identity element, so adding the wildcard alongside a real field\n * source changes nothing when that field is plain — but folds in a classified/money posture when\n * it isn't (taint composition, spec §4: \"a lookup edge whose source names a classified field\n * contributes that field's posture\"). Static tier (`backing:'static'`) has no backing collection/\n * dimension rows to reference-check — excluded. Pure; consumed only by `registerLookupRefEdges` below.\n */\nfunction collectLookupRefEdges(\n collectionName: string,\n lookupFields: Record<string, LookupDescriptor> | undefined,\n): readonly LookupRefEdge[] {\n const edges: LookupRefEdge[] = []\n for (const [field, desc] of Object.entries(lookupFields ?? {})) {\n if (desc.backing === 'static') continue\n const backing = desc.backing === 'reserved' ? dictCollectionName(desc.dimension) : desc.dimension\n edges.push({\n referencing: { collection: collectionName, field },\n sources: [\n { collection: backing, field: '*' },\n ...(desc.present?.label !== undefined ? [{ collection: backing, field: desc.present.label }] : []),\n ],\n onDelete: desc.onDelete,\n keyField: desc.key,\n })\n }\n return edges\n}\n\n/** Thin wrapper — `collectLookupRefEdges` + one `graph.registerDerived` call per edge. Lets\n * `vault.collection()` (kernel-surface-budgeted, #650 Task 5) register a collection's lookup-ref\n * edges with a single line, keeping the ceiling-guarded call site a thin call (route logic here). */\nexport function registerLookupRefEdges(\n graph: ViaGraph,\n collectionName: string,\n lookupFields: Record<string, LookupDescriptor> | undefined,\n): void {\n for (const e of collectLookupRefEdges(collectionName, lookupFields)) {\n graph.registerDerived(e.referencing, e.sources, 'ref', 'record', e.onDelete, e.keyField)\n }\n}\n\n/**\n * `LookupViaConfig.snapshotFor`'s vault-built row source (#650 Task 6, spec\n * §5; matrix-tier coverage added #650 Task 7, spec §6 — Task 6 deferred it,\n * see `task-6-report.md`'s Concerns #1; the reviewer's Task-7 dispatch\n * refuted the \"needs a new vault-resident registry\" premise: the descriptor\n * is already in hand at both call sites, so `snapshotFor` just needs to\n * ACCEPT it). Takes the full `descriptor` (not a bare dimension name) so it\n * can route the matrix tier's `key` field, which — unlike reserved tier's\n * hardcoded `'id'` — varies per collection. Routes on `descriptor.backing`:\n *\n * - **reserved**: rows come straight from the SAME `LookupHandle.\n * snapshotEntries()` write-through cache `dictLabelResolver`/\n * `resolveDictSource` already read (no second copy), keyed by each\n * entry's own canonical `key` (always `'id'` by construction for this\n * tier — `dict()`'s factory hardcodes it).\n * - **collection** (matrix): rows come from `getCollection(dimension).\n * querySourceForJoin().snapshot()` — the SAME sync, already-live cache\n * `buildLookupAltIndex`'s matrix branch (above, this file) and `.join()`\n * itself already read — re-keyed via `resolveBackingRowKey(descriptor, row)`,\n * NOT the row's own PUT-id (which may differ when `key !== 'id'`; the exact\n * distinction the #650 Task 3 review fix already applies to\n * `checkLookupMembership`'s matrix branch). A row whose `descriptor.key`\n * field coerces to `undefined` is skipped (#651 Task 3, dm12).\n * - **static**: never routed here — `descriptor.table` is read directly by\n * the caller (`binding.ts`'s `compareLookupOrder`/`resolveLookupOrderLabel`,\n * `snapshot.ts`'s `presentLookupForJoin`); no vault call needed.\n *\n * `isReservedDimension` is the vault's `reservedLookupCollections`\n * membership test.\n */\nexport function buildLookupSnapshotRows(\n descriptor: LookupDescriptor,\n isReservedDimension: (dimension: string) => boolean,\n getDictionary: (dimension: string) => LookupHandle,\n getCollection: (dimension: string) => { querySourceForJoin(): JoinableSource },\n): ReadonlyMap<string, Record<string, unknown>> | undefined {\n const dimension = descriptor.dimension\n if (isReservedDimension(dimension)) {\n const rows = new Map<string, Record<string, unknown>>()\n for (const entry of getDictionary(dimension).snapshotEntries()) {\n const key = entry['key']\n if (typeof key === 'string') rows.set(key, entry)\n }\n return rows\n }\n if (descriptor.backing === 'collection') {\n const rawRows = getCollection(dimension).querySourceForJoin().snapshot()\n const rows = new Map<string, Record<string, unknown>>()\n for (const r of rawRows) {\n const row = r as Record<string, unknown>\n const key = resolveBackingRowKey(descriptor, row)\n if (key !== undefined) rows.set(key, row)\n }\n return rows\n }\n return undefined\n}\n","/**\n * The sync lookup snapshot + join/locale seam (#650 Task 6, spec §5 — \"the\n * snapshot+locale seam\"). Retires the #626 kernel→via grandfather:\n * `kernel/query/join.ts` no longer imports `via/i18n/core.js` directly\n * — it calls the `presentForJoin` hook this file's `buildPresentForJoin`\n * builds instead (seam map Part 2 item 4, the #626 reviewer-spec'd shape:\n * a sync `presentI18nForJoin`-class hook on `JoinableSource`).\n *\n * `LookupSnapshot` is the sync materialized `key -> row` view over ONE\n * lookup dimension's ALREADY-LIVE backing data (the `active.ts`\n * `_syncCache`/`snapshotEntries` write-through-cache pattern — never a\n * second copy of the data: `LookupViaConfig.snapshotFor`'s vault-built\n * closure reads the SAME `LookupHandle._syncCache` /\n * first-class-collection cache every other lookup consumer\n * (`dictLabelResolver`, `resolveDictSource`, `getAltIndex`) already reads).\n * Serves (reserved AND matrix tier since #650 Task 7 — `registry.ts`'s\n * `buildLookupSnapshotRows` routes both; static tier is read straight off\n * `descriptor.table` by every consumer below, never through this cache):\n * - join dressing (`presentForJoin`, consumed by `kernel/query/join.ts`\n * via `JoinableSource.presentForJoin`)\n * - dimension sort (`compareForOrder`, consumed by\n * `via/lookup/binding.ts`'s `ViaBinding.compareForOrder` closure)\n * - per-call-locale order-label resolution (`resolveOrderLabel`, #650\n * Task 7 — the `orderBy(..., {by:'label'})` channel `compareForOrder`\n * structurally can't serve, no locale param; consumed by\n * `kernel/query/builder.ts`'s `buildOrderLabelMaps`)\n * - membership: reserved/static-tier membership (#650 Task 3,\n * `checkLookupMembership`) already reads the identical sync caches\n * directly — not re-plumbed through this file; see\n * `.superpowers/sdd/task-6-report.md`'s \"bridge disposition\" section.\n *\n * Sync end-to-end (#553) — every function here is a pure, synchronous\n * transform over already-materialized rows; no store read, no Promise.\n */\nimport type { LookupDescriptor } from './descriptor.js'\nimport { presentI18nForJoin, type I18nTextDescriptor } from '../i18n/core.js'\n\n/** A lookup dimension's sync materialized view — see file header. */\nexport interface LookupSnapshot {\n /** The full backing row for `key`, or `undefined` when `key` isn't (yet) present in the snapshot. */\n row(key: string): Record<string, unknown> | undefined\n /** The dimension's declared presentation label for `key` at `locale` — mirrors `binding.ts`'s `fetchLookupLabel` (matrix-row branch), generalized to any tier's already-materialized rows. */\n label(key: string, locale: string, fallback?: unknown): string | undefined\n /**\n * Exact ordering for two canonical keys against `descriptor.sortBy`\n * (falls back to `present.label`, then to the raw keys) at `locale`.\n * Never throws — degrades to comparing the raw keys when no sortable\n * value resolves for either side.\n */\n compareKeys(a: string, b: string, locale: string): number\n}\n\n/** Read one row field, resolving a `by`-keyed (locale-map) value when `by` is declared. */\nfunction readRowField(\n row: Record<string, unknown> | undefined,\n field: string | undefined,\n by: string | undefined,\n locale: string,\n fallback?: unknown,\n): string | undefined {\n if (!row || field === undefined) return undefined\n const raw = row[field]\n if (by === undefined) return typeof raw === 'string' ? raw : undefined\n if (!raw || typeof raw !== 'object') return undefined\n const map = raw as Record<string, unknown>\n const val = map[locale]\n if (typeof val === 'string') return val\n if (typeof fallback === 'string' && typeof map[fallback] === 'string') return map[fallback]\n return undefined\n}\n\n/**\n * Build a sync `LookupSnapshot` over one dimension's already-materialized\n * rows (canonical-key -> row, the SAME keying `materializeBackingTable`\n * (`registry.ts`, #650 Task 3) uses). Pure — never reads a store.\n */\nexport function buildLookupSnapshot(\n dimension: string,\n rows: ReadonlyMap<string, Record<string, unknown>>,\n descriptor: LookupDescriptor,\n): LookupSnapshot {\n void dimension // identity only — kept for parity with materializeBackingTable/buildLookupAltIndex's signature and future diagnostics\n return {\n row: (key) => rows.get(key),\n label: (key, locale, fallback) =>\n readRowField(rows.get(key), descriptor.present?.label, descriptor.present?.by, locale, fallback),\n compareKeys: (a, b, locale) => {\n const sortField = descriptor.sortBy ?? descriptor.present?.label\n const av = readRowField(rows.get(a), sortField, descriptor.present?.by, locale) ?? a\n const bv = readRowField(rows.get(b), sortField, descriptor.present?.by, locale) ?? b\n return av < bv ? -1 : av > bv ? 1 : 0\n },\n }\n}\n\n/**\n * The lookup-label HALF of `presentForJoin` (#626 retirement, spec §5;\n * matrix-tier coverage added #650 Task 7) — resolves `<field>Label` for\n * every declared lookup field with a `present` dressing dimension, sync,\n * from `getSnapshotRows` (the vault-built `LookupViaConfig.snapshotFor`\n * closure — now descriptor-routed, see `registry.ts`'s\n * `buildLookupSnapshotRows`; static tier reads its own in-config `table`\n * directly, no vault call — never `undefined` for a declared static table).\n * Mirrors `binding.ts`'s `runLookupPresent` (the async `present()` hook)\n * minus the array/`[].`-wildcard handling that hook needs for full-record\n * reads — join dressing only ever sees the joined RIGHT-side record's\n * scalar fields, so that complexity doesn't apply here.\n */\nfunction presentLookupForJoin(\n record: Record<string, unknown>,\n locale: string,\n lookupFields: Record<string, LookupDescriptor>,\n getSnapshotRows: (descriptor: LookupDescriptor) => ReadonlyMap<string, Record<string, unknown>> | undefined,\n): Record<string, unknown> {\n let result = record\n for (const [field, desc] of Object.entries(lookupFields)) {\n if (desc.present === undefined) continue\n const raw = record[field]\n if (typeof raw !== 'string') continue\n const rows = desc.backing === 'static'\n ? (desc.table ? new Map(Object.entries(desc.table)) : undefined)\n : getSnapshotRows(desc)\n if (!rows) continue\n const label = buildLookupSnapshot(desc.dimension, rows, desc).label(raw, locale)\n if (label === undefined) continue\n if (result === record) result = { ...record }\n result[`${field}Label`] = label\n }\n return result\n}\n\n/**\n * Build the combined sync `presentForJoin(record, locale)` hook a\n * `Collection` attaches to the `JoinableSource` it exposes\n * (`querySourceForJoin()`) — the i18n-text half (`presentI18nForJoin`, the\n * exact `applyI18nLocale(..., 'join')` partial application\n * `kernel/query/join.ts` used to call directly, #626) composed with the\n * lookup-label half above. `undefined` when the collection declares\n * neither — `JoinableSource.presentForJoin` then stays unset, matching\n * today's `i18nFields`-absent behavior exactly (#626 parity lock).\n */\nexport function buildPresentForJoin(\n i18nFields: Record<string, I18nTextDescriptor> | undefined,\n lookupFields: Record<string, LookupDescriptor> | undefined,\n getSnapshotRows: ((descriptor: LookupDescriptor) => ReadonlyMap<string, Record<string, unknown>> | undefined) | undefined,\n): ((record: unknown, locale: string) => unknown) | undefined {\n const hasI18n = i18nFields !== undefined && Object.keys(i18nFields).length > 0\n const hasLookup = lookupFields !== undefined && Object.keys(lookupFields).length > 0\n if (!hasI18n && !hasLookup) return undefined\n const resolveRows = getSnapshotRows ?? (() => undefined)\n return (record, locale) => {\n if (record === null || typeof record !== 'object') return record\n let result = record as Record<string, unknown>\n if (hasI18n) result = presentI18nForJoin(result, i18nFields, locale)\n if (hasLookup) result = presentLookupForJoin(result, locale, lookupFields, resolveRows)\n return result\n }\n}\n","/**\n * Lookup strategy seam (#650 Task 1 — via-lookup extraction, phase D of the\n * Via port; precedent: `port/with/i18n-strategy.ts`). Lives on the `/with`\n * port (the one seam the kernel spine may import statically) so `Vault` can\n * reach the dict-registry pure helpers and the `LookupHandle`/`NO_LOOKUP`\n * types without a spine→`via/` static import (Check 14 via-layering bans\n * that; `port/with/` is always allowed, Check 9's sanctioned exception).\n *\n * `kernel/vault.ts` imports ONLY this module for lookup — never\n * `via/lookup/*` directly.\n *\n * This task (#650 Task 1) is a pure move: `Vault.dictionary()` still\n * constructs its handle through `i18nStrategy.buildDictionaryHandle`\n * (`port/with/i18n-strategy.ts`), which now internally delegates to\n * `withLookup().buildLookupHandle` (same handle, new home). `LookupStrategy`\n * / `NO_LOOKUP` / `isLookupCollectionName` here are the seam later phase-D\n * tasks bind `vault.collection()`'s lookup fields onto — unused by Task 1's\n * wiring, but their exact shapes are frozen now so later tasks don't\n * re-litigate them.\n */\n\nimport type { NoydbStore, EncryptedEnvelope } from '../../kernel/types.js'\nimport type { LedgerStore } from '../../with-commit/history/ledger/store.js'\nimport type { UnlockedKeyring } from '../../with-party/team/keyring.js'\nimport type { NoydbEventEmitter } from '../../kernel/events.js'\nimport type { ViaCryptoCtx } from '../../kernel/via/index.js'\nimport type { LookupHandle, DictionaryOptions } from '../../via/lookup/handle.js'\nimport {\n enforceStaticDictOnPut,\n resolveDictSource,\n updateReferencingRecords,\n resolveLabelFromMap,\n collectLookupDictCompat,\n lookupToStaticDictCompat,\n reservedDictDepsOf,\n materializeBackingTable,\n checkLookupMembership,\n buildLookupAltIndex,\n registerLookupRefEdges,\n buildLookupSnapshotRows,\n coerceLookupKey,\n resolveBackingRowKey,\n matchesReferencingValue,\n type DictReferencingCollection,\n type LookupDictCompat,\n type MaterializedBacking,\n} from '../../via/lookup/registry.js'\nimport { buildPresentForJoin } from '../../via/lookup/snapshot.js'\nimport type { LookupDescriptor } from '../../via/lookup/descriptor.js'\n\n/**\n * Backing options for `LookupStrategy.buildLookupHandle` — same shape as\n * `DictionaryOptions` (kept as a distinct alias since the \"lookup\" name is\n * the forward-looking one; `DictionaryOptions` stays the dict-tier name).\n */\nexport type LookupBackingOptions = DictionaryOptions\n\n/**\n * Options accepted by `LookupStrategy.buildLookupHandle`. Mirrors the\n * `LookupHandle` constructor verbatim, plus the two choke-point\n * participation hooks (`onDirty`/`onRecordMutated`) #647 (Task 4) wires —\n * both `undefined` in this task (pure move, no new call sites).\n */\nexport interface BuildLookupHandleOptions<Keys extends string = string> {\n readonly adapter: NoydbStore\n readonly compartmentName: string\n readonly dimensionName: string\n readonly keyring: UnlockedKeyring\n /**\n * The `reservedEnvelopes('_dict_')` capability (#629 Task 4) — the\n * handle's sanctioned crypto door onto its `_dict_<name>` collection.\n * Bound by the Vault to its own `getDEK`, the same per-collection-name\n * DEK resolver every other collection uses.\n */\n readonly reservedEnvelopes: ReturnType<ViaCryptoCtx['reservedEnvelopes']>\n readonly encrypted: boolean\n readonly ledger: LedgerStore | undefined\n readonly options: LookupBackingOptions\n readonly findAndUpdateReferences:\n | ((dimension: string, oldKey: string, newKey: string) => Promise<void>)\n | undefined\n readonly emitter: NoydbEventEmitter\n /**\n * #647 fix wave 1 — mints a version-ordered delete-marker envelope. Bound by the Vault to the\n * real `kernel/enclave` `buildDeleteMarker` function — `LookupHandle` (`via/lookup/**`)\n * may not import `kernel/enclave/` itself (Check 11/15), so this capability is injected the\n * same way `reservedEnvelopes` above is.\n */\n readonly buildDeleteMarker: (version: number, actor: string) => EncryptedEnvelope\n /** #650 Task 4 (#647) — choke-point participation hooks. */\n readonly onDirty?: ((collection: string, id: string, action: 'put' | 'delete', version: number) => Promise<void>) | undefined\n readonly onRecordMutated?: ((collection: string, id: string, action: 'put' | 'delete', version: number) => Promise<void>) | undefined\n /**\n * #650 Task 5 (#648) — the real reference check `LookupHandle.delete()`'s strict branch calls:\n * restrict throws `DictKeyInUseError` naming the referencing collection, cascade/nullify apply\n * their propagation. Bound by the Vault (never a `Collection`/keyring/DEK reach-around); a\n * no-op when the dimension has no declared lookup-referencing edges (today's dangling behavior\n * for undeclared refs is unaffected). Return value is discarded by the handle — callers who\n * need cascade/nullify counts (forget) go through `VaultLinks` directly.\n */\n readonly checkReferencesOnDelete?: ((key: string) => Promise<unknown>) | undefined\n /**\n * Used by the active strategy to satisfy the generic-key parameter on the\n * returned handle. The NO_LOOKUP stub never reads it. Mirrors\n * `BuildDictionaryHandleOptions._keyMarker` (`port/with/i18n-strategy.ts`).\n */\n // marker generic — runtime sees no value\n _keyMarker?: Keys\n}\n\nexport interface LookupStrategy {\n /**\n * Construct a typed `LookupHandle` for the named dimension. Throws under\n * `NO_LOOKUP`.\n */\n buildLookupHandle<Keys extends string = string>(\n opts: BuildLookupHandleOptions<Keys>,\n ): LookupHandle<Keys>\n}\n\nfunction notEnabled(op: string): Error {\n return new Error(\n `${op}: the NO_LOOKUP stub was reached, which should be unreachable today — there is no ` +\n '`lookupStrategy` `createNoydb({ ... })` option yet to select this stub over the real one; ' +\n '`vault.dictionary()` always resolves through `withLookup()` (see `via/i18n/active.ts`\\'s ' +\n 'delegation). This is forward scaffolding for a later task (mirrors `NO_I18N`\\'s shape) — if you ' +\n 'hit this, it indicates a bug, not a missing opt-in.',\n )\n}\n\n/**\n * No-lookup stub. Mirrors `NO_I18N.buildDictionaryHandle`'s shape, but unlike `NO_I18N` (wired as\n * `vault.ts`'s `opts.i18nStrategy ?? NO_I18N` default), nothing selects this stub today — there is\n * no `lookupStrategy` option on `createNoydb()`; `vault.dictionary()`'s only construction path\n * (`Vault.i18nStrategy.buildDictionaryHandle` → `withLookup().buildLookupHandle`) never reaches\n * here. Kept as forward scaffolding for a later task that wires an independent lookup opt-in.\n */\nexport const NO_LOOKUP: LookupStrategy = {\n buildLookupHandle() {\n throw notEnabled('vault.dictionary()')\n },\n}\n\n/** `_dict_*` (legacy dict tier) and `_lookup_*` (the phase-D reserved backing). */\nexport const LOOKUP_COLLECTION_PREFIXES = ['_dict_', '_lookup_'] as const\n\n/** Return true when a collection name is a reserved lookup-backing collection. */\nexport function isLookupCollectionName(name: string): boolean {\n return LOOKUP_COLLECTION_PREFIXES.some((prefix) => name.startsWith(prefix))\n}\n\n// Re-exported pure registry helpers (#650 Task 1) — `kernel/vault.ts`'s\n// thin delegators call these directly; small always-on functions, not\n// behind the tree-shake seam (same bundling class as `isLookupCollectionName`\n// above, just too large to duplicate inline like that one is).\nexport { enforceStaticDictOnPut, resolveDictSource, updateReferencingRecords }\nexport type { DictReferencingCollection }\n\n// #650 Task 4 (#647) — the reserved-collection naming helper `vault.ts`'s sync-registry\n// bookkeeping needs (mapping a declared dimension name to its `_dict_<name>` collection name).\nexport { dictCollectionName } from '../../via/lookup/handle.js'\n\n// #650 Task 2 — the alias-equivalence bridge (`resolveLabelFromMap` +\n// `collectLookupDictCompat`/`lookupToStaticDictCompat`) + the runtime\n// brand/shape predicates `via/compose.ts` needs to route `'lookup'`-branded\n// descriptors, mirroring `isI18nTextDescriptor`/`isDictKeyDescriptor` below.\nexport { resolveLabelFromMap, collectLookupDictCompat, lookupToStaticDictCompat }\nexport type { LookupDictCompat }\n\n// #653 — partial-sync reserved-dict expansion: maps a set of named collections to the\n// one-hop `_dict_*` deps their lookup fields reference, off `dictKeyFieldRegistry`.\nexport { reservedDictDepsOf }\n\n// #650 Task 3 — altKeys ingest normalization + open/closed vocabulary\n// governance: the declare/warm-time altIndex builder + the membership test\n// vault.ts's `membership`/`getAltIndex` closures delegate to.\nexport { materializeBackingTable, checkLookupMembership, buildLookupAltIndex }\nexport type { MaterializedBacking }\n\n// #650 Task 5 — registers a collection's lookup-fields' cross-collection 'ref' graph edges.\nexport { registerLookupRefEdges }\n\n// #650 Task 6 — the sync snapshot+locale seam (#626 retirement, spec §5):\n// `snapshotFor`'s vault-built row source + the combined presentForJoin\n// builder `kernel/collection-config.ts` calls to build the\n// `JoinableSource.presentForJoin` hook `kernel/query/join.ts` consumes.\nexport { buildLookupSnapshotRows, buildPresentForJoin }\nexport type { LookupSnapshot } from '../../via/lookup/snapshot.js'\n\n// #651 Task 3 — the ONE descriptor-keyed key-resolution core (guarded coercion +\n// backing-row-key resolve + referencing-value match) — every consumer (vault.ts,\n// with-shape/links/vault-facade.ts, kernel/via/dispatch.ts) routes through here,\n// never a bare `String()`, ending the dm12 dialect drift.\nexport { coerceLookupKey, resolveBackingRowKey, matchesReferencingValue }\n\n/** Runtime predicate for detecting a `LookupDescriptor` (any of the three tiers). */\nexport function isLookupDescriptor(x: unknown): x is LookupDescriptor {\n return (\n typeof x === 'object' &&\n x !== null &&\n (x as { _viaBrand?: unknown })._viaBrand === 'lookup'\n )\n}\n\n/** Runtime predicate for the bare enum tier (`backing:'static'`, no in-code `table` — no label source). */\nexport function isEnumDescriptor(x: unknown): x is LookupDescriptor {\n return isLookupDescriptor(x) && x.backing === 'static' && x.table === undefined\n}\n\n/**\n * Type-only re-exports — the kernel spine imports these descriptor/handle\n * types through the port instead of reaching into `via/lookup/*` or\n * `via/i18n/*` directly. `isolatedModules: true` erases these at\n * build time — no runtime coupling.\n */\nexport type { LookupHandle, DictEntry, DictionaryOptions } from '../../via/lookup/handle.js'\nexport type { LookupDescriptor, Vocabulary, LookupBacking, OnDelete } from '../../via/lookup/descriptor.js'\nexport type { LookupViaConfig } from '../../via/lookup/binding.js'\nexport type { DictKeyDescriptor, StaticDictDescriptor } from '../../via/i18n/dictionary.js'\n","// kernel/via/dispatch.ts — the batched, origin-aware sync/cutover/restore dispatch wave\n// (Via port phase C, #638 Task 4, fixes #621).\n//\n// `Collection._onRecordMutated`'s `sync-apply`/`cutover`/`restore` cases feed touched\n// (collection, id) pairs into a per-session `GraphBatch` (owned by `Vault._collectGraphTouch`)\n// instead of dispatching inline — the `local-write` path keeps its own byte-identical inline\n// dispatch (`wave` stays `undefined` there, per the spec's behavior lock). At batch-flush time\n// `runGraphDispatchWave` decrypts each touched record (id threaded into the decrypt, matching\n// the phase-B at-rest contract) and re-runs the SAME `dispatchDerivations`/\n// `dispatchMaterializedViews` the local-write path uses, sharing one `WaveContext` so N touched\n// records feeding the SAME rollup/MV target recompute exactly once (per-target dedup).\n// See docs/superpowers/specs/2026-07-11-via-phase-c-design.md §3.\n\nimport type { ViaGraph } from './graph.js'\nimport type { Collection } from '../collection.js'\nimport type { EncryptedEnvelope } from '../types.js'\nimport { PeriodClosedError } from '../errors.js'\nimport { matchesReferencingValue } from '../../port/with/lookup-strategy.js'\n\n/** One deleted child's resolved rollup PARENT intent (#640) — ids + a field name only. A\n * resolved `parentId` is an id, same class as any touched record id — never a stored value. */\nexport interface RollupDeleteIntent {\n readonly into: string\n readonly parentId: string\n readonly field: string\n}\n\n/** One collection's batched touches this session (#640 widens the #638 `Set<string>` shape):\n * `puts` — the original semantics, unchanged; `deletes` — a deleted record's id mapped to its\n * resolved rollup-parent intents, captured PRE-invalidation by `Collection._onRecordMutated`'s\n * sync-apply delete case (the FK is only readable there — see `kernel/collection.ts\n * #_rollupDeleteIntents`). */\nexport interface GraphTouch {\n readonly puts: Set<string>\n readonly deletes: Map<string, readonly RollupDeleteIntent[]>\n}\n\n/** Per-session touched set — collection → its `GraphTouch`. Metadata only — ids (collection\n * names, record ids INCLUDING resolved rollup parent ids) and field names; NEVER record payload\n * or key material. A resolved parentId is an id, same class as the touched ids — not a stored\n * value. */\nexport type GraphBatch = Map<string, GraphTouch>\n\n/** Get-or-create `batch`'s `GraphTouch` entry for `collection` (#640) — shared by\n * `Vault._collectGraphTouch`/`_collectGraphDelete` so each stays a one-line call. */\nexport function touchFor(batch: GraphBatch, collection: string): GraphTouch {\n let t = batch.get(collection)\n if (!t) {\n t = { puts: new Set(), deletes: new Map() }\n batch.set(collection, t)\n }\n return t\n}\n\n/** #640 — sync, I/O-free: `deleted`'s resolved rollup PARENT intents (the FK is only readable\n * NOW, before the record is gone) — a pure function so `Collection._rollupDeleteIntents` stays\n * a one-line delegator under the kernel-surface ceiling. `registry` is `this.derivationSource\n * ?.registry()`; `collectionName` is `this.name` (the CHILD/`rollup.from` side). Generic over\n * the registry's own spec shape so this file never imports a `with-formula` type (port-layering\n * — via/dispatch.ts must not gain a with-* import). */\nexport function resolveRollupDeleteIntents<S extends { source: string; rollup?: { from: string; key: string; field: string } }>(\n registry: { strategiesForSource(name: string): ReadonlyArray<{ spec: S }> } | undefined,\n collectionName: string,\n deleted: Record<string, unknown>,\n): RollupDeleteIntent[] {\n if (!registry) return []\n const intents: RollupDeleteIntent[] = []\n for (const { spec } of registry.strategiesForSource(collectionName)) {\n if (!spec.rollup || spec.rollup.from !== collectionName) continue\n const kv = deleted[spec.rollup.key]\n if (typeof kv === 'string' || typeof kv === 'number') intents.push({ into: spec.source, parentId: String(kv), field: spec.rollup.field })\n }\n return intents\n}\n\n/** #640 — resolve a `RollupDeleteIntent` back to its registry `spec`. The wave's per-intent\n * driver needs `spec.rollup.compute`, which `GraphBatch`'s metadata-only pin forbids batching —\n * so it's re-resolved here, post-boundary, instead of carried across it. `undefined` if the\n * intent's originating strategy was unregistered between collect time and wave time (residual\n * gap, freshness-only). */\nexport function findRollupSpecForIntent<S extends { source: string; rollup?: { from: string; field: string } }>(\n registry: { strategiesForSource(name: string): ReadonlyArray<{ spec: S }> } | undefined,\n collectionName: string,\n intent: RollupDeleteIntent,\n): S | undefined {\n return registry?.strategiesForSource(collectionName).find((s) => s.spec.source === intent.into && s.spec.rollup?.field === intent.field && s.spec.rollup?.from === collectionName)?.spec\n}\n\n/** One dedup ledger for a single wave — a target is recomputed at most once (mark-on-check). */\nexport class WaveContext {\n private readonly _seen = new Set<string>()\n seen(targetKey: string): boolean {\n if (this._seen.has(targetKey)) return true\n this._seen.add(targetKey)\n return false\n }\n}\n\n/** The slice of `Vault` the wave needs: the shared graph (the #553 zero-cost skip) and cached-\n * collection lookup — never constructs, since a touched collection is, by construction,\n * already open (it just fired `_onRecordMutated`). */\nexport interface VaultLike {\n readonly graph: ViaGraph\n _getCollection(name: string): Collection<Record<string, unknown>> | undefined\n /** #640 (#644 item 3) — structured wave-error surfacing, additive to the existing console.warn. */\n _emit(event: string, payload: unknown): void\n}\n\n/**\n * Run ONE dispatch wave for a completed batch: for each touched (collection, id), decrypt the\n * applied envelope (id threaded), then run the SAME `dispatchDerivations` +\n * `dispatchMaterializedViews` the local-write path uses — with a shared `WaveContext` so N\n * touched records feeding the SAME target recompute once. #553: a collection with no graph\n * out-edges (e.g. money-only) is skipped before any decrypt/dispatch async work.\n */\nexport async function runGraphDispatchWave(vault: VaultLike, batch: GraphBatch): Promise<void> {\n const wave = new WaveContext()\n for (const [collectionName, touch] of batch) {\n if (vault.graph.dependentsOf(collectionName).length === 0) continue\n const coll = vault._getCollection(collectionName)\n if (!coll) continue\n for (const id of touch.puts) {\n try {\n // Decrypt is INSIDE the per-id isolation boundary (whole-branch review Important\n // finding, #638): an undecryptable synced envelope (`TamperedError`) must not\n // escape `_getStoredRecordForDispatch` and abort the wave — that would propagate\n // through `_flushGraphBatch` and reject the surrounding `SyncEngine.pull`/`push`\n // AFTER records were already applied + meta persisted, starving every other\n // touched target in the same batch.\n const stored = await coll._getStoredRecordForDispatch(id)\n if (!stored) continue\n await coll.dispatchDerivations(id, stored.record, stored.version, wave)\n await coll.dispatchMaterializedViews(id, stored.record, wave)\n } catch (err) {\n // #638 Task 5 review mandate: one touched record's recompute must not abort the\n // whole wave (starving co-batched healthy targets) or the pull/push it's nested\n // inside. `PeriodClosedError` never reaches here — `putDerivedOutput` already\n // intercepts it at every output-write call site and turns it into a skip+event.\n // Anything else (a genuine decrypt failure, a derive()/executor bug, a schema\n // violation on the output, ...) is surfaced — not silently swallowed — via the\n // SAME console.warn channel `dispatchDerivations`/the MV executor already use for\n // their own non-strict-mode output failures, then isolated to just this one id.\n // #644 item 3: ADDITIVELY (never in place of the warn) emit a structured event too,\n // so a listener doesn't have to scrape console output to react to a wave failure.\n console.warn(`[via-dispatch] wave recompute failed for ${collectionName}/${id}:`, err)\n vault._emit('derivation:wave-error', { collection: collectionName, id, error: err })\n }\n }\n // #640 — delete-kind touches: the deleted child's rollup-parent intents, resolved (sync,\n // pre-invalidation) at collect time by `Collection._rollupDeleteIntents`. Same per-id\n // isolation as the puts loop above. #658: the wave now ALSO heals MV rows and array-shape\n // derivation output rows for the deleted child — parity with the local-delete boundary\n // (`Collection._doDelete`'s `!internal` block, which already calls all three). Still never\n // routed through `dispatchDerivations` (the mutation-choke-point.test.ts:85-99 pin — sync-\n // applied deletes never RE-DERIVE); `dispatchMaterializedViewsOnDelete`/\n // `dispatchArrayDerivationsOnDelete` only need `id` (MV refresh recomputes+diffs; array-\n // derivation reads its per-source sidecar) and never call `derive()`, so the pin holds.\n for (const [id, intents] of touch.deletes) {\n try {\n await coll._recomputeDeletedRollups(intents, wave)\n // #658: record-shape same-id outputs are left untouched (eraseRecordShapeToo defaults\n // false), matching local delete — the user deletes those directly if wanted.\n // #658: TODO dedup MV refresh per wave — `dispatchMaterializedViewsOnDelete` doesn't\n // accept a `WaveContext` (unlike the put-path `dispatchMaterializedViews`), so N deleted\n // children of one eager MV in a batch each trigger a full refresh pass. Threading `wave`\n // through would touch collection.ts's zero-slack kernel-surface ceiling for a perf-only\n // win; correctness doesn't depend on it (idempotent per source-id) — left as a follow-up.\n await coll.dispatchMaterializedViewsOnDelete(id)\n await coll.dispatchArrayDerivationsOnDelete(id)\n } catch (err) {\n console.warn(`[via-dispatch] wave delete-recompute failed for ${collectionName}/${id}:`, err)\n vault._emit('derivation:wave-error', { collection: collectionName, id, error: err })\n }\n }\n }\n}\n\n/** A record's post-freeze source mutation, for the `'derivation:skipped-frozen'` event\n * and the optional audit-trail entry. See {@link putDerivedOutput}. */\nexport interface DerivationSkippedFrozen {\n readonly source: { readonly collection: string; readonly id: string }\n readonly target: { readonly collection: string; readonly id: string }\n readonly period: string\n readonly endDate: string\n}\n\n/** The minimal put-capable shape `putDerivedOutput` needs. Any `Collection<T>` structurally\n * satisfies this — its real `options` type is a superset of what's declared here. */\nexport interface CollectionLike {\n put(id: string, value: unknown, options?: { readonly source?: string }): Promise<void>\n}\n\nexport interface PutDerivedOutputCtx {\n readonly emit: (ev: string, p: unknown) => void\n readonly source: { readonly collection: string; readonly id: string }\n readonly audit?: ((e: DerivationSkippedFrozen) => Promise<void>) | undefined\n}\n\n/**\n * Attempt a dispatch-driven output write. On `PeriodClosedError` (the closed-period\n * `beforePut` gate — `freezePeriod`/`archivePeriod` add no separate gate, per seam map\n * Part 7): SKIP (no `_ts` stamped — the gate throws before any write happens), emit\n * `'derivation:skipped-frozen'` on the event bus (ALWAYS), and append an audit-trail entry\n * when the with-history ledger is active. Returns `'written' | 'skipped-frozen'`. Any OTHER\n * error propagates unchanged — this helper narrows exactly one error class. The SOURCE\n * write is never wrapped through this helper — only derived-output writes are (§7).\n */\nexport async function putDerivedOutput(\n outColl: CollectionLike, id: string, value: unknown,\n ctx: PutDerivedOutputCtx,\n options?: { readonly source?: string },\n): Promise<'written' | 'skipped-frozen'> {\n try {\n await outColl.put(id, value, options)\n return 'written'\n } catch (err) {\n if (!(err instanceof PeriodClosedError)) throw err\n // Reach-around for the target collection's private `name` — the SAME pattern\n // `with-formula/materialized-views/executor.ts`'s `listOutputIds` already uses to\n // read a `Collection`'s private `adapter`/`vault`/`name` fields from outside the class.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const targetCollection = (outColl as any).name as string\n const event: DerivationSkippedFrozen = {\n source: ctx.source,\n target: { collection: targetCollection, id },\n period: err.periodName,\n endDate: err.endDate,\n }\n ctx.emit('derivation:skipped-frozen', event)\n if (ctx.audit) await ctx.audit(event)\n return 'skipped-frozen'\n }\n}\n\n/** Structural (no static import — kernel spine may not statically reach a with-* service,\n * the S4 gate recipe `check-architecture.mjs`'s port-layering check enforces) shape of the\n * with-history `LedgerStore.append` seam this helper needs. */\ninterface AuditLedgerLike {\n append(input: {\n readonly op: 'lifecycle'\n readonly collection: string\n readonly id: string\n readonly version: number\n readonly actor: string\n readonly payloadHash: string\n readonly reason?: string\n }): Promise<unknown>\n}\n\n/** @internal — the optional with-history ledger audit hook for `putDerivedOutput`, present\n * only when the ledger is active (mirrors every other kernel event's `if (this.ledger)`\n * gate). Encoded as a `'lifecycle'` entry — the existing \"non-data audit event\" op (the\n * same convention `forget`'s JSON-summary-in-`reason` entry uses; `ledger/entry.ts:88-104`). */\nexport function ledgerAuditHook(\n ledger: AuditLedgerLike | undefined, actor: string,\n): ((e: DerivationSkippedFrozen) => Promise<void>) | undefined {\n if (!ledger) return undefined\n return async (e) => {\n await ledger.append({\n op: 'lifecycle', collection: e.target.collection, id: e.target.id, version: 0, actor, payloadHash: '',\n reason: JSON.stringify({ event: 'derivation-skipped-frozen', ...e }),\n })\n }\n}\n\n/** `recomputeRollup`/`dispatchRollupsOnDelete`'s per-target write outcome (#638 Task 6):\n * `'written'`/`'skipped-frozen'` mirror {@link putDerivedOutput}'s result; `'noop'` covers\n * no-parent/no-change/deduped-by-wave — nothing to report either way. */\nexport type RollupOutcome = 'written' | 'skipped-frozen' | 'noop'\n\n/** Mutable accumulator `forgetDerivedFanout` writes into, one per `Vault.forget()` call — keeps\n * the per-ref loop's call site to a single line under vault.ts's tight kernel-surface ceiling.\n * Maps 1:1 onto `ForgetResult`'s additive fields (`with-audit/forget/strategy.ts`). */\nexport interface ForgetFanoutStats {\n recordsErased: number\n aggregatesRecomputed: number\n readonly residueFrozen: string[]\n /** #650 Task 5 (#648) — referencing records tombstoned via a `'ref'` edge's `cascade` policy. */\n lookupReferencesCascaded: number\n /** #650 Task 5 (#648) — referencing fields cleared via a `'ref'` edge's `nullify` policy. */\n lookupReferencesNullified: number\n /** #650 Task 5 review (Important fix) — `'ref'` edges whose compare-key could NOT be resolved,\n * even from the LIVE pre-shred row (the backing row itself is unreadable) — propagation was\n * skipped for these, reported here so the skip is never silent. `backing:key:collection.field`\n * entries, one per un-propagated edge. */\n readonly lookupReferencesResidue: string[]\n /** #776/#782/#785 — `outputCollection:id` MV-output rows that survived erasure invalidation\n * (eager tombstone leg AND lazy/manual `invalidateMVAtRest`) despite belonging to the\n * forgotten subject, because the ownership stamp could not be decoded (undecodable under\n * the default DEK — e.g. elevated above tier 0 on a tiered output collection). Ownership\n * UNCONFIRMED. Never erased, but surfaced here rather than silently skipped. */\n readonly derivedResidueUndecodable: string[]\n /** #782/#785 — `outputCollection:id` MV-output rows that decoded and stamp-matched but whose\n * `_internalDelete` declined (the #718 tier-elevation gate). Ownership CONFIRMED, erasure\n * declined — a real silent survival, surfaced here rather than silently skipped. */\n readonly derivedResidueDeclined: string[]\n}\n\n/**\n * #622 — after `_writeTombstone(ref.id, actor)` erases the forgotten subject's own record, fan\n * out to its derived residue via the graph (spec §5): record-grain artifacts (MV rows,\n * array-shape derivation rows, same-id record-shape derivation copies) are ERASED through the\n * SAME `!internal` housekeeping-bypass machinery the ordinary delete path uses (no user\n * `onDelete` re-fires — the shred-is-not-a-domain-delete property `_writeTombstone` protects);\n * aggregate-grain rollups are RECOMPUTED without the forgotten contribution in open periods, or\n * skip+audit (via `putDerivedOutput`, already wired into the rollup/MV output paths) in frozen\n * ones. Mutates `stats` in place. `envelope` is `ref`'s PRE-tombstone envelope, decoded only if\n * a rollup edge is actually present — the #553 zero-cost-skip discipline: no decrypt for the\n * common case of a forgotten record with no aggregate-grain consumer, and no work at all when\n * `ref.collection` has no graph out-edges. `lookupCompareKeys` is the `'ref'` edges' compare-key\n * map, resolved from the LIVE row BEFORE any shred (`VaultLinks.checkLookupRefsRestrict`'s return\n * value — `Vault.forget()`'s pre-shred restrict check doubles as the live-resolve pass) — see\n * {@link applyLookupRefsFanout}.\n */\nexport async function forgetDerivedFanout(\n vault: VaultLike,\n ref: { readonly collection: string; readonly id: string },\n envelope: EncryptedEnvelope | null,\n stats: ForgetFanoutStats,\n lookupCompareKeys: ReadonlyMap<string, string | undefined>,\n): Promise<void> {\n const coll = vault._getCollection(ref.collection)\n\n // #761 item 4 — drive the MV arm off `dispatchMaterializedViewsOnDelete` UNCONDITIONALLY,\n // ABOVE the `edges` check below: `registry.edges()` drops the same-collection\n // partition-disjoint MV edge (registry.ts's `sources.length === 0 → continue`), so a\n // same-collection MV's source collection never appears in `vault.graph`'s derived-artifact\n // edges even though the MV IS registered — forget() would otherwise never reach it.\n // `dispatchMaterializedViewsOnDelete` self-guards O(1) via `mvsForSource` (a no-op when\n // this collection isn't an MV source), so this is safe to call unconditionally. Safe to\n // route through the eager executor's tombstone leg ONLY because that leg is now\n // stamp-scoped (#762) — before that fix this would have opened a NEW forget-time\n // data-loss path into the unscoped tombstone diff.\n if (coll) {\n const mv = await coll.dispatchMaterializedViewsOnDelete(ref.id)\n stats.recordsErased += mv.deleted\n stats.derivedResidueUndecodable.push(...mv.residueUndecodable)\n stats.derivedResidueDeclined.push(...mv.residueDeclined)\n }\n\n const edges = vault.graph.derivedArtifactsOf(ref.collection)\n if (edges.length === 0 || !coll) return\n\n // #650 Task 5 (#648) — 'ref' cascade/nullify propagate ADDITIVELY, here, AFTER the shred\n // (restrict already refused BEFORE any shred — the caller's pre-tombstone check, spec §4).\n // The I/O shell (loop shape, collection accessor) is duplicated, not imported, from\n // `VaultLinks.applyLookupRefsPropagation`/`checkLookupRefsRestrict` (with-shape/links/\n // vault-facade.ts) — the kernel spine may not statically import a with-* service\n // (port-layering, the #638 Task 5 via/dispatch.ts precedent); `vault._getCollection` is\n // cached-only while `VaultLinks`' accessor constructs. The pure match predicate itself is\n // shared through the port seam (#651 Task 3 — `matchesReferencingValue`, `port/with/\n // lookup-strategy.ts`), so only the shell, not the coercion logic, stays duplicated. A\n // referencing edge whose dimension uses a non-default `key` (matrix tier only) needs the\n // backing row's OWN value at that field, not its PUT-id — the row is ALREADY tombstoned by\n // now, so it's read from `lookupCompareKeys`, resolved by the caller from the LIVE row\n // BEFORE the shred (#650 Task 5 review, Important fix — eliminates the post-shred\n // envelope-decode dependency this used to have, which silently skipped propagation whenever\n // that decode failed).\n if (edges.some((e) => e.kind === 'ref')) {\n const { cascaded, nullified, residue } = await applyLookupRefsFanout(vault, ref.collection, ref.id, lookupCompareKeys)\n stats.lookupReferencesCascaded += cascaded\n stats.lookupReferencesNullified += nullified\n stats.lookupReferencesResidue.push(...residue)\n }\n\n if (edges.some((e) => e.kind === 'derivation')) {\n // #622 review Finding 1: count REAL erasures (dispatchArrayDerivationsOnDelete's own\n // `_internalDelete`-backed tally), not the derivation EDGE count — an edge exists whenever\n // this collection is ANY trigger (source/sources[]/triggerBy), but the same-id record-shape\n // guard only erases for `spec.source === this.name`, and `derive()` may never have produced\n // an output row (optional-skip) in the first place. Both cases must contribute 0, not +1.\n stats.recordsErased += await coll.dispatchArrayDerivationsOnDelete(ref.id, true)\n }\n\n if (envelope && edges.some((e) => e.kind === 'rollup')) {\n const priorRecord = await coll._decodeEnvelope(envelope, ref.id)\n if (priorRecord) {\n for (const r of await coll.dispatchRollupsOnDelete(ref.id, priorRecord)) {\n if (r.outcome === 'written') stats.aggregatesRecomputed += 1\n else if (r.outcome === 'skipped-frozen') stats.residueFrozen.push(`${r.into}:${r.parentId}`)\n }\n }\n }\n}\n\n/**\n * Apply `cascade`/`nullify` propagation for `backing`'s non-restrict `'ref'` edges — the\n * forget-path counterpart of `VaultLinks.applyLookupRefsPropagation` (I/O shell duplicated, not\n * imported, match predicate shared via the port — see {@link forgetDerivedFanout}'s call site\n * comment). `restrict` edges are skipped here: the\n * forget loop's `checkLookupRefsRestrict`-equivalent call already refused (or the reference no\n * longer existed) BEFORE `_writeTombstone` ran, so by the time this runs only cascade/nullify\n * remain to propagate. `compareKeys` is the non-`'id'`-`keyField` compare-value map, resolved by\n * the caller from the LIVE row BEFORE the shred (#650 Task 5 review, Important fix) — the live row\n * is already shredded by the time THIS function runs, so it can no longer resolve one itself. A\n * `keyField` absent from (or `undefined` in) the map means that live resolve failed too — the edge\n * is reported as residue instead of silently skipped (never a bare `continue` with no trace).\n */\nasync function applyLookupRefsFanout(\n vault: VaultLike,\n backing: string,\n key: string,\n compareKeys: ReadonlyMap<string, string | undefined>,\n): Promise<{ cascaded: number; nullified: number; residue: string[] }> {\n let cascaded = 0\n let nullified = 0\n const residue: string[] = []\n for (const { referencing, onDelete, keyField } of vault.graph.referencingEdgesOf(backing)) {\n if (onDelete === 'restrict') continue\n const compareKey = keyField === 'id' ? key : compareKeys.get(keyField)\n if (compareKey === undefined) {\n residue.push(`${backing}:${key}:${referencing.collection}.${referencing.field}`)\n continue\n }\n const coll = vault._getCollection(referencing.collection)\n if (!coll) continue\n const matches = (await coll.list()).filter((rec) => matchesReferencingValue(rec, referencing.field, compareKey))\n for (const rec of matches) {\n const id = rec['id'] as string | undefined\n if (id === undefined) continue\n if (onDelete === 'cascade') {\n await coll.delete(id)\n cascaded++\n } else if (onDelete === 'nullify') {\n await coll.put(id, { ...rec, [referencing.field]: null })\n nullified++\n }\n }\n }\n return { cascaded, nullified, residue }\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BO,SAAS,uBACd,cACA,QACM;AACN,MAAI,CAAC,gBAAgB,OAAO,KAAK,YAAY,EAAE,WAAW,EAAG;AAC7D,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU;AAE3C,QAAM,MAAM;AACZ,aAAW,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,YAAY,GAAG;AACxD,QAAI,KAAK,kBAAkB,MAAO;AAClC,UAAM,QAAQ,IAAI,IAAY,KAAK,IAAI;AACvC,UAAM,SAAS,UAAU,KAAK,KAAK;AACnC,eAAW,SAAS,QAAQ;AAC1B,UAAI,UAAU,UAAa,UAAU,KAAM;AAC3C,YAAM,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AACnD,iBAAW,QAAQ,OAAO;AACxB,YAAI,OAAO,SAAS,SAAU;AAC9B,YAAI,CAAC,MAAM,IAAI,IAAI,GAAG;AACpB,gBAAM,IAAI,qBAAqB,KAAK,MAAM,OAAO,IAAI;AAAA,QACvD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAoBO,SAAS,kBACd,gBACA,OACA,yBACA,sBACA,qBACuB;AACvB,QAAM,eAAe,wBAAwB,IAAI,cAAc;AAC/D,MAAI,gBAAgB,SAAS,cAAc;AACzC,UAAM,OAAO,aAAa,KAAK;AAC/B,UAAM,OAA2C,OAAO,QAAQ,KAAK,KAAK,EAAE;AAAA,MAC1E,CAAC,CAAC,KAAK,MAAM,OAA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
|
6
|
+
for (const [field, reg] of Object.entries(state.fields)) {
|
|
7
|
+
result[field] = reg.v;
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
case "rga": {
|
|
12
|
+
const dead = new Set(state.tombstones);
|
|
13
|
+
return state.items.filter((i) => !dead.has(i.nid)).map((i) => i.v);
|
|
14
|
+
}
|
|
15
|
+
case "yjs":
|
|
16
|
+
return state.update;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function mergeCrdtStates(a, b) {
|
|
20
|
+
if (a._crdt !== b._crdt) return a;
|
|
21
|
+
switch (a._crdt) {
|
|
22
|
+
case "lww-map":
|
|
23
|
+
return mergeLwwMap(a, b);
|
|
24
|
+
case "rga":
|
|
25
|
+
return mergeRga(a, b);
|
|
26
|
+
case "yjs":
|
|
27
|
+
return a;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function mergeLwwMap(a, b) {
|
|
31
|
+
const merged = {};
|
|
32
|
+
const allFields = /* @__PURE__ */ new Set([...Object.keys(a.fields), ...Object.keys(b.fields)]);
|
|
33
|
+
for (const field of allFields) {
|
|
34
|
+
const fa = a.fields[field];
|
|
35
|
+
const fb = b.fields[field];
|
|
36
|
+
if (!fa) {
|
|
37
|
+
merged[field] = fb;
|
|
38
|
+
} else if (!fb) {
|
|
39
|
+
merged[field] = fa;
|
|
40
|
+
} else {
|
|
41
|
+
merged[field] = fa.ts >= fb.ts ? fa : fb;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { _crdt: "lww-map", fields: merged };
|
|
45
|
+
}
|
|
46
|
+
function mergeRga(a, b) {
|
|
47
|
+
const allTombstones = /* @__PURE__ */ new Set([...a.tombstones, ...b.tombstones]);
|
|
48
|
+
const seenNids = new Set(a.items.map((i) => i.nid));
|
|
49
|
+
const merged = [
|
|
50
|
+
...a.items,
|
|
51
|
+
...b.items.filter((i) => !seenNids.has(i.nid))
|
|
52
|
+
];
|
|
53
|
+
return { _crdt: "rga", items: merged, tombstones: [...allTombstones] };
|
|
54
|
+
}
|
|
55
|
+
function buildLwwMapState(record, existing, now) {
|
|
56
|
+
const fields = {};
|
|
57
|
+
for (const [field, value] of Object.entries(record)) {
|
|
58
|
+
fields[field] = { v: value, ts: now };
|
|
59
|
+
}
|
|
60
|
+
if (existing) {
|
|
61
|
+
for (const [field, reg] of Object.entries(existing.fields)) {
|
|
62
|
+
if (!(field in fields)) {
|
|
63
|
+
fields[field] = reg;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { _crdt: "lww-map", fields };
|
|
68
|
+
}
|
|
69
|
+
function buildRgaState(arr, existing, generateNid) {
|
|
70
|
+
const existingByValue = /* @__PURE__ */ new Map();
|
|
71
|
+
if (existing) {
|
|
72
|
+
for (const item of existing.items) {
|
|
73
|
+
const key = JSON.stringify(item.v);
|
|
74
|
+
if (!existingByValue.has(key)) existingByValue.set(key, item);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const usedNids = /* @__PURE__ */ new Set();
|
|
78
|
+
const newItems = [];
|
|
79
|
+
for (const el of arr) {
|
|
80
|
+
const key = JSON.stringify(el);
|
|
81
|
+
const match = existingByValue.get(key);
|
|
82
|
+
if (match && !usedNids.has(match.nid)) {
|
|
83
|
+
newItems.push(match);
|
|
84
|
+
usedNids.add(match.nid);
|
|
85
|
+
} else {
|
|
86
|
+
const nid = generateNid();
|
|
87
|
+
newItems.push({ nid, v: el });
|
|
88
|
+
usedNids.add(nid);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const tombstones = existing ? [...existing.tombstones] : [];
|
|
92
|
+
const extraItems = [];
|
|
93
|
+
if (existing) {
|
|
94
|
+
for (const item of existing.items) {
|
|
95
|
+
if (!usedNids.has(item.nid)) {
|
|
96
|
+
if (!tombstones.includes(item.nid)) tombstones.push(item.nid);
|
|
97
|
+
extraItems.push(item);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const items = [...newItems, ...extraItems];
|
|
102
|
+
return { _crdt: "rga", items, tombstones };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
resolveCrdtSnapshot,
|
|
107
|
+
mergeCrdtStates,
|
|
108
|
+
buildLwwMapState,
|
|
109
|
+
buildRgaState
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=chunk-4GPE63GU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/with-commit/crdt/crdt.ts"],"sourcesContent":["/**\n * CRDT state types, merge logic, and build helpers.\n * per-collection CRDT mode: 'lww-map' | 'rga' | 'yjs'\n *\n * The encrypted envelope wraps the CRDT state (not the resolved snapshot).\n * Adapters only ever see ciphertext. `collection.get(id)` returns the\n * resolved snapshot; `collection.getRaw(id)` returns the full CRDT state.\n */\n\n// Hoisted to kernel/types.ts (C3 — enclave self-containment: record-codec.ts\n// consumes CrdtState/CrdtMode as spine-owned contract types; LwwMapState/\n// RgaState/YjsState were hoisted alongside them to break the types.ts ↔\n// crdt.ts cycle — #667). Re-exported here so existing importers of this\n// module are unaffected.\nimport type { CrdtState, LwwMapState, RgaState } from '../../kernel/types.js'\nexport type { CrdtMode, CrdtState, LwwMapState, RgaState, YjsState } from '../../kernel/types.js'\n\n// ─── Snapshot resolution ──────────────────────────────────────────────\n\n/**\n * Resolve a CRDT state into the end-user record snapshot.\n *\n * - `lww-map` → `Record<string, unknown>` (field values extracted from registers)\n * - `rga` → `unknown[]` (non-tombstoned items in insertion order)\n * - `yjs` → `string` (base64 update blob; use @noy-db/yjs for a Y.Doc)\n */\nexport function resolveCrdtSnapshot(state: CrdtState): unknown {\n switch (state._crdt) {\n case 'lww-map': {\n const result: Record<string, unknown> = {}\n for (const [field, reg] of Object.entries(state.fields)) {\n result[field] = reg.v\n }\n return result\n }\n case 'rga': {\n const dead = new Set(state.tombstones)\n return state.items.filter(i => !dead.has(i.nid)).map(i => i.v)\n }\n case 'yjs':\n return state.update\n }\n}\n\n// ─── CRDT merge ───────────────────────────────────────────────────────\n\n/**\n * Merge two CRDT states produced by concurrent writes.\n * Called by the collection-level conflict resolver registered with SyncEngine.\n *\n * For `yjs`: core cannot merge Yjs without importing the `yjs` package.\n * The caller must handle that case by falling back to the higher-`_v` envelope.\n */\nexport function mergeCrdtStates(a: CrdtState, b: CrdtState): CrdtState {\n // Mismatched modes shouldn't happen in practice — same collection, same schema.\n if (a._crdt !== b._crdt) return a\n\n switch (a._crdt) {\n case 'lww-map':\n return mergeLwwMap(a, b as LwwMapState)\n case 'rga':\n return mergeRga(a, b as RgaState)\n case 'yjs':\n // Signal to caller that Yjs merge is needed externally\n return a\n }\n}\n\nfunction mergeLwwMap(a: LwwMapState, b: LwwMapState): LwwMapState {\n const merged: Record<string, { v: unknown; ts: string }> = {}\n const allFields = new Set([...Object.keys(a.fields), ...Object.keys(b.fields)])\n for (const field of allFields) {\n const fa = a.fields[field]\n const fb = b.fields[field]\n if (!fa) { merged[field] = fb! }\n else if (!fb) { merged[field] = fa }\n else { merged[field] = fa.ts >= fb.ts ? fa : fb }\n }\n return { _crdt: 'lww-map', fields: merged }\n}\n\nfunction mergeRga(a: RgaState, b: RgaState): RgaState {\n // Union tombstones from both sides\n const allTombstones = new Set([...a.tombstones, ...b.tombstones])\n // Union items by nid: start with a's ordering, append b-only items\n const seenNids = new Set(a.items.map(i => i.nid))\n const merged: Array<{ nid: string; v: unknown }> = [\n ...a.items,\n ...b.items.filter(i => !seenNids.has(i.nid)),\n ]\n return { _crdt: 'rga', items: merged, tombstones: [...allTombstones] }\n}\n\n// ─── Build helpers ────────────────────────────────────────────────────\n\n/**\n * Build (or update) an lww-map state from a new record.\n *\n * All fields in the new record win at timestamp `now`.\n * Fields present in the existing state but absent from the new record\n * are preserved (they were written by another device).\n */\nexport function buildLwwMapState(\n record: Record<string, unknown>,\n existing: LwwMapState | undefined,\n now: string,\n): LwwMapState {\n const fields: Record<string, { v: unknown; ts: string }> = {}\n\n // New record fields all get the current timestamp — this device wins for these\n for (const [field, value] of Object.entries(record)) {\n fields[field] = { v: value, ts: now }\n }\n\n // Preserve fields from the existing state that aren't in the new record\n if (existing) {\n for (const [field, reg] of Object.entries(existing.fields)) {\n if (!(field in fields)) {\n fields[field] = reg\n }\n }\n }\n\n return { _crdt: 'lww-map', fields }\n}\n\n/**\n * Build (or update) an RGA state from a new array.\n *\n * Existing items are matched to new elements by deep-equality of their `v`.\n * Unmatched existing items are tombstoned. New elements that have no existing\n * match get a fresh NID via `generateNid()`.\n */\nexport function buildRgaState(\n arr: unknown[],\n existing: RgaState | undefined,\n generateNid: () => string,\n): RgaState {\n // Build an index from JSON(v) → existing item so we can match by value\n const existingByValue = new Map<string, { nid: string; v: unknown }>()\n if (existing) {\n for (const item of existing.items) {\n // Only add first occurrence per value to avoid double-matching\n const key = JSON.stringify(item.v)\n if (!existingByValue.has(key)) existingByValue.set(key, item)\n }\n }\n\n const usedNids = new Set<string>()\n const newItems: Array<{ nid: string; v: unknown }> = []\n\n for (const el of arr) {\n const key = JSON.stringify(el)\n const match = existingByValue.get(key)\n if (match && !usedNids.has(match.nid)) {\n // Reuse existing NID to preserve cross-device identity\n newItems.push(match)\n usedNids.add(match.nid)\n } else {\n // New element — assign a fresh NID\n const nid = generateNid()\n newItems.push({ nid, v: el })\n usedNids.add(nid)\n }\n }\n\n // Elements in the existing state that aren't in the new array → tombstone.\n // Tombstoned items are kept in the items array to preserve ordering for\n // cross-device merge — the resolved snapshot filters them out.\n const tombstones: string[] = existing ? [...existing.tombstones] : []\n const extraItems: Array<{ nid: string; v: unknown }> = []\n if (existing) {\n for (const item of existing.items) {\n if (!usedNids.has(item.nid)) {\n if (!tombstones.includes(item.nid)) tombstones.push(item.nid)\n extraItems.push(item) // retain in items for ordering\n }\n }\n }\n\n // Final items: live items in new order, then tombstoned extras at the end\n const items = [...newItems, ...extraItems]\n\n return { _crdt: 'rga', items, tombstones }\n}\n"],"mappings":";AA0BO,SAAS,oB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AAM,GAAG,GAAG;AAErC,eAAS,KAAK,KAAK;AACnB,eAAS,IAAI,MAAM,GAAG;AAAA,IACxB,OAAO;AAEL,YAAM,MAAM,YAAY;AACxB,eAAS,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC;AAC5B,eAAS,IAAI,GAAG;AAAA,IAClB;AAAA,EACF;AAKA,QAAM,aAAuB,WAAW,CAAC,GAAG,SAAS,UAAU,IAAI,CAAC;AACpE,QAAM,aAAiD,CAAC;AACxD,MAAI,UAAU;AACZ,eAAW,QAAQ,SAAS,OAAO;AACjC,UAAI,CAAC,SAAS,IAAI,KAAK,GAAG,GAAG;AAC3B,YAAI,CAAC,WAAW,SAAS,KAAK,GAAG,EAAG,YAAW,KAAK,KAAK,GAAG;AAC5D,mBAAW,KAAK,IAAI;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AAGA,QAAM,QAAQ,CAAC,GAAG,UAAU,GAAG,UAAU;AAEzC,SAAO,EAAE,OAAO,OAAO,OAAO,WAAW;AAC3C;","names":[]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openEnvelopeJson
|
|
3
|
+
} from "./chunk-XDYREZWE.js";
|
|
4
|
+
import {
|
|
5
|
+
encrypt
|
|
6
|
+
} from "./chunk-CIE2BASH.js";
|
|
7
|
+
import {
|
|
8
|
+
NOYDB_FORMAT_VERSION
|
|
9
|
+
} from "./chunk-JNAI2HN2.js";
|
|
10
|
+
import {
|
|
11
|
+
ConflictError,
|
|
12
|
+
USER_ENVELOPE_COLLECTION,
|
|
13
|
+
USER_ENVELOPE_MAX_BYTES,
|
|
14
|
+
UserEnvelopeOversizedError
|
|
15
|
+
} from "./chunk-BIOUI4HL.js";
|
|
16
|
+
|
|
17
|
+
// src/with-party/directory/storage.ts
|
|
18
|
+
var META_COLLECTION = "_meta";
|
|
19
|
+
var DIRECTORY_RECORD_ID = "directory";
|
|
20
|
+
async function readDirectoryConfig(store, vault) {
|
|
21
|
+
const envelope = await store.get(vault, META_COLLECTION, DIRECTORY_RECORD_ID);
|
|
22
|
+
if (!envelope) return void 0;
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(envelope._data);
|
|
25
|
+
if (!isDirectoryConfig(parsed)) return void 0;
|
|
26
|
+
return parsed;
|
|
27
|
+
} catch {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function persistDirectoryConfig(store, vault, config) {
|
|
32
|
+
const envelope = {
|
|
33
|
+
_noydb: NOYDB_FORMAT_VERSION,
|
|
34
|
+
_v: 1,
|
|
35
|
+
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
36
|
+
_iv: "",
|
|
37
|
+
_data: JSON.stringify({ enabled: config.enabled })
|
|
38
|
+
};
|
|
39
|
+
await store.put(vault, META_COLLECTION, DIRECTORY_RECORD_ID, envelope);
|
|
40
|
+
}
|
|
41
|
+
function isDirectoryConfig(x) {
|
|
42
|
+
if (x === null || typeof x !== "object") return false;
|
|
43
|
+
if (!("enabled" in x)) return false;
|
|
44
|
+
return typeof x.enabled === "boolean";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/with-party/directory/visibility.ts
|
|
48
|
+
var VISIBILITY_RECORD_PREFIX = "visibility/";
|
|
49
|
+
function visibilityRecordId(keyringId) {
|
|
50
|
+
return VISIBILITY_RECORD_PREFIX + keyringId;
|
|
51
|
+
}
|
|
52
|
+
async function readUserVisibility(store, vault, keyringId) {
|
|
53
|
+
const envelope = await store.get(vault, META_COLLECTION, visibilityRecordId(keyringId));
|
|
54
|
+
if (!envelope) return void 0;
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(envelope._data);
|
|
57
|
+
if (!isUserVisibility(parsed)) return void 0;
|
|
58
|
+
return parsed;
|
|
59
|
+
} catch {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function persistUserVisibility(store, vault, keyringId, visibility) {
|
|
64
|
+
const envelope = {
|
|
65
|
+
_noydb: NOYDB_FORMAT_VERSION,
|
|
66
|
+
_v: 1,
|
|
67
|
+
_ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
68
|
+
_iv: "",
|
|
69
|
+
_data: JSON.stringify({ hidden: visibility.hidden })
|
|
70
|
+
};
|
|
71
|
+
await store.put(vault, META_COLLECTION, visibilityRecordId(keyringId), envelope);
|
|
72
|
+
}
|
|
73
|
+
async function deleteUserVisibility(store, vault, keyringId) {
|
|
74
|
+
await store.delete(vault, META_COLLECTION, visibilityRecordId(keyringId));
|
|
75
|
+
}
|
|
76
|
+
function isUserVisibility(x) {
|
|
77
|
+
if (x === null || typeof x !== "object") return false;
|
|
78
|
+
if (!("hidden" in x)) return false;
|
|
79
|
+
return typeof x.hidden === "boolean";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/with-party/directory/user-envelope/storage.ts
|
|
83
|
+
async function loadUserEnvelope(store, vault, keyringId, dek) {
|
|
84
|
+
const envelope = await store.get(vault, USER_ENVELOPE_COLLECTION, keyringId);
|
|
85
|
+
if (!envelope) return null;
|
|
86
|
+
const plaintext = await openEnvelopeJson(envelope, dek);
|
|
87
|
+
const data = JSON.parse(plaintext);
|
|
88
|
+
return {
|
|
89
|
+
keyringId,
|
|
90
|
+
data,
|
|
91
|
+
_v: envelope._v,
|
|
92
|
+
_ts: envelope._ts
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async function saveUserEnvelope(store, vault, keyringId, payload, dek, expectedVersion) {
|
|
96
|
+
const json = JSON.stringify(payload);
|
|
97
|
+
const bytes = new TextEncoder().encode(json).byteLength;
|
|
98
|
+
if (bytes > USER_ENVELOPE_MAX_BYTES) {
|
|
99
|
+
throw new UserEnvelopeOversizedError(bytes);
|
|
100
|
+
}
|
|
101
|
+
const prior = await store.get(vault, USER_ENVELOPE_COLLECTION, keyringId);
|
|
102
|
+
if (expectedVersion !== void 0) {
|
|
103
|
+
const priorVersion = prior?._v ?? 0;
|
|
104
|
+
if (priorVersion !== expectedVersion) {
|
|
105
|
+
throw new ConflictError(
|
|
106
|
+
priorVersion,
|
|
107
|
+
`User envelope for "${keyringId}" expected version ${expectedVersion}, actual ${priorVersion}`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const nextVersion = (prior?._v ?? 0) + 1;
|
|
112
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
113
|
+
const { iv, data } = await encrypt(json, dek);
|
|
114
|
+
const envelope = {
|
|
115
|
+
_noydb: NOYDB_FORMAT_VERSION,
|
|
116
|
+
_v: nextVersion,
|
|
117
|
+
_ts: ts,
|
|
118
|
+
_iv: iv,
|
|
119
|
+
_data: data
|
|
120
|
+
};
|
|
121
|
+
await store.put(vault, USER_ENVELOPE_COLLECTION, keyringId, envelope);
|
|
122
|
+
return {
|
|
123
|
+
keyringId,
|
|
124
|
+
data: payload,
|
|
125
|
+
_v: nextVersion,
|
|
126
|
+
_ts: ts
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
async function deleteUserEnvelope(store, vault, keyringId) {
|
|
130
|
+
await store.delete(vault, USER_ENVELOPE_COLLECTION, keyringId);
|
|
131
|
+
}
|
|
132
|
+
async function listUserEnvelopeIds(store, vault) {
|
|
133
|
+
return store.list(vault, USER_ENVELOPE_COLLECTION);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
DIRECTORY_RECORD_ID,
|
|
138
|
+
readDirectoryConfig,
|
|
139
|
+
persistDirectoryConfig,
|
|
140
|
+
VISIBILITY_RECORD_PREFIX,
|
|
141
|
+
visibilityRecordId,
|
|
142
|
+
readUserVisibility,
|
|
143
|
+
persistUserVisibility,
|
|
144
|
+
deleteUserVisibility,
|
|
145
|
+
loadUserEnvelope,
|
|
146
|
+
saveUserEnvelope,
|
|
147
|
+
deleteUserEnvelope,
|
|
148
|
+
listUserEnvelopeIds
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=chunk-4JBYV75E.js.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MaterializedViewConfigError,
|
|
3
|
+
ValidationError
|
|
4
|
+
} from "./chunk-BIOUI4HL.js";
|
|
5
|
+
|
|
6
|
+
// src/with-formula/materialized-views/with-materialized-view.ts
|
|
7
|
+
function withMaterializedView(spec) {
|
|
8
|
+
if (!spec.name || spec.name.length === 0) {
|
|
9
|
+
throw new ValidationError("withMaterializedView: name is required");
|
|
10
|
+
}
|
|
11
|
+
if (spec.query && spec.unionSources) {
|
|
12
|
+
throw new MaterializedViewConfigError(
|
|
13
|
+
"query and unionSources are mutually exclusive \u2014 pick one"
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (!spec.query && !spec.unionSources) {
|
|
17
|
+
throw new MaterializedViewConfigError(
|
|
18
|
+
"strategy must declare either query or unionSources"
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (spec.query !== void 0 && typeof spec.query !== "function") {
|
|
22
|
+
throw new ValidationError("withMaterializedView: query must be a function returning a Query<T>");
|
|
23
|
+
}
|
|
24
|
+
if (spec.unionSources) {
|
|
25
|
+
if (spec.unionSources.length < 1) {
|
|
26
|
+
throw new MaterializedViewConfigError(
|
|
27
|
+
"unionSources requires at least 1 source collection"
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
const seen = /* @__PURE__ */ new Set();
|
|
31
|
+
for (const s of spec.unionSources) {
|
|
32
|
+
if (typeof s?.collection !== "string" || s.collection.length === 0) {
|
|
33
|
+
throw new MaterializedViewConfigError(
|
|
34
|
+
"each unionSources entry must declare a non-empty `collection` string"
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (typeof s.map !== "function") {
|
|
38
|
+
throw new MaterializedViewConfigError(
|
|
39
|
+
`unionSources entry for "${s.collection}" is missing a \`map\` function`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
if (seen.has(s.collection)) {
|
|
43
|
+
throw new MaterializedViewConfigError(
|
|
44
|
+
`unionSources must reference distinct collections (duplicate: "${s.collection}")`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
seen.add(s.collection);
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(spec.groupBy) && spec.groupBy.length === 0) {
|
|
50
|
+
throw new MaterializedViewConfigError(
|
|
51
|
+
`withMaterializedView "${spec.name}": groupBy must not be an empty array \u2014 omit it or provide at least one field name`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (spec.aggregate && !spec.groupBy) {
|
|
55
|
+
throw new MaterializedViewConfigError(
|
|
56
|
+
`withMaterializedView "${spec.name}": UNION strategy with aggregate requires groupBy \u2014 use groupBy to declare the bucketing keys, or remove aggregate for a pure dedup MV`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (spec.moneyFields && !spec.aggregate) {
|
|
60
|
+
throw new MaterializedViewConfigError(
|
|
61
|
+
`withMaterializedView "${spec.name}": moneyFields requires aggregate \u2014 moneyFields rewrites sum/min/max reducers over money output fields, so it is meaningless without an aggregate spec`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (spec.unionSources.some((s) => s.join && s.join.length > 0) && (!spec.sources || spec.sources.length === 0)) {
|
|
65
|
+
throw new MaterializedViewConfigError(
|
|
66
|
+
`withMaterializedView "${spec.name}": a unionSources arm declares join(s) but no \`sources\` are listed \u2014 declare sources: [...] with the right-side (join-target) collection names so writes to them trigger MV refresh`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (spec.predicates) {
|
|
70
|
+
throw new MaterializedViewConfigError(
|
|
71
|
+
`withMaterializedView "${spec.name}": predicates are not supported on UNION strategies \u2014 UNION mode does not use a Query<T> chain, so .wherePredicate() cannot fire. Use the query() form, or open an issue if per-arm predicates are needed`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (spec.i18nLocale !== void 0 && spec.i18nFields === void 0) {
|
|
76
|
+
throw new MaterializedViewConfigError(
|
|
77
|
+
`withMaterializedView "${spec.name}": i18nLocale requires i18nFields \u2014 declare the i18nText descriptors of the group-key fields so they can be resolved at the mv layer before bucketing.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (typeof spec.rowKey !== "function") {
|
|
81
|
+
throw new ValidationError("withMaterializedView: rowKey is required (no default; see spec \xA7 Type surface)");
|
|
82
|
+
}
|
|
83
|
+
if (spec.refresh !== "eager" && spec.refresh !== "lazy" && spec.refresh !== "manual") {
|
|
84
|
+
throw new ValidationError(
|
|
85
|
+
`withMaterializedView: refresh must be 'eager' | 'lazy' | 'manual', got "${String(spec.refresh)}"`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
__noydb_strategy: "materialized-view",
|
|
90
|
+
spec
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
withMaterializedView
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=chunk-4NXKCLLQ.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NoydbError
|
|
3
|
+
} from "./chunk-BIOUI4HL.js";
|
|
4
|
+
|
|
5
|
+
// src/kernel/via/index.ts
|
|
6
|
+
var binders = /* @__PURE__ */ new Map();
|
|
7
|
+
function installViaBinder(brand, binder) {
|
|
8
|
+
if (!binders.has(brand)) binders.set(brand, binder);
|
|
9
|
+
}
|
|
10
|
+
function isViaInstalled(brand) {
|
|
11
|
+
return binders.has(brand);
|
|
12
|
+
}
|
|
13
|
+
function viaBinder(brand) {
|
|
14
|
+
const b = binders.get(brand);
|
|
15
|
+
if (!b) {
|
|
16
|
+
throw new NoydbError(
|
|
17
|
+
"VIA_NOT_LINKED",
|
|
18
|
+
`via feature "${brand}" requires descriptors created via its declaration factory from @noy-db/hub`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return b;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
installViaBinder,
|
|
26
|
+
isViaInstalled,
|
|
27
|
+
viaBinder
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-4VNQOLML.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/kernel/via/index.ts"],"sourcesContent":["// kernel/via/index.ts — the ONLY kernel-resident via surface.\nimport { NoydbError } from '../errors.js'\nimport type { EncryptedEnvelope } from '../types.js'\n\n/** Awaitable type for potentially async results. */\ntype Awaitable<T> = T | Promise<T>\n\n/** Declared security posture — a property the kernel enforces (enforcement activates in phases B/C). */\nexport interface ViaPosture {\n readonly encryptedAtRest: 'envelope' | 'sealed'\n readonly queryable: 'none' | 'det-exact' | 'ordered' | 'full'\n readonly exportable: boolean\n readonly forgettable: boolean\n}\n\n/** Opaque marker every feature descriptor extends; the kernel never sees concrete descriptor types. */\nexport interface ViaDescriptor { readonly _viaBrand: string }\n\n/** Per-call write context (A: minimal; B/C extend). */\nexport interface ViaWriteCtx {\n readonly id: string\n /** Owning vault name (event payload identity — e.g. i18n:script-violation). */\n readonly vault: string\n /** Prior stored record (decoded), lazily resolved. Null when creating. */\n readonly prior: () => Promise<Record<string, unknown> | null>\n /** Typed event emission (e.g. i18n:script-violation). */\n readonly emit: (event: string, payload: unknown) => void\n}\n\n/** Per-call read context — mirrors LocaleReadOptions loosely; features narrow. */\nexport interface ViaReadCtx {\n readonly locale?: unknown\n readonly fallback?: unknown\n readonly layer: string\n}\n\n/** One sealed slot's ciphertext — matches the existing `iv:data` sealed map entries (seam map §2 step 2). */\nexport interface SealedSlotRef { readonly iv: string; readonly data: string }\n\n/**\n * A scoped crypto capability handed to a `via` feature's `encodeAtRest`/\n * `decodeAtRest`/`erase` hooks — never the keyring, never the enclave.\n * `sealedSlots` is pre-bound to one `(collection, recordId)`; `reservedEnvelopes`\n * is a whole-envelope encrypt/decrypt door scoped to collection names under a\n * declared prefix (e.g. `_dict_`).\n */\nexport interface ViaCryptoCtx {\n readonly sealedSlots: {\n seal(field: string, plaintext: unknown): Promise<SealedSlotRef>\n unseal(field: string, ref: SealedSlotRef): Promise<unknown>\n delete(field: string): Promise<void>\n }\n reservedEnvelopes(prefix: string): {\n encrypt(collection: string, json: string, v: number): Promise<EncryptedEnvelope>\n decrypt(collection: string, env: EncryptedEnvelope): Promise<string>\n }\n}\n\n/** Per-call erase context — `forget()`'s per-ref participation door (phase C). */\nexport interface ViaEraseCtx { readonly id: string; readonly vault: string; readonly live: unknown /* EncryptedEnvelope */; readonly crypto: ViaCryptoCtx }\n/**\n * What an `erase` hook reports back to `forget()`'s summary ledger entry.\n * `retainedShared` is additive (#629 Task 10) — content NOT erased because\n * still referenced by another live record (blob's shared-chunk dual\n * accounting, `shredAllForRecord()`'s `retainedShared` count). Absent/0 for\n * bindings with no such concept (a sealed field is never \"shared\").\n */\nexport interface ViaEraseReport { readonly shredded: number; readonly residue: readonly unknown[]; readonly retainedShared?: number }\n\n/**\n * A feature bound to one collection's declared config. Record-grain hooks —\n * every hook receives the whole record (matches the real engine signatures,\n * e.g. quantizeMoneyFields(record, moneyFields)). All hooks optional;\n * absent = passthrough. Query-participation hooks are SYNC (#553).\n */\nexport interface ViaBinding {\n readonly brand: string\n readonly posture: ViaPosture\n /** Declared dependencies (field paths / cross-record specs). MANDATORY for any future\n * derive-bearing binding — phase C validates well-formedness (strings, non-empty,\n * reference declared fields) and graph-registers a derived edge for each covered\n * field at declare time, right after `compileViaBindings` builds the bindings\n * (unknown source field throws `ValidationError`). See\n * `kernel/collection-config.ts`'s `resolveViaBindingDepsEdges`. */\n readonly deps?: readonly string[]\n /** Collection-name prefixes this binding's `reservedEnvelopes` capability may address (e.g. `_dict_`). */\n readonly reservedPrefixes?: readonly string[]\n /**\n * Does this binding own `field`? Backs `ViaPipeline.postureFor` (#629 Task\n * 8's posture consumer) — a passive coverage check, independent of\n * `buildClause`/`compareForOrder` (which some bindings, e.g. classified and\n * blob, never define). SYNC, no side effects.\n *\n * Contract (documentation only — not enforced at runtime, future work):\n * any binding declaring a non-default posture value — `queryable: 'none'`\n * (#629 Task 8) or `exportable: false` (#629 Task 9's `redactForExport`)\n * — MUST implement `covers()`. `postureFor`'s consumers only engage for\n * fields a binding actively claims via `covers()`; a binding that omits\n * it would silently fall through to the generic (unrefused/unredacted)\n * path instead.\n */\n covers?(field: string): boolean\n // NOTE: phase C adds a `derive` hook ADDITIVELY — do not stub it now.\n // ── write pipeline ──\n /** Refuse a write before crypto runs (classified step-3 slot: storage:'never' rejection + validators). Throws to refuse. */\n enforceWrite?(record: Record<string, unknown>, ctx: ViaWriteCtx): void | Promise<void>\n /** First pipeline stage (money canonicalizeIncomingMoney). SYNC. */\n ingest?(record: Record<string, unknown>): Record<string, unknown>\n /** Decode STORED form to canonical for internal boundaries (gates, derivations, patch bases). SYNC. */\n canonicalizeStored?(record: Record<string, unknown>): Record<string, unknown>\n /** Post-validation write encoding (money quantize; i18n translate→script→validate→densify). May be async. */\n encodeWrite?(record: Record<string, unknown>, ctx: ViaWriteCtx): Awaitable<Record<string, unknown>>\n /** Final write-pipeline stage: seal/encrypt declared fields via `crypto` before the envelope body is built (classified step-2 slot). */\n encodeAtRest?(record: Record<string, unknown>, crypto: ViaCryptoCtx): Promise<{ record: Record<string, unknown>; sealed?: Record<string, SealedSlotRef> }>\n // ── read pipeline ──\n /** First read-pipeline stage: unseal/decrypt declared fields via `crypto` before `present` runs (classified sealed-handle slot). */\n decodeAtRest?(record: Record<string, unknown>, sealed: Record<string, SealedSlotRef>, crypto: ViaCryptoCtx, opts: { asHandles: boolean }): Promise<Record<string, unknown>>\n /** Read-time presentation (money decode+virtuals; i18n locale/labels/strip). May be async. */\n present?(record: Record<string, unknown>, ctx: ViaReadCtx): Awaitable<Record<string, unknown>>\n /**\n * Late read-time presentation (#669) — runs AFTER every binding's `present()` in the\n * money+computed present-order segment (`ViaPipeline`'s `_presentOrder`, `kernel/via/\n * pipeline.ts`), BEFORE the \"everything else\" segment (i18n/lookup dressing, taint\n * redaction) runs. Exists for a binding that needs to react to a virtual computed\n * field's fresh OWN-field output before anything dresses it (money's MAJOR-UNITS\n * quantize-and-present for a field that is BOTH money AND `mode:'virtual'` computed) —\n * `present()` alone can't express \"run after computed for THESE fields only, before\n * computed for all others\", since it's a per-BINDING fold, not per-field. Folded over\n * `bindings` in declaration order (mirrors every other per-binding fold), so lookup/\n * i18n dressing and taint/redaction (both in the \"everything else\" segment) still see\n * the already-dressed value.\n */\n presentLate?(record: Record<string, unknown>, ctx: ViaReadCtx): Awaitable<Record<string, unknown>>\n // ── query participation (ALL SYNC — #553) ──\n /** Returns an opaque clause payload when this binding covers `field`, else undefined. */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n buildClause?(field: string, op: string, value: unknown): unknown | undefined\n /** Evaluate a payload produced by buildClause against a raw stored value. */\n evaluateClause?(actual: unknown, op: string, payload: unknown): boolean\n /**\n * Optional: the STORED-form operand for a direct secondary-index probe\n * against a payload produced by `buildClause` (#625) — lets\n * `candidateRecords()` (`query/builder.ts`) hit `CollectionIndexes.\n * lookupEqual`/`lookupIn` for `==`/`in` clauses instead of falling back\n * to a linear scan + per-record `evaluateClause`. Returning `undefined`\n * means \"no sound probe for this op/payload\" (e.g. a comparison whose\n * stored form isn't a single index-bucketable value, or an op the index\n * can't serve) — the caller falls back to the scan. A binding that\n * never implements this hook always falls back, unchanged from before\n * this hook existed.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n indexProbe?(op: string, payload: unknown): unknown | undefined\n /**\n * Optional: canonicalize a raw STORED field value into the bucket key an\n * eager index should use (#672) — lets `CollectionIndexes` group a\n * pre-declaration / non-canonical stored value (e.g. a money field's\n * leftover `'0100'` written before its `money()` declaration) under the\n * SAME key a canonical write produces (`'100'`), so the index-probe fast\n * path (`indexProbe` above) and the fallback scan (`evaluateClause`)\n * agree on which records match. `undefined` means \"not mine / can't\n * canonicalize this value\" — the caller buckets the raw stringified\n * value, unchanged from before this hook existed. MUST agree with what\n * this binding's own `evaluateClause`/`indexProbe` treat as equal, or\n * the fast path and the scan will disagree.\n */\n canonicalizeIndexKey?(field: string, rawValue: unknown): string | undefined\n /** Decode a raw stored record for query/scan results and callback views ('raw' — no virtuals). */\n decodeResults?(record: unknown): unknown\n /** Exact ordering for a covered field; undefined when the field is not covered. */\n compareForOrder?(field: string, a: unknown, b: unknown): number | undefined\n /**\n * Per-key, PER-CALL-locale label resolution for `orderBy(field, dir,\n * { by: 'label' })` (#650 Task 7) — the sibling `compareForOrder` above\n * structurally cannot serve, since it carries no locale parameter.\n * `locale` is the query's per-call locale (`undefined` for a locale-less\n * query — a binding may fall back to its own descriptor-level default,\n * mirroring `present`'s displayLocale hinge). `undefined` return = this\n * binding doesn't resolve a label for `key` at `field` — caller falls\n * back to the raw stored value, same graceful-degrade discipline every\n * other via query hook uses. SYNC (#553 — query participation).\n */\n resolveOrderLabel?(field: string, key: string, locale: string | undefined): string | undefined\n /** Rewrite an aggregate spec (money exact reducers). */\n wrapReducers?(spec: unknown): unknown\n // ── forget participation ──\n /** `forget()`'s per-ref erasure door — shred/report this binding's residue for one record (classified/blob forget participation). */\n erase?(ctx: ViaEraseCtx): Promise<ViaEraseReport>\n // ── introspection ──\n describeFragment?(): Record<string, unknown>\n}\n\n/** Binder: constructs a binding from a collection's declared config. Installed by the feature's declaration factory. */\nexport type ViaBinder = (config: unknown) => ViaBinding\n\nconst binders = new Map<string, ViaBinder>()\n\n/** @internal — called (idempotently, first-wins) by a feature's declaration factory, e.g. money(). */\nexport function installViaBinder(brand: string, binder: ViaBinder): void {\n if (!binders.has(brand)) binders.set(brand, binder)\n}\n\n/** @internal — registry presence check. Used by tests (mirrors isMoneyEngineInstalled) and by vault's i18n validator delegators as a no-i18n-ever-declared fast path. */\nexport function isViaInstalled(brand: string): boolean {\n return binders.has(brand)\n}\n\n/** @internal — resolve a binder; throws when the declaration factory never ran (hand-rolled descriptors). */\nexport function viaBinder(brand: string): ViaBinder {\n const b = binders.get(brand)\n if (!b) {\n throw new NoydbError(\n 'VIA_NOT_LINKED',\n `via feature \"${brand}\" requires descriptors created via its declaration factory from @noy-db/hub`,\n )\n }\n return b\n}\n"],"mappings":";;;;;AAmMA,IAAM,UAAU,oBAAI,IAAuB;AAGpC,SAAS,iBAAiB,OAAe,QAAyB;AACvE,MAAI,CAAC,QAAQ,IAAI,KAAK,EAAG,SAAQ,IAAI,OAAO,MAAM;AACpD;AAGO,SAAS,eAAe,OAAwB;AACrD,SAAO,QAAQ,IAAI,KAAK;AAC1B;AAGO,SAAS,UAAU,OAA0B;AAClD,QAAM,IAAI,QAAQ,IAAI,KAAK;AAC3B,MAAI,CAAC,GAAG;AACN,UAAM,IAAI;AAAA,MACR;AAAA,MACA,gBAAgB,KAAK;AAAA,IACvB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|