import { type IKVStore } from '@optimystic/db-p2p'; import type { SqliteDb } from './db.js'; /** * SQLite-backed `IKVStore` adapter for NativeScript peers. * * Stored keys are namespaced with `prefix` so the `kv` table can be shared * with the identity helper (which uses the `b_val` column) without collisions. * `list(prefix)` issues a bounded `SELECT key FROM kv WHERE key >= ? AND key < ?` * — never `SELECT * FROM kv` + JS-side filter — so listing latency stays * bounded as the table grows. * * Only the `s_val` column is read or written here; the `b_val` column is * reserved for binary identity material. * * Writes are autocommit statements: each is visible, and survives a crash of this process, once it * resolves, and the write-ahead log keeps them in order. `flush()` makes them survive a power cut: * when anything was written since the last flush it runs `syncSqliteDb`, one synced commit that * syncs the shared log and with it every earlier write on the connection; otherwise it resolves at * once. A failed sync latches the store, after which every write and flush throws * `StoreFailedError` (rule 5 of the flush contract on `RawStoreDriver.flush`); reads keep working. */ export declare class SqliteKVStore implements IKVStore { private readonly db; private readonly stmts; private readonly prefix; /** Set once a write has resolved, cleared by the flush that syncs it. */ private dirty; private fault; constructor(db: SqliteDb, prefix?: string); get(key: string): Promise; set(key: string, value: string): Promise; delete(key: string): Promise; list(prefix: string): Promise; /** `IKVStore.flush`: one synced commit when this store wrote since its last flush, otherwise nothing. */ flush(): Promise; private throwIfFailed; } //# sourceMappingURL=sqlite-kv-store.d.ts.map