fix logger

This commit is contained in:
2025-12-15 22:39:17 +01:00
parent 7a11daa878
commit 3b566c973d
110 changed files with 1413 additions and 903 deletions

View File

@@ -6,7 +6,7 @@
*/
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '@gridpilot/shared/application';
import type { Logger } from '@gridpilot/shared/application';
import type { IPageViewRepository } from '../../domain/repositories/IPageViewRepository';
import type { IEngagementRepository } from '../../domain/repositories/IEngagementRepository';
import type { IAnalyticsSnapshotRepository } from '../../domain/repositories/IAnalyticsSnapshotRepository';
@@ -49,7 +49,7 @@ export class GetEntityAnalyticsQuery
private readonly pageViewRepository: IPageViewRepository,
private readonly engagementRepository: IEngagementRepository,
private readonly snapshotRepository: IAnalyticsSnapshotRepository,
private readonly logger: ILogger
private readonly logger: Logger
) {}
async execute(input: GetEntityAnalyticsInput): Promise<EntityAnalyticsOutput> {

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '@gridpilot/shared/logging/ILogger';
import type { Logger } from '@gridpilot/shared/logging/Logger';
import { EngagementEvent, type EngagementAction, type EngagementEntityType } from '../../domain/entities/EngagementEvent';
import type { IEngagementRepository } from '../../domain/repositories/IEngagementRepository';
@@ -28,7 +28,7 @@ export class RecordEngagementUseCase
implements AsyncUseCase<RecordEngagementInput, RecordEngagementOutput> {
constructor(
private readonly engagementRepository: IEngagementRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(input: RecordEngagementInput): Promise<RecordEngagementOutput> {

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '@gridpilot/shared/logging/ILogger';
import type { Logger } from '@gridpilot/shared/logging/Logger';
import { PageView } from '../../domain/entities/PageView';
import type { EntityType, VisitorType } from '../../domain/types/PageView';
import type { IPageViewRepository } from '../../domain/repositories/IPageViewRepository';
@@ -29,7 +29,7 @@ export class RecordPageViewUseCase
implements AsyncUseCase<RecordPageViewInput, RecordPageViewOutput> {
constructor(
private readonly pageViewRepository: IPageViewRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(input: RecordPageViewInput): Promise<RecordPageViewOutput> {

View File

@@ -1,4 +1,4 @@
export interface ILogger {
export interface Logger {
debug(message: string, ...args: any[]): void;
info(message: string, ...args: any[]): void;
warn(message: string, ...args: any[]): void;

View File

@@ -1,4 +1,4 @@
export interface ILogger {
export interface Logger {
debug(message: string, context?: Record<string, any>): void;
info(message: string, context?: Record<string, any>): void;
warn(message: string, context?: Record<string, any>): void;

View File

@@ -1,11 +1,11 @@
import type { LogLevel } from './LoggerLogLevel';
import type { LogContext } from './LoggerContext';
import type { ILogger } from '@gridpilot/shared/logging/ILogger';
import type { Logger } from '@gridpilot/shared/logging/Logger';
/**
* LoggerPort - Port interface for application-layer logging.
*/
export interface LoggerPort extends ILogger {
export interface LoggerPort extends Logger {
debug(message: string, context?: LogContext): void;
info(message: string, context?: LogContext): void;
warn(message: string, context?: LogContext): void;

View File

@@ -1,5 +1,5 @@
import { AuthenticationState } from '../../domain/value-objects/AuthenticationState';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import { Result } from '../../../shared/result/Result';
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import { SessionLifetime } from '../../domain/value-objects/SessionLifetime';
@@ -17,7 +17,7 @@ import type { SessionValidatorPort } from '../ports/SessionValidatorPort';
*/
export class CheckAuthenticationUseCase {
constructor(
private readonly logger: ILogger,
private readonly logger: Logger,
private readonly authService: AuthenticationServicePort,
private readonly sessionValidator?: SessionValidatorPort
) {}

View File

@@ -1,6 +1,6 @@
import { Result } from '../../../shared/result/Result';
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Use case for clearing the user's session (logout).
@@ -11,7 +11,7 @@ import type { ILogger } from '../../../shared/src/logging/ILogger';
export class ClearSessionUseCase {
constructor(
private readonly authService: AuthenticationServicePort,
private readonly logger: ILogger, // Inject ILogger
private readonly logger: Logger, // Inject Logger
) {}
/**

View File

@@ -1,10 +1,10 @@
import { Result } from '../../../shared/result/Result';
import { RaceCreationResult } from '../../domain/value-objects/RaceCreationResult';
import type { CheckoutServicePort } from '../ports/CheckoutServicePort';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
export class CompleteRaceCreationUseCase {
constructor(private readonly checkoutService: CheckoutServicePort, private readonly logger: ILogger) {}
constructor(private readonly checkoutService: CheckoutServicePort, private readonly logger: Logger) {}
async execute(sessionId: string): Promise<Result<RaceCreationResult>> {
this.logger.debug(`Attempting to complete race creation for session ID: ${sessionId}`);

View File

@@ -1,5 +1,5 @@
import { Result } from '../../../shared/result/Result';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { CheckoutServicePort } from '../ports/CheckoutServicePort';
import type { CheckoutConfirmationPort } from '../ports/CheckoutConfirmationPort';
import { CheckoutStateEnum } from '../../domain/value-objects/CheckoutState';
@@ -16,7 +16,7 @@ export class ConfirmCheckoutUseCase {
constructor(
private readonly checkoutService: CheckoutServicePort,
private readonly confirmationPort: CheckoutConfirmationPort,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(sessionMetadata?: SessionMetadata): Promise<Result<void>> {

View File

@@ -1,6 +1,6 @@
import { Result } from '../../../shared/result/Result';
import type { AuthenticationServicePort } from '../ports/AuthenticationServicePort';
import type { ILogger } from '../../../shared/logger/ILogger';
import type { Logger } from '@gridpilot/shared/application/Logger';
/**
* Use case for initiating the manual login flow.
@@ -12,7 +12,7 @@ import type { ILogger } from '../../../shared/logger/ILogger';
export class InitiateLoginUseCase {
constructor(
private readonly authService: AuthenticationServicePort,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
/**

View File

@@ -1,5 +1,5 @@
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import { AutomationSession } from '../../domain/entities/AutomationSession';
import type { HostedSessionConfig } from '../../domain/types/HostedSessionConfig';
import { AutomationEnginePort } from '../ports/AutomationEnginePort';
@@ -13,7 +13,7 @@ export class StartAutomationSessionUseCase
private readonly automationEngine: AutomationEnginePort,
private readonly browserAutomation: IBrowserAutomation,
private readonly sessionRepository: SessionRepositoryPort,
private readonly logger: ILogger
private readonly logger: Logger
) {}
async execute(config: HostedSessionConfig): Promise<SessionDTO> {

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 { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Use case for verifying browser shows authenticated page state.
@@ -10,7 +10,7 @@ import type { ILogger } from '../../../shared/src/logging/ILogger';
export class VerifyAuthenticatedPageUseCase {
constructor(
private readonly authService: AuthenticationServicePort,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(): Promise<Result<BrowserAuthenticationState>> {

View File

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

View File

@@ -2,7 +2,7 @@ import type { LoggerPort } from '@gridpilot/automation/application/ports/LoggerP
import type { LogContext } from '@gridpilot/automation/application/ports/LoggerContext';
import type { LogLevel } from '@gridpilot/automation/application/ports/LoggerLogLevel';
import { loadLoggingConfig, type LoggingEnvironmentConfig } from '../../config/LoggingConfig';
import type { ILogger } from '@gridpilot/shared/logging/ILogger';
import type { Logger } from '@gridpilot/shared/logging/Logger';
const LOG_LEVEL_PRIORITY: Record<LogLevel, number> = {
debug: 10,
@@ -21,7 +21,7 @@ const LOG_LEVEL_PRIORITY: Record<LogLevel, number> = {
*
* This provides structured JSON logging to stdout with the same interface.
*/
export class PinoLogAdapter implements LoggerPort, ILogger {
export class PinoLogAdapter implements LoggerPort, Logger {
private readonly config: LoggingEnvironmentConfig;
private readonly baseContext: LogContext;
private readonly levelPriority: number;

View File

@@ -1,4 +1,4 @@
import type { AsyncUseCase, ILogger } from '@gridpilot/shared/application';
import type { AsyncUseCase, Logger } from '@gridpilot/shared/application';
import type { IAvatarGenerationRepository } from '../../domain/repositories/IAvatarGenerationRepository';
import type { FaceValidationPort } from '../ports/FaceValidationPort';
import type { AvatarGenerationPort } from '../ports/AvatarGenerationPort';
@@ -25,7 +25,7 @@ export class RequestAvatarGenerationUseCase
private readonly avatarRepository: IAvatarGenerationRepository,
private readonly faceValidation: FaceValidationPort,
private readonly avatarGeneration: AvatarGenerationPort,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: RequestAvatarGenerationCommand): Promise<RequestAvatarGenerationResult> {

View File

@@ -4,7 +4,7 @@
* Allows a user to select one of the generated avatars as their profile avatar.
*/
import type { AsyncUseCase, ILogger } from '@gridpilot/shared/application';
import type { AsyncUseCase, Logger } from '@gridpilot/shared/application';
import type { IAvatarGenerationRepository } from '../../domain/repositories/IAvatarGenerationRepository';
export interface SelectAvatarCommand {
@@ -23,7 +23,7 @@ export class SelectAvatarUseCase
implements AsyncUseCase<SelectAvatarCommand, SelectAvatarResult> {
constructor(
private readonly avatarRepository: IAvatarGenerationRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: SelectAvatarCommand): Promise<SelectAvatarResult> {

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { Notification } from '../../domain/entities/Notification';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
@@ -17,7 +17,7 @@ export interface UnreadNotificationsResult {
export class GetUnreadNotificationsUseCase implements AsyncUseCase<string, UnreadNotificationsResult> {
constructor(
private readonly notificationRepository: INotificationRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(recipientId: string): Promise<UnreadNotificationsResult> {

View File

@@ -7,7 +7,7 @@
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
import { NotificationDomainError } from '../../domain/errors/NotificationDomainError';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
export interface MarkNotificationReadCommand {
notificationId: string;
@@ -17,7 +17,7 @@ export interface MarkNotificationReadCommand {
export class MarkNotificationReadUseCase implements AsyncUseCase<MarkNotificationReadCommand, void> {
constructor(
private readonly notificationRepository: INotificationRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: MarkNotificationReadCommand): Promise<void> {

View File

@@ -5,7 +5,7 @@
*/
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '@gridpilot/shared/logging/ILogger';
import type { Logger } from '@gridpilot/shared/logging/Logger';
import { NotificationPreference } from '../../domain/entities/NotificationPreference';
import type { ChannelPreference, TypePreference } from '../../domain/entities/NotificationPreference';
import type { INotificationPreferenceRepository } from '../../domain/repositories/INotificationPreferenceRepository';
@@ -18,7 +18,7 @@ import { NotificationDomainError } from '../../domain/errors/NotificationDomainE
export class GetNotificationPreferencesQuery implements AsyncUseCase<string, NotificationPreference> {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(driverId: string): Promise<NotificationPreference> {
@@ -46,7 +46,7 @@ export interface UpdateChannelPreferenceCommand {
export class UpdateChannelPreferenceUseCase implements AsyncUseCase<UpdateChannelPreferenceCommand, void> {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: UpdateChannelPreferenceCommand): Promise<void> {
@@ -75,7 +75,7 @@ export interface UpdateTypePreferenceCommand {
export class UpdateTypePreferenceUseCase implements AsyncUseCase<UpdateTypePreferenceCommand, void> {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: UpdateTypePreferenceCommand): Promise<void> {
@@ -104,7 +104,7 @@ export interface UpdateQuietHoursCommand {
export class UpdateQuietHoursUseCase implements AsyncUseCase<UpdateQuietHoursCommand, void> {
constructor(
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: UpdateQuietHoursCommand): Promise<void> {

View File

@@ -7,7 +7,7 @@
import { v4 as uuid } from 'uuid';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import { Notification } from '../../domain/entities/Notification';
import type { NotificationData } from '../../domain/entities/Notification';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
@@ -49,7 +49,7 @@ export class SendNotificationUseCase implements AsyncUseCase<SendNotificationCom
private readonly notificationRepository: INotificationRepository,
private readonly preferenceRepository: INotificationPreferenceRepository,
private readonly gatewayRegistry: INotificationGatewayRegistry,
private readonly logger: ILogger,
private readonly logger: Logger,
) {
this.logger.debug('SendNotificationUseCase initialized.');
}

View File

@@ -5,7 +5,7 @@
* This creates an active sponsorship and notifies the sponsor.
*/
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { ISponsorshipRequestRepository } from '../../domain/repositories/ISponsorshipRequestRepository';
import type { ISeasonSponsorshipRepository } from '../../domain/repositories/ISeasonSponsorshipRepository';
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
@@ -32,7 +32,7 @@ export class AcceptSponsorshipRequestUseCase
private readonly sponsorshipRequestRepo: ISponsorshipRequestRepository,
private readonly seasonSponsorshipRepo: ISeasonSponsorshipRepository,
private readonly seasonRepository: ISeasonRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(dto: AcceptSponsorshipRequestDTO): Promise<AcceptSponsorshipRequestResultDTO> {

View File

@@ -16,7 +16,7 @@ import {
EntityNotFoundError,
BusinessRuleViolationError,
} from '../errors/RacingApplicationError';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
export interface ApplyForSponsorshipDTO {
sponsorId: string;
@@ -41,7 +41,7 @@ export class ApplyForSponsorshipUseCase
private readonly sponsorshipRequestRepo: ISponsorshipRequestRepository,
private readonly sponsorshipPricingRepo: ISponsorshipPricingRepository,
private readonly sponsorRepo: ISponsorRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(dto: ApplyForSponsorshipDTO): Promise<ApplyForSponsorshipResultDTO> {

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 '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
export interface ApplyPenaltyCommand {
raceId: string;
@@ -32,7 +32,7 @@ export class ApplyPenaltyUseCase
private readonly protestRepository: IProtestRepository,
private readonly raceRepository: IRaceRepository,
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: ApplyPenaltyCommand): Promise<{ penaltyId: string }> {

View File

@@ -1,4 +1,4 @@
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';
import type {
TeamMembership,
@@ -13,7 +13,7 @@ export class ApproveTeamJoinRequestUseCase
implements AsyncUseCase<ApproveTeamJoinRequestCommandDTO, void> {
constructor(
private readonly membershipRepository: ITeamMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: ApproveTeamJoinRequestCommandDTO): Promise<void> {

View File

@@ -1,6 +1,6 @@
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Use Case: CancelRaceUseCase
@@ -19,7 +19,7 @@ export class CancelRaceUseCase
implements AsyncUseCase<CancelRaceCommandDTO, void> {
constructor(
private readonly raceRepository: IRaceRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: CancelRaceCommandDTO): Promise<void> {

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 '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Use Case: CompleteRaceUseCase
@@ -31,7 +31,7 @@ export class CompleteRaceUseCase
private readonly resultRepository: IResultRepository,
private readonly standingRepository: IStandingRepository,
private readonly driverRatingProvider: DriverRatingProvider,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: CompleteRaceCommandDTO): Promise<void> {

View File

@@ -8,7 +8,7 @@ import { Standing } from '../../domain/entities/Standing';
import { RaceResultGenerator } from '../utils/RaceResultGenerator';
import { RatingUpdateService } from '@gridpilot/identity/domain/services/RatingUpdateService';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Enhanced CompleteRaceUseCase that includes rating updates
@@ -26,7 +26,7 @@ export class CompleteRaceUseCaseWithRatings
private readonly standingRepository: IStandingRepository,
private readonly driverRatingProvider: DriverRatingProvider,
private readonly ratingUpdateService: RatingUpdateService,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: CompleteRaceCommandDTO): Promise<void> {

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 '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
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 { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import type {
IAllRacesPagePresenter,
AllRacesPageResultDTO,
@@ -15,7 +15,7 @@ export class GetAllRacesPageDataUseCase
constructor(
private readonly raceRepository: IRaceRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(_input: void, presenter: IAllRacesPagePresenter): Promise<void> {

View File

@@ -6,7 +6,7 @@ import type {
} from '../presenters/IAllTeamsPresenter';
import type { UseCase } from '@gridpilot/shared/application';
import type { Team } from '../../domain/entities/Team';
import { ILogger } from '../../../shared/src/logging/ILogger';
import { Logger } from "@gridpilot/core/shared/application";
/**
* Use Case for retrieving all teams.
@@ -18,7 +18,7 @@ export class GetAllTeamsUseCase
constructor(
private readonly teamRepository: ITeamRepository,
private readonly teamMembershipRepository: ITeamMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(_input: void, presenter: IAllTeamsPresenter): Promise<void> {

View File

@@ -6,7 +6,7 @@ import type {
DriverTeamViewModel,
} from '../presenters/IDriverTeamPresenter';
import type { UseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Use Case for retrieving a driver's team.
@@ -18,7 +18,7 @@ export class GetDriverTeamUseCase
constructor(
private readonly teamRepository: ITeamRepository,
private readonly membershipRepository: ITeamMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
// Kept for backward compatibility; callers must pass their own presenter.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public readonly presenter: IDriverTeamPresenter,

View File

@@ -12,7 +12,7 @@ import type { SponsorableEntityType } from '../../domain/entities/SponsorshipReq
import type { SponsorshipTier } from '../../domain/entities/SeasonSponsorship';
import type { IEntitySponsorshipPricingPresenter } from '../presenters/IEntitySponsorshipPricingPresenter';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
export interface GetEntitySponsorshipPricingDTO {
entityType: SponsorableEntityType;
@@ -47,7 +47,7 @@ export class GetEntitySponsorshipPricingUseCase
private readonly sponsorshipRequestRepo: ISponsorshipRequestRepository,
private readonly seasonSponsorshipRepo: ISeasonSponsorshipRepository,
private readonly presenter: IEntitySponsorshipPricingPresenter,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(dto: GetEntitySponsorshipPricingDTO): Promise<void> {

View File

@@ -9,7 +9,7 @@ import type { IResultRepository } from '../../domain/repositories/IRaceRepositor
import type { DriverRatingProvider } from '../ports/DriverRatingProvider';
import type { ILeagueStatsPresenter } from '../presenters/ILeagueStatsPresenter';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import { ILogger } from '../../../shared/src/logging/ILogger';
import { Logger } from "@gridpilot/core/shared/application";
import {
AverageStrengthOfFieldCalculator,
type StrengthOfFieldCalculator,
@@ -32,7 +32,7 @@ export class GetLeagueStatsUseCase
private readonly resultRepository: IResultRepository,
private readonly driverRatingProvider: DriverRatingProvider,
public readonly presenter: ILeagueStatsPresenter,
private readonly logger: ILogger,
private readonly logger: Logger,
sofCalculator?: StrengthOfFieldCalculator,
) {
this.sofCalculator = sofCalculator ?? new AverageStrengthOfFieldCalculator();

View File

@@ -7,7 +7,7 @@ import type {
TeamJoinRequestsViewModel,
} from '../presenters/ITeamJoinRequestsPresenter';
import type { UseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Use Case for retrieving team join requests.
@@ -20,7 +20,7 @@ export class GetTeamJoinRequestsUseCase
private readonly membershipRepository: ITeamMembershipRepository,
private readonly driverRepository: IDriverRepository,
private readonly imageService: IImageServicePort,
private readonly logger: ILogger,
private readonly logger: Logger,
// Kept for backward compatibility; callers must pass their own presenter.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public readonly presenter: ITeamJoinRequestsPresenter,

View File

@@ -7,7 +7,7 @@ import type {
TeamMembersViewModel,
} from '../presenters/ITeamMembersPresenter';
import type { UseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
/**
* Use Case for retrieving team members.
@@ -20,7 +20,7 @@ export class GetTeamMembersUseCase
private readonly membershipRepository: ITeamMembershipRepository,
private readonly driverRepository: IDriverRepository,
private readonly imageService: IImageServicePort,
private readonly logger: ILogger,
private readonly logger: Logger,
// Kept for backward compatibility; callers must pass their own presenter.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public readonly presenter: ITeamMembersPresenter,

View File

@@ -4,7 +4,7 @@ import type { IResultRepository } from '../../domain/repositories/IResultReposit
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
import type { IStandingRepository } from '../../domain/repositories/IStandingRepository';
import { Result } from '../../domain/entities/Result';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { AsyncUseCase, Logger } from '@gridpilot/shared/application';
import {
BusinessRuleViolationError,
EntityNotFoundError,
@@ -13,7 +13,6 @@ import type {
IImportRaceResultsPresenter,
ImportRaceResultsSummaryViewModel,
} from '../presenters/IImportRaceResultsPresenter';
import type { ILogger } from '../../../shared/src/logging/ILogger';
export interface ImportRaceResultDTO {
id: string;
@@ -40,7 +39,7 @@ export class ImportRaceResultsUseCase
private readonly driverRepository: IDriverRepository,
private readonly standingRepository: IStandingRepository,
public readonly presenter: IImportRaceResultsPresenter,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(params: ImportRaceResultsParams): Promise<void> {

View File

@@ -1,4 +1,4 @@
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import type {
ILeagueMembershipRepository,
} from '@gridpilot/racing/domain/repositories/ILeagueMembershipRepository';
@@ -14,7 +14,7 @@ import { BusinessRuleViolationError } from '../errors/RacingApplicationError';
export class JoinLeagueUseCase implements AsyncUseCase<JoinLeagueCommandDTO, LeagueMembership> {
constructor(
private readonly membershipRepository: ILeagueMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
/**

View File

@@ -7,7 +7,7 @@ import type {
} from '../../domain/types/TeamMembership';
import type { JoinTeamCommandDTO } from '../dto/TeamCommandAndQueryDTO';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import {
BusinessRuleViolationError,
EntityNotFoundError,
@@ -17,7 +17,7 @@ export class JoinTeamUseCase implements AsyncUseCase<JoinTeamCommandDTO, void> {
constructor(
private readonly teamRepository: ITeamRepository,
private readonly membershipRepository: ITeamMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: JoinTeamCommandDTO): Promise<void> {

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 '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
export interface QuickPenaltyCommand {
raceId: string;
@@ -28,7 +28,7 @@ export class QuickPenaltyUseCase
private readonly penaltyRepository: IPenaltyRepository,
private readonly raceRepository: IRaceRepository,
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(command: QuickPenaltyCommand): Promise<{ penaltyId: string }> {

View File

@@ -3,7 +3,7 @@ import type { ILeagueMembershipRepository } from '@gridpilot/racing/domain/repos
import { RaceRegistration } from '@gridpilot/racing/domain/entities/RaceRegistration';
import type { RegisterForRaceCommandDTO } from '../dto/RegisterForRaceCommandDTO';
import type { AsyncUseCase } from '@gridpilot/shared/application';
import { ILogger } from '@gridpilot/shared/logging/ILogger';
import { Logger } from '@gridpilot/shared/logging/Logger';
import {
BusinessRuleViolationError,
PermissionDeniedError,
@@ -15,7 +15,7 @@ export class RegisterForRaceUseCase
constructor(
private readonly registrationRepository: IRaceRegistrationRepository,
private readonly membershipRepository: ILeagueMembershipRepository,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
/**

View File

@@ -1,4 +1,4 @@
export interface ILogger {
export interface Logger {
debug(message: string, context?: Record<string, any>): void;
info(message: string, context?: Record<string, any>): void;
warn(message: string, context?: Record<string, any>): void;

View File

@@ -1,3 +1,4 @@
export * from './UseCase';
export * from './AsyncUseCase';
export * from './Service';
export * from './Service';
export * from './Logger';

View File

@@ -1,6 +0,0 @@
export interface ILogger {
debug(message: string, ...args: any[]): void;
info(message: string, ...args: any[]): void;
warn(message: string, ...args: any[]): void;
error(message: string, ...args: any[]): void;
}

View File

@@ -1,69 +0,0 @@
import { vi } from 'vitest';
import { ConsoleLogger } from '../../../logging/ConsoleLogger'; // Assuming ConsoleLogger is here
describe('ConsoleLogger', () => {
let logger: ConsoleLogger;
let consoleDebugSpy: vi.SpyInstance;
let consoleInfoSpy: vi.SpyInstance;
let consoleWarnSpy: vi.SpyInstance;
let consoleErrorSpy: vi.SpyInstance;
let consoleLogSpy: vi.SpyInstance;
beforeEach(() => {
logger = new ConsoleLogger();
consoleDebugSpy = vi.spyOn(console, 'debug').mockImplementation(() => {});
consoleInfoSpy = vi.spyOn(console, 'info').mockImplementation(() => {});
consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
});
afterEach(() => {
consoleDebugSpy.mockRestore();
consoleInfoSpy.mockRestore();
consoleWarnSpy.mockRestore();
consoleErrorSpy.mockRestore();
consoleLogSpy.mockRestore();
});
it('should call console.debug with the correct arguments when debug is called', () => {
const message = 'Debug message';
const context = { key: 'value' };
logger.debug(message, context);
expect(consoleDebugSpy).toHaveBeenCalledTimes(1);
expect(consoleDebugSpy).toHaveBeenCalledWith(message, context);
});
it('should call console.info with the correct arguments when info is called', () => {
const message = 'Info message';
const context = { key: 'value' };
logger.info(message, context);
expect(consoleInfoSpy).toHaveBeenCalledTimes(1);
expect(consoleInfoSpy).toHaveBeenCalledWith(message, context);
});
it('should call console.warn with the correct arguments when warn is called', () => {
const message = 'Warn message';
const context = { key: 'value' };
logger.warn(message, context);
expect(consoleWarnSpy).toHaveBeenCalledTimes(1);
expect(consoleWarnSpy).toHaveBeenCalledWith(message, context);
});
it('should call console.error with the correct arguments when error is called', () => {
const message = 'Error message';
const error = new Error('Something went wrong');
const context = { key: 'value' };
logger.error(message, error, context);
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
expect(consoleErrorSpy).toHaveBeenCalledWith(message, error, context);
});
it('should call console.log with the correct arguments when log is called', () => {
const message = 'Log message';
const context = { key: 'value' };
logger.log(message, context);
expect(consoleLogSpy).toHaveBeenCalledTimes(1);
expect(consoleLogSpy).toHaveBeenCalledWith(message, context);
});
});

View File

@@ -1,5 +1,5 @@
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
import type { ISocialGraphRepository } from '../../domain/repositories/ISocialGraphRepository';
import type { CurrentUserSocialDTO } from '../dto/CurrentUserSocialDTO';
import type { FriendDTO } from '../dto/FriendDTO';
@@ -23,7 +23,7 @@ export class GetCurrentUserSocialUseCase
constructor(
private readonly socialGraphRepository: ISocialGraphRepository,
public readonly presenter: ICurrentUserSocialPresenter,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(params: GetCurrentUserSocialParams): Promise<void> {

View File

@@ -6,7 +6,7 @@ import type {
IUserFeedPresenter,
UserFeedViewModel,
} from '../presenters/ISocialPresenters';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { Logger } from '../../../shared/src/logging/Logger';
export interface GetUserFeedParams {
driverId: string;
@@ -18,7 +18,7 @@ export class GetUserFeedUseCase
constructor(
private readonly feedRepository: IFeedRepository,
public readonly presenter: IUserFeedPresenter,
private readonly logger: ILogger,
private readonly logger: Logger,
) {}
async execute(params: GetUserFeedParams): Promise<void> {

View File

@@ -2,7 +2,7 @@ import type { Driver } from '@gridpilot/racing/domain/entities/Driver';
import type { FeedItem } from '@gridpilot/social/domain/types/FeedItem';
import type { IFeedRepository } from '@gridpilot/social/domain/repositories/IFeedRepository';
import type { ISocialGraphRepository } from '@gridpilot/social/domain/repositories/ISocialGraphRepository';
import type { ILogger } from '@gridpilot/shared/logging/ILogger';
import type { Logger } from '@gridpilot/shared/logging/Logger';
export type Friendship = {
driverId: string;
@@ -19,9 +19,9 @@ export class InMemoryFeedRepository implements IFeedRepository {
private readonly feedEvents: FeedItem[];
private readonly friendships: Friendship[];
private readonly driversById: Map<string, Driver>;
private readonly logger: ILogger;
private readonly logger: Logger;
constructor(logger: ILogger, seed: RacingSeedData) {
constructor(logger: Logger, seed: RacingSeedData) {
this.logger = logger;
this.logger.info('InMemoryFeedRepository initialized.');
this.feedEvents = seed.feedEvents;
@@ -76,9 +76,9 @@ export class InMemoryFeedRepository implements IFeedRepository {
export class InMemorySocialGraphRepository implements ISocialGraphRepository {
private readonly friendships: Friendship[];
private readonly driversById: Map<string, Driver>;
private readonly logger: ILogger;
private readonly logger: Logger;
constructor(logger: ILogger, seed: RacingSeedData) {
constructor(logger: Logger, seed: RacingSeedData) {
this.logger = logger;
this.logger.info('InMemorySocialGraphRepository initialized.');
this.friendships = seed.friendships;