/**
 * Type definitions for @jlongster/sql.js
 * @author Matthew Raymer
 * @description TypeScript declaration file for the SQL.js WASM module with filesystem support
 */

declare module '@jlongster/sql.js' {
  export interface FileSystem {
    mkdir(path: string): void;
    mount(fs: any, opts: any, mountpoint: string): void;
    open(path: string, flags: string): FileStream;
    close(stream: FileStream): void;
  }

  export interface FileStream {
    node: {
      contents: {
        readIfFallback(): Promise<void>;
      };
    };
  }

  export interface Database {
    exec(sql: string, params?: any[]): Promise<QueryExecResult[]>;
    prepare(sql: string): Statement;
    run(sql: string, params?: any[]): Promise<{ changes: number; lastId?: number }>;
    close(): void;
  }

  export interface QueryExecResult {
    columns: string[];
    values: any[][];
  }

  export interface Statement {
    bind(params: any[]): void;
    step(): boolean;
    get(): any[];
    getColumnNames(): string[];
    reset(): void;
    free(): void;
  }

  export interface InitSqlJsStatic {
    (config?: {
      locateFile?: (file: string) => string;
      wasmBinary?: ArrayBuffer;
    }): Promise<{
      Database: new (path?: string | Uint8Array, opts?: { filename?: boolean }) => Database;
      FS: FileSystem;
      register_for_idb: (fs: any) => void;
    }>;
  }

  const initSqlJs: InitSqlJsStatic;
  export default initSqlJs;
} 