Add an inhouse hero, Hall of Fame, rankings, and event-specific schedules. Carry the event type through the API and admin tools, and improve results and player history displays.
2626 lines
74 KiB
TypeScript
2626 lines
74 KiB
TypeScript
import mongoose, { Schema, HydratedDocument } from 'mongoose';
|
|
import type { MatchEventType } from '@lolympus/contracts';
|
|
import type {
|
|
RiotPlatformRoute,
|
|
RiotRegionalRoute,
|
|
} from '../../riot/riot.types';
|
|
import {
|
|
Competition,
|
|
CompetitionFact,
|
|
CompetitionOutbox,
|
|
TournamentCodeAssignment,
|
|
applyCompetitionDomainInvariantIndexes,
|
|
competitionModelDefinitions,
|
|
} from '../../competition/competition.schema';
|
|
import { ModelDefinition } from './types';
|
|
import { AUCTION_CANCELLATION_CLEANUP_INDEX } from './auction-cancellation-index';
|
|
|
|
export type Position = 'TOP' | 'JGL' | 'MID' | 'ADC' | 'SUP';
|
|
export const POSITIONS: Position[] = ['TOP', 'JGL', 'MID', 'ADC', 'SUP'];
|
|
|
|
export type RiotLane = 'TOP' | 'JUNGLE' | 'MIDDLE' | 'BOTTOM' | 'UTILITY';
|
|
export const RIOT_LANES: RiotLane[] = [
|
|
'TOP',
|
|
'JUNGLE',
|
|
'MIDDLE',
|
|
'BOTTOM',
|
|
'UTILITY',
|
|
];
|
|
|
|
export type MatchStatus =
|
|
| 'recruiting'
|
|
| 'team-built'
|
|
| 'in-progress'
|
|
| 'finished';
|
|
export const MATCH_STATUSES: MatchStatus[] = [
|
|
'recruiting',
|
|
'team-built',
|
|
'in-progress',
|
|
'finished',
|
|
];
|
|
|
|
export const MATCH_EVENT_TYPES = ['inhouse', 'tournament'] as const satisfies readonly MatchEventType[];
|
|
|
|
export type TeamSide = 'blue' | 'red';
|
|
export const TEAM_SIDES: TeamSide[] = ['blue', 'red'];
|
|
|
|
export type MatchGameMode =
|
|
| 'pair'
|
|
| 'bracket'
|
|
| 'round-robin'
|
|
| 'double-elimination';
|
|
export const MATCH_GAME_MODES: MatchGameMode[] = [
|
|
'pair',
|
|
'bracket',
|
|
'round-robin',
|
|
'double-elimination',
|
|
];
|
|
|
|
export type CommunityRole = 'owner' | 'admin' | 'member';
|
|
export const COMMUNITY_ROLES: CommunityRole[] = ['owner', 'admin', 'member'];
|
|
|
|
export type TournamentCodeState =
|
|
| 'available'
|
|
| 'reserved'
|
|
| 'used'
|
|
| 'expired'
|
|
| 'released'
|
|
| 'voided';
|
|
export const TOURNAMENT_CODE_STATES: TournamentCodeState[] = [
|
|
'available',
|
|
'reserved',
|
|
'used',
|
|
'expired',
|
|
'released',
|
|
'voided',
|
|
];
|
|
export type TournamentMapType = 'SUMMONERS_RIFT';
|
|
export const TOURNAMENT_MAP_TYPES: TournamentMapType[] = ['SUMMONERS_RIFT'];
|
|
export type TournamentSpectatorType = 'NONE' | 'LOBBYONLY' | 'ALL';
|
|
export const TOURNAMENT_SPECTATOR_TYPES: TournamentSpectatorType[] = [
|
|
'NONE',
|
|
'LOBBYONLY',
|
|
'ALL',
|
|
];
|
|
|
|
export type MatchResultPollOutcome = 'matched' | 'not-found' | 'failed';
|
|
export type MatchResultPollStateValue =
|
|
| 'polling'
|
|
| 'complete'
|
|
| 'expired'
|
|
| 'failed';
|
|
export const MATCH_RESULT_POLL_STATES: MatchResultPollStateValue[] = [
|
|
'polling',
|
|
'complete',
|
|
'expired',
|
|
'failed',
|
|
];
|
|
|
|
export type LegacyImportJobState =
|
|
| 'pending'
|
|
| 'running'
|
|
| 'completed'
|
|
| 'failed'
|
|
| 'cancelled';
|
|
export const LEGACY_IMPORT_JOB_STATES: LegacyImportJobState[] = [
|
|
'pending',
|
|
'running',
|
|
'completed',
|
|
'failed',
|
|
'cancelled',
|
|
];
|
|
|
|
export type DakaoInboundMessageState = 'processing' | 'processed' | 'failed';
|
|
export const DAKAO_INBOUND_MESSAGE_STATES: DakaoInboundMessageState[] = [
|
|
'processing',
|
|
'processed',
|
|
'failed',
|
|
];
|
|
|
|
export type DakaoOutboxMessageState =
|
|
| 'pending'
|
|
| 'published'
|
|
| 'sent'
|
|
| 'failed';
|
|
export const DAKAO_OUTBOX_MESSAGE_STATES: DakaoOutboxMessageState[] = [
|
|
'pending',
|
|
'published',
|
|
'sent',
|
|
'failed',
|
|
];
|
|
|
|
export type DakaoOutboxCompensationState =
|
|
| 'none'
|
|
| 'pending'
|
|
| 'completed'
|
|
| 'failed';
|
|
export const DAKAO_OUTBOX_COMPENSATION_STATES: DakaoOutboxCompensationState[] =
|
|
['none', 'pending', 'completed', 'failed'];
|
|
|
|
export type DakaoSendResultStatus = 'succeeded' | 'failed';
|
|
export const DAKAO_SEND_RESULT_STATUSES: DakaoSendResultStatus[] = [
|
|
'succeeded',
|
|
'failed',
|
|
];
|
|
|
|
export interface PositionPreference {
|
|
position: Position;
|
|
priority: number; // 1 = 최우선, 숫자가 작을수록 높은 우선순위
|
|
}
|
|
|
|
export type AuctionPhase =
|
|
| 'waiting'
|
|
| 'presenting'
|
|
| 'bidding'
|
|
| 'sold'
|
|
| 'passed'
|
|
| 'complete';
|
|
export const AUCTION_PHASES: AuctionPhase[] = [
|
|
'waiting',
|
|
'presenting',
|
|
'bidding',
|
|
'sold',
|
|
'passed',
|
|
'complete',
|
|
];
|
|
export const AUCTION_TOP_TIER_THRESHOLDS = [
|
|
'NONE',
|
|
'EMERALD',
|
|
'DIAMOND',
|
|
'MASTER',
|
|
'MANUAL',
|
|
] as const;
|
|
export type AuctionTopTierThreshold =
|
|
(typeof AUCTION_TOP_TIER_THRESHOLDS)[number];
|
|
export const AUCTION_ACTION_TYPES = [
|
|
'start',
|
|
'open-bidding',
|
|
'bid',
|
|
'sold',
|
|
'passed',
|
|
'next',
|
|
'complete',
|
|
'reset',
|
|
'undo',
|
|
] as const;
|
|
export type AuctionActionType = (typeof AUCTION_ACTION_TYPES)[number];
|
|
export const AUCTION_ENGINE_VERSIONS = ['redis-v1', 'legacy-renamed'] as const;
|
|
export type AuctionEngineVersion = (typeof AUCTION_ENGINE_VERSIONS)[number];
|
|
export const AUCTION_MATCH_SIDE_EFFECT_STATUSES = [
|
|
'none',
|
|
'pending',
|
|
'processing',
|
|
'completed',
|
|
'failed',
|
|
] as const;
|
|
export type AuctionMatchSideEffectStatus =
|
|
(typeof AUCTION_MATCH_SIDE_EFFECT_STATUSES)[number];
|
|
export const AUCTION_SIDE_EFFECT_APPLICATION_STATES = [
|
|
'pending',
|
|
'processing',
|
|
'completed',
|
|
'failed',
|
|
] as const;
|
|
export type AuctionSideEffectApplicationState =
|
|
(typeof AUCTION_SIDE_EFFECT_APPLICATION_STATES)[number];
|
|
|
|
export type AuctionHistoryMutation =
|
|
| { type: 'append' }
|
|
| { targetHistorySequence: number; type: 'deleteAfterSequenceAndAppendUndo' }
|
|
| { resetMode: 'clear-history' | 'preserve-audit'; type: 'reset' };
|
|
|
|
export interface MongooseTimestamps {
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
// ===== Identity =====
|
|
export interface Identity extends MongooseTimestamps {
|
|
entraOid: string;
|
|
tenantId?: string;
|
|
email?: string;
|
|
displayName?: string;
|
|
lastSignInAt?: Date;
|
|
}
|
|
|
|
// ===== Tier =====
|
|
export interface TierInfo {
|
|
leagueId?: string;
|
|
queueType: string; // RANKED_SOLO_5x5, RANKED_FLEX_SR 등
|
|
tier: string; // IRON, BRONZE, ..., CHALLENGER
|
|
rank: string; // I | II | III | IV
|
|
puuid?: string;
|
|
leaguePoints: number;
|
|
wins: number;
|
|
losses: number;
|
|
veteran?: boolean;
|
|
inactive?: boolean;
|
|
freshBlood?: boolean;
|
|
hotStreak?: boolean;
|
|
miniSeries?: Record<string, unknown>;
|
|
fetchedAt: Date; // Riot API로부터 조회된 시각
|
|
}
|
|
|
|
export interface TierHistoryEntry {
|
|
queueType: string;
|
|
tier: string;
|
|
rank?: string;
|
|
leaguePoints?: number;
|
|
wins?: number;
|
|
losses?: number;
|
|
recordedAt: Date;
|
|
season?: string; // e.g., 'S13', 'S14'
|
|
peakTier?: string;
|
|
peakRank?: string;
|
|
}
|
|
|
|
// ===== RiotAccount (User 하위에 임베딩) =====
|
|
/**
|
|
* 챔피언 단위 집계 기록. 필드 추가가 잦을 것으로 예상되어 Mixed로 저장.
|
|
* key: championId (string), value: championId별 누적/평균 지표 자유형 JSON
|
|
*/
|
|
export type ChampionRecordMap = Record<string, Record<string, unknown>>;
|
|
|
|
export interface ChampionMasteryEntry {
|
|
puuid: string;
|
|
championId: number;
|
|
championLevel: number;
|
|
championPoints: number;
|
|
lastPlayTime?: number;
|
|
championPointsSinceLastLevel?: number;
|
|
championPointsUntilNextLevel?: number;
|
|
markRequiredForNextLevel?: number;
|
|
tokensEarned?: number;
|
|
championSeasonMilestone?: number;
|
|
milestoneGrades?: string[];
|
|
nextSeasonMilestone?: Record<string, unknown>;
|
|
}
|
|
|
|
export interface RiotLaneStats {
|
|
games: number;
|
|
wins: number;
|
|
losses: number;
|
|
avgKills: number;
|
|
avgDeaths: number;
|
|
avgAssists: number;
|
|
avgCs: number;
|
|
avgCsPerMin: number;
|
|
mostPlayedChampionIds: number[];
|
|
}
|
|
|
|
export interface RiotRecentStatsSummary {
|
|
overall: RiotLaneStats;
|
|
byLane: Partial<Record<RiotLane, RiotLaneStats>>;
|
|
}
|
|
|
|
export function createEmptyRiotLaneStats(): RiotLaneStats {
|
|
return {
|
|
games: 0,
|
|
wins: 0,
|
|
losses: 0,
|
|
avgKills: 0,
|
|
avgDeaths: 0,
|
|
avgAssists: 0,
|
|
avgCs: 0,
|
|
avgCsPerMin: 0,
|
|
mostPlayedChampionIds: [],
|
|
};
|
|
}
|
|
|
|
export function createEmptyRiotRecentStatsSummary(): RiotRecentStatsSummary {
|
|
return {
|
|
overall: createEmptyRiotLaneStats(),
|
|
byLane: {},
|
|
};
|
|
}
|
|
|
|
export interface RiotAccount extends MongooseTimestamps {
|
|
puuid: string;
|
|
gameName: string;
|
|
tagLine: string;
|
|
profileIconId: number;
|
|
revisionDate: number;
|
|
summonerLevel: number;
|
|
isPrimary: boolean;
|
|
|
|
// 현재 티어들(솔랭/자랭 각각)
|
|
tiers: TierInfo[];
|
|
// 과거 티어 기록
|
|
tierHistory: TierHistoryEntry[];
|
|
|
|
// Riot matchId 참조 (원본은 RiotMatch 컬렉션에 저장)
|
|
matchIds: string[];
|
|
matchIdsFetchedAt?: Date;
|
|
matchIdsByQueueFetchedAt?: Map<string, Date>;
|
|
lastRefreshRequestedAt?: Date;
|
|
|
|
// 최근 경기 요약
|
|
recentStatsSummary?: RiotRecentStatsSummary;
|
|
recentStatsFetchedAt?: Date;
|
|
|
|
// 챔피언 숙련도
|
|
championMasteries: ChampionMasteryEntry[];
|
|
championMasteriesFetchedAt?: Date;
|
|
|
|
// 챔피언별 기록 (JSON, 필드 추가 자유로움)
|
|
championRecords: ChampionRecordMap;
|
|
championRecordsFetchedAt?: Date;
|
|
}
|
|
|
|
// ===== User =====
|
|
export interface User extends MongooseTimestamps {
|
|
communityId: mongoose.Types.ObjectId;
|
|
identityId?: mongoose.Types.ObjectId;
|
|
role: CommunityRole;
|
|
kakaoTalkId?: string;
|
|
kakaoTalkNickname?: string;
|
|
discordId?: string;
|
|
discordNickname?: string;
|
|
riotAccounts: RiotAccount[];
|
|
preferredPositions: PositionPreference[];
|
|
isActivated: boolean;
|
|
}
|
|
|
|
export interface Community extends MongooseTimestamps {
|
|
name: string;
|
|
description: string;
|
|
ownerUserId: mongoose.Types.ObjectId;
|
|
dakaoProjectId?: mongoose.Types.ObjectId;
|
|
riotPlatform?: RiotPlatformRoute;
|
|
riotRegion?: RiotRegionalRoute;
|
|
seasonStartedAt?: Date;
|
|
seasons?: CommunitySeason[];
|
|
matchGameCount?: number;
|
|
}
|
|
|
|
export interface CommunitySeason {
|
|
id: string;
|
|
label: string;
|
|
startedAt: Date;
|
|
endedAt?: Date;
|
|
}
|
|
|
|
export interface DakaoInboundMessage extends MongooseTimestamps {
|
|
consumer: string;
|
|
projectId: string;
|
|
chatLogLogId: string;
|
|
state: DakaoInboundMessageState;
|
|
attempts: number;
|
|
processingExpiresAt?: Date;
|
|
processedAt?: Date;
|
|
lastError?: string;
|
|
}
|
|
|
|
export interface DakaoOutboxMessage extends MongooseTimestamps {
|
|
eventId: string;
|
|
eventSource: string;
|
|
type: string;
|
|
subject: string;
|
|
correlationId?: string;
|
|
resultSubjects?: {
|
|
succeeded: string;
|
|
failed: string;
|
|
};
|
|
payload: Record<string, unknown>;
|
|
state: DakaoOutboxMessageState;
|
|
publishAttempts: number;
|
|
publishLeaseOwnerIdentifier?: string;
|
|
publishLeaseExpiresAt?: Date;
|
|
publishedAt?: Date;
|
|
terminalAt?: Date;
|
|
resultEventId?: string;
|
|
lastPublishError?: string;
|
|
terminalError?: Record<string, unknown>;
|
|
compensationState: DakaoOutboxCompensationState;
|
|
compensationReason?: string;
|
|
}
|
|
|
|
export interface DakaoSendResultEvent extends MongooseTimestamps {
|
|
eventId: string;
|
|
requestEventId: string;
|
|
eventSource: string;
|
|
requestEventSource: string;
|
|
type: string;
|
|
subject: string;
|
|
status: DakaoSendResultStatus;
|
|
correlationId?: string;
|
|
handledAt: Date;
|
|
providerMessageId?: string;
|
|
error?: Record<string, unknown>;
|
|
raw: Record<string, unknown>;
|
|
}
|
|
|
|
export type CommunityDocument = HydratedDocument<Community>;
|
|
export type IdentityDocument = HydratedDocument<Identity>;
|
|
export type UserDocument = HydratedDocument<User>;
|
|
export type DakaoInboundMessageDocument = HydratedDocument<DakaoInboundMessage>;
|
|
export type DakaoOutboxMessageDocument = HydratedDocument<DakaoOutboxMessage>;
|
|
export type DakaoSendResultEventDocument =
|
|
HydratedDocument<DakaoSendResultEvent>;
|
|
|
|
// ===== RiotMatch (Riot 원본 매치 아카이브) =====
|
|
export interface RiotMatch extends MongooseTimestamps {
|
|
matchId: string; // Riot matchId (예: KR_7123456789)
|
|
gameCreation: number;
|
|
gameDuration: number;
|
|
gameVersion?: string;
|
|
queueId?: number;
|
|
participantPuuids: string[];
|
|
raw: Record<string, unknown>; // Riot API Match-V5 원본 응답 전체
|
|
timeline?: Record<string, unknown>; // Riot API Match-V5 timeline 원본 응답 전체
|
|
timelineFetchedAt?: Date;
|
|
fetchedAt: Date;
|
|
}
|
|
|
|
export type RiotMatchDocument = HydratedDocument<RiotMatch>;
|
|
|
|
// ===== TournamentCode (운영자가 미리 업로드한 토너먼트 코드 풀) =====
|
|
export interface TournamentCode extends MongooseTimestamps {
|
|
code: string;
|
|
region: RiotPlatformRoute;
|
|
mapType: TournamentMapType;
|
|
teamSize: number;
|
|
spectatorType: TournamentSpectatorType;
|
|
metadata?: Record<string, unknown>;
|
|
expiresAt: Date;
|
|
state: TournamentCodeState;
|
|
matchId?: mongoose.Types.ObjectId;
|
|
gameNumber?: number;
|
|
bracketMatchId?: string;
|
|
reservedAt?: Date;
|
|
usedAt?: Date;
|
|
releasedAt?: Date;
|
|
voidedAt?: Date;
|
|
riotMatchId?: string;
|
|
uploadedBy: mongoose.Types.ObjectId;
|
|
uploadedAt: Date;
|
|
source?: string;
|
|
notes?: string;
|
|
}
|
|
|
|
export type TournamentCodeDocument = HydratedDocument<TournamentCode>;
|
|
|
|
// ===== Match (내전) =====
|
|
export interface MatchParticipant {
|
|
userId: mongoose.Types.ObjectId;
|
|
// 표시용 스냅샷 (대표 RiotAccount 기준)
|
|
puuid?: string;
|
|
gameName?: string;
|
|
tagLine?: string;
|
|
profileIconId?: number;
|
|
tier?: TierInfo;
|
|
preferredPositions: PositionPreference[];
|
|
joinedAt: Date;
|
|
excluded?: boolean;
|
|
}
|
|
|
|
export interface MatchTeamMember {
|
|
userId: mongoose.Types.ObjectId;
|
|
assignedPosition: Position;
|
|
cost?: number; // 경매로 영입된 경우의 입찰가
|
|
}
|
|
|
|
export interface MatchTeam {
|
|
teamIndex: number;
|
|
name: string;
|
|
captainUserId?: mongoose.Types.ObjectId;
|
|
members: MatchTeamMember[];
|
|
}
|
|
|
|
export interface MatchGameResultParticipant {
|
|
userId: mongoose.Types.ObjectId;
|
|
teamIndex: number;
|
|
side: TeamSide;
|
|
championId: number;
|
|
kills: number;
|
|
deaths: number;
|
|
assists: number;
|
|
win: boolean;
|
|
}
|
|
|
|
export interface MatchGameResult {
|
|
gameNumber: number;
|
|
bracketMatchId?: string;
|
|
riotMatchId: string;
|
|
blueTeamIndex: number;
|
|
redTeamIndex: number;
|
|
winnerTeamIndex: number;
|
|
winnerSide: TeamSide;
|
|
gameCreation: number;
|
|
gameDuration: number;
|
|
participants: MatchGameResultParticipant[];
|
|
}
|
|
|
|
export interface MatchSeriesResult {
|
|
bracketMatchId?: string;
|
|
teamAIndex: number;
|
|
teamBIndex: number;
|
|
teamAWins: number;
|
|
teamBWins: number;
|
|
winnerTeamIndex?: number;
|
|
}
|
|
|
|
export type DoubleEliminationBracketSide =
|
|
| 'winner'
|
|
| 'loser'
|
|
| 'grand-final'
|
|
| 'reset-final';
|
|
export const DOUBLE_ELIMINATION_BRACKET_SIDES: DoubleEliminationBracketSide[] =
|
|
['winner', 'loser', 'grand-final', 'reset-final'];
|
|
|
|
export type DoubleEliminationBracketMatchState =
|
|
| 'pending'
|
|
| 'ready'
|
|
| 'completed';
|
|
export const DOUBLE_ELIMINATION_BRACKET_MATCH_STATES: DoubleEliminationBracketMatchState[] =
|
|
['pending', 'ready', 'completed'];
|
|
|
|
export type DoubleEliminationCompletionType = 'riot-result' | 'walkover';
|
|
export const DOUBLE_ELIMINATION_COMPLETION_TYPES: DoubleEliminationCompletionType[] =
|
|
['riot-result', 'walkover'];
|
|
|
|
export type DoubleEliminationEventType =
|
|
| 'bracket-created'
|
|
| 'seeds-reshuffled'
|
|
| 'seeds-swapped'
|
|
| 'bracket-match-completed'
|
|
| 'bracket-match-cancelled'
|
|
| 'walkover-awarded'
|
|
| 'walkover-cancelled'
|
|
| 'reset-final-created'
|
|
| 'riot-result-cancelled';
|
|
export const DOUBLE_ELIMINATION_EVENT_TYPES: DoubleEliminationEventType[] = [
|
|
'bracket-created',
|
|
'seeds-reshuffled',
|
|
'seeds-swapped',
|
|
'bracket-match-completed',
|
|
'bracket-match-cancelled',
|
|
'walkover-awarded',
|
|
'walkover-cancelled',
|
|
'reset-final-created',
|
|
'riot-result-cancelled',
|
|
];
|
|
|
|
export interface DoubleEliminationSeed {
|
|
seedNumber: number;
|
|
teamIndex: number;
|
|
}
|
|
|
|
export interface DoubleEliminationBracketMatchSource {
|
|
type: 'seed' | 'winner' | 'loser';
|
|
seedNumber?: number;
|
|
bracketMatchId?: string;
|
|
}
|
|
|
|
export interface DoubleEliminationBracketMatchDestination {
|
|
bracketMatchId: string;
|
|
position: 'A' | 'B';
|
|
}
|
|
|
|
export interface DoubleEliminationWalkover {
|
|
winnerTeamIndex: number;
|
|
reason?: string;
|
|
awardedBy?: mongoose.Types.ObjectId;
|
|
awardedAt: Date;
|
|
cancelledBy?: mongoose.Types.ObjectId;
|
|
cancelledAt?: Date;
|
|
cancelReason?: string;
|
|
active: boolean;
|
|
}
|
|
|
|
export interface DoubleEliminationBracketMatch {
|
|
bracketMatchId: string;
|
|
gameNumber: number;
|
|
gameCount: number;
|
|
requiredWins: number;
|
|
bracketSide: DoubleEliminationBracketSide;
|
|
roundNumber: number;
|
|
matchNumber: number;
|
|
state: DoubleEliminationBracketMatchState;
|
|
teamAIndex?: number;
|
|
teamBIndex?: number;
|
|
teamASource?: DoubleEliminationBracketMatchSource;
|
|
teamBSource?: DoubleEliminationBracketMatchSource;
|
|
winnerAdvancesTo?: DoubleEliminationBracketMatchDestination;
|
|
loserAdvancesTo?: DoubleEliminationBracketMatchDestination;
|
|
winnerTeamIndex?: number;
|
|
loserTeamIndex?: number;
|
|
completedBy?: DoubleEliminationCompletionType;
|
|
completedAt?: Date;
|
|
walkover?: DoubleEliminationWalkover;
|
|
}
|
|
|
|
export interface DoubleEliminationPlacements {
|
|
firstTeamIndex?: number;
|
|
secondTeamIndex?: number;
|
|
thirdTeamIndex?: number;
|
|
}
|
|
|
|
export interface DoubleEliminationEvent {
|
|
type: DoubleEliminationEventType;
|
|
bracketMatchId?: string;
|
|
actorUserId?: mongoose.Types.ObjectId;
|
|
reason?: string;
|
|
createdAt: Date;
|
|
}
|
|
|
|
export interface DoubleEliminationBracket {
|
|
teamCount: 4 | 8;
|
|
resetFinalEnabled: boolean;
|
|
grandFinalGameCount?: 1 | 3 | 5;
|
|
resetFinalCreated: boolean;
|
|
seeds: DoubleEliminationSeed[];
|
|
bracketMatches: DoubleEliminationBracketMatch[];
|
|
placements: DoubleEliminationPlacements;
|
|
events: DoubleEliminationEvent[];
|
|
}
|
|
|
|
export interface MatchGameAssignment {
|
|
gameNumber: number;
|
|
roundNumber?: number;
|
|
teamAIndex: number;
|
|
teamBIndex: number;
|
|
}
|
|
|
|
export interface MatchResult {
|
|
winnerTeamIndex?: number;
|
|
mvpUserId?: mongoose.Types.ObjectId;
|
|
riotMatchIds: string[]; // 내전에서 플레이된 Riot matchId들
|
|
games: MatchGameResult[];
|
|
seriesResults?: MatchSeriesResult[];
|
|
}
|
|
|
|
export interface MatchResultPollState {
|
|
startedAt: Date;
|
|
lastPolledAt?: Date;
|
|
lastPollOutcome?: MatchResultPollOutcome;
|
|
matchedCount: number;
|
|
expandedToAllPuuids: boolean;
|
|
state: MatchResultPollStateValue;
|
|
}
|
|
|
|
export interface MatchScheduleItem {
|
|
time: string;
|
|
label: string;
|
|
}
|
|
|
|
export interface Match extends MongooseTimestamps {
|
|
communityId: mongoose.Types.ObjectId;
|
|
competitionId?: mongoose.Types.ObjectId;
|
|
shortCode?: string;
|
|
title: string;
|
|
eventType?: MatchEventType;
|
|
description: string;
|
|
mapId: number; // Riot Match-V5 mapId (11=소환사의 협곡, 12=ARAM 등)
|
|
status: MatchStatus;
|
|
scheduledAt: Date;
|
|
maxParticipants: number;
|
|
gameCount: number;
|
|
gameMode: MatchGameMode;
|
|
roundRobinMaxRounds?: number;
|
|
tournamentCodeIds: mongoose.Types.ObjectId[];
|
|
gameSchedule: MatchGameAssignment[];
|
|
teamBuiltAt?: Date;
|
|
hostUserId?: mongoose.Types.ObjectId;
|
|
participants: MatchParticipant[];
|
|
teams: MatchTeam[];
|
|
result?: MatchResult;
|
|
resultPollState?: MatchResultPollState;
|
|
/** 마지막으로 취소된 Redis 경매 lifecycle. 취소 재전송을 멱등 처리한다. */
|
|
lastCancelledAuctionLifecycleId?: string;
|
|
auctionCancellationCleanupPending?: boolean;
|
|
auctionCancellationCleanupRetryAt?: Date;
|
|
auctionCancellationCleanupAttempts?: number;
|
|
auctionCancellationCleanupError?: string;
|
|
doubleElimination?: DoubleEliminationBracket;
|
|
legacyImported?: boolean;
|
|
legacyImportSource?: {
|
|
importedAt: Date;
|
|
importedBy: mongoose.Types.ObjectId;
|
|
triggeringPuuid: string;
|
|
jobId?: string;
|
|
};
|
|
prizes: string[];
|
|
notices: string[];
|
|
schedule: MatchScheduleItem[];
|
|
}
|
|
|
|
export type MatchDocument = HydratedDocument<Match>;
|
|
|
|
// ===== Legacy Import Job =====
|
|
export interface LegacyImportJobMemberOverride {
|
|
userId: mongoose.Types.ObjectId;
|
|
puuid: string;
|
|
startTime: Date;
|
|
endTime: Date;
|
|
}
|
|
|
|
export interface LegacyImportJobError {
|
|
puuid?: string;
|
|
matchId?: string;
|
|
reason: string;
|
|
at: Date;
|
|
}
|
|
|
|
export interface LegacyImportJob extends MongooseTimestamps {
|
|
jobId: string;
|
|
communityId: mongoose.Types.ObjectId;
|
|
triggeredBy: mongoose.Types.ObjectId;
|
|
startedAt: Date;
|
|
completedAt?: Date;
|
|
state: LegacyImportJobState;
|
|
windowStart: Date;
|
|
windowEnd: Date;
|
|
memberOverrides: LegacyImportJobMemberOverride[];
|
|
totalMembers: number;
|
|
processedMembers: number;
|
|
totalDiscoveredMatchIds: number;
|
|
totalImportedMatches: number;
|
|
totalSkippedDuplicate: number;
|
|
totalErrors: number;
|
|
averageMemberSeconds?: number;
|
|
completedMemberJobIds: string[];
|
|
errors?: LegacyImportJobError[];
|
|
}
|
|
|
|
export type LegacyImportJobDocument = HydratedDocument<LegacyImportJob>;
|
|
|
|
// ===== Auction (경매) =====
|
|
export interface AuctionPlayerSnapshot {
|
|
userId: mongoose.Types.ObjectId;
|
|
// 표시용 스냅샷(대표 RiotAccount 기준) — RiotAccount에서 복사
|
|
puuid: string;
|
|
gameName: string;
|
|
tagLine: string;
|
|
profileIconId: number;
|
|
preferredPositions: PositionPreference[];
|
|
tiers: TierInfo[];
|
|
tierHistory: TierHistoryEntry[];
|
|
masteries: ChampionMasteryEntry[];
|
|
recentStatsSummary?: RiotRecentStatsSummary;
|
|
passCount: number;
|
|
}
|
|
|
|
export interface AuctionTeamMember {
|
|
userId: mongoose.Types.ObjectId;
|
|
assignedPosition: Position;
|
|
cost: number;
|
|
}
|
|
|
|
export interface AuctionTeam {
|
|
teamIndex: number;
|
|
captainUserId: mongoose.Types.ObjectId;
|
|
points: number;
|
|
members: AuctionTeamMember[];
|
|
}
|
|
|
|
export interface RedisAuctionTeamMember {
|
|
userId: mongoose.Types.ObjectId;
|
|
assignedPosition: Position;
|
|
memberAcquisitionBidPointAmount: number;
|
|
}
|
|
|
|
export interface RedisAuctionTeam {
|
|
teamIndex: number;
|
|
name?: string;
|
|
captainUserId: mongoose.Types.ObjectId;
|
|
remainingBidPointAmount: number;
|
|
members: RedisAuctionTeamMember[];
|
|
}
|
|
|
|
export interface AuctionBid {
|
|
teamIndex: number;
|
|
amount: number;
|
|
bidderUserId: mongoose.Types.ObjectId;
|
|
timestamp: Date;
|
|
}
|
|
|
|
export interface AuctionBidHistoryEntry {
|
|
bidRequestId?: string;
|
|
revision?: number;
|
|
bidRoundId?: string;
|
|
playerUserId?: mongoose.Types.ObjectId;
|
|
bidderTeamIndex: number;
|
|
bidPointAmount: number;
|
|
bidderUserId: mongoose.Types.ObjectId;
|
|
bidPlacedAtTimestampMS: number;
|
|
}
|
|
|
|
export interface AuctionBidRecord extends AuctionBidHistoryEntry {
|
|
_id: string;
|
|
matchId: mongoose.Types.ObjectId;
|
|
auctionLifecycleId: string;
|
|
revision: number;
|
|
bidRequestId: string;
|
|
}
|
|
|
|
export const AuctionBidRecordSchema = new Schema<AuctionBidRecord>(
|
|
{
|
|
_id: { type: String, required: true },
|
|
matchId: { type: Schema.Types.ObjectId, required: true },
|
|
auctionLifecycleId: { type: String, required: true },
|
|
revision: { type: Number, required: true },
|
|
bidRequestId: { type: String, required: true },
|
|
bidRoundId: { type: String },
|
|
playerUserId: { type: Schema.Types.ObjectId },
|
|
bidderUserId: { type: Schema.Types.ObjectId, required: true },
|
|
bidderTeamIndex: { type: Number, required: true },
|
|
bidPointAmount: { type: Number, required: true },
|
|
bidPlacedAtTimestampMS: { type: Number, required: true },
|
|
},
|
|
{ collection: 'auctionBidRecords', versionKey: false },
|
|
);
|
|
|
|
export interface AuctionChatMessage {
|
|
id: string;
|
|
userId?: mongoose.Types.ObjectId;
|
|
displayName: string;
|
|
message: string;
|
|
sentAt: Date;
|
|
}
|
|
|
|
export interface Auction extends MongooseTimestamps {
|
|
matchId: mongoose.Types.ObjectId;
|
|
phase: AuctionPhase;
|
|
revision: number;
|
|
auctionEngineVersion?: AuctionEngineVersion;
|
|
auctionLifecycleId?: string;
|
|
lastAppliedAuctionStateTransitionId?: string;
|
|
currentAuctionHistorySequence: number;
|
|
startAuctionRequestId?: string;
|
|
startAuctionStateTransitionId?: string;
|
|
auctionStartedByUserId?: mongoose.Types.ObjectId;
|
|
matchSideEffectStatus: AuctionMatchSideEffectStatus;
|
|
matchSideEffectRevision: number;
|
|
matchSideEffectError?: string;
|
|
matchSideEffectTransitionId?: string;
|
|
startupCompleted?: boolean;
|
|
teams: AuctionTeam[];
|
|
order: AuctionPlayerSnapshot[];
|
|
passedQueue: AuctionPlayerSnapshot[];
|
|
auctionRound: number;
|
|
currentIndex: number;
|
|
bids: AuctionBid[];
|
|
currentBid: number;
|
|
currentBidderTeamIndex?: number;
|
|
maxTimerSeconds: number;
|
|
bidExtensionSeconds: number;
|
|
currentDeadline?: Date;
|
|
initialPoints: number;
|
|
topTierThreshold: AuctionTopTierThreshold;
|
|
manualTopTierUserIds: mongoose.Types.ObjectId[];
|
|
chatMessages: AuctionChatMessage[];
|
|
startedAt?: Date;
|
|
completedAt?: Date;
|
|
auctionTeams?: RedisAuctionTeam[];
|
|
auctionPlayerOrder?: AuctionPlayerSnapshot[];
|
|
passedAuctionPlayerQueue?: AuctionPlayerSnapshot[];
|
|
currentAuctionRound?: number;
|
|
currentAuctionPlayerOrderIndex?: number;
|
|
auctionBidHistory?: AuctionBidHistoryEntry[];
|
|
currentHighestBidPointAmount?: number;
|
|
currentHighestBidderTeamIndex?: number;
|
|
currentBidRoundDeadlineTimestampMS?: number;
|
|
currentBidRoundId?: string;
|
|
maximumBidRoundDurationSeconds?: number;
|
|
bidRoundExtensionSeconds?: number;
|
|
initialTeamBidPointAmount?: number;
|
|
topTierAuctionPriorityThreshold?: AuctionTopTierThreshold;
|
|
manualTopTierAuctionPriorityUserIds?: mongoose.Types.ObjectId[];
|
|
auctionStartedAtTimestampMS?: number;
|
|
auctionCompletedAtTimestampMS?: number;
|
|
}
|
|
|
|
export type AuctionDocument = HydratedDocument<Auction>;
|
|
|
|
export interface AuctionHistoryEntry extends MongooseTimestamps {
|
|
auctionId: mongoose.Types.ObjectId;
|
|
matchId: mongoose.Types.ObjectId;
|
|
sequence: number;
|
|
action: AuctionActionType;
|
|
auctionStateTransitionId?: string;
|
|
auctionLifecycleId?: string;
|
|
revision?: number;
|
|
actorUserId?: mongoose.Types.ObjectId;
|
|
snapshotBefore: Record<string, unknown>;
|
|
historyMutation?: AuctionHistoryMutation;
|
|
matchSideEffectMutation?: Record<string, unknown>;
|
|
takenAt: Date;
|
|
}
|
|
|
|
export type AuctionHistoryEntryDocument = HydratedDocument<AuctionHistoryEntry>;
|
|
|
|
export interface AuctionSideEffectApplication extends MongooseTimestamps {
|
|
auctionId: mongoose.Types.ObjectId;
|
|
matchId: mongoose.Types.ObjectId;
|
|
auctionStateTransitionId: string;
|
|
auctionLifecycleId: string;
|
|
sideEffectType: string;
|
|
state: AuctionSideEffectApplicationState;
|
|
payload: Record<string, unknown>;
|
|
payloadChecksum: string;
|
|
attempts: number;
|
|
processingStartedAtTimestampMS?: number;
|
|
processingLeaseExpiresAtTimestampMS?: number;
|
|
processingOwnerToken?: string;
|
|
completedAtTimestampMS?: number;
|
|
lastError?: string;
|
|
}
|
|
|
|
export type AuctionSideEffectApplicationDocument =
|
|
HydratedDocument<AuctionSideEffectApplication>;
|
|
|
|
// ===== MatchStats (precomputed internal stats fragment) =====
|
|
export interface MatchStatsRuneStyleSelection {
|
|
styleId: number;
|
|
perkIds: number[];
|
|
}
|
|
|
|
export interface MatchStatsRunePerks {
|
|
primaryStyle?: number;
|
|
subStyle?: number;
|
|
keystone?: number;
|
|
selectedPerkIds?: number[];
|
|
styles?: MatchStatsRuneStyleSelection[];
|
|
statPerks?: {
|
|
offense?: number;
|
|
flex?: number;
|
|
defense?: number;
|
|
};
|
|
}
|
|
|
|
export interface MatchStatsItemBuildEvent {
|
|
timestamp: number;
|
|
itemId: number;
|
|
type: 'purchased' | 'sold' | 'destroyed' | 'undo';
|
|
beforeId?: number;
|
|
afterId?: number;
|
|
}
|
|
|
|
export interface MatchStatsSkillBuildEvent {
|
|
timestamp: number;
|
|
skillSlot: 1 | 2 | 3 | 4;
|
|
level: number;
|
|
levelUpType?: string;
|
|
}
|
|
|
|
export interface MatchStatsCheckpoint {
|
|
timestamp: number;
|
|
gold: number;
|
|
cs: number;
|
|
xp: number;
|
|
kills: number;
|
|
deaths: number;
|
|
assists: number;
|
|
}
|
|
|
|
export interface MatchStatsParticipantCheckpoints {
|
|
at10?: MatchStatsCheckpoint;
|
|
at15?: MatchStatsCheckpoint;
|
|
}
|
|
|
|
export interface MatchStatsRecord {
|
|
matchId: string;
|
|
title: string;
|
|
scheduledAt: Date;
|
|
gameNumber: number;
|
|
riotMatchId: string;
|
|
gameCreation: number;
|
|
gameDuration: number;
|
|
participantId?: number;
|
|
checkpoints?: MatchStatsParticipantCheckpoints;
|
|
userId: string;
|
|
summonerName: string;
|
|
tagLine: string;
|
|
profileIconId: number;
|
|
teamIndex: number;
|
|
side: TeamSide;
|
|
championId: number;
|
|
championLevel: number;
|
|
teamPosition: string;
|
|
kills: number;
|
|
deaths: number;
|
|
assists: number;
|
|
win: boolean;
|
|
cs: number;
|
|
csPerMin: number;
|
|
gold: number;
|
|
gpm: number;
|
|
damageDealtToChampions: number;
|
|
damageTaken: number;
|
|
damageShare: number;
|
|
killParticipation: number;
|
|
visionScore: number;
|
|
controlWardsBought: number;
|
|
wardsPlaced: number;
|
|
wardsKilled: number;
|
|
firstBloodKill: boolean;
|
|
firstBloodAssist: boolean;
|
|
items: number[];
|
|
trinket: number;
|
|
summonerSpells: [number, number];
|
|
perks: MatchStatsRunePerks;
|
|
itemBuild: MatchStatsItemBuildEvent[];
|
|
skillBuild: MatchStatsSkillBuildEvent[];
|
|
rating: number;
|
|
}
|
|
|
|
export interface MatchStatsGameDetail {
|
|
gameNumber: number;
|
|
riotMatchId: string;
|
|
gameCreation: number;
|
|
gameDuration: number;
|
|
gameVersion?: string;
|
|
winnerSide: TeamSide;
|
|
timeline: MatchStatsTimelinePoint[];
|
|
timelineLoaded?: boolean;
|
|
objectiveEvents: MatchStatsObjectiveEvent[];
|
|
timelineEvents?: MatchStatsTimelineEvent[];
|
|
teams: Array<{
|
|
teamIndex: number;
|
|
side: TeamSide;
|
|
win: boolean;
|
|
objectives: MatchStatsObjectiveSummary;
|
|
bans: Array<{ championId: number; pickTurn: number }>;
|
|
participants: MatchStatsRecord[];
|
|
}>;
|
|
}
|
|
|
|
export interface MatchStatsObjectiveSummary {
|
|
tower: number;
|
|
dragon: number;
|
|
inhibitor: number;
|
|
baron: number;
|
|
riftHerald: number;
|
|
voidGrub: number;
|
|
elderDragon: number;
|
|
}
|
|
|
|
export interface MatchStatsObjectiveEvent {
|
|
timestamp: number;
|
|
side: TeamSide;
|
|
type: 'dragon' | 'elderDragon' | 'baron' | 'riftHerald' | 'voidGrub';
|
|
monsterSubType?: string;
|
|
}
|
|
|
|
export interface MatchStatsChampionKillEvent {
|
|
timestamp: number;
|
|
side?: TeamSide;
|
|
type: 'championKill';
|
|
killerParticipantId?: number;
|
|
victimParticipantId?: number;
|
|
assistingParticipantIds?: number[];
|
|
}
|
|
|
|
export interface MatchStatsBuildingEvent {
|
|
timestamp: number;
|
|
side: TeamSide;
|
|
type: 'tower' | 'inhibitor';
|
|
killerParticipantId?: number;
|
|
towerType?: string;
|
|
}
|
|
|
|
export type MatchStatsTimelineEvent =
|
|
| MatchStatsObjectiveEvent
|
|
| MatchStatsChampionKillEvent
|
|
| MatchStatsBuildingEvent;
|
|
|
|
export interface MatchStatsTimelinePoint {
|
|
timestamp: number;
|
|
blue: { gold: number; xp: number };
|
|
red: { gold: number; xp: number };
|
|
goldDiff: number;
|
|
xpDiff: number;
|
|
}
|
|
|
|
export interface MatchStats extends MongooseTimestamps {
|
|
matchId: mongoose.Types.ObjectId;
|
|
sourceCompetitionId?: mongoose.Types.ObjectId;
|
|
sourceRevision?: number;
|
|
projectorVersion?: number;
|
|
communityId: mongoose.Types.ObjectId;
|
|
scheduledAt: Date;
|
|
gameCreationMin: number;
|
|
gameCreationMax: number;
|
|
userIds: mongoose.Types.ObjectId[];
|
|
championIds: number[];
|
|
matchCard: Record<string, unknown>;
|
|
records: MatchStatsRecord[];
|
|
gameDetails: MatchStatsGameDetail[];
|
|
builtAt: Date;
|
|
builderVersion: number;
|
|
}
|
|
|
|
export type MatchStatsDocument = HydratedDocument<MatchStats>;
|
|
|
|
// ===== Sub-schemas =====
|
|
const PositionPreferenceSubSchema = new Schema<PositionPreference>(
|
|
{
|
|
position: { type: String, enum: POSITIONS, required: true },
|
|
priority: { type: Number, required: true, min: 1 },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const TierInfoSubSchema = new Schema<TierInfo>(
|
|
{
|
|
leagueId: { type: String },
|
|
queueType: { type: String, required: true },
|
|
tier: { type: String, required: true },
|
|
rank: { type: String, required: true, default: '' },
|
|
puuid: { type: String },
|
|
leaguePoints: { type: Number, required: true, default: 0 },
|
|
wins: { type: Number, required: true, default: 0 },
|
|
losses: { type: Number, required: true, default: 0 },
|
|
veteran: { type: Boolean },
|
|
inactive: { type: Boolean },
|
|
freshBlood: { type: Boolean },
|
|
hotStreak: { type: Boolean },
|
|
miniSeries: { type: Schema.Types.Mixed },
|
|
fetchedAt: { type: Date, required: true, default: Date.now },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const TierHistoryEntrySubSchema = new Schema<TierHistoryEntry>(
|
|
{
|
|
queueType: { type: String, required: true },
|
|
tier: { type: String, required: true },
|
|
rank: { type: String },
|
|
leaguePoints: { type: Number },
|
|
wins: { type: Number },
|
|
losses: { type: Number },
|
|
recordedAt: { type: Date, required: true },
|
|
season: { type: String },
|
|
peakTier: { type: String },
|
|
peakRank: { type: String },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const ChampionMasteryEntrySubSchema = new Schema<ChampionMasteryEntry>(
|
|
{
|
|
puuid: { type: String, required: true },
|
|
championId: { type: Number, required: true },
|
|
championLevel: { type: Number, required: true, default: 0 },
|
|
championPoints: { type: Number, required: true, default: 0 },
|
|
lastPlayTime: { type: Number },
|
|
championPointsSinceLastLevel: { type: Number },
|
|
championPointsUntilNextLevel: { type: Number },
|
|
markRequiredForNextLevel: { type: Number },
|
|
tokensEarned: { type: Number },
|
|
championSeasonMilestone: { type: Number },
|
|
milestoneGrades: { type: [String] },
|
|
nextSeasonMilestone: { type: Schema.Types.Mixed },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const RiotLaneStatsSubSchema = new Schema<RiotLaneStats>(
|
|
{
|
|
games: { type: Number, required: true, default: 0 },
|
|
wins: { type: Number, required: true, default: 0 },
|
|
losses: { type: Number, required: true, default: 0 },
|
|
avgKills: { type: Number, required: true, default: 0 },
|
|
avgDeaths: { type: Number, required: true, default: 0 },
|
|
avgAssists: { type: Number, required: true, default: 0 },
|
|
avgCs: { type: Number, required: true, default: 0 },
|
|
avgCsPerMin: { type: Number, required: true, default: 0 },
|
|
mostPlayedChampionIds: { type: [Number], required: true, default: [] },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const RiotRecentStatsByLaneSubSchema = new Schema<
|
|
Partial<Record<RiotLane, RiotLaneStats>>
|
|
>(
|
|
{
|
|
TOP: { type: RiotLaneStatsSubSchema, required: false },
|
|
JUNGLE: { type: RiotLaneStatsSubSchema, required: false },
|
|
MIDDLE: { type: RiotLaneStatsSubSchema, required: false },
|
|
BOTTOM: { type: RiotLaneStatsSubSchema, required: false },
|
|
UTILITY: { type: RiotLaneStatsSubSchema, required: false },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const RiotRecentStatsSummarySubSchema = new Schema<RiotRecentStatsSummary>(
|
|
{
|
|
overall: {
|
|
type: RiotLaneStatsSubSchema,
|
|
required: true,
|
|
default: createEmptyRiotLaneStats,
|
|
},
|
|
byLane: {
|
|
type: RiotRecentStatsByLaneSubSchema,
|
|
required: true,
|
|
default: () => ({}),
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const RiotAccountSubSchema = new Schema<RiotAccount>(
|
|
{
|
|
puuid: { type: String, required: true },
|
|
gameName: { type: String, required: true },
|
|
tagLine: { type: String, required: true },
|
|
profileIconId: { type: Number, required: true, default: 0 },
|
|
revisionDate: { type: Number, required: true, default: 0 },
|
|
summonerLevel: { type: Number, required: true, default: 0 },
|
|
isPrimary: { type: Boolean, required: true, default: false },
|
|
|
|
tiers: { type: [TierInfoSubSchema], required: true, default: [] },
|
|
tierHistory: {
|
|
type: [TierHistoryEntrySubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
|
|
matchIds: { type: [String], required: true, default: [] },
|
|
matchIdsFetchedAt: { type: Date },
|
|
matchIdsByQueueFetchedAt: { type: Map, of: Date },
|
|
lastRefreshRequestedAt: { type: Date },
|
|
|
|
recentStatsSummary: { type: RiotRecentStatsSummarySubSchema },
|
|
recentStatsFetchedAt: { type: Date },
|
|
|
|
championMasteries: {
|
|
type: [ChampionMasteryEntrySubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
championMasteriesFetchedAt: { type: Date },
|
|
|
|
championRecords: {
|
|
type: Schema.Types.Mixed,
|
|
required: true,
|
|
default: () => ({}),
|
|
},
|
|
championRecordsFetchedAt: { type: Date },
|
|
},
|
|
{
|
|
_id: false,
|
|
timestamps: true,
|
|
},
|
|
);
|
|
|
|
export const IdentitySchema = new Schema<Identity>(
|
|
{
|
|
entraOid: { type: String, required: true },
|
|
tenantId: { type: String },
|
|
email: { type: String },
|
|
displayName: { type: String },
|
|
lastSignInAt: { type: Date },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'identity',
|
|
},
|
|
);
|
|
|
|
IdentitySchema.index({ entraOid: 1 }, { unique: true });
|
|
IdentitySchema.index({ email: 1 });
|
|
|
|
export const CommunitySchema = new Schema<Community>(
|
|
{
|
|
name: { type: String, required: true },
|
|
description: { type: String, required: true, default: '' },
|
|
ownerUserId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
dakaoProjectId: { type: Schema.Types.ObjectId },
|
|
riotPlatform: { type: String },
|
|
riotRegion: { type: String },
|
|
seasonStartedAt: { type: Date },
|
|
matchGameCount: { type: Number, required: false, default: 3 },
|
|
seasons: {
|
|
type: [
|
|
new Schema<CommunitySeason>(
|
|
{
|
|
id: { type: String, required: true },
|
|
label: { type: String, required: true },
|
|
startedAt: { type: Date, required: true },
|
|
endedAt: { type: Date },
|
|
},
|
|
{ _id: false },
|
|
),
|
|
],
|
|
required: false,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'community',
|
|
},
|
|
);
|
|
|
|
CommunitySchema.index({ name: 1 }, { unique: true });
|
|
CommunitySchema.index({ ownerUserId: 1 });
|
|
CommunitySchema.index({ dakaoProjectId: 1 }, { unique: true, sparse: true });
|
|
|
|
export const DakaoInboundMessageSchema = new Schema<DakaoInboundMessage>(
|
|
{
|
|
consumer: { type: String, required: true },
|
|
projectId: { type: String, required: true },
|
|
chatLogLogId: { type: String, required: true },
|
|
state: {
|
|
type: String,
|
|
enum: DAKAO_INBOUND_MESSAGE_STATES,
|
|
required: true,
|
|
default: 'processing',
|
|
},
|
|
attempts: { type: Number, required: true, default: 1 },
|
|
processingExpiresAt: { type: Date },
|
|
processedAt: { type: Date },
|
|
lastError: { type: String },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'dakao_inbound_message',
|
|
},
|
|
);
|
|
|
|
DakaoInboundMessageSchema.index(
|
|
{ consumer: 1, projectId: 1, chatLogLogId: 1 },
|
|
{ unique: true },
|
|
);
|
|
DakaoInboundMessageSchema.index({ state: 1, processingExpiresAt: 1 });
|
|
|
|
export const DakaoOutboxMessageSchema = new Schema<DakaoOutboxMessage>(
|
|
{
|
|
eventId: { type: String, required: true, unique: true },
|
|
eventSource: { type: String, required: true },
|
|
type: { type: String, required: true },
|
|
subject: { type: String, required: true },
|
|
correlationId: { type: String },
|
|
resultSubjects: {
|
|
succeeded: { type: String },
|
|
failed: { type: String },
|
|
},
|
|
payload: { type: Schema.Types.Mixed, required: true },
|
|
state: {
|
|
type: String,
|
|
enum: DAKAO_OUTBOX_MESSAGE_STATES,
|
|
required: true,
|
|
default: 'pending',
|
|
},
|
|
publishAttempts: { type: Number, required: true, default: 0 },
|
|
publishLeaseOwnerIdentifier: { type: String },
|
|
publishLeaseExpiresAt: { type: Date },
|
|
publishedAt: { type: Date },
|
|
terminalAt: { type: Date },
|
|
resultEventId: { type: String },
|
|
lastPublishError: { type: String },
|
|
terminalError: { type: Schema.Types.Mixed },
|
|
compensationState: {
|
|
type: String,
|
|
enum: DAKAO_OUTBOX_COMPENSATION_STATES,
|
|
required: true,
|
|
default: 'none',
|
|
},
|
|
compensationReason: { type: String },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'dakao_outbox_message',
|
|
},
|
|
);
|
|
|
|
DakaoOutboxMessageSchema.index({ state: 1, updatedAt: 1 });
|
|
DakaoOutboxMessageSchema.index({
|
|
state: 1,
|
|
publishLeaseExpiresAt: 1,
|
|
updatedAt: 1,
|
|
});
|
|
DakaoOutboxMessageSchema.index({ correlationId: 1 }, { sparse: true });
|
|
|
|
export const DakaoSendResultEventSchema = new Schema<DakaoSendResultEvent>(
|
|
{
|
|
eventId: { type: String, required: true, unique: true },
|
|
requestEventId: { type: String, required: true },
|
|
eventSource: { type: String, required: true },
|
|
requestEventSource: { type: String, required: true },
|
|
type: { type: String, required: true },
|
|
subject: { type: String, required: true },
|
|
status: {
|
|
type: String,
|
|
enum: DAKAO_SEND_RESULT_STATUSES,
|
|
required: true,
|
|
},
|
|
correlationId: { type: String },
|
|
handledAt: { type: Date, required: true },
|
|
providerMessageId: { type: String },
|
|
error: { type: Schema.Types.Mixed },
|
|
raw: { type: Schema.Types.Mixed, required: true },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'dakao_send_result_event',
|
|
},
|
|
);
|
|
|
|
DakaoSendResultEventSchema.index({ requestEventId: 1, status: 1 });
|
|
|
|
export const UserSchema = new Schema<User>(
|
|
{
|
|
communityId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'community',
|
|
required: true,
|
|
},
|
|
identityId: { type: Schema.Types.ObjectId, ref: 'identity' },
|
|
role: {
|
|
type: String,
|
|
enum: COMMUNITY_ROLES,
|
|
required: true,
|
|
default: 'member',
|
|
},
|
|
kakaoTalkId: { type: String },
|
|
kakaoTalkNickname: { type: String },
|
|
discordId: { type: String },
|
|
discordNickname: { type: String },
|
|
riotAccounts: {
|
|
type: [RiotAccountSubSchema],
|
|
required: true,
|
|
default: [],
|
|
validate: [
|
|
{
|
|
validator: function (accounts: RiotAccount[]) {
|
|
const puuids = accounts.map((a) => a.puuid);
|
|
return puuids.length === new Set(puuids).size;
|
|
},
|
|
message: 'Duplicate Riot puuid within a user is not allowed.',
|
|
},
|
|
{
|
|
validator: function (accounts: RiotAccount[]) {
|
|
if (accounts.length === 0) return true;
|
|
const primaryCount = accounts.filter((a) => a.isPrimary).length;
|
|
return primaryCount === 1;
|
|
},
|
|
message:
|
|
'Exactly one Riot account must be marked as primary when accounts exist.',
|
|
},
|
|
],
|
|
},
|
|
preferredPositions: {
|
|
type: [PositionPreferenceSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
isActivated: { type: Boolean, required: true, default: true },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'user',
|
|
},
|
|
);
|
|
|
|
UserSchema.index({ communityId: 1 });
|
|
UserSchema.index({ communityId: 1, role: 1 });
|
|
UserSchema.index(
|
|
{ communityId: 1, identityId: 1 },
|
|
{
|
|
unique: true,
|
|
partialFilterExpression: { identityId: { $type: 'objectId' } },
|
|
},
|
|
);
|
|
UserSchema.index(
|
|
{ identityId: 1 },
|
|
{ partialFilterExpression: { identityId: { $type: 'objectId' } } },
|
|
);
|
|
UserSchema.index(
|
|
{ communityId: 1, kakaoTalkId: 1 },
|
|
{
|
|
unique: true,
|
|
partialFilterExpression: { kakaoTalkId: { $type: 'string' } },
|
|
},
|
|
);
|
|
UserSchema.index(
|
|
{ communityId: 1, discordId: 1 },
|
|
{
|
|
unique: true,
|
|
partialFilterExpression: { discordId: { $type: 'string' } },
|
|
},
|
|
);
|
|
UserSchema.index(
|
|
{ communityId: 1, 'riotAccounts.puuid': 1 },
|
|
{
|
|
unique: true,
|
|
partialFilterExpression: { 'riotAccounts.puuid': { $type: 'string' } },
|
|
},
|
|
);
|
|
|
|
export const RiotMatchSchema = new Schema<RiotMatch>(
|
|
{
|
|
matchId: { type: String, required: true, unique: true },
|
|
gameCreation: { type: Number, required: true, default: 0 },
|
|
gameDuration: { type: Number, required: true, default: 0 },
|
|
gameVersion: { type: String },
|
|
queueId: { type: Number },
|
|
participantPuuids: { type: [String], required: true, default: [] },
|
|
raw: { type: Schema.Types.Mixed, required: true, default: () => ({}) },
|
|
timeline: { type: Schema.Types.Mixed },
|
|
timelineFetchedAt: { type: Date },
|
|
fetchedAt: { type: Date, required: true, default: Date.now },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'riot_match',
|
|
},
|
|
);
|
|
|
|
RiotMatchSchema.index({ participantPuuids: 1, gameCreation: -1 });
|
|
RiotMatchSchema.index({ participantPuuids: 1, queueId: 1, gameCreation: -1 });
|
|
RiotMatchSchema.index({ 'raw.info.tournamentCode': 1 }, { sparse: true });
|
|
|
|
export const TournamentCodeSchema = new Schema<TournamentCode>(
|
|
{
|
|
code: {
|
|
type: String,
|
|
required: true,
|
|
trim: true,
|
|
},
|
|
region: { type: String, required: true, default: 'kr' },
|
|
mapType: {
|
|
type: String,
|
|
enum: TOURNAMENT_MAP_TYPES,
|
|
required: true,
|
|
default: 'SUMMONERS_RIFT',
|
|
},
|
|
teamSize: { type: Number, required: true, default: 5 },
|
|
spectatorType: {
|
|
type: String,
|
|
enum: TOURNAMENT_SPECTATOR_TYPES,
|
|
required: true,
|
|
default: 'ALL',
|
|
},
|
|
metadata: { type: Schema.Types.Mixed },
|
|
expiresAt: { type: Date, required: true },
|
|
state: {
|
|
type: String,
|
|
enum: TOURNAMENT_CODE_STATES,
|
|
required: true,
|
|
default: 'available',
|
|
},
|
|
matchId: { type: Schema.Types.ObjectId, ref: 'match' },
|
|
gameNumber: { type: Number },
|
|
bracketMatchId: { type: String },
|
|
reservedAt: { type: Date },
|
|
usedAt: { type: Date },
|
|
releasedAt: { type: Date },
|
|
voidedAt: { type: Date },
|
|
riotMatchId: { type: String },
|
|
uploadedBy: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
uploadedAt: { type: Date, required: true, default: Date.now },
|
|
source: { type: String },
|
|
notes: { type: String },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'tournament_code',
|
|
},
|
|
);
|
|
|
|
TournamentCodeSchema.index({ code: 1 }, { unique: true });
|
|
TournamentCodeSchema.index({ state: 1, expiresAt: 1 });
|
|
TournamentCodeSchema.index(
|
|
{ matchId: 1, gameNumber: 1 },
|
|
{
|
|
unique: true,
|
|
partialFilterExpression: {
|
|
matchId: { $exists: true },
|
|
gameNumber: { $exists: true },
|
|
state: { $in: ['reserved', 'used'] },
|
|
},
|
|
},
|
|
);
|
|
TournamentCodeSchema.index(
|
|
{ matchId: 1, bracketMatchId: 1 },
|
|
{
|
|
partialFilterExpression: {
|
|
matchId: { $exists: true },
|
|
bracketMatchId: { $exists: true },
|
|
state: { $in: ['reserved', 'used'] },
|
|
},
|
|
},
|
|
);
|
|
TournamentCodeSchema.index({ state: 1, uploadedAt: -1 });
|
|
TournamentCodeSchema.index(
|
|
{ riotMatchId: 1 },
|
|
{
|
|
unique: true,
|
|
partialFilterExpression: { riotMatchId: { $type: 'string' } },
|
|
},
|
|
);
|
|
|
|
const MatchParticipantSubSchema = new Schema<MatchParticipant>(
|
|
{
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
puuid: { type: String },
|
|
gameName: { type: String },
|
|
tagLine: { type: String },
|
|
profileIconId: { type: Number },
|
|
tier: { type: TierInfoSubSchema },
|
|
preferredPositions: {
|
|
type: [PositionPreferenceSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
joinedAt: { type: Date, required: true, default: Date.now },
|
|
excluded: { type: Boolean, required: true, default: false },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchTeamMemberSubSchema = new Schema<MatchTeamMember>(
|
|
{
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
assignedPosition: { type: String, enum: POSITIONS, required: true },
|
|
cost: { type: Number, required: false },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchTeamSubSchema = new Schema<MatchTeam>(
|
|
{
|
|
teamIndex: { type: Number, required: true, min: 1 },
|
|
name: { type: String, required: true },
|
|
captainUserId: { type: Schema.Types.ObjectId, ref: 'user' },
|
|
members: { type: [MatchTeamMemberSubSchema], required: true, default: [] },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchGameResultParticipantSubSchema =
|
|
new Schema<MatchGameResultParticipant>(
|
|
{
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
teamIndex: { type: Number, required: true, min: 1 },
|
|
side: { type: String, enum: TEAM_SIDES, required: true },
|
|
championId: { type: Number, required: true },
|
|
kills: { type: Number, required: true, default: 0 },
|
|
deaths: { type: Number, required: true, default: 0 },
|
|
assists: { type: Number, required: true, default: 0 },
|
|
win: { type: Boolean, required: true, default: false },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchGameResultSubSchema = new Schema<MatchGameResult>(
|
|
{
|
|
gameNumber: { type: Number, required: true },
|
|
bracketMatchId: { type: String, required: false },
|
|
riotMatchId: { type: String, required: true },
|
|
blueTeamIndex: { type: Number, required: true, min: 1 },
|
|
redTeamIndex: { type: Number, required: true, min: 1 },
|
|
winnerTeamIndex: { type: Number, required: true, min: 1 },
|
|
winnerSide: { type: String, enum: TEAM_SIDES, required: true },
|
|
gameCreation: { type: Number, required: true },
|
|
gameDuration: { type: Number, required: true },
|
|
participants: {
|
|
type: [MatchGameResultParticipantSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchSeriesResultSubSchema = new Schema<MatchSeriesResult>(
|
|
{
|
|
bracketMatchId: { type: String, required: false },
|
|
teamAIndex: { type: Number, required: true, min: 1 },
|
|
teamBIndex: { type: Number, required: true, min: 1 },
|
|
teamAWins: { type: Number, required: true, default: 0 },
|
|
teamBWins: { type: Number, required: true, default: 0 },
|
|
winnerTeamIndex: { type: Number, required: false, min: 1 },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchGameAssignmentSubSchema = new Schema<MatchGameAssignment>(
|
|
{
|
|
gameNumber: { type: Number, required: true, min: 1 },
|
|
roundNumber: { type: Number, required: false, min: 1 },
|
|
teamAIndex: { type: Number, required: true, min: 1 },
|
|
teamBIndex: { type: Number, required: true, min: 1 },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationSeedSubSchema = new Schema<DoubleEliminationSeed>(
|
|
{
|
|
seedNumber: { type: Number, required: true, min: 1 },
|
|
teamIndex: { type: Number, required: true, min: 1 },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationBracketMatchSourceSubSchema =
|
|
new Schema<DoubleEliminationBracketMatchSource>(
|
|
{
|
|
type: {
|
|
type: String,
|
|
enum: ['seed', 'winner', 'loser'],
|
|
required: true,
|
|
},
|
|
seedNumber: { type: Number, required: false, min: 1 },
|
|
bracketMatchId: { type: String, required: false },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationBracketMatchDestinationSubSchema =
|
|
new Schema<DoubleEliminationBracketMatchDestination>(
|
|
{
|
|
bracketMatchId: { type: String, required: true },
|
|
position: { type: String, enum: ['A', 'B'], required: true },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationWalkoverSubSchema =
|
|
new Schema<DoubleEliminationWalkover>(
|
|
{
|
|
winnerTeamIndex: { type: Number, required: true, min: 1 },
|
|
reason: { type: String, required: false },
|
|
awardedBy: { type: Schema.Types.ObjectId, ref: 'user' },
|
|
awardedAt: { type: Date, required: true },
|
|
cancelledBy: { type: Schema.Types.ObjectId, ref: 'user' },
|
|
cancelledAt: { type: Date },
|
|
cancelReason: { type: String },
|
|
active: { type: Boolean, required: true, default: true },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationBracketMatchSubSchema =
|
|
new Schema<DoubleEliminationBracketMatch>(
|
|
{
|
|
bracketMatchId: { type: String, required: true },
|
|
gameNumber: { type: Number, required: true, min: 1 },
|
|
gameCount: { type: Number, required: true, min: 1, default: 1 },
|
|
requiredWins: { type: Number, required: true, min: 1, default: 1 },
|
|
bracketSide: {
|
|
type: String,
|
|
enum: DOUBLE_ELIMINATION_BRACKET_SIDES,
|
|
required: true,
|
|
},
|
|
roundNumber: { type: Number, required: true, min: 1 },
|
|
matchNumber: { type: Number, required: true, min: 1 },
|
|
state: {
|
|
type: String,
|
|
enum: DOUBLE_ELIMINATION_BRACKET_MATCH_STATES,
|
|
required: true,
|
|
},
|
|
teamAIndex: { type: Number, required: false, min: 1 },
|
|
teamBIndex: { type: Number, required: false, min: 1 },
|
|
teamASource: {
|
|
type: DoubleEliminationBracketMatchSourceSubSchema,
|
|
required: false,
|
|
},
|
|
teamBSource: {
|
|
type: DoubleEliminationBracketMatchSourceSubSchema,
|
|
required: false,
|
|
},
|
|
winnerAdvancesTo: {
|
|
type: DoubleEliminationBracketMatchDestinationSubSchema,
|
|
required: false,
|
|
},
|
|
loserAdvancesTo: {
|
|
type: DoubleEliminationBracketMatchDestinationSubSchema,
|
|
required: false,
|
|
},
|
|
winnerTeamIndex: { type: Number, required: false, min: 1 },
|
|
loserTeamIndex: { type: Number, required: false, min: 1 },
|
|
completedBy: {
|
|
type: String,
|
|
enum: DOUBLE_ELIMINATION_COMPLETION_TYPES,
|
|
required: false,
|
|
},
|
|
completedAt: { type: Date, required: false },
|
|
walkover: {
|
|
type: DoubleEliminationWalkoverSubSchema,
|
|
required: false,
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationPlacementsSubSchema =
|
|
new Schema<DoubleEliminationPlacements>(
|
|
{
|
|
firstTeamIndex: { type: Number, required: false, min: 1 },
|
|
secondTeamIndex: { type: Number, required: false, min: 1 },
|
|
thirdTeamIndex: { type: Number, required: false, min: 1 },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationEventSubSchema = new Schema<DoubleEliminationEvent>(
|
|
{
|
|
type: {
|
|
type: String,
|
|
enum: DOUBLE_ELIMINATION_EVENT_TYPES,
|
|
required: true,
|
|
},
|
|
bracketMatchId: { type: String, required: false },
|
|
actorUserId: { type: Schema.Types.ObjectId, ref: 'user' },
|
|
reason: { type: String, required: false },
|
|
createdAt: { type: Date, required: true },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const DoubleEliminationBracketSubSchema = new Schema<DoubleEliminationBracket>(
|
|
{
|
|
teamCount: { type: Number, enum: [4, 8], required: true },
|
|
resetFinalEnabled: { type: Boolean, required: true, default: false },
|
|
grandFinalGameCount: { type: Number, enum: [1, 3, 5] },
|
|
resetFinalCreated: { type: Boolean, required: true, default: false },
|
|
seeds: {
|
|
type: [DoubleEliminationSeedSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
bracketMatches: {
|
|
type: [DoubleEliminationBracketMatchSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
placements: {
|
|
type: DoubleEliminationPlacementsSubSchema,
|
|
required: true,
|
|
default: () => ({}),
|
|
},
|
|
events: {
|
|
type: [DoubleEliminationEventSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchResultSubSchema = new Schema<MatchResult>(
|
|
{
|
|
winnerTeamIndex: { type: Number, required: false, min: 1 },
|
|
mvpUserId: { type: Schema.Types.ObjectId, ref: 'user' },
|
|
riotMatchIds: { type: [String], required: true, default: [] },
|
|
games: { type: [MatchGameResultSubSchema], required: true, default: [] },
|
|
seriesResults: {
|
|
type: [MatchSeriesResultSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchResultPollStateSubSchema = new Schema<MatchResultPollState>(
|
|
{
|
|
startedAt: { type: Date, required: true },
|
|
lastPolledAt: { type: Date },
|
|
lastPollOutcome: {
|
|
type: String,
|
|
enum: ['matched', 'not-found', 'failed'],
|
|
required: false,
|
|
},
|
|
matchedCount: { type: Number, required: true, default: 0 },
|
|
expandedToAllPuuids: { type: Boolean, required: true, default: false },
|
|
state: {
|
|
type: String,
|
|
enum: MATCH_RESULT_POLL_STATES,
|
|
required: true,
|
|
default: 'polling',
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchScheduleItemSubSchema = new Schema<MatchScheduleItem>(
|
|
{
|
|
time: { type: String, required: true },
|
|
label: { type: String, required: true },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const MatchLegacyImportSourceSubSchema = new Schema<
|
|
NonNullable<Match['legacyImportSource']>
|
|
>(
|
|
{
|
|
importedAt: { type: Date, required: true },
|
|
importedBy: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
triggeringPuuid: { type: String, required: true },
|
|
jobId: { type: String },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
export const MatchSchema = new Schema<Match>(
|
|
{
|
|
communityId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'community',
|
|
required: true,
|
|
},
|
|
competitionId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'competition',
|
|
required: false,
|
|
},
|
|
shortCode: {
|
|
type: String,
|
|
required: false,
|
|
trim: true,
|
|
uppercase: true,
|
|
minlength: 4,
|
|
maxlength: 6,
|
|
},
|
|
title: { type: String, required: true },
|
|
eventType: { type: String, enum: MATCH_EVENT_TYPES, default: 'inhouse' },
|
|
description: { type: String, required: false, default: '' },
|
|
mapId: { type: Number, required: true, default: 11 },
|
|
status: {
|
|
type: String,
|
|
enum: MATCH_STATUSES,
|
|
required: true,
|
|
default: 'recruiting',
|
|
},
|
|
scheduledAt: { type: Date, required: true },
|
|
maxParticipants: {
|
|
type: Number,
|
|
required: true,
|
|
default: 10,
|
|
min: 10,
|
|
validate: {
|
|
validator: (value: number) =>
|
|
Number.isInteger(value) && value % 10 === 0,
|
|
message: 'maxParticipants must be a multiple of 10.',
|
|
},
|
|
},
|
|
gameCount: { type: Number, required: true, default: 3 },
|
|
gameMode: {
|
|
type: String,
|
|
enum: MATCH_GAME_MODES,
|
|
required: true,
|
|
default: 'pair',
|
|
},
|
|
roundRobinMaxRounds: { type: Number, required: false, min: 1 },
|
|
tournamentCodeIds: {
|
|
type: [{ type: Schema.Types.ObjectId, ref: 'tournamentCode' }],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
gameSchedule: {
|
|
type: [MatchGameAssignmentSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
teamBuiltAt: { type: Date },
|
|
hostUserId: { type: Schema.Types.ObjectId, ref: 'user' },
|
|
participants: {
|
|
type: [MatchParticipantSubSchema],
|
|
required: true,
|
|
default: [],
|
|
validate: {
|
|
validator: function (parts: MatchParticipant[]) {
|
|
const ids = parts.map((p) => p.userId.toString());
|
|
return ids.length === new Set(ids).size;
|
|
},
|
|
message: 'Duplicate participants are not allowed.',
|
|
},
|
|
},
|
|
teams: { type: [MatchTeamSubSchema], required: true, default: [] },
|
|
result: { type: MatchResultSubSchema, required: false },
|
|
resultPollState: {
|
|
type: MatchResultPollStateSubSchema,
|
|
required: false,
|
|
},
|
|
lastCancelledAuctionLifecycleId: { type: String, required: false },
|
|
auctionCancellationCleanupPending: { type: Boolean },
|
|
auctionCancellationCleanupRetryAt: { type: Date },
|
|
auctionCancellationCleanupAttempts: { type: Number },
|
|
auctionCancellationCleanupError: { type: String },
|
|
doubleElimination: {
|
|
type: DoubleEliminationBracketSubSchema,
|
|
required: false,
|
|
},
|
|
legacyImported: { type: Boolean, required: false, default: false },
|
|
legacyImportSource: {
|
|
type: MatchLegacyImportSourceSubSchema,
|
|
required: false,
|
|
},
|
|
prizes: { type: [String], required: true, default: [] },
|
|
notices: { type: [String], required: true, default: [] },
|
|
schedule: {
|
|
type: [MatchScheduleItemSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'match',
|
|
},
|
|
);
|
|
|
|
MatchSchema.index({ communityId: 1, scheduledAt: -1 });
|
|
MatchSchema.index(
|
|
AUCTION_CANCELLATION_CLEANUP_INDEX.key,
|
|
AUCTION_CANCELLATION_CLEANUP_INDEX.options,
|
|
);
|
|
applyCompetitionDomainInvariantIndexes(MatchSchema, 'match');
|
|
MatchSchema.index({ communityId: 1, status: 1, scheduledAt: -1 });
|
|
MatchSchema.index(
|
|
{ communityId: 1, shortCode: 1 },
|
|
{
|
|
unique: true,
|
|
partialFilterExpression: { shortCode: { $type: 'string' } },
|
|
},
|
|
);
|
|
MatchSchema.index({ legacyImported: 1, scheduledAt: -1 });
|
|
MatchSchema.index({ 'result.games.riotMatchId': 1 }, { sparse: true });
|
|
MatchSchema.index({ title: 'text', description: 'text' });
|
|
|
|
const LegacyImportJobMemberOverrideSubSchema =
|
|
new Schema<LegacyImportJobMemberOverride>(
|
|
{
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
puuid: { type: String, required: true },
|
|
startTime: { type: Date, required: true },
|
|
endTime: { type: Date, required: true },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const LegacyImportJobErrorSubSchema = new Schema<LegacyImportJobError>(
|
|
{
|
|
puuid: { type: String },
|
|
matchId: { type: String },
|
|
reason: { type: String, required: true },
|
|
at: { type: Date, required: true, default: Date.now },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
export const LegacyImportJobSchema = new Schema<LegacyImportJob>(
|
|
{
|
|
jobId: { type: String, required: true, unique: true },
|
|
communityId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'community',
|
|
required: true,
|
|
},
|
|
triggeredBy: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
startedAt: { type: Date, required: true, default: Date.now },
|
|
completedAt: { type: Date },
|
|
state: {
|
|
type: String,
|
|
enum: LEGACY_IMPORT_JOB_STATES,
|
|
required: true,
|
|
default: 'pending',
|
|
},
|
|
windowStart: { type: Date, required: true },
|
|
windowEnd: { type: Date, required: true },
|
|
memberOverrides: {
|
|
type: [LegacyImportJobMemberOverrideSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
totalMembers: { type: Number, required: true, default: 0 },
|
|
processedMembers: { type: Number, required: true, default: 0 },
|
|
totalDiscoveredMatchIds: { type: Number, required: true, default: 0 },
|
|
totalImportedMatches: { type: Number, required: true, default: 0 },
|
|
totalSkippedDuplicate: { type: Number, required: true, default: 0 },
|
|
totalErrors: { type: Number, required: true, default: 0 },
|
|
averageMemberSeconds: { type: Number },
|
|
completedMemberJobIds: {
|
|
type: [String],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
errors: {
|
|
type: [LegacyImportJobErrorSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'legacy_import_job',
|
|
suppressReservedKeysWarning: true,
|
|
},
|
|
);
|
|
|
|
LegacyImportJobSchema.index({ communityId: 1, startedAt: -1 });
|
|
LegacyImportJobSchema.index({ communityId: 1, state: 1 });
|
|
LegacyImportJobSchema.index({ jobId: 1, completedMemberJobIds: 1 });
|
|
|
|
const AuctionPlayerSnapshotSubSchema = new Schema<AuctionPlayerSnapshot>(
|
|
{
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
puuid: { type: String, required: true },
|
|
gameName: { type: String, required: true },
|
|
tagLine: { type: String, required: true },
|
|
profileIconId: { type: Number, required: true, default: 0 },
|
|
preferredPositions: {
|
|
type: [PositionPreferenceSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
tiers: { type: [TierInfoSubSchema], required: true, default: [] },
|
|
tierHistory: {
|
|
type: [TierHistoryEntrySubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
masteries: {
|
|
type: [ChampionMasteryEntrySubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
recentStatsSummary: { type: RiotRecentStatsSummarySubSchema },
|
|
passCount: { type: Number, required: true, default: 0 },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const AuctionTeamMemberSubSchema = new Schema<AuctionTeamMember>(
|
|
{
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
assignedPosition: { type: String, enum: POSITIONS, required: true },
|
|
cost: { type: Number, required: true, default: 0 },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const AuctionTeamSubSchema = new Schema<AuctionTeam>(
|
|
{
|
|
teamIndex: { type: Number, required: true, min: 1 },
|
|
captainUserId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
points: { type: Number, required: true, default: 0 },
|
|
members: {
|
|
type: [AuctionTeamMemberSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const RedisAuctionTeamMemberSubSchema = new Schema<RedisAuctionTeamMember>(
|
|
{
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
assignedPosition: { type: String, enum: POSITIONS, required: true },
|
|
memberAcquisitionBidPointAmount: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0,
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const RedisAuctionTeamSubSchema = new Schema<RedisAuctionTeam>(
|
|
{
|
|
teamIndex: { type: Number, required: true, min: 1 },
|
|
name: { type: String, required: false },
|
|
captainUserId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
remainingBidPointAmount: { type: Number, required: true, default: 0 },
|
|
members: {
|
|
type: [RedisAuctionTeamMemberSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const AuctionBidSubSchema = new Schema<AuctionBid>(
|
|
{
|
|
teamIndex: { type: Number, required: true, min: 1 },
|
|
amount: { type: Number, required: true },
|
|
bidderUserId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
timestamp: { type: Date, required: true, default: Date.now },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const AuctionBidHistoryEntrySubSchema = new Schema<AuctionBidHistoryEntry>(
|
|
{
|
|
bidRoundId: { type: String },
|
|
playerUserId: { type: Schema.Types.ObjectId, ref: 'user' },
|
|
bidderTeamIndex: { type: Number, required: true, min: 1 },
|
|
bidPointAmount: { type: Number, required: true },
|
|
bidderUserId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
|
bidPlacedAtTimestampMS: { type: Number, required: true },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
const AuctionChatMessageSubSchema = new Schema<AuctionChatMessage>(
|
|
{
|
|
id: { type: String, required: true },
|
|
userId: { type: Schema.Types.ObjectId, ref: 'user', required: false },
|
|
displayName: { type: String, required: true },
|
|
message: { type: String, required: true },
|
|
sentAt: { type: Date, required: true, default: Date.now },
|
|
},
|
|
{ _id: false },
|
|
);
|
|
|
|
export const AuctionSchema = new Schema<Auction>(
|
|
{
|
|
startupCompleted: { type: Boolean },
|
|
matchSideEffectTransitionId: { type: String },
|
|
currentBidRoundId: { type: String },
|
|
matchId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'match',
|
|
required: true,
|
|
unique: true,
|
|
},
|
|
phase: {
|
|
type: String,
|
|
enum: AUCTION_PHASES,
|
|
required: true,
|
|
default: 'waiting',
|
|
},
|
|
revision: { type: Number, required: true, default: 0, min: 0 },
|
|
auctionEngineVersion: {
|
|
type: String,
|
|
enum: AUCTION_ENGINE_VERSIONS,
|
|
required: false,
|
|
},
|
|
auctionLifecycleId: { type: String, required: false },
|
|
lastAppliedAuctionStateTransitionId: { type: String, required: false },
|
|
currentAuctionHistorySequence: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0,
|
|
min: 0,
|
|
},
|
|
startAuctionRequestId: { type: String, required: false },
|
|
startAuctionStateTransitionId: { type: String, required: false },
|
|
auctionStartedByUserId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'user',
|
|
required: false,
|
|
},
|
|
matchSideEffectStatus: {
|
|
type: String,
|
|
enum: AUCTION_MATCH_SIDE_EFFECT_STATUSES,
|
|
required: true,
|
|
default: 'none',
|
|
},
|
|
matchSideEffectRevision: {
|
|
type: Number,
|
|
required: true,
|
|
default: 0,
|
|
min: 0,
|
|
},
|
|
matchSideEffectError: { type: String, required: false },
|
|
teams: { type: [AuctionTeamSubSchema], required: true, default: [] },
|
|
order: {
|
|
type: [AuctionPlayerSnapshotSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
passedQueue: {
|
|
type: [AuctionPlayerSnapshotSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
auctionRound: { type: Number, required: true, default: 1, min: 1 },
|
|
currentIndex: { type: Number, required: true, default: 0 },
|
|
bids: { type: [AuctionBidSubSchema], required: true, default: [] },
|
|
currentBid: { type: Number, required: true, default: 0 },
|
|
currentBidderTeamIndex: { type: Number, required: false, min: 1 },
|
|
maxTimerSeconds: { type: Number, required: true, default: 30 },
|
|
bidExtensionSeconds: { type: Number, required: true, default: 5, min: 0 },
|
|
currentDeadline: { type: Date, required: false },
|
|
initialPoints: { type: Number, required: true, default: 1000 },
|
|
topTierThreshold: {
|
|
type: String,
|
|
enum: AUCTION_TOP_TIER_THRESHOLDS,
|
|
required: true,
|
|
default: 'NONE',
|
|
},
|
|
manualTopTierUserIds: {
|
|
type: [Schema.Types.ObjectId],
|
|
ref: 'user',
|
|
required: true,
|
|
default: [],
|
|
},
|
|
chatMessages: {
|
|
type: [AuctionChatMessageSubSchema],
|
|
required: true,
|
|
default: [],
|
|
},
|
|
startedAt: { type: Date, required: false },
|
|
completedAt: { type: Date, required: false },
|
|
auctionTeams: {
|
|
type: [RedisAuctionTeamSubSchema],
|
|
required: false,
|
|
default: undefined,
|
|
},
|
|
auctionPlayerOrder: {
|
|
type: [AuctionPlayerSnapshotSubSchema],
|
|
required: false,
|
|
default: undefined,
|
|
},
|
|
passedAuctionPlayerQueue: {
|
|
type: [AuctionPlayerSnapshotSubSchema],
|
|
required: false,
|
|
default: undefined,
|
|
},
|
|
currentAuctionRound: { type: Number, required: false, min: 1 },
|
|
currentAuctionPlayerOrderIndex: { type: Number, required: false, min: 0 },
|
|
auctionBidHistory: {
|
|
type: [AuctionBidHistoryEntrySubSchema],
|
|
required: false,
|
|
default: undefined,
|
|
},
|
|
currentHighestBidPointAmount: { type: Number, required: false, min: 0 },
|
|
currentHighestBidderTeamIndex: { type: Number, required: false, min: 1 },
|
|
currentBidRoundDeadlineTimestampMS: {
|
|
type: Number,
|
|
required: false,
|
|
min: 0,
|
|
},
|
|
maximumBidRoundDurationSeconds: {
|
|
type: Number,
|
|
required: false,
|
|
min: 1,
|
|
},
|
|
bidRoundExtensionSeconds: { type: Number, required: false, min: 0 },
|
|
initialTeamBidPointAmount: { type: Number, required: false, min: 0 },
|
|
topTierAuctionPriorityThreshold: {
|
|
type: String,
|
|
enum: AUCTION_TOP_TIER_THRESHOLDS,
|
|
required: false,
|
|
},
|
|
manualTopTierAuctionPriorityUserIds: {
|
|
type: [Schema.Types.ObjectId],
|
|
ref: 'user',
|
|
required: false,
|
|
default: undefined,
|
|
},
|
|
auctionStartedAtTimestampMS: { type: Number, required: false, min: 0 },
|
|
auctionCompletedAtTimestampMS: { type: Number, required: false, min: 0 },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'auction',
|
|
},
|
|
);
|
|
|
|
export const AuctionHistoryEntrySchema = new Schema<AuctionHistoryEntry>(
|
|
{
|
|
auctionId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'auction',
|
|
required: true,
|
|
index: true,
|
|
},
|
|
matchId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'match',
|
|
required: true,
|
|
index: true,
|
|
},
|
|
sequence: { type: Number, required: true, min: 1 },
|
|
action: {
|
|
type: String,
|
|
enum: AUCTION_ACTION_TYPES,
|
|
required: true,
|
|
},
|
|
auctionStateTransitionId: { type: String, required: false },
|
|
auctionLifecycleId: { type: String, required: false },
|
|
revision: { type: Number, required: false, min: 0 },
|
|
actorUserId: { type: Schema.Types.ObjectId, ref: 'user', required: false },
|
|
snapshotBefore: { type: Schema.Types.Mixed, required: true },
|
|
historyMutation: { type: Schema.Types.Mixed, required: false },
|
|
matchSideEffectMutation: { type: Schema.Types.Mixed, required: false },
|
|
takenAt: { type: Date, required: true, default: Date.now },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'auctionHistory',
|
|
},
|
|
);
|
|
|
|
AuctionHistoryEntrySchema.index({ auctionId: 1, sequence: -1 });
|
|
AuctionHistoryEntrySchema.index(
|
|
{ auctionId: 1, sequence: 1 },
|
|
{ unique: true },
|
|
);
|
|
AuctionHistoryEntrySchema.index(
|
|
{ auctionId: 1, auctionStateTransitionId: 1 },
|
|
{ sparse: true, unique: true },
|
|
);
|
|
|
|
export const AuctionSideEffectApplicationSchema =
|
|
new Schema<AuctionSideEffectApplication>(
|
|
{
|
|
auctionId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'auction',
|
|
required: true,
|
|
index: true,
|
|
},
|
|
matchId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'match',
|
|
required: true,
|
|
index: true,
|
|
},
|
|
auctionStateTransitionId: { type: String, required: true },
|
|
auctionLifecycleId: { type: String, required: true },
|
|
sideEffectType: { type: String, required: true },
|
|
state: {
|
|
type: String,
|
|
enum: AUCTION_SIDE_EFFECT_APPLICATION_STATES,
|
|
required: true,
|
|
default: 'pending',
|
|
},
|
|
payload: { type: Schema.Types.Mixed, required: true, default: {} },
|
|
payloadChecksum: { type: String, required: true },
|
|
attempts: { type: Number, required: true, default: 0, min: 0 },
|
|
processingStartedAtTimestampMS: {
|
|
type: Number,
|
|
required: false,
|
|
min: 0,
|
|
},
|
|
processingLeaseExpiresAtTimestampMS: {
|
|
type: Number,
|
|
required: false,
|
|
min: 0,
|
|
},
|
|
processingOwnerToken: { type: String, required: false },
|
|
completedAtTimestampMS: { type: Number, required: false, min: 0 },
|
|
lastError: { type: String, required: false },
|
|
},
|
|
{
|
|
timestamps: true,
|
|
collection: 'auctionSideEffectApplications',
|
|
},
|
|
);
|
|
|
|
AuctionSideEffectApplicationSchema.index(
|
|
{
|
|
auctionId: 1,
|
|
auctionStateTransitionId: 1,
|
|
sideEffectType: 1,
|
|
},
|
|
{ unique: true },
|
|
);
|
|
AuctionSideEffectApplicationSchema.index({
|
|
state: 1,
|
|
processingLeaseExpiresAtTimestampMS: 1,
|
|
});
|
|
|
|
export const MatchStatsSchema: mongoose.Schema<MatchStats> = new Schema(
|
|
{
|
|
matchId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'match',
|
|
required: true,
|
|
unique: true,
|
|
},
|
|
sourceCompetitionId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'competition',
|
|
required: false,
|
|
},
|
|
sourceRevision: { type: Number, required: false, min: 0 },
|
|
projectorVersion: { type: Number, required: false, min: 1 },
|
|
communityId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'community',
|
|
required: true,
|
|
},
|
|
scheduledAt: { type: Date, required: true },
|
|
gameCreationMin: { type: Number, required: true },
|
|
gameCreationMax: { type: Number, required: true },
|
|
userIds: { type: [Schema.Types.ObjectId], required: true, default: [] },
|
|
championIds: { type: [Number], required: true, default: [] },
|
|
matchCard: { type: Schema.Types.Mixed, required: true },
|
|
records: { type: [Schema.Types.Mixed], required: true, default: [] },
|
|
gameDetails: { type: [Schema.Types.Mixed], required: true, default: [] },
|
|
builtAt: { type: Date, required: true, default: Date.now },
|
|
builderVersion: { type: Number, required: true, default: 1 },
|
|
} as mongoose.SchemaDefinition,
|
|
{ timestamps: true, collection: 'match_stats' },
|
|
) as mongoose.Schema<MatchStats>;
|
|
|
|
MatchStatsSchema.index({ communityId: 1, scheduledAt: -1 });
|
|
MatchStatsSchema.index({
|
|
communityId: 1,
|
|
gameCreationMin: 1,
|
|
gameCreationMax: 1,
|
|
});
|
|
MatchStatsSchema.index({ communityId: 1, userIds: 1 });
|
|
MatchStatsSchema.index({ communityId: 1, userIds: 1, scheduledAt: -1 });
|
|
MatchStatsSchema.index({ communityId: 1, championIds: 1 });
|
|
|
|
export const tournamentModelDefinitions: Array<
|
|
ModelDefinition & { name: keyof TournamentModelTypes }
|
|
> = [
|
|
...competitionModelDefinitions,
|
|
{ name: 'identity', schema: IdentitySchema, schemaName: 'identity' },
|
|
{ name: 'community', schema: CommunitySchema, schemaName: 'community' },
|
|
{
|
|
name: 'dakaoInboundMessage',
|
|
schema: DakaoInboundMessageSchema,
|
|
schemaName: 'dakaoInboundMessage',
|
|
},
|
|
{
|
|
name: 'dakaoOutboxMessage',
|
|
schema: DakaoOutboxMessageSchema,
|
|
schemaName: 'dakaoOutboxMessage',
|
|
},
|
|
{
|
|
name: 'dakaoSendResultEvent',
|
|
schema: DakaoSendResultEventSchema,
|
|
schemaName: 'dakaoSendResultEvent',
|
|
},
|
|
{ name: 'user', schema: UserSchema, schemaName: 'user' },
|
|
{ name: 'riotMatch', schema: RiotMatchSchema, schemaName: 'riotMatch' },
|
|
{
|
|
name: 'tournamentCode',
|
|
schema: TournamentCodeSchema,
|
|
schemaName: 'tournamentCode',
|
|
},
|
|
{
|
|
name: 'legacyImportJob',
|
|
schema: LegacyImportJobSchema,
|
|
schemaName: 'legacyImportJob',
|
|
},
|
|
{ name: 'match', schema: MatchSchema, schemaName: 'match' },
|
|
{ name: 'auction', schema: AuctionSchema, schemaName: 'auction' },
|
|
{
|
|
name: 'auctionBidRecord',
|
|
schema: AuctionBidRecordSchema,
|
|
schemaName: 'auctionBidRecords',
|
|
},
|
|
{
|
|
name: 'auctionHistory',
|
|
schema: AuctionHistoryEntrySchema,
|
|
schemaName: 'auctionHistory',
|
|
},
|
|
{
|
|
name: 'auctionSideEffectApplication',
|
|
schema: AuctionSideEffectApplicationSchema,
|
|
schemaName: 'auctionSideEffectApplication',
|
|
},
|
|
{
|
|
name: 'matchStats',
|
|
schema: MatchStatsSchema,
|
|
schemaName: 'matchStats',
|
|
},
|
|
];
|
|
|
|
export interface TournamentModelTypes {
|
|
competition: Competition;
|
|
competitionFact: CompetitionFact;
|
|
competitionOutbox: CompetitionOutbox;
|
|
tournamentCodeAssignment: TournamentCodeAssignment;
|
|
identity: Identity;
|
|
community: Community;
|
|
dakaoInboundMessage: DakaoInboundMessage;
|
|
dakaoOutboxMessage: DakaoOutboxMessage;
|
|
dakaoSendResultEvent: DakaoSendResultEvent;
|
|
user: User;
|
|
riotMatch: RiotMatch;
|
|
tournamentCode: TournamentCode;
|
|
legacyImportJob: LegacyImportJob;
|
|
match: Match;
|
|
auction: Auction;
|
|
auctionBidRecord: AuctionBidRecord;
|
|
auctionHistory: AuctionHistoryEntry;
|
|
auctionSideEffectApplication: AuctionSideEffectApplication;
|
|
matchStats: MatchStats;
|
|
}
|