refactor core presenters
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { SeasonScheduleGenerator } from '../../domain/services/SeasonScheduleGenerator';
|
||||
import type { LeagueSchedulePreviewDTO, LeagueScheduleDTO } from '../dto/LeagueScheduleDTO';
|
||||
import type { LeagueScheduleDTO } from '../dto/LeagueScheduleDTO';
|
||||
import { scheduleDTOToSeasonSchedule } from '../dto/LeagueScheduleDTO';
|
||||
import type { LeagueSchedulePreviewOutputPort } from '../ports/output/LeagueSchedulePreviewOutputPort';
|
||||
import type { AsyncUseCase } from '@core/shared/application/AsyncUseCase';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
@@ -16,13 +17,13 @@ type PreviewLeagueScheduleErrorCode = 'INVALID_SCHEDULE';
|
||||
|
||||
type PreviewLeagueScheduleApplicationError = ApplicationErrorCode<PreviewLeagueScheduleErrorCode, { message: string }>;
|
||||
|
||||
export class PreviewLeagueScheduleUseCase implements AsyncUseCase<PreviewLeagueScheduleQueryParams, LeagueSchedulePreviewDTO, PreviewLeagueScheduleErrorCode> {
|
||||
export class PreviewLeagueScheduleUseCase implements AsyncUseCase<PreviewLeagueScheduleQueryParams, LeagueSchedulePreviewOutputPort, PreviewLeagueScheduleErrorCode> {
|
||||
constructor(
|
||||
private readonly scheduleGenerator: typeof SeasonScheduleGenerator = SeasonScheduleGenerator,
|
||||
private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
async execute(params: PreviewLeagueScheduleQueryParams): Promise<Result<LeagueSchedulePreviewDTO, PreviewLeagueScheduleApplicationError>> {
|
||||
async execute(params: PreviewLeagueScheduleQueryParams): Promise<Result<LeagueSchedulePreviewOutputPort, PreviewLeagueScheduleApplicationError>> {
|
||||
this.logger.debug('Previewing league schedule', { params });
|
||||
|
||||
let seasonSchedule: SeasonSchedule;
|
||||
@@ -48,7 +49,7 @@ export class PreviewLeagueScheduleUseCase implements AsyncUseCase<PreviewLeagueS
|
||||
|
||||
const summary = this.buildSummary(params.schedule, rounds);
|
||||
|
||||
const result: LeagueSchedulePreviewDTO = {
|
||||
const result: LeagueSchedulePreviewOutputPort = {
|
||||
rounds,
|
||||
summary,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user