This commit is contained in:
2025-12-16 13:13:03 +01:00
parent 7d3393e1b9
commit 84f05598a6
78 changed files with 161 additions and 157 deletions

View File

@@ -1,5 +1,5 @@
import type { FaceValidationPort, FaceValidationResult } from '@core/media/application/ports/FaceValidationPort';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryFaceValidationAdapter implements FaceValidationPort {
constructor(private readonly logger: Logger) {

View File

@@ -1,5 +1,5 @@
import type { IImageServicePort } from '@core/racing/application/ports/IImageServicePort';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryImageServiceAdapter implements IImageServicePort {
constructor(private readonly logger: Logger) {

View File

@@ -1,6 +1,6 @@
import { INotificationPreferenceRepository } from '@core/notifications/domain/repositories/INotificationPreferenceRepository';
import { NotificationPreference } from '@core/notifications/domain/entities/NotificationPreference';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryNotificationPreferenceRepository implements INotificationPreferenceRepository {
private preferences: Map<string, NotificationPreference> = new Map();

View File

@@ -7,7 +7,7 @@
import { Notification } from '../../domain/entities/Notification';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
import type { NotificationType } from '../../domain/types/NotificationTypes';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryNotificationRepository implements INotificationRepository {
private notifications: Map<string, Notification> = new Map();

View File

@@ -8,7 +8,7 @@
import { v4 as uuidv4 } from 'uuid';
import { Car, CarClass, CarLicense } from '@core/racing/domain/entities/Car';
import type { ICarRepository } from '@core/racing/domain/repositories/ICarRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryCarRepository implements ICarRepository {
private cars: Map<string, Car>;

View File

@@ -1,6 +1,6 @@
import { IDriverRepository } from '@core/racing/domain/repositories/IDriverRepository';
import { Driver } from '@core/racing/domain/entities/Driver';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryDriverRepository implements IDriverRepository {
private drivers: Map<string, Driver> = new Map();

View File

@@ -1,6 +1,6 @@
import { IGameRepository } from '@core/racing/domain/repositories/IGameRepository';
import { Game } from '@core/racing/domain/entities/Game';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryGameRepository implements IGameRepository {
private games: Map<string, Game> = new Map();

View File

@@ -1,6 +1,6 @@
import { ILeagueMembershipRepository } from '@core/racing/domain/repositories/ILeagueMembershipRepository';
import { LeagueMembership, JoinRequest } from '@core/racing/domain/entities/LeagueMembership';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryLeagueMembershipRepository implements ILeagueMembershipRepository {
private memberships: Map<string, LeagueMembership> = new Map(); // Key: `${leagueId}:${driverId}`

View File

@@ -1,6 +1,6 @@
import { ILeagueRepository } from '@core/racing/domain/repositories/ILeagueRepository';
import { League } from '@core/racing/domain/entities/League';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryLeagueRepository implements ILeagueRepository {
private leagues: Map<string, League> = new Map();

View File

@@ -1,6 +1,6 @@
import { ILeagueScoringConfigRepository } from '@core/racing/domain/repositories/ILeagueScoringConfigRepository';
import { LeagueScoringConfig } from '@core/racing/domain/entities/LeagueScoringConfig';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryLeagueScoringConfigRepository implements ILeagueScoringConfigRepository {
private configs: Map<string, LeagueScoringConfig> = new Map(); // Key: seasonId

View File

@@ -1,5 +1,5 @@
import { ILeagueStandingsRepository, RawStanding } from '@core/league/application/ports/ILeagueStandingsRepository';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryLeagueStandingsRepository implements ILeagueStandingsRepository {
private standings: Map<string, RawStanding[]> = new Map(); // Key: leagueId

View File

@@ -6,7 +6,7 @@
import type { LeagueWallet } from '../../domain/entities/LeagueWallet';
import type { ILeagueWalletRepository } from '../../domain/repositories/ILeagueWalletRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryLeagueWalletRepository implements ILeagueWalletRepository {
private wallets: Map<string, LeagueWallet> = new Map();

View File

@@ -7,7 +7,7 @@
import type { DriverLivery } from '../../domain/entities/DriverLivery';
import type { LiveryTemplate } from '../../domain/entities/LiveryTemplate';
import type { ILiveryRepository } from '../../domain/repositories/ILiveryRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryLiveryRepository implements ILiveryRepository {
private driverLiveries: Map<string, DriverLivery> = new Map();

View File

@@ -6,7 +6,7 @@
import type { Penalty } from '../../domain/entities/Penalty';
import type { IPenaltyRepository } from '../../domain/repositories/IPenaltyRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryPenaltyRepository implements IPenaltyRepository {
private penalties: Map<string, Penalty> = new Map();

View File

@@ -1,6 +1,6 @@
import { IProtestRepository } from '@core/racing/domain/repositories/IProtestRepository';
import { Protest, ProtestStatus } from '@core/racing/domain/entities/Protest';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryProtestRepository implements IProtestRepository {
private protests: Map<string, Protest> = new Map();

View File

@@ -3,7 +3,7 @@
*/
import type { IRaceEventRepository } from '../../domain/repositories/IRaceEventRepository';
import type { RaceEvent } from '../../domain/entities/RaceEvent';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryRaceEventRepository implements IRaceEventRepository {
private raceEvents: Map<string, RaceEvent> = new Map();

View File

@@ -1,6 +1,6 @@
import { IRaceRegistrationRepository } from '@core/racing/domain/repositories/IRaceRegistrationRepository';
import { RaceRegistration } from '@core/racing/domain/entities/RaceRegistration';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryRaceRegistrationRepository implements IRaceRegistrationRepository {
private registrations: Map<string, RaceRegistration> = new Map(); // Key: `${raceId}:${driverId}`

View File

@@ -1,6 +1,6 @@
import { IRaceRepository } from '@core/racing/domain/repositories/IRaceRepository';
import { Race, RaceStatus } from '@core/racing/domain/entities/Race';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemoryRaceRepository implements IRaceRepository {
private races: Map<string, Race> = new Map();

View File

@@ -9,7 +9,7 @@ import { v4 as uuidv4 } from 'uuid';
import { Result } from '@core/racing/domain/entities/Result';
import type { IResultRepository } from '@core/racing/domain/repositories/IResultRepository';
import type { IRaceRepository } from '@core/racing/domain/repositories/IRaceRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryResultRepository implements IResultRepository {
private results: Map<string, Result>;

View File

@@ -13,7 +13,7 @@ import type { IChampionshipStandingRepository } from '@core/racing/domain/reposi
import { ChampionshipStanding } from '@core/racing/domain/entities/ChampionshipStanding';
import type { ChampionshipType } from '@core/racing/domain/types/ChampionshipType';
import type { ParticipantRef } from '@core/racing/domain/types/ParticipantRef';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
class SilentLogger implements Logger {
debug(..._args: unknown[]): void {

View File

@@ -1,6 +1,6 @@
import { ISeasonRepository } from '@core/racing/domain/repositories/ISeasonRepository';
import { Season } from '@core/racing/domain/entities/Season';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemorySeasonRepository implements ISeasonRepository {
private seasons: Map<string, Season> = new Map(); // Key: seasonId

View File

@@ -6,7 +6,7 @@
import type { SeasonSponsorship, SponsorshipTier } from '../../domain/entities/SeasonSponsorship';
import type { ISeasonSponsorshipRepository } from '../../domain/repositories/ISeasonSponsorshipRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemorySeasonSponsorshipRepository implements ISeasonSponsorshipRepository {
private sponsorships: Map<string, SeasonSponsorship> = new Map();

View File

@@ -3,7 +3,7 @@
*/
import type { ISessionRepository } from '../../domain/repositories/ISessionRepository';
import type { Session } from '../../domain/entities/Session';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemorySessionRepository implements ISessionRepository {
private sessions: Map<string, Session> = new Map();

View File

@@ -1,6 +1,6 @@
import { ISponsorRepository } from '@core/racing/domain/repositories/ISponsorRepository';
import { Sponsor } from '@core/racing/domain/entities/Sponsor';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemorySponsorRepository implements ISponsorRepository {
private sponsors: Map<string, Sponsor> = new Map();

View File

@@ -5,7 +5,7 @@
import type { ISponsorshipPricingRepository } from '../../domain/repositories/ISponsorshipPricingRepository';
import { SponsorshipPricing } from '../../domain/value-objects/SponsorshipPricing';
import type { SponsorableEntityType } from '../../domain/entities/SponsorshipRequest';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
interface StorageKey {
entityType: SponsorableEntityType;

View File

@@ -1,6 +1,6 @@
import { ISponsorshipRequestRepository } from '@core/racing/domain/repositories/ISponsorshipRequestRepository';
import { SponsorshipRequest, SponsorableEntityType, SponsorshipRequestStatus } from '@core/racing/domain/entities/SponsorshipRequest';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
export class InMemorySponsorshipRequestRepository implements ISponsorshipRequestRepository {
private requests: Map<string, SponsorshipRequest> = new Map();

View File

@@ -10,7 +10,7 @@ import type { IStandingRepository } from '@core/racing/domain/repositories/IStan
import type { IResultRepository } from '@core/racing/domain/repositories/IResultRepository';
import type { IRaceRepository } from '@core/racing/domain/repositories/IRaceRepository';
import type { ILeagueRepository } from '@core/racing/domain/repositories/ILeagueRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Points systems presets

View File

@@ -10,7 +10,7 @@ import type {
TeamJoinRequest,
} from '@core/racing/domain/types/TeamMembership';
import type { ITeamMembershipRepository } from '@core/racing/domain/repositories/ITeamMembershipRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryTeamMembershipRepository implements ITeamMembershipRepository {
private membershipsByTeam: Map<string, TeamMembership[]>;

View File

@@ -7,7 +7,7 @@
import type { Team } from '@core/racing/domain/entities/Team';
import type { ITeamRepository } from '@core/racing/domain/repositories/ITeamRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryTeamRepository implements ITeamRepository {
private teams: Map<string, Team>;

View File

@@ -8,7 +8,7 @@
import { v4 as uuidv4 } from 'uuid';
import { Track, TrackCategory } from '@core/racing/domain/entities/Track';
import type { ITrackRepository } from '@core/racing/domain/repositories/ITrackRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryTrackRepository implements ITrackRepository {
private tracks: Map<string, Track>;

View File

@@ -6,7 +6,7 @@
import type { Transaction, TransactionType } from '../../domain/entities/Transaction';
import type { ITransactionRepository } from '../../domain/repositories/ITransactionRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryTransactionRepository implements ITransactionRepository {
private transactions: Map<string, Transaction> = new Map();

View File

@@ -1,5 +1,5 @@
import type { DriverRatingProvider } from '@core/racing/application/ports/DriverRatingProvider';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryDriverRatingProvider implements DriverRatingProvider {
constructor(private readonly logger: Logger) {

View File

@@ -1,5 +1,5 @@
import type { IDriverStatsService, DriverStats } from '@core/racing/domain/services/IDriverStatsService';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryDriverStatsService implements IDriverStatsService {
constructor(private readonly logger: Logger) {

View File

@@ -1,5 +1,5 @@
import type { IRankingService, DriverRanking } from '@core/racing/domain/services/IRankingService';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class InMemoryRankingService implements IRankingService {
constructor(private readonly logger: Logger) {

View File

@@ -9,7 +9,7 @@ const IENGAGEMENT_REPO_TOKEN = 'IEngagementRepository_TOKEN';
const RECORD_PAGE_VIEW_USE_CASE_TOKEN = 'RecordPageViewUseCase_TOKEN';
const RECORD_ENGAGEMENT_USE_CASE_TOKEN = 'RecordEngagementUseCase_TOKEN';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
import { IPageViewRepository } from '@core/analytics/application/repositories/IPageViewRepository';
import { IEngagementRepository } from '@core/analytics/domain/repositories/IEngagementRepository';

View File

@@ -1,6 +1,6 @@
import { Injectable, Inject } from '@nestjs/common';
import { RecordEngagementInput, RecordEngagementOutput, RecordPageViewInput, RecordPageViewOutput } from './dto/AnalyticsDto';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
import { RecordPageViewUseCase } from './use-cases/RecordPageViewUseCase';
import { RecordEngagementUseCase } from './use-cases/RecordEngagementUseCase';

View File

@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RecordEngagementUseCase } from './RecordEngagementUseCase';
import { IEngagementRepository } from '@core/analytics/domain/repositories/IEngagementRepository';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
describe('RecordEngagementUseCase', () => {
let useCase: RecordEngagementUseCase;

View File

@@ -1,7 +1,7 @@
import { Injectable, Inject } from '@nestjs/common';
import { RecordEngagementInput, RecordEngagementOutput } from '../dto/AnalyticsDto';
import { IEngagementRepository } from '@core/analytics/domain/repositories/IEngagementRepository';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
import { EngagementEvent } from '@core/analytics/domain/entities/EngagementEvent';
const Logger_TOKEN = 'Logger_TOKEN';

View File

@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { RecordPageViewUseCase } from './RecordPageViewUseCase';
import { IPageViewRepository } from '@core/analytics/application/repositories/IPageViewRepository';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
describe('RecordPageViewUseCase', () => {
let useCase: RecordPageViewUseCase;

View File

@@ -1,7 +1,7 @@
import { Injectable, Inject } from '@nestjs/common';
import { RecordPageViewInput, RecordPageViewOutput } from '../dto/AnalyticsDto';
import { IPageViewRepository } from '@core/analytics/application/repositories/IPageViewRepository';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
import { PageView } from '@core/analytics/domain/entities/PageView';
const Logger_TOKEN = 'Logger_TOKEN';

View File

@@ -5,7 +5,7 @@ import { AuthService } from './AuthService';
import { IAuthRepository } from '@core/identity/domain/repositories/IAuthRepository';
import { IUserRepository, StoredUser } from '@core/identity/domain/repositories/IUserRepository';
import { IPasswordHashingService } from '@core/identity/domain/services/PasswordHashingService';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
import { InMemoryAuthRepository } from '../../..//identity/persistence/inmemory/InMemoryAuthRepository';
import { InMemoryUserRepository } from '../../..//identity/persistence/inmemory/InMemoryUserRepository';

View File

@@ -4,7 +4,7 @@ import { GetDriversLeaderboardUseCase } from '@core/racing/application/use-cases
import { GetTotalDriversUseCase } from '@core/racing/application/use-cases/GetTotalDriversUseCase';
import { CompleteDriverOnboardingUseCase } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
import { IsDriverRegisteredForRaceUseCase } from '@core/racing/application/use-cases/IsDriverRegisteredForRaceUseCase';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
describe('DriverService', () => {
let service: DriverService;

View File

@@ -15,7 +15,7 @@ import { DriverRegistrationStatusPresenter } from './presenters/DriverRegistrati
// Tokens
import { GET_DRIVERS_LEADERBOARD_USE_CASE_TOKEN, GET_TOTAL_DRIVERS_USE_CASE_TOKEN, COMPLETE_DRIVER_ONBOARDING_USE_CASE_TOKEN, IS_DRIVER_REGISTERED_FOR_RACE_USE_CASE_TOKEN, LOGGER_TOKEN } from './DriverProviders';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
@Injectable()
export class DriverService {

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
import { EngagementEvent, type EngagementAction, type EngagementEntityType } from '../../domain/entities/EngagementEvent';
import type { IEngagementRepository } from '../../domain/repositories/IEngagementRepository';
@@ -59,7 +59,7 @@ export class RecordEngagementUseCase
engagementWeight: event.getEngagementWeight(),
};
} catch (error) {
this.logger.error('Error recording engagement', error, { input });
this.logger.error('Error recording engagement', error instanceof Error ? error : new Error(String(error)), { input });
throw error;
}
}

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
import { PageView } from '../../domain/entities/PageView';
import type { EntityType, VisitorType } from '../../domain/types/PageView';
import type { IPageViewRepository } from '../../domain/repositories/IPageViewRepository';

View File

@@ -1,6 +1,6 @@
import type { LogLevel } from './LoggerLogLevel';
import type { LogContext } from './LoggerContext';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* LoggerPort - Port interface for application-layer logging.

View File

@@ -1,5 +1,5 @@
import { AuthenticationState } from '../../domain/value-objects/AuthenticationState';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import { Result } from '../../../shared/result/Result';
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import { SessionLifetime } from '../../domain/value-objects/SessionLifetime';

View File

@@ -1,6 +1,6 @@
import { Result } from '../../../shared/result/Result';
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Use case for clearing the user's session (logout).

View File

@@ -1,7 +1,7 @@
import { Result } from '../../../shared/result/Result';
import { RaceCreationResult } from '../../domain/value-objects/RaceCreationResult';
import type { CheckoutServicePort } from '../ports/CheckoutServicePort';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
export class CompleteRaceCreationUseCase {
constructor(private readonly checkoutService: CheckoutServicePort, private readonly logger: Logger) {}

View File

@@ -1,5 +1,5 @@
import { Result } from '../../../shared/result/Result';
import type { Logger } from '../../../shared/src/logging/Logger';
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';

View File

@@ -1,5 +1,5 @@
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import { AutomationSession } from '../../domain/entities/AutomationSession';
import type { HostedSessionConfig } from '../../domain/types/HostedSessionConfig';
import { AutomationEnginePort } from '../ports/AutomationEnginePort';

View File

@@ -1,7 +1,7 @@
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import { Result } from '../../../shared/result/Result';
import { BrowserAuthenticationState } from '../../domain/value-objects/BrowserAuthenticationState';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Use case for verifying browser shows authenticated page state.

View File

@@ -1,6 +1,6 @@
import type { LoggerPort } from '../../../application/ports/LoggerPort';
import type { LogContext } from '../../../application/ports/LoggerContext';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export class NoOpLogAdapter implements LoggerPort, Logger {
debug(_message: string, _context?: LogContext): void {}

View File

@@ -2,7 +2,7 @@ import type { LoggerPort } from '@core/automation/application/ports/LoggerPort';
import type { LogContext } from '@core/automation/application/ports/LoggerContext';
import type { LogLevel } from '@core/automation/application/ports/LoggerLogLevel';
import { loadLoggingConfig, type LoggingEnvironmentConfig } from '../../config/LoggingConfig';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
const LOG_LEVEL_PRIORITY: Record<LogLevel, number> = {
debug: 10,

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import type { Notification } from '../../domain/entities/Notification';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
@@ -35,7 +35,7 @@ export class GetUnreadNotificationsUseCase implements AsyncUseCase<string, Unrea
totalCount: notifications.length,
};
} catch (error) {
this.logger.error(`Failed to retrieve unread notifications for recipient ID: ${recipientId}`, error);
this.logger.error(`Failed to retrieve unread notifications for recipient ID: ${recipientId}`, error instanceof Error ? error : new Error(String(error)));
throw error;
}
}

View File

@@ -7,7 +7,7 @@
import type { AsyncUseCase } from '@core/shared/application';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
import { NotificationDomainError } from '../../domain/errors/NotificationDomainError';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
export interface MarkNotificationReadCommand {
notificationId: string;
@@ -44,7 +44,7 @@ export class MarkNotificationReadUseCase implements AsyncUseCase<MarkNotificatio
await this.notificationRepository.update(updatedNotification);
this.logger.info(`Notification ${command.notificationId} successfully marked as read.`);
} catch (error) {
this.logger.error(`Failed to mark notification ${command.notificationId} as read: ${error.message}`);
this.logger.error(`Failed to mark notification ${command.notificationId} as read: ${error instanceof Error ? error.message : String(error)}`);
throw error;
}
}

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
import { NotificationPreference } from '../../domain/entities/NotificationPreference';
import type { ChannelPreference, TypePreference } from '../../domain/entities/NotificationPreference';
import type { INotificationPreferenceRepository } from '../../domain/repositories/INotificationPreferenceRepository';

View File

@@ -7,7 +7,7 @@
import { v4 as uuid } from 'uuid';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import { Notification } from '../../domain/entities/Notification';
import type { NotificationData } from '../../domain/entities/Notification';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
@@ -60,83 +60,87 @@ export class SendNotificationUseCase implements AsyncUseCase<SendNotificationCom
// Get recipient's preferences
this.logger.debug('Checking notification preferences.', { type: command.type, recipientId: command.recipientId });
const preferences = await this.preferenceRepository.getOrCreateDefault(command.recipientId);
// Check if this notification type is enabled
if (!preferences.isTypeEnabled(command.type)) {
// User has disabled this type - create but don't deliver
const notification = Notification.create({
id: uuid(),
recipientId: command.recipientId,
type: command.type,
title: command.title,
body: command.body,
channel: 'in_app',
status: 'dismissed', // Auto-dismiss since user doesn't want these
...(command.data ? { data: command.data } : {}),
...(command.actionUrl ? { actionUrl: command.actionUrl } : {}),
});
await this.notificationRepository.create(notification);
return {
notification,
deliveryResults: [],
};
}
// Determine which channels to use
const channels = command.forceChannels ?? preferences.getEnabledChannelsForType(command.type);
// Check quiet hours (skip external channels during quiet hours)
const effectiveChannels = preferences.isInQuietHours()
? channels.filter(ch => ch === 'in_app')
: channels;
// Ensure at least in_app is used
if (!effectiveChannels.includes('in_app')) {
effectiveChannels.unshift('in_app');
}
const deliveryResults: NotificationDeliveryResult[] = [];
let primaryNotification: Notification | null = null;
// Send through each channel
for (const channel of effectiveChannels) {
const notification = Notification.create({
id: uuid(),
recipientId: command.recipientId,
type: command.type,
title: command.title,
body: command.body,
channel,
...(command.urgency ? { urgency: command.urgency } : {}),
...(command.data ? { data: command.data } : {}),
...(command.actionUrl ? { actionUrl: command.actionUrl } : {}),
...(command.actions ? { actions: command.actions } : {}),
...(command.requiresResponse !== undefined
? { requiresResponse: command.requiresResponse }
: {}),
});
// Save to repository (in_app channel) or attempt delivery (external channels)
if (channel === 'in_app') {
await this.notificationRepository.create(notification);
primaryNotification = notification;
deliveryResults.push({
success: true,
channel,
attemptedAt: new Date(),
// Check if this notification type is enabled
if (!preferences.isTypeEnabled(command.type)) {
// User has disabled this type - create but don't deliver
const notification = Notification.create({
id: uuid(),
recipientId: command.recipientId,
type: command.type,
title: command.title,
body: command.body,
channel: 'in_app',
status: 'dismissed', // Auto-dismiss since user doesn't want these
...(command.data ? { data: command.data } : {}),
...(command.actionUrl ? { actionUrl: command.actionUrl } : {}),
});
} else {
// Attempt external delivery
const result = await this.gatewayRegistry.send(notification);
deliveryResults.push(result);
await this.notificationRepository.create(notification);
return {
notification,
deliveryResults: [],
};
}
// Determine which channels to use
const channels = command.forceChannels ?? preferences.getEnabledChannelsForType(command.type);
// Check quiet hours (skip external channels during quiet hours)
const effectiveChannels = preferences.isInQuietHours()
? channels.filter(ch => ch === 'in_app')
: channels;
// Ensure at least in_app is used
if (!effectiveChannels.includes('in_app')) {
effectiveChannels.unshift('in_app');
}
const deliveryResults: NotificationDeliveryResult[] = [];
let primaryNotification: Notification | null = null;
// Send through each channel
for (const channel of effectiveChannels) {
const notification = Notification.create({
id: uuid(),
recipientId: command.recipientId,
type: command.type,
title: command.title,
body: command.body,
channel,
...(command.urgency ? { urgency: command.urgency } : {}),
...(command.data ? { data: command.data } : {}),
...(command.actionUrl ? { actionUrl: command.actionUrl } : {}),
...(command.actions ? { actions: command.actions } : {}),
...(command.requiresResponse !== undefined
? { requiresResponse: command.requiresResponse }
: {}),
});
// Save to repository (in_app channel) or attempt delivery (external channels)
if (channel === 'in_app') {
await this.notificationRepository.create(notification);
primaryNotification = notification;
deliveryResults.push({
success: true,
channel,
attemptedAt: new Date(),
});
} else {
// Attempt external delivery
const result = await this.gatewayRegistry.send(notification);
deliveryResults.push(result);
}
}
return {
notification: primaryNotification!,
deliveryResults,
};
} catch (error) {
this.logger.error('Error sending notification', error as Error);
throw error;
}
return {
notification: primaryNotification!,
deliveryResults,
};
}
}

View File

@@ -5,7 +5,7 @@
* This creates an active sponsorship and notifies the sponsor.
*/
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import type { ISponsorshipRequestRepository } from '../../domain/repositories/ISponsorshipRequestRepository';
import type { ISeasonSponsorshipRepository } from '../../domain/repositories/ISeasonSponsorshipRepository';
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';

View File

@@ -16,7 +16,7 @@ import {
EntityNotFoundError,
BusinessRuleViolationError,
} from '../errors/RacingApplicationError';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
export interface ApplyForSponsorshipDTO {
sponsorId: string;

View File

@@ -12,7 +12,7 @@ import type { IRaceRepository } from '../../domain/repositories/IRaceRepository'
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
import { randomUUID } from 'crypto';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
export interface ApplyPenaltyCommand {
raceId: string;

View File

@@ -1,4 +1,4 @@
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';
import type {
TeamMembership,

View File

@@ -1,6 +1,6 @@
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Use Case: CancelRaceUseCase

View File

@@ -6,7 +6,7 @@ import type { DriverRatingProvider } from '../ports/DriverRatingProvider';
import { Result } from '../../domain/entities/Result';
import { Standing } from '../../domain/entities/Standing';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Use Case: CompleteRaceUseCase

View File

@@ -8,7 +8,7 @@ import { Standing } from '../../domain/entities/Standing';
import { RaceResultGenerator } from '../utils/RaceResultGenerator';
import { RatingUpdateService } from '@core/identity/domain/services/RatingUpdateService';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Enhanced CompleteRaceUseCase that includes rating updates

View File

@@ -6,7 +6,7 @@ import type { ISeasonRepository } from '../../domain/repositories/ISeasonReposit
import type { ILeagueScoringConfigRepository } from '../../domain/repositories/ILeagueScoringConfigRepository';
import type { LeagueScoringConfig } from '../../domain/entities/LeagueScoringConfig';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import type {
LeagueScoringPresetProvider,
LeagueScoringPresetDTO,

View File

@@ -1,6 +1,6 @@
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import type {
IAllRacesPagePresenter,
AllRacesPageResultDTO,
@@ -8,7 +8,7 @@ import type {
AllRacesListItemViewModel,
AllRacesFilterOptionsViewModel,
} from '../presenters/IAllRacesPagePresenter';
import type { UseCase } => '@gridpilot/shared/application';
import type { UseCase } from '@core/shared/application';
export class GetAllRacesPageDataUseCase
implements UseCase<void, AllRacesPageResultDTO, AllRacesPageViewModel, IAllRacesPagePresenter> {

View File

@@ -6,7 +6,7 @@ import type {
} from '../presenters/IAllTeamsPresenter';
import type { UseCase } from '@core/shared/application';
import type { Team } from '../../domain/entities/Team';
import { Logger } from "@gridpilot/core/shared/application";
import { Logger } from "@core/shared/application";
/**
* Use Case for retrieving all teams.

View File

@@ -6,7 +6,7 @@ import type {
DriverTeamViewModel,
} from '../presenters/IDriverTeamPresenter';
import type { UseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Use Case for retrieving a driver's team.

View File

@@ -7,7 +7,7 @@ import type {
TeamJoinRequestsViewModel,
} from '../presenters/ITeamJoinRequestsPresenter';
import type { UseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Use Case for retrieving team join requests.

View File

@@ -7,7 +7,7 @@ import type {
TeamMembersViewModel,
} from '../presenters/ITeamMembersPresenter';
import type { UseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
/**
* Use Case for retrieving team members.

View File

@@ -1,4 +1,4 @@
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import type {
ILeagueMembershipRepository,
} from '@core/racing/domain/repositories/ILeagueMembershipRepository';

View File

@@ -7,7 +7,7 @@ import type {
} from '../../domain/types/TeamMembership';
import type { JoinTeamCommandDTO } from '../dto/TeamCommandAndQueryDTO';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import {
BusinessRuleViolationError,
EntityNotFoundError,

View File

@@ -11,7 +11,7 @@ import type { IRaceRepository } from '../../domain/repositories/IRaceRepository'
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
import { randomUUID } from 'crypto';
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
export interface QuickPenaltyCommand {
raceId: string;

View File

@@ -3,7 +3,7 @@ import type { ILeagueMembershipRepository } from '@core/racing/domain/repositori
import { RaceRegistration } from '@core/racing/domain/entities/RaceRegistration';
import type { RegisterForRaceCommandDTO } from '../dto/RegisterForRaceCommandDTO';
import type { AsyncUseCase } from '@core/shared/application';
import { Logger } from '@core/shared/logging/Logger';
import { Logger } from '@core/shared/application';
import {
BusinessRuleViolationError,
PermissionDeniedError,

View File

@@ -1,5 +1,5 @@
import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
import type { ISocialGraphRepository } from '../../domain/repositories/ISocialGraphRepository';
import type { CurrentUserSocialDTO } from '../dto/CurrentUserSocialDTO';
import type { FriendDTO } from '../dto/FriendDTO';

View File

@@ -6,7 +6,7 @@ import type {
IUserFeedPresenter,
UserFeedViewModel,
} from '../presenters/ISocialPresenters';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Logger } from '@core/shared/application';
export interface GetUserFeedParams {
driverId: string;

View File

@@ -2,7 +2,7 @@ import type { Driver } from '@core/racing/domain/entities/Driver';
import type { FeedItem } from '@core/social/domain/types/FeedItem';
import type { IFeedRepository } from '@core/social/domain/repositories/IFeedRepository';
import type { ISocialGraphRepository } from '@core/social/domain/repositories/ISocialGraphRepository';
import type { Logger } from '@core/shared/logging/Logger';
import type { Logger } from '@core/shared/application';
export type Friendship = {
driverId: string;