import type {
  IDiscoveryDescriptorOptions,
  IDiscoveryMatcher,
  IDiscoveryProbe,
  IDiscoveryValidator,
} from './types.js';

export class DiscoveryDescriptor {
  public readonly integrationDomain: string;
  public readonly displayName: string;

  private readonly probes: IDiscoveryProbe[] = [];
  private readonly matchers: IDiscoveryMatcher[] = [];
  private readonly validators: IDiscoveryValidator[] = [];

  constructor(optionsArg: IDiscoveryDescriptorOptions) {
    this.integrationDomain = optionsArg.integrationDomain;
    this.displayName = optionsArg.displayName;
  }

  public addProbe(probeArg: IDiscoveryProbe): this {
    this.probes.push(probeArg);
    return this;
  }

  public addMatcher<TInput>(matcherArg: IDiscoveryMatcher<TInput>): this {
    this.matchers.push(matcherArg as IDiscoveryMatcher);
    return this;
  }

  public addValidator(validatorArg: IDiscoveryValidator): this {
    this.validators.push(validatorArg);
    return this;
  }

  public getProbes(): IDiscoveryProbe[] {
    return [...this.probes];
  }

  public getMatchers(): IDiscoveryMatcher[] {
    return [...this.matchers];
  }

  public getValidators(): IDiscoveryValidator[] {
    return [...this.validators];
  }
}
