import type { StorageProvider, StorageStats } from './storage-provider.js'; /** * SQLiteStorageProvider -- cross-platform SQLite-backed StorageProvider using sql.js (WASM). * * Use this provider when you need a single-file, portable storage backend that * works identically across Windows, Linux, and macOS without native compilation. * It is ideal for desktop tools and CLI applications that need durable storage * without external database dependencies. * * **Initialization:** You MUST call {@link init} before performing any read or * write operations. Calling `init()` is safe to call multiple times; subsequent * calls are no-ops that return the same initialization promise. * * **Concurrency:** This provider is designed for single-process access. Running * multiple processes against the same database file simultaneously may cause * data corruption because sql.js loads the entire DB into memory and persists * it atomically on every write. Use file-level locking or a dedicated process * if concurrent access is required. * * **Database location:** The database file defaults to `.squad/squad.db` * relative to the working directory. The file and parent directories are * created automatically on first write. Callers are responsible for deleting * the file when it is no longer needed (e.g. in test cleanup). * * Schema: `files(path TEXT PRIMARY KEY, content TEXT, updated_at TEXT)` * * sql.js runs SQLite entirely in WASM -- no native compilation required. * The WASM bundle is loaded lazily via dynamic `import('sql.js')` so it * only impacts startup when this provider is actually instantiated. * * Sync methods work because sql.js operations are synchronous under the * hood (WASM, not network). The DB must be initialized before sync calls. */ export declare class SQLiteStorageProvider implements StorageProvider { private readonly dbPath; private db; private initPromise; constructor(dbPath?: string); /** * Initialize the SQLite database, loading the WASM bundle and creating the * schema if needed. **Must be called before any read/write operation.** * * Safe to call multiple times -- the first call performs initialization and * subsequent calls return the same resolved promise (no extra work). * * If the database file already exists on disk it is loaded into memory; * otherwise a fresh in-memory database is created and will be persisted on * the first write. * * @throws If the sql.js WASM bundle cannot be loaded (e.g. missing dependency). */ init(): Promise; private doInit; /** Throws if the DB has not been initialized (for sync methods). */ private ensureDb; /** Ensure the DB is ready (for async methods). */ private ready; /** Normalize a path to forward-slash POSIX form with no trailing slash. */ private norm; /** Escape SQL LIKE wildcards so user-supplied paths are matched literally. */ private escapeLike; /** Persist the in-memory DB to disk (atomic write-then-rename). */ private persist; private now; read(filePath: string): Promise; write(filePath: string, data: string): Promise; append(filePath: string, data: string): Promise; exists(filePath: string): Promise; list(dirPath: string): Promise; delete(filePath: string): Promise; deleteDir(dirPath: string): Promise; readSync(filePath: string): string | undefined; writeSync(filePath: string, data: string): void; existsSync(filePath: string): boolean; listSync(dirPath: string): string[]; isDirectory(targetPath: string): Promise; mkdir(_dirPath: string, _options?: { recursive?: boolean; }): Promise; rename(oldPath: string, newPath: string): Promise; copy(srcPath: string, destPath: string): Promise; stat(targetPath: string): Promise; isDirectorySync(targetPath: string): boolean; mkdirSync(_dirPath: string, _options?: { recursive?: boolean; }): void; statSync(targetPath: string): StorageStats | undefined; appendSync(filePath: string, data: string): void; deleteSync(filePath: string): void; renameSync(oldPath: string, newPath: string): void; copySync(srcPath: string, destPath: string): void; deleteDirSync(dirPath: string): void; private internalWrite; } //# sourceMappingURL=sqlite-storage-provider.d.ts.map