flash-store 2.0.0 → 2.1.0

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.
Files changed (39) hide show
  1. package/README.md +92 -19
  2. package/dist/package.json +90 -61
  3. package/dist/src/browser.d.ts +20 -0
  4. package/dist/src/browser.d.ts.map +1 -0
  5. package/dist/src/browser.js +24 -0
  6. package/dist/src/browser.js.map +1 -0
  7. package/dist/src/config.d.ts +4 -0
  8. package/dist/src/config.d.ts.map +1 -1
  9. package/dist/src/config.js +4 -11
  10. package/dist/src/config.js.map +1 -1
  11. package/dist/src/flash-store-core.d.ts +65 -0
  12. package/dist/src/flash-store-core.d.ts.map +1 -0
  13. package/dist/src/flash-store-core.js +201 -0
  14. package/dist/src/flash-store-core.js.map +1 -0
  15. package/dist/src/flash-store-sync-core.d.ts +72 -0
  16. package/dist/src/flash-store-sync-core.d.ts.map +1 -0
  17. package/dist/src/flash-store-sync-core.js +177 -0
  18. package/dist/src/flash-store-sync-core.js.map +1 -0
  19. package/dist/src/flash-store-sync.d.ts +5 -66
  20. package/dist/src/flash-store-sync.d.ts.map +1 -1
  21. package/dist/src/flash-store-sync.js +7 -171
  22. package/dist/src/flash-store-sync.js.map +1 -1
  23. package/dist/src/flash-store.d.ts +5 -63
  24. package/dist/src/flash-store.d.ts.map +1 -1
  25. package/dist/src/flash-store.js +70 -208
  26. package/dist/src/flash-store.js.map +1 -1
  27. package/dist/src/indexeddb-backend.d.ts +40 -0
  28. package/dist/src/indexeddb-backend.d.ts.map +1 -0
  29. package/dist/src/indexeddb-backend.js +200 -0
  30. package/dist/src/indexeddb-backend.js.map +1 -0
  31. package/dist/src/key-encoding.d.ts +9 -0
  32. package/dist/src/key-encoding.d.ts.map +1 -0
  33. package/dist/src/key-encoding.js +22 -0
  34. package/dist/src/key-encoding.js.map +1 -0
  35. package/dist/src/store-backend.d.ts +35 -0
  36. package/dist/src/store-backend.d.ts.map +1 -0
  37. package/dist/src/store-backend.js +2 -0
  38. package/dist/src/store-backend.js.map +1 -0
  39. package/package.json +38 -9
@@ -1,177 +1,13 @@
1
1
  /**
2
- * Provides a synchronous in-memory Map facade with ordered asynchronous write-back.
3
- * FlashStore owns persistence; ready() is the boundary for observing write failures.
4
- * Keys and values are validated and serialized when a mutation is accepted, so
5
- * invalid input throws synchronously and later object changes are not persisted.
2
+ * Binds the shared synchronous Map cache to the native LMDB-backed store.
6
3
  */
