* refactor: deepen gsdtools query execution seams * docs: add changeset for query seam deepening * docs: fix changeset summary text * fix: address coderabbit query seam findings * test: address remaining coderabbit findings and notes * refactor: use internal gsdtools error type import
32 lines
901 B
TypeScript
32 lines
901 B
TypeScript
export interface QueryCommandExecutorDeps {
|
|
nativeMatch: (command: string, args: string[]) => { cmd: string; args: string[] } | null;
|
|
execute: (input: {
|
|
legacyCommand: string;
|
|
legacyArgs: string[];
|
|
registryCommand: string;
|
|
registryArgs: string[];
|
|
mode: 'json' | 'raw';
|
|
}) => Promise<unknown>;
|
|
}
|
|
|
|
/**
|
|
* Module owning command normalization + execution payload shape.
|
|
*/
|
|
export class QueryCommandExecutor {
|
|
constructor(private readonly deps: QueryCommandExecutorDeps) {}
|
|
|
|
async exec(command: string, args: string[], mode: 'json' | 'raw'): Promise<unknown> {
|
|
const matched = this.deps.nativeMatch(command, args);
|
|
const registryCommand = matched?.cmd ?? command;
|
|
const registryArgs = matched?.args ?? args;
|
|
|
|
return this.deps.execute({
|
|
legacyCommand: command,
|
|
legacyArgs: args,
|
|
registryCommand,
|
|
registryArgs,
|
|
mode,
|
|
});
|
|
}
|
|
}
|