@harperfast/rocksdb-js 2.4.1 → 2.6.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.
package/dist/index.d.mts CHANGED
@@ -1,104 +1,121 @@
1
1
  import { ExtendedIterable } from "@harperfast/extended-iterable";
2
-
3
2
  //#region src/backup.d.ts
4
3
  /**
5
- * Options for creating a backup via `db.backup()`.
6
- *
7
- * Backups are whole-database: every column family, the manifest, and (unless
8
- * `backupLogFiles` is disabled) the write-ahead log are captured. A backup is
9
- * not scoped to an individual `Store`.
10
- */
4
+ * Options for creating a backup via `db.backup()`.
5
+ *
6
+ * Backups are whole-database: every column family, the manifest, and (unless
7
+ * `backupLogFiles` is disabled) the write-ahead log are captured. A backup is
8
+ * not scoped to an individual `Store`.
9
+ */
11
10
  interface BackupOptions {
12
11
  /**
13
- * Include write-ahead log files in the backup. Defaults to `true`.
14
- */
12
+ * Include write-ahead log files in the backup. Defaults to `true`.
13
+ */
15
14
  backupLogFiles?: boolean;
16
15
  /**
17
- * Flush the memtable before backing up. Defaults to `true` when the database
18
- * was opened with `disableWAL` (otherwise unflushed data would be lost from
19
- * the backup), and `false` otherwise.
20
- */
16
+ * Preflight the destination volume and reject the backup when it lacks room.
17
+ * Defaults to `true`. The rejection is an I/O error whose message reports the
18
+ * available and required bytes (it is not distinguishable by an `err.code`).
19
+ *
20
+ * The required size is estimated conservatively as a *full* copy of the
21
+ * database's live files, plus the transaction-log snapshot when
22
+ * `transactionLogs` is enabled (a backup only ever copies files, so this can
23
+ * never under-estimate the bytes written). For incremental backups to a
24
+ * right-sized volume this may over-reject — set `false` to skip the check in
25
+ * that case. The check also self-disables when free space is unknowable (e.g.
26
+ * some network filesystems report 0), so it never blocks a backup on an
27
+ * untrustworthy number.
28
+ *
29
+ * Only applies to directory-target backups; the streaming backup path is
30
+ * unaffected.
31
+ */
32
+ checkDiskSpace?: boolean;
33
+ /**
34
+ * Flush the memtable before backing up. Defaults to `true` when the database
35
+ * was opened with `disableWAL` (otherwise unflushed data would be lost from
36
+ * the backup), and `false` otherwise.
37
+ */
21
38
  flushBeforeBackup?: boolean;
22
39
  /**
23
- * Number of background threads used to copy files. Defaults to `1`.
24
- */
40
+ * Number of background threads used to copy files. Defaults to `1`.
41
+ */
25
42
  maxBackgroundOperations?: number;
26
43
  /**
27
- * Arbitrary application metadata stored with the backup and returned by
28
- * `backups.list()`.
29
- */
44
+ * Arbitrary application metadata stored with the backup and returned by
45
+ * `backups.list()`.
46
+ */
30
47
  metadata?: string;
31
48
  /**
32
- * Distinguish shared files by checksum to avoid collisions across databases.
33
- * Defaults to `true`. Only relevant when `shareTableFiles` is enabled.
34
- */
49
+ * Distinguish shared files by checksum to avoid collisions across databases.
50
+ * Defaults to `true`. Only relevant when `shareTableFiles` is enabled.
51
+ */
35
52
  shareFilesWithChecksum?: boolean;
36
53
  /**
37
- * Share table/blob files between backups in the same directory to enable
38
- * incremental backups. Defaults to `true`.
39
- */
54
+ * Share table/blob files between backups in the same directory to enable
55
+ * incremental backups. Defaults to `true`.
56
+ */
40
57
  shareTableFiles?: boolean;
41
58
  /**
42
- * `fsync` backup files — including the transaction log snapshot when
43
- * `transactionLogs` is enabled — for crash consistency. Defaults to `true`.
44
- */
59
+ * `fsync` backup files — including the transaction log snapshot when
60
+ * `transactionLogs` is enabled — for crash consistency. Defaults to `true`.
61
+ */
45
62
  sync?: boolean;
46
63
  /**
47
- * Snapshot the transaction log store into
48
- * `<backupDir>/transaction_logs/<backupId>/`. Defaults to `false`. This is an
49
- * all-or-nothing snapshot per backup (not incremental); `backups.delete()` and
50
- * `backups.purge()` remove the corresponding log snapshots, and
51
- * `backups.restore()` restores them into the database directory.
52
- *
53
- * The snapshot is staged and atomically renamed into place after every file
54
- * is copied (and fsynced, per `sync`), so a crash mid-backup can never leave
55
- * a partial snapshot: a backup id either has its complete log snapshot or
56
- * none at all.
57
- *
58
- * The log snapshot is captured just after the RocksDB engine snapshot, so it
59
- * may include entries committed between the two — the restored logs can run
60
- * slightly ahead of the restored key-value data, never behind it. That bias
61
- * is safe for redo-style logs that are replayed against the restored data.
62
- */
64
+ * Snapshot the transaction log store into
65
+ * `<backupDir>/transaction_logs/<backupId>/`. Defaults to `false`. This is an
66
+ * all-or-nothing snapshot per backup (not incremental); `backups.delete()` and
67
+ * `backups.purge()` remove the corresponding log snapshots, and
68
+ * `backups.restore()` restores them into the database directory.
69
+ *
70
+ * The snapshot is staged and atomically renamed into place after every file
71
+ * is copied (and fsynced, per `sync`), so a crash mid-backup can never leave
72
+ * a partial snapshot: a backup id either has its complete log snapshot or
73
+ * none at all.
74
+ *
75
+ * The log snapshot is captured just after the RocksDB engine snapshot, so it
76
+ * may include entries committed between the two — the restored logs can run
77
+ * slightly ahead of the restored key-value data, never behind it. That bias
78
+ * is safe for redo-style logs that are replayed against the restored data.
79
+ */
63
80
  transactionLogs?: boolean;
64
81
  }
65
82
  /**
66
- * The level of incremental restore to perform.
67
- *
68
- * - `purgeAllFiles` (default): purge the destination directory and restore all
69
- * files from the backup. Destructive but always correct.
70
- * - `keepLatestDbSessionIdFiles`: efficiently restore a healthy database,
71
- * reusing existing files that match the backup.
72
- * - `verifyChecksum`: reuse existing destination files whose checksums match the
73
- * backup, replacing only mismatched/corrupt files.
74
- */
83
+ * The level of incremental restore to perform.
84
+ *
85
+ * - `purgeAllFiles` (default): purge the destination directory and restore all
86
+ * files from the backup. Destructive but always correct.
87
+ * - `keepLatestDbSessionIdFiles`: efficiently restore a healthy database,
88
+ * reusing existing files that match the backup.
89
+ * - `verifyChecksum`: reuse existing destination files whose checksums match the
90
+ * backup, replacing only mismatched/corrupt files.
91
+ */
75
92
  type RestoreMode = "purgeAllFiles" | "keepLatestDbSessionIdFiles" | "verifyChecksum";
76
93
  /**
77
- * Options for restoring a backup via `backups.restore()`.
78
- */
94
+ * Options for restoring a backup via `backups.restore()`.
95
+ */
79
96
  interface RestoreOptions {
80
97
  /**
81
- * The backup id to restore. Defaults to the latest non-corrupt backup.
82
- */
98
+ * The backup id to restore. Defaults to the latest non-corrupt backup.
99
+ */
83
100
  backupId?: number;
84
101
  /**
85
- * Directory to restore write-ahead log files into. Defaults to the database
86
- * directory.
87
- */
102
+ * Directory to restore write-ahead log files into. Defaults to the database
103
+ * directory.
104
+ */
88
105
  walDir?: string;
89
106
  /**
90
- * Keep existing log files in `walDir` rather than overwriting them. Defaults
91
- * to `false`.
92
- */
107
+ * Keep existing log files in `walDir` rather than overwriting them. Defaults
108
+ * to `false`.
109
+ */
93
110
  keepLogFiles?: boolean;
94
111
  /**
95
- * The restore strategy. Defaults to `purgeAllFiles`, which is destructive.
96
- */
112
+ * The restore strategy. Defaults to `purgeAllFiles`, which is destructive.
113
+ */
97
114
  mode?: RestoreMode;
98
115
  }
