wip
This commit is contained in:
50
packages/racing/domain/repositories/IDriverRepository.ts
Normal file
50
packages/racing/domain/repositories/IDriverRepository.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Application Port: IDriverRepository
|
||||
*
|
||||
* Repository interface for Driver entity CRUD operations.
|
||||
* Defines async methods using domain entities as types.
|
||||
*/
|
||||
|
||||
import type { Driver } from '../entities/Driver';
|
||||
|
||||
export interface IDriverRepository {
|
||||
/**
|
||||
* Find a driver by ID
|
||||
*/
|
||||
findById(id: string): Promise<Driver | null>;
|
||||
|
||||
/**
|
||||
* Find a driver by iRacing ID
|
||||
*/
|
||||
findByIRacingId(iracingId: string): Promise<Driver | null>;
|
||||
|
||||
/**
|
||||
* Find all drivers
|
||||
*/
|
||||
findAll(): Promise<Driver[]>;
|
||||
|
||||
/**
|
||||
* Create a new driver
|
||||
*/
|
||||
create(driver: Driver): Promise<Driver>;
|
||||
|
||||
/**
|
||||
* Update an existing driver
|
||||
*/
|
||||
update(driver: Driver): Promise<Driver>;
|
||||
|
||||
/**
|
||||
* Delete a driver by ID
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a driver exists by ID
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Check if an iRacing ID is already registered
|
||||
*/
|
||||
existsByIRacingId(iracingId: string): Promise<boolean>;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Application Port: ILeagueMembershipRepository
|
||||
*
|
||||
* Repository interface for league membership and join request operations.
|
||||
* This defines the persistence boundary for membership-related domain entities.
|
||||
*/
|
||||
|
||||
import type {
|
||||
LeagueMembership,
|
||||
JoinRequest,
|
||||
} from '../entities/LeagueMembership';
|
||||
|
||||
export interface ILeagueMembershipRepository {
|
||||
/**
|
||||
* Get membership for a driver in a league, or null if none exists.
|
||||
*/
|
||||
getMembership(leagueId: string, driverId: string): Promise<LeagueMembership | null>;
|
||||
|
||||
/**
|
||||
* Get all active members for a league.
|
||||
*/
|
||||
getLeagueMembers(leagueId: string): Promise<LeagueMembership[]>;
|
||||
|
||||
/**
|
||||
* Get all join requests for a league.
|
||||
*/
|
||||
getJoinRequests(leagueId: string): Promise<JoinRequest[]>;
|
||||
|
||||
/**
|
||||
* Persist a membership (create or update).
|
||||
*/
|
||||
saveMembership(membership: LeagueMembership): Promise<LeagueMembership>;
|
||||
|
||||
/**
|
||||
* Remove a membership for a driver in a league.
|
||||
*/
|
||||
removeMembership(leagueId: string, driverId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Persist a join request (create or update).
|
||||
*/
|
||||
saveJoinRequest(request: JoinRequest): Promise<JoinRequest>;
|
||||
|
||||
/**
|
||||
* Remove a join request by its ID.
|
||||
*/
|
||||
removeJoinRequest(requestId: string): Promise<void>;
|
||||
}
|
||||
50
packages/racing/domain/repositories/ILeagueRepository.ts
Normal file
50
packages/racing/domain/repositories/ILeagueRepository.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Application Port: ILeagueRepository
|
||||
*
|
||||
* Repository interface for League entity CRUD operations.
|
||||
* Defines async methods using domain entities as types.
|
||||
*/
|
||||
|
||||
import type { League } from '../entities/League';
|
||||
|
||||
export interface ILeagueRepository {
|
||||
/**
|
||||
* Find a league by ID
|
||||
*/
|
||||
findById(id: string): Promise<League | null>;
|
||||
|
||||
/**
|
||||
* Find all leagues
|
||||
*/
|
||||
findAll(): Promise<League[]>;
|
||||
|
||||
/**
|
||||
* Find leagues by owner ID
|
||||
*/
|
||||
findByOwnerId(ownerId: string): Promise<League[]>;
|
||||
|
||||
/**
|
||||
* Create a new league
|
||||
*/
|
||||
create(league: League): Promise<League>;
|
||||
|
||||
/**
|
||||
* Update an existing league
|
||||
*/
|
||||
update(league: League): Promise<League>;
|
||||
|
||||
/**
|
||||
* Delete a league by ID
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a league exists by ID
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Search leagues by name
|
||||
*/
|
||||
searchByName(query: string): Promise<League[]>;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Application Port: IRaceRegistrationRepository
|
||||
*
|
||||
* Repository interface for race registration operations.
|
||||
* This defines the persistence boundary for RaceRegistration entities.
|
||||
*/
|
||||
|
||||
import type { RaceRegistration } from '../entities/RaceRegistration';
|
||||
|
||||
export interface IRaceRegistrationRepository {
|
||||
/**
|
||||
* Check if a driver is registered for a race.
|
||||
*/
|
||||
isRegistered(raceId: string, driverId: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Get all registered driver IDs for a race.
|
||||
*/
|
||||
getRegisteredDrivers(raceId: string): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* Get the number of registrations for a race.
|
||||
*/
|
||||
getRegistrationCount(raceId: string): Promise<number>;
|
||||
|
||||
/**
|
||||
* Register a driver for a race.
|
||||
*/
|
||||
register(registration: RaceRegistration): Promise<void>;
|
||||
|
||||
/**
|
||||
* Withdraw a driver from a race.
|
||||
*/
|
||||
withdraw(raceId: string, driverId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Get all race IDs a driver is registered for.
|
||||
*/
|
||||
getDriverRegistrations(driverId: string): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* Clear all registrations for a race (e.g., when race is cancelled).
|
||||
*/
|
||||
clearRaceRegistrations(raceId: string): Promise<void>;
|
||||
}
|
||||
65
packages/racing/domain/repositories/IRaceRepository.ts
Normal file
65
packages/racing/domain/repositories/IRaceRepository.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Application Port: IRaceRepository
|
||||
*
|
||||
* Repository interface for Race entity CRUD operations.
|
||||
* Defines async methods using domain entities as types.
|
||||
*/
|
||||
|
||||
import type { Race, RaceStatus } from '../entities/Race';
|
||||
|
||||
export interface IRaceRepository {
|
||||
/**
|
||||
* Find a race by ID
|
||||
*/
|
||||
findById(id: string): Promise<Race | null>;
|
||||
|
||||
/**
|
||||
* Find all races
|
||||
*/
|
||||
findAll(): Promise<Race[]>;
|
||||
|
||||
/**
|
||||
* Find races by league ID
|
||||
*/
|
||||
findByLeagueId(leagueId: string): Promise<Race[]>;
|
||||
|
||||
/**
|
||||
* Find upcoming races for a league
|
||||
*/
|
||||
findUpcomingByLeagueId(leagueId: string): Promise<Race[]>;
|
||||
|
||||
/**
|
||||
* Find completed races for a league
|
||||
*/
|
||||
findCompletedByLeagueId(leagueId: string): Promise<Race[]>;
|
||||
|
||||
/**
|
||||
* Find races by status
|
||||
*/
|
||||
findByStatus(status: RaceStatus): Promise<Race[]>;
|
||||
|
||||
/**
|
||||
* Find races scheduled within a date range
|
||||
*/
|
||||
findByDateRange(startDate: Date, endDate: Date): Promise<Race[]>;
|
||||
|
||||
/**
|
||||
* Create a new race
|
||||
*/
|
||||
create(race: Race): Promise<Race>;
|
||||
|
||||
/**
|
||||
* Update an existing race
|
||||
*/
|
||||
update(race: Race): Promise<Race>;
|
||||
|
||||
/**
|
||||
* Delete a race by ID
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a race exists by ID
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
70
packages/racing/domain/repositories/IResultRepository.ts
Normal file
70
packages/racing/domain/repositories/IResultRepository.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Application Port: IResultRepository
|
||||
*
|
||||
* Repository interface for Result entity CRUD operations.
|
||||
* Defines async methods using domain entities as types.
|
||||
*/
|
||||
|
||||
import type { Result } from '../entities/Result';
|
||||
|
||||
export interface IResultRepository {
|
||||
/**
|
||||
* Find a result by ID
|
||||
*/
|
||||
findById(id: string): Promise<Result | null>;
|
||||
|
||||
/**
|
||||
* Find all results
|
||||
*/
|
||||
findAll(): Promise<Result[]>;
|
||||
|
||||
/**
|
||||
* Find results by race ID
|
||||
*/
|
||||
findByRaceId(raceId: string): Promise<Result[]>;
|
||||
|
||||
/**
|
||||
* Find results by driver ID
|
||||
*/
|
||||
findByDriverId(driverId: string): Promise<Result[]>;
|
||||
|
||||
/**
|
||||
* Find results by driver ID for a specific league
|
||||
*/
|
||||
findByDriverIdAndLeagueId(driverId: string, leagueId: string): Promise<Result[]>;
|
||||
|
||||
/**
|
||||
* Create a new result
|
||||
*/
|
||||
create(result: Result): Promise<Result>;
|
||||
|
||||
/**
|
||||
* Create multiple results
|
||||
*/
|
||||
createMany(results: Result[]): Promise<Result[]>;
|
||||
|
||||
/**
|
||||
* Update an existing result
|
||||
*/
|
||||
update(result: Result): Promise<Result>;
|
||||
|
||||
/**
|
||||
* Delete a result by ID
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Delete all results for a race
|
||||
*/
|
||||
deleteByRaceId(raceId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a result exists by ID
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Check if results exist for a race
|
||||
*/
|
||||
existsByRaceId(raceId: string): Promise<boolean>;
|
||||
}
|
||||
55
packages/racing/domain/repositories/IStandingRepository.ts
Normal file
55
packages/racing/domain/repositories/IStandingRepository.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Application Port: IStandingRepository
|
||||
*
|
||||
* Repository interface for Standing entity operations.
|
||||
* Includes methods for calculating and retrieving standings.
|
||||
*/
|
||||
|
||||
import type { Standing } from '../entities/Standing';
|
||||
|
||||
export interface IStandingRepository {
|
||||
/**
|
||||
* Find standings by league ID (sorted by position)
|
||||
*/
|
||||
findByLeagueId(leagueId: string): Promise<Standing[]>;
|
||||
|
||||
/**
|
||||
* Find standing for a specific driver in a league
|
||||
*/
|
||||
findByDriverIdAndLeagueId(driverId: string, leagueId: string): Promise<Standing | null>;
|
||||
|
||||
/**
|
||||
* Find all standings
|
||||
*/
|
||||
findAll(): Promise<Standing[]>;
|
||||
|
||||
/**
|
||||
* Create or update a standing
|
||||
*/
|
||||
save(standing: Standing): Promise<Standing>;
|
||||
|
||||
/**
|
||||
* Create or update multiple standings
|
||||
*/
|
||||
saveMany(standings: Standing[]): Promise<Standing[]>;
|
||||
|
||||
/**
|
||||
* Delete a standing
|
||||
*/
|
||||
delete(leagueId: string, driverId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Delete all standings for a league
|
||||
*/
|
||||
deleteByLeagueId(leagueId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a standing exists
|
||||
*/
|
||||
exists(leagueId: string, driverId: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Recalculate standings for a league based on race results
|
||||
*/
|
||||
recalculate(leagueId: string): Promise<Standing[]>;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Application Port: ITeamMembershipRepository
|
||||
*
|
||||
* Repository interface for team membership and join request operations.
|
||||
* This defines the persistence boundary for team membership-related entities.
|
||||
*/
|
||||
|
||||
import type {
|
||||
TeamMembership,
|
||||
TeamJoinRequest,
|
||||
} from '../entities/Team';
|
||||
|
||||
export interface ITeamMembershipRepository {
|
||||
/**
|
||||
* Get membership for a driver in a team, or null if none exists.
|
||||
*/
|
||||
getMembership(teamId: string, driverId: string): Promise<TeamMembership | null>;
|
||||
|
||||
/**
|
||||
* Get the active team membership for a driver (if any).
|
||||
*/
|
||||
getActiveMembershipForDriver(driverId: string): Promise<TeamMembership | null>;
|
||||
|
||||
/**
|
||||
* Get all active members for a team.
|
||||
*/
|
||||
getTeamMembers(teamId: string): Promise<TeamMembership[]>;
|
||||
|
||||
/**
|
||||
* Persist a membership (create or update).
|
||||
*/
|
||||
saveMembership(membership: TeamMembership): Promise<TeamMembership>;
|
||||
|
||||
/**
|
||||
* Remove a membership for a driver in a team.
|
||||
*/
|
||||
removeMembership(teamId: string, driverId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Get all join requests for a team.
|
||||
*/
|
||||
getJoinRequests(teamId: string): Promise<TeamJoinRequest[]>;
|
||||
|
||||
/**
|
||||
* Persist a join request (create or update).
|
||||
*/
|
||||
saveJoinRequest(request: TeamJoinRequest): Promise<TeamJoinRequest>;
|
||||
|
||||
/**
|
||||
* Remove a join request by its ID.
|
||||
*/
|
||||
removeJoinRequest(requestId: string): Promise<void>;
|
||||
}
|
||||
45
packages/racing/domain/repositories/ITeamRepository.ts
Normal file
45
packages/racing/domain/repositories/ITeamRepository.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Application Port: ITeamRepository
|
||||
*
|
||||
* Repository interface for Team aggregate operations.
|
||||
* This defines the persistence boundary for Team entities.
|
||||
*/
|
||||
|
||||
import type { Team } from '../entities/Team';
|
||||
|
||||
export interface ITeamRepository {
|
||||
/**
|
||||
* Find a team by ID.
|
||||
*/
|
||||
findById(id: string): Promise<Team | null>;
|
||||
|
||||
/**
|
||||
* Find all teams.
|
||||
*/
|
||||
findAll(): Promise<Team[]>;
|
||||
|
||||
/**
|
||||
* Find teams by league ID.
|
||||
*/
|
||||
findByLeagueId(leagueId: string): Promise<Team[]>;
|
||||
|
||||
/**
|
||||
* Create a new team.
|
||||
*/
|
||||
create(team: Team): Promise<Team>;
|
||||
|
||||
/**
|
||||
* Update an existing team.
|
||||
*/
|
||||
update(team: Team): Promise<Team>;
|
||||
|
||||
/**
|
||||
* Delete a team by ID.
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a team exists by ID.
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
Reference in New Issue
Block a user