import { AdminUser } from '../../domain/entities/AdminUser';
import { Email } from '../../domain/value-objects/Email';
import { UserId } from '../../domain/value-objects/UserId';
import { UserRole } from '../../domain/value-objects/UserRole';
import { UserStatus } from '../../domain/value-objects/UserStatus';

export interface UserFilter {
  role?: UserRole;
  status?: UserStatus;
  email?: Email;
  search?: string;
}

export interface UserSort {
  field: 'email' | 'displayName' | 'createdAt' | 'lastLoginAt' | 'status';
  direction: 'asc' | 'desc';
}

export interface UserPagination {
  page: number;
  limit: number;
}

export interface UserListQuery {
  filter?: UserFilter;
  sort?: UserSort | undefined;
  pagination?: UserPagination | undefined;
}

export interface UserListResult {
  users: AdminUser[];
  total: number;
  page: number;
  limit: number;
  totalPages: number;
}

/**
 * Output port for user management operations
 * Implemented by infrastructure layer
 */
export interface AdminUserRepository {
  findById(id: UserId): Promise<AdminUser | null>;
  findByEmail(email: Email): Promise<AdminUser | null>;
  emailExists(email: Email): Promise<boolean>;
  list(query?: UserListQuery): Promise<UserListResult>;
  count(filter?: UserFilter): Promise<number>;
  create(user: AdminUser): Promise<AdminUser>;
  update(user: AdminUser): Promise<AdminUser>;
  delete(id: UserId): Promise<void>;
}