import type { Adapter } from "./adapter";

export class AdapterRegistry {
  private readonly adapters = new Map<string, Adapter>();

  register(adapter: Adapter): void {
    if (this.adapters.has(adapter.id)) {
      throw new Error(`adapter id collision: ${adapter.id}`);
    }
    this.adapters.set(adapter.id, adapter);
  }

  list(): Adapter[] {
    return [...this.adapters.values()];
  }

  get(id: string): Adapter | undefined {
    return this.adapters.get(id);
  }
}
