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

@@ -4,7 +4,6 @@ import type { ITeamRepository } from '../../domain/repositories/ITeamRepository'
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { Logger } from '@core/shared/application';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { TeamMembership } from '../../domain/types/TeamMembership';
import type { Team } from '../../domain/entities/Team';
import type { Driver } from '../../domain/entities/Driver';
@@ -29,17 +28,14 @@ export type GetTeamMembersErrorCode = 'TEAM_NOT_FOUND' | 'REPOSITORY_ERROR';
* Use Case for retrieving team members.
*/
export class GetTeamMembersUseCase {
constructor(
private readonly membershipRepository: ITeamMembershipRepository,
constructor(private readonly membershipRepository: ITeamMembershipRepository,
private readonly driverRepository: IDriverRepository,
private readonly teamRepository: ITeamRepository,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<GetTeamMembersResult>,
) {}
private readonly logger: Logger) {}
async execute(
input: GetTeamMembersInput,
): Promise<Result<void, ApplicationErrorCode<GetTeamMembersErrorCode, { message: string }>>> {
): Promise<Result<GetTeamMembersResult, ApplicationErrorCode<GetTeamMembersErrorCode, { message: string }>>> {
this.logger.debug(`Executing GetTeamMembersUseCase for teamId: ${input.teamId}`);
try {
@@ -72,12 +68,10 @@ export class GetTeamMembersUseCase {
members.push({ membership, driver });
}
this.output.present({
return Result.ok({
team,
members,
});
return Result.ok(undefined);
} catch (err) {
const error = err as { message?: string } | undefined;