mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-13 08:15:14 +02:00
refactor: remove legacy compatibility paths
This commit is contained in:
parent
c22248dabf
commit
a517c834fe
83 changed files with 239 additions and 534 deletions
|
|
@ -132,11 +132,11 @@ function uniqueSorted(values: number[]): number[] {
|
|||
}
|
||||
|
||||
function resolveMetabaseUrl(connection: KtxProjectConnectionConfig | undefined): string | undefined {
|
||||
return stringField(connection?.api_url) ?? stringField(connection?.apiUrl) ?? stringField(connection?.url);
|
||||
return stringField(connection?.api_url);
|
||||
}
|
||||
|
||||
function resolveLiteralMetabaseApiKey(connection: KtxProjectConnectionConfig | undefined): string | undefined {
|
||||
return stringField(connection?.api_key) ?? stringField(connection?.apiKey);
|
||||
return stringField(connection?.api_key);
|
||||
}
|
||||
|
||||
function listMetabaseConnectionIds(project: KtxLocalProject): string[] {
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ function shouldShowSetupEntryMenu(
|
|||
disableHistoricSql?: boolean;
|
||||
historicSqlWindowDays?: number;
|
||||
historicSqlMinExecutions?: number;
|
||||
historicSqlMinCalls?: number;
|
||||
historicSqlServiceAccountPattern?: string[];
|
||||
historicSqlRedactionPattern?: string[];
|
||||
skipDatabases?: boolean;
|
||||
|
|
@ -180,7 +179,6 @@ function shouldShowSetupEntryMenu(
|
|||
'disableHistoricSql',
|
||||
'historicSqlWindowDays',
|
||||
'historicSqlMinExecutions',
|
||||
'historicSqlMinCalls',
|
||||
'skipDatabases',
|
||||
'source',
|
||||
'sourceConnectionId',
|
||||
|
|
@ -266,11 +264,6 @@ export function registerSetupCommands(program: Command, context: KtxCliCommandCo
|
|||
.option('--disable-historic-sql', 'Disable Historic SQL for the selected database', false)
|
||||
.option('--historic-sql-window-days <number>', 'Historic SQL query-history window', positiveInteger)
|
||||
.option('--historic-sql-min-executions <number>', 'Minimum Historic SQL executions for a template', positiveInteger)
|
||||
.option(
|
||||
'--historic-sql-min-calls <number>',
|
||||
'Alias for --historic-sql-min-executions',
|
||||
positiveInteger,
|
||||
)
|
||||
.option(
|
||||
'--historic-sql-service-account-pattern <pattern>',
|
||||
'Historic SQL service-account regex; repeatable',
|
||||
|
|
@ -352,7 +345,6 @@ export function registerSetupCommands(program: Command, context: KtxCliCommandCo
|
|||
|
||||
const mode = options.new ? 'new' : options.existing ? 'existing' : 'auto';
|
||||
const resolvedAgentScope = options.global ? 'global' : options.agentScope;
|
||||
const historicSqlMinExecutions = options.historicSqlMinExecutions ?? options.historicSqlMinCalls;
|
||||
await runSetupArgs(context, {
|
||||
command: 'run',
|
||||
projectDir: resolveCommandProjectDir(command),
|
||||
|
|
@ -380,7 +372,9 @@ export function registerSetupCommands(program: Command, context: KtxCliCommandCo
|
|||
...(options.enableHistoricSql ? { enableHistoricSql: true } : {}),
|
||||
...(options.disableHistoricSql ? { disableHistoricSql: true } : {}),
|
||||
...(options.historicSqlWindowDays !== undefined ? { historicSqlWindowDays: options.historicSqlWindowDays } : {}),
|
||||
...(historicSqlMinExecutions !== undefined ? { historicSqlMinExecutions } : {}),
|
||||
...(options.historicSqlMinExecutions !== undefined
|
||||
? { historicSqlMinExecutions: options.historicSqlMinExecutions }
|
||||
: {}),
|
||||
...(options.historicSqlServiceAccountPattern.length > 0
|
||||
? { historicSqlServiceAccountPatterns: options.historicSqlServiceAccountPattern }
|
||||
: {}),
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ const SYNC_MODE_METABASE_CARDS: MetabaseCard[] = [
|
|||
collection_id: 12,
|
||||
archived: false,
|
||||
result_metadata: [],
|
||||
dataset_query: { type: 'native', database: 1, native: { query: 'select 101 as id' } },
|
||||
dataset_query: { type: 'native', database: 1, stages: [{ 'lib/type': 'mbql.stage/native', native: 'select 101 as id' }] },
|
||||
parameters: [],
|
||||
dashboard_count: 0,
|
||||
},
|
||||
|
|
@ -389,7 +389,7 @@ const SYNC_MODE_METABASE_CARDS: MetabaseCard[] = [
|
|||
collection_id: 12,
|
||||
archived: false,
|
||||
result_metadata: [],
|
||||
dataset_query: { type: 'native', database: 1, native: { query: 'select 102 as id' } },
|
||||
dataset_query: { type: 'native', database: 1, stages: [{ 'lib/type': 'mbql.stage/native', native: 'select 102 as id' }] },
|
||||
parameters: [],
|
||||
dashboard_count: 0,
|
||||
},
|
||||
|
|
@ -403,7 +403,7 @@ const SYNC_MODE_METABASE_CARDS: MetabaseCard[] = [
|
|||
collection_id: 13,
|
||||
archived: false,
|
||||
result_metadata: [],
|
||||
dataset_query: { type: 'native', database: 1, native: { query: 'select 103 as id' } },
|
||||
dataset_query: { type: 'native', database: 1, stages: [{ 'lib/type': 'mbql.stage/native', native: 'select 103 as id' }] },
|
||||
parameters: [],
|
||||
dashboard_count: 0,
|
||||
},
|
||||
|
|
@ -453,11 +453,11 @@ function createSyncModeMetabaseClient(): MetabaseRuntimeClient {
|
|||
},
|
||||
getAllCards: async () => SYNC_MODE_METABASE_CARDS.map(metabaseCardSummary),
|
||||
convertMbqlToNative: async () => ({ query: 'select 1' }),
|
||||
getNativeSql: (card) => card.dataset_query?.native?.query ?? null,
|
||||
getNativeSql: (card) => card.dataset_query?.stages?.[0]?.native ?? null,
|
||||
getTemplateTags: () => ({}),
|
||||
getCardSql: async (card) => card.dataset_query?.native?.query ?? null,
|
||||
getCardSql: async (card) => card.dataset_query?.stages?.[0]?.native ?? null,
|
||||
getResolvedSql: async (card) => ({
|
||||
resolvedSql: card.dataset_query?.native?.query ?? `select ${card.id} as id`,
|
||||
resolvedSql: card.dataset_query?.stages?.[0]?.native ?? `select ${card.id} as id`,
|
||||
templateTags: [],
|
||||
resolutionStatus: 'resolved',
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -716,7 +716,6 @@ describe('runKtxIngest', () => {
|
|||
patternPagesWritten: 30,
|
||||
stalePatternPagesMarked: 2,
|
||||
archivedPatternPages: 3,
|
||||
legacyPagesDeleted: 4,
|
||||
},
|
||||
errors: [],
|
||||
warnings: [],
|
||||
|
|
@ -750,7 +749,7 @@ describe('runKtxIngest', () => {
|
|||
|
||||
expect(io.stderr()).toBe('');
|
||||
expect(io.stdout()).toContain('Adapter: historic-sql\n');
|
||||
expect(io.stdout()).toContain('Saved memory: 39 wiki, 57 SL\n');
|
||||
expect(io.stdout()).toContain('Saved memory: 35 wiki, 57 SL\n');
|
||||
});
|
||||
|
||||
it('returns a non-zero code when local ingest reports failed work units', async () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { join } from 'node:path';
|
||||
import {
|
||||
createBigQueryLiveDatabaseIntrospection,
|
||||
isKtxBigQueryConnectionConfig,
|
||||
|
|
@ -298,7 +297,6 @@ function historicSqlOptionsForLocalRun(project: KtxLocalProject, options: KtxCli
|
|||
|
||||
const base = {
|
||||
sqlAnalysis: ktxCliHistoricSqlAnalysis(options),
|
||||
postgresBaselineRootDir: join(project.projectDir, '.ktx/cache/historic-sql'),
|
||||
};
|
||||
|
||||
if (dialect === 'postgres') {
|
||||
|
|
|
|||
|
|
@ -62,10 +62,7 @@ describe('createKtxCliScanConnector', () => {
|
|||
expect(connector.driver).toBe('sqlite');
|
||||
});
|
||||
|
||||
it.each([
|
||||
['maxBytesBilled', ' maxBytesBilled: 123456789', 123456789],
|
||||
['max_bytes_billed', ' max_bytes_billed: "987654321"', '987654321'],
|
||||
])('passes BigQuery %s from standalone config', async (_label, byteCapLine, expectedMaxBytesBilled) => {
|
||||
it('passes BigQuery max_bytes_billed from standalone config', async () => {
|
||||
await initKtxProject({ projectDir: tempDir, projectName: 'warehouse' });
|
||||
await writeFile(
|
||||
join(tempDir, 'ktx.yaml'),
|
||||
|
|
@ -76,7 +73,7 @@ describe('createKtxCliScanConnector', () => {
|
|||
' driver: bigquery',
|
||||
' dataset_id: analytics',
|
||||
' readonly: true',
|
||||
byteCapLine,
|
||||
' max_bytes_billed: "987654321"',
|
||||
'',
|
||||
].join('\n'),
|
||||
'utf-8',
|
||||
|
|
@ -90,7 +87,7 @@ describe('createKtxCliScanConnector', () => {
|
|||
expect(bigQueryMock.constructorInputs).toEqual([
|
||||
expect.objectContaining({
|
||||
connectionId: 'warehouse',
|
||||
maxBytesBilled: expectedMaxBytesBilled,
|
||||
maxBytesBilled: '987654321',
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const SUPPORTED_DRIVERS = 'sqlite, postgres, mysql, clickhouse, sqlserver, bigqu
|
|||
function bigQueryMaxBytesBilled(
|
||||
connection: KtxLocalProject['config']['connections'][string],
|
||||
): number | string | undefined {
|
||||
const raw = connection.maxBytesBilled ?? connection.max_bytes_billed;
|
||||
const raw = connection.max_bytes_billed;
|
||||
if (typeof raw === 'number') {
|
||||
return Number.isFinite(raw) && raw > 0 ? raw : undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import {
|
|||
formatSetupNextStepLines,
|
||||
} from './next-steps.js';
|
||||
|
||||
const command = (...parts: string[]) => parts.join(' ');
|
||||
|
||||
describe('KTX demo next steps', () => {
|
||||
it('uses supported context-build commands before agent usage', () => {
|
||||
expect(KTX_CONTEXT_BUILD_COMMANDS).toEqual([
|
||||
|
|
@ -57,29 +55,6 @@ describe('KTX demo next steps', () => {
|
|||
expect(rendered).not.toContain('Optional MCP:');
|
||||
});
|
||||
|
||||
it('does not advertise removed Commander migration commands', () => {
|
||||
const rendered = formatNextStepLines().join('\n');
|
||||
|
||||
expect(rendered).toContain('ktx status --json');
|
||||
expect(rendered).not.toContain('ktx agent');
|
||||
expect(rendered).toContain('ktx sl list');
|
||||
expect(rendered).toContain('ktx wiki list');
|
||||
|
||||
for (const removed of [
|
||||
command('ktx', 'ask'),
|
||||
command('ktx', 'mcp'),
|
||||
command('ktx', 'connect'),
|
||||
command('ktx', 'knowledge'),
|
||||
command('dev', 'model'),
|
||||
command('dev', 'knowledge'),
|
||||
command('ktx', 'ingest', 'run'),
|
||||
command('ktx', 'ingest', 'replay'),
|
||||
command('ktx', 'serve', '--mcp', 'stdio', '--user-id', 'local'),
|
||||
]) {
|
||||
expect(rendered).not.toContain(removed);
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps setup next steps focused on building context when the build is not ready', () => {
|
||||
const rendered = formatSetupNextStepLines({
|
||||
setupReady: true,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ function normalizedDriver(connection: KtxProjectConnectionConfig): string {
|
|||
}
|
||||
|
||||
function sourceDirForConnection(connection: KtxProjectConnectionConfig): string | undefined {
|
||||
const value = connection.source_dir ?? connection.sourceDir;
|
||||
const value = connection.source_dir;
|
||||
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,6 @@ function textInputPrompt(message: string): string {
|
|||
return `${title}\n│\n│ ${bodyLines.join('\n│ ')}\n│ Press Escape to go back.\n│`;
|
||||
}
|
||||
|
||||
const legacyHistoricSqlServiceAccountPatternsKey = ['serviceAccount', 'UserPatterns'].join('');
|
||||
|
||||
describe('setup databases step', () => {
|
||||
let tempDir: string;
|
||||
|
||||
|
|
@ -1288,7 +1286,6 @@ describe('setup databases step', () => {
|
|||
redactionPatterns: ['(?i)secret'],
|
||||
},
|
||||
});
|
||||
expect(config.connections.snowflake.historicSql).not.toHaveProperty(legacyHistoricSqlServiceAccountPatternsKey);
|
||||
expect(config.ingest.adapters).toContain('historic-sql');
|
||||
});
|
||||
|
||||
|
|
@ -1336,10 +1333,8 @@ describe('setup databases step', () => {
|
|||
},
|
||||
},
|
||||
});
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('minCalls');
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('windowDays');
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty('redactionPatterns');
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty(legacyHistoricSqlServiceAccountPatternsKey);
|
||||
expect(config.ingest.adapters).toContain('historic-sql');
|
||||
expect(config.ingest.workUnits.maxConcurrency).toBe(6);
|
||||
expect(io.stdout()).toContain('Historic SQL probe...');
|
||||
|
|
@ -1393,7 +1388,6 @@ describe('setup databases step', () => {
|
|||
redactionPatterns: [],
|
||||
},
|
||||
});
|
||||
expect(config.connections.analytics.historicSql).not.toHaveProperty(legacyHistoricSqlServiceAccountPatternsKey);
|
||||
expect(config.ingest.adapters).toContain('historic-sql');
|
||||
});
|
||||
|
||||
|
|
@ -1443,7 +1437,6 @@ describe('setup databases step', () => {
|
|||
},
|
||||
},
|
||||
});
|
||||
expect(config.connections.warehouse.historicSql).not.toHaveProperty(legacyHistoricSqlServiceAccountPatternsKey);
|
||||
});
|
||||
|
||||
it('prints a non-blocking Postgres Historic SQL probe failure after connection test succeeds', async () => {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ export interface KtxSetupDatabasesArgs {
|
|||
disableHistoricSql?: boolean;
|
||||
historicSqlWindowDays?: number;
|
||||
historicSqlMinExecutions?: number;
|
||||
historicSqlMinCalls?: number;
|
||||
historicSqlServiceAccountPatterns?: string[];
|
||||
historicSqlRedactionPatterns?: string[];
|
||||
skipDatabases: boolean;
|
||||
|
|
@ -857,14 +856,13 @@ async function maybeApplyHistoricSqlConfig(input: {
|
|||
dialect,
|
||||
filters: historicSqlFiltersForSetup(input.args.historicSqlServiceAccountPatterns),
|
||||
};
|
||||
delete common[['serviceAccount', 'UserPatterns'].join('')];
|
||||
|
||||
if (dialect === 'postgres') {
|
||||
return {
|
||||
...input.connection,
|
||||
historicSql: {
|
||||
...common,
|
||||
minExecutions: input.args.historicSqlMinExecutions ?? input.args.historicSqlMinCalls ?? 5,
|
||||
minExecutions: input.args.historicSqlMinExecutions ?? 5,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,8 +544,8 @@ function sourcePathFromFileRepoUrl(repoUrl: string, subpath?: string): string {
|
|||
}
|
||||
|
||||
function repoAuthToken(connection: KtxProjectConnectionConfig | Record<string, unknown>): string | null {
|
||||
const ref = stringField(connection.auth_token_ref) ?? stringField(connection.authTokenRef);
|
||||
const literal = stringField(connection.authToken) ?? stringField(connection.auth_token);
|
||||
const ref = stringField(connection.auth_token_ref);
|
||||
const literal = stringField(connection.auth_token);
|
||||
return literal ?? resolveKtxConfigReference(ref, process.env) ?? null;
|
||||
}
|
||||
|
||||
|
|
@ -563,8 +563,8 @@ async function collectYamlFilesRecursive(sourceRoot: string): Promise<Array<{ co
|
|||
}
|
||||
|
||||
async function defaultValidateDbt(connection: KtxProjectConnectionConfig): Promise<SourceValidationResult> {
|
||||
let sourceDir = stringField(connection.source_dir) ?? stringField(connection.sourceDir);
|
||||
const repoUrl = stringField(connection.repo_url) ?? stringField(connection.repoUrl);
|
||||
let sourceDir = stringField(connection.source_dir);
|
||||
const repoUrl = stringField(connection.repo_url);
|
||||
if (!sourceDir && repoUrl?.startsWith('file:')) {
|
||||
sourceDir = sourcePathFromFileRepoUrl(repoUrl, stringField(connection.path));
|
||||
}
|
||||
|
|
@ -624,7 +624,7 @@ async function defaultValidateLooker(projectDir: string, connectionId: string):
|
|||
}
|
||||
|
||||
async function defaultValidateLookml(connection: KtxProjectConnectionConfig): Promise<SourceValidationResult> {
|
||||
const repoUrl = stringField(connection.repoUrl) ?? stringField(connection.repo_url);
|
||||
const repoUrl = stringField(connection.repoUrl);
|
||||
if (!repoUrl) {
|
||||
return { ok: false, message: 'LookML setup requires repoUrl.' };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ export type KtxSetupArgs =
|
|||
disableHistoricSql?: boolean;
|
||||
historicSqlWindowDays?: number;
|
||||
historicSqlMinExecutions?: number;
|
||||
historicSqlMinCalls?: number;
|
||||
historicSqlServiceAccountPatterns?: string[];
|
||||
historicSqlRedactionPatterns?: string[];
|
||||
skipDatabases: boolean;
|
||||
|
|
@ -626,7 +625,6 @@ async function runKtxSetupInner(args: KtxSetupArgs, io: KtxCliIo, deps: KtxSetup
|
|||
...(args.historicSqlMinExecutions !== undefined
|
||||
? { historicSqlMinExecutions: args.historicSqlMinExecutions }
|
||||
: {}),
|
||||
...(args.historicSqlMinCalls !== undefined ? { historicSqlMinCalls: args.historicSqlMinCalls } : {}),
|
||||
...(args.historicSqlServiceAccountPatterns
|
||||
? { historicSqlServiceAccountPatterns: args.historicSqlServiceAccountPatterns }
|
||||
: {}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue