refactor dtos to ports

This commit is contained in:
2025-12-19 14:08:27 +01:00
parent 2ab86ec9bd
commit 499562c456
106 changed files with 386 additions and 1009 deletions

View File

@@ -10,7 +10,7 @@ import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { CreateSponsorResultDTO } from '../dto/CreateSponsorResultDTO';
import type { CreateSponsorOutputPort } from '../ports/output/CreateSponsorOutputPort';
export interface CreateSponsorCommand {
name: string;
@@ -20,7 +20,7 @@ export interface CreateSponsorCommand {
}
export class CreateSponsorUseCase
implements AsyncUseCase<CreateSponsorCommand, CreateSponsorResultDTO, 'VALIDATION_ERROR' | 'REPOSITORY_ERROR'>
implements AsyncUseCase<CreateSponsorCommand, CreateSponsorOutputPort, 'VALIDATION_ERROR' | 'REPOSITORY_ERROR'>
{
constructor(
private readonly sponsorRepository: ISponsorRepository,
@@ -29,7 +29,7 @@ export class CreateSponsorUseCase
async execute(
command: CreateSponsorCommand,
): Promise<Result<CreateSponsorResultDTO, ApplicationErrorCode<'VALIDATION_ERROR' | 'REPOSITORY_ERROR', { message: string }>>> {
): Promise<Result<CreateSponsorOutputPort, ApplicationErrorCode<'VALIDATION_ERROR' | 'REPOSITORY_ERROR', { message: string }>>> {
this.logger.debug('Executing CreateSponsorUseCase', { command });
const validation = this.validate(command);
if (validation.isErr()) {
@@ -51,7 +51,7 @@ export class CreateSponsorUseCase
await this.sponsorRepository.create(sponsor);
this.logger.info(`Sponsor ${sponsor.name} (${sponsor.id}) created successfully.`);
const result: CreateSponsorResultDTO = {
const result: CreateSponsorOutputPort = {
sponsor: {
id: sponsor.id,
name: sponsor.name,