import { UpdateUser, User, UserResponse } from "@/src/entities/models/users/users.model" import { IUsersRepository } from "../../repositories/users.repository.interface" import { IInstrumentationService } from "../../services/instrumentation.service.interface" import { NotFoundError } from "@/src/entities/errors/common" export type IUpdateUserUseCase = ReturnType const updateUserUseCase = ( instrumentationService: IInstrumentationService, usersRepository: IUsersRepository ) => async (id: string, input: UpdateUser): Promise => { return await instrumentationService.startSpan({ name: "updateUser Use Case", op: "function" }, async () => { const existingUser = await usersRepository.getUserById(id) if (!existingUser) { throw new NotFoundError("User not found") } const updatedUser = await usersRepository.updateUser(id, input) return { ...updatedUser } } ) }