ktx/packages/context/src/connections/query-executor.ts

26 lines
715 B
TypeScript
Raw Normal View History

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