import { DeepBaseDriver, DeepBaseDriverOptions } from 'deepbase'; export interface SqliteBusyRetryOptions { maxAttempts?: number; baseDelayMs?: number; maxDelayMs?: number; } export type SqliteCheckpointMode = 'PASSIVE' | 'FULL' | 'RESTART' | 'TRUNCATE'; export interface SqliteCheckpointResult { /** `1` when readers or writers prevented the checkpoint from completing. */ busy: number; /** Pages in the WAL file. */ log: number; /** Pages moved into the database file. */ checkpointed: number; } export interface SqliteDriverOptions extends DeepBaseDriverOptions { name?: string; /** Required absolute storage directory. */ path: string; pragma?: 'none' | 'safe' | 'balanced' | 'fast'; busyTimeoutMs?: number; busyRetry?: SqliteBusyRetryOptions; /** * Records a native `query()` window may reach, counting `offset + limit`. * Beyond it the driver reads the collection and evaluates in memory. */ queryWindowMaxRecords?: number; /** Key-index lookups the `query()` order guard may spend before falling back. */ queryWindowMaxProbes?: number; } export class SqliteDriver extends DeepBaseDriver { constructor(options: SqliteDriverOptions); name: string; path: string; fileName: string; pragma: string; busyTimeoutMs: number; busyRetry: Required; queryWindowMaxRecords: number; queryWindowMaxProbes: number; /** Opens the existing database read-only, runs `PRAGMA integrity_check`, * then closes it. Does not connect or mutate the driver database. */ checkIntegrity(): Promise; /** * Opens the existing source database read-only, writes an online backup to * `destination`, then verifies the copy with `integrity_check`. Resolves * with `destination`, or rejects with code * `DEEPBASE_SQLITE_BACKUP_CORRUPT` when the copy does not verify. */ backup(destination: string): Promise; /** Rebuilds the database file to reclaim free pages. Takes the write lock. */ vacuum(): Promise; /** * Runs `PRAGMA wal_checkpoint`. Rejects with code `DEEPBASE_SQLITE_NOT_WAL` * when the database uses a rollback journal (`pragma: 'none'`). */ checkpoint(mode?: SqliteCheckpointMode): Promise; } export { SqliteDriver as SqliteFastDriver }; export default SqliteDriver;