/**
 * User Repository Port
 *
 * Defines the interface for User persistence operations.
 * This is a secondary port (output port) in hexagonal architecture.
 */

import { User } from '../../entities/user.entity';

export const USER_REPOSITORY = 'UserRepository';

export interface UserRepository {
  /**
   * Save a user entity
   */
  save(user: User): Promise<User>;

  /**
   * Find user by ID
   */
  findById(id: string): Promise<User | null>;

  /**
   * Find user by email address
   */
  findByEmail(email: string): Promise<User | null>;

  /**
   * Find all users belonging to an organization
   */
  findByOrganization(organizationId: string): Promise<User[]>;

  /**
   * Find all users with a specific role
   */
  findByRole(role: string): Promise<User[]>;

  /**
   * Find all active users
   */
  findAllActive(): Promise<User[]>;

  /**
   * Find all users in the system (admin only)
   */
  findAll(): Promise<User[]>;

  /**
   * Update a user entity
   */
  update(user: User): Promise<User>;

  /**
   * Delete user by ID
   */
  deleteById(id: string): Promise<void>;

  /**
   * Count users in an organization
   */
  countByOrganization(organizationId: string): Promise<number>;

  /**
   * Check if email exists
   */
  emailExists(email: string): Promise<boolean>;
}
