import type { BaseIntegration } from './classes.baseintegration.js'; import type { IIntegrationRuntime, IIntegrationSetupContext } from './types.js'; export class IntegrationRuntimeManager { private readonly runtimes = new Map(); public async setupIntegration( integrationArg: BaseIntegration, configArg: TConfig, contextArg: IIntegrationSetupContext = {} ): Promise { const runtime = await integrationArg.setup(configArg, contextArg); this.runtimes.set(integrationArg.domain, runtime); return runtime; } public getRuntime(domainArg: string): IIntegrationRuntime | undefined { return this.runtimes.get(domainArg); } public listRuntimes(): IIntegrationRuntime[] { return [...this.runtimes.values()]; } public async destroyAll(): Promise { for (const runtime of this.runtimes.values()) { await runtime.destroy(); } this.runtimes.clear(); } }