UNPKG

@xcpcio/types

Version:

Types for XCPCIO

274 lines (263 loc) 7.2 kB
/** * ISO8601 String. * @example * '2019-01-01T00:00:00Z' * '2019-01-01T08:00:00+08:00' * '2019-01-01T00:00:00.000Z' */ type DateTimeISO8601String = string; /** * Color HEX. * @example * '#FFFFFF' */ type ColorHEX = string; /** * Color RGB. * @example * 'rgb(255, 255, 255)' */ type ColorRGB = string; /** * Color RGBA. * @example * 'rgba(255, 255, 255, 0.75)' */ type ColorRGBA = string; /** General color format. */ type Color = ColorHEX | ColorRGB | ColorRGBA; type ThemeColor = Color | { light: Color; dark: Color; }; interface Style { /** * Text color. * @defaultValue Determined by renderer. */ text_color?: ThemeColor; /** * Background color. * @defaultValue Determined by renderer. */ background_color?: ThemeColor; } interface BalloonColor { color: Color; background_color: Color; } /** * i18n string set. * @example * { "en-US": 'English', "zh-CN": '中文', fallback: 'English' } */ interface I18NStringSet { /** The fallback string if renderer cannot determine the language to use. */ fallback: string; /** The key is the IETF BCP 47 language tag, and the value is the string for this language tag. */ [key: string]: string; } /** * Text (i18n supported). */ type Text = string | I18NStringSet; /** * Contributor field. The email and url are optional. * @example * 'bLue <mail@example.com> (https://example.com/)' */ type Contributor = string; type Base64 = string; type LinkString = string; type ImagePreset = "ICPC" | "CCPC" | "HUNAN_CPC"; interface Link { link: LinkString; title?: string; } interface Image { url?: string; base64?: Base64; type?: "png" | "svg" | "jpg" | "jpeg"; preset?: ImagePreset; [key: string]: string | undefined; } interface StatusTimeDisplay { correct: boolean; incorrect: boolean; pending: boolean; } type TimeUnit = "second" | "millisecond" | "microsecond" | "nanosecond"; interface Problem { id: string; label: string; name?: string; time_limit?: string; memory_limit?: string; balloon_color?: BalloonColor; } type Problems = Array<Problem>; declare enum ContestState { PENDING = "PENDING", RUNNING = "RUNNING", FROZEN = "FROZEN", FINISHED = "FINISHED", PAUSED = "PAUSED" } type CalculationOfPenalty = "in_minutes" | "in_seconds" | "accumulate_in_seconds_and_finally_to_the_minute"; interface ContestOptions { calculation_of_penalty?: CalculationOfPenalty; submission_timestamp_unit?: TimeUnit; submission_has_reaction?: boolean; has_reaction_videos?: boolean; reaction_video_url_template?: string; } type MedalPreset = "ccpc" | "icpc"; type BannerMode = "ONLY_BANNER" | "ALL"; interface Contest { contest_name: string; start_time: number | DateTimeISO8601String; end_time: number | DateTimeISO8601String; penalty: number; freeze_time?: number | DateTimeISO8601String; frozen_time?: number; problems?: Array<Problem>; problem_id?: Array<string>; organization?: string; status_time_display?: Record<string, boolean>; badge?: string; medal?: Record<string, Record<string, number>> | MedalPreset; balloon_color?: Array<BalloonColor>; group?: Record<string, string>; tag?: Record<string, string>; logo?: Image; banner?: Image; banner_mode?: BannerMode; board_link?: string; version?: string; options?: ContestOptions; } interface ContestIndexConfig { contest_name: string; start_time: number; end_time: number; frozen_time: number; logo: Image; } interface ContestIndex { config: ContestIndexConfig; board_link: string; } type Lang = "en" | "zh-CN"; interface IPerson { name: string; } type IPersons = Array<IPerson>; interface IRatingIndex { id: string; name: string; } interface IRatingHistory { rank: number; rating: number; teamName: string; organization: string; members: IPersons; coaches: IPersons; contestID: string; contestName: string; contestLink: string; contestTime: Date; } interface IRatingUser { id: string; name: string; organization: string; members: IPersons; coaches: IPersons; rating: number; minRating: number; maxRating: number; ratingHistories: IRatingHistory[]; } interface IRating { id: string; name: string; baseRating: number; contestIDs: string[]; users: IRatingUser[]; } declare enum SubmissionStatus { PENDING = "PENDING", WAITING = "WAITING", PREPARING = "PREPARING", COMPILING = "COMPILING", RUNNING = "RUNNING", JUDGING = "JUDGING", FROZEN = "FROZEN", ACCEPTED = "ACCEPTED", CORRECT = "CORRECT", PARTIALLY_CORRECT = "PARTIALLY_CORRECT", REJECTED = "REJECTED", WRONG_ANSWER = "WRONG_ANSWER", NO_OUTPUT = "NO_OUTPUT", COMPILATION_ERROR = "COMPILATION_ERROR", PRESENTATION_ERROR = "PRESENTATION_ERROR", RUNTIME_ERROR = "RUNTIME_ERROR", TIME_LIMIT_EXCEEDED = "TIME_LIMIT_EXCEEDED", MEMORY_LIMIT_EXCEEDED = "MEMORY_LIMIT_EXCEEDED", OUTPUT_LIMIT_EXCEEDED = "OUTPUT_LIMIT_EXCEEDED", IDLENESS_LIMIT_EXCEEDED = "IDLENESS_LIMIT_EXCEEDED", HACKED = "HACKED", JUDGEMENT_FAILED = "JUDGEMENT_FAILED", CONFIGURATION_ERROR = "CONFIGURATION_ERROR", FILE_ERROR = "FILE_ERROR", SYSTEM_ERROR = "SYSTEM_ERROR", CANCELED = "CANCELED", SKIPPED = "SKIPPED", SECURITY_VIOLATED = "SECURITY_VIOLATED", DENIAL_OF_JUDGEMENT = "DENIAL_OF_JUDGEMENT", UNKNOWN = "UNKNOWN", UNDEFINED = "UNDEFINED" } declare const SubmissionStatusToString: { [key in SubmissionStatus]: string; }; declare const SubmissionStatusToSimpleString: { [key in SubmissionStatus]: string; }; interface SubmissionReaction { url: string; } interface Submission { id?: string; submission_id?: string; team_id: string; problem_id: number | string; timestamp: number; status: SubmissionStatus | string; time?: number; language?: string; is_ignore?: boolean; reaction?: SubmissionReaction; } type Submissions = Array<Submission> | Record<string, Submission>; interface Team { id?: string; team_id?: string; name?: string; team_name?: string; organization?: string; group?: Array<string>; tag?: Array<string>; coach?: string | Array<string>; members?: string | Array<string>; official?: boolean; unofficial?: boolean; girl?: boolean; badge?: Image; location?: string; icpc_id?: string; } type Teams = Array<Team> | Record<string, Team>; export { ContestState, SubmissionStatus, SubmissionStatusToSimpleString, SubmissionStatusToString }; export type { BalloonColor, BannerMode, Base64, CalculationOfPenalty, Color, ColorHEX, ColorRGB, ColorRGBA, Contest, ContestIndex, ContestIndexConfig, ContestOptions, Contributor, DateTimeISO8601String, I18NStringSet, IPerson, IPersons, IRating, IRatingHistory, IRatingIndex, IRatingUser, Image, ImagePreset, Lang, Link, LinkString, MedalPreset, Problem, Problems, StatusTimeDisplay, Style, Submission, SubmissionReaction, Submissions, Team, Teams, Text, ThemeColor, TimeUnit };