@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/bundle/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TransferSealPayload } from '../ulid-
|
|
2
|
-
export { C as COMPRESSION_BROTLI, a as COMPRESSION_GZIP, b as COMPRESSION_NONE, c as CompressionAlgo, F as FLAG_COMPRESSED, d as FLAG_HAS_INTEGRITY_HASH, N as NOYDB_BUNDLE_FORMAT_VERSION, e as NOYDB_BUNDLE_MAGIC, f as NOYDB_BUNDLE_PREFIX_BYTES, g as NoydbBundleHeader, h as NoydbBundleReadResult, R as ReadNoydbBundleOptions, W as WriteNoydbBundleOptions, i as encodeBundleHeader, j as generateULID, k as isULID, r as readNoydbBundle, l as readNoydbBundleHeader, m as resetBrotliSupportCache, v as validateBundleHeader, w as writeNoydbBundle } from '../ulid-
|
|
3
|
-
import {
|
|
1
|
+
import { T as TransferSealPayload } from '../ulid-Drr7ykr6.cjs';
|
|
2
|
+
export { C as COMPRESSION_BROTLI, a as COMPRESSION_GZIP, b as COMPRESSION_NONE, c as CompressionAlgo, F as FLAG_COMPRESSED, d as FLAG_HAS_INTEGRITY_HASH, N as NOYDB_BUNDLE_FORMAT_VERSION, e as NOYDB_BUNDLE_MAGIC, f as NOYDB_BUNDLE_PREFIX_BYTES, g as NoydbBundleHeader, h as NoydbBundleReadResult, R as ReadNoydbBundleOptions, W as WriteNoydbBundleOptions, i as encodeBundleHeader, j as generateULID, k as isULID, r as readNoydbBundle, l as readNoydbBundleHeader, m as resetBrotliSupportCache, v as validateBundleHeader, w as writeNoydbBundle } from '../ulid-Drr7ykr6.cjs';
|
|
3
|
+
import { bw as Vault, b3 as NoydbStore, bs as SealingKeyProvider, bx as RecoveryEnrollmentInput, by as ShamirRecoveryProvider } from '../types-DyXYr8rE.cjs';
|
|
4
4
|
export { p as AdoptionStateError, B as BackupCorruptedError, q as BackupLedgerError, r as BundleIntegrityError, s as BundleSealMismatchError, t as BundleVersionConflictError, P as PartitionExtractionError, u as TransferSealError } from '../index-4fBVt8j9.cjs';
|
|
5
5
|
import '../lazy-builder-wY4pMCEe.cjs';
|
|
6
6
|
import '../predicate-BSAGEyu5.cjs';
|
package/dist/bundle/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TransferSealPayload } from '../ulid-
|
|
2
|
-
export { C as COMPRESSION_BROTLI, a as COMPRESSION_GZIP, b as COMPRESSION_NONE, c as CompressionAlgo, F as FLAG_COMPRESSED, d as FLAG_HAS_INTEGRITY_HASH, N as NOYDB_BUNDLE_FORMAT_VERSION, e as NOYDB_BUNDLE_MAGIC, f as NOYDB_BUNDLE_PREFIX_BYTES, g as NoydbBundleHeader, h as NoydbBundleReadResult, R as ReadNoydbBundleOptions, W as WriteNoydbBundleOptions, i as encodeBundleHeader, j as generateULID, k as isULID, r as readNoydbBundle, l as readNoydbBundleHeader, m as resetBrotliSupportCache, v as validateBundleHeader, w as writeNoydbBundle } from '../ulid-
|
|
3
|
-
import {
|
|
1
|
+
import { T as TransferSealPayload } from '../ulid-CJ8RzRrm.js';
|
|
2
|
+
export { C as COMPRESSION_BROTLI, a as COMPRESSION_GZIP, b as COMPRESSION_NONE, c as CompressionAlgo, F as FLAG_COMPRESSED, d as FLAG_HAS_INTEGRITY_HASH, N as NOYDB_BUNDLE_FORMAT_VERSION, e as NOYDB_BUNDLE_MAGIC, f as NOYDB_BUNDLE_PREFIX_BYTES, g as NoydbBundleHeader, h as NoydbBundleReadResult, R as ReadNoydbBundleOptions, W as WriteNoydbBundleOptions, i as encodeBundleHeader, j as generateULID, k as isULID, r as readNoydbBundle, l as readNoydbBundleHeader, m as resetBrotliSupportCache, v as validateBundleHeader, w as writeNoydbBundle } from '../ulid-CJ8RzRrm.js';
|
|
3
|
+
import { bw as Vault, b3 as NoydbStore, bs as SealingKeyProvider, bx as RecoveryEnrollmentInput, by as ShamirRecoveryProvider } from '../types-Df28QFKb.js';
|
|
4
4
|
export { p as AdoptionStateError, B as BackupCorruptedError, q as BackupLedgerError, r as BundleIntegrityError, s as BundleSealMismatchError, t as BundleVersionConflictError, P as PartitionExtractionError, u as TransferSealError } from '../index-D8I_pyJD.js';
|
|
5
5
|
import '../lazy-builder-7tIpFyWN.js';
|
|
6
6
|
import '../predicate-BSAGEyu5.js';
|
package/dist/bundle/index.js
CHANGED
|
@@ -532,7 +532,7 @@ async function createOwnerOnAdoptedPartition(store, vaultName, opts) {
|
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
534
|
if (isManaged(opts)) {
|
|
535
|
-
const { createNoydb } = await import("../noydb-
|
|
535
|
+
const { createNoydb } = await import("../noydb-G725ZSZG.js");
|
|
536
536
|
const db = await createNoydb({
|
|
537
537
|
store,
|
|
538
538
|
user: userId,
|
|
@@ -7693,6 +7693,119 @@ var NO_SNAPSHOTS = {
|
|
|
7693
7693
|
},
|
|
7694
7694
|
async restoreSnapshot() {
|
|
7695
7695
|
throw NOT_ENABLED4;
|
|
7696
|
+
},
|
|
7697
|
+
async autoSnapshot() {
|
|
7698
|
+
throw NOT_ENABLED4;
|
|
7699
|
+
}
|
|
7700
|
+
};
|
|
7701
|
+
|
|
7702
|
+
// src/snapshots/scheduler.ts
|
|
7703
|
+
var SnapshotScheduler = class {
|
|
7704
|
+
policy;
|
|
7705
|
+
callbacks;
|
|
7706
|
+
debounceTimer = null;
|
|
7707
|
+
intervalTimer = null;
|
|
7708
|
+
lastFireTime = 0;
|
|
7709
|
+
firing = false;
|
|
7710
|
+
started = false;
|
|
7711
|
+
boundVisibility = null;
|
|
7712
|
+
boundUnload = null;
|
|
7713
|
+
constructor(policy, callbacks) {
|
|
7714
|
+
this.policy = policy;
|
|
7715
|
+
this.callbacks = callbacks;
|
|
7716
|
+
if (this.shouldRegisterUnload()) {
|
|
7717
|
+
this.boundVisibility = this.handleVisibility.bind(this);
|
|
7718
|
+
this.boundUnload = this.handleUnload.bind(this);
|
|
7719
|
+
}
|
|
7720
|
+
}
|
|
7721
|
+
start() {
|
|
7722
|
+
if (this.started) return;
|
|
7723
|
+
this.started = true;
|
|
7724
|
+
if (this.policy.mode === "interval") {
|
|
7725
|
+
const ms = this.policy.intervalMs ?? 3e5;
|
|
7726
|
+
this.intervalTimer = setInterval(() => {
|
|
7727
|
+
void this.execFire();
|
|
7728
|
+
}, ms);
|
|
7729
|
+
}
|
|
7730
|
+
if (this.boundVisibility && this.boundUnload) {
|
|
7731
|
+
if (typeof document !== "undefined") {
|
|
7732
|
+
document.addEventListener("visibilitychange", this.boundVisibility);
|
|
7733
|
+
}
|
|
7734
|
+
if (typeof globalThis.addEventListener === "function") {
|
|
7735
|
+
globalThis.addEventListener("pagehide", this.boundUnload);
|
|
7736
|
+
}
|
|
7737
|
+
if (typeof process !== "undefined" && typeof process.on === "function") {
|
|
7738
|
+
process.on("beforeExit", this.boundUnload);
|
|
7739
|
+
}
|
|
7740
|
+
}
|
|
7741
|
+
}
|
|
7742
|
+
stop() {
|
|
7743
|
+
if (!this.started) return;
|
|
7744
|
+
this.started = false;
|
|
7745
|
+
if (this.debounceTimer) {
|
|
7746
|
+
clearTimeout(this.debounceTimer);
|
|
7747
|
+
this.debounceTimer = null;
|
|
7748
|
+
}
|
|
7749
|
+
if (this.intervalTimer) {
|
|
7750
|
+
clearInterval(this.intervalTimer);
|
|
7751
|
+
this.intervalTimer = null;
|
|
7752
|
+
}
|
|
7753
|
+
if (this.boundVisibility && this.boundUnload) {
|
|
7754
|
+
if (typeof document !== "undefined") {
|
|
7755
|
+
document.removeEventListener("visibilitychange", this.boundVisibility);
|
|
7756
|
+
}
|
|
7757
|
+
if (typeof globalThis.removeEventListener === "function") {
|
|
7758
|
+
globalThis.removeEventListener("pagehide", this.boundUnload);
|
|
7759
|
+
}
|
|
7760
|
+
if (typeof process !== "undefined" && typeof process.removeListener === "function") {
|
|
7761
|
+
process.removeListener("beforeExit", this.boundUnload);
|
|
7762
|
+
}
|
|
7763
|
+
}
|
|
7764
|
+
}
|
|
7765
|
+
notifyChange() {
|
|
7766
|
+
if (!this.started) return;
|
|
7767
|
+
if (this.policy.mode === "debounce") this.resetDebounce();
|
|
7768
|
+
}
|
|
7769
|
+
resetDebounce() {
|
|
7770
|
+
if (this.debounceTimer) clearTimeout(this.debounceTimer);
|
|
7771
|
+
const ms = this.policy.debounceMs ?? 3e4;
|
|
7772
|
+
this.debounceTimer = setTimeout(() => {
|
|
7773
|
+
this.debounceTimer = null;
|
|
7774
|
+
void this.execFire();
|
|
7775
|
+
}, ms);
|
|
7776
|
+
}
|
|
7777
|
+
async execFire() {
|
|
7778
|
+
if (this.firing) return;
|
|
7779
|
+
const minInterval = this.policy.minIntervalMs ?? 0;
|
|
7780
|
+
if (minInterval > 0 && Date.now() - this.lastFireTime < minInterval) {
|
|
7781
|
+
if (this.policy.mode === "debounce") this.resetDebounce();
|
|
7782
|
+
return;
|
|
7783
|
+
}
|
|
7784
|
+
if (this.callbacks.pendingCount() === 0) return;
|
|
7785
|
+
this.firing = true;
|
|
7786
|
+
try {
|
|
7787
|
+
await this.callbacks.fire();
|
|
7788
|
+
this.lastFireTime = Date.now();
|
|
7789
|
+
} catch {
|
|
7790
|
+
} finally {
|
|
7791
|
+
this.firing = false;
|
|
7792
|
+
}
|
|
7793
|
+
}
|
|
7794
|
+
handleVisibility() {
|
|
7795
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") {
|
|
7796
|
+
this.flush();
|
|
7797
|
+
}
|
|
7798
|
+
}
|
|
7799
|
+
handleUnload() {
|
|
7800
|
+
this.flush();
|
|
7801
|
+
}
|
|
7802
|
+
flush() {
|
|
7803
|
+
if (this.callbacks.pendingCount() === 0) return;
|
|
7804
|
+
void this.callbacks.fire().catch(() => {
|
|
7805
|
+
});
|
|
7806
|
+
}
|
|
7807
|
+
shouldRegisterUnload() {
|
|
7808
|
+
return this.policy.onUnload ?? this.policy.mode !== "manual";
|
|
7696
7809
|
}
|
|
7697
7810
|
};
|
|
7698
7811
|
|
|
@@ -8049,6 +8162,8 @@ var Noydb = class {
|
|
|
8049
8162
|
sessionStrategy;
|
|
8050
8163
|
syncStrategy;
|
|
8051
8164
|
snapshotStrategy;
|
|
8165
|
+
snapshotScheduler = null;
|
|
8166
|
+
dirtySnapshotVaults = /* @__PURE__ */ new Set();
|
|
8052
8167
|
/**
|
|
8053
8168
|
* Currently-running multi-record transaction, set by
|
|
8054
8169
|
* `runTransaction` at the start of Phase 2 (commit) and cleared in
|
|
@@ -8074,6 +8189,7 @@ var Noydb = class {
|
|
|
8074
8189
|
this.sessionStrategy = options.sessionStrategy ?? NO_SESSION;
|
|
8075
8190
|
this.syncStrategy = options.syncStrategy ?? NO_SYNC;
|
|
8076
8191
|
this.snapshotStrategy = options.snapshotStrategy ?? NO_SNAPSHOTS;
|
|
8192
|
+
this.initSnapshotCadence();
|
|
8077
8193
|
this.publicEnvelopeSchema = resolveSchema(options.publicEnvelope);
|
|
8078
8194
|
if (options.sessionPolicy) {
|
|
8079
8195
|
this.sessionStrategy.validateSessionPolicy(options.sessionPolicy);
|
|
@@ -9030,6 +9146,8 @@ var Noydb = class {
|
|
|
9030
9146
|
}
|
|
9031
9147
|
close() {
|
|
9032
9148
|
this.closed = true;
|
|
9149
|
+
this.snapshotScheduler?.stop();
|
|
9150
|
+
this.snapshotScheduler = null;
|
|
9033
9151
|
if (this.sessionTimer) {
|
|
9034
9152
|
clearTimeout(this.sessionTimer);
|
|
9035
9153
|
this.sessionTimer = null;
|
|
@@ -10075,6 +10193,41 @@ var Noydb = class {
|
|
|
10075
10193
|
}
|
|
10076
10194
|
return this.snapshotStrategy.snapshot(v, this.options.user, opts);
|
|
10077
10195
|
}
|
|
10196
|
+
/**
|
|
10197
|
+
* Wire the automatic-snapshot cadence when a non-manual `snapshotPolicy` is
|
|
10198
|
+
* configured. Subscribes to `onAfterWrite` to mark the written vault dirty and
|
|
10199
|
+
* nudge the scheduler; the scheduler fires `autoSnapshot()` per dirty vault.
|
|
10200
|
+
* No-op for `mode:'manual'` or no policy.
|
|
10201
|
+
*/
|
|
10202
|
+
initSnapshotCadence() {
|
|
10203
|
+
const policy = this.snapshotStrategy.policy;
|
|
10204
|
+
if (!policy || !policy.mode || policy.mode === "manual") return;
|
|
10205
|
+
const scheduler = new SnapshotScheduler(policy, {
|
|
10206
|
+
fire: async () => {
|
|
10207
|
+
const names = [...this.dirtySnapshotVaults];
|
|
10208
|
+
this.dirtySnapshotVaults.clear();
|
|
10209
|
+
for (const name of names) {
|
|
10210
|
+
const v = this.vaultCache.get(name);
|
|
10211
|
+
if (!v) continue;
|
|
10212
|
+
try {
|
|
10213
|
+
await this.snapshotStrategy.autoSnapshot(v, this.options.user);
|
|
10214
|
+
} catch (err) {
|
|
10215
|
+
this.dirtySnapshotVaults.add(name);
|
|
10216
|
+
console.warn(
|
|
10217
|
+
`[noy-db] auto-snapshot failed for vault "${name}": ` + (err instanceof Error ? err.message : String(err))
|
|
10218
|
+
);
|
|
10219
|
+
}
|
|
10220
|
+
}
|
|
10221
|
+
},
|
|
10222
|
+
pendingCount: () => this.dirtySnapshotVaults.size
|
|
10223
|
+
});
|
|
10224
|
+
this.onAfterWrite((event) => {
|
|
10225
|
+
this.dirtySnapshotVaults.add(event.vault);
|
|
10226
|
+
scheduler.notifyChange();
|
|
10227
|
+
});
|
|
10228
|
+
scheduler.start();
|
|
10229
|
+
this.snapshotScheduler = scheduler;
|
|
10230
|
+
}
|
|
10078
10231
|
/**
|
|
10079
10232
|
* List all snapshots for the given vault, newest first.
|
|
10080
10233
|
* Reads only the sidecar index — does not download snapshot bytes.
|
|
@@ -10173,4 +10326,4 @@ export {
|
|
|
10173
10326
|
Noydb,
|
|
10174
10327
|
createNoydb
|
|
10175
10328
|
};
|
|
10176
|
-
//# sourceMappingURL=chunk-
|
|
10329
|
+
//# sourceMappingURL=chunk-6CME4UEK.js.map
|