import { UpdateQueryResponse } from "@forge/sql"; /** * Metadata structure for Forge SQL query results. * Contains execution timing, response size, and field information. */ export type ForgeSQLMetadata = { dbExecutionTime: number; responseSize: number; fields: { catalog: string; name: string; schema: string; characterSet: number; decimals: number; table: string; orgTable: string; orgName: string; flags: number; columnType: number; columnLength: number; }[]; }; /** * Result structure for Forge SQL queries. * Contains rows data and execution metadata. */ export interface ForgeSQLResult { rows: Record[] | Record; metadata: ForgeSQLMetadata; } /** * Driver result structure for Drizzle ORM compatibility. */ export interface ForgeDriverResult { rows: unknown[]; insertId?: number; affectedRows?: number; } /** * Query execution method types. */ export type QueryMethod = "all" | "execute"; /** * Type guard to check if an object is an UpdateQueryResponse. * * @param obj - The object to check * @returns True if the object is an UpdateQueryResponse */ export declare function isUpdateQueryResponse(obj: unknown): obj is UpdateQueryResponse; /** * Maps result rows (returned by the Forge SQL API as hashes/objects) into the * positional arrays expected by Drizzle ORM. * * The Forge SQL API returns each row as an object keyed by column name. The key * ordering of that object is NOT guaranteed to match the order of the columns in * the executed query. Drizzle, however, consumes rows positionally. Relying on * `Object.values(row)` therefore risks assigning values to the wrong columns. * * When field metadata is available, the column order it describes is used as the * canonical ordering and each value is looked up by its column name. When no * metadata is available (or it does not cover the row), we fall back to * `Object.values`, preserving the original behaviour of the driver. * * @param rows - The rows returned by the Forge SQL API. * @param metadata - The query metadata containing the ordered field definitions. * @returns The rows as positional value arrays aligned to the field order. */ export declare function mapRowsToValues(rows: Record[], metadata?: ForgeSQLMetadata): unknown[][]; /** * Main Forge SQL driver function for Drizzle ORM integration. * Handles DDL operations, execute operations (UPDATE/INSERT/DELETE), and select operations. * Automatically saves query execution metadata to the context for performance monitoring. * * @param query - The SQL query to execute * @param params - Query parameters (may be undefined or empty array) * @param method - Execution method ("all" for SELECT, "execute" for UPDATE/INSERT/DELETE) * @returns Promise with query results compatible with Drizzle ORM * * @throws {Error} When DDL operations are called with parameters * * @example * ```typescript * // DDL operation * await forgeDriver("CREATE TABLE users (id INT)", [], "all"); * * // SELECT operation * await forgeDriver("SELECT * FROM users WHERE id = ?", [1], "all"); * * // UPDATE operation * await forgeDriver("UPDATE users SET name = ? WHERE id = ?", ["John", 1], "execute"); * ``` */ export declare const forgeDriver: (query: string, params: unknown[] | undefined, method: QueryMethod) => Promise; //# sourceMappingURL=forgeDriver.d.ts.map