import { AutomationSession } from '../../packages/domain/entities/AutomationSession'; import { SessionStateValue } from '../../packages/domain/value-objects/SessionState'; import { ISessionRepository } from '../../packages/application/ports/ISessionRepository'; export class InMemorySessionRepository implements ISessionRepository { private sessions: Map = new Map(); async save(session: AutomationSession): Promise { this.sessions.set(session.id, session); } async findById(id: string): Promise { return this.sessions.get(id) || null; } async update(session: AutomationSession): Promise { if (!this.sessions.has(session.id)) { throw new Error('Session not found'); } this.sessions.set(session.id, session); } async delete(id: string): Promise { this.sessions.delete(id); } async findAll(): Promise { return Array.from(this.sessions.values()); } async findByState(state: SessionStateValue): Promise { return Array.from(this.sessions.values()).filter( session => session.state.value === state ); } }