refactor dtos to ports
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user