import type { Changes, SQLQueryBindings } from "bun:sqlite";
import type { SqlExpr } from "../search/types.js";
import type { DbxDatabase } from "./database.js";
export declare const DynamicModelShapeKey = "__pbDynamicModelShape";
export declare const DynamicModelFactoryKey = "__pbDynamicModelFactory";
type DbxNamedParams = Record<string, SQLQueryBindings>;
type DbxExecHookFunc = (q: DbxQuery, op: () => unknown) => unknown;
type DbxOneHookFunc = <T>(q: DbxQuery, into: T | undefined, op: (nextInto: T | undefined) => T | null) => T | null | void;
type DbxAllHookFunc = <T>(q: DbxQuery, into: T[] | undefined, op: (nextInto: T[] | undefined) => T[]) => T[] | void;
type DbxBuildHookFunc = (q: DbxQuery) => void;
declare class DbxRows {
    #private;
    constructor(rows: Array<Record<string, unknown>>);
    next(): boolean;
    nextResultSet(): boolean;
    err(): null;
    columns(): string[];
    columnTypes(): unknown[];
    scanMap(into: Record<string, unknown>): void;
    scanStruct(into: Record<string, unknown>): void;
    scan(...into: unknown[]): void;
    close(): void;
    [Symbol.dispose](): void;
}
export declare class DbxQuery {
    #private;
    fieldMapper: unknown;
    lastError: Error | null;
    logFunc: unknown;
    perfFunc: unknown;
    queryLogFunc: unknown;
    execLogFunc: unknown;
    constructor(db: DbxDatabase, sql: string, params?: SQLQueryBindings[]);
    Bind(...params: Array<SQLQueryBindings | DbxNamedParams>): this;
    bind(...params: Array<SQLQueryBindings | DbxNamedParams>): this;
    sql(): string;
    params(): SQLQueryBindings[];
    context(): unknown;
    withContext(ctx: unknown): this;
    withExecHook(fn: DbxExecHookFunc): this;
    withOneHook(fn: DbxOneHookFunc): this;
    withAllHook(fn: DbxAllHookFunc): this;
    prepare(): this;
    close(): void;
    [Symbol.dispose](): void;
    execute(): Changes;
    one<T extends Record<string, unknown>>(into?: T): T | null;
    all<T extends Record<string, unknown>>(into?: T[]): T[];
    rows(): DbxRows;
    row(...into: unknown[]): unknown;
    column(into?: unknown): unknown;
}
export declare class DbxSelectQuery {
    #private;
    fieldMapper: unknown;
    tableMapper: unknown;
    constructor(db: DbxDatabase, fields: string[]);
    select(...fields: string[]): this;
    andSelect(...fields: string[]): this;
    distinct(value: boolean): this;
    selectOption(option: string): this;
    withBuildHook(fn: DbxBuildHookFunc): this;
    context(): unknown;
    withContext(ctx: unknown): this;
    preFragment(fragment: string): this;
    postFragment(fragment: string): this;
    from(...tables: string[]): this;
    where(expr: SqlExpr | string): this;
    andWhere(expr: SqlExpr | string): this;
    orWhere(expr: SqlExpr | string): this;
    join(typ: string, table: string, on?: SqlExpr | string): this;
    innerJoin(table: string, on?: SqlExpr | string): this;
    leftJoin(table: string, on?: SqlExpr | string): this;
    rightJoin(table: string, on?: SqlExpr | string): this;
    groupBy(...columns: string[]): this;
    andGroupBy(...columns: string[]): this;
    having(expr: SqlExpr | string): this;
    andHaving(expr: SqlExpr | string): this;
    orHaving(expr: SqlExpr | string): this;
    bind(...params: Array<SQLQueryBindings | DbxNamedParams>): this;
    andBind(...params: Array<SQLQueryBindings | DbxNamedParams>): this;
    union(query: DbxQuery): this;
    unionAll(query: DbxQuery): this;
    limit(limit: number): this;
    offset(offset: number): this;
    orderBy(...expr: string[]): this;
    andOrderBy(...expr: string[]): this;
    one<T extends Record<string, unknown>>(into?: T): T | null;
    model<T extends Record<string, unknown>>(pk: SQLQueryBindings, model: T): T | null;
    all<T extends Record<string, unknown>>(into?: T[]): T[];
    rows(): DbxRows;
    row(...into: unknown[]): unknown;
    column(into?: unknown): unknown;
    info(): SelectQueryInfo;
    build(): DbxQuery;
    private buildSql;
    private buildParams;
}
type SelectJoin = {
    typ: string;
    table: string;
    on: SqlExpr | null;
};
type SelectUnion = {
    all: boolean;
    query: DbxQuery;
};
type SelectQueryInfo = {
    preFragment: string;
    postFragment: string;
    builder: DbxDatabase;
    selects: string[];
    distinct: boolean;
    selectOption: string;
    from: string[];
    where: SqlExpr | null;
    join: SelectJoin[];
    orderBy: string[];
    groupBy: string[];
    having: SqlExpr | null;
    union: SelectUnion[];
    limit: number | null;
    offset: number | null;
    params: Array<SQLQueryBindings | DbxNamedParams>;
    context: unknown;
    buildHook: DbxBuildHookFunc | null;
};
export {};