7
- import { log } from './config.js';
8
- import { FlashStore, serialize, validateKey, writeSerialized, } from './flash-store.js';
9
- /**
10
- * In-memory Map backed by asynchronous LMDB writes.
11
- * Await ready() before reading restored data; detected write failures reject further mutations.
12
- * Restored entries follow LMDB key order rather than their original insertion order.
13
- */
14
- export class FlashStoreSync {
15
- static VERSION = FlashStore.VERSION;
16
- workdir;
17
- cacheMap = new Map();
18
- flashStore;
19
- touched = new Set();
20
- loading = true;
21
- clearedDuringLoad = false;
22
- pending;
23
- closing = false;
24
- failure;
25
- /** Opens the backing store and starts restoring its cache. */
4
+ import { FlashStore } from './flash-store.js';
5
+ import { FlashStoreSyncCore } from './flash-store-sync-core.js';
6
+ /** In-memory Map with ordered write-back to LMDB. */
7
+ export class FlashStoreSync extends FlashStoreSyncCore {
8
+ /** Opens the backing path and starts restoring its cache. Await ready() before reading restored data. */
26
9
  constructor(workdir = '.flash-store-sync') {
27
- log.verbose('CacheStore', 'constructor(%s)', workdir);
28
- this.workdir = workdir;
29
- this.flashStore = new FlashStore(workdir);
30
- this.pending = this.load();
31
- this.observeFailure();
32
- }
33
- /** Restore untouched keys while immediate cache mutations remain authoritative. */
34
- async load() {
35
- try {
36
- for await (const [key, value] of this.flashStore) {
37
- if (!this.clearedDuringLoad && !this.touched.has(key))
38
- this.cacheMap.set(key, value);
39
- }
40
- }
41
- finally {
42
- this.loading = false;
43
- this.touched.clear();
44
- }
45
- }
46
- /** Serialize writes behind initialization; reject mutations after a detected failure. */
47
- enqueue(action) {
48
- if (this.closing)
49
- throw new Error('Store is closing or closed');
50
- if (this.failure)
51
- throw this.failure.error;
52
- this.pending = this.pending.then(async () => {
53
- await action();
54
- });
55
- this.observeFailure();
56
- }
57
- /** Report background errors once while retaining the rejection for lifecycle calls. */
58
- observeFailure() {
59
- void this.pending.catch((error) => {
60
- if (!this.failure) {
61
- this.failure = { error };
62
- log.error('CacheStore', 'Background operation failed: %s', error);
63
- }
64
- });
65
- }
66
- /** Returns the package version. */
67
- version() {
68
- return this.flashStore.version();
69
- }
70
- /** Waits for initialization and writes queued before this call, rejecting on failure. */
71
- async ready() {
72
- await this.pending;
73
- }
74
- /** Waits for writes and closes the backing store, preserving write and close failures. */
75
- async close() {
76
- this.closing = true;
77
- try {
78
- await this.ready();
79
- }
80
- catch (error) {
81
- try {
82
- await this.flashStore.close();
83
- }
84
- catch (closeError) {
85
- throw new AggregateError([error, closeError], 'Write and close failed');
86
- }
87
- throw error;
88
- }
89
- await this.flashStore.close();
90
- }
91
- /** Closes even on write failure; removes the directory only after successful writes. */
92
- async destroy() {
93
- await this.close();
94
- await this.flashStore.destroy();
95
- }
96
- /** Returns the current number of cached entries. */
97
- get size() {
98
- return this.cacheMap.size;
99
- }
100
- /** Identifies this object as a Map. */
101
- get [Symbol.toStringTag]() {
102
- return 'Map';
103
- }
104
- /** Iterates cached entries in insertion order. */
105
- [Symbol.iterator]() {
106
- return this.cacheMap[Symbol.iterator]();
107
- }
108
- /** Iterates cached entries in insertion order. */
109
- entries() {
110
- return this.cacheMap.entries();
111
- }
112
- /** Iterates cached keys in insertion order. */
113
- keys() {
114
- return this.cacheMap.keys();
115
- }
116
- /** Iterates cached values in insertion order. */
117
- values() {
118
- return this.cacheMap.values();
119
- }
120
- /** Clears the cache immediately and queues persistent removal. */
121
- clear() {
122
- this.enqueue(() => this.flashStore.clear());
123
- if (this.loading)
124
- this.clearedDuringLoad = true;
125
- this.cacheMap.clear();
126
- }
127
- /** Removes a cached entry immediately and queues persistent removal. */
128
- delete(key) {
129
- validateKey(key);
130
- this.enqueue(() => this.flashStore.delete(key));
131
- if (this.loading)
132
- this.touched.add(key);
133
- return this.cacheMap.delete(key);
134
- }
135
- /** Invokes the callback for each cached entry. */
136
- forEach(callbackfn, thisArg) {
137
- for (const [key, value] of this.cacheMap)
138
- callbackfn.call(thisArg, value, key, this);
139
- }
140
- /** Reads a cached value; await ready() first to include previously persisted data. */
141
- get(key) {
142
- return this.cacheMap.get(key);
143
- }
144
- /** Checks the cache; await ready() first to include previously persisted data. */
145
- has(key) {
146
- return this.cacheMap.has(key);
147
- }
148
- /** Returns a cached value or inserts and queues the supplied default. */
149
- getOrInsert(key, defaultValue) {
150
- if (this.cacheMap.has(key))
151
- return this.cacheMap.get(key);
152
- this.set(key, defaultValue);
153
- return defaultValue;
154
- }
155
- /** Returns a cached value or computes, inserts, and queues a new value. */
156
- getOrInsertComputed(key, callback) {
157
- if (this.cacheMap.has(key))
158
- return this.cacheMap.get(key);
159
- const value = callback(key);
160
- this.set(key, value);
161
- return value;
162
- }
163
- /**
164
- * Updates the cache immediately and queues an ordered persistent write of the
165
- * value's JSON at call time. Throws without changes for invalid keys or values.
166
- */
167
- set(key, value) {
168
- validateKey(key);
169
- const serialized = serialize(value);
170
- this.enqueue(() => writeSerialized(this.flashStore, key, serialized));
171
- if (this.loading)
172
- this.touched.add(key);
173
- this.cacheMap.set(key, value);
174
- return this;
10
+ super(workdir, new FlashStore(workdir));
175
11
  }
176
12
  }
177
13
  export default FlashStoreSync;
@@ -1 +1 @@
1
- {"version":3,"file":"flash-store-sync.js","sourceRoot":"","sources":["../../src/flash-store-sync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,UAAU,EAEV,SAAS,EACT,WAAW,EACX,eAAe,GAChB,MAAM,kBAAkB,CAAA;AAEzB;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAGzB,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;IAC1B,O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CAAC,GAAG,CAAC,CAAA;QAChB,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;QACnC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAA;QACrE,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"flash-store-sync.js","sourceRoot":"","sources":["../../src/flash-store-sync.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAiB,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAE/D,qDAAqD;AACrD,MAAM,OAAO,cAGX,SAAQ,kBAAwB;IAChC,yGAAyG;IACzG,YAAY,OAAO,GAAG,mBAAmB;QACvC,KAAK,CAAC,OAAO,EAAE,IAAI,UAAU,CAAO,OAAO,CAAC,CAAC,CAAA;IAC/C,CAAC;CACF;AAED,eAAe,cAAc,CAAA"}
@@ -1,68 +1,10 @@
1
- /** Keys are ordered by LMDB: numbers precede strings and each type is ordered naturally. */
2
- export type StoreKey = string | number;
3
- /** Bounds and ordering for a range of keys. Prefix is restricted to string keys. */
4
- export interface IteratorOptions<K extends StoreKey = StoreKey> {
5
- gt?: K;
6
- gte?: K;
7
- lt?: K;
8
- lte?: K;
9
- reverse?: boolean;
10
- limit?: number;
11
- prefix?: string;
12
- }
13
- /** Reject keys that the configured ordered-binary encoding cannot represent safely. */
14
- export declare function validateKey(key: StoreKey): void;
15
- /** Serialize a value once, rejecting values that JSON cannot represent. */
16
- export declare function serialize(value: unknown): string;
17
- /**
18
- * Writes pre-serialized JSON for FlashStoreSync, which serializes at call time.
19
- * Internal: mod.ts does not export it, and package exports expose only mod.ts.
20
- */
21
- export declare let writeSerialized: <K extends StoreKey>(store: FlashStore<K, unknown>, key: K, serialized: string) => Promise<void>;
22
- /**
23
- * Persistent key-value store. Values use JSON round-tripping, which may change their
24
- * runtime type; the generic value type does not validate or prevent this.
25
- */
26
- export declare class FlashStore<K extends StoreKey = StoreKey, V = unknown> {
27
- static VERSION: string;
28
- readonly workdir: string;
29
- private readonly db;
30
- private closePromise?;
1
+ import { FlashStoreCore, type StoreKey } from './flash-store-core.ts';
2
+ export type { IteratorOptions, StoreKey } from './flash-store-core.ts';
3
+ /** Persistent Map backed by LMDB with JSON-serialized values. */
4
+ export declare class FlashStore<K extends StoreKey = StoreKey, V = unknown> extends FlashStoreCore<K, V> {
31
5
  /** Opens an LMDB database in the specified directory. */
32
6
  constructor(workdir: string);
33
- /** Returns the package version. */
34
- version(): string;
35
- /** Stores a JSON-serializable value and resolves after its write completes. */
36
- set(key: K, value: V): Promise<this>;
37
- /** Writes validated, serialized JSON and publishes the set event on success. */
38
- private write;
39
- /** Returns the stored value, or undefined when the key is absent. */
40
- get(key: K): Promise<V | undefined>;
41
- /** Returns whether the key exists, including when its value is falsey. */
42
- has(key: K): Promise<boolean>;
43
- /** Deletes a key and reports whether an entry existed. */
44
- delete(key: K): Promise<boolean>;
45
- /** Removes every entry after queued writes. */
46
- clear(): Promise<void>;
47
- /** Resolves to the number of entries in the current snapshot. */
48
- get size(): Promise<number>;
49
- /**
50
- * Iterates a snapshot in LMDB key order, releasing the cursor on early exit.
51
- * A prefix seeks to its contiguous key interval and stops on leaving it, so
52
- * the cost depends on matching entries rather than database size.
53
- */
54
- entries(options?: IteratorOptions<K>): AsyncIterableIterator<[K, V]>;
55
- /** Iterates keys with the same range semantics as entries(). */
56
- keys(options?: IteratorOptions<K>): AsyncIterableIterator<K>;
57
- /** Iterates values with the same range semantics as entries(). */
58
- values(options?: IteratorOptions<K>): AsyncIterableIterator<V>;
59
- /** Returns the asynchronous entries iterator. */
60
- [Symbol.asyncIterator](): AsyncIterableIterator<[K, V]>;
61
- /** Awaits each callback in snapshot key order; stops and rejects on the first failure. */
62
- forEach(callback: (value: V, key: K, store: this) => unknown, thisArg?: unknown): Promise<void>;
63
- /** Closes the database after outstanding writes; repeated calls are safe. */
64
- close(): Promise<void>;
65
- /** Closes and removes the entire database directory. Never pass a shared directory. */
7
+ /** Refuses to close or remove protected locations. Use a dedicated directory. */
66
8
  destroy(): Promise<void>;
67
9
  }
68
10
  export default FlashStore;
@@ -1 +1 @@
1
- {"version":3,"file":"flash-store.d.ts","sourceRoot":"","sources":["../../src/flash-store.ts"],"names":[],"mappings":"AAYA,4FAA4F;AAC5F,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAEtC,oFAAoF;AACpF,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IAC5D,EAAE,CAAC,EAAE,CAAC,CAAA;IACN,GAAG,CAAC,EAAE,CAAC,CAAA;IACP,EAAE,CAAC,EAAE,CAAC,CAAA;IACN,GAAG,CAAC,EAAE,CAAC,CAAA;IACP,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAID,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,CAU/C;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKhD;AA0BD;;;GAGG;AACH,eAAO,IAAI,eAAe,EAAE,CAAC,CAAC,SAAS,QAAQ,EAC7C,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,CAAC,EACN,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,IAAI,CAAC,CAAA;AAoClB;;;G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ED,iDAAiD;IACjD,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAGtD;IAED,0FAA0F;IACpF,OAAO,CACX,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,KAAK,OAAO,EACpD,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,CAIf;IAED,6EAA6E;IACvE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;IAED,uFAAuF;IACjF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAY7B;CACF;eAEc,UAAU"}
1
+ {"version":3,"file":"flash-store.d.ts","sourceRoot":"","sources":["../../src/flash-store.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAIrE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAoGtE,iEAAiE;AACjE,qBAAa,UAAU,CACrB,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,GAAG,OAAO,CACX,SAAQ,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5B,yDAAyD;IACzD,YAAY,OAAO,EAAE,MAAM,EAG1B;IAED,iFAAiF;IAClE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAUtC;CACF;eAEc,UAAU"}
@@ -1,235 +1,98 @@
1
1
  /**
2
- * Implements the asynchronous Map-like API over an LMDB environment.
3
- * It owns the database lifecycle, key validation, and JSON serialization. The
4
- * synchronous facade builds on this API and its internal serialized-write hook.
2
+ * Binds the public native FlashStore constructor to LMDB. Filesystem paths,
3
+ * destruction safeguards, and Node diagnostics stay behind this entry point.
5
4
  */
6
5
  import { channel } from 'node:diagnostics_channel';
7
6
  import { rm } from 'node:fs/promises';
8
7
  import { homedir, tmpdir } from 'node:os';
9
8
  import { parse, resolve } from 'node:path';
10
9
  import { IF_EXISTS, open } from 'lmdb';
11
- import { log, VERSION } from './config.js';
10
+ import { FlashStoreCore } from './flash-store-core.js';
11
+ import { encodePrefixEnd } from './key-encoding.js';
12
12
  const operations = channel('flash-store.operation');
13
- /** Reject keys that the configured ordered-binary encoding cannot represent safely. */
14
- export function validateKey(key) {
15
- if ((typeof key === 'number' && !Number.isFinite(key)) ||
16
- (typeof key === 'string' && key.includes('\0')) ||
17
- (typeof key !== 'number' && typeof key !== 'string')) {
18
- throw new TypeError('Keys must be finite numbers or strings without null characters');
19
- }
20
- }
21
- /** Serialize a value once, rejecting values that JSON cannot represent. */
22
- export function serialize(value) {
23
- const serialized = JSON.stringify(value);
24
- if (serialized === undefined)
25
- throw new TypeError('Value must be JSON serializable');
26
- return serialized;
27
- }
28
- /**
29
- * Return the smallest string after every string starting with `prefix`, or
30
- * undefined when none exists. LMDB orders strings by UTF-8 bytes, which matches
31
- * code point order, so matching keys form one contiguous interval.
32
- */
33
- function prefixEnd(prefix) {
34
- const codePoints = Array.from(prefix);
35
- while (codePoints.length > 0) {
36
- const last = codePoints.pop()?.codePointAt(0);
37
- if (last !== undefined && last < 0x10ffff) {
38
- // Surrogate code points are not encodable scalar values; skip them.
39
- const next = last === 0xd7ff ? 0xe000 : last + 1;
40
- return codePoints.join('') + String.fromCodePoint(next);
41
- }
42
- }
43
- return undefined;
44
- }
45
- /** Start reverse prefix scans just below the interval end, or at the database end. */
46
- function prefixRange(prefix) {
47
- const end = prefixEnd(prefix);
48
- return { start: end, reverse: true, exclusiveStart: end !== undefined };
49
- }
50
- /**
51
- * Writes pre-serialized JSON for FlashStoreSync, which serializes at call time.
52
- * Internal: mod.ts does not export it, and package exports expose only mod.ts.
53
- */
54
- export let writeSerialized;
55
- /** Use Map's zero equality; TypeScript represents both signs as the same numeric type. */
56
- function normalizeKey(key) {
57
- return Object.is(key, -0) ? 0 : key;
58
- }
59
- /** Reject ambiguous bounds before creating an LMDB cursor. */
60
- function validateOptions(options) {
61
- if (options.prefix !== undefined && typeof options.prefix !== 'string') {
62
- throw new TypeError('prefix must be a string');
63
- }
64
- if ((options.gt !== undefined && options.gte !== undefined) ||
65
- (options.lt !== undefined && options.lte !== undefined) ||
66
- (options.prefix !== undefined &&
67
- (options.gt !== undefined ||
68
- options.gte !== undefined ||
69
- options.lt !== undefined ||
70
- options.lte !== undefined))) {
71
- throw new TypeError('Conflicting range bounds');
72
- }
73
- if (options.limit !== undefined &&
74
- (!Number.isSafeInteger(options.limit) || options.limit < 0)) {
75
- throw new RangeError('limit must be a non-negative safe integer');
76
- }
77
- for (const bound of [options.gt, options.gte, options.lt, options.lte]) {
78
- if (bound !== undefined)
79
- validateKey(bound);
80
- }
81
- }
82
- /**
83
- * Persistent key-value store. Values use JSON round-tripping, which may change their
84
- * runtime type; the generic value type does not validate or prevent this.
85
- */
86
- export class FlashStore {
87
- static VERSION = VERSION;
88
- workdir;
13
+ /** Adapts the existing LMDB layout without changing its key encoding or JSON bytes. */
14
+ class LmdbBackend {
89
15
  db;
90
- closePromise;
91
- static {
92
- writeSerialized = (store, key, serialized) => store.write(key, serialized);
93
- }
94
- /** Opens an LMDB database in the specified directory. */
95
- constructor(workdir) {
96
- this.workdir = resolve(workdir);
97
- this.db = open({
98
- path: this.workdir,
99
- noSubdir: false,
100
- // Values are serialized once before writing, using LMDB's JSON byte format.
101
- encoding: 'string',
102
- });
103
- log.verbose('FlashStore', 'constructor(%s)', workdir);
104
- }
105
- /** Returns the package version. */
106
- version() {
107
- return VERSION;
108
- }
109
- /** Stores a JSON-serializable value and resolves after its write completes. */
110
- async set(key, value) {
111
- validateKey(key);
112
- const serialized = serialize(value);
113
- log.verbose('FlashStore', 'set(%s, %s)', key, typeof value);
114
- await this.write(key, serialized);
115
- return this;
116
- }
117
- /** Writes validated, serialized JSON and publishes the set event on success. */
118
- async write(key, serialized) {
119
- log.silly('FlashStore', 'set(%s, %s)', key, serialized);
120
- await this.db.put(normalizeKey(key), serialized);
121
- if (operations.hasSubscribers)
122
- operations.publish({ operation: 'set' });
123
- }
124
- /** Returns the stored value, or undefined when the key is absent. */
125
- async get(key) {
126
- validateKey(key);
127
- log.verbose('FlashStore', 'get(%s)', key);
128
- const value = this.db.get(normalizeKey(key));
129
- return value === undefined ? undefined : JSON.parse(value);
130
- }
131
- /** Returns whether the key exists, including when its value is falsey. */
132
- async has(key) {
133
- validateKey(key);
134
- return this.db.doesExist(normalizeKey(key));
135
- }
136
- /** Deletes a key and reports whether an entry existed. */
137
- async delete(key) {
138
- validateKey(key);
139
- log.verbose('FlashStore', 'delete(%s)', key);
140
- // A plain remove() resolves true even for absent keys; IF_EXISTS makes LMDB
141
- // report this operation's own result, in order with other queued writes.
142
- const deleted = await this.db.remove(normalizeKey(key), IF_EXISTS);
143
- if (operations.hasSubscribers)
144
- operations.publish({ operation: 'delete' });
145
- return deleted;
146
- }
147
- /** Removes every entry after queued writes. */
148
- async clear() {
149
- log.verbose('FlashStore', 'clear()');
150
- await this.db.clearAsync();
151
- if (operations.hasSubscribers)
152
- operations.publish({ operation: 'clear' });
153
- }
154
- /** Resolves to the number of entries in the current snapshot. */
155
- get size() {
156
- log.verbose('FlashStore', 'size()');
157
- return Promise.resolve().then(() => this.db.getCount());
158
- }
159
- /**
160
- * Iterates a snapshot in LMDB key order, releasing the cursor on early exit.
161
- * A prefix seeks to its contiguous key interval and stops on leaving it, so
162
- * the cost depends on matching entries rather than database size.
163
- */
164
- async *entries(options = {}) {
165
- log.verbose('FlashStore', '*entries(%s)', JSON.stringify(options));
166
- validateOptions(options);
167
- if (options.limit === 0)
168
- return;
169
- const reverse = options.reverse ?? false;
170
- const lowerBound = options.gte ?? options.gt;
171
- const upperBound = options.lte ?? options.lt;
172
- const lower = lowerBound === undefined ? undefined : normalizeKey(lowerBound);
173
- const upper = upperBound === undefined ? undefined : normalizeKey(upperBound);
174
- const { prefix } = options;
16
+ path;
17
+ /** Opens the existing on-disk database or creates a fresh environment. */
18
+ constructor(path) {
19
+ this.path = path;
20
+ this.db = open({ path, noSubdir: false, encoding: 'string' });
21
+ }
22
+ /** Enqueues a write of serialized JSON. */
23
+ put(key, json) {
24
+ return this.db.put(key, json);
25
+ }
26
+ /** Reads from the current transaction snapshot. */
27
+ get(key) {
28
+ return this.db.get(key);
29
+ }
30
+ /** Checks existence without decoding the value. */
31
+ has(key) {
32
+ return this.db.doesExist(key);
33
+ }
34
+ /** Reports existence in the transaction that performs the deletion. */
35
+ delete(key) {
36
+ // A plain remove() reports success even when the key was absent.
37
+ return this.db.remove(key, IF_EXISTS);
38
+ }
39
+ /** Queues an atomic clear. */
40
+ clear() {
41
+ return this.db.clearAsync();
42
+ }
43
+ /** Counts the entries in the current snapshot. */
44
+ async count() {
45
+ return this.db.getCount();
46
+ }
47
+ /** Seeks directly to the range and releases the LMDB cursor on early exit. */
48
+ *scan({ lower, upper, lowerOpen, upperOpen, reverse, prefix, limit, }) {
49
+ const endOfPrefix = reverse && prefix !== undefined ? encodePrefixEnd(prefix) : undefined;
175
50
  const range = prefix === undefined
176
51
  ? {
177
52
  start: reverse ? upper : lower,
178
53
  end: reverse ? lower : upper,
179
54
  reverse,
180
- exclusiveStart: reverse
181
- ? options.lt !== undefined
182
- : options.gt !== undefined,
183
- inclusiveEnd: reverse
184
- ? options.gte !== undefined
185
- : options.lte !== undefined,
55
+ exclusiveStart: reverse ? upperOpen : lowerOpen,
56
+ inclusiveEnd: reverse ? !lowerOpen : !upperOpen,
186
57
  }
187
- : reverse
188
- ? prefixRange(prefix)
189
- : { start: prefix };
58
+ : {
59
+ start: reverse ? endOfPrefix : prefix,
60
+ reverse,
61
+ exclusiveStart: reverse && endOfPrefix !== undefined,
62
+ };
190
63
  let count = 0;
191
- for (const { key, value } of this.db.getRange(range)) {
192
- // Matching keys are contiguous, so the first mismatch ends the prefix.
64
+ for (const entry of this.db.getRange(range)) {
193
65
  if (prefix !== undefined &&
194
- (typeof key !== 'string' || !key.startsWith(prefix)))
66
+ (typeof entry.key !== 'string' || !entry.key.startsWith(prefix)))
195
67
  break;
196
- yield [key, JSON.parse(value)];
197
- if (++count === options.limit)
68
+ yield entry;
69
+ if (++count === limit)
198
70
  break;
199
71
  }
200
72
  }
201
- /** Iterates keys with the same range semantics as entries(). */
202
- async *keys(options = {}) {
203
- log.verbose('FlashStore', 'keys()');
204
- for await (const [key] of this.entries(options))
205
- yield key;
73
+ /** Flushes pending writes and closes LMDB. */
74
+ close() {
75
+ return this.db.close();
206
76
  }
207
- /** Iterates values with the same range semantics as entries(). */
208
- async *values(options = {}) {
209
- log.verbose('FlashStore', 'values()');
210
- for await (const [, value] of this.entries(options))
211
- yield value;
77
+ /** Removes the dedicated directory after the facade closes the environment. */
78
+ destroy() {
79
+ return rm(this.path, { recursive: true, force: true });
212
80
  }
213
- /** Returns the asynchronous entries iterator. */
214
- [Symbol.asyncIterator]() {
215
- log.verbose('FlashStore', '*[Symbol.asyncIterator]()');
216
- return this.entries();
217
- }
218
- /** Awaits each callback in snapshot key order; stops and rejects on the first failure. */
219
- async forEach(callback, thisArg) {
220
- log.verbose('FlashStore', 'forEach()');
221
- for await (const [key, value] of this)
222
- await callback.call(thisArg, value, key, this);
81
+ /** Publishes the operation name after a successful commit without storing caller data. */
82
+ publish(operation) {
83
+ if (operations.hasSubscribers)
84
+ operations.publish({ operation });
223
85
  }
224
- /** Closes the database after outstanding writes; repeated calls are safe. */
225
- async close() {
226
- log.verbose('FlashStore', 'close()');
227
- this.closePromise ??= this.db.close();
228
- await this.closePromise;
86
+ }
87
+ /** Persistent Map backed by LMDB with JSON-serialized values. */
88
+ export class FlashStore extends FlashStoreCore {
89
+ /** Opens an LMDB database in the specified directory. */
90
+ constructor(workdir) {
91
+ const path = resolve(workdir);
92
+ super(path, new LmdbBackend(path), workdir);
229
93
  }
230
- /** Closes and removes the entire database directory. Never pass a shared directory. */
94
+ /** Refuses to close or remove protected locations. Use a dedicated directory. */
231
95
  async destroy() {
232
- log.verbose('FlashStore', 'destroy()');
233
96
  const protectedPaths = [
234
97
  parse(this.workdir).root,
235
98
  resolve(process.cwd()),
@@ -238,8 +101,7 @@ export class FlashStore {
238
101
  ];
239
102
  if (protectedPaths.includes(this.workdir))
240
103
  throw new Error('Refusing to remove a protected directory');
241
- await this.close();
242
- await rm(this.workdir, { recursive: true, force: true });
104
+ await super.destroy();
243
105
  }
244
106
  }
245
107
  export default FlashStore;
@@ -1 +1 @@
1
- {"version":3,"file":"flash-store.js","sourceRoot":"","sources":["../../src/flash-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAqB,MAAM,MAAM,CAAA;AACzD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAgB1C,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAEnD,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAC,GAAa;IACvC,IACE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClD,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,EACpD,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,gEAAgE,CACjE,CAAA;IACH,CAAC;AACH,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,MAAM,UAAU,GAAG,IAAI,CA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