Files
msd-core/sdk/src/query-command-executor.ts
Tom Boucher 42ed7cee8d refactor: deepen GSDTools query execution seams (#3085)
* 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
2026-05-03 18:56:41 -04:00

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,
});
}
}