/** * Dependency Injection Container - TSyringe Facade * * Provides backward-compatible API for accessing dependencies managed by TSyringe. */ import { configureDIContainer, getDIContainer } from './di-config'; import { DI_TOKENS } from './di-tokens'; import { LeagueScoringPresetsPresenter } from './presenters/LeagueScoringPresetsPresenter'; import type { IDriverRepository } from '@gridpilot/racing/domain/repositories/IDriverRepository'; import type { ILeagueRepository } from '@gridpilot/racing/domain/repositories/ILeagueRepository'; import type { IRaceRepository } from '@gridpilot/racing/domain/repositories/IRaceRepository'; import type { IResultRepository } from '@gridpilot/racing/domain/repositories/IResultRepository'; import type { IStandingRepository } from '@gridpilot/racing/domain/repositories/IStandingRepository'; import type { IPenaltyRepository } from '@gridpilot/racing/domain/repositories/IPenaltyRepository'; import type { IProtestRepository } from '@gridpilot/racing/domain/repositories/IProtestRepository'; import type { IGameRepository } from '@gridpilot/racing/domain/repositories/IGameRepository'; import type { ISeasonRepository } from '@gridpilot/racing/domain/repositories/ISeasonRepository'; import type { ILeagueScoringConfigRepository } from '@gridpilot/racing/domain/repositories/ILeagueScoringConfigRepository'; import type { ITrackRepository } from '@gridpilot/racing/domain/repositories/ITrackRepository'; import type { ICarRepository } from '@gridpilot/racing/domain/repositories/ICarRepository'; import type { ITeamRepository, ITeamMembershipRepository, IRaceRegistrationRepository, } from '@gridpilot/racing'; import type { ILeagueMembershipRepository } from '@gridpilot/racing/domain/repositories/ILeagueMembershipRepository'; import type { LeagueMembership, JoinRequest } from '@gridpilot/racing/domain/entities/LeagueMembership'; import type { IFeedRepository } from '@gridpilot/social/domain/repositories/IFeedRepository'; import type { ISocialGraphRepository } from '@gridpilot/social/domain/repositories/ISocialGraphRepository'; import type { ImageServicePort } from '@gridpilot/media'; // Notifications package imports import type { INotificationRepository, INotificationPreferenceRepository } from '@gridpilot/notifications/application'; import type { SendNotificationUseCase, MarkNotificationReadUseCase, GetUnreadNotificationsUseCase } from '@gridpilot/notifications/application'; import type { JoinLeagueUseCase, RegisterForRaceUseCase, WithdrawFromRaceUseCase, CreateTeamUseCase, JoinTeamUseCase, LeaveTeamUseCase, ApproveTeamJoinRequestUseCase, RejectTeamJoinRequestUseCase, UpdateTeamUseCase, GetAllTeamsUseCase, GetTeamDetailsUseCase, GetTeamMembersUseCase, GetTeamJoinRequestsUseCase, GetDriverTeamUseCase, CreateLeagueWithSeasonAndScoringUseCase, FileProtestUseCase, ReviewProtestUseCase, ApplyPenaltyUseCase, RequestProtestDefenseUseCase, SubmitProtestDefenseUseCase, GetSponsorDashboardUseCase, GetSponsorSponsorshipsUseCase, ApplyForSponsorshipUseCase, AcceptSponsorshipRequestUseCase, RejectSponsorshipRequestUseCase, GetPendingSponsorshipRequestsUseCase, GetEntitySponsorshipPricingUseCase, } from '@gridpilot/racing/application'; import type { IsDriverRegisteredForRaceUseCase } from '@gridpilot/racing/application/use-cases/IsDriverRegisteredForRaceUseCase'; import type { GetRaceRegistrationsUseCase } from '@gridpilot/racing/application/use-cases/GetRaceRegistrationsUseCase'; import type { GetRaceWithSOFUseCase } from '@gridpilot/racing/application/use-cases/GetRaceWithSOFUseCase'; import type { GetRaceProtestsUseCase } from '@gridpilot/racing/application/use-cases/GetRaceProtestsUseCase'; import type { GetRacePenaltiesUseCase } from '@gridpilot/racing/application/use-cases/GetRacePenaltiesUseCase'; import type { GetRacesPageDataUseCase } from '@gridpilot/racing/application/use-cases/GetRacesPageDataUseCase'; import type { GetRaceDetailUseCase } from '@gridpilot/racing/application/use-cases/GetRaceDetailUseCase'; import type { GetRaceResultsDetailUseCase } from '@gridpilot/racing/application/use-cases/GetRaceResultsDetailUseCase'; import type { GetAllRacesPageDataUseCase } from '@gridpilot/racing/application/use-cases/GetAllRacesPageDataUseCase'; import type { GetProfileOverviewUseCase } from '@gridpilot/racing/application/use-cases/GetProfileOverviewUseCase'; import type { UpdateDriverProfileUseCase } from '@gridpilot/racing/application/use-cases/UpdateDriverProfileUseCase'; import type { GetDriversLeaderboardUseCase } from '@gridpilot/racing/application/use-cases/GetDriversLeaderboardUseCase'; import type { GetTeamsLeaderboardUseCase } from '@gridpilot/racing/application/use-cases/GetTeamsLeaderboardUseCase'; import type { GetLeagueStandingsUseCase } from '@gridpilot/racing/application/use-cases/GetLeagueStandingsUseCase'; import type { GetLeagueDriverSeasonStatsUseCase } from '@gridpilot/racing/application/use-cases/GetLeagueDriverSeasonStatsUseCase'; import type { GetAllLeaguesWithCapacityUseCase } from '@gridpilot/racing/application/use-cases/GetAllLeaguesWithCapacityUseCase'; import type { GetAllLeaguesWithCapacityAndScoringUseCase } from '@gridpilot/racing/application/use-cases/GetAllLeaguesWithCapacityAndScoringUseCase'; import type { ListLeagueScoringPresetsUseCase } from '@gridpilot/racing/application/use-cases/ListLeagueScoringPresetsUseCase'; import type { GetLeagueScoringConfigUseCase } from '@gridpilot/racing/application/use-cases/GetLeagueScoringConfigUseCase'; import type { GetLeagueFullConfigUseCase } from '@gridpilot/racing/application/use-cases/GetLeagueFullConfigUseCase'; import type { GetLeagueStatsUseCase } from '@gridpilot/racing/application/use-cases/GetLeagueStatsUseCase'; import type { CancelRaceUseCase } from '@gridpilot/racing/application/use-cases/CancelRaceUseCase'; import type { ImportRaceResultsUseCase } from '@gridpilot/racing/application/use-cases/ImportRaceResultsUseCase'; import type { ISponsorRepository } from '@gridpilot/racing/domain/repositories/ISponsorRepository'; import type { ISeasonSponsorshipRepository } from '@gridpilot/racing/domain/repositories/ISeasonSponsorshipRepository'; import type { ISponsorshipRequestRepository } from '@gridpilot/racing/domain/repositories/ISponsorshipRequestRepository'; import type { ISponsorshipPricingRepository } from '@gridpilot/racing/domain/repositories/ISponsorshipPricingRepository'; import type { TransferLeagueOwnershipUseCase } from '@gridpilot/racing/application/use-cases/TransferLeagueOwnershipUseCase'; import type { DriverRatingProvider } from '@gridpilot/racing/application'; import type { PreviewLeagueScheduleUseCase } from '@gridpilot/racing/application'; import type { LeagueScoringPresetProvider } from '@gridpilot/racing/application/ports/LeagueScoringPresetProvider'; import type { LeagueScoringPresetDTO } from '@gridpilot/racing/application/ports/LeagueScoringPresetProvider'; import type { GetDashboardOverviewUseCase } from '@gridpilot/racing/application/use-cases/GetDashboardOverviewUseCase'; import type { ListSeasonsForLeagueUseCase } from '@gridpilot/racing/application/use-cases/SeasonUseCases'; import { createDemoDriverStats, getDemoLeagueRankings, type DriverStats } from '@gridpilot/testing-support'; /** * DI Container - TSyringe Facade * Provides singleton access to TSyringe container with lazy initialization */ class DIContainer { private static instance: DIContainer; private initialized = false; private constructor() { // Private constructor for singleton pattern } /** * Ensure TSyringe container is configured */ private ensureInitialized(): void { if (this.initialized) return; configureDIContainer(); this.initialized = true; } /** * Get singleton instance */ static getInstance(): DIContainer { if (!DIContainer.instance) { DIContainer.instance = new DIContainer(); } return DIContainer.instance; } /** * Reset the container (useful for testing) */ static reset(): void { DIContainer.instance = new DIContainer(); DIContainer.instance.initialized = false; } /** * Repository getters - resolve from TSyringe container */ get driverRepository(): IDriverRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.DriverRepository); } get leagueRepository(): ILeagueRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.LeagueRepository); } get raceRepository(): IRaceRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.RaceRepository); } get resultRepository(): IResultRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ResultRepository); } get standingRepository(): IStandingRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.StandingRepository); } get penaltyRepository(): IPenaltyRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.PenaltyRepository); } get protestRepository(): IProtestRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ProtestRepository); } get raceRegistrationRepository(): IRaceRegistrationRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.RaceRegistrationRepository); } get leagueMembershipRepository(): ILeagueMembershipRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.LeagueMembershipRepository); } get gameRepository(): IGameRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GameRepository); } get seasonRepository(): ISeasonRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SeasonRepository); } get leagueScoringConfigRepository(): ILeagueScoringConfigRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.LeagueScoringConfigRepository); } get leagueScoringPresetProvider(): LeagueScoringPresetProvider { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.LeagueScoringPresetProvider); } get joinLeagueUseCase(): JoinLeagueUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.JoinLeagueUseCase); } get registerForRaceUseCase(): RegisterForRaceUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.RegisterForRaceUseCase); } get withdrawFromRaceUseCase(): WithdrawFromRaceUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.WithdrawFromRaceUseCase); } get isDriverRegisteredForRaceUseCase(): IsDriverRegisteredForRaceUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.IsDriverRegisteredForRaceUseCase); } get getRaceRegistrationsUseCase(): GetRaceRegistrationsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetRaceRegistrationsUseCase); } get getLeagueStandingsUseCase(): GetLeagueStandingsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetLeagueStandingsUseCase); } get getLeagueDriverSeasonStatsUseCase(): GetLeagueDriverSeasonStatsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetLeagueDriverSeasonStatsUseCase); } get getAllLeaguesWithCapacityUseCase(): GetAllLeaguesWithCapacityUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetAllLeaguesWithCapacityUseCase); } get getAllLeaguesWithCapacityAndScoringUseCase(): GetAllLeaguesWithCapacityAndScoringUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetAllLeaguesWithCapacityAndScoringUseCase); } get listSeasonsForLeagueUseCase(): ListSeasonsForLeagueUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ListSeasonsForLeagueUseCase); } get listLeagueScoringPresetsUseCase(): ListLeagueScoringPresetsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ListLeagueScoringPresetsUseCase); } get getLeagueScoringConfigUseCase(): GetLeagueScoringConfigUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetLeagueScoringConfigUseCase); } get getLeagueFullConfigUseCase(): GetLeagueFullConfigUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetLeagueFullConfigUseCase); } get previewLeagueScheduleUseCase(): PreviewLeagueScheduleUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.PreviewLeagueScheduleUseCase); } get getRaceWithSOFUseCase(): GetRaceWithSOFUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetRaceWithSOFUseCase); } get getLeagueStatsUseCase(): GetLeagueStatsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetLeagueStatsUseCase); } get getRacesPageDataUseCase(): GetRacesPageDataUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetRacesPageDataUseCase); } get getAllRacesPageDataUseCase(): GetAllRacesPageDataUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetAllRacesPageDataUseCase); } get getRaceDetailUseCase(): GetRaceDetailUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetRaceDetailUseCase); } get getRaceResultsDetailUseCase(): GetRaceResultsDetailUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetRaceResultsDetailUseCase); } get getDriversLeaderboardUseCase(): GetDriversLeaderboardUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetDriversLeaderboardUseCase); } get getTeamsLeaderboardUseCase(): GetTeamsLeaderboardUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetTeamsLeaderboardUseCase); } get getDashboardOverviewUseCase(): GetDashboardOverviewUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetDashboardOverviewUseCase); } get getProfileOverviewUseCase(): GetProfileOverviewUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetProfileOverviewUseCase); } get updateDriverProfileUseCase(): UpdateDriverProfileUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.UpdateDriverProfileUseCase); } get driverRatingProvider(): DriverRatingProvider { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.DriverRatingProvider); } get cancelRaceUseCase(): CancelRaceUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.CancelRaceUseCase); } get importRaceResultsUseCase(): ImportRaceResultsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ImportRaceResultsUseCase); } get createLeagueWithSeasonAndScoringUseCase(): CreateLeagueWithSeasonAndScoringUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.CreateLeagueWithSeasonAndScoringUseCase); } get createTeamUseCase(): CreateTeamUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.CreateTeamUseCase); } get joinTeamUseCase(): JoinTeamUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.JoinTeamUseCase); } get leaveTeamUseCase(): LeaveTeamUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.LeaveTeamUseCase); } get approveTeamJoinRequestUseCase(): ApproveTeamJoinRequestUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ApproveTeamJoinRequestUseCase); } get rejectTeamJoinRequestUseCase(): RejectTeamJoinRequestUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.RejectTeamJoinRequestUseCase); } get updateTeamUseCase(): UpdateTeamUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.UpdateTeamUseCase); } get getAllTeamsUseCase(): GetAllTeamsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetAllTeamsUseCase); } get getTeamDetailsUseCase(): GetTeamDetailsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetTeamDetailsUseCase); } get getTeamMembersUseCase(): GetTeamMembersUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetTeamMembersUseCase); } get getTeamJoinRequestsUseCase(): GetTeamJoinRequestsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetTeamJoinRequestsUseCase); } get getDriverTeamUseCase(): GetDriverTeamUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetDriverTeamUseCase); } get teamRepository(): ITeamRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.TeamRepository); } get teamMembershipRepository(): ITeamMembershipRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.TeamMembershipRepository); } get feedRepository(): IFeedRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.FeedRepository); } get socialRepository(): ISocialGraphRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SocialRepository); } get imageService(): ImageServicePort { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ImageService); } get trackRepository(): ITrackRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.TrackRepository); } get carRepository(): ICarRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.CarRepository); } get notificationRepository(): INotificationRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.NotificationRepository); } get notificationPreferenceRepository(): INotificationPreferenceRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.NotificationPreferenceRepository); } get sendNotificationUseCase(): SendNotificationUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SendNotificationUseCase); } get markNotificationReadUseCase(): MarkNotificationReadUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.MarkNotificationReadUseCase); } get getUnreadNotificationsUseCase(): GetUnreadNotificationsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetUnreadNotificationsUseCase); } get fileProtestUseCase(): FileProtestUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.FileProtestUseCase); } get reviewProtestUseCase(): ReviewProtestUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ReviewProtestUseCase); } get applyPenaltyUseCase(): ApplyPenaltyUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ApplyPenaltyUseCase); } get getRaceProtestsUseCase(): GetRaceProtestsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetRaceProtestsUseCase); } get getRacePenaltiesUseCase(): GetRacePenaltiesUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetRacePenaltiesUseCase); } get requestProtestDefenseUseCase(): RequestProtestDefenseUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.RequestProtestDefenseUseCase); } get submitProtestDefenseUseCase(): SubmitProtestDefenseUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SubmitProtestDefenseUseCase); } get transferLeagueOwnershipUseCase(): TransferLeagueOwnershipUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.TransferLeagueOwnershipUseCase); } get sponsorRepository(): ISponsorRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SponsorRepository); } get seasonSponsorshipRepository(): ISeasonSponsorshipRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SeasonSponsorshipRepository); } get getSponsorDashboardUseCase(): GetSponsorDashboardUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetSponsorDashboardUseCase); } get getSponsorSponsorshipsUseCase(): GetSponsorSponsorshipsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetSponsorSponsorshipsUseCase); } get sponsorshipRequestRepository(): ISponsorshipRequestRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SponsorshipRequestRepository); } get sponsorshipPricingRepository(): ISponsorshipPricingRepository { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.SponsorshipPricingRepository); } get applyForSponsorshipUseCase(): ApplyForSponsorshipUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.ApplyForSponsorshipUseCase); } get acceptSponsorshipRequestUseCase(): AcceptSponsorshipRequestUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.AcceptSponsorshipRequestUseCase); } get rejectSponsorshipRequestUseCase(): RejectSponsorshipRequestUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.RejectSponsorshipRequestUseCase); } get getPendingSponsorshipRequestsUseCase(): GetPendingSponsorshipRequestsUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetPendingSponsorshipRequestsUseCase); } get getEntitySponsorshipPricingUseCase(): GetEntitySponsorshipPricingUseCase { this.ensureInitialized(); return getDIContainer().resolve(DI_TOKENS.GetEntitySponsorshipPricingUseCase); } } /** * Exported accessor functions */ export function getDriverRepository(): IDriverRepository { return DIContainer.getInstance().driverRepository; } export function getLeagueRepository(): ILeagueRepository { return DIContainer.getInstance().leagueRepository; } export function getRaceRepository(): IRaceRepository { return DIContainer.getInstance().raceRepository; } export function getResultRepository(): IResultRepository { return DIContainer.getInstance().resultRepository; } export function getStandingRepository(): IStandingRepository { return DIContainer.getInstance().standingRepository; } export function getPenaltyRepository(): IPenaltyRepository { return DIContainer.getInstance().penaltyRepository; } export function getProtestRepository(): IProtestRepository { return DIContainer.getInstance().protestRepository; } export function getRaceRegistrationRepository(): IRaceRegistrationRepository { return DIContainer.getInstance().raceRegistrationRepository; } export function getLeagueMembershipRepository(): ILeagueMembershipRepository { return DIContainer.getInstance().leagueMembershipRepository; } export function getJoinLeagueUseCase(): JoinLeagueUseCase { return DIContainer.getInstance().joinLeagueUseCase; } export function getRegisterForRaceUseCase(): RegisterForRaceUseCase { return DIContainer.getInstance().registerForRaceUseCase; } export function getWithdrawFromRaceUseCase(): WithdrawFromRaceUseCase { return DIContainer.getInstance().withdrawFromRaceUseCase; } export function getIsDriverRegisteredForRaceUseCase(): IsDriverRegisteredForRaceUseCase { return DIContainer.getInstance().isDriverRegisteredForRaceUseCase; } /** * Query facade for checking if a driver is registered for a race. */ export function getIsDriverRegisteredForRaceQuery(): { execute(input: { raceId: string; driverId: string }): Promise; } { const useCase = DIContainer.getInstance().isDriverRegisteredForRaceUseCase; return { async execute(input: { raceId: string; driverId: string }): Promise { const result = await useCase.execute(input); return Boolean(result); }, }; } export function getGetRaceRegistrationsUseCase(): GetRaceRegistrationsUseCase { return DIContainer.getInstance().getRaceRegistrationsUseCase; } export function getGetLeagueStandingsUseCase(): GetLeagueStandingsUseCase { return DIContainer.getInstance().getLeagueStandingsUseCase; } export function getGetLeagueDriverSeasonStatsUseCase(): GetLeagueDriverSeasonStatsUseCase { return DIContainer.getInstance().getLeagueDriverSeasonStatsUseCase; } export function getGetAllLeaguesWithCapacityUseCase(): GetAllLeaguesWithCapacityUseCase { return DIContainer.getInstance().getAllLeaguesWithCapacityUseCase; } export function getGetAllLeaguesWithCapacityAndScoringUseCase(): GetAllLeaguesWithCapacityAndScoringUseCase { return DIContainer.getInstance().getAllLeaguesWithCapacityAndScoringUseCase; } export function getListSeasonsForLeagueUseCase(): ListSeasonsForLeagueUseCase { return DIContainer.getInstance().listSeasonsForLeagueUseCase; } export function getGetLeagueScoringConfigUseCase(): GetLeagueScoringConfigUseCase { return DIContainer.getInstance().getLeagueScoringConfigUseCase; } export function getGetLeagueFullConfigUseCase(): GetLeagueFullConfigUseCase { return DIContainer.getInstance().getLeagueFullConfigUseCase; } export function getPreviewLeagueScheduleUseCase(): PreviewLeagueScheduleUseCase { return DIContainer.getInstance().previewLeagueScheduleUseCase; } export function getListLeagueScoringPresetsUseCase(): ListLeagueScoringPresetsUseCase { return DIContainer.getInstance().listLeagueScoringPresetsUseCase; } /** * Lightweight query facade for listing league scoring presets. * Returns an object with an execute() method for use in UI code. */ export function getListLeagueScoringPresetsQuery(): { execute(): Promise; } { const useCase = DIContainer.getInstance().listLeagueScoringPresetsUseCase; return { async execute(): Promise { const presenter = new LeagueScoringPresetsPresenter(); await useCase.execute(undefined as void, presenter); const viewModel = presenter.getViewModel(); return viewModel.presets; }, }; } export function getCreateLeagueWithSeasonAndScoringUseCase(): CreateLeagueWithSeasonAndScoringUseCase { return DIContainer.getInstance().createLeagueWithSeasonAndScoringUseCase; } export function getCancelRaceUseCase(): CancelRaceUseCase { return DIContainer.getInstance().cancelRaceUseCase; } export function getImportRaceResultsUseCase(): ImportRaceResultsUseCase { return DIContainer.getInstance().importRaceResultsUseCase; } export function getGetRaceWithSOFUseCase(): GetRaceWithSOFUseCase { return DIContainer.getInstance().getRaceWithSOFUseCase; } export function getGetLeagueStatsUseCase(): GetLeagueStatsUseCase { return DIContainer.getInstance().getLeagueStatsUseCase; } export function getGetRacesPageDataUseCase(): GetRacesPageDataUseCase { return DIContainer.getInstance().getRacesPageDataUseCase; } export function getGetAllRacesPageDataUseCase(): GetAllRacesPageDataUseCase { return DIContainer.getInstance().getAllRacesPageDataUseCase; } export function getGetRaceDetailUseCase(): GetRaceDetailUseCase { return DIContainer.getInstance().getRaceDetailUseCase; } export function getGetRaceResultsDetailUseCase(): GetRaceResultsDetailUseCase { return DIContainer.getInstance().getRaceResultsDetailUseCase; } export function getGetDriversLeaderboardUseCase(): GetDriversLeaderboardUseCase { return DIContainer.getInstance().getDriversLeaderboardUseCase; } export function getGetTeamsLeaderboardUseCase(): GetTeamsLeaderboardUseCase { return DIContainer.getInstance().getTeamsLeaderboardUseCase; } export function getGetDashboardOverviewUseCase(): GetDashboardOverviewUseCase { return DIContainer.getInstance().getDashboardOverviewUseCase; } export function getGetProfileOverviewUseCase(): GetProfileOverviewUseCase { return DIContainer.getInstance().getProfileOverviewUseCase; } export function getUpdateDriverProfileUseCase(): UpdateDriverProfileUseCase { return DIContainer.getInstance().updateDriverProfileUseCase; } export function getDriverRatingProvider(): DriverRatingProvider { return DIContainer.getInstance().driverRatingProvider; } export function getTeamRepository(): ITeamRepository { return DIContainer.getInstance().teamRepository; } export function getTeamMembershipRepository(): ITeamMembershipRepository { return DIContainer.getInstance().teamMembershipRepository; } export function getCreateTeamUseCase(): CreateTeamUseCase { return DIContainer.getInstance().createTeamUseCase; } export function getJoinTeamUseCase(): JoinTeamUseCase { return DIContainer.getInstance().joinTeamUseCase; } export function getLeaveTeamUseCase(): LeaveTeamUseCase { return DIContainer.getInstance().leaveTeamUseCase; } export function getApproveTeamJoinRequestUseCase(): ApproveTeamJoinRequestUseCase { return DIContainer.getInstance().approveTeamJoinRequestUseCase; } export function getRejectTeamJoinRequestUseCase(): RejectTeamJoinRequestUseCase { return DIContainer.getInstance().rejectTeamJoinRequestUseCase; } export function getUpdateTeamUseCase(): UpdateTeamUseCase { return DIContainer.getInstance().updateTeamUseCase; } export function getGetAllTeamsUseCase(): GetAllTeamsUseCase { return DIContainer.getInstance().getAllTeamsUseCase; } export function getGetTeamDetailsUseCase(): GetTeamDetailsUseCase { return DIContainer.getInstance().getTeamDetailsUseCase; } export function getGetTeamMembersUseCase(): GetTeamMembersUseCase { return DIContainer.getInstance().getTeamMembersUseCase; } export function getGetTeamJoinRequestsUseCase(): GetTeamJoinRequestsUseCase { return DIContainer.getInstance().getTeamJoinRequestsUseCase; } export function getGetDriverTeamUseCase(): GetDriverTeamUseCase { return DIContainer.getInstance().getDriverTeamUseCase; } export function getFeedRepository(): IFeedRepository { return DIContainer.getInstance().feedRepository; } export function getSocialRepository(): ISocialGraphRepository { return DIContainer.getInstance().socialRepository; } export function getImageService(): ImageServicePort { return DIContainer.getInstance().imageService; } export function getTrackRepository(): ITrackRepository { return DIContainer.getInstance().trackRepository; } export function getCarRepository(): ICarRepository { return DIContainer.getInstance().carRepository; } export function getSeasonRepository(): ISeasonRepository { return DIContainer.getInstance().seasonRepository; } export function getNotificationRepository(): INotificationRepository { return DIContainer.getInstance().notificationRepository; } export function getNotificationPreferenceRepository(): INotificationPreferenceRepository { return DIContainer.getInstance().notificationPreferenceRepository; } export function getSendNotificationUseCase(): SendNotificationUseCase { return DIContainer.getInstance().sendNotificationUseCase; } export function getMarkNotificationReadUseCase(): MarkNotificationReadUseCase { return DIContainer.getInstance().markNotificationReadUseCase; } export function getGetUnreadNotificationsUseCase(): GetUnreadNotificationsUseCase { return DIContainer.getInstance().getUnreadNotificationsUseCase; } export function getFileProtestUseCase(): FileProtestUseCase { return DIContainer.getInstance().fileProtestUseCase; } export function getReviewProtestUseCase(): ReviewProtestUseCase { return DIContainer.getInstance().reviewProtestUseCase; } export function getApplyPenaltyUseCase(): ApplyPenaltyUseCase { return DIContainer.getInstance().applyPenaltyUseCase; } export function getGetRaceProtestsUseCase(): GetRaceProtestsUseCase { return DIContainer.getInstance().getRaceProtestsUseCase; } export function getGetRacePenaltiesUseCase(): GetRacePenaltiesUseCase { return DIContainer.getInstance().getRacePenaltiesUseCase; } export function getRequestProtestDefenseUseCase(): RequestProtestDefenseUseCase { return DIContainer.getInstance().requestProtestDefenseUseCase; } export function getSubmitProtestDefenseUseCase(): SubmitProtestDefenseUseCase { return DIContainer.getInstance().submitProtestDefenseUseCase; } export function getTransferLeagueOwnershipUseCase(): TransferLeagueOwnershipUseCase { return DIContainer.getInstance().transferLeagueOwnershipUseCase; } export function getSponsorRepository(): ISponsorRepository { return DIContainer.getInstance().sponsorRepository; } export function getSeasonSponsorshipRepository(): ISeasonSponsorshipRepository { return DIContainer.getInstance().seasonSponsorshipRepository; } export function getGetSponsorDashboardUseCase(): GetSponsorDashboardUseCase { return DIContainer.getInstance().getSponsorDashboardUseCase; } export function getGetSponsorSponsorshipsUseCase(): GetSponsorSponsorshipsUseCase { return DIContainer.getInstance().getSponsorSponsorshipsUseCase; } export function getSponsorshipRequestRepository(): ISponsorshipRequestRepository { return DIContainer.getInstance().sponsorshipRequestRepository; } export function getSponsorshipPricingRepository(): ISponsorshipPricingRepository { return DIContainer.getInstance().sponsorshipPricingRepository; } export function getApplyForSponsorshipUseCase(): ApplyForSponsorshipUseCase { return DIContainer.getInstance().applyForSponsorshipUseCase; } export function getAcceptSponsorshipRequestUseCase(): AcceptSponsorshipRequestUseCase { return DIContainer.getInstance().acceptSponsorshipRequestUseCase; } export function getRejectSponsorshipRequestUseCase(): RejectSponsorshipRequestUseCase { return DIContainer.getInstance().rejectSponsorshipRequestUseCase; } export function getGetPendingSponsorshipRequestsUseCase(): GetPendingSponsorshipRequestsUseCase { return DIContainer.getInstance().getPendingSponsorshipRequestsUseCase; } export function getGetEntitySponsorshipPricingUseCase(): GetEntitySponsorshipPricingUseCase { return DIContainer.getInstance().getEntitySponsorshipPricingUseCase; } /** * Reset function for testing */ export function resetContainer(): void { DIContainer.reset(); } /** * Export stats from testing-support for backward compatibility */ export type { DriverStats }; /** * Get driver statistics and rankings * These functions access the demo driver stats registered in the DI container */ export function getDriverStats(driverId: string): DriverStats | null { const container = DIContainer.getInstance(); // Ensure container is initialized container['ensureInitialized'](); const stats = getDIContainer().resolve>(DI_TOKENS.DriverStats); return stats[driverId] || null; } /** * Get all driver rankings sorted by rating */ export function getAllDriverRankings(): DriverStats[] { const container = DIContainer.getInstance(); // Ensure container is initialized container['ensureInitialized'](); const stats = getDIContainer().resolve>(DI_TOKENS.DriverStats); return Object.values(stats).sort((a, b) => b.rating - a.rating); } export { getDemoLeagueRankings as getLeagueRankings };