/**
 * TypeScript types for the ban history API.
 */

import type { TimeRange } from "./ban";

/** Optional time-range filter for history queries. */
export type { TimeRange };

/** A single row in the history ban-list table. */
export interface HistoryBanItem {
  ip: string;
  jail: string;
  banned_at: string;
  ban_count: number;
  failures: number;
  matches: string[];
  country_code: string | null;
  country_name: string | null;
  asn: string | null;
  org: string | null;
}

/** Paginated response from GET /api/history */
export interface HistoryListResponse {
  items: HistoryBanItem[];
  total: number;
  page: number;
  page_size: number;
}

/** A single ban event in a per-IP timeline. */
export interface IpTimelineEvent {
  jail: string;
  banned_at: string;
  ban_count: number;
  failures: number;
  matches: string[];
}

/** Full historical record for a single IP address. */
export interface IpDetailResponse {
  ip: string;
  total_bans: number;
  total_failures: number;
  last_ban_at: string | null;
  country_code: string | null;
  country_name: string | null;
  asn: string | null;
  org: string | null;
  timeline: IpTimelineEvent[];
}

/** Query parameters supported by GET /api/history */
import type { BanOriginFilter } from "./ban";

export interface HistoryQuery {
  range?: TimeRange;
  origin?: BanOriginFilter;
  jail?: string;
  ip?: string;
  source?: "fail2ban" | "archive";
  page?: number;
  page_size?: number;
}
