/**
 * SessionState Repository Interface
 *
 * Defines the contract for session state persistence.
 */

import { SessionState } from '../entities/session-state.entity';
import { SessionId, PartyId } from '../value-objects';
import { SessionStatus, SessionType } from '../enums';

export interface SessionStateFilters {
  partyId?: string;
  status?: SessionStatus;
  sessionType?: SessionType;
}

export interface SessionStateRepository {
  /**
   * Save a new session state
   */
  save(session: SessionState): Promise<void>;

  /**
   * Update an existing session state
   */
  update(session: SessionState): Promise<void>;

  /**
   * Find a session state by ID
   */
  findById(id: string): Promise<SessionState | null>;

  /**
   * Find a session state by session ID and party ID
   */
  findBySessionIdAndPartyId(sessionId: SessionId, partyId: PartyId): Promise<SessionState | null>;

  /**
   * Find all session states for a given session
   */
  findBySessionId(sessionId: SessionId): Promise<SessionState[]>;

  /**
   * Find all session states for a given party
   */
  findByPartyId(partyId: PartyId): Promise<SessionState[]>;

  /**
   * Find all in-progress sessions for a party
   */
  findInProgressByPartyId(partyId: PartyId): Promise<SessionState[]>;

  /**
   * Find sessions with filters
   */
  findMany(filters?: SessionStateFilters): Promise<SessionState[]>;

  /**
   * Delete old completed sessions (cleanup)
   */
  deleteCompletedBefore(date: Date): Promise<number>;
}

/**
 * Symbol for dependency injection
 */
export const SESSION_STATE_REPOSITORY = Symbol('SESSION_STATE_REPOSITORY');
