@noy-db/hub 0.1.0-pre.9 → 0.2.0-pre.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate/index.cjs +100 -36
- 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 +16 -9
- package/dist/aggregate/index.js.map +1 -1
- package/dist/attestation/index.cjs +305 -0
- package/dist/attestation/index.cjs.map +1 -0
- package/dist/attestation/index.d.cts +52 -0
- package/dist/attestation/index.d.ts +52 -0
- package/dist/attestation/index.js +36 -0
- package/dist/attestation/index.js.map +1 -0
- package/dist/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +7 -6
- package/dist/blobs/index.d.ts +7 -6
- package/dist/blobs/index.js +10 -8
- package/dist/blobs/index.js.map +1 -1
- package/dist/bundle/index.cjs +19121 -60
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +175 -6
- package/dist/bundle/index.d.ts +175 -6
- package/dist/bundle/index.js +543 -4
- package/dist/bundle/index.js.map +1 -1
- package/dist/chunk-26NK23DZ.js +296 -0
- package/dist/chunk-26NK23DZ.js.map +1 -0
- package/dist/{chunk-TDR6T5CJ.js → chunk-2LPPNWF6.js} +91 -132
- package/dist/chunk-2LPPNWF6.js.map +1 -0
- package/dist/{chunk-PTVMYYON.js → chunk-2N62W5YP.js} +3 -3
- package/dist/{chunk-QGZRWRSL.js → chunk-3LPV6BXR.js} +4 -4
- package/dist/{chunk-QAVUREFT.js → chunk-4CLICFEY.js} +12 -6
- package/dist/chunk-4CLICFEY.js.map +1 -0
- package/dist/chunk-4USCAEDT.js +10529 -0
- package/dist/chunk-4USCAEDT.js.map +1 -0
- package/dist/chunk-5IXJGFF2.js +83 -0
- package/dist/chunk-5IXJGFF2.js.map +1 -0
- package/dist/chunk-5OEJ6GOT.js +124 -0
- package/dist/chunk-5OEJ6GOT.js.map +1 -0
- package/dist/{chunk-4PWAI7Q4.js → chunk-5OX6XVNS.js} +5 -5
- package/dist/{chunk-2CSJGFCB.js → chunk-6EOXTJS2.js} +6 -229
- package/dist/chunk-6EOXTJS2.js.map +1 -0
- package/dist/chunk-6T2UDBKG.js +53 -0
- package/dist/chunk-6T2UDBKG.js.map +1 -0
- package/dist/{chunk-GOUT6DND.js → chunk-6YLPHBKR.js} +382 -95
- package/dist/chunk-6YLPHBKR.js.map +1 -0
- package/dist/chunk-7CEGU63S.js +179 -0
- package/dist/chunk-7CEGU63S.js.map +1 -0
- package/dist/chunk-A3JMGXPG.js +125 -0
- package/dist/chunk-A3JMGXPG.js.map +1 -0
- package/dist/chunk-BB27JMWB.js +795 -0
- package/dist/chunk-BB27JMWB.js.map +1 -0
- package/dist/{chunk-SCZXXXU4.js → chunk-BDV7INMP.js} +7 -32
- package/dist/chunk-BDV7INMP.js.map +1 -0
- package/dist/chunk-C3WE6UJY.js +19 -0
- package/dist/chunk-C3WE6UJY.js.map +1 -0
- package/dist/chunk-CH22FZHT.js +96 -0
- package/dist/chunk-CH22FZHT.js.map +1 -0
- package/dist/chunk-CXFOITNS.js +34 -0
- package/dist/chunk-CXFOITNS.js.map +1 -0
- package/dist/chunk-CXJG63MA.js +109 -0
- package/dist/chunk-CXJG63MA.js.map +1 -0
- package/dist/chunk-DAP2XL7Q.js +51 -0
- package/dist/chunk-DAP2XL7Q.js.map +1 -0
- package/dist/{chunk-AVVPZ4BC.js → chunk-DJRWA3Q5.js} +4 -4
- package/dist/chunk-DRXIZOFV.js +233 -0
- package/dist/chunk-DRXIZOFV.js.map +1 -0
- package/dist/chunk-FO3UEG4S.js +313 -0
- package/dist/chunk-FO3UEG4S.js.map +1 -0
- package/dist/chunk-GAUEWM7D.js +147 -0
- package/dist/chunk-GAUEWM7D.js.map +1 -0
- package/dist/{chunk-MDDTIZUO.js → chunk-GNHAC43Q.js} +218 -119
- package/dist/chunk-GNHAC43Q.js.map +1 -0
- package/dist/chunk-HHOO7HGH.js +57 -0
- package/dist/chunk-HHOO7HGH.js.map +1 -0
- package/dist/{chunk-WDM5XGGS.js → chunk-HQSQC2XL.js} +182 -12
- package/dist/chunk-HQSQC2XL.js.map +1 -0
- package/dist/chunk-IMYKDWB4.js +139 -0
- package/dist/chunk-IMYKDWB4.js.map +1 -0
- package/dist/{chunk-M62XNWRA.js → chunk-LSTBFLL2.js} +2 -2
- package/dist/{chunk-ACLDOTNQ.js → chunk-O6EJ6WTI.js} +436 -3
- package/dist/chunk-O6EJ6WTI.js.map +1 -0
- package/dist/chunk-PC6ZEDRL.js +71 -0
- package/dist/chunk-PC6ZEDRL.js.map +1 -0
- package/dist/chunk-PM3QYWUU.js +251 -0
- package/dist/chunk-PM3QYWUU.js.map +1 -0
- package/dist/chunk-PVUUIWHY.js +73 -0
- package/dist/chunk-PVUUIWHY.js.map +1 -0
- package/dist/chunk-PXTQPZO4.js +830 -0
- package/dist/chunk-PXTQPZO4.js.map +1 -0
- package/dist/{chunk-ZFKD4QMV.js → chunk-QSOYKKMD.js} +4 -4
- package/dist/chunk-QSOYKKMD.js.map +1 -0
- package/dist/{chunk-MR4424N3.js → chunk-R233SLY3.js} +2 -2
- package/dist/chunk-RC6SU5NO.js +36 -0
- package/dist/chunk-RC6SU5NO.js.map +1 -0
- package/dist/{chunk-USKYUS74.js → chunk-RRNA5GKT.js} +2 -2
- package/dist/{chunk-R36SIKES.js → chunk-RYIL3PI2.js} +2 -2
- package/dist/chunk-STNPB3UM.js +9 -0
- package/dist/chunk-STNPB3UM.js.map +1 -0
- package/dist/{chunk-M5INGEFC.js → chunk-TV3YZ35S.js} +7 -1
- package/dist/chunk-TV3YZ35S.js.map +1 -0
- package/dist/chunk-TY32C732.js +59 -0
- package/dist/chunk-TY32C732.js.map +1 -0
- package/dist/chunk-UMLVJTYV.js +20 -0
- package/dist/chunk-UMLVJTYV.js.map +1 -0
- package/dist/{chunk-NPC4LFV5.js → chunk-WIBHRONM.js} +2 -2
- package/dist/chunk-WIBHRONM.js.map +1 -0
- package/dist/{chunk-RKJ6OL7K.js → chunk-WIRRPTFH.js} +1 -1
- package/dist/chunk-WIRRPTFH.js.map +1 -0
- package/dist/{chunk-VQBTTTUN.js → chunk-Y26YV5R3.js} +4 -4
- package/dist/{chunk-VQBTTTUN.js.map → chunk-Y26YV5R3.js.map} +1 -1
- package/dist/{chunk-NXFEYLVG.js → chunk-YM7LFCG7.js} +5 -4
- package/dist/{chunk-NXFEYLVG.js.map → chunk-YM7LFCG7.js.map} +1 -1
- package/dist/{chunk-CIMZBAZB.js → chunk-Z6FNBOTC.js} +1 -1
- package/dist/chunk-Z6FNBOTC.js.map +1 -0
- package/dist/chunk-ZROPXHJY.js +82 -0
- package/dist/chunk-ZROPXHJY.js.map +1 -0
- package/dist/consent/index.cjs.map +1 -1
- package/dist/consent/index.d.cts +7 -6
- package/dist/consent/index.d.ts +7 -6
- package/dist/consent/index.js +3 -3
- package/dist/{crypto-IVKU7YTT.js → crypto-2CRLG4F4.js} +3 -3
- package/dist/{delegation-2DBS2EOH.js → delegation-ZTRT2PRV.js} +5 -4
- package/dist/derivations/index.cjs +368 -0
- package/dist/derivations/index.cjs.map +1 -0
- package/dist/derivations/index.d.cts +72 -0
- package/dist/derivations/index.d.ts +72 -0
- package/dist/derivations/index.js +27 -0
- package/dist/{dev-unlock-Da1B0TIK.d.cts → dev-unlock-AglVnkPY.d.cts} +1 -1
- package/dist/{dev-unlock-BdPp68qn.d.ts → dev-unlock-BOEYl1xl.d.ts} +1 -1
- package/dist/discriminant-BN9REW3o.d.cts +60 -0
- package/dist/discriminant-BN9REW3o.d.ts +60 -0
- package/dist/executor-S76VN45G.js +8 -0
- package/dist/executor-UCXLIGLW.js +11 -0
- package/dist/executor-UCXLIGLW.js.map +1 -0
- package/dist/executor-ZCNZJMGR.js +8 -0
- package/dist/executor-ZCNZJMGR.js.map +1 -0
- package/dist/fanout-sidecar-OKPMMPLG.js +51 -0
- package/dist/fanout-sidecar-OKPMMPLG.js.map +1 -0
- package/dist/guards/index.cjs +322 -0
- package/dist/guards/index.cjs.map +1 -0
- package/dist/guards/index.d.cts +31 -0
- package/dist/guards/index.d.ts +31 -0
- package/dist/guards/index.js +29 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/{hash-lsoL3eEW.d.ts → hash-B9m3_fhj.d.ts} +1 -1
- package/dist/{hash-BEfzPKwo.d.cts → hash-RVqz2zi8.d.cts} +1 -1
- package/dist/history/index.cjs +9 -2
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +8 -7
- package/dist/history/index.d.ts +8 -7
- package/dist/history/index.js +6 -6
- package/dist/i18n/index.cjs +368 -27
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +7 -6
- package/dist/i18n/index.d.ts +7 -6
- package/dist/i18n/index.js +34 -6
- package/dist/i18n/index.js.map +1 -1
- package/dist/{index-DJTf9yxn.d.ts → index-B8bjExET.d.cts} +508 -14
- package/dist/{index-6xNpPsxR.d.cts → index-DfUbNad8.d.ts} +508 -14
- package/dist/index.cjs +8779 -1260
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +231 -19
- package/dist/index.d.ts +231 -19
- package/dist/index.js +311 -7370
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.cjs +7 -1
- package/dist/indexing/index.cjs.map +1 -1
- package/dist/indexing/index.d.cts +3 -3
- package/dist/indexing/index.d.ts +3 -3
- package/dist/indexing/index.js +4 -4
- package/dist/issue-3W6IVLKH.js +12 -0
- package/dist/issue-3W6IVLKH.js.map +1 -0
- package/dist/{lazy-builder-BwEoBQZ9.d.ts → lazy-builder-Ci5_YG73.d.cts} +2 -2
- package/dist/{lazy-builder-CZVLKh0Z.d.cts → lazy-builder-D5GU14TS.d.ts} +2 -2
- package/dist/{ledger-QZTTHQAQ.js → ledger-O7FXOG3D.js} +6 -6
- package/dist/ledger-O7FXOG3D.js.map +1 -0
- package/dist/materialized-views/index.cjs +856 -0
- package/dist/materialized-views/index.cjs.map +1 -0
- package/dist/materialized-views/index.d.cts +186 -0
- package/dist/materialized-views/index.d.ts +186 -0
- package/dist/materialized-views/index.js +45 -0
- package/dist/materialized-views/index.js.map +1 -0
- package/dist/noydb-YAZNH5TI.js +34 -0
- package/dist/noydb-YAZNH5TI.js.map +1 -0
- package/dist/overlay-views/index.cjs +369 -0
- package/dist/overlay-views/index.cjs.map +1 -0
- package/dist/overlay-views/index.d.cts +82 -0
- package/dist/overlay-views/index.d.ts +82 -0
- package/dist/overlay-views/index.js +25 -0
- package/dist/overlay-views/index.js.map +1 -0
- package/dist/periods/index.cjs +7 -1
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +7 -6
- package/dist/periods/index.d.ts +7 -6
- package/dist/periods/index.js +6 -6
- package/dist/{predicate-SBHmi6D0.d.cts → predicate-Bt5ft-9c.d.cts} +51 -2
- package/dist/{predicate-SBHmi6D0.d.ts → predicate-Bt5ft-9c.d.ts} +51 -2
- package/dist/{public-envelope-6JTACYJV.js → public-envelope-HMYHZIRH.js} +4 -4
- package/dist/public-envelope-HMYHZIRH.js.map +1 -0
- package/dist/query/index.cjs +555 -128
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +3 -3
- package/dist/query/index.d.ts +3 -3
- package/dist/query/index.js +32 -11
- package/dist/read-only-facade-ITU6L7BL.js +7 -0
- package/dist/read-only-facade-ITU6L7BL.js.map +1 -0
- package/dist/registry-DKEXOJVO.js +7 -0
- package/dist/registry-DKEXOJVO.js.map +1 -0
- package/dist/registry-ST2VNFZC.js +10 -0
- package/dist/registry-ST2VNFZC.js.map +1 -0
- package/dist/registry-UFIK7CSR.js +8 -0
- package/dist/registry-UFIK7CSR.js.map +1 -0
- package/dist/registry-ZGYYSM5I.js +8 -0
- package/dist/registry-ZGYYSM5I.js.map +1 -0
- package/dist/revoke-S6JMSLUN.js +17 -0
- package/dist/revoke-S6JMSLUN.js.map +1 -0
- package/dist/session/index.cjs +7 -1
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +8 -7
- package/dist/session/index.d.ts +8 -7
- package/dist/session/index.js +10 -3
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.cjs.map +1 -1
- package/dist/shadow/index.d.cts +7 -6
- package/dist/shadow/index.d.ts +7 -6
- package/dist/shadow/index.js +2 -2
- package/dist/signer-7NPTB3SQ.js +18 -0
- package/dist/signer-7NPTB3SQ.js.map +1 -0
- package/dist/snapshots/index.cjs +937 -0
- package/dist/snapshots/index.cjs.map +1 -0
- package/dist/snapshots/index.d.cts +28 -0
- package/dist/snapshots/index.d.ts +28 -0
- package/dist/snapshots/index.js +152 -0
- package/dist/snapshots/index.js.map +1 -0
- package/dist/stale-VKXSXJF4.js +13 -0
- package/dist/stale-VKXSXJF4.js.map +1 -0
- package/dist/store/index.cjs +14 -0
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +7 -6
- package/dist/store/index.d.ts +7 -6
- package/dist/store/index.js +5 -2
- package/dist/{strategy-D-SrOLCl.d.ts → strategy-CT2LCKAX.d.cts} +84 -19
- package/dist/{strategy-D-SrOLCl.d.cts → strategy-CT2LCKAX.d.ts} +84 -19
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +6 -5
- package/dist/sync/index.d.ts +6 -5
- package/dist/sync/index.js +4 -4
- package/dist/team/index.cjs +1554 -2
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +7 -6
- package/dist/team/index.d.ts +7 -6
- package/dist/team/index.js +77 -8
- package/dist/tx/index.cjs +375 -43
- package/dist/tx/index.cjs.map +1 -1
- package/dist/tx/index.d.cts +8 -7
- package/dist/tx/index.d.ts +8 -7
- package/dist/tx/index.js +56 -3
- package/dist/tx/index.js.map +1 -1
- package/dist/{types-Bo7NSXJr.d.ts → types-CaNQm4i8.d.ts} +3902 -614
- package/dist/{types-Bnb82f5R.d.cts → types-n2_IfwlQ.d.cts} +3902 -614
- package/dist/{index-CywCC1qZ.d.cts → ulid-B9SMWj5i.d.ts} +216 -27
- package/dist/{index-8QDuznDr.d.ts → ulid-CLMjmyhG.d.cts} +216 -27
- package/dist/util/index.cjs +7 -0
- package/dist/util/index.cjs.map +1 -1
- package/dist/util/index.d.cts +2 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +5 -1
- package/dist/util/index.js.map +1 -1
- package/dist/with-derivation-CVIOPTUf.d.ts +13 -0
- package/dist/with-derivation-aKrtS7Jj.d.cts +13 -0
- package/dist/with-guard-DZQbPzoP.d.cts +18 -0
- package/dist/with-guard-DseETUrF.d.ts +18 -0
- package/dist/with-materialized-view-C1eA1_T_.d.cts +27 -0
- package/dist/with-materialized-view-DaYaE8-Q.d.ts +27 -0
- package/dist/with-overlayed-view-DQsh2p8H.d.ts +13 -0
- package/dist/with-overlayed-view-DleJfKcV.d.cts +13 -0
- package/package.json +77 -3
- package/dist/chunk-2CSJGFCB.js.map +0 -1
- package/dist/chunk-ACLDOTNQ.js.map +0 -1
- package/dist/chunk-BTDCBVJW.js +0 -160
- package/dist/chunk-BTDCBVJW.js.map +0 -1
- package/dist/chunk-CIMZBAZB.js.map +0 -1
- package/dist/chunk-EXHNQEV4.js +0 -392
- package/dist/chunk-EXHNQEV4.js.map +0 -1
- package/dist/chunk-GOUT6DND.js.map +0 -1
- package/dist/chunk-M5INGEFC.js.map +0 -1
- package/dist/chunk-MDDTIZUO.js.map +0 -1
- package/dist/chunk-NPC4LFV5.js.map +0 -1
- package/dist/chunk-QAVUREFT.js.map +0 -1
- package/dist/chunk-RKJ6OL7K.js.map +0 -1
- package/dist/chunk-SCZXXXU4.js.map +0 -1
- package/dist/chunk-TDR6T5CJ.js.map +0 -1
- package/dist/chunk-WDM5XGGS.js.map +0 -1
- package/dist/chunk-ZFKD4QMV.js.map +0 -1
- /package/dist/{chunk-PTVMYYON.js.map → chunk-2N62W5YP.js.map} +0 -0
- /package/dist/{chunk-QGZRWRSL.js.map → chunk-3LPV6BXR.js.map} +0 -0
- /package/dist/{chunk-4PWAI7Q4.js.map → chunk-5OX6XVNS.js.map} +0 -0
- /package/dist/{chunk-AVVPZ4BC.js.map → chunk-DJRWA3Q5.js.map} +0 -0
- /package/dist/{chunk-M62XNWRA.js.map → chunk-LSTBFLL2.js.map} +0 -0
- /package/dist/{chunk-MR4424N3.js.map → chunk-R233SLY3.js.map} +0 -0
- /package/dist/{chunk-USKYUS74.js.map → chunk-RRNA5GKT.js.map} +0 -0
- /package/dist/{chunk-R36SIKES.js.map → chunk-RYIL3PI2.js.map} +0 -0
- /package/dist/{crypto-IVKU7YTT.js.map → crypto-2CRLG4F4.js.map} +0 -0
- /package/dist/{delegation-2DBS2EOH.js.map → delegation-ZTRT2PRV.js.map} +0 -0
- /package/dist/{ledger-QZTTHQAQ.js.map → derivations/index.js.map} +0 -0
- /package/dist/{public-envelope-6JTACYJV.js.map → executor-S76VN45G.js.map} +0 -0
package/dist/team/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import '../lazy-builder-
|
|
4
|
-
import '../predicate-
|
|
5
|
-
import '../strategy-
|
|
1
|
+
import { b3 as NoydbStore, b1 as UnlockedKeyring } from '../types-n2_IfwlQ.cjs';
|
|
2
|
+
export { bt as BundleRecipient, cg as EnrollAuthenticatorOptions, ch as EnrollAuthenticatorWrappingDEKsOptions, ci as EnrollAuthenticatorWrappingKEKOptions, cN as ListUsersOptions, d9 as PaperRecoveryEntry, dh as PresenceHandle, dD as RecoverPassphraseInput, dE as RecoverPassphraseResult, dF as RecoverUserOptions, dG as RecoveryProof, dJ as RotatePassphraseInput, dV as SlotRewrapCeremony, dW as SlotRewrapContext, e1 as SyncEngine, e9 as SyncTransaction, em as UpdateAuthenticatorOptions, eB as WrappedDeksBlob, eH as buildRecipientKeyringFile, eI as burnPaperRecoveryEntry, fr as changeSecret, fs as createOwnerKeyring, eL as deriveMagicLinkContentKey, eM as enrollAuthenticator, ft as ensureCollectionDEK, eO as evaluateExportCapability, eP as evaluateImportCapability, eQ as findAuthenticator, fu as grant, eR as hasExportCapability, eS as hasImportCapability, eU as isMagicLinkGrantExpired, eZ as listMagicLinkGrants, e_ as listUsers, e$ as listUsersWithEnvelopes, fv as loadKeyring, f1 as loadPaperRecoveryEntries, f4 as magicLinkGrantRecordId, f5 as mintPaperRecoveryEntry, f7 as mintWrappedDeksBlob, fw as persistKeyring, f9 as readMagicLinkGrantRecord, eX as recoverPassphrase, fa as recoverUser, fb as removeAuthenticator, fx as revoke, fe as revokeMagicLinkGrant, eY as rotatePassphrase, ff as savePaperRecoveryEntries, fi as unwrapDeksFromBlob, fj as unwrapDeksFromPaperEntry, fl as unwrapMagicLinkGrant, fy as updateAuthenticator, fz as updateKeyringIdentity, fq as writeMagicLinkGrant } from '../types-n2_IfwlQ.cjs';
|
|
3
|
+
import '../lazy-builder-Ci5_YG73.cjs';
|
|
4
|
+
import '../predicate-Bt5ft-9c.cjs';
|
|
5
|
+
import '../strategy-CT2LCKAX.cjs';
|
|
6
6
|
import '../strategy-BSxFXGzb.cjs';
|
|
7
|
-
import '../index-
|
|
7
|
+
import '../index-B8bjExET.cjs';
|
|
8
|
+
import '@noy-db/attestation';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* _sync_credentials reserved collection —
|
package/dist/team/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import '../lazy-builder-
|
|
4
|
-
import '../predicate-
|
|
5
|
-
import '../strategy-
|
|
1
|
+
import { b3 as NoydbStore, b1 as UnlockedKeyring } from '../types-CaNQm4i8.js';
|
|
2
|
+
export { bt as BundleRecipient, cg as EnrollAuthenticatorOptions, ch as EnrollAuthenticatorWrappingDEKsOptions, ci as EnrollAuthenticatorWrappingKEKOptions, cN as ListUsersOptions, d9 as PaperRecoveryEntry, dh as PresenceHandle, dD as RecoverPassphraseInput, dE as RecoverPassphraseResult, dF as RecoverUserOptions, dG as RecoveryProof, dJ as RotatePassphraseInput, dV as SlotRewrapCeremony, dW as SlotRewrapContext, e1 as SyncEngine, e9 as SyncTransaction, em as UpdateAuthenticatorOptions, eB as WrappedDeksBlob, eH as buildRecipientKeyringFile, eI as burnPaperRecoveryEntry, fr as changeSecret, fs as createOwnerKeyring, eL as deriveMagicLinkContentKey, eM as enrollAuthenticator, ft as ensureCollectionDEK, eO as evaluateExportCapability, eP as evaluateImportCapability, eQ as findAuthenticator, fu as grant, eR as hasExportCapability, eS as hasImportCapability, eU as isMagicLinkGrantExpired, eZ as listMagicLinkGrants, e_ as listUsers, e$ as listUsersWithEnvelopes, fv as loadKeyring, f1 as loadPaperRecoveryEntries, f4 as magicLinkGrantRecordId, f5 as mintPaperRecoveryEntry, f7 as mintWrappedDeksBlob, fw as persistKeyring, f9 as readMagicLinkGrantRecord, eX as recoverPassphrase, fa as recoverUser, fb as removeAuthenticator, fx as revoke, fe as revokeMagicLinkGrant, eY as rotatePassphrase, ff as savePaperRecoveryEntries, fi as unwrapDeksFromBlob, fj as unwrapDeksFromPaperEntry, fl as unwrapMagicLinkGrant, fy as updateAuthenticator, fz as updateKeyringIdentity, fq as writeMagicLinkGrant } from '../types-CaNQm4i8.js';
|
|
3
|
+
import '../lazy-builder-D5GU14TS.js';
|
|
4
|
+
import '../predicate-Bt5ft-9c.js';
|
|
5
|
+
import '../strategy-CT2LCKAX.js';
|
|
6
6
|
import '../strategy-BSxFXGzb.js';
|
|
7
|
-
import '../index-
|
|
7
|
+
import '../index-DfUbNad8.js';
|
|
8
|
+
import '@noy-db/attestation';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* _sync_credentials reserved collection —
|
package/dist/team/index.js
CHANGED
|
@@ -5,35 +5,104 @@ import {
|
|
|
5
5
|
getCredential,
|
|
6
6
|
listCredentials,
|
|
7
7
|
putCredential
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-5OX6XVNS.js";
|
|
9
|
+
import {
|
|
10
|
+
burnPaperRecoveryEntry,
|
|
11
|
+
deriveMagicLinkContentKey,
|
|
12
|
+
enrollAuthenticator,
|
|
13
|
+
findAuthenticator,
|
|
14
|
+
isMagicLinkGrantExpired,
|
|
15
|
+
listMagicLinkGrants,
|
|
16
|
+
loadPaperRecoveryEntries,
|
|
17
|
+
magicLinkGrantRecordId,
|
|
18
|
+
mintPaperRecoveryEntry,
|
|
19
|
+
mintWrappedDeksBlob,
|
|
20
|
+
readMagicLinkGrantRecord,
|
|
21
|
+
recoverPassphrase,
|
|
22
|
+
recoverUser,
|
|
23
|
+
removeAuthenticator,
|
|
24
|
+
revokeMagicLinkGrant,
|
|
25
|
+
rotatePassphrase,
|
|
26
|
+
savePaperRecoveryEntries,
|
|
27
|
+
unwrapDeksFromBlob,
|
|
28
|
+
unwrapDeksFromPaperEntry,
|
|
29
|
+
unwrapMagicLinkGrant,
|
|
30
|
+
updateAuthenticator,
|
|
31
|
+
writeMagicLinkGrant
|
|
32
|
+
} from "../chunk-PXTQPZO4.js";
|
|
33
|
+
import "../chunk-CXFOITNS.js";
|
|
9
34
|
import {
|
|
10
35
|
PresenceHandle,
|
|
11
36
|
SyncEngine,
|
|
12
37
|
SyncTransaction
|
|
13
|
-
} from "../chunk-
|
|
38
|
+
} from "../chunk-DJRWA3Q5.js";
|
|
14
39
|
import {
|
|
40
|
+
buildRecipientKeyringFile,
|
|
41
|
+
changeSecret,
|
|
42
|
+
createOwnerKeyring,
|
|
43
|
+
ensureCollectionDEK,
|
|
15
44
|
evaluateExportCapability,
|
|
16
45
|
evaluateImportCapability,
|
|
46
|
+
grant,
|
|
17
47
|
hasExportCapability,
|
|
18
|
-
hasImportCapability
|
|
19
|
-
|
|
48
|
+
hasImportCapability,
|
|
49
|
+
listUsers,
|
|
50
|
+
listUsersWithEnvelopes,
|
|
51
|
+
loadKeyring,
|
|
52
|
+
persistKeyring,
|
|
53
|
+
revoke,
|
|
54
|
+
updateKeyringIdentity
|
|
55
|
+
} from "../chunk-HQSQC2XL.js";
|
|
20
56
|
import "../chunk-2QR2PQTT.js";
|
|
21
|
-
import "../chunk-
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
57
|
+
import "../chunk-WIRRPTFH.js";
|
|
58
|
+
import "../chunk-R233SLY3.js";
|
|
59
|
+
import "../chunk-O6EJ6WTI.js";
|
|
24
60
|
export {
|
|
25
61
|
PresenceHandle,
|
|
26
62
|
SYNC_CREDENTIALS_COLLECTION,
|
|
27
63
|
SyncEngine,
|
|
28
64
|
SyncTransaction,
|
|
65
|
+
buildRecipientKeyringFile,
|
|
66
|
+
burnPaperRecoveryEntry,
|
|
67
|
+
changeSecret,
|
|
68
|
+
createOwnerKeyring,
|
|
29
69
|
credentialStatus,
|
|
30
70
|
deleteCredential,
|
|
71
|
+
deriveMagicLinkContentKey,
|
|
72
|
+
enrollAuthenticator,
|
|
73
|
+
ensureCollectionDEK,
|
|
31
74
|
evaluateExportCapability,
|
|
32
75
|
evaluateImportCapability,
|
|
76
|
+
findAuthenticator,
|
|
33
77
|
getCredential,
|
|
78
|
+
grant,
|
|
34
79
|
hasExportCapability,
|
|
35
80
|
hasImportCapability,
|
|
81
|
+
isMagicLinkGrantExpired,
|
|
36
82
|
listCredentials,
|
|
37
|
-
|
|
83
|
+
listMagicLinkGrants,
|
|
84
|
+
listUsers,
|
|
85
|
+
listUsersWithEnvelopes,
|
|
86
|
+
loadKeyring,
|
|
87
|
+
loadPaperRecoveryEntries,
|
|
88
|
+
magicLinkGrantRecordId,
|
|
89
|
+
mintPaperRecoveryEntry,
|
|
90
|
+
mintWrappedDeksBlob,
|
|
91
|
+
persistKeyring,
|
|
92
|
+
putCredential,
|
|
93
|
+
readMagicLinkGrantRecord,
|
|
94
|
+
recoverPassphrase,
|
|
95
|
+
recoverUser,
|
|
96
|
+
removeAuthenticator,
|
|
97
|
+
revoke,
|
|
98
|
+
revokeMagicLinkGrant,
|
|
99
|
+
rotatePassphrase,
|
|
100
|
+
savePaperRecoveryEntries,
|
|
101
|
+
unwrapDeksFromBlob,
|
|
102
|
+
unwrapDeksFromPaperEntry,
|
|
103
|
+
unwrapMagicLinkGrant,
|
|
104
|
+
updateAuthenticator,
|
|
105
|
+
updateKeyringIdentity,
|
|
106
|
+
writeMagicLinkGrant
|
|
38
107
|
};
|
|
39
108
|
//# sourceMappingURL=index.js.map
|
package/dist/tx/index.cjs
CHANGED
|
@@ -3,6 +3,9 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __esm = (fn, res) => function __init() {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
};
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,6 +20,147 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
20
|
};
|
|
18
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
22
|
|
|
23
|
+
// src/errors.ts
|
|
24
|
+
var NoydbError, FieldFrozenError, InvariantError, AmendmentForbiddenError, ConflictError, ValidationError;
|
|
25
|
+
var init_errors = __esm({
|
|
26
|
+
"src/errors.ts"() {
|
|
27
|
+
"use strict";
|
|
28
|
+
NoydbError = class extends Error {
|
|
29
|
+
/** Machine-readable error code. Stable across library versions. */
|
|
30
|
+
code;
|
|
31
|
+
constructor(code, message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = "NoydbError";
|
|
34
|
+
this.code = code;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
FieldFrozenError = class extends NoydbError {
|
|
38
|
+
collection;
|
|
39
|
+
id;
|
|
40
|
+
fields;
|
|
41
|
+
constructor(collection, id, fields) {
|
|
42
|
+
super(
|
|
43
|
+
"FIELD_FROZEN",
|
|
44
|
+
`Cannot change frozen field(s) on ${collection}/${id}: ${fields.join(", ")}. Use withTransactions({ amendment: true, reason }) with admin/owner role to override.`
|
|
45
|
+
);
|
|
46
|
+
this.name = "FieldFrozenError";
|
|
47
|
+
this.collection = collection;
|
|
48
|
+
this.id = id;
|
|
49
|
+
this.fields = fields;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
InvariantError = class extends NoydbError {
|
|
53
|
+
constructor(message) {
|
|
54
|
+
super("INVARIANT_VIOLATED", message);
|
|
55
|
+
this.name = "InvariantError";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
AmendmentForbiddenError = class extends NoydbError {
|
|
59
|
+
userId;
|
|
60
|
+
role;
|
|
61
|
+
constructor(userId, role) {
|
|
62
|
+
super(
|
|
63
|
+
"AMENDMENT_FORBIDDEN",
|
|
64
|
+
`User "${userId}" with role "${role}" cannot open an amendment transaction. Amendments require admin or owner role.`
|
|
65
|
+
);
|
|
66
|
+
this.name = "AmendmentForbiddenError";
|
|
67
|
+
this.userId = userId;
|
|
68
|
+
this.role = role;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
ConflictError = class extends NoydbError {
|
|
72
|
+
/** The actual stored version at the time of conflict. */
|
|
73
|
+
version;
|
|
74
|
+
constructor(version, message = "Version conflict") {
|
|
75
|
+
super("CONFLICT", message);
|
|
76
|
+
this.name = "ConflictError";
|
|
77
|
+
this.version = version;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
ValidationError = class extends NoydbError {
|
|
81
|
+
constructor(message = "Validation error") {
|
|
82
|
+
super("VALIDATION_ERROR", message);
|
|
83
|
+
this.name = "ValidationError";
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// src/guards/executor.ts
|
|
90
|
+
var executor_exports = {};
|
|
91
|
+
__export(executor_exports, {
|
|
92
|
+
GuardExecutor: () => GuardExecutor
|
|
93
|
+
});
|
|
94
|
+
function deepEqual(a, b) {
|
|
95
|
+
if (a === b) return true;
|
|
96
|
+
if (a === null || b === null) return a === b;
|
|
97
|
+
if (typeof a !== typeof b) return false;
|
|
98
|
+
if (typeof a !== "object") return a === b;
|
|
99
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
100
|
+
if (Array.isArray(a)) {
|
|
101
|
+
const aa = a;
|
|
102
|
+
const bb = b;
|
|
103
|
+
if (aa.length !== bb.length) return false;
|
|
104
|
+
for (let i = 0; i < aa.length; i++) if (!deepEqual(aa[i], bb[i])) return false;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
const ao = a;
|
|
108
|
+
const bo = b;
|
|
109
|
+
const ak = Object.keys(ao);
|
|
110
|
+
const bk = Object.keys(bo);
|
|
111
|
+
if (ak.length !== bk.length) return false;
|
|
112
|
+
for (const k of ak) {
|
|
113
|
+
if (!Object.prototype.hasOwnProperty.call(bo, k)) return false;
|
|
114
|
+
if (!deepEqual(ao[k], bo[k])) return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
var GuardExecutor;
|
|
119
|
+
var init_executor = __esm({
|
|
120
|
+
"src/guards/executor.ts"() {
|
|
121
|
+
"use strict";
|
|
122
|
+
init_errors();
|
|
123
|
+
GuardExecutor = {
|
|
124
|
+
/**
|
|
125
|
+
* Compare existing vs incoming for each `frozenFields.fields` entry
|
|
126
|
+
* when `frozenFields.when(existing)` is true. Throws
|
|
127
|
+
* `FieldFrozenError` listing every changed frozen field.
|
|
128
|
+
*/
|
|
129
|
+
async checkFrozenFields(guard, id, existing, incoming) {
|
|
130
|
+
const ff = guard.frozenFields;
|
|
131
|
+
if (!ff) return;
|
|
132
|
+
if (existing === null) return;
|
|
133
|
+
if (!ff.when(existing)) return;
|
|
134
|
+
const changed = [];
|
|
135
|
+
for (const f of ff.fields) {
|
|
136
|
+
if (existing[f] !== incoming[f]) {
|
|
137
|
+
if (!deepEqual(existing[f], incoming[f])) changed.push(String(f));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (changed.length > 0) {
|
|
141
|
+
throw new FieldFrozenError(guard.collection, id, changed);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* Run a single guard's invariant over its slice of the change-set.
|
|
146
|
+
* Any throw is converted to `InvariantError` unless it already is one.
|
|
147
|
+
*/
|
|
148
|
+
async runInvariant(guard, changes, ctx) {
|
|
149
|
+
const amendment = guard.amendment;
|
|
150
|
+
if (!amendment) return;
|
|
151
|
+
try {
|
|
152
|
+
await amendment.invariant(changes, ctx);
|
|
153
|
+
} catch (err) {
|
|
154
|
+
if (err instanceof InvariantError) throw err;
|
|
155
|
+
throw new InvariantError(
|
|
156
|
+
err instanceof Error ? err.message : `invariant violated: ${String(err)}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
20
164
|
// src/tx/index.ts
|
|
21
165
|
var tx_exports = {};
|
|
22
166
|
__export(tx_exports, {
|
|
@@ -28,39 +172,80 @@ __export(tx_exports, {
|
|
|
28
172
|
});
|
|
29
173
|
module.exports = __toCommonJS(tx_exports);
|
|
30
174
|
|
|
31
|
-
// src/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/** The actual stored version at the time of conflict. */
|
|
43
|
-
version;
|
|
44
|
-
constructor(version, message = "Version conflict") {
|
|
45
|
-
super("CONFLICT", message);
|
|
46
|
-
this.name = "ConflictError";
|
|
47
|
-
this.version = version;
|
|
175
|
+
// src/tx/transaction.ts
|
|
176
|
+
init_errors();
|
|
177
|
+
|
|
178
|
+
// src/bundle/ulid.ts
|
|
179
|
+
var CROCKFORD_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
180
|
+
function encodeBase32(value, length) {
|
|
181
|
+
let out = "";
|
|
182
|
+
let v = value;
|
|
183
|
+
for (let i = 0; i < length; i++) {
|
|
184
|
+
out = CROCKFORD_ALPHABET[v % 32] + out;
|
|
185
|
+
v = Math.floor(v / 32);
|
|
48
186
|
}
|
|
49
|
-
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
function generateULID() {
|
|
190
|
+
const now = Date.now();
|
|
191
|
+
const timestampHigh = Math.floor(now / 16777216);
|
|
192
|
+
const timestampLow = now & 16777215;
|
|
193
|
+
const tsPart = encodeBase32(timestampHigh, 5) + encodeBase32(timestampLow, 5);
|
|
194
|
+
const randBytes = new Uint8Array(10);
|
|
195
|
+
crypto.getRandomValues(randBytes);
|
|
196
|
+
const rand1 = randBytes[0] * 2 ** 32 + (randBytes[1] << 24 >>> 0) + (randBytes[2] << 16) + (randBytes[3] << 8) + randBytes[4];
|
|
197
|
+
const rand2 = randBytes[5] * 2 ** 32 + (randBytes[6] << 24 >>> 0) + (randBytes[7] << 16) + (randBytes[8] << 8) + randBytes[9];
|
|
198
|
+
const randPart = encodeBase32(rand1, 8) + encodeBase32(rand2, 8);
|
|
199
|
+
return tsPart + randPart;
|
|
200
|
+
}
|
|
50
201
|
|
|
51
202
|
// src/tx/transaction.ts
|
|
52
203
|
var TxContext = class {
|
|
204
|
+
/** Stable id for this transaction; shared by all writes it performs. */
|
|
205
|
+
txId = generateULID();
|
|
53
206
|
/** @internal */
|
|
54
207
|
_ops = [];
|
|
208
|
+
/**
|
|
209
|
+
* @internal — write log built up in Phase 2. Each entry records the
|
|
210
|
+
* envelope captured BEFORE the write so a mid-batch failure can
|
|
211
|
+
* restore prior state via `revertExecuted`. Side-effect writes (e.g.
|
|
212
|
+
* recursive derivation outputs fired inside `Collection.put`) are
|
|
213
|
+
* appended here in execution order so they roll back alongside the
|
|
214
|
+
* main staged ops.
|
|
215
|
+
*/
|
|
216
|
+
_executed = [];
|
|
55
217
|
/** @internal */
|
|
56
218
|
_db;
|
|
219
|
+
/**
|
|
220
|
+
* @internal — true when this TxContext was opened in amendment
|
|
221
|
+
* mode. Toggles the lazy-`beginAmendment` + role-check path on first
|
|
222
|
+
* `tx.vault(name)` and unlocks the post-Phase-2 invariant + audit run.
|
|
223
|
+
*/
|
|
224
|
+
_amendment;
|
|
225
|
+
/** @internal — vaults that have already had `beginAmendment` called. */
|
|
226
|
+
_amendmentVaults = /* @__PURE__ */ new Map();
|
|
57
227
|
/** @internal */
|
|
58
|
-
constructor(db) {
|
|
228
|
+
constructor(db, amendment = false) {
|
|
59
229
|
this._db = db;
|
|
230
|
+
this._amendment = amendment;
|
|
60
231
|
}
|
|
61
232
|
/** Scope subsequent `collection()` calls to the named vault. */
|
|
62
233
|
vault(name) {
|
|
63
234
|
const v = this._db.vault(name);
|
|
235
|
+
if (this._amendment && !this._amendmentVaults.has(name)) {
|
|
236
|
+
const role = v.role;
|
|
237
|
+
if (role !== "admin" && role !== "owner") {
|
|
238
|
+
throw new AmendmentForbiddenError(v.userId, role);
|
|
239
|
+
}
|
|
240
|
+
const reg = v._getGuardRegistry();
|
|
241
|
+
if (reg === null) {
|
|
242
|
+
throw new ValidationError(
|
|
243
|
+
`Vault "${name}": amendment mode requires at least one guardStrategy registered via createNoydb({ guardStrategies }). Open the vault with guardStrategies before calling db.transaction({ amendment: true }).`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
reg.beginAmendment();
|
|
247
|
+
this._amendmentVaults.set(name, v);
|
|
248
|
+
}
|
|
64
249
|
return new TxVault(this, v);
|
|
65
250
|
}
|
|
66
251
|
};
|
|
@@ -124,6 +309,7 @@ var TxCollection = class {
|
|
|
124
309
|
record
|
|
125
310
|
};
|
|
126
311
|
if (options?.expectedVersion !== void 0) op.expectedVersion = options.expectedVersion;
|
|
312
|
+
if (options?.reason !== void 0) op.reason = options.reason;
|
|
127
313
|
this._ctx._ops.push(op);
|
|
128
314
|
}
|
|
129
315
|
/**
|
|
@@ -142,10 +328,28 @@ var TxCollection = class {
|
|
|
142
328
|
this._ctx._ops.push(op);
|
|
143
329
|
}
|
|
144
330
|
};
|
|
145
|
-
async function runTransaction(db, fn) {
|
|
146
|
-
|
|
331
|
+
async function runTransaction(db, fn, options) {
|
|
332
|
+
if (options?.amendment) {
|
|
333
|
+
if (typeof options.reason !== "string" || options.reason.trim().length === 0) {
|
|
334
|
+
throw new ValidationError(
|
|
335
|
+
"db.transaction({ amendment: true }) requires a non-empty `reason` string."
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
const ctx = new TxContext(db, options?.amendment === true);
|
|
147
340
|
const bodyResult = await fn(ctx);
|
|
148
|
-
if (ctx._ops.length === 0)
|
|
341
|
+
if (ctx._ops.length === 0) {
|
|
342
|
+
if (ctx._amendment) {
|
|
343
|
+
for (const v of ctx._amendmentVaults.values()) {
|
|
344
|
+
const reg = v._getGuardRegistry();
|
|
345
|
+
if (reg !== null) {
|
|
346
|
+
reg.consumeChanges();
|
|
347
|
+
reg.consumeMeta();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return bodyResult;
|
|
352
|
+
}
|
|
149
353
|
const priorEnvelopes = /* @__PURE__ */ new Map();
|
|
150
354
|
const store = db._store;
|
|
151
355
|
for (const op of ctx._ops) {
|
|
@@ -165,41 +369,169 @@ async function runTransaction(db, fn) {
|
|
|
165
369
|
}
|
|
166
370
|
}
|
|
167
371
|
}
|
|
168
|
-
|
|
372
|
+
db._setActiveTxContext(ctx);
|
|
169
373
|
try {
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
374
|
+
try {
|
|
375
|
+
for (const op of ctx._ops) {
|
|
376
|
+
const coll = db.vault(op.vaultName).collection(op.collectionName);
|
|
377
|
+
const key = keyOf(op);
|
|
378
|
+
const prior = priorEnvelopes.get(key) ?? null;
|
|
379
|
+
ctx._executed.push({ op, priorEnvelope: prior });
|
|
380
|
+
if (op.type === "put") {
|
|
381
|
+
await coll.put(op.id, op.record, op.reason !== void 0 ? { reason: op.reason } : void 0);
|
|
382
|
+
} else {
|
|
383
|
+
await coll.delete(op.id);
|
|
384
|
+
}
|
|
178
385
|
}
|
|
179
|
-
|
|
386
|
+
} catch (err) {
|
|
387
|
+
await revertExecuted(ctx._executed, store, db);
|
|
388
|
+
if (ctx._amendment) {
|
|
389
|
+
for (const v of ctx._amendmentVaults.values()) {
|
|
390
|
+
const reg = v._getGuardRegistry();
|
|
391
|
+
if (reg !== null) {
|
|
392
|
+
reg.consumeChanges();
|
|
393
|
+
reg.consumeMeta();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
throw err;
|
|
180
398
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
399
|
+
} finally {
|
|
400
|
+
db._clearActiveTxContext(ctx);
|
|
401
|
+
}
|
|
402
|
+
if (ctx._amendment) {
|
|
403
|
+
const { GuardExecutor: GuardExecutor2 } = await Promise.resolve().then(() => (init_executor(), executor_exports));
|
|
404
|
+
try {
|
|
405
|
+
for (const [vaultName, v] of ctx._amendmentVaults) {
|
|
406
|
+
const registry = v._getGuardRegistry();
|
|
407
|
+
if (registry === null) continue;
|
|
408
|
+
const changesByCollection = registry.consumeChanges();
|
|
409
|
+
const meta = registry.consumeMeta();
|
|
410
|
+
if (changesByCollection.size === 0) continue;
|
|
411
|
+
const readOnlyVault = v._getReadOnlyFacade();
|
|
412
|
+
if (readOnlyVault === null) continue;
|
|
413
|
+
const invariantsPassed = [];
|
|
414
|
+
for (const [collection, changes] of changesByCollection) {
|
|
415
|
+
const guards = registry.guardsFor(collection).filter((g) => g.amendment !== void 0);
|
|
416
|
+
for (const guard of guards) {
|
|
417
|
+
await GuardExecutor2.runInvariant(guard, changes, {
|
|
418
|
+
existing: null,
|
|
419
|
+
vault: readOnlyVault,
|
|
420
|
+
userId: v.userId,
|
|
421
|
+
role: v.role
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
if (guards.length > 0) invariantsPassed.push(collection);
|
|
189
425
|
}
|
|
190
|
-
|
|
426
|
+
const ledger = v._getLedgerOrNull();
|
|
427
|
+
if (ledger) {
|
|
428
|
+
const role = v.role;
|
|
429
|
+
const amendment = {
|
|
430
|
+
reason: options.reason,
|
|
431
|
+
role,
|
|
432
|
+
changes: meta,
|
|
433
|
+
invariantsPassed
|
|
434
|
+
};
|
|
435
|
+
await ledger.append({
|
|
436
|
+
op: "amendment",
|
|
437
|
+
collection: "",
|
|
438
|
+
id: "",
|
|
439
|
+
version: 0,
|
|
440
|
+
actor: v.userId,
|
|
441
|
+
// No payload to hash — the per-record entries already
|
|
442
|
+
// captured `payloadHash` at their own append time. We use
|
|
443
|
+
// a sha256 of the canonical reason string so the field is
|
|
444
|
+
// populated with something deterministic and non-empty.
|
|
445
|
+
payloadHash: "",
|
|
446
|
+
amendment
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
void vaultName;
|
|
191
450
|
}
|
|
451
|
+
} catch (err) {
|
|
452
|
+
await revertExecuted(ctx._executed, store, db);
|
|
453
|
+
throw err instanceof InvariantError ? err : new InvariantError(
|
|
454
|
+
err instanceof Error ? err.message : `invariant violated: ${String(err)}`
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return bodyResult;
|
|
459
|
+
}
|
|
460
|
+
async function revertExecuted(executed, store, db) {
|
|
461
|
+
for (const { op, priorEnvelope } of executed.slice().reverse()) {
|
|
462
|
+
try {
|
|
463
|
+
if (priorEnvelope) {
|
|
464
|
+
await store.put(op.vaultName, op.collectionName, op.id, priorEnvelope);
|
|
465
|
+
} else {
|
|
466
|
+
await store.delete(op.vaultName, op.collectionName, op.id);
|
|
467
|
+
}
|
|
468
|
+
if (db) {
|
|
469
|
+
const coll = db.vault(op.vaultName).collection(op.collectionName);
|
|
470
|
+
await coll._invalidateCacheEntry(op.id);
|
|
471
|
+
}
|
|
472
|
+
} catch {
|
|
192
473
|
}
|
|
193
|
-
throw err;
|
|
194
474
|
}
|
|
195
475
|
}
|
|
196
476
|
function keyOf(op) {
|
|
197
477
|
return `${op.vaultName}\0${op.collectionName}\0${op.id}`;
|
|
198
478
|
}
|
|
199
479
|
|
|
480
|
+
// src/tx/dry-run.ts
|
|
481
|
+
var SEP = " ";
|
|
482
|
+
var keyOf2 = (op) => `${op.vaultName}${SEP}${op.collectionName}${SEP}${op.id}`;
|
|
483
|
+
async function runDryRun(db, fn) {
|
|
484
|
+
const ctx = new TxContext(db);
|
|
485
|
+
await fn(ctx);
|
|
486
|
+
const lastOp = /* @__PURE__ */ new Map();
|
|
487
|
+
for (const op of ctx._ops) lastOp.set(keyOf2(op), op);
|
|
488
|
+
const affected = [];
|
|
489
|
+
const guardViolations = [];
|
|
490
|
+
for (const op of lastOp.values()) {
|
|
491
|
+
const v = db.vault(op.vaultName);
|
|
492
|
+
const coll = v.collection(op.collectionName);
|
|
493
|
+
const before = await coll.get(op.id);
|
|
494
|
+
if (op.type === "delete") {
|
|
495
|
+
affected.push({ vault: op.vaultName, op: "delete", collection: op.collectionName, docId: op.id, before, after: null });
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
const after = op.record ?? null;
|
|
499
|
+
affected.push({
|
|
500
|
+
vault: op.vaultName,
|
|
501
|
+
op: before === null ? "create" : "update",
|
|
502
|
+
collection: op.collectionName,
|
|
503
|
+
docId: op.id,
|
|
504
|
+
before,
|
|
505
|
+
after
|
|
506
|
+
});
|
|
507
|
+
const registry = v._getGuardRegistry();
|
|
508
|
+
if (!registry) continue;
|
|
509
|
+
const guards = registry.guardsFor(op.collectionName);
|
|
510
|
+
if (guards.length === 0) continue;
|
|
511
|
+
const facade = v._getReadOnlyFacade();
|
|
512
|
+
if (!facade) continue;
|
|
513
|
+
const gctx = { existing: before, vault: facade, userId: v.userId, role: v.role };
|
|
514
|
+
try {
|
|
515
|
+
await registry.runChecks(op.collectionName, after, gctx);
|
|
516
|
+
const { GuardExecutor: GuardExecutor2 } = await Promise.resolve().then(() => (init_executor(), executor_exports));
|
|
517
|
+
for (const g of guards) {
|
|
518
|
+
await GuardExecutor2.checkFrozenFields(g, op.id, before, after);
|
|
519
|
+
}
|
|
520
|
+
} catch (err) {
|
|
521
|
+
guardViolations.push({
|
|
522
|
+
vault: op.vaultName,
|
|
523
|
+
collection: op.collectionName,
|
|
524
|
+
docId: op.id,
|
|
525
|
+
message: err instanceof Error ? err.message : String(err)
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return { affected, guardViolations };
|
|
530
|
+
}
|
|
531
|
+
|
|
200
532
|
// src/tx/active.ts
|
|
201
533
|
function withTransactions() {
|
|
202
|
-
return { runTransaction };
|
|
534
|
+
return { runTransaction, runDryRun };
|
|
203
535
|
}
|
|
204
536
|
// Annotate the CommonJS export names for ESM import in node:
|
|
205
537
|
0 && (module.exports = {
|