import type { Presenter } from '../presentation'; import type { Result } from './Result'; import type { ApplicationErrorCode } from '../errors/ApplicationErrorCode'; /** * Use Case interface for commands. * * Use cases represent application-level business logic. They coordinate domain objects and repositories, * but contain no infrastructure or framework concerns. * * Commands change system state and return nothing on success. They use a presenter to handle the output. * If a business rejection is possible, the output must be a Result> handled by the presenter. * Use cases do not throw errors; they use error codes in Result. * * Example: * ```typescript * export type CreateRaceErrorCode = * | 'INSUFFICIENT_PERMISSIONS' * | 'RACE_ALREADY_EXISTS' * | 'INVALID_RACE_CONFIG'; * * export class CreateRaceUseCase implements UseCase>, ViewModel>> { * execute(input: CreateRaceInput, presenter: Presenter>, ViewModel>): Promise { * // implementation * } * } * ``` * * @template Input - The input type for the use case * @template Success - The success type in the Result passed to the presenter * @template ErrorCode - The error code type for ApplicationErrorCode * @template ViewModel - The view model type * @template P - The presenter type, extending Presenter>, ViewModel> */ export interface UseCase>, ViewModel>> { execute(input: Input, presenter: P): Promise | void; }