import { Readable, Writable } from 'stream';
export { Readable, Writable } from 'stream';

interface CLOB {
    type: 'CLOB';
    value: string;
}
interface BLOB {
    type: 'BLOB';
    value: string;
}
type Param = string | number | Date | null | CLOB | BLOB;
interface QueryOptions {
    trim: boolean;
}
interface Metadata {
    name: string;
    typeName: string;
    precision: number;
    scale: number;
}
interface Statement {
    isQuery: () => boolean;
    metadata: () => Promise<Metadata[]>;
    asArray: () => Promise<string[][]>;
    asIterable: () => AsyncIterable<string[]>;
    asStream: (options?: any) => Readable;
    asObjectStream: (options?: any) => Promise<Readable>;
    updated: () => Promise<number>;
    close: Close;
}
type Execute = (sql: string, params?: Param[]) => Promise<Statement>;
type Query = <T>(sql: string, params?: Param[], options?: QueryOptions) => Promise<T[]>;
type Update = (sql: string, params?: Param[]) => Promise<number>;
type CreateReadStream = (sql: string, params?: Param[]) => Readable;
type InsertAndGetId = (sql: string, params?: Param[]) => Promise<number>;
interface WriteStreamOptions {
    bufferSize: number;
}
type CreateWriteStream = (sql: string, options?: WriteStreamOptions) => Writable;
type BatchUpdate = (sql: string, params?: Param[][]) => Promise<number[]>;
type Close = () => void;
type InsertList = (tableName: string, idColumn: string, rows: any[]) => Promise<number[]>;
interface BaseConnection {
    query: Query;
    update: Update;
    isInMemory: () => boolean;
    createReadStream: CreateReadStream;
    insertAndGetId: InsertAndGetId;
    insertList: InsertList;
    createWriteStream: CreateWriteStream;
    batchUpdate: BatchUpdate;
    execute: Execute;
}

export type { BLOB, BaseConnection, BatchUpdate, CLOB, Close, CreateReadStream, CreateWriteStream, Execute, InsertAndGetId, InsertList, Metadata, Param, Query, QueryOptions, Statement, Update, WriteStreamOptions };
