import { DatabaseConnection, Dialect, Driver, QueryCompiler, DialectAdapter, Kysely, DatabaseIntrospector } from 'kysely';

type Promisable<T> = T | Promise<T>;
type BunWorkerDialectConfig = {
    /**
     * db file path
     *
     * @default ':memory:'
     */
    url?: string;
    /**
     * use `bun:sqlite` built-in statment cache
     * @see https://bun.sh/docs/api/sqlite#query
     */
    cacheStatment?: boolean;
    /**
     * custom worker, default is a worker that use bun:sqlite
     */
    worker?: Worker;
    onCreateConnection?: (connection: DatabaseConnection) => Promisable<void>;
};

declare class BunWorkerDialect implements Dialect {
    private config?;
    /**
     * dialect for `bun:sqlite`, run sql in worker
     */
    constructor(config?: BunWorkerDialectConfig);
    createDriver(): Driver;
    createQueryCompiler(): QueryCompiler;
    createAdapter(): DialectAdapter;
    createIntrospector(db: Kysely<any>): DatabaseIntrospector;
}

export { BunWorkerDialect };
