import { BaseIntegration } from './classes.baseintegration.js';
import { DiscoveryDescriptor } from './classes.discoverydescriptor.js';
import { IntegrationError } from './errors.js';
import type { IIntegrationRuntime, IIntegrationSetupContext, TIntegrationStatus } from './types.js';

export interface IDescriptorOnlyIntegrationOptions {
  domain: string;
  displayName: string;
  status?: TIntegrationStatus;
  metadata?: Record<string, unknown>;
}

export class DescriptorOnlyIntegration extends BaseIntegration<unknown> {
  public readonly domain: string;
  public readonly displayName: string;
  public readonly status: TIntegrationStatus;
  public readonly discoveryDescriptor: DiscoveryDescriptor;
  public readonly metadata: Record<string, unknown>;

  constructor(optionsArg: IDescriptorOnlyIntegrationOptions) {
    super();
    this.domain = optionsArg.domain;
    this.displayName = optionsArg.displayName;
    this.status = optionsArg.status || 'descriptor-only';
    this.metadata = optionsArg.metadata || {};
    this.discoveryDescriptor = new DiscoveryDescriptor({
      integrationDomain: this.domain,
      displayName: this.displayName,
    });
  }

  public async setup(configArg: unknown, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void configArg;
    void contextArg;
    throw new IntegrationError(
      `Integration ${this.domain} is descriptor-only and has no TypeScript runtime yet.`,
      'DESCRIPTOR_ONLY_INTEGRATION'
    );
  }

  public async destroy(): Promise<void> {}
}
