/** Shared audit types (mirror `GET /api/v1/admin/audit` contract). */

export type AuditActionType =
  | 'create'
  | 'read'
  | 'update'
  | 'delete'
  | 'login'
  | 'logout'
  | 'login_failed';

export interface AuditListItem {
  id: number;
  occurred_at: string;
  actor_user_id: string | null;
  actor_email: string;
  actor_role: string;
  action: AuditActionType;
  entity_type: string;
  entity_id: string | null;
  metadata: Record<string, unknown>;
  request_id: string | null;
  has_before: boolean;
  has_after: boolean;
}

export interface AuditListResponse {
  items: AuditListItem[];
  total: number;
  page: number;
  page_size: number;
}

export interface AuditEventDetail {
  id: number;
  occurred_at: string;
  actor_user_id: string | null;
  actor_email: string;
  actor_role: string;
  action: AuditActionType;
  entity_type: string;
  entity_id: string | null;
  before: Record<string, unknown> | null;
  after: Record<string, unknown> | null;
  metadata: Record<string, unknown>;
  request_id: string | null;
}

export interface AuditListQuery {
  from?: string;
  to?: string;
  actor_user_id?: string;
  actor_email?: string;
  entity_type?: string;
  entity_id?: string;
  action?: string;
  request_id?: string;
  page?: number;
  page_size?: number;
  sort?: string;
}
