@noy-db/hub 0.2.0-pre.8 → 0.2.0-pre.9
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/attestation/index.d.cts +1 -1
- package/dist/attestation/index.d.ts +1 -1
- package/dist/blobs/index.d.cts +2 -2
- package/dist/blobs/index.d.ts +2 -2
- package/dist/bundle/index.cjs +160 -0
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +3 -3
- package/dist/bundle/index.d.ts +3 -3
- package/dist/bundle/index.js +1 -1
- package/dist/{chunk-6774ZOQ7.js → chunk-6CME4UEK.js} +154 -1
- package/dist/chunk-6CME4UEK.js.map +1 -0
- package/dist/consent/index.d.cts +2 -2
- package/dist/consent/index.d.ts +2 -2
- package/dist/derivations/index.d.cts +3 -3
- package/dist/derivations/index.d.ts +3 -3
- package/dist/{dev-unlock-p3ysikWP.d.ts → dev-unlock-B4kDxep_.d.ts} +1 -1
- package/dist/{dev-unlock-M4VAWNq_.d.cts → dev-unlock-BIoEFbwm.d.cts} +1 -1
- package/dist/guards/index.d.cts +3 -3
- package/dist/guards/index.d.ts +3 -3
- package/dist/{hash-BPsYPcv_.d.cts → hash-DdpVypUp.d.cts} +1 -1
- package/dist/{hash-C1GtiOhR.d.ts → hash-HJqD14vS.d.ts} +1 -1
- package/dist/history/index.d.cts +3 -3
- package/dist/history/index.d.ts +3 -3
- package/dist/i18n/index.d.cts +2 -2
- package/dist/i18n/index.d.ts +2 -2
- package/dist/index.cjs +153 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/materialized-views/index.d.cts +3 -3
- package/dist/materialized-views/index.d.ts +3 -3
- package/dist/{noydb-LZBH3XDK.js → noydb-G725ZSZG.js} +2 -2
- package/dist/overlay-views/index.d.cts +3 -3
- package/dist/overlay-views/index.d.ts +3 -3
- package/dist/periods/index.d.cts +2 -2
- package/dist/periods/index.d.ts +2 -2
- package/dist/session/index.d.cts +3 -3
- package/dist/session/index.d.ts +3 -3
- package/dist/shadow/index.d.cts +2 -2
- package/dist/shadow/index.d.ts +2 -2
- package/dist/snapshots/index.cjs +37 -3
- package/dist/snapshots/index.cjs.map +1 -1
- package/dist/snapshots/index.d.cts +12 -5
- package/dist/snapshots/index.d.ts +12 -5
- package/dist/snapshots/index.js +37 -3
- package/dist/snapshots/index.js.map +1 -1
- package/dist/store/index.d.cts +2 -2
- package/dist/store/index.d.ts +2 -2
- package/dist/sync/index.d.cts +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/team/index.d.cts +2 -2
- package/dist/team/index.d.ts +2 -2
- package/dist/tx/index.d.cts +2 -2
- package/dist/tx/index.d.ts +2 -2
- package/dist/{types-DGU60JDt.d.ts → types-Df28QFKb.d.ts} +43 -1
- package/dist/{types-DjunxzJa.d.cts → types-DyXYr8rE.d.cts} +43 -1
- package/dist/{ulid-BFJkYRRW.d.ts → ulid-CJ8RzRrm.d.ts} +1 -1
- package/dist/{ulid-DPeuPgi3.d.cts → ulid-Drr7ykr6.d.cts} +1 -1
- package/dist/{with-derivation-DfOpKjFw.d.ts → with-derivation-DFnFByiQ.d.ts} +1 -1
- package/dist/{with-derivation-Df0kMlED.d.cts → with-derivation-DU3Sjazm.d.cts} +1 -1
- package/dist/{with-guard-C6W5RVrH.d.cts → with-guard-ByyxmEe7.d.cts} +1 -1
- package/dist/{with-guard-0KksDtSR.d.ts → with-guard-qube6BMI.d.ts} +1 -1
- package/dist/{with-materialized-view-BiasFcYx.d.ts → with-materialized-view-BLkQxoQN.d.ts} +1 -1
- package/dist/{with-materialized-view-BmDKyHrm.d.cts → with-materialized-view-BmEToIR1.d.cts} +1 -1
- package/dist/{with-overlayed-view-CA66vhHz.d.cts → with-overlayed-view-BMsQQbWm.d.cts} +1 -1
- package/dist/{with-overlayed-view-CQViuko_.d.ts → with-overlayed-view-CRsSEwHR.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-6774ZOQ7.js.map +0 -1
- /package/dist/{noydb-LZBH3XDK.js.map → noydb-G725ZSZG.js.map} +0 -0
package/dist/consent/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a8 as ConsentStrategy } from '../types-
|
|
2
|
-
export { a9 as CONSENT_AUDIT_COLLECTION, aa as ConsentAuditEntry, ab as ConsentAuditFilter, ac as ConsentContext, ad as ConsentOp, ae as loadConsentEntries, af as writeConsentEntry } from '../types-
|
|
1
|
+
import { a8 as ConsentStrategy } from '../types-DyXYr8rE.cjs';
|
|
2
|
+
export { a9 as CONSENT_AUDIT_COLLECTION, aa as ConsentAuditEntry, ab as ConsentAuditFilter, ac as ConsentContext, ad as ConsentOp, ae as loadConsentEntries, af as writeConsentEntry } from '../types-DyXYr8rE.cjs';
|
|
3
3
|
import '../lazy-builder-wY4pMCEe.cjs';
|
|
4
4
|
import '../predicate-BSAGEyu5.cjs';
|
|
5
5
|
import '../strategy-DSTrsZ8t.cjs';
|
package/dist/consent/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a8 as ConsentStrategy } from '../types-
|
|
2
|
-
export { a9 as CONSENT_AUDIT_COLLECTION, aa as ConsentAuditEntry, ab as ConsentAuditFilter, ac as ConsentContext, ad as ConsentOp, ae as loadConsentEntries, af as writeConsentEntry } from '../types-
|
|
1
|
+
import { a8 as ConsentStrategy } from '../types-Df28QFKb.js';
|
|
2
|
+
export { a9 as CONSENT_AUDIT_COLLECTION, aa as ConsentAuditEntry, ab as ConsentAuditFilter, ac as ConsentContext, ad as ConsentOp, ae as loadConsentEntries, af as writeConsentEntry } from '../types-Df28QFKb.js';
|
|
3
3
|
import '../lazy-builder-7tIpFyWN.js';
|
|
4
4
|
import '../predicate-BSAGEyu5.js';
|
|
5
5
|
import '../strategy-DSTrsZ8t.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { w as withDerivation } from '../with-derivation-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
export { w as withDerivation } from '../with-derivation-DU3Sjazm.cjs';
|
|
2
|
+
import { aN as DerivationStrategy, aO as DerivationContext } from '../types-DyXYr8rE.cjs';
|
|
3
|
+
export { aP as ArrayOutputSpec, aQ as DerivationRegistry, aR as DerivationStrategyHandle, aS as DerivedFromMeta, aT as OutputSpec, aU as RecordOutputSpec } from '../types-DyXYr8rE.cjs';
|
|
4
4
|
export { g as DerivationCapExceededError, h as DerivationCycleError, i as DerivationDepthError, j as DerivationOutputShapeError, k as DerivationOutputUnknownError } from '../index-4fBVt8j9.cjs';
|
|
5
5
|
import '../lazy-builder-wY4pMCEe.cjs';
|
|
6
6
|
import '../predicate-BSAGEyu5.cjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { w as withDerivation } from '../with-derivation-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
export { w as withDerivation } from '../with-derivation-DFnFByiQ.js';
|
|
2
|
+
import { aN as DerivationStrategy, aO as DerivationContext } from '../types-Df28QFKb.js';
|
|
3
|
+
export { aP as ArrayOutputSpec, aQ as DerivationRegistry, aR as DerivationStrategyHandle, aS as DerivedFromMeta, aT as OutputSpec, aU as RecordOutputSpec } from '../types-Df28QFKb.js';
|
|
4
4
|
export { g as DerivationCapExceededError, h as DerivationCycleError, i as DerivationDepthError, j as DerivationOutputShapeError, k as DerivationOutputUnknownError } from '../index-D8I_pyJD.js';
|
|
5
5
|
import '../lazy-builder-7tIpFyWN.js';
|
|
6
6
|
import '../predicate-BSAGEyu5.js';
|
package/dist/guards/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { w as withGuard } from '../with-guard-
|
|
2
|
-
import { as as GuardStrategy, at as GuardChange, au as GuardContext } from '../types-
|
|
3
|
-
export { av as GuardRegistry, aw as GuardStrategyHandle, ax as ReadOnlyVaultFacade } from '../types-
|
|
1
|
+
export { w as withGuard } from '../with-guard-ByyxmEe7.cjs';
|
|
2
|
+
import { as as GuardStrategy, at as GuardChange, au as GuardContext } from '../types-DyXYr8rE.cjs';
|
|
3
|
+
export { av as GuardRegistry, aw as GuardStrategyHandle, ax as ReadOnlyVaultFacade } from '../types-DyXYr8rE.cjs';
|
|
4
4
|
export { A as AmendmentForbiddenError, F as FieldFrozenError, I as InvariantError, e as RecordLockedError } from '../index-4fBVt8j9.cjs';
|
|
5
5
|
import '../lazy-builder-wY4pMCEe.cjs';
|
|
6
6
|
import '../predicate-BSAGEyu5.cjs';
|
package/dist/guards/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { w as withGuard } from '../with-guard-
|
|
2
|
-
import { as as GuardStrategy, at as GuardChange, au as GuardContext } from '../types-
|
|
3
|
-
export { av as GuardRegistry, aw as GuardStrategyHandle, ax as ReadOnlyVaultFacade } from '../types-
|
|
1
|
+
export { w as withGuard } from '../with-guard-qube6BMI.js';
|
|
2
|
+
import { as as GuardStrategy, at as GuardChange, au as GuardContext } from '../types-Df28QFKb.js';
|
|
3
|
+
export { av as GuardRegistry, aw as GuardStrategyHandle, ax as ReadOnlyVaultFacade } from '../types-Df28QFKb.js';
|
|
4
4
|
export { A as AmendmentForbiddenError, F as FieldFrozenError, I as InvariantError, e as RecordLockedError } from '../index-D8I_pyJD.js';
|
|
5
5
|
import '../lazy-builder-7tIpFyWN.js';
|
|
6
6
|
import '../predicate-BSAGEyu5.js';
|
package/dist/history/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from '../hash-
|
|
1
|
+
import { b2 as HistoryStrategy, b3 as NoydbStore, b4 as HistoryOptions, b5 as EncryptedEnvelope, b6 as PruneOptions } from '../types-DyXYr8rE.cjs';
|
|
2
|
+
export { b7 as AppendInput, b8 as ChangeType, b9 as CollectionInstant, ba as DiffEntry, bb as JsonPatch, bc as JsonPatchOp, bd as LedgerEntry, be as LedgerStore, bf as VaultEngine, bg as VaultInstant, bh as VerifyResult, bi as applyPatch, bj as canonicalJson, bk as computePatch, bl as diff, bm as formatDiff, bn as hashEntry, bo as paddedIndex, bp as parseIndex, bq as sha256Hex } from '../types-DyXYr8rE.cjs';
|
|
3
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from '../hash-DdpVypUp.cjs';
|
|
4
4
|
import '../lazy-builder-wY4pMCEe.cjs';
|
|
5
5
|
import '../predicate-BSAGEyu5.cjs';
|
|
6
6
|
import '../strategy-DSTrsZ8t.cjs';
|
package/dist/history/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from '../hash-
|
|
1
|
+
import { b2 as HistoryStrategy, b3 as NoydbStore, b4 as HistoryOptions, b5 as EncryptedEnvelope, b6 as PruneOptions } from '../types-Df28QFKb.js';
|
|
2
|
+
export { b7 as AppendInput, b8 as ChangeType, b9 as CollectionInstant, ba as DiffEntry, bb as JsonPatch, bc as JsonPatchOp, bd as LedgerEntry, be as LedgerStore, bf as VaultEngine, bg as VaultInstant, bh as VerifyResult, bi as applyPatch, bj as canonicalJson, bk as computePatch, bl as diff, bm as formatDiff, bn as hashEntry, bo as paddedIndex, bp as parseIndex, bq as sha256Hex } from '../types-Df28QFKb.js';
|
|
3
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from '../hash-HJqD14vS.js';
|
|
4
4
|
import '../lazy-builder-7tIpFyWN.js';
|
|
5
5
|
import '../predicate-BSAGEyu5.js';
|
|
6
6
|
import '../strategy-DSTrsZ8t.js';
|
package/dist/i18n/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as I18nStrategy } from '../types-
|
|
2
|
-
export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nMap, f as I18nTextDescriptor, g as I18nTextOptions, L as Layer, O as OnMissing, h as OnMissingPolicy, R as ResolveI18nOptions, S as ScriptWarning, i as applyI18nLocale, j as dictCollectionName, k as dictKey, l as enforceScript, m as getAtPath, n as i18nText, o as inferScripts, p as isDictCollectionName, q as isDictKeyDescriptor, r as isI18nTextDescriptor, s as resolveI18nText, t as resolvePolicy, u as setAtPathInPlace, v as validateI18nTextValue } from '../types-
|
|
1
|
+
import { I as I18nStrategy } from '../types-DyXYr8rE.cjs';
|
|
2
|
+
export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nMap, f as I18nTextDescriptor, g as I18nTextOptions, L as Layer, O as OnMissing, h as OnMissingPolicy, R as ResolveI18nOptions, S as ScriptWarning, i as applyI18nLocale, j as dictCollectionName, k as dictKey, l as enforceScript, m as getAtPath, n as i18nText, o as inferScripts, p as isDictCollectionName, q as isDictKeyDescriptor, r as isI18nTextDescriptor, s as resolveI18nText, t as resolvePolicy, u as setAtPathInPlace, v as validateI18nTextValue } from '../types-DyXYr8rE.cjs';
|
|
3
3
|
export { D as DictKeyInUseError, a as DictKeyMissingError, L as LocaleNotSpecifiedError, M as MissingTranslationError, R as ReservedCollectionNameError, S as ScriptViolationError, T as TranslatorNotConfiguredError } from '../index-4fBVt8j9.cjs';
|
|
4
4
|
import '../lazy-builder-wY4pMCEe.cjs';
|
|
5
5
|
import '../predicate-BSAGEyu5.cjs';
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as I18nStrategy } from '../types-
|
|
2
|
-
export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nMap, f as I18nTextDescriptor, g as I18nTextOptions, L as Layer, O as OnMissing, h as OnMissingPolicy, R as ResolveI18nOptions, S as ScriptWarning, i as applyI18nLocale, j as dictCollectionName, k as dictKey, l as enforceScript, m as getAtPath, n as i18nText, o as inferScripts, p as isDictCollectionName, q as isDictKeyDescriptor, r as isI18nTextDescriptor, s as resolveI18nText, t as resolvePolicy, u as setAtPathInPlace, v as validateI18nTextValue } from '../types-
|
|
1
|
+
import { I as I18nStrategy } from '../types-Df28QFKb.js';
|
|
2
|
+
export { D as DICT_COLLECTION_PREFIX, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, e as I18nMap, f as I18nTextDescriptor, g as I18nTextOptions, L as Layer, O as OnMissing, h as OnMissingPolicy, R as ResolveI18nOptions, S as ScriptWarning, i as applyI18nLocale, j as dictCollectionName, k as dictKey, l as enforceScript, m as getAtPath, n as i18nText, o as inferScripts, p as isDictCollectionName, q as isDictKeyDescriptor, r as isI18nTextDescriptor, s as resolveI18nText, t as resolvePolicy, u as setAtPathInPlace, v as validateI18nTextValue } from '../types-Df28QFKb.js';
|
|
3
3
|
export { D as DictKeyInUseError, a as DictKeyMissingError, L as LocaleNotSpecifiedError, M as MissingTranslationError, R as ReservedCollectionNameError, S as ScriptViolationError, T as TranslatorNotConfiguredError } from '../index-D8I_pyJD.js';
|
|
4
4
|
import '../lazy-builder-7tIpFyWN.js';
|
|
5
5
|
import '../predicate-BSAGEyu5.js';
|
package/dist/index.cjs
CHANGED
|
@@ -19863,6 +19863,119 @@ var NO_SNAPSHOTS = {
|
|
|
19863
19863
|
},
|
|
19864
19864
|
async restoreSnapshot() {
|
|
19865
19865
|
throw NOT_ENABLED5;
|
|
19866
|
+
},
|
|
19867
|
+
async autoSnapshot() {
|
|
19868
|
+
throw NOT_ENABLED5;
|
|
19869
|
+
}
|
|
19870
|
+
};
|
|
19871
|
+
|
|
19872
|
+
// src/snapshots/scheduler.ts
|
|
19873
|
+
var SnapshotScheduler = class {
|
|
19874
|
+
policy;
|
|
19875
|
+
callbacks;
|
|
19876
|
+
debounceTimer = null;
|
|
19877
|
+
intervalTimer = null;
|
|
19878
|
+
lastFireTime = 0;
|
|
19879
|
+
firing = false;
|
|
19880
|
+
started = false;
|
|
19881
|
+
boundVisibility = null;
|
|
19882
|
+
boundUnload = null;
|
|
19883
|
+
constructor(policy, callbacks) {
|
|
19884
|
+
this.policy = policy;
|
|
19885
|
+
this.callbacks = callbacks;
|
|
19886
|
+
if (this.shouldRegisterUnload()) {
|
|
19887
|
+
this.boundVisibility = this.handleVisibility.bind(this);
|
|
19888
|
+
this.boundUnload = this.handleUnload.bind(this);
|
|
19889
|
+
}
|
|
19890
|
+
}
|
|
19891
|
+
start() {
|
|
19892
|
+
if (this.started) return;
|
|
19893
|
+
this.started = true;
|
|
19894
|
+
if (this.policy.mode === "interval") {
|
|
19895
|
+
const ms = this.policy.intervalMs ?? 3e5;
|
|
19896
|
+
this.intervalTimer = setInterval(() => {
|
|
19897
|
+
void this.execFire();
|
|
19898
|
+
}, ms);
|
|
19899
|
+
}
|
|
19900
|
+
if (this.boundVisibility && this.boundUnload) {
|
|
19901
|
+
if (typeof document !== "undefined") {
|
|
19902
|
+
document.addEventListener("visibilitychange", this.boundVisibility);
|
|
19903
|
+
}
|
|
19904
|
+
if (typeof globalThis.addEventListener === "function") {
|
|
19905
|
+
globalThis.addEventListener("pagehide", this.boundUnload);
|
|
19906
|
+
}
|
|
19907
|
+
if (typeof process !== "undefined" && typeof process.on === "function") {
|
|
19908
|
+
process.on("beforeExit", this.boundUnload);
|
|
19909
|
+
}
|
|
19910
|
+
}
|
|
19911
|
+
}
|
|
19912
|
+
stop() {
|
|
19913
|
+
if (!this.started) return;
|
|
19914
|
+
this.started = false;
|
|
19915
|
+
if (this.debounceTimer) {
|
|
19916
|
+
clearTimeout(this.debounceTimer);
|
|
19917
|
+
this.debounceTimer = null;
|
|
19918
|
+
}
|
|
19919
|
+
if (this.intervalTimer) {
|
|
19920
|
+
clearInterval(this.intervalTimer);
|
|
19921
|
+
this.intervalTimer = null;
|
|
19922
|
+
}
|
|
19923
|
+
if (this.boundVisibility && this.boundUnload) {
|
|
19924
|
+
if (typeof document !== "undefined") {
|
|
19925
|
+
document.removeEventListener("visibilitychange", this.boundVisibility);
|
|
19926
|
+
}
|
|
19927
|
+
if (typeof globalThis.removeEventListener === "function") {
|
|
19928
|
+
globalThis.removeEventListener("pagehide", this.boundUnload);
|
|
19929
|
+
}
|
|
19930
|
+
if (typeof process !== "undefined" && typeof process.removeListener === "function") {
|
|
19931
|
+
process.removeListener("beforeExit", this.boundUnload);
|
|
19932
|
+
}
|
|
19933
|
+
}
|
|
19934
|
+
}
|
|
19935
|
+
notifyChange() {
|
|
19936
|
+
if (!this.started) return;
|
|
19937
|
+
if (this.policy.mode === "debounce") this.resetDebounce();
|
|
19938
|
+
}
|
|
19939
|
+
resetDebounce() {
|
|
19940
|
+
if (this.debounceTimer) clearTimeout(this.debounceTimer);
|
|
19941
|
+
const ms = this.policy.debounceMs ?? 3e4;
|
|
19942
|
+
this.debounceTimer = setTimeout(() => {
|
|
19943
|
+
this.debounceTimer = null;
|
|
19944
|
+
void this.execFire();
|
|
19945
|
+
}, ms);
|
|
19946
|
+
}
|
|
19947
|
+
async execFire() {
|
|
19948
|
+
if (this.firing) return;
|
|
19949
|
+
const minInterval = this.policy.minIntervalMs ?? 0;
|
|
19950
|
+
if (minInterval > 0 && Date.now() - this.lastFireTime < minInterval) {
|
|
19951
|
+
if (this.policy.mode === "debounce") this.resetDebounce();
|
|
19952
|
+
return;
|
|
19953
|
+
}
|
|
19954
|
+
if (this.callbacks.pendingCount() === 0) return;
|
|
19955
|
+
this.firing = true;
|
|
19956
|
+
try {
|
|
19957
|
+
await this.callbacks.fire();
|
|
19958
|
+
this.lastFireTime = Date.now();
|
|
19959
|
+
} catch {
|
|
19960
|
+
} finally {
|
|
19961
|
+
this.firing = false;
|
|
19962
|
+
}
|
|
19963
|
+
}
|
|
19964
|
+
handleVisibility() {
|
|
19965
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") {
|
|
19966
|
+
this.flush();
|
|
19967
|
+
}
|
|
19968
|
+
}
|
|
19969
|
+
handleUnload() {
|
|
19970
|
+
this.flush();
|
|
19971
|
+
}
|
|
19972
|
+
flush() {
|
|
19973
|
+
if (this.callbacks.pendingCount() === 0) return;
|
|
19974
|
+
void this.callbacks.fire().catch(() => {
|
|
19975
|
+
});
|
|
19976
|
+
}
|
|
19977
|
+
shouldRegisterUnload() {
|
|
19978
|
+
return this.policy.onUnload ?? this.policy.mode !== "manual";
|
|
19866
19979
|
}
|
|
19867
19980
|
};
|
|
19868
19981
|
|
|
@@ -20219,6 +20332,8 @@ var Noydb = class {
|
|
|
20219
20332
|
sessionStrategy;
|
|
20220
20333
|
syncStrategy;
|
|
20221
20334
|
snapshotStrategy;
|
|
20335
|
+
snapshotScheduler = null;
|
|
20336
|
+
dirtySnapshotVaults = /* @__PURE__ */ new Set();
|
|
20222
20337
|
/**
|
|
20223
20338
|
* Currently-running multi-record transaction, set by
|
|
20224
20339
|
* `runTransaction` at the start of Phase 2 (commit) and cleared in
|
|
@@ -20244,6 +20359,7 @@ var Noydb = class {
|
|
|
20244
20359
|
this.sessionStrategy = options.sessionStrategy ?? NO_SESSION;
|
|
20245
20360
|
this.syncStrategy = options.syncStrategy ?? NO_SYNC;
|
|
20246
20361
|
this.snapshotStrategy = options.snapshotStrategy ?? NO_SNAPSHOTS;
|
|
20362
|
+
this.initSnapshotCadence();
|
|
20247
20363
|
this.publicEnvelopeSchema = resolveSchema(options.publicEnvelope);
|
|
20248
20364
|
if (options.sessionPolicy) {
|
|
20249
20365
|
this.sessionStrategy.validateSessionPolicy(options.sessionPolicy);
|
|
@@ -21200,6 +21316,8 @@ var Noydb = class {
|
|
|
21200
21316
|
}
|
|
21201
21317
|
close() {
|
|
21202
21318
|
this.closed = true;
|
|
21319
|
+
this.snapshotScheduler?.stop();
|
|
21320
|
+
this.snapshotScheduler = null;
|
|
21203
21321
|
if (this.sessionTimer) {
|
|
21204
21322
|
clearTimeout(this.sessionTimer);
|
|
21205
21323
|
this.sessionTimer = null;
|
|
@@ -22245,6 +22363,41 @@ var Noydb = class {
|
|
|
22245
22363
|
}
|
|
22246
22364
|
return this.snapshotStrategy.snapshot(v, this.options.user, opts);
|
|
22247
22365
|
}
|
|
22366
|
+
/**
|
|
22367
|
+
* Wire the automatic-snapshot cadence when a non-manual `snapshotPolicy` is
|
|
22368
|
+
* configured. Subscribes to `onAfterWrite` to mark the written vault dirty and
|
|
22369
|
+
* nudge the scheduler; the scheduler fires `autoSnapshot()` per dirty vault.
|
|
22370
|
+
* No-op for `mode:'manual'` or no policy.
|
|
22371
|
+
*/
|
|
22372
|
+
initSnapshotCadence() {
|
|
22373
|
+
const policy = this.snapshotStrategy.policy;
|
|
22374
|
+
if (!policy || !policy.mode || policy.mode === "manual") return;
|
|
22375
|
+
const scheduler = new SnapshotScheduler(policy, {
|
|
22376
|
+
fire: async () => {
|
|
22377
|
+
const names = [...this.dirtySnapshotVaults];
|
|
22378
|
+
this.dirtySnapshotVaults.clear();
|
|
22379
|
+
for (const name of names) {
|
|
22380
|
+
const v = this.vaultCache.get(name);
|
|
22381
|
+
if (!v) continue;
|
|
22382
|
+
try {
|
|
22383
|
+
await this.snapshotStrategy.autoSnapshot(v, this.options.user);
|
|
22384
|
+
} catch (err) {
|
|
22385
|
+
this.dirtySnapshotVaults.add(name);
|
|
22386
|
+
console.warn(
|
|
22387
|
+
`[noy-db] auto-snapshot failed for vault "${name}": ` + (err instanceof Error ? err.message : String(err))
|
|
22388
|
+
);
|
|
22389
|
+
}
|
|
22390
|
+
}
|
|
22391
|
+
},
|
|
22392
|
+
pendingCount: () => this.dirtySnapshotVaults.size
|
|
22393
|
+
});
|
|
22394
|
+
this.onAfterWrite((event) => {
|
|
22395
|
+
this.dirtySnapshotVaults.add(event.vault);
|
|
22396
|
+
scheduler.notifyChange();
|
|
22397
|
+
});
|
|
22398
|
+
scheduler.start();
|
|
22399
|
+
this.snapshotScheduler = scheduler;
|
|
22400
|
+
}
|
|
22248
22401
|
/**
|
|
22249
22402
|
* List all snapshots for the given vault, newest first.
|
|
22250
22403
|
* Reads only the sidecar index — does not download snapshot bytes.
|