refactor dtos to ports

This commit is contained in:
2025-12-19 15:07:53 +01:00
parent 499562c456
commit 8116fe888f
46 changed files with 718 additions and 266 deletions

View File

@@ -1,5 +1,3 @@
import type { LeagueVisibilityInput } from '../../dtos/LeagueVisibilityInput';
export interface CreateLeagueWithSeasonAndScoringInputPort {
name: string;
description?: string;
@@ -8,7 +6,7 @@ export interface CreateLeagueWithSeasonAndScoringInputPort {
* - 'ranked' (or legacy 'public'): Competitive, public, affects ratings. Requires min 10 drivers.
* - 'unranked' (or legacy 'private'): Casual with friends, no rating impact.
*/
visibility: LeagueVisibilityInput;
visibility: 'ranked' | 'unranked' | 'public' | 'private';
ownerId: string;
gameId: string;
maxDrivers?: number;

View File

@@ -1,10 +1,14 @@
import { ProtestIncident } from "@/racing/domain/entities/ProtestIncident";
export interface FileProtestInputPort {
raceId: string;
protestingDriverId: string;
accusedDriverId: string;
incident: ProtestIncident;
incident: {
sessionType: string;
lapNumber: number;
cornerNumber?: number;
description: string;
severity: 'minor' | 'major' | 'severe';
};
comment?: string;
proofVideoUrl?: string;
}

View File

@@ -1,6 +1,4 @@
import type { SponsorableEntityType } from '../../../domain/entities/SponsorshipRequest';
export interface GetEntitySponsorshipPricingInputPort {
entityType: SponsorableEntityType;
entityType: 'league' | 'team' | 'driver';
entityId: string;
}

View File

@@ -0,0 +1,4 @@
export interface IsDriverRegisteredForRaceInputPort {
raceId: string;
driverId: string;
}

View File

@@ -3,4 +3,6 @@
* - 'ranked' (or legacy 'public'): Competitive, public, affects driver ratings. Min 10 drivers.
* - 'unranked' (or legacy 'private'): Casual with friends, no rating impact.
*/
export type LeagueVisibilityInputPort = 'ranked' | 'unranked' | 'public' | 'private';
export interface LeagueVisibilityInputPort {
visibility: 'ranked' | 'unranked' | 'public' | 'private';
}

View File

@@ -1,8 +1,3 @@
export interface IsDriverRegisteredForRaceInputPort {
raceId: string;
driverId: string;
}
export interface GetRaceRegistrationsInputPort {
raceId: string;
}

View File

@@ -1,7 +1,8 @@
import type { Money } from '../../domain/value-objects/Money';
export interface RefundPaymentInputPort {
originalTransactionId: string;
amount: Money;
amount: {
value: number;
currency: string;
};
reason: string;
}

View File

@@ -1,7 +1,10 @@
import type { Team } from '../../../domain/entities/Team';
export interface UpdateTeamInputPort {
teamId: string;
updates: Partial<Pick<Team, 'name' | 'tag' | 'description' | 'leagues'>>;
updates: {
name?: string;
tag?: string;
description?: string;
leagues?: string[];
};
updatedBy: string;
}

View File

@@ -1,8 +1,16 @@
import type { ChampionshipStandingsRowOutputPort } from './ChampionshipStandingsRowOutputPort';
export interface ChampionshipStandingsOutputPort {
seasonId: string;
championshipId: string;
championshipName: string;
rows: ChampionshipStandingsRowOutputPort[];
rows: {
participant: {
id: string;
type: 'driver' | 'team';
name: string;
};
position: number;
totalPoints: number;
resultsCounted: number;
resultsDropped: number;
}[];
}

View File

@@ -1,7 +1,9 @@
import type { ParticipantRef } from '@core/racing/domain/types/ParticipantRef';
export interface ChampionshipStandingsRowOutputPort {
participant: ParticipantRef;
participant: {
id: string;
type: 'driver' | 'team';
name: string;
};
position: number;
totalPoints: number;
resultsCounted: number;

View File

@@ -1,5 +1,11 @@
import type { Team } from '../../../domain/entities/Team';
export interface CreateTeamOutputPort {
team: Team;
team: {
id: string;
name: string;
tag: string;
description: string;
ownerId: string;
leagues: string[];
createdAt: Date;
};
}

View File

@@ -0,0 +1,4 @@
export interface DriverOutputPort {
id: string;
name: string;
}

View File

@@ -1,3 +1,11 @@
import type { Team } from '../../../domain/entities/Team';
export type GetAllTeamsOutputPort = Team[];
export interface GetAllTeamsOutputPort {
teams: Array<{
id: string;
name: string;
tag: string;
description: string;
ownerId: string;
leagues: string[];
createdAt: Date;
}>;
}

View File

@@ -1,7 +1,17 @@
import type { Team } from '../../../domain/entities/Team';
import type { TeamMembership } from '../../../domain/types/TeamMembership';
export interface GetDriverTeamOutputPort {
team: Team;
membership: TeamMembership;
team: {
id: string;
name: string;
tag: string;
description: string;
ownerId: string;
leagues: string[];
createdAt: Date;
};
membership: {
driverId: string;
teamId: string;
role: 'member' | 'captain' | 'admin';
joinedAt: Date;
};
}

View File

@@ -1,11 +1,28 @@
import type { SponsorableEntityType } from '../../../domain/entities/SponsorshipRequest';
import type { SponsorshipSlotDTO } from './SponsorshipSlotOutputPort';
export interface GetEntitySponsorshipPricingOutputPort {
entityType: SponsorableEntityType;
entityType: 'league' | 'team' | 'driver';
entityId: string;
acceptingApplications: boolean;
customRequirements?: string;
mainSlot?: SponsorshipSlotDTO;
secondarySlot?: SponsorshipSlotDTO;
mainSlot?: {
tier: string;
price: number;
currency: string;
formattedPrice: string;
benefits: string[];
available: boolean;
maxSlots: number;
filledSlots: number;
pendingRequests: number;
};
secondarySlot?: {
tier: string;
price: number;
currency: string;
formattedPrice: string;
benefits: string[];
available: boolean;
maxSlots: number;
filledSlots: number;
pendingRequests: number;
};
}

View File

@@ -1,6 +1,10 @@
import type { LeagueMembership } from '../../../domain/entities/LeagueMembership';
export interface GetLeagueMembershipsOutputPort {
memberships: LeagueMembership[];
memberships: Array<{
id: string;
leagueId: string;
driverId: string;
role: 'member' | 'admin' | 'owner';
joinedAt: Date;
}>;
drivers: { id: string; name: string }[];
}

View File

@@ -1,18 +1,20 @@
import type { ProtestOutputPort } from './ProtestOutputPort';
export interface RaceOutputPort {
id: string;
name: string;
date: string;
}
export interface DriverOutputPort {
id: string;
name: string;
}
export interface GetLeagueProtestsOutputPort {
protests: ProtestOutputPort[];
races: RaceOutputPort[];
drivers: DriverOutputPort[];
protests: Array<{
id: string;
raceId: string;
protestingDriverId: string;
accusedDriverId: string;
submittedAt: Date;
description: string;
status: string;
}>;
races: Array<{
id: string;
name: string;
date: string;
}>;
drivers: Array<{
id: string;
name: string;
}>;
}

View File

@@ -1,7 +1,17 @@
import type { Team } from '../../../domain/entities/Team';
import type { TeamMembership } from '../../../domain/types/TeamMembership';
export interface GetTeamDetailsOutputPort {
team: Team;
membership: TeamMembership | null;
team: {
id: string;
name: string;
tag: string;
description: string;
ownerId: string;
leagues: string[];
createdAt: Date;
};
membership: {
driverId: string;
teamId: string;
role: 'member' | 'captain' | 'admin';
joinedAt: Date;
} | null;
}

View File

@@ -1,18 +1,11 @@
import type { Weekday } from '../../../domain/types/Weekday';
export interface LeagueScheduleOutputPort {
seasonStartDate: string;
raceStartTime: string;
timezoneId: string;
recurrenceStrategy: 'weekly' | 'everyNWeeks' | 'monthlyNthWeekday';
intervalWeeks?: number;
weekdays?: Weekday[];
weekdays?: ('monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday')[];
monthlyOrdinal?: 1 | 2 | 3 | 4;
monthlyWeekday?: Weekday;
monthlyWeekday?: 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
plannedRounds: number;
}
export interface LeagueSchedulePreviewOutputPort {
rounds: Array<{ roundNumber: number; scheduledAt: string; timezoneId: string }>;
summary: string;
}

View File

@@ -0,0 +1,4 @@
export interface LeagueSchedulePreviewOutputPort {
rounds: Array<{ roundNumber: number; scheduledAt: string; timezoneId: string }>;
summary: string;
}

View File

@@ -0,0 +1,9 @@
export interface LeagueScoringChampionshipOutputPort {
id: string;
name: string;
type: 'driver' | 'team' | 'nations' | 'trophy';
sessionTypes: string[];
pointsPreview: Array<{ sessionType: string; position: number; points: number }>;
bonusSummary: string[];
dropPolicyDescription: string;
}

View File

@@ -1,13 +1,3 @@
export interface LeagueScoringChampionshipOutputPort {
id: string;
name: string;
type: 'driver' | 'team' | 'nations' | 'trophy';
sessionTypes: string[];
pointsPreview: Array<{ sessionType: string; position: number; points: number }>;
bonusSummary: string[];
dropPolicyDescription: string;
}
export interface LeagueScoringConfigOutputPort {
leagueId: string;
seasonId: string;
@@ -16,5 +6,13 @@ export interface LeagueScoringConfigOutputPort {
scoringPresetId?: string;
scoringPresetName?: string;
dropPolicySummary: string;
championships: LeagueScoringChampionshipOutputPort[];
championships: Array<{
id: string;
name: string;
type: 'driver' | 'team' | 'nations' | 'trophy';
sessionTypes: string[];
pointsPreview: Array<{ sessionType: string; position: number; points: number }>;
bonusSummary: string[];
dropPolicyDescription: string;
}>;
}

View File

@@ -1,14 +1,8 @@
export type LeagueScoringPresetPrimaryChampionshipType =
| 'driver'
| 'team'
| 'nations'
| 'trophy';
export interface LeagueScoringPresetOutputPort {
id: string;
name: string;
description: string;
primaryChampionshipType: LeagueScoringPresetPrimaryChampionshipType;
primaryChampionshipType: 'driver' | 'team' | 'nations' | 'trophy';
sessionSummary: string;
bonusSummary: string;
dropPolicySummary: string;

View File

@@ -1,13 +1,3 @@
export interface LeagueSummaryScoringOutputPort {
gameId: string;
gameName: string;
primaryChampionshipType: 'driver' | 'team' | 'nations' | 'trophy';
scoringPresetId: string;
scoringPresetName: string;
dropPolicySummary: string;
scoringPatternSummary: string;
}
export interface LeagueSummaryOutputPort {
id: string;
name: string;
@@ -21,5 +11,13 @@ export interface LeagueSummaryOutputPort {
structureSummary?: string;
scoringPatternSummary?: string;
timingSummary?: string;
scoring?: LeagueSummaryScoringOutputPort;
scoring?: {
gameId: string;
gameName: string;
primaryChampionshipType: 'driver' | 'team' | 'nations' | 'trophy';
scoringPresetId: string;
scoringPresetName: string;
dropPolicySummary: string;
scoringPatternSummary: string;
};
}

View File

@@ -0,0 +1,9 @@
export interface LeagueSummaryScoringOutputPort {
gameId: string;
gameName: string;
primaryChampionshipType: 'driver' | 'team' | 'nations' | 'trophy';
scoringPresetId: string;
scoringPresetName: string;
dropPolicySummary: string;
scoringPatternSummary: string;
}

View File

@@ -0,0 +1,5 @@
export interface RaceOutputPort {
id: string;
name: string;
date: string;
}

View File

@@ -1,7 +1,5 @@
import type { SponsorshipTier } from '../../../domain/entities/SeasonSponsorship';
export interface SponsorshipSlotOutputPort {
tier: SponsorshipTier;
tier: string;
price: number;
currency: string;
formattedPrice: string;