/** * SQLite Backend Abstraction * * Multi-backend support: tries `node:sqlite` (Node 22.5+, zero deps, fastest) * first, then falls back to `better-sqlite3` (any Node with prebuilt binary). * * Both backends expose the same minimal interface needed by the SQLiteAdapter. * * Note: `node:sqlite` is a built-in module accessed via the `node:` URL scheme. * We use createRequire to load it from CJS, since vitest's ESM resolver * doesn't recognize the `node:` scheme for built-in modules. */ export interface SQLiteConnection { /** Execute a multi-statement SQL script with no result */ exec(sql: string): void; /** Prepare a parameterized statement */ prepare(sql: string): SQLiteStatement; /** Set PRAGMA (e.g. foreign_keys = ON) */ pragma(key: string, value: string): void; /** Close the connection */ close(): void; } export interface SQLiteStatement { /** Run a SELECT and return all rows as objects */ all(...params: unknown[]): Record[]; /** Run a SELECT and return the first row (or undefined) */ get(...params: unknown[]): Record | undefined; /** Run INSERT/UPDATE/DELETE; return changes count and lastInsertRowid */ run(...params: unknown[]): SQLiteRunResult; } export interface SQLiteRunResult { changes: number; lastInsertRowid: number | bigint; } export interface SQLiteBackend { name: 'node-sqlite' | 'better-sqlite3'; /** * Open a connection to a database file (or ':memory:' for in-memory). * `readonly: true` is supported when the backend allows it. */ open(filePath: string, options: { readonly?: boolean; }): Promise; } export declare function detectSqliteBackend(): Promise; export declare function getActiveBackendName(): string | null; /** * Wrap a better-sqlite3-compatible Database instance to expose the * SQLiteConnection interface. Used by EncryptedSqliteBackend when opening * SQLCipher-encrypted databases via `better-sqlite3-multiple-ciphers`. * * Exported so other modules (e.g. encrypted-sqlite.ts) can reuse the wrapper. */ export declare function wrapBetterSqlite3(db: any): SQLiteConnection; //# sourceMappingURL=types.d.ts.map