|
|
|
|
@@ -13,6 +13,8 @@ import type { IRaceRepository } from '@core/racing/domain/repositories/IRaceRepo
|
|
|
|
|
import type { IResultRepository } from '@core/racing/domain/repositories/IResultRepository';
|
|
|
|
|
import type { IStandingRepository } from '@core/racing/domain/repositories/IStandingRepository';
|
|
|
|
|
import type { Logger } from '@core/shared/application/Logger';
|
|
|
|
|
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
|
|
|
|
import { Result } from '@core/shared/application/Result';
|
|
|
|
|
|
|
|
|
|
// Import concrete in-memory implementations
|
|
|
|
|
import { getPointsSystems } from '@adapters/bootstrap/PointsSystems';
|
|
|
|
|
@@ -52,6 +54,29 @@ import { RequestProtestDefenseUseCase } from '@core/racing/application/use-cases
|
|
|
|
|
import { ReviewProtestUseCase } from '@core/racing/application/use-cases/ReviewProtestUseCase';
|
|
|
|
|
import { WithdrawFromRaceUseCase } from '@core/racing/application/use-cases/WithdrawFromRaceUseCase';
|
|
|
|
|
|
|
|
|
|
// Import use case result types
|
|
|
|
|
import type { GetAllRacesResult } from '@core/racing/application/use-cases/GetAllRacesUseCase';
|
|
|
|
|
import type { GetTotalRacesResult } from '@core/racing/application/use-cases/GetTotalRacesUseCase';
|
|
|
|
|
import type { ImportRaceResultsApiResult } from '@core/racing/application/use-cases/ImportRaceResultsApiUseCase';
|
|
|
|
|
import type { GetRaceDetailResult } from '@core/racing/application/use-cases/GetRaceDetailUseCase';
|
|
|
|
|
import type { GetRacesPageDataResult } from '@core/racing/application/use-cases/GetRacesPageDataUseCase';
|
|
|
|
|
import type { GetAllRacesPageDataResult } from '@core/racing/application/use-cases/GetAllRacesPageDataUseCase';
|
|
|
|
|
import type { GetRaceResultsDetailResult } from '@core/racing/application/use-cases/GetRaceResultsDetailUseCase';
|
|
|
|
|
import type { GetRaceWithSOFResult } from '@core/racing/application/use-cases/GetRaceWithSOFUseCase';
|
|
|
|
|
import type { GetRaceProtestsResult } from '@core/racing/application/use-cases/GetRaceProtestsUseCase';
|
|
|
|
|
import type { GetRacePenaltiesResult } from '@core/racing/application/use-cases/GetRacePenaltiesUseCase';
|
|
|
|
|
import type { RegisterForRaceResult } from '@core/racing/application/use-cases/RegisterForRaceUseCase';
|
|
|
|
|
import type { WithdrawFromRaceResult } from '@core/racing/application/use-cases/WithdrawFromRaceUseCase';
|
|
|
|
|
import type { CancelRaceResult } from '@core/racing/application/use-cases/CancelRaceUseCase';
|
|
|
|
|
import type { CompleteRaceResult } from '@core/racing/application/use-cases/CompleteRaceUseCase';
|
|
|
|
|
import type { ReopenRaceResult } from '@core/racing/application/use-cases/ReopenRaceUseCase';
|
|
|
|
|
import type { ImportRaceResultsResult } from '@core/racing/application/use-cases/ImportRaceResultsUseCase';
|
|
|
|
|
import type { FileProtestResult } from '@core/racing/application/use-cases/FileProtestUseCase';
|
|
|
|
|
import type { QuickPenaltyResult } from '@core/racing/application/use-cases/QuickPenaltyUseCase';
|
|
|
|
|
import type { ApplyPenaltyResult } from '@core/racing/application/use-cases/ApplyPenaltyUseCase';
|
|
|
|
|
import type { RequestProtestDefenseResult } from '@core/racing/application/use-cases/RequestProtestDefenseUseCase';
|
|
|
|
|
import type { ReviewProtestResult } from '@core/racing/application/use-cases/ReviewProtestUseCase';
|
|
|
|
|
|
|
|
|
|
// Import presenters
|
|
|
|
|
import { AllRacesPageDataPresenter } from './presenters/AllRacesPageDataPresenter';
|
|
|
|
|
import { CommandResultPresenter } from './presenters/CommandResultPresenter';
|
|
|
|
|
@@ -92,6 +117,183 @@ export const RACE_PROTESTS_PRESENTER_TOKEN = 'RaceProtestsPresenter';
|
|
|
|
|
export const RACE_PENALTIES_PRESENTER_TOKEN = 'RacePenaltiesPresenter';
|
|
|
|
|
export const COMMAND_RESULT_PRESENTER_TOKEN = 'CommandResultPresenter';
|
|
|
|
|
|
|
|
|
|
// Adapter classes to bridge presenters with UseCaseOutputPort interface
|
|
|
|
|
class GetAllRacesOutputAdapter implements UseCaseOutputPort<GetAllRacesResult> {
|
|
|
|
|
constructor(private presenter: GetAllRacesPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetAllRacesResult): void {
|
|
|
|
|
this.presenter.present(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class GetTotalRacesOutputAdapter implements UseCaseOutputPort<GetTotalRacesResult> {
|
|
|
|
|
constructor(private presenter: GetTotalRacesPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetTotalRacesResult): void {
|
|
|
|
|
// Wrap the result in a Result.ok() to match presenter expectations
|
|
|
|
|
const resultWrapper = Result.ok<GetTotalRacesResult, { code: 'REPOSITORY_ERROR'; details: { message: string } }>(result);
|
|
|
|
|
this.presenter.present(resultWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ImportRaceResultsApiOutputAdapter implements UseCaseOutputPort<ImportRaceResultsApiResult> {
|
|
|
|
|
constructor(private presenter: ImportRaceResultsApiPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: ImportRaceResultsApiResult): void {
|
|
|
|
|
const resultWrapper = Result.ok<ImportRaceResultsApiResult, { code: 'REPOSITORY_ERROR'; details: { message: string } }>(result);
|
|
|
|
|
this.presenter.present(resultWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RaceDetailOutputAdapter implements UseCaseOutputPort<GetRaceDetailResult> {
|
|
|
|
|
constructor(private presenter: RaceDetailPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetRaceDetailResult): void {
|
|
|
|
|
this.presenter.present(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RacesPageDataOutputAdapter implements UseCaseOutputPort<GetRacesPageDataResult> {
|
|
|
|
|
constructor(private presenter: RacesPageDataPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetRacesPageDataResult): void {
|
|
|
|
|
const resultWrapper = Result.ok<GetRacesPageDataResult, { code: 'REPOSITORY_ERROR'; details: { message: string } }>(result);
|
|
|
|
|
this.presenter.present(resultWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AllRacesPageDataOutputAdapter implements UseCaseOutputPort<GetAllRacesPageDataResult> {
|
|
|
|
|
constructor(private presenter: AllRacesPageDataPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetAllRacesPageDataResult): void {
|
|
|
|
|
const resultWrapper = Result.ok<GetAllRacesPageDataResult, { code: 'REPOSITORY_ERROR'; details: { message: string } }>(result);
|
|
|
|
|
this.presenter.present(resultWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RaceResultsDetailOutputAdapter implements UseCaseOutputPort<GetRaceResultsDetailResult> {
|
|
|
|
|
constructor(private presenter: RaceResultsDetailPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetRaceResultsDetailResult): void {
|
|
|
|
|
this.presenter.present(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RaceWithSOFOutputAdapter implements UseCaseOutputPort<GetRaceWithSOFResult> {
|
|
|
|
|
constructor(private presenter: RaceWithSOFPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetRaceWithSOFResult): void {
|
|
|
|
|
const resultWrapper = Result.ok<GetRaceWithSOFResult, { code: 'RACE_NOT_FOUND' | 'REPOSITORY_ERROR'; details: { message: string } }>(result);
|
|
|
|
|
this.presenter.present(resultWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RaceProtestsOutputAdapter implements UseCaseOutputPort<GetRaceProtestsResult> {
|
|
|
|
|
constructor(private presenter: RaceProtestsPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetRaceProtestsResult): void {
|
|
|
|
|
const resultWrapper = Result.ok<GetRaceProtestsResult, { code: 'REPOSITORY_ERROR'; details: { message: string } }>(result);
|
|
|
|
|
this.presenter.present(resultWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RacePenaltiesOutputAdapter implements UseCaseOutputPort<GetRacePenaltiesResult> {
|
|
|
|
|
constructor(private presenter: RacePenaltiesPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(result: GetRacePenaltiesResult): void {
|
|
|
|
|
const resultWrapper = Result.ok<GetRacePenaltiesResult, { code: 'REPOSITORY_ERROR'; details: { message: string } }>(result);
|
|
|
|
|
this.presenter.present(resultWrapper);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RegisterForRaceOutputAdapter implements UseCaseOutputPort<RegisterForRaceResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Race registered successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class WithdrawFromRaceOutputAdapter implements UseCaseOutputPort<WithdrawFromRaceResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Race withdrawal successful');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CancelRaceOutputAdapter implements UseCaseOutputPort<CancelRaceResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Race cancelled successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CompleteRaceOutputAdapter implements UseCaseOutputPort<CompleteRaceResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Race completed successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ReopenRaceOutputAdapter implements UseCaseOutputPort<ReopenRaceResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Race reopened successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ImportRaceResultsOutputAdapter implements UseCaseOutputPort<ImportRaceResultsResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Race results imported successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FileProtestOutputAdapter implements UseCaseOutputPort<FileProtestResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Protest filed successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class QuickPenaltyOutputAdapter implements UseCaseOutputPort<QuickPenaltyResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Penalty applied successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ApplyPenaltyOutputAdapter implements UseCaseOutputPort<ApplyPenaltyResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Penalty applied successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RequestProtestDefenseOutputAdapter implements UseCaseOutputPort<RequestProtestDefenseResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Defense request sent successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ReviewProtestOutputAdapter implements UseCaseOutputPort<ReviewProtestResult> {
|
|
|
|
|
constructor(private presenter: CommandResultPresenter) {}
|
|
|
|
|
|
|
|
|
|
present(): void {
|
|
|
|
|
this.presenter.presentSuccess('Protest reviewed successfully');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const RaceProviders: Provider[] = [
|
|
|
|
|
RaceService,
|
|
|
|
|
{
|
|
|
|
|
@@ -168,7 +370,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: RACE_DETAIL_PRESENTER_TOKEN,
|
|
|
|
|
useFactory: (driverRatingProvider: DriverRatingProvider, imageService: any) =>
|
|
|
|
|
useFactory: (driverRatingProvider: DriverRatingProvider, imageService: InMemoryImageServiceAdapter) =>
|
|
|
|
|
new RaceDetailPresenter(driverRatingProvider, imageService, { raceId: '', driverId: '' }),
|
|
|
|
|
inject: [DRIVER_RATING_PROVIDER_TOKEN, IMAGE_SERVICE_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
@@ -182,7 +384,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: RACE_RESULTS_DETAIL_PRESENTER_TOKEN,
|
|
|
|
|
useFactory: (imageService: any) => new RaceResultsDetailPresenter(imageService),
|
|
|
|
|
useFactory: (imageService: InMemoryImageServiceAdapter) => new RaceResultsDetailPresenter(imageService),
|
|
|
|
|
inject: [IMAGE_SERVICE_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -201,34 +403,31 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
provide: COMMAND_RESULT_PRESENTER_TOKEN,
|
|
|
|
|
useClass: CommandResultPresenter,
|
|
|
|
|
},
|
|
|
|
|
// Use cases - using simplified approach since presenters need to be adapted
|
|
|
|
|
// Use cases
|
|
|
|
|
{
|
|
|
|
|
provide: GetAllRacesUseCase,
|
|
|
|
|
useFactory: (
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueRepo: ILeagueRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: GetAllRacesPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const useCase = new GetAllRacesUseCase(raceRepo, leagueRepo, logger);
|
|
|
|
|
// Create a simple wrapper that calls the presenter
|
|
|
|
|
const wrapper = {
|
|
|
|
|
present: (data: any) => {
|
|
|
|
|
const presenter = new GetAllRacesPresenter();
|
|
|
|
|
presenter.present(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
useCase.setOutput(wrapper as any);
|
|
|
|
|
useCase.setOutput(new GetAllRacesOutputAdapter(presenter));
|
|
|
|
|
return useCase;
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LEAGUE_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LEAGUE_REPOSITORY_TOKEN, LOGGER_TOKEN, GET_ALL_RACES_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: GetTotalRacesUseCase,
|
|
|
|
|
useFactory: (raceRepo: IRaceRepository, logger: Logger) => {
|
|
|
|
|
const presenter = new GetTotalRacesPresenter();
|
|
|
|
|
return new GetTotalRacesUseCase(raceRepo, logger, presenter as any);
|
|
|
|
|
useFactory: (
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: GetTotalRacesPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
return new GetTotalRacesUseCase(raceRepo, logger, new GetTotalRacesOutputAdapter(presenter));
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LOGGER_TOKEN, GET_TOTAL_RACES_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: ImportRaceResultsApiUseCase,
|
|
|
|
|
@@ -239,9 +438,17 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
driverRepo: IDriverRepository,
|
|
|
|
|
standingRepo: IStandingRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: ImportRaceResultsApiPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new ImportRaceResultsApiPresenter();
|
|
|
|
|
return new ImportRaceResultsApiUseCase(raceRepo, leagueRepo, resultRepo, driverRepo, standingRepo, logger, presenter as any);
|
|
|
|
|
return new ImportRaceResultsApiUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueRepo,
|
|
|
|
|
resultRepo,
|
|
|
|
|
driverRepo,
|
|
|
|
|
standingRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new ImportRaceResultsApiOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [
|
|
|
|
|
RACE_REPOSITORY_TOKEN,
|
|
|
|
|
@@ -250,6 +457,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
DRIVER_REPOSITORY_TOKEN,
|
|
|
|
|
STANDING_REPOSITORY_TOKEN,
|
|
|
|
|
LOGGER_TOKEN,
|
|
|
|
|
IMPORT_RACE_RESULTS_API_PRESENTER_TOKEN,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -261,6 +469,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRegRepo: IRaceRegistrationRepository,
|
|
|
|
|
resultRepo: IResultRepository,
|
|
|
|
|
leagueMembershipRepo: ILeagueMembershipRepository,
|
|
|
|
|
presenter: RaceDetailPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const useCase = new GetRaceDetailUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
@@ -270,13 +479,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
resultRepo,
|
|
|
|
|
leagueMembershipRepo,
|
|
|
|
|
);
|
|
|
|
|
const wrapper = {
|
|
|
|
|
present: (data: any) => {
|
|
|
|
|
const presenter = new RaceDetailPresenter({} as any, {} as any, {} as any);
|
|
|
|
|
presenter.present(data);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
useCase.setOutput(wrapper as any);
|
|
|
|
|
useCase.setOutput(new RaceDetailOutputAdapter(presenter));
|
|
|
|
|
return useCase;
|
|
|
|
|
},
|
|
|
|
|
inject: [
|
|
|
|
|
@@ -286,6 +489,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
RACE_REGISTRATION_REPOSITORY_TOKEN,
|
|
|
|
|
RESULT_REPOSITORY_TOKEN,
|
|
|
|
|
LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN,
|
|
|
|
|
RACE_DETAIL_PRESENTER_TOKEN,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -294,11 +498,16 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueRepo: ILeagueRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: RacesPageDataPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new RacesPageDataPresenter();
|
|
|
|
|
return new GetRacesPageDataUseCase(raceRepo, leagueRepo, logger, presenter as any);
|
|
|
|
|
return new GetRacesPageDataUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new RacesPageDataOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LEAGUE_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LEAGUE_REPOSITORY_TOKEN, LOGGER_TOKEN, RACES_PAGE_DATA_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: GetAllRacesPageDataUseCase,
|
|
|
|
|
@@ -306,11 +515,16 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueRepo: ILeagueRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: AllRacesPageDataPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new AllRacesPageDataPresenter();
|
|
|
|
|
return new GetAllRacesPageDataUseCase(raceRepo, leagueRepo, logger, presenter as any);
|
|
|
|
|
return new GetAllRacesPageDataUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new AllRacesPageDataOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LEAGUE_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LEAGUE_REPOSITORY_TOKEN, LOGGER_TOKEN, ALL_RACES_PAGE_DATA_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: GetRaceResultsDetailUseCase,
|
|
|
|
|
@@ -320,9 +534,16 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
resultRepo: IResultRepository,
|
|
|
|
|
driverRepo: IDriverRepository,
|
|
|
|
|
penaltyRepo: IPenaltyRepository,
|
|
|
|
|
presenter: RaceResultsDetailPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new RaceResultsDetailPresenter({} as any);
|
|
|
|
|
return new GetRaceResultsDetailUseCase(raceRepo, leagueRepo, resultRepo, driverRepo, penaltyRepo, presenter as any);
|
|
|
|
|
return new GetRaceResultsDetailUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueRepo,
|
|
|
|
|
resultRepo,
|
|
|
|
|
driverRepo,
|
|
|
|
|
penaltyRepo,
|
|
|
|
|
new RaceResultsDetailOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [
|
|
|
|
|
RACE_REPOSITORY_TOKEN,
|
|
|
|
|
@@ -330,6 +551,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
RESULT_REPOSITORY_TOKEN,
|
|
|
|
|
DRIVER_REPOSITORY_TOKEN,
|
|
|
|
|
PENALTY_REPOSITORY_TOKEN,
|
|
|
|
|
RACE_RESULTS_DETAIL_PRESENTER_TOKEN,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -339,32 +561,56 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRegRepo: IRaceRegistrationRepository,
|
|
|
|
|
resultRepo: IResultRepository,
|
|
|
|
|
driverRatingProvider: DriverRatingProvider,
|
|
|
|
|
presenter: RaceWithSOFPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new RaceWithSOFPresenter();
|
|
|
|
|
return new GetRaceWithSOFUseCase(raceRepo, raceRegRepo, resultRepo, driverRatingProvider as any, presenter as any);
|
|
|
|
|
return new GetRaceWithSOFUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
raceRegRepo,
|
|
|
|
|
resultRepo,
|
|
|
|
|
async (input: { driverId: string }) => {
|
|
|
|
|
const rating = driverRatingProvider.getRating(input.driverId);
|
|
|
|
|
return { rating };
|
|
|
|
|
},
|
|
|
|
|
new RaceWithSOFOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [
|
|
|
|
|
RACE_REPOSITORY_TOKEN,
|
|
|
|
|
RACE_REGISTRATION_REPOSITORY_TOKEN,
|
|
|
|
|
RESULT_REPOSITORY_TOKEN,
|
|
|
|
|
DRIVER_RATING_PROVIDER_TOKEN,
|
|
|
|
|
RACE_WITH_SOF_PRESENTER_TOKEN,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: GetRaceProtestsUseCase,
|
|
|
|
|
useFactory: (protestRepo: IProtestRepository, driverRepo: IDriverRepository) => {
|
|
|
|
|
const presenter = new RaceProtestsPresenter();
|
|
|
|
|
return new GetRaceProtestsUseCase(protestRepo, driverRepo, presenter as any);
|
|
|
|
|
useFactory: (
|
|
|
|
|
protestRepo: IProtestRepository,
|
|
|
|
|
driverRepo: IDriverRepository,
|
|
|
|
|
presenter: RaceProtestsPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
return new GetRaceProtestsUseCase(
|
|
|
|
|
protestRepo,
|
|
|
|
|
driverRepo,
|
|
|
|
|
new RaceProtestsOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, DRIVER_REPOSITORY_TOKEN],
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, DRIVER_REPOSITORY_TOKEN, RACE_PROTESTS_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: GetRacePenaltiesUseCase,
|
|
|
|
|
useFactory: (penaltyRepo: IPenaltyRepository, driverRepo: IDriverRepository) => {
|
|
|
|
|
const presenter = new RacePenaltiesPresenter();
|
|
|
|
|
return new GetRacePenaltiesUseCase(penaltyRepo, driverRepo, presenter as any);
|
|
|
|
|
useFactory: (
|
|
|
|
|
penaltyRepo: IPenaltyRepository,
|
|
|
|
|
driverRepo: IDriverRepository,
|
|
|
|
|
presenter: RacePenaltiesPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
return new GetRacePenaltiesUseCase(
|
|
|
|
|
penaltyRepo,
|
|
|
|
|
driverRepo,
|
|
|
|
|
new RacePenaltiesOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [PENALTY_REPOSITORY_TOKEN, DRIVER_REPOSITORY_TOKEN],
|
|
|
|
|
inject: [PENALTY_REPOSITORY_TOKEN, DRIVER_REPOSITORY_TOKEN, RACE_PENALTIES_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: RegisterForRaceUseCase,
|
|
|
|
|
@@ -372,11 +618,16 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRegRepo: IRaceRegistrationRepository,
|
|
|
|
|
leagueMembershipRepo: ILeagueMembershipRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new RegisterForRaceUseCase(raceRegRepo, leagueMembershipRepo, logger, presenter as any);
|
|
|
|
|
return new RegisterForRaceUseCase(
|
|
|
|
|
raceRegRepo,
|
|
|
|
|
leagueMembershipRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new RegisterForRaceOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REGISTRATION_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REGISTRATION_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: WithdrawFromRaceUseCase,
|
|
|
|
|
@@ -384,19 +635,31 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
raceRegRepo: IRaceRegistrationRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new WithdrawFromRaceUseCase(raceRepo, raceRegRepo, logger, presenter as any);
|
|
|
|
|
return new WithdrawFromRaceUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
raceRegRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new WithdrawFromRaceOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, RACE_REGISTRATION_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, RACE_REGISTRATION_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: CancelRaceUseCase,
|
|
|
|
|
useFactory: (raceRepo: IRaceRepository, logger: Logger) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new CancelRaceUseCase(raceRepo, logger, presenter as any);
|
|
|
|
|
useFactory: (
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
return new CancelRaceUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new CancelRaceOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: CompleteRaceUseCase,
|
|
|
|
|
@@ -406,9 +669,19 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
resultRepo: IResultRepository,
|
|
|
|
|
standingRepo: IStandingRepository,
|
|
|
|
|
driverRatingProvider: DriverRatingProvider,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new CompleteRaceUseCase(raceRepo, raceRegRepo, resultRepo, standingRepo, driverRatingProvider as any, presenter as any);
|
|
|
|
|
return new CompleteRaceUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
raceRegRepo,
|
|
|
|
|
resultRepo,
|
|
|
|
|
standingRepo,
|
|
|
|
|
async (input: { driverId: string }) => {
|
|
|
|
|
const rating = driverRatingProvider.getRating(input.driverId);
|
|
|
|
|
return { rating, ratingChange: null };
|
|
|
|
|
},
|
|
|
|
|
new CompleteRaceOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [
|
|
|
|
|
RACE_REPOSITORY_TOKEN,
|
|
|
|
|
@@ -416,15 +689,23 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
RESULT_REPOSITORY_TOKEN,
|
|
|
|
|
STANDING_REPOSITORY_TOKEN,
|
|
|
|
|
DRIVER_RATING_PROVIDER_TOKEN,
|
|
|
|
|
COMMAND_RESULT_PRESENTER_TOKEN,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: ReopenRaceUseCase,
|
|
|
|
|
useFactory: (raceRepo: IRaceRepository, logger: Logger) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new ReopenRaceUseCase(raceRepo, logger, presenter as any);
|
|
|
|
|
useFactory: (
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
return new ReopenRaceUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new ReopenRaceOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [RACE_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: ImportRaceResultsUseCase,
|
|
|
|
|
@@ -435,9 +716,17 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
driverRepo: IDriverRepository,
|
|
|
|
|
standingRepo: IStandingRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new ImportRaceResultsUseCase(raceRepo, leagueRepo, resultRepo, driverRepo, standingRepo, logger, presenter as any);
|
|
|
|
|
return new ImportRaceResultsUseCase(
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueRepo,
|
|
|
|
|
resultRepo,
|
|
|
|
|
driverRepo,
|
|
|
|
|
standingRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new ImportRaceResultsOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [
|
|
|
|
|
RACE_REPOSITORY_TOKEN,
|
|
|
|
|
@@ -446,6 +735,7 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
DRIVER_REPOSITORY_TOKEN,
|
|
|
|
|
STANDING_REPOSITORY_TOKEN,
|
|
|
|
|
LOGGER_TOKEN,
|
|
|
|
|
COMMAND_RESULT_PRESENTER_TOKEN,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -454,11 +744,16 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
protestRepo: IProtestRepository,
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueMembershipRepo: ILeagueMembershipRepository,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new FileProtestUseCase(protestRepo, raceRepo, leagueMembershipRepo, presenter as any);
|
|
|
|
|
return new FileProtestUseCase(
|
|
|
|
|
protestRepo,
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueMembershipRepo,
|
|
|
|
|
new FileProtestOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN],
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: QuickPenaltyUseCase,
|
|
|
|
|
@@ -467,11 +762,17 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueMembershipRepo: ILeagueMembershipRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new QuickPenaltyUseCase(penaltyRepo, raceRepo, leagueMembershipRepo, logger, presenter as any);
|
|
|
|
|
return new QuickPenaltyUseCase(
|
|
|
|
|
penaltyRepo,
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueMembershipRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new QuickPenaltyOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [PENALTY_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [PENALTY_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: ApplyPenaltyUseCase,
|
|
|
|
|
@@ -481,11 +782,18 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueMembershipRepo: ILeagueMembershipRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new ApplyPenaltyUseCase(penaltyRepo, protestRepo, raceRepo, leagueMembershipRepo, logger, presenter as any);
|
|
|
|
|
return new ApplyPenaltyUseCase(
|
|
|
|
|
penaltyRepo,
|
|
|
|
|
protestRepo,
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueMembershipRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new ApplyPenaltyOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [PENALTY_REPOSITORY_TOKEN, PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [PENALTY_REPOSITORY_TOKEN, PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: RequestProtestDefenseUseCase,
|
|
|
|
|
@@ -494,11 +802,17 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueMembershipRepo: ILeagueMembershipRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new RequestProtestDefenseUseCase(protestRepo, raceRepo, leagueMembershipRepo, logger, presenter as any);
|
|
|
|
|
return new RequestProtestDefenseUseCase(
|
|
|
|
|
protestRepo,
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueMembershipRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new RequestProtestDefenseOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
provide: ReviewProtestUseCase,
|
|
|
|
|
@@ -507,10 +821,16 @@ export const RaceProviders: Provider[] = [
|
|
|
|
|
raceRepo: IRaceRepository,
|
|
|
|
|
leagueMembershipRepo: ILeagueMembershipRepository,
|
|
|
|
|
logger: Logger,
|
|
|
|
|
presenter: CommandResultPresenter,
|
|
|
|
|
) => {
|
|
|
|
|
const presenter = new CommandResultPresenter();
|
|
|
|
|
return new ReviewProtestUseCase(protestRepo, raceRepo, leagueMembershipRepo, logger, presenter as any);
|
|
|
|
|
return new ReviewProtestUseCase(
|
|
|
|
|
protestRepo,
|
|
|
|
|
raceRepo,
|
|
|
|
|
leagueMembershipRepo,
|
|
|
|
|
logger,
|
|
|
|
|
new ReviewProtestOutputAdapter(presenter)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN],
|
|
|
|
|
inject: [PROTEST_REPOSITORY_TOKEN, RACE_REPOSITORY_TOKEN, LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN, LOGGER_TOKEN, COMMAND_RESULT_PRESENTER_TOKEN],
|
|
|
|
|
},
|
|
|
|
|
];
|