99
116
  /**
100
- * Information about a single backup, as returned by `backups.list()`.
101
- */
117
+ * Information about a single backup, as returned by `backups.list()`.
118
+ */
102
119
  interface BackupInfo {
103
120
  /** The backup id (monotonically increasing integer). */
104
121
  backupId: number;
@@ -112,45 +129,64 @@ interface BackupInfo {
112
129
  appMetadata: string;
113
130
  }
114
131
  /**
115
- * Backup management operations that act on a backup directory and do not
116
- * require an open database. To create a backup, use the `db.backup()` instance
117
- * method instead (it needs a live database for a consistent snapshot).
118
- *
119
- * @example
120
- * ```typescript
121
- * import { backups } from '@harperfast/rocksdb-js';
122
- *
123
- * const id = await db.backup('/path/to/backups');
124
- * db.close();
125
- * await backups.restore('/path/to/backups', '/path/to/restored-db');
126
- * ```
127
- */
132
+ * Backup management operations that act on a backup directory and do not
133
+ * require an open database. To create a backup, use the `db.backup()` instance
134
+ * method instead (it needs a live database for a consistent snapshot).
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * import { backups } from '@harperfast/rocksdb-js';
139
+ *
140
+ * const id = await db.backup('/path/to/backups');
141
+ * db.close();
142
+ * await backups.restore('/path/to/backups', '/path/to/restored-db');
143
+ * ```
144
+ */
128
145
  declare const backups: {
129
146
  /**
130
- * Restores a database from a backup directory into a (closed) database
131
- * directory. The default mode purges the destination directory, so it must
132
- * not point at a live database.
133
- */
147
+ * Restores a database from a backup directory into a (closed) database
148
+ * directory. The default mode purges the destination directory, so it must
149
+ * not point at a live database.
150
+ *
151
+ * Holds the backup directory lock in shared mode for the duration: multiple
152
+ * restores can read concurrently, but a writer (`db.backup()`, `delete`,
153
+ * `purge`) rejects while a restore is in flight rather than deleting files
154
+ * out from under it — and a restore rejects while a writer holds the lock.
155
+ *
156
+ * The shared lock needs no write access to `backupDir`, so restoring from a
157
+ * read-only backup directory (immutable/WORM store, read-only-mounted volume)
158
+ * works: the lock is taken on an existing `.backup.lock` read-only, degrading
159
+ * to a no-op only when the media is read-only for every process (`EROFS`). A
160
+ * mere permission denial hard-fails instead — it doesn't prove a privileged
161
+ * writer isn't running.
162
+ */
134
163
  restore(backupDir: string, dbDir: string, options?: RestoreOptions): Promise<void>;
135
164
  /**
136
- * Lists the non-corrupt backups in a backup directory, ordered by id.
137
- */
165
+ * Lists the non-corrupt backups in a backup directory, ordered by id.
166
+ */
138
167
  list(backupDir: string): Promise<BackupInfo[]>;
139
168
  /**
140
- * Deletes a specific backup. Shared files are reference-counted and only
141
- * removed once no remaining backup references them.
142
- */
169
+ * Deletes a specific backup. Shared files are reference-counted and only
170
+ * removed once no remaining backup references them.
171
+ */
143
172
  delete(backupDir: string, backupId: number): Promise<void>;
144
173
  /**
145
- * Deletes all but the newest `keepCount` backups.
146
- */
174
+ * Deletes all but the newest `keepCount` backups.
175
+ */
147
176
  purge(backupDir: string, keepCount: number): Promise<void>;
148
177
  /**
149
- * Verifies a backup's file sizes, and optionally their checksums (which
150
- * requires reading all backed-up data).
151
- */
178
+ * Verifies a backup's file sizes, and optionally their checksums (which
179
+ * requires reading all backed-up data).
180
+ *
181
+ * When the backup was created with `transactionLogs: true`, the backup's
182
+ * transaction log snapshot (`<backupDir>/transaction_logs/<backupId>/`) is
183
+ * also validated — every log file's header and entry framing must be intact
184
+ * (snapshots are copied on committed entry boundaries, so even a torn tail
185
+ * is a verification failure). Set `verifyTransactionLogs: false` to skip.
186
+ */
152
187
  verify(backupDir: string, backupId: number, options?: {
153
188
  verifyWithChecksum?: boolean;
189
+ verifyTransactionLogs?: boolean;
154
190
  }): Promise<void>;
155
191
  };
156
192
  //#endregion
@@ -190,14 +226,14 @@ interface DBIteratorValue<T> {
190
226
  value: T;
191
227
  }
192
228
  /**
193
- * Wraps the `NativeIterator` C++ binding, decoding keys and values from the
194
- * shared key/value buffers (fast path) or from per-iteration buffers (slow
195
- * fallback path used for oversized data or stable-buffer decoders).
196
- *
197
- * The native `next()` returns a primitive signal (and writes lengths to the
198
- * shared `ITERATOR_STATE` buffer) instead of constructing a JS result object,
199
- * so this class is responsible for building the `IteratorResult`.
200
- */
229
+ * Wraps the `NativeIterator` C++ binding, decoding keys and values from the
230
+ * shared key/value buffers (fast path) or from per-iteration buffers (slow
231
+ * fallback path used for oversized data or stable-buffer decoders).
232
+ *
233
+ * The native `next()` returns a primitive signal (and writes lengths to the
234
+ * shared `ITERATOR_STATE` buffer) instead of constructing a JS result object,
235
+ * so this class is responsible for building the `IteratorResult`.
236
+ */
201
237
  declare class DBIterator<T> implements Iterator<DBIteratorValue<T>> {
202
238
  #private;
203
239
  iterator: InstanceType<typeof NativeIteratorCls>;
@@ -221,9 +257,51 @@ type CompactOptions = {
221
257
  end?: Key;
222
258
  };
223
259
  /**
224
- * Options for the `Store` class.
225
- */
226
- interface StoreOptions extends Omit<NativeDatabaseOptions, "mode" | "transactionLogRetentionMs"> {
260
+ * A RocksDB block/blob compression algorithm. Which algorithms are actually
261
+ * available depends on the libraries the native binding was compiled with —
262
+ * check `supportedCompression` at runtime. `'none'` disables compression and
263
+ * is always available.
264
+ */
265
+ type CompressionAlgorithm = "none" | "snappy" | "zlib" | "bzip2" | "lz4" | "lz4hc" | "xpress" | "zstd";
266
+ /**
267
+ * The `compression` open option: either an algorithm name, or an object with
268
+ * an algorithm and an optional level (forwarded to RocksDB's
269
+ * `compression_opts.level`; meaning is algorithm-specific).
270
+ */
271
+ type CompressionOption = CompressionAlgorithm | {
272
+ algorithm: CompressionAlgorithm;
273
+ level?: number;
274
+ };
275
+ /**
276
+ * The compression currently in effect for a column family, as returned by the
277
+ * `compression` getter. `level` is present only when a non-default compression
278
+ * level is configured.
279
+ */
280
+ type CompressionInfo = {
281
+ algorithm: CompressionAlgorithm;
282
+ level?: number;
283
+ };
284
+ /**
285
+ * Options for the `Store` class.
286
+ */
287
+ interface StoreOptions extends Omit<NativeDatabaseOptions, "compression" | "compressionLevel" | "mode" | "transactionLogRetentionMs"> {
288
+ /**
289
+ * The block/blob compression algorithm for this column family. Accepts an
290
+ * algorithm name (`'lz4'`, `'zstd'`, `'none'`, ...) or an object with an
291
+ * `algorithm` and optional `level`. Applies to both SST blocks and blob
292
+ * files (large values). Which algorithms are available depends on the native
293
+ * build — see `supportedCompression`.
294
+ *
295
+ * When omitted, defaults to `lz4` if the build supports it, otherwise
296
+ * RocksDB's own default (Snappy when linked, else no compression).
297
+ * Compression is a dynamically-changeable option: reopening with a
298
+ * different algorithm governs subsequently written files; existing files
299
+ * keep their compression until rewritten by compaction. Use the
300
+ * `compression` getter to read the value currently in effect.
301
+ *
302
+ * @default 'lz4'
303
+ */
304
+ compression?: CompressionOption;
227
305
  decoder?: Encoder | null;
228
306
  encoder?: Encoder | null;
229
307
  encoding?: Encoding;
@@ -236,266 +314,293 @@ interface StoreOptions extends Omit<NativeDatabaseOptions, "mode" | "transaction
236
314
  maxKeySize?: number;
237
315
  pessimistic?: boolean;
238
316
  /**
239
- * If `true`, the encoder will use a random access structure.
240
- */
317
+ * If `true`, the encoder will use a random access structure.
318
+ */
241
319
  randomAccessStructure?: boolean;
242
320
  /**
243
- * When `true`, the database is opened in read-only mode. Write operations
244
- * will throw an error with code `ERR_DATABASE_READONLY`.
245
- */
321
+ * When `true`, the database is opened in read-only mode. Write operations
322
+ * will throw an error with code `ERR_DATABASE_READONLY`.
323
+ */
246
324
  readOnly?: boolean;
247
325
  sharedStructuresKey?: symbol;
248
326
  /**
249
- * A string containing the amount of time or the number of milliseconds to
250
- * retain transaction logs before purging.
251
- *
252
- * @default '3d' (3 days)
253
- */
327
+ * A string containing the amount of time or the number of milliseconds to
328
+ * retain transaction logs before purging.
329
+ *
330
+ * @default '3d' (3 days)
331
+ */
254
332
  transactionLogRetention?: number | string;
255
333
  }
256
334
  /**
257
- * Options for the `getUserSharedBuffer()` method.
258
- */
335
+ * Options for the `getUserSharedBuffer()` method.
336
+ */
259
337
  type UserSharedBufferOptions = {
260
338
  callback?: UserSharedBufferCallback;
261
339
  };
262
340
  /**
263
- * The return type of `getUserSharedBuffer()`.
264
- */
341
+ * The return type of `getUserSharedBuffer()`.
342
+ */
265
343
  type ArrayBufferWithNotify = ArrayBuffer & {
266
344
  cancel: () => void;
267
345
  notify: () => void;
268
346
  };
269
347
  /**
270
- * A store wraps the `NativeDatabase` binding and database settings so that a
271
- * single database instance can be shared between the main `RocksDatabase`
272
- * instance and the `Transaction` instance.
273
- *
274
- * This store should not be shared between `RocksDatabase` instances.
275
- */
348
+ * A store wraps the `NativeDatabase` binding and database settings so that a
349
+ * single database instance can be shared between the main `RocksDatabase`
350
+ * instance and the `Transaction` instance.
351
+ *
352
+ * A store is bound to a single `RocksDatabase` instance and must not be shared
353
+ * between `RocksDatabase` instances. Each `RocksDatabase` claims its store on
354
+ * construction (see `claim()`); passing a store that another `RocksDatabase`
355
+ * already owns throws. (Sharing with the owning database's `Transaction`
356
+ * instances is expected and allowed.)
357
+ */
276
358
  declare class Store {
359
+ #private;
277
360
  /**
278
- * The database instance.
279
- */
361
+ * The database instance.
362
+ */
280
363
  db: NativeDatabase;
281
364
  /**
282
- * The decoder instance. This is commonly the same as the `encoder`
283
- * instance.
284
- */
365
+ * The decoder instance. This is commonly the same as the `encoder`
366
+ * instance.
367
+ */
285
368
  decoder: Encoder | null;
286
369
  /**
287
- * Whether the decoder copies the buffer when encoding values.
288
- */
370
+ * Whether the decoder copies the buffer when encoding values.
371
+ */
289
372
  decoderCopies: boolean;
290
373
  /**
291
- * Whether to disable the write ahead log.
292
- */
374
+ * The compression algorithm (or `{ algorithm, level }`) requested for this
375
+ * store's column family. Normalized and applied when the database opens.
376
+ */
377
+ compression?: CompressionOption;
378
+ /**
379
+ * Whether to disable the write ahead log.
380
+ */
293
381
  disableWAL: boolean;
294
382
  /**
295
- * Whether to enable RocksDB statistics.
296
- */
383
+ * Whether to enable RocksDB statistics.
384
+ */
297
385
  enableStats: boolean;
298
386
  /**
299
- * Reusable buffer for encoding values using `writeKey()` when the custom
300
- * encoder does not provide a `encode()` method.
301
- */
387
+ * Reusable buffer for encoding values using `writeKey()` when the custom
388
+ * encoder does not provide a `encode()` method.
389
+ */
302
390
  encodeBuffer: BufferWithDataView;
303
391
  /**
304
- * The encoder instance.
305
- */
392
+ * The encoder instance.
393
+ */
306
394
  encoder: Encoder | null;
307
395
  /**
308
- * The encoding used to encode values. Defaults to `'msgpack'` in
309
- * `RocksDatabase.open()`.
310
- */
396
+ * The encoding used to encode values. Defaults to `'msgpack'` in
397
+ * `RocksDatabase.open()`.
398
+ */
311
399
  encoding: Encoding | null;
312
400
  /**
313
- * Encoder specific option used to signal that the data should be frozen.
314
- */
401
+ * Encoder specific option used to signal that the data should be frozen.
402
+ */
315
403
  freezeData: boolean;
316
404
  /**
317
- * Reusable buffer for encoding keys.
318
- */
405
+ * Reusable buffer for encoding keys.
406
+ */
319
407
  keyBuffer: BufferWithDataView;
320
408
  /**
321
- * The key encoding to use for keys. Defaults to `'ordered-binary'`.
322
- */
409
+ * The key encoding to use for keys. Defaults to `'ordered-binary'`.
410
+ */
323
411
  keyEncoding: KeyEncoding;
324
412
  /**
325
- * The maximum key size.
326
- */
413
+ * The maximum key size.
414
+ */
327
415
  maxKeySize: number;
328
416
  /**
329
- * The maximum number of memtables that can be queued per column family
330
- * before writes stall. Higher values absorb write bursts while flushes catch
331
- * up, at the cost of memory.
332
- */
417
+ * The maximum number of table files RocksDB keeps open. `0` (the default)
418
+ * derives a budget from the effective per-process open-file limit (an
419
+ * eighth of the limit — several databases can share one process — clamped
420
+ * to `[1024, 262144]`); `-1` holds every table file open (the RocksDB
421
+ * default, which can exhaust the process file-descriptor limit when
422
+ * compaction falls behind under sustained ingest); a positive `int32` is
423
+ * an explicit cap.
424
+ */
425
+ maxOpenFiles?: number;
426
+ /**
427
+ * The maximum number of memtables that can be queued per column family
428
+ * before writes stall. Higher values absorb write bursts while flushes catch
429
+ * up, at the cost of memory.
430
+ */
333
431
  maxWriteBufferNumber?: number;
334
432
  /**
335
- * The bytes of recent memtable history to retain in memory for transaction
336
- * conflict checking. `-1` derives the value from
337
- * `maxWriteBufferNumber * writeBufferSize`.
338
- */
433
+ * The bytes of recent memtable history to retain in memory for transaction
434
+ * conflict checking. `-1` derives the value from
435
+ * `maxWriteBufferNumber * writeBufferSize`.
436
+ */
339
437
  maxWriteBufferSizeToMaintain?: number;
340
438
  /**
341
- * The total memtable budget in bytes across all column families. When the
342
- * sum of memtables reaches this size, RocksDB flushes the largest one. `0`
343
- * disables the global trigger so per-CF `writeBufferSize` drives flushing.
344
- */
439
+ * The total memtable budget in bytes across all column families. When the
440
+ * sum of memtables reaches this size, RocksDB flushes the largest one. `0`
441
+ * disables the global trigger so per-CF `writeBufferSize` drives flushing.
442
+ */
345
443
  dbWriteBufferSize?: number;
346
444
  /**
347
- * The name of the store (e.g. the column family). Defaults to `'default'`.
348
- */
445
+ * The name of the store (e.g. the column family). Defaults to `'default'`.
446
+ */
349
447
  name: string;
350
448
  /**
351
- * Whether to disable the block cache.
352
- */
449
+ * Whether to disable the block cache.
450
+ */
353
451
  noBlockCache?: boolean;
354
452
  /**
355
- * The number of threads to use for parallel operations. This is a RocksDB
356
- * option. When undefined, the native layer picks
357
- * `max(1, hardware_concurrency() / 2)`.
358
- */
453
+ * The number of threads to use for parallel operations. This is a RocksDB
454
+ * option. When undefined, the native layer picks
455
+ * `max(1, hardware_concurrency() / 2)`.
456
+ */
359
457
  parallelismThreads?: number;
360
458
  /**
361
- * The path to the database.
362
- */
459
+ * The path to the database.
460
+ */
363
461
  path: string;
364
462
  /**
365
- * Whether to use pessimistic locking for transactions. When `true`,
366
- * transactions will fail as soon as a conflict is detected. When `false`,
367
- * transactions will only fail when `commit()` is called.
368
- */
463
+ * Whether to use pessimistic locking for transactions. When `true`,
464
+ * transactions will fail as soon as a conflict is detected. When `false`,
465
+ * transactions will only fail when `commit()` is called.
466
+ */
369
467
  pessimistic: boolean;
370
468
  /**
371
- * Whether the database is open in readonly mode. When `true`, write
372
- * operations will throw an error with code `ERR_DATABASE_READONLY`.
373
- */
469
+ * Whether the database is open in readonly mode. When `true`, write
470
+ * operations will throw an error with code `ERR_DATABASE_READONLY`.
471
+ */
374
472
  readOnly: boolean;
375
473
  /**
376
- * Encoder specific flag used to signal that the encoder should use a random
377
- * access structure.
378
- */
474
+ * Encoder specific flag used to signal that the encoder should use a random
475
+ * access structure.
476
+ */
379
477
  randomAccessStructure: boolean;
380
478
  /**
381
- * The function used to encode keys.
382
- */
479
+ * The function used to encode keys.
480
+ */
383
481
  readKey: ReadKeyFunction<Key>;
384
482
  /**
385
- * The key used to store shared structures.
386
- */
483
+ * The key used to store shared structures.
484
+ */
387
485
  sharedStructuresKey?: symbol;
388
486
  /**
389
- * The level of statistics to capture.
390
- */
487
+ * The level of statistics to capture.
488
+ */
391
489
  statsLevel?: (typeof stats.StatsLevel)[keyof typeof stats.StatsLevel];
392
490
  /**
393
- * The threshold for the transaction log file's last modified time to be
394
- * older than the retention period before it is rotated to the next sequence
395
- * number. A threshold of 0 means ignore age check.
396
- */
491
+ * The threshold for the transaction log file's last modified time to be
492
+ * older than the retention period before it is rotated to the next sequence
493
+ * number. A threshold of 0 means ignore age check.
494
+ */
397
495
  transactionLogMaxAgeThreshold?: number;
398
496
  /**
399
- * The maximum size of a transaction log before it is rotated to the next
400
- * sequence number.
401
- */
497
+ * The maximum size of a transaction log before it is rotated to the next
498
+ * sequence number.
499
+ */
402
500
  transactionLogMaxSize?: number;
403
501
  /**
404
- * A string containing the amount of time or the number of milliseconds to
405
- * retain transaction logs before purging.
406
- *
407
- * @default '3d' (3 days)
408
- */
502
+ * A string containing the amount of time or the number of milliseconds to
503
+ * retain transaction logs before purging.
504
+ *
505
+ * @default '3d' (3 days)
506
+ */
409
507
  transactionLogRetention?: number | string;
410
508
  /**
411
- * The path to the transaction logs directory.
412
- */
509
+ * The path to the transaction logs directory.
510
+ */
413
511
  transactionLogsPath?: string;
414
512
  /**
415
- * Whether this store's column family participates in the VerificationTable.
416
- */
513
+ * Whether this store's column family participates in the VerificationTable.
514
+ */
417
515
  verificationTable?: boolean;
418
516
  /**
419
- * The per-column-family memtable size in bytes at which the memtable is
420
- * sealed and flushed.
421
- */
517
+ * The per-column-family memtable size in bytes at which the memtable is
518
+ * sealed and flushed.
519
+ */
422
520
  writeBufferSize?: number;
423
521
  /**
424
- * The function used to encode keys using the shared `keyBuffer`.
425
- */
522
+ * The function used to encode keys using the shared `keyBuffer`.
523
+ */
426
524
  writeKey: WriteKeyFunction;
427
525
  /**
428
- * Initializes the store with a new `NativeDatabase` instance.
429
- *
430
- * @param path - The path to the database.
431
- * @param options - The options for the store.
432
- */
526
+ * Initializes the store with a new `NativeDatabase` instance.
527
+ *
528
+ * @param path - The path to the database.
529
+ * @param options - The options for the store.
530
+ */
433
531
  constructor(path: string, options?: StoreOptions);
434
532
  /**
435
- * Closes the database.
436
- */
533
+ * Closes the database.
534
+ */
437
535
  close(): void;
438
536
  /**
439
- * Compacts the entire key range of the database asynchronously.
440
- * This triggers manual compaction which removes tombstones and reclaims space.
441
- *
442
- * @example
443
- * ```typescript
444
- * const db = RocksDatabase.open('/path/to/database');
445
- * await db.compact();
446
- * ```
447
- */
537
+ * Claims this store for a `RocksDatabase`. A store is bound to a single
538
+ * database instance, so claiming a store that another `RocksDatabase` has
539
+ * already claimed throws. The claim is durable across close/reopen, so a
540
+ * store reused after its owner temporarily closed still throws.
541
+ */
542
+ claim(): void;
543
+ /**
544
+ * Compacts the entire key range of the database asynchronously.
545
+ * This triggers manual compaction which removes tombstones and reclaims space.
546
+ *
547
+ * @example
548
+ * ```typescript
549
+ * const db = RocksDatabase.open('/path/to/database');
550
+ * await db.compact();
551
+ * ```
552
+ */
448
553
  compact(options?: CompactOptions): Promise<void>;
449
554
  /**
450
- * Creates a backup of the entire database (all column families) into the
451
- * given directory and resolves with the new backup id. Parent directories
452
- * are created as needed. See `backups` for restore and management.
453
- *
454
- * @example
455
- * ```typescript
456
- * const id = await db.backup('/path/to/backups');
457
- * ```
458
- */
555
+ * Creates a backup of the entire database (all column families) into the
556
+ * given directory and resolves with the new backup id. Parent directories
557
+ * are created as needed. See `backups` for restore and management.
558
+ *
559
+ * @example
560
+ * ```typescript
561
+ * const id = await db.backup('/path/to/backups');
562
+ * ```
563
+ */
459
564
  backup(backupDir: string, options?: BackupOptions): Promise<number>;
460
565
  backup(stream: WritableStream<Uint8Array>, options?: BackupStreamOptions): Promise<void>;
461
566
  /**
462
- * Compacts the entire key range of the database synchronously.
463
- * This triggers manual compaction which removes tombstones and reclaims space.
464
- *
465
- * @example
466
- * ```typescript
467
- * const db = RocksDatabase.open('/path/to/database');
468
- * db.compactSync();
469
- * ```
470
- */
567
+ * Compacts the entire key range of the database synchronously.
568
+ * This triggers manual compaction which removes tombstones and reclaims space.
569
+ *
570
+ * @example
571
+ * ```typescript
572
+ * const db = RocksDatabase.open('/path/to/database');
573
+ * db.compactSync();
574
+ * ```
575
+ */
471
576
  compactSync(options?: CompactOptions): void;
472
577
  /**
473
- * Decodes a key from the database.
474
- *
475
- * @param key - The key to decode.
476
- * @returns The decoded key.
477
- */
578
+ * Decodes a key from the database.
579
+ *
580
+ * @param key - The key to decode.
581
+ * @returns The decoded key.
582
+ */
478
583
  decodeKey(key: Buffer): Key;
479
584
  /**
480
- * Decodes a value from the database.
481
- *
482
- * @param value - The value to decode.
483
- * @returns The decoded value.
484
- */
585
+ * Decodes a value from the database.
586
+ *
587
+ * @param value - The value to decode.
588
+ * @returns The decoded value.
589
+ */
485
590
  decodeValue(value: BufferWithDataView): any;
486
591
  /**
487
- * Encodes a key for the database.
488
- *
489
- * @param key - The key to encode.
490
- * @returns The encoded key.
491
- */
592
+ * Encodes a key for the database.
593
+ *
594
+ * @param key - The key to encode.
595
+ * @returns The encoded key.
596
+ */
492
597
  encodeKey(key: Key): BufferWithDataView;
493
598
  /**
494
- * Encodes a value for the database.
495
- *
496
- * @param value - The value to encode.
497
- * @returns The encoded value.
498
- */
599
+ * Encodes a value for the database.
600
+ *
601
+ * @param value - The value to encode.
602
+ * @returns The encoded value.
603
+ */
499
604
  encodeValue(value: any): BufferWithDataView | Uint8Array;
500
605
  get(context: StoreContext, key: Key, alwaysCreateNewBuffer?: boolean, options?: StoreGetOptions): any | undefined;
501
606
  getCount(context: StoreContext, options?: StoreRangeOptions): number;
@@ -504,118 +609,118 @@ declare class Store {
504
609
  getRange(context: StoreContext, options?: StoreIteratorOptions): ExtendedIterable<DBIteratorValue<any>>;
505
610
  getSync(context: StoreContext, key: Key, alwaysCreateNewBuffer?: boolean, options?: StoreGetOptions): any | undefined;
506
611
  /**
507
- * Checks if the data method options object contains a transaction ID and
508
- * returns it.
509
- */
612
+ * Checks if the data method options object contains a transaction ID and
613
+ * returns it.
614
+ */
510
615
  getTxnId(options?: DBITransactional | unknown): number | undefined;
511
616
  /**
512
- * Gets or creates a buffer that can be shared across worker threads.
513
- *
514
- * @param key - The key to get or create the buffer for.
515
- * @param defaultBuffer - The default buffer to copy and use if the buffer
516
- * does not exist.
517
- * @param [options] - The options for the buffer.
518
- * @param [options.callback] - A optional callback is called when `notify()`
519
- * on the returned buffer is called.
520
- * @returns An `ArrayBuffer` that is internally backed by a rocksdb-js
521
- * managed buffer. The buffer also has `notify()` and `cancel()` methods
522
- * that can be used to notify the specified `options.callback`.
523
- */
617
+ * Gets or creates a buffer that can be shared across worker threads.
618
+ *
619
+ * @param key - The key to get or create the buffer for.
620
+ * @param defaultBuffer - The default buffer to copy and use if the buffer
621
+ * does not exist.
622
+ * @param [options] - The options for the buffer.
623
+ * @param [options.callback] - A optional callback is called when `notify()`
624
+ * on the returned buffer is called.
625
+ * @returns An `ArrayBuffer` that is internally backed by a rocksdb-js
626
+ * managed buffer. The buffer also has `notify()` and `cancel()` methods
627
+ * that can be used to notify the specified `options.callback`.
628
+ */
524
629
  getUserSharedBuffer(key: Key, defaultBuffer: ArrayBuffer, options?: UserSharedBufferOptions): ArrayBufferWithNotify;
525
630
  /**
526
- * Checks if a lock exists.
527
- * @param key The lock key.
528
- * @returns `true` if the lock exists, `false` otherwise
529
- */
631
+ * Checks if a lock exists.
632
+ * @param key The lock key.
633
+ * @returns `true` if the lock exists, `false` otherwise
634
+ */
530
635
  hasLock(key: Key): boolean;
531
636
  /**
532
- * Checks if the database is open.
533
- *
534
- * @returns `true` if the database is open, `false` otherwise.
535
- */
637
+ * Checks if the database is open.
638
+ *
639
+ * @returns `true` if the database is open, `false` otherwise.
640
+ */
536
641
  isOpen(): boolean;
537
642
  /**
538
- * Lists all transaction log names.
539
- *
540
- * @returns an array of transaction log names.
541
- */
643
+ * Lists all transaction log names.
644
+ *
645
+ * @returns an array of transaction log names.
646
+ */
542
647
  listLogs(): string[];
543
648
  /**
544
- * Opens the database. This must be called before any database operations
545
- * are performed.
546
- */
649
+ * Opens the database. This must be called before any database operations
650
+ * are performed.
651
+ */
547
652
  open(): boolean;
548
653
  putSync(context: StoreContext, key: Key, value: any, options?: StorePutOptions): void;
549
654
  removeSync(context: StoreContext, key: Key, options?: StoreRemoveOptions): void;
550
655
  /**
551
- * Attempts to acquire a lock for a given key. If the lock is available,
552
- * the function returns `true` and the optional callback is never called.
553
- * If the lock is not available, the function returns `false` and the
554
- * callback is queued until the lock is released.
555
- *
556
- * @param key - The key to lock.
557
- * @param onUnlocked - A callback to call when the lock is released.
558
- * @returns `true` if the lock was acquired, `false` otherwise.
559
- */
656
+ * Attempts to acquire a lock for a given key. If the lock is available,
657
+ * the function returns `true` and the optional callback is never called.
658
+ * If the lock is not available, the function returns `false` and the
659
+ * callback is queued until the lock is released.
660
+ *
661
+ * @param key - The key to lock.
662
+ * @param onUnlocked - A callback to call when the lock is released.
663
+ * @returns `true` if the lock was acquired, `false` otherwise.
664
+ */
560
665
  tryLock(key: Key, onUnlocked?: () => void): boolean;
561
666
  /**
562
- * Releases the lock on the given key and calls any queued `onUnlocked`
563
- * callback handlers.
564
- *
565
- * @param key - The key to unlock.
566
- */
667
+ * Releases the lock on the given key and calls any queued `onUnlocked`
668
+ * callback handlers.
669
+ *
670
+ * @param key - The key to unlock.
671
+ */
567
672
  unlock(key: Key): void;
568
673
  /**
569
- * Gets or creates a transaction log instance.
570
- *
571
- * @param context - The context to use for the transaction log.
572
- * @param name - The name of the transaction log.
573
- * @returns The transaction log.
574
- */
674
+ * Gets or creates a transaction log instance.
675
+ *
676
+ * @param context - The context to use for the transaction log.
677
+ * @param name - The name of the transaction log.
678
+ * @returns The transaction log.
679
+ */
575
680
  useLog(context: StoreContext, name: string | number): TransactionLog;
576
681
  /**
577
- * Checks the process-global verification table for a fresh version match
578
- * on `key`. Returns `true` when the table currently records `version` for
579
- * this database+column-family. Provides a fast cache-freshness check
580
- * before falling back to a full read.
581
- */
682
+ * Checks the process-global verification table for a fresh version match
683
+ * on `key`. Returns `true` when the table currently records `version` for
684
+ * this database+column-family. Provides a fast cache-freshness check
685
+ * before falling back to a full read.
686
+ */
582
687
  verifyVersion(key: Key, version: number): boolean;
583
688
  /**
584
- * Seeds the verification-table slot for `key` with `version`. Has no
585
- * effect if the slot is currently lock-tagged or the table is disabled.
586
- * Useful after a full read where the caller already knows the version.
587
- */
689
+ * Seeds the verification-table slot for `key` with `version`. Has no
690
+ * effect if the slot is currently lock-tagged or the table is disabled.
691
+ * Useful after a full read where the caller already knows the version.
692
+ */
588
693
  populateVersion(key: Key, version: number): void;
589
694
  /**
590
- * Acquires a lock on the given key and calls the callback.
591
- *
592
- * @param key - The key to lock.
593
- * @param callback - The callback to call when the lock is acquired.
594
- * @returns A promise that resolves when the lock is acquired.
595
- */
695
+ * Acquires a lock on the given key and calls the callback.
696
+ *
697
+ * @param key - The key to lock.
698
+ * @param callback - The callback to call when the lock is acquired.
699
+ * @returns A promise that resolves when the lock is acquired.
700
+ */
596
701
  withLock(key: Key, callback: () => void | Promise<void>): Promise<void>;
597
702
  }
598
703
  interface GetOptions {
599
704
  /**
600
- * When set, the native layer checks the verification table before reading.
601
- * If the slot holds this version, returns `FRESH_VERSION_FLAG` immediately
602
- * (the cached value is still valid). After a DB read, also seeds the slot
603
- * with the version extracted from the value.
604
- */
705
+ * When set, the native layer checks the verification table before reading.
706
+ * If the slot holds this version, returns `FRESH_VERSION_FLAG` immediately
707
+ * (the cached value is still valid). After a DB read, also seeds the slot
708
+ * with the version extracted from the value.
709
+ */
605
710
  expectedVersion?: number;
606
711
  /**
607
- * When `true`, after a DB read the native layer automatically seeds the
608
- * verification-table slot with the version extracted from the value.
609
- * Eliminates the need for a separate `populateVersion` call on cold reads.
610
- *
611
- * @default false
612
- */
712
+ * When `true`, after a DB read the native layer automatically seeds the
713
+ * verification-table slot with the version extracted from the value.
714
+ * Eliminates the need for a separate `populateVersion` call on cold reads.
715
+ *
716
+ * @default false
717
+ */
613
718
  populateVersion?: boolean;
614
719
  /**
615
- * Whether to skip decoding the value.
616
- *
617
- * @default false
618
- */
720
+ * Whether to skip decoding the value.
721
+ *
722
+ * @default false
723
+ */
619
724
  skipDecode?: boolean;
620
725
  }
621
726
  interface PutOptions {
@@ -627,55 +732,55 @@ interface PutOptions {
627
732
  //#endregion
628
733
  //#region src/transaction.d.ts
629
734
  /**
630
- * Sentinel value returned by `commit()` when `coordinatedRetry: true` and the
631
- * transaction encountered an IsBusy conflict. The native layer parks on VT
632
- * slots and resolves only after the conflicting transaction releases its write
633
- * intent, so callers should retry immediately without any backoff delay.
634
- */
735
+ * Sentinel value returned by `commit()` when `coordinatedRetry: true` and the
736
+ * transaction encountered an IsBusy conflict. The native layer parks on VT
737
+ * slots and resolves only after the conflicting transaction releases its write
738
+ * intent, so callers should retry immediately without any backoff delay.
739
+ */
635
740
  declare const RETRY_NOW: number;
636
741
  /**
637
- * Provides transaction level operations to a transaction callback.
638
- */
742
+ * Provides transaction level operations to a transaction callback.
743
+ */
639
744
  declare class Transaction extends DBI {
640
745
  #private;
641
746
  /**
642
- * Create a new transaction.
643
- *
644
- * @param store - The base store interface for this transaction.
645
- * @param options - The options for the transaction.
646
- */
747
+ * Create a new transaction.
748
+ *
749
+ * @param store - The base store interface for this transaction.
750
+ * @param options - The options for the transaction.
751
+ */
647
752
  constructor(store: Store, options?: NativeTransactionOptions);
648
753
  /**
649
- * Abort the transaction.
650
- */
754
+ * Abort the transaction.
755
+ */
651
756
  abort(): void;
652
757
  /**
653
- * Commit the transaction.
654
- *
655
- * Returns `RETRY_NOW` when `coordinatedRetry: true` and an IsBusy conflict
656
- * was detected. The caller should retry the transaction body immediately.
657
- */
758
+ * Commit the transaction.
759
+ *
760
+ * Returns `RETRY_NOW` when `coordinatedRetry: true` and an IsBusy conflict
761
+ * was detected. The caller should retry the transaction body immediately.
762
+ */
658
763
  commit(): Promise<typeof RETRY_NOW | void>;
659
764
  /**
660
- * Commit the transaction synchronously.
661
- */
765
+ * Commit the transaction synchronously.
766
+ */
662
767
  commitSync(): void;
663
768
  /**
664
- * Returns the transaction start timestamp in seconds. Defaults to the time at which
665
- * the transaction was created.
666
- *
667
- * @returns The transaction start timestamp in seconds.
668
- */
769
+ * Returns the transaction start timestamp in seconds. Defaults to the time at which
770
+ * the transaction was created.
771
+ *
772
+ * @returns The transaction start timestamp in seconds.
773
+ */
669
774
  getTimestamp(): number;
670
775
  /**
671
- * Get the transaction id.
672
- */
776
+ * Get the transaction id.
777
+ */
673
778
  get id(): number;
674
779
  /**
675
- * Set the transaction start timestamp in seconds.
676
- *
677
- * @param timestamp - The timestamp to set in seconds.
678
- */
780
+ * Set the transaction start timestamp in seconds.
781
+ *
782
+ * @param timestamp - The timestamp to set in seconds.
783
+ */
679
784
  setTimestamp(timestamp?: number): void;
680
785
  }
681
786
  //#endregion
@@ -685,317 +790,317 @@ type MaybePromise<T> = T | Promise<T>;
685
790
  //#region src/dbi.d.ts
686
791
  interface RocksDBOptions {
687
792
  /**
688
- * When `true`, RocksDB will do some enhancements for prefetching the data.
689
- * Defaults to `true`. Note that RocksDB defaults this to `false`.
690
- */
793
+ * When `true`, RocksDB will do some enhancements for prefetching the data.
794
+ * Defaults to `true`. Note that RocksDB defaults this to `false`.
795
+ */
691
796
  adaptiveReadahead?: boolean;
692
797
  /**
693
- * When `true`, RocksDB will prefetch some data async and apply it if reads
694
- * are sequential and its internal automatic prefetching. Defaults to
695
- * `true`. Note that RocksDB defaults this to `false`.
696
- */
798
+ * When `true`, RocksDB will prefetch some data async and apply it if reads
799
+ * are sequential and its internal automatic prefetching. Defaults to
800
+ * `true`. Note that RocksDB defaults this to `false`.
801
+ */
697
802
  asyncIO?: boolean;
698
803
  /**
699
- * When `true`, RocksDB will auto-tune the readahead size during scans
700
- * internally based on the block cache data when block caching is enabled,
701
- * an end key (e.g. upper bound) is set, and prefix is the same as the start
702
- * key. Defaults to `true`.
703
- */
804
+ * When `true`, RocksDB will auto-tune the readahead size during scans
805
+ * internally based on the block cache data when block caching is enabled,
806
+ * an end key (e.g. upper bound) is set, and prefix is the same as the start
807
+ * key. Defaults to `true`.
808
+ */
704
809
  autoReadaheadSize?: boolean;
705
810
  /**
706
- * When `true`, after the iterator is closed, a background job is scheduled
707
- * to flush the job queue and delete obsolete files. Defaults to `true`.
708
- * Note that RocksDB defaults this to `false`.
709
- */
811
+ * When `true`, after the iterator is closed, a background job is scheduled
812
+ * to flush the job queue and delete obsolete files. Defaults to `true`.
813
+ * Note that RocksDB defaults this to `false`.
814
+ */
710
815
  backgroundPurgeOnIteratorCleanup?: boolean;
711
816
  /**
712
- * When `true`, the iterator will fill the block cache. Filling the block
713
- * cache is not desirable for bulk scans and could impact eviction order.
714
- * Defaults to `false`. Note that RocksDB defaults this to `true`.
715
- */
817
+ * When `true`, the iterator will fill the block cache. Filling the block
818
+ * cache is not desirable for bulk scans and could impact eviction order.
819
+ * Defaults to `false`. Note that RocksDB defaults this to `true`.
820
+ */
716
821
  fillCache?: boolean;
717
822
  /**
718
- * The RocksDB readahead size. RocksDB does auto-readahead for iterators
719
- * when there is more than two reads for a table file. The readahead
720
- * starts at 8KB and doubles on every additional read up to 256KB. This
721
- * option can help if most of the range scans are large and if a larger
722
- * readahead than that enabled by auto-readahead is needed. Using a large
723
- * readahead size (> 2MB) can typically improve the performance of forward
724
- * iteration on spinning disks. Defaults to `0`.
725
- */
823
+ * The RocksDB readahead size. RocksDB does auto-readahead for iterators
824
+ * when there is more than two reads for a table file. The readahead
825
+ * starts at 8KB and doubles on every additional read up to 256KB. This
826
+ * option can help if most of the range scans are large and if a larger
827
+ * readahead than that enabled by auto-readahead is needed. Using a large
828
+ * readahead size (> 2MB) can typically improve the performance of forward
829
+ * iteration on spinning disks. Defaults to `0`.
830
+ */
726
831
  readaheadSize?: number;
727
832
  /**
728
- * When `true`, creates a "tailing iterator" which is a special iterator
729
- * that has a view of the complete database including newly added data and
730
- * is optimized for sequential reads. This will return records that were
731
- * inserted into the database after the creation of the iterator. Defaults
732
- * to `false`.
733
- */
833
+ * When `true`, creates a "tailing iterator" which is a special iterator
834
+ * that has a view of the complete database including newly added data and
835
+ * is optimized for sequential reads. This will return records that were
836
+ * inserted into the database after the creation of the iterator. Defaults
837
+ * to `false`.
838
+ */
734
839
  tailing?: boolean;
735
840
  }
736
841
  interface RangeOptions extends RocksDBOptions {
737
842
  /**
738
- * The range end key, otherwise known as the "upper bound". Defaults to
739
- * the last key in the database.
740
- */
843
+ * The range end key, otherwise known as the "upper bound". Defaults to
844
+ * the last key in the database.
845
+ */
741
846
  end?: Key | Uint8Array;
742
847
  /**
743
- * When `true`, the iterator will exclude the first key if it matches the start key.
744
- * Defaults to `false`.
745
- */
848
+ * When `true`, the iterator will exclude the first key if it matches the start key.
849
+ * Defaults to `false`.
850
+ */
746
851
  exclusiveStart?: boolean;
747
852
  /**
748
- * When `true`, the iterator will include the last key if it matches the end
749
- * key. Defaults to `false`.
750
- */
853
+ * When `true`, the iterator will include the last key if it matches the end
854
+ * key. Defaults to `false`.
855
+ */
751
856
  inclusiveEnd?: boolean;
752
857
  /**
753
- * The range start key, otherwise known as the "lower bound". Defaults to
754
- * the first key in the database.
755
- */
858
+ * The range start key, otherwise known as the "lower bound". Defaults to
859
+ * the first key in the database.
860
+ */
756
861
  start?: Key | Uint8Array;
757
862
  }
758
863
  interface IteratorOptions extends RangeOptions {
759
864
  /**
760
- * The maximum number of entries to yield. When set, iteration stops after
761
- * `limit` entries regardless of the range bounds. Values <= 0 yield nothing.
762
- * Unset means no limit.
763
- */
865
+ * The maximum number of entries to yield. When set, iteration stops after
866
+ * `limit` entries regardless of the range bounds. Values <= 0 yield nothing.
867
+ * Unset means no limit.
868
+ */
764
869
  limit?: number;
765
870
  /**
766
- * A specific key to match which may result in zero, one, or many values.
767
- */
871
+ * A specific key to match which may result in zero, one, or many values.
872
+ */
768
873
  key?: Key;
769
874
  /**
770
- * When `true`, only returns the number of values for the given query.
771
- */
875
+ * When `true`, only returns the number of values for the given query.
876
+ */
772
877
  onlyCount?: boolean;
773
878
  /**
774
- * When `true`, the iterator will iterate in reverse order. Defaults to
775
- * `false`.
776
- */
879
+ * When `true`, the iterator will iterate in reverse order. Defaults to
880
+ * `false`.
881
+ */
777
882
  reverse?: boolean;
778
883
  /**
779
- * When `true`, decodes and returns the value. When `false`, the value is
780
- * omitted. Defaults to `true`.
781
- */
884
+ * When `true`, decodes and returns the value. When `false`, the value is
885
+ * omitted. Defaults to `true`.
886
+ */
782
887
  values?: boolean;
783
888
  /**
784
- * When `true`, the iterator will only return the values.
785
- */
889
+ * When `true`, the iterator will only return the values.
890
+ */
786
891
  valuesOnly?: boolean;
787
892
  }
788
893
  interface DBITransactional {
789
894
  transaction?: Transaction;
790
895
  }
791
896
  /**
792
- * The base class for all database operations. This base class is shared by
793
- * `RocksDatabase` and `Transaction`.
794
- *
795
- * This class is not meant to be used directly.
796
- */
897
+ * The base class for all database operations. This base class is shared by
898
+ * `RocksDatabase` and `Transaction`.
899
+ *
900
+ * This class is not meant to be used directly.
901
+ */
797
902
  declare class DBI<T extends DBITransactional | unknown = unknown> {
798
903
  /**
799
- * The RocksDB context for `get()`, `put()`, and `remove()`.
800
- */
904
+ * The RocksDB context for `get()`, `put()`, and `remove()`.
905
+ */
801
906
  _context: StoreContext;
802
907
  /**
803
- * The database store instance. The store instance is tied to the database
804
- * instance and shared with transaction instances.
805
- */
908
+ * The database store instance. The store instance is tied to the database
909
+ * instance and shared with transaction instances.
910
+ */
806
911
  store: Store;
807
912
  /**
808
- * Initializes the DBI context.
809
- *
810
- * @param store - The store instance.
811
- * @param transaction - The transaction instance.
812
- */
913
+ * Initializes the DBI context.
914
+ *
915
+ * @param store - The store instance.
916
+ * @param transaction - The transaction instance.
917
+ */
813
918
  constructor(store: Store, transaction?: NativeTransaction);
814
919
  /**
815
- * Adds a listener for the given key.
816
- *
817
- * @param event - The event name to add the listener for.
818
- * @param callback - The callback to add.
819
- */
920
+ * Adds a listener for the given key.
921
+ *
922
+ * @param event - The event name to add the listener for.
923
+ * @param callback - The callback to add.
924
+ */
820
925
  addListener(event: string, callback: (...args: any[]) => void): this;
821
926
  /**
822
- * Retrieves the value for the given key, then returns the decoded value.
823
- */
927
+ * Retrieves the value for the given key, then returns the decoded value.
928
+ */
824
929
  get(key: Key, options?: GetOptions & T): MaybePromise<any | undefined>;
825
930
  /**
826
- * Retrieves the binary data for the given key. This is just like `get()`,
827
- * but bypasses the decoder.
828
- *
829
- * Note: Used by HDBreplication.
830
- */
931
+ * Retrieves the binary data for the given key. This is just like `get()`,
932
+ * but bypasses the decoder.
933
+ *
934
+ * Note: Used by HDBreplication.
935
+ */
831
936
  getBinary(key: Key, options?: GetOptions & T): MaybePromise<Buffer | number | undefined>;
832
937
  /**
833
- * Synchronously retrieves the binary data for the given key.
834
- */
938
+ * Synchronously retrieves the binary data for the given key.
939
+ */
835
940
  getBinarySync(key: Key, options?: GetOptions & T): Buffer | number | undefined;
836
941
  /**
837
- * Retrieves the binary data for the given key using a preallocated,
838
- * reusable buffer. Data in the buffer is only valid until the next get
839
- * operation (including cursor operations).
840
- *
841
- * Note: The reusable buffer slightly differs from a typical buffer:
842
- * - `.length` is set to the size of the value
843
- * - `.byteLength` is set to the size of the full allocated memory area for
844
- * the buffer (usually much larger).
845
- */
942
+ * Retrieves the binary data for the given key using a preallocated,
943
+ * reusable buffer. Data in the buffer is only valid until the next get
944
+ * operation (including cursor operations).
945
+ *
946
+ * Note: The reusable buffer slightly differs from a typical buffer:
947
+ * - `.length` is set to the size of the value
948
+ * - `.byteLength` is set to the size of the full allocated memory area for
949
+ * the buffer (usually much larger).
950
+ */
846
951
  getBinaryFast(key: Key, options?: GetOptions & T): MaybePromise<Buffer | number | undefined>;
847
952
  /**
848
- * Synchronously retrieves the binary data for the given key using a
849
- * preallocated, reusable buffer. Data in the buffer is only valid until the
850
- * next get operation (including cursor operations).
851
- */
953
+ * Synchronously retrieves the binary data for the given key using a
954
+ * preallocated, reusable buffer. Data in the buffer is only valid until the
955
+ * next get operation (including cursor operations).
956
+ */
852
957
  getBinaryFastSync(key: Key, options?: GetOptions & T): Buffer | number | undefined;
853
958
  /**
854
- * Retrieves all keys within a range.
855
- */
959
+ * Retrieves all keys within a range.
960
+ */
856
961
  getKeys(options?: IteratorOptions & T): any | undefined;
857
962
  /**
858
- * Retrieves the number of keys within a range.
859
- *
860
- * @param options - The range options.
861
- * @returns The number of keys within the range.
862
- *
863
- * @example
864
- * ```typescript
865
- * const total = db.getKeysCount();
866
- * const range = db.getKeysCount({ start: 'a', end: 'z' });
867
- * ```
868
- */
963
+ * Retrieves the number of keys within a range.
964
+ *
965
+ * @param options - The range options.
966
+ * @returns The number of keys within the range.
967
+ *
968
+ * @example
969
+ * ```typescript
970
+ * const total = db.getKeysCount();
971
+ * const range = db.getKeysCount({ start: 'a', end: 'z' });
972
+ * ```
973
+ */
869
974
  getKeysCount(options?: RangeOptions & T): number;
870
975
  /**
871
- * Retrieves a range of keys and their values.
872
- *
873
- * @param options - The iterator options.
874
- * @returns A range iterable.
875
- *
876
- * @example
877
- * ```typescript
878
- * for (const { key, value } of db.getRange()) {
879
- * console.log({ key, value });
880
- * }
881
- *
882
- * for (const { key, value } of db.getRange({ start: 'a', end: 'z' })) {
883
- * console.log({ key, value });
884
- * }
885
- * ```
886
- */
976
+ * Retrieves a range of keys and their values.
977
+ *
978
+ * @param options - The iterator options.
979
+ * @returns A range iterable.
980
+ *
981
+ * @example
982
+ * ```typescript
983
+ * for (const { key, value } of db.getRange()) {
984
+ * console.log({ key, value });
985
+ * }
986
+ *
987
+ * for (const { key, value } of db.getRange({ start: 'a', end: 'z' })) {
988
+ * console.log({ key, value });
989
+ * }
990
+ * ```
991
+ */
887
992
  getRange(options?: IteratorOptions & T): any | undefined;
888
993
  /**
889
- * Synchronously retrieves the value for the given key, then returns the
890
- * decoded value.
891
- */
994
+ * Synchronously retrieves the value for the given key, then returns the
995
+ * decoded value.
996
+ */
892
997
  getSync(key: Key, options?: GetOptions & T): any | undefined;
893
998
  /**
894
- * Gets the number of listeners for the given key.
895
- *
896
- * @param event - The event name to get the listeners for.
897
- * @returns The number of listeners for the given key.
898
- */
999
+ * Gets the number of listeners for the given key.
1000
+ *
1001
+ * @param event - The event name to get the listeners for.
1002
+ * @returns The number of listeners for the given key.
1003
+ */
899
1004
  listeners(event: string | BufferWithDataView): number;
900
1005
  /**
901
- * Notifies an event for the given key.
902
- *
903
- * @param event - The event name to emit the event for.
904
- * @param args - The arguments to emit.
905
- * @returns `true` if there were listeners, `false` otherwise.
906
- */
1006
+ * Notifies an event for the given key.
1007
+ *
1008
+ * @param event - The event name to emit the event for.
1009
+ * @param args - The arguments to emit.
1010
+ * @returns `true` if there were listeners, `false` otherwise.
1011
+ */
907
1012
  notify(event: string, ...args: any[]): boolean;
908
1013
  /**
909
- * Alias for `removeListener()`.
910
- *
911
- * @param event - The event name to remove the listener for.
912
- * @param callback - The callback to remove.
913
- */
1014
+ * Alias for `removeListener()`.
1015
+ *
1016
+ * @param event - The event name to remove the listener for.
1017
+ * @param callback - The callback to remove.
1018
+ */
914
1019
  off(event: string, callback: (...args: any[]) => void): this;
915
1020
  /**
916
- * Alias for `addListener()`.
917
- *
918
- * @param event - The event name to add the listener for.
919
- * @param callback - The callback to add.
920
- */
1021
+ * Alias for `addListener()`.
1022
+ *
1023
+ * @param event - The event name to add the listener for.
1024
+ * @param callback - The callback to add.
1025
+ */
921
1026
  on(event: string, callback: (...args: any[]) => void): this;
922
1027
  /**
923
- * Adds a one-time listener, then automatically removes it.
924
- *
925
- * @param event - The event name to add the listener for.
926
- * @param callback - The callback to add.
927
- */
1028
+ * Adds a one-time listener, then automatically removes it.
1029
+ *
1030
+ * @param event - The event name to add the listener for.
1031
+ * @param callback - The callback to add.
1032
+ */
928
1033
  once(event: string, callback: (...args: any[]) => void): this;
929
1034
  /**
930
- * Stores a value for the given key.
931
- *
932
- * @param key - The key to store the value for.
933
- * @param value - The value to store.
934
- * @param options - The put options.
935
- * @returns The key and value.
936
- *
937
- * @example
938
- * ```typescript
939
- * await db.put('a', 'b');
940
- * ```
941
- */
1035
+ * Stores a value for the given key.
1036
+ *
1037
+ * @param key - The key to store the value for.
1038
+ * @param value - The value to store.
1039
+ * @param options - The put options.
1040
+ * @returns The key and value.
1041
+ *
1042
+ * @example
1043
+ * ```typescript
1044
+ * await db.put('a', 'b');
1045
+ * ```
1046
+ */
942
1047
  put(key: Key, value: any, options?: PutOptions & T): Promise<void>;
943
1048
  /**
944
- * Synchronously stores a value for the given key.
945
- *
946
- * @param key - The key to store the value for.
947
- * @param value - The value to store.
948
- * @param options - The put options.
949
- * @returns The key and value.
950
- *
951
- * @example
952
- * ```typescript
953
- * db.putSync('a', 'b');
954
- * ```
955
- */
1049
+ * Synchronously stores a value for the given key.
1050
+ *
1051
+ * @param key - The key to store the value for.
1052
+ * @param value - The value to store.
1053
+ * @param options - The put options.
1054
+ * @returns The key and value.
1055
+ *
1056
+ * @example
1057
+ * ```typescript
1058
+ * db.putSync('a', 'b');
1059
+ * ```
1060
+ */
956
1061
  putSync(key: Key, value: any, options?: PutOptions & T): void;
957
1062
  /**
958
- * Removes a value for the given key. If the key does not exist, it will
959
- * not error.
960
- *
961
- * @param key - The key to remove the value for.
962
- * @param options - The remove options.
963
- * @returns The key and value.
964
- *
965
- * @example
966
- * ```typescript
967
- * await db.remove('a');
968
- * ```
969
- */
1063
+ * Removes a value for the given key. If the key does not exist, it will
1064
+ * not error.
1065
+ *
1066
+ * @param key - The key to remove the value for.
1067
+ * @param options - The remove options.
1068
+ * @returns The key and value.
1069
+ *
1070
+ * @example
1071
+ * ```typescript
1072
+ * await db.remove('a');
1073
+ * ```
1074
+ */
970
1075
  remove(key: Key, options?: T): Promise<void>;
971
1076
  /**
972
- * Removes a value for the given key. If the key does not exist, it will
973
- * not error.
974
- *
975
- * @param key - The key to remove the value for.
976
- * @param options - The remove options.
977
- * @returns The key and value.
978
- *
979
- * @example
980
- * ```typescript
981
- * db.removeSync('a');
982
- * ```
983
- */
1077
+ * Removes a value for the given key. If the key does not exist, it will
1078
+ * not error.
1079
+ *
1080
+ * @param key - The key to remove the value for.
1081
+ * @param options - The remove options.
1082
+ * @returns The key and value.
1083
+ *
1084
+ * @example
1085
+ * ```typescript
1086
+ * db.removeSync('a');
1087
+ * ```
1088
+ */
984
1089
  removeSync(key: Key, options?: T): void;
985
1090
  /**
986
- * Removes an event listener. You must specify the exact same callback that was
987
- * used in `addListener()`.
988
- *
989
- * @param event - The event name to remove the listener for.
990
- * @param callback - The callback to remove.
991
- */
1091
+ * Removes an event listener. You must specify the exact same callback that was
1092
+ * used in `addListener()`.
1093
+ *
1094
+ * @param event - The event name to remove the listener for.
1095
+ * @param callback - The callback to remove.
1096
+ */
992
1097
  removeListener(event: string, callback: (value?: any) => void): boolean;
993
1098
  /**
994
- * Get or create a transaction log instance.
995
- *
996
- * @param name - The name of the transaction log.
997
- * @returns The transaction log.
998
- */
1099
+ * Get or create a transaction log instance.
1100
+ *
1101
+ * @param name - The name of the transaction log.
1102
+ * @returns The transaction log.
1103
+ */
999
1104
  useLog(name: string | number): TransactionLog;
1000
1105
  }
1001
1106
  //#endregion
@@ -1049,6 +1154,8 @@ type StatsBasics = {
1049
1154
  "txnlog.transactionsWritten": number;
1050
1155
  "txnlog.bytesWritten": number;
1051
1156
  "txnlog.replayGapBytes": number;
1157
+ "commitPipeline.logQueueDepth": number;
1158
+ "commitPipeline.commitQueueDepth": number;
1052
1159
  };
1053
1160
  type StatsCuratedExtras = {
1054
1161
  "rocksdb.block.cache.hit": number;
@@ -1367,24 +1474,132 @@ interface GetStatsMethod {
1367
1474
  getStats(all: true): StatsAll;
1368
1475
  }
1369
1476
  //#endregion
1477
+ //#region src/validate-transaction-log.d.ts
1478
+ /**
1479
+ * The validation result for a single transaction log file within a store, as
1480
+ * returned by {@link validateTransactionLogStore}.
1481
+ */
1482
+ interface TransactionLogFileValidation {
1483
+ /** File name relative to the store directory, e.g. `"3.txnlog"`. */
1484
+ file: string;
1485
+ /** Sequence number parsed from the file name. */
1486
+ sequence: number;
1487
+ /** On-disk file size in bytes. */
1488
+ size: number;
1489
+ /** Number of well-formed entry frames. */
1490
+ entries: number;
1491
+ /** End offset of the validly framed data (header + well-formed entries). */
1492
+ validBytes: number;
1493
+ /** `true` when `errors` is empty. */
1494
+ valid: boolean;
1495
+ /**
1496
+ * Conditions that make the file invalid: a bad/missing header, an
1497
+ * unsupported version, or a mid-file framing break. With `strict`, a torn
1498
+ * tail is also reported here.
1499
+ */
1500
+ errors: string[];
1501
+ /**
1502
+ * Conditions that do not invalidate the file: a torn tail (recoverable —
1503
+ * open-time recovery truncates it without losing committed entries) and
1504
+ * per-entry anomalies such as suspicious timestamps or undefined flag bits.
1505
+ */
1506
+ warnings: string[];
1507
+ }
1508
+ /**
1509
+ * The result of validating a transaction log store directory, as returned by
1510
+ * {@link validateTransactionLogStore}.
1511
+ */
1512
+ interface TransactionLogStoreValidation {
1513
+ /** The validated store directory. */
1514
+ path: string;
1515
+ /**
1516
+ * `true` when there are no store-level errors and every log file is valid.
1517
+ */
1518
+ valid: boolean;
1519
+ /** Per-file validation results, ordered by sequence number. */
1520
+ files: TransactionLogFileValidation[];
1521
+ /**
1522
+ * Store-level errors: malformed file names, an unreadable file, or a
1523
+ * corrupt `txn.state`.
1524
+ */
1525
+ errors: string[];
1526
+ /**
1527
+ * Store-level warnings: sequence gaps, unexpected directory entries, or an
1528
+ * implausible `txn.state` flushed position.
1529
+ */
1530
+ warnings: string[];
1531
+ }
1532
+ /**
1533
+ * Options for {@link validateTransactionLogStore}.
1534
+ */
1535
+ interface ValidateTransactionLogStoreOptions {
1536
+ /**
1537
+ * Report conditions that indicate an incomplete snapshot — a torn tail, a
1538
+ * sequence gap, or a `txn.state` flushed position beyond the newest log
1539
+ * file or beyond its file's actual size — as errors instead of warnings. A
1540
+ * torn tail on a live store is a normal crash artifact that open-time
1541
+ * recovery truncates, but a backup snapshot captures every surviving file
1542
+ * on committed entry boundaries and must be clean end to end —
1543
+ * `backups.verify()` validates snapshots with `strict: true`. Defaults to
1544
+ * `false`.
1545
+ */
1546
+ strict?: boolean;
1547
+ }
1548
+ /**
1549
+ * Validates a transaction log store directory: every `<sequence>.txnlog` file
1550
+ * is checked for a valid header (token, version) and intact v1 entry framing
1551
+ * (using the same scan as open-time crash recovery), file-name and sequence
1552
+ * continuity are checked, and the `txn.state` side file (when present) is
1553
+ * checked for shape and a plausible flushed position. The result reports
1554
+ * per-file entry counts, errors, and warnings; it does not throw when the
1555
+ * store is invalid — check `result.valid`.
1556
+ *
1557
+ * Runs entirely in native code on a worker thread and does not require (or
1558
+ * open) a database, so it works on the store of a closed database and on the
1559
+ * per-backup snapshots under `<backupDir>/transaction_logs/<backupId>/` alike.
1560
+ *
1561
+ * Validating a store that is being actively appended to can spuriously report
1562
+ * a torn tail for the current log file — the tail of an in-flight append is
1563
+ * indistinguishable from a crash artifact.
1564
+ *
1565
+ * Rejects if `path` does not exist or is not a directory (a bad argument, as
1566
+ * opposed to an invalid store).
1567
+ *
1568
+ * @param path The store directory, e.g. `<dbDir>/transaction_logs/<name>`.
1569
+ * @param options Validation options.
1570
+ *
1571
+ * @example
1572
+ * ```typescript
1573
+ * import { validateTransactionLogStore } from '@harperfast/rocksdb-js';
1574
+ *
1575
+ * const result = await validateTransactionLogStore('/path/to/db/transaction_logs/mylog');
1576
+ * if (!result.valid) {
1577
+ * for (const file of result.files) {
1578
+ * console.error(file.file, file.errors);
1579
+ * }
1580
+ * }
1581
+ * ```
1582
+ */
1583
+ declare function validateTransactionLogStore(path: string, options?: ValidateTransactionLogStoreOptions): Promise<TransactionLogStoreValidation>;
1584
+ //#endregion
1370
1585
  //#region src/load-binding.d.ts
1371
1586
  type NativeTransactionOptions = {
1372
1587
  /**
1373
- * Whether to disable snapshots.
1374
- *
1375
- * @default false
1376
- */
1588
+ * Whether to disable snapshots.
1589
+ *
1590
+ * @default false
1591
+ */
1377
1592
  disableSnapshot?: boolean;
1378
1593
  /**
1379
- * When `true`, an `IsBusy` conflict at commit time is resolved with the
1380
- * `RETRY_NOW` sentinel value instead of being rejected. The native layer
1381
- * may park on a VT slot before resolving, so the JS retry fires only after
1382
- * the conflicting transaction has committed and released its write intent.
1383
- *
1384
- * Use together with `verificationTable: true` on the database.
1385
- *
1386
- * @default false
1387
- */
1594
+ * When `true`, an `IsBusy` conflict at commit time is resolved with the
1595
+ * `RETRY_NOW` sentinel value instead of being rejected. The native layer
1596
+ * may park on a VT slot before resolving, so the JS retry fires only after
1597
+ * the conflicting transaction has committed and released its write intent.
1598
+ *
1599
+ * Use together with `verificationTable: true` on the database.
1600
+ *
1601
+ * @default false
1602
+ */
1388
1603
  coordinatedRetry?: boolean;
1389
1604
  };
1390
1605
  type NativeTransaction = {
@@ -1421,23 +1636,23 @@ type TransactionEntry = {
1421
1636
  endTxn: boolean;
1422
1637
  };
1423
1638
  /**
1424
- * A position within a transaction log, identifying a log file by its sequence
1425
- * number and a byte `offset` within that file.
1426
- */
1639
+ * A position within a transaction log, identifying a log file by its sequence
1640
+ * number and a byte `offset` within that file.
1641
+ */
1427
1642
  type TransactionLogPosition = {
1428
1643
  sequence: number;
1429
1644
  offset: number;
1430
1645
  };
1431
1646
  /**
1432
- * A detailed statistics snapshot for a single transaction log store, returned
1433
- * by {@link TransactionLog.getStats}. All sizes are in bytes; timestamps are
1434
- * milliseconds since the Unix epoch.
1435
- *
1436
- * Memory note: `memory.mappedBytes` is virtual address space — the active write
1437
- * file is mapped at the full configured `maxFileSize` on POSIX, so it does not
1438
- * reflect resident memory. `memory.overlayBytes` (POSIX only; 0 on Windows) is
1439
- * the file-backed portion and is the closer proxy for real consumption.
1440
- */
1647
+ * A detailed statistics snapshot for a single transaction log store, returned
1648
+ * by {@link TransactionLog.getStats}. All sizes are in bytes; timestamps are
1649
+ * milliseconds since the Unix epoch.
1650
+ *
1651
+ * Memory note: `memory.mappedBytes` is virtual address space — the active write
1652
+ * file is mapped at the full configured `maxFileSize` on POSIX, so it does not
1653
+ * reflect resident memory. `memory.overlayBytes` (POSIX only; 0 on Windows) is
1654
+ * the file-backed portion and is the closer proxy for real consumption.
1655
+ */
1441
1656
  type TransactionLogStats = {
1442
1657
  name: string;
1443
1658
  path: string;
@@ -1497,10 +1712,10 @@ type TransactionLog = {
1497
1712
  _logBuffers: Map<number, WeakRef<LogBuffer>>;
1498
1713
  };
1499
1714
  /**
1500
- * Shape of options that can be passed to the native iterator constructor for
1501
- * the rare case of advanced RocksDB ReadOptions overrides. Common iterator
1502
- * options are passed via the bitmask `flags` argument instead.
1503
- */
1715
+ * Shape of options that can be passed to the native iterator constructor for
1716
+ * the rare case of advanced RocksDB ReadOptions overrides. Common iterator
1717
+ * options are passed via the bitmask `flags` argument instead.
1718
+ */
1504
1719
  type NativeIteratorAdvancedOptions = {
1505
1720
  adaptiveReadahead?: boolean;
1506
1721
  asyncIO?: boolean;
@@ -1511,11 +1726,11 @@ type NativeIteratorAdvancedOptions = {
1511
1726
  tailing?: boolean;
1512
1727
  };
1513
1728
  /**
1514
- * The result of a single native iterator step. A number value matches one of
1515
- * the `ITERATOR_RESULT_*` constants. The slow-path object is returned when
1516
- * the data does not fit in the shared key/value buffers, or when the decoder
1517
- * needs a stable value buffer.
1518
- */
1729
+ * The result of a single native iterator step. A number value matches one of
1730
+ * the `ITERATOR_RESULT_*` constants. The slow-path object is returned when
1731
+ * the data does not fit in the shared key/value buffers, or when the decoder
1732
+ * needs a stable value buffer.
1733
+ */
1519
1734
  type NativeIteratorResult = number | {
1520
1735
  key: Buffer;
1521
1736
  value?: Buffer;
@@ -1528,9 +1743,22 @@ declare class NativeIteratorCls {
1528
1743
  }
1529
1744
  type NativeDatabaseMode = "optimistic" | "pessimistic";
1530
1745
  type NativeDatabaseOptions = {
1746
+ /**
1747
+ * The friendly name of a compression algorithm compiled into this RocksDB
1748
+ * build (see `supportedCompression`), e.g. `'lz4'`, `'zstd'`, `'none'`. The
1749
+ * higher-level `StoreOptions.compression` (which also accepts an object with
1750
+ * a level) is normalized down to this string plus `compressionLevel`.
1751
+ */
1752
+ compression?: string;
1753
+ /**
1754
+ * Compression level forwarded to RocksDB's `compression_opts.level`. Meaning
1755
+ * is algorithm-specific; omit to use the algorithm's default.
1756
+ */
1757
+ compressionLevel?: number;
1531
1758
  dbWriteBufferSize?: number;
1532
1759
  disableWAL?: boolean;
1533
1760
  enableStats?: boolean;
1761
+ maxOpenFiles?: number;
1534
1762
  maxWriteBufferNumber?: number;
1535
1763
  maxWriteBufferSizeToMaintain?: number;
1536
1764
  mode?: NativeDatabaseMode;
@@ -1544,11 +1772,11 @@ type NativeDatabaseOptions = {
1544
1772
  transactionLogRetentionMs?: number;
1545
1773
  transactionLogsPath?: string;
1546
1774
  /**
1547
- * When true, transaction writes to this column family invalidate the
1548
- * VerificationTable slot for each written key at write time (not at
1549
- * commit time). Enable only for column families whose records are
1550
- * cached (e.g. the primary CF of a table). Default: false.
1551
- */
1775
+ * When true, transaction writes to this column family invalidate the
1776
+ * VerificationTable slot for each written key at write time (not at
1777
+ * commit time). Enable only for column families whose records are
1778
+ * cached (e.g. the primary CF of a table). Default: false.
1779
+ */
1552
1780
  verificationTable?: boolean;
1553
1781
  writeBufferSize?: number;
1554
1782
  };
@@ -1559,16 +1787,16 @@ type PurgeLogsOptions = {
1559
1787
  before?: number;
1560
1788
  destroy?: boolean;
1561
1789
  /**
1562
- * When `true`, count the entries in each purged log file (extra work) and
1563
- * return `PurgedLog[]` instead of the default `string[]` of file paths.
1564
- */
1790
+ * When `true`, count the entries in each purged log file (extra work) and
1791
+ * return `PurgedLog[]` instead of the default `string[]` of file paths.
1792
+ */
1565
1793
  includeEntryCounts?: boolean;
1566
1794
  name?: string;
1567
1795
  };
1568
1796
  /**
1569
- * A purged transaction log file and the number of entries it held, returned by
1570
- * `purgeLogs()` when `includeEntryCounts` is `true`.
1571
- */
1797
+ * A purged transaction log file and the number of entries it held, returned by
1798
+ * `purgeLogs()` when `includeEntryCounts` is `true`.
1799
+ */
1572
1800
  type PurgedLog = {
1573
1801
  path: string;
1574
1802
  entries: number;
@@ -1595,6 +1823,10 @@ type NativeDatabase = {
1595
1823
  flushSync(): void;
1596
1824
  notify(event: string | BufferWithDataView, args?: any[]): boolean;
1597
1825
  get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
1826
+ getCompression(): {
1827
+ algorithm: string;
1828
+ level?: number;
1829
+ };
1598
1830
  getCount(options?: RangeOptions, txnId?: number): number;
1599
1831
  getDBIntProperty(propertyName: string): number | undefined;
1600
1832
  getDBProperty(propertyName: string): string | undefined;
@@ -1633,47 +1865,47 @@ type NativeDatabase = {
1633
1865
  type RocksDatabaseConfig = {
1634
1866
  blockCacheSize?: number;
1635
1867
  /**
1636
- * Number of slots in the process-global verification table. Each slot is
1637
- * 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
1638
- *
1639
- * Must be configured before the first database is opened. Once the table
1640
- * is materialized, attempts to change this value will throw.
1641
- */
1868
+ * Number of slots in the process-global verification table. Each slot is
1869
+ * 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
1870
+ *
1871
+ * Must be configured before the first database is opened. Once the table
1872
+ * is materialized, attempts to change this value will throw.
1873
+ */
1642
1874
  verificationTableEntries?: number;
1643
1875
  compactOnClose?: boolean;
1644
1876
  /**
1645
- * Total memtable memory limit (bytes) shared across every database opened
1646
- * in this process. When set, RocksDB uses a single `WriteBufferManager` so
1647
- * write buffers are bounded process-wide rather than per database. 0 (the
1648
- * default) disables the manager.
1649
- *
1650
- * Can be updated at runtime; the new size takes effect on the existing
1651
- * manager via `SetBufferSize`.
1652
- */
1877
+ * Total memtable memory limit (bytes) shared across every database opened
1878
+ * in this process. When set, RocksDB uses a single `WriteBufferManager` so
1879
+ * write buffers are bounded process-wide rather than per database. 0 (the
1880
+ * default) disables the manager.
1881
+ *
1882
+ * Can be updated at runtime; the new size takes effect on the existing
1883
+ * manager via `SetBufferSize`.
1884
+ */
1653
1885
  writeBufferManagerSize?: number;
1654
1886
  /**
1655
- * When `true`, memtable memory is "charged" against the shared block cache
1656
- * so the block cache and write buffers draw from a single pool. During
1657
- * write bursts the cache shrinks to make room for memtables; once
1658
- * memtables flush, the cache can grow back into the reclaimed space.
1659
- *
1660
- * Has no effect when the block cache is disabled (size 0) or
1661
- * `writeBufferManagerSize` is 0. Must be set on the same `config()` call
1662
- * that first enables the manager — changing it after the manager has been
1663
- * created has no effect on the running instance.
1664
- *
1665
- * @default false
1666
- */
1887
+ * When `true`, memtable memory is "charged" against the shared block cache
1888
+ * so the block cache and write buffers draw from a single pool. During
1889
+ * write bursts the cache shrinks to make room for memtables; once
1890
+ * memtables flush, the cache can grow back into the reclaimed space.
1891
+ *
1892
+ * Has no effect when the block cache is disabled (size 0) or
1893
+ * `writeBufferManagerSize` is 0. Must be set on the same `config()` call
1894
+ * that first enables the manager — changing it after the manager has been
1895
+ * created has no effect on the running instance.
1896
+ *
1897
+ * @default false
1898
+ */
1667
1899
  writeBufferManagerCostToCache?: boolean;
1668
1900
  /**
1669
- * When `true`, writes are stalled once the manager's `buffer_size` is
1670
- * exceeded, providing a hard cap on memtable memory. When `false`,
1671
- * memtables are allowed to grow past the limit and flushes are simply
1672
- * scheduled more aggressively. Off by default to favor write throughput
1673
- * over hard memory bounding.
1674
- *
1675
- * @default false
1676
- */
1901
+ * When `true`, writes are stalled once the manager's `buffer_size` is
1902
+ * exceeded, providing a hard cap on memtable memory. When `false`,
1903
+ * memtables are allowed to grow past the limit and flushes are simply
1904
+ * scheduled more aggressively. Off by default to favor write throughput
1905
+ * over hard memory bounding.
1906
+ *
1907
+ * @default false
1908
+ */
1677
1909
  writeBufferManagerAllowStall?: boolean;
1678
1910
  };
1679
1911
  type RegistryStatusDB = {
@@ -1694,10 +1926,10 @@ declare const constants: {
1694
1926
  POPULATE_VERSION_FLAG: number;
1695
1927
  FRESH_VERSION_FLAG: number;
1696
1928
  /**
1697
- * Sentinel value resolved (not rejected) by `commit()` when
1698
- * `coordinatedRetry: true` and the transaction encountered an IsBusy
1699
- * conflict. JS should retry the transaction body immediately.
1700
- */
1929
+ * Sentinel value resolved (not rejected) by `commit()` when
1930
+ * `coordinatedRetry: true` and the transaction encountered an IsBusy
1931
+ * conflict. JS should retry the transaction body immediately.
1932
+ */
1701
1933
  RETRY_NOW_VALUE: number;
1702
1934
  TRANSACTION_LOG_TOKEN: number;
1703
1935
  TRANSACTION_LOG_ENTRY_HEADER_SIZE: number;
@@ -1711,6 +1943,15 @@ declare const constants: {
1711
1943
  ITERATOR_RESULT_DONE: number;
1712
1944
  ITERATOR_RESULT_FAST: number;
1713
1945
  };
1946
+ /**
1947
+ * The friendly names of every compression algorithm compiled into the loaded
1948
+ * RocksDB native binding, e.g. `['none', 'snappy', 'lz4', 'zstd']`. The set is
1949
+ * fixed for a given binary (it depends on which compression libraries RocksDB
1950
+ * was linked against), so this is a static list. `'none'` (no compression) is
1951
+ * always present. Use it to validate a `compression` option or to pick an
1952
+ * algorithm that is actually available at runtime.
1953
+ */
1954
+ declare const supportedCompression: readonly string[];
1714
1955
  declare const NativeDatabase: NativeDatabase;
1715
1956
  declare const NativeTransaction: NativeTransaction;
1716
1957
  declare const TransactionLog: TransactionLog;
@@ -1718,36 +1959,38 @@ declare const registryStatus: () => RegistryStatus;
1718
1959
  declare const shutdown: () => void;
1719
1960
  declare const currentThreadId: () => number;
1720
1961
  /**
1721
- * Advises the kernel that the file-backed pages of every mapped transaction log
1722
- * are cold (Linux MADV_COLD), so they are reclaimed first under memory pressure
1723
- * without being freed — useful during replication catch-up, where a full read of
1724
- * the logs would otherwise inflate the container's reclaimable cache toward its
1725
- * cgroup limit. No-op on kernels < 5.4, macOS, and Windows.
1726
- *
1727
- * The transaction log registry is a process-global singleton shared across all
1728
- * worker threads, so a single call cools every worker's maps. Call it on an
1729
- * interval from one thread (e.g. an `unref()`ed timer on the main thread).
1730
- *
1731
- * @returns the number of maps cooled and total file-backed bytes advised.
1732
- */
1962
+ * Advises the kernel that the file-backed pages of every mapped transaction log
1963
+ * are cold (Linux MADV_COLD), so they are reclaimed first under memory pressure
1964
+ * without being freed — useful during replication catch-up, where a full read of
1965
+ * the logs would otherwise inflate the container's reclaimable cache toward its
1966
+ * cgroup limit. No-op on kernels < 5.4, macOS, and Windows.
1967
+ *
1968
+ * The transaction log registry is a process-global singleton shared across all
1969
+ * worker threads, so a single call cools every worker's maps. Call it on an
1970
+ * interval from one thread (e.g. an `unref()`ed timer on the main thread).
1971
+ *
1972
+ * @returns the number of maps cooled and total file-backed bytes advised.
1973
+ */
1733
1974
  declare const coolTransactionLogs: () => {
1734
1975
  maps: number;
1735
1976
  bytes: number;
1736
1977
  };
1737
1978
  /**
1738
- * Creates a native file lock using the specified file path (`flock` on POSIX,
1739
- * `LockFileEx` on Windows). Returns an opaque non-zero token to pass to
1740
- * `fileLockRelease`, or `0` if another holder — in any process, container, or
1741
- * worker thread — currently has it. Throws if `file` is missing or on a hard
1742
- * error. The OS handle is owned entirely in native code (no fd crosses into
1743
- * JS), and the kernel releases the lock when the handle closes, including on
1744
- * process death.
1745
- */
1746
- declare const tryFileLock: (file: string) => number;
1979
+ * Creates a native file lock using the specified file path (`flock` on POSIX,
1980
+ * `LockFileEx` on Windows), creating the file and any missing parent
1981
+ * directories. Exclusive by default; pass `shared` for a shared (reader) lock
1982
+ * that coexists with other shared holders but conflicts with an exclusive
1983
+ * holder in either direction. Returns an opaque non-zero token to pass to
1984
+ * `fileLockRelease`, or `0` if a conflicting holder — in any process,
1985
+ * container, or worker thread — currently has it. Throws on a hard error. The
1986
+ * OS handle is owned entirely in native code (no fd crosses into JS), and the
1987
+ * kernel releases the lock when the handle closes, including on process death.
1988
+ */
1989
+ declare const tryFileLock: (file: string, shared?: boolean) => number;
1747
1990
  /**
1748
- * Releases a file lock acquired via `tryFileLock`. A no-op for
1749
- * token `0` or an unknown token.
1750
- */
1991
+ * Releases a file lock acquired via `tryFileLock`. A no-op for
1992
+ * token `0` or an unknown token.
1993
+ */
1751
1994
  declare const fileLockRelease: (token: number) => void;
1752
1995
  declare const stats: {
1753
1996
  StatsLevel: {
@@ -1763,32 +2006,32 @@ declare const stats: {
1763
2006
  //#endregion
1764
2007
  //#region src/backup-stream.d.ts
1765
2008
  /**
1766
- * Options for streaming a backup via `db.backup(stream)`.
1767
- */
2009
+ * Options for streaming a backup via `db.backup(stream)`.
2010
+ */
1768
2011
  interface BackupStreamOptions {
1769
2012
  /**
1770
- * Flush the memtable before streaming. Defaults to `true` when the database
1771
- * was opened with `disableWAL` (otherwise unflushed data would be missing
1772
- * from the stream), and `false` otherwise — matching `db.backup(dir)`.
1773
- */
2013
+ * Flush the memtable before streaming. Defaults to `true` when the database
2014
+ * was opened with `disableWAL` (otherwise unflushed data would be missing
2015
+ * from the stream), and `false` otherwise — matching `db.backup(dir)`.
2016
+ */
1774
2017
  flushBeforeBackup?: boolean;
1775
2018
  /**
1776
- * Gzip-compress the archive before writing it to the stream, producing a
1777
- * `.tar.gz` stream instead of a plain `.tar`. Defaults to `false`.
1778
- *
1779
- * Compression runs in the runtime's `CompressionStream`, downstream of the tar
1780
- * encoder, so end-to-end backpressure is preserved. RocksDB SST files are
1781
- * usually already block-compressed, so the additional savings vary with the
1782
- * data and the configured compression.
1783
- */
2019
+ * Gzip-compress the archive before writing it to the stream, producing a
2020
+ * `.tar.gz` stream instead of a plain `.tar`. Defaults to `false`.
2021
+ *
2022
+ * Compression runs in the runtime's `CompressionStream`, downstream of the tar
2023
+ * encoder, so end-to-end backpressure is preserved. RocksDB SST files are
2024
+ * usually already block-compressed, so the additional savings vary with the
2025
+ * data and the configured compression.
2026
+ */
1784
2027
  gzip?: boolean;
1785
2028
  /**
1786
- * Also stream the transaction log store as `transaction_logs/<store>/…`
1787
- * entries (each `*.txnlog` and `txn.state` file) after the database files.
1788
- * Defaults to `false`. Extraction reconstructs them next to the database, and
1789
- * their mtimes are preserved so the store's age-based rotation/retention stays
1790
- * correct.
1791
- */
2029
+ * Also stream the transaction log store as `transaction_logs/<store>/…`
2030
+ * entries (each `*.txnlog` and `txn.state` file) after the database files.
2031
+ * Defaults to `false`. Extraction reconstructs them next to the database, and
2032
+ * their mtimes are preserved so the store's age-based rotation/retention stays
2033
+ * correct.
2034
+ */
1792
2035
  transactionLogs?: boolean;
1793
2036
  }
1794
2037
  //#endregion
@@ -1796,418 +2039,432 @@ interface BackupStreamOptions {
1796
2039
  type TransactionCallback<T> = (txn: Transaction, attempt: number) => T | PromiseLike<T>;
1797
2040
  interface RocksDatabaseOptions extends StoreOptions {
1798
2041
  /**
1799
- * The column family name.
1800
- *
1801
- * @default 'default'
1802
- */
2042
+ * The column family name.
2043
+ *
2044
+ * @default 'default'
2045
+ */
1803
2046
  name?: string;
1804
2047
  }
1805
2048
  interface TransactionOptions extends NativeTransactionOptions {
1806
2049
  /**
1807
- * The maximum number of times to retry the transaction.
1808
- *
1809
- * @default 3
1810
- */
2050
+ * The maximum number of times to retry the transaction.
2051
+ *
2052
+ * @default 3
2053
+ */
1811
2054
  maxRetries?: number;
1812
2055
  /**
1813
- * Whether to retry the transaction if it fails with `IsBusy`.
1814
- *
1815
- * @default `true` when the transaction is bound to a transaction log, otherwise `false`
1816
- */
2056
+ * Whether to retry the transaction if it fails with `IsBusy`.
2057
+ *
2058
+ * @default `true` when the transaction is bound to a transaction log, otherwise `false`
2059
+ */
1817
2060
  retryOnBusy?: boolean;
1818
2061
  }
1819
2062
  type RocksDBStat = StatsValue;
1820
2063
  type RocksDBStats = StatsDefault | StatsAll;
1821
2064
  /**
1822
- * The main class for interacting with a RocksDB database.
1823
- *
1824
- * Before using this class, you must open the database first.
1825
- *
1826
- * @example
1827
- * ```typescript
1828
- * const db = RocksDatabase.open('/path/to/database');
1829
- * await db.put('key', 'value');
1830
- * const value = await db.get('key');
1831
- * db.close();
1832
- * ```
1833
- */
2065
+ * The main class for interacting with a RocksDB database.
2066
+ *
2067
+ * Before using this class, you must open the database first.
2068
+ *
2069
+ * @example
2070
+ * ```typescript
2071
+ * const db = RocksDatabase.open('/path/to/database');
2072
+ * await db.put('key', 'value');
2073
+ * const value = await db.get('key');
2074
+ * db.close();
2075
+ * ```
2076
+ */
1834
2077
  declare class RocksDatabase extends DBI<DBITransactional> {
1835
2078
  #private;
1836
2079
  constructor(pathOrStore: string | Store, options?: RocksDatabaseOptions);
1837
2080
  /**
1838
- * Removes all data from the database asynchronously.
1839
- *
1840
- * @example
1841
- * ```typescript
1842
- * const db = RocksDatabase.open('/path/to/database');
1843
- * await db.clear();
1844
- * ```
1845
- */
2081
+ * Removes all data from the database asynchronously.
2082
+ *
2083
+ * @example
2084
+ * ```typescript
2085
+ * const db = RocksDatabase.open('/path/to/database');
2086
+ * await db.clear();
2087
+ * ```
2088
+ */
1846
2089
  clear(): Promise<void>;
1847
2090
  /**
1848
- * Removes all entries from the database synchronously.
1849
- *
1850
- * @example
1851
- * ```typescript
1852
- * const db = RocksDatabase.open('/path/to/database');
1853
- * db.clearSync();
1854
- * ```
1855
- */
2091
+ * Removes all entries from the database synchronously.
2092
+ *
2093
+ * @example
2094
+ * ```typescript
2095
+ * const db = RocksDatabase.open('/path/to/database');
2096
+ * db.clearSync();
2097
+ * ```
2098
+ */
1856
2099
  clearSync(): void;
1857
2100
  /**
1858
- * Closes the database.
1859
- *
1860
- * @example
1861
- * ```typescript
1862
- * const db = RocksDatabase.open('/path/to/database');
1863
- * db.close();
1864
- * ```
1865
- */
2101
+ * Closes the database.
2102
+ *
2103
+ * @example
2104
+ * ```typescript
2105
+ * const db = RocksDatabase.open('/path/to/database');
2106
+ * db.close();
2107
+ * ```
2108
+ */
1866
2109
  close(): void;
1867
2110
  /**
1868
- * Compacts the entire key range of the database asynchronously.
1869
- * This triggers manual compaction which removes tombstones and reclaims space.
1870
- *
1871
- * @example
1872
- * ```typescript
1873
- * const db = RocksDatabase.open('/path/to/database');
1874
- * await db.compact();
1875
- * ```
1876
- */
2111
+ * Compacts the entire key range of the database asynchronously.
2112
+ * This triggers manual compaction which removes tombstones and reclaims space.
2113
+ *
2114
+ * @example
2115
+ * ```typescript
2116
+ * const db = RocksDatabase.open('/path/to/database');
2117
+ * await db.compact();
2118
+ * ```
2119
+ */
1877
2120
  compact(options?: CompactOptions): Promise<void>;
1878
2121
  /**
1879
- * Creates a backup of the entire database (all column families) into the
1880
- * given directory, creating parent directories as needed, and resolves with
1881
- * the new backup id. Use the `backups` namespace to restore, list, delete,
1882
- * purge, or verify backups.
1883
- *
1884
- * When the database was opened with `disableWAL`, the memtable is flushed
1885
- * before the backup by default so unflushed data is not lost.
1886
- *
1887
- * @example
1888
- * ```typescript
1889
- * import { backups } from '@harperfast/rocksdb-js';
1890
- *
1891
- * const db = RocksDatabase.open('/path/to/database');
1892
- * const id = await db.backup('/path/to/backups');
1893
- * ```
1894
- */
2122
+ * Creates a backup of the entire database (all column families) into the
2123
+ * given directory, creating parent directories as needed, and resolves with
2124
+ * the new backup id. Use the `backups` namespace to restore, list, delete,
2125
+ * purge, or verify backups.
2126
+ *
2127
+ * When the database was opened with `disableWAL`, the memtable is flushed
2128
+ * before the backup by default so unflushed data is not lost.
2129
+ *
2130
+ * @example
2131
+ * ```typescript
2132
+ * import { backups } from '@harperfast/rocksdb-js';
2133
+ *
2134
+ * const db = RocksDatabase.open('/path/to/database');
2135
+ * const id = await db.backup('/path/to/backups');
2136
+ * ```
2137
+ */
1895
2138
  backup(backupDir: string, options?: BackupOptions): Promise<number>;
1896
2139
  /**
1897
- * Streams a consistent snapshot of the entire database to a `WritableStream`
1898
- * as a tar archive, with no intermediate copy written to disk. Resolves once
1899
- * the stream has been fully written and closed.
1900
- *
1901
- * Backpressure is honored end to end, so a slow consumer (e.g. a network or
1902
- * S3 upload) paces the backup rather than buffering it in memory. The archive
1903
- * unpacks with any tar tool into a directory that opens as a RocksDB database.
1904
- *
1905
- * @example
1906
- * ```typescript
1907
- * const file = await fetch(uploadUrl, { method: 'PUT', body: stream });
1908
- * await db.backup(stream); // `stream` is the request's WritableStream
1909
- * ```
1910
- */
2140
+ * Streams a consistent snapshot of the entire database to a `WritableStream`
2141
+ * as a tar archive, with no intermediate copy written to disk. Resolves once
2142
+ * the stream has been fully written and closed.
2143
+ *
2144
+ * Backpressure is honored end to end, so a slow consumer (e.g. a network or
2145
+ * S3 upload) paces the backup rather than buffering it in memory. The archive
2146
+ * unpacks with any tar tool into a directory that opens as a RocksDB database.
2147
+ *
2148
+ * @example
2149
+ * ```typescript
2150
+ * const file = await fetch(uploadUrl, { method: 'PUT', body: stream });
2151
+ * await db.backup(stream); // `stream` is the request's WritableStream
2152
+ * ```
2153
+ */
1911
2154
  backup(stream: WritableStream<Uint8Array>, options?: BackupStreamOptions): Promise<void>;
1912
2155
  /**
1913
- * Creates a hardlinked, point-in-time, fully independent copy of the entire
1914
- * database (all column families) at `targetPath` and resolves once written.
1915
- *
1916
- * Unlike a backup, a checkpoint is a normal, writable sibling database: open
1917
- * it with {@link RocksDatabase.open} and it diverges independently from the
1918
- * source. SST and blob files are hardlinked when `targetPath` is on the same
1919
- * filesystem as the database and copied otherwise (other files such as the
1920
- * MANIFEST are always copied), so the operation is near-instant on the same
1921
- * filesystem. The memtable is flushed so the checkpoint includes the latest
1922
- * writes even when the WAL is disabled.
1923
- *
1924
- * Parent directories are created as needed. `targetPath` itself must not
1925
- * already exist (RocksDB creates the checkpoint directory) and rejects with
1926
- * `Create checkpoint failed: target path exists` if it does. The caller is
1927
- * responsible for eventual cleanup of the directory.
1928
- *
1929
- * @example
1930
- * ```typescript
1931
- * const db = RocksDatabase.open('/path/to/database');
1932
- * await db.createCheckpoint('/path/to/checkpoint');
1933
- * const branch = RocksDatabase.open('/path/to/checkpoint');
1934
- * ```
1935
- */
2156
+ * Creates a hardlinked, point-in-time, fully independent copy of the entire
2157
+ * database (all column families) at `targetPath` and resolves once written.
2158
+ *
2159
+ * Unlike a backup, a checkpoint is a normal, writable sibling database: open
2160
+ * it with {@link RocksDatabase.open} and it diverges independently from the
2161
+ * source. SST and blob files are hardlinked when `targetPath` is on the same
2162
+ * filesystem as the database and copied otherwise (other files such as the
2163
+ * MANIFEST are always copied), so the operation is near-instant on the same
2164
+ * filesystem. The memtable is flushed so the checkpoint includes the latest
2165
+ * writes even when the WAL is disabled.
2166
+ *
2167
+ * Parent directories are created as needed. `targetPath` itself must not
2168
+ * already exist (RocksDB creates the checkpoint directory) and rejects with
2169
+ * `Create checkpoint failed: target path exists` if it does. The caller is
2170
+ * responsible for eventual cleanup of the directory.
2171
+ *
2172
+ * @example
2173
+ * ```typescript
2174
+ * const db = RocksDatabase.open('/path/to/database');
2175
+ * await db.createCheckpoint('/path/to/checkpoint');
2176
+ * const branch = RocksDatabase.open('/path/to/checkpoint');
2177
+ * ```
2178
+ */
1936
2179
  createCheckpoint(targetPath: string): Promise<void>;
1937
2180
  /**
1938
- * Compacts the entire key range of the database synchronously.
1939
- * This triggers manual compaction which removes tombstones and reclaims space.
1940
- *
1941
- * @example
1942
- * ```typescript
1943
- * const db = RocksDatabase.open('/path/to/database');
1944
- * db.compactSync();
1945
- * ```
1946
- */
2181
+ * Compacts the entire key range of the database synchronously.
2182
+ * This triggers manual compaction which removes tombstones and reclaims space.
2183
+ *
2184
+ * @example
2185
+ * ```typescript
2186
+ * const db = RocksDatabase.open('/path/to/database');
2187
+ * db.compactSync();
2188
+ * ```
2189
+ */
1947
2190
  compactSync(options?: CompactOptions): void;
1948
2191
  /**
1949
- * Returns the list of column families in the RocksDB database.
1950
- */
2192
+ * Returns the list of column families in the RocksDB database.
2193
+ */
1951
2194
  get columns(): string[];
1952
2195
  /**
1953
- * Set global database settings.
1954
- *
1955
- * @param options - The options for the database.
1956
- *
1957
- * @example
1958
- * ```typescript
1959
- * RocksDatabase.config({ blockCacheSize: 1024 * 1024 });
1960
- * ```
1961
- */
2196
+ * The compression currently in effect for this database's column family, read
2197
+ * live from RocksDB, as `{ algorithm, level? }`. `algorithm` is a friendly
2198
+ * name (e.g. `'lz4'`, `'zstd'`, `'none'`); `level` is present only when a
2199
+ * non-default compression level is set. The database must be open. Defaults to
2200
+ * LZ4 when the native build supports it.
2201
+ *
2202
+ * @example
2203
+ * ```typescript
2204
+ * const db = RocksDatabase.open('/path/to/db', { compression: { algorithm: 'zstd', level: 3 } });
2205
+ * db.compression; // { algorithm: 'zstd', level: 3 }
2206
+ * ```
2207
+ */
2208
+ get compression(): CompressionInfo;
2209
+ /**
2210
+ * Set global database settings.
2211
+ *
2212
+ * @param options - The options for the database.
2213
+ *
2214
+ * @example
2215
+ * ```typescript
2216
+ * RocksDatabase.config({ blockCacheSize: 1024 * 1024 });
2217
+ * ```
2218
+ */
1962
2219
  static config(options: RocksDatabaseConfig): void;
1963
2220
  /**
1964
- * Registers a process-wide event listener. Internal events emitted by the
1965
- * native binding use namespaced keys (e.g. `'transactionLog:warning'`).
1966
- *
1967
- * Listeners are not tied to any specific database — they fire for every
1968
- * matching event emitted in this process.
1969
- *
1970
- * @example
1971
- * ```typescript
1972
- * RocksDatabase.on('transactionLog:warning', (warning) => {
1973
- * console.warn(warning);
1974
- * });
1975
- * ```
1976
- */
2221
+ * Registers a process-wide event listener. Internal events emitted by the
2222
+ * native binding use namespaced keys (e.g. `'transactionLog:warning'`).
2223
+ *
2224
+ * Listeners are not tied to any specific database — they fire for every
2225
+ * matching event emitted in this process.
2226
+ *
2227
+ * @example
2228
+ * ```typescript
2229
+ * RocksDatabase.on('transactionLog:warning', (warning) => {
2230
+ * console.warn(warning);
2231
+ * });
2232
+ * ```
2233
+ */
1977
2234
  static on(event: string, callback: (...args: any[]) => void): void;
1978
2235
  /**
1979
- * Alias for {@link RocksDatabase.on}, mirroring the Node `EventEmitter` API.
1980
- */
2236
+ * Alias for {@link RocksDatabase.on}, mirroring the Node `EventEmitter` API.
2237
+ */
1981
2238
  static addListener(event: string, callback: (...args: any[]) => void): void;
1982
2239
  /**
1983
- * Removes a previously-registered process-wide event listener. The
1984
- * callback identity must match the one passed to {@link RocksDatabase.on}.
1985
- *
1986
- * @returns `true` if a matching listener was removed.
1987
- */
2240
+ * Removes a previously-registered process-wide event listener. The
2241
+ * callback identity must match the one passed to {@link RocksDatabase.on}.
2242
+ *
2243
+ * @returns `true` if a matching listener was removed.
2244
+ */
1988
2245
  static off(event: string, callback: (...args: any[]) => void): boolean;
1989
2246
  /**
1990
- * Alias for {@link RocksDatabase.off}, mirroring the Node `EventEmitter` API.
1991
- */
2247
+ * Alias for {@link RocksDatabase.off}, mirroring the Node `EventEmitter` API.
2248
+ */
1992
2249
  static removeListener(event: string, callback: (...args: any[]) => void): boolean;
1993
2250
  /**
1994
- * Returns the number of process-wide listeners registered for the given event.
1995
- */
2251
+ * Returns the number of process-wide listeners registered for the given event.
2252
+ */
1996
2253
  static listenerCount(event: string): number;
1997
2254
  /**
1998
- * Emits a process-wide event. Mostly intended for tests and as a peer to
1999
- * {@link RocksDatabase.on} — native code should call `emitGlobalEvent` in
2000
- * `napi/global_events.h` directly rather than round-tripping through JS.
2001
- *
2002
- * @returns `true` if there was at least one listener.
2003
- */
2255
+ * Emits a process-wide event. Mostly intended for tests and as a peer to
2256
+ * {@link RocksDatabase.on} — native code should call `emitGlobalEvent` in
2257
+ * `napi/global_events.h` directly rather than round-tripping through JS.
2258
+ *
2259
+ * @returns `true` if there was at least one listener.
2260
+ */
2004
2261
  static notify(event: string, ...args: any[]): boolean;
2005
2262
  destroy(): void;
2006
2263
  drop(): Promise<void>;
2007
2264
  dropSync(): void;
2008
2265
  get encoder(): Encoder | null;
2009
2266
  /**
2010
- * Flushes the underlying database by performing a commit or clearing any buffered operations.
2011
- *
2012
- * @return {void} Does not return a value.
2013
- */
2267
+ * Flushes the underlying database by performing a commit or clearing any buffered operations.
2268
+ *
2269
+ * @return {void} Does not return a value.
2270
+ */
2014
2271
  flush(): Promise<void>;
2015
2272
  /**
2016
- * Synchronously flushes the underlying database by performing a commit or clearing any buffered operations.
2017
- *
2018
- * @return {void} Does not return a value.
2019
- */
2273
+ * Synchronously flushes the underlying database by performing a commit or clearing any buffered operations.
2274
+ *
2275
+ * @return {void} Does not return a value.
2276
+ */
2020
2277
  flushSync(): void;
2021
2278
  /**
2022
- * Gets a RocksDB database property as an integer.
2023
- *
2024
- * @param propertyName - The name of the property to retrieve (e.g., 'rocksdb.num-blob-files').
2025
- * @returns The property value as a number.
2026
- *
2027
- * @example
2028
- * ```typescript
2029
- * const db = RocksDatabase.open('/path/to/database');
2030
- * const blobFiles = db.getDBIntProperty('rocksdb.num-blob-files');
2031
- * const numKeys = db.getDBIntProperty('rocksdb.estimate-num-keys');
2032
- * ```
2033
- */
2279
+ * Gets a RocksDB database property as an integer.
2280
+ *
2281
+ * @param propertyName - The name of the property to retrieve (e.g., 'rocksdb.num-blob-files').
2282
+ * @returns The property value as a number.
2283
+ *
2284
+ * @example
2285
+ * ```typescript
2286
+ * const db = RocksDatabase.open('/path/to/database');
2287
+ * const blobFiles = db.getDBIntProperty('rocksdb.num-blob-files');
2288
+ * const numKeys = db.getDBIntProperty('rocksdb.estimate-num-keys');
2289
+ * ```
2290
+ */
2034
2291
  getDBIntProperty(propertyName: string): number | undefined;
2035
2292
  /**
2036
- * Gets a RocksDB database property as a string.
2037
- *
2038
- * @param propertyName - The name of the property to retrieve (e.g., 'rocksdb.levelstats').
2039
- * @returns The property value as a string.
2040
- *
2041
- * @example
2042
- * ```typescript
2043
- * const db = RocksDatabase.open('/path/to/database');
2044
- * const levelStats = db.getDBProperty('rocksdb.levelstats');
2045
- * const stats = db.getDBProperty('rocksdb.stats');
2046
- * ```
2047
- */
2293
+ * Gets a RocksDB database property as a string.
2294
+ *
2295
+ * @param propertyName - The name of the property to retrieve (e.g., 'rocksdb.levelstats').
2296
+ * @returns The property value as a string.
2297
+ *
2298
+ * @example
2299
+ * ```typescript
2300
+ * const db = RocksDatabase.open('/path/to/database');
2301
+ * const levelStats = db.getDBProperty('rocksdb.levelstats');
2302
+ * const stats = db.getDBProperty('rocksdb.stats');
2303
+ * ```
2304
+ */
2048
2305
  getDBProperty(propertyName: string): string | undefined;
2049
2306
  /**
2050
- * Retrieves the estimated number of keys in the database.
2051
- *
2052
- * @example
2053
- * ```typescript
2054
- * const db = RocksDatabase.open('/path/to/database');
2055
- * const estimated = db.getEstimatedKeyCount();
2056
- * console.log(estimated);
2057
- * ```
2058
- */
2307
+ * Retrieves the estimated number of keys in the database.
2308
+ *
2309
+ * @example
2310
+ * ```typescript
2311
+ * const db = RocksDatabase.open('/path/to/database');
2312
+ * const estimated = db.getEstimatedKeyCount();
2313
+ * console.log(estimated);
2314
+ * ```
2315
+ */
2059
2316
  getEstimatedKeyCount(): number;
2060
2317
  /**
2061
- * Returns the current timestamp as a monotonically increasing timestamp in
2062
- * milliseconds represented as a decimal number.
2063
- *
2064
- * @returns The current monotonic timestamp in milliseconds.
2065
- */
2318
+ * Returns the current timestamp as a monotonically increasing timestamp in
2319
+ * milliseconds represented as a decimal number.
2320
+ *
2321
+ * @returns The current monotonic timestamp in milliseconds.
2322
+ */
2066
2323
  getMonotonicTimestamp(): number;
2067
2324
  /**
2068
- * Returns a number representing a unix timestamp of the oldest unreleased
2069
- * snapshot.
2070
- *
2071
- * @returns The oldest snapshot timestamp.
2072
- */
2325
+ * Returns a number representing a unix timestamp of the oldest unreleased
2326
+ * snapshot.
2327
+ *
2328
+ * @returns The oldest snapshot timestamp.
2329
+ */
2073
2330
  getOldestSnapshotTimestamp(): number;
2074
2331
  /**
2075
- * Gets a RocksDB statistic.
2076
- *
2077
- * @param statName - The name of the statistic to retrieve.
2078
- * @returns The statistic value.
2079
- */
2332
+ * Gets a RocksDB statistic.
2333
+ *
2334
+ * @param statName - The name of the statistic to retrieve.
2335
+ * @returns The statistic value.
2336
+ */
2080
2337
  getStat(statName: string): RocksDBStat;
2081
2338
  /**
2082
- * Gets the RocksDB statistics. The RocksDB ticker/histogram stats require
2083
- * statistics to be enabled, but the result always includes a summarized,
2084
- * aggregate set of `txnlog.*` keys (across all of this database's transaction
2085
- * logs), regardless of whether statistics are enabled. For detailed per-log
2086
- * statistics, including memory-map usage, use `log.getStats()` on the log
2087
- * returned by {@link RocksDatabase#useLog}.
2088
- *
2089
- * @example
2090
- * ```typescript
2091
- * const db = RocksDatabase.open('/path/to/database');
2092
- * const stats = db.getStats();
2093
- * stats['txnlog.totalSizeBytes']; // bytes across all transaction logs
2094
- * ```
2095
- */
2339
+ * Gets the RocksDB statistics. The RocksDB ticker/histogram stats require
2340
+ * statistics to be enabled, but the result always includes a summarized,
2341
+ * aggregate set of `txnlog.*` keys (across all of this database's transaction
2342
+ * logs), regardless of whether statistics are enabled. For detailed per-log
2343
+ * statistics, including memory-map usage, use `log.getStats()` on the log
2344
+ * returned by {@link RocksDatabase#useLog}.
2345
+ *
2346
+ * @example
2347
+ * ```typescript
2348
+ * const db = RocksDatabase.open('/path/to/database');
2349
+ * const stats = db.getStats();
2350
+ * stats['txnlog.totalSizeBytes']; // bytes across all transaction logs
2351
+ * ```
2352
+ */
2096
2353
  getStats(all?: false): StatsDefault;
2097
2354
  getStats(all: true): StatsAll;
2098
2355
  /**
2099
- * Gets or creates a buffer that can be shared across worker threads.
2100
- *
2101
- * @param key - The key to get or create the buffer for.
2102
- * @param defaultBuffer - The default buffer to copy and use if the buffer
2103
- * does not exist.
2104
- * @param [options] - The options for the buffer.
2105
- * @param [options.callback] - A optional callback that receives
2106
- * key-specific events.
2107
- * @returns An `ArrayBuffer` that is internally backed by a shared block of
2108
- * memory. The buffer also has `notify()` and `cancel()` methods that can be
2109
- * used to notify the specified `options.callback`.
2110
- *
2111
- * @example
2112
- * ```typescript
2113
- * const db = RocksDatabase.open('/path/to/database');
2114
- * const buffer = db.getUserSharedBuffer('foo', new ArrayBuffer(10));
2115
- */
2356
+ * Gets or creates a buffer that can be shared across worker threads.
2357
+ *
2358
+ * @param key - The key to get or create the buffer for.
2359
+ * @param defaultBuffer - The default buffer to copy and use if the buffer
2360
+ * does not exist.
2361
+ * @param [options] - The options for the buffer.
2362
+ * @param [options.callback] - A optional callback that receives
2363
+ * key-specific events.
2364
+ * @returns An `ArrayBuffer` that is internally backed by a shared block of
2365
+ * memory. The buffer also has `notify()` and `cancel()` methods that can be
2366
+ * used to notify the specified `options.callback`.
2367
+ *
2368
+ * @example
2369
+ * ```typescript
2370
+ * const db = RocksDatabase.open('/path/to/database');
2371
+ * const buffer = db.getUserSharedBuffer('foo', new ArrayBuffer(10));
2372
+ */
2116
2373
  getUserSharedBuffer(key: Key, defaultBuffer: ArrayBuffer, options?: UserSharedBufferOptions): ArrayBufferWithNotify;
2117
2374
  /**
2118
- * Returns whether the database has a lock for the given key.
2119
- *
2120
- * @param key - The key to check.
2121
- * @returns `true` if the database has a lock for the given key, `false`
2122
- * otherwise.
2123
- *
2124
- * @example
2125
- * ```typescript
2126
- * const db = RocksDatabase.open('/path/to/database');
2127
- * db.hasLock('foo'); // false
2128
- * db.tryLock('foo', () => {});
2129
- * db.hasLock('foo'); // true
2130
- * ```
2131
- */
2375
+ * Returns whether the database has a lock for the given key.
2376
+ *
2377
+ * @param key - The key to check.
2378
+ * @returns `true` if the database has a lock for the given key, `false`
2379
+ * otherwise.
2380
+ *
2381
+ * @example
2382
+ * ```typescript
2383
+ * const db = RocksDatabase.open('/path/to/database');
2384
+ * db.hasLock('foo'); // false
2385
+ * db.tryLock('foo', () => {});
2386
+ * db.hasLock('foo'); // true
2387
+ * ```
2388
+ */
2132
2389
  hasLock(key: Key): boolean;
2133
2390
  ifNoExists(_key: Key): Promise<void>;
2134
2391
  /**
2135
- * Checks the process-global verification table for a fresh version match
2136
- * on `key`. Returns `true` when the table currently records `version`. Use
2137
- * this as a fast cache-freshness check before falling back to a full read:
2138
- *
2139
- * ```typescript
2140
- * if (db.verifyVersion(key, cachedEntry.version)) {
2141
- * return cachedEntry.value;
2142
- * }
2143
- * const value = db.getSync(key);
2144
- * db.populateVersion(key, extractVersion(value));
2145
- * ```
2146
- */
2392
+ * Checks the process-global verification table for a fresh version match
2393
+ * on `key`. Returns `true` when the table currently records `version`. Use
2394
+ * this as a fast cache-freshness check before falling back to a full read:
2395
+ *
2396
+ * ```typescript
2397
+ * if (db.verifyVersion(key, cachedEntry.version)) {
2398
+ * return cachedEntry.value;
2399
+ * }
2400
+ * const value = db.getSync(key);
2401
+ * db.populateVersion(key, extractVersion(value));
2402
+ * ```
2403
+ */
2147
2404
  verifyVersion(key: Key, version: number): boolean;
2148
2405
  /**
2149
- * Seeds the verification-table slot for `key` with `version`. Has no
2150
- * effect if the slot is currently lock-tagged or if the verification
2151
- * table is disabled.
2152
- */
2406
+ * Seeds the verification-table slot for `key` with `version`. Has no
2407
+ * effect if the slot is currently lock-tagged or if the verification
2408
+ * table is disabled.
2409
+ */
2153
2410
  populateVersion(key: Key, version: number): void;
2154
2411
  /**
2155
- * Returns whether the database is open.
2156
- *
2157
- * @returns `true` if the database is open, `false` otherwise.
2158
- */
2412
+ * Returns whether the database is open.
2413
+ *
2414
+ * @returns `true` if the database is open, `false` otherwise.
2415
+ */
2159
2416
  isOpen(): boolean;
2160
2417
  /**
2161
- * Lists all transaction log names.
2162
- *
2163
- * @returns an array of transaction log names.
2164
- */
2418
+ * Lists all transaction log names.
2419
+ *
2420
+ * @returns an array of transaction log names.
2421
+ */
2165
2422
  listLogs(): string[];
2166
2423
  /**
2167
- * The name of the database.
2168
- */
2424
+ * The name of the database.
2425
+ */
2169
2426
  get name(): string;
2170
2427
  /**
2171
- * Whether the database is open in readonly mode.
2172
- */
2428
+ * Whether the database is open in readonly mode.
2429
+ */
2173
2430
  get readOnly(): boolean;
2174
2431
  /**
2175
- * Sugar method for opening a database.
2176
- *
2177
- * @param pathOrStore - The filesystem path to the database or a custom store.
2178
- * @param options - The options for the database.
2179
- * @returns A new RocksDatabase instance.
2180
- *
2181
- * @example
2182
- * ```typescript
2183
- * const db = RocksDatabase.open('/path/to/database');
2184
- * ```
2185
- */
2432
+ * Sugar method for opening a database.
2433
+ *
2434
+ * @param pathOrStore - The filesystem path to the database or a custom store.
2435
+ * @param options - The options for the database.
2436
+ * @returns A new RocksDatabase instance.
2437
+ *
2438
+ * @example
2439
+ * ```typescript
2440
+ * const db = RocksDatabase.open('/path/to/database');
2441
+ * ```
2442
+ */
2186
2443
  static open(pathOrStore: string | Store, options?: RocksDatabaseOptions): RocksDatabase;
2187
2444
  /**
2188
- * Opens the database. This function returns immediately if the database is
2189
- * already open.
2190
- *
2191
- * @returns A new RocksDatabase instance.
2192
- *
2193
- * @example
2194
- * ```typescript
2195
- * const db = new RocksDatabase('/path/to/database');
2196
- * db.open();
2197
- * ```
2198
- */
2445
+ * Opens the database. This function returns immediately if the database is
2446
+ * already open.
2447
+ *
2448
+ * @returns A new RocksDatabase instance.
2449
+ *
2450
+ * @example
2451
+ * ```typescript
2452
+ * const db = new RocksDatabase('/path/to/database');
2453
+ * db.open();
2454
+ * ```
2455
+ */
2199
2456
  open(): RocksDatabase;
2200
2457
  /**
2201
- * Returns the path to the database.
2202
- */
2458
+ * Returns the path to the database.
2459
+ */
2203
2460
  get path(): string;
2204
2461
  /**
2205
- * Purges transaction logs.
2206
- *
2207
- * By default returns the paths of the deleted log files. Pass
2208
- * `includeEntryCounts: true` to instead return, for each deleted file, its
2209
- * path and the number of entries it held (`{ path, entries }`).
2210
- */
2462
+ * Purges transaction logs.
2463
+ *
2464
+ * By default returns the paths of the deleted log files. Pass
2465
+ * `includeEntryCounts: true` to instead return, for each deleted file, its
2466
+ * path and the number of entries it held (`{ path, entries }`).
2467
+ */
2211
2468
  purgeLogs(options: PurgeLogsOptions & {
2212
2469
  includeEntryCounts: true;
2213
2470
  }): PurgedLog[];
@@ -2216,93 +2473,93 @@ declare class RocksDatabase extends DBI<DBITransactional> {
2216
2473
  }): string[];
2217
2474
  purgeLogs(options?: PurgeLogsOptions): string[] | PurgedLog[];
2218
2475
  /**
2219
- * The status of the database.
2220
- */
2476
+ * The status of the database.
2477
+ */
2221
2478
  get status(): "open" | "closed";
2222
2479
  /**
2223
- * Executes all operations in the callback as a single transaction.
2224
- *
2225
- * @param callback - A async function that receives the transaction as an argument.
2226
- * @returns A promise that resolves the `callback` return value.
2227
- *
2228
- * @example
2229
- * ```typescript
2230
- * const db = RocksDatabase.open('/path/to/database');
2231
- * await db.transaction(async (txn) => {
2232
- * await txn.put('key', 'value');
2233
- * });
2234
- * ```
2235
- */
2480
+ * Executes all operations in the callback as a single transaction.
2481
+ *
2482
+ * @param callback - A async function that receives the transaction as an argument.
2483
+ * @returns A promise that resolves the `callback` return value.
2484
+ *
2485
+ * @example
2486
+ * ```typescript
2487
+ * const db = RocksDatabase.open('/path/to/database');
2488
+ * await db.transaction(async (txn) => {
2489
+ * await txn.put('key', 'value');
2490
+ * });
2491
+ * ```
2492
+ */
2236
2493
  transaction<T>(callback: TransactionCallback<T>, options?: TransactionOptions): Promise<T | void>;
2237
2494
  /**
2238
- * Executes all operations in the callback as a single transaction.
2239
- *
2240
- * @param callback - A function that receives the transaction as an
2241
- * argument. If the callback return promise-like value, it is awaited
2242
- * before committing the transaction. Otherwise, the callback is treated as
2243
- * synchronous.
2244
- * @returns The `callback` return value.
2245
- *
2246
- * @example
2247
- * ```typescript
2248
- * const db = RocksDatabase.open('/path/to/database');
2249
- * await db.transaction(async (txn) => {
2250
- * await txn.put('key', 'value');
2251
- * });
2252
- * ```
2253
- */
2495
+ * Executes all operations in the callback as a single transaction.
2496
+ *
2497
+ * @param callback - A function that receives the transaction as an
2498
+ * argument. If the callback return promise-like value, it is awaited
2499
+ * before committing the transaction. Otherwise, the callback is treated as
2500
+ * synchronous.
2501
+ * @returns The `callback` return value.
2502
+ *
2503
+ * @example
2504
+ * ```typescript
2505
+ * const db = RocksDatabase.open('/path/to/database');
2506
+ * await db.transaction(async (txn) => {
2507
+ * await txn.put('key', 'value');
2508
+ * });
2509
+ * ```
2510
+ */
2254
2511
  transactionSync<T>(callback: TransactionCallback<T>, options?: TransactionOptions): T | PromiseLike<T> | void;
2255
2512
  /**
2256
- * Attempts to acquire a lock for a given key. If the lock is available,
2257
- * the function returns `true` and the optional callback is never called.
2258
- * If the lock is not available, the function returns `false` and the
2259
- * callback is queued until the lock is released.
2260
- *
2261
- * @param key - The key to lock.
2262
- * @param onUnlocked - A callback to call when the lock is released.
2263
- *
2264
- * @example
2265
- * ```typescript
2266
- * const db = RocksDatabase.open('/path/to/database');
2267
- * db.tryLock('foo', () => {
2268
- * console.log('lock acquired');
2269
- * });
2270
- * ```
2271
- * @returns `true` if the lock was acquired, `false` otherwise.
2272
- */
2513
+ * Attempts to acquire a lock for a given key. If the lock is available,
2514
+ * the function returns `true` and the optional callback is never called.
2515
+ * If the lock is not available, the function returns `false` and the
2516
+ * callback is queued until the lock is released.
2517
+ *
2518
+ * @param key - The key to lock.
2519
+ * @param onUnlocked - A callback to call when the lock is released.
2520
+ *
2521
+ * @example
2522
+ * ```typescript
2523
+ * const db = RocksDatabase.open('/path/to/database');
2524
+ * db.tryLock('foo', () => {
2525
+ * console.log('lock acquired');
2526
+ * });
2527
+ * ```
2528
+ * @returns `true` if the lock was acquired, `false` otherwise.
2529
+ */
2273
2530
  tryLock(key: Key, onUnlocked?: () => void): boolean;
2274
2531
  /**
2275
- * Releases the lock on the given key and calls any queued `onUnlocked`
2276
- * callback handlers.
2277
- *
2278
- * @param key - The key to unlock.
2279
- * @returns `true` if the lock was released or `false` if the lock did not
2280
- * exist.
2281
- *
2282
- * @example
2283
- * ```typescript
2284
- * const db = RocksDatabase.open('/path/to/database');
2285
- * db.tryLock('foo', () => {});
2286
- * db.unlock('foo'); // returns `true`
2287
- * db.unlock('foo'); // already unlocked, returns `false`
2288
- * ```
2289
- */
2532
+ * Releases the lock on the given key and calls any queued `onUnlocked`
2533
+ * callback handlers.
2534
+ *
2535
+ * @param key - The key to unlock.
2536
+ * @returns `true` if the lock was released or `false` if the lock did not
2537
+ * exist.
2538
+ *
2539
+ * @example
2540
+ * ```typescript
2541
+ * const db = RocksDatabase.open('/path/to/database');
2542
+ * db.tryLock('foo', () => {});
2543
+ * db.unlock('foo'); // returns `true`
2544
+ * db.unlock('foo'); // already unlocked, returns `false`
2545
+ * ```
2546
+ */
2290
2547
  unlock(key: Key): void;
2291
2548
  /**
2292
- * Excecutes a function using a thread-safe lock to ensure mutual
2293
- * exclusion.
2294
- *
2295
- * @param callback - A callback to call when the lock is acquired.
2296
- * @returns A promise that resolves when the lock is acquired.
2297
- *
2298
- * @example
2299
- * ```typescript
2300
- * const db = RocksDatabase.open('/path/to/database');
2301
- * await db.withLock(async (waited) => {
2302
- * console.log('lock acquired', waited);
2303
- * });
2304
- * ```
2305
- */
2549
+ * Excecutes a function using a thread-safe lock to ensure mutual
2550
+ * exclusion.
2551
+ *
2552
+ * @param callback - A callback to call when the lock is acquired.
2553
+ * @returns A promise that resolves when the lock is acquired.
2554
+ *
2555
+ * @example
2556
+ * ```typescript
2557
+ * const db = RocksDatabase.open('/path/to/database');
2558
+ * await db.withLock(async (waited) => {
2559
+ * console.log('lock acquired', waited);
2560
+ * });
2561
+ * ```
2562
+ */
2306
2563
  withLock(key: Key, callback: () => void | Promise<void>): Promise<void> | undefined;
2307
2564
  }
2308
2565
  //#endregion
@@ -2323,10 +2580,10 @@ interface TransactionLog$1 {
2323
2580
  version: number;
2324
2581
  }
2325
2582
  /**
2326
- * Loads an entire transaction log file into memory.
2327
- * @param path - The path to the transaction log file.
2328
- * @returns The transaction log.
2329
- */
2583
+ * Loads an entire transaction log file into memory.
2584
+ * @param path - The path to the transaction log file.
2585
+ * @returns The transaction log.
2586
+ */
2330
2587
  declare function parseTransactionLog(path: string, options?: {
2331
2588
  skipData?: boolean;
2332
2589
  }): TransactionLog$1;
@@ -2337,5 +2594,5 @@ declare const versions: {
2337
2594
  "rocksdb-js": string;
2338
2595
  };
2339
2596
  //#endregion
2340
- export { type BackupInfo, type BackupOptions, type BackupStreamOptions, DBI, DBIterator, type GetStatsMethod, type IteratorOptions, type Key, type RestoreMode, type RestoreOptions, type RocksDBStat, type RocksDBStats, RocksDatabase, type RocksDatabaseOptions, type StatsAll, type StatsAllExtras, type StatsBasics, type StatsCurated, type StatsCuratedExtras, type StatsDefault, type StatsHistogramData, type StatsValue, Store, type StoreContext, type StoreGetOptions, type StoreIteratorOptions, type StorePutOptions, type StoreRangeOptions, type StoreRemoveOptions, Transaction, type TransactionEntry, TransactionLog, type TransactionLogPosition, type TransactionLogStats, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, tryFileLock, versions };
2597
+ export { type BackupInfo, type BackupOptions, type BackupStreamOptions, type CompressionAlgorithm, type CompressionInfo, type CompressionOption, DBI, DBIterator, type GetStatsMethod, type IteratorOptions, type Key, type RestoreMode, type RestoreOptions, type RocksDBStat, type RocksDBStats, RocksDatabase, type RocksDatabaseOptions, type StatsAll, type StatsAllExtras, type StatsBasics, type StatsCurated, type StatsCuratedExtras, type StatsDefault, type StatsHistogramData, type StatsValue, Store, type StoreContext, type StoreGetOptions, type StoreIteratorOptions, type StorePutOptions, type StoreRangeOptions, type StoreRemoveOptions, Transaction, type TransactionEntry, TransactionLog, type TransactionLogFileValidation, type TransactionLogPosition, type TransactionLogStats, type TransactionLogStoreValidation, type ValidateTransactionLogStoreOptions, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, supportedCompression, tryFileLock, validateTransactionLogStore, versions };
2341
2598
  //# sourceMappingURL=index.d.mts.map