mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
fix(cli): close driver registry type export gaps
This commit is contained in:
parent
8a8d40c993
commit
853ab10be2
2 changed files with 27 additions and 12 deletions
|
|
@ -1,8 +1,10 @@
|
|||
import type { KtxConnectionDriver, KtxScanConnector } from '../scan/types.js';
|
||||
|
||||
type KtxScopeConfigKey = 'dataset_ids' | 'databases' | 'schemas' | 'schema_names';
|
||||
/** @internal */
|
||||
export type KtxScopeConfigKey = 'dataset_ids' | 'databases' | 'schemas' | 'schema_names';
|
||||
|
||||
interface KtxDriverConnectorModule {
|
||||
/** @internal */
|
||||
export interface KtxDriverConnectorModule {
|
||||
isConnectionConfig(connection: unknown): boolean;
|
||||
createScanConnector(args: {
|
||||
connectionId: string;
|
||||
|
|
@ -181,15 +183,7 @@ export const driverRegistrations: Record<KtxConnectionDriver, KtxDriverRegistrat
|
|||
},
|
||||
};
|
||||
|
||||
const supportedDrivers: KtxConnectionDriver[] = [
|
||||
'bigquery',
|
||||
'clickhouse',
|
||||
'mysql',
|
||||
'postgres',
|
||||
'sqlite',
|
||||
'snowflake',
|
||||
'sqlserver',
|
||||
];
|
||||
const supportedDrivers = Object.keys(driverRegistrations).sort() as KtxConnectionDriver[];
|
||||
|
||||
function isRegisteredDriver(driver: string): driver is KtxConnectionDriver {
|
||||
return Object.prototype.hasOwnProperty.call(driverRegistrations, driver);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ import {
|
|||
getDriverRegistration,
|
||||
listSupportedDrivers,
|
||||
} from '../../../src/context/connections/drivers.js';
|
||||
import type {
|
||||
KtxDriverConnectorModule,
|
||||
KtxScopeConfigKey,
|
||||
} from '../../../src/context/connections/drivers.js';
|
||||
import type { KtxConnectionDriver } from '../../../src/context/scan/types.js';
|
||||
|
||||
type FixtureFactory = (projectDir: string) => Record<string, unknown>;
|
||||
|
|
@ -66,6 +70,16 @@ const allowedScopeKeys = new Set(['dataset_ids', 'databases', 'schemas', 'schema
|
|||
const historicSqlReaderDrivers = new Set<KtxConnectionDriver>(['postgres', 'bigquery', 'snowflake']);
|
||||
const localExecutorDrivers = new Set<KtxConnectionDriver>(['postgres', 'sqlite']);
|
||||
|
||||
function assertExportedRegistryBoundaryTypes(input: {
|
||||
scopeConfigKey: KtxScopeConfigKey;
|
||||
connectorModule: KtxDriverConnectorModule;
|
||||
}): {
|
||||
scopeConfigKey: KtxScopeConfigKey;
|
||||
connectorModule: KtxDriverConnectorModule;
|
||||
} {
|
||||
return input;
|
||||
}
|
||||
|
||||
describe('driverRegistrations', () => {
|
||||
let projectDir: string;
|
||||
|
||||
|
|
@ -78,13 +92,15 @@ describe('driverRegistrations', () => {
|
|||
});
|
||||
|
||||
it('lists every supported warehouse driver', () => {
|
||||
const registryDrivers = Object.keys(driverRegistrations).sort();
|
||||
expect(listSupportedDrivers()).toEqual(registryDrivers);
|
||||
expect(listSupportedDrivers()).toEqual([
|
||||
'bigquery',
|
||||
'clickhouse',
|
||||
'mysql',
|
||||
'postgres',
|
||||
'sqlite',
|
||||
'snowflake',
|
||||
'sqlite',
|
||||
'sqlserver',
|
||||
]);
|
||||
});
|
||||
|
|
@ -97,6 +113,11 @@ describe('driverRegistrations', () => {
|
|||
it.each(Object.values(driverRegistrations))('adapts $driver connector exports', async (registration) => {
|
||||
const connectorModule = await registration.load();
|
||||
const connection = connectionFixtures[registration.driver](projectDir);
|
||||
const exportedBoundary = assertExportedRegistryBoundaryTypes({
|
||||
scopeConfigKey: registration.scopeConfigKey ?? 'schemas',
|
||||
connectorModule,
|
||||
});
|
||||
expect(exportedBoundary.connectorModule.createScanConnector).toEqual(expect.any(Function));
|
||||
|
||||
expect(connectorModule.isConnectionConfig(connection)).toBe(true);
|
||||
expect(connectorModule.isConnectionConfig({})).toBe(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue