rename to core
This commit is contained in:
65
core/racing/domain/repositories/ICarRepository.ts
Normal file
65
core/racing/domain/repositories/ICarRepository.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Application Port: ICarRepository
|
||||
*
|
||||
* Repository interface for Car entity CRUD operations.
|
||||
* Defines async methods using domain entities as types.
|
||||
*/
|
||||
|
||||
import type { Car, CarClass, CarLicense } from '../entities/Car';
|
||||
|
||||
export interface ICarRepository {
|
||||
/**
|
||||
* Find a car by ID
|
||||
*/
|
||||
findById(id: string): Promise<Car | null>;
|
||||
|
||||
/**
|
||||
* Find all cars
|
||||
*/
|
||||
findAll(): Promise<Car[]>;
|
||||
|
||||
/**
|
||||
* Find cars by game ID
|
||||
*/
|
||||
findByGameId(gameId: string): Promise<Car[]>;
|
||||
|
||||
/**
|
||||
* Find cars by class
|
||||
*/
|
||||
findByClass(carClass: CarClass): Promise<Car[]>;
|
||||
|
||||
/**
|
||||
* Find cars by license level
|
||||
*/
|
||||
findByLicense(license: CarLicense): Promise<Car[]>;
|
||||
|
||||
/**
|
||||
* Find cars by manufacturer
|
||||
*/
|
||||
findByManufacturer(manufacturer: string): Promise<Car[]>;
|
||||
|
||||
/**
|
||||
* Search cars by name
|
||||
*/
|
||||
searchByName(query: string): Promise<Car[]>;
|
||||
|
||||
/**
|
||||
* Create a new car
|
||||
*/
|
||||
create(car: Car): Promise<Car>;
|
||||
|
||||
/**
|
||||
* Update an existing car
|
||||
*/
|
||||
update(car: Car): Promise<Car>;
|
||||
|
||||
/**
|
||||
* Delete a car by ID
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a car exists by ID
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { ChampionshipStanding } from '../entities/ChampionshipStanding';
|
||||
|
||||
export interface IChampionshipStandingRepository {
|
||||
findBySeasonAndChampionship(
|
||||
seasonId: string,
|
||||
championshipId: string,
|
||||
): Promise<ChampionshipStanding[]>;
|
||||
|
||||
saveAll(standings: ChampionshipStanding[]): Promise<void>;
|
||||
}
|
||||
50
core/racing/domain/repositories/IDriverRepository.ts
Normal file
50
core/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>;
|
||||
}
|
||||
6
core/racing/domain/repositories/IGameRepository.ts
Normal file
6
core/racing/domain/repositories/IGameRepository.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Game } from '../entities/Game';
|
||||
|
||||
export interface IGameRepository {
|
||||
findById(id: string): Promise<Game | null>;
|
||||
findAll(): Promise<Game[]>;
|
||||
}
|
||||
@@ -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
core/racing/domain/repositories/ILeagueRepository.ts
Normal file
50
core/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,6 @@
|
||||
import type { LeagueScoringConfig } from '../entities/LeagueScoringConfig';
|
||||
|
||||
export interface ILeagueScoringConfigRepository {
|
||||
findBySeasonId(seasonId: string): Promise<LeagueScoringConfig | null>;
|
||||
save(config: LeagueScoringConfig): Promise<LeagueScoringConfig>;
|
||||
}
|
||||
16
core/racing/domain/repositories/ILeagueWalletRepository.ts
Normal file
16
core/racing/domain/repositories/ILeagueWalletRepository.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Repository Interface: ILeagueWalletRepository
|
||||
*
|
||||
* Defines operations for LeagueWallet aggregate persistence
|
||||
*/
|
||||
|
||||
import type { LeagueWallet } from '../entities/LeagueWallet';
|
||||
|
||||
export interface ILeagueWalletRepository {
|
||||
findById(id: string): Promise<LeagueWallet | null>;
|
||||
findByLeagueId(leagueId: string): Promise<LeagueWallet | null>;
|
||||
create(wallet: LeagueWallet): Promise<LeagueWallet>;
|
||||
update(wallet: LeagueWallet): Promise<LeagueWallet>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
28
core/racing/domain/repositories/ILiveryRepository.ts
Normal file
28
core/racing/domain/repositories/ILiveryRepository.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Repository Interface: ILiveryRepository
|
||||
*
|
||||
* Defines operations for livery-related entities
|
||||
*/
|
||||
|
||||
import type { DriverLivery } from '../entities/DriverLivery';
|
||||
import type { LiveryTemplate } from '../entities/LiveryTemplate';
|
||||
|
||||
export interface ILiveryRepository {
|
||||
// DriverLivery operations
|
||||
findDriverLiveryById(id: string): Promise<DriverLivery | null>;
|
||||
findDriverLiveriesByDriverId(driverId: string): Promise<DriverLivery[]>;
|
||||
findDriverLiveryByDriverAndCar(driverId: string, carId: string): Promise<DriverLivery | null>;
|
||||
findDriverLiveriesByGameId(gameId: string): Promise<DriverLivery[]>;
|
||||
findDriverLiveryByDriverAndGame(driverId: string, gameId: string): Promise<DriverLivery[]>;
|
||||
createDriverLivery(livery: DriverLivery): Promise<DriverLivery>;
|
||||
updateDriverLivery(livery: DriverLivery): Promise<DriverLivery>;
|
||||
deleteDriverLivery(id: string): Promise<void>;
|
||||
|
||||
// LiveryTemplate operations
|
||||
findTemplateById(id: string): Promise<LiveryTemplate | null>;
|
||||
findTemplatesBySeasonId(seasonId: string): Promise<LiveryTemplate[]>;
|
||||
findTemplateBySeasonAndCar(seasonId: string, carId: string): Promise<LiveryTemplate | null>;
|
||||
createTemplate(template: LiveryTemplate): Promise<LiveryTemplate>;
|
||||
updateTemplate(template: LiveryTemplate): Promise<LiveryTemplate>;
|
||||
deleteTemplate(id: string): Promise<void>;
|
||||
}
|
||||
54
core/racing/domain/repositories/IPenaltyRepository.ts
Normal file
54
core/racing/domain/repositories/IPenaltyRepository.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Repository Interface: IPenaltyRepository
|
||||
*
|
||||
* Defines the contract for persisting and retrieving Penalty entities.
|
||||
*/
|
||||
|
||||
import type { Penalty } from '../entities/Penalty';
|
||||
|
||||
export interface IPenaltyRepository {
|
||||
/**
|
||||
* Find a penalty by ID
|
||||
*/
|
||||
findById(id: string): Promise<Penalty | null>;
|
||||
|
||||
/**
|
||||
* Find all penalties for a race
|
||||
*/
|
||||
findByRaceId(raceId: string): Promise<Penalty[]>;
|
||||
|
||||
/**
|
||||
* Find all penalties for a specific driver
|
||||
*/
|
||||
findByDriverId(driverId: string): Promise<Penalty[]>;
|
||||
|
||||
/**
|
||||
* Find all penalties related to a specific protest
|
||||
*/
|
||||
findByProtestId(protestId: string): Promise<Penalty[]>;
|
||||
|
||||
/**
|
||||
* Find all pending penalties (not yet applied)
|
||||
*/
|
||||
findPending(): Promise<Penalty[]>;
|
||||
|
||||
/**
|
||||
* Find all penalties issued by a specific steward
|
||||
*/
|
||||
findIssuedBy(stewardId: string): Promise<Penalty[]>;
|
||||
|
||||
/**
|
||||
* Save a new penalty
|
||||
*/
|
||||
create(penalty: Penalty): Promise<void>;
|
||||
|
||||
/**
|
||||
* Update an existing penalty
|
||||
*/
|
||||
update(penalty: Penalty): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a penalty exists
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
19
core/racing/domain/repositories/IPrizeRepository.ts
Normal file
19
core/racing/domain/repositories/IPrizeRepository.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Repository Interface: IPrizeRepository
|
||||
*
|
||||
* Defines operations for Prize entity persistence
|
||||
*/
|
||||
|
||||
import type { Prize, PrizeStatus } from '../entities/Prize';
|
||||
|
||||
export interface IPrizeRepository {
|
||||
findById(id: string): Promise<Prize | null>;
|
||||
findBySeasonId(seasonId: string): Promise<Prize[]>;
|
||||
findByDriverId(driverId: string): Promise<Prize[]>;
|
||||
findByStatus(status: PrizeStatus): Promise<Prize[]>;
|
||||
findBySeasonAndPosition(seasonId: string, position: number): Promise<Prize | null>;
|
||||
create(prize: Prize): Promise<Prize>;
|
||||
update(prize: Prize): Promise<Prize>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
54
core/racing/domain/repositories/IProtestRepository.ts
Normal file
54
core/racing/domain/repositories/IProtestRepository.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Repository Interface: IProtestRepository
|
||||
*
|
||||
* Defines the contract for persisting and retrieving Protest entities.
|
||||
*/
|
||||
|
||||
import type { Protest } from '../entities/Protest';
|
||||
|
||||
export interface IProtestRepository {
|
||||
/**
|
||||
* Find a protest by ID
|
||||
*/
|
||||
findById(id: string): Promise<Protest | null>;
|
||||
|
||||
/**
|
||||
* Find all protests for a race
|
||||
*/
|
||||
findByRaceId(raceId: string): Promise<Protest[]>;
|
||||
|
||||
/**
|
||||
* Find all protests filed by a specific driver
|
||||
*/
|
||||
findByProtestingDriverId(driverId: string): Promise<Protest[]>;
|
||||
|
||||
/**
|
||||
* Find all protests against a specific driver
|
||||
*/
|
||||
findByAccusedDriverId(driverId: string): Promise<Protest[]>;
|
||||
|
||||
/**
|
||||
* Find all pending protests (for steward review queue)
|
||||
*/
|
||||
findPending(): Promise<Protest[]>;
|
||||
|
||||
/**
|
||||
* Find all protests under review by a specific steward
|
||||
*/
|
||||
findUnderReviewBy(stewardId: string): Promise<Protest[]>;
|
||||
|
||||
/**
|
||||
* Save a new protest
|
||||
*/
|
||||
create(protest: Protest): Promise<void>;
|
||||
|
||||
/**
|
||||
* Update an existing protest
|
||||
*/
|
||||
update(protest: Protest): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a protest exists
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
14
core/racing/domain/repositories/IRaceEventRepository.ts
Normal file
14
core/racing/domain/repositories/IRaceEventRepository.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { RaceEvent } from '../entities/RaceEvent';
|
||||
|
||||
export interface IRaceEventRepository {
|
||||
findById(id: string): Promise<RaceEvent | null>;
|
||||
findAll(): Promise<RaceEvent[]>;
|
||||
findBySeasonId(seasonId: string): Promise<RaceEvent[]>;
|
||||
findByLeagueId(leagueId: string): Promise<RaceEvent[]>;
|
||||
findByStatus(status: string): Promise<RaceEvent[]>;
|
||||
findAwaitingStewardingClose(): Promise<RaceEvent[]>;
|
||||
create(raceEvent: RaceEvent): Promise<RaceEvent>;
|
||||
update(raceEvent: RaceEvent): Promise<RaceEvent>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
@@ -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
core/racing/domain/repositories/IRaceRepository.ts
Normal file
65
core/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
core/racing/domain/repositories/IResultRepository.ts
Normal file
70
core/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>;
|
||||
}
|
||||
35
core/racing/domain/repositories/ISeasonRepository.ts
Normal file
35
core/racing/domain/repositories/ISeasonRepository.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { Season } from '../entities/Season';
|
||||
|
||||
export interface ISeasonRepository {
|
||||
findById(id: string): Promise<Season | null>;
|
||||
/**
|
||||
* Backward-compatible alias retained for existing callers.
|
||||
* Prefer listByLeague for new usage.
|
||||
*/
|
||||
findByLeagueId(leagueId: string): Promise<Season[]>;
|
||||
/**
|
||||
* Backward-compatible alias retained for existing callers.
|
||||
* Prefer add for new usage.
|
||||
*/
|
||||
create(season: Season): Promise<Season>;
|
||||
|
||||
/**
|
||||
* Add a new Season aggregate.
|
||||
*/
|
||||
add(season: Season): Promise<void>;
|
||||
|
||||
/**
|
||||
* Persist changes to an existing Season aggregate.
|
||||
*/
|
||||
update(season: Season): Promise<void>;
|
||||
|
||||
/**
|
||||
* List all Seasons for a given League.
|
||||
*/
|
||||
listByLeague(leagueId: string): Promise<Season[]>;
|
||||
|
||||
/**
|
||||
* List Seasons for a League that are currently active.
|
||||
*/
|
||||
listActiveByLeague(leagueId: string): Promise<Season[]>;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Repository Interface: ISeasonSponsorshipRepository
|
||||
*
|
||||
* Defines operations for SeasonSponsorship aggregate persistence
|
||||
*/
|
||||
|
||||
import type { SeasonSponsorship, SponsorshipTier } from '../entities/SeasonSponsorship';
|
||||
|
||||
export interface ISeasonSponsorshipRepository {
|
||||
findById(id: string): Promise<SeasonSponsorship | null>;
|
||||
findBySeasonId(seasonId: string): Promise<SeasonSponsorship[]>;
|
||||
/**
|
||||
* Convenience lookup for aggregating sponsorships at league level.
|
||||
* Implementations should rely on the denormalized leagueId where present,
|
||||
* falling back to joining through Seasons if needed.
|
||||
*/
|
||||
findByLeagueId(leagueId: string): Promise<SeasonSponsorship[]>;
|
||||
findBySponsorId(sponsorId: string): Promise<SeasonSponsorship[]>;
|
||||
findBySeasonAndTier(seasonId: string, tier: SponsorshipTier): Promise<SeasonSponsorship[]>;
|
||||
create(sponsorship: SeasonSponsorship): Promise<SeasonSponsorship>;
|
||||
update(sponsorship: SeasonSponsorship): Promise<SeasonSponsorship>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
13
core/racing/domain/repositories/ISessionRepository.ts
Normal file
13
core/racing/domain/repositories/ISessionRepository.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { Session } from '../entities/Session';
|
||||
|
||||
export interface ISessionRepository {
|
||||
findById(id: string): Promise<Session | null>;
|
||||
findAll(): Promise<Session[]>;
|
||||
findByRaceEventId(raceEventId: string): Promise<Session[]>;
|
||||
findByLeagueId(leagueId: string): Promise<Session[]>;
|
||||
findByStatus(status: string): Promise<Session[]>;
|
||||
create(session: Session): Promise<Session>;
|
||||
update(session: Session): Promise<Session>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
17
core/racing/domain/repositories/ISponsorRepository.ts
Normal file
17
core/racing/domain/repositories/ISponsorRepository.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Repository Interface: ISponsorRepository
|
||||
*
|
||||
* Defines operations for Sponsor aggregate persistence
|
||||
*/
|
||||
|
||||
import type { Sponsor } from '../entities/Sponsor';
|
||||
|
||||
export interface ISponsorRepository {
|
||||
findById(id: string): Promise<Sponsor | null>;
|
||||
findAll(): Promise<Sponsor[]>;
|
||||
findByEmail(email: string): Promise<Sponsor | null>;
|
||||
create(sponsor: Sponsor): Promise<Sponsor>;
|
||||
update(sponsor: Sponsor): Promise<Sponsor>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Repository Interface: ISponsorshipPricingRepository
|
||||
*
|
||||
* Stores sponsorship pricing configuration for any sponsorable entity.
|
||||
* This allows drivers, teams, races, and leagues to define their sponsorship slots.
|
||||
*/
|
||||
|
||||
import type { SponsorshipPricing } from '../value-objects/SponsorshipPricing';
|
||||
import type { SponsorableEntityType } from '../entities/SponsorshipRequest';
|
||||
|
||||
export interface ISponsorshipPricingRepository {
|
||||
/**
|
||||
* Get pricing configuration for an entity
|
||||
*/
|
||||
findByEntity(entityType: SponsorableEntityType, entityId: string): Promise<SponsorshipPricing | null>;
|
||||
|
||||
/**
|
||||
* Save or update pricing configuration for an entity
|
||||
*/
|
||||
save(entityType: SponsorableEntityType, entityId: string, pricing: SponsorshipPricing): Promise<void>;
|
||||
|
||||
/**
|
||||
* Delete pricing configuration for an entity
|
||||
*/
|
||||
delete(entityType: SponsorableEntityType, entityId: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if entity has pricing configured
|
||||
*/
|
||||
exists(entityType: SponsorableEntityType, entityId: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Find all entities accepting sponsorship applications
|
||||
*/
|
||||
findAcceptingApplications(entityType: SponsorableEntityType): Promise<Array<{
|
||||
entityId: string;
|
||||
pricing: SponsorshipPricing;
|
||||
}>>;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Repository Interface: ISponsorshipRequestRepository
|
||||
*
|
||||
* Defines operations for SponsorshipRequest aggregate persistence
|
||||
*/
|
||||
|
||||
import type { SponsorshipRequest, SponsorableEntityType, SponsorshipRequestStatus } from '../entities/SponsorshipRequest';
|
||||
|
||||
export interface ISponsorshipRequestRepository {
|
||||
findById(id: string): Promise<SponsorshipRequest | null>;
|
||||
|
||||
/**
|
||||
* Find all requests for a specific entity (driver, team, race, or season)
|
||||
*/
|
||||
findByEntity(entityType: SponsorableEntityType, entityId: string): Promise<SponsorshipRequest[]>;
|
||||
|
||||
/**
|
||||
* Find pending requests for an entity that need review
|
||||
*/
|
||||
findPendingByEntity(entityType: SponsorableEntityType, entityId: string): Promise<SponsorshipRequest[]>;
|
||||
|
||||
/**
|
||||
* Find all requests made by a sponsor
|
||||
*/
|
||||
findBySponsorId(sponsorId: string): Promise<SponsorshipRequest[]>;
|
||||
|
||||
/**
|
||||
* Find requests by status
|
||||
*/
|
||||
findByStatus(status: SponsorshipRequestStatus): Promise<SponsorshipRequest[]>;
|
||||
|
||||
/**
|
||||
* Find requests by sponsor and status
|
||||
*/
|
||||
findBySponsorIdAndStatus(sponsorId: string, status: SponsorshipRequestStatus): Promise<SponsorshipRequest[]>;
|
||||
|
||||
/**
|
||||
* Check if a sponsor already has a pending request for an entity
|
||||
*/
|
||||
hasPendingRequest(sponsorId: string, entityType: SponsorableEntityType, entityId: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Count pending requests for an entity
|
||||
*/
|
||||
countPendingByEntity(entityType: SponsorableEntityType, entityId: string): Promise<number>;
|
||||
|
||||
create(request: SponsorshipRequest): Promise<SponsorshipRequest>;
|
||||
update(request: SponsorshipRequest): Promise<SponsorshipRequest>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
55
core/racing/domain/repositories/IStandingRepository.ts
Normal file
55
core/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[]>;
|
||||
}
|
||||
58
core/racing/domain/repositories/ITeamMembershipRepository.ts
Normal file
58
core/racing/domain/repositories/ITeamMembershipRepository.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 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 '../types/TeamMembership';
|
||||
|
||||
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>;
|
||||
|
||||
/**
|
||||
* Count active members for a team.
|
||||
*/
|
||||
countByTeamId(teamId: string): Promise<number>;
|
||||
|
||||
/**
|
||||
* 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
core/racing/domain/repositories/ITeamRepository.ts
Normal file
45
core/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>;
|
||||
}
|
||||
60
core/racing/domain/repositories/ITrackRepository.ts
Normal file
60
core/racing/domain/repositories/ITrackRepository.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Application Port: ITrackRepository
|
||||
*
|
||||
* Repository interface for Track entity CRUD operations.
|
||||
* Defines async methods using domain entities as types.
|
||||
*/
|
||||
|
||||
import type { Track, TrackCategory } from '../entities/Track';
|
||||
|
||||
export interface ITrackRepository {
|
||||
/**
|
||||
* Find a track by ID
|
||||
*/
|
||||
findById(id: string): Promise<Track | null>;
|
||||
|
||||
/**
|
||||
* Find all tracks
|
||||
*/
|
||||
findAll(): Promise<Track[]>;
|
||||
|
||||
/**
|
||||
* Find tracks by game ID
|
||||
*/
|
||||
findByGameId(gameId: string): Promise<Track[]>;
|
||||
|
||||
/**
|
||||
* Find tracks by category
|
||||
*/
|
||||
findByCategory(category: TrackCategory): Promise<Track[]>;
|
||||
|
||||
/**
|
||||
* Find tracks by country
|
||||
*/
|
||||
findByCountry(country: string): Promise<Track[]>;
|
||||
|
||||
/**
|
||||
* Search tracks by name
|
||||
*/
|
||||
searchByName(query: string): Promise<Track[]>;
|
||||
|
||||
/**
|
||||
* Create a new track
|
||||
*/
|
||||
create(track: Track): Promise<Track>;
|
||||
|
||||
/**
|
||||
* Update an existing track
|
||||
*/
|
||||
update(track: Track): Promise<Track>;
|
||||
|
||||
/**
|
||||
* Delete a track by ID
|
||||
*/
|
||||
delete(id: string): Promise<void>;
|
||||
|
||||
/**
|
||||
* Check if a track exists by ID
|
||||
*/
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
17
core/racing/domain/repositories/ITransactionRepository.ts
Normal file
17
core/racing/domain/repositories/ITransactionRepository.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Repository Interface: ITransactionRepository
|
||||
*
|
||||
* Defines operations for Transaction entity persistence
|
||||
*/
|
||||
|
||||
import type { Transaction, TransactionType } from '../entities/Transaction';
|
||||
|
||||
export interface ITransactionRepository {
|
||||
findById(id: string): Promise<Transaction | null>;
|
||||
findByWalletId(walletId: string): Promise<Transaction[]>;
|
||||
findByType(type: TransactionType): Promise<Transaction[]>;
|
||||
create(transaction: Transaction): Promise<Transaction>;
|
||||
update(transaction: Transaction): Promise<Transaction>;
|
||||
delete(id: string): Promise<void>;
|
||||
exists(id: string): Promise<boolean>;
|
||||
}
|
||||
Reference in New Issue
Block a user