refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -9,8 +9,6 @@ import { RecurrenceStrategyFactory } from '../../domain/value-objects/Recurrence
import { WeekdaySet } from '../../domain/value-objects/WeekdaySet';
import { MonthlyRecurrencePattern } from '../../domain/value-objects/MonthlyRecurrencePattern';
import { ALL_WEEKDAYS, type Weekday } from '../../domain/types/Weekday';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
export type SeasonScheduleConfig = {
seasonStartDate: string;
recurrenceStrategy: 'weekly' | 'everyNWeeks' | 'monthlyNthWeekday';
@@ -88,20 +86,17 @@ export type PreviewLeagueScheduleErrorCode =
| 'REPOSITORY_ERROR';
export class PreviewLeagueScheduleUseCase {
constructor(
private readonly scheduleGenerator: Pick<
constructor(private readonly scheduleGenerator: Pick<
typeof SeasonScheduleGenerator,
'generateSlotsUpTo'
> = SeasonScheduleGenerator,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<PreviewLeagueScheduleResult>,
) {}
private readonly logger: Logger) {}
async execute(
params: PreviewLeagueScheduleInput,
): Promise<
Result<
void,
PreviewLeagueScheduleResult,
ApplicationErrorCode<PreviewLeagueScheduleErrorCode, { message: string }>
>
> {
@@ -149,9 +144,7 @@ export class PreviewLeagueScheduleUseCase {
roundCount: rounds.length,
});
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
this.logger.error(
'Failed to preview league schedule due to an unexpected error',