/**
 * @ai-summary Admin feature types and interfaces
 * @ai-context Defines admin user, audit log, and related data structures
 */

export interface AdminUser {
  auth0Sub: string;
  email: string;
  role: 'admin' | 'super_admin';
  createdAt: Date;
  createdBy: string;
  revokedAt: Date | null;
  updatedAt: Date;
}

export interface CreateAdminRequest {
  email: string;
  role?: 'admin' | 'super_admin';
}

export interface RevokeAdminRequest {
  auth0Sub: string;
}

export interface ReinstateAdminRequest {
  auth0Sub: string;
}

export interface AdminAuditLog {
  id: string;
  actorAdminId: string;
  targetAdminId: string | null;
  action: 'CREATE' | 'REVOKE' | 'REINSTATE' | 'UPDATE' | 'DELETE';
  resourceType?: string;
  resourceId?: string;
  context?: Record<string, any>;
  createdAt: Date;
}

export interface AdminContext {
  userId: string;
  email: string;
  isAdmin: boolean;
  adminRecord?: AdminUser;
}

export interface AdminListResponse {
  total: number;
  admins: AdminUser[];
}

export interface AdminAuditResponse {
  total: number;
  logs: AdminAuditLog[];
}

// Batch operation types
export interface BulkCreateAdminRequest {
  admins: Array<{
    email: string;
    role?: 'admin' | 'super_admin';
  }>;
}

export interface BulkCreateAdminResponse {
  created: AdminUser[];
  failed: Array<{
    email: string;
    error: string;
  }>;
}

export interface BulkRevokeAdminRequest {
  auth0Subs: string[];
}

export interface BulkRevokeAdminResponse {
  revoked: AdminUser[];
  failed: Array<{
    auth0Sub: string;
    error: string;
  }>;
}

export interface BulkReinstateAdminRequest {
  auth0Subs: string[];
}

export interface BulkReinstateAdminResponse {
  reinstated: AdminUser[];
  failed: Array<{
    auth0Sub: string;
    error: string;
  }>;
}

export interface BulkDeleteCatalogResponse {
  deleted: number[];
  failed: Array<{
    id: number;
    error: string;
  }>;
}
