import { cast } from './cast.js'; export { cast } from './cast.js'; import { format } from './sanitization.js'; export { format } from './sanitization.js'; export { hex } from './text.js'; type Row = T extends 'array' ? any[] : T extends 'object' ? Record : never; interface VitessError { message: string; code: string; } export declare class DatabaseError extends Error { body: VitessError; status: number; constructor(message: string, status: number, body: VitessError); } type Types = Record; export interface ExecutedQuery | Row<'object'>> { headers: string[]; types: Types; rows: T[]; fields: Field[]; size: number; statement: string; insertId: string; rowsAffected: number; time: number; } type Fetch = (input: string, init?: Req) => Promise; type Req = { method: string; headers: Record; body: string; cache?: RequestCache; }; type Res = { ok: boolean; status: number; statusText: string; json(): Promise; text(): Promise; }; export type Cast = typeof cast; type Format = typeof format; export interface Config { url?: string; username?: string; password?: string; host?: string; fetch?: Fetch; format?: Format; cast?: Cast; } export interface Field { name: string; type: string; table?: string; orgTable?: string | null; database?: string | null; orgName?: string | null; columnLength?: number | null; charset?: number | null; decimals?: number; flags?: number | null; columnType?: string | null; } type ExecuteAs = 'array' | 'object'; type ExecuteArgs = Record | any[] | null; type ExecuteOptions = T extends 'array' ? { as?: 'object'; cast?: Cast; } : T extends 'object' ? { as: 'array'; cast?: Cast; } : never; export declare class Client { readonly config: Config; constructor(config: Config); transaction(fn: (tx: Transaction) => Promise): Promise; execute>(query: string, args?: ExecuteArgs, options?: ExecuteOptions<'object'>): Promise>; execute>(query: string, args: ExecuteArgs, options: ExecuteOptions<'array'>): Promise>; connection(): Connection; } export type Transaction = Tx; declare class Tx { private conn; constructor(conn: Connection); execute>(query: string, args?: ExecuteArgs, options?: ExecuteOptions<'object'>): Promise>; execute>(query: string, args: ExecuteArgs, options: ExecuteOptions<'array'>): Promise>; } export declare class Connection { readonly config: Config; private fetch; private session; private url; constructor(config: Config); transaction(fn: (tx: Transaction) => Promise): Promise; refresh(): Promise; execute>(query: string, args?: ExecuteArgs, options?: ExecuteOptions<'object'>): Promise>; execute>(query: string, args: ExecuteArgs, options: ExecuteOptions<'array'>): Promise>; private createSession; } export declare function connect(config: Config): Connection;