feat: project competition results by team identity
This commit is contained in:
1 parent
39112ff7ff
commit
5d4fe443d0
9 files changed
+3408
No files matched your search
@@ -0,0 +1,48 @@
|
||||
export type CompetitionDomainErrorCode =
|
||||
| 'DUPLICATE_FACT_ID'
|
||||
| 'DUPLICATE_GAME_ID'
|
||||
| 'DUPLICATE_RIOT_MATCH_ID'
|
||||
| 'DUPLICATE_GAME_SLOT'
|
||||
| 'DUPLICATE_GAME_ORDINAL'
|
||||
| 'DUPLICATE_ADJUDICATION'
|
||||
| 'FACT_REFERENCE_NOT_FOUND'
|
||||
| 'FACT_ALREADY_REVERSED'
|
||||
| 'FACT_TYPE_INVALID'
|
||||
| 'GAME_SLOT_INVALID'
|
||||
| 'GAME_ORDINAL_INVALID'
|
||||
| 'GAME_SERIES_MISMATCH'
|
||||
| 'GAME_TEAM_MISMATCH'
|
||||
| 'GAME_WINNER_INVALID'
|
||||
| 'SERIES_ALREADY_COMPLETED'
|
||||
| 'SERIES_DEFINITION_INVALID'
|
||||
| 'SERIES_PARTICIPANTS_INVALID'
|
||||
| 'ADJUDICATION_INVALID'
|
||||
| 'ADJUDICATION_DRAW_NOT_ALLOWED'
|
||||
| 'WALKOVER_HAS_ACTIVE_GAMES';
|
||||
|
||||
/**
|
||||
* A deterministic domain-invariant failure. Command handlers translate these
|
||||
* errors to the appropriate HTTP conflict/validation response; projectors do
|
||||
* not depend on NestJS or transport concerns.
|
||||
*/
|
||||
export class CompetitionDomainError extends Error {
|
||||
constructor(
|
||||
public readonly code: CompetitionDomainErrorCode,
|
||||
message: string,
|
||||
public readonly details?: Readonly<Record<string, unknown>>,
|
||||
) {
|
||||
super(message);
|
||||
this.name = 'CompetitionDomainError';
|
||||
}
|
||||
}
|
||||
|
||||
export function assertCompetitionInvariant(
|
||||
condition: unknown,
|
||||
code: CompetitionDomainErrorCode,
|
||||
message: string,
|
||||
details?: Readonly<Record<string, unknown>>,
|
||||
): asserts condition {
|
||||
if (!condition) {
|
||||
throw new CompetitionDomainError(code, message, details);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user