/** * In-memory implementation of ISessionRepository for development/testing. */ import type { ISessionRepository } from '../../domain/repositories/ISessionRepository'; import type { Session } from '../../domain/entities/Session'; export class InMemorySessionRepository implements ISessionRepository { private sessions: Map = new Map(); async findById(id: string): Promise { return this.sessions.get(id) ?? null; } async findAll(): Promise { return Array.from(this.sessions.values()); } async findByRaceEventId(raceEventId: string): Promise { return Array.from(this.sessions.values()).filter( session => session.raceEventId === raceEventId ); } async findByLeagueId(leagueId: string): Promise { // Sessions don't have leagueId directly - would need to join with RaceEvent // For now, return empty array return []; } async findByStatus(status: string): Promise { return Array.from(this.sessions.values()).filter( session => session.status === status ); } async create(session: Session): Promise { this.sessions.set(session.id, session); return session; } async update(session: Session): Promise { this.sessions.set(session.id, session); return session; } async delete(id: string): Promise { this.sessions.delete(id); } async exists(id: string): Promise { return this.sessions.has(id); } // Test helper methods clear(): void { this.sessions.clear(); } getAll(): Session[] { return Array.from(this.sessions.values()); } }