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

@@ -10,8 +10,6 @@ import type { Team } from '../../domain/entities/Team';
import type { TeamMembership } from '../../domain/types/TeamMembership';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
export type GetProfileOverviewInput = {
driverId: string;
};
@@ -74,21 +72,18 @@ export type GetProfileOverviewErrorCode =
| 'REPOSITORY_ERROR';
export class GetProfileOverviewUseCase {
constructor(
private readonly driverRepository: IDriverRepository,
constructor(private readonly driverRepository: IDriverRepository,
private readonly teamRepository: ITeamRepository,
private readonly teamMembershipRepository: ITeamMembershipRepository,
private readonly socialRepository: ISocialGraphRepository,
private readonly driverExtendedProfileProvider: DriverExtendedProfileProvider,
private readonly driverStatsUseCase: IDriverStatsUseCase,
private readonly rankingUseCase: IRankingUseCase,
private readonly output: UseCaseOutputPort<GetProfileOverviewResult>,
) {}
private readonly rankingUseCase: IRankingUseCase) {}
async execute(
input: GetProfileOverviewInput,
): Promise<
Result<void, ApplicationErrorCode<GetProfileOverviewErrorCode, { message: string }>>
Result<GetProfileOverviewResult, ApplicationErrorCode<GetProfileOverviewErrorCode, { message: string }>>
> {
try {
const { driverId } = input;
@@ -125,9 +120,7 @@ export class GetProfileOverviewUseCase {
extendedProfile,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
return Result.err({
code: 'REPOSITORY_ERROR',