/** * Login Mutation * * Framework-agnostic mutation for login operations. * Called from Server Actions. * * Pattern: Server Action → Mutation → Service → API Client */ import { Result } from '@/lib/contracts/Result'; import { AuthService } from '@/lib/services/auth/AuthService'; import { SessionViewModel } from '@/lib/view-models/SessionViewModel'; import { LoginParamsDTO } from '@/lib/types/generated/LoginParamsDTO'; export class LoginMutation { async execute(params: LoginParamsDTO): Promise> { try { const authService = new AuthService(); const session = await authService.login(params); return Result.ok(session); } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Login failed'; return Result.err(errorMessage); } } }