-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
626 lines (521 loc) · 13.7 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
/*! *****************************************************************************
Copyright (c) algoUX. All rights reserved.
***************************************************************************** */
export type Type = 'general';
export type Version = '0.3.4';
//#region common
/**
* ISO8601 String.
* @example
* '2019-01-01T00:00:00Z'
* '2019-01-01T08:00:00+08:00'
* '2019-01-01T00:00:00.000Z'
*/
export type DatetimeISOString = string;
/** Time unit. */
export type TimeUnit = 'ms' | 's' | 'min' | 'h' | 'd';
/**
* Time duration.
* @example
* [25, 'ms'] // 25ms
* [2, 's'] // 2s
* [60, 's'] // 1m
*/
export type TimeDuration = [number, TimeUnit];
/**
* i18n string set.
* @example
* { "en-US": 'English', "zh-CN": '中文', fallback: 'English' }
*/
export type 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).
*/
export type Text = string | I18NStringSet;
/** URL. */
export type Link = string;
/**
* Link with title.
* @example
* { link: 'https://icpc.baylor.edu/', title: 'ICPC Home Page' }
*/
export interface LinkWithTitle {
link: Link;
title: Text;
}
/** Base64 string. */
export type Base64 = string;
/** Image. */
export type Image = Link | Base64;
/** Image with link. */
export interface ImageWithLink {
image: Image;
link: Link;
}
/**
* Color HEX.
* @example
* '#FFFFFF'
*/
export type ColorHEX = string;
/**
* Color RGB.
* @example
* 'rgb(255, 255, 255)'
*/
export type ColorRGB = string;
/**
* Color RGBA.
* @example
* 'rgba(255, 255, 255, 0.75)'
*/
export type ColorRGBA = string;
/** General color format. */
export type Color = ColorHEX | ColorRGB | ColorRGBA;
/** Theme color. If only one color (for light theme) provided, the color for dark theme will be same as the light. */
export type ThemeColor =
| Color
| {
light: Color;
dark: Color;
};
export interface Style {
/**
* Text color.
* @defaultValue Determined by renderer.
*/
textColor?: ThemeColor;
/**
* Background color.
* @defaultValue Determined by renderer.
*/
backgroundColor?: ThemeColor;
}
/**
* Contributor field. The email and url are optional.
* @example
* 'bLue <mail@example.com> (https://example.com/)'
*/
export type Contributor = string;
//#endregion common
//#region ranklist
export interface ExternalUser {
/** Username. */
name: Text;
/**
* User avatar.
* @defaultValue Ignored by renderer.
*/
avatar?: Image;
/**
* The link to view user.
* @defaultValue Ignored by renderer.
*/
link?: string;
}
export interface User {
/** Unique ID for each user. */
id: string;
/** Username. */
name: Text;
/**
* Determines whether the user is official. If it's false, the user's rank will not be calculated in ranklist.
* @defaultValue true
*/
official?: boolean;
/**
* User avatar.
* @defaultValue Ignored by renderer.
*/
avatar?: Image;
/**
* Organization.
* @defaultValue Ignored by renderer.
*/
organization?: Text;
/**
* Team members.
* @defaultValue []
*/
teamMembers?: ExternalUser[];
/**
* Marker id for this user.
* @defaultValue Ignored by renderer.
*/
marker?: string;
}
export interface ProblemStatistics {
/** The number of accepted solutions totally. */
accepted: number;
/** The number of submitted solutions totally. */
submitted: number;
}
export interface Problem {
/**
* Problem title.
* @defaultValue Ignored by renderer.
*/
title?: Text;
/**
* Specifies an alias for problem.
* @defaultValue Determined by renderer.
* @example
* 'A'
* 'B'
* '1-1'
*/
alias?: string;
/**
* The link to view problem.
* @defaultValue Ignored by renderer.
*/
link?: Link;
/** Problem statistics. */
statistics?: ProblemStatistics;
/**
* Custom style on ranklist table header.
* @defaultValue Determined by renderer.
*/
style?: Style;
}
/**
* Solution result lite preset.
* 'FB' means "First Blood", the first to solve.
* 'AC' means accepted.
* 'RJ' means rejected.
* '?' means the result is frozen.
* null means no solutions submitted yet.
*/
export type SolutionResultLite = 'FB' | 'AC' | 'RJ' | '?' | null;
/**
* Solution result full preset.
* 'WA' means "Wrong Answer".
* 'PE' means "Presentation Error".
* 'TLE' means "Time Limit Exceeded".
* 'MLE' means "Memory Limit Exceeded".
* 'OLE' means "Output Limit Exceeded".
* 'RTE' means "Runtime Error".
* 'NOUT' means "No Output".
* 'CE' means "Compilation error".
* 'UKE' means "Unknown Error".
*/
export type SolutionResultFull =
| SolutionResultLite
| 'WA'
| 'PE'
| 'TLE'
| 'MLE'
| 'OLE'
| 'RTE'
| 'NOUT'
| 'CE'
| 'UKE';
/** Solution result custom (allows any string). */
export type SolutionResultCustom = string;
export interface Solution {
/** Result. */
result: Exclude<SolutionResultFull, null> | SolutionResultCustom;
/**
* The score.
* @defaultValue Ignored by renderer.
*/
score?: number;
/** Submission time. */
time: TimeDuration;
/**
* The link to view solution.
* @defaultValue Ignored by renderer.
*/
link?: Link;
}
export interface Contest {
/** Contest title. */
title: Text;
/** Start time. */
startAt: DatetimeISOString;
/** Contest duration. */
duration: TimeDuration;
/**
* Ranklist frozen duration.
* @defaultValue [0, 's']
*/
frozenDuration?: TimeDuration;
/** Banner image. */
banner?: Image | ImageWithLink;
/**
* Reference links of contest.
* @defaultValue Ignored by renderer.
*/
refLinks?: LinkWithTitle[];
}
/** Rank series segment style preset. The style value will be determined by renderer. */
export type RankSeriesSegmentStylePreset =
| 'gold'
| 'silver'
| 'bronze'
| 'iron';
export interface RankSeriesSegment {
/**
* Segment title.
* @defaultValue Ignored by renderer.
*/
title?: string;
/**
* Custom style on ranklist table body.
* @defaultValue Determined by renderer.
*/
style?: Style | RankSeriesSegmentStylePreset;
}
/**
* A series preset which is used to generate rank without any special process.
* This preset will directly assign rank to each user in ascending order if their scores are different.
*/
export interface RankSeriesRulePresetNormal {
preset: 'Normal';
options?: {
/**
* Whether to include official users only.
* @defaultValue false
*/
includeOfficialOnly?: boolean;
};
}
/**
* A series preset which is used to generate rank by unique user field value.
* This preset will pick a subset of users with different specified user field values to assign rank in scending order.
* If multiple users have the same value of the field, only the first one will be picked.
*/
export interface RankSeriesRulePresetUniqByUserField {
preset: 'UniqByUserField';
options: {
/**
* Specify the field name of `user`.
* @example 'organization'
*/
field: keyof User;
/**
* Whether to include official users only.
* @defaultValue false
*/
includeOfficialOnly?: boolean;
};
}
/**
* A series preset which is used to generate rank by ICPC rules.
* This preset will calculate rank by classic ICPC rules.
*/
export interface RankSeriesRulePresetICPC {
preset: 'ICPC';
options: {
/**
* Use ratio algorithm to calculate rank.
* This algorithm will assign rank based on ratio.
*
* For example, if there are 240 users and the medal segment size are 10%, 20%, 30% of total user number,
* then the rank of the first 24 users will win gold medal (the first segment),
* the rank of the next 48 users will win silver medal (the second segment), and so on.
*
* Note that if multi algorithms specified, the segment will only be assigned if all algorithms are satisfied.
*/
ratio?: {
/**
* The ratio size of each segment.
* @example [0.1, 0.2, 0.3]
*/
value: number[];
/**
* The rounding method.
*
* For example, if their are 248 users and the ratio values are 10%, 20%, 30%,
* then there should be 24.8 users assigned the first segment.
* If the rounding method is 'ceil', actually the first 25 users will be assigned the first segment.
* If the rounding method is 'floor', actually the first 24 users will be assigned the first segment.
* If the rounding method is 'round', actually the first 25 users will be assigned the first segment.
* @defaultValue 'ceil'
*/
rounding?: 'floor' | 'ceil' | 'round';
/**
* Specify how to count the denominator (total user number).
* If the value is 'all', the denominator will be the total user number.
* If the value is 'submitted', the denominator will be number of users which have submitted at least one solution.
* @defaultValue 'all'
*/
denominator?: 'all' | 'submitted';
/**
* Whether force no tied for rank segments calculation.
* For example, if the tied ranks are [1, 1, 3, 4] and the option is true, the ranks will be fixed to [1, 2, 3, 4] then calculate.
*/
noTied?: boolean
};
/**
* Use count algorithm to calculate rank.
* This algorithm will assign rank based on fixed number, i.e. each segment will have the fixed size.
*/
count?: {
/**
* The fixed size of each segment.
* @example [24, 48, 72]
*/
value: number[];
/**
* Whether force no tied for rank segments calculation.
* For example, if the tied ranks are [1, 1, 3, 4] and the option is true, the ranks will be fixed to [1, 2, 3, 4] then calculate.
*/
noTied?: boolean;
};
/**
* Use filter to determine users to be included.
* Only if the user matches all filter options, it will be included as denominator.
*/
filter?: {
byUserFields?: {
/**
* The field name of `user` to be filtered.
* @example 'organization'
*/
field: keyof User;
/**
* The field match rule (RegExp constructor string) of `user` to be filtered.
* @example 'SDUT'
*/
rule: string;
}[];
},
};
}
export type RankSeriesRulePreset =
| RankSeriesRulePresetNormal
| RankSeriesRulePresetUniqByUserField
| RankSeriesRulePresetICPC;
export interface RankSeries {
/**
* Series title on ranklist table header.
* @defaultValue Generated by renderer.
*/
title?: string;
/**
* Series segments.
* @defaultValue []
*/
segments?: RankSeriesSegment[];
/**
* Calculation rule for this series.
*/
rule?: RankSeriesRulePreset;
}
export interface RankScore {
/** The total score value. */
value: number;
/** Time used totally. */
time?: TimeDuration;
}
export interface RankProblemStatus {
/** Latest confirmed result. */
result: SolutionResultLite;
/** The score. */
score?: number;
/** The time of result. */
time?: TimeDuration;
/** The tries count. */
tries?: number;
/**
* Solutions for this problem (sorted by submission time in ascending order).
* If no solutions provided, auto-sort feature will be disabled.
* @defaultValue []
*/
solutions?: Solution[];
}
export interface RanklistRow {
/** User info. */
user: User;
/** Score. */
score: RankScore;
/** Problem statuses. Each one corresponding to a problem. */
statuses: RankProblemStatus[];
}
/** Marker style preset. The style value will be determined by renderer. */
export type MarkerStylePreset =
| 'red'
| 'orange'
| 'yellow'
| 'green'
| 'blue'
| 'purple'
| 'pink';
/** Marker to mark the specified user. */
export interface Marker {
/** Marker id. */
id: string;
/** Marker label to display. */
label: Text;
/** Custom style for marker. */
style: Style | MarkerStylePreset;
}
export interface SorterBase {}
export interface SorterICPC extends SorterBase {
algorithm: 'ICPC';
config: {
/**
* Penalty time per extra tries before the first accepted solution.
* @defaultValue [20, 'min']
*/
penalty?: TimeDuration;
/**
* No penalty solution result list.
* @defaultValue ['FB', 'AC', '?', 'NOUT', 'CE', 'UKE', null]
*/
noPenaltyResults?: SolutionResultFull[];
/**
* Time precision when calculating ranklist.
*
* For example, if the time unit of raw statuses is 's' (second) and the target time unit is 'min' (minute),
* then the time will be converted to minutes before calculating ranklist.
* @defaultValue No converting, based on raw precision of statuses data
*/
timePrecision?: TimeUnit;
/**
* The rounding method when converting time unit to specified time precision.
* @defaultValue 'floor'
*/
timeRounding?: 'floor' | 'ceil' | 'round';
};
}
export interface SorterScore extends SorterBase {
algorithm: 'score';
config: any;
}
/** Sorter type. */
export type Sorter = SorterICPC | SorterScore;
export interface Ranklist {
/** Ranklist type. */
type: Type | string;
/** Ranklist version for current type. */
version: Version | string;
/** Contest info. */
contest: Contest;
/** Problems info. */
problems: Problem[];
/** Rank series. */
series: RankSeries[];
/** Ranklist data. */
rows: RanklistRow[];
/**
* Available markers.
* @defaultValue []
*/
markers?: Marker[];
/** Sorter. If no sorter specified, any extra auto-sort feature will be disabled by renderer. */
sorter?: Sorter;
/** Contributors. */
contributors?: Contributor[];
/** Remarks of the ranklist. */
remarks?: Text;
/** Current time. Used for real-time ranklist. */
_now?: DatetimeISOString;
}
//#endregion ranklist