/** * In-Memory Implementation: ISeasonSponsorshipRepository * * Mock repository for testing and development */ import type { SeasonSponsorship, SponsorshipTier } from '../../domain/entities/SeasonSponsorship'; import type { ISeasonSponsorshipRepository } from '../../domain/repositories/ISeasonSponsorshipRepository'; export class InMemorySeasonSponsorshipRepository implements ISeasonSponsorshipRepository { private sponsorships: Map = new Map(); async findById(id: string): Promise { return this.sponsorships.get(id) ?? null; } async findBySeasonId(seasonId: string): Promise { return Array.from(this.sponsorships.values()).filter(s => s.seasonId === seasonId); } async findByLeagueId(leagueId: string): Promise { return Array.from(this.sponsorships.values()).filter(s => s.leagueId === leagueId); } async findBySponsorId(sponsorId: string): Promise { return Array.from(this.sponsorships.values()).filter(s => s.sponsorId === sponsorId); } async findBySeasonAndTier(seasonId: string, tier: SponsorshipTier): Promise { return Array.from(this.sponsorships.values()).filter( s => s.seasonId === seasonId && s.tier === tier ); } async create(sponsorship: SeasonSponsorship): Promise { if (this.sponsorships.has(sponsorship.id)) { throw new Error('SeasonSponsorship with this ID already exists'); } this.sponsorships.set(sponsorship.id, sponsorship); return sponsorship; } async update(sponsorship: SeasonSponsorship): Promise { if (!this.sponsorships.has(sponsorship.id)) { throw new Error('SeasonSponsorship not found'); } this.sponsorships.set(sponsorship.id, sponsorship); return sponsorship; } async delete(id: string): Promise { this.sponsorships.delete(id); } async exists(id: string): Promise { return this.sponsorships.has(id); } /** * Seed initial data */ seed(sponsorships: SeasonSponsorship[]): void { for (const sponsorship of sponsorships) { this.sponsorships.set(sponsorship.id, sponsorship); } } // Test helper clear(): void { this.sponsorships.clear(); } }