fix: clean up ktx yaml config parameters

This commit is contained in:
Andrey Avtomonov 2026-05-13 20:02:25 +02:00
parent 3fde4438b1
commit 2c5560112a
25 changed files with 473 additions and 62 deletions

View file

@ -90,6 +90,13 @@ describe('KtxSqliteScanConnector', () => {
connection: { driver: 'sqlite', path: 'warehouse.db' },
}),
).toBe(dbPath);
expect(() =>
sqliteDatabasePathFromConfig({
connectionId: 'warehouse',
projectDir: tempDir,
connection: { driver: 'sqlite', file_path: 'warehouse.db' },
}),
).toThrow('Native SQLite connector requires connections.warehouse.path or url');
} finally {
if (originalDatabaseUrl === undefined) {
delete process.env.KTX_SQLITE_TEST_URL;

View file

@ -28,7 +28,6 @@ export interface KtxSqliteConnectionConfig {
driver?: string;
path?: string;
url?: string;
file_path?: string;
[key: string]: unknown;
}
@ -146,12 +145,9 @@ export function sqliteDatabasePathFromConfig(input: SqliteDatabasePathInput): st
if (!isKtxSqliteConnectionConfig(input.connection)) {
throw new Error(`Native SQLite connector cannot run driver "${inputDriver}"`);
}
const configuredPath =
stringConfigValue(input.connection, 'path') ??
stringConfigValue(input.connection, 'file_path') ??
sqlitePathFromUrl(stringConfigValue(input.connection, 'url') ?? '');
const configuredPath = stringConfigValue(input.connection, 'path') ?? sqlitePathFromUrl(stringConfigValue(input.connection, 'url') ?? '');
if (!configuredPath) {
throw new Error(`Native SQLite connector requires connections.${input.connectionId}.path, file_path, or url`);
throw new Error(`Native SQLite connector requires connections.${input.connectionId}.path or url`);
}
return isAbsolute(configuredPath) ? configuredPath : resolve(input.projectDir ?? process.cwd(), configuredPath);
}