import type {
  ContentExpectations,
  KeyedExpectations,
  RawContentExpectations,
  RawKeyedExpectations,
  RawValueExpectation,
  ValueExpectation,
} from "../../expect/types";
import type { ResolvedTargetBase } from "../../types";

export interface HttpDefaultsConfig {
  headers?: Record<string, string>;
  maxBodyBytes?: string;
  method?: string;
}

export interface HttpTargetConfig {
  body?: string;
  headers?: Record<string, string>;
  ignoreSSL?: boolean;
  maxBodyBytes?: string;
  maxRedirects?: number;
  method?: string;
  url: string;
}

export interface RawHttpExpectConfig {
  body?: RawContentExpectations;
  durationMs?: RawValueExpectation;
  headers?: RawKeyedExpectations;
  status?: Array<number | string>;
}

export interface ResolvedHttpConfig {
  body?: string;
  headers: Record<string, string>;
  ignoreSSL: boolean;
  maxBodyBytes: number;
  maxRedirects: number;
  method: string;
  url: string;
}

export interface ResolvedHttpExpectConfig {
  body?: ContentExpectations;
  durationMs?: ValueExpectation;
  headers?: KeyedExpectations;
  status: Array<number | string>;
}

export interface ResolvedHttpTarget extends ResolvedTargetBase {
  expect?: ResolvedHttpExpectConfig;
  group: string;
  http: ResolvedHttpConfig;
  intervalMs: number;
  name: null | string;
  rawExpect?: RawHttpExpectConfig;
  timeoutMs: number;
  type: "http";
}
