/** * In-Memory FieldSession Repository * * Adapter: Implements FieldSessionRepository using a Map. * Purpose: Testing, development, CI/CD pipelines. * NOT for production. * * ADR-006: In-memory adapters for testing * - Fast, isolated, no external dependencies * - Reset between tests * - Never used in production */ import { FieldSession, SessionId, } from '@landvex/domain'; import { FieldSessionRepository } from '../repositories/repository-interfaces'; export class InMemoryFieldSessionRepository implements FieldSessionRepository { private sessions = new Map(); async save(session: FieldSession): Promise { this.sessions.set(session.id, session); } async findById(id: SessionId): Promise { return this.sessions.get(id) ?? null; } async findActive(): Promise { return Array.from(this.sessions.values()) .filter(s => s.status === 'planned' || s.status === 'active'); } async findByDateRange(start: Date, end: Date): Promise { return Array.from(this.sessions.values()) .filter(s => s.date >= start && s.date <= end); } /** Reset for testing */ clear(): void { this.sessions.clear(); } /** Count for assertions */ count(): number { return this.sessions.size; } }