mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-13 18:21:27 +00:00
fix(check): repair latest type drift batch
This commit is contained in:
@@ -84,6 +84,11 @@ export function defineImportedCommandGroupSpecs<TRegisterArgs, TModule>(
|
||||
}
|
||||
|
||||
type ProgramCommandRegistrar = (program: Command) => Promise<void> | void;
|
||||
type AnyImportedProgramCommandGroupDefinition = {
|
||||
commandNames: readonly string[];
|
||||
loadModule: () => Promise<Record<string, unknown>>;
|
||||
exportName: string;
|
||||
};
|
||||
|
||||
export type ImportedProgramCommandGroupDefinition<
|
||||
TModule extends Record<TKey, ProgramCommandRegistrar>,
|
||||
@@ -108,10 +113,17 @@ export function defineImportedProgramCommandGroupSpec<
|
||||
}
|
||||
|
||||
export function defineImportedProgramCommandGroupSpecs<
|
||||
TModule extends Record<TKey, ProgramCommandRegistrar>,
|
||||
TKey extends keyof TModule & string,
|
||||
>(
|
||||
definitions: readonly ImportedProgramCommandGroupDefinition<TModule, TKey>[],
|
||||
): CommandGroupDescriptorSpec<(program: Command) => Promise<void>>[] {
|
||||
return definitions.map((definition) => defineImportedProgramCommandGroupSpec(definition));
|
||||
const TDefinitions extends readonly AnyImportedProgramCommandGroupDefinition[],
|
||||
>(definitions: TDefinitions): CommandGroupDescriptorSpec<(program: Command) => Promise<void>>[] {
|
||||
return definitions.map((definition) => ({
|
||||
commandNames: definition.commandNames,
|
||||
register: async (program: Command) => {
|
||||
const module = await definition.loadModule();
|
||||
const register = module[definition.exportName];
|
||||
if (typeof register !== "function") {
|
||||
throw new Error(`Missing program command registrar: ${definition.exportName}`);
|
||||
}
|
||||
await register(program);
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user