/** * Database schema and initialization. * * Uses node:sqlite (built-in) for synchronous SQLite access. * DB file is stored at local-server/data/brain.db. */ import { DatabaseSync, type SQLInputValue } from 'node:sqlite'; /** A prepared statement with typed results. Use with `prepare()`. */ export interface TypedStatement { run(...params: SupportedValue[]): { changes: number | bigint; lastInsertRowid: number | bigint; }; get(...params: SupportedValue[]): TRow | undefined; all(...params: SupportedValue[]): TRow[]; } type SupportedValue = SQLInputValue | undefined; /** * Type-safe prepare: wraps `db.prepare()` and returns a `TypedStatement` * so `.get()` and `.all()` return the expected row shape directly. */ export declare function prepare(sql: string): TypedStatement; /** Register a callback to be called when the DB instance is replaced (test-only). */ export declare function _onDbReset(cb: () => void): void; /** Get the singleton database instance. */ export declare function getDb(): DatabaseSync; /** Initialize the database, creating tables if needed. */ export declare function initDatabase(): void; /** Test-only: init an in-memory database, resetting all state. */ export declare function _initTestDatabase(): void; export {};