import { ExternalGameRatingProfile } from '../entities/ExternalGameRatingProfile';

/**
 * Repository Interface: IExternalGameRatingRepository
 * 
 * Port for persisting and retrieving external game rating profiles.
 * Store/display only, no compute.
 */

export interface ExternalGameRatingFilter {
  /** Filter by specific game keys */
  gameKeys?: string[];
  /** Filter by source */
  sources?: string[];
  /** Filter by verification status */
  verified?: boolean;
  /** Filter by last synced date */
  lastSyncedAfter?: Date;
}

export interface PaginatedQueryOptions {
  limit?: number;
  offset?: number;
  filter?: ExternalGameRatingFilter;
}

export interface PaginatedResult<T> {
  items: T[];
  total: number;
  limit: number;
  offset: number;
  hasMore: boolean;
  nextOffset?: number;
}

export interface IExternalGameRatingRepository {
  /**
   * Find profile by user ID and game key
   */
  findByUserIdAndGameKey(userId: string, gameKey: string): Promise<ExternalGameRatingProfile | null>;

  /**
   * Find all profiles for a user
   */
  findByUserId(userId: string): Promise<ExternalGameRatingProfile[]>;

  /**
   * Find all profiles for a game
   */
  findByGameKey(gameKey: string): Promise<ExternalGameRatingProfile[]>;

  /**
   * Save or update a profile
   */
  save(profile: ExternalGameRatingProfile): Promise<ExternalGameRatingProfile>;

  /**
   * Save multiple profiles
   */
  saveMany(profiles: ExternalGameRatingProfile[]): Promise<ExternalGameRatingProfile[]>;

  /**
   * Delete a profile
   */
  delete(userId: string, gameKey: string): Promise<boolean>;

  /**
   * Check if profile exists
   */
  exists(userId: string, gameKey: string): Promise<boolean>;
  
  /**
   * Find profiles with pagination and filtering
   */
  findProfilesPaginated(userId: string, options?: PaginatedQueryOptions): Promise<PaginatedResult<ExternalGameRatingProfile>>;
}
