@noy-db/hub 0.2.0-pre.10 → 0.2.0-pre.12
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/README.md +126 -0
- package/dist/aggregate/index.cjs +289 -12
- package/dist/aggregate/index.cjs.map +1 -1
- package/dist/aggregate/index.d.cts +2 -2
- package/dist/aggregate/index.d.ts +2 -2
- package/dist/aggregate/index.js +7 -7
- package/dist/aggregate/index.js.map +1 -1
- package/dist/attestation/index.cjs.map +1 -1
- package/dist/attestation/index.d.cts +3 -3
- package/dist/attestation/index.d.ts +3 -3
- package/dist/attestation/index.js +6 -6
- package/dist/blobs/index.cjs +28 -0
- package/dist/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +4 -4
- package/dist/blobs/index.d.ts +4 -4
- package/dist/blobs/index.js +5 -5
- package/dist/bundle/index.cjs +1468 -19
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +5 -5
- package/dist/bundle/index.d.ts +5 -5
- package/dist/bundle/index.js +9 -9
- package/dist/{chunk-7CEGU63S.js → chunk-4BHFNKTP.js} +2 -2
- package/dist/{chunk-5OEJ6GOT.js → chunk-5ARRXIVR.js} +2 -2
- package/dist/{chunk-DRXIZOFV.js → chunk-6AD5TBF2.js} +31 -3
- package/dist/chunk-6AD5TBF2.js.map +1 -0
- package/dist/{chunk-YM7LFCG7.js → chunk-6BYBVRZU.js} +3 -3
- package/dist/{chunk-5IXJGFF2.js → chunk-7JJE3OMJ.js} +5 -5
- package/dist/{chunk-HHOO7HGH.js → chunk-7LVRIW4G.js} +4 -4
- package/dist/{chunk-O6EJ6WTI.js → chunk-AGRC7NQQ.js} +62 -2
- package/dist/chunk-AGRC7NQQ.js.map +1 -0
- package/dist/{chunk-IMYKDWB4.js → chunk-B7GGYNKQ.js} +2 -2
- package/dist/{chunk-BDV7INMP.js → chunk-BXOUVUES.js} +4 -4
- package/dist/{chunk-FO3UEG4S.js → chunk-C2CIIQRG.js} +2 -2
- package/dist/{chunk-ZROPXHJY.js → chunk-CHBXWJZQ.js} +2 -2
- package/dist/{chunk-RYIL3PI2.js → chunk-CILT6V3V.js} +2 -2
- package/dist/{chunk-PXTQPZO4.js → chunk-DLTU4M2I.js} +6 -6
- package/dist/{chunk-GAUEWM7D.js → chunk-EKNUBIIQ.js} +4 -4
- package/dist/{chunk-HQSQC2XL.js → chunk-GFPR7VJS.js} +17 -4
- package/dist/chunk-GFPR7VJS.js.map +1 -0
- package/dist/{chunk-6EOXTJS2.js → chunk-HBAJDI2N.js} +5 -5
- package/dist/{chunk-PVUUIWHY.js → chunk-HLGDYFWR.js} +10 -3
- package/dist/chunk-HLGDYFWR.js.map +1 -0
- package/dist/{chunk-RRNA5GKT.js → chunk-IEPT7HVP.js} +2 -2
- package/dist/{chunk-R233SLY3.js → chunk-IUBHXEPJ.js} +2 -2
- package/dist/{chunk-CH22FZHT.js → chunk-L6BYRCYB.js} +2 -2
- package/dist/{chunk-5OX6XVNS.js → chunk-LOA2VCMS.js} +5 -5
- package/dist/{chunk-BB27JMWB.js → chunk-LSEW3ZZ2.js} +3 -3
- package/dist/{chunk-Y26YV5R3.js → chunk-LWSD4QPT.js} +3 -3
- package/dist/{chunk-WIRRPTFH.js → chunk-LYNNZEQD.js} +1 -1
- package/dist/chunk-LYNNZEQD.js.map +1 -0
- package/dist/{chunk-26NK23DZ.js → chunk-M45IRXDM.js} +3 -3
- package/dist/{chunk-CXJG63MA.js → chunk-NP6EZT44.js} +20 -6
- package/dist/chunk-NP6EZT44.js.map +1 -0
- package/dist/{chunk-GNHAC43Q.js → chunk-O53RIZCC.js} +5 -5
- package/dist/chunk-OPDTLHFA.js +783 -0
- package/dist/chunk-OPDTLHFA.js.map +1 -0
- package/dist/{chunk-LSTBFLL2.js → chunk-P3Z5Y2TS.js} +2 -2
- package/dist/{chunk-QSOYKKMD.js → chunk-P4EDT5ZP.js} +2 -2
- package/dist/{chunk-PC6ZEDRL.js → chunk-RHQYVHFH.js} +2 -2
- package/dist/{chunk-3LPV6BXR.js → chunk-RRDWXNBQ.js} +3 -3
- package/dist/{chunk-4CLICFEY.js → chunk-SJJQKNMP.js} +4 -4
- package/dist/{chunk-TY32C732.js → chunk-SZ4N3IL5.js} +5 -5
- package/dist/{chunk-4USCAEDT.js → chunk-TMHJEYW7.js} +502 -60
- package/dist/chunk-TMHJEYW7.js.map +1 -0
- package/dist/{chunk-2N62W5YP.js → chunk-UA6G45ME.js} +3 -3
- package/dist/{chunk-6YLPHBKR.js → chunk-UOC7JMZO.js} +13 -4
- package/dist/chunk-UOC7JMZO.js.map +1 -0
- package/dist/{chunk-DAP2XL7Q.js → chunk-VOXMU6LB.js} +2 -2
- package/dist/chunk-WNRGOVLG.js +64 -0
- package/dist/chunk-WNRGOVLG.js.map +1 -0
- package/dist/{chunk-DJRWA3Q5.js → chunk-WUG3E423.js} +4 -4
- package/dist/{chunk-PM3QYWUU.js → chunk-XHM2SARW.js} +3 -3
- package/dist/{chunk-RC6SU5NO.js → chunk-XSIFXX54.js} +2 -2
- package/dist/{chunk-CXFOITNS.js → chunk-ZC7MNVYN.js} +2 -2
- package/dist/{chunk-6T2UDBKG.js → chunk-ZCFS7U4J.js} +2 -2
- package/dist/consent/index.cjs.map +1 -1
- package/dist/consent/index.d.cts +4 -4
- package/dist/consent/index.d.ts +4 -4
- package/dist/consent/index.js +3 -3
- package/dist/{crypto-2CRLG4F4.js → crypto-AJB72OKN.js} +3 -3
- package/dist/{delegation-ZTRT2PRV.js → delegation-6FCWDRUS.js} +5 -5
- package/dist/derivations/index.cjs.map +1 -1
- package/dist/derivations/index.d.cts +5 -5
- package/dist/derivations/index.d.ts +5 -5
- package/dist/derivations/index.js +4 -4
- package/dist/{dev-unlock-BOEYl1xl.d.ts → dev-unlock-D3mpVFRc.d.ts} +1 -1
- package/dist/{dev-unlock-AglVnkPY.d.cts → dev-unlock-ckqa_Nso.d.cts} +1 -1
- package/dist/executor-7KSCEIFA.js +8 -0
- package/dist/executor-D2QMNGRJ.js +8 -0
- package/dist/executor-O5AZK7UW.js +11 -0
- package/dist/{fanout-sidecar-OKPMMPLG.js → fanout-sidecar-ZSKEQ6NI.js} +2 -2
- package/dist/guards/index.cjs +53 -1
- package/dist/guards/index.cjs.map +1 -1
- package/dist/guards/index.d.cts +12 -6
- package/dist/guards/index.d.ts +12 -6
- package/dist/guards/index.js +5 -3
- package/dist/{hash-B9m3_fhj.d.ts → hash-CTZVkXLx.d.ts} +1 -1
- package/dist/{hash-RVqz2zi8.d.cts → hash-rDSSd_oW.d.cts} +1 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +5 -5
- package/dist/history/index.d.ts +5 -5
- package/dist/history/index.js +5 -5
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +4 -4
- package/dist/i18n/index.d.ts +4 -4
- package/dist/i18n/index.js +6 -6
- package/dist/immutable-guard-C51vAHuh.d.cts +67 -0
- package/dist/immutable-guard-DyD0qg2k.d.ts +67 -0
- package/dist/index-CkFHr4OP.d.ts +1190 -0
- package/dist/index-Cmop06zJ.d.cts +1190 -0
- package/dist/index.cjs +1636 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -13
- package/dist/index.d.ts +46 -13
- package/dist/index.js +76 -44
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.cjs.map +1 -1
- package/dist/indexing/index.js +2 -2
- package/dist/issue-YIYG4OW5.js +12 -0
- package/dist/{ledger-O7FXOG3D.js → ledger-5JMVF7PY.js} +5 -5
- package/dist/materialized-views/index.cjs.map +1 -1
- package/dist/materialized-views/index.d.cts +5 -6
- package/dist/materialized-views/index.d.ts +5 -6
- package/dist/materialized-views/index.js +6 -6
- package/dist/noydb-D5SLAJ6V.js +34 -0
- package/dist/overlay-views/index.cjs.map +1 -1
- package/dist/overlay-views/index.d.cts +5 -5
- package/dist/overlay-views/index.d.ts +5 -5
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +4 -4
- package/dist/periods/index.d.ts +4 -4
- package/dist/periods/index.js +5 -5
- package/dist/{public-envelope-HMYHZIRH.js → public-envelope-PFLZI5MO.js} +4 -4
- package/dist/query/index.cjs +293 -10
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +2 -2
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +4 -4
- package/dist/registry-BVQ5ITMF.js +8 -0
- package/dist/registry-JLP3QOLD.js +8 -0
- package/dist/{registry-ST2VNFZC.js → registry-NCY445U5.js} +3 -3
- package/dist/{revoke-S6JMSLUN.js → revoke-7RLGQWZ7.js} +6 -6
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +5 -5
- package/dist/session/index.d.ts +5 -5
- package/dist/session/index.js +3 -3
- package/dist/shadow/index.cjs.map +1 -1
- package/dist/shadow/index.d.cts +4 -4
- package/dist/shadow/index.d.ts +4 -4
- package/dist/shadow/index.js +2 -2
- package/dist/{signer-7NPTB3SQ.js → signer-6JF44I4A.js} +5 -5
- package/dist/snapshots/index.cjs.map +1 -1
- package/dist/snapshots/index.d.cts +4 -4
- package/dist/snapshots/index.d.ts +4 -4
- package/dist/snapshots/index.js +4 -4
- package/dist/{stale-VKXSXJF4.js → stale-UBLP3RJ3.js} +2 -2
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +4 -4
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +2 -2
- package/dist/strategy-rtpKDfTC.d.cts +2029 -0
- package/dist/strategy-rtpKDfTC.d.ts +2029 -0
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +3 -3
- package/dist/sync/index.d.ts +3 -3
- package/dist/sync/index.js +4 -4
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +4 -4
- package/dist/team/index.d.ts +4 -4
- package/dist/team/index.js +8 -8
- package/dist/tx/index.cjs +8 -1
- package/dist/tx/index.cjs.map +1 -1
- package/dist/tx/index.d.cts +4 -4
- package/dist/tx/index.d.ts +4 -4
- package/dist/tx/index.js +3 -3
- package/dist/{types-n2_IfwlQ.d.cts → types-BGwjsDef.d.cts} +520 -6
- package/dist/{types-CaNQm4i8.d.ts → types-DRdfwgTG.d.ts} +520 -6
- package/dist/{ulid-CLMjmyhG.d.cts → ulid-D4d0Xto3.d.cts} +1 -1
- package/dist/{ulid-B9SMWj5i.d.ts → ulid-DOTPZ5_h.d.ts} +1 -1
- package/dist/util/index.cjs.map +1 -1
- package/dist/util/index.js +1 -1
- package/dist/vault-group-Z4KB75ZH.js +450 -0
- package/dist/vault-group-Z4KB75ZH.js.map +1 -0
- package/dist/{with-derivation-CVIOPTUf.d.ts → with-derivation-B082Y_WQ.d.ts} +1 -1
- package/dist/{with-derivation-aKrtS7Jj.d.cts → with-derivation-CB1EdcFF.d.cts} +1 -1
- package/dist/{with-materialized-view-C1eA1_T_.d.cts → with-materialized-view-CzRg1Dpr.d.cts} +1 -1
- package/dist/{with-materialized-view-DaYaE8-Q.d.ts → with-materialized-view-Dw4SwjKl.d.ts} +1 -1
- package/dist/{with-overlayed-view-DleJfKcV.d.cts → with-overlayed-view-C9YFKXzn.d.cts} +1 -1
- package/dist/{with-overlayed-view-DQsh2p8H.d.ts → with-overlayed-view-CaCXeW26.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-2LPPNWF6.js +0 -340
- package/dist/chunk-2LPPNWF6.js.map +0 -1
- package/dist/chunk-4USCAEDT.js.map +0 -1
- package/dist/chunk-6YLPHBKR.js.map +0 -1
- package/dist/chunk-C3WE6UJY.js +0 -19
- package/dist/chunk-C3WE6UJY.js.map +0 -1
- package/dist/chunk-CXJG63MA.js.map +0 -1
- package/dist/chunk-DRXIZOFV.js.map +0 -1
- package/dist/chunk-HQSQC2XL.js.map +0 -1
- package/dist/chunk-O6EJ6WTI.js.map +0 -1
- package/dist/chunk-PVUUIWHY.js.map +0 -1
- package/dist/chunk-WIRRPTFH.js.map +0 -1
- package/dist/executor-S76VN45G.js +0 -8
- package/dist/executor-UCXLIGLW.js +0 -11
- package/dist/executor-ZCNZJMGR.js +0 -8
- package/dist/index-B8bjExET.d.cts +0 -2434
- package/dist/index-DfUbNad8.d.ts +0 -2434
- package/dist/issue-3W6IVLKH.js +0 -12
- package/dist/noydb-YAZNH5TI.js +0 -34
- package/dist/registry-UFIK7CSR.js +0 -8
- package/dist/registry-ZGYYSM5I.js +0 -8
- package/dist/strategy-CT2LCKAX.d.cts +0 -613
- package/dist/strategy-CT2LCKAX.d.ts +0 -613
- package/dist/with-guard-DZQbPzoP.d.cts +0 -18
- package/dist/with-guard-DseETUrF.d.ts +0 -18
- /package/dist/{chunk-7CEGU63S.js.map → chunk-4BHFNKTP.js.map} +0 -0
- /package/dist/{chunk-5OEJ6GOT.js.map → chunk-5ARRXIVR.js.map} +0 -0
- /package/dist/{chunk-YM7LFCG7.js.map → chunk-6BYBVRZU.js.map} +0 -0
- /package/dist/{chunk-5IXJGFF2.js.map → chunk-7JJE3OMJ.js.map} +0 -0
- /package/dist/{chunk-HHOO7HGH.js.map → chunk-7LVRIW4G.js.map} +0 -0
- /package/dist/{chunk-IMYKDWB4.js.map → chunk-B7GGYNKQ.js.map} +0 -0
- /package/dist/{chunk-BDV7INMP.js.map → chunk-BXOUVUES.js.map} +0 -0
- /package/dist/{chunk-FO3UEG4S.js.map → chunk-C2CIIQRG.js.map} +0 -0
- /package/dist/{chunk-ZROPXHJY.js.map → chunk-CHBXWJZQ.js.map} +0 -0
- /package/dist/{chunk-RYIL3PI2.js.map → chunk-CILT6V3V.js.map} +0 -0
- /package/dist/{chunk-PXTQPZO4.js.map → chunk-DLTU4M2I.js.map} +0 -0
- /package/dist/{chunk-GAUEWM7D.js.map → chunk-EKNUBIIQ.js.map} +0 -0
- /package/dist/{chunk-6EOXTJS2.js.map → chunk-HBAJDI2N.js.map} +0 -0
- /package/dist/{chunk-RRNA5GKT.js.map → chunk-IEPT7HVP.js.map} +0 -0
- /package/dist/{chunk-R233SLY3.js.map → chunk-IUBHXEPJ.js.map} +0 -0
- /package/dist/{chunk-CH22FZHT.js.map → chunk-L6BYRCYB.js.map} +0 -0
- /package/dist/{chunk-5OX6XVNS.js.map → chunk-LOA2VCMS.js.map} +0 -0
- /package/dist/{chunk-BB27JMWB.js.map → chunk-LSEW3ZZ2.js.map} +0 -0
- /package/dist/{chunk-Y26YV5R3.js.map → chunk-LWSD4QPT.js.map} +0 -0
- /package/dist/{chunk-26NK23DZ.js.map → chunk-M45IRXDM.js.map} +0 -0
- /package/dist/{chunk-GNHAC43Q.js.map → chunk-O53RIZCC.js.map} +0 -0
- /package/dist/{chunk-LSTBFLL2.js.map → chunk-P3Z5Y2TS.js.map} +0 -0
- /package/dist/{chunk-QSOYKKMD.js.map → chunk-P4EDT5ZP.js.map} +0 -0
- /package/dist/{chunk-PC6ZEDRL.js.map → chunk-RHQYVHFH.js.map} +0 -0
- /package/dist/{chunk-3LPV6BXR.js.map → chunk-RRDWXNBQ.js.map} +0 -0
- /package/dist/{chunk-4CLICFEY.js.map → chunk-SJJQKNMP.js.map} +0 -0
- /package/dist/{chunk-TY32C732.js.map → chunk-SZ4N3IL5.js.map} +0 -0
- /package/dist/{chunk-2N62W5YP.js.map → chunk-UA6G45ME.js.map} +0 -0
- /package/dist/{chunk-DAP2XL7Q.js.map → chunk-VOXMU6LB.js.map} +0 -0
- /package/dist/{chunk-DJRWA3Q5.js.map → chunk-WUG3E423.js.map} +0 -0
- /package/dist/{chunk-PM3QYWUU.js.map → chunk-XHM2SARW.js.map} +0 -0
- /package/dist/{chunk-RC6SU5NO.js.map → chunk-XSIFXX54.js.map} +0 -0
- /package/dist/{chunk-CXFOITNS.js.map → chunk-ZC7MNVYN.js.map} +0 -0
- /package/dist/{chunk-6T2UDBKG.js.map → chunk-ZCFS7U4J.js.map} +0 -0
- /package/dist/{crypto-2CRLG4F4.js.map → crypto-AJB72OKN.js.map} +0 -0
- /package/dist/{delegation-ZTRT2PRV.js.map → delegation-6FCWDRUS.js.map} +0 -0
- /package/dist/{executor-S76VN45G.js.map → executor-7KSCEIFA.js.map} +0 -0
- /package/dist/{executor-UCXLIGLW.js.map → executor-D2QMNGRJ.js.map} +0 -0
- /package/dist/{executor-ZCNZJMGR.js.map → executor-O5AZK7UW.js.map} +0 -0
- /package/dist/{fanout-sidecar-OKPMMPLG.js.map → fanout-sidecar-ZSKEQ6NI.js.map} +0 -0
- /package/dist/{issue-3W6IVLKH.js.map → issue-YIYG4OW5.js.map} +0 -0
- /package/dist/{ledger-O7FXOG3D.js.map → ledger-5JMVF7PY.js.map} +0 -0
- /package/dist/{noydb-YAZNH5TI.js.map → noydb-D5SLAJ6V.js.map} +0 -0
- /package/dist/{public-envelope-HMYHZIRH.js.map → public-envelope-PFLZI5MO.js.map} +0 -0
- /package/dist/{registry-ST2VNFZC.js.map → registry-BVQ5ITMF.js.map} +0 -0
- /package/dist/{registry-UFIK7CSR.js.map → registry-JLP3QOLD.js.map} +0 -0
- /package/dist/{registry-ZGYYSM5I.js.map → registry-NCY445U5.js.map} +0 -0
- /package/dist/{revoke-S6JMSLUN.js.map → revoke-7RLGQWZ7.js.map} +0 -0
- /package/dist/{signer-7NPTB3SQ.js.map → signer-6JF44I4A.js.map} +0 -0
- /package/dist/{stale-VKXSXJF4.js.map → stale-UBLP3RJ3.js.map} +0 -0
|
@@ -4,37 +4,37 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
TxContext,
|
|
6
6
|
revertExecuted
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-M45IRXDM.js";
|
|
8
8
|
import {
|
|
9
9
|
OverlayedCollection
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4BHFNKTP.js";
|
|
11
11
|
import {
|
|
12
12
|
LazyQuery,
|
|
13
13
|
decodeIdxId,
|
|
14
14
|
encodeIdxId
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-P4EDT5ZP.js";
|
|
16
16
|
import {
|
|
17
17
|
SCHEMAS_COLLECTION,
|
|
18
18
|
loadPersistedSchema,
|
|
19
19
|
resolveManagedSecret,
|
|
20
20
|
savePersistedSchema,
|
|
21
21
|
saveSealedPassphrase
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-XHM2SARW.js";
|
|
23
23
|
import {
|
|
24
24
|
loadPublicEnvelope,
|
|
25
25
|
readPublicEnvelope,
|
|
26
26
|
savePublicEnvelope,
|
|
27
27
|
validatePublicEnvelopeInput
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-UA6G45ME.js";
|
|
29
29
|
import {
|
|
30
30
|
PERIODS_COLLECTION
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-RRDWXNBQ.js";
|
|
32
32
|
import {
|
|
33
33
|
getAtPath,
|
|
34
34
|
isDictCollectionName,
|
|
35
35
|
resolvePolicy,
|
|
36
36
|
setAtPathInPlace
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-O53RIZCC.js";
|
|
38
38
|
import {
|
|
39
39
|
ManagedRecoveryNotEnrolledError,
|
|
40
40
|
PolicyDeniedError,
|
|
@@ -56,13 +56,14 @@ import {
|
|
|
56
56
|
saveShamirRecoveryEntries,
|
|
57
57
|
updateAuthenticator,
|
|
58
58
|
writeMagicLinkGrant
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-DLTU4M2I.js";
|
|
60
60
|
import {
|
|
61
61
|
assertTierAccess,
|
|
62
62
|
dekKey
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-ZC7MNVYN.js";
|
|
64
64
|
import {
|
|
65
65
|
USER_ENVELOPE_COLLECTION,
|
|
66
|
+
assertKeyringOpenAllowed,
|
|
66
67
|
buildRecipientKeyringFile,
|
|
67
68
|
changeSecret,
|
|
68
69
|
createOwnerKeyring,
|
|
@@ -84,7 +85,7 @@ import {
|
|
|
84
85
|
rotateKeys,
|
|
85
86
|
saveUserEnvelope,
|
|
86
87
|
updateKeyringIdentity
|
|
87
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-GFPR7VJS.js";
|
|
88
89
|
import {
|
|
89
90
|
INDEXED_STORE_POLICY
|
|
90
91
|
} from "./chunk-2QR2PQTT.js";
|
|
@@ -94,7 +95,7 @@ import {
|
|
|
94
95
|
import {
|
|
95
96
|
LEDGER_COLLECTION,
|
|
96
97
|
LEDGER_DELTAS_COLLECTION
|
|
97
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-SJJQKNMP.js";
|
|
98
99
|
import {
|
|
99
100
|
sha256Hex as sha256Hex2
|
|
100
101
|
} from "./chunk-Z6FNBOTC.js";
|
|
@@ -102,10 +103,13 @@ import {
|
|
|
102
103
|
NO_AGGREGATE,
|
|
103
104
|
Query,
|
|
104
105
|
ScanBuilder
|
|
105
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-UOC7JMZO.js";
|
|
106
107
|
import {
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
MoneyPrecisionError,
|
|
109
|
+
canonicalGroupKey,
|
|
110
|
+
formatScaledInt,
|
|
111
|
+
parseToScaledInt
|
|
112
|
+
} from "./chunk-OPDTLHFA.js";
|
|
109
113
|
import {
|
|
110
114
|
readPath
|
|
111
115
|
} from "./chunk-TV3YZ35S.js";
|
|
@@ -113,17 +117,17 @@ import {
|
|
|
113
117
|
EXPORT_AUDIT_COLLECTION,
|
|
114
118
|
createExportBlobsHandle,
|
|
115
119
|
runCompaction
|
|
116
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-6AD5TBF2.js";
|
|
117
121
|
import {
|
|
118
122
|
NOYDB_BACKUP_VERSION,
|
|
119
123
|
NOYDB_FORMAT_VERSION
|
|
120
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-LYNNZEQD.js";
|
|
121
125
|
import {
|
|
122
126
|
decrypt,
|
|
123
127
|
encrypt,
|
|
124
128
|
encryptDeterministic,
|
|
125
129
|
sha256Hex
|
|
126
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-IUBHXEPJ.js";
|
|
127
131
|
import {
|
|
128
132
|
AlreadyElevatedError,
|
|
129
133
|
AttestationError,
|
|
@@ -146,14 +150,17 @@ import {
|
|
|
146
150
|
ReservedCollectionNameError,
|
|
147
151
|
SchemaFenceError,
|
|
148
152
|
SchemaValidationError,
|
|
153
|
+
SequenceContentionError,
|
|
154
|
+
SequenceOfflineError,
|
|
149
155
|
StoreCapabilityError,
|
|
150
156
|
TierDemoteDeniedError,
|
|
151
157
|
TierNotGrantedError,
|
|
152
158
|
TranslatorNotConfiguredError,
|
|
153
159
|
UniqueConstraintError,
|
|
154
160
|
UnsupportedIndexOptionError,
|
|
155
|
-
ValidationError
|
|
156
|
-
|
|
161
|
+
ValidationError,
|
|
162
|
+
VaultTemplateNotFoundError
|
|
163
|
+
} from "./chunk-AGRC7NQQ.js";
|
|
157
164
|
|
|
158
165
|
// src/policy/storage.ts
|
|
159
166
|
var META_COLLECTION = "_meta";
|
|
@@ -328,6 +335,116 @@ var NO_CRDT = {
|
|
|
328
335
|
}
|
|
329
336
|
};
|
|
330
337
|
|
|
338
|
+
// src/money/normalize.ts
|
|
339
|
+
function isMoneyValueObject(v) {
|
|
340
|
+
return typeof v === "object" && v !== null && "currency" in v;
|
|
341
|
+
}
|
|
342
|
+
function quantizeAmount(field, input, scale, rounding) {
|
|
343
|
+
const r = parseToScaledInt(input, scale, rounding);
|
|
344
|
+
if (!r.ok) {
|
|
345
|
+
if (r.reason === "precision") throw new MoneyPrecisionError(field, input, scale);
|
|
346
|
+
throw new TypeError(`money: field "${field}" value ${JSON.stringify(input)} is not a finite decimal`);
|
|
347
|
+
}
|
|
348
|
+
return r.value.toString();
|
|
349
|
+
}
|
|
350
|
+
function quantizeMoneyFields(record, moneyFields) {
|
|
351
|
+
const out = { ...record };
|
|
352
|
+
for (const [field, desc] of Object.entries(moneyFields)) {
|
|
353
|
+
const raw = out[field];
|
|
354
|
+
if (raw === null || raw === void 0) continue;
|
|
355
|
+
if (desc.mode === "fixed") {
|
|
356
|
+
const currency2 = desc.fixedCurrency;
|
|
357
|
+
out[field] = quantizeAmount(field, raw, desc.scaleFor(currency2), desc.rounding);
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
let amount;
|
|
361
|
+
let currency;
|
|
362
|
+
if (isMoneyValueObject(raw)) {
|
|
363
|
+
currency = String(raw.currency);
|
|
364
|
+
amount = raw.amount;
|
|
365
|
+
} else {
|
|
366
|
+
const sole = desc.soleCurrency();
|
|
367
|
+
if (sole === void 0) {
|
|
368
|
+
throw new TypeError(
|
|
369
|
+
`money: field "${field}" is multi-currency \u2014 write { amount, currency }, not a bare amount`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
currency = sole;
|
|
373
|
+
amount = raw;
|
|
374
|
+
}
|
|
375
|
+
const scale = desc.scaleFor(currency);
|
|
376
|
+
out[field] = { amount: quantizeAmount(field, amount, scale, desc.rounding), currency };
|
|
377
|
+
}
|
|
378
|
+
return out;
|
|
379
|
+
}
|
|
380
|
+
function formatCurrency(decimal, currency, scale, locale) {
|
|
381
|
+
const fmt = new Intl.NumberFormat(locale, {
|
|
382
|
+
style: "currency",
|
|
383
|
+
currency,
|
|
384
|
+
minimumFractionDigits: scale,
|
|
385
|
+
maximumFractionDigits: scale
|
|
386
|
+
});
|
|
387
|
+
return fmt.format(decimal);
|
|
388
|
+
}
|
|
389
|
+
function decodeMoneyFields(record, moneyFields, locale) {
|
|
390
|
+
const out = { ...record };
|
|
391
|
+
const format = locale !== "raw";
|
|
392
|
+
const fmtLocale = typeof locale === "string" && locale !== "raw" ? locale : "en-US";
|
|
393
|
+
for (const [field, desc] of Object.entries(moneyFields)) {
|
|
394
|
+
const stored = out[field];
|
|
395
|
+
if (stored === null || stored === void 0) continue;
|
|
396
|
+
let currency;
|
|
397
|
+
let scaledIntString;
|
|
398
|
+
if (desc.mode === "fixed") {
|
|
399
|
+
if (typeof stored !== "string" && typeof stored !== "number") continue;
|
|
400
|
+
currency = desc.fixedCurrency;
|
|
401
|
+
scaledIntString = String(stored);
|
|
402
|
+
} else {
|
|
403
|
+
if (!isMoneyValueObject(stored)) continue;
|
|
404
|
+
const amount = stored.amount;
|
|
405
|
+
if (typeof stored.currency !== "string" || typeof amount !== "string" && typeof amount !== "number") continue;
|
|
406
|
+
currency = stored.currency;
|
|
407
|
+
scaledIntString = String(amount);
|
|
408
|
+
}
|
|
409
|
+
const scale = desc.scaleFor(currency);
|
|
410
|
+
const decimal = formatScaledInt(BigInt(scaledIntString), scale);
|
|
411
|
+
out[field] = desc.mode === "fixed" ? decimal : { amount: decimal, currency };
|
|
412
|
+
if (format) {
|
|
413
|
+
out[`${field}Formatted`] = formatCurrency(decimal, currency, scale, fmtLocale);
|
|
414
|
+
out[`${field}Number`] = Number(decimal);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return out;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// src/computed/index.ts
|
|
421
|
+
var ComputedFieldError = class extends NoydbError {
|
|
422
|
+
constructor(field, id, cause) {
|
|
423
|
+
super(
|
|
424
|
+
"COMPUTED_FIELD",
|
|
425
|
+
`computed field "${field}" threw for record "${id}": ` + (cause instanceof Error ? cause.message : String(cause))
|
|
426
|
+
);
|
|
427
|
+
this.field = field;
|
|
428
|
+
this.id = id;
|
|
429
|
+
this.cause = cause;
|
|
430
|
+
this.name = "ComputedFieldError";
|
|
431
|
+
}
|
|
432
|
+
field;
|
|
433
|
+
id;
|
|
434
|
+
cause;
|
|
435
|
+
};
|
|
436
|
+
function evalComputedFields(record, computed, id) {
|
|
437
|
+
const out = { ...record };
|
|
438
|
+
for (const [field, fn] of Object.entries(computed)) {
|
|
439
|
+
try {
|
|
440
|
+
out[field] = fn(out);
|
|
441
|
+
} catch (cause) {
|
|
442
|
+
throw new ComputedFieldError(field, id, cause);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return out;
|
|
446
|
+
}
|
|
447
|
+
|
|
331
448
|
// src/i18n/strategy.ts
|
|
332
449
|
function notEnabled(op) {
|
|
333
450
|
return new Error(
|
|
@@ -768,7 +885,7 @@ async function resolveStaleOnRead(accessor, outputCollection, id) {
|
|
|
768
885
|
}
|
|
769
886
|
const sourceWithId = { ...source, id };
|
|
770
887
|
if (DerivationExecutor === null) {
|
|
771
|
-
({ DerivationExecutor } = await import("./executor-
|
|
888
|
+
({ DerivationExecutor } = await import("./executor-D2QMNGRJ.js"));
|
|
772
889
|
}
|
|
773
890
|
const ctx = { vault: accessor.getReadOnlyFacade() };
|
|
774
891
|
const result = await DerivationExecutor.run(spec, sourceWithId, 0, strategyHash, ctx);
|
|
@@ -961,6 +1078,18 @@ var Collection = class {
|
|
|
961
1078
|
* fields when a locale is requested.
|
|
962
1079
|
*/
|
|
963
1080
|
dictKeyFields;
|
|
1081
|
+
/**
|
|
1082
|
+
* Money field descriptors keyed by field path. Declared via the
|
|
1083
|
+
* `moneyFields` collection option: `put()` quantizes to a scaled-int
|
|
1084
|
+
* string, `get()`/`list()` decode back. Mutable so {@link _applyMoneyFields}
|
|
1085
|
+
* can attach descriptors to a collection MV-analysis pre-created.
|
|
1086
|
+
*/
|
|
1087
|
+
moneyFields;
|
|
1088
|
+
/**
|
|
1089
|
+
* Computed scalar fields, evaluated first on every `put()`. Mutable for
|
|
1090
|
+
* the same MV-pre-creation reconcile as {@link moneyFields}.
|
|
1091
|
+
*/
|
|
1092
|
+
computed;
|
|
964
1093
|
/**
|
|
965
1094
|
* Async callback provided by the Vault that resolves a dict key
|
|
966
1095
|
* to its label for a given locale. Used by the locale-read path for
|
|
@@ -1102,6 +1231,8 @@ var Collection = class {
|
|
|
1102
1231
|
this.joinResolver = opts.joinResolver;
|
|
1103
1232
|
this.i18nFields = opts.i18nFields;
|
|
1104
1233
|
this.dictKeyFields = opts.dictKeyFields;
|
|
1234
|
+
this.moneyFields = opts.moneyFields;
|
|
1235
|
+
this.computed = opts.computed;
|
|
1105
1236
|
this.dictLabelResolver = opts.dictLabelResolver;
|
|
1106
1237
|
this.i18nPutValidator = opts.i18nPutValidator;
|
|
1107
1238
|
this.autoTranslateHook = opts.autoTranslateHook;
|
|
@@ -1226,6 +1357,19 @@ var Collection = class {
|
|
|
1226
1357
|
getSchema() {
|
|
1227
1358
|
return this.schema;
|
|
1228
1359
|
}
|
|
1360
|
+
/**
|
|
1361
|
+
* @internal — attach money descriptors post-construction. MV dependency
|
|
1362
|
+
* analysis auto-creates a source collection (without options) during
|
|
1363
|
+
* `openVault`, before the user's `collection(name, { moneyFields })`
|
|
1364
|
+
* declaration; this reconciles that ordering. First-wins. Not public.
|
|
1365
|
+
*/
|
|
1366
|
+
_applyMoneyFields(moneyFields) {
|
|
1367
|
+
if (this.moneyFields === void 0) this.moneyFields = moneyFields;
|
|
1368
|
+
}
|
|
1369
|
+
/** @internal — attach computed fields post-construction. See {@link _applyMoneyFields}. */
|
|
1370
|
+
_applyComputed(computed) {
|
|
1371
|
+
if (this.computed === void 0) this.computed = computed;
|
|
1372
|
+
}
|
|
1229
1373
|
/**
|
|
1230
1374
|
* Get a single record by ID.
|
|
1231
1375
|
*
|
|
@@ -1247,7 +1391,7 @@ var Collection = class {
|
|
|
1247
1391
|
}
|
|
1248
1392
|
}
|
|
1249
1393
|
if (this.materializedViewSource !== void 0) {
|
|
1250
|
-
const { resolveStaleMVOnRead } = await import("./stale-
|
|
1394
|
+
const { resolveStaleMVOnRead } = await import("./stale-UBLP3RJ3.js");
|
|
1251
1395
|
await resolveStaleMVOnRead(this.materializedViewSource, this.name);
|
|
1252
1396
|
}
|
|
1253
1397
|
let record;
|
|
@@ -1397,7 +1541,7 @@ var Collection = class {
|
|
|
1397
1541
|
existingRecord = null;
|
|
1398
1542
|
}
|
|
1399
1543
|
}
|
|
1400
|
-
|
|
1544
|
+
const gateEvent = {
|
|
1401
1545
|
op: existingEnv ? "update" : "create",
|
|
1402
1546
|
vault: this.vault,
|
|
1403
1547
|
collection: this.name,
|
|
@@ -1407,12 +1551,20 @@ var Collection = class {
|
|
|
1407
1551
|
existingVersion: existingEnv?._v ?? 0,
|
|
1408
1552
|
existingTs: existingEnv?._ts,
|
|
1409
1553
|
userId: this.keyring.userId,
|
|
1410
|
-
role: this.keyring.role
|
|
1411
|
-
|
|
1554
|
+
role: this.keyring.role,
|
|
1555
|
+
...this.computed !== void 0 ? { computedFieldNames: new Set(Object.keys(this.computed)) } : {}
|
|
1556
|
+
};
|
|
1557
|
+
await this.subsystemBus.dispatchGate("beforePut", gateEvent);
|
|
1558
|
+
}
|
|
1559
|
+
if (this.computed !== void 0) {
|
|
1560
|
+
record = evalComputedFields(record, this.computed, id);
|
|
1412
1561
|
}
|
|
1413
1562
|
if (this.schema !== void 0) {
|
|
1414
1563
|
record = await validateSchemaInput(this.schema, record, `put(${id})`);
|
|
1415
1564
|
}
|
|
1565
|
+
if (this.moneyFields) {
|
|
1566
|
+
record = quantizeMoneyFields(record, this.moneyFields);
|
|
1567
|
+
}
|
|
1416
1568
|
if (this.i18nFields) {
|
|
1417
1569
|
const obj = record;
|
|
1418
1570
|
for (const [field, descriptor] of Object.entries(this.i18nFields)) {
|
|
@@ -1636,7 +1788,7 @@ var Collection = class {
|
|
|
1636
1788
|
if (mode === "eager") {
|
|
1637
1789
|
if (executor === null) {
|
|
1638
1790
|
;
|
|
1639
|
-
({ MaterializedViewExecutor: executor } = await import("./executor-
|
|
1791
|
+
({ MaterializedViewExecutor: executor } = await import("./executor-O5AZK7UW.js"));
|
|
1640
1792
|
}
|
|
1641
1793
|
await executor.refresh(reg, {
|
|
1642
1794
|
getCollection: (name) => this.materializedViewSource.getCollection(name),
|
|
@@ -1645,7 +1797,7 @@ var Collection = class {
|
|
|
1645
1797
|
});
|
|
1646
1798
|
} else if (mode === "lazy") {
|
|
1647
1799
|
if (staleHelpers === null) {
|
|
1648
|
-
staleHelpers = await import("./stale-
|
|
1800
|
+
staleHelpers = await import("./stale-UBLP3RJ3.js");
|
|
1649
1801
|
}
|
|
1650
1802
|
staleHelpers.markMVStale(registry, reg.spec.name);
|
|
1651
1803
|
}
|
|
@@ -1674,7 +1826,7 @@ var Collection = class {
|
|
|
1674
1826
|
const mode = typeof spec.lifecycle === "string" ? spec.lifecycle : spec.lifecycle.mode;
|
|
1675
1827
|
if (mode === "eager") {
|
|
1676
1828
|
if (DerivationExecutor === null) {
|
|
1677
|
-
({ DerivationExecutor } = await import("./executor-
|
|
1829
|
+
({ DerivationExecutor } = await import("./executor-D2QMNGRJ.js"));
|
|
1678
1830
|
}
|
|
1679
1831
|
const sourceWithId = { ...incoming, id };
|
|
1680
1832
|
const ctx = { vault: this.derivationSource.getReadOnlyFacade() };
|
|
@@ -1693,7 +1845,7 @@ var Collection = class {
|
|
|
1693
1845
|
const outputCollection = this.derivationSource.getCollection(outSpec.collection);
|
|
1694
1846
|
const txCtx = this.derivationSource.getActiveTxContext();
|
|
1695
1847
|
if (out.kind === "array") {
|
|
1696
|
-
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-
|
|
1848
|
+
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-ZSKEQ6NI.js");
|
|
1697
1849
|
const prior = await loadFanoutSidecar(
|
|
1698
1850
|
this.adapter,
|
|
1699
1851
|
this.vault,
|
|
@@ -1986,7 +2138,7 @@ var Collection = class {
|
|
|
1986
2138
|
for (const [outputKey, outSpec] of Object.entries(spec.outputs)) {
|
|
1987
2139
|
if (outSpec.shape !== "array") continue;
|
|
1988
2140
|
if (helpers === null) {
|
|
1989
|
-
helpers = await import("./fanout-sidecar-
|
|
2141
|
+
helpers = await import("./fanout-sidecar-ZSKEQ6NI.js");
|
|
1990
2142
|
}
|
|
1991
2143
|
const sidecar = await helpers.loadFanoutSidecar(
|
|
1992
2144
|
this.adapter,
|
|
@@ -2026,7 +2178,7 @@ var Collection = class {
|
|
|
2026
2178
|
if (mode === "eager") {
|
|
2027
2179
|
if (executor === null) {
|
|
2028
2180
|
;
|
|
2029
|
-
({ MaterializedViewExecutor: executor } = await import("./executor-
|
|
2181
|
+
({ MaterializedViewExecutor: executor } = await import("./executor-O5AZK7UW.js"));
|
|
2030
2182
|
}
|
|
2031
2183
|
await executor.refresh(reg, {
|
|
2032
2184
|
getCollection: (name) => this.materializedViewSource.getCollection(name),
|
|
@@ -2035,7 +2187,7 @@ var Collection = class {
|
|
|
2035
2187
|
});
|
|
2036
2188
|
} else if (mode === "lazy") {
|
|
2037
2189
|
if (staleHelpers === null) {
|
|
2038
|
-
staleHelpers = await import("./stale-
|
|
2190
|
+
staleHelpers = await import("./stale-UBLP3RJ3.js");
|
|
2039
2191
|
}
|
|
2040
2192
|
staleHelpers.markMVStale(registry, reg.spec.name);
|
|
2041
2193
|
}
|
|
@@ -2058,7 +2210,7 @@ var Collection = class {
|
|
|
2058
2210
|
);
|
|
2059
2211
|
}
|
|
2060
2212
|
if (this.materializedViewSource !== void 0) {
|
|
2061
|
-
const { resolveStaleMVOnRead } = await import("./stale-
|
|
2213
|
+
const { resolveStaleMVOnRead } = await import("./stale-UBLP3RJ3.js");
|
|
2062
2214
|
await resolveStaleMVOnRead(this.materializedViewSource, this.name);
|
|
2063
2215
|
}
|
|
2064
2216
|
await this.ensureHydrated();
|
|
@@ -2234,7 +2386,8 @@ var Collection = class {
|
|
|
2234
2386
|
// fields. The Query builder consults these when present and falls
|
|
2235
2387
|
// back to a linear scan otherwise.
|
|
2236
2388
|
getIndexes: () => this.getIndexes(),
|
|
2237
|
-
lookupById: (id) => this.cache.get(id)?.record
|
|
2389
|
+
lookupById: (id) => this.cache.get(id)?.record,
|
|
2390
|
+
...this.moneyFields ? { moneyFields: this.moneyFields } : {}
|
|
2238
2391
|
};
|
|
2239
2392
|
const resolver = this.joinResolver;
|
|
2240
2393
|
const leftCollection = this.name;
|
|
@@ -2916,10 +3069,14 @@ var Collection = class {
|
|
|
2916
3069
|
async applyLocaleToRecord(record, localeOpts) {
|
|
2917
3070
|
const hasI18n = this.i18nFields && Object.keys(this.i18nFields).length > 0;
|
|
2918
3071
|
const hasDict = this.dictKeyFields && Object.keys(this.dictKeyFields).length > 0;
|
|
2919
|
-
|
|
3072
|
+
const hasMoney = this.moneyFields && Object.keys(this.moneyFields).length > 0;
|
|
3073
|
+
if (!hasI18n && !hasDict && !hasMoney) return record;
|
|
2920
3074
|
const locale = localeOpts?.locale ?? this.defaultLocale;
|
|
2921
|
-
if (!locale) return record;
|
|
2922
3075
|
let result = record;
|
|
3076
|
+
if (hasMoney && this.moneyFields) {
|
|
3077
|
+
result = decodeMoneyFields(result, this.moneyFields, typeof locale === "string" ? locale : void 0);
|
|
3078
|
+
}
|
|
3079
|
+
if (!locale) return result;
|
|
2923
3080
|
if (hasI18n && this.i18nFields) {
|
|
2924
3081
|
result = this.i18nStrategy.applyI18nLocale(result, this.i18nFields, locale, localeOpts?.fallback);
|
|
2925
3082
|
}
|
|
@@ -3615,6 +3772,165 @@ function valuesMatch(stored, live) {
|
|
|
3615
3772
|
}
|
|
3616
3773
|
}
|
|
3617
3774
|
|
|
3775
|
+
// src/archive/engine.ts
|
|
3776
|
+
function isHeld(policy, record) {
|
|
3777
|
+
if (!policy.legalHold) return false;
|
|
3778
|
+
try {
|
|
3779
|
+
return policy.legalHold(record);
|
|
3780
|
+
} catch {
|
|
3781
|
+
return true;
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
async function runArchive(ctx, options = {}) {
|
|
3785
|
+
const maxArchives = options.maxArchives ?? Infinity;
|
|
3786
|
+
const dryRun = options.dryRun === true;
|
|
3787
|
+
let archived = 0;
|
|
3788
|
+
let held = 0;
|
|
3789
|
+
let scanned = 0;
|
|
3790
|
+
const byCollection = {};
|
|
3791
|
+
outer: for (const collection of ctx.collectionsWithPolicy()) {
|
|
3792
|
+
const policy = ctx.getPolicy(collection);
|
|
3793
|
+
if (!policy) continue;
|
|
3794
|
+
byCollection[collection] = { archived: 0, held: 0 };
|
|
3795
|
+
for (const id of await ctx.listRecordIds(collection)) {
|
|
3796
|
+
if (archived >= maxArchives) break outer;
|
|
3797
|
+
const record = await ctx.getRecord(collection, id).catch(() => null);
|
|
3798
|
+
if (record === null) continue;
|
|
3799
|
+
scanned += 1;
|
|
3800
|
+
let eligible = false;
|
|
3801
|
+
try {
|
|
3802
|
+
eligible = policy.archiveWhen(record);
|
|
3803
|
+
} catch {
|
|
3804
|
+
eligible = false;
|
|
3805
|
+
}
|
|
3806
|
+
if (!eligible) continue;
|
|
3807
|
+
if (isHeld(policy, record)) {
|
|
3808
|
+
held += 1;
|
|
3809
|
+
byCollection[collection].held += 1;
|
|
3810
|
+
continue;
|
|
3811
|
+
}
|
|
3812
|
+
if (!dryRun) {
|
|
3813
|
+
const env = await ctx.getEnvelope(collection, id);
|
|
3814
|
+
if (!env) continue;
|
|
3815
|
+
await ctx.archiveStore.put(ctx.vaultId, collection, id, env);
|
|
3816
|
+
await ctx.removeFromPrimary(collection, id);
|
|
3817
|
+
}
|
|
3818
|
+
archived += 1;
|
|
3819
|
+
byCollection[collection].archived += 1;
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
return { archived, held, scanned, byCollection };
|
|
3823
|
+
}
|
|
3824
|
+
async function runRestore(ctx, collection, id) {
|
|
3825
|
+
const env = await ctx.archiveStore.get(ctx.vaultId, collection, id);
|
|
3826
|
+
if (!env) return false;
|
|
3827
|
+
await ctx.restoreToPrimary(collection, id, env);
|
|
3828
|
+
await ctx.archiveStore.delete(ctx.vaultId, collection, id);
|
|
3829
|
+
return true;
|
|
3830
|
+
}
|
|
3831
|
+
async function runListArchived(ctx, collection) {
|
|
3832
|
+
const collections = collection ? [collection] : ctx.collectionsWithPolicy();
|
|
3833
|
+
const out = [];
|
|
3834
|
+
for (const c of collections) {
|
|
3835
|
+
const ids = await ctx.archiveStore.list(ctx.vaultId, c);
|
|
3836
|
+
for (const id of ids) out.push({ collection: c, id });
|
|
3837
|
+
}
|
|
3838
|
+
return out;
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
// src/archive/index.ts
|
|
3842
|
+
function withArchive(opts) {
|
|
3843
|
+
return { store: opts.store };
|
|
3844
|
+
}
|
|
3845
|
+
|
|
3846
|
+
// src/sequence/index.ts
|
|
3847
|
+
var SEQUENCE_COLLECTION = "_sequences";
|
|
3848
|
+
var MAX_NEXT_ATTEMPTS = 16;
|
|
3849
|
+
async function sleepBackoff(attempt) {
|
|
3850
|
+
const ceil = Math.min(2 ** attempt, 32);
|
|
3851
|
+
const ms = Math.floor(Math.random() * ceil);
|
|
3852
|
+
await new Promise((r) => setTimeout(r, ms));
|
|
3853
|
+
}
|
|
3854
|
+
var SequenceStore = class {
|
|
3855
|
+
adapter;
|
|
3856
|
+
vault;
|
|
3857
|
+
encrypted;
|
|
3858
|
+
getDEK;
|
|
3859
|
+
actor;
|
|
3860
|
+
/**
|
|
3861
|
+
* Memoized DEK promise. The `_sequences` collection DEK is created on
|
|
3862
|
+
* first access; without sharing one promise, a burst of concurrent
|
|
3863
|
+
* `next()` calls would each trigger DEK creation and diverge (one
|
|
3864
|
+
* writer's ciphertext unreadable by another). One shared promise → one
|
|
3865
|
+
* DEK.
|
|
3866
|
+
*/
|
|
3867
|
+
dekPromise = null;
|
|
3868
|
+
constructor(opts) {
|
|
3869
|
+
this.adapter = opts.adapter;
|
|
3870
|
+
this.vault = opts.vault;
|
|
3871
|
+
this.encrypted = opts.encrypted;
|
|
3872
|
+
this.getDEK = opts.getDEK;
|
|
3873
|
+
this.actor = opts.actor;
|
|
3874
|
+
}
|
|
3875
|
+
/** A handle bound to one sequence name. */
|
|
3876
|
+
handle(name) {
|
|
3877
|
+
return {
|
|
3878
|
+
next: () => this.next(name),
|
|
3879
|
+
peek: () => this.peek(name)
|
|
3880
|
+
};
|
|
3881
|
+
}
|
|
3882
|
+
assertOnline() {
|
|
3883
|
+
if (this.adapter.capabilities?.casAtomic !== true) {
|
|
3884
|
+
throw new SequenceOfflineError();
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
dek() {
|
|
3888
|
+
if (!this.dekPromise) this.dekPromise = this.getDEK(SEQUENCE_COLLECTION);
|
|
3889
|
+
return this.dekPromise;
|
|
3890
|
+
}
|
|
3891
|
+
async read(name) {
|
|
3892
|
+
const env = await this.adapter.get(this.vault, SEQUENCE_COLLECTION, name);
|
|
3893
|
+
if (!env) return { env: null, value: 0 };
|
|
3894
|
+
const json = this.encrypted ? await decrypt(env._iv, env._data, await this.dek()) : env._data;
|
|
3895
|
+
const state = JSON.parse(json);
|
|
3896
|
+
return { env, value: state.value };
|
|
3897
|
+
}
|
|
3898
|
+
async encryptState(state, version) {
|
|
3899
|
+
const json = JSON.stringify(state);
|
|
3900
|
+
if (!this.encrypted) {
|
|
3901
|
+
return { _noydb: NOYDB_FORMAT_VERSION, _v: version, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: "", _data: json, _by: this.actor };
|
|
3902
|
+
}
|
|
3903
|
+
const { iv, data } = await encrypt(json, await this.dek());
|
|
3904
|
+
return { _noydb: NOYDB_FORMAT_VERSION, _v: version, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data, _by: this.actor };
|
|
3905
|
+
}
|
|
3906
|
+
async peek(name) {
|
|
3907
|
+
return (await this.read(name)).value;
|
|
3908
|
+
}
|
|
3909
|
+
async next(name) {
|
|
3910
|
+
this.assertOnline();
|
|
3911
|
+
let lastConflict;
|
|
3912
|
+
for (let attempt = 0; attempt < MAX_NEXT_ATTEMPTS; attempt++) {
|
|
3913
|
+
const { env, value } = await this.read(name);
|
|
3914
|
+
const nextValue = value + 1;
|
|
3915
|
+
const expectedVersion = env?._v ?? 0;
|
|
3916
|
+
const envelope = await this.encryptState({ value: nextValue }, expectedVersion + 1);
|
|
3917
|
+
try {
|
|
3918
|
+
await this.adapter.put(this.vault, SEQUENCE_COLLECTION, name, envelope, expectedVersion);
|
|
3919
|
+
return nextValue;
|
|
3920
|
+
} catch (err) {
|
|
3921
|
+
if (err instanceof ConflictError) {
|
|
3922
|
+
lastConflict = err;
|
|
3923
|
+
if (attempt < MAX_NEXT_ATTEMPTS - 1) await sleepBackoff(attempt);
|
|
3924
|
+
continue;
|
|
3925
|
+
}
|
|
3926
|
+
throw err;
|
|
3927
|
+
}
|
|
3928
|
+
}
|
|
3929
|
+
void lastConflict;
|
|
3930
|
+
throw new SequenceContentionError(name, MAX_NEXT_ATTEMPTS);
|
|
3931
|
+
}
|
|
3932
|
+
};
|
|
3933
|
+
|
|
3618
3934
|
// src/shadow/strategy.ts
|
|
3619
3935
|
var NOT_ENABLED2 = new Error(
|
|
3620
3936
|
'VaultFrame requires the shadow strategy. Import `{ withShadow }` from "@noy-db/hub/shadow" and pass it to `createNoydb({ shadowStrategy: withShadow() })`.'
|
|
@@ -4725,6 +5041,10 @@ var Vault = class {
|
|
|
4725
5041
|
* call throws with a pointer at `@noy-db/hub/blobs`.
|
|
4726
5042
|
*/
|
|
4727
5043
|
blobStrategy;
|
|
5044
|
+
/** Cold-storage archival strategy (the archive target store). */
|
|
5045
|
+
archiveStrategy;
|
|
5046
|
+
/** Per-collection record archival policies. Indexed by collection name. */
|
|
5047
|
+
archiveRegistry = /* @__PURE__ */ new Map();
|
|
4728
5048
|
indexStrategy;
|
|
4729
5049
|
aggregateStrategy;
|
|
4730
5050
|
crdtStrategy;
|
|
@@ -4828,6 +5148,8 @@ var Vault = class {
|
|
|
4828
5148
|
* docstring.
|
|
4829
5149
|
*/
|
|
4830
5150
|
ledgerStore = null;
|
|
5151
|
+
/** Lazily-built atomic-sequence store. See {@link sequence}. */
|
|
5152
|
+
sequenceStore = null;
|
|
4831
5153
|
/**
|
|
4832
5154
|
* Background writes for persisted-schema envelopes (#schema-dump v0
|
|
4833
5155
|
* slice 1). One promise per `collection({ persistJsonSchema: true })`
|
|
@@ -4929,6 +5251,7 @@ var Vault = class {
|
|
|
4929
5251
|
this.onRegisterConflictResolver = opts.onRegisterConflictResolver;
|
|
4930
5252
|
this.syncAdapter = opts.syncAdapter;
|
|
4931
5253
|
this.blobStrategy = opts.blobStrategy;
|
|
5254
|
+
this.archiveStrategy = opts.archiveStrategy;
|
|
4932
5255
|
this.indexStrategy = opts.indexStrategy;
|
|
4933
5256
|
this.aggregateStrategy = opts.aggregateStrategy;
|
|
4934
5257
|
this.crdtStrategy = opts.crdtStrategy;
|
|
@@ -4991,8 +5314,9 @@ var Vault = class {
|
|
|
4991
5314
|
*. `put()` validates keys against the declared set; reads
|
|
4992
5315
|
* with `{ locale }` add `<field>Label` virtual fields.
|
|
4993
5316
|
*
|
|
4994
|
-
* Throws `ReservedCollectionNameError` for names starting with `_dict_
|
|
4995
|
-
* Use `vault.dictionary(name)`
|
|
5317
|
+
* Throws `ReservedCollectionNameError` for names starting with `_dict_` or
|
|
5318
|
+
* equal to `_sequences`. Use `vault.dictionary(name)` for dict collections
|
|
5319
|
+
* and `vault.sequence(name)` for sequence counters.
|
|
4996
5320
|
*
|
|
4997
5321
|
* Lazy mode + indexes is rejected at construction time — see the
|
|
4998
5322
|
* Collection constructor for the rationale.
|
|
@@ -5011,7 +5335,16 @@ var Vault = class {
|
|
|
5011
5335
|
if (isDictCollectionName(collectionName)) {
|
|
5012
5336
|
throw new ReservedCollectionNameError(collectionName);
|
|
5013
5337
|
}
|
|
5338
|
+
if (collectionName === SEQUENCE_COLLECTION) {
|
|
5339
|
+
throw new ReservedCollectionNameError(collectionName);
|
|
5340
|
+
}
|
|
5014
5341
|
let coll = this.collectionCache.get(collectionName);
|
|
5342
|
+
if (coll && options?.moneyFields) {
|
|
5343
|
+
coll._applyMoneyFields(options.moneyFields);
|
|
5344
|
+
}
|
|
5345
|
+
if (coll && options?.computed) {
|
|
5346
|
+
coll._applyComputed(options.computed);
|
|
5347
|
+
}
|
|
5015
5348
|
if (!coll) {
|
|
5016
5349
|
if (options?.refs) {
|
|
5017
5350
|
this.refRegistry.register(collectionName, options.refs);
|
|
@@ -5022,6 +5355,9 @@ var Vault = class {
|
|
|
5022
5355
|
if (options?.blobFields) {
|
|
5023
5356
|
this.blobFieldsRegistry.set(collectionName, options.blobFields);
|
|
5024
5357
|
}
|
|
5358
|
+
if (options?.archive) {
|
|
5359
|
+
this.archiveRegistry.set(collectionName, options.archive);
|
|
5360
|
+
}
|
|
5025
5361
|
if (options?.attestation !== void 0) {
|
|
5026
5362
|
this.attestationRegistry.set(collectionName, options.attestation);
|
|
5027
5363
|
}
|
|
@@ -5137,6 +5473,8 @@ var Vault = class {
|
|
|
5137
5473
|
collOpts.onCrossTierAccess = (event) => this.emitCrossTier(event);
|
|
5138
5474
|
if (this.syncAdapter !== void 0) collOpts.syncAdapter = this.syncAdapter;
|
|
5139
5475
|
if (options?.i18nFields !== void 0) collOpts.i18nFields = options.i18nFields;
|
|
5476
|
+
if (options?.moneyFields !== void 0) collOpts.moneyFields = options.moneyFields;
|
|
5477
|
+
if (options?.computed !== void 0) collOpts.computed = options.computed;
|
|
5140
5478
|
if (options?.dictKeyFields !== void 0) {
|
|
5141
5479
|
collOpts.dictLabelResolver = async (dictName, key, locale, fallback) => {
|
|
5142
5480
|
const handle = this.dictionary(dictName);
|
|
@@ -5556,6 +5894,33 @@ var Vault = class {
|
|
|
5556
5894
|
* await vault.compact({ maxEvictions: 1000 }) // cap batch
|
|
5557
5895
|
* ```
|
|
5558
5896
|
*/
|
|
5897
|
+
/**
|
|
5898
|
+
* Atomic, gap-free numbering. `vault.sequence('invoice-2026').next()`
|
|
5899
|
+
* returns 1, 2, 3, … with no gaps or duplicates under concurrency, via
|
|
5900
|
+
* an optimistic-CAS counter at `_sequences/<name>`. Each name is an
|
|
5901
|
+
* independent sequence.
|
|
5902
|
+
*
|
|
5903
|
+
* **Online-only:** `next()` throws `SequenceOfflineError` unless the
|
|
5904
|
+
* store advertises `capabilities.casAtomic` — gap-free numbering cannot
|
|
5905
|
+
* be serialized by an offline / non-CAS writer.
|
|
5906
|
+
*
|
|
5907
|
+
* ```ts
|
|
5908
|
+
* const n = await vault.sequence('invoice-2026').next() // 1, then 2, …
|
|
5909
|
+
* const cur = await vault.sequence('invoice-2026').peek() // current value, no allocation
|
|
5910
|
+
* ```
|
|
5911
|
+
*/
|
|
5912
|
+
sequence(name) {
|
|
5913
|
+
if (!this.sequenceStore) {
|
|
5914
|
+
this.sequenceStore = new SequenceStore({
|
|
5915
|
+
adapter: this.adapter,
|
|
5916
|
+
vault: this.name,
|
|
5917
|
+
encrypted: this.encrypted,
|
|
5918
|
+
getDEK: this.getDEK,
|
|
5919
|
+
actor: this.keyring.userId
|
|
5920
|
+
});
|
|
5921
|
+
}
|
|
5922
|
+
return this.sequenceStore.handle(name);
|
|
5923
|
+
}
|
|
5559
5924
|
async compact(options = {}) {
|
|
5560
5925
|
return runCompaction({
|
|
5561
5926
|
adapter: this.adapter,
|
|
@@ -5580,6 +5945,48 @@ var Vault = class {
|
|
|
5580
5945
|
}
|
|
5581
5946
|
}, options);
|
|
5582
5947
|
}
|
|
5948
|
+
/**
|
|
5949
|
+
* Sweep records eligible by their collection's `archive` policy into the
|
|
5950
|
+
* cold archive store. Relocation is envelope-level (no re-encryption) and
|
|
5951
|
+
* bypasses guards + materialized-view dispatch, so issued/immutable
|
|
5952
|
+
* records over a sealed period can be archived without recomputing
|
|
5953
|
+
* finalized aggregates. A `legalHold` predicate blocks archival.
|
|
5954
|
+
* Requires `archiveStrategy: withArchive({ store })` in `createNoydb`.
|
|
5955
|
+
*/
|
|
5956
|
+
async archive(options = {}) {
|
|
5957
|
+
return runArchive(this._archiveContext(), options);
|
|
5958
|
+
}
|
|
5959
|
+
/** Relocate one archived record back to the primary store. Returns false if it was not archived. */
|
|
5960
|
+
async restore(collection, id) {
|
|
5961
|
+
return runRestore(this._archiveContext(), collection, id);
|
|
5962
|
+
}
|
|
5963
|
+
/** List archived record ids for a collection (or all collections with an archive policy). */
|
|
5964
|
+
async listArchived(collection) {
|
|
5965
|
+
return runListArchived(this._archiveContext(), collection);
|
|
5966
|
+
}
|
|
5967
|
+
_archiveContext() {
|
|
5968
|
+
const strategy = this.archiveStrategy;
|
|
5969
|
+
if (!strategy) {
|
|
5970
|
+
throw new Error(
|
|
5971
|
+
"vault.archive/restore/listArchived require `archiveStrategy: withArchive({ store })` in createNoydb"
|
|
5972
|
+
);
|
|
5973
|
+
}
|
|
5974
|
+
const archiveStore = strategy.store;
|
|
5975
|
+
return {
|
|
5976
|
+
vaultId: this.name,
|
|
5977
|
+
archiveStore,
|
|
5978
|
+
collectionsWithPolicy: () => [...this.archiveRegistry.keys()],
|
|
5979
|
+
getPolicy: (c) => this.archiveRegistry.get(c) ?? null,
|
|
5980
|
+
listRecordIds: (c) => this.adapter.list(this.name, c),
|
|
5981
|
+
getRecord: async (c, id) => await this.collection(c).get(id, { locale: "raw" }),
|
|
5982
|
+
getEnvelope: (c, id) => this.adapter.get(this.name, c, id),
|
|
5983
|
+
removeFromPrimary: (c, id) => this.collection(c)._internalDelete(id),
|
|
5984
|
+
restoreToPrimary: async (c, id, env) => {
|
|
5985
|
+
await this.adapter.put(this.name, c, id, env);
|
|
5986
|
+
await this.collection(c)._invalidateCacheEntry(id);
|
|
5987
|
+
}
|
|
5988
|
+
};
|
|
5989
|
+
}
|
|
5583
5990
|
exportBlobs(options = {}) {
|
|
5584
5991
|
this.assertCanExport("plaintext", "blob");
|
|
5585
5992
|
return createExportBlobsHandle(
|
|
@@ -5595,12 +6002,12 @@ var Vault = class {
|
|
|
5595
6002
|
if (!fieldSchema) {
|
|
5596
6003
|
throw new AttestationError(`issueAttestation: collection '${collectionName}' has no attestation field-schema. Declare it via vault.collection('${collectionName}', { attestation: { fields: [...] } }).`);
|
|
5597
6004
|
}
|
|
5598
|
-
const { issueAttestationCore } = await import("./issue-
|
|
6005
|
+
const { issueAttestationCore } = await import("./issue-YIYG4OW5.js");
|
|
5599
6006
|
const out = await issueAttestationCore(this.makeIssueContext(), { collection: collectionName, id, fieldSchema });
|
|
5600
6007
|
return { docId: out.docId, qr: out.qr, keyId: out.keyId, publicKeyB64: out.publicKeyB64 };
|
|
5601
6008
|
}
|
|
5602
6009
|
async getDocumentSigningPublicKey() {
|
|
5603
|
-
const { loadSigner, loadOrCreateSigner } = await import("./signer-
|
|
6010
|
+
const { loadSigner, loadOrCreateSigner } = await import("./signer-6JF44I4A.js");
|
|
5604
6011
|
const existing = await loadSigner(this.adapter, this.name, this.getDEK);
|
|
5605
6012
|
if (existing) return { keyId: existing.keyId, publicKeyB64: existing.publicKeyB64 };
|
|
5606
6013
|
if (this.keyring.role !== "owner") {
|
|
@@ -5626,19 +6033,19 @@ var Vault = class {
|
|
|
5626
6033
|
};
|
|
5627
6034
|
}
|
|
5628
6035
|
async revokeAttestation(docId) {
|
|
5629
|
-
const { revokeDocCore } = await import("./revoke-
|
|
6036
|
+
const { revokeDocCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5630
6037
|
await revokeDocCore(this.makeRevokeContext(), docId);
|
|
5631
6038
|
}
|
|
5632
6039
|
async unrevokeAttestation(docId) {
|
|
5633
|
-
const { unrevokeDocCore } = await import("./revoke-
|
|
6040
|
+
const { unrevokeDocCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5634
6041
|
await unrevokeDocCore(this.makeRevokeContext(), docId);
|
|
5635
6042
|
}
|
|
5636
6043
|
async getRevokedDocIds() {
|
|
5637
|
-
const { getRevokedDocIdsCore } = await import("./revoke-
|
|
6044
|
+
const { getRevokedDocIdsCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5638
6045
|
return getRevokedDocIdsCore(this.makeRevokeContext());
|
|
5639
6046
|
}
|
|
5640
6047
|
async publishRevocationList() {
|
|
5641
|
-
const { publishRevocationListCore } = await import("./revoke-
|
|
6048
|
+
const { publishRevocationListCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5642
6049
|
return publishRevocationListCore(this.makeRevokeContext());
|
|
5643
6050
|
}
|
|
5644
6051
|
makeRevokeContext() {
|
|
@@ -5955,7 +6362,7 @@ var Vault = class {
|
|
|
5955
6362
|
async _initDerivations(handles) {
|
|
5956
6363
|
if (handles.length === 0) return;
|
|
5957
6364
|
const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
|
|
5958
|
-
import("./registry-
|
|
6365
|
+
import("./registry-JLP3QOLD.js"),
|
|
5959
6366
|
import("./read-only-facade-ITU6L7BL.js")
|
|
5960
6367
|
]);
|
|
5961
6368
|
const registry = new DerivationRegistry();
|
|
@@ -5986,7 +6393,7 @@ var Vault = class {
|
|
|
5986
6393
|
*/
|
|
5987
6394
|
async _initMaterializedViews(handles) {
|
|
5988
6395
|
if (handles.length === 0) return;
|
|
5989
|
-
const { MaterializedViewRegistry } = await import("./registry-
|
|
6396
|
+
const { MaterializedViewRegistry } = await import("./registry-NCY445U5.js");
|
|
5990
6397
|
const registry = new MaterializedViewRegistry();
|
|
5991
6398
|
this.materializedViewRegistry = registry;
|
|
5992
6399
|
const db = this;
|
|
@@ -6010,7 +6417,7 @@ var Vault = class {
|
|
|
6010
6417
|
*/
|
|
6011
6418
|
async _initOverlayedViews(handles) {
|
|
6012
6419
|
if (handles.length === 0) return;
|
|
6013
|
-
const { OverlayedViewRegistry } = await import("./registry-
|
|
6420
|
+
const { OverlayedViewRegistry } = await import("./registry-BVQ5ITMF.js");
|
|
6014
6421
|
const registry = new OverlayedViewRegistry();
|
|
6015
6422
|
const mvRegistry = this.materializedViewRegistry;
|
|
6016
6423
|
const overlayNames = /* @__PURE__ */ new Set();
|
|
@@ -6057,13 +6464,13 @@ var Vault = class {
|
|
|
6057
6464
|
if (!reg) {
|
|
6058
6465
|
throw new Error(`refreshView: no MV registered with name "${name}"`);
|
|
6059
6466
|
}
|
|
6060
|
-
const { MaterializedViewExecutor } = await import("./executor-
|
|
6467
|
+
const { MaterializedViewExecutor } = await import("./executor-O5AZK7UW.js");
|
|
6061
6468
|
const result = await MaterializedViewExecutor.refresh(reg, {
|
|
6062
6469
|
getCollection: (n) => this.collection(n),
|
|
6063
6470
|
getActiveTxContext: () => this.noydb._activeTxContextOrNull,
|
|
6064
6471
|
getQueryContext: () => this
|
|
6065
6472
|
});
|
|
6066
|
-
const { clearMVStale } = await import("./stale-
|
|
6473
|
+
const { clearMVStale } = await import("./stale-UBLP3RJ3.js");
|
|
6067
6474
|
clearMVStale(registry, name);
|
|
6068
6475
|
return result;
|
|
6069
6476
|
}
|
|
@@ -6079,7 +6486,7 @@ var Vault = class {
|
|
|
6079
6486
|
if (registry === null) return { derived: 0, failed: 0 };
|
|
6080
6487
|
const strategies = registry.strategiesForSource(sourceCollection);
|
|
6081
6488
|
if (strategies.length === 0) return { derived: 0, failed: 0 };
|
|
6082
|
-
const { DerivationExecutor } = await import("./executor-
|
|
6489
|
+
const { DerivationExecutor } = await import("./executor-D2QMNGRJ.js");
|
|
6083
6490
|
const sourceColl = this.collection(sourceCollection);
|
|
6084
6491
|
const records = await sourceColl.list();
|
|
6085
6492
|
const ctx = { vault: this.readOnlyFacade ?? new (await import("./read-only-facade-ITU6L7BL.js")).ReadOnlyVaultFacade(this) };
|
|
@@ -6104,7 +6511,7 @@ var Vault = class {
|
|
|
6104
6511
|
if (!outSpec) continue;
|
|
6105
6512
|
const outputColl = this.collection(outSpec.collection);
|
|
6106
6513
|
if (out.kind === "array") {
|
|
6107
|
-
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-
|
|
6514
|
+
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-ZSKEQ6NI.js");
|
|
6108
6515
|
const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key);
|
|
6109
6516
|
const prevKeys = new Set(prior?.keys ?? []);
|
|
6110
6517
|
const newKeysList = out.entries.map((e) => e.key);
|
|
@@ -6325,7 +6732,7 @@ var Vault = class {
|
|
|
6325
6732
|
* collection.
|
|
6326
6733
|
*/
|
|
6327
6734
|
async delegate(opts) {
|
|
6328
|
-
const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-
|
|
6735
|
+
const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-6FCWDRUS.js");
|
|
6329
6736
|
if (!this.keyring.kek) {
|
|
6330
6737
|
throw new ValidationError(
|
|
6331
6738
|
"issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (passphrase) first."
|
|
@@ -6347,7 +6754,7 @@ var Vault = class {
|
|
|
6347
6754
|
* if the id does not exist.
|
|
6348
6755
|
*/
|
|
6349
6756
|
async revokeDelegation(id) {
|
|
6350
|
-
const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-
|
|
6757
|
+
const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-6FCWDRUS.js");
|
|
6351
6758
|
await revokeDelegation(this.adapter, this.name, id);
|
|
6352
6759
|
void DELEGATIONS_COLLECTION;
|
|
6353
6760
|
}
|
|
@@ -6816,7 +7223,7 @@ var Vault = class {
|
|
|
6816
7223
|
* @see docs/subsystems/public-envelope.md
|
|
6817
7224
|
*/
|
|
6818
7225
|
async getPublicEnvelope(opts = {}) {
|
|
6819
|
-
const { readPublicEnvelope: readPublicEnvelope2 } = await import("./public-envelope-
|
|
7226
|
+
const { readPublicEnvelope: readPublicEnvelope2 } = await import("./public-envelope-PFLZI5MO.js");
|
|
6820
7227
|
return readPublicEnvelope2(this.adapter, this.name, opts);
|
|
6821
7228
|
}
|
|
6822
7229
|
/**
|
|
@@ -6841,7 +7248,7 @@ var Vault = class {
|
|
|
6841
7248
|
}
|
|
6842
7249
|
}
|
|
6843
7250
|
const internalSnapshot = {};
|
|
6844
|
-
for (const internalName of [LEDGER_COLLECTION, LEDGER_DELTAS_COLLECTION, SCHEMAS_COLLECTION]) {
|
|
7251
|
+
for (const internalName of [LEDGER_COLLECTION, LEDGER_DELTAS_COLLECTION, SCHEMAS_COLLECTION, SEQUENCE_COLLECTION]) {
|
|
6845
7252
|
const ids = await this.adapter.list(this.name, internalName);
|
|
6846
7253
|
if (ids.length === 0) continue;
|
|
6847
7254
|
const records = {};
|
|
@@ -8358,6 +8765,7 @@ var Noydb = class {
|
|
|
8358
8765
|
writeRelay;
|
|
8359
8766
|
/** Per-vault policy enforcers. */
|
|
8360
8767
|
policyEnforcers = /* @__PURE__ */ new Map();
|
|
8768
|
+
vaultTemplates = /* @__PURE__ */ new Map();
|
|
8361
8769
|
txStrategy;
|
|
8362
8770
|
sessionStrategy;
|
|
8363
8771
|
syncStrategy;
|
|
@@ -8425,9 +8833,9 @@ var Noydb = class {
|
|
|
8425
8833
|
if (!facade) return;
|
|
8426
8834
|
const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
|
|
8427
8835
|
await registry.runChecks(e.collection, incoming, ctx);
|
|
8428
|
-
const { GuardExecutor } = await import("./executor-
|
|
8836
|
+
const { GuardExecutor } = await import("./executor-7KSCEIFA.js");
|
|
8429
8837
|
for (const g of guards) {
|
|
8430
|
-
await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming);
|
|
8838
|
+
await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
|
|
8431
8839
|
}
|
|
8432
8840
|
});
|
|
8433
8841
|
this.subsystemBus.registerGate("beforeDelete", async (e) => {
|
|
@@ -8548,7 +8956,7 @@ var Noydb = class {
|
|
|
8548
8956
|
}
|
|
8549
8957
|
return comp;
|
|
8550
8958
|
}
|
|
8551
|
-
const keyring = await this.getKeyringInternal(name);
|
|
8959
|
+
const keyring = await this.getKeyringInternal(name, { create: opts?.create !== false });
|
|
8552
8960
|
if (!this.activeTier.has(name)) {
|
|
8553
8961
|
this.activeTier.set(name, 1);
|
|
8554
8962
|
}
|
|
@@ -8606,6 +9014,7 @@ var Noydb = class {
|
|
|
8606
9014
|
syncAdapter: targets.length > 0 ? targets[0].store : void 0,
|
|
8607
9015
|
historyConfig: this.options.history,
|
|
8608
9016
|
...this.options.blobStrategy !== void 0 ? { blobStrategy: this.options.blobStrategy } : {},
|
|
9017
|
+
...this.options.archiveStrategy !== void 0 ? { archiveStrategy: this.options.archiveStrategy } : {},
|
|
8609
9018
|
...this.options.indexStrategy !== void 0 ? { indexStrategy: this.options.indexStrategy } : {},
|
|
8610
9019
|
...this.options.aggregateStrategy !== void 0 ? { aggregateStrategy: this.options.aggregateStrategy } : {},
|
|
8611
9020
|
...this.options.crdtStrategy !== void 0 ? { crdtStrategy: this.options.crdtStrategy } : {},
|
|
@@ -8659,6 +9068,7 @@ var Noydb = class {
|
|
|
8659
9068
|
emitter: this.emitter,
|
|
8660
9069
|
historyConfig: this.options.history,
|
|
8661
9070
|
...this.options.blobStrategy !== void 0 ? { blobStrategy: this.options.blobStrategy } : {},
|
|
9071
|
+
...this.options.archiveStrategy !== void 0 ? { archiveStrategy: this.options.archiveStrategy } : {},
|
|
8662
9072
|
...this.options.indexStrategy !== void 0 ? { indexStrategy: this.options.indexStrategy } : {},
|
|
8663
9073
|
...this.options.aggregateStrategy !== void 0 ? { aggregateStrategy: this.options.aggregateStrategy } : {},
|
|
8664
9074
|
...this.options.crdtStrategy !== void 0 ? { crdtStrategy: this.options.crdtStrategy } : {},
|
|
@@ -8687,6 +9097,7 @@ var Noydb = class {
|
|
|
8687
9097
|
encrypted: true,
|
|
8688
9098
|
historyConfig: this.options.history,
|
|
8689
9099
|
...this.options.blobStrategy !== void 0 ? { blobStrategy: this.options.blobStrategy } : {},
|
|
9100
|
+
...this.options.archiveStrategy !== void 0 ? { archiveStrategy: this.options.archiveStrategy } : {},
|
|
8690
9101
|
...this.options.indexStrategy !== void 0 ? { indexStrategy: this.options.indexStrategy } : {},
|
|
8691
9102
|
...this.options.aggregateStrategy !== void 0 ? { aggregateStrategy: this.options.aggregateStrategy } : {},
|
|
8692
9103
|
...this.options.crdtStrategy !== void 0 ? { crdtStrategy: this.options.crdtStrategy } : {},
|
|
@@ -8976,7 +9387,7 @@ var Noydb = class {
|
|
|
8976
9387
|
const vaultId = vaultIds[idx];
|
|
8977
9388
|
const task = (async () => {
|
|
8978
9389
|
try {
|
|
8979
|
-
const comp = await this.openVault(vaultId);
|
|
9390
|
+
const comp = await this.openVault(vaultId, { create: options.create !== false });
|
|
8980
9391
|
const result = await fn(comp);
|
|
8981
9392
|
results[idx] = { vault: vaultId, result };
|
|
8982
9393
|
} catch (err) {
|
|
@@ -9001,6 +9412,32 @@ var Noydb = class {
|
|
|
9001
9412
|
}
|
|
9002
9413
|
return results;
|
|
9003
9414
|
}
|
|
9415
|
+
/**
|
|
9416
|
+
* Register a shard schema blueprint. `createShard` / `openVaultGroup`
|
|
9417
|
+
* stamp shards from the named template. See the MVF design spec.
|
|
9418
|
+
*/
|
|
9419
|
+
withVaultTemplate(name, template) {
|
|
9420
|
+
this.vaultTemplates.set(name, template);
|
|
9421
|
+
}
|
|
9422
|
+
/**
|
|
9423
|
+
* Open a VaultGroup — transparent routing over per-partition shard
|
|
9424
|
+
* vaults, with shard discovery backed by the supplied `vault-registry`
|
|
9425
|
+
* collection.
|
|
9426
|
+
*/
|
|
9427
|
+
async openVaultGroup(name, opts) {
|
|
9428
|
+
if (this.closed) throw new ValidationError("Instance is closed");
|
|
9429
|
+
const template = this.vaultTemplates.get(opts.sharding.vaultTemplate);
|
|
9430
|
+
if (!template) throw new VaultTemplateNotFoundError(opts.sharding.vaultTemplate);
|
|
9431
|
+
const { VaultGroup } = await import("./vault-group-Z4KB75ZH.js");
|
|
9432
|
+
return new VaultGroup(this, name, opts.registry, opts.sharding, template);
|
|
9433
|
+
}
|
|
9434
|
+
/**
|
|
9435
|
+
* @internal — true when an encrypted shard vault is provisioned
|
|
9436
|
+
* (its keyring exists in the store).
|
|
9437
|
+
*/
|
|
9438
|
+
async _shardVaultProvisioned(vaultId) {
|
|
9439
|
+
return (await this.options.store.list(vaultId, "_keyring")).length > 0;
|
|
9440
|
+
}
|
|
9004
9441
|
/**
|
|
9005
9442
|
* Change the current user's passphrase for a vault.
|
|
9006
9443
|
*
|
|
@@ -10318,7 +10755,7 @@ var Noydb = class {
|
|
|
10318
10755
|
* accesses see them. Not exposed publicly — callers outside hub
|
|
10319
10756
|
* should use {@link getKeyring}, which returns a defensive copy.
|
|
10320
10757
|
*/
|
|
10321
|
-
async getKeyringInternal(vault) {
|
|
10758
|
+
async getKeyringInternal(vault, opts = { create: true }) {
|
|
10322
10759
|
if (this.options.encrypt === false) {
|
|
10323
10760
|
return createPlaintextKeyring(this.options.user);
|
|
10324
10761
|
}
|
|
@@ -10329,6 +10766,7 @@ var Noydb = class {
|
|
|
10329
10766
|
this.keyringCache.set(vault, keyring2);
|
|
10330
10767
|
return keyring2;
|
|
10331
10768
|
}
|
|
10769
|
+
await assertKeyringOpenAllowed(this.options.store, vault, this.options.user, opts.create);
|
|
10332
10770
|
let effectiveSecret;
|
|
10333
10771
|
if (this.options.passphraseMode === "managed") {
|
|
10334
10772
|
effectiveSecret = await resolveManagedSecret(
|
|
@@ -10491,6 +10929,8 @@ function normalizeSyncTargets(sync) {
|
|
|
10491
10929
|
}
|
|
10492
10930
|
|
|
10493
10931
|
export {
|
|
10932
|
+
withArchive,
|
|
10933
|
+
SequenceStore,
|
|
10494
10934
|
validateSchemaInput,
|
|
10495
10935
|
validateSchemaOutput,
|
|
10496
10936
|
isZodSchema,
|
|
@@ -10510,6 +10950,8 @@ export {
|
|
|
10510
10950
|
diagramAuthConfig,
|
|
10511
10951
|
describeUserAuth,
|
|
10512
10952
|
describeAllUsersAuth,
|
|
10953
|
+
ComputedFieldError,
|
|
10954
|
+
evalComputedFields,
|
|
10513
10955
|
Lru,
|
|
10514
10956
|
parseBytes,
|
|
10515
10957
|
estimateRecordBytes,
|
|
@@ -10526,4 +10968,4 @@ export {
|
|
|
10526
10968
|
Noydb,
|
|
10527
10969
|
createNoydb
|
|
10528
10970
|
};
|
|
10529
|
-
//# sourceMappingURL=chunk-
|
|
10971
|
+
//# sourceMappingURL=chunk-TMHJEYW7.js.map
|