import type { DatabaseConnection } from '../../driver/database-connection.js'; import type { AbortableOperationOptions } from '../../util/abort.js'; /** * Config for the PGlite dialect. */ export interface PGliteDialectConfig { /** * Called once when the first query is executed. * * This is a Kysely specific feature and does not come from the `@electric-sql/pglite` * module. */ onCreateConnection?: (connection: DatabaseConnection, options?: AbortableOperationOptions) => Promise; /** * A PGlite instance or a function that returns one. * * If a function is provided, it's called once when the first query is executed. * * https://pglite.dev/docs/api#main-constructor */ pglite: PGlite | ((options?: AbortableOperationOptions) => PGlite | Promise); } /** * This interface is the subset of the PGlite instance that kysely needs. * * We don't use the type from `@electric-sql/pglite` here to not have a dependency * to it. * * https://pglite.dev/docs/api */ export interface PGlite { close(): Promise; closed: boolean; query(query: string, params?: any[], options?: PGliteQueryOptions): Promise>; ready: boolean; transaction(callback: (tx: PGliteTransaction) => Promise): Promise; waitReady: Promise; } export interface PGliteQueryOptions { blob?: Blob | File; onNotice?: (notice: any) => void; paramTypes?: number[]; parsers?: Record any>; rowMode?: 'array' | 'object'; serializers?: Record string>; } export interface PGliteQueryResults { affectedRows?: number; blob?: Blob; fields: { dataTypeID: number; name: string; }[]; rows: T[]; } export interface PGliteTransaction extends Pick { rollback(): Promise; }