@noy-db/hub 0.2.0-pre.11 → 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 +1452 -16
- 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-77DWLQRY.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-73YLDCNF.js → chunk-7JJE3OMJ.js} +5 -5
- package/dist/{chunk-GKI4SDP7.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-YVZRTCGG.js → chunk-DLTU4M2I.js} +6 -6
- package/dist/{chunk-GAUEWM7D.js → chunk-EKNUBIIQ.js} +4 -4
- package/dist/{chunk-QCXNMCHN.js → chunk-GFPR7VJS.js} +4 -4
- package/dist/{chunk-V2PZC6AW.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-PC3ZZBTO.js → chunk-LOA2VCMS.js} +5 -5
- package/dist/{chunk-TGALXXLV.js → chunk-LSEW3ZZ2.js} +3 -3
- package/dist/{chunk-Y26YV5R3.js → chunk-LWSD4QPT.js} +3 -3
- package/dist/{chunk-SLV4LAKX.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-ZBBW7YQN.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-3DGHRDCX.js → chunk-RRDWXNBQ.js} +3 -3
- package/dist/{chunk-6MFH4BMK.js → chunk-SJJQKNMP.js} +4 -4
- package/dist/{chunk-EBVBE7UK.js → chunk-SZ4N3IL5.js} +5 -5
- package/dist/{chunk-MPOLUAMI.js → chunk-TMHJEYW7.js} +497 -57
- package/dist/chunk-TMHJEYW7.js.map +1 -0
- package/dist/{chunk-JQ4NEJJ6.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-YW5DBAPG.js → chunk-WUG3E423.js} +4 -4
- package/dist/{chunk-LJXYPGRH.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-BH6y3Hx0.d.ts → dev-unlock-D3mpVFRc.d.ts} +1 -1
- package/dist/{dev-unlock-H1Xwxc3U.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-F3ZRFU4H.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-D89JdDbj.d.ts → hash-CTZVkXLx.d.ts} +1 -1
- package/dist/{hash-_sDFvtmX.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 +1620 -58
- 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-NYCGJX2D.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-QOXZEHKH.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-RT7QYB4G.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-QNU66JF5.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-DiSXn3a4.d.cts → types-BGwjsDef.d.cts} +511 -6
- package/dist/{types-CD8mc8zR.d.ts → types-DRdfwgTG.d.ts} +511 -6
- package/dist/{ulid-DQ1hcJvZ.d.cts → ulid-D4d0Xto3.d.cts} +1 -1
- package/dist/{ulid-8p83wbR4.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-DWMTpgEH.d.ts → with-derivation-B082Y_WQ.d.ts} +1 -1
- package/dist/{with-derivation-CVT7-dUt.d.cts → with-derivation-CB1EdcFF.d.cts} +1 -1
- package/dist/{with-materialized-view-BTTU3BNK.d.cts → with-materialized-view-CzRg1Dpr.d.cts} +1 -1
- package/dist/{with-materialized-view-X0CoL8-L.d.ts → with-materialized-view-Dw4SwjKl.d.ts} +1 -1
- package/dist/{with-overlayed-view-DcacRRsS.d.cts → with-overlayed-view-C9YFKXzn.d.cts} +1 -1
- package/dist/{with-overlayed-view-DQjO_DSG.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-6YLPHBKR.js.map +0 -1
- package/dist/chunk-77DWLQRY.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-MPOLUAMI.js.map +0 -1
- package/dist/chunk-O6EJ6WTI.js.map +0 -1
- package/dist/chunk-PVUUIWHY.js.map +0 -1
- package/dist/chunk-SLV4LAKX.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-IVTVSKWW.js +0 -12
- package/dist/noydb-SH4RLE47.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-BRvt53da.d.ts +0 -18
- package/dist/with-guard-Dx2zZnTA.d.cts +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-73YLDCNF.js.map → chunk-7JJE3OMJ.js.map} +0 -0
- /package/dist/{chunk-GKI4SDP7.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-YVZRTCGG.js.map → chunk-DLTU4M2I.js.map} +0 -0
- /package/dist/{chunk-GAUEWM7D.js.map → chunk-EKNUBIIQ.js.map} +0 -0
- /package/dist/{chunk-QCXNMCHN.js.map → chunk-GFPR7VJS.js.map} +0 -0
- /package/dist/{chunk-V2PZC6AW.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-PC3ZZBTO.js.map → chunk-LOA2VCMS.js.map} +0 -0
- /package/dist/{chunk-TGALXXLV.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-ZBBW7YQN.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-3DGHRDCX.js.map → chunk-RRDWXNBQ.js.map} +0 -0
- /package/dist/{chunk-6MFH4BMK.js.map → chunk-SJJQKNMP.js.map} +0 -0
- /package/dist/{chunk-EBVBE7UK.js.map → chunk-SZ4N3IL5.js.map} +0 -0
- /package/dist/{chunk-JQ4NEJJ6.js.map → chunk-UA6G45ME.js.map} +0 -0
- /package/dist/{chunk-DAP2XL7Q.js.map → chunk-VOXMU6LB.js.map} +0 -0
- /package/dist/{chunk-YW5DBAPG.js.map → chunk-WUG3E423.js.map} +0 -0
- /package/dist/{chunk-LJXYPGRH.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-F3ZRFU4H.js.map → fanout-sidecar-ZSKEQ6NI.js.map} +0 -0
- /package/dist/{issue-IVTVSKWW.js.map → issue-YIYG4OW5.js.map} +0 -0
- /package/dist/{ledger-NYCGJX2D.js.map → ledger-5JMVF7PY.js.map} +0 -0
- /package/dist/{noydb-SH4RLE47.js.map → noydb-D5SLAJ6V.js.map} +0 -0
- /package/dist/{public-envelope-QOXZEHKH.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-RT7QYB4G.js.map → revoke-7RLGQWZ7.js.map} +0 -0
- /package/dist/{signer-QNU66JF5.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,11 +56,11 @@ 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
66
|
assertKeyringOpenAllowed,
|
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
rotateKeys,
|
|
86
86
|
saveUserEnvelope,
|
|
87
87
|
updateKeyringIdentity
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-GFPR7VJS.js";
|
|
89
89
|
import {
|
|
90
90
|
INDEXED_STORE_POLICY
|
|
91
91
|
} from "./chunk-2QR2PQTT.js";
|
|
@@ -95,7 +95,7 @@ import {
|
|
|
95
95
|
import {
|
|
96
96
|
LEDGER_COLLECTION,
|
|
97
97
|
LEDGER_DELTAS_COLLECTION
|
|
98
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-SJJQKNMP.js";
|
|
99
99
|
import {
|
|
100
100
|
sha256Hex as sha256Hex2
|
|
101
101
|
} from "./chunk-Z6FNBOTC.js";
|
|
@@ -103,10 +103,13 @@ import {
|
|
|
103
103
|
NO_AGGREGATE,
|
|
104
104
|
Query,
|
|
105
105
|
ScanBuilder
|
|
106
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-UOC7JMZO.js";
|
|
107
107
|
import {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
MoneyPrecisionError,
|
|
109
|
+
canonicalGroupKey,
|
|
110
|
+
formatScaledInt,
|
|
111
|
+
parseToScaledInt
|
|
112
|
+
} from "./chunk-OPDTLHFA.js";
|
|
110
113
|
import {
|
|
111
114
|
readPath
|
|
112
115
|
} from "./chunk-TV3YZ35S.js";
|
|
@@ -114,17 +117,17 @@ import {
|
|
|
114
117
|
EXPORT_AUDIT_COLLECTION,
|
|
115
118
|
createExportBlobsHandle,
|
|
116
119
|
runCompaction
|
|
117
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-6AD5TBF2.js";
|
|
118
121
|
import {
|
|
119
122
|
NOYDB_BACKUP_VERSION,
|
|
120
123
|
NOYDB_FORMAT_VERSION
|
|
121
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-LYNNZEQD.js";
|
|
122
125
|
import {
|
|
123
126
|
decrypt,
|
|
124
127
|
encrypt,
|
|
125
128
|
encryptDeterministic,
|
|
126
129
|
sha256Hex
|
|
127
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-IUBHXEPJ.js";
|
|
128
131
|
import {
|
|
129
132
|
AlreadyElevatedError,
|
|
130
133
|
AttestationError,
|
|
@@ -147,14 +150,17 @@ import {
|
|
|
147
150
|
ReservedCollectionNameError,
|
|
148
151
|
SchemaFenceError,
|
|
149
152
|
SchemaValidationError,
|
|
153
|
+
SequenceContentionError,
|
|
154
|
+
SequenceOfflineError,
|
|
150
155
|
StoreCapabilityError,
|
|
151
156
|
TierDemoteDeniedError,
|
|
152
157
|
TierNotGrantedError,
|
|
153
158
|
TranslatorNotConfiguredError,
|
|
154
159
|
UniqueConstraintError,
|
|
155
160
|
UnsupportedIndexOptionError,
|
|
156
|
-
ValidationError
|
|
157
|
-
|
|
161
|
+
ValidationError,
|
|
162
|
+
VaultTemplateNotFoundError
|
|
163
|
+
} from "./chunk-AGRC7NQQ.js";
|
|
158
164
|
|
|
159
165
|
// src/policy/storage.ts
|
|
160
166
|
var META_COLLECTION = "_meta";
|
|
@@ -329,6 +335,116 @@ var NO_CRDT = {
|
|
|
329
335
|
}
|
|
330
336
|
};
|
|
331
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
|
+
|
|
332
448
|
// src/i18n/strategy.ts
|
|
333
449
|
function notEnabled(op) {
|
|
334
450
|
return new Error(
|
|
@@ -769,7 +885,7 @@ async function resolveStaleOnRead(accessor, outputCollection, id) {
|
|
|
769
885
|
}
|
|
770
886
|
const sourceWithId = { ...source, id };
|
|
771
887
|
if (DerivationExecutor === null) {
|
|
772
|
-
({ DerivationExecutor } = await import("./executor-
|
|
888
|
+
({ DerivationExecutor } = await import("./executor-D2QMNGRJ.js"));
|
|
773
889
|
}
|
|
774
890
|
const ctx = { vault: accessor.getReadOnlyFacade() };
|
|
775
891
|
const result = await DerivationExecutor.run(spec, sourceWithId, 0, strategyHash, ctx);
|
|
@@ -962,6 +1078,18 @@ var Collection = class {
|
|
|
962
1078
|
* fields when a locale is requested.
|
|
963
1079
|
*/
|
|
964
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;
|
|
965
1093
|
/**
|
|
966
1094
|
* Async callback provided by the Vault that resolves a dict key
|
|
967
1095
|
* to its label for a given locale. Used by the locale-read path for
|
|
@@ -1103,6 +1231,8 @@ var Collection = class {
|
|
|
1103
1231
|
this.joinResolver = opts.joinResolver;
|
|
1104
1232
|
this.i18nFields = opts.i18nFields;
|
|
1105
1233
|
this.dictKeyFields = opts.dictKeyFields;
|
|
1234
|
+
this.moneyFields = opts.moneyFields;
|
|
1235
|
+
this.computed = opts.computed;
|
|
1106
1236
|
this.dictLabelResolver = opts.dictLabelResolver;
|
|
1107
1237
|
this.i18nPutValidator = opts.i18nPutValidator;
|
|
1108
1238
|
this.autoTranslateHook = opts.autoTranslateHook;
|
|
@@ -1227,6 +1357,19 @@ var Collection = class {
|
|
|
1227
1357
|
getSchema() {
|
|
1228
1358
|
return this.schema;
|
|
1229
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
|
+
}
|
|
1230
1373
|
/**
|
|
1231
1374
|
* Get a single record by ID.
|
|
1232
1375
|
*
|
|
@@ -1248,7 +1391,7 @@ var Collection = class {
|
|
|
1248
1391
|
}
|
|
1249
1392
|
}
|
|
1250
1393
|
if (this.materializedViewSource !== void 0) {
|
|
1251
|
-
const { resolveStaleMVOnRead } = await import("./stale-
|
|
1394
|
+
const { resolveStaleMVOnRead } = await import("./stale-UBLP3RJ3.js");
|
|
1252
1395
|
await resolveStaleMVOnRead(this.materializedViewSource, this.name);
|
|
1253
1396
|
}
|
|
1254
1397
|
let record;
|
|
@@ -1398,7 +1541,7 @@ var Collection = class {
|
|
|
1398
1541
|
existingRecord = null;
|
|
1399
1542
|
}
|
|
1400
1543
|
}
|
|
1401
|
-
|
|
1544
|
+
const gateEvent = {
|
|
1402
1545
|
op: existingEnv ? "update" : "create",
|
|
1403
1546
|
vault: this.vault,
|
|
1404
1547
|
collection: this.name,
|
|
@@ -1408,12 +1551,20 @@ var Collection = class {
|
|
|
1408
1551
|
existingVersion: existingEnv?._v ?? 0,
|
|
1409
1552
|
existingTs: existingEnv?._ts,
|
|
1410
1553
|
userId: this.keyring.userId,
|
|
1411
|
-
role: this.keyring.role
|
|
1412
|
-
|
|
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);
|
|
1413
1561
|
}
|
|
1414
1562
|
if (this.schema !== void 0) {
|
|
1415
1563
|
record = await validateSchemaInput(this.schema, record, `put(${id})`);
|
|
1416
1564
|
}
|
|
1565
|
+
if (this.moneyFields) {
|
|
1566
|
+
record = quantizeMoneyFields(record, this.moneyFields);
|
|
1567
|
+
}
|
|
1417
1568
|
if (this.i18nFields) {
|
|
1418
1569
|
const obj = record;
|
|
1419
1570
|
for (const [field, descriptor] of Object.entries(this.i18nFields)) {
|
|
@@ -1637,7 +1788,7 @@ var Collection = class {
|
|
|
1637
1788
|
if (mode === "eager") {
|
|
1638
1789
|
if (executor === null) {
|
|
1639
1790
|
;
|
|
1640
|
-
({ MaterializedViewExecutor: executor } = await import("./executor-
|
|
1791
|
+
({ MaterializedViewExecutor: executor } = await import("./executor-O5AZK7UW.js"));
|
|
1641
1792
|
}
|
|
1642
1793
|
await executor.refresh(reg, {
|
|
1643
1794
|
getCollection: (name) => this.materializedViewSource.getCollection(name),
|
|
@@ -1646,7 +1797,7 @@ var Collection = class {
|
|
|
1646
1797
|
});
|
|
1647
1798
|
} else if (mode === "lazy") {
|
|
1648
1799
|
if (staleHelpers === null) {
|
|
1649
|
-
staleHelpers = await import("./stale-
|
|
1800
|
+
staleHelpers = await import("./stale-UBLP3RJ3.js");
|
|
1650
1801
|
}
|
|
1651
1802
|
staleHelpers.markMVStale(registry, reg.spec.name);
|
|
1652
1803
|
}
|
|
@@ -1675,7 +1826,7 @@ var Collection = class {
|
|
|
1675
1826
|
const mode = typeof spec.lifecycle === "string" ? spec.lifecycle : spec.lifecycle.mode;
|
|
1676
1827
|
if (mode === "eager") {
|
|
1677
1828
|
if (DerivationExecutor === null) {
|
|
1678
|
-
({ DerivationExecutor } = await import("./executor-
|
|
1829
|
+
({ DerivationExecutor } = await import("./executor-D2QMNGRJ.js"));
|
|
1679
1830
|
}
|
|
1680
1831
|
const sourceWithId = { ...incoming, id };
|
|
1681
1832
|
const ctx = { vault: this.derivationSource.getReadOnlyFacade() };
|
|
@@ -1694,7 +1845,7 @@ var Collection = class {
|
|
|
1694
1845
|
const outputCollection = this.derivationSource.getCollection(outSpec.collection);
|
|
1695
1846
|
const txCtx = this.derivationSource.getActiveTxContext();
|
|
1696
1847
|
if (out.kind === "array") {
|
|
1697
|
-
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-
|
|
1848
|
+
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-ZSKEQ6NI.js");
|
|
1698
1849
|
const prior = await loadFanoutSidecar(
|
|
1699
1850
|
this.adapter,
|
|
1700
1851
|
this.vault,
|
|
@@ -1987,7 +2138,7 @@ var Collection = class {
|
|
|
1987
2138
|
for (const [outputKey, outSpec] of Object.entries(spec.outputs)) {
|
|
1988
2139
|
if (outSpec.shape !== "array") continue;
|
|
1989
2140
|
if (helpers === null) {
|
|
1990
|
-
helpers = await import("./fanout-sidecar-
|
|
2141
|
+
helpers = await import("./fanout-sidecar-ZSKEQ6NI.js");
|
|
1991
2142
|
}
|
|
1992
2143
|
const sidecar = await helpers.loadFanoutSidecar(
|
|
1993
2144
|
this.adapter,
|
|
@@ -2027,7 +2178,7 @@ var Collection = class {
|
|
|
2027
2178
|
if (mode === "eager") {
|
|
2028
2179
|
if (executor === null) {
|
|
2029
2180
|
;
|
|
2030
|
-
({ MaterializedViewExecutor: executor } = await import("./executor-
|
|
2181
|
+
({ MaterializedViewExecutor: executor } = await import("./executor-O5AZK7UW.js"));
|
|
2031
2182
|
}
|
|
2032
2183
|
await executor.refresh(reg, {
|
|
2033
2184
|
getCollection: (name) => this.materializedViewSource.getCollection(name),
|
|
@@ -2036,7 +2187,7 @@ var Collection = class {
|
|
|
2036
2187
|
});
|
|
2037
2188
|
} else if (mode === "lazy") {
|
|
2038
2189
|
if (staleHelpers === null) {
|
|
2039
|
-
staleHelpers = await import("./stale-
|
|
2190
|
+
staleHelpers = await import("./stale-UBLP3RJ3.js");
|
|
2040
2191
|
}
|
|
2041
2192
|
staleHelpers.markMVStale(registry, reg.spec.name);
|
|
2042
2193
|
}
|
|
@@ -2059,7 +2210,7 @@ var Collection = class {
|
|
|
2059
2210
|
);
|
|
2060
2211
|
}
|
|
2061
2212
|
if (this.materializedViewSource !== void 0) {
|
|
2062
|
-
const { resolveStaleMVOnRead } = await import("./stale-
|
|
2213
|
+
const { resolveStaleMVOnRead } = await import("./stale-UBLP3RJ3.js");
|
|
2063
2214
|
await resolveStaleMVOnRead(this.materializedViewSource, this.name);
|
|
2064
2215
|
}
|
|
2065
2216
|
await this.ensureHydrated();
|
|
@@ -2235,7 +2386,8 @@ var Collection = class {
|
|
|
2235
2386
|
// fields. The Query builder consults these when present and falls
|
|
2236
2387
|
// back to a linear scan otherwise.
|
|
2237
2388
|
getIndexes: () => this.getIndexes(),
|
|
2238
|
-
lookupById: (id) => this.cache.get(id)?.record
|
|
2389
|
+
lookupById: (id) => this.cache.get(id)?.record,
|
|
2390
|
+
...this.moneyFields ? { moneyFields: this.moneyFields } : {}
|
|
2239
2391
|
};
|
|
2240
2392
|
const resolver = this.joinResolver;
|
|
2241
2393
|
const leftCollection = this.name;
|
|
@@ -2917,10 +3069,14 @@ var Collection = class {
|
|
|
2917
3069
|
async applyLocaleToRecord(record, localeOpts) {
|
|
2918
3070
|
const hasI18n = this.i18nFields && Object.keys(this.i18nFields).length > 0;
|
|
2919
3071
|
const hasDict = this.dictKeyFields && Object.keys(this.dictKeyFields).length > 0;
|
|
2920
|
-
|
|
3072
|
+
const hasMoney = this.moneyFields && Object.keys(this.moneyFields).length > 0;
|
|
3073
|
+
if (!hasI18n && !hasDict && !hasMoney) return record;
|
|
2921
3074
|
const locale = localeOpts?.locale ?? this.defaultLocale;
|
|
2922
|
-
if (!locale) return record;
|
|
2923
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;
|
|
2924
3080
|
if (hasI18n && this.i18nFields) {
|
|
2925
3081
|
result = this.i18nStrategy.applyI18nLocale(result, this.i18nFields, locale, localeOpts?.fallback);
|
|
2926
3082
|
}
|
|
@@ -3616,6 +3772,165 @@ function valuesMatch(stored, live) {
|
|
|
3616
3772
|
}
|
|
3617
3773
|
}
|
|
3618
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
|
+
|
|
3619
3934
|
// src/shadow/strategy.ts
|
|
3620
3935
|
var NOT_ENABLED2 = new Error(
|
|
3621
3936
|
'VaultFrame requires the shadow strategy. Import `{ withShadow }` from "@noy-db/hub/shadow" and pass it to `createNoydb({ shadowStrategy: withShadow() })`.'
|
|
@@ -4726,6 +5041,10 @@ var Vault = class {
|
|
|
4726
5041
|
* call throws with a pointer at `@noy-db/hub/blobs`.
|
|
4727
5042
|
*/
|
|
4728
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();
|
|
4729
5048
|
indexStrategy;
|
|
4730
5049
|
aggregateStrategy;
|
|
4731
5050
|
crdtStrategy;
|
|
@@ -4829,6 +5148,8 @@ var Vault = class {
|
|
|
4829
5148
|
* docstring.
|
|
4830
5149
|
*/
|
|
4831
5150
|
ledgerStore = null;
|
|
5151
|
+
/** Lazily-built atomic-sequence store. See {@link sequence}. */
|
|
5152
|
+
sequenceStore = null;
|
|
4832
5153
|
/**
|
|
4833
5154
|
* Background writes for persisted-schema envelopes (#schema-dump v0
|
|
4834
5155
|
* slice 1). One promise per `collection({ persistJsonSchema: true })`
|
|
@@ -4930,6 +5251,7 @@ var Vault = class {
|
|
|
4930
5251
|
this.onRegisterConflictResolver = opts.onRegisterConflictResolver;
|
|
4931
5252
|
this.syncAdapter = opts.syncAdapter;
|
|
4932
5253
|
this.blobStrategy = opts.blobStrategy;
|
|
5254
|
+
this.archiveStrategy = opts.archiveStrategy;
|
|
4933
5255
|
this.indexStrategy = opts.indexStrategy;
|
|
4934
5256
|
this.aggregateStrategy = opts.aggregateStrategy;
|
|
4935
5257
|
this.crdtStrategy = opts.crdtStrategy;
|
|
@@ -4992,8 +5314,9 @@ var Vault = class {
|
|
|
4992
5314
|
*. `put()` validates keys against the declared set; reads
|
|
4993
5315
|
* with `{ locale }` add `<field>Label` virtual fields.
|
|
4994
5316
|
*
|
|
4995
|
-
* Throws `ReservedCollectionNameError` for names starting with `_dict_
|
|
4996
|
-
* 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.
|
|
4997
5320
|
*
|
|
4998
5321
|
* Lazy mode + indexes is rejected at construction time — see the
|
|
4999
5322
|
* Collection constructor for the rationale.
|
|
@@ -5012,7 +5335,16 @@ var Vault = class {
|
|
|
5012
5335
|
if (isDictCollectionName(collectionName)) {
|
|
5013
5336
|
throw new ReservedCollectionNameError(collectionName);
|
|
5014
5337
|
}
|
|
5338
|
+
if (collectionName === SEQUENCE_COLLECTION) {
|
|
5339
|
+
throw new ReservedCollectionNameError(collectionName);
|
|
5340
|
+
}
|
|
5015
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
|
+
}
|
|
5016
5348
|
if (!coll) {
|
|
5017
5349
|
if (options?.refs) {
|
|
5018
5350
|
this.refRegistry.register(collectionName, options.refs);
|
|
@@ -5023,6 +5355,9 @@ var Vault = class {
|
|
|
5023
5355
|
if (options?.blobFields) {
|
|
5024
5356
|
this.blobFieldsRegistry.set(collectionName, options.blobFields);
|
|
5025
5357
|
}
|
|
5358
|
+
if (options?.archive) {
|
|
5359
|
+
this.archiveRegistry.set(collectionName, options.archive);
|
|
5360
|
+
}
|
|
5026
5361
|
if (options?.attestation !== void 0) {
|
|
5027
5362
|
this.attestationRegistry.set(collectionName, options.attestation);
|
|
5028
5363
|
}
|
|
@@ -5138,6 +5473,8 @@ var Vault = class {
|
|
|
5138
5473
|
collOpts.onCrossTierAccess = (event) => this.emitCrossTier(event);
|
|
5139
5474
|
if (this.syncAdapter !== void 0) collOpts.syncAdapter = this.syncAdapter;
|
|
5140
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;
|
|
5141
5478
|
if (options?.dictKeyFields !== void 0) {
|
|
5142
5479
|
collOpts.dictLabelResolver = async (dictName, key, locale, fallback) => {
|
|
5143
5480
|
const handle = this.dictionary(dictName);
|
|
@@ -5557,6 +5894,33 @@ var Vault = class {
|
|
|
5557
5894
|
* await vault.compact({ maxEvictions: 1000 }) // cap batch
|
|
5558
5895
|
* ```
|
|
5559
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
|
+
}
|
|
5560
5924
|
async compact(options = {}) {
|
|
5561
5925
|
return runCompaction({
|
|
5562
5926
|
adapter: this.adapter,
|
|
@@ -5581,6 +5945,48 @@ var Vault = class {
|
|
|
5581
5945
|
}
|
|
5582
5946
|
}, options);
|
|
5583
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
|
+
}
|
|
5584
5990
|
exportBlobs(options = {}) {
|
|
5585
5991
|
this.assertCanExport("plaintext", "blob");
|
|
5586
5992
|
return createExportBlobsHandle(
|
|
@@ -5596,12 +6002,12 @@ var Vault = class {
|
|
|
5596
6002
|
if (!fieldSchema) {
|
|
5597
6003
|
throw new AttestationError(`issueAttestation: collection '${collectionName}' has no attestation field-schema. Declare it via vault.collection('${collectionName}', { attestation: { fields: [...] } }).`);
|
|
5598
6004
|
}
|
|
5599
|
-
const { issueAttestationCore } = await import("./issue-
|
|
6005
|
+
const { issueAttestationCore } = await import("./issue-YIYG4OW5.js");
|
|
5600
6006
|
const out = await issueAttestationCore(this.makeIssueContext(), { collection: collectionName, id, fieldSchema });
|
|
5601
6007
|
return { docId: out.docId, qr: out.qr, keyId: out.keyId, publicKeyB64: out.publicKeyB64 };
|
|
5602
6008
|
}
|
|
5603
6009
|
async getDocumentSigningPublicKey() {
|
|
5604
|
-
const { loadSigner, loadOrCreateSigner } = await import("./signer-
|
|
6010
|
+
const { loadSigner, loadOrCreateSigner } = await import("./signer-6JF44I4A.js");
|
|
5605
6011
|
const existing = await loadSigner(this.adapter, this.name, this.getDEK);
|
|
5606
6012
|
if (existing) return { keyId: existing.keyId, publicKeyB64: existing.publicKeyB64 };
|
|
5607
6013
|
if (this.keyring.role !== "owner") {
|
|
@@ -5627,19 +6033,19 @@ var Vault = class {
|
|
|
5627
6033
|
};
|
|
5628
6034
|
}
|
|
5629
6035
|
async revokeAttestation(docId) {
|
|
5630
|
-
const { revokeDocCore } = await import("./revoke-
|
|
6036
|
+
const { revokeDocCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5631
6037
|
await revokeDocCore(this.makeRevokeContext(), docId);
|
|
5632
6038
|
}
|
|
5633
6039
|
async unrevokeAttestation(docId) {
|
|
5634
|
-
const { unrevokeDocCore } = await import("./revoke-
|
|
6040
|
+
const { unrevokeDocCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5635
6041
|
await unrevokeDocCore(this.makeRevokeContext(), docId);
|
|
5636
6042
|
}
|
|
5637
6043
|
async getRevokedDocIds() {
|
|
5638
|
-
const { getRevokedDocIdsCore } = await import("./revoke-
|
|
6044
|
+
const { getRevokedDocIdsCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5639
6045
|
return getRevokedDocIdsCore(this.makeRevokeContext());
|
|
5640
6046
|
}
|
|
5641
6047
|
async publishRevocationList() {
|
|
5642
|
-
const { publishRevocationListCore } = await import("./revoke-
|
|
6048
|
+
const { publishRevocationListCore } = await import("./revoke-7RLGQWZ7.js");
|
|
5643
6049
|
return publishRevocationListCore(this.makeRevokeContext());
|
|
5644
6050
|
}
|
|
5645
6051
|
makeRevokeContext() {
|
|
@@ -5956,7 +6362,7 @@ var Vault = class {
|
|
|
5956
6362
|
async _initDerivations(handles) {
|
|
5957
6363
|
if (handles.length === 0) return;
|
|
5958
6364
|
const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
|
|
5959
|
-
import("./registry-
|
|
6365
|
+
import("./registry-JLP3QOLD.js"),
|
|
5960
6366
|
import("./read-only-facade-ITU6L7BL.js")
|
|
5961
6367
|
]);
|
|
5962
6368
|
const registry = new DerivationRegistry();
|
|
@@ -5987,7 +6393,7 @@ var Vault = class {
|
|
|
5987
6393
|
*/
|
|
5988
6394
|
async _initMaterializedViews(handles) {
|
|
5989
6395
|
if (handles.length === 0) return;
|
|
5990
|
-
const { MaterializedViewRegistry } = await import("./registry-
|
|
6396
|
+
const { MaterializedViewRegistry } = await import("./registry-NCY445U5.js");
|
|
5991
6397
|
const registry = new MaterializedViewRegistry();
|
|
5992
6398
|
this.materializedViewRegistry = registry;
|
|
5993
6399
|
const db = this;
|
|
@@ -6011,7 +6417,7 @@ var Vault = class {
|
|
|
6011
6417
|
*/
|
|
6012
6418
|
async _initOverlayedViews(handles) {
|
|
6013
6419
|
if (handles.length === 0) return;
|
|
6014
|
-
const { OverlayedViewRegistry } = await import("./registry-
|
|
6420
|
+
const { OverlayedViewRegistry } = await import("./registry-BVQ5ITMF.js");
|
|
6015
6421
|
const registry = new OverlayedViewRegistry();
|
|
6016
6422
|
const mvRegistry = this.materializedViewRegistry;
|
|
6017
6423
|
const overlayNames = /* @__PURE__ */ new Set();
|
|
@@ -6058,13 +6464,13 @@ var Vault = class {
|
|
|
6058
6464
|
if (!reg) {
|
|
6059
6465
|
throw new Error(`refreshView: no MV registered with name "${name}"`);
|
|
6060
6466
|
}
|
|
6061
|
-
const { MaterializedViewExecutor } = await import("./executor-
|
|
6467
|
+
const { MaterializedViewExecutor } = await import("./executor-O5AZK7UW.js");
|
|
6062
6468
|
const result = await MaterializedViewExecutor.refresh(reg, {
|
|
6063
6469
|
getCollection: (n) => this.collection(n),
|
|
6064
6470
|
getActiveTxContext: () => this.noydb._activeTxContextOrNull,
|
|
6065
6471
|
getQueryContext: () => this
|
|
6066
6472
|
});
|
|
6067
|
-
const { clearMVStale } = await import("./stale-
|
|
6473
|
+
const { clearMVStale } = await import("./stale-UBLP3RJ3.js");
|
|
6068
6474
|
clearMVStale(registry, name);
|
|
6069
6475
|
return result;
|
|
6070
6476
|
}
|
|
@@ -6080,7 +6486,7 @@ var Vault = class {
|
|
|
6080
6486
|
if (registry === null) return { derived: 0, failed: 0 };
|
|
6081
6487
|
const strategies = registry.strategiesForSource(sourceCollection);
|
|
6082
6488
|
if (strategies.length === 0) return { derived: 0, failed: 0 };
|
|
6083
|
-
const { DerivationExecutor } = await import("./executor-
|
|
6489
|
+
const { DerivationExecutor } = await import("./executor-D2QMNGRJ.js");
|
|
6084
6490
|
const sourceColl = this.collection(sourceCollection);
|
|
6085
6491
|
const records = await sourceColl.list();
|
|
6086
6492
|
const ctx = { vault: this.readOnlyFacade ?? new (await import("./read-only-facade-ITU6L7BL.js")).ReadOnlyVaultFacade(this) };
|
|
@@ -6105,7 +6511,7 @@ var Vault = class {
|
|
|
6105
6511
|
if (!outSpec) continue;
|
|
6106
6512
|
const outputColl = this.collection(outSpec.collection);
|
|
6107
6513
|
if (out.kind === "array") {
|
|
6108
|
-
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-
|
|
6514
|
+
const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-ZSKEQ6NI.js");
|
|
6109
6515
|
const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key);
|
|
6110
6516
|
const prevKeys = new Set(prior?.keys ?? []);
|
|
6111
6517
|
const newKeysList = out.entries.map((e) => e.key);
|
|
@@ -6326,7 +6732,7 @@ var Vault = class {
|
|
|
6326
6732
|
* collection.
|
|
6327
6733
|
*/
|
|
6328
6734
|
async delegate(opts) {
|
|
6329
|
-
const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-
|
|
6735
|
+
const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-6FCWDRUS.js");
|
|
6330
6736
|
if (!this.keyring.kek) {
|
|
6331
6737
|
throw new ValidationError(
|
|
6332
6738
|
"issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (passphrase) first."
|
|
@@ -6348,7 +6754,7 @@ var Vault = class {
|
|
|
6348
6754
|
* if the id does not exist.
|
|
6349
6755
|
*/
|
|
6350
6756
|
async revokeDelegation(id) {
|
|
6351
|
-
const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-
|
|
6757
|
+
const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-6FCWDRUS.js");
|
|
6352
6758
|
await revokeDelegation(this.adapter, this.name, id);
|
|
6353
6759
|
void DELEGATIONS_COLLECTION;
|
|
6354
6760
|
}
|
|
@@ -6817,7 +7223,7 @@ var Vault = class {
|
|
|
6817
7223
|
* @see docs/subsystems/public-envelope.md
|
|
6818
7224
|
*/
|
|
6819
7225
|
async getPublicEnvelope(opts = {}) {
|
|
6820
|
-
const { readPublicEnvelope: readPublicEnvelope2 } = await import("./public-envelope-
|
|
7226
|
+
const { readPublicEnvelope: readPublicEnvelope2 } = await import("./public-envelope-PFLZI5MO.js");
|
|
6821
7227
|
return readPublicEnvelope2(this.adapter, this.name, opts);
|
|
6822
7228
|
}
|
|
6823
7229
|
/**
|
|
@@ -6842,7 +7248,7 @@ var Vault = class {
|
|
|
6842
7248
|
}
|
|
6843
7249
|
}
|
|
6844
7250
|
const internalSnapshot = {};
|
|
6845
|
-
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]) {
|
|
6846
7252
|
const ids = await this.adapter.list(this.name, internalName);
|
|
6847
7253
|
if (ids.length === 0) continue;
|
|
6848
7254
|
const records = {};
|
|
@@ -8359,6 +8765,7 @@ var Noydb = class {
|
|
|
8359
8765
|
writeRelay;
|
|
8360
8766
|
/** Per-vault policy enforcers. */
|
|
8361
8767
|
policyEnforcers = /* @__PURE__ */ new Map();
|
|
8768
|
+
vaultTemplates = /* @__PURE__ */ new Map();
|
|
8362
8769
|
txStrategy;
|
|
8363
8770
|
sessionStrategy;
|
|
8364
8771
|
syncStrategy;
|
|
@@ -8426,9 +8833,9 @@ var Noydb = class {
|
|
|
8426
8833
|
if (!facade) return;
|
|
8427
8834
|
const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
|
|
8428
8835
|
await registry.runChecks(e.collection, incoming, ctx);
|
|
8429
|
-
const { GuardExecutor } = await import("./executor-
|
|
8836
|
+
const { GuardExecutor } = await import("./executor-7KSCEIFA.js");
|
|
8430
8837
|
for (const g of guards) {
|
|
8431
|
-
await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming);
|
|
8838
|
+
await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
|
|
8432
8839
|
}
|
|
8433
8840
|
});
|
|
8434
8841
|
this.subsystemBus.registerGate("beforeDelete", async (e) => {
|
|
@@ -8607,6 +9014,7 @@ var Noydb = class {
|
|
|
8607
9014
|
syncAdapter: targets.length > 0 ? targets[0].store : void 0,
|
|
8608
9015
|
historyConfig: this.options.history,
|
|
8609
9016
|
...this.options.blobStrategy !== void 0 ? { blobStrategy: this.options.blobStrategy } : {},
|
|
9017
|
+
...this.options.archiveStrategy !== void 0 ? { archiveStrategy: this.options.archiveStrategy } : {},
|
|
8610
9018
|
...this.options.indexStrategy !== void 0 ? { indexStrategy: this.options.indexStrategy } : {},
|
|
8611
9019
|
...this.options.aggregateStrategy !== void 0 ? { aggregateStrategy: this.options.aggregateStrategy } : {},
|
|
8612
9020
|
...this.options.crdtStrategy !== void 0 ? { crdtStrategy: this.options.crdtStrategy } : {},
|
|
@@ -8660,6 +9068,7 @@ var Noydb = class {
|
|
|
8660
9068
|
emitter: this.emitter,
|
|
8661
9069
|
historyConfig: this.options.history,
|
|
8662
9070
|
...this.options.blobStrategy !== void 0 ? { blobStrategy: this.options.blobStrategy } : {},
|
|
9071
|
+
...this.options.archiveStrategy !== void 0 ? { archiveStrategy: this.options.archiveStrategy } : {},
|
|
8663
9072
|
...this.options.indexStrategy !== void 0 ? { indexStrategy: this.options.indexStrategy } : {},
|
|
8664
9073
|
...this.options.aggregateStrategy !== void 0 ? { aggregateStrategy: this.options.aggregateStrategy } : {},
|
|
8665
9074
|
...this.options.crdtStrategy !== void 0 ? { crdtStrategy: this.options.crdtStrategy } : {},
|
|
@@ -8688,6 +9097,7 @@ var Noydb = class {
|
|
|
8688
9097
|
encrypted: true,
|
|
8689
9098
|
historyConfig: this.options.history,
|
|
8690
9099
|
...this.options.blobStrategy !== void 0 ? { blobStrategy: this.options.blobStrategy } : {},
|
|
9100
|
+
...this.options.archiveStrategy !== void 0 ? { archiveStrategy: this.options.archiveStrategy } : {},
|
|
8691
9101
|
...this.options.indexStrategy !== void 0 ? { indexStrategy: this.options.indexStrategy } : {},
|
|
8692
9102
|
...this.options.aggregateStrategy !== void 0 ? { aggregateStrategy: this.options.aggregateStrategy } : {},
|
|
8693
9103
|
...this.options.crdtStrategy !== void 0 ? { crdtStrategy: this.options.crdtStrategy } : {},
|
|
@@ -9002,6 +9412,32 @@ var Noydb = class {
|
|
|
9002
9412
|
}
|
|
9003
9413
|
return results;
|
|
9004
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
|
+
}
|
|
9005
9441
|
/**
|
|
9006
9442
|
* Change the current user's passphrase for a vault.
|
|
9007
9443
|
*
|
|
@@ -10493,6 +10929,8 @@ function normalizeSyncTargets(sync) {
|
|
|
10493
10929
|
}
|
|
10494
10930
|
|
|
10495
10931
|
export {
|
|
10932
|
+
withArchive,
|
|
10933
|
+
SequenceStore,
|
|
10496
10934
|
validateSchemaInput,
|
|
10497
10935
|
validateSchemaOutput,
|
|
10498
10936
|
isZodSchema,
|
|
@@ -10512,6 +10950,8 @@ export {
|
|
|
10512
10950
|
diagramAuthConfig,
|
|
10513
10951
|
describeUserAuth,
|
|
10514
10952
|
describeAllUsersAuth,
|
|
10953
|
+
ComputedFieldError,
|
|
10954
|
+
evalComputedFields,
|
|
10515
10955
|
Lru,
|
|
10516
10956
|
parseBytes,
|
|
10517
10957
|
estimateRecordBytes,
|
|
@@ -10528,4 +10968,4 @@ export {
|
|
|
10528
10968
|
Noydb,
|
|
10529
10969
|
createNoydb
|
|
10530
10970
|
};
|
|
10531
|
-
//# sourceMappingURL=chunk-
|
|
10971
|
+
//# sourceMappingURL=chunk-TMHJEYW7.js.map
|