ktx/packages/context/src/connections/query-executor.ts
2026-05-10 23:51:24 +02:00

25 lines
715 B
TypeScript

import type { KtxProjectConnectionConfig } from '../project/index.js';
export interface KtxSqlQueryExecutionInput {
connectionId: string;
projectDir?: string;
connection: KtxProjectConnectionConfig | undefined;
sql: string;
maxRows?: number;
}
export interface KtxSqlQueryExecutionResult {
headers: string[];
rows: unknown[][];
totalRows: number;
command: string;
rowCount: number | null;
}
export interface KtxSqlQueryExecutorPort {
execute(input: KtxSqlQueryExecutionInput): Promise<KtxSqlQueryExecutionResult>;
}
export function normalizeQueryRows(rows: unknown[]): unknown[][] {
return rows.map((row) => (Array.isArray(row) ? row : Object.values(row as Record<string, unknown>)));
}