/** * SQLite Database wrapper for AiDex */ import Database from 'better-sqlite3'; export interface DatabaseConfig { dbPath: string; readonly?: boolean; } export declare class AiDexDatabase { private db; private dbPath; private _statsStmt?; constructor(config: DatabaseConfig); /** * Initialize database with schema. Runs incremental migrations BEFORE * exec'ing the schema file, so `CREATE INDEX` statements that reference * newer columns don't blow up on legacy DBs. */ initSchema(): void; /** * Idempotent schema migrations for legacy DBs. Safe to run on a fresh DB * (PRAGMA returns no rows for tables that don't yet exist — every * migration step early-returns in that case). Called from `initSchema()` * AND from `openDatabase()` for writeable opens, so every entry point * (init / update / remove / task / etc.) is covered. */ migrateLegacySchema(): void; private tableColumns; /** * Set metadata value */ setMetadata(key: string, value: string | null): void; /** * Get metadata value */ getMetadata(key: string): string | null; /** * Delete metadata entry */ deleteMetadata(key: string): void; /** * Archive a note to the history table (called before overwriting) */ archiveNote(note: string, summary?: string | null): void; /** * Get note history entries, newest first */ getNoteHistory(limit?: number): Array<{ id: number; note: string; summary: string | null; created_at: number; }>; /** * Search note history by text (case-insensitive LIKE) */ searchNoteHistory(query: string, limit?: number): Array<{ id: number; note: string; summary: string | null; created_at: number; }>; /** * Count note history entries */ countNoteHistory(): number; /** * Run a function in a transaction */ transaction(fn: () => T): T; /** * Get the underlying better-sqlite3 database instance */ getDb(): Database.Database; /** * Get database file path */ getPath(): string; /** * Get database statistics */ getStats(): { files: number; lines: number; items: number; occurrences: number; methods: number; types: number; dependencies: number; sizeBytes: number; }; /** * Close database connection */ close(): void; } /** * Open or create an AiDex database. Writeable opens automatically run * idempotent legacy-schema migrations so that callers like aidex_update / * aidex_remove / aidex_task can safely operate on DBs created by older * versions without crashing on missing columns. */ export declare function openDatabase(dbPath: string, readonly?: boolean): AiDexDatabase; /** * Create and initialize a new AiDex database * If incremental=true, keeps existing data for incremental updates * If incremental=false (default), clears all data for fresh re-index */ export declare function createDatabase(dbPath: string, projectName?: string, projectRoot?: string, incremental?: boolean): AiDexDatabase; //# sourceMappingURL=database.d.ts.map