wcif-helpers
Version:
Some helpers for WCIF
213 lines (207 loc) • 6.59 kB
TypeScript
type CountryCode = string;
type CurrencyCode = string;
type ResultValue = number;
type Scramble = string;
type ActivityCode = string;
type Role = "delegate" | "trainee-delegate" | "organizer" | string;
type AssignmentCode = "competitor" | "staff-judge" | "staff-scrambler" | "staff-runner" | "staff-dataentry" | "staff-announcer" | string;
type RoundFormat = "1" | "2" | "3" | "5" | "a" | "m" | "h";
interface Extension {
id: string;
specUrl: string;
data: Record<string, unknown>;
}
interface Avatar {
url: string;
thumbUrl: string;
}
interface Assignment {
activityId: number;
assignmentCode: AssignmentCode;
stationNumber: number | null;
}
interface PersonalBest {
eventId: string;
value: ResultValue;
type: "single" | "average";
worldRanking: number;
continentalRanking: number;
nationalRanking: number;
}
interface Registration {
wcaRegistrationId: number;
eventIds: string[];
status: "accepted" | "pending" | "deleted";
guests: number;
comments: string;
administrativeNotes: string;
isCompeting: boolean;
}
interface Person {
registrantId: number;
name: string;
wcaUserId: number;
wcaId: string | null;
countryIso2: CountryCode;
gender: "m" | "f" | "o";
birthdate: string;
email: string;
avatar: Avatar | null;
roles: Role[];
registration: Registration | null;
assignments: Assignment[];
personalBests: PersonalBest[];
extensions: Extension[];
}
interface TimeLimit {
centiseconds: number;
cumulativeRoundIds: string[];
}
interface Cutoff {
numberOfAttempts: number;
resultValue: ResultValue;
}
type ResultCondition = {
type: "resultAchieved";
scope: "single" | "average";
value: ResultValue | null;
} | {
type: "ranking";
scope: "single" | "average";
value: number;
} | {
type: "percent";
scope: "single" | "average";
value: number;
};
type ParticipationSource = {
type: "registrations";
} | {
type: "round";
roundId: string;
resultCondition: ResultCondition;
} | {
type: "linkedRounds";
roundIds: string[];
resultCondition: ResultCondition;
};
interface ReservedPlaces {
nationalities: CountryCode[];
count: number;
}
interface ParticipationRuleset {
participationSource: ParticipationSource | null;
reservedPlaces: ReservedPlaces | null;
}
interface Qualification {
earliestResultDate: string | null;
latestResultDate: string;
resultCondition: ResultCondition;
}
interface Attempt {
value: ResultValue;
reconstruction: string | null;
}
interface Result {
personId: number;
ranking: number | null;
attempts: Attempt[];
best: ResultValue;
average: ResultValue;
}
interface ScrambleSet {
id: number;
scrambles: Scramble[];
extraScrambles: Scramble[];
}
interface Round {
id: string;
linkedRounds: string[] | null;
format: RoundFormat;
timeLimit: TimeLimit | null;
cutoff: Cutoff | null;
participationRuleset: ParticipationRuleset | null;
results: Result[];
scrambleSetCount: number;
scrambleSets: ScrambleSet[];
extensions: Extension[];
}
interface Event {
id: string;
rounds: Round[];
competitorLimit: number | null;
qualification: Qualification | null;
extensions: Extension[];
}
interface Activity {
id: number;
name: string;
activityCode: ActivityCode;
startTime: string;
endTime: string;
childActivities: Activity[];
scrambleSetId: number | null;
extensions: Extension[];
}
interface Room {
id: number;
name: string;
color: string;
activities: Activity[];
extensions: Extension[];
}
interface Venue {
id: number;
name: string;
latitudeMicrodegrees: number;
longitudeMicrodegrees: number;
countryIso2: CountryCode;
timezone: string;
rooms: Room[];
extensions: Extension[];
}
interface Schedule {
startDate: string;
numberOfDays: number;
venues: Venue[];
}
interface RegistrationInfo {
openTime: string;
closeTime: string;
baseEntryFee: number;
currencyCode: CurrencyCode;
onTheSpotRegistration: boolean;
useWcaRegistration: boolean;
}
interface Series {
id: string;
name: string;
shortName: string;
competitionIds: string[];
}
interface Competition {
formatVersion: string;
id: string;
name: string;
shortName: string;
series: Series | null;
persons: Person[];
events: Event[];
schedule: Schedule;
registrationInfo: RegistrationInfo;
competitorLimit: number | null;
extensions: Extension[];
}
declare const getActivityInfoFromSchedule: (roundId: string, wcif: Competition) => null;
declare const getActivityInfoFromScheduleWithRoom: (roundId: string, roomName: string, wcif: Competition) => null;
declare const getGroupInfoByActivityId: (activityId: number, wcif: Competition) => Activity | null;
declare const prettyRoundFormat: (format: string, cutoffAttempts?: number) => string;
declare const getEventInfoFromWcif: (eventId: string, wcif: Competition) => Event | undefined;
declare const getRoundInfoFromWcif: (roundId: string, wcif: Competition) => Round | undefined;
declare const getEventIdFromRoundId: (roundId: string) => string;
declare const getCutoffByRoundId: (roundId: string, wcif: Competition) => Cutoff | null;
declare const getLimitByRoundId: (roundId: string, wcif: Competition) => TimeLimit | null;
declare const getNumberOfAttemptsForRound: (roundId: string, wcif: Competition) => number;
declare const getCompetitionDates: (startDate: Date, numberOfDays: number) => Date[];
declare const getPersonFromWcif: (registrantId: number, wcif: Competition) => Person | undefined;
export { type Activity, type ActivityCode, type Assignment, type AssignmentCode, type Attempt, type Avatar, type Competition, type CountryCode, type CurrencyCode, type Cutoff, type Event, type Extension, type ParticipationRuleset, type ParticipationSource, type Person, type PersonalBest, type Qualification, type Registration, type RegistrationInfo, type ReservedPlaces, type Result, type ResultCondition, type ResultValue, type Role, type Room, type Round, type RoundFormat, type Schedule, type Scramble, type ScrambleSet, type Series, type TimeLimit, type Venue, getActivityInfoFromSchedule, getActivityInfoFromScheduleWithRoom, getCompetitionDates, getCutoffByRoundId, getEventIdFromRoundId, getEventInfoFromWcif, getGroupInfoByActivityId, getLimitByRoundId, getNumberOfAttemptsForRound, getPersonFromWcif, getRoundInfoFromWcif, prettyRoundFormat };