/** * Session Response Mapper * * Transforms session API responses to Session objects. * Handles individual sessions and session lists. * * @layer Infrastructure - API Client */ import { sessionSchema, sessionListSchema, type Session, } from '@archer/api-interface'; /** * SessionResponseMapper * * Maps session responses from API to Session objects. * Sessions are simple data objects (not domain entities). */ export class SessionResponseMapper { /** * Maps SessionResponse to Session object * * @param response - Session response from API * @returns Session object * @throws ZodError if validation fails */ static toSession(response: unknown): Session { return sessionSchema.parse(response); } /** * Maps SessionListResponse to array of Session objects * * @param response - Session list response from API * @returns Array of Session objects with total count * @throws ZodError if validation fails */ static toSessionList(response: unknown): { sessions: Session[]; total: number } { const validated = sessionListSchema.parse(response); return { sessions: validated.sessions, total: validated.total, }; } }