import { Inject, Injectable } from '@nestjs/common';
import { PLUGIN_REGISTRY } from './plugin.tokens.js';
import type { IChannelPlugin } from './plugin.interface.js';

@Injectable()
export class PluginService {
  constructor(@Inject(PLUGIN_REGISTRY) private readonly plugins: IChannelPlugin[]) {}

  getPlugins(): IChannelPlugin[] {
    return this.plugins;
  }

  getPlugin(name: string): IChannelPlugin | undefined {
    return this.plugins.find((plugin: IChannelPlugin) => plugin.name === name);
  }
}
