feat: expose revision-safe competition API
This commit is contained in:
1 parent
f3286e7fd1
commit
55e5b8df70
11 files changed
+2443
-19
No files matched your search
@@ -0,0 +1,178 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
IsEnum,
|
||||
IsArray,
|
||||
IsDate,
|
||||
IsInt,
|
||||
IsMongoId,
|
||||
IsNumber,
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Matches,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
MinLength,
|
||||
ValidateIf,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
|
||||
const ADJUDICATION_TYPES = [
|
||||
'walkover',
|
||||
'forfeit',
|
||||
'administrative',
|
||||
'administrative-draw',
|
||||
] as const;
|
||||
const REVERSAL_MODES = ['strict', 'cascade'] as const;
|
||||
const EVIDENCE_TYPES = ['riot', 'legacy'] as const;
|
||||
|
||||
export class CompetitionGameEvidenceDto {
|
||||
@IsEnum(EVIDENCE_TYPES)
|
||||
type!: (typeof EVIDENCE_TYPES)[number];
|
||||
|
||||
@ValidateIf(({ type }) => type === 'riot')
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(128)
|
||||
riotMatchId?: string;
|
||||
|
||||
@ValidateIf(({ type }) => type === 'riot')
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(256)
|
||||
payloadHash?: string;
|
||||
|
||||
@ValidateIf(({ type }) => type === 'legacy')
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(512)
|
||||
legacyReference?: string;
|
||||
}
|
||||
|
||||
export class CompetitionGameMappingDto {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
mappingVersion!: number;
|
||||
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@Max(1)
|
||||
confidence!: number;
|
||||
|
||||
@IsMongoId()
|
||||
blueTeamId!: string;
|
||||
|
||||
@IsMongoId()
|
||||
redTeamId!: string;
|
||||
|
||||
@IsMongoId()
|
||||
winnerTeamId!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsObject({ each: true })
|
||||
participantAssignments?: Array<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export class TournamentCodeReferenceDto {
|
||||
@IsMongoId()
|
||||
tournamentCodeId!: string;
|
||||
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(128)
|
||||
riotMatchId!: string;
|
||||
}
|
||||
|
||||
export class AcceptCompetitionGameDto {
|
||||
@IsMongoId()
|
||||
gameId!: string;
|
||||
|
||||
@IsMongoId()
|
||||
seriesId!: string;
|
||||
|
||||
@IsMongoId()
|
||||
gameSlotId!: string;
|
||||
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
ordinal!: number;
|
||||
|
||||
@ValidateNested()
|
||||
@Type(() => CompetitionGameEvidenceDto)
|
||||
evidence!: CompetitionGameEvidenceDto;
|
||||
|
||||
@ValidateNested()
|
||||
@Type(() => CompetitionGameMappingDto)
|
||||
mapping!: CompetitionGameMappingDto;
|
||||
|
||||
@IsOptional()
|
||||
@IsDate()
|
||||
@Type(() => Date)
|
||||
startedAt?: Date;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
durationSeconds?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsObject({ each: true })
|
||||
participants?: Array<Record<string, unknown>>;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => TournamentCodeReferenceDto)
|
||||
tournamentCode?: TournamentCodeReferenceDto;
|
||||
}
|
||||
|
||||
export class CompetitionAdjudicationDecisionDto {
|
||||
@IsEnum(ADJUDICATION_TYPES)
|
||||
type!: (typeof ADJUDICATION_TYPES)[number];
|
||||
|
||||
@ValidateIf(({ type }) => type !== 'administrative-draw')
|
||||
@IsMongoId()
|
||||
winnerTeamId?: string;
|
||||
}
|
||||
|
||||
export class AdjudicateCompetitionSeriesDto {
|
||||
@ValidateNested()
|
||||
@Type(() => CompetitionAdjudicationDecisionDto)
|
||||
decision!: CompetitionAdjudicationDecisionDto;
|
||||
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(2000)
|
||||
reason!: string;
|
||||
}
|
||||
|
||||
export class PreviewCompetitionSeriesReversalDto {
|
||||
@IsEnum(REVERSAL_MODES)
|
||||
mode!: (typeof REVERSAL_MODES)[number];
|
||||
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
@MaxLength(2000)
|
||||
reason!: string;
|
||||
}
|
||||
|
||||
export class ReverseCompetitionSeriesDto extends PreviewCompetitionSeriesReversalDto {
|
||||
@Matches(/^[a-f0-9]{64}$/)
|
||||
impactHash!: string;
|
||||
}
|
||||
|
||||
export class CompetitionFactsQueryDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(512)
|
||||
cursor?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
@Type(() => Number)
|
||||
limit?: number;
|
||||
}
|
||||
Reference in new issue
Block a user