import { type DeleteRangeOptions } from './delete-range'; import { type BatchOperation, type ConditionalBatchCondition, type ScanOptions, type Storage, type StorageCapabilities } from './interface'; /** * Construction options for {@link LMDBStorage}. * * @example * ```ts * import { LMDBStorage, type LMDBStorageOptions } from '@lostgradient/weft/storage/lmdb'; * * const options: LMDBStorageOptions = { durability: 'relaxed' }; * await using storage = new LMDBStorage('./weft-data', options); * void storage; * ``` */ export type LMDBStorageOptions = { /** * LMDB commit durability. * - `'full'` (default): every commit fsyncs both data and metadata to disk * before resolving—safe for production use. * - `'relaxed'`: opens the environment with `noSync: true` and * `noMetaSync: true`, skipping `fsync` on every commit. This trades crash * durability for write latency and is intended for test fixtures and other * disposable environments, not for storage backing recoverable workflows. */ durability?: 'full' | 'relaxed'; }; type LMDBRangeOptions = { start: string; end: string; reverse?: boolean; }; type LMDBDatabase = { get(key: string): Uint8Array | undefined; put(key: string, value: Uint8Array): Promise; remove(key: string): Promise; doesExist(key: string): boolean; batch(action: () => unknown): Promise; getRange(options: LMDBRangeOptions): Iterable<{ key: string; value: Uint8Array; }>; getKeys(options: LMDBRangeOptions): Iterable; getKeysCount(options: LMDBRangeOptions): number; transactionSync(action: () => T): T; putSync(key: string, value: Uint8Array): void; removeSync(key: string): boolean; close(): Promise; }; type OpenLMDBEnvironment = (options: { path: string; encoding: 'binary'; noSync?: boolean; noMetaSync?: boolean; }) => LMDBDatabase; /** * LMDB-backed storage adapter. Reads hit lmdb-js's synchronous memory-mapped * path internally, but the Storage interface presents them as Promises and * copies the bytes into a fresh Uint8Array on each call. Writes use lmdb-js's * async batching: individual `put`/`remove` calls return promises that resolve * once the next batched transaction commits to disk. lmdb-js `^3.5.2` * automatically resets its cached read transaction after each write commit; * this adapter relies on that behavior rather than calling `resetReadTxn()` * directly. * * @example * ```ts * import { LMDBStorage } from '@lostgradient/weft/storage/lmdb'; * import { workflow, Engine } from '@lostgradient/weft'; * * await using storage = new LMDBStorage('./weft-data'); * await using engine = new Engine({ storage }); * engine.register(workflow({ name: 'ping' }).execute(async function* () { return 'pong'; })); * ``` */ export declare class LMDBStorage implements Storage { #private; constructor(path: string, options?: LMDBStorageOptions, openEnvironment?: OpenLMDBEnvironment); capabilities(): StorageCapabilities; get(key: string): Promise; put(key: string, value: Uint8Array): Promise; delete(key: string): Promise; has(key: string): Promise; deletePrefix(prefix: string): Promise; deleteRange(prefix: string, options: DeleteRangeOptions): Promise; scan(prefix: string, options?: ScanOptions): AsyncIterable<[string, Uint8Array]>; keys(prefix: string, options?: ScanOptions): AsyncIterable; count(prefix: string): Promise; scoped(prefix: string): Storage; batch(operations: BatchOperation[]): Promise; conditionalBatch(conditions: ConditionalBatchCondition[], operations: BatchOperation[]): Promise; close(): Promise; [Symbol.dispose](): void; } export {};