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,20 +1,20 @@
import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';
import type { LeaveTeamCommandDTO } from '../dtos/LeaveTeamCommandDTO';
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 { LeaveTeamInputPort } from '../ports/input/LeaveTeamInputPort';
type LeaveTeamErrorCode = 'NOT_MEMBER' | 'OWNER_CANNOT_LEAVE' | 'REPOSITORY_ERROR';
type LeaveTeamApplicationError = ApplicationErrorCode<LeaveTeamErrorCode, { message: string }>;
export class LeaveTeamUseCase implements AsyncUseCase<LeaveTeamCommandDTO, void, LeaveTeamErrorCode> {
export class LeaveTeamUseCase implements AsyncUseCase<LeaveTeamInputPort, void, LeaveTeamErrorCode> {
constructor(
private readonly membershipRepository: ITeamMembershipRepository,
private readonly logger: Logger,
) {}
async execute(command: LeaveTeamCommandDTO): Promise<SharedResult<void, LeaveTeamApplicationError>> {
async execute(command: LeaveTeamInputPort): Promise<SharedResult<void, LeaveTeamApplicationError>> {
this.logger.debug('Attempting to leave team', { command });
const { teamId, driverId } = command;