/**
 * Type declarations for optional store dependencies.
 *
 * These modules are optional — they may not be installed.
 * We declare just enough types here for the store implementations to compile
 * without requiring the actual packages.
 */

declare module 'better-sqlite3' {
  interface RunResult {
    changes: number;
    lastInsertRowid: number | bigint;
  }

  interface Statement {
    run(...params: unknown[]): RunResult;
    get(...params: unknown[]): unknown;
    all(...params: unknown[]): unknown[];
  }

  class Database {
    constructor(filename: string, options?: unknown);
    prepare(sql: string): Statement;
    exec(sql: string): Database;
    pragma(pragma: string): unknown;
    close(): void;
  }

  export default Database;
}

declare module 'postgres' {
  interface Sql {
    <T = unknown>(
      strings: TemplateStringsArray,
      ...values: unknown[]
    ): Promise<T[]>;
    unsafe(sql: string, params?: unknown[]): Promise<unknown[]>;
    json(data: unknown): unknown;
    end(): Promise<void>;
  }

  function postgres(connectionString: string): Sql;

  export default postgres;
}