@noy-db/hub 0.1.0-pre.3
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/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/aggregate/index.cjs +476 -0
- package/dist/aggregate/index.cjs.map +1 -0
- package/dist/aggregate/index.d.cts +38 -0
- package/dist/aggregate/index.d.ts +38 -0
- package/dist/aggregate/index.js +53 -0
- package/dist/aggregate/index.js.map +1 -0
- package/dist/blobs/index.cjs +1480 -0
- package/dist/blobs/index.cjs.map +1 -0
- package/dist/blobs/index.d.cts +45 -0
- package/dist/blobs/index.d.ts +45 -0
- package/dist/blobs/index.js +48 -0
- package/dist/blobs/index.js.map +1 -0
- package/dist/bundle/index.cjs +436 -0
- package/dist/bundle/index.cjs.map +1 -0
- package/dist/bundle/index.d.cts +7 -0
- package/dist/bundle/index.d.ts +7 -0
- package/dist/bundle/index.js +40 -0
- package/dist/bundle/index.js.map +1 -0
- package/dist/chunk-2QR2PQTT.js +217 -0
- package/dist/chunk-2QR2PQTT.js.map +1 -0
- package/dist/chunk-4OWFYIDQ.js +79 -0
- package/dist/chunk-4OWFYIDQ.js.map +1 -0
- package/dist/chunk-5AATM2M2.js +90 -0
- package/dist/chunk-5AATM2M2.js.map +1 -0
- package/dist/chunk-ACLDOTNQ.js +543 -0
- package/dist/chunk-ACLDOTNQ.js.map +1 -0
- package/dist/chunk-BTDCBVJW.js +160 -0
- package/dist/chunk-BTDCBVJW.js.map +1 -0
- package/dist/chunk-CIMZBAZB.js +72 -0
- package/dist/chunk-CIMZBAZB.js.map +1 -0
- package/dist/chunk-E445ICYI.js +365 -0
- package/dist/chunk-E445ICYI.js.map +1 -0
- package/dist/chunk-EXQRC2L4.js +722 -0
- package/dist/chunk-EXQRC2L4.js.map +1 -0
- package/dist/chunk-FZU343FL.js +32 -0
- package/dist/chunk-FZU343FL.js.map +1 -0
- package/dist/chunk-GJILMRPO.js +354 -0
- package/dist/chunk-GJILMRPO.js.map +1 -0
- package/dist/chunk-GOUT6DND.js +1285 -0
- package/dist/chunk-GOUT6DND.js.map +1 -0
- package/dist/chunk-J66GRPNH.js +111 -0
- package/dist/chunk-J66GRPNH.js.map +1 -0
- package/dist/chunk-M2F2JAWB.js +464 -0
- package/dist/chunk-M2F2JAWB.js.map +1 -0
- package/dist/chunk-M5INGEFC.js +84 -0
- package/dist/chunk-M5INGEFC.js.map +1 -0
- package/dist/chunk-M62XNWRA.js +72 -0
- package/dist/chunk-M62XNWRA.js.map +1 -0
- package/dist/chunk-MR4424N3.js +275 -0
- package/dist/chunk-MR4424N3.js.map +1 -0
- package/dist/chunk-NPC4LFV5.js +132 -0
- package/dist/chunk-NPC4LFV5.js.map +1 -0
- package/dist/chunk-NXFEYLVG.js +311 -0
- package/dist/chunk-NXFEYLVG.js.map +1 -0
- package/dist/chunk-R36SIKES.js +79 -0
- package/dist/chunk-R36SIKES.js.map +1 -0
- package/dist/chunk-TDR6T5CJ.js +381 -0
- package/dist/chunk-TDR6T5CJ.js.map +1 -0
- package/dist/chunk-UF3BUNQZ.js +1 -0
- package/dist/chunk-UF3BUNQZ.js.map +1 -0
- package/dist/chunk-UQFSPSWG.js +1109 -0
- package/dist/chunk-UQFSPSWG.js.map +1 -0
- package/dist/chunk-USKYUS74.js +793 -0
- package/dist/chunk-USKYUS74.js.map +1 -0
- package/dist/chunk-XCL3WP6J.js +121 -0
- package/dist/chunk-XCL3WP6J.js.map +1 -0
- package/dist/chunk-XHFOENR2.js +680 -0
- package/dist/chunk-XHFOENR2.js.map +1 -0
- package/dist/chunk-ZFKD4QMV.js +430 -0
- package/dist/chunk-ZFKD4QMV.js.map +1 -0
- package/dist/chunk-ZLMV3TUA.js +490 -0
- package/dist/chunk-ZLMV3TUA.js.map +1 -0
- package/dist/chunk-ZRG4V3F5.js +17 -0
- package/dist/chunk-ZRG4V3F5.js.map +1 -0
- package/dist/consent/index.cjs +204 -0
- package/dist/consent/index.cjs.map +1 -0
- package/dist/consent/index.d.cts +24 -0
- package/dist/consent/index.d.ts +24 -0
- package/dist/consent/index.js +23 -0
- package/dist/consent/index.js.map +1 -0
- package/dist/crdt/index.cjs +152 -0
- package/dist/crdt/index.cjs.map +1 -0
- package/dist/crdt/index.d.cts +30 -0
- package/dist/crdt/index.d.ts +30 -0
- package/dist/crdt/index.js +24 -0
- package/dist/crdt/index.js.map +1 -0
- package/dist/crypto-IVKU7YTT.js +44 -0
- package/dist/crypto-IVKU7YTT.js.map +1 -0
- package/dist/delegation-XDJCBTI2.js +16 -0
- package/dist/delegation-XDJCBTI2.js.map +1 -0
- package/dist/dev-unlock-CeXic1xC.d.cts +263 -0
- package/dist/dev-unlock-KrKkcqD3.d.ts +263 -0
- package/dist/hash-9KO1BGxh.d.cts +63 -0
- package/dist/hash-ChfJjRjQ.d.ts +63 -0
- package/dist/history/index.cjs +1215 -0
- package/dist/history/index.cjs.map +1 -0
- package/dist/history/index.d.cts +62 -0
- package/dist/history/index.d.ts +62 -0
- package/dist/history/index.js +79 -0
- package/dist/history/index.js.map +1 -0
- package/dist/i18n/index.cjs +746 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +38 -0
- package/dist/i18n/index.d.ts +38 -0
- package/dist/i18n/index.js +55 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index-BRHBCmLt.d.ts +1940 -0
- package/dist/index-C8kQtmOk.d.ts +380 -0
- package/dist/index-DN-J-5wT.d.cts +1940 -0
- package/dist/index-DhjMjz7L.d.cts +380 -0
- package/dist/index.cjs +14756 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.js +6085 -0
- package/dist/index.js.map +1 -0
- package/dist/indexing/index.cjs +736 -0
- package/dist/indexing/index.cjs.map +1 -0
- package/dist/indexing/index.d.cts +36 -0
- package/dist/indexing/index.d.ts +36 -0
- package/dist/indexing/index.js +77 -0
- package/dist/indexing/index.js.map +1 -0
- package/dist/lazy-builder-BwEoBQZ9.d.ts +304 -0
- package/dist/lazy-builder-CZVLKh0Z.d.cts +304 -0
- package/dist/ledger-2NX4L7PN.js +33 -0
- package/dist/ledger-2NX4L7PN.js.map +1 -0
- package/dist/mime-magic-CBBSOkjm.d.cts +50 -0
- package/dist/mime-magic-CBBSOkjm.d.ts +50 -0
- package/dist/periods/index.cjs +1035 -0
- package/dist/periods/index.cjs.map +1 -0
- package/dist/periods/index.d.cts +21 -0
- package/dist/periods/index.d.ts +21 -0
- package/dist/periods/index.js +25 -0
- package/dist/periods/index.js.map +1 -0
- package/dist/predicate-SBHmi6D0.d.cts +161 -0
- package/dist/predicate-SBHmi6D0.d.ts +161 -0
- package/dist/query/index.cjs +1957 -0
- package/dist/query/index.cjs.map +1 -0
- package/dist/query/index.d.cts +3 -0
- package/dist/query/index.d.ts +3 -0
- package/dist/query/index.js +62 -0
- package/dist/query/index.js.map +1 -0
- package/dist/session/index.cjs +487 -0
- package/dist/session/index.cjs.map +1 -0
- package/dist/session/index.d.cts +45 -0
- package/dist/session/index.d.ts +45 -0
- package/dist/session/index.js +44 -0
- package/dist/session/index.js.map +1 -0
- package/dist/shadow/index.cjs +133 -0
- package/dist/shadow/index.cjs.map +1 -0
- package/dist/shadow/index.d.cts +16 -0
- package/dist/shadow/index.d.ts +16 -0
- package/dist/shadow/index.js +20 -0
- package/dist/shadow/index.js.map +1 -0
- package/dist/store/index.cjs +1069 -0
- package/dist/store/index.cjs.map +1 -0
- package/dist/store/index.d.cts +491 -0
- package/dist/store/index.d.ts +491 -0
- package/dist/store/index.js +34 -0
- package/dist/store/index.js.map +1 -0
- package/dist/strategy-BSxFXGzb.d.cts +110 -0
- package/dist/strategy-BSxFXGzb.d.ts +110 -0
- package/dist/strategy-D-SrOLCl.d.cts +548 -0
- package/dist/strategy-D-SrOLCl.d.ts +548 -0
- package/dist/sync/index.cjs +1062 -0
- package/dist/sync/index.cjs.map +1 -0
- package/dist/sync/index.d.cts +42 -0
- package/dist/sync/index.d.ts +42 -0
- package/dist/sync/index.js +28 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/team/index.cjs +1233 -0
- package/dist/team/index.cjs.map +1 -0
- package/dist/team/index.d.cts +117 -0
- package/dist/team/index.d.ts +117 -0
- package/dist/team/index.js +39 -0
- package/dist/team/index.js.map +1 -0
- package/dist/tx/index.cjs +212 -0
- package/dist/tx/index.cjs.map +1 -0
- package/dist/tx/index.d.cts +20 -0
- package/dist/tx/index.d.ts +20 -0
- package/dist/tx/index.js +20 -0
- package/dist/tx/index.js.map +1 -0
- package/dist/types-BZpCZB8N.d.ts +7526 -0
- package/dist/types-Bfs0qr5F.d.cts +7526 -0
- package/dist/ulid-COREQ2RQ.js +9 -0
- package/dist/ulid-COREQ2RQ.js.map +1 -0
- package/dist/util/index.cjs +230 -0
- package/dist/util/index.cjs.map +1 -0
- package/dist/util/index.d.cts +77 -0
- package/dist/util/index.d.ts +77 -0
- package/dist/util/index.js +190 -0
- package/dist/util/index.js.map +1 -0
- package/package.json +244 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { as as HistoryStrategy, at as NoydbStore, au as HistoryOptions, av as EncryptedEnvelope, aw as PruneOptions } from '../types-Bfs0qr5F.cjs';
|
|
2
|
+
export { ax as AppendInput, ay as ChangeType, az as CollectionInstant, aA as DiffEntry, aB as JsonPatch, aC as JsonPatchOp, aD as LedgerEntry, aE as LedgerStore, aF as VaultEngine, aG as VaultInstant, aH as VerifyResult, aI as applyPatch, aJ as canonicalJson, aK as computePatch, aL as diff, aM as formatDiff, aN as hashEntry, aO as paddedIndex, aP as parseIndex, aQ as sha256Hex } from '../types-Bfs0qr5F.cjs';
|
|
3
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from '../hash-9KO1BGxh.cjs';
|
|
4
|
+
import '../lazy-builder-CZVLKh0Z.cjs';
|
|
5
|
+
import '../predicate-SBHmi6D0.cjs';
|
|
6
|
+
import '../strategy-D-SrOLCl.cjs';
|
|
7
|
+
import '../strategy-BSxFXGzb.cjs';
|
|
8
|
+
import '../index-DN-J-5wT.cjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Active history strategy — `withHistory()` returns the real
|
|
12
|
+
* implementation that wires per-record snapshots, the hash-chained
|
|
13
|
+
* audit ledger, JSON-patch deltas, and time-machine reads into the
|
|
14
|
+
* core write/read paths.
|
|
15
|
+
*
|
|
16
|
+
* Consumers opt in by:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { createNoydb } from '@noy-db/hub'
|
|
20
|
+
* import { withHistory } from '@noy-db/hub/history'
|
|
21
|
+
*
|
|
22
|
+
* const db = await createNoydb({
|
|
23
|
+
* store: ...,
|
|
24
|
+
* user: ...,
|
|
25
|
+
* historyStrategy: withHistory(),
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* The factory is a thin wrapper that delegates to the existing
|
|
30
|
+
* `history.ts`, `diff.ts`, `ledger/store.ts`, `ledger/patch.ts`, and
|
|
31
|
+
* `time-machine.ts` modules. Splitting the import chain through this
|
|
32
|
+
* file is what lets `tsup` tree-shake the heavy modules out of the
|
|
33
|
+
* default `@noy-db/hub` bundle when no `withHistory()` import is
|
|
34
|
+
* present in the consumer.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Build the active history strategy. Today the factory takes no
|
|
41
|
+
* options; per-collection retention tuning still flows through
|
|
42
|
+
* `HistoryConfig` on `Vault.collection()` / `vault.openVault()`.
|
|
43
|
+
*
|
|
44
|
+
* Future option slots (kept off the LTS surface for now):
|
|
45
|
+
* - global maxVersions cap
|
|
46
|
+
* - global beforeDate prune cadence
|
|
47
|
+
* - ledger encryption toggle (today inferred from vault.encrypted)
|
|
48
|
+
*/
|
|
49
|
+
declare function withHistory(): HistoryStrategy;
|
|
50
|
+
|
|
51
|
+
/** Save a history entry (a complete encrypted envelope snapshot). */
|
|
52
|
+
declare function saveHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string, envelope: EncryptedEnvelope): Promise<void>;
|
|
53
|
+
/** Get history entries for a record, sorted newest-first. */
|
|
54
|
+
declare function getHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string, options?: HistoryOptions): Promise<EncryptedEnvelope[]>;
|
|
55
|
+
/** Get a specific version's envelope from history. */
|
|
56
|
+
declare function getVersionEnvelope(adapter: NoydbStore, vault: string, collection: string, recordId: string, version: number): Promise<EncryptedEnvelope | null>;
|
|
57
|
+
/** Prune history entries. Returns the number of entries deleted. */
|
|
58
|
+
declare function pruneHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string | undefined, options: PruneOptions): Promise<number>;
|
|
59
|
+
/** Clear all history for a vault, optionally scoped to a collection or record. */
|
|
60
|
+
declare function clearHistory(adapter: NoydbStore, vault: string, collection?: string, recordId?: string): Promise<number>;
|
|
61
|
+
|
|
62
|
+
export { HistoryStrategy, clearHistory, getHistory, getVersionEnvelope, pruneHistory, saveHistory, withHistory };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { as as HistoryStrategy, at as NoydbStore, au as HistoryOptions, av as EncryptedEnvelope, aw as PruneOptions } from '../types-BZpCZB8N.js';
|
|
2
|
+
export { ax as AppendInput, ay as ChangeType, az as CollectionInstant, aA as DiffEntry, aB as JsonPatch, aC as JsonPatchOp, aD as LedgerEntry, aE as LedgerStore, aF as VaultEngine, aG as VaultInstant, aH as VerifyResult, aI as applyPatch, aJ as canonicalJson, aK as computePatch, aL as diff, aM as formatDiff, aN as hashEntry, aO as paddedIndex, aP as parseIndex, aQ as sha256Hex } from '../types-BZpCZB8N.js';
|
|
3
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from '../hash-ChfJjRjQ.js';
|
|
4
|
+
import '../lazy-builder-BwEoBQZ9.js';
|
|
5
|
+
import '../predicate-SBHmi6D0.js';
|
|
6
|
+
import '../strategy-D-SrOLCl.js';
|
|
7
|
+
import '../strategy-BSxFXGzb.js';
|
|
8
|
+
import '../index-BRHBCmLt.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Active history strategy — `withHistory()` returns the real
|
|
12
|
+
* implementation that wires per-record snapshots, the hash-chained
|
|
13
|
+
* audit ledger, JSON-patch deltas, and time-machine reads into the
|
|
14
|
+
* core write/read paths.
|
|
15
|
+
*
|
|
16
|
+
* Consumers opt in by:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { createNoydb } from '@noy-db/hub'
|
|
20
|
+
* import { withHistory } from '@noy-db/hub/history'
|
|
21
|
+
*
|
|
22
|
+
* const db = await createNoydb({
|
|
23
|
+
* store: ...,
|
|
24
|
+
* user: ...,
|
|
25
|
+
* historyStrategy: withHistory(),
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* The factory is a thin wrapper that delegates to the existing
|
|
30
|
+
* `history.ts`, `diff.ts`, `ledger/store.ts`, `ledger/patch.ts`, and
|
|
31
|
+
* `time-machine.ts` modules. Splitting the import chain through this
|
|
32
|
+
* file is what lets `tsup` tree-shake the heavy modules out of the
|
|
33
|
+
* default `@noy-db/hub` bundle when no `withHistory()` import is
|
|
34
|
+
* present in the consumer.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Build the active history strategy. Today the factory takes no
|
|
41
|
+
* options; per-collection retention tuning still flows through
|
|
42
|
+
* `HistoryConfig` on `Vault.collection()` / `vault.openVault()`.
|
|
43
|
+
*
|
|
44
|
+
* Future option slots (kept off the LTS surface for now):
|
|
45
|
+
* - global maxVersions cap
|
|
46
|
+
* - global beforeDate prune cadence
|
|
47
|
+
* - ledger encryption toggle (today inferred from vault.encrypted)
|
|
48
|
+
*/
|
|
49
|
+
declare function withHistory(): HistoryStrategy;
|
|
50
|
+
|
|
51
|
+
/** Save a history entry (a complete encrypted envelope snapshot). */
|
|
52
|
+
declare function saveHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string, envelope: EncryptedEnvelope): Promise<void>;
|
|
53
|
+
/** Get history entries for a record, sorted newest-first. */
|
|
54
|
+
declare function getHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string, options?: HistoryOptions): Promise<EncryptedEnvelope[]>;
|
|
55
|
+
/** Get a specific version's envelope from history. */
|
|
56
|
+
declare function getVersionEnvelope(adapter: NoydbStore, vault: string, collection: string, recordId: string, version: number): Promise<EncryptedEnvelope | null>;
|
|
57
|
+
/** Prune history entries. Returns the number of entries deleted. */
|
|
58
|
+
declare function pruneHistory(adapter: NoydbStore, vault: string, collection: string, recordId: string | undefined, options: PruneOptions): Promise<number>;
|
|
59
|
+
/** Clear all history for a vault, optionally scoped to a collection or record. */
|
|
60
|
+
declare function clearHistory(adapter: NoydbStore, vault: string, collection?: string, recordId?: string): Promise<number>;
|
|
61
|
+
|
|
62
|
+
export { HistoryStrategy, clearHistory, getHistory, getVersionEnvelope, pruneHistory, saveHistory, withHistory };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CollectionInstant,
|
|
3
|
+
VaultInstant,
|
|
4
|
+
clearHistory,
|
|
5
|
+
diff,
|
|
6
|
+
formatDiff,
|
|
7
|
+
getHistory,
|
|
8
|
+
getVersionEnvelope,
|
|
9
|
+
pruneHistory,
|
|
10
|
+
saveHistory
|
|
11
|
+
} from "../chunk-NXFEYLVG.js";
|
|
12
|
+
import {
|
|
13
|
+
LEDGER_COLLECTION,
|
|
14
|
+
LEDGER_DELTAS_COLLECTION,
|
|
15
|
+
LedgerStore,
|
|
16
|
+
applyPatch,
|
|
17
|
+
computePatch
|
|
18
|
+
} from "../chunk-XHFOENR2.js";
|
|
19
|
+
import {
|
|
20
|
+
canonicalJson,
|
|
21
|
+
envelopePayloadHash,
|
|
22
|
+
hashEntry,
|
|
23
|
+
paddedIndex,
|
|
24
|
+
parseIndex,
|
|
25
|
+
sha256Hex
|
|
26
|
+
} from "../chunk-CIMZBAZB.js";
|
|
27
|
+
import "../chunk-ZRG4V3F5.js";
|
|
28
|
+
import "../chunk-MR4424N3.js";
|
|
29
|
+
import "../chunk-ACLDOTNQ.js";
|
|
30
|
+
|
|
31
|
+
// src/history/active.ts
|
|
32
|
+
function withHistory() {
|
|
33
|
+
return {
|
|
34
|
+
saveHistory,
|
|
35
|
+
getHistoryEntries: getHistory,
|
|
36
|
+
getVersionEnvelope,
|
|
37
|
+
pruneHistory,
|
|
38
|
+
clearHistory,
|
|
39
|
+
envelopePayloadHash,
|
|
40
|
+
computePatch,
|
|
41
|
+
diff,
|
|
42
|
+
buildLedger(opts) {
|
|
43
|
+
return new LedgerStore({
|
|
44
|
+
adapter: opts.adapter,
|
|
45
|
+
vault: opts.vault,
|
|
46
|
+
encrypted: opts.encrypted,
|
|
47
|
+
getDEK: opts.getDEK,
|
|
48
|
+
actor: opts.actor
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
buildVaultInstant(engine, timestamp) {
|
|
52
|
+
return new VaultInstant(engine, timestamp);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
CollectionInstant,
|
|
58
|
+
LEDGER_COLLECTION,
|
|
59
|
+
LEDGER_DELTAS_COLLECTION,
|
|
60
|
+
LedgerStore,
|
|
61
|
+
VaultInstant,
|
|
62
|
+
applyPatch,
|
|
63
|
+
canonicalJson,
|
|
64
|
+
clearHistory,
|
|
65
|
+
computePatch,
|
|
66
|
+
diff,
|
|
67
|
+
envelopePayloadHash,
|
|
68
|
+
formatDiff,
|
|
69
|
+
getHistory,
|
|
70
|
+
getVersionEnvelope,
|
|
71
|
+
hashEntry,
|
|
72
|
+
paddedIndex,
|
|
73
|
+
parseIndex,
|
|
74
|
+
pruneHistory,
|
|
75
|
+
saveHistory,
|
|
76
|
+
sha256Hex,
|
|
77
|
+
withHistory
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/history/active.ts"],"sourcesContent":["/**\n * Active history strategy — `withHistory()` returns the real\n * implementation that wires per-record snapshots, the hash-chained\n * audit ledger, JSON-patch deltas, and time-machine reads into the\n * core write/read paths.\n *\n * Consumers opt in by:\n *\n * ```ts\n * import { createNoydb } from '@noy-db/hub'\n * import { withHistory } from '@noy-db/hub/history'\n *\n * const db = await createNoydb({\n * store: ...,\n * user: ...,\n * historyStrategy: withHistory(),\n * })\n * ```\n *\n * The factory is a thin wrapper that delegates to the existing\n * `history.ts`, `diff.ts`, `ledger/store.ts`, `ledger/patch.ts`, and\n * `time-machine.ts` modules. Splitting the import chain through this\n * file is what lets `tsup` tree-shake the heavy modules out of the\n * default `@noy-db/hub` bundle when no `withHistory()` import is\n * present in the consumer.\n *\n * @public\n */\n\nimport type { HistoryStrategy, BuildLedgerOptions } from './strategy.js'\nimport {\n saveHistory,\n getHistory,\n getVersionEnvelope,\n pruneHistory,\n clearHistory,\n} from './history.js'\nimport { diff as computeDiff } from './diff.js'\nimport { LedgerStore, envelopePayloadHash } from './ledger/store.js'\nimport { computePatch } from './ledger/patch.js'\nimport { VaultInstant } from './time-machine.js'\n\n/**\n * Build the active history strategy. Today the factory takes no\n * options; per-collection retention tuning still flows through\n * `HistoryConfig` on `Vault.collection()` / `vault.openVault()`.\n *\n * Future option slots (kept off the LTS surface for now):\n * - global maxVersions cap\n * - global beforeDate prune cadence\n * - ledger encryption toggle (today inferred from vault.encrypted)\n */\nexport function withHistory(): HistoryStrategy {\n return {\n saveHistory,\n getHistoryEntries: getHistory,\n getVersionEnvelope,\n pruneHistory,\n clearHistory,\n envelopePayloadHash,\n computePatch,\n diff: computeDiff,\n buildLedger(opts: BuildLedgerOptions): LedgerStore {\n return new LedgerStore({\n adapter: opts.adapter,\n vault: opts.vault,\n encrypted: opts.encrypted,\n getDEK: opts.getDEK,\n actor: opts.actor,\n })\n },\n buildVaultInstant(engine, timestamp): VaultInstant {\n return new VaultInstant(engine, timestamp)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDO,SAAS,cAA+B;AAC7C,SAAO;AAAA,IACL;AAAA,IACA,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,MAAuC;AACjD,aAAO,IAAI,YAAY;AAAA,QACrB,SAAS,KAAK;AAAA,QACd,OAAO,KAAK;AAAA,QACZ,WAAW,KAAK;AAAA,QAChB,QAAQ,KAAK;AAAA,QACb,OAAO,KAAK;AAAA,MACd,CAAC;AAAA,IACH;AAAA,IACA,kBAAkB,QAAQ,WAAyB;AACjD,aAAO,IAAI,aAAa,QAAQ,SAAS;AAAA,IAC3C;AAAA,EACF;AACF;","names":[]}
|