codeforces-plus
Version:
A Typescript library to simplify Codeforces API
306 lines (305 loc) • 8.59 kB
TypeScript
export type BlogEntryCommentsParams = {
blogEntryId: number;
};
export type BlogEntryViewParams = {
blogEntryId: number;
};
export type ContestHacksParams = {
contestId: number;
asManager?: boolean;
};
export type ContestListParams = {
gym: boolean;
};
export type ContestRatingChangesParams = {
contestId: number;
};
export type ContestStandingsParams = {
contestId: number;
asManager?: boolean;
from?: number;
count?: number;
handles?: string;
room?: string;
showUnofficial?: boolean;
participantTypes?: "CONTESTANT" | "PRACTICE" | "VIRTUAL" | "MANAGER" | "OUT_OF_COMPETITION";
};
export type ContestStatusParams = {
contestId: number;
asManager?: boolean;
handle?: string;
from?: number;
count?: number;
};
export type ProblemsetProblemsParams = {
tags: string;
peoblemsetName: string;
};
export type ProblemsetRecentStatusParams = {
count: number;
problemsetName?: string;
};
export type RecentActionsParams = {
maxCount: number;
};
export type UserBlogEntriesParams = {
handle: string;
};
export type UserFriendsParams = {
onlyOnline?: boolean;
};
export type UserInfoParams = {
handles: string;
checkHistoricHandles?: boolean;
};
export type UserRatedListParams = {
activeOnly?: boolean;
includeRetired?: boolean;
contestId?: number;
};
export type UserRatingParams = {
handle: string;
};
export type UserStatusParams = {
handle: string;
from?: number;
count?: number;
};
export type Method = "blogEntry.comments" | "blogEntry.view" | "contest.hacks" | "contest.list" | "contest.ratingChanges" | "contest.standings" | "contest.status" | "problemset.problems" | "problemset.recentStatus" | "recentActions" | "user.blogEntries" | "user.friends" | "user.info" | "user.ratedList" | "user.rating" | "user.status";
export type MethodParams = {
"blogEntry.comments": BlogEntryCommentsParams;
"blogEntry.view": BlogEntryViewParams;
"contest.hacks": ContestHacksParams;
"contest.list": ContestListParams;
"contest.ratingChanges": ContestRatingChangesParams;
"contest.standings": ContestStandingsParams;
"contest.status": ContestStatusParams;
"problemset.problems": ProblemsetProblemsParams;
"problemset.recentStatus": ProblemsetRecentStatusParams;
"recentActions": RecentActionsParams;
"user.blogEntries": UserBlogEntriesParams;
"user.friends": UserFriendsParams;
"user.info": UserInfoParams;
"user.ratedList": UserRatedListParams;
"user.rating": UserRatingParams;
"user.status": UserStatusParams;
};
export type User = {
handle: string;
email?: string;
vkId?: string;
openId?: string;
firstName?: string;
lastName?: string;
country?: string;
city?: string;
organization?: string;
contribution: number;
rank: string;
rating: number;
maxRank: string;
maxRating: number;
lastOnlineTimeSeconds: number;
registrationTimeSeconds: number;
friendOfCount: number;
avatar: string;
titlePhoto: string;
};
export type BlogEntry = {
id: number;
originalLocale: string;
creationTimeSeconds: number;
authorHandle: string;
title: string;
content?: string;
locale: string;
modificationTimeSeconds: number;
allowViewHistory: boolean;
tags: string[];
rating: number;
};
export type Comment = {
id: number;
creationTimeSeconds: number;
commentatorHandle: string;
locale: string;
text: string;
parentCommentId?: number;
rating: number;
};
export type RecentAction = {
timeSeconds: number;
blogEntry?: BlogEntry;
comment?: Comment;
};
export type RatingChange = {
contestId: number;
contestName: string;
handle: string;
rank: number;
ratingUpdateTimeSeconds: number;
oldRating: number;
newRating: number;
};
export type Contest = {
id: number;
name: string;
type: "CF" | "IOI" | "ICPC";
phase: "BEFORE" | "CODING" | "PENDING_SYSTEM_TEST" | "SYSTEM_TEST" | "FINISHED";
frozen: boolean;
durationSeconds: number;
startTimeSeconds?: number;
relativeTimeSeconds?: number;
preparedBy?: string;
websiteUrl?: string;
description?: string;
difficulty?: number;
kind?: string;
icpcRegion?: string;
country?: string;
city?: string;
season?: string;
};
export type Member = {
handle: string;
name?: string;
};
export type Party = {
contestId?: number;
members: Member[];
participantType: "CONTESTANT" | "PRACTICE" | "VIRTUAL" | "MANAGER" | "OUT_OF_COMPETITION";
teamId?: number;
teamName?: string;
ghost: boolean;
room?: number;
startTimeSeconds?: number;
};
export type Problem = {
contestId?: number;
problemsetName?: string;
index: string;
name: string;
type: "PROGRAMMING" | "QUESTION";
points?: number;
rating?: number;
tags: string[];
};
export type ProblemStatistics = {
contestId?: number;
index: string;
solvedCount: number;
};
export type Submission = {
id: number;
contestId?: number;
creationTimeSeconds: number;
relativeTimeSeconds: number;
problem: Problem;
author: Party;
programmingLanguage: string;
verdict?: "FAILED" | "OK" | "PARTIAL" | "COMPILATION_ERROR" | "RUNTIME_ERROR" | "WRONG_ANSWER" | "PRESENTATION_ERROR" | "TIME_LIMIT_EXCEEDED" | "MEMORY_LIMIT_EXCEEDED" | "IDLENESS_LIMIT_EXCEEDED" | "SECURITY_VIOLATED" | "CRASHED" | "INPUT_PREPARATION_CRASHED" | "CHALLENGED" | "SKIPPED" | "TESTING" | "REJECTED";
testset: "SAMPLES" | "PRETESTS" | "TESTS" | "CHALLENGES" | "TESTS1" | "TESTS2" | "TESTS3" | "TESTS4" | "TESTS5" | "TESTS6" | "TESTS7" | "TESTS8" | "TESTS9" | "TESTS10";
passedTestCount: number;
timeConsumedMillis: number;
memoryConsumedBytes: number;
points?: number;
};
export type Hack = {
id: number;
creationTimeSeconds: number;
hacker: Party;
defender: Party;
verdict?: "HACK_SUCCESSFUL" | "HACK_UNSUCCESSFUL" | "INVALID_INPUT" | "GENERATOR_INCOMPILABLE" | "GENERATOR_CRASHED" | "IGNORED" | "TESTING" | "OTHER";
problem: Problem;
test?: string;
judgeProtocol?: {
manual: boolean;
protocol: string;
verdict: string;
};
};
export type RanklistRow = {
party: Party;
rank: number;
points: number;
penalty: number;
successfulHackCount: number;
unsuccessfulHackCount: number;
problemResults: ProblemResult[];
lastSubmissionTimeSeconds?: number;
};
export type ProblemResult = {
points: number;
penalty?: number;
rejectedAttemptCount: number;
type: "PRELIMINARY" | "FINAL";
bestSubmissionTimeSeconds?: number;
};
export type MethodResponse = {
"blogEntry.comments": Comment[];
"blogEntry.view": BlogEntry;
"contest.hacks": Hack[];
"contest.list": Contest[];
"contest.ratingChanges": RatingChange[];
"contest.standings": {
contest: Contest;
problems: Problem[];
rows: RanklistRow[];
};
"contest.status": Submission[];
"problemset.problems": {
problems: Problem[];
problemStastics: ProblemStatistics[];
};
"problemset.recentStatus": Submission[];
"recentActions": RecentAction[];
"user.blogEntries": BlogEntry[];
"user.friends": string[];
"user.info": User[];
"user.ratedList": User[];
"user.rating": RatingChange[];
"user.status": Submission[];
};
export type ApiResponse<T extends Method> = {
status: "OK" | "FAILED";
comment?: string;
result?: MethodResponse[T];
queryUrl: string;
error?: string;
};
export type Creds = {
readonly apiKey: string;
readonly apiSecret: string;
};
export type FetchCodeforcesData<T extends Method> = {
creds?: Creds | undefined;
method: T;
props: MethodParams[T];
};
declare const participants: readonly ["CONTESTANT", "PRACTICE", "VIRTUAL", "MANAGER", "OUT_OF_COMPETITION"];
export type MakeLeaderboard = {
creds?: Creds;
contestIds: number[];
asManager?: boolean;
from?: number;
count?: number;
participantTypes: typeof participants[number][];
};
export type IUser = {
[handle: string]: {
acceptedCount: number;
totalSubmissionTime: number;
totalPenality: number;
totalWrongs: number;
submissions: {
[problem: string]: {
contestId: number;
accepted: boolean;
wrongs: number;
time: number;
};
};
profileLink: string;
};
};
export {};