refactor dtos to ports

This commit is contained in:
2025-12-19 13:07:38 +01:00
parent 08ec2af5bf
commit 2ab86ec9bd
42 changed files with 83 additions and 81 deletions

View File

@@ -1,27 +1,27 @@
import type { ITeamRepository } from '../../domain/repositories/ITeamRepository';
import type { AsyncUseCase, Logger } from '@core/shared/application';
import { Result as SharedResult } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';
import type { ITeamRepository } from '../../domain/repositories/ITeamRepository';
import type {
TeamMembership,
TeamMembershipStatus,
TeamRole,
} from '../../domain/types/TeamMembership';
import type { JoinTeamCommandDTO } from '../dtos/JoinTeamCommandDTO';
import type { AsyncUseCase, Logger } from '@core/shared/application';
import { Result as SharedResult } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { JoinTeamInputPort } from '../ports/input/JoinTeamInputPort';
type JoinTeamErrorCode = 'ALREADY_IN_TEAM' | 'ALREADY_MEMBER' | 'TEAM_NOT_FOUND' | 'REPOSITORY_ERROR';
type JoinTeamApplicationError = ApplicationErrorCode<JoinTeamErrorCode, { message: string }>;
export class JoinTeamUseCase implements AsyncUseCase<JoinTeamCommandDTO, void, JoinTeamErrorCode> {
export class JoinTeamUseCase implements AsyncUseCase<JoinTeamInputPort, void, JoinTeamErrorCode> {
constructor(
private readonly teamRepository: ITeamRepository,
private readonly membershipRepository: ITeamMembershipRepository,
private readonly logger: Logger,
) {}
async execute(command: JoinTeamCommandDTO): Promise<SharedResult<void, JoinTeamApplicationError>> {
async execute(command: JoinTeamInputPort): Promise<SharedResult<void, JoinTeamApplicationError>> {
this.logger.debug('Attempting to join team', { command });
const { teamId, driverId } = command;