809 lines
29 KiB
TypeScript
809 lines
29 KiB
TypeScript
/**
|
|
* 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 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,
|
|
GetUnreadNotificationsQuery
|
|
} from '@gridpilot/notifications/application';
|
|
import type {
|
|
JoinLeagueUseCase,
|
|
RegisterForRaceUseCase,
|
|
WithdrawFromRaceUseCase,
|
|
IsDriverRegisteredForRaceQuery,
|
|
GetRaceRegistrationsQuery,
|
|
CreateTeamUseCase,
|
|
JoinTeamUseCase,
|
|
LeaveTeamUseCase,
|
|
ApproveTeamJoinRequestUseCase,
|
|
RejectTeamJoinRequestUseCase,
|
|
UpdateTeamUseCase,
|
|
GetAllTeamsQuery,
|
|
GetTeamDetailsQuery,
|
|
GetTeamMembersQuery,
|
|
GetTeamJoinRequestsQuery,
|
|
GetDriverTeamQuery,
|
|
GetLeagueStandingsQuery,
|
|
GetLeagueDriverSeasonStatsQuery,
|
|
GetAllLeaguesWithCapacityQuery,
|
|
GetAllLeaguesWithCapacityAndScoringQuery,
|
|
ListLeagueScoringPresetsQuery,
|
|
GetLeagueScoringConfigQuery,
|
|
CreateLeagueWithSeasonAndScoringUseCase,
|
|
GetLeagueFullConfigQuery,
|
|
GetRaceWithSOFQuery,
|
|
GetLeagueStatsQuery,
|
|
FileProtestUseCase,
|
|
ReviewProtestUseCase,
|
|
ApplyPenaltyUseCase,
|
|
GetRaceProtestsQuery,
|
|
GetRacePenaltiesQuery,
|
|
RequestProtestDefenseUseCase,
|
|
SubmitProtestDefenseUseCase,
|
|
GetSponsorDashboardQuery,
|
|
GetSponsorSponsorshipsQuery,
|
|
ApplyForSponsorshipUseCase,
|
|
AcceptSponsorshipRequestUseCase,
|
|
RejectSponsorshipRequestUseCase,
|
|
GetPendingSponsorshipRequestsQuery,
|
|
GetEntitySponsorshipPricingQuery,
|
|
} from '@gridpilot/racing/application';
|
|
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 { PreviewLeagueScheduleQuery } from '@gridpilot/racing/application';
|
|
import type { LeagueScoringPresetProvider } from '@gridpilot/racing/application/ports/LeagueScoringPresetProvider';
|
|
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<IDriverRepository>(DI_TOKENS.DriverRepository);
|
|
}
|
|
|
|
get leagueRepository(): ILeagueRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ILeagueRepository>(DI_TOKENS.LeagueRepository);
|
|
}
|
|
|
|
get raceRepository(): IRaceRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IRaceRepository>(DI_TOKENS.RaceRepository);
|
|
}
|
|
|
|
get resultRepository(): IResultRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IResultRepository>(DI_TOKENS.ResultRepository);
|
|
}
|
|
|
|
get standingRepository(): IStandingRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IStandingRepository>(DI_TOKENS.StandingRepository);
|
|
}
|
|
|
|
get penaltyRepository(): IPenaltyRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IPenaltyRepository>(DI_TOKENS.PenaltyRepository);
|
|
}
|
|
|
|
get protestRepository(): IProtestRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IProtestRepository>(DI_TOKENS.ProtestRepository);
|
|
}
|
|
|
|
get raceRegistrationRepository(): IRaceRegistrationRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IRaceRegistrationRepository>(DI_TOKENS.RaceRegistrationRepository);
|
|
}
|
|
|
|
get leagueMembershipRepository(): ILeagueMembershipRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ILeagueMembershipRepository>(DI_TOKENS.LeagueMembershipRepository);
|
|
}
|
|
|
|
get gameRepository(): IGameRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IGameRepository>(DI_TOKENS.GameRepository);
|
|
}
|
|
|
|
get seasonRepository(): ISeasonRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ISeasonRepository>(DI_TOKENS.SeasonRepository);
|
|
}
|
|
|
|
get leagueScoringConfigRepository(): ILeagueScoringConfigRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ILeagueScoringConfigRepository>(DI_TOKENS.LeagueScoringConfigRepository);
|
|
}
|
|
|
|
get leagueScoringPresetProvider(): LeagueScoringPresetProvider {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<LeagueScoringPresetProvider>(DI_TOKENS.LeagueScoringPresetProvider);
|
|
}
|
|
|
|
get joinLeagueUseCase(): JoinLeagueUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<JoinLeagueUseCase>(DI_TOKENS.JoinLeagueUseCase);
|
|
}
|
|
|
|
get registerForRaceUseCase(): RegisterForRaceUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<RegisterForRaceUseCase>(DI_TOKENS.RegisterForRaceUseCase);
|
|
}
|
|
|
|
get withdrawFromRaceUseCase(): WithdrawFromRaceUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<WithdrawFromRaceUseCase>(DI_TOKENS.WithdrawFromRaceUseCase);
|
|
}
|
|
|
|
get isDriverRegisteredForRaceQuery(): IsDriverRegisteredForRaceQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IsDriverRegisteredForRaceQuery>(DI_TOKENS.IsDriverRegisteredForRaceQuery);
|
|
}
|
|
|
|
get getRaceRegistrationsQuery(): GetRaceRegistrationsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetRaceRegistrationsQuery>(DI_TOKENS.GetRaceRegistrationsQuery);
|
|
}
|
|
|
|
get getLeagueStandingsQuery(): GetLeagueStandingsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetLeagueStandingsQuery>(DI_TOKENS.GetLeagueStandingsQuery);
|
|
}
|
|
|
|
get getLeagueDriverSeasonStatsQuery(): GetLeagueDriverSeasonStatsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetLeagueDriverSeasonStatsQuery>(DI_TOKENS.GetLeagueDriverSeasonStatsQuery);
|
|
}
|
|
|
|
get getAllLeaguesWithCapacityQuery(): GetAllLeaguesWithCapacityQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetAllLeaguesWithCapacityQuery>(DI_TOKENS.GetAllLeaguesWithCapacityQuery);
|
|
}
|
|
|
|
get getAllLeaguesWithCapacityAndScoringQuery(): GetAllLeaguesWithCapacityAndScoringQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetAllLeaguesWithCapacityAndScoringQuery>(DI_TOKENS.GetAllLeaguesWithCapacityAndScoringQuery);
|
|
}
|
|
|
|
get listLeagueScoringPresetsQuery(): ListLeagueScoringPresetsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ListLeagueScoringPresetsQuery>(DI_TOKENS.ListLeagueScoringPresetsQuery);
|
|
}
|
|
|
|
get getLeagueScoringConfigQuery(): GetLeagueScoringConfigQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetLeagueScoringConfigQuery>(DI_TOKENS.GetLeagueScoringConfigQuery);
|
|
}
|
|
|
|
get getLeagueFullConfigQuery(): GetLeagueFullConfigQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetLeagueFullConfigQuery>(DI_TOKENS.GetLeagueFullConfigQuery);
|
|
}
|
|
|
|
get previewLeagueScheduleQuery(): PreviewLeagueScheduleQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<PreviewLeagueScheduleQuery>(DI_TOKENS.PreviewLeagueScheduleQuery);
|
|
}
|
|
|
|
get getRaceWithSOFQuery(): GetRaceWithSOFQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetRaceWithSOFQuery>(DI_TOKENS.GetRaceWithSOFQuery);
|
|
}
|
|
|
|
get getLeagueStatsQuery(): GetLeagueStatsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetLeagueStatsQuery>(DI_TOKENS.GetLeagueStatsQuery);
|
|
}
|
|
|
|
get driverRatingProvider(): DriverRatingProvider {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<DriverRatingProvider>(DI_TOKENS.DriverRatingProvider);
|
|
}
|
|
|
|
get createLeagueWithSeasonAndScoringUseCase(): CreateLeagueWithSeasonAndScoringUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<CreateLeagueWithSeasonAndScoringUseCase>(DI_TOKENS.CreateLeagueWithSeasonAndScoringUseCase);
|
|
}
|
|
|
|
get createTeamUseCase(): CreateTeamUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<CreateTeamUseCase>(DI_TOKENS.CreateTeamUseCase);
|
|
}
|
|
|
|
get joinTeamUseCase(): JoinTeamUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<JoinTeamUseCase>(DI_TOKENS.JoinTeamUseCase);
|
|
}
|
|
|
|
get leaveTeamUseCase(): LeaveTeamUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<LeaveTeamUseCase>(DI_TOKENS.LeaveTeamUseCase);
|
|
}
|
|
|
|
get approveTeamJoinRequestUseCase(): ApproveTeamJoinRequestUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ApproveTeamJoinRequestUseCase>(DI_TOKENS.ApproveTeamJoinRequestUseCase);
|
|
}
|
|
|
|
get rejectTeamJoinRequestUseCase(): RejectTeamJoinRequestUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<RejectTeamJoinRequestUseCase>(DI_TOKENS.RejectTeamJoinRequestUseCase);
|
|
}
|
|
|
|
get updateTeamUseCase(): UpdateTeamUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<UpdateTeamUseCase>(DI_TOKENS.UpdateTeamUseCase);
|
|
}
|
|
|
|
get getAllTeamsQuery(): GetAllTeamsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetAllTeamsQuery>(DI_TOKENS.GetAllTeamsQuery);
|
|
}
|
|
|
|
get getTeamDetailsQuery(): GetTeamDetailsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetTeamDetailsQuery>(DI_TOKENS.GetTeamDetailsQuery);
|
|
}
|
|
|
|
get getTeamMembersQuery(): GetTeamMembersQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetTeamMembersQuery>(DI_TOKENS.GetTeamMembersQuery);
|
|
}
|
|
|
|
get getTeamJoinRequestsQuery(): GetTeamJoinRequestsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetTeamJoinRequestsQuery>(DI_TOKENS.GetTeamJoinRequestsQuery);
|
|
}
|
|
|
|
get getDriverTeamQuery(): GetDriverTeamQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetDriverTeamQuery>(DI_TOKENS.GetDriverTeamQuery);
|
|
}
|
|
|
|
get teamRepository(): ITeamRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ITeamRepository>(DI_TOKENS.TeamRepository);
|
|
}
|
|
|
|
get teamMembershipRepository(): ITeamMembershipRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ITeamMembershipRepository>(DI_TOKENS.TeamMembershipRepository);
|
|
}
|
|
|
|
get feedRepository(): IFeedRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<IFeedRepository>(DI_TOKENS.FeedRepository);
|
|
}
|
|
|
|
get socialRepository(): ISocialGraphRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ISocialGraphRepository>(DI_TOKENS.SocialRepository);
|
|
}
|
|
|
|
get imageService(): ImageServicePort {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ImageServicePort>(DI_TOKENS.ImageService);
|
|
}
|
|
|
|
get trackRepository(): ITrackRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ITrackRepository>(DI_TOKENS.TrackRepository);
|
|
}
|
|
|
|
get carRepository(): ICarRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ICarRepository>(DI_TOKENS.CarRepository);
|
|
}
|
|
|
|
get notificationRepository(): INotificationRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<INotificationRepository>(DI_TOKENS.NotificationRepository);
|
|
}
|
|
|
|
get notificationPreferenceRepository(): INotificationPreferenceRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<INotificationPreferenceRepository>(DI_TOKENS.NotificationPreferenceRepository);
|
|
}
|
|
|
|
get sendNotificationUseCase(): SendNotificationUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<SendNotificationUseCase>(DI_TOKENS.SendNotificationUseCase);
|
|
}
|
|
|
|
get markNotificationReadUseCase(): MarkNotificationReadUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<MarkNotificationReadUseCase>(DI_TOKENS.MarkNotificationReadUseCase);
|
|
}
|
|
|
|
get getUnreadNotificationsQuery(): GetUnreadNotificationsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetUnreadNotificationsQuery>(DI_TOKENS.GetUnreadNotificationsQuery);
|
|
}
|
|
|
|
get fileProtestUseCase(): FileProtestUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<FileProtestUseCase>(DI_TOKENS.FileProtestUseCase);
|
|
}
|
|
|
|
get reviewProtestUseCase(): ReviewProtestUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ReviewProtestUseCase>(DI_TOKENS.ReviewProtestUseCase);
|
|
}
|
|
|
|
get applyPenaltyUseCase(): ApplyPenaltyUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ApplyPenaltyUseCase>(DI_TOKENS.ApplyPenaltyUseCase);
|
|
}
|
|
|
|
get getRaceProtestsQuery(): GetRaceProtestsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetRaceProtestsQuery>(DI_TOKENS.GetRaceProtestsQuery);
|
|
}
|
|
|
|
get getRacePenaltiesQuery(): GetRacePenaltiesQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetRacePenaltiesQuery>(DI_TOKENS.GetRacePenaltiesQuery);
|
|
}
|
|
|
|
get requestProtestDefenseUseCase(): RequestProtestDefenseUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<RequestProtestDefenseUseCase>(DI_TOKENS.RequestProtestDefenseUseCase);
|
|
}
|
|
|
|
get submitProtestDefenseUseCase(): SubmitProtestDefenseUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<SubmitProtestDefenseUseCase>(DI_TOKENS.SubmitProtestDefenseUseCase);
|
|
}
|
|
|
|
get transferLeagueOwnershipUseCase(): TransferLeagueOwnershipUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<TransferLeagueOwnershipUseCase>(DI_TOKENS.TransferLeagueOwnershipUseCase);
|
|
}
|
|
|
|
get sponsorRepository(): ISponsorRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ISponsorRepository>(DI_TOKENS.SponsorRepository);
|
|
}
|
|
|
|
get seasonSponsorshipRepository(): ISeasonSponsorshipRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ISeasonSponsorshipRepository>(DI_TOKENS.SeasonSponsorshipRepository);
|
|
}
|
|
|
|
get getSponsorDashboardQuery(): GetSponsorDashboardQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetSponsorDashboardQuery>(DI_TOKENS.GetSponsorDashboardQuery);
|
|
}
|
|
|
|
get getSponsorSponsorshipsQuery(): GetSponsorSponsorshipsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetSponsorSponsorshipsQuery>(DI_TOKENS.GetSponsorSponsorshipsQuery);
|
|
}
|
|
|
|
get sponsorshipRequestRepository(): ISponsorshipRequestRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ISponsorshipRequestRepository>(DI_TOKENS.SponsorshipRequestRepository);
|
|
}
|
|
|
|
get sponsorshipPricingRepository(): ISponsorshipPricingRepository {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ISponsorshipPricingRepository>(DI_TOKENS.SponsorshipPricingRepository);
|
|
}
|
|
|
|
get applyForSponsorshipUseCase(): ApplyForSponsorshipUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<ApplyForSponsorshipUseCase>(DI_TOKENS.ApplyForSponsorshipUseCase);
|
|
}
|
|
|
|
get acceptSponsorshipRequestUseCase(): AcceptSponsorshipRequestUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<AcceptSponsorshipRequestUseCase>(DI_TOKENS.AcceptSponsorshipRequestUseCase);
|
|
}
|
|
|
|
get rejectSponsorshipRequestUseCase(): RejectSponsorshipRequestUseCase {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<RejectSponsorshipRequestUseCase>(DI_TOKENS.RejectSponsorshipRequestUseCase);
|
|
}
|
|
|
|
get getPendingSponsorshipRequestsQuery(): GetPendingSponsorshipRequestsQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetPendingSponsorshipRequestsQuery>(DI_TOKENS.GetPendingSponsorshipRequestsQuery);
|
|
}
|
|
|
|
get getEntitySponsorshipPricingQuery(): GetEntitySponsorshipPricingQuery {
|
|
this.ensureInitialized();
|
|
return getDIContainer().resolve<GetEntitySponsorshipPricingQuery>(DI_TOKENS.GetEntitySponsorshipPricingQuery);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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 getIsDriverRegisteredForRaceQuery(): IsDriverRegisteredForRaceQuery {
|
|
return DIContainer.getInstance().isDriverRegisteredForRaceQuery;
|
|
}
|
|
|
|
export function getGetRaceRegistrationsQuery(): GetRaceRegistrationsQuery {
|
|
return DIContainer.getInstance().getRaceRegistrationsQuery;
|
|
}
|
|
|
|
export function getGetLeagueStandingsQuery(): GetLeagueStandingsQuery {
|
|
return DIContainer.getInstance().getLeagueStandingsQuery;
|
|
}
|
|
|
|
export function getGetLeagueDriverSeasonStatsQuery(): GetLeagueDriverSeasonStatsQuery {
|
|
return DIContainer.getInstance().getLeagueDriverSeasonStatsQuery;
|
|
}
|
|
|
|
export function getGetAllLeaguesWithCapacityQuery(): GetAllLeaguesWithCapacityQuery {
|
|
return DIContainer.getInstance().getAllLeaguesWithCapacityQuery;
|
|
}
|
|
|
|
export function getGetAllLeaguesWithCapacityAndScoringQuery(): GetAllLeaguesWithCapacityAndScoringQuery {
|
|
return DIContainer.getInstance().getAllLeaguesWithCapacityAndScoringQuery;
|
|
}
|
|
|
|
export function getGetLeagueScoringConfigQuery(): GetLeagueScoringConfigQuery {
|
|
return DIContainer.getInstance().getLeagueScoringConfigQuery;
|
|
}
|
|
|
|
export function getGetLeagueFullConfigQuery(): GetLeagueFullConfigQuery {
|
|
return DIContainer.getInstance().getLeagueFullConfigQuery;
|
|
}
|
|
|
|
// Placeholder export for future schedule preview API wiring.
|
|
export function getPreviewLeagueScheduleQuery(): PreviewLeagueScheduleQuery {
|
|
return DIContainer.getInstance().previewLeagueScheduleQuery;
|
|
}
|
|
|
|
export function getListLeagueScoringPresetsQuery(): ListLeagueScoringPresetsQuery {
|
|
return DIContainer.getInstance().listLeagueScoringPresetsQuery;
|
|
}
|
|
|
|
export function getCreateLeagueWithSeasonAndScoringUseCase(): CreateLeagueWithSeasonAndScoringUseCase {
|
|
return DIContainer.getInstance().createLeagueWithSeasonAndScoringUseCase;
|
|
}
|
|
|
|
export function getGetRaceWithSOFQuery(): GetRaceWithSOFQuery {
|
|
return DIContainer.getInstance().getRaceWithSOFQuery;
|
|
}
|
|
|
|
export function getGetLeagueStatsQuery(): GetLeagueStatsQuery {
|
|
return DIContainer.getInstance().getLeagueStatsQuery;
|
|
}
|
|
|
|
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 getGetAllTeamsQuery(): GetAllTeamsQuery {
|
|
return DIContainer.getInstance().getAllTeamsQuery;
|
|
}
|
|
|
|
export function getGetTeamDetailsQuery(): GetTeamDetailsQuery {
|
|
return DIContainer.getInstance().getTeamDetailsQuery;
|
|
}
|
|
|
|
export function getGetTeamMembersQuery(): GetTeamMembersQuery {
|
|
return DIContainer.getInstance().getTeamMembersQuery;
|
|
}
|
|
|
|
export function getGetTeamJoinRequestsQuery(): GetTeamJoinRequestsQuery {
|
|
return DIContainer.getInstance().getTeamJoinRequestsQuery;
|
|
}
|
|
|
|
export function getGetDriverTeamQuery(): GetDriverTeamQuery {
|
|
return DIContainer.getInstance().getDriverTeamQuery;
|
|
}
|
|
|
|
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 getGetUnreadNotificationsQuery(): GetUnreadNotificationsQuery {
|
|
return DIContainer.getInstance().getUnreadNotificationsQuery;
|
|
}
|
|
|
|
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 getGetRaceProtestsQuery(): GetRaceProtestsQuery {
|
|
return DIContainer.getInstance().getRaceProtestsQuery;
|
|
}
|
|
|
|
export function getGetRacePenaltiesQuery(): GetRacePenaltiesQuery {
|
|
return DIContainer.getInstance().getRacePenaltiesQuery;
|
|
}
|
|
|
|
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 getGetSponsorDashboardQuery(): GetSponsorDashboardQuery {
|
|
return DIContainer.getInstance().getSponsorDashboardQuery;
|
|
}
|
|
|
|
export function getGetSponsorSponsorshipsQuery(): GetSponsorSponsorshipsQuery {
|
|
return DIContainer.getInstance().getSponsorSponsorshipsQuery;
|
|
}
|
|
|
|
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 getGetPendingSponsorshipRequestsQuery(): GetPendingSponsorshipRequestsQuery {
|
|
return DIContainer.getInstance().getPendingSponsorshipRequestsQuery;
|
|
}
|
|
|
|
export function getGetEntitySponsorshipPricingQuery(): GetEntitySponsorshipPricingQuery {
|
|
return DIContainer.getInstance().getEntitySponsorshipPricingQuery;
|
|
}
|
|
|
|
/**
|
|
* 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<Record<string, DriverStats>>(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<Record<string, DriverStats>>(DI_TOKENS.DriverStats);
|
|
return Object.values(stats).sort((a, b) => b.rating - a.rating);
|
|
}
|
|
export { getDemoLeagueRankings as getLeagueRankings }; |