From 37b1aa626cd1939996827cf49a2f13b5a8752b88 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Fri, 16 Jan 2026 15:20:25 +0100 Subject: [PATCH] website refactor --- ...nMemoryAnalyticsSnapshotRepository.test.ts | 4 +- .../InMemoryEngagementRepository.test.ts | 4 +- .../InMemoryPageViewRepository.test.ts | 4 +- adapters/bootstrap/EnsureInitialData.ts | 10 +- adapters/bootstrap/ScoringDemoSetup.ts | 12 +- adapters/bootstrap/SeedDemoUsers.test.ts | 14 +- adapters/bootstrap/SeedDemoUsers.ts | 13 +- .../SeedRacingData.forceReseed.test.ts | 4 +- adapters/bootstrap/SeedRacingData.ts | 39 +----- .../bootstrap/racing/RacingDriverFactory.ts | 2 +- .../bootstrap/racing/RacingTeamFactory.ts | 2 +- adapters/eslint-rules/adapter-naming.js | 4 +- .../InMemoryAchievementRepository.test.ts | 4 +- .../inmemory/InMemoryAchievementRepository.ts | 9 +- .../inmemory/InMemoryAuthRepository.test.ts | 10 +- .../InMemorySponsorAccountRepository.test.ts | 5 +- .../InMemoryUserRatingRepository.test.ts | 4 +- .../inmemory/InMemoryUserRepository.test.ts | 4 +- .../session/CookieIdentitySessionAdapter.ts | 4 +- ...InMemoryAvatarGenerationRepository.test.ts | 4 +- .../InMemoryFaceValidationAdapter.test.ts | 2 +- .../ports/InMemoryFaceValidationAdapter.ts | 2 +- .../ports/InMemoryImageServiceAdapter.test.ts | 2 +- .../ports/InMemoryImageServiceAdapter.ts | 2 +- ...ryNotificationPreferenceRepository.test.ts | 4 +- .../InMemoryNotificationRepository.test.ts | 4 +- .../InMemoryNotificationRepository.ts | 2 +- .../ports/NotificationServiceAdapter.ts | 6 +- .../inmemory/InMemoryCarRepository.test.ts | 6 +- .../inmemory/InMemoryCarRepository.ts | 4 +- .../inmemory/InMemoryDriverRepository.test.ts | 8 +- .../inmemory/InMemoryDriverStatsRepository.ts | 4 +- .../inmemory/InMemoryGameRepository.test.ts | 4 +- ...InMemoryLeagueMembershipRepository.test.ts | 2 +- .../inmemory/InMemoryLeagueRepository.test.ts | 6 +- ...emoryLeagueScoringConfigRepository.test.ts | 6 +- .../InMemoryLeagueStandingsRepository.test.ts | 6 +- .../InMemoryLeagueWalletRepository.test.ts | 6 +- .../InMemoryLeagueWalletRepository.ts | 2 +- .../inmemory/InMemoryLiveryRepository.test.ts | 6 +- .../inmemory/InMemoryLiveryRepository.ts | 2 +- .../InMemoryPenaltyRepository.test.ts | 6 +- .../inmemory/InMemoryPenaltyRepository.ts | 2 +- .../InMemoryProtestRepository.test.ts | 6 +- .../InMemoryRaceEventRepository.test.ts | 6 +- .../inmemory/InMemoryRaceEventRepository.ts | 4 +- ...InMemoryRaceRegistrationRepository.test.ts | 6 +- .../inmemory/InMemoryRaceRepository.test.ts | 6 +- .../inmemory/InMemoryResultRepository.test.ts | 7 +- .../inmemory/InMemoryResultRepository.ts | 5 +- .../InMemoryScoringRepositories.test.ts | 18 +-- .../inmemory/InMemoryScoringRepositories.ts | 16 +-- .../inmemory/InMemorySeasonRepository.test.ts | 6 +- ...nMemorySeasonSponsorshipRepository.test.ts | 6 +- .../InMemorySeasonSponsorshipRepository.ts | 2 +- .../InMemorySessionRepository.test.ts | 6 +- .../inmemory/InMemorySessionRepository.ts | 4 +- .../InMemorySponsorRepository.test.ts | 6 +- ...MemorySponsorshipPricingRepository.test.ts | 6 +- .../InMemorySponsorshipPricingRepository.ts | 4 +- ...MemorySponsorshipRequestRepository.test.ts | 10 +- .../InMemoryStandingRepository.test.ts | 6 +- .../inmemory/InMemoryStandingRepository.ts | 5 +- .../InMemoryTeamMembershipRepository.test.ts | 6 +- .../InMemoryTeamMembershipRepository.ts | 10 +- .../inmemory/InMemoryTeamRepository.test.ts | 6 +- .../inmemory/InMemoryTeamRepository.ts | 4 +- .../inmemory/InMemoryTrackRepository.test.ts | 6 +- .../inmemory/InMemoryTrackRepository.ts | 4 +- .../InMemoryTransactionRepository.test.ts | 8 +- .../inmemory/InMemoryTransactionRepository.ts | 2 +- .../media/InMemoryMediaRepository.ts | 2 +- .../TeamTypeOrmRepositories.test.ts | 4 +- .../TypeOrmDriverRepository.test.ts | 61 +++------ ...emoryDriverExtendedProfileProvider.test.ts | 2 +- .../InMemoryDriverExtendedProfileProvider.ts | 2 +- .../InMemoryDriverRatingProvider.test.ts | 2 +- .../ports/InMemoryDriverRatingProvider.ts | 2 +- .../inmemory/InMemorySocialAndFeed.test.ts | 2 +- .../inmemory/InMemorySocialAndFeed.ts | 2 +- .../domain/analytics/AnalyticsProviders.ts | 8 +- apps/api/src/domain/auth/AuthProviders.ts | 26 ++-- apps/api/src/domain/auth/AuthService.ts | 64 ++++----- .../src/domain/bootstrap/BootstrapModule.ts | 14 +- .../domain/bootstrap/BootstrapProviders.ts | 22 +-- apps/api/src/domain/driver/DriverProviders.ts | 66 +++++---- apps/api/src/domain/driver/DriverService.ts | 26 ++-- apps/api/src/domain/league/LeagueService.ts | 126 +++++++++--------- apps/api/src/domain/media/MediaProviders.ts | 62 ++++----- apps/api/src/domain/media/MediaService.ts | 54 ++++---- .../src/domain/sponsor/SponsorProviders.ts | 2 +- .../src/domain/sponsor/SponsorService.test.ts | 8 +- apps/api/src/domain/sponsor/SponsorService.ts | 100 +++++++------- .../application/ports/LoggerPort.ts | 2 +- .../use-cases/CheckAuthenticationUseCase.ts | 6 +- .../use-cases/ClearSessionUseCase.ts | 2 +- .../use-cases/CompleteRaceCreationUseCase.ts | 2 +- .../use-cases/ConfirmCheckoutUseCase.ts | 6 +- .../StartAutomationSessionUseCase.ts | 4 +- .../VerifyAuthenticatedPageUseCase.ts | 4 +- .../adapters/logging/NoOpLogAdapter.ts | 4 +- .../adapters/logging/PinoLogAdapter.ts | 4 +- core/admin/domain/entities/AdminUser.ts | 6 +- .../GetAnalyticsMetricsUseCase.test.ts | 4 +- .../use-cases/GetDashboardDataUseCase.test.ts | 4 +- .../use-cases/GetEntityAnalyticsQuery.test.ts | 8 +- .../use-cases/RecordEngagementUseCase.test.ts | 7 +- .../use-cases/RecordPageViewUseCase.test.ts | 6 +- .../domain/entities/AnalyticsSnapshot.ts | 12 +- .../domain/entities/EngagementEvent.ts | 10 +- core/analytics/domain/entities/PageView.ts | 8 +- .../use-cases/ForgotPasswordUseCase.test.ts | 12 +- .../GetCurrentSessionUseCase.test.ts | 7 +- .../use-cases/GetCurrentSessionUseCase.ts | 7 +- .../GetCurrentUserSessionUseCase.test.ts | 7 +- .../use-cases/GetCurrentUserSessionUseCase.ts | 4 +- .../use-cases/GetUserUseCase.test.ts | 10 +- .../HandleAuthCallbackUseCase.test.ts | 7 +- .../use-cases/HandleAuthCallbackUseCase.ts | 6 +- .../use-cases/LoginUseCase.test.ts | 12 +- .../use-cases/LoginWithEmailUseCase.test.ts | 7 +- .../use-cases/LoginWithEmailUseCase.ts | 7 +- .../use-cases/LogoutUseCase.test.ts | 7 +- .../use-cases/ResetPasswordUseCase.test.ts | 13 +- .../use-cases/SignupSponsorUseCase.test.ts | 8 +- .../use-cases/SignupUseCase.test.ts | 10 +- .../use-cases/SignupWithEmailUseCase.test.ts | 8 +- .../use-cases/SignupWithEmailUseCase.ts | 13 +- .../use-cases/StartAuthUseCase.test.ts | 7 +- .../application/use-cases/StartAuthUseCase.ts | 4 +- .../CreateAchievementUseCase.test.ts | 6 +- .../achievement/CreateAchievementUseCase.ts | 2 +- core/identity/domain/entities/Achievement.ts | 2 +- .../domain/entities/AdminVoteSession.ts | 4 +- .../entities/ExternalGameRatingProfile.ts | 2 +- core/identity/domain/entities/RatingEvent.ts | 8 +- .../domain/entities/UserAchievement.ts | 2 +- .../use-cases/DeleteMediaUseCase.test.ts | 17 ++- .../use-cases/DeleteMediaUseCase.ts | 4 +- .../use-cases/GetAvatarUseCase.test.ts | 15 +-- .../application/use-cases/GetAvatarUseCase.ts | 2 - .../use-cases/GetMediaUseCase.test.ts | 15 +-- .../application/use-cases/GetMediaUseCase.ts | 2 - .../RequestAvatarGenerationUseCase.test.ts | 19 ++- .../RequestAvatarGenerationUseCase.ts | 11 +- .../use-cases/SelectAvatarUseCase.test.ts | 15 +-- .../use-cases/SelectAvatarUseCase.ts | 2 - .../use-cases/UpdateAvatarUseCase.test.ts | 17 ++- .../use-cases/UpdateAvatarUseCase.ts | 5 +- .../use-cases/UploadMediaUseCase.test.ts | 23 ++-- .../use-cases/UploadMediaUseCase.ts | 6 +- core/media/domain/entities/Avatar.ts | 2 +- .../entities/AvatarGenerationRequest.ts | 10 +- core/media/domain/entities/Media.ts | 2 +- .../use-cases/GetAllNotificationsUseCase.ts | 4 +- .../GetUnreadNotificationsUseCase.test.ts | 13 +- .../GetUnreadNotificationsUseCase.ts | 9 +- .../MarkNotificationReadUseCase.test.ts | 21 ++- .../use-cases/MarkNotificationReadUseCase.ts | 10 +- .../NotificationPreferencesUseCases.test.ts | 25 ++-- .../NotificationPreferencesUseCases.ts | 10 +- .../use-cases/SendNotificationUseCase.test.ts | 16 +-- .../use-cases/SendNotificationUseCase.ts | 6 +- .../domain/entities/Notification.ts | 4 +- .../domain/entities/NotificationPreference.ts | 4 +- .../AcceptSponsorshipRequestUseCase.test.ts | 7 +- .../AcceptSponsorshipRequestUseCase.ts | 6 - .../ApplyForSponsorshipUseCase.test.ts | 9 +- .../use-cases/ApplyForSponsorshipUseCase.ts | 11 +- .../use-cases/ApplyPenaltyUseCase.test.ts | 122 ++++++----------- .../use-cases/ApplyPenaltyUseCase.ts | 12 +- .../use-cases/CancelRaceUseCase.test.ts | 24 ++-- .../use-cases/CancelRaceUseCase.ts | 2 - .../CloseRaceEventStewardingUseCase.test.ts | 45 +++---- .../CloseRaceEventStewardingUseCase.ts | 9 +- .../use-cases/CompleteRaceUseCase.test.ts | 24 ++-- .../CreateLeagueSeasonScheduleRaceUseCase.ts | 17 +-- ...eLeagueWithSeasonAndScoringUseCase.test.ts | 46 +++---- ...CreateLeagueWithSeasonAndScoringUseCase.ts | 29 ++-- .../CreateSeasonForLeagueUseCase.test.ts | 40 +++--- .../use-cases/CreateSponsorUseCase.test.ts | 5 +- .../use-cases/CreateSponsorUseCase.ts | 7 +- .../use-cases/CreateTeamUseCase.test.ts | 30 ++--- .../use-cases/CreateTeamUseCase.ts | 14 +- .../DeleteLeagueSeasonScheduleRaceUseCase.ts | 9 +- .../use-cases/FileProtestUseCase.test.ts | 55 +++----- ...aguesWithCapacityAndScoringUseCase.test.ts | 37 +++-- .../GetAllRacesPageDataUseCase.test.ts | 39 +++--- .../use-cases/GetAllRacesPageDataUseCase.ts | 3 - .../use-cases/GetAllRacesUseCase.test.ts | 43 +++--- .../use-cases/GetAllRacesUseCase.ts | 5 +- .../use-cases/GetAllTeamsUseCase.test.ts | 120 ++++------------- .../use-cases/GetAllTeamsUseCase.ts | 7 +- .../GetDriverLiveriesUseCase.test.ts | 7 +- .../use-cases/GetDriverLiveriesUseCase.ts | 7 +- .../use-cases/GetDriverTeamUseCase.test.ts | 97 +++++++------- .../use-cases/GetDriverTeamUseCase.ts | 6 +- .../GetDriversLeaderboardUseCase.test.ts | 12 +- ...GetEntitySponsorshipPricingUseCase.test.ts | 40 +++--- .../GetEntitySponsorshipPricingUseCase.ts | 2 - .../GetLeagueAdminPermissionsUseCase.test.ts | 64 +++++---- .../GetLeagueAdminPermissionsUseCase.ts | 8 +- .../use-cases/GetLeagueAdminUseCase.test.ts | 18 +-- .../GetLeagueDriverSeasonStatsUseCase.test.ts | 46 +++---- .../GetLeagueFullConfigUseCase.test.ts | 38 ++---- .../GetLeagueMembershipsUseCase.test.ts | 43 +++--- .../GetLeagueOwnerSummaryUseCase.test.ts | 44 ++++-- .../use-cases/GetLeagueScheduleUseCase.ts | 7 +- .../GetLeagueScoringConfigUseCase.test.ts | 63 ++++----- .../GetLeagueScoringConfigUseCase.ts | 2 +- .../use-cases/GetLeagueSeasonsUseCase.test.ts | 50 +++---- .../GetLeagueStandingsUseCase.test.ts | 22 ++- .../use-cases/GetLeagueStatsUseCase.test.ts | 21 +-- .../use-cases/GetLeagueWalletUseCase.test.ts | 16 +-- .../use-cases/GetRaceProtestsUseCase.test.ts | 21 +-- .../GetRaceRegistrationsUseCase.test.ts | 30 ++--- .../GetRaceResultsDetailUseCase.test.ts | 23 ++-- .../use-cases/GetRaceWithSOFUseCase.test.ts | 55 +++----- .../use-cases/GetRacesPageDataUseCase.test.ts | 20 ++- .../use-cases/GetRacesPageDataUseCase.ts | 7 +- .../use-cases/GetSeasonDetailsUseCase.test.ts | 108 +++------------ .../GetSeasonSponsorshipsUseCase.test.ts | 21 +-- .../use-cases/GetSponsorsUseCase.test.ts | 21 ++- .../use-cases/GetSponsorsUseCase.ts | 22 ++- .../use-cases/GetTeamDetailsUseCase.test.ts | 21 ++- .../GetTeamJoinRequestsUseCase.test.ts | 6 +- .../use-cases/GetTeamMembersUseCase.test.ts | 27 ++-- .../use-cases/GetTeamMembersUseCase.ts | 8 +- .../GetTeamMembershipUseCase.test.ts | 42 +++--- .../use-cases/GetTeamMembershipUseCase.ts | 2 - .../GetTeamsLeaderboardUseCase.test.ts | 35 ++--- .../use-cases/GetTeamsLeaderboardUseCase.ts | 6 +- .../use-cases/GetTotalLeaguesUseCase.test.ts | 2 +- .../use-cases/GetTotalRacesUseCase.test.ts | 4 +- .../ImportRaceResultsApiUseCase.test.ts | 30 ++--- .../use-cases/ImportRaceResultsApiUseCase.ts | 8 +- .../ImportRaceResultsUseCase.test.ts | 20 +-- .../use-cases/ImportRaceResultsUseCase.ts | 8 +- .../IsDriverRegisteredForRaceUseCase.test.ts | 22 ++- .../use-cases/JoinLeagueUseCase.test.ts | 4 +- .../use-cases/JoinLeagueUseCase.ts | 7 +- .../use-cases/JoinTeamUseCase.test.ts | 28 ++-- .../application/use-cases/JoinTeamUseCase.ts | 6 +- ...gueSeasonScheduleMutationsUseCases.test.ts | 123 ++++++++--------- .../use-cases/LeaveTeamUseCase.test.ts | 4 +- .../application/use-cases/LeaveTeamUseCase.ts | 6 +- .../ListLeagueScoringPresetsUseCase.test.ts | 31 ++--- .../ManageSeasonLifecycleUseCase.test.ts | 71 +++++----- .../PreviewLeagueScheduleUseCase.test.ts | 15 +-- .../use-cases/PreviewLeagueScheduleUseCase.ts | 16 +-- .../PublishLeagueSeasonScheduleUseCase.ts | 7 +- .../use-cases/QuickPenaltyUseCase.test.ts | 9 +- .../use-cases/QuickPenaltyUseCase.ts | 11 +- ...culateChampionshipStandingsUseCase.test.ts | 64 ++++----- ...RecalculateChampionshipStandingsUseCase.ts | 17 +-- .../use-cases/RegisterForRaceUseCase.test.ts | 6 +- .../RejectSponsorshipRequestUseCase.test.ts | 13 +- .../RejectSponsorshipRequestUseCase.ts | 8 +- .../RejectTeamJoinRequestUseCase.test.ts | 4 +- .../use-cases/RejectTeamJoinRequestUseCase.ts | 10 +- .../RemoveLeagueMemberUseCase.test.ts | 5 +- .../use-cases/ReopenRaceUseCase.test.ts | 34 +++-- .../use-cases/ReopenRaceUseCase.ts | 2 - .../RequestProtestDefenseUseCase.test.ts | 4 +- .../use-cases/ReviewProtestUseCase.ts | 4 - .../use-cases/SendFinalResultsUseCase.test.ts | 4 +- .../use-cases/SendFinalResultsUseCase.ts | 12 +- .../SendPerformanceSummaryUseCase.test.ts | 4 +- .../SendPerformanceSummaryUseCase.ts | 13 +- .../SubmitProtestDefenseUseCase.test.ts | 20 ++- .../use-cases/TeamRankingUseCase.test.ts | 6 +- .../use-cases/TeamRankingUseCase.ts | 71 ++++++++-- .../TeamRatingFactoryUseCase.test.ts | 6 +- .../use-cases/TeamRatingFactoryUseCase.ts | 9 +- .../TransferLeagueOwnershipUseCase.test.ts | 89 +++++-------- .../TransferLeagueOwnershipUseCase.ts | 14 +- .../UnpublishLeagueSeasonScheduleUseCase.ts | 7 +- .../UpdateDriverProfileUseCase.test.ts | 3 - .../UpdateLeagueMemberRoleUseCase.test.ts | 42 ++---- .../UpdateLeagueSeasonScheduleRaceUseCase.ts | 6 +- .../use-cases/UpdateTeamUseCase.test.ts | 9 +- .../WithdrawFromLeagueWalletUseCase.test.ts | 55 ++++---- .../WithdrawFromLeagueWalletUseCase.ts | 9 +- .../use-cases/WithdrawFromRaceUseCase.test.ts | 36 ++--- core/racing/domain/entities/Car.ts | 16 +-- core/racing/domain/entities/Driver.ts | 15 ++- core/racing/domain/entities/DriverLivery.ts | 10 +- core/racing/domain/entities/Game.ts | 2 +- core/racing/domain/entities/JoinRequest.ts | 11 +- core/racing/domain/entities/League.ts | 25 ++-- .../domain/entities/LeagueMembership.ts | 17 ++- .../domain/entities/LeagueScoringConfig.ts | 6 +- core/racing/domain/entities/LiveryTemplate.ts | 12 +- core/racing/domain/entities/Protest.ts | 28 ++-- core/racing/domain/entities/Race.ts | 17 ++- core/racing/domain/entities/RaceEvent.ts | 13 +- .../domain/entities/RaceRegistration.ts | 11 +- .../domain/entities/ResultWithIncidents.ts | 2 +- core/racing/domain/entities/Session.ts | 4 +- .../domain/entities/SponsorshipRequest.ts | 4 +- core/racing/domain/entities/Standing.ts | 13 +- core/racing/domain/entities/Team.ts | 14 +- .../racing/domain/entities/TeamRatingEvent.ts | 8 +- core/racing/domain/entities/Track.ts | 10 +- .../championship/ChampionshipStanding.ts | 2 +- .../entities/league-wallet/LeagueWallet.ts | 6 +- .../entities/league-wallet/Transaction.ts | 6 +- .../racing/domain/entities/penalty/Penalty.ts | 33 +++-- core/racing/domain/entities/prize/Prize.ts | 8 +- core/racing/domain/entities/result/Result.ts | 15 ++- core/racing/domain/entities/season/Season.ts | 21 ++- .../entities/season/SeasonSponsorship.ts | 4 +- .../racing/domain/entities/sponsor/Sponsor.ts | 2 +- .../domain/value-objects/CountryCode.ts | 6 +- core/racing/domain/value-objects/JoinedAt.ts | 6 +- core/racing/domain/value-objects/Points.ts | 2 +- .../domain/value-objects/RacingId.test.ts | 2 +- core/racing/domain/value-objects/RacingId.ts | 6 +- .../domain/value-objects/driver/DriverBio.ts | 4 +- .../domain/value-objects/driver/DriverName.ts | 4 +- core/shared/domain/ValueObject.ts | 7 +- .../GetCurrentUserSocialUseCase.test.ts | 15 +-- .../use-cases/GetCurrentUserSocialUseCase.ts | 4 +- .../use-cases/GetUserFeedUseCase.test.ts | 13 +- .../use-cases/GetUserFeedUseCase.ts | 4 +- 325 files changed, 2167 insertions(+), 2782 deletions(-) diff --git a/adapters/analytics/persistence/inmemory/InMemoryAnalyticsSnapshotRepository.test.ts b/adapters/analytics/persistence/inmemory/InMemoryAnalyticsSnapshotRepository.test.ts index 4958fcbee..bd46f86e2 100644 --- a/adapters/analytics/persistence/inmemory/InMemoryAnalyticsSnapshotRepository.test.ts +++ b/adapters/analytics/persistence/inmemory/InMemoryAnalyticsSnapshotRepository.test.ts @@ -1,6 +1,6 @@ +import { AnalyticsSnapshot } from '@core/analytics/domain/entities/AnalyticsSnapshot'; +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; -import { AnalyticsSnapshot } from '@core/analytics/application/repositories/PageViewRepository'; import { InMemoryAnalyticsSnapshotRepository } from './InMemoryAnalyticsSnapshotRepository'; describe('InMemoryAnalyticsSnapshotRepository', () => { diff --git a/adapters/analytics/persistence/inmemory/InMemoryEngagementRepository.test.ts b/adapters/analytics/persistence/inmemory/InMemoryEngagementRepository.test.ts index 99407ac27..686b22b27 100644 --- a/adapters/analytics/persistence/inmemory/InMemoryEngagementRepository.test.ts +++ b/adapters/analytics/persistence/inmemory/InMemoryEngagementRepository.test.ts @@ -1,6 +1,6 @@ +import { EngagementEvent } from '@core/analytics/domain/entities/EngagementEvent'; +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; -import { EngagementEvent } from '@core/analytics/application/repositories/PageViewRepository'; import { InMemoryEngagementRepository } from './InMemoryEngagementRepository'; describe('InMemoryEngagementRepository', () => { diff --git a/adapters/analytics/persistence/inmemory/InMemoryPageViewRepository.test.ts b/adapters/analytics/persistence/inmemory/InMemoryPageViewRepository.test.ts index 0dd0aa0ea..beff680af 100644 --- a/adapters/analytics/persistence/inmemory/InMemoryPageViewRepository.test.ts +++ b/adapters/analytics/persistence/inmemory/InMemoryPageViewRepository.test.ts @@ -1,6 +1,6 @@ +import { PageView } from '@core/analytics/domain/entities/PageView'; +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; -import { PageView } from '@core/analytics/application/repositories/PageViewRepository'; import { InMemoryPageViewRepository } from './InMemoryPageViewRepository'; describe('InMemoryPageViewRepository', () => { diff --git a/adapters/bootstrap/EnsureInitialData.ts b/adapters/bootstrap/EnsureInitialData.ts index d73e76d41..b32b1ee4b 100644 --- a/adapters/bootstrap/EnsureInitialData.ts +++ b/adapters/bootstrap/EnsureInitialData.ts @@ -1,13 +1,13 @@ import { SignupWithEmailUseCase } from '@core/identity/application/use-cases/SignupWithEmailUseCase'; import { CreateAchievementUseCase } from '@core/identity/application/use-cases/achievement/CreateAchievementUseCase'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; import { - DRIVER_ACHIEVEMENTS, - STEWARD_ACHIEVEMENTS, - ADMIN_ACHIEVEMENTS, - COMMUNITY_ACHIEVEMENTS, + ADMIN_ACHIEVEMENTS, + COMMUNITY_ACHIEVEMENTS, + DRIVER_ACHIEVEMENTS, + STEWARD_ACHIEVEMENTS, } from '@core/identity/domain/AchievementConstants'; diff --git a/adapters/bootstrap/ScoringDemoSetup.ts b/adapters/bootstrap/ScoringDemoSetup.ts index cc3904ef4..fdd88dd53 100644 --- a/adapters/bootstrap/ScoringDemoSetup.ts +++ b/adapters/bootstrap/ScoringDemoSetup.ts @@ -1,13 +1,13 @@ import { Game } from '@core/racing/domain/entities/Game'; -import { Season } from '@core/racing/domain/entities/season/Season'; import type { LeagueScoringConfig } from '@core/racing/domain/entities/LeagueScoringConfig'; +import { Season } from '@core/racing/domain/entities/season/Season'; +import type { Logger } from '@core/shared/domain/Logger'; import { - InMemoryChampionshipStandingRepository, - InMemoryGameRepository, - InMemoryLeagueScoringConfigRepository, - InMemorySeasonRepository, + InMemoryChampionshipStandingRepository, + InMemoryGameRepository, + InMemoryLeagueScoringConfigRepository, + InMemorySeasonRepository, } from '../racing/persistence/inmemory/InMemoryScoringRepositories'; -import type { Logger } from '@core/shared/domain'; import { getLeagueScoringPresetById } from './LeagueScoringPresets'; /* eslint-disable @typescript-eslint/no-unused-vars */ diff --git a/adapters/bootstrap/SeedDemoUsers.test.ts b/adapters/bootstrap/SeedDemoUsers.test.ts index 7e3f0a5d0..683c7fcea 100644 --- a/adapters/bootstrap/SeedDemoUsers.test.ts +++ b/adapters/bootstrap/SeedDemoUsers.test.ts @@ -1,16 +1,12 @@ -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import type { Logger } from '@core/shared/domain'; -import type { AuthRepository } from '@core/identity/domain/repositories/AuthRepository'; -import type { PasswordHashingService } from '@core/identity/domain/services/PasswordHashingService'; -import type { AdminUserRepository } from '@core/admin/domain/repositories/AdminUserRepository'; -import { User } from '@core/identity/domain/entities/User'; import { AdminUser } from '@core/admin/domain/entities/AdminUser'; -import { EmailAddress } from '@core/identity/domain/value-objects/EmailAddress'; -import { UserId } from '@core/identity/domain/value-objects/UserId'; import { Email } from '@core/admin/domain/value-objects/Email'; import { UserRole } from '@core/admin/domain/value-objects/UserRole'; -import { UserStatus } from '@core/admin/domain/value-objects/UserStatus'; +import { User } from '@core/identity/domain/entities/User'; +import { EmailAddress } from '@core/identity/domain/value-objects/EmailAddress'; import { PasswordHash } from '@core/identity/domain/value-objects/PasswordHash'; +import { UserId } from '@core/identity/domain/value-objects/UserId'; +import type { Logger } from '@core/shared/domain/Logger'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; // Import the class we're testing (will be created) import { SeedDemoUsers } from './SeedDemoUsers'; diff --git a/adapters/bootstrap/SeedDemoUsers.ts b/adapters/bootstrap/SeedDemoUsers.ts index 2480496b2..0e3388da2 100644 --- a/adapters/bootstrap/SeedDemoUsers.ts +++ b/adapters/bootstrap/SeedDemoUsers.ts @@ -1,13 +1,10 @@ -import type { Logger } from '@core/shared/domain'; -import type { AuthRepository } from '@core/identity/domain/repositories/AuthRepository'; -import type { PasswordHashingService } from '@core/identity/domain/services/PasswordHashingService'; -import type { AdminUserRepository } from '@core/admin/domain/repositories/AdminUserRepository'; -import { User } from '@core/identity/domain/entities/User'; import { AdminUser } from '@core/admin/domain/entities/AdminUser'; -import { EmailAddress } from '@core/identity/domain/value-objects/EmailAddress'; -import { UserId } from '@core/identity/domain/value-objects/UserId'; import { Email } from '@core/admin/domain/value-objects/Email'; +import { User } from '@core/identity/domain/entities/User'; +import { EmailAddress } from '@core/identity/domain/value-objects/EmailAddress'; import { PasswordHash } from '@core/identity/domain/value-objects/PasswordHash'; +import { UserId } from '@core/identity/domain/value-objects/UserId'; +import type { Logger } from '@core/shared/domain/Logger'; import { stableUuidFromSeedKey } from './racing/SeedIdHelper'; interface DemoUserSpec { @@ -38,7 +35,7 @@ export class SeedDemoUsers { { email: 'demo.sponsor@example.com', password: 'Demo1234!', - needsAdminUser: true, + needsAdminUser: false, needsPrimaryDriverId: false, roles: ['sponsor'], displayName: 'Jane Sponsor', diff --git a/adapters/bootstrap/SeedRacingData.forceReseed.test.ts b/adapters/bootstrap/SeedRacingData.forceReseed.test.ts index e857d57c2..432a73606 100644 --- a/adapters/bootstrap/SeedRacingData.forceReseed.test.ts +++ b/adapters/bootstrap/SeedRacingData.forceReseed.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; // IMPORTANT: SeedRacingData imports createRacingSeed from ./racing/RacingSeed // We mock it to avoid heavy seed generation and to keep the test focused on @@ -34,7 +34,7 @@ vi.mock('./racing/RacingSeed', () => { }; }); -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; import { SeedRacingData, type RacingSeedDependencies } from './SeedRacingData'; describe('SeedRacingData force reseed behavior', () => { diff --git a/adapters/bootstrap/SeedRacingData.ts b/adapters/bootstrap/SeedRacingData.ts index 5510639f3..cb4791f0f 100644 --- a/adapters/bootstrap/SeedRacingData.ts +++ b/adapters/bootstrap/SeedRacingData.ts @@ -1,39 +1,14 @@ -import type { Logger } from '@core/shared/domain'; -import type { DriverRepository } from '@core/racing/domain/repositories/DriverRepository'; -import type { LeagueRepository } from '@core/racing/domain/repositories/LeagueRepository'; -import type { RaceRepository } from '@core/racing/domain/repositories/RaceRepository'; -import type { ResultRepository } from '@core/racing/domain/repositories/ResultRepository'; -import type { StandingRepository } from '@core/racing/domain/repositories/StandingRepository'; -import type { LeagueMembershipRepository } from '@core/racing/domain/repositories/LeagueMembershipRepository'; -import type { RaceRegistrationRepository } from '@core/racing/domain/repositories/RaceRegistrationRepository'; -import type { TeamRepository } from '@core/racing/domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '@core/racing/domain/repositories/TeamMembershipRepository'; -import type { SponsorRepository } from '@core/racing/domain/repositories/SponsorRepository'; -import type { SeasonRepository } from '@core/racing/domain/repositories/SeasonRepository'; -import type { LeagueScoringConfigRepository } from '@core/racing/domain/repositories/LeagueScoringConfigRepository'; -import type { SeasonSponsorshipRepository } from '@core/racing/domain/repositories/SeasonSponsorshipRepository'; -import type { SponsorshipRequestRepository } from '@core/racing/domain/repositories/SponsorshipRequestRepository'; -import type { LeagueWalletRepository } from '@core/racing/domain/repositories/LeagueWalletRepository'; -import type { TransactionRepository } from '@core/racing/domain/repositories/TransactionRepository'; -import type { Season } from '@core/racing/domain/entities/season/Season'; -import { getLeagueScoringPresetById } from './LeagueScoringPresets'; -import type { ProtestRepository } from '@core/racing/domain/repositories/ProtestRepository'; -import type { PenaltyRepository } from '@core/racing/domain/repositories/PenaltyRepository'; -import type { FeedRepository } from '@core/social/domain/repositories/FeedRepository'; -import type { SocialGraphRepository } from '@core/social/domain/repositories/SocialGraphRepository'; -import type { DriverStatsRepository } from '@core/racing/domain/repositories/DriverStatsRepository'; -import type { TeamStatsRepository, TeamStats } from '@core/racing/domain/repositories/TeamStatsRepository'; -import type { MediaRepository } from '@core/racing/domain/repositories/MediaRepository'; -import type { AuthRepository } from '@core/identity/domain/repositories/AuthRepository'; -import type { PasswordHashingService } from '@core/identity/domain/services/PasswordHashingService'; -import type { AdminUserRepository } from '@core/admin/domain/repositories/AdminUserRepository'; -import { createRacingSeed } from './racing/RacingSeed'; -import { seedId } from './racing/SeedIdHelper'; +import type { DriverStats } from '@core/racing/application/use-cases/DriverStatsUseCase'; import { Driver } from '@core/racing/domain/entities/Driver'; import { Result } from '@core/racing/domain/entities/result/Result'; +import type { Season } from '@core/racing/domain/entities/season/Season'; import { Standing } from '@core/racing/domain/entities/Standing'; import { Team } from '@core/racing/domain/entities/Team'; -import type { DriverStats } from '@core/racing/application/use-cases/DriverStatsUseCase'; +import type { TeamStats } from '@core/racing/domain/repositories/TeamStatsRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { getLeagueScoringPresetById } from './LeagueScoringPresets'; +import { createRacingSeed } from './racing/RacingSeed'; +import { seedId } from './racing/SeedIdHelper'; export type RacingSeedDependencies = { driverRepository: IDriverRepository; diff --git a/adapters/bootstrap/racing/RacingDriverFactory.ts b/adapters/bootstrap/racing/RacingDriverFactory.ts index bbf479ea6..d5c2b7c71 100644 --- a/adapters/bootstrap/racing/RacingDriverFactory.ts +++ b/adapters/bootstrap/racing/RacingDriverFactory.ts @@ -62,7 +62,7 @@ export class RacingDriverFactory { } // Create system-default reference with avatar variant - return MediaReference.systemDefault(avatarVariant); + return MediaReference.createSystemDefault('avatar', avatarVariant); } create(): Driver[] { diff --git a/adapters/bootstrap/racing/RacingTeamFactory.ts b/adapters/bootstrap/racing/RacingTeamFactory.ts index 9cf6b7c70..e9d6b4973 100644 --- a/adapters/bootstrap/racing/RacingTeamFactory.ts +++ b/adapters/bootstrap/racing/RacingTeamFactory.ts @@ -48,7 +48,7 @@ export class RacingTeamFactory { leagues: teamLeagues, isRecruiting, createdAt: faker.date.past({ years: 2, refDate: this.baseDate }), - logoRef: MediaReference.generated('team', teamId), + logoRef: MediaReference.createGenerated(`team-${teamId}`), }); }); } diff --git a/adapters/eslint-rules/adapter-naming.js b/adapters/eslint-rules/adapter-naming.js index de83d6cb3..7968c5bab 100644 --- a/adapters/eslint-rules/adapter-naming.js +++ b/adapters/eslint-rules/adapter-naming.js @@ -9,7 +9,7 @@ module.exports = { fixable: null, schema: [], messages: { - invalidNaming: 'Adapter classes should end with "Adapter", "Repository", "Service", or "Entity". Found: {{name}}', + invalidNaming: 'Adapter classes should end with "Adapter", "Repository", "Service", "Factory" or "Entity". Found: {{name}}', }, }, @@ -20,7 +20,7 @@ module.exports = { if (!filename.includes('adapters/')) return; const name = node.id.name; - const isValidName = /(.+)(Adapter|Repository|Service|Entity|Mapper|Schema|Guard|Module|Controller)$/.test(name); + const isValidName = /(.+)(Adapter|Factory|Repository|Service|Entity|Mapper|Schema|Guard|Module|Controller)$/.test(name); if (!isValidName) { context.report({ diff --git a/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.test.ts b/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.test.ts index 2b7a1fc9d..c9a176e94 100644 --- a/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.test.ts +++ b/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.test.ts @@ -1,6 +1,6 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import type { UserAchievement } from '@core/identity'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryAchievementRepository } from './InMemoryAchievementRepository'; describe('InMemoryAchievementRepository (identity)', () => { diff --git a/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.ts b/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.ts index 1852e7238..abe2c922a 100644 --- a/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.ts +++ b/adapters/identity/persistence/inmemory/InMemoryAchievementRepository.ts @@ -4,12 +4,13 @@ * In-memory implementation of IAchievementRepository */ -import { Achievement, AchievementCategory, IAchievementRepository, UserAchievement } from "@core/identity"; +import { Achievement } from "@core/identity/domain/entities/Achievement"; +import { AchievementCategory } from "@core/identity/domain/types/AchievementTypes"; +import { AchievementRepository } from "@core/identity/domain/repositories/AchievementRepository"; +import { UserAchievement } from "@core/identity/domain/entities/UserAchievement"; import { ADMIN_ACHIEVEMENTS, COMMUNITY_ACHIEVEMENTS, DRIVER_ACHIEVEMENTS, STEWARD_ACHIEVEMENTS } from "@core/identity/domain/AchievementConstants"; import { Logger } from "@core/shared/domain"; - - export class InMemoryAchievementRepository implements AchievementRepository { private achievements: Map = new Map(); private userAchievements: Map = new Map(); @@ -282,4 +283,4 @@ export class InMemoryAchievementRepository implements AchievementRepository { this.userAchievements.clear(); this.logger.info('All achievement data cleared.'); } -} \ No newline at end of file +} diff --git a/adapters/identity/persistence/inmemory/InMemoryAuthRepository.test.ts b/adapters/identity/persistence/inmemory/InMemoryAuthRepository.test.ts index e760a8789..dd88cb2cd 100644 --- a/adapters/identity/persistence/inmemory/InMemoryAuthRepository.test.ts +++ b/adapters/identity/persistence/inmemory/InMemoryAuthRepository.test.ts @@ -1,10 +1,10 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; -import { UserId } from '@core/identity'; import { User } from '@core/identity/domain/entities/User'; -import { InMemoryUserRepository } from './InMemoryUserRepository'; -import { InMemoryAuthRepository } from './InMemoryAuthRepository'; +import { UserId } from '@core/identity/domain/value-objects/UserId'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryPasswordHashingService } from '../../services/InMemoryPasswordHashingService'; +import { InMemoryAuthRepository } from './InMemoryAuthRepository'; +import { InMemoryUserRepository } from './InMemoryUserRepository'; describe('InMemoryAuthRepository', () => { let mockLogger: Logger; diff --git a/adapters/identity/persistence/inmemory/InMemorySponsorAccountRepository.test.ts b/adapters/identity/persistence/inmemory/InMemorySponsorAccountRepository.test.ts index 6a7431f3d..0a6b6238b 100644 --- a/adapters/identity/persistence/inmemory/InMemorySponsorAccountRepository.test.ts +++ b/adapters/identity/persistence/inmemory/InMemorySponsorAccountRepository.test.ts @@ -1,6 +1,7 @@ +import type { SponsorAccount } from '@core/identity/domain/entities/SponsorAccount'; +import { UserId } from '@core/identity/domain/value-objects/UserId'; +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; -import { UserId, type SponsorAccount } from '@core/identity'; import { InMemorySponsorAccountRepository } from './InMemorySponsorAccountRepository'; describe('InMemorySponsorAccountRepository', () => { diff --git a/adapters/identity/persistence/inmemory/InMemoryUserRatingRepository.test.ts b/adapters/identity/persistence/inmemory/InMemoryUserRatingRepository.test.ts index e5eb3813a..47b5f7714 100644 --- a/adapters/identity/persistence/inmemory/InMemoryUserRatingRepository.test.ts +++ b/adapters/identity/persistence/inmemory/InMemoryUserRatingRepository.test.ts @@ -1,6 +1,6 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import type { UserRating } from '@core/identity'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryUserRatingRepository } from './InMemoryUserRatingRepository'; describe('InMemoryUserRatingRepository', () => { diff --git a/adapters/identity/persistence/inmemory/InMemoryUserRepository.test.ts b/adapters/identity/persistence/inmemory/InMemoryUserRepository.test.ts index 80e4cc69b..10dfe1a03 100644 --- a/adapters/identity/persistence/inmemory/InMemoryUserRepository.test.ts +++ b/adapters/identity/persistence/inmemory/InMemoryUserRepository.test.ts @@ -1,6 +1,6 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import type { StoredUser } from '@core/identity/domain/repositories/UserRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryUserRepository } from './InMemoryUserRepository'; describe('InMemoryUserRepository', () => { diff --git a/adapters/identity/session/CookieIdentitySessionAdapter.ts b/adapters/identity/session/CookieIdentitySessionAdapter.ts index 34b981291..6e5fd3f94 100644 --- a/adapters/identity/session/CookieIdentitySessionAdapter.ts +++ b/adapters/identity/session/CookieIdentitySessionAdapter.ts @@ -1,9 +1,9 @@ import { randomUUID } from 'node:crypto'; +import { tryGetHttpRequestContext } from '@adapters/http/RequestContext'; import type { AuthenticatedUser } from '@core/identity/application/ports/IdentityProviderPort'; import type { AuthSession, IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort'; -import type { Logger } from '@core/shared/domain'; -import { tryGetHttpRequestContext } from '@adapters/http/RequestContext'; +import type { Logger } from '@core/shared/domain/Logger'; const COOKIE_NAME = 'gp_session'; const SESSION_TTL_MS = 3600 * 1000; // 1 hour diff --git a/adapters/media/persistence/inmemory/InMemoryAvatarGenerationRepository.test.ts b/adapters/media/persistence/inmemory/InMemoryAvatarGenerationRepository.test.ts index 0d691cdb6..1ce737775 100644 --- a/adapters/media/persistence/inmemory/InMemoryAvatarGenerationRepository.test.ts +++ b/adapters/media/persistence/inmemory/InMemoryAvatarGenerationRepository.test.ts @@ -1,6 +1,6 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { AvatarGenerationRequest } from '@core/media/domain/entities/AvatarGenerationRequest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryAvatarGenerationRepository } from './InMemoryAvatarGenerationRepository'; describe('InMemoryAvatarGenerationRepository', () => { diff --git a/adapters/media/ports/InMemoryFaceValidationAdapter.test.ts b/adapters/media/ports/InMemoryFaceValidationAdapter.test.ts index 3330e1207..e22ce0108 100644 --- a/adapters/media/ports/InMemoryFaceValidationAdapter.test.ts +++ b/adapters/media/ports/InMemoryFaceValidationAdapter.test.ts @@ -1,5 +1,5 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { InMemoryFaceValidationAdapter } from './InMemoryFaceValidationAdapter'; describe('InMemoryFaceValidationAdapter', () => { diff --git a/adapters/media/ports/InMemoryFaceValidationAdapter.ts b/adapters/media/ports/InMemoryFaceValidationAdapter.ts index 0f73fe014..61eae89f4 100644 --- a/adapters/media/ports/InMemoryFaceValidationAdapter.ts +++ b/adapters/media/ports/InMemoryFaceValidationAdapter.ts @@ -1,5 +1,5 @@ import type { FaceValidationPort, FaceValidationResult } from '@core/media/application/ports/FaceValidationPort'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryFaceValidationAdapter implements FaceValidationPort { constructor(private readonly logger: Logger) { diff --git a/adapters/media/ports/InMemoryImageServiceAdapter.test.ts b/adapters/media/ports/InMemoryImageServiceAdapter.test.ts index ad00ad8ac..c48af52e1 100644 --- a/adapters/media/ports/InMemoryImageServiceAdapter.test.ts +++ b/adapters/media/ports/InMemoryImageServiceAdapter.test.ts @@ -1,5 +1,5 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { InMemoryImageServiceAdapter } from './InMemoryImageServiceAdapter'; describe('InMemoryImageServiceAdapter', () => { diff --git a/adapters/media/ports/InMemoryImageServiceAdapter.ts b/adapters/media/ports/InMemoryImageServiceAdapter.ts index d29170d34..9f20e8fe6 100644 --- a/adapters/media/ports/InMemoryImageServiceAdapter.ts +++ b/adapters/media/ports/InMemoryImageServiceAdapter.ts @@ -1,5 +1,5 @@ import type { ImageServicePort } from '@core/racing/application/ports/ImageServicePort'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryImageServiceAdapter implements ImageServicePort { constructor(private readonly logger: Logger) { diff --git a/adapters/notifications/persistence/inmemory/InMemoryNotificationPreferenceRepository.test.ts b/adapters/notifications/persistence/inmemory/InMemoryNotificationPreferenceRepository.test.ts index 5276b5b1f..58f79efb6 100644 --- a/adapters/notifications/persistence/inmemory/InMemoryNotificationPreferenceRepository.test.ts +++ b/adapters/notifications/persistence/inmemory/InMemoryNotificationPreferenceRepository.test.ts @@ -1,6 +1,6 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { NotificationPreference } from '@core/notifications/domain/entities/NotificationPreference'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryNotificationPreferenceRepository } from './InMemoryNotificationPreferenceRepository'; describe('InMemoryNotificationPreferenceRepository', () => { diff --git a/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.test.ts b/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.test.ts index 03a8044f1..22ca9a0b9 100644 --- a/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.test.ts +++ b/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.test.ts @@ -1,6 +1,6 @@ -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { Notification } from '@core/notifications/domain/entities/Notification'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryNotificationRepository } from './InMemoryNotificationRepository'; describe('InMemoryNotificationRepository', () => { diff --git a/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.ts b/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.ts index 5ce7ceea5..b5769dfc0 100644 --- a/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.ts +++ b/adapters/notifications/persistence/inmemory/InMemoryNotificationRepository.ts @@ -7,7 +7,7 @@ import { Notification } from '@core/notifications/domain/entities/Notification'; import type { NotificationRepository } from '@core/notifications/domain/repositories/NotificationRepository'; import type { NotificationType } from '@core/notifications/domain/types/NotificationTypes'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryNotificationRepository implements NotificationRepository { private notifications: Map = new Map(); diff --git a/adapters/notifications/ports/NotificationServiceAdapter.ts b/adapters/notifications/ports/NotificationServiceAdapter.ts index 0c0176760..d105e96cc 100644 --- a/adapters/notifications/ports/NotificationServiceAdapter.ts +++ b/adapters/notifications/ports/NotificationServiceAdapter.ts @@ -1,9 +1,7 @@ -import type { NotificationService, SendNotificationCommand } from '@core/notifications/application/ports/NotificationService'; -import type { NotificationRepository } from '@core/notifications/domain/repositories/NotificationRepository'; -import type { NotificationPreferenceRepository } from '@core/notifications/domain/repositories/NotificationPreferenceRepository'; import type { NotificationGatewayRegistry } from '@core/notifications/application/ports/NotificationGateway'; +import type { NotificationService, SendNotificationCommand } from '@core/notifications/application/ports/NotificationService'; import { SendNotificationUseCase } from '@core/notifications/application/use-cases/SendNotificationUseCase'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class NotificationServiceAdapter implements NotificationService { private readonly useCase: SendNotificationUseCase; diff --git a/adapters/racing/persistence/inmemory/InMemoryCarRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryCarRepository.test.ts index 9185374d7..84dedb05e 100644 --- a/adapters/racing/persistence/inmemory/InMemoryCarRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryCarRepository.test.ts @@ -1,9 +1,9 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryCarRepository } from './InMemoryCarRepository'; import { Car } from '@core/racing/domain/entities/Car'; import { CarClass } from '@core/racing/domain/entities/CarClass'; import { CarLicense } from '@core/racing/domain/entities/CarLicense'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryCarRepository } from './InMemoryCarRepository'; describe('InMemoryCarRepository', () => { let repository: InMemoryCarRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryCarRepository.ts b/adapters/racing/persistence/inmemory/InMemoryCarRepository.ts index 20894e203..9ccaeaa51 100644 --- a/adapters/racing/persistence/inmemory/InMemoryCarRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryCarRepository.ts @@ -5,12 +5,12 @@ * Stores data in Map structure with UUID generation. */ -import { v4 as uuidv4 } from 'uuid'; import { Car } from '@core/racing/domain/entities/Car'; import { CarClass } from '@core/racing/domain/entities/CarClass'; import { CarLicense } from '@core/racing/domain/entities/CarLicense'; import type { CarRepository } from '@core/racing/domain/repositories/CarRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { v4 as uuidv4 } from 'uuid'; export class InMemoryCarRepository implements CarRepository { private cars: Map; diff --git a/adapters/racing/persistence/inmemory/InMemoryDriverRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryDriverRepository.test.ts index 444536a96..f28b05523 100644 --- a/adapters/racing/persistence/inmemory/InMemoryDriverRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryDriverRepository.test.ts @@ -1,8 +1,8 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryDriverRepository } from './InMemoryDriverRepository'; -import { Driver } from '@core/racing/domain/entities/Driver'; -import type { Logger } from '@core/shared/domain'; import { MediaReference } from '@core/domain/media/MediaReference'; +import { Driver } from '@core/racing/domain/entities/Driver'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryDriverRepository } from './InMemoryDriverRepository'; describe('InMemoryDriverRepository', () => { let repository: InMemoryDriverRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryDriverStatsRepository.ts b/adapters/racing/persistence/inmemory/InMemoryDriverStatsRepository.ts index 98def84d5..f0fd3a4d3 100644 --- a/adapters/racing/persistence/inmemory/InMemoryDriverStatsRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryDriverStatsRepository.ts @@ -5,9 +5,9 @@ * Stores computed driver statistics for caching and frontend queries. */ -import type { DriverStatsRepository } from '@core/racing/domain/repositories/DriverStatsRepository'; import type { DriverStats } from '@core/racing/application/use-cases/DriverStatsUseCase'; -import type { Logger } from '@core/shared/domain'; +import type { DriverStatsRepository } from '@core/racing/domain/repositories/DriverStatsRepository'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryDriverStatsRepository implements DriverStatsRepository { private stats = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemoryGameRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryGameRepository.test.ts index b418f7327..71b39ad34 100644 --- a/adapters/racing/persistence/inmemory/InMemoryGameRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryGameRepository.test.ts @@ -1,6 +1,6 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryGameRepository } from './InMemoryGameRepository'; -import type { Logger } from '@core/shared/domain'; describe('InMemoryGameRepository', () => { let repository: InMemoryGameRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryLeagueMembershipRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryLeagueMembershipRepository.test.ts index f71cb90c2..22f3a0cf4 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLeagueMembershipRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLeagueMembershipRepository.test.ts @@ -1,5 +1,5 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { InMemoryLeagueMembershipRepository } from './InMemoryLeagueMembershipRepository'; describe('InMemoryLeagueMembershipRepository', () => { diff --git a/adapters/racing/persistence/inmemory/InMemoryLeagueRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryLeagueRepository.test.ts index 23d186095..0736a9e34 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLeagueRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLeagueRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryLeagueRepository } from './InMemoryLeagueRepository'; import { League } from '@core/racing/domain/entities/League'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryLeagueRepository } from './InMemoryLeagueRepository'; describe('InMemoryLeagueRepository', () => { let repository: InMemoryLeagueRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryLeagueScoringConfigRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryLeagueScoringConfigRepository.test.ts index 386726251..25f3effb9 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLeagueScoringConfigRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLeagueScoringConfigRepository.test.ts @@ -1,9 +1,9 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryLeagueScoringConfigRepository } from './InMemoryLeagueScoringConfigRepository'; import { LeagueScoringConfig, type LeagueScoringConfigProps } from '@core/racing/domain/entities/LeagueScoringConfig'; import type { ChampionshipConfig } from '@core/racing/domain/types/ChampionshipConfig'; import { PointsTable } from '@core/racing/domain/value-objects/PointsTable'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryLeagueScoringConfigRepository } from './InMemoryLeagueScoringConfigRepository'; const mockPointsTable = new PointsTable({ 1: 25, 2: 18, 3: 15 }); diff --git a/adapters/racing/persistence/inmemory/InMemoryLeagueStandingsRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryLeagueStandingsRepository.test.ts index 4ff72a5c8..71ddb2b36 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLeagueStandingsRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLeagueStandingsRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryLeagueStandingsRepository } from './InMemoryLeagueStandingsRepository'; -import type { Logger } from '@core/shared/domain'; import type { RawStanding } from '@core/league/application/ports/LeagueStandingsRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryLeagueStandingsRepository } from './InMemoryLeagueStandingsRepository'; describe('InMemoryLeagueStandingsRepository', () => { let repository: InMemoryLeagueStandingsRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.test.ts index 2de91ee18..7fdd3e2b4 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.test.ts @@ -1,8 +1,8 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryLeagueWalletRepository } from './InMemoryLeagueWalletRepository'; import { LeagueWallet } from '@core/racing/domain/entities/league-wallet/LeagueWallet'; import { Money } from '@core/racing/domain/value-objects/Money'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryLeagueWalletRepository } from './InMemoryLeagueWalletRepository'; describe('InMemoryLeagueWalletRepository', () => { let repository: InMemoryLeagueWalletRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.ts b/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.ts index 139bc8dbf..81606c79c 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLeagueWalletRepository.ts @@ -6,7 +6,7 @@ import { LeagueWallet } from '@core/racing/domain/entities/league-wallet/LeagueWallet'; import type { LeagueWalletRepository } from '@core/racing/domain/repositories/LeagueWalletRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryLeagueWalletRepository implements LeagueWalletRepository { private wallets: Map = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.test.ts index 28cfce3ff..b81e732f5 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.test.ts @@ -1,9 +1,9 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryLiveryRepository } from './InMemoryLiveryRepository'; import { DriverLivery } from '@core/racing/domain/entities/DriverLivery'; import { LiveryTemplate } from '@core/racing/domain/entities/LiveryTemplate'; import { LiveryDecal } from '@core/racing/domain/value-objects/LiveryDecal'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryLiveryRepository } from './InMemoryLiveryRepository'; describe('InMemoryLiveryRepository', () => { let repository: InMemoryLiveryRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.ts b/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.ts index 12e963611..39d35990a 100644 --- a/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryLiveryRepository.ts @@ -4,10 +4,10 @@ * Mock repository for testing and development */ +import type { Logger } from '@core/shared/domain/Logger'; import type { DriverLivery } from '../../../../core/racing/domain/entities/DriverLivery'; import type { LiveryTemplate } from '../../../../core/racing/domain/entities/LiveryTemplate'; import type { LiveryRepository } from '../../../../core/racing/domain/repositories/LiveryRepository'; -import type { Logger } from '@core/shared/domain'; export class InMemoryLiveryRepository implements LiveryRepository { private driverLiveries: Map = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.test.ts index a89193409..fd4da0f0d 100644 --- a/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryPenaltyRepository } from './InMemoryPenaltyRepository'; import { Penalty } from '@core/racing/domain/entities/penalty/Penalty'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryPenaltyRepository } from './InMemoryPenaltyRepository'; describe('InMemoryPenaltyRepository', () => { let repository: InMemoryPenaltyRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.ts b/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.ts index 5ade0137e..65d8f200a 100644 --- a/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryPenaltyRepository.ts @@ -6,7 +6,7 @@ import type { Penalty } from '@core/racing/domain/entities/penalty/Penalty'; import type { PenaltyRepository } from '@core/racing/domain/repositories/PenaltyRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryPenaltyRepository implements PenaltyRepository { private penalties: Map = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemoryProtestRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryProtestRepository.test.ts index 8f3c8f8d4..5d2bb4afa 100644 --- a/adapters/racing/persistence/inmemory/InMemoryProtestRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryProtestRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryProtestRepository } from './InMemoryProtestRepository'; import { Protest } from '@core/racing/domain/entities/Protest'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryProtestRepository } from './InMemoryProtestRepository'; describe('InMemoryProtestRepository', () => { let repository: InMemoryProtestRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.test.ts index f02d43b27..fa74dede6 100644 --- a/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.test.ts @@ -1,9 +1,9 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryRaceEventRepository } from './InMemoryRaceEventRepository'; import { RaceEvent } from '@core/racing/domain/entities/RaceEvent'; import { Session } from '@core/racing/domain/entities/Session'; import { SessionType } from '@core/racing/domain/value-objects/SessionType'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryRaceEventRepository } from './InMemoryRaceEventRepository'; describe('InMemoryRaceEventRepository', () => { let repository: InMemoryRaceEventRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.ts b/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.ts index 5c5a79a2f..d6638b552 100644 --- a/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryRaceEventRepository.ts @@ -1,9 +1,9 @@ /** * In-memory implementation of IRaceEventRepository for development/testing. */ -import type { RaceEventRepository } from '@core/racing/domain/repositories/RaceEventRepository'; import type { RaceEvent } from '@core/racing/domain/entities/RaceEvent'; -import type { Logger } from '@core/shared/domain'; +import type { RaceEventRepository } from '@core/racing/domain/repositories/RaceEventRepository'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryRaceEventRepository implements RaceEventRepository { private raceEvents: Map = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository.test.ts index f14362290..b5b47f414 100644 --- a/adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryRaceRegistrationRepository } from './InMemoryRaceRegistrationRepository'; import { RaceRegistration } from '@core/racing/domain/entities/RaceRegistration'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryRaceRegistrationRepository } from './InMemoryRaceRegistrationRepository'; describe('InMemoryRaceRegistrationRepository', () => { let repository: InMemoryRaceRegistrationRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryRaceRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryRaceRepository.test.ts index fca5595d9..7c02b5645 100644 --- a/adapters/racing/persistence/inmemory/InMemoryRaceRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryRaceRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryRaceRepository } from './InMemoryRaceRepository'; import { Race, type RaceStatusValue } from '@core/racing/domain/entities/Race'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryRaceRepository } from './InMemoryRaceRepository'; describe('InMemoryRaceRepository', () => { let repository: InMemoryRaceRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryResultRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryResultRepository.test.ts index 725935283..2b31f1e77 100644 --- a/adapters/racing/persistence/inmemory/InMemoryResultRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryResultRepository.test.ts @@ -1,8 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryResultRepository } from './InMemoryResultRepository'; import { Result } from '@core/racing/domain/entities/result/Result'; -import type { Logger } from '@core/shared/domain'; -import type { RaceRepository } from '@core/racing/domain/repositories/RaceRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryResultRepository } from './InMemoryResultRepository'; describe('InMemoryResultRepository', () => { let repository: InMemoryResultRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryResultRepository.ts b/adapters/racing/persistence/inmemory/InMemoryResultRepository.ts index 616abcd0a..c3b83cfd9 100644 --- a/adapters/racing/persistence/inmemory/InMemoryResultRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryResultRepository.ts @@ -5,11 +5,10 @@ * Stores data in Map structure with UUID generation. */ -import { v4 as uuidv4 } from 'uuid'; import { Result } from '@core/racing/domain/entities/result/Result'; import type { ResultRepository } from '@core/racing/domain/repositories/ResultRepository'; -import type { RaceRepository } from '@core/racing/domain/repositories/RaceRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { v4 as uuidv4 } from 'uuid'; export class InMemoryResultRepository implements ResultRepository { private results: Map; diff --git a/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.test.ts b/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.test.ts index 136900b66..124524609 100644 --- a/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.test.ts @@ -1,15 +1,15 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { - InMemoryGameRepository, - InMemorySeasonRepository, - InMemoryLeagueScoringConfigRepository, - InMemoryChampionshipStandingRepository, -} from './InMemoryScoringRepositories'; import { Game } from '@core/racing/domain/entities/Game'; -import { Season } from '@core/racing/domain/entities/season/Season'; import { LeagueScoringConfig } from '@core/racing/domain/entities/LeagueScoringConfig'; import { ChampionshipStanding } from '@core/racing/domain/entities/championship/ChampionshipStanding'; -import type { Logger } from '@core/shared/domain'; +import { Season } from '@core/racing/domain/entities/season/Season'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { + InMemoryChampionshipStandingRepository, + InMemoryGameRepository, + InMemoryLeagueScoringConfigRepository, + InMemorySeasonRepository, +} from './InMemoryScoringRepositories'; describe('InMemoryScoringRepositories', () => { let mockLogger: Logger; diff --git a/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.ts b/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.ts index 532506b61..1cf498aa7 100644 --- a/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.ts +++ b/adapters/racing/persistence/inmemory/InMemoryScoringRepositories.ts @@ -1,12 +1,12 @@ -import { Game } from '@core/racing/domain/entities/Game'; -import { Season } from '@core/racing/domain/entities/season/Season'; -import type { LeagueScoringConfig } from '@core/racing/domain/entities/LeagueScoringConfig'; -import type { GameRepository } from '@core/racing/domain/repositories/GameRepository'; -import type { SeasonRepository } from '@core/racing/domain/repositories/SeasonRepository'; -import type { LeagueScoringConfigRepository } from '@core/racing/domain/repositories/LeagueScoringConfigRepository'; -import type { ChampionshipStandingRepository } from '@core/racing/domain/repositories/ChampionshipStandingRepository'; import { ChampionshipStanding } from '@core/racing/domain/entities/championship/ChampionshipStanding'; -import type { Logger } from '@core/shared/domain'; +import { Game } from '@core/racing/domain/entities/Game'; +import type { LeagueScoringConfig } from '@core/racing/domain/entities/LeagueScoringConfig'; +import { Season } from '@core/racing/domain/entities/season/Season'; +import type { ChampionshipStandingRepository } from '@core/racing/domain/repositories/ChampionshipStandingRepository'; +import type { GameRepository } from '@core/racing/domain/repositories/GameRepository'; +import type { LeagueScoringConfigRepository } from '@core/racing/domain/repositories/LeagueScoringConfigRepository'; +import type { SeasonRepository } from '@core/racing/domain/repositories/SeasonRepository'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryGameRepository implements GameRepository { diff --git a/adapters/racing/persistence/inmemory/InMemorySeasonRepository.test.ts b/adapters/racing/persistence/inmemory/InMemorySeasonRepository.test.ts index 3330e7f2e..a18c0433d 100644 --- a/adapters/racing/persistence/inmemory/InMemorySeasonRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemorySeasonRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemorySeasonRepository } from './InMemorySeasonRepository'; import { Season } from '@core/racing/domain/entities/season/Season'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemorySeasonRepository } from './InMemorySeasonRepository'; describe('InMemorySeasonRepository', () => { let repository: InMemorySeasonRepository; diff --git a/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.test.ts b/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.test.ts index d9564ae17..418bf0b78 100644 --- a/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.test.ts @@ -1,8 +1,8 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemorySeasonSponsorshipRepository } from './InMemorySeasonSponsorshipRepository'; import { SeasonSponsorship, type SponsorshipTier } from '@core/racing/domain/entities/season/SeasonSponsorship'; import { Money } from '@core/racing/domain/value-objects/Money'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemorySeasonSponsorshipRepository } from './InMemorySeasonSponsorshipRepository'; describe('InMemorySeasonSponsorshipRepository', () => { let repository: InMemorySeasonSponsorshipRepository; diff --git a/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.ts b/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.ts index 03724513c..a3d9620db 100644 --- a/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository.ts @@ -6,7 +6,7 @@ import type { SeasonSponsorship, SponsorshipTier } from '@core/racing/domain/entities/season/SeasonSponsorship'; import type { SeasonSponsorshipRepository } from '@core/racing/domain/repositories/SeasonSponsorshipRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemorySeasonSponsorshipRepository implements SeasonSponsorshipRepository { private sponsorships: Map = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemorySessionRepository.test.ts b/adapters/racing/persistence/inmemory/InMemorySessionRepository.test.ts index 80f0cfb53..878a8abe2 100644 --- a/adapters/racing/persistence/inmemory/InMemorySessionRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemorySessionRepository.test.ts @@ -1,8 +1,8 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemorySessionRepository } from './InMemorySessionRepository'; import { Session, SessionStatus } from '@core/racing/domain/entities/Session'; import { SessionType } from '@core/racing/domain/value-objects/SessionType'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemorySessionRepository } from './InMemorySessionRepository'; describe('InMemorySessionRepository', () => { let repository: InMemorySessionRepository; diff --git a/adapters/racing/persistence/inmemory/InMemorySessionRepository.ts b/adapters/racing/persistence/inmemory/InMemorySessionRepository.ts index 0bd4fc795..4b079a69c 100644 --- a/adapters/racing/persistence/inmemory/InMemorySessionRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemorySessionRepository.ts @@ -1,9 +1,9 @@ /** * In-memory implementation of ISessionRepository for development/testing. */ -import type { SessionRepository } from '@core/racing/domain/repositories/SessionRepository'; import type { Session } from '@core/racing/domain/entities/Session'; -import type { Logger } from '@core/shared/domain'; +import type { SessionRepository } from '@core/racing/domain/repositories/SessionRepository'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemorySessionRepository implements SessionRepository { private sessions: Map = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemorySponsorRepository.test.ts b/adapters/racing/persistence/inmemory/InMemorySponsorRepository.test.ts index 86cab9895..8c7aec36d 100644 --- a/adapters/racing/persistence/inmemory/InMemorySponsorRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemorySponsorRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemorySponsorRepository } from './InMemorySponsorRepository'; import { Sponsor } from '@core/racing/domain/entities/sponsor/Sponsor'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemorySponsorRepository } from './InMemorySponsorRepository'; describe('InMemorySponsorRepository', () => { let repository: InMemorySponsorRepository; diff --git a/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.test.ts b/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.test.ts index 516c672fe..b65a6b081 100644 --- a/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemorySponsorshipPricingRepository } from './InMemorySponsorshipPricingRepository'; import { SponsorshipPricing } from '@core/racing/domain/value-objects/SponsorshipPricing'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemorySponsorshipPricingRepository } from './InMemorySponsorshipPricingRepository'; describe('InMemorySponsorshipPricingRepository', () => { let repository: InMemorySponsorshipPricingRepository; diff --git a/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.ts b/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.ts index 9ae1e5b77..95851ea0b 100644 --- a/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemorySponsorshipPricingRepository.ts @@ -2,10 +2,10 @@ * InMemory implementation of ISponsorshipPricingRepository */ +import type { SponsorableEntityType } from '@core/racing/domain/entities/SponsorshipRequest'; import type { SponsorshipPricingRepository } from '@core/racing/domain/repositories/SponsorshipPricingRepository'; import { SponsorshipPricing } from '@core/racing/domain/value-objects/SponsorshipPricing'; -import type { SponsorableEntityType } from '@core/racing/domain/entities/SponsorshipRequest'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemorySponsorshipPricingRepository implements SponsorshipPricingRepository { private pricings: Map = new Map(); diff --git a/adapters/racing/persistence/inmemory/InMemorySponsorshipRequestRepository.test.ts b/adapters/racing/persistence/inmemory/InMemorySponsorshipRequestRepository.test.ts index 134923025..6b837f2c9 100644 --- a/adapters/racing/persistence/inmemory/InMemorySponsorshipRequestRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemorySponsorshipRequestRepository.test.ts @@ -1,9 +1,9 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemorySponsorshipRequestRepository } from './InMemorySponsorshipRequestRepository'; -import { SponsorshipRequest, SponsorableEntityType, SponsorshipRequestStatus } from '@core/racing/domain/entities/SponsorshipRequest'; -import { Money } from '@core/racing/domain/value-objects/Money'; import { SponsorshipTier } from '@core/racing/domain/entities/season/SeasonSponsorship'; -import type { Logger } from '@core/shared/domain'; +import { SponsorableEntityType, SponsorshipRequest, SponsorshipRequestStatus } from '@core/racing/domain/entities/SponsorshipRequest'; +import { Money } from '@core/racing/domain/value-objects/Money'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemorySponsorshipRequestRepository } from './InMemorySponsorshipRequestRepository'; describe('InMemorySponsorshipRequestRepository', () => { let repository: InMemorySponsorshipRequestRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryStandingRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryStandingRepository.test.ts index 8906e2ad0..171588a1a 100644 --- a/adapters/racing/persistence/inmemory/InMemoryStandingRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryStandingRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryStandingRepository } from './InMemoryStandingRepository'; import { Standing } from '@core/racing/domain/entities/Standing'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryStandingRepository } from './InMemoryStandingRepository'; /* eslint-disable @typescript-eslint/no-explicit-any */ diff --git a/adapters/racing/persistence/inmemory/InMemoryStandingRepository.ts b/adapters/racing/persistence/inmemory/InMemoryStandingRepository.ts index 09c68242d..610b1464c 100644 --- a/adapters/racing/persistence/inmemory/InMemoryStandingRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryStandingRepository.ts @@ -7,10 +7,7 @@ import { Standing } from '@core/racing/domain/entities/Standing'; import type { StandingRepository } from '@core/racing/domain/repositories/StandingRepository'; -import type { ResultRepository } from '@core/racing/domain/repositories/ResultRepository'; -import type { RaceRepository } from '@core/racing/domain/repositories/RaceRepository'; -import type { LeagueRepository } from '@core/racing/domain/repositories/LeagueRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryStandingRepository implements StandingRepository { private standings: Map; diff --git a/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.test.ts index d50030a2b..dfd977e9f 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; +import type { TeamJoinRequest, TeamMembership } from '@core/racing/domain/types/TeamMembership'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { InMemoryTeamMembershipRepository } from './InMemoryTeamMembershipRepository'; -import type { TeamMembership, TeamJoinRequest } from '@core/racing/domain/types/TeamMembership'; -import type { Logger } from '@core/shared/domain'; /* eslint-disable @typescript-eslint/no-explicit-any */ diff --git a/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.ts b/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.ts index a699749ef..aa70a5b29 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTeamMembershipRepository.ts @@ -5,12 +5,12 @@ * Stores memberships and join requests in Map structures. */ -import type { - TeamMembership, - TeamJoinRequest, -} from '@core/racing/domain/types/TeamMembership'; import type { TeamMembershipRepository } from '@core/racing/domain/repositories/TeamMembershipRepository'; -import type { Logger } from '@core/shared/domain'; +import type { + TeamJoinRequest, + TeamMembership, +} from '@core/racing/domain/types/TeamMembership'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryTeamMembershipRepository implements TeamMembershipRepository { private membershipsByTeam: Map; diff --git a/adapters/racing/persistence/inmemory/InMemoryTeamRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryTeamRepository.test.ts index 10e9debcd..ae67fcd4b 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTeamRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTeamRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryTeamRepository } from './InMemoryTeamRepository'; -import type { Logger } from '@core/shared/domain'; import { Team } from '@core/racing/domain/entities/Team'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryTeamRepository } from './InMemoryTeamRepository'; describe('InMemoryTeamRepository', () => { let repository: InMemoryTeamRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryTeamRepository.ts b/adapters/racing/persistence/inmemory/InMemoryTeamRepository.ts index 57827ff2e..dde70c0b9 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTeamRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTeamRepository.ts @@ -5,10 +5,10 @@ * Stores data in a Map structure. */ +import { MediaReference } from '@core/domain/media/MediaReference'; import { Team } from '@core/racing/domain/entities/Team'; import type { TeamRepository } from '@core/racing/domain/repositories/TeamRepository'; -import type { Logger } from '@core/shared/domain'; -import { MediaReference } from '@core/domain/media/MediaReference'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryTeamRepository implements TeamRepository { private teams: Map; diff --git a/adapters/racing/persistence/inmemory/InMemoryTrackRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryTrackRepository.test.ts index 3c1d7467f..5dd273280 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTrackRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTrackRepository.test.ts @@ -1,7 +1,7 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryTrackRepository } from './InMemoryTrackRepository'; -import type { Logger } from '@core/shared/domain'; import { Track } from '@core/racing/domain/entities/Track'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryTrackRepository } from './InMemoryTrackRepository'; describe('InMemoryTrackRepository', () => { let repository: InMemoryTrackRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryTrackRepository.ts b/adapters/racing/persistence/inmemory/InMemoryTrackRepository.ts index 8ed118e22..b76689c99 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTrackRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTrackRepository.ts @@ -5,10 +5,10 @@ * Stores data in Map structure with UUID generation. */ -import { v4 as uuidv4 } from 'uuid'; import { Track, TrackCategory } from '@core/racing/domain/entities/Track'; import type { TrackRepository } from '@core/racing/domain/repositories/TrackRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { v4 as uuidv4 } from 'uuid'; export class InMemoryTrackRepository implements TrackRepository { private tracks: Map; diff --git a/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.test.ts b/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.test.ts index ba56f2ce3..7fca922cf 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.test.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.test.ts @@ -1,10 +1,10 @@ -import { vi, describe, it, expect, beforeEach } from 'vitest'; -import { InMemoryTransactionRepository } from './InMemoryTransactionRepository'; +import { LeagueWalletId } from '@core/racing/domain/entities/league-wallet/LeagueWalletId'; import { Transaction, TransactionType } from '@core/racing/domain/entities/league-wallet/Transaction'; import { TransactionId } from '@core/racing/domain/entities/league-wallet/TransactionId'; -import { LeagueWalletId } from '@core/racing/domain/entities/league-wallet/LeagueWalletId'; import { Money } from '@core/racing/domain/value-objects/Money'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { InMemoryTransactionRepository } from './InMemoryTransactionRepository'; describe('InMemoryTransactionRepository', () => { let repository: InMemoryTransactionRepository; diff --git a/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.ts b/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.ts index b1c335b15..b2fe972bc 100644 --- a/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.ts +++ b/adapters/racing/persistence/inmemory/InMemoryTransactionRepository.ts @@ -6,7 +6,7 @@ import type { Transaction, TransactionType } from '@core/racing/domain/entities/league-wallet/Transaction'; import type { TransactionRepository } from '@core/racing/domain/repositories/TransactionRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryTransactionRepository implements TransactionRepository { private transactions: Map = new Map(); diff --git a/adapters/racing/persistence/media/InMemoryMediaRepository.ts b/adapters/racing/persistence/media/InMemoryMediaRepository.ts index 3e8d6d1e3..7d3fd1212 100644 --- a/adapters/racing/persistence/media/InMemoryMediaRepository.ts +++ b/adapters/racing/persistence/media/InMemoryMediaRepository.ts @@ -6,7 +6,7 @@ */ import type { MediaRepository } from '@core/racing/domain/repositories/MediaRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; export class InMemoryMediaRepository implements MediaRepository { private driverAvatars = new Map(); diff --git a/adapters/racing/persistence/typeorm/repositories/TeamTypeOrmRepositories.test.ts b/adapters/racing/persistence/typeorm/repositories/TeamTypeOrmRepositories.test.ts index 172d85320..8308bd13b 100644 --- a/adapters/racing/persistence/typeorm/repositories/TeamTypeOrmRepositories.test.ts +++ b/adapters/racing/persistence/typeorm/repositories/TeamTypeOrmRepositories.test.ts @@ -22,9 +22,9 @@ describe('TypeOrmTeamRepository', () => { const teamRepo = new TypeOrmTeamRepository(repo as any, mapper as any); - const team = await teamRepo.findById('team-1'); + const team = await teamRepo.findById('550e8400-e29b-41d4-a716-446655440000'); - expect(repo.findOne).toHaveBeenCalledWith({ where: { id: 'team-1' } }); + expect(repo.findOne).toHaveBeenCalledWith({ where: { id: '550e8400-e29b-41d4-a716-446655440000' } }); expect(mapper.toDomain).toHaveBeenCalledWith(ormEntity); expect(team).toEqual({ id: 'domain-team' }); }); diff --git a/adapters/racing/persistence/typeorm/repositories/TypeOrmDriverRepository.test.ts b/adapters/racing/persistence/typeorm/repositories/TypeOrmDriverRepository.test.ts index 7a3b47796..2069cede5 100644 --- a/adapters/racing/persistence/typeorm/repositories/TypeOrmDriverRepository.test.ts +++ b/adapters/racing/persistence/typeorm/repositories/TypeOrmDriverRepository.test.ts @@ -33,31 +33,20 @@ describe('TypeOrmDriverRepository', () => { const repo = new TypeOrmDriverRepository(dataSource, mapper); - await expect(repo.findById('driver-1')).resolves.toBeNull(); + await expect(repo.findById('00000000-0000-0000-0000-000000000001')).resolves.toBeNull(); }); it('persists and retrieves driver with avatarRef (roundtrip test)', async () => { + const driverId = '00000000-0000-0000-0000-000000000123'; // Create a driver with a specific avatar reference const driver = Driver.create({ - id: 'driver-123', + id: driverId, iracingId: '456789', name: 'Test Driver', country: 'US', avatarRef: MediaReference.createUploaded('media-abc-123'), }); - // Mock entity that would be saved - const mockEntity = { - id: 'driver-123', - iracingId: '456789', - name: 'Test Driver', - country: 'US', - bio: null, - joinedAt: driver.joinedAt.toDate(), - category: null, - avatarRef: { type: 'uploaded', mediaId: 'media-abc-123' }, - }; - const savedEntities: any[] = []; const repo = { @@ -82,32 +71,22 @@ describe('TypeOrmDriverRepository', () => { expect(savedEntities[0].avatarRef).toEqual({ type: 'uploaded', mediaId: 'media-abc-123' }); // Test load - const loaded = await typeOrmRepo.findById('driver-123'); + const loaded = await typeOrmRepo.findById(driverId); expect(loaded).not.toBeNull(); expect(loaded!.avatarRef.type).toBe('uploaded'); expect(loaded!.avatarRef.mediaId).toBe('media-abc-123'); }); it('handles system-default avatarRef correctly', async () => { + const driverId = '00000000-0000-0000-0000-000000000456'; const driver = Driver.create({ - id: 'driver-456', + id: driverId, iracingId: '98765', name: 'Default Driver', country: 'UK', avatarRef: MediaReference.createSystemDefault('avatar'), }); - const mockEntity = { - id: 'driver-456', - iracingId: '98765', - name: 'Default Driver', - country: 'UK', - bio: null, - joinedAt: driver.joinedAt.toDate(), - category: null, - avatarRef: { type: 'system-default', variant: 'avatar' }, - }; - const savedEntities: any[] = []; const repo = { @@ -129,31 +108,22 @@ describe('TypeOrmDriverRepository', () => { expect(savedEntities[0].avatarRef).toEqual({ type: 'system-default', variant: 'avatar' }); - const loaded = await typeOrmRepo.findById('driver-456'); + const loaded = await typeOrmRepo.findById(driverId); + expect(loaded).not.toBeNull(); expect(loaded!.avatarRef.type).toBe('system-default'); expect(loaded!.avatarRef.variant).toBe('avatar'); }); it('handles generated avatarRef correctly', async () => { + const driverId = '00000000-0000-0000-0000-000000000789'; const driver = Driver.create({ - id: 'driver-789', + id: driverId, iracingId: '11111', name: 'Generated Driver', country: 'DE', avatarRef: MediaReference.createGenerated('gen-req-xyz'), }); - const mockEntity = { - id: 'driver-789', - iracingId: '11111', - name: 'Generated Driver', - country: 'DE', - bio: null, - joinedAt: driver.joinedAt.toDate(), - category: null, - avatarRef: { type: 'generated', generationRequestId: 'gen-req-xyz' }, - }; - const savedEntities: any[] = []; const repo = { @@ -175,14 +145,16 @@ describe('TypeOrmDriverRepository', () => { expect(savedEntities[0].avatarRef).toEqual({ type: 'generated', generationRequestId: 'gen-req-xyz' }); - const loaded = await typeOrmRepo.findById('driver-789'); + const loaded = await typeOrmRepo.findById(driverId); + expect(loaded).not.toBeNull(); expect(loaded!.avatarRef.type).toBe('generated'); expect(loaded!.avatarRef.generationRequestId).toBe('gen-req-xyz'); }); it('handles update with changed avatarRef', async () => { + const driverId = '00000000-0000-0000-0000-000000000000'; const driver = Driver.create({ - id: 'driver-update', + id: driverId, iracingId: '22222', name: 'Update Driver', country: 'FR', @@ -220,8 +192,9 @@ describe('TypeOrmDriverRepository', () => { expect(savedEntities).toHaveLength(2); expect(savedEntities[1].avatarRef).toEqual({ type: 'uploaded', mediaId: 'new-media-id' }); - const loaded = await typeOrmRepo.findById('driver-update'); + const loaded = await typeOrmRepo.findById(driverId); + expect(loaded).not.toBeNull(); expect(loaded!.avatarRef.type).toBe('uploaded'); expect(loaded!.avatarRef.mediaId).toBe('new-media-id'); }); -}); \ No newline at end of file +}); diff --git a/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.test.ts b/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.test.ts index 1541d53a3..de2991e13 100644 --- a/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.test.ts +++ b/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.test.ts @@ -1,5 +1,5 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { InMemoryDriverExtendedProfileProvider } from './InMemoryDriverExtendedProfileProvider'; describe('InMemoryDriverExtendedProfileProvider', () => { diff --git a/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.ts b/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.ts index 4ba7ca3eb..560e5a652 100644 --- a/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.ts +++ b/adapters/racing/ports/InMemoryDriverExtendedProfileProvider.ts @@ -1,5 +1,5 @@ import type { DriverExtendedProfileProvider } from '@core/racing/application/ports/DriverExtendedProfileProvider'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; // TODO Provider doesnt exist in Clean Architecture // TODO Hardcoded data here must be moved to a better place diff --git a/adapters/racing/ports/InMemoryDriverRatingProvider.test.ts b/adapters/racing/ports/InMemoryDriverRatingProvider.test.ts index ed9a83368..010742c2e 100644 --- a/adapters/racing/ports/InMemoryDriverRatingProvider.test.ts +++ b/adapters/racing/ports/InMemoryDriverRatingProvider.test.ts @@ -1,5 +1,5 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import { InMemoryDriverRatingProvider } from './InMemoryDriverRatingProvider'; describe('InMemoryDriverRatingProvider', () => { diff --git a/adapters/racing/ports/InMemoryDriverRatingProvider.ts b/adapters/racing/ports/InMemoryDriverRatingProvider.ts index 035718a36..4f3d1f710 100644 --- a/adapters/racing/ports/InMemoryDriverRatingProvider.ts +++ b/adapters/racing/ports/InMemoryDriverRatingProvider.ts @@ -1,5 +1,5 @@ import type { DriverRatingProvider } from '@core/racing/application/ports/DriverRatingProvider'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; // TODO Provider doesnt exist in Clean Architecture // TODO Hardcoded data here must be moved to a better place diff --git a/adapters/social/persistence/inmemory/InMemorySocialAndFeed.test.ts b/adapters/social/persistence/inmemory/InMemorySocialAndFeed.test.ts index aa8985d22..3af6c24dc 100644 --- a/adapters/social/persistence/inmemory/InMemorySocialAndFeed.test.ts +++ b/adapters/social/persistence/inmemory/InMemorySocialAndFeed.test.ts @@ -1,5 +1,5 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { Logger } from '@core/shared/domain'; import type { RacingSeedData } from './InMemorySocialAndFeed'; import { InMemoryFeedRepository, InMemorySocialGraphRepository } from './InMemorySocialAndFeed'; diff --git a/adapters/social/persistence/inmemory/InMemorySocialAndFeed.ts b/adapters/social/persistence/inmemory/InMemorySocialAndFeed.ts index 34788a841..ca8baa520 100644 --- a/adapters/social/persistence/inmemory/InMemorySocialAndFeed.ts +++ b/adapters/social/persistence/inmemory/InMemorySocialAndFeed.ts @@ -1,5 +1,5 @@ import type { Driver } from '@core/racing/domain/entities/Driver'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; import type { FeedRepository } from '@core/social/domain/repositories/FeedRepository'; import type { SocialGraphRepository } from '@core/social/domain/repositories/SocialGraphRepository'; import type { FeedItem } from '@core/social/domain/types/FeedItem'; diff --git a/apps/api/src/domain/analytics/AnalyticsProviders.ts b/apps/api/src/domain/analytics/AnalyticsProviders.ts index db9d0b195..f4a45d538 100644 --- a/apps/api/src/domain/analytics/AnalyticsProviders.ts +++ b/apps/api/src/domain/analytics/AnalyticsProviders.ts @@ -1,11 +1,11 @@ -import type { IEngagementRepository } from '@core/analytics/domain/repositories/EngagementRepository'; import type { IPageViewRepository } from '@core/analytics/application/repositories/PageViewRepository'; -import type { Logger } from '@core/shared/application'; +import type { IEngagementRepository } from '@core/analytics/domain/repositories/EngagementRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import { Provider } from '@nestjs/common'; import { - ANALYTICS_ENGAGEMENT_REPOSITORY_TOKEN, - ANALYTICS_PAGE_VIEW_REPOSITORY_TOKEN, + ANALYTICS_ENGAGEMENT_REPOSITORY_TOKEN, + ANALYTICS_PAGE_VIEW_REPOSITORY_TOKEN, } from '../../persistence/analytics/AnalyticsPersistenceTokens'; const LOGGER_TOKEN = 'Logger'; diff --git a/apps/api/src/domain/auth/AuthProviders.ts b/apps/api/src/domain/auth/AuthProviders.ts index e1ec6d4c0..e36fc73f9 100644 --- a/apps/api/src/domain/auth/AuthProviders.ts +++ b/apps/api/src/domain/auth/AuthProviders.ts @@ -1,36 +1,36 @@ import { Provider } from '@nestjs/common'; -import type { Logger } from '@core/shared/application'; import { CookieIdentitySessionAdapter } from '@adapters/identity/session/CookieIdentitySessionAdapter'; +import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort'; +import { ForgotPasswordUseCase } from '@core/identity/application/use-cases/ForgotPasswordUseCase'; import { LoginUseCase } from '@core/identity/application/use-cases/LoginUseCase'; import { LogoutUseCase } from '@core/identity/application/use-cases/LogoutUseCase'; -import { SignupUseCase } from '@core/identity/application/use-cases/SignupUseCase'; -import { SignupSponsorUseCase } from '@core/identity/application/use-cases/SignupSponsorUseCase'; -import { ForgotPasswordUseCase } from '@core/identity/application/use-cases/ForgotPasswordUseCase'; import { ResetPasswordUseCase } from '@core/identity/application/use-cases/ResetPasswordUseCase'; -import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort'; +import { SignupSponsorUseCase } from '@core/identity/application/use-cases/SignupSponsorUseCase'; +import { SignupUseCase } from '@core/identity/application/use-cases/SignupUseCase'; +import type { IMagicLinkNotificationPort } from '@core/identity/domain/ports/MagicLinkNotificationPort'; import type { IAuthRepository } from '@core/identity/domain/repositories/AuthRepository'; import type { ICompanyRepository } from '@core/identity/domain/repositories/CompanyRepository'; import type { IMagicLinkRepository } from '@core/identity/domain/repositories/MagicLinkRepository'; import type { IPasswordHashingService } from '@core/identity/domain/services/PasswordHashingService'; -import type { IMagicLinkNotificationPort } from '@core/identity/domain/ports/MagicLinkNotificationPort'; +import type { Logger } from '@core/shared/domain/Logger'; import { - AUTH_REPOSITORY_TOKEN, - PASSWORD_HASHING_SERVICE_TOKEN, - USER_REPOSITORY_TOKEN, - MAGIC_LINK_REPOSITORY_TOKEN, - COMPANY_REPOSITORY_TOKEN, + AUTH_REPOSITORY_TOKEN, + COMPANY_REPOSITORY_TOKEN, + MAGIC_LINK_REPOSITORY_TOKEN, + PASSWORD_HASHING_SERVICE_TOKEN, + USER_REPOSITORY_TOKEN, } from '../../persistence/identity/IdentityPersistenceTokens'; +import { ConsoleMagicLinkNotificationAdapter } from '@adapters/notifications/ports/ConsoleMagicLinkNotificationAdapter'; import { AuthSessionPresenter } from './presenters/AuthSessionPresenter'; import { CommandResultPresenter } from './presenters/CommandResultPresenter'; import { ForgotPasswordPresenter } from './presenters/ForgotPasswordPresenter'; import { ResetPasswordPresenter } from './presenters/ResetPasswordPresenter'; -import { ConsoleMagicLinkNotificationAdapter } from '@adapters/notifications/ports/ConsoleMagicLinkNotificationAdapter'; // Define the tokens for dependency injection -export { AUTH_REPOSITORY_TOKEN, USER_REPOSITORY_TOKEN, PASSWORD_HASHING_SERVICE_TOKEN }; +export { AUTH_REPOSITORY_TOKEN, PASSWORD_HASHING_SERVICE_TOKEN, USER_REPOSITORY_TOKEN }; export const LOGGER_TOKEN = 'Logger'; export const IDENTITY_SESSION_PORT_TOKEN = 'IdentitySessionPort'; export const LOGIN_USE_CASE_TOKEN = 'LoginUseCase'; diff --git a/apps/api/src/domain/auth/AuthService.ts b/apps/api/src/domain/auth/AuthService.ts index 8c7d6654f..e46dfea4a 100644 --- a/apps/api/src/domain/auth/AuthService.ts +++ b/apps/api/src/domain/auth/AuthService.ts @@ -1,49 +1,49 @@ import { Inject } from '@nestjs/common'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { - LoginUseCase, - type LoginApplicationError, - type LoginInput, + ForgotPasswordUseCase, + type ForgotPasswordApplicationError, + type ForgotPasswordInput, +} from '@core/identity/application/use-cases/ForgotPasswordUseCase'; +import { + LoginUseCase, + type LoginApplicationError, + type LoginInput, } from '@core/identity/application/use-cases/LoginUseCase'; import { LogoutUseCase, type LogoutApplicationError } from '@core/identity/application/use-cases/LogoutUseCase'; import { - SignupUseCase, - type SignupApplicationError, - type SignupInput, -} from '@core/identity/application/use-cases/SignupUseCase'; + ResetPasswordUseCase, + type ResetPasswordApplicationError, + type ResetPasswordInput, +} from '@core/identity/application/use-cases/ResetPasswordUseCase'; import { - SignupSponsorUseCase, - type SignupSponsorApplicationError, - type SignupSponsorInput, + SignupSponsorUseCase, + type SignupSponsorApplicationError, + type SignupSponsorInput, } from '@core/identity/application/use-cases/SignupSponsorUseCase'; import { - ForgotPasswordUseCase, - type ForgotPasswordApplicationError, - type ForgotPasswordInput, -} from '@core/identity/application/use-cases/ForgotPasswordUseCase'; -import { - ResetPasswordUseCase, - type ResetPasswordApplicationError, - type ResetPasswordInput, -} from '@core/identity/application/use-cases/ResetPasswordUseCase'; + SignupUseCase, + type SignupApplicationError, + type SignupInput, +} from '@core/identity/application/use-cases/SignupUseCase'; import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort'; import { - AUTH_SESSION_OUTPUT_PORT_TOKEN, - COMMAND_RESULT_OUTPUT_PORT_TOKEN, - FORGOT_PASSWORD_OUTPUT_PORT_TOKEN, - RESET_PASSWORD_OUTPUT_PORT_TOKEN, - IDENTITY_SESSION_PORT_TOKEN, - LOGGER_TOKEN, - LOGIN_USE_CASE_TOKEN, - LOGOUT_USE_CASE_TOKEN, - SIGNUP_USE_CASE_TOKEN, - SIGNUP_SPONSOR_USE_CASE_TOKEN, - FORGOT_PASSWORD_USE_CASE_TOKEN, - RESET_PASSWORD_USE_CASE_TOKEN, + AUTH_SESSION_OUTPUT_PORT_TOKEN, + COMMAND_RESULT_OUTPUT_PORT_TOKEN, + FORGOT_PASSWORD_OUTPUT_PORT_TOKEN, + FORGOT_PASSWORD_USE_CASE_TOKEN, + IDENTITY_SESSION_PORT_TOKEN, + LOGGER_TOKEN, + LOGIN_USE_CASE_TOKEN, + LOGOUT_USE_CASE_TOKEN, + RESET_PASSWORD_OUTPUT_PORT_TOKEN, + RESET_PASSWORD_USE_CASE_TOKEN, + SIGNUP_SPONSOR_USE_CASE_TOKEN, + SIGNUP_USE_CASE_TOKEN, } from './AuthProviders'; import type { AuthSessionDTO } from './dtos/AuthDto'; import { LoginParamsDTO, SignupParamsDTO, SignupSponsorParamsDTO } from './dtos/AuthDto'; diff --git a/apps/api/src/domain/bootstrap/BootstrapModule.ts b/apps/api/src/domain/bootstrap/BootstrapModule.ts index bcb7b738a..690787753 100644 --- a/apps/api/src/domain/bootstrap/BootstrapModule.ts +++ b/apps/api/src/domain/bootstrap/BootstrapModule.ts @@ -1,14 +1,14 @@ -import type { Logger } from '@core/shared/application'; -import type { EnsureInitialData } from '../../../../../adapters/bootstrap/EnsureInitialData'; -import { SeedRacingData, type RacingSeedDependencies } from '../../../../../adapters/bootstrap/SeedRacingData'; -import { SeedDemoUsers } from '../../../../../adapters/bootstrap/SeedDemoUsers'; +import type { Logger } from '@core/shared/domain/Logger'; import { Inject, Module, OnModuleInit } from '@nestjs/common'; +import type { EnsureInitialData } from '../../../../../adapters/bootstrap/EnsureInitialData'; +import { SeedDemoUsers } from '../../../../../adapters/bootstrap/SeedDemoUsers'; +import { SeedRacingData, type RacingSeedDependencies } from '../../../../../adapters/bootstrap/SeedRacingData'; import { getApiPersistence, getEnableBootstrap, getForceReseed } from '../../env'; +import { AchievementPersistenceModule } from '../../persistence/achievement/AchievementPersistenceModule'; +import { AdminPersistenceModule } from '../../persistence/admin/AdminPersistenceModule'; +import { IdentityPersistenceModule } from '../../persistence/identity/IdentityPersistenceModule'; import { RacingPersistenceModule } from '../../persistence/racing/RacingPersistenceModule'; import { SocialPersistenceModule } from '../../persistence/social/SocialPersistenceModule'; -import { AchievementPersistenceModule } from '../../persistence/achievement/AchievementPersistenceModule'; -import { IdentityPersistenceModule } from '../../persistence/identity/IdentityPersistenceModule'; -import { AdminPersistenceModule } from '../../persistence/admin/AdminPersistenceModule'; import { BootstrapProviders, ENSURE_INITIAL_DATA_TOKEN, SEED_DEMO_USERS_TOKEN } from './BootstrapProviders'; @Module({ diff --git a/apps/api/src/domain/bootstrap/BootstrapProviders.ts b/apps/api/src/domain/bootstrap/BootstrapProviders.ts index 04694bc83..0f886e627 100644 --- a/apps/api/src/domain/bootstrap/BootstrapProviders.ts +++ b/apps/api/src/domain/bootstrap/BootstrapProviders.ts @@ -1,20 +1,20 @@ -import { Provider } from '@nestjs/common'; -import { SOCIAL_FEED_REPOSITORY_TOKEN, SOCIAL_GRAPH_REPOSITORY_TOKEN } from '../../persistence/social/SocialPersistenceTokens'; -import { ACHIEVEMENT_REPOSITORY_TOKEN } from '../../persistence/achievement/AchievementPersistenceTokens'; -import { EnsureInitialData } from '../../../../../adapters/bootstrap/EnsureInitialData'; -import type { RacingSeedDependencies } from '../../../../../adapters/bootstrap/SeedRacingData'; -import { SeedDemoUsers } from '../../../../../adapters/bootstrap/SeedDemoUsers'; +import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort'; import { SignupWithEmailUseCase } from '@core/identity/application/use-cases/SignupWithEmailUseCase'; import { - CreateAchievementUseCase, - type IAchievementRepository, + CreateAchievementUseCase, + type IAchievementRepository, } from '@core/identity/application/use-cases/achievement/CreateAchievementUseCase'; import type { IUserRepository } from '@core/identity/domain/repositories/UserRepository'; -import type { IdentitySessionPort } from '@core/identity/application/ports/IdentitySessionPort'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; +import { Provider } from '@nestjs/common'; +import { EnsureInitialData } from '../../../../../adapters/bootstrap/EnsureInitialData'; +import { SeedDemoUsers } from '../../../../../adapters/bootstrap/SeedDemoUsers'; +import type { RacingSeedDependencies } from '../../../../../adapters/bootstrap/SeedRacingData'; import { CookieIdentitySessionAdapter } from '../../../../../adapters/identity/session/CookieIdentitySessionAdapter'; -import { USER_REPOSITORY_TOKEN as IDENTITY_USER_REPOSITORY_TOKEN, AUTH_REPOSITORY_TOKEN, PASSWORD_HASHING_SERVICE_TOKEN } from '../../persistence/identity/IdentityPersistenceTokens'; +import { ACHIEVEMENT_REPOSITORY_TOKEN } from '../../persistence/achievement/AchievementPersistenceTokens'; import { ADMIN_USER_REPOSITORY_TOKEN } from '../../persistence/admin/AdminPersistenceTokens'; +import { AUTH_REPOSITORY_TOKEN, USER_REPOSITORY_TOKEN as IDENTITY_USER_REPOSITORY_TOKEN, PASSWORD_HASHING_SERVICE_TOKEN } from '../../persistence/identity/IdentityPersistenceTokens'; +import { SOCIAL_FEED_REPOSITORY_TOKEN, SOCIAL_GRAPH_REPOSITORY_TOKEN } from '../../persistence/social/SocialPersistenceTokens'; // Define tokens export const USER_REPOSITORY_TOKEN = 'IUserRepository_Bootstrap'; diff --git a/apps/api/src/domain/driver/DriverProviders.ts b/apps/api/src/domain/driver/DriverProviders.ts index 775082bae..ea4e1bd23 100644 --- a/apps/api/src/domain/driver/DriverProviders.ts +++ b/apps/api/src/domain/driver/DriverProviders.ts @@ -1,22 +1,22 @@ import { Provider } from '@nestjs/common'; // Import core interfaces +import type { MediaResolverPort } from '@core/ports/media/MediaResolverPort'; import { DriverExtendedProfileProvider } from '@core/racing/application/ports/DriverExtendedProfileProvider'; import { IDriverRepository } from '@core/racing/domain/repositories/DriverRepository'; import { ILiveryRepository } from '@core/racing/domain/repositories/LiveryRepository'; import { IRaceRegistrationRepository } from '@core/racing/domain/repositories/RaceRegistrationRepository'; -import type { ITeamMembershipRepository } from '@core/racing/domain/repositories/TeamMembershipRepository'; -import type { ITeamRepository } from '@core/racing/domain/repositories/TeamRepository'; -import type { Logger } from '@core/shared/application'; -import type { ISocialGraphRepository } from '@core/social/domain/repositories/SocialGraphRepository'; import type { IResultRepository } from '@core/racing/domain/repositories/ResultRepository'; import type { IStandingRepository } from '@core/racing/domain/repositories/StandingRepository'; -import type { MediaResolverPort } from '@core/ports/media/MediaResolverPort'; +import type { ITeamMembershipRepository } from '@core/racing/domain/repositories/TeamMembershipRepository'; +import type { ITeamRepository } from '@core/racing/domain/repositories/TeamRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import type { ISocialGraphRepository } from '@core/social/domain/repositories/SocialGraphRepository'; // Import use cases import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase'; -import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase'; import { GetDriverLiveriesUseCase } from '@core/racing/application/use-cases/GetDriverLiveriesUseCase'; +import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase'; import { GetDriverUseCase } from '@core/racing/application/use-cases/GetDriverUseCase'; import { GetProfileOverviewUseCase } from '@core/racing/application/use-cases/GetProfileOverviewUseCase'; import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase'; @@ -27,12 +27,10 @@ import { UpdateDriverProfileUseCase } from '@core/racing/application/use-cases/U import { ConsoleLogger } from '@adapters/logging/ConsoleLogger'; import { InMemoryImageServiceAdapter } from '@adapters/media/ports/InMemoryImageServiceAdapter'; import { InMemoryNotificationPreferenceRepository } from '@adapters/notifications/persistence/inmemory/InMemoryNotificationPreferenceRepository'; +import { InMemoryLiveryRepository } from '@adapters/racing/persistence/inmemory/InMemoryLiveryRepository'; import { InMemoryDriverExtendedProfileProvider } from '@adapters/racing/ports/InMemoryDriverExtendedProfileProvider'; import { InMemoryDriverRatingProvider } from '@adapters/racing/ports/InMemoryDriverRatingProvider'; -import { InMemoryLiveryRepository } from '@adapters/racing/persistence/inmemory/InMemoryLiveryRepository'; // Import new use cases -import { RankingUseCase } from '@core/racing/application/use-cases/RankingUseCase'; -import { DriverStatsUseCase } from '@core/racing/application/use-cases/DriverStatsUseCase'; // Import new repositories import { InMemoryDriverStatsRepository } from '@adapters/racing/persistence/inmemory/InMemoryDriverStatsRepository'; import { InMemoryMediaRepository } from '@adapters/racing/persistence/media/InMemoryMediaRepository'; @@ -41,8 +39,8 @@ import { MediaResolverAdapter } from '@adapters/media/MediaResolverAdapter'; // Import repository tokens import { IDriverStatsRepository } from '@core/racing/domain/repositories/DriverStatsRepository'; // Import use case interfaces -import type { IRankingUseCase } from '@core/racing/application/use-cases/RankingUseCase'; import type { IDriverStatsUseCase } from '@core/racing/application/use-cases/DriverStatsUseCase'; +import type { IRankingUseCase } from '@core/racing/application/use-cases/RankingUseCase'; // Import presenters import { CompleteOnboardingPresenter } from './presenters/CompleteOnboardingPresenter'; @@ -54,30 +52,30 @@ import { DriverStatsPresenter } from './presenters/DriverStatsPresenter'; import { GetDriverLiveriesPresenter } from './presenters/GetDriverLiveriesPresenter'; import { - DRIVER_REPOSITORY_TOKEN, - DRIVER_RATING_PROVIDER_TOKEN, - DRIVER_EXTENDED_PROFILE_PROVIDER_TOKEN, - IMAGE_SERVICE_PORT_TOKEN, - RACE_REGISTRATION_REPOSITORY_TOKEN, - NOTIFICATION_PREFERENCE_REPOSITORY_TOKEN, - TEAM_REPOSITORY_TOKEN, - TEAM_MEMBERSHIP_REPOSITORY_TOKEN, - SOCIAL_GRAPH_REPOSITORY_TOKEN, - LIVERY_REPOSITORY_TOKEN, - LOGGER_TOKEN, - GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN, - GET_TOTAL_DRIVERS_USE_CASE_TOKEN, - GET_DRIVER_LIVERIES_USE_CASE_TOKEN, - GET_DRIVER_USE_CASE_TOKEN, - COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN, - IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN, - UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN, - GET_PROFILE_OVERVIEW_USE_CASE_TOKEN, - DRIVER_STATS_REPOSITORY_TOKEN, - MEDIA_REPOSITORY_TOKEN, - RANKING_SERVICE_TOKEN, - DRIVER_STATS_SERVICE_TOKEN, - MEDIA_RESOLVER_TOKEN, + COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN, + DRIVER_EXTENDED_PROFILE_PROVIDER_TOKEN, + DRIVER_RATING_PROVIDER_TOKEN, + DRIVER_REPOSITORY_TOKEN, + DRIVER_STATS_REPOSITORY_TOKEN, + DRIVER_STATS_SERVICE_TOKEN, + GET_DRIVER_LIVERIES_USE_CASE_TOKEN, + GET_DRIVER_USE_CASE_TOKEN, + GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN, + GET_PROFILE_OVERVIEW_USE_CASE_TOKEN, + GET_TOTAL_DRIVERS_USE_CASE_TOKEN, + IMAGE_SERVICE_PORT_TOKEN, + IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN, + LIVERY_REPOSITORY_TOKEN, + LOGGER_TOKEN, + MEDIA_REPOSITORY_TOKEN, + MEDIA_RESOLVER_TOKEN, + NOTIFICATION_PREFERENCE_REPOSITORY_TOKEN, + RACE_REGISTRATION_REPOSITORY_TOKEN, + RANKING_SERVICE_TOKEN, + SOCIAL_GRAPH_REPOSITORY_TOKEN, + TEAM_MEMBERSHIP_REPOSITORY_TOKEN, + TEAM_REPOSITORY_TOKEN, + UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN, } from './DriverTokens'; export * from './DriverTokens'; diff --git a/apps/api/src/domain/driver/DriverService.ts b/apps/api/src/domain/driver/DriverService.ts index 799a53365..8a3a0e01b 100644 --- a/apps/api/src/domain/driver/DriverService.ts +++ b/apps/api/src/domain/driver/DriverService.ts @@ -1,12 +1,12 @@ -import { Inject, Injectable } from '@nestjs/common'; import { Result } from '@core/shared/domain/Result'; +import { Inject, Injectable } from '@nestjs/common'; import { CompleteOnboardingInputDTO } from './dtos/CompleteOnboardingInputDTO'; import { CompleteOnboardingOutputDTO } from './dtos/CompleteOnboardingOutputDTO'; import { DriverRegistrationStatusDTO } from './dtos/DriverRegistrationStatusDTO'; import { DriversLeaderboardDTO } from './dtos/DriversLeaderboardDTO'; import { DriverStatsDTO } from './dtos/DriverStatsDTO'; -import { GetDriverOutputDTO } from './dtos/GetDriverOutputDTO'; import { GetDriverLiveriesOutputDTO } from './dtos/GetDriverLiveriesOutputDTO'; +import { GetDriverOutputDTO } from './dtos/GetDriverOutputDTO'; import { GetDriverProfileOutputDTO } from './dtos/GetDriverProfileOutputDTO'; import { GetDriverRegistrationStatusQueryDTO } from './dtos/GetDriverRegistrationStatusQueryDTO'; @@ -14,11 +14,11 @@ import { GetDriverRegistrationStatusQueryDTO } from './dtos/GetDriverRegistratio import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase'; import { GetDriverLiveriesUseCase } from '@core/racing/application/use-cases/GetDriverLiveriesUseCase'; import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase'; +import { GetDriverUseCase } from '@core/racing/application/use-cases/GetDriverUseCase'; import { GetProfileOverviewUseCase } from '@core/racing/application/use-cases/GetProfileOverviewUseCase'; import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase'; import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase'; import { UpdateDriverProfileUseCase, type UpdateDriverProfileInput } from '@core/racing/application/use-cases/UpdateDriverProfileUseCase'; -import { GetDriverUseCase } from '@core/racing/application/use-cases/GetDriverUseCase'; // Presenters import { CompleteOnboardingPresenter } from './presenters/CompleteOnboardingPresenter'; @@ -30,17 +30,17 @@ import { DriverStatsPresenter } from './presenters/DriverStatsPresenter'; import { GetDriverLiveriesPresenter } from './presenters/GetDriverLiveriesPresenter'; // Tokens -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { - COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN, - GET_DRIVER_LIVERIES_USE_CASE_TOKEN, - GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN, - GET_PROFILE_OVERVIEW_USE_CASE_TOKEN, - GET_TOTAL_DRIVERS_USE_CASE_TOKEN, - IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN, - LOGGER_TOKEN, - UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN, - GET_DRIVER_USE_CASE_TOKEN, + COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN, + GET_DRIVER_LIVERIES_USE_CASE_TOKEN, + GET_DRIVER_USE_CASE_TOKEN, + GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN, + GET_PROFILE_OVERVIEW_USE_CASE_TOKEN, + GET_TOTAL_DRIVERS_USE_CASE_TOKEN, + IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN, + LOGGER_TOKEN, + UPDATE_DRIVER_PROFILE_USE_CASE_TOKEN, } from './DriverTokens'; @Injectable() diff --git a/apps/api/src/domain/league/LeagueService.ts b/apps/api/src/domain/league/LeagueService.ts index 4c087e402..a39ec2963 100644 --- a/apps/api/src/domain/league/LeagueService.ts +++ b/apps/api/src/domain/league/LeagueService.ts @@ -7,15 +7,9 @@ import { GetLeagueAdminPermissionsInputDTO } from './dtos/GetLeagueAdminPermissi import { GetLeagueOwnerSummaryQueryDTO } from './dtos/GetLeagueOwnerSummaryQueryDTO'; import { GetLeagueProtestsQueryDTO } from './dtos/GetLeagueProtestsQueryDTO'; import { GetLeagueRacesOutputDTO } from './dtos/GetLeagueRacesOutputDTO'; +import { GetLeagueScheduleQueryDTO } from './dtos/GetLeagueScheduleQueryDTO'; import { GetLeagueSeasonsQueryDTO } from './dtos/GetLeagueSeasonsQueryDTO'; import { GetLeagueWalletOutputDTO } from './dtos/GetLeagueWalletOutputDTO'; -import { GetLeagueScheduleQueryDTO } from './dtos/GetLeagueScheduleQueryDTO'; -import { - CreateLeagueScheduleRaceInputDTO, - CreateLeagueScheduleRaceOutputDTO, - LeagueScheduleRaceMutationSuccessDTO, - UpdateLeagueScheduleRaceInputDTO, -} from './dtos/LeagueScheduleRaceAdminDTO'; import { GetSeasonSponsorshipsOutputDTO } from './dtos/GetSeasonSponsorshipsOutputDTO'; import { LeagueAdminDTO } from './dtos/LeagueAdminDTO'; import { LeagueAdminPermissionsDTO } from './dtos/LeagueAdminPermissionsDTO'; @@ -23,13 +17,19 @@ import { LeagueAdminProtestsDTO } from './dtos/LeagueAdminProtestsDTO'; import { LeagueConfigFormModelDTO } from './dtos/LeagueConfigFormModelDTO'; import { LeagueJoinRequestWithDriverDTO } from './dtos/LeagueJoinRequestWithDriverDTO'; import { LeagueMembershipsDTO } from './dtos/LeagueMembershipsDTO'; +import { LeagueOwnerSummaryDTO } from './dtos/LeagueOwnerSummaryDTO'; import { LeagueRosterJoinRequestDTO } from './dtos/LeagueRosterJoinRequestDTO'; import { LeagueRosterMemberDTO } from './dtos/LeagueRosterMemberDTO'; -import { LeagueOwnerSummaryDTO } from './dtos/LeagueOwnerSummaryDTO'; import { LeagueScheduleDTO } from './dtos/LeagueScheduleDTO'; import { - LeagueSeasonSchedulePublishInputDTO, - LeagueSeasonSchedulePublishOutputDTO, + CreateLeagueScheduleRaceInputDTO, + CreateLeagueScheduleRaceOutputDTO, + LeagueScheduleRaceMutationSuccessDTO, + UpdateLeagueScheduleRaceInputDTO, +} from './dtos/LeagueScheduleRaceAdminDTO'; +import { + LeagueSeasonSchedulePublishInputDTO, + LeagueSeasonSchedulePublishOutputDTO, } from './dtos/LeagueSeasonSchedulePublishDTO'; import { LeagueSeasonSummaryDTO } from './dtos/LeagueSeasonSummaryDTO'; import { LeagueStandingsDTO } from './dtos/LeagueStandingsDTO'; @@ -38,8 +38,8 @@ import { RejectJoinRequestInputDTO } from './dtos/RejectJoinRequestInputDTO'; import { RejectJoinRequestOutputDTO } from './dtos/RejectJoinRequestOutputDTO'; import { RemoveLeagueMemberInputDTO } from './dtos/RemoveLeagueMemberInputDTO'; import { RemoveLeagueMemberOutputDTO } from './dtos/RemoveLeagueMemberOutputDTO'; -import { TransferLeagueOwnershipOutputDTO } from './dtos/TransferLeagueOwnershipOutputDTO'; import { TransferLeagueOwnershipInputDTO } from './dtos/TransferLeagueOwnershipInputDTO'; +import { TransferLeagueOwnershipOutputDTO } from './dtos/TransferLeagueOwnershipOutputDTO'; import { UpdateLeagueMemberRoleInputDTO } from './dtos/UpdateLeagueMemberRoleInputDTO'; import { UpdateLeagueMemberRoleOutputDTO } from './dtos/UpdateLeagueMemberRoleOutputDTO'; import { WithdrawFromLeagueWalletInputDTO } from './dtos/WithdrawFromLeagueWalletInputDTO'; @@ -49,8 +49,8 @@ import { getActorFromRequestContext } from '../auth/getActorFromRequestContext'; import { requireLeagueAdminOrOwner } from './LeagueAuthorization'; // Core imports for view models -import type { AllLeaguesWithCapacityDTO as AllLeaguesWithCapacityViewModel } from './dtos/AllLeaguesWithCapacityDTO'; import type { AllLeaguesWithCapacityAndScoringDTO as AllLeaguesWithCapacityAndScoringViewModel } from './dtos/AllLeaguesWithCapacityAndScoringDTO'; +import type { AllLeaguesWithCapacityDTO as AllLeaguesWithCapacityViewModel } from './dtos/AllLeaguesWithCapacityDTO'; import type { CreateLeagueViewModel } from './dtos/CreateLeagueDTO'; import type { JoinLeagueOutputDTO } from './dtos/JoinLeagueOutputDTO'; import { TotalLeaguesDTO } from './dtos/TotalLeaguesDTO'; @@ -58,23 +58,23 @@ import type { LeagueScoringConfigViewModel } from './presenters/LeagueScoringCon import type { LeagueScoringPresetsViewModel } from './presenters/LeagueScoringPresetsPresenter'; // Core imports -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; // Use cases import { ApproveLeagueJoinRequestUseCase } from '@core/racing/application/use-cases/ApproveLeagueJoinRequestUseCase'; import { CreateLeagueWithSeasonAndScoringUseCase } from '@core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase'; -import { GetAllLeaguesWithCapacityUseCase } from '@core/racing/application/use-cases/GetAllLeaguesWithCapacityUseCase'; import { GetAllLeaguesWithCapacityAndScoringUseCase } from '@core/racing/application/use-cases/GetAllLeaguesWithCapacityAndScoringUseCase'; +import { GetAllLeaguesWithCapacityUseCase } from '@core/racing/application/use-cases/GetAllLeaguesWithCapacityUseCase'; import { GetLeagueAdminPermissionsUseCase } from '@core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase'; import { GetLeagueFullConfigUseCase } from '@core/racing/application/use-cases/GetLeagueFullConfigUseCase'; import { GetLeagueJoinRequestsUseCase } from '@core/racing/application/use-cases/GetLeagueJoinRequestsUseCase'; import { GetLeagueMembershipsUseCase } from '@core/racing/application/use-cases/GetLeagueMembershipsUseCase'; -import { GetLeagueRosterMembersUseCase } from '@core/racing/application/use-cases/GetLeagueRosterMembersUseCase'; -import { GetLeagueRosterJoinRequestsUseCase } from '@core/racing/application/use-cases/GetLeagueRosterJoinRequestsUseCase'; import { GetLeagueOwnerSummaryUseCase } from '@core/racing/application/use-cases/GetLeagueOwnerSummaryUseCase'; import { GetLeagueProtestsUseCase } from '@core/racing/application/use-cases/GetLeagueProtestsUseCase'; -import { GetLeagueScheduleUseCase } from '@core/racing/application/use-cases/GetLeagueScheduleUseCase'; +import { GetLeagueRosterJoinRequestsUseCase } from '@core/racing/application/use-cases/GetLeagueRosterJoinRequestsUseCase'; +import { GetLeagueRosterMembersUseCase } from '@core/racing/application/use-cases/GetLeagueRosterMembersUseCase'; import type { GetLeagueScheduleInput } from '@core/racing/application/use-cases/GetLeagueScheduleUseCase'; +import { GetLeagueScheduleUseCase } from '@core/racing/application/use-cases/GetLeagueScheduleUseCase'; import { GetLeagueScoringConfigUseCase } from '@core/racing/application/use-cases/GetLeagueScoringConfigUseCase'; import { GetLeagueSeasonsUseCase } from '@core/racing/application/use-cases/GetLeagueSeasonsUseCase'; import { GetLeagueStandingsUseCase } from '@core/racing/application/use-cases/GetLeagueStandingsUseCase'; @@ -97,26 +97,34 @@ import { UnpublishLeagueSeasonScheduleUseCase } from '@core/racing/application/u import { UpdateLeagueSeasonScheduleRaceUseCase } from '@core/racing/application/use-cases/UpdateLeagueSeasonScheduleRaceUseCase'; // API Presenters -import { AllLeaguesWithCapacityPresenter } from './presenters/AllLeaguesWithCapacityPresenter'; import { AllLeaguesWithCapacityAndScoringPresenter } from './presenters/AllLeaguesWithCapacityAndScoringPresenter'; +import { AllLeaguesWithCapacityPresenter } from './presenters/AllLeaguesWithCapacityPresenter'; import { ApproveLeagueJoinRequestPresenter } from './presenters/ApproveLeagueJoinRequestPresenter'; import { CreateLeaguePresenter } from './presenters/CreateLeaguePresenter'; import { GetLeagueAdminPermissionsPresenter } from './presenters/GetLeagueAdminPermissionsPresenter'; import { GetLeagueMembershipsPresenter } from './presenters/GetLeagueMembershipsPresenter'; -import { - GetLeagueRosterJoinRequestsPresenter, - GetLeagueRosterMembersPresenter, -} from './presenters/LeagueRosterAdminReadPresenters'; import { GetLeagueOwnerSummaryPresenter } from './presenters/GetLeagueOwnerSummaryPresenter'; import { GetLeagueProtestsPresenter } from './presenters/GetLeagueProtestsPresenter'; import { GetLeagueSeasonsPresenter } from './presenters/GetLeagueSeasonsPresenter'; +import { GetLeagueWalletPresenter } from './presenters/GetLeagueWalletPresenter'; import { GetSeasonSponsorshipsPresenter } from './presenters/GetSeasonSponsorshipsPresenter'; import { JoinLeaguePresenter } from './presenters/JoinLeaguePresenter'; import { LeagueConfigPresenter } from './presenters/LeagueConfigPresenter'; import { LeagueJoinRequestsPresenter } from './presenters/LeagueJoinRequestsPresenter'; +import { + GetLeagueRosterJoinRequestsPresenter, + GetLeagueRosterMembersPresenter, +} from './presenters/LeagueRosterAdminReadPresenters'; import { LeagueSchedulePresenter } from './presenters/LeagueSchedulePresenter'; import { LeagueScoringConfigPresenter } from './presenters/LeagueScoringConfigPresenter'; import { LeagueScoringPresetsPresenter } from './presenters/LeagueScoringPresetsPresenter'; +import { + CreateLeagueSeasonScheduleRacePresenter, + DeleteLeagueSeasonScheduleRacePresenter, + PublishLeagueSeasonSchedulePresenter, + UnpublishLeagueSeasonSchedulePresenter, + UpdateLeagueSeasonScheduleRacePresenter, +} from './presenters/LeagueSeasonScheduleMutationPresenters'; import { LeagueStandingsPresenter } from './presenters/LeagueStandingsPresenter'; import { LeagueStatsPresenter } from './presenters/LeagueStatsPresenter'; import { RejectLeagueJoinRequestPresenter } from './presenters/RejectLeagueJoinRequestPresenter'; @@ -124,50 +132,42 @@ import { RemoveLeagueMemberPresenter } from './presenters/RemoveLeagueMemberPres import { TotalLeaguesPresenter } from './presenters/TotalLeaguesPresenter'; import { TransferLeagueOwnershipPresenter } from './presenters/TransferLeagueOwnershipPresenter'; import { UpdateLeagueMemberRolePresenter } from './presenters/UpdateLeagueMemberRolePresenter'; -import { GetLeagueWalletPresenter } from './presenters/GetLeagueWalletPresenter'; import { WithdrawFromLeagueWalletPresenter } from './presenters/WithdrawFromLeagueWalletPresenter'; -import { - CreateLeagueSeasonScheduleRacePresenter, - DeleteLeagueSeasonScheduleRacePresenter, - PublishLeagueSeasonSchedulePresenter, - UnpublishLeagueSeasonSchedulePresenter, - UpdateLeagueSeasonScheduleRacePresenter, -} from './presenters/LeagueSeasonScheduleMutationPresenters'; // Tokens import { - APPROVE_LEAGUE_JOIN_REQUEST_USE_CASE, - CREATE_LEAGUE_SEASON_SCHEDULE_RACE_USE_CASE, - CREATE_LEAGUE_WITH_SEASON_AND_SCORING_USE_CASE, - GET_ALL_LEAGUES_WITH_CAPACITY_AND_SCORING_USE_CASE, - GET_ALL_LEAGUES_WITH_CAPACITY_USE_CASE, - GET_LEAGUE_ADMIN_PERMISSIONS_USE_CASE, - GET_LEAGUE_FULL_CONFIG_USE_CASE, - GET_LEAGUE_JOIN_REQUESTS_USE_CASE, - GET_LEAGUE_MEMBERSHIPS_USE_CASE, - GET_LEAGUE_OWNER_SUMMARY_USE_CASE, - GET_LEAGUE_PROTESTS_USE_CASE, - GET_LEAGUE_SCHEDULE_USE_CASE, - GET_LEAGUE_SCORING_CONFIG_USE_CASE, - GET_LEAGUE_SEASONS_USE_CASE, - GET_LEAGUE_STATS_USE_CASE, - GET_LEAGUE_STANDINGS_USE_CASE, - GET_LEAGUE_WALLET_USE_CASE, - GET_SEASON_SPONSORSHIPS_USE_CASE, - GET_TOTAL_LEAGUES_USE_CASE, - JOIN_LEAGUE_USE_CASE, - LIST_LEAGUE_SCORING_PRESETS_USE_CASE, - LOGGER_TOKEN, - PUBLISH_LEAGUE_SEASON_SCHEDULE_USE_CASE, - REJECT_LEAGUE_JOIN_REQUEST_USE_CASE, - REMOVE_LEAGUE_MEMBER_USE_CASE, - TRANSFER_LEAGUE_OWNERSHIP_USE_CASE, - UNPUBLISH_LEAGUE_SEASON_SCHEDULE_USE_CASE, - UPDATE_LEAGUE_MEMBER_ROLE_USE_CASE, - UPDATE_LEAGUE_SEASON_SCHEDULE_RACE_USE_CASE, - DELETE_LEAGUE_SEASON_SCHEDULE_RACE_USE_CASE, - WITHDRAW_FROM_LEAGUE_WALLET_USE_CASE, - GET_LEAGUE_ROSTER_MEMBERS_USE_CASE, - GET_LEAGUE_ROSTER_JOIN_REQUESTS_USE_CASE, + APPROVE_LEAGUE_JOIN_REQUEST_USE_CASE, + CREATE_LEAGUE_SEASON_SCHEDULE_RACE_USE_CASE, + CREATE_LEAGUE_WITH_SEASON_AND_SCORING_USE_CASE, + DELETE_LEAGUE_SEASON_SCHEDULE_RACE_USE_CASE, + GET_ALL_LEAGUES_WITH_CAPACITY_AND_SCORING_USE_CASE, + GET_ALL_LEAGUES_WITH_CAPACITY_USE_CASE, + GET_LEAGUE_ADMIN_PERMISSIONS_USE_CASE, + GET_LEAGUE_FULL_CONFIG_USE_CASE, + GET_LEAGUE_JOIN_REQUESTS_USE_CASE, + GET_LEAGUE_MEMBERSHIPS_USE_CASE, + GET_LEAGUE_OWNER_SUMMARY_USE_CASE, + GET_LEAGUE_PROTESTS_USE_CASE, + GET_LEAGUE_ROSTER_JOIN_REQUESTS_USE_CASE, + GET_LEAGUE_ROSTER_MEMBERS_USE_CASE, + GET_LEAGUE_SCHEDULE_USE_CASE, + GET_LEAGUE_SCORING_CONFIG_USE_CASE, + GET_LEAGUE_SEASONS_USE_CASE, + GET_LEAGUE_STANDINGS_USE_CASE, + GET_LEAGUE_STATS_USE_CASE, + GET_LEAGUE_WALLET_USE_CASE, + GET_SEASON_SPONSORSHIPS_USE_CASE, + GET_TOTAL_LEAGUES_USE_CASE, + JOIN_LEAGUE_USE_CASE, + LIST_LEAGUE_SCORING_PRESETS_USE_CASE, + LOGGER_TOKEN, + PUBLISH_LEAGUE_SEASON_SCHEDULE_USE_CASE, + REJECT_LEAGUE_JOIN_REQUEST_USE_CASE, + REMOVE_LEAGUE_MEMBER_USE_CASE, + TRANSFER_LEAGUE_OWNERSHIP_USE_CASE, + UNPUBLISH_LEAGUE_SEASON_SCHEDULE_USE_CASE, + UPDATE_LEAGUE_MEMBER_ROLE_USE_CASE, + UPDATE_LEAGUE_SEASON_SCHEDULE_RACE_USE_CASE, + WITHDRAW_FROM_LEAGUE_WALLET_USE_CASE, } from './LeagueTokens'; @Injectable() diff --git a/apps/api/src/domain/media/MediaProviders.ts b/apps/api/src/domain/media/MediaProviders.ts index 8d6f5c323..ecea0164a 100644 --- a/apps/api/src/domain/media/MediaProviders.ts +++ b/apps/api/src/domain/media/MediaProviders.ts @@ -1,56 +1,56 @@ import { Provider } from '@nestjs/common'; // Import core interfaces -import { IAvatarGenerationRepository } from '@core/media/domain/repositories/AvatarGenerationRepository'; -import { IMediaRepository } from '@core/media/domain/repositories/MediaRepository'; -import { IAvatarRepository } from '@core/media/domain/repositories/AvatarRepository'; -import { FaceValidationPort } from '@core/media/application/ports/FaceValidationPort'; import { AvatarGenerationPort } from '@core/media/application/ports/AvatarGenerationPort'; +import { FaceValidationPort } from '@core/media/application/ports/FaceValidationPort'; import { MediaStoragePort } from '@core/media/application/ports/MediaStoragePort'; -import type { Logger } from '@core/shared/application'; +import { IAvatarGenerationRepository } from '@core/media/domain/repositories/AvatarGenerationRepository'; +import { IAvatarRepository } from '@core/media/domain/repositories/AvatarRepository'; +import { IMediaRepository } from '@core/media/domain/repositories/MediaRepository'; import type { MediaResolverPort } from '@core/ports/media/MediaResolverPort'; +import type { Logger } from '@core/shared/domain/Logger'; // Import use cases -import { RequestAvatarGenerationUseCase } from '@core/media/application/use-cases/RequestAvatarGenerationUseCase'; -import { UploadMediaUseCase } from '@core/media/application/use-cases/UploadMediaUseCase'; -import { GetMediaUseCase } from '@core/media/application/use-cases/GetMediaUseCase'; import { DeleteMediaUseCase } from '@core/media/application/use-cases/DeleteMediaUseCase'; import { GetAvatarUseCase } from '@core/media/application/use-cases/GetAvatarUseCase'; -import { UpdateAvatarUseCase } from '@core/media/application/use-cases/UpdateAvatarUseCase'; -import { ResolveMediaReferenceUseCase } from '@core/media/application/use-cases/ResolveMediaReferenceUseCase'; +import { GetMediaUseCase } from '@core/media/application/use-cases/GetMediaUseCase'; import { GetUploadedMediaUseCase } from '@core/media/application/use-cases/GetUploadedMediaUseCase'; +import { RequestAvatarGenerationUseCase } from '@core/media/application/use-cases/RequestAvatarGenerationUseCase'; +import { ResolveMediaReferenceUseCase } from '@core/media/application/use-cases/ResolveMediaReferenceUseCase'; +import { UpdateAvatarUseCase } from '@core/media/application/use-cases/UpdateAvatarUseCase'; +import { UploadMediaUseCase } from '@core/media/application/use-cases/UploadMediaUseCase'; // Import presenters -import { RequestAvatarGenerationPresenter } from './presenters/RequestAvatarGenerationPresenter'; -import { UploadMediaPresenter } from './presenters/UploadMediaPresenter'; -import { GetMediaPresenter } from './presenters/GetMediaPresenter'; import { DeleteMediaPresenter } from './presenters/DeleteMediaPresenter'; import { GetAvatarPresenter } from './presenters/GetAvatarPresenter'; +import { GetMediaPresenter } from './presenters/GetMediaPresenter'; +import { RequestAvatarGenerationPresenter } from './presenters/RequestAvatarGenerationPresenter'; import { UpdateAvatarPresenter } from './presenters/UpdateAvatarPresenter'; +import { UploadMediaPresenter } from './presenters/UploadMediaPresenter'; import { - AVATAR_GENERATION_REPOSITORY_TOKEN, - MEDIA_REPOSITORY_TOKEN, - AVATAR_REPOSITORY_TOKEN, - FACE_VALIDATION_PORT_TOKEN, - AVATAR_GENERATION_PORT_TOKEN, - MEDIA_STORAGE_PORT_TOKEN, - LOGGER_TOKEN, - REQUEST_AVATAR_GENERATION_USE_CASE_TOKEN, - UPLOAD_MEDIA_USE_CASE_TOKEN, - GET_MEDIA_USE_CASE_TOKEN, - DELETE_MEDIA_USE_CASE_TOKEN, - GET_AVATAR_USE_CASE_TOKEN, - UPDATE_AVATAR_USE_CASE_TOKEN, - RESOLVE_MEDIA_REFERENCE_USE_CASE_TOKEN, - GET_UPLOADED_MEDIA_USE_CASE_TOKEN, - MEDIA_RESOLVER_PORT_TOKEN, + AVATAR_GENERATION_PORT_TOKEN, + AVATAR_GENERATION_REPOSITORY_TOKEN, + AVATAR_REPOSITORY_TOKEN, + DELETE_MEDIA_USE_CASE_TOKEN, + FACE_VALIDATION_PORT_TOKEN, + GET_AVATAR_USE_CASE_TOKEN, + GET_MEDIA_USE_CASE_TOKEN, + GET_UPLOADED_MEDIA_USE_CASE_TOKEN, + LOGGER_TOKEN, + MEDIA_REPOSITORY_TOKEN, + MEDIA_RESOLVER_PORT_TOKEN, + MEDIA_STORAGE_PORT_TOKEN, + REQUEST_AVATAR_GENERATION_USE_CASE_TOKEN, + RESOLVE_MEDIA_REFERENCE_USE_CASE_TOKEN, + UPDATE_AVATAR_USE_CASE_TOKEN, + UPLOAD_MEDIA_USE_CASE_TOKEN, } from './MediaTokens'; export * from './MediaTokens'; -import type { FaceValidationResult } from '@core/media/application/ports/FaceValidationPort'; import type { AvatarGenerationResult } from '@core/media/application/ports/AvatarGenerationPort'; +import type { FaceValidationResult } from '@core/media/application/ports/FaceValidationPort'; // External adapters (ports) - these remain mock implementations class MockFaceValidationAdapter implements FaceValidationPort { @@ -84,9 +84,9 @@ class MockLogger implements Logger { error(): void {} } -import { MediaGenerationService } from '@core/media/domain/services/MediaGenerationService'; import { MediaResolverAdapter } from '@adapters/media/MediaResolverAdapter'; import { FileSystemMediaStorageAdapter } from '@adapters/media/ports/FileSystemMediaStorageAdapter'; +import { MediaGenerationService } from '@core/media/domain/services/MediaGenerationService'; // Import logging infrastructure import { InitializationLogger } from '../../shared/logging/InitializationLogger'; diff --git a/apps/api/src/domain/media/MediaService.ts b/apps/api/src/domain/media/MediaService.ts index 3db91890e..050123f07 100644 --- a/apps/api/src/domain/media/MediaService.ts +++ b/apps/api/src/domain/media/MediaService.ts @@ -1,53 +1,53 @@ -import { Injectable, Inject } from '@nestjs/common'; -import type { RequestAvatarGenerationInputDTO } from './dtos/RequestAvatarGenerationInputDTO'; -import type { UploadMediaInputDTO } from './dtos/UploadMediaInputDTO'; -import type { UpdateAvatarInputDTO } from './dtos/UpdateAvatarInputDTO'; -import type { RequestAvatarGenerationOutputDTO } from './dtos/RequestAvatarGenerationOutputDTO'; -import type { UploadMediaOutputDTO } from './dtos/UploadMediaOutputDTO'; -import type { GetMediaOutputDTO } from './dtos/GetMediaOutputDTO'; +import type { MediaReference } from '@core/domain/media/MediaReference'; +import type { RacingSuitColor } from '@core/media/domain/types/AvatarGenerationRequest'; +import { Inject, Injectable } from '@nestjs/common'; import type { DeleteMediaOutputDTO } from './dtos/DeleteMediaOutputDTO'; import type { GetAvatarOutputDTO } from './dtos/GetAvatarOutputDTO'; +import type { GetMediaOutputDTO } from './dtos/GetMediaOutputDTO'; +import type { RequestAvatarGenerationInputDTO } from './dtos/RequestAvatarGenerationInputDTO'; +import type { RequestAvatarGenerationOutputDTO } from './dtos/RequestAvatarGenerationOutputDTO'; +import type { UpdateAvatarInputDTO } from './dtos/UpdateAvatarInputDTO'; import type { UpdateAvatarOutputDTO } from './dtos/UpdateAvatarOutputDTO'; +import type { UploadMediaInputDTO } from './dtos/UploadMediaInputDTO'; +import type { UploadMediaOutputDTO } from './dtos/UploadMediaOutputDTO'; import type { ValidateFaceInputDTO } from './dtos/ValidateFaceInputDTO'; import type { ValidateFaceOutputDTO } from './dtos/ValidateFaceOutputDTO'; -import type { RacingSuitColor } from '@core/media/domain/types/AvatarGenerationRequest'; import type { MulterFile } from './types/MulterFile'; -import type { MediaReference } from '@core/domain/media/MediaReference'; type RequestAvatarGenerationInput = RequestAvatarGenerationInputDTO; type UploadMediaInput = UploadMediaInputDTO; type UpdateAvatarInput = UpdateAvatarInputDTO; // Use cases -import { RequestAvatarGenerationUseCase } from '@core/media/application/use-cases/RequestAvatarGenerationUseCase'; -import { UploadMediaUseCase } from '@core/media/application/use-cases/UploadMediaUseCase'; -import { GetMediaUseCase } from '@core/media/application/use-cases/GetMediaUseCase'; import { DeleteMediaUseCase } from '@core/media/application/use-cases/DeleteMediaUseCase'; import { GetAvatarUseCase } from '@core/media/application/use-cases/GetAvatarUseCase'; -import { UpdateAvatarUseCase } from '@core/media/application/use-cases/UpdateAvatarUseCase'; -import { ResolveMediaReferenceUseCase } from '@core/media/application/use-cases/ResolveMediaReferenceUseCase'; +import { GetMediaUseCase } from '@core/media/application/use-cases/GetMediaUseCase'; import { GetUploadedMediaUseCase, type GetUploadedMediaResult } from '@core/media/application/use-cases/GetUploadedMediaUseCase'; +import { RequestAvatarGenerationUseCase } from '@core/media/application/use-cases/RequestAvatarGenerationUseCase'; +import { ResolveMediaReferenceUseCase } from '@core/media/application/use-cases/ResolveMediaReferenceUseCase'; +import { UpdateAvatarUseCase } from '@core/media/application/use-cases/UpdateAvatarUseCase'; +import { UploadMediaUseCase } from '@core/media/application/use-cases/UploadMediaUseCase'; // Presenters (now transformers) -import { RequestAvatarGenerationPresenter } from './presenters/RequestAvatarGenerationPresenter'; -import { UploadMediaPresenter } from './presenters/UploadMediaPresenter'; -import { GetMediaPresenter } from './presenters/GetMediaPresenter'; import { DeleteMediaPresenter } from './presenters/DeleteMediaPresenter'; import { GetAvatarPresenter } from './presenters/GetAvatarPresenter'; +import { GetMediaPresenter } from './presenters/GetMediaPresenter'; +import { RequestAvatarGenerationPresenter } from './presenters/RequestAvatarGenerationPresenter'; import { UpdateAvatarPresenter } from './presenters/UpdateAvatarPresenter'; +import { UploadMediaPresenter } from './presenters/UploadMediaPresenter'; +import type { Logger } from '@core/shared/domain/Logger'; import { - REQUEST_AVATAR_GENERATION_USE_CASE_TOKEN, - UPLOAD_MEDIA_USE_CASE_TOKEN, - GET_MEDIA_USE_CASE_TOKEN, - DELETE_MEDIA_USE_CASE_TOKEN, - GET_AVATAR_USE_CASE_TOKEN, - UPDATE_AVATAR_USE_CASE_TOKEN, - RESOLVE_MEDIA_REFERENCE_USE_CASE_TOKEN, - GET_UPLOADED_MEDIA_USE_CASE_TOKEN, - LOGGER_TOKEN, + DELETE_MEDIA_USE_CASE_TOKEN, + GET_AVATAR_USE_CASE_TOKEN, + GET_MEDIA_USE_CASE_TOKEN, + GET_UPLOADED_MEDIA_USE_CASE_TOKEN, + LOGGER_TOKEN, + REQUEST_AVATAR_GENERATION_USE_CASE_TOKEN, + RESOLVE_MEDIA_REFERENCE_USE_CASE_TOKEN, + UPDATE_AVATAR_USE_CASE_TOKEN, + UPLOAD_MEDIA_USE_CASE_TOKEN, } from './MediaTokens'; -import type { Logger } from '@core/shared/application'; @Injectable() export class MediaService { diff --git a/apps/api/src/domain/sponsor/SponsorProviders.ts b/apps/api/src/domain/sponsor/SponsorProviders.ts index 4088a6d49..a70396b99 100644 --- a/apps/api/src/domain/sponsor/SponsorProviders.ts +++ b/apps/api/src/domain/sponsor/SponsorProviders.ts @@ -14,7 +14,7 @@ import { ISeasonSponsorshipRepository } from '@core/racing/domain/repositories/S import { ISponsorRepository } from '@core/racing/domain/repositories/SponsorRepository'; import { ISponsorshipPricingRepository } from '@core/racing/domain/repositories/SponsorshipPricingRepository'; import { ISponsorshipRequestRepository } from '@core/racing/domain/repositories/SponsorshipRequestRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { GetSponsorBillingUseCase } from '@core/payments/application/use-cases/GetSponsorBillingUseCase'; import { AcceptSponsorshipRequestUseCase } from '@core/racing/application/use-cases/AcceptSponsorshipRequestUseCase'; diff --git a/apps/api/src/domain/sponsor/SponsorService.test.ts b/apps/api/src/domain/sponsor/SponsorService.test.ts index cb3a26ff5..0cc014956 100644 --- a/apps/api/src/domain/sponsor/SponsorService.test.ts +++ b/apps/api/src/domain/sponsor/SponsorService.test.ts @@ -1,19 +1,19 @@ import type { GetSponsorBillingUseCase } from '@core/payments/application/use-cases/GetSponsorBillingUseCase'; import type { AcceptSponsorshipRequestUseCase } from '@core/racing/application/use-cases/AcceptSponsorshipRequestUseCase'; import type { CreateSponsorUseCase } from '@core/racing/application/use-cases/CreateSponsorUseCase'; +import type { GetEntitySponsorshipPricingUseCase } from '@core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase'; import type { GetPendingSponsorshipRequestsUseCase } from '@core/racing/application/use-cases/GetPendingSponsorshipRequestsUseCase'; import type { GetSponsorDashboardInput, GetSponsorDashboardUseCase } from '@core/racing/application/use-cases/GetSponsorDashboardUseCase'; -import type { GetEntitySponsorshipPricingUseCase } from '@core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase'; import type { GetSponsorSponsorshipsInput, GetSponsorSponsorshipsUseCase } from '@core/racing/application/use-cases/GetSponsorSponsorshipsUseCase'; import type { GetSponsorsUseCase } from '@core/racing/application/use-cases/GetSponsorsUseCase'; import type { GetSponsorUseCase } from '@core/racing/application/use-cases/GetSponsorUseCase'; import type { RejectSponsorshipRequestUseCase } from '@core/racing/application/use-cases/RejectSponsorshipRequestUseCase'; -import type { Logger } from '@core/shared/application'; +import { Sponsor } from '@core/racing/domain/entities/sponsor/Sponsor'; +import { Money } from '@core/racing/domain/value-objects/Money'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import type { CreateSponsorInputDTO } from './dtos/CreateSponsorInputDTO'; -import { Sponsor } from '@core/racing/domain/entities/sponsor/Sponsor'; -import { Money } from '@core/racing/domain/value-objects/Money'; import { SponsorService } from './SponsorService'; describe('SponsorService', () => { diff --git a/apps/api/src/domain/sponsor/SponsorService.ts b/apps/api/src/domain/sponsor/SponsorService.ts index 90c613407..d1331c26e 100644 --- a/apps/api/src/domain/sponsor/SponsorService.ts +++ b/apps/api/src/domain/sponsor/SponsorService.ts @@ -1,74 +1,74 @@ -import { Injectable, Inject } from '@nestjs/common'; +import { Inject, Injectable } from '@nestjs/common'; +import { AvailableLeagueDTO } from './dtos/AvailableLeagueDTO'; +import { BillingStatsDTO } from './dtos/BillingStatsDTO'; import { CreateSponsorInputDTO } from './dtos/CreateSponsorInputDTO'; import { CreateSponsorOutputDTO } from './dtos/CreateSponsorOutputDTO'; -import { GetSponsorDashboardQueryParamsDTO } from './dtos/GetSponsorDashboardQueryParamsDTO'; -import { SponsorDashboardDTO } from './dtos/SponsorDashboardDTO'; -import { GetSponsorSponsorshipsQueryParamsDTO } from './dtos/GetSponsorSponsorshipsQueryParamsDTO'; -import { SponsorSponsorshipsDTO } from './dtos/SponsorSponsorshipsDTO'; -import { GetSponsorOutputDTO } from './dtos/GetSponsorOutputDTO'; -import { GetPendingSponsorshipRequestsOutputDTO } from './dtos/GetPendingSponsorshipRequestsOutputDTO'; import { GetEntitySponsorshipPricingResultDTO } from './dtos/GetEntitySponsorshipPricingResultDTO'; +import { GetPendingSponsorshipRequestsOutputDTO } from './dtos/GetPendingSponsorshipRequestsOutputDTO'; +import { GetSponsorDashboardQueryParamsDTO } from './dtos/GetSponsorDashboardQueryParamsDTO'; +import { GetSponsorOutputDTO } from './dtos/GetSponsorOutputDTO'; import { GetSponsorsOutputDTO } from './dtos/GetSponsorsOutputDTO'; -import { AvailableLeagueDTO } from './dtos/AvailableLeagueDTO'; -import { LeagueDetailDTO } from './dtos/LeagueDetailDTO'; -import { SponsorDriverDTO } from './dtos/SponsorDriverDTO'; -import { SponsorRaceDTO } from './dtos/RaceDTO'; -import { SponsorProfileDTO } from './dtos/SponsorProfileDTO'; -import { NotificationSettingsDTO } from './dtos/NotificationSettingsDTO'; -import { PrivacySettingsDTO } from './dtos/PrivacySettingsDTO'; -import { PaymentMethodDTO } from './dtos/PaymentMethodDTO'; +import { GetSponsorSponsorshipsQueryParamsDTO } from './dtos/GetSponsorSponsorshipsQueryParamsDTO'; import { InvoiceDTO } from './dtos/InvoiceDTO'; -import { BillingStatsDTO } from './dtos/BillingStatsDTO'; +import { LeagueDetailDTO } from './dtos/LeagueDetailDTO'; +import { NotificationSettingsDTO } from './dtos/NotificationSettingsDTO'; +import { PaymentMethodDTO } from './dtos/PaymentMethodDTO'; +import { PrivacySettingsDTO } from './dtos/PrivacySettingsDTO'; +import { SponsorRaceDTO } from './dtos/RaceDTO'; +import { SponsorDashboardDTO } from './dtos/SponsorDashboardDTO'; +import { SponsorDriverDTO } from './dtos/SponsorDriverDTO'; +import { SponsorProfileDTO } from './dtos/SponsorProfileDTO'; +import { SponsorSponsorshipsDTO } from './dtos/SponsorSponsorshipsDTO'; // Use cases -import { GetEntitySponsorshipPricingUseCase } from '@core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase'; -import { GetSponsorsUseCase } from '@core/racing/application/use-cases/GetSponsorsUseCase'; +import { GetSponsorBillingUseCase } from '@core/payments/application/use-cases/GetSponsorBillingUseCase'; +import { AcceptSponsorshipRequestUseCase } from '@core/racing/application/use-cases/AcceptSponsorshipRequestUseCase'; import { CreateSponsorUseCase } from '@core/racing/application/use-cases/CreateSponsorUseCase'; +import { GetEntitySponsorshipPricingUseCase } from '@core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase'; +import { + GetPendingSponsorshipRequestsInput, + GetPendingSponsorshipRequestsUseCase, +} from '@core/racing/application/use-cases/GetPendingSponsorshipRequestsUseCase'; import { GetSponsorDashboardUseCase } from '@core/racing/application/use-cases/GetSponsorDashboardUseCase'; import { GetSponsorSponsorshipsUseCase } from '@core/racing/application/use-cases/GetSponsorSponsorshipsUseCase'; +import { GetSponsorsUseCase } from '@core/racing/application/use-cases/GetSponsorsUseCase'; import { GetSponsorUseCase } from '@core/racing/application/use-cases/GetSponsorUseCase'; -import { - GetPendingSponsorshipRequestsUseCase, - GetPendingSponsorshipRequestsInput, -} from '@core/racing/application/use-cases/GetPendingSponsorshipRequestsUseCase'; -import { AcceptSponsorshipRequestUseCase } from '@core/racing/application/use-cases/AcceptSponsorshipRequestUseCase'; import { RejectSponsorshipRequestUseCase } from '@core/racing/application/use-cases/RejectSponsorshipRequestUseCase'; -import { GetSponsorBillingUseCase } from '@core/payments/application/use-cases/GetSponsorBillingUseCase'; import type { SponsorableEntityType } from '@core/racing/domain/entities/SponsorshipRequest'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; // Tokens import { - GET_SPONSORS_USE_CASE_TOKEN, - CREATE_SPONSOR_USE_CASE_TOKEN, - GET_SPONSOR_DASHBOARD_USE_CASE_TOKEN, - GET_SPONSOR_SPONSORSHIPS_USE_CASE_TOKEN, - GET_SPONSOR_USE_CASE_TOKEN, - GET_PENDING_SPONSORSHIP_REQUESTS_USE_CASE_TOKEN, - ACCEPT_SPONSORSHIP_REQUEST_USE_CASE_TOKEN, - REJECT_SPONSORSHIP_REQUEST_USE_CASE_TOKEN, - GET_SPONSOR_BILLING_USE_CASE_TOKEN, - GET_ENTITY_SPONSORSHIP_PRICING_USE_CASE_TOKEN, - LOGGER_TOKEN, + ACCEPT_SPONSORSHIP_REQUEST_USE_CASE_TOKEN, + CREATE_SPONSOR_USE_CASE_TOKEN, + GET_ENTITY_SPONSORSHIP_PRICING_USE_CASE_TOKEN, + GET_PENDING_SPONSORSHIP_REQUESTS_USE_CASE_TOKEN, + GET_SPONSOR_BILLING_USE_CASE_TOKEN, + GET_SPONSOR_DASHBOARD_USE_CASE_TOKEN, + GET_SPONSOR_SPONSORSHIPS_USE_CASE_TOKEN, + GET_SPONSOR_USE_CASE_TOKEN, + GET_SPONSORS_USE_CASE_TOKEN, + LOGGER_TOKEN, + REJECT_SPONSORSHIP_REQUEST_USE_CASE_TOKEN, } from './SponsorTokens'; // Presenters (for view model transformation only) -import { GetEntitySponsorshipPricingPresenter } from './presenters/GetEntitySponsorshipPricingPresenter'; -import { GetSponsorsPresenter } from './presenters/GetSponsorsPresenter'; -import { CreateSponsorPresenter } from './presenters/CreateSponsorPresenter'; -import { GetSponsorDashboardPresenter } from './presenters/GetSponsorDashboardPresenter'; -import { GetSponsorSponsorshipsPresenter } from './presenters/GetSponsorSponsorshipsPresenter'; -import { GetSponsorPresenter } from './presenters/GetSponsorPresenter'; -import { GetPendingSponsorshipRequestsPresenter } from './presenters/GetPendingSponsorshipRequestsPresenter'; -import { AcceptSponsorshipRequestPresenter } from './presenters/AcceptSponsorshipRequestPresenter'; -import { RejectSponsorshipRequestPresenter } from './presenters/RejectSponsorshipRequestPresenter'; -import { SponsorBillingPresenter } from './presenters/SponsorBillingPresenter'; -import { AvailableLeaguesPresenter } from './presenters/AvailableLeaguesPresenter'; -import { LeagueDetailPresenter } from './presenters/LeagueDetailPresenter'; -import { SponsorSettingsPresenter } from './presenters/SponsorSettingsPresenter'; -import { SponsorSettingsUpdatePresenter } from './presenters/SponsorSettingsUpdatePresenter'; import type { RejectSponsorshipRequestResult } from '@core/racing/application/use-cases/RejectSponsorshipRequestUseCase'; import type { AcceptSponsorshipRequestResultViewModel } from './presenters/AcceptSponsorshipRequestPresenter'; +import { AcceptSponsorshipRequestPresenter } from './presenters/AcceptSponsorshipRequestPresenter'; +import { AvailableLeaguesPresenter } from './presenters/AvailableLeaguesPresenter'; +import { CreateSponsorPresenter } from './presenters/CreateSponsorPresenter'; +import { GetEntitySponsorshipPricingPresenter } from './presenters/GetEntitySponsorshipPricingPresenter'; +import { GetPendingSponsorshipRequestsPresenter } from './presenters/GetPendingSponsorshipRequestsPresenter'; +import { GetSponsorDashboardPresenter } from './presenters/GetSponsorDashboardPresenter'; +import { GetSponsorPresenter } from './presenters/GetSponsorPresenter'; +import { GetSponsorSponsorshipsPresenter } from './presenters/GetSponsorSponsorshipsPresenter'; +import { GetSponsorsPresenter } from './presenters/GetSponsorsPresenter'; +import { LeagueDetailPresenter } from './presenters/LeagueDetailPresenter'; +import { RejectSponsorshipRequestPresenter } from './presenters/RejectSponsorshipRequestPresenter'; +import { SponsorBillingPresenter } from './presenters/SponsorBillingPresenter'; +import { SponsorSettingsPresenter } from './presenters/SponsorSettingsPresenter'; +import { SponsorSettingsUpdatePresenter } from './presenters/SponsorSettingsUpdatePresenter'; @Injectable() export class SponsorService { diff --git a/apps/companion/main/automation/application/ports/LoggerPort.ts b/apps/companion/main/automation/application/ports/LoggerPort.ts index 70ba3ae7a..ae11f7cd3 100644 --- a/apps/companion/main/automation/application/ports/LoggerPort.ts +++ b/apps/companion/main/automation/application/ports/LoggerPort.ts @@ -1,5 +1,5 @@ +import type { Logger } from '@core/shared/domain/Logger'; import type { LogContext } from './LoggerContext'; -import type { Logger } from '@core/shared/application'; /** * LoggerPort - Port interface for application-layer logging. diff --git a/apps/companion/main/automation/application/use-cases/CheckAuthenticationUseCase.ts b/apps/companion/main/automation/application/use-cases/CheckAuthenticationUseCase.ts index b0f1b5bfe..a3df0048e 100644 --- a/apps/companion/main/automation/application/use-cases/CheckAuthenticationUseCase.ts +++ b/apps/companion/main/automation/application/use-cases/CheckAuthenticationUseCase.ts @@ -1,8 +1,8 @@ -import { AuthenticationState } from '../../domain/value-objects/AuthenticationState'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; -import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort'; +import { AuthenticationState } from '../../domain/value-objects/AuthenticationState'; import { SessionLifetime } from '../../domain/value-objects/SessionLifetime'; +import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort'; import type { SessionValidatorPort } from '../ports/SessionValidatorPort'; /** diff --git a/apps/companion/main/automation/application/use-cases/ClearSessionUseCase.ts b/apps/companion/main/automation/application/use-cases/ClearSessionUseCase.ts index 9c9ad127e..9255ba47d 100644 --- a/apps/companion/main/automation/application/use-cases/ClearSessionUseCase.ts +++ b/apps/companion/main/automation/application/use-cases/ClearSessionUseCase.ts @@ -1,6 +1,6 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort'; -import type { Logger } from '@core/shared/application'; /** * Use case for clearing the user's session (logout). diff --git a/apps/companion/main/automation/application/use-cases/CompleteRaceCreationUseCase.ts b/apps/companion/main/automation/application/use-cases/CompleteRaceCreationUseCase.ts index 4818d5789..3904a613f 100644 --- a/apps/companion/main/automation/application/use-cases/CompleteRaceCreationUseCase.ts +++ b/apps/companion/main/automation/application/use-cases/CompleteRaceCreationUseCase.ts @@ -1,7 +1,7 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import { RaceCreationResult } from '../../domain/value-objects/RaceCreationResult'; import type { CheckoutServicePort } from '../ports/CheckoutServicePort'; -import type { Logger } from '@core/shared/application'; export class CompleteRaceCreationUseCase { constructor(private readonly checkoutService: CheckoutServicePort, private readonly logger: Logger) {} diff --git a/apps/companion/main/automation/application/use-cases/ConfirmCheckoutUseCase.ts b/apps/companion/main/automation/application/use-cases/ConfirmCheckoutUseCase.ts index a13bcc72c..bca6e71ac 100644 --- a/apps/companion/main/automation/application/use-cases/ConfirmCheckoutUseCase.ts +++ b/apps/companion/main/automation/application/use-cases/ConfirmCheckoutUseCase.ts @@ -1,8 +1,8 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; -import type { Logger } from '@core/shared/application'; -import type { CheckoutServicePort } from '../ports/CheckoutServicePort'; -import type { CheckoutConfirmationPort } from '../ports/CheckoutConfirmationPort'; import { CheckoutStateEnum } from '../../domain/value-objects/CheckoutState'; +import type { CheckoutConfirmationPort } from '../ports/CheckoutConfirmationPort'; +import type { CheckoutServicePort } from '../ports/CheckoutServicePort'; interface SessionMetadata { diff --git a/apps/companion/main/automation/application/use-cases/StartAutomationSessionUseCase.ts b/apps/companion/main/automation/application/use-cases/StartAutomationSessionUseCase.ts index 03dc38119..9ffeff091 100644 --- a/apps/companion/main/automation/application/use-cases/StartAutomationSessionUseCase.ts +++ b/apps/companion/main/automation/application/use-cases/StartAutomationSessionUseCase.ts @@ -1,11 +1,11 @@ import type { AsyncUseCase } from '@core/shared/application'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { AutomationSession } from '../../domain/entities/AutomationSession'; import type { HostedSessionConfig } from '../../domain/types/HostedSessionConfig'; +import type { SessionDTO } from '../dto/SessionDTO'; import { AutomationEnginePort } from '../ports/AutomationEnginePort'; import type { IBrowserAutomation } from '../ports/ScreenAutomationPort'; import { SessionRepositoryPort } from '../ports/SessionRepositoryPort'; -import type { SessionDTO } from '../dto/SessionDTO'; export class StartAutomationSessionUseCase implements AsyncUseCase { diff --git a/apps/companion/main/automation/application/use-cases/VerifyAuthenticatedPageUseCase.ts b/apps/companion/main/automation/application/use-cases/VerifyAuthenticatedPageUseCase.ts index ac0bf9daf..4825fba95 100644 --- a/apps/companion/main/automation/application/use-cases/VerifyAuthenticatedPageUseCase.ts +++ b/apps/companion/main/automation/application/use-cases/VerifyAuthenticatedPageUseCase.ts @@ -1,7 +1,7 @@ -import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import { BrowserAuthenticationState } from '../../domain/value-objects/BrowserAuthenticationState'; -import type { Logger } from '@core/shared/application'; +import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort'; /** * Use case for verifying browser shows authenticated page state. diff --git a/apps/companion/main/automation/infrastructure/adapters/logging/NoOpLogAdapter.ts b/apps/companion/main/automation/infrastructure/adapters/logging/NoOpLogAdapter.ts index 1f98367e9..c10abcc0f 100644 --- a/apps/companion/main/automation/infrastructure/adapters/logging/NoOpLogAdapter.ts +++ b/apps/companion/main/automation/infrastructure/adapters/logging/NoOpLogAdapter.ts @@ -1,6 +1,6 @@ -import type { LoggerPort } from '../../../application/ports/LoggerPort'; +import type { Logger } from '@core/shared/domain/Logger'; import type { LogContext } from '../../../application/ports/LoggerContext'; -import type { Logger } from '@core/shared/application'; +import type { LoggerPort } from '../../../application/ports/LoggerPort'; export class NoOpLogAdapter implements LoggerPort, Logger { debug(__message: string, __context?: LogContext): void {} diff --git a/apps/companion/main/automation/infrastructure/adapters/logging/PinoLogAdapter.ts b/apps/companion/main/automation/infrastructure/adapters/logging/PinoLogAdapter.ts index 34dcac957..9e2e33d9a 100644 --- a/apps/companion/main/automation/infrastructure/adapters/logging/PinoLogAdapter.ts +++ b/apps/companion/main/automation/infrastructure/adapters/logging/PinoLogAdapter.ts @@ -1,8 +1,8 @@ -import type { LoggerPort } from 'apps/companion/main/automation/application/ports/LoggerPort'; +import type { Logger } from '@core/shared/domain/Logger'; import type { LogContext } from 'apps/companion/main/automation/application/ports/LoggerContext'; import type { LogLevel } from 'apps/companion/main/automation/application/ports/LoggerLogLevel'; +import type { LoggerPort } from 'apps/companion/main/automation/application/ports/LoggerPort'; import { loadLoggingConfig, type LoggingEnvironmentConfig } from '../../config/LoggingConfig'; -import type { Logger } from '@core/shared/application'; const LOG_LEVEL_PRIORITY: Record = { debug: 10, diff --git a/core/admin/domain/entities/AdminUser.ts b/core/admin/domain/entities/AdminUser.ts index 90d7a259a..4c18c1565 100644 --- a/core/admin/domain/entities/AdminUser.ts +++ b/core/admin/domain/entities/AdminUser.ts @@ -1,9 +1,9 @@ -import type { Entity } from '@core/shared/domain'; -import { UserId } from '../value-objects/UserId'; +import type { Entity } from '@core/shared/domain/Entity'; +import { AdminDomainInvariantError, AdminDomainValidationError } from '../errors/AdminDomainError'; import { Email } from '../value-objects/Email'; +import { UserId } from '../value-objects/UserId'; import { UserRole } from '../value-objects/UserRole'; import { UserStatus } from '../value-objects/UserStatus'; -import { AdminDomainValidationError, AdminDomainInvariantError } from '../errors/AdminDomainError'; export interface AdminUserProps { id: UserId; diff --git a/core/analytics/application/use-cases/GetAnalyticsMetricsUseCase.test.ts b/core/analytics/application/use-cases/GetAnalyticsMetricsUseCase.test.ts index 27071498b..4f7271a53 100644 --- a/core/analytics/application/use-cases/GetAnalyticsMetricsUseCase.test.ts +++ b/core/analytics/application/use-cases/GetAnalyticsMetricsUseCase.test.ts @@ -1,6 +1,6 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { GetAnalyticsMetricsUseCase, type GetAnalyticsMetricsInput } from './GetAnalyticsMetricsUseCase'; -import type { Logger } from '@core/shared/application'; describe('GetAnalyticsMetricsUseCase', () => { let logger: Logger; diff --git a/core/analytics/application/use-cases/GetDashboardDataUseCase.test.ts b/core/analytics/application/use-cases/GetDashboardDataUseCase.test.ts index 17caac797..17161a101 100644 --- a/core/analytics/application/use-cases/GetDashboardDataUseCase.test.ts +++ b/core/analytics/application/use-cases/GetDashboardDataUseCase.test.ts @@ -1,6 +1,6 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { GetDashboardDataUseCase } from './GetDashboardDataUseCase'; -import type { Logger } from '@core/shared/application'; describe('GetDashboardDataUseCase', () => { let logger: Logger; diff --git a/core/analytics/application/use-cases/GetEntityAnalyticsQuery.test.ts b/core/analytics/application/use-cases/GetEntityAnalyticsQuery.test.ts index fe53bd0c3..69de23650 100644 --- a/core/analytics/application/use-cases/GetEntityAnalyticsQuery.test.ts +++ b/core/analytics/application/use-cases/GetEntityAnalyticsQuery.test.ts @@ -1,9 +1,7 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { GetEntityAnalyticsQuery, type GetEntityAnalyticsInput } from './GetEntityAnalyticsQuery'; -import type { PageViewRepository } from '../repositories/PageViewRepository'; -import type { EngagementRepository } from '@core/analytics/domain/repositories/EngagementRepository'; -import type { Logger } from '@core/shared/domain'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import type { EntityType } from '../../domain/types/PageView'; +import { GetEntityAnalyticsQuery, type GetEntityAnalyticsInput } from './GetEntityAnalyticsQuery'; describe('GetEntityAnalyticsQuery', () => { let pageViewRepository: { diff --git a/core/analytics/application/use-cases/RecordEngagementUseCase.test.ts b/core/analytics/application/use-cases/RecordEngagementUseCase.test.ts index b23541f5a..56de058f1 100644 --- a/core/analytics/application/use-cases/RecordEngagementUseCase.test.ts +++ b/core/analytics/application/use-cases/RecordEngagementUseCase.test.ts @@ -1,9 +1,8 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { RecordEngagementUseCase, type RecordEngagementInput } from './RecordEngagementUseCase'; -import type { EngagementRepository } from '../../domain/repositories/EngagementRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { EngagementEvent } from '../../domain/entities/EngagementEvent'; -import type { Logger } from '@core/shared/application'; import type { EngagementAction, EngagementEntityType } from '../../domain/types/EngagementEvent'; +import { RecordEngagementUseCase, type RecordEngagementInput } from './RecordEngagementUseCase'; describe('RecordEngagementUseCase', () => { let engagementRepository: { diff --git a/core/analytics/application/use-cases/RecordPageViewUseCase.test.ts b/core/analytics/application/use-cases/RecordPageViewUseCase.test.ts index 7e59ae000..07da86f5c 100644 --- a/core/analytics/application/use-cases/RecordPageViewUseCase.test.ts +++ b/core/analytics/application/use-cases/RecordPageViewUseCase.test.ts @@ -1,8 +1,8 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { RecordPageViewUseCase, type RecordPageViewInput } from './RecordPageViewUseCase'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { PageView } from '../../domain/entities/PageView'; -import type { Logger } from '@core/shared/application'; import type { EntityType, VisitorType } from '../../domain/types/PageView'; +import { RecordPageViewUseCase, type RecordPageViewInput } from './RecordPageViewUseCase'; describe('RecordPageViewUseCase', () => { let pageViewRepository: { diff --git a/core/analytics/domain/entities/AnalyticsSnapshot.ts b/core/analytics/domain/entities/AnalyticsSnapshot.ts index e15f22e0f..ff2cd4542 100644 --- a/core/analytics/domain/entities/AnalyticsSnapshot.ts +++ b/core/analytics/domain/entities/AnalyticsSnapshot.ts @@ -5,15 +5,15 @@ * Pre-calculated metrics for sponsor dashboard and entity analytics. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import type { - AnalyticsSnapshotProps, - AnalyticsMetrics, - SnapshotEntityType, - SnapshotPeriod, + AnalyticsMetrics, + AnalyticsSnapshotProps, + SnapshotEntityType, + SnapshotPeriod, } from '../types/AnalyticsSnapshot'; -export type { SnapshotEntityType, SnapshotPeriod } from '../types/AnalyticsSnapshot'; import { AnalyticsEntityId } from '../value-objects/AnalyticsEntityId'; +export type { SnapshotEntityType, SnapshotPeriod } from '../types/AnalyticsSnapshot'; export class AnalyticsSnapshot implements Entity { readonly id: string; diff --git a/core/analytics/domain/entities/EngagementEvent.ts b/core/analytics/domain/entities/EngagementEvent.ts index eeab6cf39..8d80fe1ed 100644 --- a/core/analytics/domain/entities/EngagementEvent.ts +++ b/core/analytics/domain/entities/EngagementEvent.ts @@ -5,15 +5,15 @@ * Tracks clicks, downloads, sign-ups, and other engagement actions. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import type { - EngagementAction, - EngagementEntityType, - EngagementEventProps, + EngagementAction, + EngagementEntityType, + EngagementEventProps, } from '../types/EngagementEvent'; +import { AnalyticsEntityId } from '../value-objects/AnalyticsEntityId'; export type { EngagementAction, EngagementEntityType } from '../types/EngagementEvent'; -import { AnalyticsEntityId } from '../value-objects/AnalyticsEntityId'; export class EngagementEvent implements Entity { readonly id: string; diff --git a/core/analytics/domain/entities/PageView.ts b/core/analytics/domain/entities/PageView.ts index 63e5df702..c300519e7 100644 --- a/core/analytics/domain/entities/PageView.ts +++ b/core/analytics/domain/entities/PageView.ts @@ -5,14 +5,14 @@ * Captures visitor interactions with leagues, drivers, teams, races. */ -import type { Entity } from '@core/shared/domain'; -import type { EntityType, VisitorType, PageViewProps } from '../types/PageView'; - -export type { EntityType, VisitorType } from '../types/PageView'; +import type { Entity } from '@core/shared/domain/Entity'; +import type { EntityType, PageViewProps, VisitorType } from '../types/PageView'; import { AnalyticsEntityId } from '../value-objects/AnalyticsEntityId'; import { AnalyticsSessionId } from '../value-objects/AnalyticsSessionId'; import { PageViewId } from '../value-objects/PageViewId'; +export type { EntityType, VisitorType } from '../types/PageView'; + export class PageView implements Entity { readonly entityType: EntityType; readonly visitorId: string | undefined; diff --git a/core/identity/application/use-cases/ForgotPasswordUseCase.test.ts b/core/identity/application/use-cases/ForgotPasswordUseCase.test.ts index 570d4d09b..8ee905c15 100644 --- a/core/identity/application/use-cases/ForgotPasswordUseCase.test.ts +++ b/core/identity/application/use-cases/ForgotPasswordUseCase.test.ts @@ -1,14 +1,10 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { ForgotPasswordUseCase } from './ForgotPasswordUseCase'; -import type { AuthRepository } from '../../domain/repositories/AuthRepository'; -import type { MagicLinkRepository } from '../../domain/repositories/MagicLinkRepository'; -import type { MagicLinkNotificationPort } from '../../domain/ports/MagicLinkNotificationPort'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { User } from '../../domain/entities/User'; -import { UserId } from '../../domain/value-objects/UserId'; import { PasswordHash } from '../../domain/value-objects/PasswordHash'; -import { EmailAddress } from '../../domain/value-objects/EmailAddress'; +import { UserId } from '../../domain/value-objects/UserId'; +import { ForgotPasswordUseCase } from './ForgotPasswordUseCase'; describe('ForgotPasswordUseCase', () => { let authRepo: { diff --git a/core/identity/application/use-cases/GetCurrentSessionUseCase.test.ts b/core/identity/application/use-cases/GetCurrentSessionUseCase.test.ts index 1489d96b6..db40fcccf 100644 --- a/core/identity/application/use-cases/GetCurrentSessionUseCase.test.ts +++ b/core/identity/application/use-cases/GetCurrentSessionUseCase.test.ts @@ -1,9 +1,8 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { vi, type Mock } from 'vitest'; -import { GetCurrentSessionUseCase } from './GetCurrentSessionUseCase'; import { User } from '../../domain/entities/User'; -import { UserRepository, StoredUser } from '../../domain/repositories/UserRepository'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { StoredUser } from '../../domain/repositories/UserRepository'; +import { GetCurrentSessionUseCase } from './GetCurrentSessionUseCase'; describe('GetCurrentSessionUseCase', () => { let useCase: GetCurrentSessionUseCase; diff --git a/core/identity/application/use-cases/GetCurrentSessionUseCase.ts b/core/identity/application/use-cases/GetCurrentSessionUseCase.ts index 1972d1fb2..f5a945146 100644 --- a/core/identity/application/use-cases/GetCurrentSessionUseCase.ts +++ b/core/identity/application/use-cases/GetCurrentSessionUseCase.ts @@ -1,8 +1,7 @@ -import { User } from '../../domain/entities/User'; -import { UserRepository } from '../../domain/repositories/UserRepository'; -import { Result } from '@core/shared/domain/Result'; +import { Result } from '@/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import { User } from '../../domain/entities/User'; export type GetCurrentSessionInput = { userId: string; diff --git a/core/identity/application/use-cases/GetCurrentUserSessionUseCase.test.ts b/core/identity/application/use-cases/GetCurrentUserSessionUseCase.test.ts index e23ac21a6..d17f3233d 100644 --- a/core/identity/application/use-cases/GetCurrentUserSessionUseCase.test.ts +++ b/core/identity/application/use-cases/GetCurrentUserSessionUseCase.test.ts @@ -1,8 +1,7 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { GetCurrentUserSessionUseCase } from './GetCurrentUserSessionUseCase'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { GetCurrentUserSessionUseCase } from './GetCurrentUserSessionUseCase'; describe('GetCurrentUserSessionUseCase', () => { let sessionPort: { diff --git a/core/identity/application/use-cases/GetCurrentUserSessionUseCase.ts b/core/identity/application/use-cases/GetCurrentUserSessionUseCase.ts index 6341bf398..cbfdec4b7 100644 --- a/core/identity/application/use-cases/GetCurrentUserSessionUseCase.ts +++ b/core/identity/application/use-cases/GetCurrentUserSessionUseCase.ts @@ -1,7 +1,7 @@ -import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort'; export type GetCurrentUserSessionInput = void; diff --git a/core/identity/application/use-cases/GetUserUseCase.test.ts b/core/identity/application/use-cases/GetUserUseCase.test.ts index 59b362e0f..76ad7e118 100644 --- a/core/identity/application/use-cases/GetUserUseCase.test.ts +++ b/core/identity/application/use-cases/GetUserUseCase.test.ts @@ -1,12 +1,6 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { GetUserUseCase } from './GetUserUseCase'; -import type { UserRepository } from '../../domain/repositories/UserRepository'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; -import { User } from '../../domain/entities/User'; -import { UserId } from '../../domain/value-objects/UserId'; -import { PasswordHash } from '../../domain/value-objects/PasswordHash'; -import { EmailAddress } from '../../domain/value-objects/EmailAddress'; describe('GetUserUseCase', () => { let userRepo: { diff --git a/core/identity/application/use-cases/HandleAuthCallbackUseCase.test.ts b/core/identity/application/use-cases/HandleAuthCallbackUseCase.test.ts index 395bb694e..c42b3ac5b 100644 --- a/core/identity/application/use-cases/HandleAuthCallbackUseCase.test.ts +++ b/core/identity/application/use-cases/HandleAuthCallbackUseCase.test.ts @@ -1,9 +1,8 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { HandleAuthCallbackUseCase } from './HandleAuthCallbackUseCase'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import type { IdentityProviderPort } from '../ports/IdentityProviderPort'; import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { HandleAuthCallbackUseCase } from './HandleAuthCallbackUseCase'; describe('HandleAuthCallbackUseCase', () => { let provider: { diff --git a/core/identity/application/use-cases/HandleAuthCallbackUseCase.ts b/core/identity/application/use-cases/HandleAuthCallbackUseCase.ts index 8300861b0..3268c74ff 100644 --- a/core/identity/application/use-cases/HandleAuthCallbackUseCase.ts +++ b/core/identity/application/use-cases/HandleAuthCallbackUseCase.ts @@ -1,8 +1,8 @@ -import type { AuthCallbackCommand, AuthenticatedUser, IdentityProviderPort } from '../ports/IdentityProviderPort'; -import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import type { AuthCallbackCommand, AuthenticatedUser, IdentityProviderPort } from '../ports/IdentityProviderPort'; +import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort'; export type HandleAuthCallbackInput = AuthCallbackCommand; diff --git a/core/identity/application/use-cases/LoginUseCase.test.ts b/core/identity/application/use-cases/LoginUseCase.test.ts index 5399fb928..968c9af03 100644 --- a/core/identity/application/use-cases/LoginUseCase.test.ts +++ b/core/identity/application/use-cases/LoginUseCase.test.ts @@ -1,13 +1,9 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { LoginUseCase } from './LoginUseCase'; -import type { AuthRepository } from '../../domain/repositories/AuthRepository'; -import type { PasswordHashingService } from '../../domain/services/PasswordHashingService'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { User } from '../../domain/entities/User'; -import { UserId } from '../../domain/value-objects/UserId'; import { PasswordHash } from '../../domain/value-objects/PasswordHash'; -import { EmailAddress } from '../../domain/value-objects/EmailAddress'; +import { UserId } from '../../domain/value-objects/UserId'; +import { LoginUseCase } from './LoginUseCase'; describe('LoginUseCase', () => { let authRepo: { diff --git a/core/identity/application/use-cases/LoginWithEmailUseCase.test.ts b/core/identity/application/use-cases/LoginWithEmailUseCase.test.ts index 230670620..edf6d6a9f 100644 --- a/core/identity/application/use-cases/LoginWithEmailUseCase.test.ts +++ b/core/identity/application/use-cases/LoginWithEmailUseCase.test.ts @@ -1,8 +1,7 @@ -import { describe, it, expect, vi, type Mock, beforeEach } from 'vitest'; -import { LoginWithEmailUseCase } from './LoginWithEmailUseCase'; -import type { UserRepository } from '../../domain/repositories/UserRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; -import type { Logger } from '@core/shared/application'; +import { LoginWithEmailUseCase } from './LoginWithEmailUseCase'; // Mock the PasswordHash module vi.mock('@core/identity/domain/value-objects/PasswordHash', () => ({ diff --git a/core/identity/application/use-cases/LoginWithEmailUseCase.ts b/core/identity/application/use-cases/LoginWithEmailUseCase.ts index 4c6d54fa9..6cda9cdb5 100644 --- a/core/identity/application/use-cases/LoginWithEmailUseCase.ts +++ b/core/identity/application/use-cases/LoginWithEmailUseCase.ts @@ -4,12 +4,11 @@ * Authenticates a user with email and password. */ -import type { UserRepository } from '../../domain/repositories/UserRepository'; -import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; +import { PasswordHash } from '@/identity/domain/value-objects/PasswordHash'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import { PasswordHash } from '@core/identity/domain/value-objects/PasswordHash'; +import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; export type LoginWithEmailInput = { email: string; diff --git a/core/identity/application/use-cases/LogoutUseCase.test.ts b/core/identity/application/use-cases/LogoutUseCase.test.ts index 7a89e5923..3a3aba5af 100644 --- a/core/identity/application/use-cases/LogoutUseCase.test.ts +++ b/core/identity/application/use-cases/LogoutUseCase.test.ts @@ -1,8 +1,7 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { LogoutUseCase } from './LogoutUseCase'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { LogoutUseCase } from './LogoutUseCase'; describe('LogoutUseCase', () => { let sessionPort: { diff --git a/core/identity/application/use-cases/ResetPasswordUseCase.test.ts b/core/identity/application/use-cases/ResetPasswordUseCase.test.ts index bd3967ff5..7fba61463 100644 --- a/core/identity/application/use-cases/ResetPasswordUseCase.test.ts +++ b/core/identity/application/use-cases/ResetPasswordUseCase.test.ts @@ -1,14 +1,9 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { ResetPasswordUseCase } from './ResetPasswordUseCase'; -import type { AuthRepository } from '../../domain/repositories/AuthRepository'; -import type { MagicLinkRepository } from '../../domain/repositories/MagicLinkRepository'; -import type { PasswordHashingService } from '../../domain/services/PasswordHashingService'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { User } from '../../domain/entities/User'; -import { UserId } from '../../domain/value-objects/UserId'; import { PasswordHash } from '../../domain/value-objects/PasswordHash'; -import { EmailAddress } from '../../domain/value-objects/EmailAddress'; +import { UserId } from '../../domain/value-objects/UserId'; +import { ResetPasswordUseCase } from './ResetPasswordUseCase'; describe('ResetPasswordUseCase', () => { let authRepo: { diff --git a/core/identity/application/use-cases/SignupSponsorUseCase.test.ts b/core/identity/application/use-cases/SignupSponsorUseCase.test.ts index 1329366e0..cacd6e702 100644 --- a/core/identity/application/use-cases/SignupSponsorUseCase.test.ts +++ b/core/identity/application/use-cases/SignupSponsorUseCase.test.ts @@ -1,10 +1,6 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { SignupSponsorUseCase } from './SignupSponsorUseCase'; -import type { AuthRepository } from '../../domain/repositories/AuthRepository'; -import type { CompanyRepository } from '../../domain/repositories/CompanyRepository'; -import type { PasswordHashingService } from '../../domain/services/PasswordHashingService'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; describe('SignupSponsorUseCase', () => { let authRepo: { diff --git a/core/identity/application/use-cases/SignupUseCase.test.ts b/core/identity/application/use-cases/SignupUseCase.test.ts index 6bdec269c..5641c337a 100644 --- a/core/identity/application/use-cases/SignupUseCase.test.ts +++ b/core/identity/application/use-cases/SignupUseCase.test.ts @@ -1,11 +1,9 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { SignupUseCase } from './SignupUseCase'; -import type { AuthRepository } from '../../domain/repositories/AuthRepository'; -import type { PasswordHashingService } from '../../domain/services/PasswordHashingService'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { User } from '../../domain/entities/User'; -import { UserId } from '../../domain/value-objects/UserId'; import { PasswordHash } from '../../domain/value-objects/PasswordHash'; +import { UserId } from '../../domain/value-objects/UserId'; +import { SignupUseCase } from './SignupUseCase'; describe('SignupUseCase', () => { let authRepo: { diff --git a/core/identity/application/use-cases/SignupWithEmailUseCase.test.ts b/core/identity/application/use-cases/SignupWithEmailUseCase.test.ts index c08513c6c..fa145024a 100644 --- a/core/identity/application/use-cases/SignupWithEmailUseCase.test.ts +++ b/core/identity/application/use-cases/SignupWithEmailUseCase.test.ts @@ -1,9 +1,7 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { SignupWithEmailUseCase } from './SignupWithEmailUseCase'; -import type { UserRepository } from '../../domain/repositories/UserRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { SignupWithEmailUseCase } from './SignupWithEmailUseCase'; describe('SignupWithEmailUseCase', () => { let userRepository: { diff --git a/core/identity/application/use-cases/SignupWithEmailUseCase.ts b/core/identity/application/use-cases/SignupWithEmailUseCase.ts index 315c83190..e0543c6db 100644 --- a/core/identity/application/use-cases/SignupWithEmailUseCase.ts +++ b/core/identity/application/use-cases/SignupWithEmailUseCase.ts @@ -1,15 +1,8 @@ -/** - * Signup with Email Use Case - * - * Creates a new user account with email and password. - */ - -import type { UserRepository, StoredUser } from '../../domain/repositories/UserRepository'; -import type { AuthenticatedUser } from '../ports/IdentityProviderPort'; -import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import type { StoredUser } from '../../domain/repositories/UserRepository'; +import type { AuthenticatedUser } from '../ports/IdentityProviderPort'; +import type { IdentitySessionPort } from '../ports/IdentitySessionPort'; export type SignupWithEmailInput = { email: string; diff --git a/core/identity/application/use-cases/StartAuthUseCase.test.ts b/core/identity/application/use-cases/StartAuthUseCase.test.ts index c6dc3a9f8..3fbdcc35f 100644 --- a/core/identity/application/use-cases/StartAuthUseCase.test.ts +++ b/core/identity/application/use-cases/StartAuthUseCase.test.ts @@ -1,8 +1,7 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { StartAuthUseCase } from './StartAuthUseCase'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import type { IdentityProviderPort } from '../ports/IdentityProviderPort'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { StartAuthUseCase } from './StartAuthUseCase'; describe('StartAuthUseCase', () => { let provider: { diff --git a/core/identity/application/use-cases/StartAuthUseCase.ts b/core/identity/application/use-cases/StartAuthUseCase.ts index 4458b0de8..c4f96c914 100644 --- a/core/identity/application/use-cases/StartAuthUseCase.ts +++ b/core/identity/application/use-cases/StartAuthUseCase.ts @@ -1,7 +1,7 @@ -import type { IdentityProviderPort, AuthProvider, StartAuthCommand } from '../ports/IdentityProviderPort'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import type { AuthProvider, IdentityProviderPort, StartAuthCommand } from '../ports/IdentityProviderPort'; export type StartAuthInput = { provider: AuthProvider; diff --git a/core/identity/application/use-cases/achievement/CreateAchievementUseCase.test.ts b/core/identity/application/use-cases/achievement/CreateAchievementUseCase.test.ts index eb97f2eee..dbb6725ae 100644 --- a/core/identity/application/use-cases/achievement/CreateAchievementUseCase.test.ts +++ b/core/identity/application/use-cases/achievement/CreateAchievementUseCase.test.ts @@ -1,8 +1,6 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { CreateAchievementUseCase, type IAchievementRepository } from './CreateAchievementUseCase'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; -import { Achievement } from '@core/identity/domain/entities/Achievement'; describe('CreateAchievementUseCase', () => { let achievementRepository: { diff --git a/core/identity/application/use-cases/achievement/CreateAchievementUseCase.ts b/core/identity/application/use-cases/achievement/CreateAchievementUseCase.ts index d1b70e11d..bc42a75a9 100644 --- a/core/identity/application/use-cases/achievement/CreateAchievementUseCase.ts +++ b/core/identity/application/use-cases/achievement/CreateAchievementUseCase.ts @@ -1,7 +1,7 @@ import { Achievement, AchievementProps } from '@core/identity/domain/entities/Achievement'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; export interface AchievementRepository { save(achievement: Achievement): Promise; diff --git a/core/identity/domain/entities/Achievement.ts b/core/identity/domain/entities/Achievement.ts index 39794fdd3..6cff622e3 100644 --- a/core/identity/domain/entities/Achievement.ts +++ b/core/identity/domain/entities/Achievement.ts @@ -5,7 +5,7 @@ * Achievements are categorized by role (driver, steward, admin) and type. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; export type AchievementCategory = 'driver' | 'steward' | 'admin' | 'community'; diff --git a/core/identity/domain/entities/AdminVoteSession.ts b/core/identity/domain/entities/AdminVoteSession.ts index f009d08d9..cb69ff207 100644 --- a/core/identity/domain/entities/AdminVoteSession.ts +++ b/core/identity/domain/entities/AdminVoteSession.ts @@ -1,5 +1,5 @@ -import type { Entity } from '@core/shared/domain'; -import { IdentityDomainValidationError, IdentityDomainInvariantError } from '../errors/IdentityDomainError'; +import type { Entity, IEntity } from '@core/shared/domain/Entity'; +import { IdentityDomainInvariantError, IdentityDomainValidationError } from '../errors/IdentityDomainError'; export interface AdminVote { voterId: string; diff --git a/core/identity/domain/entities/ExternalGameRatingProfile.ts b/core/identity/domain/entities/ExternalGameRatingProfile.ts index e436b3bb5..b1ab8a1ca 100644 --- a/core/identity/domain/entities/ExternalGameRatingProfile.ts +++ b/core/identity/domain/entities/ExternalGameRatingProfile.ts @@ -1,4 +1,4 @@ -import { Entity } from '@core/shared/domain'; +import { Entity } from '@core/shared/domain/Entity'; import { UserId } from '../value-objects/UserId'; import { GameKey } from '../value-objects/GameKey'; import { ExternalRating } from '../value-objects/ExternalRating'; diff --git a/core/identity/domain/entities/RatingEvent.ts b/core/identity/domain/entities/RatingEvent.ts index 9906c80f8..dfd21bf6f 100644 --- a/core/identity/domain/entities/RatingEvent.ts +++ b/core/identity/domain/entities/RatingEvent.ts @@ -1,8 +1,8 @@ -import type { Entity } from '@core/shared/domain'; -import { RatingEventId } from '../value-objects/RatingEventId'; -import { RatingDimensionKey } from '../value-objects/RatingDimensionKey'; +import type { Entity, IEntity } from '@core/shared/domain/Entity'; +import { IdentityDomainInvariantError, IdentityDomainValidationError } from '../errors/IdentityDomainError'; import { RatingDelta } from '../value-objects/RatingDelta'; -import { IdentityDomainValidationError, IdentityDomainInvariantError } from '../errors/IdentityDomainError'; +import { RatingDimensionKey } from '../value-objects/RatingDimensionKey'; +import { RatingEventId } from '../value-objects/RatingEventId'; export interface RatingEventSource { type: 'race' | 'penalty' | 'vote' | 'adminAction' | 'manualAdjustment'; diff --git a/core/identity/domain/entities/UserAchievement.ts b/core/identity/domain/entities/UserAchievement.ts index 87b5ed9e8..7ed3e830d 100644 --- a/core/identity/domain/entities/UserAchievement.ts +++ b/core/identity/domain/entities/UserAchievement.ts @@ -4,7 +4,7 @@ * Represents an achievement earned by a specific user. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; export interface UserAchievementProps { id: string; diff --git a/core/media/application/use-cases/DeleteMediaUseCase.test.ts b/core/media/application/use-cases/DeleteMediaUseCase.test.ts index 225be9203..6aafe7972 100644 --- a/core/media/application/use-cases/DeleteMediaUseCase.test.ts +++ b/core/media/application/use-cases/DeleteMediaUseCase.test.ts @@ -1,15 +1,14 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { - DeleteMediaUseCase, - type DeleteMediaInput, - type DeleteMediaErrorCode, -} from './DeleteMediaUseCase'; -import type { MediaRepository } from '../../domain/repositories/MediaRepository'; -import type { MediaStoragePort } from '../ports/MediaStoragePort'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { Media } from '../../domain/entities/Media'; +import type { MediaStoragePort } from '../ports/MediaStoragePort'; +import { + DeleteMediaUseCase, + type DeleteMediaErrorCode, + type DeleteMediaInput, +} from './DeleteMediaUseCase'; describe('DeleteMediaUseCase', () => { let mediaRepo: { diff --git a/core/media/application/use-cases/DeleteMediaUseCase.ts b/core/media/application/use-cases/DeleteMediaUseCase.ts index 0d90c1cf2..c9dabf045 100644 --- a/core/media/application/use-cases/DeleteMediaUseCase.ts +++ b/core/media/application/use-cases/DeleteMediaUseCase.ts @@ -4,11 +4,9 @@ * Handles the business logic for deleting media files. */ -import type { MediaRepository } from '../../domain/repositories/MediaRepository'; -import type { MediaStoragePort } from '../ports/MediaStoragePort'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import type { MediaStoragePort } from '../ports/MediaStoragePort'; export interface DeleteMediaInput { mediaId: string; diff --git a/core/media/application/use-cases/GetAvatarUseCase.test.ts b/core/media/application/use-cases/GetAvatarUseCase.test.ts index 549222587..0d84744ef 100644 --- a/core/media/application/use-cases/GetAvatarUseCase.test.ts +++ b/core/media/application/use-cases/GetAvatarUseCase.test.ts @@ -1,14 +1,13 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { - GetAvatarUseCase, - type GetAvatarInput, - type GetAvatarErrorCode, -} from './GetAvatarUseCase'; -import type { AvatarRepository } from '../../domain/repositories/AvatarRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { Avatar } from '../../domain/entities/Avatar'; +import { + GetAvatarUseCase, + type GetAvatarErrorCode, + type GetAvatarInput, +} from './GetAvatarUseCase'; describe('GetAvatarUseCase', () => { let avatarRepo: { diff --git a/core/media/application/use-cases/GetAvatarUseCase.ts b/core/media/application/use-cases/GetAvatarUseCase.ts index 872477a2a..42ec6caaa 100644 --- a/core/media/application/use-cases/GetAvatarUseCase.ts +++ b/core/media/application/use-cases/GetAvatarUseCase.ts @@ -4,8 +4,6 @@ * Handles the business logic for retrieving a driver's avatar. */ -import type { AvatarRepository } from '../../domain/repositories/AvatarRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; diff --git a/core/media/application/use-cases/GetMediaUseCase.test.ts b/core/media/application/use-cases/GetMediaUseCase.test.ts index d2f5e1c45..121dde98e 100644 --- a/core/media/application/use-cases/GetMediaUseCase.test.ts +++ b/core/media/application/use-cases/GetMediaUseCase.test.ts @@ -1,14 +1,13 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { - GetMediaUseCase, - type GetMediaInput, - type GetMediaErrorCode, -} from './GetMediaUseCase'; -import type { MediaRepository } from '../../domain/repositories/MediaRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { Media } from '../../domain/entities/Media'; +import { + GetMediaUseCase, + type GetMediaErrorCode, + type GetMediaInput, +} from './GetMediaUseCase'; describe('GetMediaUseCase', () => { let mediaRepo: { diff --git a/core/media/application/use-cases/GetMediaUseCase.ts b/core/media/application/use-cases/GetMediaUseCase.ts index bd9182e62..44588eb6d 100644 --- a/core/media/application/use-cases/GetMediaUseCase.ts +++ b/core/media/application/use-cases/GetMediaUseCase.ts @@ -4,8 +4,6 @@ * Handles the business logic for retrieving media information. */ -import type { MediaRepository } from '../../domain/repositories/MediaRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; diff --git a/core/media/application/use-cases/RequestAvatarGenerationUseCase.test.ts b/core/media/application/use-cases/RequestAvatarGenerationUseCase.test.ts index 74938d2c7..94e4907b1 100644 --- a/core/media/application/use-cases/RequestAvatarGenerationUseCase.test.ts +++ b/core/media/application/use-cases/RequestAvatarGenerationUseCase.test.ts @@ -1,16 +1,15 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { - RequestAvatarGenerationUseCase, - type RequestAvatarGenerationInput, - type RequestAvatarGenerationErrorCode, - type RequestAvatarGenerationResult, -} from './RequestAvatarGenerationUseCase'; -import type { AvatarGenerationRepository } from '../../domain/repositories/AvatarGenerationRepository'; -import type { FaceValidationPort } from '../ports/FaceValidationPort'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import type { AvatarGenerationPort } from '../ports/AvatarGenerationPort'; +import type { FaceValidationPort } from '../ports/FaceValidationPort'; +import { + RequestAvatarGenerationUseCase, + type RequestAvatarGenerationErrorCode, + type RequestAvatarGenerationInput, + type RequestAvatarGenerationResult, +} from './RequestAvatarGenerationUseCase'; vi.mock('uuid', () => ({ v4: () => 'request-1', diff --git a/core/media/application/use-cases/RequestAvatarGenerationUseCase.ts b/core/media/application/use-cases/RequestAvatarGenerationUseCase.ts index ff5d84d09..183cd1765 100644 --- a/core/media/application/use-cases/RequestAvatarGenerationUseCase.ts +++ b/core/media/application/use-cases/RequestAvatarGenerationUseCase.ts @@ -4,15 +4,14 @@ * Handles the business logic for requesting avatar generation from a face photo. */ +import { Result } from '@/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { v4 as uuidv4 } from 'uuid'; -import type { AvatarGenerationRepository } from '../../domain/repositories/AvatarGenerationRepository'; -import type { FaceValidationPort } from '../ports/FaceValidationPort'; -import type { AvatarGenerationPort } from '../ports/AvatarGenerationPort'; -import type { Logger } from '@core/shared/application'; import { AvatarGenerationRequest } from '../../domain/entities/AvatarGenerationRequest'; import type { RacingSuitColor } from '../../domain/types/AvatarGenerationRequest'; -import { Result } from '@core/shared/domain/Result'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import type { AvatarGenerationPort } from '../ports/AvatarGenerationPort'; +import type { FaceValidationPort } from '../ports/FaceValidationPort'; export interface RequestAvatarGenerationInput { userId: string; diff --git a/core/media/application/use-cases/SelectAvatarUseCase.test.ts b/core/media/application/use-cases/SelectAvatarUseCase.test.ts index 0c478101a..f6700a137 100644 --- a/core/media/application/use-cases/SelectAvatarUseCase.test.ts +++ b/core/media/application/use-cases/SelectAvatarUseCase.test.ts @@ -1,14 +1,13 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { - SelectAvatarUseCase, - type SelectAvatarErrorCode, - type SelectAvatarInput, -} from './SelectAvatarUseCase'; -import type { AvatarGenerationRepository } from '../../domain/repositories/AvatarGenerationRepository'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { AvatarGenerationRequest } from '../../domain/entities/AvatarGenerationRequest'; +import { + SelectAvatarUseCase, + type SelectAvatarErrorCode, + type SelectAvatarInput, +} from './SelectAvatarUseCase'; describe('SelectAvatarUseCase', () => { let avatarRepo: { findById: Mock; save: Mock }; diff --git a/core/media/application/use-cases/SelectAvatarUseCase.ts b/core/media/application/use-cases/SelectAvatarUseCase.ts index 48a65651b..448510b7c 100644 --- a/core/media/application/use-cases/SelectAvatarUseCase.ts +++ b/core/media/application/use-cases/SelectAvatarUseCase.ts @@ -4,8 +4,6 @@ * Handles the business logic for selecting a generated avatar from the options. */ -import type { AvatarGenerationRepository } from '../../domain/repositories/AvatarGenerationRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; diff --git a/core/media/application/use-cases/UpdateAvatarUseCase.test.ts b/core/media/application/use-cases/UpdateAvatarUseCase.test.ts index 05e4f5214..2806307c6 100644 --- a/core/media/application/use-cases/UpdateAvatarUseCase.test.ts +++ b/core/media/application/use-cases/UpdateAvatarUseCase.test.ts @@ -1,15 +1,14 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { - UpdateAvatarUseCase, - type UpdateAvatarErrorCode, - type UpdateAvatarInput, - type UpdateAvatarResult, -} from './UpdateAvatarUseCase'; -import type { AvatarRepository } from '../../domain/repositories/AvatarRepository'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { Avatar } from '../../domain/entities/Avatar'; +import { + UpdateAvatarUseCase, + type UpdateAvatarErrorCode, + type UpdateAvatarInput, + type UpdateAvatarResult, +} from './UpdateAvatarUseCase'; vi.mock('uuid', () => ({ v4: () => 'avatar-1', diff --git a/core/media/application/use-cases/UpdateAvatarUseCase.ts b/core/media/application/use-cases/UpdateAvatarUseCase.ts index c4696b402..4e719f0d1 100644 --- a/core/media/application/use-cases/UpdateAvatarUseCase.ts +++ b/core/media/application/use-cases/UpdateAvatarUseCase.ts @@ -4,13 +4,12 @@ * Handles the business logic for updating a driver's avatar. */ -import type { Logger } from '@core/shared/application'; +import { AvatarId } from '@/media/domain/value-objects/AvatarId'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { v4 as uuidv4 } from 'uuid'; import { Avatar } from '../../domain/entities/Avatar'; -import type { AvatarRepository } from '../../domain/repositories/AvatarRepository'; -import { AvatarId } from '../../domain/value-objects/AvatarId'; export interface UpdateAvatarInput { driverId: string; diff --git a/core/media/application/use-cases/UploadMediaUseCase.test.ts b/core/media/application/use-cases/UploadMediaUseCase.test.ts index 9e42b43c7..037e889bd 100644 --- a/core/media/application/use-cases/UploadMediaUseCase.test.ts +++ b/core/media/application/use-cases/UploadMediaUseCase.test.ts @@ -1,18 +1,17 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { Readable } from 'node:stream'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { - UploadMediaUseCase, - type MulterFile, - type UploadMediaErrorCode, - type UploadMediaInput, - type UploadMediaResult, -} from './UploadMediaUseCase'; -import type { MediaRepository } from '../../domain/repositories/MediaRepository'; -import type { MediaStoragePort } from '../ports/MediaStoragePort'; +import { Readable } from 'node:stream'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { Media } from '../../domain/entities/Media'; +import type { MediaStoragePort } from '../ports/MediaStoragePort'; +import { + UploadMediaUseCase, + type MulterFile, + type UploadMediaErrorCode, + type UploadMediaInput, + type UploadMediaResult, +} from './UploadMediaUseCase'; vi.mock('uuid', () => ({ v4: () => 'media-1', diff --git a/core/media/application/use-cases/UploadMediaUseCase.ts b/core/media/application/use-cases/UploadMediaUseCase.ts index ec515855d..5aeb966f0 100644 --- a/core/media/application/use-cases/UploadMediaUseCase.ts +++ b/core/media/application/use-cases/UploadMediaUseCase.ts @@ -4,13 +4,11 @@ * Handles the business logic for uploading media files. */ -import type { MediaRepository } from '../../domain/repositories/MediaRepository'; -import type { MediaStoragePort } from '../ports/MediaStoragePort'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { Media } from '../../domain/entities/Media'; import { v4 as uuidv4 } from 'uuid'; +import { Media } from '../../domain/entities/Media'; +import type { MediaStoragePort } from '../ports/MediaStoragePort'; // Define Multer file type locally since @types/multer is not available export interface MulterFile { diff --git a/core/media/domain/entities/Avatar.ts b/core/media/domain/entities/Avatar.ts index 7a8a6f461..25f0947ff 100644 --- a/core/media/domain/entities/Avatar.ts +++ b/core/media/domain/entities/Avatar.ts @@ -4,7 +4,7 @@ * Represents a user's selected avatar. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { MediaUrl } from '../value-objects/MediaUrl'; export interface AvatarProps { diff --git a/core/media/domain/entities/AvatarGenerationRequest.ts b/core/media/domain/entities/AvatarGenerationRequest.ts index 3864145d0..8d131d87b 100644 --- a/core/media/domain/entities/AvatarGenerationRequest.ts +++ b/core/media/domain/entities/AvatarGenerationRequest.ts @@ -4,12 +4,12 @@ * Represents a request to generate a racing avatar from a face photo. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import type { - AvatarGenerationRequestProps, - AvatarGenerationStatus, - AvatarStyle, - RacingSuitColor, + AvatarGenerationRequestProps, + AvatarGenerationStatus, + AvatarStyle, + RacingSuitColor, } from '../types/AvatarGenerationRequest'; import { MediaUrl } from '../value-objects/MediaUrl'; diff --git a/core/media/domain/entities/Media.ts b/core/media/domain/entities/Media.ts index 50fc476bb..230f9fd3d 100644 --- a/core/media/domain/entities/Media.ts +++ b/core/media/domain/entities/Media.ts @@ -4,7 +4,7 @@ * Represents a media file (image, video, etc.) stored in the system. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { MediaUrl } from '../value-objects/MediaUrl'; export type MediaType = 'image' | 'video' | 'document'; diff --git a/core/notifications/application/use-cases/GetAllNotificationsUseCase.ts b/core/notifications/application/use-cases/GetAllNotificationsUseCase.ts index f6b3b9832..b1eaf4354 100644 --- a/core/notifications/application/use-cases/GetAllNotificationsUseCase.ts +++ b/core/notifications/application/use-cases/GetAllNotificationsUseCase.ts @@ -4,7 +4,7 @@ * Retrieves all notifications for a recipient. */ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Notification } from '../../domain/entities/Notification'; @@ -23,7 +23,7 @@ export type GetAllNotificationsErrorCode = 'REPOSITORY_ERROR'; export class GetAllNotificationsUseCase { constructor( - private readonly notificationRepository: INotificationRepository, + private readonly notificationRepository: NotificationRepository, private readonly logger: Logger, ) {} diff --git a/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.test.ts b/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.test.ts index bc10240bc..dcb524a9b 100644 --- a/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.test.ts +++ b/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.test.ts @@ -1,13 +1,12 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { - GetUnreadNotificationsUseCase, - type GetUnreadNotificationsInput, -} from './GetUnreadNotificationsUseCase'; -import type { NotificationRepository } from '../../domain/repositories/NotificationRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { Notification } from '../../domain/entities/Notification'; +import { + GetUnreadNotificationsUseCase, + type GetUnreadNotificationsInput, +} from './GetUnreadNotificationsUseCase'; interface NotificationRepositoryMock { findUnreadByRecipientId: Mock; diff --git a/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.ts b/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.ts index 750200aa3..d17dd99bc 100644 --- a/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.ts +++ b/core/notifications/application/use-cases/GetUnreadNotificationsUseCase.ts @@ -4,15 +4,12 @@ * Retrieves unread notifications for a recipient. */ -import type { Logger } from '@core/shared/application'; +import { NotificationRepository } from '@/notifications/domain/repositories/NotificationRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Notification } from '../../domain/entities/Notification'; -import type { NotificationRepository } from '../../domain/repositories/NotificationRepository'; -export type GetUnreadNotificationsInput = { - recipientId: string; -}; export interface GetUnreadNotificationsResult { notifications: Notification[]; @@ -23,7 +20,7 @@ export type GetUnreadNotificationsErrorCode = 'REPOSITORY_ERROR'; export class GetUnreadNotificationsUseCase { constructor( - private readonly notificationRepository: INotificationRepository, + private readonly notificationRepository: NotificationRepository, private readonly logger: Logger, ) {} diff --git a/core/notifications/application/use-cases/MarkNotificationReadUseCase.test.ts b/core/notifications/application/use-cases/MarkNotificationReadUseCase.test.ts index b0374618a..49fe446e8 100644 --- a/core/notifications/application/use-cases/MarkNotificationReadUseCase.test.ts +++ b/core/notifications/application/use-cases/MarkNotificationReadUseCase.test.ts @@ -1,17 +1,16 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import { - MarkNotificationReadUseCase, - type MarkNotificationReadCommand, - MarkAllNotificationsReadUseCase, - type MarkAllNotificationsReadInput, - DismissNotificationUseCase, - type DismissNotificationCommand, -} from './MarkNotificationReadUseCase'; -import type { NotificationRepository } from '../../domain/repositories/NotificationRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { Notification } from '../../domain/entities/Notification'; +import { + DismissNotificationUseCase, + MarkAllNotificationsReadUseCase, + MarkNotificationReadUseCase, + type DismissNotificationCommand, + type MarkAllNotificationsReadInput, + type MarkNotificationReadCommand, +} from './MarkNotificationReadUseCase'; interface NotificationRepositoryMock { findById: Mock; diff --git a/core/notifications/application/use-cases/MarkNotificationReadUseCase.ts b/core/notifications/application/use-cases/MarkNotificationReadUseCase.ts index a78ec9c29..86a1f9ebc 100644 --- a/core/notifications/application/use-cases/MarkNotificationReadUseCase.ts +++ b/core/notifications/application/use-cases/MarkNotificationReadUseCase.ts @@ -4,15 +4,11 @@ * Marks a notification as read. */ -import type { Logger } from '@core/shared/application'; +import { NotificationRepository } from '@/notifications/domain/repositories/NotificationRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { NotificationRepository } from '../../domain/repositories/NotificationRepository'; -export interface MarkNotificationReadCommand { - notificationId: string; - recipientId: string; // For validation -} export interface MarkNotificationReadResult { notificationId: string; @@ -27,7 +23,7 @@ export type MarkNotificationReadErrorCode = export class MarkNotificationReadUseCase { constructor( - private readonly notificationRepository: INotificationRepository, + private readonly notificationRepository: NotificationRepository, private readonly logger: Logger, ) {} diff --git a/core/notifications/application/use-cases/NotificationPreferencesUseCases.test.ts b/core/notifications/application/use-cases/NotificationPreferencesUseCases.test.ts index 9e6ad46b3..470129104 100644 --- a/core/notifications/application/use-cases/NotificationPreferencesUseCases.test.ts +++ b/core/notifications/application/use-cases/NotificationPreferencesUseCases.test.ts @@ -1,21 +1,20 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { describe, expect, it, vi, type Mock, beforeEach } from 'vitest'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; import type { ChannelPreference, NotificationPreference, TypePreference } from '../../domain/entities/NotificationPreference'; -import type { NotificationPreferenceRepository } from '../../domain/repositories/NotificationPreferenceRepository'; import type { NotificationChannel, NotificationType } from '../../domain/types/NotificationTypes'; import { - GetNotificationPreferencesQuery, - SetDigestModeUseCase, - UpdateChannelPreferenceUseCase, - UpdateQuietHoursUseCase, - UpdateTypePreferenceUseCase, - type GetNotificationPreferencesInput, - type SetDigestModeCommand, - type UpdateChannelPreferenceCommand, - type UpdateQuietHoursCommand, - type UpdateTypePreferenceCommand, + GetNotificationPreferencesQuery, + SetDigestModeUseCase, + UpdateChannelPreferenceUseCase, + UpdateQuietHoursUseCase, + UpdateTypePreferenceUseCase, + type GetNotificationPreferencesInput, + type SetDigestModeCommand, + type UpdateChannelPreferenceCommand, + type UpdateQuietHoursCommand, + type UpdateTypePreferenceCommand, } from './NotificationPreferencesUseCases'; describe('NotificationPreferencesUseCases', () => { diff --git a/core/notifications/application/use-cases/NotificationPreferencesUseCases.ts b/core/notifications/application/use-cases/NotificationPreferencesUseCases.ts index 56cc87bc9..53c4ca335 100644 --- a/core/notifications/application/use-cases/NotificationPreferencesUseCases.ts +++ b/core/notifications/application/use-cases/NotificationPreferencesUseCases.ts @@ -4,13 +4,13 @@ * Manages user notification preferences. */ -import type { Logger } from '@core/shared/application'; +import { NotificationPreferenceRepository } from '@/notifications/domain/repositories/NotificationPreferenceRepository'; +import { NotificationChannel, NotificationType } from '@/notifications/domain/types/NotificationTypes'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { NotificationPreference } from '../../domain/entities/NotificationPreference'; import type { ChannelPreference, TypePreference } from '../../domain/entities/NotificationPreference'; -import type { NotificationPreferenceRepository } from '../../domain/repositories/NotificationPreferenceRepository'; -import type { NotificationType, NotificationChannel } from '../../domain/types/NotificationTypes'; +import { NotificationPreference } from '../../domain/entities/NotificationPreference'; /** * Query: GetNotificationPreferencesQuery @@ -27,7 +27,7 @@ export type GetNotificationPreferencesErrorCode = 'REPOSITORY_ERROR'; export class GetNotificationPreferencesQuery { constructor( - private readonly preferenceRepository: INotificationPreferenceRepository, + private readonly preferenceRepository: NotificationPreferenceRepository, private readonly logger: Logger, ) {} diff --git a/core/notifications/application/use-cases/SendNotificationUseCase.test.ts b/core/notifications/application/use-cases/SendNotificationUseCase.test.ts index 5941f2d30..9de7d1ba7 100644 --- a/core/notifications/application/use-cases/SendNotificationUseCase.test.ts +++ b/core/notifications/application/use-cases/SendNotificationUseCase.test.ts @@ -1,19 +1,17 @@ -import { describe, it, expect, vi, type Mock } from 'vitest'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { describe, expect, it, vi, type Mock } from 'vitest'; import { - SendNotificationUseCase, - type SendNotificationCommand, - type SendNotificationErrorCode, - type SendNotificationResult, + SendNotificationUseCase, + type SendNotificationCommand, + type SendNotificationErrorCode, + type SendNotificationResult, } from './SendNotificationUseCase'; -import type { NotificationRepository } from '../../domain/repositories/NotificationRepository'; -import type { NotificationPreferenceRepository } from '../../domain/repositories/NotificationPreferenceRepository'; -import type { NotificationGatewayRegistry } from '../ports/NotificationGateway'; import type { NotificationChannel, NotificationType } from '../../domain/types/NotificationTypes'; +import type { NotificationGatewayRegistry } from '../ports/NotificationGateway'; vi.mock('uuid', () => ({ v4: () => 'notif-1', diff --git a/core/notifications/application/use-cases/SendNotificationUseCase.ts b/core/notifications/application/use-cases/SendNotificationUseCase.ts index 96018ba33..5765813e4 100644 --- a/core/notifications/application/use-cases/SendNotificationUseCase.ts +++ b/core/notifications/application/use-cases/SendNotificationUseCase.ts @@ -5,15 +5,13 @@ * based on their preferences. */ -import type { Logger } from '@core/shared/application'; +import { NotificationChannel, NotificationType } from '@/notifications/domain/types/NotificationTypes'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { v4 as uuid } from 'uuid'; import type { NotificationData } from '../../domain/entities/Notification'; import { Notification } from '../../domain/entities/Notification'; -import type { NotificationPreferenceRepository } from '../../domain/repositories/NotificationPreferenceRepository'; -import type { NotificationRepository } from '../../domain/repositories/NotificationRepository'; -import type { NotificationChannel, NotificationType } from '../../domain/types/NotificationTypes'; import type { NotificationDeliveryResult, NotificationGatewayRegistry } from '../ports/NotificationGateway'; export interface SendNotificationCommand { diff --git a/core/notifications/domain/entities/Notification.ts b/core/notifications/domain/entities/Notification.ts index 7078fa34b..8381073b1 100644 --- a/core/notifications/domain/entities/Notification.ts +++ b/core/notifications/domain/entities/Notification.ts @@ -5,11 +5,11 @@ * Immutable entity with factory methods and domain validation. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { NotificationDomainError } from '../errors/NotificationDomainError'; import { NotificationId } from '../value-objects/NotificationId'; -import type { NotificationType, NotificationChannel } from '../types/NotificationTypes'; +import type { NotificationChannel, NotificationType } from '../types/NotificationTypes'; export type NotificationStatus = 'unread' | 'read' | 'dismissed' | 'action_required'; diff --git a/core/notifications/domain/entities/NotificationPreference.ts b/core/notifications/domain/entities/NotificationPreference.ts index c083aa951..cbf89f59c 100644 --- a/core/notifications/domain/entities/NotificationPreference.ts +++ b/core/notifications/domain/entities/NotificationPreference.ts @@ -4,9 +4,9 @@ * Represents a user's notification preferences for different channels and types. */ -import type { Entity } from '@core/shared/domain'; -import type { NotificationType, NotificationChannel } from '../types/NotificationTypes'; +import type { Entity } from '@core/shared/domain/Entity'; import { NotificationDomainError } from '../errors/NotificationDomainError'; +import type { NotificationChannel, NotificationType } from '../types/NotificationTypes'; import { QuietHours } from '../value-objects/QuietHours'; export interface ChannelPreference { diff --git a/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.test.ts b/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.test.ts index 3cc6c586d..a3810b23a 100644 --- a/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.test.ts +++ b/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.test.ts @@ -1,14 +1,9 @@ import type { NotificationService } from '@core/notifications/application/ports/NotificationService'; -import type { WalletRepository } from '@core/payments/domain/repositories/WalletRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { LeagueWallet } from '../../domain/entities/league-wallet/LeagueWallet'; import { Season } from '../../domain/entities/season/Season'; import { SponsorshipRequest } from '../../domain/entities/SponsorshipRequest'; -import type { LeagueWalletRepository } from '../../domain/repositories/LeagueWalletRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import type { SeasonSponsorshipRepository } from '../../domain/repositories/SeasonSponsorshipRepository'; -import type { SponsorshipRequestRepository } from '../../domain/repositories/SponsorshipRequestRepository'; import { Money } from '../../domain/value-objects/Money'; import { AcceptSponsorshipRequestUseCase } from './AcceptSponsorshipRequestUseCase'; diff --git a/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.ts b/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.ts index b79a99b8b..5ae9c6023 100644 --- a/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.ts +++ b/core/racing/application/use-cases/AcceptSponsorshipRequestUseCase.ts @@ -6,15 +6,9 @@ */ import type { NotificationService } from '@core/notifications/application/ports/NotificationService'; -import type { WalletRepository } from '@core/payments/domain/repositories/WalletRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { SeasonSponsorship } from '../../domain/entities/season/SeasonSponsorship'; -import type { LeagueWalletRepository } from '../../domain/repositories/LeagueWalletRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import type { SeasonSponsorshipRepository } from '../../domain/repositories/SeasonSponsorshipRepository'; -import type { SponsorshipRequestRepository } from '../../domain/repositories/SponsorshipRequestRepository'; export interface AcceptSponsorshipRequestInput { requestId: string; diff --git a/core/racing/application/use-cases/ApplyForSponsorshipUseCase.test.ts b/core/racing/application/use-cases/ApplyForSponsorshipUseCase.test.ts index 81b327084..53d51c370 100644 --- a/core/racing/application/use-cases/ApplyForSponsorshipUseCase.test.ts +++ b/core/racing/application/use-cases/ApplyForSponsorshipUseCase.test.ts @@ -1,10 +1,7 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { ApplyForSponsorshipUseCase } from './ApplyForSponsorshipUseCase'; -import type { SponsorshipRequestRepository } from '../../domain/repositories/SponsorshipRequestRepository'; -import type { SponsorshipPricingRepository } from '../../domain/repositories/SponsorshipPricingRepository'; -import type { SponsorRepository } from '../../domain/repositories/SponsorRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { Money } from '../../domain/value-objects/Money'; +import { ApplyForSponsorshipUseCase } from './ApplyForSponsorshipUseCase'; describe('ApplyForSponsorshipUseCase', () => { let mockSponsorshipRequestRepo: { diff --git a/core/racing/application/use-cases/ApplyForSponsorshipUseCase.ts b/core/racing/application/use-cases/ApplyForSponsorshipUseCase.ts index 9a2c56adf..2f5f8731b 100644 --- a/core/racing/application/use-cases/ApplyForSponsorshipUseCase.ts +++ b/core/racing/application/use-cases/ApplyForSponsorshipUseCase.ts @@ -5,14 +5,11 @@ * (driver, team, race, or season/league). */ -import { SponsorshipRequest } from '../../domain/entities/SponsorshipRequest'; -import type { SponsorshipRequestRepository } from '../../domain/repositories/SponsorshipRequestRepository'; -import type { SponsorshipPricingRepository } from '../../domain/repositories/SponsorshipPricingRepository'; -import type { SponsorRepository } from '../../domain/repositories/SponsorRepository'; -import { Money, isCurrency } from '../../domain/value-objects/Money'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { Result } from '@/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { SponsorshipRequest } from '../../domain/entities/SponsorshipRequest'; +import { Money, isCurrency } from '../../domain/value-objects/Money'; export interface ApplyForSponsorshipInput { sponsorId: string; diff --git a/core/racing/application/use-cases/ApplyPenaltyUseCase.test.ts b/core/racing/application/use-cases/ApplyPenaltyUseCase.test.ts index 84cc01984..c4743097b 100644 --- a/core/racing/application/use-cases/ApplyPenaltyUseCase.test.ts +++ b/core/racing/application/use-cases/ApplyPenaltyUseCase.test.ts @@ -1,9 +1,6 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { ApplyPenaltyUseCase, type ApplyPenaltyResult } from './ApplyPenaltyUseCase'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { ProtestRepository } from '../../domain/repositories/ProtestRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; +import { ApplyPenaltyUseCase } from './ApplyPenaltyUseCase'; + describe('ApplyPenaltyUseCase', () => { let mockPenaltyRepo: { create: Mock; @@ -46,15 +43,11 @@ describe('ApplyPenaltyUseCase', () => { }); it('should return error when race does not exist', async () => { - const output: { present: Mock } = { - present: vi.fn(), - }; - - const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as unknown as IPenaltyRepository, - mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository, - mockLogger as unknown as Logger); + const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as any, + mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any, + mockLogger as any); mockRaceRepo.findById.mockResolvedValue(null); @@ -68,19 +61,15 @@ describe('ApplyPenaltyUseCase', () => { }); expect(result.isOk()).toBe(false); - expect(result.error!.code).toBe('RACE_NOT_FOUND'); + expect(result.unwrapErr().code).toBe('RACE_NOT_FOUND'); }); it('should return error when steward does not have authority', async () => { - const output: { present: Mock } = { - present: vi.fn(), - }; - - const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as unknown as IPenaltyRepository, - mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository, - mockLogger as unknown as Logger); + const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as any, + mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any, + mockLogger as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); @@ -102,19 +91,15 @@ describe('ApplyPenaltyUseCase', () => { }); expect(result.isOk()).toBe(false); - expect(result.error!.code).toBe('INSUFFICIENT_AUTHORITY'); + expect(result.unwrapErr().code).toBe('INSUFFICIENT_AUTHORITY'); }); it('should return error when protest does not exist', async () => { - const output: { present: Mock } = { - present: vi.fn(), - }; - - const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as unknown as IPenaltyRepository, - mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository, - mockLogger as unknown as Logger); + const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as any, + mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any, + mockLogger as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); @@ -138,19 +123,15 @@ describe('ApplyPenaltyUseCase', () => { }); expect(result.isOk()).toBe(false); - expect(result.error!.code).toBe('PROTEST_NOT_FOUND'); + expect(result.unwrapErr().code).toBe('PROTEST_NOT_FOUND'); }); it('should return error when protest is not upheld', async () => { - const output: { present: Mock } = { - present: vi.fn(), - }; - - const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as unknown as IPenaltyRepository, - mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository, - mockLogger as unknown as Logger); + const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as any, + mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any, + mockLogger as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); @@ -174,19 +155,15 @@ describe('ApplyPenaltyUseCase', () => { }); expect(result.isOk()).toBe(false); - expect(result.error!.code).toBe('PROTEST_NOT_UPHELD'); + expect(result.unwrapErr().code).toBe('PROTEST_NOT_UPHELD'); }); it('should return error when protest is not for this race', async () => { - const output: { present: Mock } = { - present: vi.fn(), - }; - - const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as unknown as IPenaltyRepository, - mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository, - mockLogger as unknown as Logger); + const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as any, + mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any, + mockLogger as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); @@ -210,19 +187,15 @@ describe('ApplyPenaltyUseCase', () => { }); expect(result.isOk()).toBe(false); - expect(result.error!.code).toBe('PROTEST_NOT_FOR_RACE'); + expect(result.unwrapErr().code).toBe('PROTEST_NOT_FOR_RACE'); }); it('should create penalty and return result on success', async () => { - const output: { present: Mock } = { - present: vi.fn(), - }; - - const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as unknown as IPenaltyRepository, - mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository, - mockLogger as unknown as Logger); + const useCase = new ApplyPenaltyUseCase(mockPenaltyRepo as any, + mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any, + mockLogger as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); @@ -246,22 +219,11 @@ describe('ApplyPenaltyUseCase', () => { }); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const presented = (expect(presented).toEqual({ penaltyId: expect.any(String) }); + const presented = result.unwrap(); + expect(presented.penaltyId).toBeDefined(); expect(mockPenaltyRepo.create).toHaveBeenCalledTimes(1); - const createdPenalty = (mockPenaltyRepo.create as Mock).mock.calls[0]?.[0] as unknown as { - leagueId: unknown; - raceId: unknown; - driverId: unknown; - type: string; - value?: number; - reason: string; - issuedBy: unknown; - status: unknown; - notes?: string; - }; + const createdPenalty = (mockPenaltyRepo.create as Mock).mock.calls[0]?.[0] as any; type ToStringable = { toString(): string }; const asString = (value: unknown): string => { @@ -287,4 +249,4 @@ describe('ApplyPenaltyUseCase', () => { expect(asString(createdPenalty.status)).toBe('pending'); expect(createdPenalty.notes).toBe('Test notes'); }); -}); \ No newline at end of file +}); diff --git a/core/racing/application/use-cases/ApplyPenaltyUseCase.ts b/core/racing/application/use-cases/ApplyPenaltyUseCase.ts index 66414ded9..d3bd70d88 100644 --- a/core/racing/application/use-cases/ApplyPenaltyUseCase.ts +++ b/core/racing/application/use-cases/ApplyPenaltyUseCase.ts @@ -5,15 +5,11 @@ * The penalty can be standalone or linked to an upheld protest. */ -import { Penalty } from '../../domain/entities/penalty/Penalty'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { ProtestRepository } from '../../domain/repositories/ProtestRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import { randomUUID } from 'crypto'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { Result } from '@/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { randomUUID } from 'crypto'; +import { Penalty } from '../../domain/entities/penalty/Penalty'; export interface ApplyPenaltyInput { raceId: string; diff --git a/core/racing/application/use-cases/CancelRaceUseCase.test.ts b/core/racing/application/use-cases/CancelRaceUseCase.test.ts index 07c6dc432..4cb547c83 100644 --- a/core/racing/application/use-cases/CancelRaceUseCase.test.ts +++ b/core/racing/application/use-cases/CancelRaceUseCase.test.ts @@ -1,9 +1,8 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { CancelRaceUseCase, type CancelRaceResult } from './CancelRaceUseCase'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { Logger } from '@core/shared/application'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { Race } from '../../domain/entities/Race'; import { SessionType } from '../../domain/value-objects/SessionType'; +import { CancelRaceUseCase } from './CancelRaceUseCase'; + describe('CancelRaceUseCase', () => { let useCase: CancelRaceUseCase; let raceRepository: { @@ -16,6 +15,7 @@ describe('CancelRaceUseCase', () => { info: Mock; error: Mock; }; + beforeEach(() => { raceRepository = { findById: vi.fn(), @@ -27,8 +27,8 @@ describe('CancelRaceUseCase', () => { info: vi.fn(), error: vi.fn(), }; - useCase = new CancelRaceUseCase(raceRepository as unknown as IRaceRepository, - logger as unknown as Logger); + useCase = new CancelRaceUseCase(raceRepository as any, + logger as any); }); it('should cancel race successfully', async () => { @@ -48,14 +48,14 @@ describe('CancelRaceUseCase', () => { const result = await useCase.execute({ raceId, cancelledById: 'admin-1' }); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(raceRepository.findById).toHaveBeenCalledWith(raceId); expect(raceRepository.update).toHaveBeenCalledTimes(1); const updatedRace = (raceRepository.update as Mock).mock.calls[0]?.[0] as Race; expect(updatedRace.id).toBe(raceId); expect(updatedRace.status.toString()).toBe('cancelled'); - const presented = (expect(presented.race.id).toBe(raceId); + expect(presented.race.id).toBe(raceId); expect(presented.race.status.toString()).toBe('cancelled'); }); @@ -67,7 +67,7 @@ describe('CancelRaceUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr().code).toBe('RACE_NOT_FOUND'); - }); + }); it('should return domain error if race is already cancelled', async () => { const raceId = 'race-1'; @@ -91,7 +91,7 @@ describe('CancelRaceUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toContain('already cancelled'); } - }); + }); it('should return domain error if race is completed', async () => { const raceId = 'race-1'; @@ -115,5 +115,5 @@ describe('CancelRaceUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toContain('completed race'); } - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/CancelRaceUseCase.ts b/core/racing/application/use-cases/CancelRaceUseCase.ts index f440c656a..f60a3a5e1 100644 --- a/core/racing/application/use-cases/CancelRaceUseCase.ts +++ b/core/racing/application/use-cases/CancelRaceUseCase.ts @@ -1,5 +1,3 @@ -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Race } from '../../domain/entities/Race'; diff --git a/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.test.ts b/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.test.ts index 6ecfac221..f67788af4 100644 --- a/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.test.ts +++ b/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.test.ts @@ -1,13 +1,9 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { CloseRaceEventStewardingUseCase, type CloseRaceEventStewardingResult } from './CloseRaceEventStewardingUseCase'; -import type { RaceEventRepository } from '../../domain/repositories/RaceEventRepository'; -import type { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { DomainEventPublisher } from '@core/shared/domain/DomainEvent'; -import type { Logger } from '@core/shared/application'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { RaceEvent } from '../../domain/entities/RaceEvent'; import { Session } from '../../domain/entities/Session'; import { SessionType } from '../../domain/value-objects/SessionType'; +import { CloseRaceEventStewardingUseCase } from './CloseRaceEventStewardingUseCase'; + describe('CloseRaceEventStewardingUseCase', () => { let useCase: CloseRaceEventStewardingUseCase; let raceEventRepository: { @@ -27,6 +23,7 @@ describe('CloseRaceEventStewardingUseCase', () => { let logger: { error: Mock; }; + beforeEach(() => { raceEventRepository = { findAwaitingStewardingClose: vi.fn(), @@ -45,11 +42,11 @@ describe('CloseRaceEventStewardingUseCase', () => { logger = { error: vi.fn(), }; - useCase = new CloseRaceEventStewardingUseCase(logger as unknown as Logger, - raceEventRepository as unknown as IRaceEventRepository, - raceRegistrationRepository as unknown as IRaceRegistrationRepository, - penaltyRepository as unknown as IPenaltyRepository, - domainEventPublisher as unknown as DomainEventPublisher); + useCase = new CloseRaceEventStewardingUseCase(logger as any, + raceEventRepository as any, + raceRegistrationRepository as any, + penaltyRepository as any, + domainEventPublisher as any); }); it('should close stewarding for expired events successfully', async () => { @@ -82,33 +79,27 @@ describe('CloseRaceEventStewardingUseCase', () => { const result = await useCase.execute({ raceId: 'event-1', closedById: 'admin-1' }); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(raceEventRepository.findAwaitingStewardingClose).toHaveBeenCalled(); expect(raceEventRepository.update).toHaveBeenCalledWith( expect.objectContaining({ status: 'closed' }) ); expect(domainEventPublisher.publish).toHaveBeenCalled(); - const presentedRace = (status?: unknown; - }; - const presentedId = - presentedRace?.id && typeof presentedRace.id === 'object' && typeof presentedRace.id.toString === 'function' - ? presentedRace.id.toString() - : presentedRace?.id; - expect(presentedId).toBe('event-1'); - expect(presentedRace?.status).toBe('closed'); + expect(presented.race.id).toBe('event-1'); + expect(presented.race.status).toBe('closed'); }); - it('should handle no expired events', async () => { + it('should return error when no expired events', async () => { raceEventRepository.findAwaitingStewardingClose.mockResolvedValue([]); const result = await useCase.execute({ raceId: 'event-1', closedById: 'admin-1' }); - expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + expect(result.isErr()).toBe(true); + expect(result.unwrapErr().code).toBe('RACE_NOT_FOUND'); expect(raceEventRepository.update).not.toHaveBeenCalled(); expect(domainEventPublisher.publish).not.toHaveBeenCalled(); - }); + }); it('should return error when repository throws', async () => { raceEventRepository.findAwaitingStewardingClose.mockRejectedValue(new Error('DB error')); @@ -121,5 +112,5 @@ describe('CloseRaceEventStewardingUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toContain('DB error'); } - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.ts b/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.ts index 7bda899b1..d18be8d04 100644 --- a/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.ts +++ b/core/racing/application/use-cases/CloseRaceEventStewardingUseCase.ts @@ -1,12 +1,9 @@ -import type { Logger } from '@core/shared/application'; -import type { RaceEventRepository } from '../../domain/repositories/RaceEventRepository'; -import type { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { DomainEventPublisher } from '@core/shared/domain/DomainEvent'; -import { RaceEventStewardingClosedEvent } from '../../domain/events/RaceEventStewardingClosed'; +import { DomainEventPublisher } from '@/shared/domain/DomainEvent'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { RaceEvent } from '../../domain/entities/RaceEvent'; +import { RaceEventStewardingClosedEvent } from '../../domain/events/RaceEventStewardingClosed'; export type CloseRaceEventStewardingInput = { raceId: string; diff --git a/core/racing/application/use-cases/CompleteRaceUseCase.test.ts b/core/racing/application/use-cases/CompleteRaceUseCase.test.ts index 5cc9307d6..ced15904d 100644 --- a/core/racing/application/use-cases/CompleteRaceUseCase.test.ts +++ b/core/racing/application/use-cases/CompleteRaceUseCase.test.ts @@ -4,6 +4,7 @@ import type { RaceRepository } from '../../domain/repositories/RaceRepository'; import type { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository'; import type { ResultRepository } from '../../domain/repositories/ResultRepository'; import type { StandingRepository } from '../../domain/repositories/StandingRepository'; + describe('CompleteRaceUseCase', () => { let useCase: CompleteRaceUseCase; let raceRepository: { @@ -21,7 +22,6 @@ describe('CompleteRaceUseCase', () => { save: Mock; }; let getDriverRating: Mock; - let output: { present: Mock }; beforeEach(() => { raceRepository = { @@ -39,11 +39,10 @@ describe('CompleteRaceUseCase', () => { save: vi.fn(), }; getDriverRating = vi.fn(); - output = { present: vi.fn() }; - useCase = new CompleteRaceUseCase(raceRepository as unknown as IRaceRepository, - raceRegistrationRepository as unknown as IRaceRegistrationRepository, - resultRepository as unknown as IResultRepository, - standingRepository as unknown as IStandingRepository, + useCase = new CompleteRaceUseCase(raceRepository as any, + raceRegistrationRepository as any, + resultRepository as any, + standingRepository as any, getDriverRating); }); @@ -73,7 +72,8 @@ describe('CompleteRaceUseCase', () => { const result = await useCase.execute(command); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); + expect(presented.raceId).toBe('race-1'); expect(raceRepository.findById).toHaveBeenCalledWith('race-1'); expect(raceRegistrationRepository.getRegisteredDrivers).toHaveBeenCalledWith('race-1'); expect(getDriverRating).toHaveBeenCalledTimes(2); @@ -81,7 +81,7 @@ describe('CompleteRaceUseCase', () => { expect(standingRepository.save).toHaveBeenCalledTimes(2); expect(mockRace.complete).toHaveBeenCalled(); expect(raceRepository.update).toHaveBeenCalledWith({ id: 'race-1', status: 'completed' }); - }); + }); it('should return error when race does not exist', async () => { const command: CompleteRaceInput = { @@ -94,7 +94,7 @@ describe('CompleteRaceUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr().code).toBe('RACE_NOT_FOUND'); - }); + }); it('should return error when no registered drivers', async () => { const command: CompleteRaceInput = { @@ -114,7 +114,7 @@ describe('CompleteRaceUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr().code).toBe('NO_REGISTERED_DRIVERS'); - }); + }); it('should return error when repository throws', async () => { const command: CompleteRaceInput = { @@ -138,5 +138,5 @@ describe('CompleteRaceUseCase', () => { const error = result.unwrapErr(); expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details?.message).toBe('DB error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/CreateLeagueSeasonScheduleRaceUseCase.ts b/core/racing/application/use-cases/CreateLeagueSeasonScheduleRaceUseCase.ts index 0ae1dcd89..b09dd8834 100644 --- a/core/racing/application/use-cases/CreateLeagueSeasonScheduleRaceUseCase.ts +++ b/core/racing/application/use-cases/CreateLeagueSeasonScheduleRaceUseCase.ts @@ -1,19 +1,10 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { Race } from '../../domain/entities/Race'; import type { Season } from '../../domain/entities/season/Season'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -export type CreateLeagueSeasonScheduleRaceInput = { - leagueId: string; - seasonId: string; - track: string; - car: string; - scheduledAt: Date; -}; export type CreateLeagueSeasonScheduleRaceResult = { raceId: string; @@ -96,9 +87,7 @@ export class CreateLeagueSeasonScheduleRaceUseCase { } } - private isWithinSeasonWindow(_season: Season, _scheduledAt: Date): boolean { - // Implementation would check if scheduledAt is within season's schedule window - // For now, return true as a placeholder - return true; + private isWithinSeasonWindow(season: Season, scheduledAt: Date): boolean { + return scheduledAt >= season.startDate && scheduledAt <= season.endDate; } } \ No newline at end of file diff --git a/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.test.ts b/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.test.ts index 01286043a..a46a293d6 100644 --- a/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.test.ts +++ b/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.test.ts @@ -1,12 +1,8 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { - CreateLeagueWithSeasonAndScoringUseCase, - type CreateLeagueWithSeasonAndScoringCommand, - type CreateLeagueWithSeasonAndScoringResult, + CreateLeagueWithSeasonAndScoringUseCase, + type CreateLeagueWithSeasonAndScoringCommand } from './CreateLeagueWithSeasonAndScoringUseCase'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import type { LeagueScoringConfigRepository } from '../../domain/repositories/LeagueScoringConfigRepository'; describe('CreateLeagueWithSeasonAndScoringUseCase', () => { let useCase: CreateLeagueWithSeasonAndScoringUseCase; @@ -26,7 +22,6 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { warn: Mock; error: Mock; }; - let output: { present: Mock } ; beforeEach(() => { leagueRepository = { @@ -45,12 +40,11 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { warn: vi.fn(), error: vi.fn(), }; - output = { present: vi.fn() } as unknown as typeof output; - useCase = new CreateLeagueWithSeasonAndScoringUseCase(leagueRepository as unknown as ILeagueRepository, - seasonRepository as unknown as ISeasonRepository, - leagueScoringConfigRepository as unknown as ILeagueScoringConfigRepository, + useCase = new CreateLeagueWithSeasonAndScoringUseCase(leagueRepository as any, + seasonRepository as any, + leagueScoringConfigRepository as any, getLeagueScoringPresetById, - logger as unknown as Logger); + logger as any); }); it('should create league, season, and scoring successfully', async () => { @@ -82,11 +76,11 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { const result = await useCase.execute(command); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = (expect(presented?.league.id.toString()).toBeDefined(); - expect(presented?.season.id).toBeDefined(); - expect(presented?.scoringConfig.seasonId.toString()).toBe(presented?.season.id); + expect(presented.league.id).toBeDefined(); + expect(presented.season.id).toBeDefined(); + expect(presented.scoringConfig.seasonId.toString()).toBe(presented.season.id); expect(leagueRepository.create).toHaveBeenCalledTimes(1); expect(seasonRepository.create).toHaveBeenCalledTimes(1); expect(leagueScoringConfigRepository.save).toHaveBeenCalledTimes(1); @@ -113,7 +107,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toBe('League name is required'); } - }); + }); it('should return error when ownerId is empty', async () => { const command = { @@ -136,7 +130,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toBe('League ownerId is required'); } - }); + }); it('should return error when gameId is empty', async () => { const command = { @@ -159,7 +153,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toBe('gameId is required'); } - }); + }); it('should return error when visibility is missing', async () => { const command: Partial = { @@ -180,7 +174,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toBe('visibility is required'); } - }); + }); it('should return error when maxDrivers is invalid', async () => { const command = { @@ -204,7 +198,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toBe('maxDrivers must be greater than 0 when provided'); } - }); + }); it('should return error when ranked league has insufficient drivers', async () => { const command = { @@ -228,7 +222,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toContain('Ranked leagues require at least 10 drivers'); } - }); + }); it('should return error when scoring preset is unknown', async () => { const command = { @@ -254,7 +248,7 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toBe('Unknown scoring preset: unknown-preset'); } - }); + }); it('should return error when repository throws', async () => { const command = { @@ -285,5 +279,5 @@ describe('CreateLeagueWithSeasonAndScoringUseCase', () => { if ('details' in err && err.details && typeof err.details === 'object' && 'message' in err.details) { expect(err.details.message).toBe('DB error'); } - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.ts b/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.ts index 8127f9fed..8ce87a399 100644 --- a/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.ts +++ b/core/racing/application/use-cases/CreateLeagueWithSeasonAndScoringUseCase.ts @@ -1,21 +1,18 @@ -import { v4 as uuidv4 } from 'uuid'; -import { League } from '../../domain/entities/League'; -import { Season } from '../../domain/entities/season/Season'; -import { LeagueScoringConfig } from '../../domain/entities/LeagueScoringConfig'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import type { LeagueScoringConfigRepository } from '../../domain/repositories/LeagueScoringConfigRepository'; -import type { Logger } from '@core/shared/application'; -import type { ChampionshipConfig } from '../../domain/types/ChampionshipConfig'; -import type { SessionType } from '../../domain/types/SessionType'; -import type { BonusRule } from '../../domain/types/BonusRule'; -import { PointsTable } from '../../domain/value-objects/PointsTable'; -import { - LeagueVisibility, - MIN_RANKED_LEAGUE_DRIVERS, -} from '../../domain/value-objects/LeagueVisibility'; +import { League } from '@/racing/domain/entities/League'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { v4 as uuidv4 } from 'uuid'; +import { LeagueScoringConfig } from '../../domain/entities/LeagueScoringConfig'; +import { Season } from '../../domain/entities/season/Season'; +import type { BonusRule } from '../../domain/types/BonusRule'; +import type { ChampionshipConfig } from '../../domain/types/ChampionshipConfig'; +import type { SessionType } from '../../domain/types/SessionType'; +import { + LeagueVisibility, + MIN_RANKED_LEAGUE_DRIVERS, +} from '../../domain/value-objects/LeagueVisibility'; +import { PointsTable } from '../../domain/value-objects/PointsTable'; export type CreateLeagueWithSeasonAndScoringCommand = { name: string; diff --git a/core/racing/application/use-cases/CreateSeasonForLeagueUseCase.test.ts b/core/racing/application/use-cases/CreateSeasonForLeagueUseCase.test.ts index 8adfa1380..1e6bcc4c6 100644 --- a/core/racing/application/use-cases/CreateSeasonForLeagueUseCase.test.ts +++ b/core/racing/application/use-cases/CreateSeasonForLeagueUseCase.test.ts @@ -1,5 +1,4 @@ -import { describe, it, expect, vi, Mock } from 'vitest'; - +import { describe, it, expect, vi, Mock, beforeEach } from 'vitest'; import { Season } from '@core/racing/domain/entities/season/Season'; import type { SeasonRepository } from '@core/racing/domain/repositories/SeasonRepository'; import type { LeagueRepository } from '@core/racing/domain/repositories/LeagueRepository'; @@ -75,7 +74,7 @@ type CreateSeasonErrorCode = ApplicationErrorCode<'LEAGUE_NOT_FOUND' | 'VALIDATI describe('CreateSeasonForLeagueUseCase', () => { const mockLeagueFindById = vi.fn(); - const mockLeagueRepo: ILeagueRepository = { + const mockLeagueRepo: any = { findById: mockLeagueFindById, findAll: vi.fn(), findByOwnerId: vi.fn(), @@ -88,7 +87,7 @@ describe('CreateSeasonForLeagueUseCase', () => { const mockSeasonFindById = vi.fn(); const mockSeasonAdd = vi.fn(); - const mockSeasonRepo: ISeasonRepository = { + const mockSeasonRepo: any = { findById: mockSeasonFindById, findByLeagueId: vi.fn(), create: vi.fn(), @@ -98,11 +97,8 @@ describe('CreateSeasonForLeagueUseCase', () => { listActiveByLeague: vi.fn(), }; - let output: { present: Mock } ; - beforeEach(() => { vi.clearAllMocks(); - output = { present: vi.fn() } as unknown as typeof output; }); it('creates a planned Season for an existing league with config-derived props', async () => { @@ -125,8 +121,6 @@ describe('CreateSeasonForLeagueUseCase', () => { strategy: 'dropWorstN', n: 2, }, - // Intentionally omit seasonStartDate / raceStartTime to avoid schedule derivation, - // focusing this test on scoring/drop/stewarding/maxDrivers mapping. timings: { qualifyingMinutes: 10, mainRaceMinutes: 30, @@ -141,13 +135,13 @@ describe('CreateSeasonForLeagueUseCase', () => { config, }; - const result: Result = await useCase.execute(command); + const result = await useCase.execute(command); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = (expect(presented?.season).toBeInstanceOf(Season); - expect(presented?.league.id).toBe('league-1'); + expect(presented.season).toBeInstanceOf(Season); + expect(presented.league.id).toBe('league-1'); }); it('clones configuration from a source season when sourceSeasonId is provided', async () => { @@ -172,15 +166,15 @@ describe('CreateSeasonForLeagueUseCase', () => { sourceSeasonId: 'source-season', }; - const result: Result = await useCase.execute(command); + const result = await useCase.execute(command); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = (expect(presented?.season.maxDrivers).toBe(40); + expect(presented.season.maxDrivers).toBe(40); }); - it('returns error when league not found and does not call output', async () => { + it('returns error when league not found', async () => { mockLeagueFindById.mockResolvedValue(null); const useCase = new CreateSeasonForLeagueUseCase(mockLeagueRepo, mockSeasonRepo); @@ -191,15 +185,15 @@ describe('CreateSeasonForLeagueUseCase', () => { gameId: 'iracing', }; - const result: Result = await useCase.execute(command); + const result = await useCase.execute(command); expect(result.isErr()).toBe(true); const error = result.unwrapErr(); expect(error.code).toBe('LEAGUE_NOT_FOUND'); expect(error.details?.message).toBe('League not found: missing-league'); - }); + }); - it('returns validation error when source season is missing and does not call output', async () => { + it('returns validation error when source season is missing', async () => { mockLeagueFindById.mockResolvedValue({ id: 'league-1' }); mockSeasonFindById.mockResolvedValue(undefined); @@ -212,11 +206,11 @@ describe('CreateSeasonForLeagueUseCase', () => { sourceSeasonId: 'missing-source', }; - const result: Result = await useCase.execute(command); + const result = await useCase.execute(command); expect(result.isErr()).toBe(true); const error = result.unwrapErr(); expect(error.code).toBe('VALIDATION_ERROR'); expect(error.details?.message).toBe('Source Season not found: missing-source'); - }); -}) + }); +}); diff --git a/core/racing/application/use-cases/CreateSponsorUseCase.test.ts b/core/racing/application/use-cases/CreateSponsorUseCase.test.ts index ad8dae47c..1721f5cd4 100644 --- a/core/racing/application/use-cases/CreateSponsorUseCase.test.ts +++ b/core/racing/application/use-cases/CreateSponsorUseCase.test.ts @@ -1,7 +1,6 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { CreateSponsorUseCase, type CreateSponsorInput } from './CreateSponsorUseCase'; -import type { SponsorRepository } from '../../domain/repositories/SponsorRepository'; -import type { Logger } from '@core/shared/application'; describe('CreateSponsorUseCase', () => { let useCase: CreateSponsorUseCase; diff --git a/core/racing/application/use-cases/CreateSponsorUseCase.ts b/core/racing/application/use-cases/CreateSponsorUseCase.ts index e37e85c13..af106c990 100644 --- a/core/racing/application/use-cases/CreateSponsorUseCase.ts +++ b/core/racing/application/use-cases/CreateSponsorUseCase.ts @@ -3,12 +3,11 @@ * * Creates a new sponsor. */ +import { ApplicationErrorCode } from '@/shared/errors/ApplicationErrorCode'; +import type { Logger } from '@core/shared/domain/Logger'; +import { Result } from '@core/shared/domain/Result'; import { v4 as uuidv4 } from 'uuid'; import { Sponsor } from '../../domain/entities/sponsor/Sponsor'; -import type { SponsorRepository } from '../../domain/repositories/SponsorRepository'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; export interface CreateSponsorInput { name: string; diff --git a/core/racing/application/use-cases/CreateTeamUseCase.test.ts b/core/racing/application/use-cases/CreateTeamUseCase.test.ts index ecf2e384e..72768a467 100644 --- a/core/racing/application/use-cases/CreateTeamUseCase.test.ts +++ b/core/racing/application/use-cases/CreateTeamUseCase.test.ts @@ -1,12 +1,9 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { - CreateTeamUseCase, - type CreateTeamInput, - type CreateTeamResult, + CreateTeamUseCase, + type CreateTeamInput } from './CreateTeamUseCase'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { Logger } from '@core/shared/application'; + describe('CreateTeamUseCase', () => { let useCase: CreateTeamUseCase; let teamRepository: { @@ -22,7 +19,6 @@ describe('CreateTeamUseCase', () => { warn: Mock; error: Mock; }; - let output: { present: Mock }; beforeEach(() => { teamRepository = { @@ -38,10 +34,9 @@ describe('CreateTeamUseCase', () => { warn: vi.fn(), error: vi.fn(), }; - output = { present: vi.fn() }; - useCase = new CreateTeamUseCase(teamRepository as unknown as ITeamRepository, - membershipRepository as unknown as ITeamMembershipRepository, - logger as unknown as Logger); + useCase = new CreateTeamUseCase(teamRepository as any, + membershipRepository as any, + logger as any); }); it('should create team successfully', async () => { @@ -69,10 +64,11 @@ describe('CreateTeamUseCase', () => { const result = await useCase.execute(command); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); + expect(presented.team.id).toBe('team-uuid'); expect(teamRepository.create).toHaveBeenCalledTimes(1); expect(membershipRepository.saveMembership).toHaveBeenCalledTimes(1); - }); + }); it('should return error when driver already belongs to a team', async () => { const command: CreateTeamInput = { @@ -100,7 +96,7 @@ describe('CreateTeamUseCase', () => { ); expect(teamRepository.create).not.toHaveBeenCalled(); expect(membershipRepository.saveMembership).not.toHaveBeenCalled(); - }); + }); it('should return error when repository throws', async () => { const command: CreateTeamInput = { @@ -119,5 +115,5 @@ describe('CreateTeamUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr().code).toBe('REPOSITORY_ERROR'); expect(result.unwrapErr().details?.message).toBe('DB error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/CreateTeamUseCase.ts b/core/racing/application/use-cases/CreateTeamUseCase.ts index 7a1c08e5f..f50d1d5d2 100644 --- a/core/racing/application/use-cases/CreateTeamUseCase.ts +++ b/core/racing/application/use-cases/CreateTeamUseCase.ts @@ -3,18 +3,16 @@ * * Creates a new team. */ +import { Result } from '@/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { v4 as uuidv4 } from 'uuid'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import { Team } from '../../domain/entities/Team'; import type { - TeamMembership, - TeamMembershipStatus, - TeamRole, + TeamMembership, + TeamMembershipStatus, + TeamRole, } from '../../domain/types/TeamMembership'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; export interface CreateTeamInput { name: string; tag: string; diff --git a/core/racing/application/use-cases/DeleteLeagueSeasonScheduleRaceUseCase.ts b/core/racing/application/use-cases/DeleteLeagueSeasonScheduleRaceUseCase.ts index c3508b52c..74ed6cd6f 100644 --- a/core/racing/application/use-cases/DeleteLeagueSeasonScheduleRaceUseCase.ts +++ b/core/racing/application/use-cases/DeleteLeagueSeasonScheduleRaceUseCase.ts @@ -1,15 +1,8 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -export type DeleteLeagueSeasonScheduleRaceInput = { - leagueId: string; - seasonId: string; - raceId: string; -}; export type DeleteLeagueSeasonScheduleRaceResult = { success: true; diff --git a/core/racing/application/use-cases/FileProtestUseCase.test.ts b/core/racing/application/use-cases/FileProtestUseCase.test.ts index efec9234e..034eade99 100644 --- a/core/racing/application/use-cases/FileProtestUseCase.test.ts +++ b/core/racing/application/use-cases/FileProtestUseCase.test.ts @@ -15,6 +15,7 @@ describe('FileProtestUseCase', () => { let mockLeagueMembershipRepo: { getLeagueMembers: Mock; }; + beforeEach(() => { mockProtestRepo = { create: vi.fn(), @@ -25,12 +26,12 @@ describe('FileProtestUseCase', () => { mockLeagueMembershipRepo = { getLeagueMembers: vi.fn(), }; - }); + }); it('should return error when race does not exist', async () => { - const useCase = new FileProtestUseCase(mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository); + const useCase = new FileProtestUseCase(mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any); mockRaceRepo.findById.mockResolvedValue(null); @@ -45,12 +46,12 @@ describe('FileProtestUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('RACE_NOT_FOUND'); expect(err.details?.message).toBe('Race not found'); - }); + }); it('should return error when protesting against self', async () => { - const useCase = new FileProtestUseCase(mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository); + const useCase = new FileProtestUseCase(mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); @@ -65,12 +66,12 @@ describe('FileProtestUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('SELF_PROTEST'); expect(err.details?.message).toBe('Cannot file a protest against yourself'); - }); + }); it('should return error when protesting driver is not an active member', async () => { - const useCase = new FileProtestUseCase(mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository); + const useCase = new FileProtestUseCase(mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); mockLeagueMembershipRepo.getLeagueMembers.mockResolvedValue([ @@ -88,12 +89,12 @@ describe('FileProtestUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('NOT_MEMBER'); expect(err.details?.message).toBe('Protesting driver is not an active member of this league'); - }); + }); it('should create protest and return protestId on success', async () => { - const useCase = new FileProtestUseCase(mockProtestRepo as unknown as IProtestRepository, - mockRaceRepo as unknown as IRaceRepository, - mockLeagueMembershipRepo as unknown as ILeagueMembershipRepository); + const useCase = new FileProtestUseCase(mockProtestRepo as any, + mockRaceRepo as any, + mockLeagueMembershipRepo as any); mockRaceRepo.findById.mockResolvedValue({ id: 'race1', leagueId: 'league1' }); mockLeagueMembershipRepo.getLeagueMembers.mockResolvedValue([ @@ -111,21 +112,9 @@ describe('FileProtestUseCase', () => { } as FileProtestInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(mockProtestRepo.create).toHaveBeenCalledTimes(1); - const created = (mockProtestRepo.create as unknown as Mock).mock.calls[0]?.[0] as unknown as { - raceId: { toString(): string }; - protestingDriverId: { toString(): string }; - accusedDriverId: { toString(): string }; - comment?: string; - proofVideoUrl: { toString(): string }; - status: { toString(): string }; - incident: { - lap: { toNumber(): number }; - description: { toString(): string }; - timeInRace?: unknown; - }; - }; + const created = (mockProtestRepo.create as unknown as Mock).mock.calls[0]?.[0] as any; expect(created.raceId.toString()).toBe('race1'); expect(created.protestingDriverId.toString()).toBe('driver1'); @@ -136,16 +125,14 @@ describe('FileProtestUseCase', () => { expect(created.incident.lap.toNumber()).toBe(5); expect(created.incident.description.toString()).toBe('Collision'); - expect(created.incident.timeInRace).toBeUndefined(); - const presented = (expect(presented.protest.raceId.toString()).toBe('race1'); + expect(presented.protest.raceId.toString()).toBe('race1'); expect(presented.protest.protestingDriverId.toString()).toBe('driver1'); expect(presented.protest.accusedDriverId.toString()).toBe('driver2'); expect(presented.protest.incident.lap.toNumber()).toBe(5); expect(presented.protest.incident.description.toString()).toBe('Collision'); - expect(presented.protest.incident.timeInRace).toBeUndefined(); expect(presented.protest.comment).toBe('Test comment'); expect(presented.protest.proofVideoUrl).toBeDefined(); expect(presented.protest.proofVideoUrl!.toString()).toBe('http://example.com/video'); }); -}); \ No newline at end of file +}); diff --git a/core/racing/application/use-cases/GetAllLeaguesWithCapacityAndScoringUseCase.test.ts b/core/racing/application/use-cases/GetAllLeaguesWithCapacityAndScoringUseCase.test.ts index 554f62705..b7b5e505a 100644 --- a/core/racing/application/use-cases/GetAllLeaguesWithCapacityAndScoringUseCase.test.ts +++ b/core/racing/application/use-cases/GetAllLeaguesWithCapacityAndScoringUseCase.test.ts @@ -16,23 +16,23 @@ describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => { let mockSeasonRepo: { findByLeagueId: Mock }; let mockScoringConfigRepo: { findBySeasonId: Mock }; let mockGameRepo: { findById: Mock }; + beforeEach(() => { mockLeagueRepo = { findAll: vi.fn() }; mockMembershipRepo = { getLeagueMembers: vi.fn() }; mockSeasonRepo = { findByLeagueId: vi.fn() }; mockScoringConfigRepo = { findBySeasonId: vi.fn() }; mockGameRepo = { findById: vi.fn() }; - output = { present: vi.fn() } as unknown as typeof output; }); it('should return enriched leagues with capacity and scoring', async () => { - const useCase = new GetAllLeaguesWithCapacityAndScoringUseCase(mockLeagueRepo as unknown as ILeagueRepository, - mockMembershipRepo as unknown as ILeagueMembershipRepository, - mockSeasonRepo as unknown as ISeasonRepository, - mockScoringConfigRepo as unknown as ILeagueScoringConfigRepository, - mockGameRepo as unknown as IGameRepository, - { getPresetById: vi.fn().mockReturnValue({ id: 'preset1', name: 'Default' }) }, - output, + const useCase = new GetAllLeaguesWithCapacityAndScoringUseCase( + mockLeagueRepo as any, + mockMembershipRepo as any, + mockSeasonRepo as any, + mockScoringConfigRepo as any, + mockGameRepo as any, + { getPresetById: vi.fn().mockReturnValue({ id: 'preset1', name: 'Default' }) } ); const league = { id: 'league1', name: 'Test League', settings: { maxDrivers: 30 } }; @@ -53,19 +53,18 @@ describe('GetAllLeaguesWithCapacityAndScoringUseCase', () => { const result = await useCase.execute({} as GetAllLeaguesWithCapacityAndScoringInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = - expect(presented?.leagues).toHaveLength(1); + expect(presented.leagues).toHaveLength(1); - const [summary] = presented?.leagues ?? []; + const summary = presented.leagues[0]; - expect(summary?.league).toEqual(league); - expect(summary?.currentDrivers).toBe(2); - expect(summary?.maxDrivers).toBe(30); - expect(summary?.season).toEqual(season); - expect(summary?.scoringConfig).toEqual(scoringConfig); - expect(summary?.game).toEqual(game); - expect(summary?.preset).toEqual({ id: 'preset1', name: 'Default' }); + expect(summary.league).toEqual(league); + expect(summary.currentDrivers).toBe(2); + expect(summary.maxDrivers).toBe(30); + expect(summary.season).toEqual(season); + expect(summary.scoringConfig).toEqual(scoringConfig); + expect(summary.game).toEqual(game); + expect(summary.preset).toEqual({ id: 'preset1', name: 'Default' }); }); }); diff --git a/core/racing/application/use-cases/GetAllRacesPageDataUseCase.test.ts b/core/racing/application/use-cases/GetAllRacesPageDataUseCase.test.ts index 7d8bd17bd..cfe2e36ed 100644 --- a/core/racing/application/use-cases/GetAllRacesPageDataUseCase.test.ts +++ b/core/racing/application/use-cases/GetAllRacesPageDataUseCase.test.ts @@ -1,18 +1,15 @@ -import { describe, it, expect, beforeEach, vi } from 'vitest'; -import { - GetAllRacesPageDataUseCase, - type GetAllRacesPageDataResult, - type GetAllRacesPageDataInput, -} from './GetAllRacesPageDataUseCase'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { Logger } from '@core/shared/application'; -import { Race } from '../../domain/entities/Race'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { League } from '../../domain/entities/League'; +import { Race } from '../../domain/entities/Race'; +import { + GetAllRacesPageDataUseCase, + type GetAllRacesPageDataInput +} from './GetAllRacesPageDataUseCase'; describe('GetAllRacesPageDataUseCase', () => { const mockRaceFindAll = vi.fn(); - const mockRaceRepo: IRaceRepository = { + const mockRaceRepo: any = { findById: vi.fn(), findAll: mockRaceFindAll, findByLeagueId: vi.fn(), @@ -27,7 +24,7 @@ describe('GetAllRacesPageDataUseCase', () => { }; const mockLeagueFindAll = vi.fn(); - const mockLeagueRepo: ILeagueRepository = { + const mockLeagueRepo: any = { findById: vi.fn(), findAll: mockLeagueFindAll, findByOwnerId: vi.fn(), @@ -47,9 +44,9 @@ describe('GetAllRacesPageDataUseCase', () => { beforeEach(() => { vi.clearAllMocks(); - }); + }); - it('should present races and filters data', async () => { + it('should return races and filters data', async () => { const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo, mockLeagueRepo, mockLogger); @@ -95,8 +92,8 @@ describe('GetAllRacesPageDataUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented.races).toEqual([ + const presented = result.unwrap(); + expect(presented.races).toEqual([ { id: 'race2', track: 'Track B', @@ -134,7 +131,7 @@ describe('GetAllRacesPageDataUseCase', () => { }); }); - it('should present empty result when no races or leagues', async () => { + it('should return empty result when no races or leagues', async () => { const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo, mockLeagueRepo, mockLogger); @@ -145,8 +142,8 @@ describe('GetAllRacesPageDataUseCase', () => { const result = await useCase.execute({}); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented.races).toEqual([]); + const presented = result.unwrap(); + expect(presented.races).toEqual([]); expect(presented.filters).toEqual({ statuses: [ { value: 'all', label: 'All Statuses' }, @@ -159,7 +156,7 @@ describe('GetAllRacesPageDataUseCase', () => { }); }); - it('should return error when repository throws and not present data', async () => { + it('should return error when repository throws', async () => { const useCase = new GetAllRacesPageDataUseCase(mockRaceRepo, mockLeagueRepo, mockLogger); @@ -173,5 +170,5 @@ describe('GetAllRacesPageDataUseCase', () => { const err = result.unwrapErr(); expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('Repository error'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetAllRacesPageDataUseCase.ts b/core/racing/application/use-cases/GetAllRacesPageDataUseCase.ts index bbc3dbf2d..602533be5 100644 --- a/core/racing/application/use-cases/GetAllRacesPageDataUseCase.ts +++ b/core/racing/application/use-cases/GetAllRacesPageDataUseCase.ts @@ -1,6 +1,3 @@ -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { RaceStatusValue } from '../../domain/entities/Race'; diff --git a/core/racing/application/use-cases/GetAllRacesUseCase.test.ts b/core/racing/application/use-cases/GetAllRacesUseCase.test.ts index 2ca318b00..824810c1b 100644 --- a/core/racing/application/use-cases/GetAllRacesUseCase.test.ts +++ b/core/racing/application/use-cases/GetAllRacesUseCase.test.ts @@ -1,18 +1,17 @@ -import { describe, it, expect, beforeEach, vi } from 'vitest'; -import { - GetAllRacesUseCase, - type GetAllRacesResult, - type GetAllRacesInput, -} from './GetAllRacesUseCase'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { Logger } from '@core/shared/application'; -import { Race } from '../../domain/entities/Race'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { League } from '../../domain/entities/League'; +import { Race } from '../../domain/entities/Race'; +import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; +import type { RaceRepository } from '../../domain/repositories/RaceRepository'; +import { + GetAllRacesUseCase, + type GetAllRacesInput +} from './GetAllRacesUseCase'; describe('GetAllRacesUseCase', () => { const mockRaceFindAll = vi.fn(); - const mockRaceRepo: IRaceRepository = { + const mockRaceRepo: RaceRepository = { findById: vi.fn(), findAll: mockRaceFindAll, findByLeagueId: vi.fn(), @@ -27,7 +26,7 @@ describe('GetAllRacesUseCase', () => { }; const mockLeagueFindAll = vi.fn(); - const mockLeagueRepo: ILeagueRepository = { + const mockLeagueRepo: LeagueRepository = { findById: vi.fn(), findAll: mockLeagueFindAll, findByOwnerId: vi.fn(), @@ -47,13 +46,12 @@ describe('GetAllRacesUseCase', () => { beforeEach(() => { vi.clearAllMocks(); - }); + }); - it('should present domain races and leagues data', async () => { + it('should return domain races and leagues data', async () => { const useCase = new GetAllRacesUseCase(mockRaceRepo, mockLeagueRepo, mockLogger); - useCase.setOutput(output); const race1 = Race.create({ id: 'race1', @@ -95,17 +93,16 @@ describe('GetAllRacesUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented.totalCount).toBe(2); + const presented = result.unwrap(); + expect(presented.totalCount).toBe(2); expect(presented.races).toEqual([race1, race2]); expect(presented.leagues).toEqual([league1, league2]); }); - it('should present empty result when no races or leagues', async () => { + it('should return empty result when no races or leagues', async () => { const useCase = new GetAllRacesUseCase(mockRaceRepo, mockLeagueRepo, mockLogger); - useCase.setOutput(output); mockRaceFindAll.mockResolvedValue([]); mockLeagueFindAll.mockResolvedValue([]); @@ -113,13 +110,13 @@ describe('GetAllRacesUseCase', () => { const result = await useCase.execute({}); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented.totalCount).toBe(0); + const presented = result.unwrap(); + expect(presented.totalCount).toBe(0); expect(presented.races).toEqual([]); expect(presented.leagues).toEqual([]); }); - it('should return error when repository throws and not present data', async () => { + it('should return error when repository throws', async () => { const useCase = new GetAllRacesUseCase(mockRaceRepo, mockLeagueRepo, mockLogger); @@ -133,5 +130,5 @@ describe('GetAllRacesUseCase', () => { const err = result.unwrapErr(); expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('Repository error'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetAllRacesUseCase.ts b/core/racing/application/use-cases/GetAllRacesUseCase.ts index ba647d2f0..7a5f18373 100644 --- a/core/racing/application/use-cases/GetAllRacesUseCase.ts +++ b/core/racing/application/use-cases/GetAllRacesUseCase.ts @@ -1,10 +1,7 @@ -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import type { Race } from '../../domain/entities/Race'; import type { League } from '../../domain/entities/League'; +import type { Race } from '../../domain/entities/Race'; export type GetAllRacesInput = {}; diff --git a/core/racing/application/use-cases/GetAllTeamsUseCase.test.ts b/core/racing/application/use-cases/GetAllTeamsUseCase.test.ts index a0f3d8c9a..8d5b3c526 100644 --- a/core/racing/application/use-cases/GetAllTeamsUseCase.test.ts +++ b/core/racing/application/use-cases/GetAllTeamsUseCase.test.ts @@ -1,13 +1,13 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { GetAllTeamsUseCase, type GetAllTeamsInput, type GetAllTeamsResult } from './GetAllTeamsUseCase'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; +import type { TeamRepository } from '../../domain/repositories/TeamRepository'; import type { TeamStatsRepository } from '../../domain/repositories/TeamStatsRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { Logger } from '@core/shared/application'; +import { GetAllTeamsUseCase, type GetAllTeamsInput } from './GetAllTeamsUseCase'; + describe('GetAllTeamsUseCase', () => { const mockTeamFindAll = vi.fn(); - const mockTeamRepo: ITeamRepository = { + const mockTeamRepo: TeamRepository = { findById: vi.fn(), findAll: mockTeamFindAll, findByLeagueId: vi.fn(), @@ -18,7 +18,7 @@ describe('GetAllTeamsUseCase', () => { }; const mockTeamMembershipCountByTeamId = vi.fn(); - const mockTeamMembershipRepo: ITeamMembershipRepository = { + const mockTeamMembershipRepo: TeamMembershipRepository = { getMembership: vi.fn(), getActiveMembershipForDriver: vi.fn(), getTeamMembers: vi.fn(), @@ -30,28 +30,13 @@ describe('GetAllTeamsUseCase', () => { removeJoinRequest: vi.fn(), }; - const mockTeamStatsRepo: ITeamStatsRepository = { + const mockTeamStatsRepo: TeamStatsRepository = { getTeamStats: vi.fn(), saveTeamStats: vi.fn(), getAllStats: vi.fn(), clear: vi.fn(), }; - const mockResultRepo: IResultRepository = { - findAll: vi.fn(), - findById: vi.fn(), - findByRaceId: vi.fn(), - findByDriverId: vi.fn(), - findByDriverIdAndLeagueId: vi.fn(), - create: vi.fn(), - createMany: vi.fn(), - update: vi.fn(), - delete: vi.fn(), - deleteByRaceId: vi.fn(), - exists: vi.fn(), - existsByRaceId: vi.fn(), - }; - const mockLogger: Logger = { debug: vi.fn(), info: vi.fn(), @@ -61,20 +46,19 @@ describe('GetAllTeamsUseCase', () => { beforeEach(() => { vi.clearAllMocks(); - }); + }); it('should return teams data', async () => { const useCase = new GetAllTeamsUseCase(mockTeamRepo, mockTeamMembershipRepo, mockTeamStatsRepo, - mockResultRepo, mockLogger); const team1 = { - id: 'team1', - name: { props: 'Team One' }, - tag: { props: 'TO' }, - description: { props: 'Description One' }, + id: { toString: () => 'team1' }, + name: { toString: () => 'Team One' }, + tag: { toString: () => 'TO' }, + description: { toString: () => 'Description One' }, ownerId: { toString: () => 'owner1' }, leagues: [{ toString: () => 'league1' }], createdAt: { toDate: () => new Date('2023-01-01T00:00:00Z') }, @@ -83,10 +67,10 @@ describe('GetAllTeamsUseCase', () => { isRecruiting: false, }; const team2 = { - id: 'team2', - name: { props: 'Team Two' }, - tag: { props: 'TT' }, - description: { props: 'Description Two' }, + id: { toString: () => 'team2' }, + name: { toString: () => 'Team Two' }, + tag: { toString: () => 'TT' }, + description: { toString: () => 'Description Two' }, ownerId: { toString: () => 'owner2' }, leagues: [{ toString: () => 'league2' }], createdAt: { toDate: () => new Date('2023-01-02T00:00:00Z') }, @@ -98,7 +82,6 @@ describe('GetAllTeamsUseCase', () => { mockTeamFindAll.mockResolvedValue([team1, team2]); mockTeamMembershipCountByTeamId.mockImplementation((id: string) => Promise.resolve(id === 'team1' ? 5 : 3)); - // Provide precomputed stats so the use case doesn't compute from results. (mockTeamStatsRepo.getTeamStats as unknown as Mock).mockImplementation((teamId: string) => Promise.resolve( teamId === 'team1' @@ -126,62 +109,21 @@ describe('GetAllTeamsUseCase', () => { const result = await useCase.execute({} as GetAllTeamsInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented).toEqual({ - teams: [ - { - id: 'team1', - name: 'Team One', - tag: 'TO', - description: 'Description One', - ownerId: 'owner1', - leagues: ['league1'], - createdAt: new Date('2023-01-01T00:00:00Z'), - memberCount: 5, - totalWins: 2, - totalRaces: 10, - performanceLevel: 'intermediate', - specialization: 'mixed', - region: 'EU', - languages: ['en'], - logoRef: team1.logoRef, - logoUrl: null, - rating: 1200, - category: undefined, - isRecruiting: false, - }, - { - id: 'team2', - name: 'Team Two', - tag: 'TT', - description: 'Description Two', - ownerId: 'owner2', - leagues: ['league2'], - createdAt: new Date('2023-01-02T00:00:00Z'), - memberCount: 3, - totalWins: 5, - totalRaces: 20, - performanceLevel: 'advanced', - specialization: 'mixed', - region: 'US', - languages: ['en', 'de'], - logoRef: team2.logoRef, - logoUrl: null, - rating: 1400, - category: undefined, - isRecruiting: true, - }, - ], - totalCount: 2, - }); + expect(presented.totalCount).toBe(2); + expect(presented.teams[0].team).toBe(team1); + expect(presented.teams[0].memberCount).toBe(5); + expect(presented.teams[0].rating).toBe(1200); + expect(presented.teams[1].team).toBe(team2); + expect(presented.teams[1].memberCount).toBe(3); + expect(presented.teams[1].rating).toBe(1400); }); it('should return empty result when no teams', async () => { const useCase = new GetAllTeamsUseCase(mockTeamRepo, mockTeamMembershipRepo, mockTeamStatsRepo, - mockResultRepo, mockLogger); mockTeamFindAll.mockResolvedValue([]); @@ -189,19 +131,16 @@ describe('GetAllTeamsUseCase', () => { const result = await useCase.execute({} as GetAllTeamsInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented).toEqual({ - teams: [], - totalCount: 0, - }); + expect(presented.teams).toEqual([]); + expect(presented.totalCount).toBe(0); }); it('should return error when repository throws', async () => { const useCase = new GetAllTeamsUseCase(mockTeamRepo, mockTeamMembershipRepo, mockTeamStatsRepo, - mockResultRepo, mockLogger); const error = new Error('Repository error'); @@ -214,6 +153,5 @@ describe('GetAllTeamsUseCase', () => { expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('Repository error'); - - }); + }); }); diff --git a/core/racing/application/use-cases/GetAllTeamsUseCase.ts b/core/racing/application/use-cases/GetAllTeamsUseCase.ts index bd9440107..ad3e91a2a 100644 --- a/core/racing/application/use-cases/GetAllTeamsUseCase.ts +++ b/core/racing/application/use-cases/GetAllTeamsUseCase.ts @@ -1,10 +1,7 @@ +import { Team } from '@/racing/domain/entities/Team'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { TeamStatsRepository } from '../../domain/repositories/TeamStatsRepository'; -import type { Team } from '../../domain/entities/Team'; export interface GetAllTeamsInput {} diff --git a/core/racing/application/use-cases/GetDriverLiveriesUseCase.test.ts b/core/racing/application/use-cases/GetDriverLiveriesUseCase.test.ts index 7b72a17f3..6dcda03b4 100644 --- a/core/racing/application/use-cases/GetDriverLiveriesUseCase.test.ts +++ b/core/racing/application/use-cases/GetDriverLiveriesUseCase.test.ts @@ -1,8 +1,7 @@ -import { describe, it, expect, vi } from 'vitest'; -import { GetDriverLiveriesUseCase, type GetDriverLiveriesInput } from './GetDriverLiveriesUseCase'; -import type { LiveryRepository } from '../../domain/repositories/LiveryRepository'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi } from 'vitest'; import type { DriverLivery } from '../../domain/entities/DriverLivery'; -import type { Logger } from '@core/shared/application'; +import { GetDriverLiveriesUseCase, type GetDriverLiveriesInput } from './GetDriverLiveriesUseCase'; describe('GetDriverLiveriesUseCase', () => { const mockLiveryRepository: ILiveryRepository = { diff --git a/core/racing/application/use-cases/GetDriverLiveriesUseCase.ts b/core/racing/application/use-cases/GetDriverLiveriesUseCase.ts index e19ad923b..1090296a7 100644 --- a/core/racing/application/use-cases/GetDriverLiveriesUseCase.ts +++ b/core/racing/application/use-cases/GetDriverLiveriesUseCase.ts @@ -4,12 +4,11 @@ * Retrieves all liveries for a specific driver. */ -import { Result } from '@core/shared/domain/Result'; +import { DriverLivery } from '@/racing/domain/entities/DriverLivery'; import { UseCase } from '@core/shared/application/UseCase'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; +import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { LiveryRepository } from '../../domain/repositories/LiveryRepository'; -import type { DriverLivery } from '../../domain/entities/DriverLivery'; export interface GetDriverLiveriesInput { driverId: string; diff --git a/core/racing/application/use-cases/GetDriverTeamUseCase.test.ts b/core/racing/application/use-cases/GetDriverTeamUseCase.test.ts index dd9ea85eb..62ba1c316 100644 --- a/core/racing/application/use-cases/GetDriverTeamUseCase.test.ts +++ b/core/racing/application/use-cases/GetDriverTeamUseCase.test.ts @@ -1,43 +1,42 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { GetDriverTeamUseCase, type GetDriverTeamInput, type GetDriverTeamResult } from './GetDriverTeamUseCase'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { GetDriverTeamUseCase, type GetDriverTeamInput } from './GetDriverTeamUseCase'; + describe('GetDriverTeamUseCase', () => { - const mockFindById = vi.fn(); - const mockGetActiveMembershipForDriver = vi.fn(); - const mockTeamRepo: ITeamRepository = { - findById: mockFindById, - findAll: vi.fn(), - findByLeagueId: vi.fn(), - create: vi.fn(), - update: vi.fn(), - delete: vi.fn(), - exists: vi.fn(), - }; - - const mockMembershipRepo: ITeamMembershipRepository = { - getActiveMembershipForDriver: mockGetActiveMembershipForDriver, - getMembership: vi.fn(), - getTeamMembers: vi.fn(), - saveMembership: vi.fn(), - removeMembership: vi.fn(), - getJoinRequests: vi.fn(), - countByTeamId: vi.fn(), - saveJoinRequest: vi.fn(), - removeJoinRequest: vi.fn(), - }; - - const mockLogger: Logger = { - debug: vi.fn(), - info: vi.fn(), - warn: vi.fn(), - error: vi.fn(), - }; + let mockTeamRepo: any; + let mockMembershipRepo: any; + let mockLogger: Logger; beforeEach(() => { - vi.clearAllMocks(); - }); + mockTeamRepo = { + findById: vi.fn(), + findAll: vi.fn(), + findByLeagueId: vi.fn(), + create: vi.fn(), + update: vi.fn(), + delete: vi.fn(), + exists: vi.fn(), + }; + + mockMembershipRepo = { + getActiveMembershipForDriver: vi.fn(), + getMembership: vi.fn(), + getTeamMembers: vi.fn(), + saveMembership: vi.fn(), + removeMembership: vi.fn(), + getJoinRequests: vi.fn(), + countByTeamId: vi.fn(), + saveJoinRequest: vi.fn(), + removeJoinRequest: vi.fn(), + }; + + mockLogger = { + debug: vi.fn(), + info: vi.fn(), + warn: vi.fn(), + error: vi.fn(), + }; + }); it('should return driver team data when membership and team exist', async () => { const useCase = new GetDriverTeamUseCase(mockTeamRepo, @@ -48,15 +47,15 @@ describe('GetDriverTeamUseCase', () => { const membership = { id: 'membership1', driverId, teamId: 'team1' }; const team = { id: 'team1', name: 'Team One' }; - mockGetActiveMembershipForDriver.mockResolvedValue(membership); - mockFindById.mockResolvedValue(team); + mockMembershipRepo.getActiveMembershipForDriver.mockResolvedValue(membership); + mockTeamRepo.findById.mockResolvedValue(team); const input: GetDriverTeamInput = { driverId }; const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const [[presented]] = (expect(presented.driverId).toBe(driverId); + const presented = result.unwrap(); + expect(presented.driverId).toBe(driverId); expect(presented.team).toBe(team); expect(presented.membership).toBe(membership); }); @@ -68,7 +67,7 @@ describe('GetDriverTeamUseCase', () => { const driverId = 'driver1'; - mockGetActiveMembershipForDriver.mockResolvedValue(null); + mockMembershipRepo.getActiveMembershipForDriver.mockResolvedValue(null); const input: GetDriverTeamInput = { driverId }; const result = await useCase.execute(input); @@ -76,7 +75,7 @@ describe('GetDriverTeamUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr().code).toBe('MEMBERSHIP_NOT_FOUND'); expect(result.unwrapErr().details.message).toBe('No active membership found for driver driver1'); - }); + }); it('should return error when team not found', async () => { const useCase = new GetDriverTeamUseCase(mockTeamRepo, @@ -86,8 +85,8 @@ describe('GetDriverTeamUseCase', () => { const driverId = 'driver1'; const membership = { id: 'membership1', driverId, teamId: 'team1' }; - mockGetActiveMembershipForDriver.mockResolvedValue(membership); - mockFindById.mockResolvedValue(null); + mockMembershipRepo.getActiveMembershipForDriver.mockResolvedValue(membership); + mockTeamRepo.findById.mockResolvedValue(null); const input: GetDriverTeamInput = { driverId }; const result = await useCase.execute(input); @@ -95,7 +94,7 @@ describe('GetDriverTeamUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr().code).toBe('TEAM_NOT_FOUND'); expect(result.unwrapErr().details.message).toBe('Team not found for teamId team1'); - }); + }); it('should return error when repository throws', async () => { const useCase = new GetDriverTeamUseCase(mockTeamRepo, @@ -105,7 +104,7 @@ describe('GetDriverTeamUseCase', () => { const driverId = 'driver1'; const error = new Error('Repository error'); - mockGetActiveMembershipForDriver.mockRejectedValue(error); + mockMembershipRepo.getActiveMembershipForDriver.mockRejectedValue(error); const input: GetDriverTeamInput = { driverId }; const result = await useCase.execute(input); @@ -113,5 +112,5 @@ describe('GetDriverTeamUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr().code).toBe('REPOSITORY_ERROR'); expect(result.unwrapErr().details.message).toBe('Repository error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetDriverTeamUseCase.ts b/core/racing/application/use-cases/GetDriverTeamUseCase.ts index 42f22b64e..748d74956 100644 --- a/core/racing/application/use-cases/GetDriverTeamUseCase.ts +++ b/core/racing/application/use-cases/GetDriverTeamUseCase.ts @@ -1,10 +1,8 @@ +import { TeamMembership } from '@/racing/domain/types/TeamMembership'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; import type { Team } from '../../domain/entities/Team'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { TeamMembership } from '../../domain/types/TeamMembership'; export interface GetDriverTeamInput { driverId: string; diff --git a/core/racing/application/use-cases/GetDriversLeaderboardUseCase.test.ts b/core/racing/application/use-cases/GetDriversLeaderboardUseCase.test.ts index 6aeb57b77..16fd46812 100644 --- a/core/racing/application/use-cases/GetDriversLeaderboardUseCase.test.ts +++ b/core/racing/application/use-cases/GetDriversLeaderboardUseCase.test.ts @@ -1,13 +1,9 @@ -import { describe, it, expect, vi } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; +import { describe, expect, it, vi } from 'vitest'; import { - GetDriversLeaderboardUseCase, - type GetDriversLeaderboardInput, - type GetDriversLeaderboardResult + GetDriversLeaderboardUseCase, + type GetDriversLeaderboardInput } from './GetDriversLeaderboardUseCase'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; -import type { RankingUseCase } from './RankingUseCase'; -import type { DriverStatsUseCase } from './DriverStatsUseCase'; -import type { Logger } from '@core/shared/application'; describe('GetDriversLeaderboardUseCase', () => { const mockDriverFindAll = vi.fn(); diff --git a/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.test.ts b/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.test.ts index ffe87eb8c..63a9e3490 100644 --- a/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.test.ts +++ b/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.test.ts @@ -1,25 +1,18 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { - GetEntitySponsorshipPricingUseCase, - type GetEntitySponsorshipPricingInput, - type GetEntitySponsorshipPricingResult, -} from './GetEntitySponsorshipPricingUseCase'; -import type { SponsorshipPricingRepository } from '../../domain/repositories/SponsorshipPricingRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; +import { + GetEntitySponsorshipPricingUseCase, + type GetEntitySponsorshipPricingInput +} from './GetEntitySponsorshipPricingUseCase'; describe('GetEntitySponsorshipPricingUseCase', () => { - let mockSponsorshipPricingRepo: ISponsorshipPricingRepository; + let mockSponsorshipPricingRepo: any; let mockLogger: Logger; let mockFindByEntity: Mock; - let mockFindPendingByEntity: Mock; - let mockFindBySeasonId: Mock; - }; beforeEach(() => { mockFindByEntity = vi.fn(); - mockFindPendingByEntity = vi.fn(); - mockFindBySeasonId = vi.fn(); mockSponsorshipPricingRepo = { findByEntity: mockFindByEntity, findAll: vi.fn(), @@ -29,18 +22,17 @@ describe('GetEntitySponsorshipPricingUseCase', () => { save: vi.fn(), exists: vi.fn(), findAcceptingApplications: vi.fn(), - } as ISponsorshipPricingRepository; + }; mockLogger = { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn(), }; - output = { present: vi.fn() } as unknown as typeof output; }); it('should return PRICING_NOT_CONFIGURED when no pricing found', async () => { - const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as unknown as ISponsorshipPricingRepository, + const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as any, mockLogger); const dto: GetEntitySponsorshipPricingInput = { @@ -59,10 +51,10 @@ describe('GetEntitySponsorshipPricingUseCase', () => { >; expect(err.code).toBe('PRICING_NOT_CONFIGURED'); expect(err.details.message).toContain('No sponsorship pricing configured'); - }); + }); it('should return pricing data when found', async () => { - const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as unknown as ISponsorshipPricingRepository, + const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as any, mockLogger); const dto: GetEntitySponsorshipPricingInput = { @@ -88,14 +80,12 @@ describe('GetEntitySponsorshipPricingUseCase', () => { }; mockFindByEntity.mockResolvedValue(pricing); - mockFindPendingByEntity.mockResolvedValue([]); - mockFindBySeasonId.mockResolvedValue([]); const result = await useCase.execute(dto); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = (expect(presented.entityType).toBe('season'); + const presented = result.unwrap(); + expect(presented.entityType).toBe('season'); expect(presented.entityId).toBe('season1'); expect(presented.acceptingApplications).toBe(true); expect(presented.customRequirements).toBe('Some requirements'); @@ -116,7 +106,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => { }); it('should return error when repository throws', async () => { - const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as unknown as ISponsorshipPricingRepository, + const useCase = new GetEntitySponsorshipPricingUseCase(mockSponsorshipPricingRepo as any, mockLogger); const dto: GetEntitySponsorshipPricingInput = { @@ -137,5 +127,5 @@ describe('GetEntitySponsorshipPricingUseCase', () => { >; expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('Repository error'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.ts b/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.ts index 70fe8f8e0..572d883bb 100644 --- a/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.ts +++ b/core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase.ts @@ -5,8 +5,6 @@ * Used by sponsors to see available slots and prices. */ -import type { SponsorshipPricingRepository } from '../../domain/repositories/SponsorshipPricingRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { SponsorableEntityType } from '../../domain/entities/SponsorshipRequest'; diff --git a/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.test.ts b/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.test.ts index 13b3651c3..a255bb789 100644 --- a/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.test.ts @@ -1,18 +1,15 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { - GetLeagueAdminPermissionsUseCase, - type GetLeagueAdminPermissionsInput, - type GetLeagueAdminPermissionsResult, - type GetLeagueAdminPermissionsErrorCode, -} from './GetLeagueAdminPermissionsUseCase'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import { + GetLeagueAdminPermissionsUseCase, + type GetLeagueAdminPermissionsErrorCode, + type GetLeagueAdminPermissionsInput +} from './GetLeagueAdminPermissionsUseCase'; describe('GetLeagueAdminPermissionsUseCase', () => { - let mockLeagueRepo: ILeagueRepository; - let mockMembershipRepo: ILeagueMembershipRepository; + let mockLeagueRepo: any; + let mockMembershipRepo: any; let mockFindById: Mock; let mockGetMembership: Mock; const logger: Logger = { @@ -34,7 +31,7 @@ describe('GetLeagueAdminPermissionsUseCase', () => { exists: vi.fn(), findByOwnerId: vi.fn(), searchByName: vi.fn(), - } as ILeagueRepository; + }; mockMembershipRepo = { getMembership: mockGetMembership, @@ -46,9 +43,8 @@ describe('GetLeagueAdminPermissionsUseCase', () => { removeJoinRequest: vi.fn(), countByLeagueId: vi.fn(), getLeagueMembers: vi.fn(), - } as ILeagueMembershipRepository; - - }); + }; + }); const createUseCase = () => new GetLeagueAdminPermissionsUseCase(mockLeagueRepo, mockMembershipRepo, @@ -59,7 +55,7 @@ describe('GetLeagueAdminPermissionsUseCase', () => { performerDriverId: 'driver1', }; - it('returns LEAGUE_NOT_FOUND when league does not exist and does not call output', async () => { + it('returns LEAGUE_NOT_FOUND when league does not exist', async () => { mockFindById.mockResolvedValue(null); const useCase = createUseCase(); @@ -69,9 +65,9 @@ describe('GetLeagueAdminPermissionsUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('LEAGUE_NOT_FOUND'); expect(err.details.message).toBe('League not found'); - }); + }); - it('returns USER_NOT_MEMBER when membership is missing and does not call output', async () => { + it('returns USER_NOT_MEMBER when membership is missing', async () => { mockFindById.mockResolvedValue({ id: 'league1' }); mockGetMembership.mockResolvedValue(null); @@ -82,9 +78,9 @@ describe('GetLeagueAdminPermissionsUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('USER_NOT_MEMBER'); expect(err.details.message).toBe('User is not a member of this league'); - }); + }); - it('returns USER_NOT_MEMBER when membership is not active and does not call output', async () => { + it('returns USER_NOT_MEMBER when membership is not active', async () => { mockFindById.mockResolvedValue({ id: 'league1' }); mockGetMembership.mockResolvedValue({ status: 'inactive', role: 'admin' }); @@ -95,9 +91,9 @@ describe('GetLeagueAdminPermissionsUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('USER_NOT_MEMBER'); expect(err.details.message).toBe('User is not a member of this league'); - }); + }); - it('returns USER_NOT_MEMBER when role is member and does not call output', async () => { + it('returns USER_NOT_MEMBER when role is member', async () => { mockFindById.mockResolvedValue({ id: 'league1' }); mockGetMembership.mockResolvedValue({ status: 'active', role: 'member' }); @@ -108,10 +104,10 @@ describe('GetLeagueAdminPermissionsUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('USER_NOT_MEMBER'); expect(err.details.message).toBe('User is not a member of this league'); - }); + }); - it('returns admin permissions for admin role and calls output once', async () => { - const league = { id: 'league1' } as unknown as { id: string }; + it('returns admin permissions for admin role', async () => { + const league = { id: 'league1' } as any; mockFindById.mockResolvedValue(league); mockGetMembership.mockResolvedValue({ status: 'active', role: 'admin' }); @@ -119,9 +115,9 @@ describe('GetLeagueAdminPermissionsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.league).toBe(league); + expect(presented.league).toBe(league); expect(presented.permissions).toEqual({ canManageSchedule: true, canManageMembers: true, @@ -130,8 +126,8 @@ describe('GetLeagueAdminPermissionsUseCase', () => { }); }); - it('returns admin permissions for owner role and calls output once', async () => { - const league = { id: 'league1' } as unknown as { id: string }; + it('returns admin permissions for owner role', async () => { + const league = { id: 'league1' } as any; mockFindById.mockResolvedValue(league); mockGetMembership.mockResolvedValue({ status: 'active', role: 'owner' }); @@ -139,9 +135,9 @@ describe('GetLeagueAdminPermissionsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.league).toBe(league); + expect(presented.league).toBe(league); expect(presented.permissions).toEqual({ canManageSchedule: true, canManageMembers: true, @@ -150,7 +146,7 @@ describe('GetLeagueAdminPermissionsUseCase', () => { }); }); - it('wraps repository errors in REPOSITORY_ERROR and does not call output', async () => { + it('wraps repository errors in REPOSITORY_ERROR', async () => { const error = new Error('repo failed'); mockFindById.mockRejectedValue(error); @@ -161,5 +157,5 @@ describe('GetLeagueAdminPermissionsUseCase', () => { const err = result.unwrapErr() as ApplicationErrorCode; expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('repo failed'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.ts b/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.ts index 322df399f..2a4c1f877 100644 --- a/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.ts +++ b/core/racing/application/use-cases/GetLeagueAdminPermissionsUseCase.ts @@ -1,14 +1,8 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { League } from '../../domain/entities/League'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -export type GetLeagueAdminPermissionsInput = { - leagueId: string; - performerDriverId: string; -}; export type LeagueAdminPermissions = { canManageSchedule: boolean; diff --git a/core/racing/application/use-cases/GetLeagueAdminUseCase.test.ts b/core/racing/application/use-cases/GetLeagueAdminUseCase.test.ts index d16a3e4d9..4656d4801 100644 --- a/core/racing/application/use-cases/GetLeagueAdminUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueAdminUseCase.test.ts @@ -9,8 +9,9 @@ import type { LeagueRepository } from '../../domain/repositories/LeagueRepositor import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; describe('GetLeagueAdminUseCase', () => { - let mockLeagueRepo: ILeagueRepository; + let mockLeagueRepo: any; let mockFindById: Mock; + beforeEach(() => { mockFindById = vi.fn(); mockLeagueRepo = { @@ -22,9 +23,8 @@ describe('GetLeagueAdminUseCase', () => { exists: vi.fn(), findByOwnerId: vi.fn(), searchByName: vi.fn(), - } as ILeagueRepository; - - }); + }; + }); const createUseCase = () => new GetLeagueAdminUseCase(mockLeagueRepo); @@ -42,7 +42,7 @@ describe('GetLeagueAdminUseCase', () => { const error = result.unwrapErr() as ApplicationErrorCode; expect(error.code).toBe('LEAGUE_NOT_FOUND'); expect(error.details.message).toBe('League not found'); - }); + }); it('should return league data when league found', async () => { const league = { id: 'league1', ownerId: 'owner1' }; @@ -52,8 +52,8 @@ describe('GetLeagueAdminUseCase', () => { const result = await useCase.execute(params); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented.league.id).toBe('league1'); + const presented = result.unwrap(); + expect(presented.league.id).toBe('league1'); expect(presented.league.ownerId).toBe('owner1'); }); @@ -68,5 +68,5 @@ describe('GetLeagueAdminUseCase', () => { const error = result.unwrapErr() as ApplicationErrorCode; expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toBe('Repository failure'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetLeagueDriverSeasonStatsUseCase.test.ts b/core/racing/application/use-cases/GetLeagueDriverSeasonStatsUseCase.test.ts index 14d03f3f0..c95d7a395 100644 --- a/core/racing/application/use-cases/GetLeagueDriverSeasonStatsUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueDriverSeasonStatsUseCase.test.ts @@ -1,17 +1,17 @@ -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { StandingRepository } from '../../domain/repositories/StandingRepository'; -import type { DriverRatingPort } from '../ports/DriverRatingPort'; +import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { GetLeagueDriverSeasonStatsUseCase, type GetLeagueDriverSeasonStatsErrorCode, type GetLeagueDriverSeasonStatsInput, type GetLeagueDriverSeasonStatsResult, } from './GetLeagueDriverSeasonStatsUseCase'; +import type { StandingRepository } from '../../domain/repositories/StandingRepository'; +import type { ResultRepository } from '../../domain/repositories/ResultRepository'; +import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; +import type { RaceRepository } from '../../domain/repositories/RaceRepository'; +import type { DriverRepository } from '../../domain/repositories/DriverRepository'; +import type { DriverRatingPort } from '../ports/DriverRatingPort'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; describe('GetLeagueDriverSeasonStatsUseCase', () => { const mockStandingFindByLeagueId = vi.fn(); @@ -20,15 +20,15 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => { const mockRaceFindByLeagueId = vi.fn(); const mockDriverRatingGetRating = vi.fn(); const mockDriverFindById = vi.fn(); - const mockTeamFindById = vi.fn(); let useCase: GetLeagueDriverSeasonStatsUseCase; - let standingRepository: IStandingRepository; - let resultRepository: IResultRepository; - let penaltyRepository: IPenaltyRepository; - let raceRepository: IRaceRepository; - let driverRepository: IDriverRepository; - let driverRatingPort: DriverRatingPort; + let standingRepository: any; + let resultRepository: any; + let penaltyRepository: any; + let raceRepository: any; + let driverRepository: any; + let driverRatingPort: any; + beforeEach(() => { mockStandingFindByLeagueId.mockReset(); mockResultFindByDriverIdAndLeagueId.mockReset(); @@ -36,7 +36,6 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => { mockRaceFindByLeagueId.mockReset(); mockDriverRatingGetRating.mockReset(); mockDriverFindById.mockReset(); - mockTeamFindById.mockReset(); standingRepository = { findByLeagueId: mockStandingFindByLeagueId, @@ -103,8 +102,6 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => { updateDriverRating: vi.fn(), }; - }; - useCase = new GetLeagueDriverSeasonStatsUseCase(standingRepository, resultRepository, penaltyRepository, @@ -182,8 +179,8 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented.leagueId).toBe('league-1'); + const presented = result.unwrap(); + expect(presented.leagueId).toBe('league-1'); expect(presented.stats).toHaveLength(2); expect(presented.stats[0]).toEqual({ @@ -231,8 +228,8 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented?.stats[0]?.penaltyPoints).toBe(0); + const presented = result.unwrap(); + expect(presented.stats[0]?.penaltyPoints).toBe(0); }); it('should return LEAGUE_NOT_FOUND when no standings are found', async () => { @@ -250,7 +247,7 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => { >; expect(err.code).toBe('LEAGUE_NOT_FOUND'); expect(err.details.message).toBe('League not found'); - }); + }); it('should return REPOSITORY_ERROR when an unexpected error occurs', async () => { const input: GetLeagueDriverSeasonStatsInput = { leagueId: 'league-1' }; @@ -265,8 +262,7 @@ describe('GetLeagueDriverSeasonStatsUseCase', () => { GetLeagueDriverSeasonStatsErrorCode, { message: string } >; - expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('repository failure'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetLeagueFullConfigUseCase.test.ts b/core/racing/application/use-cases/GetLeagueFullConfigUseCase.test.ts index 33c34190c..e614a4f39 100644 --- a/core/racing/application/use-cases/GetLeagueFullConfigUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueFullConfigUseCase.test.ts @@ -13,30 +13,23 @@ import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorC describe('GetLeagueFullConfigUseCase', () => { let useCase: GetLeagueFullConfigUseCase; - let leagueRepository: ILeagueRepository & { findById: ReturnType }; - let seasonRepository: ISeasonRepository & { findByLeagueId: ReturnType }; - let leagueScoringConfigRepository: ILeagueScoringConfigRepository & { - findBySeasonId: ReturnType; - }; - let gameRepository: IGameRepository & { findById: ReturnType }; + let leagueRepository: any; + let seasonRepository: any; + let leagueScoringConfigRepository: any; + let gameRepository: any; + beforeEach(() => { leagueRepository = { findById: vi.fn(), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any; + }; seasonRepository = { findByLeagueId: vi.fn(), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any; + }; leagueScoringConfigRepository = { findBySeasonId: vi.fn(), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any; + }; gameRepository = { findById: vi.fn(), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any; - }; useCase = new GetLeagueFullConfigUseCase(leagueRepository, @@ -78,9 +71,7 @@ describe('GetLeagueFullConfigUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const firstCall = const presented = firstCall[0] as GetLeagueFullConfigResult; + const presented = result.unwrap(); expect(presented.config.league).toEqual(mockLeague); expect(presented.config.activeSeason).toEqual(mockSeasons[0]); @@ -88,7 +79,7 @@ describe('GetLeagueFullConfigUseCase', () => { expect(presented.config.game).toEqual(mockGame); }); - it('should return error when league not found and not call presenter', async () => { + it('should return error when league not found', async () => { const input: GetLeagueFullConfigInput = { leagueId: 'league-1' }; leagueRepository.findById.mockResolvedValue(null); @@ -103,7 +94,7 @@ describe('GetLeagueFullConfigUseCase', () => { expect(error.code).toBe('LEAGUE_NOT_FOUND'); expect(error.details.message).toBe('League not found'); - }); + }); it('should handle no active season', async () => { const input: GetLeagueFullConfigInput = { leagueId: 'league-1' }; @@ -121,8 +112,7 @@ describe('GetLeagueFullConfigUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const firstCall = const presented = firstCall[0] as GetLeagueFullConfigResult; + const presented = result.unwrap(); expect(presented.config.league).toEqual(mockLeague); expect(presented.config.activeSeason).toBeUndefined(); @@ -130,7 +120,7 @@ describe('GetLeagueFullConfigUseCase', () => { expect(presented.config.game).toBeUndefined(); }); - it('should return repository error when repository throws and not call presenter', async () => { + it('should return repository error when repository throws', async () => { const input: GetLeagueFullConfigInput = { leagueId: 'league-1' }; const thrownError = new Error('Repository failure'); @@ -146,5 +136,5 @@ describe('GetLeagueFullConfigUseCase', () => { expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toBe('Repository failure'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetLeagueMembershipsUseCase.test.ts b/core/racing/application/use-cases/GetLeagueMembershipsUseCase.test.ts index 4025a6c8f..2cb37d0e5 100644 --- a/core/racing/application/use-cases/GetLeagueMembershipsUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueMembershipsUseCase.test.ts @@ -5,9 +5,6 @@ import { type GetLeagueMembershipsResult, type GetLeagueMembershipsErrorCode, } from './GetLeagueMembershipsUseCase'; -import { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import { DriverRepository } from '../../domain/repositories/DriverRepository'; -import { LeagueRepository } from '../../domain/repositories/LeagueRepository'; import { LeagueMembership } from '../../domain/entities/LeagueMembership'; import { Driver } from '../../domain/entities/Driver'; import { League } from '../../domain/entities/League'; @@ -24,6 +21,7 @@ describe('GetLeagueMembershipsUseCase', () => { let leagueRepository: { findById: Mock; }; + beforeEach(() => { leagueMembershipRepository = { getLeagueMembers: vi.fn(), @@ -34,12 +32,9 @@ describe('GetLeagueMembershipsUseCase', () => { leagueRepository = { findById: vi.fn(), }; - output = { - present: vi.fn(), - }; - useCase = new GetLeagueMembershipsUseCase(leagueMembershipRepository as unknown as ILeagueMembershipRepository, - driverRepository as unknown as IDriverRepository, - leagueRepository as unknown as ILeagueRepository); + useCase = new GetLeagueMembershipsUseCase(leagueMembershipRepository as any, + driverRepository as any, + leagueRepository as any); }); it('should return league memberships with drivers', async () => { @@ -90,14 +85,14 @@ describe('GetLeagueMembershipsUseCase', () => { const result = await useCase.execute({ leagueId } as GetLeagueMembershipsInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented?.league).toEqual(league); - expect(presented?.memberships).toHaveLength(2); - expect(presented?.memberships[0]?.membership).toEqual(memberships[0]); - expect(presented?.memberships[0]?.driver).toEqual(driver1); - expect(presented?.memberships[1]?.membership).toEqual(memberships[1]); - expect(presented?.memberships[1]?.driver).toEqual(driver2); + expect(presented.league).toEqual(league); + expect(presented.memberships).toHaveLength(2); + expect(presented.memberships[0]?.membership).toEqual(memberships[0]); + expect(presented.memberships[0]?.driver).toEqual(driver1); + expect(presented.memberships[1]?.membership).toEqual(memberships[1]); + expect(presented.memberships[1]?.driver).toEqual(driver2); }); it('should handle drivers not found', async () => { @@ -125,12 +120,12 @@ describe('GetLeagueMembershipsUseCase', () => { const result = await useCase.execute({ leagueId } as GetLeagueMembershipsInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented?.league).toEqual(league); - expect(presented?.memberships).toHaveLength(1); - expect(presented?.memberships[0]?.membership).toEqual(memberships[0]); - expect(presented?.memberships[0]?.driver).toBeNull(); + expect(presented.league).toEqual(league); + expect(presented.memberships).toHaveLength(1); + expect(presented.memberships[0]?.membership).toEqual(memberships[0]); + expect(presented.memberships[0]?.driver).toBeNull(); }); it('should return error when league not found', async () => { @@ -149,7 +144,7 @@ describe('GetLeagueMembershipsUseCase', () => { expect(err.code).toBe('LEAGUE_NOT_FOUND'); expect(err.details?.message).toBe('League not found'); - }); + }); it('should return repository error on unexpected failure', async () => { const leagueId = 'league-1'; @@ -169,5 +164,5 @@ describe('GetLeagueMembershipsUseCase', () => { expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details?.message).toBe('Database connection failed'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetLeagueOwnerSummaryUseCase.test.ts b/core/racing/application/use-cases/GetLeagueOwnerSummaryUseCase.test.ts index 5befbe10c..efec2b2da 100644 --- a/core/racing/application/use-cases/GetLeagueOwnerSummaryUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueOwnerSummaryUseCase.test.ts @@ -5,11 +5,10 @@ import { type GetLeagueOwnerSummaryResult, type GetLeagueOwnerSummaryErrorCode, } from './GetLeagueOwnerSummaryUseCase'; -import { DriverRepository } from '../../domain/repositories/DriverRepository'; -import { LeagueRepository } from '../../domain/repositories/LeagueRepository'; import { Driver } from '../../domain/entities/Driver'; import { League } from '../../domain/entities/League'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; + describe('GetLeagueOwnerSummaryUseCase', () => { let useCase: GetLeagueOwnerSummaryUseCase; let leagueRepository: { @@ -18,6 +17,14 @@ describe('GetLeagueOwnerSummaryUseCase', () => { let driverRepository: { findById: Mock; }; + let leagueMembershipRepository: { + getLeagueMembers: Mock; + }; + let standingRepository: { + findByDriverIdAndLeagueId: Mock; + findByLeagueId: Mock; + }; + beforeEach(() => { leagueRepository = { findById: vi.fn(), @@ -25,8 +32,19 @@ describe('GetLeagueOwnerSummaryUseCase', () => { driverRepository = { findById: vi.fn(), }; - useCase = new GetLeagueOwnerSummaryUseCase(leagueRepository as unknown as ILeagueRepository, - driverRepository as unknown as IDriverRepository); + leagueMembershipRepository = { + getLeagueMembers: vi.fn(), + }; + standingRepository = { + findByDriverIdAndLeagueId: vi.fn(), + findByLeagueId: vi.fn(), + }; + useCase = new GetLeagueOwnerSummaryUseCase( + leagueRepository as any, + driverRepository as any, + leagueMembershipRepository as any, + standingRepository as any + ); }); it('should return owner summary when league and owner exist', async () => { @@ -48,15 +66,17 @@ describe('GetLeagueOwnerSummaryUseCase', () => { leagueRepository.findById.mockResolvedValue(league); driverRepository.findById.mockResolvedValue(driver); + leagueMembershipRepository.getLeagueMembers.mockResolvedValue([]); + standingRepository.findByDriverIdAndLeagueId.mockResolvedValue(null); const result = await useCase.execute({ leagueId } as GetLeagueOwnerSummaryInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented?.league).toBe(league); - expect(presented?.owner).toBe(driver); - expect(presented?.rating).toBe(0); - expect(presented?.rank).toBe(0); + const presented = result.unwrap(); + expect(presented.league).toBe(league); + expect(presented.owner).toBe(driver); + expect(presented.rating).toBeNull(); + expect(presented.rank).toBeNull(); }); it('should return error when league does not exist', async () => { @@ -73,7 +93,7 @@ describe('GetLeagueOwnerSummaryUseCase', () => { >; expect(errorResult.code).toBe('LEAGUE_NOT_FOUND'); expect(errorResult.details.message).toBe('League not found'); - }); + }); it('should return error when owner does not exist', async () => { const leagueId = 'league-1'; @@ -98,7 +118,7 @@ describe('GetLeagueOwnerSummaryUseCase', () => { >; expect(errorResult.code).toBe('OWNER_NOT_FOUND'); expect(errorResult.details.message).toBe('League owner not found'); - }); + }); it('should return repository error when repository throws', async () => { const leagueId = 'league-1'; @@ -115,5 +135,5 @@ describe('GetLeagueOwnerSummaryUseCase', () => { expect(errorResult.code).toBe('REPOSITORY_ERROR'); expect(errorResult.details.message).toBe('DB failure'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetLeagueScheduleUseCase.ts b/core/racing/application/use-cases/GetLeagueScheduleUseCase.ts index cd5b2cf59..0c9042c34 100644 --- a/core/racing/application/use-cases/GetLeagueScheduleUseCase.ts +++ b/core/racing/application/use-cases/GetLeagueScheduleUseCase.ts @@ -1,13 +1,10 @@ -import type { Logger } from '@core/shared/application'; +import { SeasonScheduleGenerator } from '@/racing/domain/services/SeasonScheduleGenerator'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { League } from '../../domain/entities/League'; import type { Race } from '../../domain/entities/Race'; import type { Season } from '../../domain/entities/season/Season'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import { SeasonScheduleGenerator } from '../../domain/services/SeasonScheduleGenerator'; export type GetLeagueScheduleErrorCode = | 'LEAGUE_NOT_FOUND' diff --git a/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.test.ts b/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.test.ts index e53ded08e..5fe632b88 100644 --- a/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.test.ts @@ -1,3 +1,4 @@ +import { describe, it, expect, beforeEach, vi } from 'vitest'; import { Result } from '@core/shared/domain/Result'; import { GetLeagueScoringConfigUseCase } from './GetLeagueScoringConfigUseCase'; import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; @@ -12,39 +13,39 @@ import type { LeagueScoringPreset } from '../../domain/types/LeagueScoringPreset describe('GetLeagueScoringConfigUseCase', () => { let useCase: GetLeagueScoringConfigUseCase; - let mockLeagueRepository: jest.Mocked; - let mockSeasonRepository: jest.Mocked; - let mockLeagueScoringConfigRepository: jest.Mocked; - let mockGameRepository: jest.Mocked; - let mockPresetProvider: { getPresetById: jest.Mock }; + let mockLeagueRepository: any; + let mockSeasonRepository: any; + let mockLeagueScoringConfigRepository: any; + let mockGameRepository: any; + let mockPresetProvider: { getPresetById: any }; beforeEach(() => { mockLeagueRepository = { - findById: jest.fn(), - exists: jest.fn(), - save: jest.fn(), - findAll: jest.fn(), - } as any; + findById: vi.fn(), + exists: vi.fn(), + save: vi.fn(), + findAll: vi.fn(), + }; mockSeasonRepository = { - findByLeagueId: jest.fn(), - save: jest.fn(), - findById: jest.fn(), - } as any; + findByLeagueId: vi.fn(), + save: vi.fn(), + findById: vi.fn(), + }; mockLeagueScoringConfigRepository = { - findBySeasonId: jest.fn(), - save: jest.fn(), - } as any; + findBySeasonId: vi.fn(), + save: vi.fn(), + }; mockGameRepository = { - findById: jest.fn(), - save: jest.fn(), - findAll: jest.fn(), - } as any; + findById: vi.fn(), + save: vi.fn(), + findAll: vi.fn(), + }; mockPresetProvider = { - getPresetById: jest.fn(), + getPresetById: vi.fn(), }; useCase = new GetLeagueScoringConfigUseCase( @@ -80,7 +81,7 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'league-1' }); expect(result.isOk()).toBe(true); - const value = result.value as any; + const value = result.unwrap() as any; expect(value.league).toBe(mockLeague); expect(value.season).toBe(mockSeason); expect(value.scoringConfig).toBe(mockScoringConfig); @@ -94,7 +95,7 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'non-existent' }); expect(result.isErr()).toBe(true); - expect(result.value).toEqual({ + expect(result.unwrapErr()).toEqual({ code: 'LEAGUE_NOT_FOUND', details: { message: 'League not found' }, }); @@ -109,7 +110,7 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'league-1' }); expect(result.isErr()).toBe(true); - expect(result.value).toEqual({ + expect(result.unwrapErr()).toEqual({ code: 'NO_SEASONS', details: { message: 'No seasons found for league' }, }); @@ -129,7 +130,7 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'league-1' }); expect(result.isErr()).toBe(true); - expect(result.value).toEqual({ + expect(result.unwrapErr()).toEqual({ code: 'NO_ACTIVE_SEASON', details: { message: 'No active season found for league' }, }); @@ -150,7 +151,7 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'league-1' }); expect(result.isErr()).toBe(true); - expect(result.value).toEqual({ + expect(result.unwrapErr()).toEqual({ code: 'NO_SCORING_CONFIG', details: { message: 'Scoring configuration not found' }, }); @@ -177,7 +178,7 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'league-1' }); expect(result.isErr()).toBe(true); - expect(result.value).toEqual({ + expect(result.unwrapErr()).toEqual({ code: 'GAME_NOT_FOUND', details: { message: 'Game not found for season' }, }); @@ -205,7 +206,7 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'league-1' }); expect(result.isOk()).toBe(true); - const value = result.value as any; + const value = result.unwrap() as any; expect(value.preset).toBeUndefined(); }); @@ -215,9 +216,9 @@ describe('GetLeagueScoringConfigUseCase', () => { const result = await useCase.execute({ leagueId: 'league-1' }); expect(result.isErr()).toBe(true); - expect(result.value).toEqual({ + expect(result.unwrapErr()).toEqual({ code: 'REPOSITORY_ERROR', details: { message: 'Database error' }, }); }); -}); \ No newline at end of file +}); diff --git a/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.ts b/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.ts index 611311a54..38adab913 100644 --- a/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.ts +++ b/core/racing/application/use-cases/GetLeagueScoringConfigUseCase.ts @@ -74,7 +74,7 @@ export class GetLeagueScoringConfigUseCase { return (seasonStatus as { toString: () => string }).toString() === 'active'; } return false; - }) ?? seasons[0]; + }); if (!activeSeason) { return Result.err({ diff --git a/core/racing/application/use-cases/GetLeagueSeasonsUseCase.test.ts b/core/racing/application/use-cases/GetLeagueSeasonsUseCase.test.ts index 68f206fef..ee4ee88e7 100644 --- a/core/racing/application/use-cases/GetLeagueSeasonsUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueSeasonsUseCase.test.ts @@ -8,7 +8,7 @@ import { import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import { Season } from '../../domain/entities/season'; +import { Season } from '../../domain/entities/season/Season'; import { League } from '../../domain/entities/League'; describe('GetLeagueSeasonsUseCase', () => { @@ -18,7 +18,7 @@ describe('GetLeagueSeasonsUseCase', () => { }; let leagueRepository: { findById: Mock; - }; + exists: Mock; }; beforeEach(() => { @@ -28,15 +28,14 @@ describe('GetLeagueSeasonsUseCase', () => { leagueRepository = { findById: vi.fn(), + exists: vi.fn(), }; - }; - - useCase = new GetLeagueSeasonsUseCase(seasonRepository as unknown as ISeasonRepository, - leagueRepository as unknown as ILeagueRepository); + useCase = new GetLeagueSeasonsUseCase(leagueRepository as any, + seasonRepository as any); }); - it('should present seasons with correct isParallelActive flags on success', async () => { + it('should return seasons with correct isParallelActive flags on success', async () => { const leagueId = 'league-1'; const league = League.create({ id: leagueId, @@ -64,24 +63,24 @@ describe('GetLeagueSeasonsUseCase', () => { }), ]; + leagueRepository.exists.mockResolvedValue(true); leagueRepository.findById.mockResolvedValue(league); seasonRepository.findByLeagueId.mockResolvedValue(seasons); const result = await useCase.execute({ leagueId } satisfies GetLeagueSeasonsInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented?.league).toBe(league); - expect(presented?.seasons).toHaveLength(2); + expect(presented.seasons).toHaveLength(2); - expect(presented?.seasons[0]?.season).toBe(seasons[0]); - expect(presented?.seasons[0]?.isPrimary).toBe(false); - expect(presented?.seasons[0]?.isParallelActive).toBe(false); + expect(presented.seasons[0]?.season).toBe(seasons[0]); + expect(presented.seasons[0]?.isPrimary).toBe(true); + expect(presented.seasons[0]?.isParallelActive).toBe(false); - expect(presented?.seasons[1]?.season).toBe(seasons[1]); - expect(presented?.seasons[1]?.isPrimary).toBe(false); - expect(presented?.seasons[1]?.isParallelActive).toBe(false); + expect(presented.seasons[1]?.season).toBe(seasons[1]); + expect(presented.seasons[1]?.isPrimary).toBe(false); + expect(presented.seasons[1]?.isParallelActive).toBe(false); }); it('should set isParallelActive true for active seasons when multiple active', async () => { @@ -110,23 +109,24 @@ describe('GetLeagueSeasonsUseCase', () => { }), ]; + leagueRepository.exists.mockResolvedValue(true); leagueRepository.findById.mockResolvedValue(league); seasonRepository.findByLeagueId.mockResolvedValue(seasons); const result = await useCase.execute({ leagueId } satisfies GetLeagueSeasonsInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented?.seasons).toHaveLength(2); - expect(presented?.seasons[0]?.isParallelActive).toBe(true); - expect(presented?.seasons[1]?.isParallelActive).toBe(true); + expect(presented.seasons).toHaveLength(2); + expect(presented.seasons[0]?.isParallelActive).toBe(true); + expect(presented.seasons[1]?.isParallelActive).toBe(true); }); it('should return LEAGUE_NOT_FOUND error when league does not exist', async () => { const leagueId = 'missing-league'; - leagueRepository.findById.mockResolvedValue(null); + leagueRepository.exists.mockResolvedValue(false); const result = await useCase.execute({ leagueId } satisfies GetLeagueSeasonsInput); @@ -138,13 +138,13 @@ describe('GetLeagueSeasonsUseCase', () => { expect(err.code).toBe('LEAGUE_NOT_FOUND'); expect(err.details.message).toBe('League not found'); - }); + }); it('should return REPOSITORY_ERROR when repository throws', async () => { const leagueId = 'league-1'; const errorMessage = 'DB error'; - leagueRepository.findById.mockRejectedValue(new Error(errorMessage)); + leagueRepository.exists.mockRejectedValue(new Error(errorMessage)); const result = await useCase.execute({ leagueId } satisfies GetLeagueSeasonsInput); @@ -156,5 +156,5 @@ describe('GetLeagueSeasonsUseCase', () => { expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe(errorMessage); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetLeagueStandingsUseCase.test.ts b/core/racing/application/use-cases/GetLeagueStandingsUseCase.test.ts index 41b118b6c..de5906851 100644 --- a/core/racing/application/use-cases/GetLeagueStandingsUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueStandingsUseCase.test.ts @@ -6,8 +6,6 @@ import { type GetLeagueStandingsResult, type GetLeagueStandingsErrorCode, } from './GetLeagueStandingsUseCase'; -import type { StandingRepository } from '../../domain/repositories/StandingRepository'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; import { Standing } from '../../domain/entities/Standing'; import { Driver } from '../../domain/entities/Driver'; @@ -19,6 +17,7 @@ describe('GetLeagueStandingsUseCase', () => { let driverRepository: { findById: Mock; }; + beforeEach(() => { standingRepository = { findByLeagueId: vi.fn(), @@ -26,15 +25,12 @@ describe('GetLeagueStandingsUseCase', () => { driverRepository = { findById: vi.fn(), }; - output = { - present: vi.fn(), - }; - useCase = new GetLeagueStandingsUseCase(standingRepository as unknown as IStandingRepository, - driverRepository as unknown as IDriverRepository); + useCase = new GetLeagueStandingsUseCase(standingRepository as any, + driverRepository as any); }); - it('should present standings with drivers mapped and return ok result', async () => { + it('should return standings with drivers mapped', async () => { const leagueId = 'league-1'; const standings = [ Standing.create({ @@ -75,9 +71,9 @@ describe('GetLeagueStandingsUseCase', () => { const result = await useCase.execute({ leagueId } satisfies GetLeagueStandingsInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.standings).toHaveLength(2); + expect(presented.standings).toHaveLength(2); expect(presented.standings[0]).toEqual({ driverId: 'driver-1', driver: driver1, @@ -92,7 +88,7 @@ describe('GetLeagueStandingsUseCase', () => { }); }); - it('should return repository error and not call output when repository fails', async () => { + it('should return repository error when repository fails', async () => { const leagueId = 'league-1'; standingRepository.findByLeagueId.mockRejectedValue(new Error('DB error')); @@ -106,5 +102,5 @@ describe('GetLeagueStandingsUseCase', () => { expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toBe('DB error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetLeagueStatsUseCase.test.ts b/core/racing/application/use-cases/GetLeagueStatsUseCase.test.ts index d27a037de..e64c66196 100644 --- a/core/racing/application/use-cases/GetLeagueStatsUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueStatsUseCase.test.ts @@ -5,8 +5,8 @@ import { type GetLeagueStatsResult, type GetLeagueStatsErrorCode, } from './GetLeagueStatsUseCase'; -import { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import { RaceRepository } from '../../domain/repositories/RaceRepository'; +import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; +import type { RaceRepository } from '../../domain/repositories/RaceRepository'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; describe('GetLeagueStatsUseCase', () => { @@ -18,6 +18,7 @@ describe('GetLeagueStatsUseCase', () => { findByLeagueId: Mock; }; let getDriverRating: Mock; + beforeEach(() => { leagueMembershipRepository = { getLeagueMembers: vi.fn(), @@ -26,8 +27,8 @@ describe('GetLeagueStatsUseCase', () => { findByLeagueId: vi.fn(), }; getDriverRating = vi.fn(); - useCase = new GetLeagueStatsUseCase(leagueMembershipRepository as unknown as ILeagueMembershipRepository, - raceRepository as unknown as IRaceRepository, + useCase = new GetLeagueStatsUseCase(leagueMembershipRepository as any, + raceRepository as any, getDriverRating); }); @@ -52,8 +53,8 @@ describe('GetLeagueStatsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = (expect(presented.leagueId).toBe(input.leagueId); + const presented = result.unwrap(); + expect(presented.leagueId).toBe(input.leagueId); expect(presented.driverCount).toBe(3); expect(presented.raceCount).toBe(2); expect(presented.averageRating).toBe(1550); // (1500 + 1600) / 2 @@ -71,8 +72,8 @@ describe('GetLeagueStatsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = (expect(presented.leagueId).toBe(input.leagueId); + const presented = result.unwrap(); + expect(presented.leagueId).toBe(input.leagueId); expect(presented.driverCount).toBe(1); expect(presented.raceCount).toBe(1); expect(presented.averageRating).toBe(0); @@ -92,7 +93,7 @@ describe('GetLeagueStatsUseCase', () => { >; expect(error.code).toBe('LEAGUE_NOT_FOUND'); expect(error.details.message).toBe('League not found'); - }); + }); it('should return error when repository fails', async () => { const input: GetLeagueStatsInput = { leagueId: 'league-1' }; @@ -107,5 +108,5 @@ describe('GetLeagueStatsUseCase', () => { >; expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toBe('DB error'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetLeagueWalletUseCase.test.ts b/core/racing/application/use-cases/GetLeagueWalletUseCase.test.ts index ac1c578b7..abe598bf9 100644 --- a/core/racing/application/use-cases/GetLeagueWalletUseCase.test.ts +++ b/core/racing/application/use-cases/GetLeagueWalletUseCase.test.ts @@ -40,9 +40,9 @@ describe('GetLeagueWalletUseCase', () => { findByWalletId: vi.fn(), }; - useCase = new GetLeagueWalletUseCase(leagueRepository as unknown as ILeagueRepository, - leagueWalletRepository as unknown as ILeagueWalletRepository, - transactionRepository as unknown as ITransactionRepository); + useCase = new GetLeagueWalletUseCase(leagueRepository as any, + leagueWalletRepository as any, + transactionRepository as any); }); it('returns mapped wallet data when wallet exists', async () => { @@ -123,8 +123,8 @@ describe('GetLeagueWalletUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = (expect(presented.wallet).toBe(wallet); + const presented = result.unwrap(); + expect(presented.wallet).toBe(wallet); expect(presented.transactions).toHaveLength(transactions.length); expect(presented.transactions[0]!.id).toEqual( transactions.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())[0]! @@ -171,7 +171,7 @@ describe('GetLeagueWalletUseCase', () => { expect(err.code).toBe('WALLET_NOT_FOUND'); expect(err.details.message).toBe('League wallet not found'); - }); + }); it('returns league not found when league does not exist', async () => { const leagueId = 'league-missing'; @@ -190,7 +190,7 @@ describe('GetLeagueWalletUseCase', () => { expect(err.code).toBe('LEAGUE_NOT_FOUND'); expect(err.details.message).toBe('League not found'); - }); + }); it('returns repository error when repository throws', async () => { const leagueId = 'league-1'; @@ -209,5 +209,5 @@ describe('GetLeagueWalletUseCase', () => { expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('DB error'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetRaceProtestsUseCase.test.ts b/core/racing/application/use-cases/GetRaceProtestsUseCase.test.ts index e3ecfc8b4..ba279a9be 100644 --- a/core/racing/application/use-cases/GetRaceProtestsUseCase.test.ts +++ b/core/racing/application/use-cases/GetRaceProtestsUseCase.test.ts @@ -5,8 +5,6 @@ import { type GetRaceProtestsResult, type GetRaceProtestsErrorCode, } from './GetRaceProtestsUseCase'; -import type { ProtestRepository } from '../../domain/repositories/ProtestRepository'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; import { Protest } from '../../domain/entities/Protest'; import { Driver } from '../../domain/entities/Driver'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; @@ -15,11 +13,12 @@ describe('GetRaceProtestsUseCase', () => { let useCase: GetRaceProtestsUseCase; let protestRepository: { findByRaceId: Mock }; let driverRepository: { findById: Mock }; + beforeEach(() => { protestRepository = { findByRaceId: vi.fn() }; driverRepository = { findById: vi.fn() }; - useCase = new GetRaceProtestsUseCase(protestRepository as unknown as IProtestRepository, - driverRepository as unknown as IDriverRepository); + useCase = new GetRaceProtestsUseCase(protestRepository as any, + driverRepository as any); }); it('should return protests with drivers', async () => { @@ -66,10 +65,7 @@ describe('GetRaceProtestsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as GetRaceProtestsResult; + const presented = result.unwrap(); expect(presented.protests).toHaveLength(1); expect(presented.protests[0]).toEqual(protest); @@ -85,10 +81,7 @@ describe('GetRaceProtestsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as GetRaceProtestsResult; + const presented = result.unwrap(); expect(presented.protests).toEqual([]); expect(presented.drivers).toEqual([]); @@ -109,5 +102,5 @@ describe('GetRaceProtestsUseCase', () => { expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('DB error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetRaceRegistrationsUseCase.test.ts b/core/racing/application/use-cases/GetRaceRegistrationsUseCase.test.ts index f70acb596..39293b416 100644 --- a/core/racing/application/use-cases/GetRaceRegistrationsUseCase.test.ts +++ b/core/racing/application/use-cases/GetRaceRegistrationsUseCase.test.ts @@ -5,25 +5,23 @@ import { type GetRaceRegistrationsResult, type GetRaceRegistrationsErrorCode, } from './GetRaceRegistrationsUseCase'; -import type { RaceRepository } from '@core/racing/domain/repositories/RaceRepository'; -import type { RaceRegistrationRepository } from '@core/racing/domain/repositories/RaceRegistrationRepository'; import { RaceRegistration } from '@core/racing/domain/entities/RaceRegistration'; import { Race } from '@core/racing/domain/entities/Race'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import { Result } from '@core/shared/domain/Result'; describe('GetRaceRegistrationsUseCase', () => { let useCase: GetRaceRegistrationsUseCase; let raceRepository: { findById: Mock }; let registrationRepository: { findByRaceId: Mock }; + beforeEach(() => { raceRepository = { findById: vi.fn() }; registrationRepository = { findByRaceId: vi.fn() }; - useCase = new GetRaceRegistrationsUseCase(raceRepository as unknown as IRaceRepository, - registrationRepository as unknown as IRaceRegistrationRepository); + useCase = new GetRaceRegistrationsUseCase(raceRepository as any, + registrationRepository as any); }); - it('should present race and registrations on success', async () => { + it('should return race and registrations on success', async () => { const input: GetRaceRegistrationsInput = { raceId: 'race-1' }; const race = Race.create({ @@ -42,14 +40,10 @@ describe('GetRaceRegistrationsUseCase', () => { raceRepository.findById.mockResolvedValue(race); registrationRepository.findByRaceId.mockResolvedValue(registrations); - const result: Result> = - await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as GetRaceRegistrationsResult; + const presented = result.unwrap(); expect(presented.race).toEqual(race); expect(presented.registrations).toHaveLength(2); @@ -62,8 +56,7 @@ describe('GetRaceRegistrationsUseCase', () => { raceRepository.findById.mockResolvedValue(null); - const result: Result> = - await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const err = result.unwrapErr() as ApplicationErrorCode< @@ -73,15 +66,14 @@ describe('GetRaceRegistrationsUseCase', () => { expect(err.code).toBe('RACE_NOT_FOUND'); expect(err.details?.message).toBe('Race not found'); - }); + }); it('should return REPOSITORY_ERROR when repository throws', async () => { const input: GetRaceRegistrationsInput = { raceId: 'race-1' }; raceRepository.findById.mockRejectedValue(new Error('DB failure')); - const result: Result> = - await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const err = result.unwrapErr() as ApplicationErrorCode< @@ -91,5 +83,5 @@ describe('GetRaceRegistrationsUseCase', () => { expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details?.message).toBe('DB failure'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetRaceResultsDetailUseCase.test.ts b/core/racing/application/use-cases/GetRaceResultsDetailUseCase.test.ts index 1f125ff20..024d84d07 100644 --- a/core/racing/application/use-cases/GetRaceResultsDetailUseCase.test.ts +++ b/core/racing/application/use-cases/GetRaceResultsDetailUseCase.test.ts @@ -19,19 +19,19 @@ describe('GetRaceResultsDetailUseCase', () => { let resultRepository: { findByRaceId: Mock }; let driverRepository: { findAll: Mock }; let penaltyRepository: { findByRaceId: Mock }; + beforeEach(() => { raceRepository = { findById: vi.fn() }; leagueRepository = { findById: vi.fn() }; resultRepository = { findByRaceId: vi.fn() }; driverRepository = { findAll: vi.fn() }; penaltyRepository = { findByRaceId: vi.fn() }; - }; - useCase = new GetRaceResultsDetailUseCase(raceRepository as unknown as IRaceRepository, - leagueRepository as unknown as ILeagueRepository, - resultRepository as unknown as IResultRepository, - driverRepository as unknown as IDriverRepository, - penaltyRepository as unknown as IPenaltyRepository); + useCase = new GetRaceResultsDetailUseCase(raceRepository as any, + leagueRepository as any, + resultRepository as any, + driverRepository as any, + penaltyRepository as any); }); it('presents race results detail when race exists', async () => { @@ -104,19 +104,18 @@ describe('GetRaceResultsDetailUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = (expect(presented.race).toEqual(race); + expect(presented.race).toEqual(race); expect(presented.league).toEqual(league); expect(presented.results).toEqual(results); expect(presented.drivers).toEqual(drivers); expect(presented.penalties).toEqual(penalties); expect(presented.pointsSystem).toBeDefined(); expect(presented.fastestLapTime).toBe(120); - expect(presented.currentDriverId).toBe('driver-1'); }); - it('returns error when race not found and does not present data', async () => { + it('returns error when race not found', async () => { const input: GetRaceResultsDetailInput = { raceId: 'race-1' }; raceRepository.findById.mockResolvedValue(null); @@ -131,7 +130,7 @@ describe('GetRaceResultsDetailUseCase', () => { expect(error.code).toBe('RACE_NOT_FOUND'); expect(error.details.message).toBe('Race not found'); - }); + }); it('returns repository error when an unexpected error occurs', async () => { const input: GetRaceResultsDetailInput = { raceId: 'race-1' }; @@ -148,5 +147,5 @@ describe('GetRaceResultsDetailUseCase', () => { expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toBe('Database failure'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetRaceWithSOFUseCase.test.ts b/core/racing/application/use-cases/GetRaceWithSOFUseCase.test.ts index 94d573d05..1c4e6d5ee 100644 --- a/core/racing/application/use-cases/GetRaceWithSOFUseCase.test.ts +++ b/core/racing/application/use-cases/GetRaceWithSOFUseCase.test.ts @@ -5,9 +5,6 @@ import { type GetRaceWithSOFResult, type GetRaceWithSOFErrorCode, } from './GetRaceWithSOFUseCase'; -import { RaceRepository } from '../../domain/repositories/RaceRepository'; -import { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository'; -import { ResultRepository } from '../../domain/repositories/ResultRepository'; import { Race } from '../../domain/entities/Race'; import { SessionType } from '../../domain/value-objects/SessionType'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; @@ -24,6 +21,7 @@ describe('GetRaceWithSOFUseCase', () => { findByRaceId: Mock; }; let getDriverRating: Mock; + beforeEach(() => { raceRepository = { findById: vi.fn(), @@ -35,13 +33,12 @@ describe('GetRaceWithSOFUseCase', () => { findByRaceId: vi.fn(), }; getDriverRating = vi.fn(); - output = { - present: vi.fn(), - }; - useCase = new GetRaceWithSOFUseCase(raceRepository as unknown as IRaceRepository, - registrationRepository as unknown as IRaceRegistrationRepository, - resultRepository as unknown as IResultRepository, - getDriverRating); + useCase = new GetRaceWithSOFUseCase( + raceRepository as any, + registrationRepository as any, + resultRepository as any, + getDriverRating + ); }); it('should return error when race not found', async () => { @@ -56,7 +53,7 @@ describe('GetRaceWithSOFUseCase', () => { >; expect(err.code).toBe('RACE_NOT_FOUND'); expect(err.details?.message).toBe('Race with id race-1 not found'); - }); + }); it('should return race with stored SOF when available', async () => { const race = Race.create({ @@ -74,23 +71,15 @@ describe('GetRaceWithSOFUseCase', () => { raceRepository.findById.mockResolvedValue(race); registrationRepository.getRegisteredDrivers.mockResolvedValue([ - 'driver-1', - 'driver-2', - 'driver-3', - 'driver-4', - 'driver-5', - 'driver-6', - 'driver-7', - 'driver-8', - 'driver-9', - 'driver-10', + 'driver-1', 'driver-2', 'driver-3', 'driver-4', 'driver-5', + 'driver-6', 'driver-7', 'driver-8', 'driver-9', 'driver-10', ]); const result = await useCase.execute({ raceId: 'race-1' } as GetRaceWithSOFInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const [[presented]] = expect(presented.race.id).toBe('race-1'); + const presented = result.unwrap(); + expect(presented.race.id).toBe('race-1'); expect(presented.race.leagueId).toBe('league-1'); expect(presented.strengthOfField).toBe(1500); expect(presented.registeredCount).toBe(10); @@ -124,8 +113,8 @@ describe('GetRaceWithSOFUseCase', () => { const result = await useCase.execute({ raceId: 'race-1' } as GetRaceWithSOFInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const [[presented]] = expect(presented.strengthOfField).toBe(1500); // average + const presented = result.unwrap(); + expect(presented.strengthOfField).toBe(1500); // average expect(presented.participantCount).toBe(2); expect(registrationRepository.getRegisteredDrivers).toHaveBeenCalledWith('race-1'); expect(resultRepository.findByRaceId).not.toHaveBeenCalled(); @@ -160,8 +149,8 @@ describe('GetRaceWithSOFUseCase', () => { const result = await useCase.execute({ raceId: 'race-1' } as GetRaceWithSOFInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const [[presented]] = expect(presented.strengthOfField).toBe(1500); + const presented = result.unwrap(); + expect(presented.strengthOfField).toBe(1500); expect(presented.participantCount).toBe(2); expect(resultRepository.findByRaceId).toHaveBeenCalledWith('race-1'); expect(registrationRepository.getRegisteredDrivers).not.toHaveBeenCalled(); @@ -191,8 +180,8 @@ describe('GetRaceWithSOFUseCase', () => { const result = await useCase.execute({ raceId: 'race-1' } as GetRaceWithSOFInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const [[presented]] = expect(presented.strengthOfField).toBe(1400); // only one rating + const presented = result.unwrap(); + expect(presented.strengthOfField).toBe(1400); // only one rating expect(presented.participantCount).toBe(2); }); @@ -213,12 +202,12 @@ describe('GetRaceWithSOFUseCase', () => { const result = await useCase.execute({ raceId: 'race-1' } as GetRaceWithSOFInput); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const [[presented]] = expect(presented.strengthOfField).toBe(null); + const presented = result.unwrap(); + expect(presented.strengthOfField).toBe(null); expect(presented.participantCount).toBe(0); }); - it('should wrap repository errors in REPOSITORY_ERROR and not call output', async () => { + it('should wrap repository errors in REPOSITORY_ERROR', async () => { raceRepository.findById.mockRejectedValue(new Error('boom')); const result = await useCase.execute({ raceId: 'race-1' } as GetRaceWithSOFInput); @@ -230,5 +219,5 @@ describe('GetRaceWithSOFUseCase', () => { >; expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details?.message).toBe('boom'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetRacesPageDataUseCase.test.ts b/core/racing/application/use-cases/GetRacesPageDataUseCase.test.ts index ebb6897a1..25b6ba511 100644 --- a/core/racing/application/use-cases/GetRacesPageDataUseCase.test.ts +++ b/core/racing/application/use-cases/GetRacesPageDataUseCase.test.ts @@ -1,15 +1,13 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { - GetRacesPageDataUseCase, - type GetRacesPageDataResult, - type GetRacesPageDataInput, - type GetRacesPageDataErrorCode, -} from './GetRacesPageDataUseCase'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import type { Logger } from '@core/shared/domain/Logger'; import type { Result } from '@core/shared/domain/Result'; -import type { Logger } from '@core/shared/application'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import { + GetRacesPageDataUseCase, + type GetRacesPageDataErrorCode, + type GetRacesPageDataInput, + type GetRacesPageDataResult, +} from './GetRacesPageDataUseCase'; describe('GetRacesPageDataUseCase', () => { let useCase: GetRacesPageDataUseCase; diff --git a/core/racing/application/use-cases/GetRacesPageDataUseCase.ts b/core/racing/application/use-cases/GetRacesPageDataUseCase.ts index c37ce0a60..e064a2231 100644 --- a/core/racing/application/use-cases/GetRacesPageDataUseCase.ts +++ b/core/racing/application/use-cases/GetRacesPageDataUseCase.ts @@ -1,13 +1,8 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Race } from '../../domain/entities/Race'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -export type GetRacesPageDataInput = { - leagueId: string; -}; export type GetRacesPageRaceItem = { race: Race; diff --git a/core/racing/application/use-cases/GetSeasonDetailsUseCase.test.ts b/core/racing/application/use-cases/GetSeasonDetailsUseCase.test.ts index dcece8fd4..7dce88eac 100644 --- a/core/racing/application/use-cases/GetSeasonDetailsUseCase.test.ts +++ b/core/racing/application/use-cases/GetSeasonDetailsUseCase.test.ts @@ -5,38 +5,24 @@ import { type GetSeasonDetailsResult, type GetSeasonDetailsErrorCode, } from './GetSeasonDetailsUseCase'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; import { Season } from '../../domain/entities/season/Season'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; describe('GetSeasonDetailsUseCase', () => { let useCase: GetSeasonDetailsUseCase; - let leagueRepository: { - findById: Mock; - }; let seasonRepository: { findById: Mock; }; - }; beforeEach(() => { - leagueRepository = { - findById: vi.fn(), - }; seasonRepository = { findById: vi.fn(), }; - output = { - present: vi.fn(), - }; - useCase = new GetSeasonDetailsUseCase(leagueRepository as unknown as ILeagueRepository, - seasonRepository as unknown as ISeasonRepository); + useCase = new GetSeasonDetailsUseCase(seasonRepository as any); }); - it('returns full details for a season belonging to the league', async () => { - const league = { id: 'league-1' }; + it('returns full details for a season', async () => { const season = Season.create({ id: 'season-1', leagueId: 'league-1', @@ -45,58 +31,30 @@ describe('GetSeasonDetailsUseCase', () => { status: 'planned', }).withMaxDrivers(24); - leagueRepository.findById.mockResolvedValue(league); seasonRepository.findById.mockResolvedValue(season); const input: GetSeasonDetailsInput = { - leagueId: 'league-1', seasonId: 'season-1', }; const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = - (expect(presented).toBeDefined(); - expect(presented?.leagueId).toBe('league-1'); - expect(presented?.season.id).toBe('season-1'); - expect(presented?.season.leagueId).toBe('league-1'); - expect(presented?.season.gameId).toBe('iracing'); - expect(presented?.season.name).toBe('Detailed Season'); - expect(presented?.season.status.toString()).toBe('planned'); - expect(presented?.season.maxDrivers).toBe(24); + expect(presented).toBeDefined(); + expect(presented.season.id).toBe('season-1'); + expect(presented.season.leagueId).toBe('league-1'); + expect(presented.season.gameId).toBe('iracing'); + expect(presented.season.name).toBe('Detailed Season'); + expect(presented.season.status.toString()).toBe('planned'); + expect(presented.season.maxDrivers).toBe(24); }); - it('returns error when league not found', async () => { - leagueRepository.findById.mockResolvedValue(null); - - const input: GetSeasonDetailsInput = { - leagueId: 'league-1', - seasonId: 'season-1', - }; - - const result = await useCase.execute(input); - - expect(result.isErr()).toBe(true); - - const error = result.unwrapErr() as ApplicationErrorCode< - GetSeasonDetailsErrorCode, - { message: string } - >; - - expect(error.code).toBe('LEAGUE_NOT_FOUND'); - expect(error.details.message).toBe('League not found: league-1'); - }); - it('returns error when season not found', async () => { - const league = { id: 'league-1' }; - leagueRepository.findById.mockResolvedValue(league); seasonRepository.findById.mockResolvedValue(null); const input: GetSeasonDetailsInput = { - leagueId: 'league-1', seasonId: 'season-1', }; @@ -110,51 +68,15 @@ describe('GetSeasonDetailsUseCase', () => { >; expect(error.code).toBe('SEASON_NOT_FOUND'); - expect(error.details.message).toBe( - 'Season season-1 does not belong to league league-1', - ); - }); - - it('returns error when season belongs to different league', async () => { - const league = { id: 'league-1' }; - const season = Season.create({ - id: 'season-1', - leagueId: 'league-2', - gameId: 'iracing', - name: 'Season', - status: 'active', - }); - - leagueRepository.findById.mockResolvedValue(league); - seasonRepository.findById.mockResolvedValue(season); - - const input: GetSeasonDetailsInput = { - leagueId: 'league-1', - seasonId: 'season-1', - }; - - const result = await useCase.execute(input); - - expect(result.isErr()).toBe(true); - - const error = result.unwrapErr() as ApplicationErrorCode< - GetSeasonDetailsErrorCode, - { message: string } - >; - - expect(error.code).toBe('SEASON_NOT_FOUND'); - expect(error.details.message).toBe( - 'Season season-1 does not belong to league league-1', - ); - }); + expect(error.details.message).toBe('Season not found'); + }); it('returns repository error when an unexpected exception occurs', async () => { - leagueRepository.findById.mockRejectedValue( + seasonRepository.findById.mockRejectedValue( new Error('Unexpected repository failure'), ); const input: GetSeasonDetailsInput = { - leagueId: 'league-1', seasonId: 'season-1', }; @@ -169,5 +91,5 @@ describe('GetSeasonDetailsUseCase', () => { expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toBe('Unexpected repository failure'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetSeasonSponsorshipsUseCase.test.ts b/core/racing/application/use-cases/GetSeasonSponsorshipsUseCase.test.ts index 4cd7330cc..37c065719 100644 --- a/core/racing/application/use-cases/GetSeasonSponsorshipsUseCase.test.ts +++ b/core/racing/application/use-cases/GetSeasonSponsorshipsUseCase.test.ts @@ -52,11 +52,11 @@ describe('GetSeasonSponsorshipsUseCase', () => { findByLeagueId: vi.fn(), }; - useCase = new GetSeasonSponsorshipsUseCase(seasonSponsorshipRepository as unknown as ISeasonSponsorshipRepository, - seasonRepository as unknown as ISeasonRepository, - leagueRepository as unknown as ILeagueRepository, - leagueMembershipRepository as unknown as ILeagueMembershipRepository, - raceRepository as unknown as IRaceRepository); + useCase = new GetSeasonSponsorshipsUseCase(seasonSponsorshipRepository as any, + seasonRepository as any, + leagueRepository as any, + leagueMembershipRepository as any, + raceRepository as any); }); it('returns SEASON_NOT_FOUND when season does not exist', async () => { @@ -73,7 +73,7 @@ describe('GetSeasonSponsorshipsUseCase', () => { >; expect(err.code).toBe('SEASON_NOT_FOUND'); expect(err.details.message).toBe('Season not found'); - }); + }); it('returns LEAGUE_NOT_FOUND when league for season does not exist', async () => { const input: GetSeasonSponsorshipsInput = { seasonId: 'season-1' }; @@ -98,7 +98,7 @@ describe('GetSeasonSponsorshipsUseCase', () => { >; expect(err.code).toBe('LEAGUE_NOT_FOUND'); expect(err.details.message).toBe('League not found for season'); - }); + }); it('presents sponsorship details with computed metrics', async () => { const input: GetSeasonSponsorshipsInput = { seasonId: 'season-1' }; @@ -149,8 +149,9 @@ describe('GetSeasonSponsorshipsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); + const presented = result.unwrap(); - const presented = (expect(presented.seasonId).toBe('season-1'); + expect(presented.seasonId).toBe('season-1'); expect(presented.sponsorships).toHaveLength(1); const detail = presented.sponsorships[0]!; @@ -187,5 +188,5 @@ describe('GetSeasonSponsorshipsUseCase', () => { >; expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('DB error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetSponsorsUseCase.test.ts b/core/racing/application/use-cases/GetSponsorsUseCase.test.ts index 35e8aee19..330bf5dce 100644 --- a/core/racing/application/use-cases/GetSponsorsUseCase.test.ts +++ b/core/racing/application/use-cases/GetSponsorsUseCase.test.ts @@ -1,24 +1,18 @@ import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; import { GetSponsorsUseCase } from './GetSponsorsUseCase'; -import { SponsorRepository } from '../../domain/repositories/SponsorRepository'; import { Sponsor } from '../../domain/entities/sponsor/Sponsor'; + describe('GetSponsorsUseCase', () => { let useCase: GetSponsorsUseCase; let sponsorRepository: { findAll: Mock; }; - let output: { - present: Mock; - }; beforeEach(() => { sponsorRepository = { findAll: vi.fn(), }; - output = { - present: vi.fn(), - }; - useCase = new GetSponsorsUseCase(sponsorRepository as unknown as ISponsorRepository); + useCase = new GetSponsorsUseCase(sponsorRepository as any); }); it('should return all sponsors', async () => { @@ -41,8 +35,9 @@ describe('GetSponsorsUseCase', () => { const result = await useCase.execute(); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - }); + const presented = result.unwrap(); + expect(presented.sponsors).toEqual(sponsors); + }); it('should return error on repository failure', async () => { sponsorRepository.findAll.mockRejectedValue(new Error('DB error')); @@ -52,7 +47,7 @@ describe('GetSponsorsUseCase', () => { expect(result.isErr()).toBe(true); expect(result.unwrapErr()).toEqual({ code: 'REPOSITORY_ERROR', - message: 'Failed to fetch sponsors', + details: { message: 'DB error' }, }); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetSponsorsUseCase.ts b/core/racing/application/use-cases/GetSponsorsUseCase.ts index 814e076f0..9624afac1 100644 --- a/core/racing/application/use-cases/GetSponsorsUseCase.ts +++ b/core/racing/application/use-cases/GetSponsorsUseCase.ts @@ -1,6 +1,7 @@ import type { Sponsor } from '../../domain/entities/sponsor/Sponsor'; import type { SponsorRepository } from '../../domain/repositories/SponsorRepository'; import { Result } from '@core/shared/domain/Result'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; export interface GetSponsorsInput {} @@ -8,11 +9,20 @@ export interface GetSponsorsResult { sponsors: Sponsor[]; } -export class GetSponsorsUseCase { - constructor(private readonly sponsorRepository: ISponsorRepository) {} +export type GetSponsorsErrorCode = 'REPOSITORY_ERROR'; - async execute(_input: GetSponsorsInput): Promise> { - const sponsors = await this.sponsorRepository.findAll(); - return Result.ok({ sponsors }); +export class GetSponsorsUseCase { + constructor(private readonly sponsorRepository: SponsorRepository) {} + + async execute(_input: GetSponsorsInput): Promise>> { + try { + const sponsors = await this.sponsorRepository.findAll(); + return Result.ok({ sponsors }); + } catch (error) { + return Result.err({ + code: 'REPOSITORY_ERROR', + details: { message: error instanceof Error ? error.message : 'Unknown error' }, + }); + } } -} \ No newline at end of file +} diff --git a/core/racing/application/use-cases/GetTeamDetailsUseCase.test.ts b/core/racing/application/use-cases/GetTeamDetailsUseCase.test.ts index cb0530bef..e5e920316 100644 --- a/core/racing/application/use-cases/GetTeamDetailsUseCase.test.ts +++ b/core/racing/application/use-cases/GetTeamDetailsUseCase.test.ts @@ -5,8 +5,6 @@ import { type GetTeamDetailsResult, type GetTeamDetailsErrorCode, } from './GetTeamDetailsUseCase'; -import { TeamRepository } from '../../domain/repositories/TeamRepository'; -import { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import { Team } from '../../domain/entities/Team'; import type { TeamMembership } from '../../domain/types/TeamMembership'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; @@ -19,6 +17,7 @@ describe('GetTeamDetailsUseCase', () => { let membershipRepository: { getMembership: Mock; }; + beforeEach(() => { teamRepository = { findById: vi.fn(), @@ -26,8 +25,8 @@ describe('GetTeamDetailsUseCase', () => { membershipRepository = { getMembership: vi.fn(), }; - useCase = new GetTeamDetailsUseCase(teamRepository as unknown as ITeamRepository, - membershipRepository as unknown as ITeamMembershipRepository); + useCase = new GetTeamDetailsUseCase(teamRepository as any, + membershipRepository as any); }); it('should return team details with membership', async () => { @@ -57,9 +56,7 @@ describe('GetTeamDetailsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as GetTeamDetailsResult; + const presented = result.unwrap(); expect(presented.team).toBe(team); expect(presented.membership).toEqual(membership); expect(presented.canManage).toBe(false); @@ -92,9 +89,7 @@ describe('GetTeamDetailsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as GetTeamDetailsResult; + const presented = result.unwrap(); expect(presented.canManage).toBe(true); }); @@ -114,7 +109,7 @@ describe('GetTeamDetailsUseCase', () => { >; expect(errorResult.code).toBe('TEAM_NOT_FOUND'); expect(errorResult.details?.message).toBe('Team not found'); - }); + }); it('should return error on repository failure', async () => { const teamId = 'team-1'; @@ -132,5 +127,5 @@ describe('GetTeamDetailsUseCase', () => { >; expect(errorResult.code).toBe('REPOSITORY_ERROR'); expect(errorResult.details?.message).toBe('DB error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetTeamJoinRequestsUseCase.test.ts b/core/racing/application/use-cases/GetTeamJoinRequestsUseCase.test.ts index 7f99fce52..592d1dd5c 100644 --- a/core/racing/application/use-cases/GetTeamJoinRequestsUseCase.test.ts +++ b/core/racing/application/use-cases/GetTeamJoinRequestsUseCase.test.ts @@ -34,9 +34,9 @@ describe('GetTeamJoinRequestsUseCase', () => { findById: vi.fn(), }; - useCase = new GetTeamJoinRequestsUseCase(membershipRepository as unknown as ITeamMembershipRepository, - driverRepository as unknown as IDriverRepository, - teamRepository as unknown as ITeamRepository); + useCase = new GetTeamJoinRequestsUseCase(membershipRepository as any, + driverRepository as any, + teamRepository as any); }); it('should return join requests with drivers when team exists', async () => { diff --git a/core/racing/application/use-cases/GetTeamMembersUseCase.test.ts b/core/racing/application/use-cases/GetTeamMembersUseCase.test.ts index f4b199063..33e94a8a2 100644 --- a/core/racing/application/use-cases/GetTeamMembersUseCase.test.ts +++ b/core/racing/application/use-cases/GetTeamMembersUseCase.test.ts @@ -1,17 +1,12 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { - GetTeamMembersUseCase, - type GetTeamMembersInput, - type GetTeamMembersResult, - type GetTeamMembersErrorCode, -} from './GetTeamMembersUseCase'; -import { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import { DriverRepository } from '../../domain/repositories/DriverRepository'; -import { TeamRepository } from '../../domain/repositories/TeamRepository'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; import { Driver } from '../../domain/entities/Driver'; import { Team } from '../../domain/entities/Team'; -import type { Logger } from '@core/shared/application'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { + GetTeamMembersUseCase, + type GetTeamMembersErrorCode, + type GetTeamMembersInput +} from './GetTeamMembersUseCase'; describe('GetTeamMembersUseCase', () => { let useCase: GetTeamMembersUseCase; @@ -46,10 +41,10 @@ describe('GetTeamMembersUseCase', () => { warn: vi.fn(), error: vi.fn(), }; - useCase = new GetTeamMembersUseCase(membershipRepository as unknown as ITeamMembershipRepository, - driverRepository as unknown as IDriverRepository, - teamRepository as unknown as ITeamRepository, - logger as unknown as Logger); + useCase = new GetTeamMembersUseCase(membershipRepository as any, + driverRepository as any, + teamRepository as any, + logger as any); }); it('should return team members with driver entities', async () => { diff --git a/core/racing/application/use-cases/GetTeamMembersUseCase.ts b/core/racing/application/use-cases/GetTeamMembersUseCase.ts index 882d50909..03577c1b8 100644 --- a/core/racing/application/use-cases/GetTeamMembersUseCase.ts +++ b/core/racing/application/use-cases/GetTeamMembersUseCase.ts @@ -1,12 +1,8 @@ -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import type { TeamMembership } from '../../domain/types/TeamMembership'; -import type { Team } from '../../domain/entities/Team'; import type { Driver } from '../../domain/entities/Driver'; +import type { Team } from '../../domain/entities/Team'; +import type { TeamMembership } from '../../domain/types/TeamMembership'; export type GetTeamMembersInput = { teamId: string; diff --git a/core/racing/application/use-cases/GetTeamMembershipUseCase.test.ts b/core/racing/application/use-cases/GetTeamMembershipUseCase.test.ts index f7ee6ca09..7812f0ead 100644 --- a/core/racing/application/use-cases/GetTeamMembershipUseCase.test.ts +++ b/core/racing/application/use-cases/GetTeamMembershipUseCase.test.ts @@ -1,17 +1,15 @@ -import { describe, it, expect, beforeEach, vi } from 'vitest'; -import { - GetTeamMembershipUseCase, - type GetTeamMembershipInput, - type GetTeamMembershipResult, - type GetTeamMembershipErrorCode, -} from './GetTeamMembershipUseCase'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { + GetTeamMembershipUseCase, + type GetTeamMembershipErrorCode, + type GetTeamMembershipInput +} from './GetTeamMembershipUseCase'; describe('GetTeamMembershipUseCase', () => { const mockGetMembership = vi.fn(); - const mockMembershipRepo: ITeamMembershipRepository = { + const mockMembershipRepo: any = { getMembership: mockGetMembership, getActiveMembershipForDriver: vi.fn(), getTeamMembers: vi.fn(), @@ -34,13 +32,10 @@ describe('GetTeamMembershipUseCase', () => { beforeEach(() => { vi.clearAllMocks(); - - }; - useCase = new GetTeamMembershipUseCase(mockMembershipRepo, mockLogger); }); - it('should present membership data when membership exists', async () => { + it('should return membership data when membership exists', async () => { const teamId = 'team1'; const driverId = 'driver1'; const membership = { @@ -58,16 +53,16 @@ describe('GetTeamMembershipUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.membership).toEqual({ + expect(presented.membership).toEqual({ role: 'manager', joinedAt: '2023-01-01T00:00:00.000Z', isActive: true, }); }); - it('should present null membership when no membership exists', async () => { + it('should return null membership when no membership exists', async () => { const teamId = 'team1'; const driverId = 'driver1'; @@ -78,9 +73,9 @@ describe('GetTeamMembershipUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.membership).toBeNull(); + expect(presented.membership).toBeNull(); }); it('should map driver role to member', async () => { @@ -101,9 +96,9 @@ describe('GetTeamMembershipUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.membership?.role).toBe('member'); + expect(presented.membership?.role).toBe('member'); }); it('should return error when repository throws', async () => { @@ -126,6 +121,5 @@ describe('GetTeamMembershipUseCase', () => { expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('Repository error'); - - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/GetTeamMembershipUseCase.ts b/core/racing/application/use-cases/GetTeamMembershipUseCase.ts index 3be9d77d7..0f9c5730c 100644 --- a/core/racing/application/use-cases/GetTeamMembershipUseCase.ts +++ b/core/racing/application/use-cases/GetTeamMembershipUseCase.ts @@ -1,7 +1,5 @@ -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; export type GetTeamMembershipInput = { teamId: string; driverId: string; diff --git a/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.test.ts b/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.test.ts index ce6cc38c5..b9c8c2f8e 100644 --- a/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.test.ts +++ b/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.test.ts @@ -1,15 +1,11 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { - GetTeamsLeaderboardUseCase, - type GetTeamsLeaderboardResult, - type GetTeamsLeaderboardInput, - type GetTeamsLeaderboardErrorCode, -} from './GetTeamsLeaderboardUseCase'; -import { TeamRepository } from '../../domain/repositories/TeamRepository'; -import { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import { Team } from '../../domain/entities/Team'; -import type { Logger } from '@core/shared/application'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; +import { Team } from '../../domain/entities/Team'; +import { + GetTeamsLeaderboardUseCase, + type GetTeamsLeaderboardErrorCode, + type GetTeamsLeaderboardInput +} from './GetTeamsLeaderboardUseCase'; describe('GetTeamsLeaderboardUseCase', () => { let useCase: GetTeamsLeaderboardUseCase; @@ -26,6 +22,7 @@ describe('GetTeamsLeaderboardUseCase', () => { warn: Mock; error: Mock; }; + beforeEach(() => { teamRepository = { findAll: vi.fn(), @@ -40,11 +37,10 @@ describe('GetTeamsLeaderboardUseCase', () => { warn: vi.fn(), error: vi.fn(), }; - useCase = new GetTeamsLeaderboardUseCase(teamRepository as unknown as ITeamRepository, - teamMembershipRepository as unknown as ITeamMembershipRepository, - getDriverStats as unknown as (driverId: string) => { rating: number | null; wins: number; totalRaces: number } | null, - logger as unknown as Logger, - output, + useCase = new GetTeamsLeaderboardUseCase(teamRepository as any, + teamMembershipRepository as any, + getDriverStats as any, + logger as any ); }); @@ -91,10 +87,7 @@ describe('GetTeamsLeaderboardUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const presentedRaw = (expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as GetTeamsLeaderboardResult; + const presented = result.unwrap(); expect(presented.recruitingCount).toBe(2); // both teams are recruiting expect(presented.items).toHaveLength(2); @@ -134,5 +127,5 @@ describe('GetTeamsLeaderboardUseCase', () => { >; expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('Repository error'); - }); + }); }); diff --git a/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.ts b/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.ts index 6b2abb47a..366e8cfcd 100644 --- a/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.ts +++ b/core/racing/application/use-cases/GetTeamsLeaderboardUseCase.ts @@ -1,10 +1,8 @@ -import type { TeamRepository } from '@core/racing/domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '@core/racing/domain/repositories/TeamMembershipRepository'; +import { Team } from '@/racing/domain/entities/Team'; import { SkillLevelService, type SkillLevel } from '@core/racing/domain/services/SkillLevelService'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import type { Team } from '@core/racing/domain/entities/Team'; interface DriverStatsAdapter { rating: number | null; diff --git a/core/racing/application/use-cases/GetTotalLeaguesUseCase.test.ts b/core/racing/application/use-cases/GetTotalLeaguesUseCase.test.ts index 1bf4aa8c4..e0bbb3cdf 100644 --- a/core/racing/application/use-cases/GetTotalLeaguesUseCase.test.ts +++ b/core/racing/application/use-cases/GetTotalLeaguesUseCase.test.ts @@ -35,7 +35,7 @@ describe('GetTotalLeaguesUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + expect(result.unwrap()).toEqual({ totalLeagues: 3 }); }); it('should return error on repository failure', async () => { diff --git a/core/racing/application/use-cases/GetTotalRacesUseCase.test.ts b/core/racing/application/use-cases/GetTotalRacesUseCase.test.ts index 21cd72202..e7a17de5c 100644 --- a/core/racing/application/use-cases/GetTotalRacesUseCase.test.ts +++ b/core/racing/application/use-cases/GetTotalRacesUseCase.test.ts @@ -46,9 +46,7 @@ describe('GetTotalRacesUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const payloadRaw = expect(payloadRaw).toBeDefined(); - const payload = payloadRaw as GetTotalRacesResult; + const payload = result.unwrap(); expect(payload.totalRaces).toBe(2); }); diff --git a/core/racing/application/use-cases/ImportRaceResultsApiUseCase.test.ts b/core/racing/application/use-cases/ImportRaceResultsApiUseCase.test.ts index e142e8424..a0566cd28 100644 --- a/core/racing/application/use-cases/ImportRaceResultsApiUseCase.test.ts +++ b/core/racing/application/use-cases/ImportRaceResultsApiUseCase.test.ts @@ -1,18 +1,13 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { - ImportRaceResultsApiUseCase, - type ImportRaceResultsApiInput, - type ImportRaceResultsApiResult, - type ImportRaceResultsApiErrorCode, -} from './ImportRaceResultsApiUseCase'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; -import type { StandingRepository } from '../../domain/repositories/StandingRepository'; -import type { Logger } from '@core/shared/application'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import { + ImportRaceResultsApiUseCase, + type ImportRaceResultsApiErrorCode, + type ImportRaceResultsApiInput, + type ImportRaceResultsApiResult, +} from './ImportRaceResultsApiUseCase'; describe('ImportRaceResultsApiUseCase', () => { let useCase: ImportRaceResultsApiUseCase; @@ -165,15 +160,12 @@ describe('ImportRaceResultsApiUseCase', () => { standingRepository.recalculate.mockResolvedValue(undefined); const result: Result< - void, + ImportRaceResultsApiResult, ApplicationErrorCode > = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as ImportRaceResultsApiResult; + const presented = result.unwrap(); expect(presented.success).toBe(true); expect(presented.raceId).toBe('race-1'); diff --git a/core/racing/application/use-cases/ImportRaceResultsApiUseCase.ts b/core/racing/application/use-cases/ImportRaceResultsApiUseCase.ts index 886068091..368478fa9 100644 --- a/core/racing/application/use-cases/ImportRaceResultsApiUseCase.ts +++ b/core/racing/application/use-cases/ImportRaceResultsApiUseCase.ts @@ -1,12 +1,6 @@ -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; -import type { StandingRepository } from '../../domain/repositories/StandingRepository'; -import { Result as RaceResult } from '../../domain/entities/result/Result'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { Result as RaceResult } from '../../domain/entities/result/Result'; export type ImportRaceResultDTO = { id: string; diff --git a/core/racing/application/use-cases/ImportRaceResultsUseCase.test.ts b/core/racing/application/use-cases/ImportRaceResultsUseCase.test.ts index 832584fe8..54cbeb88a 100644 --- a/core/racing/application/use-cases/ImportRaceResultsUseCase.test.ts +++ b/core/racing/application/use-cases/ImportRaceResultsUseCase.test.ts @@ -1,17 +1,11 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { - ImportRaceResultsUseCase, - type ImportRaceResultsInput, - type ImportRaceResultsResult, - type ImportRaceResultsErrorCode, -} from './ImportRaceResultsUseCase'; -import { RaceRepository } from '../../domain/repositories/RaceRepository'; -import { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import { ResultRepository } from '../../domain/repositories/ResultRepository'; -import { DriverRepository } from '../../domain/repositories/DriverRepository'; -import { StandingRepository } from '../../domain/repositories/StandingRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; +import { + ImportRaceResultsUseCase, + type ImportRaceResultsErrorCode, + type ImportRaceResultsInput +} from './ImportRaceResultsUseCase'; describe('ImportRaceResultsUseCase', () => { let useCase: ImportRaceResultsUseCase; diff --git a/core/racing/application/use-cases/ImportRaceResultsUseCase.ts b/core/racing/application/use-cases/ImportRaceResultsUseCase.ts index 2adcc0cc8..8428219de 100644 --- a/core/racing/application/use-cases/ImportRaceResultsUseCase.ts +++ b/core/racing/application/use-cases/ImportRaceResultsUseCase.ts @@ -1,12 +1,6 @@ -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; -import type { StandingRepository } from '../../domain/repositories/StandingRepository'; -import { Result as RaceResult } from '../../domain/entities/result/Result'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { Result as RaceResult } from '../../domain/entities/result/Result'; export type ImportRaceResultRow = { id: string; diff --git a/core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase.test.ts b/core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase.test.ts index 715a87d8a..af9262990 100644 --- a/core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase.test.ts +++ b/core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase.test.ts @@ -1,13 +1,10 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { - IsDriverRegisteredForRaceUseCase, - type IsDriverRegisteredForRaceInput, - type IsDriverRegisteredForRaceErrorCode, - type IsDriverRegisteredForRaceResult, -} from './IsDriverRegisteredForRaceUseCase'; -import { RaceRegistrationRepository } from '../../domain/repositories/RaceRegistrationRepository'; -import type { Logger } from '@core/shared/application'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; +import { + IsDriverRegisteredForRaceUseCase, + type IsDriverRegisteredForRaceErrorCode, + type IsDriverRegisteredForRaceInput +} from './IsDriverRegisteredForRaceUseCase'; describe('IsDriverRegisteredForRaceUseCase', () => { let useCase: IsDriverRegisteredForRaceUseCase; let registrationRepository: { @@ -29,11 +26,8 @@ describe('IsDriverRegisteredForRaceUseCase', () => { warn: vi.fn(), error: vi.fn(), }; - output = { - present: vi.fn(), - }; - useCase = new IsDriverRegisteredForRaceUseCase(registrationRepository as unknown as IRaceRegistrationRepository, - logger as unknown as Logger); + useCase = new IsDriverRegisteredForRaceUseCase(registrationRepository as any, + logger as any); }); it('should return true when driver is registered', async () => { diff --git a/core/racing/application/use-cases/JoinLeagueUseCase.test.ts b/core/racing/application/use-cases/JoinLeagueUseCase.test.ts index 959634000..5e9e5059a 100644 --- a/core/racing/application/use-cases/JoinLeagueUseCase.test.ts +++ b/core/racing/application/use-cases/JoinLeagueUseCase.test.ts @@ -49,9 +49,9 @@ describe('JoinLeagueUseCase', () => { const result = await useCase.execute(command); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.membership.id).toBe('membership-1'); + expect(presented.membership.id).toBe('membership-1'); expect(presented.membership.leagueId.toString()).toBe('league-1'); expect(presented.membership.driverId.toString()).toBe('driver-1'); expect(presented.membership.role.toString()).toBe('member'); diff --git a/core/racing/application/use-cases/JoinLeagueUseCase.ts b/core/racing/application/use-cases/JoinLeagueUseCase.ts index cec534aa0..b552ba053 100644 --- a/core/racing/application/use-cases/JoinLeagueUseCase.ts +++ b/core/racing/application/use-cases/JoinLeagueUseCase.ts @@ -1,8 +1,7 @@ -import type { Logger } from '@core/shared/application'; -import type { LeagueMembershipRepository } from '@core/racing/domain/repositories/LeagueMembershipRepository'; -import { LeagueMembership } from '../../domain/entities/LeagueMembership'; -import { Result } from '@core/shared/domain/Result'; +import { Result } from '@/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { LeagueMembership } from '../../domain/entities/LeagueMembership'; export type JoinLeagueErrorCode = 'ALREADY_MEMBER' | 'REPOSITORY_ERROR'; diff --git a/core/racing/application/use-cases/JoinTeamUseCase.test.ts b/core/racing/application/use-cases/JoinTeamUseCase.test.ts index 5058deeb7..b68f5b6a3 100644 --- a/core/racing/application/use-cases/JoinTeamUseCase.test.ts +++ b/core/racing/application/use-cases/JoinTeamUseCase.test.ts @@ -1,15 +1,12 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { - JoinTeamUseCase, - type JoinTeamInput, - type JoinTeamResult, - type JoinTeamErrorCode, -} from './JoinTeamUseCase'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { Logger } from '@core/shared/application'; -import { Team } from '../../domain/entities/Team'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import { Team } from '../../domain/entities/Team'; +import { + JoinTeamUseCase, + type JoinTeamErrorCode, + type JoinTeamInput +} from './JoinTeamUseCase'; describe('JoinTeamUseCase', () => { let useCase: JoinTeamUseCase; @@ -46,7 +43,14 @@ describe('JoinTeamUseCase', () => { it('should successfully join a team', async () => { const input: JoinTeamInput = { teamId: 'team-1', driverId: 'driver-1' }; - const team = Team.create({ id: 'team-1', name: 'Test Team', ownerId: 'owner-1' }); + const team = Team.create({ + id: 'team-1', + name: 'Test Team', + tag: 'TT', + description: 'Test Description', + ownerId: 'owner-1', + leagues: [], + }); const membership = { teamId: 'team-1', driverId: 'driver-1', diff --git a/core/racing/application/use-cases/JoinTeamUseCase.ts b/core/racing/application/use-cases/JoinTeamUseCase.ts index d9408c9a2..a4eddeff9 100644 --- a/core/racing/application/use-cases/JoinTeamUseCase.ts +++ b/core/racing/application/use-cases/JoinTeamUseCase.ts @@ -1,10 +1,8 @@ -import type { Logger } from '@core/shared/application'; +import { TeamMembership } from '@/racing/domain/types/TeamMembership'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Team } from '../../domain/entities/Team'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembership } from '../../domain/types/TeamMembership'; export type JoinTeamErrorCode = | 'ALREADY_IN_TEAM' diff --git a/core/racing/application/use-cases/LeagueSeasonScheduleMutationsUseCases.test.ts b/core/racing/application/use-cases/LeagueSeasonScheduleMutationsUseCases.test.ts index 7612dce2f..df3b8831a 100644 --- a/core/racing/application/use-cases/LeagueSeasonScheduleMutationsUseCases.test.ts +++ b/core/racing/application/use-cases/LeagueSeasonScheduleMutationsUseCases.test.ts @@ -1,37 +1,31 @@ import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { Race } from '../../domain/entities/Race'; import { Season } from '../../domain/entities/season/Season'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; import { - CreateLeagueSeasonScheduleRaceUseCase, - type CreateLeagueSeasonScheduleRaceErrorCode, - type CreateLeagueSeasonScheduleRaceResult, + CreateLeagueSeasonScheduleRaceUseCase, + type CreateLeagueSeasonScheduleRaceErrorCode } from './CreateLeagueSeasonScheduleRaceUseCase'; import { - UpdateLeagueSeasonScheduleRaceUseCase, - type UpdateLeagueSeasonScheduleRaceErrorCode, - type UpdateLeagueSeasonScheduleRaceResult, -} from './UpdateLeagueSeasonScheduleRaceUseCase'; -import { - DeleteLeagueSeasonScheduleRaceUseCase, - type DeleteLeagueSeasonScheduleRaceErrorCode, - type DeleteLeagueSeasonScheduleRaceResult, + DeleteLeagueSeasonScheduleRaceUseCase, + type DeleteLeagueSeasonScheduleRaceErrorCode } from './DeleteLeagueSeasonScheduleRaceUseCase'; import { - PublishLeagueSeasonScheduleUseCase, - type PublishLeagueSeasonScheduleErrorCode, - type PublishLeagueSeasonScheduleResult, + PublishLeagueSeasonScheduleUseCase, + type PublishLeagueSeasonScheduleErrorCode } from './PublishLeagueSeasonScheduleUseCase'; import { - UnpublishLeagueSeasonScheduleUseCase, - type UnpublishLeagueSeasonScheduleErrorCode, - type UnpublishLeagueSeasonScheduleResult, + UnpublishLeagueSeasonScheduleUseCase, + type UnpublishLeagueSeasonScheduleErrorCode } from './UnpublishLeagueSeasonScheduleUseCase'; +import { + UpdateLeagueSeasonScheduleRaceUseCase, + type UpdateLeagueSeasonScheduleRaceErrorCode +} from './UpdateLeagueSeasonScheduleRaceUseCase'; function createLogger(): Logger { return { @@ -62,7 +56,6 @@ describe('CreateLeagueSeasonScheduleRaceUseCase', () => { beforeEach(() => { seasonRepository = { findById: vi.fn() }; raceRepository = { create: vi.fn() }; - output = { present: vi.fn() }; logger = createLogger(); }); @@ -71,8 +64,8 @@ describe('CreateLeagueSeasonScheduleRaceUseCase', () => { seasonRepository.findById.mockResolvedValue(season); raceRepository.create.mockImplementation(async (race: Race) => race); - const useCase = new CreateLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new CreateLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger, { generateRaceId: () => 'race-123' }, ); @@ -100,8 +93,8 @@ describe('CreateLeagueSeasonScheduleRaceUseCase', () => { const season = createSeasonWithinWindow({ leagueId: 'other-league' }); seasonRepository.findById.mockResolvedValue(season); - const useCase = new CreateLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new CreateLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger, { generateRaceId: () => 'race-123' }, ); @@ -127,8 +120,8 @@ describe('CreateLeagueSeasonScheduleRaceUseCase', () => { const season = createSeasonWithinWindow(); seasonRepository.findById.mockResolvedValue(season); - const useCase = new CreateLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new CreateLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger, { generateRaceId: () => 'race-123' }, ); @@ -159,7 +152,6 @@ describe('UpdateLeagueSeasonScheduleRaceUseCase', () => { beforeEach(() => { seasonRepository = { findById: vi.fn() }; raceRepository = { findById: vi.fn(), update: vi.fn() }; - output = { present: vi.fn() }; logger = createLogger(); }); @@ -177,8 +169,8 @@ describe('UpdateLeagueSeasonScheduleRaceUseCase', () => { raceRepository.findById.mockResolvedValue(existing); raceRepository.update.mockImplementation(async (race: Race) => race); - const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger); const newScheduledAt = new Date('2025-01-20T20:00:00Z'); @@ -193,20 +185,16 @@ describe('UpdateLeagueSeasonScheduleRaceUseCase', () => { expect(result.isOk()).toBe(true); expect(raceRepository.update).toHaveBeenCalledTimes(1); - const updated = raceRepository.update.mock.calls[0]?.[0] as Race; - expect(updated.id).toBe('race-1'); - expect(updated.leagueId).toBe('league-1'); - expect(updated.track).toBe('New Track'); - expect(updated.car).toBe('New Car'); - expect(updated.scheduledAt.getTime()).toBe(newScheduledAt.getTime()); + const presented = result.unwrap(); + expect(presented.success).toBe(true); }); it('returns SEASON_NOT_FOUND when season does not belong to league and does not read/update race', async () => { const season = createSeasonWithinWindow({ leagueId: 'other-league' }); seasonRepository.findById.mockResolvedValue(season); - const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger); const result = await useCase.execute({ @@ -224,7 +212,7 @@ describe('UpdateLeagueSeasonScheduleRaceUseCase', () => { expect(error.code).toBe('SEASON_NOT_FOUND'); expect(raceRepository.findById).not.toHaveBeenCalled(); expect(raceRepository.update).not.toHaveBeenCalled(); - }); + }); it('returns RACE_OUTSIDE_SEASON_WINDOW when updated scheduledAt is outside window and does not update', async () => { const season = createSeasonWithinWindow(); @@ -239,8 +227,8 @@ describe('UpdateLeagueSeasonScheduleRaceUseCase', () => { }); raceRepository.findById.mockResolvedValue(existing); - const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger); const result = await useCase.execute({ @@ -257,15 +245,15 @@ describe('UpdateLeagueSeasonScheduleRaceUseCase', () => { >; expect(error.code).toBe('RACE_OUTSIDE_SEASON_WINDOW'); expect(raceRepository.update).not.toHaveBeenCalled(); - }); + }); it('returns RACE_NOT_FOUND when race does not exist for league and does not update', async () => { const season = createSeasonWithinWindow(); seasonRepository.findById.mockResolvedValue(season); raceRepository.findById.mockResolvedValue(null); - const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new UpdateLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger); const result = await useCase.execute({ @@ -282,7 +270,7 @@ describe('UpdateLeagueSeasonScheduleRaceUseCase', () => { >; expect(error.code).toBe('RACE_NOT_FOUND'); expect(raceRepository.update).not.toHaveBeenCalled(); - }); + }); }); describe('DeleteLeagueSeasonScheduleRaceUseCase', () => { @@ -293,7 +281,6 @@ describe('DeleteLeagueSeasonScheduleRaceUseCase', () => { beforeEach(() => { seasonRepository = { findById: vi.fn() }; raceRepository = { findById: vi.fn(), delete: vi.fn() }; - output = { present: vi.fn() }; logger = createLogger(); }); @@ -311,8 +298,8 @@ describe('DeleteLeagueSeasonScheduleRaceUseCase', () => { raceRepository.findById.mockResolvedValue(existing); raceRepository.delete.mockResolvedValue(undefined); - const useCase = new DeleteLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new DeleteLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger); const result = await useCase.execute({ @@ -330,8 +317,8 @@ describe('DeleteLeagueSeasonScheduleRaceUseCase', () => { const season = createSeasonWithinWindow({ leagueId: 'other-league' }); seasonRepository.findById.mockResolvedValue(season); - const useCase = new DeleteLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new DeleteLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger); const result = await useCase.execute({ @@ -348,15 +335,15 @@ describe('DeleteLeagueSeasonScheduleRaceUseCase', () => { expect(error.code).toBe('SEASON_NOT_FOUND'); expect(raceRepository.findById).not.toHaveBeenCalled(); expect(raceRepository.delete).not.toHaveBeenCalled(); - }); + }); it('returns RACE_NOT_FOUND when race does not exist for league and does not delete', async () => { const season = createSeasonWithinWindow(); seasonRepository.findById.mockResolvedValue(season); raceRepository.findById.mockResolvedValue(null); - const useCase = new DeleteLeagueSeasonScheduleRaceUseCase(seasonRepository as unknown as ISeasonRepository, - raceRepository as unknown as IRaceRepository, + const useCase = new DeleteLeagueSeasonScheduleRaceUseCase(seasonRepository as any, + raceRepository as any, logger); const result = await useCase.execute({ @@ -372,7 +359,7 @@ describe('DeleteLeagueSeasonScheduleRaceUseCase', () => { >; expect(error.code).toBe('RACE_NOT_FOUND'); expect(raceRepository.delete).not.toHaveBeenCalled(); - }); + }); }); describe('PublishLeagueSeasonScheduleUseCase', () => { @@ -381,7 +368,6 @@ describe('PublishLeagueSeasonScheduleUseCase', () => { beforeEach(() => { seasonRepository = { findById: vi.fn(), update: vi.fn() }; - output = { present: vi.fn() }; logger = createLogger(); }); @@ -390,24 +376,23 @@ describe('PublishLeagueSeasonScheduleUseCase', () => { seasonRepository.findById.mockResolvedValue(season); seasonRepository.update.mockResolvedValue(undefined); - const useCase = new PublishLeagueSeasonScheduleUseCase(seasonRepository as unknown as ISeasonRepository, + const useCase = new PublishLeagueSeasonScheduleUseCase(seasonRepository as any, logger); const result = await useCase.execute({ leagueId: 'league-1', seasonId: 'season-1' }); expect(result.isOk()).toBe(true); expect(seasonRepository.update).toHaveBeenCalledTimes(1); - const updatedSeason = seasonRepository.update.mock.calls[0]?.[0] as Season; - expect(updatedSeason.id).toBe('season-1'); - expect(updatedSeason.leagueId).toBe('league-1'); - expect(updatedSeason.schedulePublished).toBe(true); + const presented = result.unwrap(); + expect(presented.seasonId).toBe('season-1'); + expect(presented.published).toBe(true); }); it('returns SEASON_NOT_FOUND when season does not belong to league and does not update', async () => { const season = createSeasonWithinWindow({ leagueId: 'other-league' }); seasonRepository.findById.mockResolvedValue(season); - const useCase = new PublishLeagueSeasonScheduleUseCase(seasonRepository as unknown as ISeasonRepository, + const useCase = new PublishLeagueSeasonScheduleUseCase(seasonRepository as any, logger); const result = await useCase.execute({ leagueId: 'league-1', seasonId: 'season-1' }); @@ -419,7 +404,7 @@ describe('PublishLeagueSeasonScheduleUseCase', () => { >; expect(error.code).toBe('SEASON_NOT_FOUND'); expect(seasonRepository.update).not.toHaveBeenCalled(); - }); + }); }); describe('UnpublishLeagueSeasonScheduleUseCase', () => { @@ -428,7 +413,6 @@ describe('UnpublishLeagueSeasonScheduleUseCase', () => { beforeEach(() => { seasonRepository = { findById: vi.fn(), update: vi.fn() }; - output = { present: vi.fn() }; logger = createLogger(); }); @@ -437,24 +421,23 @@ describe('UnpublishLeagueSeasonScheduleUseCase', () => { seasonRepository.findById.mockResolvedValue(season); seasonRepository.update.mockResolvedValue(undefined); - const useCase = new UnpublishLeagueSeasonScheduleUseCase(seasonRepository as unknown as ISeasonRepository, + const useCase = new UnpublishLeagueSeasonScheduleUseCase(seasonRepository as any, logger); const result = await useCase.execute({ leagueId: 'league-1', seasonId: 'season-1' }); expect(result.isOk()).toBe(true); expect(seasonRepository.update).toHaveBeenCalledTimes(1); - const updatedSeason = seasonRepository.update.mock.calls[0]?.[0] as Season; - expect(updatedSeason.id).toBe('season-1'); - expect(updatedSeason.leagueId).toBe('league-1'); - expect(updatedSeason.schedulePublished).toBe(false); + const presented = result.unwrap(); + expect(presented.seasonId).toBe('season-1'); + expect(presented.published).toBe(false); }); it('returns SEASON_NOT_FOUND when season does not belong to league and does not update', async () => { const season = createSeasonWithinWindow({ leagueId: 'other-league' }); seasonRepository.findById.mockResolvedValue(season); - const useCase = new UnpublishLeagueSeasonScheduleUseCase(seasonRepository as unknown as ISeasonRepository, + const useCase = new UnpublishLeagueSeasonScheduleUseCase(seasonRepository as any, logger); const result = await useCase.execute({ leagueId: 'league-1', seasonId: 'season-1' }); @@ -466,5 +449,5 @@ describe('UnpublishLeagueSeasonScheduleUseCase', () => { >; expect(error.code).toBe('SEASON_NOT_FOUND'); expect(seasonRepository.update).not.toHaveBeenCalled(); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/LeaveTeamUseCase.test.ts b/core/racing/application/use-cases/LeaveTeamUseCase.test.ts index f65c47704..9e77c4d57 100644 --- a/core/racing/application/use-cases/LeaveTeamUseCase.test.ts +++ b/core/racing/application/use-cases/LeaveTeamUseCase.test.ts @@ -53,9 +53,9 @@ describe('LeaveTeamUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); - const presented = expect(presented.team.id).toBe('team-1'); + expect(presented.team.id).toBe('team-1'); expect(presented.previousMembership).toEqual(membership); }); diff --git a/core/racing/application/use-cases/LeaveTeamUseCase.ts b/core/racing/application/use-cases/LeaveTeamUseCase.ts index 2927c9ecf..da6fbd531 100644 --- a/core/racing/application/use-cases/LeaveTeamUseCase.ts +++ b/core/racing/application/use-cases/LeaveTeamUseCase.ts @@ -1,10 +1,8 @@ -import type { Logger } from '@core/shared/application'; +import { TeamMembership } from '@/racing/domain/types/TeamMembership'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Team } from '../../domain/entities/Team'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -import type { TeamMembership } from '../../domain/types/TeamMembership'; export type LeaveTeamErrorCode = | 'TEAM_NOT_FOUND' diff --git a/core/racing/application/use-cases/ListLeagueScoringPresetsUseCase.test.ts b/core/racing/application/use-cases/ListLeagueScoringPresetsUseCase.test.ts index 8803a28fa..88101f995 100644 --- a/core/racing/application/use-cases/ListLeagueScoringPresetsUseCase.test.ts +++ b/core/racing/application/use-cases/ListLeagueScoringPresetsUseCase.test.ts @@ -7,7 +7,7 @@ import { } from './ListLeagueScoringPresetsUseCase'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Result } from '@core/shared/domain/Result'; - + describe('ListLeagueScoringPresetsUseCase', () => { let useCase: ListLeagueScoringPresetsUseCase; beforeEach(() => { @@ -47,21 +47,17 @@ describe('ListLeagueScoringPresetsUseCase', () => { createConfig: vi.fn(), }, ]; - - useCase = new ListLeagueScoringPresetsUseCase(mockPresets); + + useCase = new ListLeagueScoringPresetsUseCase(mockPresets as any); }); - + it('should list presets successfully', async () => { const input: ListLeagueScoringPresetsInput = {}; - const result: Result< - void, - ApplicationErrorCode - > = await useCase.execute(input); - + const result = await useCase.execute(input); + expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const firstCall = const presented = firstCall[0] as ListLeagueScoringPresetsResult; + const presented = result.unwrap(); expect(presented).toEqual({ presets: [ @@ -101,21 +97,18 @@ describe('ListLeagueScoringPresetsUseCase', () => { }); }); - it('should wrap repository errors in ApplicationErrorCode and not call output', async () => { + it('should return repository error when mapping fails', async () => { const failingPresets = { map: () => { throw new Error('Repository failure'); }, - } as unknown as never[]; + } as any; useCase = new ListLeagueScoringPresetsUseCase(failingPresets); const input: ListLeagueScoringPresetsInput = {}; - const result: Result< - void, - ApplicationErrorCode - > = await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); @@ -126,5 +119,5 @@ describe('ListLeagueScoringPresetsUseCase', () => { expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details?.message).toBe('Repository failure'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/ManageSeasonLifecycleUseCase.test.ts b/core/racing/application/use-cases/ManageSeasonLifecycleUseCase.test.ts index f385fbba9..2e151a671 100644 --- a/core/racing/application/use-cases/ManageSeasonLifecycleUseCase.test.ts +++ b/core/racing/application/use-cases/ManageSeasonLifecycleUseCase.test.ts @@ -19,8 +19,7 @@ describe('ManageSeasonLifecycleUseCase', () => { findById: Mock; update: Mock; }; - }; - + beforeEach(() => { leagueRepository = { findById: vi.fn(), @@ -29,11 +28,10 @@ describe('ManageSeasonLifecycleUseCase', () => { findById: vi.fn(), update: vi.fn(), }; - }; - useCase = new ManageSeasonLifecycleUseCase(leagueRepository as unknown as ILeagueRepository, - seasonRepository as unknown as ISeasonRepository); + useCase = new ManageSeasonLifecycleUseCase(leagueRepository as any, + seasonRepository as any); }); - + it('applies activate → complete → archive transitions and persists state', async () => { const league = { id: 'league-1' }; let currentSeason = Season.create({ @@ -43,57 +41,48 @@ describe('ManageSeasonLifecycleUseCase', () => { name: 'Lifecycle Season', status: 'planned', }); - + leagueRepository.findById.mockResolvedValue(league); seasonRepository.findById.mockImplementation(() => Promise.resolve(currentSeason)); seasonRepository.update.mockImplementation((s) => { currentSeason = s; return Promise.resolve(s); }); - + const activateInput: ManageSeasonLifecycleInput = { leagueId: 'league-1', seasonId: currentSeason.id, transition: 'activate', }; - + const activated = await useCase.execute(activateInput); expect(activated.isOk()).toBe(true); - expect(activated.unwrap()).toBeUndefined(); - const [firstCall] = const [firstArg] = firstCall as [ManageSeasonLifecycleResult]; - let presented = firstArg; + let presented = activated.unwrap(); expect(presented.season.status.toString()).toBe('active'); - - (const completeInput: ManageSeasonLifecycleInput = { + + const completeInput: ManageSeasonLifecycleInput = { leagueId: 'league-1', seasonId: currentSeason.id, transition: 'complete', }; - + const completed = await useCase.execute(completeInput); expect(completed.isOk()).toBe(true); - expect(completed.unwrap()).toBeUndefined(); - { - const [[arg]] = presented = arg; - } + presented = completed.unwrap(); expect(presented.season.status.toString()).toBe('completed'); - - (const archiveInput: ManageSeasonLifecycleInput = { + + const archiveInput: ManageSeasonLifecycleInput = { leagueId: 'league-1', seasonId: currentSeason.id, transition: 'archive', }; - + const archived = await useCase.execute(archiveInput); expect(archived.isOk()).toBe(true); - expect(archived.unwrap()).toBeUndefined(); - { - const presentedRaw = expect(presentedRaw).toBeDefined(); - presented = presentedRaw as ManageSeasonLifecycleResult; - } + presented = archived.unwrap(); expect(presented.season.status.toString()).toBe('archived'); }); - + it('propagates domain invariant errors for invalid transitions', async () => { const league = { id: 'league-1' }; const season = Season.create({ @@ -103,16 +92,16 @@ describe('ManageSeasonLifecycleUseCase', () => { name: 'Lifecycle Season', status: 'planned', }); - + leagueRepository.findById.mockResolvedValue(league); seasonRepository.findById.mockResolvedValue(season); - + const completeInput: ManageSeasonLifecycleInput = { leagueId: 'league-1', seasonId: season.id, transition: 'complete', }; - + const result = await useCase.execute(completeInput); expect(result.isErr()).toBe(true); const error = result.unwrapErr() as ApplicationErrorCode< @@ -120,17 +109,17 @@ describe('ManageSeasonLifecycleUseCase', () => { { message: string } >; expect(error.code).toEqual('INVALID_TRANSITION'); - }); - + }); + it('returns error when league not found', async () => { leagueRepository.findById.mockResolvedValue(null); - + const input: ManageSeasonLifecycleInput = { leagueId: 'league-1', seasonId: 'season-1', transition: 'activate', }; - + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const error = result.unwrapErr() as ApplicationErrorCode< @@ -139,19 +128,19 @@ describe('ManageSeasonLifecycleUseCase', () => { >; expect(error.code).toEqual('LEAGUE_NOT_FOUND'); expect(error.details).toEqual({ message: 'League not found: league-1' }); - }); - + }); + it('returns error when season not found', async () => { const league = { id: 'league-1' }; leagueRepository.findById.mockResolvedValue(league); seasonRepository.findById.mockResolvedValue(null); - + const input: ManageSeasonLifecycleInput = { leagueId: 'league-1', seasonId: 'season-1', transition: 'activate', }; - + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const error = result.unwrapErr() as ApplicationErrorCode< @@ -162,5 +151,5 @@ describe('ManageSeasonLifecycleUseCase', () => { expect(error.details).toEqual({ message: 'Season season-1 does not belong to league league-1', }); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.test.ts b/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.test.ts index 58987e3c1..2e2e7ea0a 100644 --- a/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.test.ts +++ b/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.test.ts @@ -1,12 +1,11 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { - PreviewLeagueScheduleUseCase, - type PreviewLeagueScheduleResult, - type PreviewLeagueScheduleInput, - type PreviewLeagueScheduleErrorCode, -} from './PreviewLeagueScheduleUseCase'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; +import { + PreviewLeagueScheduleUseCase, + type PreviewLeagueScheduleErrorCode, + type PreviewLeagueScheduleInput +} from './PreviewLeagueScheduleUseCase'; describe('PreviewLeagueScheduleUseCase', () => { let useCase: PreviewLeagueScheduleUseCase; diff --git a/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.ts b/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.ts index 7ea3d5f9e..fd36a6512 100644 --- a/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.ts +++ b/core/racing/application/use-cases/PreviewLeagueScheduleUseCase.ts @@ -1,14 +1,14 @@ -import { SeasonScheduleGenerator } from '../../domain/services/SeasonScheduleGenerator'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import { SeasonSchedule } from '../../domain/value-objects/SeasonSchedule'; -import { RaceTimeOfDay } from '../../domain/value-objects/RaceTimeOfDay'; -import { LeagueTimezone } from '../../domain/value-objects/LeagueTimezone'; -import { RecurrenceStrategyFactory } from '../../domain/value-objects/RecurrenceStrategy'; -import { WeekdaySet } from '../../domain/value-objects/WeekdaySet'; -import { MonthlyRecurrencePattern } from '../../domain/value-objects/MonthlyRecurrencePattern'; +import { SeasonScheduleGenerator } from '../../domain/services/SeasonScheduleGenerator'; import { ALL_WEEKDAYS, type Weekday } from '../../domain/types/Weekday'; +import { LeagueTimezone } from '../../domain/value-objects/LeagueTimezone'; +import { MonthlyRecurrencePattern } from '../../domain/value-objects/MonthlyRecurrencePattern'; +import { RaceTimeOfDay } from '../../domain/value-objects/RaceTimeOfDay'; +import { RecurrenceStrategyFactory } from '../../domain/value-objects/RecurrenceStrategy'; +import { SeasonSchedule } from '../../domain/value-objects/SeasonSchedule'; +import { WeekdaySet } from '../../domain/value-objects/WeekdaySet'; export type SeasonScheduleConfig = { seasonStartDate: string; recurrenceStrategy: 'weekly' | 'everyNWeeks' | 'monthlyNthWeekday'; diff --git a/core/racing/application/use-cases/PublishLeagueSeasonScheduleUseCase.ts b/core/racing/application/use-cases/PublishLeagueSeasonScheduleUseCase.ts index 606f879fc..b256756bc 100644 --- a/core/racing/application/use-cases/PublishLeagueSeasonScheduleUseCase.ts +++ b/core/racing/application/use-cases/PublishLeagueSeasonScheduleUseCase.ts @@ -1,13 +1,8 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -export type PublishLeagueSeasonScheduleInput = { - leagueId: string; - seasonId: string; -}; export type PublishLeagueSeasonScheduleResult = { success: true; diff --git a/core/racing/application/use-cases/QuickPenaltyUseCase.test.ts b/core/racing/application/use-cases/QuickPenaltyUseCase.test.ts index 523c6924b..c60a729e0 100644 --- a/core/racing/application/use-cases/QuickPenaltyUseCase.test.ts +++ b/core/racing/application/use-cases/QuickPenaltyUseCase.test.ts @@ -1,10 +1,7 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import { QuickPenaltyUseCase, type QuickPenaltyInput, type QuickPenaltyResult, type QuickPenaltyErrorCode } from './QuickPenaltyUseCase'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; +import { QuickPenaltyUseCase, type QuickPenaltyErrorCode, type QuickPenaltyInput } from './QuickPenaltyUseCase'; describe('QuickPenaltyUseCase', () => { let useCase: QuickPenaltyUseCase; diff --git a/core/racing/application/use-cases/QuickPenaltyUseCase.ts b/core/racing/application/use-cases/QuickPenaltyUseCase.ts index b6ffa5e0b..51c859320 100644 --- a/core/racing/application/use-cases/QuickPenaltyUseCase.ts +++ b/core/racing/application/use-cases/QuickPenaltyUseCase.ts @@ -5,14 +5,11 @@ * Designed for fast, common penalty scenarios like track limits, warnings, etc. */ -import { Penalty } from '../../domain/entities/penalty/Penalty'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import { randomUUID } from 'crypto'; -import type { Logger } from '@core/shared/application'; -import { Result } from '@core/shared/domain/Result'; +import { Result } from '@/shared/domain/Result'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { randomUUID } from 'crypto'; +import { Penalty } from '../../domain/entities/penalty/Penalty'; export type QuickPenaltyErrorCode = 'RACE_NOT_FOUND' | 'UNAUTHORIZED' | 'UNKNOWN_INFRACTION' | 'REPOSITORY_ERROR'; diff --git a/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.test.ts b/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.test.ts index ae01eaf7c..89fc31074 100644 --- a/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.test.ts +++ b/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.test.ts @@ -1,22 +1,12 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { - RecalculateChampionshipStandingsUseCase, - type RecalculateChampionshipStandingsInput, - type RecalculateChampionshipStandingsResult, - type RecalculateChampionshipStandingsErrorCode, -} from './RecalculateChampionshipStandingsUseCase'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import type { LeagueScoringConfigRepository } from '../../domain/repositories/LeagueScoringConfigRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { PenaltyRepository } from '../../domain/repositories/PenaltyRepository'; -import type { ChampionshipStandingRepository } from '../../domain/repositories/ChampionshipStandingRepository'; -import type { Penalty } from '../../domain/entities/Penalty'; -import { EventScoringService } from '../../domain/services/EventScoringService'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import { ChampionshipAggregator } from '../../domain/services/ChampionshipAggregator'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; - +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import type { Penalty } from '../../domain/entities/Penalty'; +import { + RecalculateChampionshipStandingsUseCase, + type RecalculateChampionshipStandingsErrorCode, + type RecalculateChampionshipStandingsInput +} from './RecalculateChampionshipStandingsUseCase'; describe('RecalculateChampionshipStandingsUseCase', () => { let useCase: RecalculateChampionshipStandingsUseCase; @@ -30,7 +20,6 @@ describe('RecalculateChampionshipStandingsUseCase', () => { let eventScoringService: { scoreSession: Mock }; let championshipAggregator: { aggregate: Mock }; let logger: Logger; - }; beforeEach(() => { leagueRepository = { findById: vi.fn() }; @@ -47,18 +36,17 @@ describe('RecalculateChampionshipStandingsUseCase', () => { info: vi.fn(), warn: vi.fn(), error: vi.fn(), - }; - output = { present: vi.fn() } as unknown as typeof output; + } as any; - useCase = new RecalculateChampionshipStandingsUseCase(leagueRepository as unknown as ILeagueRepository, - seasonRepository as unknown as ISeasonRepository, - leagueScoringConfigRepository as unknown as ILeagueScoringConfigRepository, - raceRepository as unknown as IRaceRepository, - resultRepository as unknown as IResultRepository, - penaltyRepository as unknown as IPenaltyRepository, - championshipStandingRepository as unknown as IChampionshipStandingRepository, - eventScoringService as unknown as EventScoringService, - championshipAggregator as unknown as ChampionshipAggregator, + useCase = new RecalculateChampionshipStandingsUseCase(leagueRepository as any, + seasonRepository as any, + leagueScoringConfigRepository as any, + raceRepository as any, + resultRepository as any, + penaltyRepository as any, + championshipStandingRepository as any, + eventScoringService as any, + championshipAggregator as any, logger); }); @@ -79,7 +67,7 @@ describe('RecalculateChampionshipStandingsUseCase', () => { >; expect(error.code).toBe('LEAGUE_NOT_FOUND'); expect(error.details.message).toContain('league-1'); - }); + }); it('returns season not found error when season does not exist', async () => { leagueRepository.findById.mockResolvedValue({ id: 'league-1' }); @@ -98,7 +86,7 @@ describe('RecalculateChampionshipStandingsUseCase', () => { { message: string } >; expect(error.code).toBe('SEASON_NOT_FOUND'); - }); + }); it('returns season not found error when season belongs to different league', async () => { leagueRepository.findById.mockResolvedValue({ id: 'league-1' }); @@ -117,9 +105,9 @@ describe('RecalculateChampionshipStandingsUseCase', () => { { message: string } >; expect(error.code).toBe('SEASON_NOT_FOUND'); - }); + }); - it('recalculates standings successfully and presents result', async () => { + it('recalculates standings successfully and returns result', async () => { const league = { id: 'league-1' }; const season = { id: 'season-1', leagueId: 'league-1' }; const championship = { @@ -161,9 +149,7 @@ describe('RecalculateChampionshipStandingsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as RecalculateChampionshipStandingsResult; + const presented = result.unwrap(); expect(presented.leagueId).toBe('league-1'); expect(presented.seasonId).toBe('season-1'); expect(presented.entries).toHaveLength(1); @@ -175,7 +161,7 @@ describe('RecalculateChampionshipStandingsUseCase', () => { }); }); - it('wraps repository failures in REPOSITORY_ERROR and does not call output', async () => { + it('wraps repository failures in REPOSITORY_ERROR', async () => { leagueRepository.findById.mockResolvedValue({ id: 'league-1' }); seasonRepository.findById.mockResolvedValue({ id: 'season-1', leagueId: 'league-1' }); leagueScoringConfigRepository.findBySeasonId.mockImplementation(() => { @@ -196,5 +182,5 @@ describe('RecalculateChampionshipStandingsUseCase', () => { >; expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toContain('boom'); - }); + }); }); diff --git a/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.ts b/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.ts index 79bcbc141..e96f8dfc3 100644 --- a/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.ts +++ b/core/racing/application/use-cases/RecalculateChampionshipStandingsUseCase.ts @@ -1,20 +1,13 @@ -import type { SeasonRepository } from '@core/racing/domain/repositories/SeasonRepository'; -import type { LeagueScoringConfigRepository } from '@core/racing/domain/repositories/LeagueScoringConfigRepository'; -import type { RaceRepository } from '@core/racing/domain/repositories/RaceRepository'; -import type { ResultRepository } from '@core/racing/domain/repositories/ResultRepository'; -import type { PenaltyRepository } from '@core/racing/domain/repositories/PenaltyRepository'; -import type { ChampionshipStandingRepository } from '@core/racing/domain/repositories/ChampionshipStandingRepository'; -import type { LeagueRepository } from '@core/racing/domain/repositories/LeagueRepository'; +import { ChampionshipStanding } from '@/racing/domain/entities/championship/ChampionshipStanding'; +import { ChampionshipAggregator } from '@core/racing/domain/services/ChampionshipAggregator'; +import { EventScoringService } from '@core/racing/domain/services/EventScoringService'; import type { ChampionshipConfig } from '@core/racing/domain/types/ChampionshipConfig'; import type { SessionType } from '@core/racing/domain/types/SessionType'; -import type { ChampionshipStanding } from '@core/racing/domain/entities/championship/ChampionshipStanding'; -import { EventScoringService } from '@core/racing/domain/services/EventScoringService'; -import { ChampionshipAggregator } from '@core/racing/domain/services/ChampionshipAggregator'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; export type RecalculateChampionshipStandingsInput = { leagueId: string; @@ -132,7 +125,7 @@ export class RecalculateChampionshipStandingsUseCase { })), }; - return Result.ok(undefined); + return Result.ok(result); } catch (error) { const err = error as Error; this.logger.error('Failed to recalculate championship standings', err, { diff --git a/core/racing/application/use-cases/RegisterForRaceUseCase.test.ts b/core/racing/application/use-cases/RegisterForRaceUseCase.test.ts index cdbaa1cea..8946162be 100644 --- a/core/racing/application/use-cases/RegisterForRaceUseCase.test.ts +++ b/core/racing/application/use-cases/RegisterForRaceUseCase.test.ts @@ -86,15 +86,13 @@ describe('RegisterForRaceUseCase', () => { const result = await useCase.execute(buildInput()); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as RegisterForRaceResult; + const presented = result.unwrap(); expect(presented).toEqual({ raceId: 'race-1', driverId: 'driver-1', status: 'registered', }); + expect(registrationRepository.register).toHaveBeenCalled(); }); it('wraps unexpected repository errors', async () => { diff --git a/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.test.ts b/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.test.ts index 6d350ad0e..0c8f29702 100644 --- a/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.test.ts +++ b/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.test.ts @@ -1,14 +1,13 @@ -import { describe, it, expect, beforeEach, vi, Mock } from 'vitest'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, Mock, vi } from 'vitest'; import { - RejectSponsorshipRequestUseCase, - type RejectSponsorshipRequestInput, - type RejectSponsorshipRequestResult, - type RejectSponsorshipRequestErrorCode, + RejectSponsorshipRequestUseCase, + type RejectSponsorshipRequestErrorCode, + type RejectSponsorshipRequestInput, + type RejectSponsorshipRequestResult, } from './RejectSponsorshipRequestUseCase'; -import type { SponsorshipRequestRepository } from '../../domain/repositories/SponsorshipRequestRepository'; describe('RejectSponsorshipRequestUseCase', () => { let useCase: RejectSponsorshipRequestUseCase; diff --git a/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.ts b/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.ts index 733d61eee..f2a0aa399 100644 --- a/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.ts +++ b/core/racing/application/use-cases/RejectSponsorshipRequestUseCase.ts @@ -4,16 +4,10 @@ * Allows an entity owner to reject a sponsorship request. */ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { SponsorshipRequestRepository } from '../../domain/repositories/SponsorshipRequestRepository'; -export type RejectSponsorshipRequestInput = { - requestId: string; - respondedBy: string; - reason?: string; -}; export type RejectSponsorshipRequestResult = { requestId: string; diff --git a/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.test.ts b/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.test.ts index ec0d23fd9..fd100afe3 100644 --- a/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.test.ts +++ b/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.test.ts @@ -78,8 +78,8 @@ describe('RejectTeamJoinRequestUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); - const presented = expect(presented.teamId).toBe('team-1'); + const presented = result.unwrap(); + expect(presented.teamId).toBe('team-1'); expect(presented.requestId).toBe('req-1'); expect(presented.status).toBe('rejected'); expect(membershipRepository.removeJoinRequest).toHaveBeenCalledWith('req-1'); diff --git a/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.ts b/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.ts index baa51b913..17bb9e7df 100644 --- a/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.ts +++ b/core/racing/application/use-cases/RejectTeamJoinRequestUseCase.ts @@ -1,15 +1,7 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { TeamMembershipRepository } from '../../domain/repositories/TeamMembershipRepository'; -import type { TeamRepository } from '../../domain/repositories/TeamRepository'; -export type RejectTeamJoinRequestInput = { - teamId: string; - managerId: string; - requestId: string; - reason?: string; -}; export type RejectTeamJoinRequestResult = { teamId: string; diff --git a/core/racing/application/use-cases/RemoveLeagueMemberUseCase.test.ts b/core/racing/application/use-cases/RemoveLeagueMemberUseCase.test.ts index b21698f45..74a53bc3e 100644 --- a/core/racing/application/use-cases/RemoveLeagueMemberUseCase.test.ts +++ b/core/racing/application/use-cases/RemoveLeagueMemberUseCase.test.ts @@ -40,8 +40,9 @@ describe('RemoveLeagueMemberUseCase', () => { expect(result.isOk()).toBe(true); const removeResult = result.unwrap(); - expect(removeResult.success).toBe(true); - expect(removeResult.message).toBeDefined(); + expect(removeResult.leagueId).toBe(leagueId); + expect(removeResult.memberId).toBe(targetDriverId); + expect(removeResult.removedRole).toBe('member'); expect(leagueMembershipRepository.saveMembership).toHaveBeenCalledTimes(1); const savedMembership = leagueMembershipRepository.saveMembership.mock.calls[0]?.[0]; diff --git a/core/racing/application/use-cases/ReopenRaceUseCase.test.ts b/core/racing/application/use-cases/ReopenRaceUseCase.test.ts index eaec821c9..a666a7408 100644 --- a/core/racing/application/use-cases/ReopenRaceUseCase.test.ts +++ b/core/racing/application/use-cases/ReopenRaceUseCase.test.ts @@ -1,15 +1,12 @@ +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; -import { - ReopenRaceUseCase, - type ReopenRaceInput, - type ReopenRaceResult, - type ReopenRaceErrorCode, -} from './ReopenRaceUseCase'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { Logger } from '@core/shared/application'; import { Race } from '../../domain/entities/Race'; import { SessionType } from '../../domain/value-objects/SessionType'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { + ReopenRaceUseCase, + type ReopenRaceErrorCode, + type ReopenRaceInput +} from './ReopenRaceUseCase'; describe('ReopenRaceUseCase', () => { let raceRepository: { @@ -37,8 +34,8 @@ describe('ReopenRaceUseCase', () => { error: vi.fn(), }; - useCase = new ReopenRaceUseCase(raceRepository as unknown as IRaceRepository, - logger as unknown as Logger); + useCase = new ReopenRaceUseCase(raceRepository as any, + logger as any); }); it('returns RACE_NOT_FOUND when race does not exist', async () => { @@ -55,9 +52,9 @@ describe('ReopenRaceUseCase', () => { >; expect(err.code).toBe('RACE_NOT_FOUND'); expect(err.details.message).toContain('race-404'); - }); + }); - it('reopens a completed race, persists, and presents the result', async () => { + it('reopens a completed race, persists, and returns the result', async () => { const race = Race.create({ id: 'race-1', leagueId: 'league-1', @@ -81,7 +78,8 @@ describe('ReopenRaceUseCase', () => { expect(updatedRace.id).toBe('race-1'); expect(updatedRace.status.toString()).toBe('scheduled'); - const presented = (expect(presented.race.id).toBe('race-1'); + const presented = result.unwrap(); + expect(presented.race.id).toBe('race-1'); expect(presented.race.status.toString()).toBe('scheduled'); expect(logger.info).toHaveBeenCalled(); @@ -110,7 +108,7 @@ describe('ReopenRaceUseCase', () => { >; expect(err.code).toBe('INVALID_RACE_STATE'); expect(err.details.message).toContain('already scheduled'); - }); + }); it('returns INVALID_RACE_STATE when race is running', async () => { const race = Race.create({ @@ -135,7 +133,7 @@ describe('ReopenRaceUseCase', () => { >; expect(err.code).toBe('INVALID_RACE_STATE'); expect(err.details.message).toContain('running race'); - }); + }); it('returns REPOSITORY_ERROR when repository throws unexpected error', async () => { raceRepository.findById.mockRejectedValue(new Error('DB error')); @@ -150,5 +148,5 @@ describe('ReopenRaceUseCase', () => { >; expect(err.code).toBe('REPOSITORY_ERROR'); expect(err.details.message).toBe('DB error'); - }); -}); \ No newline at end of file + }); +}); diff --git a/core/racing/application/use-cases/ReopenRaceUseCase.ts b/core/racing/application/use-cases/ReopenRaceUseCase.ts index 99612faac..1bf6168eb 100644 --- a/core/racing/application/use-cases/ReopenRaceUseCase.ts +++ b/core/racing/application/use-cases/ReopenRaceUseCase.ts @@ -1,5 +1,3 @@ -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { Race } from '../../domain/entities/Race'; diff --git a/core/racing/application/use-cases/RequestProtestDefenseUseCase.test.ts b/core/racing/application/use-cases/RequestProtestDefenseUseCase.test.ts index 29b0e6dab..a367f7fd4 100644 --- a/core/racing/application/use-cases/RequestProtestDefenseUseCase.test.ts +++ b/core/racing/application/use-cases/RequestProtestDefenseUseCase.test.ts @@ -132,12 +132,10 @@ describe('RequestProtestDefenseUseCase', () => { const result = await useCase.execute(createInput()); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(protestRepository.update).toHaveBeenCalledWith(updatedProtest); - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as RequestProtestDefenseResult; expect(presented).toEqual({ leagueId: 'league-1', protestId: 'protest-1', diff --git a/core/racing/application/use-cases/ReviewProtestUseCase.ts b/core/racing/application/use-cases/ReviewProtestUseCase.ts index f7a9db493..a453f6c5b 100644 --- a/core/racing/application/use-cases/ReviewProtestUseCase.ts +++ b/core/racing/application/use-cases/ReviewProtestUseCase.ts @@ -4,10 +4,6 @@ * Allows a steward to review a protest and make a decision (uphold or dismiss). */ -import type { ProtestRepository } from '../../domain/repositories/ProtestRepository'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import type { Logger } from '@core/shared/application'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; diff --git a/core/racing/application/use-cases/SendFinalResultsUseCase.test.ts b/core/racing/application/use-cases/SendFinalResultsUseCase.test.ts index 23988ad10..46fff35f4 100644 --- a/core/racing/application/use-cases/SendFinalResultsUseCase.test.ts +++ b/core/racing/application/use-cases/SendFinalResultsUseCase.test.ts @@ -95,15 +95,13 @@ describe('SendFinalResultsUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(leagueRepository.findById).toHaveBeenCalledWith('league-1'); expect(raceEventRepository.findById).toHaveBeenCalledWith('race-1'); expect(resultRepository.findByRaceId).toHaveBeenCalledWith('session-1'); expect(notificationService.sendNotification).toHaveBeenCalledTimes(2); - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as SendFinalResultsResult; expect(presented).toEqual({ leagueId: 'league-1', raceId: 'race-1', diff --git a/core/racing/application/use-cases/SendFinalResultsUseCase.ts b/core/racing/application/use-cases/SendFinalResultsUseCase.ts index 618957821..77b0aa2c8 100644 --- a/core/racing/application/use-cases/SendFinalResultsUseCase.ts +++ b/core/racing/application/use-cases/SendFinalResultsUseCase.ts @@ -1,17 +1,13 @@ +import { Position } from '@/racing/domain/entities/result/Position'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; import type { NotificationService } from '../../../notifications/application/ports/NotificationService'; import type { NotificationType } from '../../../notifications/domain/types/NotificationTypes'; import type { RaceEvent } from '../../domain/entities/RaceEvent'; -import type { Result as RaceResult } from '../../domain/entities/result/Result'; -import type { RaceEventRepository } from '../../domain/repositories/RaceEventRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import { isLeagueStewardOrHigherRole } from '../../domain/types/LeagueRoles'; -import { Position } from '../../domain/entities/result/Position'; import { IncidentCount } from '../../domain/entities/result/IncidentCount'; +import type { Result as RaceResult } from '../../domain/entities/result/Result'; +import { isLeagueStewardOrHigherRole } from '../../domain/types/LeagueRoles'; export type SendFinalResultsInput = { leagueId: string; diff --git a/core/racing/application/use-cases/SendPerformanceSummaryUseCase.test.ts b/core/racing/application/use-cases/SendPerformanceSummaryUseCase.test.ts index 6aebe337e..11bce9fe2 100644 --- a/core/racing/application/use-cases/SendPerformanceSummaryUseCase.test.ts +++ b/core/racing/application/use-cases/SendPerformanceSummaryUseCase.test.ts @@ -93,7 +93,7 @@ describe('SendPerformanceSummaryUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(leagueRepository.findById).toHaveBeenCalledWith('league-1'); expect(raceEventRepository.findById).toHaveBeenCalledWith('race-1'); @@ -109,8 +109,6 @@ describe('SendPerformanceSummaryUseCase', () => { }), ); - const presentedRaw = expect(presentedRaw).toBeDefined(); - const presented = presentedRaw as SendPerformanceSummaryResult; expect(presented).toEqual({ leagueId: 'league-1', raceId: 'race-1', diff --git a/core/racing/application/use-cases/SendPerformanceSummaryUseCase.ts b/core/racing/application/use-cases/SendPerformanceSummaryUseCase.ts index ee68aa0ab..af37aeab5 100644 --- a/core/racing/application/use-cases/SendPerformanceSummaryUseCase.ts +++ b/core/racing/application/use-cases/SendPerformanceSummaryUseCase.ts @@ -1,18 +1,13 @@ -import type { Logger } from '@core/shared/application'; +import { isLeagueStewardOrHigherRole } from '@/racing/domain/types/LeagueRoles'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; import type { NotificationService } from '../../../notifications/application/ports/NotificationService'; import type { NotificationType } from '../../../notifications/domain/types/NotificationTypes'; import type { RaceEvent } from '../../domain/entities/RaceEvent'; -import type { Result as RaceResult } from '../../domain/entities/result/Result'; -import { Position } from '../../domain/entities/result/Position'; import { IncidentCount } from '../../domain/entities/result/IncidentCount'; -import type { RaceEventRepository } from '../../domain/repositories/RaceEventRepository'; -import type { ResultRepository } from '../../domain/repositories/ResultRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import type { DriverRepository } from '../../domain/repositories/DriverRepository'; -import { isLeagueStewardOrHigherRole } from '../../domain/types/LeagueRoles'; +import { Position } from '../../domain/entities/result/Position'; +import type { Result as RaceResult } from '../../domain/entities/result/Result'; export type SendPerformanceSummaryInput = { leagueId: string; diff --git a/core/racing/application/use-cases/SubmitProtestDefenseUseCase.test.ts b/core/racing/application/use-cases/SubmitProtestDefenseUseCase.test.ts index 061fa8467..0776757c8 100644 --- a/core/racing/application/use-cases/SubmitProtestDefenseUseCase.test.ts +++ b/core/racing/application/use-cases/SubmitProtestDefenseUseCase.test.ts @@ -1,15 +1,13 @@ -import { describe, it, expect, vi, beforeEach } from 'vitest'; -import { - SubmitProtestDefenseUseCase, - type SubmitProtestDefenseInput, - type SubmitProtestDefenseResult, - type SubmitProtestDefenseErrorCode, -} from './SubmitProtestDefenseUseCase'; -import type { ProtestRepository } from '../../domain/repositories/ProtestRepository'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; -import type { Logger } from '@core/shared/application'; +import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; +import { + SubmitProtestDefenseUseCase, + type SubmitProtestDefenseErrorCode, + type SubmitProtestDefenseInput, + type SubmitProtestDefenseResult, +} from './SubmitProtestDefenseUseCase'; interface MockProtest { id: string; diff --git a/core/racing/application/use-cases/TeamRankingUseCase.test.ts b/core/racing/application/use-cases/TeamRankingUseCase.test.ts index a1be98011..e99dc60f6 100644 --- a/core/racing/application/use-cases/TeamRankingUseCase.test.ts +++ b/core/racing/application/use-cases/TeamRankingUseCase.test.ts @@ -1,10 +1,10 @@ -import { TeamRankingUseCase } from './TeamRankingUseCase'; +import { Team } from '@core/racing/domain/entities/Team'; import type { TeamRatingRepository } from '@core/racing/domain/repositories/TeamRatingRepository'; import type { TeamRepository } from '@core/racing/domain/repositories/TeamRepository'; -import type { Logger } from '@core/shared/application'; import { TeamRatingSnapshot } from '@core/racing/domain/services/TeamRatingSnapshotCalculator'; import { TeamRatingValue } from '@core/racing/domain/value-objects/TeamRatingValue'; -import { Team } from '@core/racing/domain/entities/Team'; +import type { Logger } from '@core/shared/domain/Logger'; +import { TeamRankingUseCase } from './TeamRankingUseCase'; // Mock repositories class MockTeamRatingRepository implements TeamRatingRepository { diff --git a/core/racing/application/use-cases/TeamRankingUseCase.ts b/core/racing/application/use-cases/TeamRankingUseCase.ts index 606ef207d..feb9081ea 100644 --- a/core/racing/application/use-cases/TeamRankingUseCase.ts +++ b/core/racing/application/use-cases/TeamRankingUseCase.ts @@ -1,9 +1,6 @@ -/** - * Application Use Case Interface: ITeamRankingUseCase - * - * Use case for computing team rankings from rating snapshots. - * This is an application layer concern that orchestrates domain data. - */ +import type { TeamRatingRepository } from '@core/racing/domain/repositories/TeamRatingRepository'; +import type { TeamRepository } from '@core/racing/domain/repositories/TeamRepository'; +import type { Logger } from '@core/shared/domain/Logger'; export interface TeamRanking { teamId: string; @@ -16,7 +13,61 @@ export interface TeamRanking { overallRank: number | null; } -export interface TeamRankingUseCase { - getAllTeamRankings(): Promise; - getTeamRanking(teamId: string): Promise; -} \ No newline at end of file +export class TeamRankingUseCase { + constructor( + private readonly ratingRepository: TeamRatingRepository, + private readonly teamRepository: TeamRepository, + private readonly logger: Logger, + ) {} + + async getAllTeamRankings(): Promise { + try { + const teams = await this.teamRepository.findAll(); + const rankings: TeamRanking[] = []; + + for (const team of teams) { + const snapshot = await this.ratingRepository.findByTeamId(team.id); + if (snapshot) { + rankings.push({ + teamId: team.id, + teamName: team.name.toString(), + drivingRating: snapshot.driving.value, + adminTrustRating: snapshot.adminTrust.value, + overallRating: snapshot.overall, + eventCount: snapshot.eventCount, + lastUpdated: snapshot.lastUpdated, + overallRank: null, + }); + } + } + + // Sort by overall rating descending + rankings.sort((a, b) => b.overallRating - a.overallRating); + + // Assign ranks + return rankings.map((r, index) => ({ + ...r, + overallRank: index + 1, + })); + } catch (error) { + this.logger.error('Failed to get all team rankings', error as Error); + throw error; + } + } + + async getTeamRanking(teamId: string): Promise { + try { + const team = await this.teamRepository.findById(teamId); + if (!team) return null; + + const snapshot = await this.ratingRepository.findByTeamId(teamId); + if (!snapshot) return null; + + const allRankings = await this.getAllTeamRankings(); + return allRankings.find(r => r.teamId === teamId) || null; + } catch (error) { + this.logger.error(`Failed to get team ranking for ${teamId}`, error as Error); + throw error; + } + } +} diff --git a/core/racing/application/use-cases/TeamRatingFactoryUseCase.test.ts b/core/racing/application/use-cases/TeamRatingFactoryUseCase.test.ts index abaf314c6..024e9330f 100644 --- a/core/racing/application/use-cases/TeamRatingFactoryUseCase.test.ts +++ b/core/racing/application/use-cases/TeamRatingFactoryUseCase.test.ts @@ -1,7 +1,7 @@ -import { TeamRatingFactoryUseCase } from './TeamRatingFactoryUseCase'; -import type { TeamRaceResultsProvider } from '../ports/TeamRaceResultsProvider'; -import type { Logger } from '@core/shared/application'; import { TeamDrivingRaceFactsDto } from '@core/racing/domain/services/TeamDrivingRatingEventFactory'; +import type { Logger } from '@core/shared/domain/Logger'; +import type { TeamRaceResultsProvider } from '../ports/TeamRaceResultsProvider'; +import { TeamRatingFactoryUseCase } from './TeamRatingFactoryUseCase'; // Mock provider class MockTeamRaceResultsProvider implements TeamRaceResultsProvider { diff --git a/core/racing/application/use-cases/TeamRatingFactoryUseCase.ts b/core/racing/application/use-cases/TeamRatingFactoryUseCase.ts index 46a8b8f0d..87c6f0c86 100644 --- a/core/racing/application/use-cases/TeamRatingFactoryUseCase.ts +++ b/core/racing/application/use-cases/TeamRatingFactoryUseCase.ts @@ -6,13 +6,12 @@ * Mirrors the user rating factory pattern. */ -import type { Logger } from '@core/shared/application'; -import type { TeamRaceResultsProvider } from '../ports/TeamRaceResultsProvider'; -import { TeamDrivingRatingEventFactory } from '@core/racing/domain/services/TeamDrivingRatingEventFactory'; +import { TeamDrivingRatingEventFactory } from '@/racing/domain/services/TeamDrivingRatingEventFactory'; import { TeamRatingEvent } from '@core/racing/domain/entities/TeamRatingEvent'; -import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId'; -import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey'; import { TeamRatingDelta } from '@core/racing/domain/value-objects/TeamRatingDelta'; +import { TeamRatingDimensionKey } from '@core/racing/domain/value-objects/TeamRatingDimensionKey'; +import { TeamRatingEventId } from '@core/racing/domain/value-objects/TeamRatingEventId'; +import type { Logger } from '@core/shared/domain/Logger'; export interface TeamRatingFactoryInput { raceId: string; diff --git a/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.test.ts b/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.test.ts index 583217ae1..02a75435c 100644 --- a/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.test.ts +++ b/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.test.ts @@ -1,19 +1,15 @@ -import { describe, it, expect, beforeEach, vi, type Mock } from 'vitest'; -import { - TransferLeagueOwnershipUseCase, - type TransferLeagueOwnershipInput, - type TransferLeagueOwnershipResult, - type TransferLeagueOwnershipErrorCode, -} from './TransferLeagueOwnershipUseCase'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { LeagueMembershipRepository } from '../../domain/repositories/LeagueMembershipRepository'; -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Result } from '@core/shared/domain/Result'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; +import { + TransferLeagueOwnershipUseCase, + type TransferLeagueOwnershipErrorCode, + type TransferLeagueOwnershipInput +} from './TransferLeagueOwnershipUseCase'; describe('TransferLeagueOwnershipUseCase', () => { - let leagueRepository: ILeagueRepository; - let membershipRepository: ILeagueMembershipRepository; + let leagueRepository: any; + let membershipRepository: any; let logger: Logger & { error: Mock }; let useCase: TransferLeagueOwnershipUseCase; @@ -21,19 +17,19 @@ describe('TransferLeagueOwnershipUseCase', () => { leagueRepository = { findById: vi.fn(), update: vi.fn(), - } as unknown as ILeagueRepository; + }; membershipRepository = { getMembership: vi.fn(), saveMembership: vi.fn(), - } as unknown as ILeagueMembershipRepository; + }; logger = { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn(), - } as unknown as Logger & { error: Mock }; + } as any; useCase = new TransferLeagueOwnershipUseCase( leagueRepository, @@ -47,25 +43,25 @@ describe('TransferLeagueOwnershipUseCase', () => { id: 'league-1', ownerId: { toString: () => 'owner-1' }, update: vi.fn().mockReturnValue({}), - } as unknown as { id: string; ownerId: { toString: () => string }; update: Mock }; + } as any; const mockNewOwnerMembership = { leagueId: 'league-1', driverId: 'owner-2', status: { toString: () => 'active' }, role: 'member', - } as unknown as { leagueId: string; driverId: string; status: { toString: () => string }; role: string }; + } as any; const mockCurrentOwnerMembership = { leagueId: 'league-1', driverId: 'owner-1', status: { toString: () => 'active' }, role: 'owner', - } as unknown as { leagueId: string; driverId: string; status: { toString: () => string }; role: string }; + } as any; - (leagueRepository.findById as unknown as Mock).mockResolvedValue(mockLeague); + leagueRepository.findById.mockResolvedValue(mockLeague); - (membershipRepository.getMembership as unknown as Mock) + membershipRepository.getMembership .mockResolvedValueOnce(mockNewOwnerMembership) .mockResolvedValueOnce(mockCurrentOwnerMembership); @@ -75,10 +71,7 @@ describe('TransferLeagueOwnershipUseCase', () => { newOwnerId: 'owner-2', }; - const result: Result< - TransferLeagueOwnershipResult, - ApplicationErrorCode - > = await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isOk()).toBe(true); const successResult = result.unwrap(); @@ -94,7 +87,7 @@ describe('TransferLeagueOwnershipUseCase', () => { expect(membershipRepository.saveMembership).toHaveBeenCalledTimes(2); - const saveMembershipMock = membershipRepository.saveMembership as unknown as Mock; + const saveMembershipMock = membershipRepository.saveMembership as Mock; const firstSaveCall = saveMembershipMock.mock.calls[0]![0] as { role: string }; const secondSaveCall = saveMembershipMock.mock.calls[1]![0] as { role: string }; @@ -106,7 +99,7 @@ describe('TransferLeagueOwnershipUseCase', () => { }); it('returns LEAGUE_NOT_FOUND when league does not exist', async () => { - (leagueRepository.findById as unknown as Mock).mockResolvedValue(null); + leagueRepository.findById.mockResolvedValue(null); const input: TransferLeagueOwnershipInput = { leagueId: 'non-existent', @@ -114,10 +107,7 @@ describe('TransferLeagueOwnershipUseCase', () => { newOwnerId: 'owner-2', }; - const result: Result< - TransferLeagueOwnershipResult, - ApplicationErrorCode - > = await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const error = result.unwrapErr() as ApplicationErrorCode< @@ -134,9 +124,9 @@ describe('TransferLeagueOwnershipUseCase', () => { id: 'league-1', ownerId: { toString: () => 'other-owner' }, update: vi.fn(), - } as unknown as { id: string; ownerId: { toString: () => string }; update: Mock }; + } as any; - (leagueRepository.findById as unknown as Mock).mockResolvedValue(mockLeague); + leagueRepository.findById.mockResolvedValue(mockLeague); const input: TransferLeagueOwnershipInput = { leagueId: 'league-1', @@ -144,10 +134,7 @@ describe('TransferLeagueOwnershipUseCase', () => { newOwnerId: 'owner-2', }; - const result: Result< - TransferLeagueOwnershipResult, - ApplicationErrorCode - > = await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const error = result.unwrapErr() as ApplicationErrorCode< @@ -163,11 +150,11 @@ describe('TransferLeagueOwnershipUseCase', () => { id: 'league-1', ownerId: { toString: () => 'owner-1' }, update: vi.fn(), - } as unknown as { id: string; ownerId: { toString: () => string }; update: Mock }; + } as any; - (leagueRepository.findById as unknown as Mock).mockResolvedValue(mockLeague); + leagueRepository.findById.mockResolvedValue(mockLeague); - (membershipRepository.getMembership as unknown as Mock).mockResolvedValue(null); + membershipRepository.getMembership.mockResolvedValue(null); const input: TransferLeagueOwnershipInput = { leagueId: 'league-1', @@ -175,10 +162,7 @@ describe('TransferLeagueOwnershipUseCase', () => { newOwnerId: 'owner-2', }; - const result: Result< - TransferLeagueOwnershipResult, - ApplicationErrorCode - > = await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const error = result.unwrapErr() as ApplicationErrorCode< @@ -194,23 +178,23 @@ describe('TransferLeagueOwnershipUseCase', () => { id: 'league-1', ownerId: { toString: () => 'owner-1' }, update: vi.fn().mockReturnValue({}), - } as unknown as { id: string; ownerId: { toString: () => string }; update: Mock }; + } as any; - (leagueRepository.findById as unknown as Mock).mockResolvedValue(mockLeague); + leagueRepository.findById.mockResolvedValue(mockLeague); const mockNewOwnerMembership = { leagueId: 'league-1', driverId: 'owner-2', status: { toString: () => 'active' }, role: 'member', - } as unknown as { leagueId: string; driverId: string; status: { toString: () => string }; role: string }; + } as any; - (membershipRepository.getMembership as unknown as Mock) + membershipRepository.getMembership .mockResolvedValueOnce(mockNewOwnerMembership) .mockResolvedValueOnce(null); const updateError = new Error('update failed'); - (leagueRepository.update as unknown as Mock).mockRejectedValue(updateError); + leagueRepository.update.mockRejectedValue(updateError); const input: TransferLeagueOwnershipInput = { leagueId: 'league-1', @@ -218,10 +202,7 @@ describe('TransferLeagueOwnershipUseCase', () => { newOwnerId: 'owner-2', }; - const result: Result< - TransferLeagueOwnershipResult, - ApplicationErrorCode - > = await useCase.execute(input); + const result = await useCase.execute(input); expect(result.isErr()).toBe(true); const error = result.unwrapErr() as ApplicationErrorCode< @@ -240,4 +221,4 @@ describe('TransferLeagueOwnershipUseCase', () => { const loggedMessage = calls[0]?.[0] as string; expect(loggedMessage).toContain('update failed'); }); -}); \ No newline at end of file +}); diff --git a/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.ts b/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.ts index 01ec3f6cd..405fb995e 100644 --- a/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.ts +++ b/core/racing/application/use-cases/TransferLeagueOwnershipUseCase.ts @@ -1,16 +1,10 @@ +import type { + ILeagueMembershipRepository, +} from '@core/racing/domain/repositories/LeagueMembershipRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import type { - ILeagueMembershipRepository, -} from '@core/racing/domain/repositories/LeagueMembershipRepository'; -import type { LeagueRepository } from '@core/racing/domain/repositories/LeagueRepository'; -export type TransferLeagueOwnershipInput = { - leagueId: string; - currentOwnerId: string; - newOwnerId: string; -}; export type TransferLeagueOwnershipResult = { leagueId: string; diff --git a/core/racing/application/use-cases/UnpublishLeagueSeasonScheduleUseCase.ts b/core/racing/application/use-cases/UnpublishLeagueSeasonScheduleUseCase.ts index abf5080c9..b89a5fd6c 100644 --- a/core/racing/application/use-cases/UnpublishLeagueSeasonScheduleUseCase.ts +++ b/core/racing/application/use-cases/UnpublishLeagueSeasonScheduleUseCase.ts @@ -1,13 +1,8 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -export type UnpublishLeagueSeasonScheduleInput = { - leagueId: string; - seasonId: string; -}; export type UnpublishLeagueSeasonScheduleResult = { success: true; diff --git a/core/racing/application/use-cases/UpdateDriverProfileUseCase.test.ts b/core/racing/application/use-cases/UpdateDriverProfileUseCase.test.ts index af0bed894..29516d92a 100644 --- a/core/racing/application/use-cases/UpdateDriverProfileUseCase.test.ts +++ b/core/racing/application/use-cases/UpdateDriverProfileUseCase.test.ts @@ -58,9 +58,6 @@ describe('UpdateDriverProfileUseCase', () => { country: 'US', }); expect(driverRepository.update).toHaveBeenCalled(); - - const presentedRaw = expect(presentedRaw).toBeDefined(); - expect(presentedRaw).toEqual({ id: 'driver-1' }); }); it('returns error when driver not found', async () => { diff --git a/core/racing/application/use-cases/UpdateLeagueMemberRoleUseCase.test.ts b/core/racing/application/use-cases/UpdateLeagueMemberRoleUseCase.test.ts index 6fa8001c4..b84c93882 100644 --- a/core/racing/application/use-cases/UpdateLeagueMemberRoleUseCase.test.ts +++ b/core/racing/application/use-cases/UpdateLeagueMemberRoleUseCase.test.ts @@ -22,11 +22,7 @@ describe('UpdateLeagueMemberRoleUseCase', () => { const mockLeagueMembershipRepository = { getLeagueMembers: vi.fn().mockResolvedValue([mockMembership]), saveMembership: vi.fn().mockResolvedValue(undefined), - } as unknown as ILeagueMembershipRepository; - - const output: { present: Mock } = { - present: vi.fn(), - }; + } as any; const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); @@ -39,12 +35,12 @@ describe('UpdateLeagueMemberRoleUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(mockLeagueMembershipRepository.getLeagueMembers).toHaveBeenCalledWith('league-1'); expect(mockLeagueMembershipRepository.saveMembership).toHaveBeenCalledTimes(1); - const presented = (expect(presented.membership.id).toBe('league-1:driver-1'); + expect(presented.membership.id).toBe('league-1:driver-1'); expect(presented.membership.leagueId.toString()).toBe('league-1'); expect(presented.membership.driverId.toString()).toBe('driver-1'); expect(presented.membership.role.toString()).toBe('admin'); @@ -53,11 +49,7 @@ describe('UpdateLeagueMemberRoleUseCase', () => { it('returns error if membership not found', async () => { const mockLeagueMembershipRepository = { getLeagueMembers: vi.fn().mockResolvedValue([]), - } as unknown as ILeagueMembershipRepository; - - const output: { present: Mock } = { - present: vi.fn(), - }; + } as any; const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); @@ -77,18 +69,14 @@ describe('UpdateLeagueMemberRoleUseCase', () => { expect(error.code).toBe('MEMBERSHIP_NOT_FOUND'); expect(error.details.message).toBe('League membership not found'); - }); + }); it('handles repository errors', async () => { const mockLeagueMembershipRepository = { getLeagueMembers: vi .fn() .mockRejectedValue(new Error('Database connection failed')), - } as unknown as ILeagueMembershipRepository; - - const output: { present: Mock } = { - present: vi.fn(), - }; + } as any; const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); @@ -108,7 +96,7 @@ describe('UpdateLeagueMemberRoleUseCase', () => { expect(error.code).toBe('REPOSITORY_ERROR'); expect(error.details.message).toBe('Database connection failed'); - }); + }); it('rejects invalid roles', async () => { const mockMembership = { @@ -123,18 +111,14 @@ describe('UpdateLeagueMemberRoleUseCase', () => { const mockLeagueMembershipRepository = { getLeagueMembers: vi.fn().mockResolvedValue([mockMembership]), saveMembership: vi.fn().mockResolvedValue(undefined), - } as unknown as ILeagueMembershipRepository; - - const output: { present: Mock } = { - present: vi.fn(), - }; + } as any; const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); const result = await useCase.execute({ leagueId: 'league-1', targetDriverId: 'driver-1', - newRole: 'manager', + newRole: 'manager' as any, }); expect(result.isErr()).toBe(true); @@ -160,11 +144,7 @@ describe('UpdateLeagueMemberRoleUseCase', () => { const mockLeagueMembershipRepository = { getLeagueMembers: vi.fn().mockResolvedValue([mockOwnerMembership]), saveMembership: vi.fn().mockResolvedValue(undefined), - } as unknown as ILeagueMembershipRepository; - - const output: { present: Mock } = { - present: vi.fn(), - }; + } as any; const useCase = new UpdateLeagueMemberRoleUseCase(mockLeagueMembershipRepository); @@ -183,4 +163,4 @@ describe('UpdateLeagueMemberRoleUseCase', () => { expect(error.code).toBe('CANNOT_DOWNGRADE_LAST_OWNER'); expect(mockLeagueMembershipRepository.saveMembership).not.toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/core/racing/application/use-cases/UpdateLeagueSeasonScheduleRaceUseCase.ts b/core/racing/application/use-cases/UpdateLeagueSeasonScheduleRaceUseCase.ts index 2c61fbabc..ac5daa126 100644 --- a/core/racing/application/use-cases/UpdateLeagueSeasonScheduleRaceUseCase.ts +++ b/core/racing/application/use-cases/UpdateLeagueSeasonScheduleRaceUseCase.ts @@ -1,12 +1,10 @@ -import type { Logger } from '@core/shared/application'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { SeasonScheduleGenerator } from '@/racing/domain/services/SeasonScheduleGenerator'; import { Race } from '../../domain/entities/Race'; import type { Season } from '../../domain/entities/season/Season'; -import type { RaceRepository } from '../../domain/repositories/RaceRepository'; -import type { SeasonRepository } from '../../domain/repositories/SeasonRepository'; -import { SeasonScheduleGenerator } from '../../domain/services/SeasonScheduleGenerator'; export type UpdateLeagueSeasonScheduleRaceInput = { leagueId: string; diff --git a/core/racing/application/use-cases/UpdateTeamUseCase.test.ts b/core/racing/application/use-cases/UpdateTeamUseCase.test.ts index dd03252e3..2c8039b95 100644 --- a/core/racing/application/use-cases/UpdateTeamUseCase.test.ts +++ b/core/racing/application/use-cases/UpdateTeamUseCase.test.ts @@ -42,17 +42,12 @@ describe('UpdateTeamUseCase', () => { const result = await useCase.execute(command); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const successResult = result.unwrap(); + expect(successResult.team).toBe(mockUpdatedTeam); expect(mockMembershipRepository.getMembership).toHaveBeenCalledWith('team-1', 'user-1'); expect(mockTeamRepository.findById).toHaveBeenCalledWith('team-1'); expect(mockTeam.update).toHaveBeenCalledWith({ name: 'New Name', tag: 'NEW' }); expect(mockTeamRepository.update).toHaveBeenCalledWith(mockUpdatedTeam); - - expect(present).toHaveBeenCalledTimes(1); - const firstCall = present.mock.calls[0]; - expect(firstCall).toBeDefined(); - const presented = firstCall![0] as UpdateTeamResult; - expect(presented.team).toBe(mockUpdatedTeam); }); it('returns permission denied error if insufficient permissions', async () => { diff --git a/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.test.ts b/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.test.ts index 8a3ed155e..510049c74 100644 --- a/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.test.ts +++ b/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.test.ts @@ -1,17 +1,14 @@ -import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; -import { - WithdrawFromLeagueWalletUseCase, - type WithdrawFromLeagueWalletErrorCode, - type WithdrawFromLeagueWalletInput, - type WithdrawFromLeagueWalletResult, -} from './WithdrawFromLeagueWalletUseCase'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { LeagueWalletRepository } from '../../domain/repositories/LeagueWalletRepository'; -import type { TransactionRepository } from '../../domain/repositories/TransactionRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; +import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; import { League } from '../../domain/entities/League'; import { LeagueWallet } from '../../domain/entities/league-wallet/LeagueWallet'; import { Money } from '../../domain/value-objects/Money'; +import { + WithdrawFromLeagueWalletUseCase, + type WithdrawFromLeagueWalletErrorCode, + type WithdrawFromLeagueWalletInput +} from './WithdrawFromLeagueWalletUseCase'; describe('WithdrawFromLeagueWalletUseCase', () => { let leagueRepository: { findById: Mock }; @@ -25,13 +22,16 @@ describe('WithdrawFromLeagueWalletUseCase', () => { walletRepository = { findByLeagueId: vi.fn(), update: vi.fn() }; transactionRepository = { create: vi.fn() }; - logger = { error: vi.fn() } as unknown as Logger & { error: Mock }; + logger = { + debug: vi.fn(), + info: vi.fn(), + warn: vi.fn(), + error: vi.fn() + } as any; - }; - - useCase = new WithdrawFromLeagueWalletUseCase(leagueRepository as unknown as ILeagueRepository, - walletRepository as unknown as ILeagueWalletRepository, - transactionRepository as unknown as ITransactionRepository, + useCase = new WithdrawFromLeagueWalletUseCase(leagueRepository as any, + walletRepository as any, + transactionRepository as any, logger); }); @@ -55,7 +55,7 @@ describe('WithdrawFromLeagueWalletUseCase', () => { expect(err.code).toBe('LEAGUE_NOT_FOUND'); expect(err.details.message).toBe('League with id league-1 not found'); - }); + }); it('returns WALLET_NOT_FOUND when wallet is missing', async () => { const league = League.create({ @@ -85,7 +85,7 @@ describe('WithdrawFromLeagueWalletUseCase', () => { expect(err.code).toBe('WALLET_NOT_FOUND'); expect(err.details.message).toBe('Wallet for league league-1 not found'); - }); + }); it('returns UNAUTHORIZED_WITHDRAWAL when requester is not owner', async () => { const league = League.create({ @@ -121,7 +121,7 @@ describe('WithdrawFromLeagueWalletUseCase', () => { expect(err.code).toBe('UNAUTHORIZED_WITHDRAWAL'); expect(err.details.message).toBe('Only the league owner can withdraw from the league wallet'); - }); + }); it('returns INSUFFICIENT_FUNDS when wallet cannot withdraw amount', async () => { const league = League.create({ @@ -157,7 +157,7 @@ describe('WithdrawFromLeagueWalletUseCase', () => { expect(err.code).toBe('INSUFFICIENT_FUNDS'); expect(err.details.message).toBe('Insufficient balance for withdrawal'); - }); + }); it('creates withdrawal transaction and updates wallet on success', async () => { vi.useFakeTimers(); @@ -193,17 +193,10 @@ describe('WithdrawFromLeagueWalletUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); expect(transactionRepository.create).toHaveBeenCalledTimes(1); - const createdTx = (transactionRepository.create as Mock).mock.calls[0]![0] as { - id: { toString(): string }; - type: string; - amount: { amount: number; currency: string }; - description: string | undefined; - metadata: Record | undefined; - walletId: { toString(): string }; - }; + const createdTx = (transactionRepository.create as Mock).mock.calls[0]![0] as any; const expectedTransactionId = `txn-${new Date('2025-01-01T00:00:00.000Z').getTime()}`; @@ -222,7 +215,7 @@ describe('WithdrawFromLeagueWalletUseCase', () => { expect(updatedWallet.balance.currency).toBe('USD'); expect(updatedWallet.getTransactionIds()).toContain(expectedTransactionId); - const presented = (expect(presented.leagueId).toBe('league-1'); + expect(presented.leagueId).toBe('league-1'); expect(presented.amount.amount).toBe(250); expect(presented.amount.currency).toBe('USD'); expect(presented.transactionId).toBe(expectedTransactionId); @@ -274,4 +267,4 @@ describe('WithdrawFromLeagueWalletUseCase', () => { expect(err.details.message).toBe('DB down'); expect(logger.error).toHaveBeenCalledTimes(1); }); -}); \ No newline at end of file +}); diff --git a/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.ts b/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.ts index c5a14c7a5..a1881f1b5 100644 --- a/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.ts +++ b/core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase.ts @@ -1,13 +1,10 @@ +import { LeagueWalletId } from '@/racing/domain/entities/league-wallet/LeagueWalletId'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { Logger } from '@core/shared/application'; -import type { LeagueRepository } from '../../domain/repositories/LeagueRepository'; -import type { LeagueWalletRepository } from '../../domain/repositories/LeagueWalletRepository'; -import type { TransactionRepository } from '../../domain/repositories/TransactionRepository'; -import { Money } from '../../domain/value-objects/Money'; import { Transaction } from '../../domain/entities/league-wallet/Transaction'; import { TransactionId } from '../../domain/entities/league-wallet/TransactionId'; -import { LeagueWalletId } from '../../domain/entities/league-wallet/LeagueWalletId'; +import { Money } from '../../domain/value-objects/Money'; export type WithdrawFromLeagueWalletInput = { leagueId: string; diff --git a/core/racing/application/use-cases/WithdrawFromRaceUseCase.test.ts b/core/racing/application/use-cases/WithdrawFromRaceUseCase.test.ts index c0acfb9d8..d2c29de40 100644 --- a/core/racing/application/use-cases/WithdrawFromRaceUseCase.test.ts +++ b/core/racing/application/use-cases/WithdrawFromRaceUseCase.test.ts @@ -14,6 +14,7 @@ describe('WithdrawFromRaceUseCase', () => { let raceRepository: { findById: ReturnType }; let registrationRepository: { isRegistered: ReturnType; withdraw: ReturnType }; let logger: Logger; + beforeEach(() => { raceRepository = { findById: vi.fn(), @@ -29,14 +30,12 @@ describe('WithdrawFromRaceUseCase', () => { info: vi.fn(), warn: vi.fn(), error: vi.fn(), - }; - - }; + } as any; }); const createUseCase = () => - new WithdrawFromRaceUseCase(raceRepository as unknown as IRaceRepository, - registrationRepository as unknown as IRaceRegistrationRepository, + new WithdrawFromRaceUseCase(raceRepository as any, + registrationRepository as any, logger); it('withdraws from race successfully', async () => { @@ -45,9 +44,7 @@ describe('WithdrawFromRaceUseCase', () => { isUpcoming: vi.fn().mockReturnValue(true), }; - raceRepository.findById.mockResolvedValue( - race as unknown as Awaited>, - ); + raceRepository.findById.mockResolvedValue(race); registrationRepository.isRegistered.mockResolvedValue(true); registrationRepository.withdraw.mockResolvedValue(undefined); @@ -61,7 +58,8 @@ describe('WithdrawFromRaceUseCase', () => { const result = await useCase.execute(input); expect(result.isOk()).toBe(true); - expect(result.unwrap()).toBeUndefined(); + const presented = result.unwrap(); + expect(presented.status).toBe('withdrawn'); expect(registrationRepository.withdraw).toHaveBeenCalledWith('race-1', 'driver-1'); }); @@ -81,7 +79,7 @@ describe('WithdrawFromRaceUseCase', () => { const error = result.unwrapErr() as ApplicationErrorCode; expect(error.code).toBe('RACE_NOT_FOUND'); expect(error.details?.message).toContain('Race race-unknown not found'); - }); + }); it('returns error when registration is not found', async () => { const race = { @@ -89,9 +87,7 @@ describe('WithdrawFromRaceUseCase', () => { isUpcoming: vi.fn().mockReturnValue(true), }; - raceRepository.findById.mockResolvedValue( - race as unknown as Awaited>, - ); + raceRepository.findById.mockResolvedValue(race); registrationRepository.isRegistered.mockResolvedValue(false); const useCase = createUseCase(); @@ -107,7 +103,7 @@ describe('WithdrawFromRaceUseCase', () => { const error = result.unwrapErr() as ApplicationErrorCode; expect(error.code).toBe('REGISTRATION_NOT_FOUND'); expect(error.details?.message).toContain('Driver driver-unknown is not registered for race race-1'); - }); + }); it('returns error when withdrawal is not allowed', async () => { const race = { @@ -115,9 +111,7 @@ describe('WithdrawFromRaceUseCase', () => { isUpcoming: vi.fn().mockReturnValue(false), }; - raceRepository.findById.mockResolvedValue( - race as unknown as Awaited>, - ); + raceRepository.findById.mockResolvedValue(race); registrationRepository.isRegistered.mockResolvedValue(true); const useCase = createUseCase(); @@ -133,7 +127,7 @@ describe('WithdrawFromRaceUseCase', () => { const error = result.unwrapErr() as ApplicationErrorCode; expect(error.code).toBe('WITHDRAWAL_NOT_ALLOWED'); expect(error.details?.message).toContain('Withdrawal is not allowed for this race'); - }); + }); it('wraps repository errors and logs them', async () => { const race = { @@ -141,9 +135,7 @@ describe('WithdrawFromRaceUseCase', () => { isUpcoming: vi.fn().mockReturnValue(true), }; - raceRepository.findById.mockResolvedValue( - race as unknown as Awaited>, - ); + raceRepository.findById.mockResolvedValue(race); registrationRepository.isRegistered.mockResolvedValue(true); registrationRepository.withdraw.mockRejectedValue(new Error('DB failure')); @@ -162,4 +154,4 @@ describe('WithdrawFromRaceUseCase', () => { expect(error.details?.message).toBe('DB failure'); expect(logger.error).toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/core/racing/domain/entities/Car.ts b/core/racing/domain/entities/Car.ts index 22a99eae3..28b0efe29 100644 --- a/core/racing/domain/entities/Car.ts +++ b/core/racing/domain/entities/Car.ts @@ -5,18 +5,18 @@ * Immutable entity with factory methods and domain validation. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import { CarName } from './CarName'; -import { Manufacturer } from './Manufacturer'; import { CarClass, CarClassType } from './CarClass'; -import { CarLicense, CarLicenseType } from './CarLicense'; -import { Year } from './Year'; -import { Horsepower } from './Horsepower'; -import { Weight } from './Weight'; -import { GameId } from './GameId'; import { CarId } from './CarId'; +import { CarLicense, CarLicenseType } from './CarLicense'; +import { CarName } from './CarName'; +import { GameId } from './GameId'; +import { Horsepower } from './Horsepower'; import { ImageUrl } from './ImageUrl'; +import { Manufacturer } from './Manufacturer'; +import { Weight } from './Weight'; +import { Year } from './Year'; export class Car implements Entity { readonly id: CarId; diff --git a/core/racing/domain/entities/Driver.ts b/core/racing/domain/entities/Driver.ts index 94755607f..8547d5a54 100644 --- a/core/racing/domain/entities/Driver.ts +++ b/core/racing/domain/entities/Driver.ts @@ -5,14 +5,14 @@ * Immutable entity with factory methods and domain validation. */ +import { MediaReference } from '@core/domain/media/MediaReference'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; -import { RacingId } from '../value-objects/RacingId'; -import { DriverName } from '../value-objects/driver/DriverName'; import { CountryCode } from '../value-objects/CountryCode'; import { DriverBio } from '../value-objects/driver/DriverBio'; +import { DriverName } from '../value-objects/driver/DriverName'; import { JoinedAt } from '../value-objects/JoinedAt'; -import { MediaReference } from '@core/domain/media/MediaReference'; +import { IRacingId } from '../value-objects/RacingId'; export class Driver implements Entity { readonly id: string; @@ -170,4 +170,11 @@ export class Driver implements Entity { return new Driver(driverProps); } + + equals(other: Entity): boolean { + if (!(other instanceof Driver)) { + return false; + } + return this.id === other.id; + } } \ No newline at end of file diff --git a/core/racing/domain/entities/DriverLivery.ts b/core/racing/domain/entities/DriverLivery.ts index 3506c34ef..04c149605 100644 --- a/core/racing/domain/entities/DriverLivery.ts +++ b/core/racing/domain/entities/DriverLivery.ts @@ -5,15 +5,15 @@ * Includes user-placed decals and league-specific overrides. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import { LiveryDecal } from '../value-objects/LiveryDecal'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; +import { CarId } from '../value-objects/CarId'; import { DecalOverride } from '../value-objects/DecalOverride'; import { DriverId } from '../value-objects/driver/DriverId'; -import { GameId } from './GameId'; -import { CarId } from '../value-objects/CarId'; import { ImageUrl } from '../value-objects/ImageUrl'; +import { LiveryDecal } from '../value-objects/LiveryDecal'; +import { GameId } from './GameId'; export interface DriverLiveryProps { id: string; diff --git a/core/racing/domain/entities/Game.ts b/core/racing/domain/entities/Game.ts index 7a2daaadc..8a49d5e2d 100644 --- a/core/racing/domain/entities/Game.ts +++ b/core/racing/domain/entities/Game.ts @@ -1,4 +1,4 @@ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { GameId } from './GameId'; import { GameName } from './GameName'; diff --git a/core/racing/domain/entities/JoinRequest.ts b/core/racing/domain/entities/JoinRequest.ts index c9e44551c..c7eb0d70e 100644 --- a/core/racing/domain/entities/JoinRequest.ts +++ b/core/racing/domain/entities/JoinRequest.ts @@ -4,11 +4,11 @@ * Represents a request to join a league. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; +import { JoinedAt } from '../value-objects/JoinedAt'; import { LeagueId } from './LeagueId'; import { LeagueOwnerId } from './LeagueOwnerId'; -import { JoinedAt } from '../value-objects/JoinedAt'; export interface JoinRequestProps { id?: string; @@ -74,4 +74,11 @@ export class JoinRequest implements Entity { throw new RacingDomainValidationError('Driver ID is required'); } } + + equals(other: Entity): boolean { + if (!(other instanceof JoinRequest)) { + return false; + } + return this.id === other.id; + } } \ No newline at end of file diff --git a/core/racing/domain/entities/League.ts b/core/racing/domain/entities/League.ts index 962bda2fb..7ac3359d4 100644 --- a/core/racing/domain/entities/League.ts +++ b/core/racing/domain/entities/League.ts @@ -5,19 +5,19 @@ * Immutable entity with factory methods and domain validation. */ -import type { Entity } from '@core/shared/domain'; +import { MediaReference } from '@core/domain/media/MediaReference'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; +import { LeagueVisibility, LeagueVisibilityType } from '../value-objects/LeagueVisibility'; +import { MaxParticipants } from '../value-objects/MaxParticipants'; +import { ParticipantCount } from '../value-objects/ParticipantCount'; +import { SessionDuration } from '../value-objects/SessionDuration'; +import { LeagueCreatedAt } from './LeagueCreatedAt'; +import { LeagueDescription } from './LeagueDescription'; import { LeagueId } from './LeagueId'; import { LeagueName } from './LeagueName'; -import { LeagueDescription } from './LeagueDescription'; import { LeagueOwnerId } from './LeagueOwnerId'; -import { LeagueCreatedAt } from './LeagueCreatedAt'; import { LeagueSocialLinks } from './LeagueSocialLinks'; -import { LeagueVisibility, LeagueVisibilityType } from '../value-objects/LeagueVisibility'; -import { ParticipantCount } from '../value-objects/ParticipantCount'; -import { MaxParticipants } from '../value-objects/MaxParticipants'; -import { SessionDuration } from '../value-objects/SessionDuration'; -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import { MediaReference } from '@core/domain/media/MediaReference'; /** * Stewarding decision mode for protests @@ -536,4 +536,11 @@ export class League implements Entity { canAcceptMore(): boolean { return !this.isFull(); } + + equals(other: Entity): boolean { + if (!(other instanceof League)) { + return false; + } + return this.id.equals(other.id); + } } \ No newline at end of file diff --git a/core/racing/domain/entities/LeagueMembership.ts b/core/racing/domain/entities/LeagueMembership.ts index 745b0daa6..32fb9240b 100644 --- a/core/racing/domain/entities/LeagueMembership.ts +++ b/core/racing/domain/entities/LeagueMembership.ts @@ -4,14 +4,14 @@ * Represents a driver's membership in a league. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import { LeagueId } from './LeagueId'; -import { MembershipRole, MembershipRoleValue } from './MembershipRole'; -import { MembershipStatus, MembershipStatusValue } from './MembershipStatus'; import { JoinedAt } from '../value-objects/JoinedAt'; import { DriverId } from './DriverId'; import { JoinRequest } from './JoinRequest'; +import { LeagueId } from './LeagueId'; +import { MembershipRole, MembershipRoleValue } from './MembershipRole'; +import { MembershipStatus, MembershipStatusValue } from './MembershipStatus'; export interface LeagueMembershipProps { id?: string; @@ -101,6 +101,13 @@ export class LeagueMembership implements Entity { throw new RacingDomainValidationError('Membership role is required'); } } + + equals(other: Entity): boolean { + if (!(other instanceof LeagueMembership)) { + return false; + } + return this.id === other.id; + } } -export { MembershipRole, MembershipStatus, JoinRequest }; \ No newline at end of file +export { JoinRequest, MembershipRole, MembershipStatus }; diff --git a/core/racing/domain/entities/LeagueScoringConfig.ts b/core/racing/domain/entities/LeagueScoringConfig.ts index f369436f7..4ae74ef83 100644 --- a/core/racing/domain/entities/LeagueScoringConfig.ts +++ b/core/racing/domain/entities/LeagueScoringConfig.ts @@ -4,12 +4,12 @@ * Represents the scoring configuration for a league season. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; import type { ChampionshipConfig } from '../types/ChampionshipConfig'; -import { SeasonId } from './season/SeasonId'; -import { ScoringPresetId } from './ScoringPresetId'; import { LeagueScoringConfigId } from './LeagueScoringConfigId'; +import { ScoringPresetId } from './ScoringPresetId'; +import { SeasonId } from './season/SeasonId'; export interface LeagueScoringConfigProps { id?: string; diff --git a/core/racing/domain/entities/LiveryTemplate.ts b/core/racing/domain/entities/LiveryTemplate.ts index 0b5003679..1b7e4433e 100644 --- a/core/racing/domain/entities/LiveryTemplate.ts +++ b/core/racing/domain/entities/LiveryTemplate.ts @@ -5,16 +5,16 @@ * Contains base image and sponsor decal placements. */ -import type { Entity } from '@core/shared/domain'; -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import type { LiveryDecal } from '../value-objects/LiveryDecal'; -import { LiveryTemplateId } from './LiveryTemplateId'; -import { LeagueId } from './LeagueId'; -import { SeasonId } from './season/SeasonId'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; import { CarId } from '../value-objects/CarId'; +import type { LiveryDecal } from '../value-objects/LiveryDecal'; import { ImageUrl } from './ImageUrl'; +import { LeagueId } from './LeagueId'; import { LiveryTemplateCreatedAt } from './LiveryTemplateCreatedAt'; +import { LiveryTemplateId } from './LiveryTemplateId'; import { LiveryTemplateUpdatedAt } from './LiveryTemplateUpdatedAt'; +import { SeasonId } from './season/SeasonId'; export class LiveryTemplate implements Entity { readonly id: LiveryTemplateId; diff --git a/core/racing/domain/entities/Protest.ts b/core/racing/domain/entities/Protest.ts index bef70df4c..37074ef49 100644 --- a/core/racing/domain/entities/Protest.ts +++ b/core/racing/domain/entities/Protest.ts @@ -11,21 +11,21 @@ * - dismissed: Protest was dismissed (no action taken) * - withdrawn: Protesting driver withdrew the protest */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; -import { ProtestId } from './ProtestId'; -import { RaceId } from './RaceId'; -import { DriverId } from './DriverId'; -import { StewardId } from './StewardId'; -import { ProtestStatus } from './ProtestStatus'; -import { ProtestIncident } from './ProtestIncident'; -import { ProtestComment } from './ProtestComment'; -import { VideoUrl } from './VideoUrl'; -import { FiledAt } from './FiledAt'; -import { ReviewedAt } from './ReviewedAt'; -import { ProtestDefense } from './ProtestDefense'; -import { DefenseRequestedAt } from './DefenseRequestedAt'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; import { DecisionNotes } from './DecisionNotes'; +import { DefenseRequestedAt } from './DefenseRequestedAt'; +import { DriverId } from './DriverId'; +import { FiledAt } from './FiledAt'; +import { ProtestComment } from './ProtestComment'; +import { ProtestDefense } from './ProtestDefense'; +import { ProtestId } from './ProtestId'; +import { ProtestIncident } from './ProtestIncident'; +import { ProtestStatus } from './ProtestStatus'; +import { RaceId } from './RaceId'; +import { ReviewedAt } from './ReviewedAt'; +import { StewardId } from './StewardId'; +import { VideoUrl } from './VideoUrl'; export interface ProtestProps { id: ProtestId; diff --git a/core/racing/domain/entities/Race.ts b/core/racing/domain/entities/Race.ts index 44c34922b..705365e02 100644 --- a/core/racing/domain/entities/Race.ts +++ b/core/racing/domain/entities/Race.ts @@ -5,12 +5,12 @@ * Immutable entity with factory methods and domain validation. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; -import { SessionType } from '../value-objects/SessionType'; -import { RaceStatus, RaceStatusValue } from '../value-objects/RaceStatus'; -import { ParticipantCount } from '../value-objects/ParticipantCount'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; import { MaxParticipants } from '../value-objects/MaxParticipants'; +import { ParticipantCount } from '../value-objects/ParticipantCount'; +import { RaceStatus, RaceStatusValue } from '../value-objects/RaceStatus'; +import { SessionType } from '../value-objects/SessionType'; import { StrengthOfField } from '../value-objects/StrengthOfField'; export type { RaceStatus, RaceStatusValue } from '../value-objects/RaceStatus'; @@ -486,4 +486,11 @@ export class Race implements Entity { getStatus(): string { return this.status.toString(); } + + equals(other: Entity): boolean { + if (!(other instanceof Race)) { + return false; + } + return this.id === other.id; + } } \ No newline at end of file diff --git a/core/racing/domain/entities/RaceEvent.ts b/core/racing/domain/entities/RaceEvent.ts index 67a5bff85..6aef807c2 100644 --- a/core/racing/domain/entities/RaceEvent.ts +++ b/core/racing/domain/entities/RaceEvent.ts @@ -5,10 +5,10 @@ * Immutable aggregate root with factory methods and domain validation. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; -import type { Session } from './Session'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; import { SessionType } from '../value-objects/SessionType'; +import type { Session } from './Session'; export type RaceEventStatus = 'scheduled' | 'in_progress' | 'awaiting_stewarding' | 'closed' | 'cancelled'; @@ -280,4 +280,11 @@ export class RaceEvent implements Entity { isClosed(): boolean { return this.status === 'closed'; } + + equals(other: Entity): boolean { + if (!(other instanceof RaceEvent)) { + return false; + } + return this.id === other.id; + } } \ No newline at end of file diff --git a/core/racing/domain/entities/RaceRegistration.ts b/core/racing/domain/entities/RaceRegistration.ts index f56b95e9b..3c6485ecd 100644 --- a/core/racing/domain/entities/RaceRegistration.ts +++ b/core/racing/domain/entities/RaceRegistration.ts @@ -4,10 +4,10 @@ * Represents a registration of a driver for a specific race. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import { RaceId } from './RaceId'; import { DriverId } from './DriverId'; +import { RaceId } from './RaceId'; import { RegisteredAt } from './RegisteredAt'; export interface RaceRegistrationProps { @@ -73,4 +73,11 @@ export class RaceRegistration implements Entity { throw new RacingDomainValidationError('Driver ID is required'); } } + + equals(other: Entity): boolean { + if (!(other instanceof RaceRegistration)) { + return false; + } + return this.id === other.id; + } } \ No newline at end of file diff --git a/core/racing/domain/entities/ResultWithIncidents.ts b/core/racing/domain/entities/ResultWithIncidents.ts index 442bc05d9..6472ffe10 100644 --- a/core/racing/domain/entities/ResultWithIncidents.ts +++ b/core/racing/domain/entities/ResultWithIncidents.ts @@ -2,7 +2,7 @@ * Enhanced Result entity with detailed incident tracking */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; import { RaceIncidents, type IncidentRecord } from '../value-objects/RaceIncidents'; import { DriverId } from './DriverId'; diff --git a/core/racing/domain/entities/Session.ts b/core/racing/domain/entities/Session.ts index 3a7d73921..78956e7f0 100644 --- a/core/racing/domain/entities/Session.ts +++ b/core/racing/domain/entities/Session.ts @@ -5,8 +5,8 @@ * Immutable entity with factory methods and domain validation. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; import type { SessionType } from '../value-objects/SessionType'; export type SessionStatus = 'scheduled' | 'running' | 'completed' | 'cancelled'; diff --git a/core/racing/domain/entities/SponsorshipRequest.ts b/core/racing/domain/entities/SponsorshipRequest.ts index ce04e74b4..ad68cbbef 100644 --- a/core/racing/domain/entities/SponsorshipRequest.ts +++ b/core/racing/domain/entities/SponsorshipRequest.ts @@ -5,8 +5,8 @@ * (driver, team, race, or league/season). The entity owner must approve/reject. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; import type { Money } from '../value-objects/Money'; import type { SponsorshipTier } from './season/SeasonSponsorship'; diff --git a/core/racing/domain/entities/Standing.ts b/core/racing/domain/entities/Standing.ts index b828edd53..e72f5d41e 100644 --- a/core/racing/domain/entities/Standing.ts +++ b/core/racing/domain/entities/Standing.ts @@ -6,12 +6,12 @@ */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import { LeagueId } from './LeagueId'; -import { DriverId } from './DriverId'; import { Points } from '../value-objects/Points'; import { Position } from './championship/Position'; +import { DriverId } from './DriverId'; +import { LeagueId } from './LeagueId'; export class Standing implements Entity { readonly id: string; @@ -115,6 +115,13 @@ export class Standing implements Entity { } } + equals(other: Entity): boolean { + if (!(other instanceof Standing)) { + return false; + } + return this.id === other.id; + } + /** * Add points from a race result */ diff --git a/core/racing/domain/entities/Team.ts b/core/racing/domain/entities/Team.ts index 370c048d3..0558e146b 100644 --- a/core/racing/domain/entities/Team.ts +++ b/core/racing/domain/entities/Team.ts @@ -6,15 +6,15 @@ * basic invariants around identity and core properties. */ -import type { Entity } from '@core/shared/domain'; +import { MediaReference } from '@core/domain/media/MediaReference'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; +import { TeamCreatedAt } from '../value-objects/TeamCreatedAt'; +import { TeamDescription } from '../value-objects/TeamDescription'; import { TeamName } from '../value-objects/TeamName'; import { TeamTag } from '../value-objects/TeamTag'; -import { TeamDescription } from '../value-objects/TeamDescription'; import { DriverId } from './DriverId'; import { LeagueId } from './LeagueId'; -import { TeamCreatedAt } from '../value-objects/TeamCreatedAt'; -import { MediaReference } from '@core/domain/media/MediaReference'; export class Team implements Entity { readonly id: string; @@ -159,4 +159,10 @@ export class Team implements Entity { }); } + equals(other: Entity): boolean { + if (!(other instanceof Team)) { + return false; + } + return this.id === other.id; + } } \ No newline at end of file diff --git a/core/racing/domain/entities/TeamRatingEvent.ts b/core/racing/domain/entities/TeamRatingEvent.ts index f319795fd..7b3743d59 100644 --- a/core/racing/domain/entities/TeamRatingEvent.ts +++ b/core/racing/domain/entities/TeamRatingEvent.ts @@ -1,8 +1,8 @@ -import type { Entity } from '@core/shared/domain'; -import { TeamRatingEventId } from '../value-objects/TeamRatingEventId'; -import { TeamRatingDimensionKey } from '../value-objects/TeamRatingDimensionKey'; +import type { Entity, IEntity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../errors/RacingDomainError'; import { TeamRatingDelta } from '../value-objects/TeamRatingDelta'; -import { RacingDomainValidationError, RacingDomainInvariantError } from '../errors/RacingDomainError'; +import { TeamRatingDimensionKey } from '../value-objects/TeamRatingDimensionKey'; +import { TeamRatingEventId } from '../value-objects/TeamRatingEventId'; export interface TeamRatingEventSource { type: 'race' | 'penalty' | 'vote' | 'adminAction' | 'manualAdjustment'; diff --git a/core/racing/domain/entities/Track.ts b/core/racing/domain/entities/Track.ts index 6c6b77b8f..121f7cbb9 100644 --- a/core/racing/domain/entities/Track.ts +++ b/core/racing/domain/entities/Track.ts @@ -5,15 +5,15 @@ * Immutable entity with factory methods and domain validation. */ +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; -import { TrackName } from '../value-objects/TrackName'; -import { TrackShortName } from '../value-objects/TrackShortName'; import { TrackCountry } from '../value-objects/TrackCountry'; -import { TrackLength } from '../value-objects/TrackLength'; -import { TrackTurns } from '../value-objects/TrackTurns'; import { TrackGameId } from '../value-objects/TrackGameId'; import { TrackImageUrl } from '../value-objects/TrackImageUrl'; +import { TrackLength } from '../value-objects/TrackLength'; +import { TrackName } from '../value-objects/TrackName'; +import { TrackShortName } from '../value-objects/TrackShortName'; +import { TrackTurns } from '../value-objects/TrackTurns'; export type TrackCategory = 'oval' | 'road' | 'street' | 'dirt'; export type TrackDifficulty = 'beginner' | 'intermediate' | 'advanced' | 'expert'; diff --git a/core/racing/domain/entities/championship/ChampionshipStanding.ts b/core/racing/domain/entities/championship/ChampionshipStanding.ts index b637a1cfb..c7b13af64 100644 --- a/core/racing/domain/entities/championship/ChampionshipStanding.ts +++ b/core/racing/domain/entities/championship/ChampionshipStanding.ts @@ -1,4 +1,4 @@ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../../errors/RacingDomainError'; import type { ParticipantRef } from '../../types/ParticipantRef'; import { Points } from '../../value-objects/Points'; diff --git a/core/racing/domain/entities/league-wallet/LeagueWallet.ts b/core/racing/domain/entities/league-wallet/LeagueWallet.ts index 50d3e69d7..7ae952d13 100644 --- a/core/racing/domain/entities/league-wallet/LeagueWallet.ts +++ b/core/racing/domain/entities/league-wallet/LeagueWallet.ts @@ -5,12 +5,12 @@ * Aggregate root for managing league finances and transactions. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../../errors/RacingDomainError'; import type { Money } from '../../value-objects/Money'; -import { LeagueWalletId } from './LeagueWalletId'; import { LeagueId } from '../LeagueId'; +import { LeagueWalletId } from './LeagueWalletId'; import { TransactionId } from './TransactionId'; export interface LeagueWalletProps { diff --git a/core/racing/domain/entities/league-wallet/Transaction.ts b/core/racing/domain/entities/league-wallet/Transaction.ts index 6f470b2df..2467f9576 100644 --- a/core/racing/domain/entities/league-wallet/Transaction.ts +++ b/core/racing/domain/entities/league-wallet/Transaction.ts @@ -4,12 +4,12 @@ * Represents a financial transaction in the league wallet system. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../../errors/RacingDomainError'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../../errors/RacingDomainError'; +import type { Entity } from '@core/shared/domain/Entity'; import type { Money } from '../../value-objects/Money'; -import type { Entity } from '@core/shared/domain'; -import { TransactionId } from './TransactionId'; import { LeagueWalletId } from './LeagueWalletId'; +import { TransactionId } from './TransactionId'; export type TransactionType = | 'sponsorship_payment' diff --git a/core/racing/domain/entities/penalty/Penalty.ts b/core/racing/domain/entities/penalty/Penalty.ts index 5f237e5e3..5265a0377 100644 --- a/core/racing/domain/entities/penalty/Penalty.ts +++ b/core/racing/domain/entities/penalty/Penalty.ts @@ -5,21 +5,21 @@ * Penalties can be applied as a result of an upheld protest or directly by stewards. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; -import { PenaltyId } from './PenaltyId'; -import { LeagueId } from '../LeagueId'; -import { RaceId } from '../RaceId'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../../errors/RacingDomainError'; +import { AppliedAt } from '../AppliedAt'; import { DriverId } from '../DriverId'; +import { IssuedAt } from '../IssuedAt'; +import { LeagueId } from '../LeagueId'; +import { ProtestId } from '../ProtestId'; +import { RaceId } from '../RaceId'; +import { StewardId } from '../StewardId'; +import { PenaltyId } from './PenaltyId'; +import { PenaltyNotes } from './PenaltyNotes'; +import { PenaltyReason } from './PenaltyReason'; +import { PenaltyStatus } from './PenaltyStatus'; import { PenaltyType, type PenaltyTypeValue } from './PenaltyType'; import { PenaltyValue } from './PenaltyValue'; -import { PenaltyReason } from './PenaltyReason'; -import { ProtestId } from '../ProtestId'; -import { StewardId } from '../StewardId'; -import { PenaltyStatus } from './PenaltyStatus'; -import { IssuedAt } from '../IssuedAt'; -import { AppliedAt } from '../AppliedAt'; -import { PenaltyNotes } from './PenaltyNotes'; export interface PenaltyProps { id: PenaltyId; @@ -239,4 +239,11 @@ export class Penalty implements Entity { return 'Penalty'; } } -} \ No newline at end of file + + equals(other: Entity): boolean { + if (!(other instanceof Penalty)) { + return false; + } + return this.id === other.id; + } +} diff --git a/core/racing/domain/entities/prize/Prize.ts b/core/racing/domain/entities/prize/Prize.ts index f15066996..f5c68059c 100644 --- a/core/racing/domain/entities/prize/Prize.ts +++ b/core/racing/domain/entities/prize/Prize.ts @@ -4,15 +4,15 @@ * Represents a prize awarded to a driver for a specific position in a season. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../../errors/RacingDomainError'; import type { Money } from '../../value-objects/Money'; import { Position } from '../championship/Position'; +import { DriverId } from '../DriverId'; +import { SeasonId } from '../season/SeasonId'; import { PrizeId } from './PrizeId'; import { PrizeStatus } from './PrizeStatus'; -import { SeasonId } from '../season/SeasonId'; -import { DriverId } from '../DriverId'; export interface PrizeProps { id: PrizeId; diff --git a/core/racing/domain/entities/result/Result.ts b/core/racing/domain/entities/result/Result.ts index 46f6df944..f4847afb1 100644 --- a/core/racing/domain/entities/result/Result.ts +++ b/core/racing/domain/entities/result/Result.ts @@ -5,13 +5,13 @@ * Immutable entity with factory methods and domain validation. */ +import type { Entity } from '@core/shared/domain/Entity'; import { RacingDomainValidationError } from '../../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; -import { RaceId } from '../RaceId'; import { DriverId } from '../DriverId'; -import { Position } from './Position'; -import { LapTime } from './LapTime'; +import { RaceId } from '../RaceId'; import { IncidentCount } from './IncidentCount'; +import { LapTime } from './LapTime'; +import { Position } from './Position'; export class Result implements Entity { readonly id: string; @@ -121,6 +121,13 @@ export class Result implements Entity { } } + equals(other: Entity): boolean { + if (!(other instanceof Result)) { + return false; + } + return this.id === other.id; + } + /** * Calculate positions gained/lost */ diff --git a/core/racing/domain/entities/season/Season.ts b/core/racing/domain/entities/season/Season.ts index e9b212bbe..d27fd974c 100644 --- a/core/racing/domain/entities/season/Season.ts +++ b/core/racing/domain/entities/season/Season.ts @@ -1,15 +1,15 @@ +import type { Entity } from '@core/shared/domain/Entity'; import { - RacingDomainInvariantError, - RacingDomainValidationError, + RacingDomainInvariantError, + RacingDomainValidationError, } from '../../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; +import { MaxParticipants } from '../../value-objects/MaxParticipants'; +import { ParticipantCount } from '../../value-objects/ParticipantCount'; +import type { SeasonDropPolicy } from '../../value-objects/SeasonDropPolicy'; import type { SeasonSchedule } from '../../value-objects/SeasonSchedule'; import type { SeasonScoringConfig } from '../../value-objects/SeasonScoringConfig'; -import type { SeasonDropPolicy } from '../../value-objects/SeasonDropPolicy'; -import type { SeasonStewardingConfig } from '../../value-objects/SeasonStewardingConfig'; import { SeasonStatus, SeasonStatusValue } from '../../value-objects/SeasonStatus'; -import { ParticipantCount } from '../../value-objects/ParticipantCount'; -import { MaxParticipants } from '../../value-objects/MaxParticipants'; +import type { SeasonStewardingConfig } from '../../value-objects/SeasonStewardingConfig'; export class Season implements Entity { readonly id: string; @@ -662,4 +662,11 @@ export class Season implements Entity { participantCount: newCount.toNumber(), }); } + + equals(other: Entity): boolean { + if (!(other instanceof Season)) { + return false; + } + return this.id === other.id; + } } \ No newline at end of file diff --git a/core/racing/domain/entities/season/SeasonSponsorship.ts b/core/racing/domain/entities/season/SeasonSponsorship.ts index bac45f636..ed3a86f89 100644 --- a/core/racing/domain/entities/season/SeasonSponsorship.ts +++ b/core/racing/domain/entities/season/SeasonSponsorship.ts @@ -5,8 +5,8 @@ * Aggregate root for managing sponsorship slots and pricing. */ -import { RacingDomainValidationError, RacingDomainInvariantError } from '../../errors/RacingDomainError'; -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; +import { RacingDomainInvariantError, RacingDomainValidationError } from '../../errors/RacingDomainError'; import type { Money } from '../../value-objects/Money'; diff --git a/core/racing/domain/entities/sponsor/Sponsor.ts b/core/racing/domain/entities/sponsor/Sponsor.ts index 1df92c0c4..ad5c37b87 100644 --- a/core/racing/domain/entities/sponsor/Sponsor.ts +++ b/core/racing/domain/entities/sponsor/Sponsor.ts @@ -4,7 +4,7 @@ * Represents a sponsor that can sponsor leagues/seasons. * Aggregate root for sponsor information. */ -import type { Entity } from '@core/shared/domain'; +import type { Entity } from '@core/shared/domain/Entity'; import { SponsorCreatedAt } from './SponsorCreatedAt'; import { SponsorEmail } from './SponsorEmail'; import { SponsorId } from './SponsorId'; diff --git a/core/racing/domain/value-objects/CountryCode.ts b/core/racing/domain/value-objects/CountryCode.ts index 7387d5b9a..25aa59d75 100644 --- a/core/racing/domain/value-objects/CountryCode.ts +++ b/core/racing/domain/value-objects/CountryCode.ts @@ -1,5 +1,5 @@ import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import type { ValueObject } from '@core/shared/domain'; +import type { ValueObject } from '@core/shared/domain/ValueObject'; export class CountryCode implements ValueObject { private constructor(private readonly value: string) {} @@ -19,11 +19,11 @@ export class CountryCode implements ValueObject { return this.value; } - equals(other: IValueObject): boolean { + equals(other: ValueObject): boolean { return this.value === other.props; } get props(): string { return this.value; } -} \ No newline at end of file +} diff --git a/core/racing/domain/value-objects/JoinedAt.ts b/core/racing/domain/value-objects/JoinedAt.ts index cd9b93c7d..705d82716 100644 --- a/core/racing/domain/value-objects/JoinedAt.ts +++ b/core/racing/domain/value-objects/JoinedAt.ts @@ -1,5 +1,5 @@ import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import type { ValueObject } from '@core/shared/domain'; +import type { ValueObject } from '@core/shared/domain/ValueObject'; export class JoinedAt implements ValueObject { private constructor(private readonly value: Date) {} @@ -20,7 +20,7 @@ export class JoinedAt implements ValueObject { return new Date(this.value); } - equals(other: IValueObject): boolean { + equals(other: ValueObject): boolean { return this.props.getTime() === other.props.getTime(); } -} \ No newline at end of file +} diff --git a/core/racing/domain/value-objects/Points.ts b/core/racing/domain/value-objects/Points.ts index d57aa7cd6..8beece3c9 100644 --- a/core/racing/domain/value-objects/Points.ts +++ b/core/racing/domain/value-objects/Points.ts @@ -19,7 +19,7 @@ export class Points implements ValueObject<{ value: number }> { return this.value; } - equals(other: IValueObject<{ value: number }>): boolean { + equals(other: ValueObject<{ value: number }>): boolean { return this.value === other.props.value; } } \ No newline at end of file diff --git a/core/racing/domain/value-objects/RacingId.test.ts b/core/racing/domain/value-objects/RacingId.test.ts index 58998b998..a20b993d5 100644 --- a/core/racing/domain/value-objects/RacingId.test.ts +++ b/core/racing/domain/value-objects/RacingId.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { RacingId } from './RacingId'; +import { IRacingId } from './RacingId'; describe('IRacingId', () => { it('should create an iRacing id', () => { diff --git a/core/racing/domain/value-objects/RacingId.ts b/core/racing/domain/value-objects/RacingId.ts index b14d6a6dc..60b21af8e 100644 --- a/core/racing/domain/value-objects/RacingId.ts +++ b/core/racing/domain/value-objects/RacingId.ts @@ -1,5 +1,5 @@ import { RacingDomainValidationError } from '../errors/RacingDomainError'; -import type { ValueObject } from '@core/shared/domain'; +import type { ValueObject } from '@core/shared/domain/ValueObject'; export class IRacingId implements ValueObject { private constructor(private readonly value: string) {} @@ -19,7 +19,7 @@ export class IRacingId implements ValueObject { return this.value; } - equals(other: IValueObject): boolean { + equals(other: ValueObject): boolean { return this.props === other.props; } -} \ No newline at end of file +} diff --git a/core/racing/domain/value-objects/driver/DriverBio.ts b/core/racing/domain/value-objects/driver/DriverBio.ts index e3a8d5be9..f9606da10 100644 --- a/core/racing/domain/value-objects/driver/DriverBio.ts +++ b/core/racing/domain/value-objects/driver/DriverBio.ts @@ -1,5 +1,5 @@ import { RacingDomainValidationError } from '../../errors/RacingDomainError'; -import type { ValueObject } from '@core/shared/domain'; +import type { ValueObject } from '@core/shared/domain/ValueObject'; export interface DriverBioProps { value: string; @@ -19,7 +19,7 @@ export class DriverBio implements ValueObject { return this.value; } - equals(other: IValueObject): boolean { + equals(other: ValueObject): boolean { return this.props.value === other.props.value; } diff --git a/core/racing/domain/value-objects/driver/DriverName.ts b/core/racing/domain/value-objects/driver/DriverName.ts index 170c5fac4..4000fea50 100644 --- a/core/racing/domain/value-objects/driver/DriverName.ts +++ b/core/racing/domain/value-objects/driver/DriverName.ts @@ -1,5 +1,5 @@ import { RacingDomainValidationError } from '../../errors/RacingDomainError'; -import type { ValueObject } from '@core/shared/domain'; +import type { ValueObject } from '@core/shared/domain/ValueObject'; export interface DriverNameProps { value: string; @@ -19,7 +19,7 @@ export class DriverName implements ValueObject { return this.value; } - equals(other: IValueObject): boolean { + equals(other: ValueObject): boolean { return this.props.value === other.props.value; } diff --git a/core/shared/domain/ValueObject.ts b/core/shared/domain/ValueObject.ts index f9825696a..09ab392a9 100644 --- a/core/shared/domain/ValueObject.ts +++ b/core/shared/domain/ValueObject.ts @@ -1,7 +1,6 @@ -export interface ValueObjectProps { +export interface ValueObject { readonly props: Props; - equals(other: ValueObjectProps): boolean; + equals(other: ValueObject): boolean; } -// Alias for backward compatibility -export type IValueObject = ValueObjectProps; +export type IValueObject = ValueObject; diff --git a/core/social/application/use-cases/GetCurrentUserSocialUseCase.test.ts b/core/social/application/use-cases/GetCurrentUserSocialUseCase.test.ts index 4c07d1603..de5ec6204 100644 --- a/core/social/application/use-cases/GetCurrentUserSocialUseCase.test.ts +++ b/core/social/application/use-cases/GetCurrentUserSocialUseCase.test.ts @@ -1,12 +1,11 @@ +import { Driver } from '@core/racing/domain/entities/Driver'; +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; import { - GetCurrentUserSocialUseCase, - type GetCurrentUserSocialApplicationError, - type GetCurrentUserSocialInput, + GetCurrentUserSocialUseCase, + type GetCurrentUserSocialApplicationError, + type GetCurrentUserSocialInput, } from './GetCurrentUserSocialUseCase'; -import type { SocialGraphRepository } from '../../domain/repositories/SocialGraphRepository'; -import type { Logger } from '@core/shared/application'; -import { Driver } from '@core/racing/domain/entities/Driver'; describe('GetCurrentUserSocialUseCase', () => { let socialGraphRepository: ISocialGraphRepository & { getFriends: Mock }; @@ -18,14 +17,14 @@ describe('GetCurrentUserSocialUseCase', () => { getFriends: vi.fn(), getFriendIds: vi.fn(), getSuggestedFriends: vi.fn(), - } as unknown as ISocialGraphRepository & { getFriends: Mock }; + } as any; logger = { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn(), - } as unknown as Logger & { debug: Mock; info: Mock; warn: Mock; error: Mock }; + } as any; useCase = new GetCurrentUserSocialUseCase(socialGraphRepository, logger); }); diff --git a/core/social/application/use-cases/GetCurrentUserSocialUseCase.ts b/core/social/application/use-cases/GetCurrentUserSocialUseCase.ts index 7af629764..2307d0842 100644 --- a/core/social/application/use-cases/GetCurrentUserSocialUseCase.ts +++ b/core/social/application/use-cases/GetCurrentUserSocialUseCase.ts @@ -1,7 +1,7 @@ -import type { Logger } from '@core/shared/application'; +import { ISocialGraphRepository } from '@/social/domain/repositories/SocialGraphRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { SocialGraphRepository } from '../../domain/repositories/SocialGraphRepository'; import type { SocialFriendSummary, SocialUserSummary } from '../types/SocialUser'; export interface GetCurrentUserSocialParams { diff --git a/core/social/application/use-cases/GetUserFeedUseCase.test.ts b/core/social/application/use-cases/GetUserFeedUseCase.test.ts index 00797c8db..681af083c 100644 --- a/core/social/application/use-cases/GetUserFeedUseCase.test.ts +++ b/core/social/application/use-cases/GetUserFeedUseCase.test.ts @@ -1,12 +1,11 @@ +import type { Logger } from '@core/shared/domain/Logger'; import { beforeEach, describe, expect, it, vi, type Mock } from 'vitest'; -import { - GetUserFeedUseCase, - type GetUserFeedApplicationError, - type GetUserFeedInput, -} from './GetUserFeedUseCase'; -import type { FeedRepository } from '../../domain/repositories/FeedRepository'; import type { FeedItem } from '../../domain/types/FeedItem'; -import type { Logger } from '@core/shared/application'; +import { + GetUserFeedUseCase, + type GetUserFeedApplicationError, + type GetUserFeedInput, +} from './GetUserFeedUseCase'; describe('GetUserFeedUseCase', () => { let feedRepository: IFeedRepository & { getFeedForDriver: Mock }; diff --git a/core/social/application/use-cases/GetUserFeedUseCase.ts b/core/social/application/use-cases/GetUserFeedUseCase.ts index 3d20c54b9..705713835 100644 --- a/core/social/application/use-cases/GetUserFeedUseCase.ts +++ b/core/social/application/use-cases/GetUserFeedUseCase.ts @@ -1,7 +1,7 @@ -import type { Logger } from '@core/shared/application'; +import { IFeedRepository } from '@/social/domain/repositories/FeedRepository'; +import type { Logger } from '@core/shared/domain/Logger'; import { Result } from '@core/shared/domain/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; -import type { FeedRepository } from '../../domain/repositories/FeedRepository'; import type { FeedItem } from '../../domain/types/FeedItem'; export interface GetUserFeedParams {