refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -1,5 +1,4 @@
import { Result } from '@core/shared/application/Result';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { Team } from '../../domain/entities/Team';
import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';
@@ -23,15 +22,12 @@ export type UpdateTeamResult = {
export type UpdateTeamErrorCode = 'TEAM_NOT_FOUND' | 'PERMISSION_DENIED' | 'REPOSITORY_ERROR';
export class UpdateTeamUseCase {
constructor(
private readonly teamRepository: ITeamRepository,
private readonly membershipRepository: ITeamMembershipRepository,
private readonly output: UseCaseOutputPort<UpdateTeamResult>,
) {}
constructor(private readonly teamRepository: ITeamRepository,
private readonly membershipRepository: ITeamMembershipRepository) {}
async execute(
command: UpdateTeamInput,
): Promise<Result<void, ApplicationErrorCode<UpdateTeamErrorCode, { message: string }>>> {
): Promise<Result<UpdateTeamResult, ApplicationErrorCode<UpdateTeamErrorCode, { message: string }>>> {
try {
const { teamId, updatedBy, updates } = command;
@@ -64,9 +60,7 @@ export class UpdateTeamUseCase {
await this.teamRepository.update(updated);
this.output.present({ team: updated });
return Result.ok(undefined);
return Result.ok({ team: updated });
} catch (err) {
const error = err as { message?: string } | undefined;