feat: 일반 역할 및 슬롯 인터페이스 추가, 시나리오 파싱 및 부트스트랩 로직 개선
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import type { CommandResolver as CommandResolverType } from './che_상업투자.js';
|
||||
|
||||
export type DomesticCommandKey = 'che_상업투자';
|
||||
|
||||
export type DomesticCommandImporter = () => Promise<{
|
||||
CommandResolver: typeof CommandResolverType;
|
||||
}>;
|
||||
|
||||
const defaultImporters: Record<DomesticCommandKey, DomesticCommandImporter> = {
|
||||
che_상업투자: async () => import('./che_상업투자.js'),
|
||||
};
|
||||
|
||||
export class DomesticCommandLoader {
|
||||
constructor(
|
||||
private readonly importers: Record<
|
||||
DomesticCommandKey,
|
||||
DomesticCommandImporter
|
||||
> = defaultImporters
|
||||
) {}
|
||||
|
||||
async load(
|
||||
key: DomesticCommandKey
|
||||
): Promise<{ CommandResolver: typeof CommandResolverType }> {
|
||||
const importer = this.importers[key];
|
||||
if (!importer) {
|
||||
throw new Error(`Unknown domestic command key: ${key}`);
|
||||
}
|
||||
return importer();
|
||||
}
|
||||
|
||||
async create(key: DomesticCommandKey, ...args: unknown[]): Promise<unknown> {
|
||||
const { CommandResolver } = await this.load(key);
|
||||
return new CommandResolver(...args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user