import { type OptimysticNSDBHandle, type SqliteDb } from './db.js'; /** * Minimal subset of `@nativescript-community/sqlite`'s `Db` we depend on. * Re-declared locally so this module's *types* don't pull in the plugin's * declarations (the plugin is a peer dependency that may not be installed * at typecheck time on non-NativeScript consumers). */ interface NSPluginDb { execute(sql: string, params?: ReadonlyArray): unknown; get(sql: string, params?: ReadonlyArray): Promise | null | undefined> | Record | null | undefined; select(sql: string, params?: ReadonlyArray): Promise>> | Array>; close(): void | Promise; } /** * Opens (creating if needed) the Optimystic SQLite database at `name` under * the NativeScript app's documents directory, applies WAL pragmas, and runs * the migration to `version`. * * The returned `SqliteDb` handle is safe to share across `SqliteRawStorage`, * `SqliteKVStore`, and `loadOrCreateNSPeerKey`. Because SQLite allows at most * one open transaction per connection, the wrapper serializes every mutating * operation — `exec`, statement `run`, and whole `transaction` bodies — through * a per-connection FIFO mutex. Without it, two concurrent `transaction` bodies * would each `BEGIN` on the shared connection; the second would nest and its * rollback would silently discard the first's still-open writes. Reads * (`get`/`all`) stay off the mutex to preserve read concurrency. * * `path` may be passed in as the full filesystem path if the caller wants * to control file placement; otherwise the plugin's documents-directory * default is used. */ export declare function openOptimysticNSDb(name?: string, version?: number): Promise; /** * Wraps a `@nativescript-community/sqlite` `Db` instance to satisfy the * internal `SqliteDb` interface used by the storage classes. Exported only * for callers that already hold an open NS-plugin handle and want to skip * the opener (rare — typically users just call `openOptimysticNSDb`). * * NOTE: the serialization mutex lives on the wrapper, not the raw handle. Wrap * a given raw connection exactly once — two wrappers over one handle each hold * their own mutex and would not serialize against each other, reintroducing the * cross-rollback this fix closes. */ export declare function wrapNSPluginDb(raw: NSPluginDb): SqliteDb; export {}; //# sourceMappingURL=ns-opener.d.ts.map