/**
 * Database Adapter Interface
 * Defines contract for different database implementations
 */
import type { SupportedDriver } from '../migrations/enum';
/**
 * Minimal D1 Database interface for type safety
 */
export interface ID1Database {
    prepare(sql: string): {
        bind(...values: unknown[]): {
            all<T = unknown>(): Promise<{
                results?: T[];
                success: boolean;
                error?: string;
                meta?: Record<string, unknown>;
            }>;
            first<T = unknown>(): Promise<T | null>;
            run(): Promise<{
                success: boolean;
                error?: string;
            }>;
        };
    };
}
export interface DatabaseConfig {
    d1?: ID1Database;
    driver: SupportedDriver;
    database?: string;
    host?: string;
    port?: number;
    username?: string;
    password?: string;
    synchronize?: boolean;
    logging?: boolean;
    readHosts?: string[];
}
export interface QueryResult {
    rows: Record<string, unknown>[];
    rowCount: number;
    lastInsertId?: string | number | bigint;
}
export interface IDatabaseAdapter {
    /**
     * Connect to database
     */
    connect(): Promise<void>;
    /**
     * Disconnect from database
     */
    disconnect(): Promise<void>;
    /**
     * Execute a query
     */
    query(sql: string, parameters: unknown[]): Promise<QueryResult>;
    /**
     * Execute a query and return first result
     */
    queryOne(sql: string, parameters: unknown[]): Promise<Record<string, unknown> | null>;
    /**
     * Lightweight connection probe.
     *
     * This should be safe to call from health/readiness endpoints.
     */
    ping(): Promise<void>;
    /**
     * Execute multiple queries in transaction
     */
    transaction<T>(callback: (adapter: IDatabaseAdapter) => Promise<T>): Promise<T>;
    /**
     * Execute raw SQL query (only available when USE_RAW_QRY=true)
     * WARNING: Bypasses QueryBuilder safety. Use parameterized queries.
     */
    rawQuery<T = unknown>(sql: string, parameters?: unknown[]): Promise<T[]>;
    /**
     * Ensure the migrations tracking table exists.
     *
     * This intentionally lives on the adapter so higher-level framework code
     * doesn't embed DDL SQL.
     */
    ensureMigrationsTable?(): Promise<void>;
    /**
     * Best-effort schema reset for development workflows.
     *
     * For SQL databases, this typically means dropping user tables.
     */
    resetSchema?(): Promise<void>;
    /**
     * Get database type
     */
    getType(): SupportedDriver;
    /**
     * Check connection status
     */
    isConnected(): boolean;
    /**
     * Get placeholder for parameterized query
     */
    getPlaceholder(index: number): string;
}
/**
 * Base Adapter Utilities
 * Refactored to Functional Object pattern
 */
export declare const BaseAdapter: Readonly<{
    /**
     * Sanitize parameter value
     */
    sanitize(value: unknown): string;
    /**
     * Build parameterized query (for adapters that need it)
     */
    buildParameterizedQuery(sql: string, parameters: unknown[], getPlaceholder?: (index: number) => string): {
        sql: string;
        parameters: unknown[];
    };
}>;
//# sourceMappingURL=DatabaseAdapter.d.ts.map