import { AdminApiClient } from '@/lib/api/admin/AdminApiClient'; import { AdminService } from '@/lib/services/admin/AdminService'; import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter'; import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger'; import { Mutation } from '@/lib/contracts/mutations/Mutation'; /** * UpdateUserStatusMutation * * Framework-agnostic mutation for updating user status. * Called from Server Actions. * * Input: { userId: string; status: string } * Output: void * * Pattern: Server Action → Mutation → Service → API Client */ export class UpdateUserStatusMutation implements Mutation<{ userId: string; status: string }, void> { private service: AdminService; constructor() { // Manual DI for serverless const logger = new ConsoleLogger(); const errorReporter = new EnhancedErrorReporter(logger, { showUserNotifications: true, logToConsole: true, reportToExternal: process.env.NODE_ENV === 'production', }); const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3001'; const apiClient = new AdminApiClient(baseUrl, errorReporter, logger); this.service = new AdminService(apiClient); } async execute(input: { userId: string; status: string }): Promise { await this.service.updateUserStatus(input.userId, input.status); } }