@juki-team/commons 0.1.46 → 0.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/{types/constants → constants}/commons.d.ts +1 -1
  2. package/dist/constants/commons.js +648 -0
  3. package/dist/{types/constants → constants}/contest.d.ts +1 -1
  4. package/dist/constants/contest.js +28 -0
  5. package/dist/{types/constants → constants}/course.d.ts +1 -1
  6. package/dist/constants/course.js +12 -0
  7. package/dist/constants/date.js +23 -0
  8. package/dist/constants/email.js +34 -0
  9. package/dist/{types/constants → constants}/entity.d.ts +1 -1
  10. package/dist/constants/entity.js +18 -0
  11. package/dist/{types/constants → constants}/file.d.ts +1 -1
  12. package/dist/constants/file.js +45 -0
  13. package/dist/constants/index.d.ts +18 -0
  14. package/dist/constants/index.js +18 -0
  15. package/dist/{types/constants → constants}/judge.d.ts +1 -1
  16. package/dist/constants/judge.js +225 -0
  17. package/dist/{types/constants → constants}/organization.d.ts +1 -1
  18. package/dist/constants/organization.js +24 -0
  19. package/dist/{types/constants → constants}/problem.d.ts +1 -1
  20. package/dist/constants/problem.js +69 -0
  21. package/dist/constants/routing.js +7 -0
  22. package/dist/{types/constants → constants}/services.d.ts +1 -1
  23. package/dist/constants/services.js +157 -0
  24. package/dist/{types/constants → constants}/system.d.ts +1 -1
  25. package/dist/constants/system.js +9 -0
  26. package/dist/{types/constants → constants}/teams.d.ts +1 -1
  27. package/dist/constants/teams.js +17 -0
  28. package/dist/constants/time.js +9 -0
  29. package/dist/{types/constants → constants}/user.d.ts +2 -2
  30. package/dist/constants/user.js +40 -0
  31. package/dist/{types/constants → constants}/websocket.d.ts +7 -3
  32. package/dist/constants/websocket.js +56 -0
  33. package/dist/{types/constants → constants}/worksheet.d.ts +1 -1
  34. package/dist/constants/worksheet.js +66 -0
  35. package/dist/{types/dto → dto}/class.d.ts +3 -3
  36. package/dist/dto/class.js +1 -0
  37. package/dist/{types/dto → dto}/code.d.ts +1 -1
  38. package/dist/dto/code.js +1 -0
  39. package/dist/{types/dto → dto}/comments.d.ts +1 -1
  40. package/dist/dto/comments.js +1 -0
  41. package/dist/{types/dto → dto}/contest.d.ts +4 -4
  42. package/dist/dto/contest.js +7 -0
  43. package/dist/{types/dto → dto}/course.d.ts +4 -4
  44. package/dist/dto/course.js +1 -0
  45. package/dist/{types/dto → dto}/entity.d.ts +2 -2
  46. package/dist/dto/entity.js +5 -0
  47. package/dist/{types/dto → dto}/excalidraw.d.ts +3 -3
  48. package/dist/dto/excalidraw.js +1 -0
  49. package/dist/{types/dto → dto}/file.d.ts +2 -2
  50. package/dist/dto/file.js +1 -0
  51. package/dist/dto/image.js +1 -0
  52. package/dist/dto/index.d.ts +25 -0
  53. package/dist/dto/index.js +25 -0
  54. package/dist/{types/dto → dto}/judge.d.ts +1 -1
  55. package/dist/dto/judge.js +1 -0
  56. package/dist/{types/dto → dto}/markdown.d.ts +3 -3
  57. package/dist/dto/markdown.js +1 -0
  58. package/dist/{types/dto → dto}/mermaid.d.ts +3 -3
  59. package/dist/dto/mermaid.js +1 -0
  60. package/dist/{types/dto → dto}/organization.d.ts +3 -3
  61. package/dist/dto/organization.js +1 -0
  62. package/dist/{types/dto → dto}/problem.d.ts +3 -3
  63. package/dist/dto/problem.js +1 -0
  64. package/dist/{types/dto → dto}/scoreboard.d.ts +2 -2
  65. package/dist/dto/scoreboard.js +1 -0
  66. package/dist/{types/dto → dto}/session.d.ts +2 -2
  67. package/dist/dto/session.js +1 -0
  68. package/dist/{types/dto → dto}/socket.d.ts +5 -5
  69. package/dist/dto/socket.js +1 -0
  70. package/dist/{types/dto → dto}/statistics.d.ts +1 -1
  71. package/dist/dto/statistics.js +1 -0
  72. package/dist/{types/dto → dto}/submission.d.ts +3 -3
  73. package/dist/dto/submission.js +1 -0
  74. package/dist/{types/dto → dto}/system.d.ts +1 -1
  75. package/dist/dto/system.js +1 -0
  76. package/dist/dto/url.js +1 -0
  77. package/dist/{types/dto → dto}/user.d.ts +3 -3
  78. package/dist/dto/user.js +1 -0
  79. package/dist/{types/dto → dto}/virtual-user.d.ts +1 -1
  80. package/dist/dto/virtual-user.js +1 -0
  81. package/dist/{types/dto → dto}/worksheet-submissions.d.ts +3 -3
  82. package/dist/dto/worksheet-submissions.js +1 -0
  83. package/dist/{types/dto → dto}/worksheet.d.ts +3 -3
  84. package/dist/dto/worksheet.js +1 -0
  85. package/dist/{types/helpers → helpers}/class.d.ts +1 -1
  86. package/dist/helpers/class.js +10 -0
  87. package/dist/helpers/comments.js +4 -0
  88. package/dist/{types/helpers → helpers}/commons.d.ts +1 -1
  89. package/dist/helpers/commons.js +187 -0
  90. package/dist/{types/helpers → helpers}/contest.d.ts +1 -1
  91. package/dist/helpers/contest.js +21 -0
  92. package/dist/helpers/date.js +181 -0
  93. package/dist/{types/helpers → helpers}/document.d.ts +2 -2
  94. package/dist/helpers/document.js +51 -0
  95. package/dist/{types/helpers → helpers}/errors.d.ts +1 -1
  96. package/dist/helpers/errors.js +17 -0
  97. package/dist/helpers/file.js +4 -0
  98. package/dist/helpers/index.d.ts +17 -0
  99. package/dist/helpers/index.js +17 -0
  100. package/dist/helpers/interval.js +24 -0
  101. package/dist/{types/helpers → helpers}/judging.d.ts +1 -1
  102. package/dist/helpers/judging.js +124 -0
  103. package/dist/helpers/number.js +2 -0
  104. package/dist/helpers/object.js +33 -0
  105. package/dist/{types/helpers → helpers}/responses.d.ts +2 -2
  106. package/dist/helpers/responses.js +95 -0
  107. package/dist/{types/helpers → helpers}/socket.d.ts +3 -3
  108. package/dist/helpers/socket.js +279 -0
  109. package/dist/{types/helpers → helpers}/time.d.ts +1 -1
  110. package/dist/helpers/time.js +69 -0
  111. package/dist/{types/helpers → helpers}/user.d.ts +1 -1
  112. package/dist/helpers/user.js +14 -0
  113. package/dist/{types/helpers → helpers}/worksheet.d.ts +1 -1
  114. package/dist/helpers/worksheet.js +107 -0
  115. package/dist/index.d.ts +4 -0
  116. package/dist/index.js +4 -0
  117. package/dist/types/account.js +10 -0
  118. package/dist/types/{types/class.d.ts → class.d.ts} +2 -2
  119. package/dist/types/class.js +7 -0
  120. package/dist/types/comments.js +1 -0
  121. package/dist/types/{types/commons.d.ts → commons.d.ts} +1 -1
  122. package/dist/types/commons.js +69 -0
  123. package/dist/types/{types/contest.d.ts → contest.d.ts} +4 -4
  124. package/dist/types/contest.js +27 -0
  125. package/dist/types/{types/course.d.ts → course.d.ts} +1 -1
  126. package/dist/types/course.js +1 -0
  127. package/dist/types/entity.js +50 -0
  128. package/dist/types/{types/excalidraw.d.ts → excalidraw.d.ts} +1 -1
  129. package/dist/types/excalidraw.js +1 -0
  130. package/dist/types/{types/file.d.ts → file.d.ts} +2 -2
  131. package/dist/types/file.js +19 -0
  132. package/dist/types/{types/group.d.ts → group.d.ts} +1 -1
  133. package/dist/types/group.js +5 -0
  134. package/dist/types/index.d.ts +27 -4
  135. package/dist/types/index.js +27 -0
  136. package/dist/types/{types/judge.d.ts → judge.d.ts} +2 -2
  137. package/dist/types/judge.js +49 -0
  138. package/dist/types/{types/markdown.d.ts → markdown.d.ts} +1 -1
  139. package/dist/types/markdown.js +1 -0
  140. package/dist/types/{types/mermaid.d.ts → mermaid.d.ts} +1 -1
  141. package/dist/types/mermaid.js +1 -0
  142. package/dist/types/notification.js +8 -0
  143. package/dist/types/organization.js +14 -0
  144. package/dist/types/{types/prisma.d.ts → prisma.d.ts} +1 -1
  145. package/dist/types/prisma.js +106 -0
  146. package/dist/types/{types/problems.d.ts → problems.d.ts} +3 -3
  147. package/dist/types/problems.js +28 -0
  148. package/dist/types/scoreboard.js +1 -0
  149. package/dist/types/{types/services.d.ts → services.d.ts} +1 -1
  150. package/dist/types/services.js +152 -0
  151. package/dist/types/{types/sheet.d.ts → sheet.d.ts} +2 -2
  152. package/dist/types/sheet.js +16 -0
  153. package/dist/types/{types/socket.d.ts → socket.d.ts} +3 -2
  154. package/dist/types/socket.js +76 -0
  155. package/dist/types/submission.js +1 -0
  156. package/dist/types/system.js +1 -0
  157. package/dist/types/{types/teams.d.ts → teams.d.ts} +2 -2
  158. package/dist/types/teams.js +1 -0
  159. package/dist/types/{types/users.d.ts → users.d.ts} +2 -2
  160. package/dist/types/users.js +23 -0
  161. package/dist/types/virtual-user.js +8 -0
  162. package/dist/types/{types/worksheet.d.ts → worksheet.d.ts} +3 -3
  163. package/dist/types/worksheet.js +11 -0
  164. package/package.json +8 -11
  165. package/dist/cjs/index.cjs +0 -3695
  166. package/dist/esm/index.js +0 -3415
  167. package/dist/types/constants/index.d.ts +0 -18
  168. package/dist/types/dto/index.d.ts +0 -25
  169. package/dist/types/helpers/index.d.ts +0 -17
  170. package/dist/types/types/index.d.ts +0 -27
  171. /package/dist/{types/constants → constants}/date.d.ts +0 -0
  172. /package/dist/{types/constants → constants}/email.d.ts +0 -0
  173. /package/dist/{types/constants → constants}/routing.d.ts +0 -0
  174. /package/dist/{types/constants → constants}/time.d.ts +0 -0
  175. /package/dist/{types/dto → dto}/image.d.ts +0 -0
  176. /package/dist/{types/dto → dto}/url.d.ts +0 -0
  177. /package/dist/{types/helpers → helpers}/comments.d.ts +0 -0
  178. /package/dist/{types/helpers → helpers}/date.d.ts +0 -0
  179. /package/dist/{types/helpers → helpers}/file.d.ts +0 -0
  180. /package/dist/{types/helpers → helpers}/interval.d.ts +0 -0
  181. /package/dist/{types/helpers → helpers}/number.d.ts +0 -0
  182. /package/dist/{types/helpers → helpers}/object.d.ts +0 -0
  183. /package/dist/types/{types/account.d.ts → account.d.ts} +0 -0
  184. /package/dist/types/{types/comments.d.ts → comments.d.ts} +0 -0
  185. /package/dist/types/{types/entity.d.ts → entity.d.ts} +0 -0
  186. /package/dist/types/{types/notification.d.ts → notification.d.ts} +0 -0
  187. /package/dist/types/{types/organization.d.ts → organization.d.ts} +0 -0
  188. /package/dist/types/{types/scoreboard.d.ts → scoreboard.d.ts} +0 -0
  189. /package/dist/types/{types/submission.d.ts → submission.d.ts} +0 -0
  190. /package/dist/types/{types/system.d.ts → system.d.ts} +0 -0
  191. /package/dist/types/{types/virtual-user.d.ts → virtual-user.d.ts} +0 -0
package/dist/esm/index.js DELETED
@@ -1,3415 +0,0 @@
1
- import { v4 } from 'uuid';
2
-
3
- var ProfileSetting;
4
- (function (ProfileSetting) {
5
- ProfileSetting["NEWSLETTER_SUBSCRIPTION"] = "newsletterSubscription";
6
- ProfileSetting["LANGUAGE"] = "preferredLanguage";
7
- ProfileSetting["THEME"] = "preferredTheme";
8
- ProfileSetting["DATA_VIEW_MODE"] = "preferredDataViewMode";
9
- ProfileSetting["MENU_VIEW_MODE"] = "preferredMenuViewMode";
10
- ProfileSetting["TIME_ZONE"] = "preferredTimeZone";
11
- ProfileSetting["FONT_SIZE"] = "preferredFontSize";
12
- })(ProfileSetting || (ProfileSetting = {}));
13
-
14
- var AssignmentClass;
15
- (function (AssignmentClass) {
16
- AssignmentClass["NONE"] = "NONE";
17
- AssignmentClass["COURSE"] = "COURSE";
18
- AssignmentClass["WORKSHEET"] = "WORKSHEET";
19
- AssignmentClass["CONTEST"] = "CONTEST";
20
- })(AssignmentClass || (AssignmentClass = {}));
21
-
22
- var CodeLanguage;
23
- (function (CodeLanguage) {
24
- CodeLanguage["C_11"] = "c11";
25
- CodeLanguage["CPP_11"] = "cpp11";
26
- CodeLanguage["CPP_20"] = "cpp20";
27
- CodeLanguage["JAVA_21"] = "java21";
28
- CodeLanguage["PYTHON_3"] = "python3";
29
- CodeLanguage["PYTHON_PYPY_3"] = "pypy3";
30
- CodeLanguage["JAVASCRIPT_NODE_JS_22"] = "nodejs22";
31
- // DEPRECATED
32
- CodeLanguage["PYTHON_2"] = "python2";
33
- CodeLanguage["PYTHON_PYPY_2"] = "pypy2";
34
- CodeLanguage["ICPC_C"] = "ICPC_C";
35
- CodeLanguage["C"] = "C";
36
- CodeLanguage["CPP"] = "CPP";
37
- CodeLanguage["ICPC_CPP"] = "ICPC_CPP";
38
- CodeLanguage["CPP11"] = "CPP11";
39
- CodeLanguage["CPP14"] = "CPP14";
40
- CodeLanguage["CPP17"] = "CPP17";
41
- CodeLanguage["JAVA"] = "JAVA";
42
- CodeLanguage["ICPC_PYTHON"] = "ICPC_PYTHON";
43
- CodeLanguage["PYTHON"] = "PYTHON";
44
- CodeLanguage["PYTHON2"] = "PYTHON2";
45
- CodeLanguage["PYTHON3"] = "PYTHON3";
46
- CodeLanguage["JAVASCRIPT"] = "JAVASCRIPT";
47
- CodeLanguage["TYPESCRIPT"] = "TYPESCRIPT";
48
- CodeLanguage["JSX"] = "JSX";
49
- CodeLanguage["TSX"] = "TSX";
50
- CodeLanguage["MDX"] = "MDX";
51
- CodeLanguage["PSEUDOCODE_PSEINT"] = "PSEUDOCODE_PSEINT";
52
- CodeLanguage["LATEX"] = "LATEX";
53
- CodeLanguage["JSON"] = "JSON";
54
- CodeLanguage["HTML"] = "HTML";
55
- CodeLanguage["TEXT"] = "TEXT";
56
- CodeLanguage["DIFF"] = "DIFF";
57
- CodeLanguage["MARKDOWN"] = "MARKDOWN";
58
- CodeLanguage["ARDUINO"] = "ARDUINO";
59
- CodeLanguage["DOT"] = "DOT";
60
- CodeLanguage["MERMAID"] = "MERMAID";
61
- CodeLanguage["BASH"] = "BASH";
62
- })(CodeLanguage || (CodeLanguage = {}));
63
- var ScopeData;
64
- (function (ScopeData) {
65
- ScopeData["USER"] = "USER";
66
- ScopeData["PROBLEM"] = "PROBLEM";
67
- ScopeData["CONTEST"] = "CONTEST";
68
- ScopeData["ATTEMPT"] = "ATTEMPT";
69
- })(ScopeData || (ScopeData = {}));
70
- var Status;
71
- (function (Status) {
72
- Status["SUCCESS"] = "SUCCESS";
73
- Status["ERROR"] = "ERROR";
74
- Status["LOADING"] = "LOADING";
75
- Status["NONE"] = "NONE";
76
- })(Status || (Status = {}));
77
- var EntityStatus;
78
- (function (EntityStatus) {
79
- EntityStatus["PUBLIC"] = "PUBLIC";
80
- EntityStatus["RESERVED"] = "RESERVED";
81
- EntityStatus["PRIVATE"] = "PRIVATE";
82
- EntityStatus["ARCHIVED"] = "ARCHIVED";
83
- })(EntityStatus || (EntityStatus = {}));
84
- var EntityAccess;
85
- (function (EntityAccess) {
86
- EntityAccess["PRIVATE"] = "PRIVATE";
87
- EntityAccess["RESTRICTED"] = "RESTRICTED";
88
- EntityAccess["PUBLIC"] = "PUBLIC";
89
- EntityAccess["EXPOSED"] = "EXPOSED";
90
- })(EntityAccess || (EntityAccess = {}));
91
-
92
- var OrganizationPlan;
93
- (function (OrganizationPlan) {
94
- OrganizationPlan["FREE"] = "FREE";
95
- OrganizationPlan["STANDARD"] = "STANDARD";
96
- OrganizationPlan["PREMIUM"] = "PREMIUM";
97
- OrganizationPlan["CUSTOM"] = "CUSTOM";
98
- })(OrganizationPlan || (OrganizationPlan = {}));
99
- var OrganizationLogoType;
100
- (function (OrganizationLogoType) {
101
- OrganizationLogoType["HORIZONTAL_WHITE"] = "horizontal-white";
102
- OrganizationLogoType["HORIZONTAL_COLOR"] = "horizontal-color";
103
- OrganizationLogoType["VERTICAL_WHITE"] = "vertical-white";
104
- OrganizationLogoType["VERTICAL_COLOR"] = "vertical-color";
105
- })(OrganizationLogoType || (OrganizationLogoType = {}));
106
-
107
- var ContestStatus;
108
- (function (ContestStatus) {
109
- ContestStatus["PUBLIC"] = "PUBLIC";
110
- ContestStatus["RESERVED"] = "RESERVED";
111
- ContestStatus["ARCHIVED"] = "ARCHIVED";
112
- })(ContestStatus || (ContestStatus = {}));
113
- var ContestTimeStatus;
114
- (function (ContestTimeStatus) {
115
- ContestTimeStatus["UPCOMING"] = "upcoming";
116
- ContestTimeStatus["LIVE"] = "live";
117
- ContestTimeStatus["PAST"] = "past";
118
- })(ContestTimeStatus || (ContestTimeStatus = {}));
119
- var ContestProblemPrerequisiteType;
120
- (function (ContestProblemPrerequisiteType) {
121
- ContestProblemPrerequisiteType["INDIVIDUALLY"] = "INDIVIDUALLY";
122
- ContestProblemPrerequisiteType["CONTEST"] = "CONTEST";
123
- })(ContestProblemPrerequisiteType || (ContestProblemPrerequisiteType = {}));
124
- var ContestEventAction;
125
- (function (ContestEventAction) {
126
- ContestEventAction["DATA_UPDATE"] = "DATA_UPDATE";
127
- ContestEventAction["SCOREBOARD_RECALCULATE"] = "SCOREBOARD_RECALCULATE";
128
- ContestEventAction["SCOREBOARD_UNLOCK"] = "SCOREBOARD_UNLOCK";
129
- ContestEventAction["SCOREBOARD_LOCK"] = "SCOREBOARD_LOCK";
130
- ContestEventAction["ENABLE_UPSOLVING"] = "ENABLE_UPSOLVING";
131
- ContestEventAction["DISABLE_UPSOLVING"] = "DISABLE_UPSOLVING";
132
- ContestEventAction["PARTICIPANT_JOIN"] = "PARTICIPANT_JOIN";
133
- })(ContestEventAction || (ContestEventAction = {}));
134
-
135
- var EntityMembersRank;
136
- (function (EntityMembersRank) {
137
- EntityMembersRank["NONE"] = "NONE";
138
- EntityMembersRank["CLOSE"] = "CLOSE";
139
- EntityMembersRank["OPEN"] = "OPEN";
140
- })(EntityMembersRank || (EntityMembersRank = {}));
141
- var EntityState;
142
- (function (EntityState) {
143
- EntityState["RELEASED"] = "RELEASED";
144
- EntityState["ARCHIVED"] = "ARCHIVED";
145
- })(EntityState || (EntityState = {}));
146
- var EntityCollection;
147
- (function (EntityCollection) {
148
- EntityCollection["ORGANIZATION"] = "ORGANIZATION";
149
- EntityCollection["PROBLEM"] = "PROBLEM";
150
- EntityCollection["CONTEST"] = "CONTEST";
151
- EntityCollection["JUDGE"] = "JUDGE";
152
- EntityCollection["USER"] = "USER";
153
- EntityCollection["SUBMISSION"] = "SUBMISSION";
154
- })(EntityCollection || (EntityCollection = {}));
155
- var CollectionKey;
156
- (function (CollectionKey) {
157
- CollectionKey["ORGANIZATION"] = "C";
158
- CollectionKey["USER"] = "U";
159
- CollectionKey["PROBLEM"] = "P";
160
- CollectionKey["CLASS"] = "K";
161
- CollectionKey["CLASS_ASSIGNMENT"] = "KA";
162
- CollectionKey["CONTEST"] = "T";
163
- CollectionKey["SCOREBOARD"] = "B";
164
- CollectionKey["SCOREBOARD_EVENTS"] = "BE";
165
- CollectionKey["COURSE"] = "R";
166
- CollectionKey["FILE"] = "F";
167
- CollectionKey["GROUP"] = "G";
168
- CollectionKey["JUDGE"] = "J";
169
- CollectionKey["WORKSHEET"] = "W";
170
- CollectionKey["WORKSHEET_SUBMISSIONS"] = "WS";
171
- CollectionKey["SUBMIT"] = "S";
172
- CollectionKey["LOCALE"] = "L";
173
- CollectionKey["COMMENT"] = "M";
174
- CollectionKey["EXCALIDRAW"] = "E";
175
- CollectionKey["MARKDOWN"] = "MD";
176
- CollectionKey["DOCUMENT_TEMPLATE"] = "DT";
177
- CollectionKey["MERMAID"] = "MM";
178
- })(CollectionKey || (CollectionKey = {}));
179
- var LogOperation;
180
- (function (LogOperation) {
181
- LogOperation["REMOVE"] = "REMOVE";
182
- LogOperation["ADD"] = "ADD";
183
- LogOperation["UPDATE"] = "UPDATE";
184
- })(LogOperation || (LogOperation = {}));
185
-
186
- var FileMemberRole;
187
- (function (FileMemberRole) {
188
- FileMemberRole["VIEWER"] = "VIEWER";
189
- FileMemberRole["EDITOR"] = "EDITOR";
190
- })(FileMemberRole || (FileMemberRole = {}));
191
- var FileType;
192
- (function (FileType) {
193
- FileType["FOLDER"] = "FOLDER";
194
- FileType["FILE"] = "FILE";
195
- })(FileType || (FileType = {}));
196
- var FilesJukiPub;
197
- (function (FilesJukiPub) {
198
- FilesJukiPub["SHARED"] = "shared";
199
- FilesJukiPub["SHARED_EXCALIDRAW"] = "shared/E";
200
- FilesJukiPub["TEMP"] = "temp";
201
- FilesJukiPub["PROBLEMS"] = "problems";
202
- FilesJukiPub["CONTESTS"] = "contests";
203
- })(FilesJukiPub || (FilesJukiPub = {}));
204
-
205
- var GroupType;
206
- (function (GroupType) {
207
- GroupType["CLASS"] = "CLASS";
208
- GroupType["TEAM"] = "TEAM";
209
- })(GroupType || (GroupType = {}));
210
-
211
- var Judge;
212
- (function (Judge) {
213
- Judge["JUKI_JUDGE"] = "JUKI_JUDGE";
214
- Judge["CODEFORCES"] = "CODEFORCES";
215
- Judge["CODEFORCES_GYM"] = "CODEFORCES_GYM";
216
- Judge["JV_UMSA"] = "JV_UMSA";
217
- Judge["UVA_ONLINE_JUDGE"] = "UVA_ONLINE_JUDGE";
218
- Judge["AT_CODER"] = "AT_CODER";
219
- Judge["CODECHEF"] = "CODECHEF";
220
- Judge["TOPCODER"] = "TOPCODER";
221
- Judge["LEETCODE"] = "LEETCODE";
222
- })(Judge || (Judge = {}));
223
- var ProblemVerdict;
224
- (function (ProblemVerdict) {
225
- ProblemVerdict["NONE"] = "NONE";
226
- ProblemVerdict["PENDING"] = "PENDING";
227
- ProblemVerdict["HIDDEN"] = "HIDDEN";
228
- ProblemVerdict["CE"] = "CE";
229
- ProblemVerdict["RE"] = "RE";
230
- ProblemVerdict["TLE"] = "TLE";
231
- ProblemVerdict["MLE"] = "MLE";
232
- ProblemVerdict["WA"] = "WA";
233
- ProblemVerdict["PE"] = "PE";
234
- ProblemVerdict["PA"] = "PA";
235
- ProblemVerdict["AC"] = "AC";
236
- })(ProblemVerdict || (ProblemVerdict = {}));
237
- var SubmissionRunStatus;
238
- (function (SubmissionRunStatus) {
239
- SubmissionRunStatus["NONE"] = "NONE";
240
- SubmissionRunStatus["RECEIVED"] = "RECEIVED";
241
- SubmissionRunStatus["COMPILING"] = "COMPILING";
242
- SubmissionRunStatus["COMPILED"] = "COMPILED";
243
- SubmissionRunStatus["COMPILATION_ERROR"] = "COMPILATION_ERROR";
244
- SubmissionRunStatus["FETCHING_TEST_CASES"] = "FETCHING_TEST_CASES";
245
- SubmissionRunStatus["RUNNING_TEST_CASE"] = "RUNNING_TEST_CASE";
246
- SubmissionRunStatus["RUNNING_TEST_CASES"] = "RUNNING_TEST_CASES";
247
- SubmissionRunStatus["RUNNING_SAMPLE_TEST_CASES"] = "RUNNING_SAMPLE_TEST_CASES";
248
- SubmissionRunStatus["EXECUTED_TEST_CASE"] = "EXECUTED_TEST_CASE";
249
- SubmissionRunStatus["FAILED_TEST_CASE"] = "FAILED_TEST_CASE";
250
- SubmissionRunStatus["JUDGING_TEST_CASE"] = "JUDGING_TEST_CASE";
251
- SubmissionRunStatus["GRADING"] = "GRADING";
252
- SubmissionRunStatus["FAILED"] = "FAILED";
253
- SubmissionRunStatus["COMPLETED"] = "COMPLETED";
254
- })(SubmissionRunStatus || (SubmissionRunStatus = {}));
255
- var RunnerType;
256
- (function (RunnerType) {
257
- RunnerType["HIGH_PERFORMANCE"] = "HIGH_PERFORMANCE";
258
- RunnerType["LOW_PERFORMANCE"] = "LOW_PERFORMANCE";
259
- })(RunnerType || (RunnerType = {}));
260
-
261
- var NotificationType;
262
- (function (NotificationType) {
263
- NotificationType["SUCCESS"] = "success";
264
- NotificationType["INFO"] = "info";
265
- NotificationType["WARNING"] = "warning";
266
- NotificationType["ERROR"] = "error";
267
- NotificationType["QUIET"] = "quiet";
268
- })(NotificationType || (NotificationType = {}));
269
-
270
- /**
271
- * Enums
272
- */
273
- // Based on
274
- // https://github.com/microsoft/TypeScript/issues/3192#issuecomment-261720275
275
- const CourseStatus = {
276
- RELEASED: 'RELEASED',
277
- IN_DRAFT: 'IN_DRAFT',
278
- IN_REVIEW: 'IN_REVIEW',
279
- ARCHIVED: 'ARCHIVED',
280
- };
281
- const CourseType = {
282
- PUBLIC: 'PUBLIC',
283
- PRIVATE: 'PRIVATE',
284
- CLOSED: 'CLOSED',
285
- };
286
- const AssignmentType = {
287
- READING_PDF: 'READING_PDF',
288
- READING_WEB: 'READING_WEB',
289
- SOLVE_JUKI_JUDGE_PROBLEM: 'SOLVE_JUKI_JUDGE_PROBLEM',
290
- SOLVE_CODEFORCES_JUDGE_PROBLEM: 'SOLVE_CODEFORCES_JUDGE_PROBLEM',
291
- };
292
- const AssignmentState = {
293
- ASSIGNED: 'ASSIGNED',
294
- IN_PROGRESS: 'IN_PROGRESS',
295
- TO_REVIEW: 'TO_REVIEW',
296
- RESOLVED: 'RESOLVED',
297
- };
298
- const TeamStatus = {
299
- ACTIVE: 'ACTIVE',
300
- REPORTED: 'REPORTED',
301
- ARCHIVED: 'ARCHIVED',
302
- };
303
- const MemberRole = {
304
- COACH: 'COACH',
305
- CO_COACH: 'CO_COACH',
306
- CONTESTANT: 'CONTESTANT',
307
- ATTENDEE: 'ATTENDEE',
308
- RESERVE: 'RESERVE',
309
- STAFF: 'STAFF',
310
- };
311
- const UserTeamStatus = {
312
- PENDING: 'PENDING',
313
- ACCEPTED: 'ACCEPTED',
314
- REJECTED: 'REJECTED',
315
- };
316
- const Language = {
317
- ES: 'ES',
318
- EN: 'EN',
319
- };
320
- const Theme = {
321
- LIGHT: 'LIGHT',
322
- DARK: 'DARK',
323
- };
324
- const EmailSubscription = {
325
- NONE: 'NONE',
326
- RANKED_CONTESTS: 'RANKED_CONTESTS',
327
- WEEKLY_NEWS_SUBSCRIPTION: 'WEEKLY_NEWS_SUBSCRIPTION',
328
- MONTHLY_NEWS_SUBSCRIPTION: 'MONTHLY_NEWS_SUBSCRIPTION',
329
- };
330
- const EmailValidationState = {
331
- PENDING: 'PENDING',
332
- VALIDATED: 'VALIDATED',
333
- };
334
- const UserStatus = {
335
- ACTIVE: 'ACTIVE',
336
- REPORTED: 'REPORTED',
337
- ARCHIVED: 'ARCHIVED',
338
- };
339
- const UserRole = {
340
- RESTRICTED: 'RESTRICTED',
341
- GUEST: 'GUEST',
342
- LIMITED: 'LIMITED',
343
- REGULAR: 'REGULAR',
344
- MANAGER: 'MANAGER',
345
- ADMIN: 'ADMIN',
346
- SUPER_ADMIN: 'SUPER_ADMIN',
347
- };
348
- const SystemRole = {
349
- GUEST: 'GUEST',
350
- REGULAR: 'REGULAR',
351
- MANAGER: 'MANAGER',
352
- MASTER: 'MASTER',
353
- ADMIN: 'ADMIN',
354
- SUPER_ADMIN: 'SUPER_ADMIN',
355
- };
356
- const TeamRole = {
357
- RESTRICTED: 'RESTRICTED',
358
- GUEST: 'GUEST',
359
- REGULAR: 'REGULAR',
360
- MANAGER: 'MANAGER',
361
- ADMIN: 'ADMIN',
362
- SUPER_ADMIN: 'SUPER_ADMIN',
363
- };
364
- const CourseRole = {
365
- RESTRICTED: 'RESTRICTED',
366
- GUEST: 'GUEST',
367
- REGULAR: 'REGULAR',
368
- CREATOR: 'CREATOR',
369
- SUPER_CREATOR: 'SUPER_CREATOR',
370
- MANAGER: 'MANAGER',
371
- MASTER: 'MASTER',
372
- ADMIN: 'ADMIN',
373
- SUPER_ADMIN: 'SUPER_ADMIN',
374
- };
375
-
376
- var TypeTestCase;
377
- (function (TypeTestCase) {
378
- TypeTestCase["INPUT"] = "INPUT";
379
- TypeTestCase["OUTPUT"] = "OUTPUT";
380
- })(TypeTestCase || (TypeTestCase = {}));
381
- var ProblemInput;
382
- (function (ProblemInput) {
383
- ProblemInput["STANDARD"] = "STANDARD";
384
- ProblemInput["INTERACTIVE"] = "INTERACTIVE";
385
- })(ProblemInput || (ProblemInput = {}));
386
- var ProblemOutput;
387
- (function (ProblemOutput) {
388
- ProblemOutput["STANDARD"] = "STANDARD";
389
- ProblemOutput["DYNAMIC"] = "DYNAMIC";
390
- ProblemOutput["INTERACTIVE"] = "INTERACTIVE";
391
- })(ProblemOutput || (ProblemOutput = {}));
392
- var ProblemType;
393
- (function (ProblemType) {
394
- ProblemType["STANDARD"] = "STANDARD";
395
- ProblemType["DYNAMIC"] = "DYNAMIC";
396
- ProblemType["INTERACTIVE"] = "INTERACTIVE";
397
- })(ProblemType || (ProblemType = {}));
398
- var ProblemScoringMode;
399
- (function (ProblemScoringMode) {
400
- ProblemScoringMode["SUBTASK"] = "SUBTASK";
401
- ProblemScoringMode["TOTAL"] = "TOTAL";
402
- ProblemScoringMode["PARTIAL"] = "PARTIAL";
403
- })(ProblemScoringMode || (ProblemScoringMode = {}));
404
-
405
- var ErrorCode;
406
- (function (ErrorCode) {
407
- // General errors
408
- ErrorCode["ERR400"] = "ERR400";
409
- ErrorCode["ERR401"] = "ERR401";
410
- ErrorCode["ERR403"] = "ERR403";
411
- ErrorCode["ERR404"] = "ERR404";
412
- ErrorCode["ERR405"] = "ERR405";
413
- ErrorCode["ERR500"] = "ERR500";
414
- // UI general errors
415
- ErrorCode["ERR9997"] = "ERR9997";
416
- ErrorCode["ERR9998"] = "ERR9998";
417
- ErrorCode["ERR9999"] = "ERR9999";
418
- // User errors // 'unable update nickname yet', 'User not active'
419
- ErrorCode["ERR0000"] = "ERR0000";
420
- ErrorCode["ERR0010"] = "ERR0010";
421
- ErrorCode["ERR0011"] = "ERR0011";
422
- ErrorCode["ERR0012"] = "ERR0012";
423
- ErrorCode["ERR0013"] = "ERR0013";
424
- ErrorCode["ERR0014"] = "ERR0014";
425
- ErrorCode["ERR0015"] = "ERR0015";
426
- ErrorCode["ERR0016"] = "ERR0016";
427
- ErrorCode["ERR0017"] = "ERR0017";
428
- ErrorCode["ERR0018"] = "ERR0018";
429
- ErrorCode["ERR0019"] = "ERR0019";
430
- ErrorCode["ERR0020"] = "ERR0020";
431
- ErrorCode["ERR0021"] = "ERR0021";
432
- ErrorCode["ERR0022"] = "ERR0022";
433
- ErrorCode["ERR0023"] = "ERR0023";
434
- ErrorCode["ERR0024"] = "ERR0024";
435
- ErrorCode["ERR0050"] = "ERR0050";
436
- ErrorCode["ERR0051"] = "ERR0051";
437
- ErrorCode["ERR0052"] = "ERR0052";
438
- ErrorCode["ERR0053"] = "ERR0053";
439
- // Problem Errors ERR01XX',
440
- ErrorCode["ERR0100"] = "ERR0100";
441
- ErrorCode["ERR0110"] = "ERR0110";
442
- ErrorCode["ERR0111"] = "ERR0111";
443
- ErrorCode["ERR0112"] = " ERR0112";
444
- ErrorCode["ERR0113"] = "ERR0113";
445
- ErrorCode["ERR0114"] = "ERR0114";
446
- ErrorCode["ERR0115"] = "ERR0115";
447
- ErrorCode["ERR0116"] = "ERR0116";
448
- ErrorCode["ERR0117"] = "ERR0117";
449
- ErrorCode["ERR0118"] = "ERR0118";
450
- ErrorCode["ERR0119"] = "ERR0119";
451
- ErrorCode["ERR0120"] = "ERR0120";
452
- ErrorCode["ERR0121"] = "ERR0121";
453
- ErrorCode["ERR0122"] = "ERR0122";
454
- // Contest Errors ERR02XX',
455
- ErrorCode["ERR0200"] = "ERR0200";
456
- // CRUD contest
457
- ErrorCode["ERR0210"] = "ERR0210";
458
- ErrorCode["ERR0211"] = "ERR0211";
459
- ErrorCode["ERR0212"] = "ERR0212";
460
- ErrorCode["ERR0213"] = "ERR0213";
461
- // permissions contest
462
- ErrorCode["ERR0214"] = "ERR0214";
463
- ErrorCode["ERR0215"] = "ERR0215";
464
- ErrorCode["ERR0216"] = "ERR0216";
465
- ErrorCode["ERR0217"] = "ERR0217";
466
- ErrorCode["ERR0218"] = "ERR0218";
467
- ErrorCode["ERR0219"] = "ERR0219";
468
- ErrorCode["ERR0220"] = "ERR0220";
469
- // CRUD scoreboard
470
- ErrorCode["ERR0230"] = "ERR0230";
471
- ErrorCode["ERR0231"] = "ERR0231";
472
- ErrorCode["ERR0232"] = "ERR0232";
473
- ErrorCode["ERR0233"] = "ERR0233";
474
- // permissions scoreboard
475
- ErrorCode["ERR0234"] = "ERR0234";
476
- ErrorCode["ERR0235"] = "ERR0235";
477
- ErrorCode["ERR0236"] = "ERR0236";
478
- ErrorCode["ERR0237"] = "ERR0237";
479
- ErrorCode["ERR0240"] = "ERR0240";
480
- ErrorCode["ERR0241"] = "ERR0241";
481
- ErrorCode["ERR0242"] = "ERR0242";
482
- ErrorCode["ERR0243"] = "ERR0243";
483
- ErrorCode["ERR0244"] = "ERR0244";
484
- ErrorCode["ERR0245"] = "ERR0245";
485
- ErrorCode["ERR0246"] = "ERR0246";
486
- ErrorCode["ERR0247"] = "ERR0247";
487
- // Submission Errors ERR03XXX',
488
- ErrorCode["ERR0300"] = "ERR0300";
489
- ErrorCode["ERR0301"] = "ERR0301";
490
- ErrorCode["ERR0302"] = "ERR0302";
491
- ErrorCode["ERR0303"] = "ERR0303";
492
- ErrorCode["ERR0310"] = "ERR0310";
493
- ErrorCode["ERR0311"] = "ERR0311";
494
- ErrorCode["ERR0321"] = "ERR0321";
495
- ErrorCode["ERR0331"] = "ERR0331";
496
- // Utils Errors ERR04XX
497
- ErrorCode["ERR0400"] = "ERR0400";
498
- ErrorCode["ERR0410"] = "ERR0410";
499
- ErrorCode["ERR0420"] = "ERR0420";
500
- ErrorCode["ERR0421"] = "ERR0421";
501
- ErrorCode["ERR0430"] = "ERR0430";
502
- ErrorCode["ERR0440"] = "ERR0440";
503
- // Team Errors ERR06XX
504
- ErrorCode["ERR0600"] = "ERR0600";
505
- ErrorCode["ERR0610"] = "ERR0610";
506
- ErrorCode["ERR0611"] = "ERR0611";
507
- ErrorCode["ERR0612"] = "ERR0612";
508
- ErrorCode["ERR0613"] = "ERR0613";
509
- ErrorCode["ERR0614"] = "ERR0614";
510
- ErrorCode["ERR0615"] = "ERR0615";
511
- ErrorCode["ERR0616"] = "ERR0665";
512
- ErrorCode["ERR0617"] = "ERR0617";
513
- ErrorCode["ERR0618"] = "ERR0618";
514
- ErrorCode["ERR0619"] = "ERR0619";
515
- // Course Errors ERR07XXX',
516
- // Sheets Errors ERR08XXX',
517
- ErrorCode["ERR0800"] = "ERR0800";
518
- ErrorCode["ERR0810"] = "ERR0810";
519
- ErrorCode["ERR0811"] = "ERR0811";
520
- ErrorCode["ERR0812"] = "ERR0812";
521
- ErrorCode["ERR0813"] = "ERR0813";
522
- ErrorCode["ERR0814"] = "ERR0814";
523
- ErrorCode["ERR0815"] = "ERR0815";
524
- ErrorCode["ERR0816"] = "ERR0865";
525
- ErrorCode["ERR0817"] = "ERR0817";
526
- ErrorCode["ERR0818"] = "ERR0818";
527
- ErrorCode["ERR0819"] = "ERR0819";
528
- ErrorCode["ERR0820"] = "ERR0820";
529
- // Organization Errors ERR99XXX',
530
- ErrorCode["ERR9900"] = "ERR9900";
531
- ErrorCode["ERR9910"] = "ERR9910";
532
- ErrorCode["ERR9911"] = "ERR9911";
533
- ErrorCode["ERR9912"] = "ERR9912";
534
- ErrorCode["ERR9913"] = "ERR9913";
535
- ErrorCode["ERR9914"] = "ERR9914";
536
- ErrorCode["ERR9915"] = "ERR9915";
537
- ErrorCode["ERR9916"] = "ERR9916";
538
- ErrorCode["ERR9917"] = "ERR9917";
539
- })(ErrorCode || (ErrorCode = {}));
540
- var LogLevel;
541
- (function (LogLevel) {
542
- LogLevel["FATAL"] = "FATAL";
543
- LogLevel["ERROR"] = "ERROR";
544
- LogLevel["WARN"] = "WARN";
545
- LogLevel["INFO"] = "INFO";
546
- LogLevel["DEBUG"] = "DEBUG";
547
- LogLevel["TRACE"] = "TRACE";
548
- })(LogLevel || (LogLevel = {}));
549
- var HTTPMethod;
550
- (function (HTTPMethod) {
551
- HTTPMethod["POST"] = "POST";
552
- HTTPMethod["GET"] = "GET";
553
- HTTPMethod["PUT"] = "PUT";
554
- HTTPMethod["PATCH"] = "PATCH";
555
- HTTPMethod["DELETE"] = "DELETE";
556
- })(HTTPMethod || (HTTPMethod = {}));
557
-
558
- var WorksheetType;
559
- (function (WorksheetType) {
560
- WorksheetType["JK_MD"] = "JK_MD";
561
- WorksheetType["CODE_EDITOR"] = "CODE_EDITOR";
562
- WorksheetType["LIST"] = "LIST";
563
- WorksheetType["GRAPH"] = "GRAPH";
564
- WorksheetType["QUIZ_PROBLEM"] = "QUIZ_PROBLEM";
565
- WorksheetType["QUIZ_TEXT"] = "QUIZ_TEXT";
566
- WorksheetType["QUIZ_OPTIONS"] = "QUIZ_OPTIONS";
567
- WorksheetType["NEW_PAGE"] = "NEW_PAGE";
568
- })(WorksheetType || (WorksheetType = {}));
569
- var QuizScoringMode;
570
- (function (QuizScoringMode) {
571
- QuizScoringMode["TOTAL"] = "TOTAL";
572
- QuizScoringMode["PARTIAL"] = "PARTIAL";
573
- })(QuizScoringMode || (QuizScoringMode = {}));
574
-
575
- /**
576
- * Subscriptions of the client. With the TOPIC channels they are not sent to the server anymore:
577
- * they only say which channel the client attaches (`getChannelOfWebSocketSubscribeEvent`) and the dispatch key.
578
- */
579
- var WebSocketSubscriptionEvent;
580
- (function (WebSocketSubscriptionEvent) {
581
- WebSocketSubscriptionEvent["SUBSCRIBE_CODE_RUN_STATUS"] = "SUBSCRIBE_CODE_RUN_STATUS";
582
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CODE_RUN_STATUS"] = "UNSUBSCRIBE_CODE_RUN_STATUS";
583
- WebSocketSubscriptionEvent["SUBSCRIBE_SUBMISSION_RUN_STATUS"] = "SUBSCRIBE_SUBMISSION_RUN_STATUS";
584
- WebSocketSubscriptionEvent["UNSUBSCRIBE_SUBMISSION_RUN_STATUS"] = "UNSUBSCRIBE_SUBMISSION_RUN_STATUS";
585
- WebSocketSubscriptionEvent["SUBSCRIBE_GET_DATA"] = "SUBSCRIBE_GET_DATA";
586
- WebSocketSubscriptionEvent["UNSUBSCRIBE_GET_DATA"] = "SUBSCRIBE_GET_DATA";
587
- WebSocketSubscriptionEvent["SUBSCRIBE_PROBLEM_CRAWLED"] = "SUBSCRIBE_PROBLEM_CRAWLED";
588
- WebSocketSubscriptionEvent["UNSUBSCRIBE_PROBLEM_CRAWLED"] = "UNSUBSCRIBE_PROBLEM_CRAWLED";
589
- WebSocketSubscriptionEvent["SUBSCRIBE_SUBMISSIONS_CRAWL"] = "SUBSCRIBE_SUBMISSIONS_CRAWL";
590
- WebSocketSubscriptionEvent["UNSUBSCRIBE_SUBMISSIONS_CRAWL"] = "UNSUBSCRIBE_SUBMISSIONS_CRAWL";
591
- WebSocketSubscriptionEvent["SUBSCRIBE_CONTEST_CHANGES"] = "SUBSCRIBE_CONTEST_CHANGES";
592
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CONTEST_CHANGES"] = "UNSUBSCRIBE_CONTEST_CHANGES";
593
- WebSocketSubscriptionEvent["SUBSCRIBE_USER_NOTIFICATION"] = "SUBSCRIBE_USER_NOTIFICATION";
594
- WebSocketSubscriptionEvent["UNSUBSCRIBE_USER_NOTIFICATION"] = "UNSUBSCRIBE_USER_NOTIFICATION";
595
- WebSocketSubscriptionEvent["SUBSCRIBE_SUBMISSIONS_JUDGING"] = "SUBSCRIBE_SUBMISSIONS_JUDGING";
596
- WebSocketSubscriptionEvent["UNSUBSCRIBE_SUBMISSIONS_JUDGING"] = "UNSUBSCRIBE_SUBMISSIONS_JUDGING";
597
- })(WebSocketSubscriptionEvent || (WebSocketSubscriptionEvent = {}));
598
- var WebSocketResponseEvent;
599
- (function (WebSocketResponseEvent) {
600
- WebSocketResponseEvent["CODE_RUN_STATUS"] = "CODE_RUN_STATUS";
601
- WebSocketResponseEvent["SUBMISSION_RUN_STATUS"] = "SUBMISSION_RUN_STATUS";
602
- WebSocketResponseEvent["USER_MESSAGE"] = "USER_MESSAGE";
603
- WebSocketResponseEvent["SEND_DATA_"] = "SEND_DATA_";
604
- WebSocketResponseEvent["SEND_DATA_ECS_TASK_DEFINITIONS_LIST"] = "SEND_DATA_ECS_TASK_DEFINITIONS_LIST";
605
- WebSocketResponseEvent["SEND_DATA_ECS_TASKS_LIST"] = "SEND_DATA_ECS_TASKS_LIST";
606
- WebSocketResponseEvent["SEND_DATA_EC2_INSTANCES_LIST"] = "SEND_DATA_EC2_INSTANCES_LIST";
607
- WebSocketResponseEvent["SEND_DATA_SSM_SESSIONS_LIST"] = "SEND_DATA_SSM_SESSIONS_LIST";
608
- WebSocketResponseEvent["SEND_DATA_RUN_COMMAND"] = "SEND_DATA_RUN_COMMAND";
609
- WebSocketResponseEvent["PROBLEM_CRAWLED"] = "PROBLEM_CRAWLED";
610
- WebSocketResponseEvent["SUBMISSIONS_CRAWL"] = "SUBMISSIONS_CRAWL";
611
- WebSocketResponseEvent["CONTEST_CHANGES"] = "CONTEST_CHANGES";
612
- WebSocketResponseEvent["USER_NOTIFICATION_"] = "USER_NOTIFICATION_";
613
- WebSocketResponseEvent["USER_NOTIFICATION_SUBMISSION"] = "USER_NOTIFICATION_SUBMISSION";
614
- WebSocketResponseEvent["USER_NOTIFICATION_CONTEST_CLARIFICATION"] = "USER_NOTIFICATION_CONTEST_CLARIFICATION";
615
- WebSocketResponseEvent["SUBMISSION_JUDGING"] = "SUBMISSION_JUDGING";
616
- })(WebSocketResponseEvent || (WebSocketResponseEvent = {}));
617
- /**
618
- * Roles of a contest, with the same names as the contest members in the DB.
619
- * Each role has its own Ably channel: `contest:{contestKey}:{role}` (see `CHANNEL_CONTEST`).
620
- * The inclusions follow `getContestAccessPermissions`:
621
- * spectators ⊇ managers ⊇ administrators, spectators ⊇ participants, spectators ⊇ guests
622
- */
623
- var ContestChannelRole;
624
- (function (ContestChannelRole) {
625
- ContestChannelRole["ADMINISTRATORS"] = "administrators";
626
- ContestChannelRole["MANAGERS"] = "managers";
627
- ContestChannelRole["PARTICIPANTS"] = "participants";
628
- ContestChannelRole["GUESTS"] = "guests";
629
- ContestChannelRole["SPECTATORS"] = "spectators";
630
- })(ContestChannelRole || (ContestChannelRole = {}));
631
- /**
632
- * Roles of a problem, the ones computed by `getProblemAccessPermissions` (backend).
633
- * Each role has its own Ably channel: `problem:{problemKey}:{role}` (see `CHANNEL_PROBLEM`).
634
- */
635
- var ProblemChannelRole;
636
- (function (ProblemChannelRole) {
637
- ProblemChannelRole["ADMINISTRATORS"] = "administrators";
638
- ProblemChannelRole["MANAGERS"] = "managers";
639
- ProblemChannelRole["SPECTATORS"] = "spectators";
640
- })(ProblemChannelRole || (ProblemChannelRole = {}));
641
- /**
642
- * Roles of the public channels of a user: `user:{userId}:{role}` (see `CHANNEL_USER_ROLE`).
643
- * There are no per-user permissions: `spectators` is everyone who can list the submissions of the user.
644
- * The private channel of the user is `user:{userId}` (see `CHANNEL_USER`).
645
- */
646
- var UserChannelRole;
647
- (function (UserChannelRole) {
648
- UserChannelRole["SPECTATORS"] = "spectators";
649
- })(UserChannelRole || (UserChannelRole = {}));
650
-
651
- var DataViewMode;
652
- (function (DataViewMode) {
653
- DataViewMode["CARDS"] = "CARDS";
654
- DataViewMode["ROWS"] = "ROWS";
655
- })(DataViewMode || (DataViewMode = {}));
656
- var MenuViewMode;
657
- (function (MenuViewMode) {
658
- MenuViewMode["HORIZONTAL"] = "HORIZONTAL";
659
- MenuViewMode["VERTICAL"] = "VERTICAL";
660
- })(MenuViewMode || (MenuViewMode = {}));
661
- var Role;
662
- (function (Role) {
663
- Role["SUPER_ADMIN"] = "SUPER_ADMIN";
664
- Role["ADMIN"] = "ADMIN";
665
- Role["MASTER"] = "MASTER";
666
- Role["MANAGER"] = "MANAGER";
667
- Role["CREATOR"] = "CREATOR";
668
- Role["REGULAR"] = "REGULAR";
669
- Role["LIMITED"] = "LIMITED";
670
- Role["GUEST"] = "GUEST";
671
- Role["RESTRICTED"] = "RESTRICTED";
672
- })(Role || (Role = {}));
673
-
674
- var WorkingIn;
675
- (function (WorkingIn) {
676
- WorkingIn["NOTHING"] = "NOTHING";
677
- WorkingIn["SEND_SUBMISSION"] = "SEND_SUBMISSION";
678
- WorkingIn["TRACKING_SUBMISSION"] = "TRACKING_SUBMISSION";
679
- WorkingIn["CRAWLING_LANGUAGES"] = "CRAWLING_LANGUAGES";
680
- WorkingIn["CRAWLING_PROBLEM_DATA"] = "CRAWLING_PROBLEM_DATA";
681
- })(WorkingIn || (WorkingIn = {}));
682
-
683
- var AspectRatio;
684
- (function (AspectRatio) {
685
- AspectRatio["RATIO_21_9"] = "21:9";
686
- AspectRatio["RATIO_20_9"] = "20:9";
687
- AspectRatio["RATIO_16_9"] = "16:9";
688
- AspectRatio["RATIO_16_10"] = "16:10";
689
- AspectRatio["RATIO_3_2"] = "3:2";
690
- AspectRatio["RATIO_4_3"] = "4:3";
691
- AspectRatio["RATIO_5_4"] = "5:4";
692
- AspectRatio["RATIO_1_1"] = "1:1";
693
- })(AspectRatio || (AspectRatio = {}));
694
-
695
- const LANGUAGE = {
696
- [Language.EN]: { value: Language.EN, label: 'english' },
697
- [Language.ES]: { value: Language.ES, label: 'español' },
698
- };
699
- const THEME = {
700
- [Theme.LIGHT]: { value: Theme.LIGHT, label: 'light' },
701
- [Theme.DARK]: { value: Theme.DARK, label: 'dark' },
702
- };
703
- const GCC_VERSION = `gcc (Debian 12.2.0-14+deb12u1) 12.2.0
704
- Copyright (C) 2022 Free Software Foundation, Inc.
705
- This is free software; see the source for copying conditions. There is NO
706
- warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.`;
707
- const GPP_VERSION = `g++ (Debian 12.2.0-14+deb12u1) 12.2.0
708
- Copyright (C) 2022 Free Software Foundation, Inc.
709
- This is free software; see the source for copying conditions. There is NO
710
- warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.`;
711
- const JAVAC_VERSION = `javac 17.0.15`;
712
- const NODE_VERSION = `v20.19.2`;
713
- const PYTHON3_VERSION = 'Python 3.11.2';
714
- const PYPY3_VERSION = `Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
715
- [PyPy 7.3.11 with GCC 12.2.0]`;
716
- const PSEINT_VERSION = `PSeInt 20230904-l64-wx3
717
- http://pseint.sourceforge.net
718
- by Pablo Novara (zaskar_84@yahoo.com.ar)
719
- psExport 20230904-l64-wx3
720
- http://pseint.sourceforge.net
721
- by Pablo Novara (zaskar_84@yahoo.com.ar)`;
722
- const C = {
723
- mime: 'text/x-csrc',
724
- mainFilename: 'main.c',
725
- fileExtension: ['c'],
726
- hasBuildFile: true,
727
- executable: 'gcc',
728
- executableVersion: GCC_VERSION,
729
- templateSourceCode: '#include <stdio.h>\n \nint main(void) {\n \n printf("Hello World\\n");\n \n return 0;\n}',
730
- monacoKey: 'c',
731
- codeMirrorKey: 'c',
732
- highlightJsKey: 'c',
733
- };
734
- const CPP = {
735
- mime: 'text/x-c++src',
736
- mainFilename: 'main.cpp',
737
- fileExtension: ['cpp', 'c++', 'cxx', 'cc'],
738
- hasBuildFile: true,
739
- executable: 'g++',
740
- executableVersion: GPP_VERSION,
741
- templateSourceCode: '#include <iostream>\n\nusing namespace std;\n\n' + 'int main() {\n \n cout << "Hello World" << endl;\n \n return 0;\n}',
742
- monacoKey: 'cpp',
743
- codeMirrorKey: 'cpp',
744
- highlightJsKey: 'cpp',
745
- };
746
- const PYTHON = {
747
- mime: 'text/x-python',
748
- mainFilename: 'main.py',
749
- fileExtension: ['py'],
750
- hasBuildFile: false,
751
- templateSourceCode: 'print("Hello World\\n")',
752
- monacoKey: 'python',
753
- codeMirrorKey: 'python',
754
- highlightJsKey: 'python',
755
- };
756
- const CODE_LANGUAGE = {
757
- [CodeLanguage.C_11]: {
758
- value: CodeLanguage.C_11,
759
- label: 'C 11',
760
- compilePattern: '/usr/bin/jk-c11 -static -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE -fno-asm -lm -s -O2 -std=gnu11 -o ' +
761
- '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
762
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
763
- ...C,
764
- /*
765
- -static
766
- Binario independiente.
767
- -fno-optimize-sibling-calls
768
- Desactiva la optimización de llamadas recursivas “tail call”. Facilita detectar desbordes de pila o trazas correctas.
769
- -fno-strict-aliasing
770
- Evita asumir aliasing de punteros agresivo. Previene bugs raros en código competitivo.
771
- -DONLINE_JUDGE
772
- Define la macro ONLINE_JUDGE, usada a veces para omitir logs o debug prints (#ifdef ONLINE_JUDGE).
773
- -fno-asm
774
- Prohíbe insertar código ensamblador inline (asm()). Seguridad en entornos restringidos.
775
- -lm
776
- Enlaza libm.
777
- -s
778
- “Strips symbols”: elimina toda información de depuración. Binario más pequeño y más difícil de desensamblar.
779
- -O2
780
- Nivel medio de optimización (rápido y seguro).
781
- -std=gnu11
782
- Usa el estándar C11 con extensiones GNU.
783
- */
784
- },
785
- [CodeLanguage.CPP_11]: {
786
- value: CodeLanguage.CPP_11,
787
- label: 'C++ 11',
788
- compilePattern: '/usr/bin/jk-cpp11 -x c++ -static -DONLINE_JUDGE -lm -s -O2 -std=gnu++11 -o ' +
789
- '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
790
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
791
- ...CPP,
792
- },
793
- [CodeLanguage.CPP_20]: {
794
- value: CodeLanguage.CPP_20,
795
- label: 'C++ 20',
796
- compilePattern: '/usr/bin/jk-cpp20 -x c++ -static -DONLINE_JUDGE -lm -s -O2 -std=gnu++20 -o ' +
797
- '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
798
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
799
- ...CPP,
800
- },
801
- [CodeLanguage.JAVA_21]: {
802
- value: CodeLanguage.JAVA_21,
803
- label: 'Java 21',
804
- mime: 'text/x-java',
805
- mainFilename: 'Main.java',
806
- fileExtension: ['java'],
807
- compilePattern: "/usr/bin/jk-javac -cp '.;*' {{folder_path}}/{{source_full_file_name}}",
808
- // compilePattern: 'javac {{folder_path}}/{{source_full_file_name}}',
809
- // runPattern: 'java -cp {{folder_path}} {{class_name}}'
810
- runPattern: '/usr/bin/jk-java -Xmx512M -Xss64M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -cp ' + '{{folder_path}} {{class_name}}',
811
- templateSourceCode: 'class Main {\n public static void main (String[] args) {' + '\n \n System.out.println("Hello World");\n \n }\n}',
812
- hasBuildFile: true,
813
- executable: 'java',
814
- executableVersion: JAVAC_VERSION,
815
- monacoKey: 'java',
816
- codeMirrorKey: 'java',
817
- highlightJsKey: 'java',
818
- },
819
- [CodeLanguage.PYTHON_2]: {
820
- // DEPRECATED
821
- value: CodeLanguage.PYTHON_2,
822
- label: 'Python 2 *',
823
- compilePattern: '/usr/bin/jk-python2 -m py_compile {{folder_path}}/{{source_full_file_name}}',
824
- runPattern: '/usr/bin/jk-python2 {{folder_path}}/{{source_full_file_name}}',
825
- executable: 'python2',
826
- executableVersion: PYPY3_VERSION,
827
- ...PYTHON,
828
- },
829
- [CodeLanguage.PYTHON_3]: {
830
- value: CodeLanguage.PYTHON_3,
831
- label: 'Python 3',
832
- compilePattern: '/usr/bin/jk-python3 -m py_compile {{folder_path}}/{{source_full_file_name}}',
833
- runPattern: '/usr/bin/jk-python3 {{folder_path}}/{{source_full_file_name}}',
834
- executable: 'python3',
835
- executableVersion: PYPY3_VERSION,
836
- ...PYTHON,
837
- },
838
- [CodeLanguage.PYTHON_PYPY_2]: {
839
- // DEPRECATED
840
- value: CodeLanguage.PYTHON_PYPY_2,
841
- label: 'PyPy 2 *',
842
- compilePattern: '/usr/bin/jk-pypy2 -m py_compile {{folder_path}}/{{source_full_file_name}}',
843
- runPattern: '/usr/bin/jk-pypy2 {{folder_path}}/{{source_full_file_name}}',
844
- executable: 'pypy2',
845
- executableVersion: PYPY3_VERSION,
846
- ...PYTHON,
847
- },
848
- [CodeLanguage.PYTHON_PYPY_3]: {
849
- value: CodeLanguage.PYTHON_PYPY_3,
850
- label: 'PyPy 3',
851
- compilePattern: '/usr/bin/jk-pypy3 -m py_compile {{folder_path}}/{{source_full_file_name}}',
852
- runPattern: '/usr/bin/jk-pypy3 {{folder_path}}/{{source_full_file_name}}',
853
- executable: 'pypy3',
854
- executableVersion: PYPY3_VERSION,
855
- ...PYTHON,
856
- },
857
- [CodeLanguage.JAVASCRIPT_NODE_JS_22]: {
858
- value: CodeLanguage.JAVASCRIPT_NODE_JS_22,
859
- label: 'Javascript Node.js 22',
860
- mime: 'application/x-javascript',
861
- mainFilename: 'main.js',
862
- fileExtension: ['js'],
863
- compilePattern: '',
864
- runPattern: '/usr/bin/jk-node22 {{folder_path}}/{{source_full_file_name}}',
865
- templateSourceCode: 'console.log("Hello World\\n")',
866
- hasBuildFile: false,
867
- executable: 'node',
868
- executableVersion: NODE_VERSION,
869
- monacoKey: 'javascript',
870
- codeMirrorKey: 'javascript',
871
- highlightJsKey: 'javascript',
872
- },
873
- [CodeLanguage.ICPC_C]: {
874
- // DEPRECATED
875
- value: CodeLanguage.ICPC_C,
876
- label: 'ICPC C *',
877
- compilePattern: 'gcc -x c -g -O2 -std=gnu11 -static -lm -o ' + '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
878
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
879
- ...C,
880
- },
881
- [CodeLanguage.C]: {
882
- // DEPRECATED
883
- value: CodeLanguage.C,
884
- label: 'C *',
885
- compilePattern: 'gcc -static -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE -fno-asm -lm -s -O2 -o ' +
886
- '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
887
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
888
- ...C,
889
- },
890
- [CodeLanguage.ICPC_CPP]: {
891
- // DEPRECATED
892
- value: CodeLanguage.ICPC_CPP,
893
- label: 'ICPC C++ *',
894
- compilePattern: 'g++ -x c++ -static -g -O2 -std=gnu++20 -o ' + '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
895
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
896
- ...CPP,
897
- },
898
- [CodeLanguage.CPP]: {
899
- // DEPRECATED
900
- value: CodeLanguage.CPP,
901
- label: 'C++ *',
902
- compilePattern: 'g++ -x c++ -static -DONLINE_JUDGE -lm -s -O2 -o ' + '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
903
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
904
- ...CPP,
905
- },
906
- [CodeLanguage.CPP11]: {
907
- // DEPRECATED
908
- value: CodeLanguage.CPP11,
909
- label: 'C++ 11 *',
910
- compilePattern: 'g++ -x c++ -static -DONLINE_JUDGE -lm -s -O2 -std=c++11 -o ' + '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
911
- // compilePattern: 'g++ -O2 -s -Wall -std=c++11 -o {{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}} -lm',
912
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
913
- ...CPP,
914
- },
915
- [CodeLanguage.CPP14]: {
916
- // DEPRECATED
917
- value: CodeLanguage.CPP14,
918
- label: 'C++ 14 *',
919
- // compilePattern: 'g++ -O2 -s -Wall -std=c++14 -o {{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}} -lm',
920
- compilePattern: 'g++ -x c++ -static -DONLINE_JUDGE -lm -s -O2 -std=c++14 -o ' + '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
921
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
922
- ...CPP,
923
- },
924
- [CodeLanguage.CPP17]: {
925
- // DEPRECATED
926
- value: CodeLanguage.CPP17,
927
- label: 'C++ 17 *',
928
- // compilePattern: 'g++ -O2 -s -Wall -std=c++17 -o {{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}} -lm',
929
- compilePattern: 'g++ -x c++ -static -DONLINE_JUDGE -lm -s -O2 -std=c++17 -o ' + '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}',
930
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
931
- ...CPP,
932
- },
933
- [CodeLanguage.JAVA]: {
934
- // DEPRECATED
935
- value: CodeLanguage.JAVA,
936
- label: 'Java *',
937
- mime: 'text/x-java',
938
- mainFilename: 'Main.java',
939
- fileExtension: ['java'],
940
- compilePattern: "javac -cp '.;*' {{folder_path}}/{{source_full_file_name}}",
941
- // compilePattern: 'javac {{folder_path}}/{{source_full_file_name}}',
942
- // runPattern: 'java -cp {{folder_path}} {{class_name}}'
943
- runPattern: '/usr/lib/jvm/java-17-openjdk-amd64/bin/java -Xmx512M -Xss64M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -cp ' +
944
- '{{folder_path}} {{class_name}}',
945
- templateSourceCode: 'class Main {\n public static void main (String[] args) {' + '\n \n System.out.println("Hello World");\n \n }\n}',
946
- hasBuildFile: true,
947
- executable: 'javac',
948
- executableVersion: JAVAC_VERSION,
949
- monacoKey: 'java',
950
- codeMirrorKey: 'java',
951
- highlightJsKey: 'java',
952
- },
953
- [CodeLanguage.ICPC_PYTHON]: {
954
- // DEPRECATED
955
- value: CodeLanguage.ICPC_PYTHON,
956
- label: 'ICPC Python *',
957
- compilePattern: 'pypy3 -m py_compile {{folder_path}}/{{source_full_file_name}}',
958
- runPattern: '/usr/bin/pypy3 {{folder_path}}/{{source_full_file_name}}',
959
- executable: 'pypy3',
960
- executableVersion: PYPY3_VERSION,
961
- ...PYTHON,
962
- },
963
- [CodeLanguage.PYTHON]: {
964
- // DEPRECATED
965
- value: CodeLanguage.PYTHON,
966
- label: 'Python *',
967
- compilePattern: 'python3 -m py_compile {{folder_path}}/{{source_full_file_name}}',
968
- runPattern: '/usr/bin/python3 {{folder_path}}/{{source_full_file_name}}',
969
- executable: 'python3',
970
- executableVersion: PYTHON3_VERSION,
971
- ...PYTHON,
972
- },
973
- [CodeLanguage.PYTHON2]: {
974
- // DEPRECATED
975
- value: CodeLanguage.PYTHON2,
976
- label: 'Python 2 *',
977
- compilePattern: 'python2 -m py_compile {{folder_path}}/{{source_full_file_name}}',
978
- runPattern: '/usr/bin/python2 {{folder_path}}/{{source_full_file_name}}',
979
- executable: 'python',
980
- executableVersion: 'Python 2.7.18',
981
- ...PYTHON,
982
- },
983
- [CodeLanguage.PYTHON3]: {
984
- // DEPRECATED
985
- value: CodeLanguage.PYTHON3,
986
- label: 'Python 3 *',
987
- compilePattern: 'python3 -m py_compile {{folder_path}}/{{source_full_file_name}}',
988
- runPattern: '/usr/bin/python3 {{folder_path}}/{{source_full_file_name}}',
989
- executable: 'python3',
990
- executableVersion: PYTHON3_VERSION,
991
- ...PYTHON,
992
- },
993
- [CodeLanguage.JAVASCRIPT]: {
994
- // DEPRECATED
995
- value: CodeLanguage.JAVASCRIPT,
996
- label: 'Javascript *',
997
- mime: 'application/x-javascript',
998
- mainFilename: 'main.js',
999
- fileExtension: ['js'],
1000
- compilePattern: '',
1001
- runPattern: '/usr/bin/node {{folder_path}}/{{source_full_file_name}}',
1002
- templateSourceCode: 'console.log("Hello World\\n")',
1003
- hasBuildFile: false,
1004
- executable: 'node',
1005
- executableVersion: NODE_VERSION,
1006
- monacoKey: 'javascript',
1007
- codeMirrorKey: 'javascript',
1008
- highlightJsKey: 'javascript',
1009
- },
1010
- [CodeLanguage.TYPESCRIPT]: {
1011
- // DEPRECATED
1012
- value: CodeLanguage.TYPESCRIPT,
1013
- label: 'Typescript *',
1014
- mime: 'application/x-typescript',
1015
- mainFilename: 'main.ts',
1016
- fileExtension: ['ts'],
1017
- compilePattern: '',
1018
- runPattern: '/usr/bin/node {{folder_path}}/{{source_full_file_name}}',
1019
- templateSourceCode: 'console.log("Hello World\\n")',
1020
- hasBuildFile: false,
1021
- executable: 'node',
1022
- executableVersion: NODE_VERSION,
1023
- monacoKey: 'typescript',
1024
- codeMirrorKey: 'typescript',
1025
- highlightJsKey: 'typescript',
1026
- },
1027
- [CodeLanguage.TSX]: {
1028
- // DEPRECATED
1029
- value: CodeLanguage.TSX,
1030
- label: 'TSX *',
1031
- mime: 'application/x-typescript',
1032
- mainFilename: 'main.tsx',
1033
- fileExtension: ['tsx'],
1034
- compilePattern: '',
1035
- runPattern: '/usr/bin/node {{folder_path}}/{{source_full_file_name}}',
1036
- templateSourceCode: 'console.log("Hello World\\n")',
1037
- hasBuildFile: false,
1038
- executable: 'node',
1039
- executableVersion: NODE_VERSION,
1040
- monacoKey: 'typescript',
1041
- codeMirrorKey: 'typescript',
1042
- highlightJsKey: 'typescript',
1043
- },
1044
- [CodeLanguage.JSX]: {
1045
- // DEPRECATED
1046
- value: CodeLanguage.JSX,
1047
- label: 'JSX *',
1048
- mime: 'application/x-javascript',
1049
- mainFilename: 'main.jsx',
1050
- fileExtension: ['jsx'],
1051
- compilePattern: '',
1052
- runPattern: '/usr/bin/node {{folder_path}}/{{source_full_file_name}}',
1053
- templateSourceCode: 'console.log("Hello World\\n")',
1054
- hasBuildFile: false,
1055
- executable: 'node',
1056
- executableVersion: NODE_VERSION,
1057
- monacoKey: 'javascript',
1058
- codeMirrorKey: 'javascript',
1059
- highlightJsKey: 'javascript',
1060
- },
1061
- [CodeLanguage.PSEUDOCODE_PSEINT]: {
1062
- value: CodeLanguage.PSEUDOCODE_PSEINT,
1063
- label: 'Pseudo-código (PSeInt)',
1064
- mime: 'text/plain',
1065
- mainFilename: 'main.psc',
1066
- fileExtension: ['psc'],
1067
- compilePattern: 'jk-pseint {{folder_path}}/{{source_full_file_name}} --norun --nouser' +
1068
- ' && jk-pseint {{folder_path}}/{{source_full_file_name}} --draw {{folder_path}}/{{source_full_file_name}}.psd' +
1069
- ' && jk-psexport {{folder_path}}/{{source_full_file_name}}.psd {{folder_path}}/{{source_full_file_name}}.cpp --lang=cpp' +
1070
- ' && g++ -x c++ -g -O2 -std=gnu++20 -static -o ' +
1071
- '{{folder_path}}/{{compiled_file_name}} {{folder_path}}/{{source_full_file_name}}.cpp',
1072
- runPattern: '{{folder_path}}/{{compiled_file_name}}',
1073
- templateSourceCode: 'Algoritmo HOLA_MUNDO\n\tImprimir "Hello World"\nFinAlgoritmo\n',
1074
- hasBuildFile: false,
1075
- executable: '',
1076
- executableVersion: PSEINT_VERSION,
1077
- monacoKey: 'text',
1078
- codeMirrorKey: 'pseudocode-pseint',
1079
- highlightJsKey: 'plaintext',
1080
- },
1081
- [CodeLanguage.DOT]: {
1082
- value: CodeLanguage.DOT,
1083
- label: 'DOT',
1084
- mime: 'text/vnd.graphviz',
1085
- mainFilename: 'diagram.dot',
1086
- fileExtension: ['dot'],
1087
- compilePattern: '',
1088
- runPattern: '',
1089
- templateSourceCode: 'digraph G {\n A -> B;\n B -> C;\n}',
1090
- hasBuildFile: false,
1091
- executable: '',
1092
- executableVersion: '',
1093
- monacoKey: 'dot',
1094
- codeMirrorKey: 'dot',
1095
- highlightJsKey: 'plaintext',
1096
- },
1097
- [CodeLanguage.MERMAID]: {
1098
- value: CodeLanguage.MERMAID,
1099
- label: 'Mermaid',
1100
- mime: 'text/mermaid',
1101
- mainFilename: 'diagram.mmd',
1102
- fileExtension: ['mmd', 'mermaid'],
1103
- compilePattern: '',
1104
- runPattern: '',
1105
- templateSourceCode: `graph TD
1106
- A[Start] --> B{Is it working?}
1107
- B -- Yes --> C[Great!]
1108
- B -- No --> D[Fix it]
1109
- D --> B
1110
- `,
1111
- hasBuildFile: false,
1112
- executable: '',
1113
- executableVersion: '',
1114
- monacoKey: 'mermaid',
1115
- codeMirrorKey: 'mermaid',
1116
- highlightJsKey: 'plaintext',
1117
- },
1118
- [CodeLanguage.JSON]: {
1119
- value: CodeLanguage.JSON,
1120
- label: 'JSON',
1121
- mime: 'application/json',
1122
- mainFilename: 'main.json',
1123
- fileExtension: ['json'],
1124
- compilePattern: '',
1125
- runPattern: '',
1126
- templateSourceCode: '{\n \n}',
1127
- hasBuildFile: false,
1128
- executable: '',
1129
- executableVersion: '',
1130
- monacoKey: 'json',
1131
- codeMirrorKey: 'javascript',
1132
- highlightJsKey: 'json',
1133
- },
1134
- [CodeLanguage.TEXT]: {
1135
- value: CodeLanguage.TEXT,
1136
- label: 'plain text',
1137
- mime: 'text/plain',
1138
- mainFilename: 'main.txt',
1139
- fileExtension: ['txt', 'text', 'in', 'out'],
1140
- compilePattern: '',
1141
- runPattern: '',
1142
- templateSourceCode: '',
1143
- hasBuildFile: false,
1144
- executable: '',
1145
- executableVersion: '',
1146
- monacoKey: 'text',
1147
- codeMirrorKey: 'text',
1148
- highlightJsKey: 'plaintext',
1149
- },
1150
- [CodeLanguage.DIFF]: {
1151
- value: CodeLanguage.DIFF,
1152
- label: 'diff',
1153
- mime: 'text/plain',
1154
- mainFilename: 'main.patch',
1155
- fileExtension: ['diff', 'patch'],
1156
- compilePattern: '',
1157
- runPattern: '',
1158
- templateSourceCode: '',
1159
- hasBuildFile: false,
1160
- executable: '',
1161
- executableVersion: '',
1162
- monacoKey: 'diff',
1163
- codeMirrorKey: 'diff',
1164
- highlightJsKey: 'diff',
1165
- },
1166
- [CodeLanguage.LATEX]: {
1167
- value: CodeLanguage.LATEX,
1168
- label: 'LaTeX',
1169
- mime: 'application/x-latex',
1170
- mainFilename: 'main.tex',
1171
- fileExtension: ['tex'],
1172
- compilePattern: '',
1173
- runPattern: '',
1174
- templateSourceCode: '',
1175
- hasBuildFile: false,
1176
- executable: '',
1177
- executableVersion: '',
1178
- monacoKey: 'latex',
1179
- codeMirrorKey: 'stex',
1180
- highlightJsKey: 'latex',
1181
- },
1182
- // asc txt text diff pot
1183
- [CodeLanguage.MARKDOWN]: {
1184
- value: CodeLanguage.MARKDOWN,
1185
- label: 'Markdown',
1186
- mime: 'text/plain',
1187
- mainFilename: 'main.md',
1188
- fileExtension: ['md'],
1189
- compilePattern: '',
1190
- runPattern: '',
1191
- templateSourceCode: '# Hello World\n',
1192
- hasBuildFile: false,
1193
- executable: '',
1194
- executableVersion: '',
1195
- monacoKey: 'markdown',
1196
- codeMirrorKey: 'markdown',
1197
- highlightJsKey: 'markdown',
1198
- },
1199
- [CodeLanguage.MDX]: {
1200
- value: CodeLanguage.MDX,
1201
- label: 'MDX',
1202
- mime: 'text/plain',
1203
- mainFilename: 'main.mdx',
1204
- fileExtension: ['mdx'],
1205
- compilePattern: '',
1206
- runPattern: '',
1207
- templateSourceCode: '# Hello World\n',
1208
- hasBuildFile: false,
1209
- executable: '',
1210
- executableVersion: '',
1211
- monacoKey: 'markdown',
1212
- codeMirrorKey: 'markdown',
1213
- highlightJsKey: 'markdown',
1214
- },
1215
- [CodeLanguage.ARDUINO]: {
1216
- value: CodeLanguage.ARDUINO,
1217
- label: 'Arduino',
1218
- mime: 'text/plain',
1219
- mainFilename: 'main.c',
1220
- fileExtension: ['c', 'cpp', 'pde', 'h', 'ino'],
1221
- compilePattern: '',
1222
- runPattern: '',
1223
- templateSourceCode: '',
1224
- hasBuildFile: false,
1225
- executable: '',
1226
- executableVersion: '',
1227
- monacoKey: 'c',
1228
- codeMirrorKey: 'c',
1229
- highlightJsKey: 'c',
1230
- },
1231
- [CodeLanguage.HTML]: {
1232
- value: CodeLanguage.HTML,
1233
- label: 'HTML',
1234
- mime: 'text/HTML',
1235
- mainFilename: 'index.html',
1236
- fileExtension: ['html'],
1237
- compilePattern: '',
1238
- runPattern: '',
1239
- templateSourceCode: '',
1240
- hasBuildFile: false,
1241
- executable: '',
1242
- executableVersion: '',
1243
- monacoKey: 'html',
1244
- codeMirrorKey: 'html',
1245
- highlightJsKey: 'xml',
1246
- },
1247
- [CodeLanguage.BASH]: {
1248
- value: CodeLanguage.BASH,
1249
- label: 'Bash',
1250
- mime: 'text/plain',
1251
- mainFilename: 'main.sh',
1252
- fileExtension: ['sh', 'bash'],
1253
- compilePattern: '',
1254
- runPattern: '',
1255
- templateSourceCode: '#!/bin/bash\necho "Hello World"\n',
1256
- hasBuildFile: false,
1257
- executable: 'bash',
1258
- executableVersion: '',
1259
- monacoKey: 'shell',
1260
- codeMirrorKey: 'shell',
1261
- highlightJsKey: 'bash',
1262
- },
1263
- };
1264
- const PAGE_SIZES = ['32', '64', '128', '256', '512'];
1265
- const PALLETE = {
1266
- VIVOS: [
1267
- { color: '#FF0000', title: 'Rojo' },
1268
- { color: '#FF5900', title: 'Rojo - Naranja' },
1269
- { color: '#FF8600', title: 'Naranja' },
1270
- { color: '#FFBF00', title: 'Ámbar' },
1271
- { color: '#FFFF00', title: 'Amarillo' },
1272
- { color: '#A6FF00', title: 'Lima o Verde limon' },
1273
- { color: '#00FF8C', title: 'Verde puro' },
1274
- { color: '#00FF8C', title: 'Verde cian' },
1275
- { color: '#00FFFF', title: 'Cian' },
1276
- { color: '#0099FF', title: 'Cerúleo o Azur' },
1277
- { color: '#0000FF', title: 'Azul' },
1278
- { color: '#9F00FF', title: 'Violeta' },
1279
- { color: '#FF00FF', title: 'Magenta' },
1280
- { color: '#FF0099', title: 'Fucsia' },
1281
- ],
1282
- OSCUROS: [
1283
- { color: '#880000', title: 'Granate' },
1284
- { color: '#882F00', title: 'Caoba o Rojo indio' },
1285
- { color: '#884700', title: 'Marrón o Pardo' },
1286
- { color: '#886600', title: 'Marrón dorado' },
1287
- { color: '#888800', title: 'Oliva' },
1288
- { color: '#588800', title: 'Verde palta' },
1289
- { color: '#008800', title: 'Verde estándar' },
1290
- { color: '#008858', title: 'Esmeralda' },
1291
- { color: '#008888', title: 'Cerceta o Azul verde' },
1292
- { color: '#005288', title: 'Añil' },
1293
- { color: '#000080', title: 'Azul marino' },
1294
- { color: '#880088', title: 'Azul púrpura' },
1295
- { color: '#880088', title: 'Púrpura o Morado' },
1296
- { color: '#880047', title: 'Vino' },
1297
- ],
1298
- AGRISADOS: [
1299
- { color: '#BF4040', title: 'Lacre' },
1300
- { color: '#BF6340', title: 'Cobre' },
1301
- { color: '#BF8340', title: 'Cnalea o Ocre' },
1302
- { color: '#BF9F40', title: 'Dorado' },
1303
- { color: '#BFBF40', title: 'Chartreuse' },
1304
- { color: '#93BF40', title: 'Verde manzana' },
1305
- { color: '#93BF40', title: 'Verde bosque' },
1306
- { color: '#40BF40', title: 'Verde mar' },
1307
- { color: '#40BFBF', title: 'Turquesa' },
1308
- { color: '#408CBF', title: 'Azul acero' },
1309
- { color: '#4040BF', title: 'Zafiro' },
1310
- { color: '#9340BF', title: 'Amastista' },
1311
- { color: '#B140BF', title: 'Púrpureo' },
1312
- { color: '#B140BF', title: 'Fandango' },
1313
- ],
1314
- CLAROS: [
1315
- { color: '#FF7777', title: 'Coral' },
1316
- { color: '#FF9977', title: 'Salmón' },
1317
- { color: '#FFB977', title: 'Melón o Durazno' },
1318
- { color: '#FFDA80', title: 'Crema' },
1319
- { color: '#FFFF88', title: 'Maíz' },
1320
- { color: '#CFFF77', title: 'Té verde' },
1321
- { color: '#77FF77', title: 'Verde claro' },
1322
- { color: '#77FFAA', title: 'Menta' },
1323
- { color: '#80FFFF', title: 'Aguamarina' },
1324
- { color: '#73C7FF', title: 'Celeste' },
1325
- { color: '#8082FF', title: 'Bígaro o aciano' },
1326
- { color: '#C977FF', title: 'Lavanda o lila' },
1327
- { color: '#FF77FF', title: 'Malva' },
1328
- { color: '#FF77C1', title: 'Rosado' },
1329
- ],
1330
- };
1331
- const UPPERCASE_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
1332
- const LOWERCASE_LETTERS = UPPERCASE_LETTERS.toLowerCase();
1333
- const NUMBERS = '012345678';
1334
- const DEFAULT_JUKI_PROFILE_IMAGE = 'https://juki-judge.s3.us-east-2.amazonaws.com/public/file/5f69783aa7a8e048ef8d0ce2.';
1335
- const SEPARATOR_TOKEN = '\x1E';
1336
- const HEADER_JUKI_FORWARDED_HOST = 'x-juki-forwarded-host';
1337
- const HEADER_JUKI_VISITOR_SESSION_ID = 'x-juki-visitor-session-id';
1338
- const HEADER_JUKI_METADATA = 'x-juki-metadata';
1339
- const HEADER_JUKI_SECRET_TOKEN = 'x-juki-secret-token';
1340
- const HEADER_JUKI_INTERNAL_API_KEY = 'x-juki-internal-api-key';
1341
- const COOKIE_JUKI_SESSION_ID = 'juki-session-id';
1342
-
1343
- const JUKI_APP_ORGANIZATION_KEY = 'juki-app';
1344
- const ORGANIZATION_PLAN = {
1345
- [OrganizationPlan.FREE]: {
1346
- value: OrganizationPlan.FREE,
1347
- label: 'free',
1348
- description: 'the resources, runners and compilers, are shared with the juki.app giving priority to juki.app',
1349
- },
1350
- [OrganizationPlan.STANDARD]: {
1351
- value: OrganizationPlan.STANDARD,
1352
- label: 'standard',
1353
- description: 'the resources are dedicated, 1 runner and 1 compiler',
1354
- },
1355
- [OrganizationPlan.PREMIUM]: {
1356
- value: OrganizationPlan.PREMIUM,
1357
- label: 'premium',
1358
- description: 'the resources are dedicated and on demand use with at least 1 runner and 1 compiler',
1359
- },
1360
- [OrganizationPlan.CUSTOM]: {
1361
- value: OrganizationPlan.CUSTOM,
1362
- label: 'custom',
1363
- description: 'the resources are dedicated and on demand use with at least 1 (settable) runner and 1 (settable) compiler',
1364
- },
1365
- };
1366
-
1367
- const CONTEST_STATUS = {
1368
- [ContestStatus.PUBLIC]: {
1369
- value: ContestStatus.PUBLIC,
1370
- label: 'public',
1371
- description: 'the contest will appear in the contest list and the users will have access according to their roles',
1372
- },
1373
- [ContestStatus.RESERVED]: {
1374
- value: ContestStatus.RESERVED,
1375
- label: 'reserved',
1376
- description: 'the contest will appear in the contest list only for contest members and the users will have access according to their roles',
1377
- },
1378
- [ContestStatus.ARCHIVED]: {
1379
- value: ContestStatus.ARCHIVED,
1380
- label: 'archived',
1381
- description: 'the contest will not appear for anyone, contact the administrator to see it again',
1382
- },
1383
- };
1384
- const CONTEST_ROLE = {
1385
- [Role.RESTRICTED]: { value: Role.RESTRICTED, label: 'restricted', level: 7 },
1386
- [Role.GUEST]: { value: Role.GUEST, label: 'guest', level: 6 },
1387
- [Role.REGULAR]: { value: Role.REGULAR, label: 'regular', level: 5 },
1388
- [Role.CREATOR]: { value: Role.CREATOR, label: 'creator', level: 4 },
1389
- [Role.MANAGER]: { value: Role.MANAGER, label: 'manager', level: 3 },
1390
- [Role.MASTER]: { value: Role.MASTER, label: 'master', level: 2 },
1391
- [Role.ADMIN]: { value: Role.ADMIN, label: 'admin', level: 1 },
1392
- [Role.SUPER_ADMIN]: { value: Role.SUPER_ADMIN, label: 'super admin', level: 0 },
1393
- };
1394
-
1395
- const COURSE_ROLE = {
1396
- [CourseRole.RESTRICTED]: { value: CourseRole.RESTRICTED, label: 'restricted', level: 8 },
1397
- [CourseRole.GUEST]: { value: CourseRole.GUEST, label: 'guest', level: 7 },
1398
- [CourseRole.REGULAR]: { value: CourseRole.REGULAR, label: 'regular', level: 6 },
1399
- [CourseRole.CREATOR]: { value: CourseRole.CREATOR, label: 'creator', level: 5 },
1400
- [CourseRole.SUPER_CREATOR]: { value: CourseRole.SUPER_CREATOR, label: 'super creator', level: 4 },
1401
- [CourseRole.MANAGER]: { value: CourseRole.MANAGER, label: 'manager', level: 3 },
1402
- [CourseRole.MASTER]: { value: CourseRole.MASTER, label: 'super admin', level: 2 },
1403
- [CourseRole.ADMIN]: { value: CourseRole.ADMIN, label: 'admin', level: 1 },
1404
- [CourseRole.SUPER_ADMIN]: { value: CourseRole.SUPER_ADMIN, label: 'super admin', level: 0 },
1405
- };
1406
-
1407
- function isStringJson(str) {
1408
- try {
1409
- if (typeof str === 'string') {
1410
- JSON.parse(str);
1411
- return true;
1412
- }
1413
- }
1414
- catch (e) {
1415
- return false;
1416
- }
1417
- return false;
1418
- }
1419
- function safeJsonParse(str) {
1420
- try {
1421
- if (typeof str === 'string') {
1422
- return JSON.parse(str);
1423
- }
1424
- }
1425
- catch (e) {
1426
- return null;
1427
- }
1428
- return null;
1429
- }
1430
- function isObjectJson(obj) {
1431
- try {
1432
- return typeof JSON.stringify(obj) === 'string';
1433
- }
1434
- catch (e) {
1435
- return false;
1436
- }
1437
- }
1438
- function mex(array) {
1439
- let i = 0;
1440
- while (array.indexOf(i) !== -1) {
1441
- i++;
1442
- }
1443
- return i;
1444
- }
1445
- function range(start, end) {
1446
- const result = [];
1447
- for (let i = start; i < end; i++) {
1448
- result.push(i);
1449
- }
1450
- return result;
1451
- }
1452
- async function getPlainText(url) {
1453
- return await fetch(url)
1454
- .then(data => data.text())
1455
- .catch((error) => {
1456
- console.error('ERROR:', error);
1457
- return '';
1458
- });
1459
- }
1460
- function objectUpdate(base, update) {
1461
- if (JSON.stringify(base) === JSON.stringify(update)) {
1462
- return base;
1463
- }
1464
- if (base !== null && update !== null && !Array.isArray(base) && typeof base === 'object' && typeof update === 'object') {
1465
- const mergeKeys = new Set([...Object.keys(base), ...Object.keys(update)]);
1466
- Array.from(mergeKeys).forEach(key => {
1467
- if (update[key] !== null && update[key] !== undefined && base[key] !== update[key]) {
1468
- base[key] = objectUpdate(base[key], update[key]);
1469
- }
1470
- });
1471
- return base;
1472
- }
1473
- if (update !== null && update !== undefined) {
1474
- return update;
1475
- }
1476
- return base;
1477
- }
1478
- function objectsUpdate(base, ...objects) {
1479
- let newObject = { ...base };
1480
- objects.forEach((update) => {
1481
- newObject = objectUpdate(newObject, update);
1482
- });
1483
- return newObject;
1484
- }
1485
- function consoleWarn(...warn) {
1486
- console.warn(new Date().toLocaleString(), ...warn);
1487
- }
1488
- function consoleInfo(...info) {
1489
- console.info(new Date().toLocaleString(), ...info);
1490
- }
1491
- function consoleError(...error) {
1492
- console.error(new Date().toLocaleString(), ...error);
1493
- }
1494
- function indexToLetters(index) {
1495
- const d = Math.ceil(index / 26);
1496
- if (d === 1) {
1497
- return UPPERCASE_LETTERS.charAt(index - 1);
1498
- }
1499
- return UPPERCASE_LETTERS.charAt(d - 2) + UPPERCASE_LETTERS.charAt(index - (26 * (d - 1)) - 1);
1500
- }
1501
- function lettersToIndex(index) {
1502
- if (index.length) {
1503
- if (index.length === 1) {
1504
- const d = UPPERCASE_LETTERS.indexOf(index);
1505
- if (d !== -1) {
1506
- return d + 1;
1507
- }
1508
- }
1509
- else if (index.length === 2) {
1510
- const a = index.charAt(0);
1511
- const b = index.charAt(1);
1512
- const numA = lettersToIndex(a);
1513
- const numB = lettersToIndex(b);
1514
- return numA * 26 + numB;
1515
- }
1516
- }
1517
- return 0;
1518
- }
1519
- function getProblemJudgeKey(judge, key) {
1520
- return `${judge}-${key}`;
1521
- }
1522
- /**
1523
- * https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string
1524
- * Format bytes as human-readable text.
1525
- *
1526
- * @param bytes Number of bytes.
1527
- * @param si True to use metric (SI) units, aka powers of 1000. False to use
1528
- * binary (IEC), aka powers of 1024.
1529
- * @param dp Number of decimal places to display.
1530
- *
1531
- * @return Formatted string.
1532
- */
1533
- function humanFileSize(bytes, si = false, dp = 1) {
1534
- const thresh = si ? 1000 : 1024;
1535
- if (Math.abs(bytes) < thresh) {
1536
- return bytes + ' B';
1537
- }
1538
- const units = si
1539
- ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
1540
- : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
1541
- let u = -1;
1542
- const r = 10 ** dp;
1543
- do {
1544
- bytes /= thresh;
1545
- ++u;
1546
- } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
1547
- return bytes.toFixed(dp) + ' ' + units[u];
1548
- }
1549
- function stringToArrayBuffer(str) {
1550
- const buf = new ArrayBuffer(str.length); //convert str to arrayBuffer
1551
- const view = new Uint8Array(buf); //create Uint8Array as viewer
1552
- for (let i = 0; i < str.length; i++) {
1553
- view[i] = str.charCodeAt(i) & 0xFF; //convert to octet
1554
- }
1555
- return buf;
1556
- }
1557
- function chunkString(str, size) {
1558
- const numChunks = Math.ceil(str.length / size);
1559
- const chunks = new Array(numChunks);
1560
- for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
1561
- chunks[i] = str.substr(o, size);
1562
- }
1563
- return chunks;
1564
- }
1565
- function getRandomString(length) {
1566
- const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // 62
1567
- let retVal = '';
1568
- for (let i = 0; i < length; ++i) {
1569
- retVal += charset.charAt(Math.floor(Math.random() * charset.length));
1570
- }
1571
- return retVal;
1572
- }
1573
- function join(array) {
1574
- return array.join(SEPARATOR_TOKEN);
1575
- }
1576
- function split(text) {
1577
- return text.split(SEPARATOR_TOKEN);
1578
- }
1579
- const areArraysDifferent = (a, b) => {
1580
- if (a === b) {
1581
- return false;
1582
- }
1583
- if (a.length !== b.length) {
1584
- return true;
1585
- }
1586
- for (let i = 0; i < b.length; i += 1) {
1587
- if (b[i] !== a[i]) {
1588
- return true;
1589
- }
1590
- }
1591
- return false;
1592
- };
1593
-
1594
- const YEARS = range(1970, 2100);
1595
- const MONTH_NAMES = [
1596
- 'January',
1597
- 'February',
1598
- 'March',
1599
- 'April',
1600
- 'May',
1601
- 'June',
1602
- 'July',
1603
- 'August',
1604
- 'September',
1605
- 'October',
1606
- 'November',
1607
- 'December',
1608
- ];
1609
- const DAY_NAMES = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
1610
- const HOURS = range(0, 24);
1611
- const MINUTES = range(0, 60);
1612
- const SECONDS = range(0, 60);
1613
- const MILLISECONDS = range(0, 1000);
1614
- const MAX_DATE = new Date(8640000000000000);
1615
- const MIN_DATE = new Date(0);
1616
-
1617
- const SUPPORT_EMAIL = 'support@juki.app';
1618
- const JUKI_APP_EMAIL_TEMPLATE = `<div style="width: 100%; background: #F2F2F2;">
1619
- <div style="background: #164066; width: 100%;">
1620
- <div style="height: 56px; color: white; width: 100px; margin: 0 auto">
1621
- <img
1622
- src="https://images.juki.pub/assets/juki-app-horizontal-white-logo.svg"
1623
- alt="juki app logo"
1624
- height="56px"
1625
- style="padding:10px; box-sizing: border-box"
1626
- />
1627
- </div>
1628
- </div>
1629
- <div style="padding: 24px; color: #333333; font-family: sans-serif; font-size: 16px; line-height: 24px;">
1630
- <div style="max-width: 520px; margin: 0 auto; padding: 24px; background: white; border-radius: 6px;">
1631
- <section style="padding: 0 0 1em 0; border-bottom: 1px solid #828282;">
1632
- {{content}}
1633
- </section>
1634
- <div style="font-size: 14px; text-align: center; color: #828282; line-height: 16px; padding-top: 1em">
1635
- <p style="margin: 0;">
1636
- Si tú no realizaste la solicitud, escribenos a
1637
- <a href="mailto:${SUPPORT_EMAIL}" style="color: #2468A6; text-decoration: none;">
1638
- ${SUPPORT_EMAIL}
1639
- </a>
1640
- </p>
1641
- <p style="margin: 0;">
1642
- Este mensaje fue enviado por el equipo de
1643
- <a href="https://juki.app" style="color: #2468A6; text-decoration: none;">
1644
- juki.app
1645
- </a>
1646
- </p>
1647
- </div>
1648
- </div>
1649
- </div>
1650
- </div>`;
1651
-
1652
- const EMPTY_DOCUMENT_MEMBERS = () => ({
1653
- access: EntityAccess.PRIVATE,
1654
- managers: {},
1655
- spectators: {},
1656
- });
1657
- const EMPTY_ENTITY_MEMBERS = () => ({
1658
- rankAdministrators: EntityMembersRank.CLOSE,
1659
- administrators: {},
1660
- rankManagers: EntityMembersRank.CLOSE,
1661
- managers: {},
1662
- rankGuests: EntityMembersRank.CLOSE,
1663
- guests: {},
1664
- rankSpectators: EntityMembersRank.CLOSE,
1665
- spectators: {},
1666
- rankParticipants: EntityMembersRank.CLOSE,
1667
- participants: {},
1668
- });
1669
-
1670
- const JUDGE = {
1671
- // [Judge.CUSTOMER]: {
1672
- // value: Judge.CUSTOMER,
1673
- // label: '',
1674
- // logo: 'https://images.juki.pub/c/juki-judge-logo-horizontal-color.svg',
1675
- // logoSize: [ 883.991, 435 ],
1676
- // url: '',
1677
- // // getLoginUrl: () => '',
1678
- // // getProfileUrl: () => '',
1679
- // // getSubmitUrl: () => '',
1680
- // // getSubmissionUrl: () => '',
1681
- // // getProblemUrl: (key: string) => `/problem/view/${key}`,
1682
- // // getUserSubmissionsUrl: () => '',
1683
- // },
1684
- [Judge.JUKI_JUDGE]: {
1685
- value: Judge.JUKI_JUDGE,
1686
- label: 'Juki Judge',
1687
- logo: 'https://images.juki.pub/c/juki-judge-logo-horizontal-color.svg',
1688
- logoSize: [883.991, 435],
1689
- url: 'https://judge.juki.app',
1690
- // getLoginUrl: () => '',
1691
- // getProfileUrl: () => '',
1692
- // getSubmitUrl: () => '',
1693
- // getSubmissionUrl: () => '',
1694
- // getProblemUrl: (key: string) => `https://judge.juki.app/problem/view/${key}`,
1695
- // getUserSubmissionsUrl: () => '',
1696
- },
1697
- [Judge.CODEFORCES]: {
1698
- value: Judge.CODEFORCES,
1699
- label: 'Codeforces',
1700
- logo: 'https://images.juki.pub/c/codeforces-logo-horizontal-color.svg',
1701
- logoSize: [1232.75, 145.12],
1702
- url: 'https://codeforces.com',
1703
- // getLoginUrl: () => 'https://codeforces.com/enter',
1704
- // getProfileUrl: () => '',
1705
- // getSubmitUrl: () => 'https://codeforces.com/problemset/submit',
1706
- // getSubmissionUrl: (problemKey: string, submissionId: string) => {
1707
- // const [ contestId ] = problemKey.split('-');
1708
- // return `https://codeforces.com/problemset/submission/${contestId}/${submissionId}`;
1709
- // },
1710
- // getProblemUrl: (problemKey: string) => {
1711
- // const [ contestId, index ] = problemKey.split('-');
1712
- // return `https://codeforces.com/problemset/problem/${contestId}/${index}`;
1713
- // },
1714
- // getUserSubmissionsUrl: () => '',
1715
- },
1716
- [Judge.CODEFORCES_GYM]: {
1717
- value: Judge.CODEFORCES_GYM,
1718
- label: 'Codeforces Gym',
1719
- logo: 'https://images.juki.pub/c/codeforces-logo-horizontal-color.svg',
1720
- logoSize: [1232.75, 145.12],
1721
- url: 'https://codeforces.com',
1722
- // getLoginUrl: () => 'https://codeforces.com/enter',
1723
- // getProfileUrl: () => '',
1724
- // getSubmitUrl: (problemKey: string) => {
1725
- // const [ gymContestId, index ] = problemKey.split('-');
1726
- // return `https://codeforces.com/gym/${gymContestId}/submit`;
1727
- // },
1728
- // getSubmissionUrl: (problemKey: string, submissionId: string) => {
1729
- // const [ gymContestId ] = problemKey.split('-');
1730
- // return `https://codeforces.com/gym/${gymContestId}/submission/${submissionId}`;
1731
- // },
1732
- // getProblemUrl: (problemKey: string) => {
1733
- // const [ gymContestId, index ] = problemKey.split('-');
1734
- // return `https://codeforces.com/gym/${gymContestId}/problem/${index}`;
1735
- // },
1736
- // getUserSubmissionsUrl: () => '',
1737
- },
1738
- [Judge.JV_UMSA]: {
1739
- value: Judge.JV_UMSA,
1740
- label: 'Juez Virtual UMSA',
1741
- logo: 'https://images.juki.pub/c/codeforces-logo-horizontal-color.svg',
1742
- logoSize: [1232.75, 145.12],
1743
- url: 'https://jv.umsa.bo',
1744
- // getLoginUrl: () => 'https://jv.umsa.bo/oj/login.php',
1745
- // getProfileUrl: () => 'https://jv.umsa.bo/oj/userInfo.php',
1746
- // getSubmitUrl: (problemKey: string) => {
1747
- // // single problem: '1019'
1748
- // // cib problem: '1019-A'
1749
- // const isContestProblem = problemKey.includes('-');
1750
- // // A -> 0, B -> 1, C -> 2, D -> 3, E -> 4, F -> 5, G -> 6, H -> 7, I -> 8, J -> 9
1751
- // const params = problemKey.split('-');
1752
- // return isContestProblem
1753
- // ? `https://jv.umsa.bo/oj/submitpage.php?cid=${params[0]}&pid=${params[1].charCodeAt(0) - 65}`
1754
- // : `https://jv.umsa.bo/oj/submitpage.php?id=${problemKey}`;
1755
- // },
1756
- // getSubmissionUrl: (problemKey: string, submissionId: string, username: string) => {
1757
- // // return `https://jv.umsa.bo/status.php?problem_id=&user_id=${username}&language=-1&jresult=-1`;
1758
- // return `https://jv.umsa.bo/oj/showsource.php?id=${submissionId}`;
1759
- // },
1760
- // getProblemUrl: (problemKey: string) => {
1761
- // const isContestProblem = problemKey.includes('-');
1762
- // const params = problemKey.split('-');
1763
- // return isContestProblem
1764
- // ? `https://jv.umsa.bo/oj/problem.php?cid=${params[0]}&pid=${params[1].charCodeAt(0) - 65}`
1765
- // : `https://jv.umsa.bo/oj/problem.php?id=${problemKey}`;
1766
- // },
1767
- // getUserSubmissionsUrl: (username: string) => `https://jv.umsa.bo/oj/status.php?user_id=${username}`,
1768
- },
1769
- [Judge.UVA_ONLINE_JUDGE]: {
1770
- value: Judge.UVA_ONLINE_JUDGE,
1771
- label: 'Uva Online Judge',
1772
- logo: 'https://images.juki.pub/c/uva-online-judge-logo-color.png',
1773
- logoSize: [150, 135.994],
1774
- url: 'https://onlinejudge.org',
1775
- },
1776
- [Judge.AT_CODER]: {
1777
- value: Judge.AT_CODER,
1778
- label: 'AtCoder',
1779
- logo: 'https://images.juki.pub/c/at-coder-logo-color.png',
1780
- logoSize: [762.997, 675],
1781
- url: 'https://atcoder.jp',
1782
- },
1783
- [Judge.CODECHEF]: {
1784
- value: Judge.CODECHEF,
1785
- label: 'Codechef',
1786
- logo: 'https://images.juki.pub/c/codechef-logo-color.svg',
1787
- logoSize: [1207.7, 453.17],
1788
- url: 'https://www.codechef.com',
1789
- },
1790
- [Judge.TOPCODER]: {
1791
- value: Judge.TOPCODER,
1792
- label: 'Topcoder',
1793
- logo: 'https://images.juki.pub/c/topcoder-logo-color.png',
1794
- logoSize: [971.99, 415.99],
1795
- url: 'https://www.topcoder.com',
1796
- },
1797
- [Judge.LEETCODE]: {
1798
- value: Judge.LEETCODE,
1799
- label: 'LeetCode',
1800
- logo: 'https://images.juki.pub/assets/leetcode-logo-color.svg',
1801
- logoSize: [95, 111],
1802
- url: 'https://leetcode.com',
1803
- // getProblemUrl: (problemKey: string) => {
1804
- // return `https://leetcode.com/problems/${problemKey.replace('PL-', '')}`;
1805
- // },
1806
- // getProfileUrl: (userNickname: string) => {
1807
- // return `https://leetcode.com/u/${userNickname}`;
1808
- // },
1809
- // getSubmissionUrl: (problemKey: string, submissionId: string, username: string, submissionRunId: string) => {
1810
- // return `https://leetcode.com/problems/${problemKey.replace('PL-', '')}/submissions/${submissionRunId}`;
1811
- // },
1812
- },
1813
- };
1814
- const RUNNER_ACCEPTED_PROBLEM_MODES = [
1815
- ProblemScoringMode.TOTAL,
1816
- ProblemScoringMode.SUBTASK,
1817
- ProblemScoringMode.PARTIAL,
1818
- ];
1819
- const RUNNER_ACCEPTED_PROBLEM_TYPES = [
1820
- ProblemType.STANDARD,
1821
- ProblemType.DYNAMIC,
1822
- ];
1823
- const RUNNER_ACCEPTED_PROGRAMMING_LANGUAGES = [
1824
- CodeLanguage.C_11,
1825
- CodeLanguage.CPP_11,
1826
- CodeLanguage.CPP_20,
1827
- CodeLanguage.JAVA_21,
1828
- CodeLanguage.PYTHON_3,
1829
- CodeLanguage.PYTHON_PYPY_3,
1830
- CodeLanguage.JAVASCRIPT_NODE_JS_22,
1831
- CodeLanguage.PSEUDOCODE_PSEINT,
1832
- ];
1833
- const ACCEPTED_PROGRAMMING_LANGUAGES = [
1834
- ...RUNNER_ACCEPTED_PROGRAMMING_LANGUAGES,
1835
- ];
1836
- const PROBLEM_VERDICT = {
1837
- [ProblemVerdict.NONE]: { value: ProblemVerdict.NONE, label: 'none', color: '#555555' },
1838
- [ProblemVerdict.PENDING]: { value: ProblemVerdict.PENDING, label: 'pending', color: '#79B6FD' },
1839
- [ProblemVerdict.HIDDEN]: { value: ProblemVerdict.HIDDEN, label: 'hidden', color: '#555555' },
1840
- [ProblemVerdict.AC]: { value: ProblemVerdict.AC, label: 'accepted', color: '#43D787' },
1841
- [ProblemVerdict.PE]: { value: ProblemVerdict.PE, label: 'presentation error', color: '#55db93' },
1842
- [ProblemVerdict.PA]: { value: ProblemVerdict.PA, label: 'partial accepted', color: '#55db93' },
1843
- [ProblemVerdict.CE]: { value: ProblemVerdict.CE, label: 'compilation error', color: '#FE9F9F' },
1844
- [ProblemVerdict.RE]: { value: ProblemVerdict.RE, label: 'runtime error', color: '#FE9F9F' },
1845
- [ProblemVerdict.TLE]: { value: ProblemVerdict.TLE, label: 'time limit exceed', color: '#FE9F9F' },
1846
- [ProblemVerdict.MLE]: { value: ProblemVerdict.MLE, label: 'memory limit exceed', color: '#FE9F9F' },
1847
- [ProblemVerdict.WA]: { value: ProblemVerdict.WA, label: 'wrong answer', color: '#FE9F9F' },
1848
- };
1849
- const PROBLEM_VERDICTS = [
1850
- ProblemVerdict.NONE,
1851
- ProblemVerdict.PENDING,
1852
- ProblemVerdict.AC,
1853
- ProblemVerdict.PE,
1854
- ProblemVerdict.PA,
1855
- ProblemVerdict.CE,
1856
- ProblemVerdict.RE,
1857
- ProblemVerdict.TLE,
1858
- ProblemVerdict.MLE,
1859
- ProblemVerdict.WA,
1860
- ];
1861
- const SUBMISSION_RUN_STATUS = {
1862
- [SubmissionRunStatus.NONE]: { value: SubmissionRunStatus.NONE, label: 'none' }, // status
1863
- [SubmissionRunStatus.RECEIVED]: { value: SubmissionRunStatus.RECEIVED, label: 'received' }, // state
1864
- [SubmissionRunStatus.COMPILING]: { value: SubmissionRunStatus.COMPILING, label: 'compiling' }, // state
1865
- [SubmissionRunStatus.COMPILED]: { value: SubmissionRunStatus.COMPILED, label: 'compiled' }, // status
1866
- [SubmissionRunStatus.COMPILATION_ERROR]: { value: SubmissionRunStatus.COMPILATION_ERROR, label: 'compilation error' }, // status
1867
- [SubmissionRunStatus.FETCHING_TEST_CASES]: {
1868
- value: SubmissionRunStatus.FETCHING_TEST_CASES,
1869
- label: 'fetching test cases',
1870
- }, // state
1871
- [SubmissionRunStatus.RUNNING_TEST_CASE]: { value: SubmissionRunStatus.RUNNING_TEST_CASE, label: 'running test case' }, // state
1872
- [SubmissionRunStatus.RUNNING_TEST_CASES]: {
1873
- value: SubmissionRunStatus.RUNNING_TEST_CASES,
1874
- label: 'running test cases',
1875
- }, // state
1876
- [SubmissionRunStatus.RUNNING_SAMPLE_TEST_CASES]: {
1877
- value: SubmissionRunStatus.RUNNING_SAMPLE_TEST_CASES,
1878
- label: 'running sample cases',
1879
- }, // state
1880
- [SubmissionRunStatus.EXECUTED_TEST_CASE]: {
1881
- value: SubmissionRunStatus.EXECUTED_TEST_CASE,
1882
- label: 'executed test case',
1883
- }, // status
1884
- [SubmissionRunStatus.FAILED_TEST_CASE]: { value: SubmissionRunStatus.FAILED_TEST_CASE, label: 'failed test case' }, // status
1885
- [SubmissionRunStatus.JUDGING_TEST_CASE]: { value: SubmissionRunStatus.JUDGING_TEST_CASE, label: 'judging test case' }, // state
1886
- [SubmissionRunStatus.GRADING]: { value: SubmissionRunStatus.GRADING, label: 'grading' }, // status
1887
- [SubmissionRunStatus.FAILED]: { value: SubmissionRunStatus.FAILED, label: 'failed' }, // status
1888
- [SubmissionRunStatus.COMPLETED]: { value: SubmissionRunStatus.COMPLETED, label: 'completed' }, // status
1889
- };
1890
- const RUNNER_TYPE = {
1891
- [RunnerType.HIGH_PERFORMANCE]: { value: RunnerType.HIGH_PERFORMANCE, label: 'high performance' },
1892
- [RunnerType.LOW_PERFORMANCE]: { value: RunnerType.LOW_PERFORMANCE, label: 'low performance' },
1893
- };
1894
-
1895
- const PROBLEM_INPUT = {
1896
- [ProblemInput.STANDARD]: { value: ProblemInput.STANDARD, label: 'standard' },
1897
- [ProblemInput.INTERACTIVE]: { value: ProblemInput.INTERACTIVE, label: 'interactive' },
1898
- };
1899
- const PROBLEM_OUTPUT = {
1900
- [ProblemOutput.STANDARD]: { value: ProblemOutput.STANDARD, label: 'standard' },
1901
- [ProblemOutput.DYNAMIC]: { value: ProblemOutput.DYNAMIC, label: 'dynamic' },
1902
- [ProblemOutput.INTERACTIVE]: { value: ProblemOutput.INTERACTIVE, label: 'interactive' },
1903
- };
1904
- const PROBLEM_MODES = [ProblemScoringMode.TOTAL, ProblemScoringMode.SUBTASK, ProblemScoringMode.PARTIAL];
1905
- const PROBLEM_MODE = {
1906
- [ProblemScoringMode.TOTAL]: {
1907
- value: ProblemScoringMode.TOTAL,
1908
- label: 'total',
1909
- description: 'if all test cases are Accepted the result is Accepted '
1910
- + 'otherwise it will be Runtime Error, Time Limited Exceeded, Memory Limited Exceeded, Wrong Answer or Presentation Error in that order.',
1911
- },
1912
- [ProblemScoringMode.SUBTASK]: {
1913
- value: ProblemScoringMode.SUBTASK,
1914
- label: 'subtask',
1915
- description: 'the test cases are grouped and each group of test cases is assigned a score, '
1916
- + 'if all test cases in a group are Accepted then the score assigned to that group of test cases is added to total score, '
1917
- + 'if total score is equal to the sum of the assigned scores of all groups of test cases then the result is Accepted, '
1918
- + 'otherwise if the total score is greater than zero the result is Partial Accepted with the total accumulated score, '
1919
- + 'otherwise it will be Runtime Error, Time Limited Exceeded, Memory Limited Exceeded, Wrong Answer or Presentation Error in that order.',
1920
- },
1921
- [ProblemScoringMode.PARTIAL]: {
1922
- value: ProblemScoringMode.PARTIAL,
1923
- label: 'partial',
1924
- description: 'the test cases are grouped and each group is associated with X points, '
1925
- + 'and each test case in a group scores X points ',
1926
- },
1927
- };
1928
- const PROBLEM_TYPES = [ProblemType.STANDARD, ProblemType.DYNAMIC, ProblemType.INTERACTIVE];
1929
- const PROBLEM_TYPE = {
1930
- [ProblemType.STANDARD]: {
1931
- value: ProblemType.STANDARD,
1932
- label: 'standard',
1933
- description: 'The contestant submit a single source code in one of the allowed programming languages. '
1934
- + 'The source code is either standalone or to be compiled. '
1935
- + 'The resulting user\'s executable does I/O standard input and output. '
1936
- + 'The output produced by the contestant\'s program is then compared to the correct output using a simple diff algorithm.',
1937
- },
1938
- [ProblemType.INTERACTIVE]: {
1939
- value: ProblemType.INTERACTIVE, label: 'interactive', description: 'developing..',
1940
- },
1941
- [ProblemType.DYNAMIC]: {
1942
- value: ProblemType.DYNAMIC,
1943
- label: 'dynamic',
1944
- description: 'The contestant submit a single source code in one of the allowed programming languages. '
1945
- + 'The user\'s source code is either standalone or to be compiled. '
1946
- + 'The resulting user\'s executable does I/O standard input and output. '
1947
- + 'The output produced by the contestant\'s program is saved. '
1948
- + 'The problem editor save a single source code in C++ 17. '
1949
- + 'The editor\'s source code can read judge input filepath argv[1], judge output filepath argv[2], user\'s output filepath argv[3], user\'s error filepath argv[4], user\'s log filepath argv[5], user\'s source filepath argv[6] and submission information filepath argv[7] (companyId, submitId, runId, userId, contestId, problemId, language, userNickname, timestamp). '
1950
- + 'The resulting editor\'s executable should be "AC" or a number between 1 and 100 for partial accepted',
1951
- },
1952
- };
1953
- const PROBLEM_ROLE = {
1954
- [Role.RESTRICTED]: { value: Role.RESTRICTED, label: 'restricted', level: 7 },
1955
- [Role.GUEST]: { value: Role.GUEST, label: 'guest', level: 6 },
1956
- [Role.REGULAR]: { value: Role.REGULAR, label: 'regular', level: 5 },
1957
- [Role.CREATOR]: { value: Role.CREATOR, label: 'creator', level: 4 },
1958
- [Role.MANAGER]: { value: Role.MANAGER, label: 'manager', level: 3 },
1959
- [Role.MASTER]: { value: Role.MASTER, label: 'master', level: 2 },
1960
- [Role.ADMIN]: { value: Role.ADMIN, label: 'admin', level: 1 },
1961
- [Role.SUPER_ADMIN]: { value: Role.SUPER_ADMIN, label: 'super admin', level: 0 },
1962
- };
1963
-
1964
- const _TYPE = ':type';
1965
- const _KEY = ':key';
1966
- const _TAB = ':tab';
1967
- const _SUB_TAB = ':subTab?';
1968
- const _SUB_SUB_TAB = ':subSubTab?';
1969
- const PAGE = 'page';
1970
- const PAGE_SIZE = 'size';
1971
-
1972
- const ERROR = {
1973
- // Http Errors
1974
- [ErrorCode.ERR500]: { value: ErrorCode.ERR500, message: 'internal server error', status: 500 },
1975
- [ErrorCode.ERR400]: { value: ErrorCode.ERR400, message: 'bad request', status: 400 },
1976
- [ErrorCode.ERR401]: { value: ErrorCode.ERR401, message: 'unauthorized', status: 401 },
1977
- [ErrorCode.ERR403]: { value: ErrorCode.ERR403, message: 'forbidden', status: 403 },
1978
- [ErrorCode.ERR404]: { value: ErrorCode.ERR404, message: 'not found', status: 404 },
1979
- [ErrorCode.ERR405]: { value: ErrorCode.ERR405, message: 'method not allowed', status: 405 },
1980
- // UI general errors
1981
- [ErrorCode.ERR9997]: { value: ErrorCode.ERR9997, message: 'aborted request', status: 400 },
1982
- [ErrorCode.ERR9998]: { value: ErrorCode.ERR9998, message: 'error on response', status: 400 },
1983
- [ErrorCode.ERR9999]: { value: ErrorCode.ERR9999, message: 'service no found', status: 400 },
1984
- // ORGANIZATION ERRORS ERR99XX
1985
- [ErrorCode.ERR9900]: { value: ErrorCode.ERR9900, message: 'internal server error on organization service', status: 500 },
1986
- // Organization server errors
1987
- [ErrorCode.ERR9910]: { value: ErrorCode.ERR9910, message: 'organization not created', status: 500 },
1988
- [ErrorCode.ERR9911]: { value: ErrorCode.ERR9911, message: 'organization not found', status: 500 },
1989
- [ErrorCode.ERR9912]: { value: ErrorCode.ERR9912, message: 'organization not updated', status: 500 },
1990
- [ErrorCode.ERR9913]: { value: ErrorCode.ERR9913, message: 'organization not deleted', status: 500 },
1991
- // Organization user permission error
1992
- [ErrorCode.ERR9914]: { value: ErrorCode.ERR9914, message: 'not allowed to create the organization', status: 400 },
1993
- [ErrorCode.ERR9915]: { value: ErrorCode.ERR9915, message: 'not allowed to view the organization', status: 400 },
1994
- [ErrorCode.ERR9916]: { value: ErrorCode.ERR9916, message: 'not allowed to updated the organization', status: 400 },
1995
- [ErrorCode.ERR9917]: { value: ErrorCode.ERR9917, message: 'not allowed to deleted the organization', status: 400 },
1996
- // USER ERRORS ERR00XX
1997
- [ErrorCode.ERR0000]: { value: ErrorCode.ERR0000, message: 'internal server error on users service', status: 500 },
1998
- // User server errors
1999
- [ErrorCode.ERR0010]: { value: ErrorCode.ERR0010, message: 'user not created', status: 500 },
2000
- [ErrorCode.ERR0011]: { value: ErrorCode.ERR0011, message: 'user not found', status: 500 },
2001
- [ErrorCode.ERR0012]: { value: ErrorCode.ERR0012, message: 'user not updated', status: 500 },
2002
- [ErrorCode.ERR0013]: { value: ErrorCode.ERR0013, message: 'user not deleted', status: 500 },
2003
- // User user permission error
2004
- [ErrorCode.ERR0014]: { value: ErrorCode.ERR0014, message: 'not allowed to create the user', status: 400 },
2005
- [ErrorCode.ERR0015]: { value: ErrorCode.ERR0015, message: 'not allowed to view the user', status: 400 },
2006
- [ErrorCode.ERR0016]: { value: ErrorCode.ERR0016, message: 'not allowed to updated the user', status: 400 },
2007
- [ErrorCode.ERR0017]: { value: ErrorCode.ERR0017, message: 'not allowed to deleted the user', status: 400 },
2008
- // User status permissions errors
2009
- [ErrorCode.ERR0018]: { value: ErrorCode.ERR0018, message: 'user is reported', status: 400 },
2010
- [ErrorCode.ERR0019]: { value: ErrorCode.ERR0019, message: 'user is archived', status: 400 },
2011
- // User others permissions errors
2012
- [ErrorCode.ERR0020]: { value: ErrorCode.ERR0020, message: 'user with email requested not found', status: 400 },
2013
- [ErrorCode.ERR0021]: { value: ErrorCode.ERR0021, message: 'user with nickname requested not found', status: 400 },
2014
- [ErrorCode.ERR0022]: { value: ErrorCode.ERR0022, message: 'the email is already registered', status: 400 },
2015
- [ErrorCode.ERR0023]: { value: ErrorCode.ERR0023, message: 'the nickname is already taken', status: 400 },
2016
- [ErrorCode.ERR0024]: { value: ErrorCode.ERR0024, message: 'incorrect password', status: 400 },
2017
- // User sessions errors
2018
- [ErrorCode.ERR0050]: { value: ErrorCode.ERR0050, message: 'user session not created', status: 500 },
2019
- [ErrorCode.ERR0051]: { value: ErrorCode.ERR0051, message: 'user session not found', status: 500 },
2020
- [ErrorCode.ERR0052]: { value: ErrorCode.ERR0052, message: 'user session not updated', status: 500 },
2021
- [ErrorCode.ERR0053]: { value: ErrorCode.ERR0053, message: 'user session not deleted', status: 500 },
2022
- // PROBLEM ERRORS ERR01XX
2023
- [ErrorCode.ERR0100]: { value: ErrorCode.ERR0100, message: 'internal server error on problems service', status: 500 },
2024
- // Problem server errors
2025
- [ErrorCode.ERR0110]: { value: ErrorCode.ERR0110, message: 'problem not created', status: 500 },
2026
- [ErrorCode.ERR0111]: { value: ErrorCode.ERR0111, message: 'problem not found', status: 500 },
2027
- [ErrorCode.ERR0112]: { value: ErrorCode.ERR0112, message: 'problem not updated', status: 500 },
2028
- [ErrorCode.ERR0113]: { value: ErrorCode.ERR0113, message: 'problem not deleted', status: 500 },
2029
- // Problem user permission error
2030
- [ErrorCode.ERR0114]: { value: ErrorCode.ERR0114, message: 'not allowed to create the problem', status: 400 },
2031
- [ErrorCode.ERR0115]: { value: ErrorCode.ERR0115, message: 'not allowed to view the problem', status: 400 },
2032
- [ErrorCode.ERR0116]: { value: ErrorCode.ERR0116, message: 'not allowed to updated the problem', status: 400 },
2033
- [ErrorCode.ERR0117]: { value: ErrorCode.ERR0117, message: 'not allowed to deleted the problem', status: 400 },
2034
- // Problem others permissions errors
2035
- [ErrorCode.ERR0118]: { value: ErrorCode.ERR0118, message: 'problem mode not supported', status: 500 },
2036
- [ErrorCode.ERR0119]: { value: ErrorCode.ERR0119, message: 'problem type not supported', status: 500 },
2037
- [ErrorCode.ERR0120]: { value: ErrorCode.ERR0120, message: 'problem time limit must be a number', status: 500 },
2038
- [ErrorCode.ERR0121]: { value: ErrorCode.ERR0121, message: 'problem memory limit must be number', status: 500 },
2039
- [ErrorCode.ERR0122]: { value: ErrorCode.ERR0122, message: 'test case file empty', status: 400 },
2040
- // Contest Errors ERR02XX
2041
- [ErrorCode.ERR0200]: { value: ErrorCode.ERR0200, message: 'internal server error on contests service', status: 500 },
2042
- // Contest Server Error
2043
- [ErrorCode.ERR0210]: { value: ErrorCode.ERR0210, message: 'contest not created', status: 500 },
2044
- [ErrorCode.ERR0211]: { value: ErrorCode.ERR0211, message: 'contest not found', status: 500 },
2045
- [ErrorCode.ERR0212]: { value: ErrorCode.ERR0212, message: 'contest not updated', status: 500 },
2046
- [ErrorCode.ERR0213]: { value: ErrorCode.ERR0213, message: 'contest not deleted', status: 500 },
2047
- // Contest User Permission error
2048
- [ErrorCode.ERR0214]: { value: ErrorCode.ERR0214, message: 'not allowed to create the contest', status: 400 },
2049
- [ErrorCode.ERR0215]: { value: ErrorCode.ERR0215, message: 'not allowed to view the contest', status: 400 },
2050
- [ErrorCode.ERR0216]: { value: ErrorCode.ERR0216, message: 'not allowed to updated the contest', status: 400 },
2051
- [ErrorCode.ERR0217]: { value: ErrorCode.ERR0217, message: 'not allowed to deleted the contest', status: 400 },
2052
- // Contest Others permissions errors
2053
- [ErrorCode.ERR0218]: { value: ErrorCode.ERR0218, message: 'not allowed to register to the contest', status: 400 },
2054
- [ErrorCode.ERR0219]: { value: ErrorCode.ERR0219, message: 'is already registered', status: 400 },
2055
- [ErrorCode.ERR0220]: { value: ErrorCode.ERR0220, message: 'not allowed to view contests', status: 400 },
2056
- [ErrorCode.ERR0230]: { value: ErrorCode.ERR0230, message: 'scoreboard not created', status: 500 },
2057
- [ErrorCode.ERR0231]: { value: ErrorCode.ERR0231, message: 'scoreboard not found', status: 500 },
2058
- [ErrorCode.ERR0232]: { value: ErrorCode.ERR0232, message: 'scoreboard not updated', status: 500 },
2059
- [ErrorCode.ERR0233]: { value: ErrorCode.ERR0233, message: 'scoreboard not deleted', status: 500 },
2060
- [ErrorCode.ERR0234]: { value: ErrorCode.ERR0234, message: 'not allowed to create the scoreboard', status: 400 },
2061
- [ErrorCode.ERR0235]: { value: ErrorCode.ERR0235, message: 'not allowed to view the scoreboard', status: 400 },
2062
- [ErrorCode.ERR0236]: { value: ErrorCode.ERR0236, message: 'not allowed to update the scoreboard', status: 400 },
2063
- [ErrorCode.ERR0237]: { value: ErrorCode.ERR0237, message: 'not allowed to delete the scoreboard', status: 400 },
2064
- [ErrorCode.ERR0240]: { value: ErrorCode.ERR0240, message: 'clarification not created', status: 500 },
2065
- [ErrorCode.ERR0241]: { value: ErrorCode.ERR0241, message: 'clarification not found', status: 500 },
2066
- [ErrorCode.ERR0242]: { value: ErrorCode.ERR0242, message: 'clarification not updated', status: 500 },
2067
- [ErrorCode.ERR0243]: { value: ErrorCode.ERR0243, message: 'clarification not deleted', status: 500 },
2068
- [ErrorCode.ERR0244]: { value: ErrorCode.ERR0244, message: 'not allowed to submit clarification', status: 400 },
2069
- [ErrorCode.ERR0245]: { value: ErrorCode.ERR0245, message: 'not allowed to view clarification', status: 400 },
2070
- [ErrorCode.ERR0246]: { value: ErrorCode.ERR0246, message: 'not allowed to update clarification', status: 400 },
2071
- [ErrorCode.ERR0247]: { value: ErrorCode.ERR0247, message: 'not allowed to delete clarification', status: 400 },
2072
- // Submission Errors ERR03XXX
2073
- [ErrorCode.ERR0300]: {
2074
- value: ErrorCode.ERR0300,
2075
- message: 'internal server error on submissions service',
2076
- status: 500,
2077
- },
2078
- [ErrorCode.ERR0301]: { value: ErrorCode.ERR0301, message: 'submission not found', status: 500 },
2079
- [ErrorCode.ERR0302]: { value: ErrorCode.ERR0302, message: 'submission not created', status: 500 },
2080
- [ErrorCode.ERR0303]: { value: ErrorCode.ERR0303, message: 'submission not updated', status: 500 },
2081
- [ErrorCode.ERR0310]: { value: ErrorCode.ERR0310, message: 'source empty', status: 400 },
2082
- [ErrorCode.ERR0311]: { value: ErrorCode.ERR0311, message: 'programming language not supported', status: 400 },
2083
- [ErrorCode.ERR0321]: {
2084
- value: ErrorCode.ERR0321,
2085
- message: 'not allowed submit the problem in the contest',
2086
- status: 400,
2087
- },
2088
- [ErrorCode.ERR0331]: { value: ErrorCode.ERR0331, message: 'judgement unavailable', status: 400 },
2089
- // Utils Errors ERR04XX
2090
- [ErrorCode.ERR0400]: { value: ErrorCode.ERR0400, message: 'internal server error on utils services', status: 500 },
2091
- [ErrorCode.ERR0410]: { value: ErrorCode.ERR0410, message: 'empty image', status: 400 },
2092
- [ErrorCode.ERR0420]: { value: ErrorCode.ERR0420, message: '', status: 400 }, // codes
2093
- [ErrorCode.ERR0421]: { value: ErrorCode.ERR0421, message: 'compilation failed', status: 400 }, // codes
2094
- [ErrorCode.ERR0430]: { value: ErrorCode.ERR0430, message: '', status: 400 }, // files
2095
- [ErrorCode.ERR0440]: { value: ErrorCode.ERR0440, message: 'the email could not be sent', status: 400 }, // mails
2096
- // TEAMS ERRORS ERR06XX
2097
- [ErrorCode.ERR0600]: { value: ErrorCode.ERR0600, message: 'internal server error on teams service', status: 500 },
2098
- // Teams server errors
2099
- [ErrorCode.ERR0610]: { value: ErrorCode.ERR0610, message: 'team not created', status: 400 },
2100
- [ErrorCode.ERR0611]: { value: ErrorCode.ERR0611, message: 'team not found', status: 400 },
2101
- [ErrorCode.ERR0612]: { value: ErrorCode.ERR0612, message: 'team not updated', status: 400 },
2102
- [ErrorCode.ERR0613]: { value: ErrorCode.ERR0613, message: 'team not deleted', status: 400 },
2103
- // Teams user permission error
2104
- [ErrorCode.ERR0614]: { value: ErrorCode.ERR0614, message: 'not allowed to create the team', status: 400 },
2105
- [ErrorCode.ERR0615]: { value: ErrorCode.ERR0615, message: 'not allowed to view the team', status: 400 },
2106
- [ErrorCode.ERR0616]: { value: ErrorCode.ERR0616, message: 'not allowed to updated the team', status: 400 },
2107
- [ErrorCode.ERR0617]: { value: ErrorCode.ERR0617, message: 'not allowed to deleted the team', status: 400 },
2108
- // Teams status permission error
2109
- [ErrorCode.ERR0618]: { value: ErrorCode.ERR0618, message: 'team is reported', status: 400 },
2110
- [ErrorCode.ERR0619]: { value: ErrorCode.ERR0619, message: 'team is archived', status: 400 },
2111
- // FILES ERRORS ERR08XX
2112
- [ErrorCode.ERR0800]: { value: ErrorCode.ERR0800, message: 'internal server error on files service', status: 500 },
2113
- // Files server errors
2114
- [ErrorCode.ERR0810]: { value: ErrorCode.ERR0810, message: 'file not created', status: 400 },
2115
- [ErrorCode.ERR0811]: { value: ErrorCode.ERR0811, message: 'file not found', status: 400 },
2116
- [ErrorCode.ERR0812]: { value: ErrorCode.ERR0812, message: 'file not updated', status: 400 },
2117
- [ErrorCode.ERR0813]: { value: ErrorCode.ERR0813, message: 'file not deleted', status: 400 },
2118
- // Files user permission error
2119
- [ErrorCode.ERR0814]: { value: ErrorCode.ERR0814, message: 'not allowed to create the file', status: 400 },
2120
- [ErrorCode.ERR0815]: { value: ErrorCode.ERR0815, message: 'not allowed to view the file', status: 400 },
2121
- [ErrorCode.ERR0816]: { value: ErrorCode.ERR0816, message: 'not allowed to updated the file', status: 400 },
2122
- [ErrorCode.ERR0817]: { value: ErrorCode.ERR0817, message: 'not allowed to deleted the file', status: 400 },
2123
- // Files status permission error
2124
- [ErrorCode.ERR0818]: { value: ErrorCode.ERR0818, message: 'file is reserved', status: 400 },
2125
- [ErrorCode.ERR0819]: { value: ErrorCode.ERR0819, message: 'file is private', status: 400 },
2126
- [ErrorCode.ERR0820]: { value: ErrorCode.ERR0820, message: 'file is archived', status: 400 },
2127
- };
2128
-
2129
- const FILE_TYPE = {
2130
- [FileType.FILE]: { value: FileType.FILE, label: 'file' },
2131
- [FileType.FOLDER]: { value: FileType.FOLDER, label: 'folder' },
2132
- };
2133
- const FILE_ROLE = {
2134
- [Role.RESTRICTED]: { value: Role.RESTRICTED, label: 'restricted', level: 5 },
2135
- [Role.GUEST]: { value: Role.GUEST, label: 'guest', level: 4 },
2136
- [Role.REGULAR]: { value: Role.REGULAR, label: 'regular', level: 3 },
2137
- [Role.MASTER]: { value: Role.MASTER, label: 'master', level: 2 },
2138
- [Role.ADMIN]: { value: Role.ADMIN, label: 'admin', level: 1 },
2139
- [Role.SUPER_ADMIN]: { value: Role.SUPER_ADMIN, label: 'super admin', level: 0 },
2140
- };
2141
- const ENTITY_STATE = {
2142
- [EntityState.RELEASED]: {
2143
- value: EntityState.RELEASED,
2144
- label: 'released',
2145
- },
2146
- [EntityState.ARCHIVED]: {
2147
- value: EntityState.ARCHIVED,
2148
- label: 'archived',
2149
- },
2150
- };
2151
- const ENTITY_ACCESS = {
2152
- [EntityAccess.PRIVATE]: {
2153
- value: EntityAccess.PRIVATE,
2154
- label: 'private',
2155
- description: 'the record will be visible and editable only to the owner',
2156
- },
2157
- [EntityAccess.RESTRICTED]: {
2158
- value: EntityAccess.RESTRICTED,
2159
- label: 'restricted',
2160
- description: 'the record will be visible to viewers and the owner and editable to editors and the owner',
2161
- },
2162
- [EntityAccess.PUBLIC]: {
2163
- value: EntityAccess.PUBLIC,
2164
- label: 'public',
2165
- description: 'the record will be visible to anyone and editable to editors and the owner',
2166
- },
2167
- [EntityAccess.EXPOSED]: {
2168
- value: EntityAccess.EXPOSED,
2169
- label: 'exposed',
2170
- description: 'the record will be visible and editable to anyone',
2171
- },
2172
- };
2173
-
2174
- const SYSTEM_ROLE = {
2175
- [SystemRole.GUEST]: { value: SystemRole.GUEST, label: 'guest', level: 5 },
2176
- [SystemRole.REGULAR]: { value: SystemRole.REGULAR, label: 'regular', level: 4 },
2177
- [SystemRole.MANAGER]: { value: SystemRole.MANAGER, label: 'manager', level: 3 },
2178
- [SystemRole.MASTER]: { value: SystemRole.MASTER, label: 'master', level: 2 },
2179
- [SystemRole.ADMIN]: { value: SystemRole.ADMIN, label: 'admin', level: 1 },
2180
- [SystemRole.SUPER_ADMIN]: { value: SystemRole.SUPER_ADMIN, label: 'super admin', level: 0 },
2181
- };
2182
-
2183
- const MEMBER_ROLE = {
2184
- [MemberRole.COACH]: { value: MemberRole.COACH, label: 'coach' },
2185
- [MemberRole.CO_COACH]: { value: MemberRole.CO_COACH, label: 'co-coach' },
2186
- [MemberRole.STAFF]: { value: MemberRole.STAFF, label: 'staff' },
2187
- [MemberRole.ATTENDEE]: { value: MemberRole.ATTENDEE, label: 'attendee' },
2188
- [MemberRole.RESERVE]: { value: MemberRole.RESERVE, label: 'reserve' },
2189
- [MemberRole.CONTESTANT]: { value: MemberRole.CONTESTANT, label: 'contestant' },
2190
- };
2191
- const TEAM_ROLE = {
2192
- [TeamRole.RESTRICTED]: { value: TeamRole.RESTRICTED, label: 'restricted', level: 5 },
2193
- [TeamRole.GUEST]: { value: TeamRole.GUEST, label: 'guest', level: 4 },
2194
- [TeamRole.REGULAR]: { value: TeamRole.REGULAR, label: 'regular', level: 3 },
2195
- [TeamRole.MANAGER]: { value: TeamRole.MANAGER, label: 'manager', level: 2 },
2196
- [TeamRole.ADMIN]: { value: TeamRole.ADMIN, label: 'admin', level: 1 },
2197
- [TeamRole.SUPER_ADMIN]: { value: TeamRole.SUPER_ADMIN, label: 'super admin', level: 0 },
2198
- };
2199
-
2200
- const ONE_SECOND = 1000;
2201
- const SEC_30 = ONE_SECOND * 30;
2202
- const SEC_60 = ONE_SECOND * 60;
2203
- const SEC_90 = ONE_SECOND * 90;
2204
- const SEC_120 = ONE_SECOND * 120;
2205
- const ONE_MINUTE = ONE_SECOND * 60;
2206
- const ONE_HOUR = ONE_MINUTE * 60;
2207
- const ONE_DAY = ONE_HOUR * 24;
2208
- const ONE_WEEK = ONE_DAY * 7;
2209
-
2210
- const USER_STATUS = {
2211
- [UserStatus.ACTIVE]: { value: UserStatus.ACTIVE, label: 'active' },
2212
- [UserStatus.REPORTED]: { value: UserStatus.REPORTED, label: 'reported' },
2213
- [UserStatus.ARCHIVED]: { value: UserStatus.ARCHIVED, label: 'archived' },
2214
- };
2215
- const USER_ROLE = {
2216
- [UserRole.RESTRICTED]: { value: UserRole.RESTRICTED, label: 'restricted', level: 6 },
2217
- [UserRole.GUEST]: { value: UserRole.GUEST, label: 'guest', level: 5 },
2218
- [UserRole.LIMITED]: { value: UserRole.LIMITED, label: 'limited', level: 4 },
2219
- [UserRole.REGULAR]: { value: UserRole.REGULAR, label: 'regular', level: 3 },
2220
- [UserRole.MANAGER]: { value: UserRole.MANAGER, label: 'manager', level: 2 },
2221
- [UserRole.ADMIN]: { value: UserRole.ADMIN, label: 'admin', level: 1 },
2222
- [UserRole.SUPER_ADMIN]: { value: UserRole.SUPER_ADMIN, label: 'super admin', level: 0 },
2223
- };
2224
- const EMPTY_USER_PERMISSIONS = {
2225
- users: {
2226
- create: false,
2227
- manage: false,
2228
- administrate: false,
2229
- },
2230
- problems: {
2231
- create: false,
2232
- manage: false,
2233
- },
2234
- submissions: {
2235
- manage: false,
2236
- },
2237
- contests: {
2238
- create: false,
2239
- manage: false,
2240
- },
2241
- organization: {
2242
- manage: false,
2243
- administrate: false,
2244
- },
2245
- services: {
2246
- administrate: false,
2247
- },
2248
- };
2249
-
2250
- // TOPIC channels
2251
- // The backend publishes each event once on the channel of its topic and Ably does the fan-out.
2252
- // Who can subscribe to each channel is decided by the API in the Ably token (capability), never by the client.
2253
- // Dynamic segments are encoded so a key can never inject a `:` (the Ably segment separator used by the wildcards).
2254
- const segment = (value) => encodeURIComponent(value);
2255
- /** private: events of one session (code runs, requested data) */
2256
- const CHANNEL_SESSION = (sessionId) => `session:${segment(sessionId)}`;
2257
- /** private: events of one user (own submissions while the contest is frozen, notifications, own problem crawls) */
2258
- const CHANNEL_USER = (userId) => `user:${segment(userId)}`;
2259
- /** per role: public events of one user (judging of its submissions visible to everyone, see `UserChannelRole`) */
2260
- const CHANNEL_USER_ROLE = (userId, role) => `user:${segment(userId)}:${role}`;
2261
- /** public: status of a submission when it is visible to everyone */
2262
- const CHANNEL_SUBMISSION = (submitId) => `submission:${segment(submitId)}`;
2263
- /** per role: events of a problem for one role (judging of its submissions, see `ProblemChannelRole`) */
2264
- const CHANNEL_PROBLEM = (problemKey, role) => `problem:${segment(problemKey)}:${role}`;
2265
- /** per role: events of a contest for one role (and the roles above it, see `ContestChannelRole`) */
2266
- const CHANNEL_CONTEST = (contestKey, role) => `contest:${segment(contestKey)}:${role}`;
2267
- /**
2268
- * presence of the clients (tabs) of the logged users of a organization (by its key), data: `UserPresenceData`.
2269
- * The clients only enter (capability `presence`), only the administrators of the organization receive it
2270
- * (capability `presence-subscribe`). Ably limits the presence members per channel (200 by default,
2271
- * more with server-side batching enabled on the `presence` namespace).
2272
- * The identity of a member is its `clientId` (`sessionId|uiId`, verified by Ably), never its data.
2273
- */
2274
- const CHANNEL_ORGANIZATION_PRESENCE = (organizationKey) => `presence:organization:${segment(organizationKey)}`;
2275
- // capability resources (wildcards) of the public channels.
2276
- // Ably: a trailing `*` replaces one or more segments, any other `*` exactly one segment. So `user:*:spectators`
2277
- // matches every `user:{userId}:spectators` but never the private `user:{userId}`.
2278
- // There is no public `problem:*`: it would also match the role channels `problem:{problemKey}:{role}`.
2279
- const CHANNEL_SUBMISSION_ALL = 'submission:*';
2280
- const CHANNEL_USER_SPECTATORS_ALL = `user:*:${UserChannelRole.SPECTATORS}`;
2281
- /**
2282
- * Returns the contest and role of a `CHANNEL_CONTEST` channel name, or null if it is not one.
2283
- */
2284
- const getContestChannelParams = (channel) => {
2285
- const [namespace, contestKey, role, ...rest] = channel.split(':');
2286
- if (namespace !== 'contest' || !contestKey || rest.length || !Object.values(ContestChannelRole).includes(role)) {
2287
- return null;
2288
- }
2289
- return { contestKey: decodeURIComponent(contestKey), role: role };
2290
- };
2291
- /**
2292
- * Returns the problem and role of a `CHANNEL_PROBLEM` channel name, or null if it is not one.
2293
- */
2294
- const getProblemChannelParams = (channel) => {
2295
- const [namespace, problemKey, role, ...rest] = channel.split(':');
2296
- if (namespace !== 'problem' || !problemKey || rest.length || !Object.values(ProblemChannelRole).includes(role)) {
2297
- return null;
2298
- }
2299
- return { problemKey: decodeURIComponent(problemKey), role: role };
2300
- };
2301
-
2302
- const NEW_PAGE_SHEET = () => ({
2303
- id: v4(),
2304
- type: WorksheetType.NEW_PAGE,
2305
- title: '',
2306
- points: 0,
2307
- });
2308
- const ASPECT_RATIO = {
2309
- [AspectRatio.RATIO_21_9]: {
2310
- aspectRatio: AspectRatio.RATIO_21_9,
2311
- width: 2520,
2312
- height: 1080,
2313
- decimal: 21 / 9,
2314
- label: 'ultrawide',
2315
- },
2316
- [AspectRatio.RATIO_20_9]: {
2317
- aspectRatio: AspectRatio.RATIO_20_9,
2318
- width: 2400,
2319
- height: 1080,
2320
- decimal: 20 / 9,
2321
- label: 'mobile wide',
2322
- },
2323
- [AspectRatio.RATIO_16_9]: {
2324
- aspectRatio: AspectRatio.RATIO_16_9,
2325
- width: 1920,
2326
- height: 1080,
2327
- decimal: 16 / 9,
2328
- label: 'widescreen',
2329
- },
2330
- [AspectRatio.RATIO_16_10]: {
2331
- aspectRatio: AspectRatio.RATIO_16_10,
2332
- width: 1920,
2333
- height: 1200,
2334
- decimal: 16 / 10,
2335
- label: 'widescreen tall',
2336
- },
2337
- [AspectRatio.RATIO_3_2]: {
2338
- aspectRatio: AspectRatio.RATIO_3_2,
2339
- width: 1440,
2340
- height: 960,
2341
- decimal: 3 / 2,
2342
- label: 'balanced',
2343
- },
2344
- [AspectRatio.RATIO_4_3]: {
2345
- aspectRatio: AspectRatio.RATIO_4_3,
2346
- width: 1024,
2347
- height: 768,
2348
- decimal: 4 / 3,
2349
- label: 'standard',
2350
- },
2351
- [AspectRatio.RATIO_5_4]: {
2352
- aspectRatio: AspectRatio.RATIO_5_4,
2353
- width: 1280,
2354
- height: 1024,
2355
- decimal: 5 / 4,
2356
- label: 'square old',
2357
- },
2358
- [AspectRatio.RATIO_1_1]: {
2359
- aspectRatio: AspectRatio.RATIO_1_1,
2360
- width: 1000,
2361
- height: 1000,
2362
- decimal: 1,
2363
- label: 'square',
2364
- },
2365
- };
2366
-
2367
- var ContestProblemBlockedByType;
2368
- (function (ContestProblemBlockedByType) {
2369
- ContestProblemBlockedByType["UNMET_PREREQUISITES"] = "UNMET_PREREQUISITES";
2370
- ContestProblemBlockedByType["MAX_ACCEPTED_SUBMISSIONS_ACHIEVED"] = "MAX_ACCEPTED_SUBMISSIONS_ACHIEVED";
2371
- ContestProblemBlockedByType["START_TIME_IN_THE_FUTURE"] = "START_TIME_IN_THE_FUTURE";
2372
- ContestProblemBlockedByType["END_TIME_IN_THE_PAST"] = "END_TIME_IN_THE_PAST";
2373
- })(ContestProblemBlockedByType || (ContestProblemBlockedByType = {}));
2374
-
2375
- var MemberType;
2376
- (function (MemberType) {
2377
- MemberType["USER"] = "USER";
2378
- MemberType["TEAM"] = "TEAM";
2379
- })(MemberType || (MemberType = {}));
2380
-
2381
- const isWorksheetAssignment = (assignment) => {
2382
- return assignment.type === AssignmentClass.WORKSHEET;
2383
- };
2384
- const isCourseAssignment = (assignment) => {
2385
- return assignment.type === AssignmentClass.COURSE;
2386
- };
2387
- const isContestAssignment = (assignment) => {
2388
- return assignment.type === AssignmentClass.CONTEST;
2389
- };
2390
-
2391
- const getAssignmentCommentKey = (classKey, cycleKey, sessionKey, assignmentKey) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}`;
2392
- const getAssignmentUserCommentKey = (classKey, cycleKey, sessionKey, assignmentKey, userNickname, userOrganization) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}|user_nickname:${userNickname}|user_organization:${userOrganization}`;
2393
- const getProblemCommentKey = (problemKey) => `problem:${problemKey}`;
2394
- const getContestCommentKey = (contestKey) => `contest:${contestKey}`;
2395
-
2396
- const isEndlessContest = (settings) => {
2397
- return settings?.startsAt === MIN_DATE.getTime()
2398
- && settings?.frozenAt === MAX_DATE.getTime()
2399
- && settings?.silencedAt === MAX_DATE.getTime()
2400
- && settings?.endsAt === MAX_DATE.getTime()
2401
- && settings?.penalty === 0;
2402
- };
2403
- const isGlobalContest = (settings) => {
2404
- return settings?.startsAt === 0
2405
- && settings?.frozenAt === 0
2406
- && settings?.silencedAt === 0
2407
- && settings?.endsAt === 0
2408
- && settings?.penalty === 0;
2409
- };
2410
- const isPastContest = (settings) => {
2411
- return Date.now() > (settings?.endsAt ?? 0);
2412
- };
2413
- const isFutureContest = (settings) => {
2414
- return (settings?.startsAt ?? 0) > Date.now();
2415
- };
2416
-
2417
- const changeYear = (date, year) => {
2418
- const newDate = new Date(date);
2419
- newDate.setFullYear(year);
2420
- return newDate;
2421
- };
2422
- const changeMonth = (date, monthIndex) => {
2423
- const newDate = new Date(date);
2424
- newDate.setMonth(monthIndex);
2425
- return newDate;
2426
- };
2427
- const changeDay = (date, day) => {
2428
- const newDate = new Date(date);
2429
- newDate.setDate(day);
2430
- return newDate;
2431
- };
2432
- const changeHours = (date, hours) => {
2433
- const newDate = new Date(date);
2434
- newDate.setHours(hours);
2435
- return newDate;
2436
- };
2437
- const changeMinutes = (date, minutes) => {
2438
- const newDate = new Date(date);
2439
- newDate.setMinutes(minutes);
2440
- return newDate;
2441
- };
2442
- const changeSeconds = (date, seconds) => {
2443
- const newDate = new Date(date);
2444
- newDate.setSeconds(seconds);
2445
- return newDate;
2446
- };
2447
- const changeMilliseconds = (date, milliseconds) => {
2448
- const newDate = new Date(date);
2449
- newDate.setMilliseconds(milliseconds);
2450
- return newDate;
2451
- };
2452
- const decreaseYear = (date, count = 1) => changeYear(date, date.getFullYear() - count);
2453
- const increaseYear = (date, count = 1) => changeYear(date, date.getFullYear() + count);
2454
- const decreaseMonth = (date) => {
2455
- const newDate = new Date(date);
2456
- newDate.setMonth(newDate.getMonth() - 1);
2457
- return newDate;
2458
- };
2459
- const increaseMonth = (date) => {
2460
- const newDate = new Date(date);
2461
- newDate.setMonth(newDate.getMonth() + 1);
2462
- return newDate;
2463
- };
2464
- const decreaseDay = (date) => {
2465
- const newDate = new Date(date);
2466
- newDate.setDate(newDate.getDate() - 1);
2467
- return newDate;
2468
- };
2469
- const increaseDay = (date) => {
2470
- const newDate = new Date(date);
2471
- newDate.setDate(newDate.getDate() + 1);
2472
- return newDate;
2473
- };
2474
- const startOfDay = (date) => {
2475
- const newDate = new Date(date);
2476
- newDate.setHours(0, 0, 0, 0);
2477
- return newDate;
2478
- };
2479
- const endOfDay = (date) => {
2480
- const newDate = new Date(date);
2481
- newDate.setHours(23, 59, 59, 999);
2482
- return newDate;
2483
- };
2484
- const startOfMonth = (date) => {
2485
- const newDate = new Date(date);
2486
- newDate.setDate(1);
2487
- return startOfDay(newDate);
2488
- };
2489
- const endOfMonth = (date) => {
2490
- const nextMonth = startOfMonth(increaseMonth(date));
2491
- return new Date(nextMonth.getTime() - 1);
2492
- };
2493
- const startOfYear = (date) => {
2494
- const newDate = new Date(date);
2495
- newDate.setMonth(0);
2496
- return startOfMonth(newDate);
2497
- };
2498
- const endOfYear = (date) => {
2499
- const nextYear = startOfYear(increaseYear(date));
2500
- return new Date(nextYear.getTime() - 1);
2501
- };
2502
- const startOfWeek = (date) => {
2503
- const newDate = new Date(date);
2504
- while (newDate.getDay()) {
2505
- newDate.setDate(newDate.getDate() - 1);
2506
- }
2507
- return startOfDay(newDate);
2508
- };
2509
- const endOfWeek = (date) => {
2510
- const newDate = new Date(date);
2511
- while (newDate.getDay() < 6) {
2512
- newDate.setDate(newDate.getDate() + 1);
2513
- }
2514
- return endOfDay(newDate);
2515
- };
2516
- const startOfHour = (date) => {
2517
- const newDate = new Date(date);
2518
- newDate.setMinutes(0, 0, 0);
2519
- return newDate;
2520
- };
2521
- const endOfHour = (date) => {
2522
- const newDate = new Date(date);
2523
- newDate.setMinutes(59, 59, 999);
2524
- return newDate;
2525
- };
2526
- const startOfMinute = (date) => {
2527
- const newDate = new Date(date);
2528
- newDate.setSeconds(0, 0);
2529
- return newDate;
2530
- };
2531
- const endOfMinute = (date) => {
2532
- const newDate = new Date(date);
2533
- newDate.setSeconds(59, 999);
2534
- return newDate;
2535
- };
2536
- const startOfSecond = (date) => {
2537
- const newDate = new Date(date);
2538
- newDate.setMilliseconds(0);
2539
- return newDate;
2540
- };
2541
- const endOfSecond = (date) => {
2542
- const newDate = new Date(date);
2543
- newDate.setMilliseconds(999);
2544
- return newDate;
2545
- };
2546
- const isEqual = (a, b) => a.getTime() === b.getTime();
2547
- const isSameYear = (a, b) => a.getFullYear() === b.getFullYear();
2548
- const isSameMonth = (a, b) => isSameYear(a, b) && a.getMonth() === b.getMonth();
2549
- const isSameDay = (a, b) => isSameMonth(a, b) && a.getDate() === b.getDate();
2550
- const isSameHour = (a, b) => isSameDay(a, b) && a.getHours() === b.getHours();
2551
- const isSameMinute = (a, b) => isSameHour(a, b) && a.getMinutes() === b.getMinutes();
2552
- const isSameSecond = (a, b) => isSameMinute(a, b) && a.getSeconds() === b.getSeconds();
2553
- const isSameMillisecond = (a, b) => isEqual(a, b);
2554
- const isToday = (date) => isSameDay(date, new Date());
2555
- const isValidDate = (date) => date instanceof Date && !Number.isNaN(date.getTime());
2556
- const isAfter = (a, b) => a.getTime() > b.getTime();
2557
- const isBefore = (a, b) => a.getTime() < b.getTime();
2558
- const isYearAfter = (a, b) => a.getFullYear() > b.getFullYear();
2559
- const isMonthAfter = (a, b) => isYearAfter(a, b) || (isSameYear(a, b) && a.getMonth() > b.getMonth());
2560
- const isDayAfter = (a, b) => isMonthAfter(a, b) || (isSameMonth(a, b) && a.getDate() > b.getDate());
2561
- const isHoursAfter = (a, b) => isDayAfter(a, b) || (isSameDay(a, b) && a.getHours() > b.getHours());
2562
- const isMinutesAfter = (a, b) => isHoursAfter(a, b) || (isSameHour(a, b) && a.getMinutes() > b.getMinutes());
2563
- const isSecondsAfter = (a, b) => isMinutesAfter(a, b) || (isSameMinute(a, b) && a.getSeconds() > b.getSeconds());
2564
- const isMillisecondsAfter = (a, b) => isSecondsAfter(a, b) || (isSameSecond(a, b) && a.getMilliseconds() > b.getMilliseconds());
2565
- const isYearBefore = (a, b) => a.getFullYear() < b.getFullYear();
2566
- const isMonthBefore = (a, b) => isYearBefore(a, b) || (isSameYear(a, b) && a.getMonth() < b.getMonth());
2567
- const isDayBefore = (a, b) => isMonthBefore(a, b) || (isSameMonth(a, b) && a.getDate() < b.getDate());
2568
- const isHoursBefore = (a, b) => isDayBefore(a, b) || (isSameDay(a, b) && a.getHours() < b.getHours());
2569
- const isMinutesBefore = (a, b) => isHoursBefore(a, b) || (isSameHour(a, b) && a.getMinutes() < b.getMinutes());
2570
- const isSecondsBefore = (a, b) => isMinutesBefore(a, b) || (isSameMinute(a, b) && a.getSeconds() < b.getSeconds());
2571
- const isMillisecondsBefore = (a, b) => isSecondsBefore(a, b) || (isSameSecond(a, b) && a.getMilliseconds() < b.getMilliseconds());
2572
- const isWithinInterval = (date, { start, end }, cmp = '[]') => (cmp.charAt(0) === '[' ? isEqual(date, start) || isAfter(date, start) : isAfter(date, start)) &&
2573
- (cmp.charAt(1) === ']' ? isEqual(date, end) || isBefore(date, end) : isBefore(date, end));
2574
- const normalizeToLocalStartOfDay = (timestamp) => {
2575
- const d = new Date(timestamp);
2576
- return new Date(d.getFullYear(), d.getMonth(), d.getDate());
2577
- };
2578
- const normalizeToLocalStartOfHour = (timestamp) => {
2579
- const d = new Date(timestamp);
2580
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
2581
- };
2582
- const normalizeToLocalStartOfMinutes = (timestamp) => {
2583
- const d = new Date(timestamp);
2584
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes());
2585
- };
2586
- const normalizeToLocalStartOfSeconds = (timestamp) => {
2587
- const d = new Date(timestamp);
2588
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
2589
- };
2590
- const getYears = (d) => d.getFullYear();
2591
- const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
2592
- const getDays = (d) => Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
2593
- const getHours = (d) => Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
2594
- const getMinutes = (d) => Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
2595
- const getSeconds = (d) => Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
2596
- const getMilliseconds = (d) => d.getTime();
2597
-
2598
- const getDocumentAccess = (document) => {
2599
- switch (true) {
2600
- case (document?.members?.rankAdministrators === EntityMembersRank.NONE || document?.members?.rankAdministrators === EntityMembersRank.CLOSE)
2601
- && document?.members?.rankManagers === EntityMembersRank.OPEN
2602
- && (document?.members?.rankGuests === EntityMembersRank.NONE || document?.members?.rankGuests === EntityMembersRank.CLOSE || document?.members?.rankGuests === EntityMembersRank.OPEN)
2603
- && document?.members?.rankSpectators === EntityMembersRank.OPEN
2604
- && (document?.members?.rankParticipants === EntityMembersRank.NONE || document?.members?.rankParticipants === EntityMembersRank.CLOSE || document?.members?.rankParticipants === EntityMembersRank.OPEN):
2605
- return EntityAccess.EXPOSED;
2606
- case (document?.members?.rankAdministrators === EntityMembersRank.NONE || document?.members?.rankAdministrators === EntityMembersRank.CLOSE)
2607
- && document?.members?.rankManagers === EntityMembersRank.CLOSE
2608
- && (document?.members?.rankGuests === EntityMembersRank.NONE || document?.members?.rankGuests === EntityMembersRank.CLOSE || document?.members?.rankGuests === EntityMembersRank.OPEN)
2609
- && document?.members?.rankSpectators === EntityMembersRank.OPEN
2610
- && (document?.members?.rankParticipants === EntityMembersRank.NONE || document?.members?.rankParticipants === EntityMembersRank.CLOSE || document?.members?.rankParticipants === EntityMembersRank.OPEN):
2611
- return EntityAccess.PUBLIC;
2612
- case (document?.members?.rankAdministrators === EntityMembersRank.NONE || document?.members?.rankAdministrators === EntityMembersRank.CLOSE)
2613
- && document?.members?.rankManagers === EntityMembersRank.CLOSE
2614
- && (document?.members?.rankGuests === EntityMembersRank.NONE || document?.members?.rankGuests === EntityMembersRank.CLOSE || document?.members?.rankGuests === EntityMembersRank.OPEN)
2615
- && document?.members?.rankSpectators === EntityMembersRank.CLOSE
2616
- && (document?.members?.rankParticipants === EntityMembersRank.NONE || document?.members?.rankParticipants === EntityMembersRank.CLOSE || document?.members?.rankParticipants === EntityMembersRank.OPEN):
2617
- return EntityAccess.RESTRICTED;
2618
- case document?.members?.rankAdministrators === EntityMembersRank.NONE
2619
- && document?.members?.rankManagers === EntityMembersRank.NONE
2620
- && document?.members?.rankGuests === EntityMembersRank.NONE
2621
- && document?.members?.rankSpectators === EntityMembersRank.NONE
2622
- && document?.members?.rankParticipants === EntityMembersRank.NONE:
2623
- return EntityAccess.PRIVATE;
2624
- default:
2625
- return EntityAccess.PRIVATE;
2626
- }
2627
- };
2628
- const isUserMember = (member) => {
2629
- return typeof member.userId === 'string';
2630
- };
2631
- const isTeamMember = (member) => {
2632
- return typeof member.teamId === 'string';
2633
- };
2634
- const toEntityMembersDto = (members) => {
2635
- return {
2636
- rankAdministrators: members.rankAdministrators,
2637
- administrators: Object.keys(members.administrators),
2638
- rankManagers: members.rankManagers,
2639
- managers: Object.keys(members.managers),
2640
- rankParticipants: members.rankParticipants,
2641
- participants: Object.keys(members.participants),
2642
- rankGuests: members.rankGuests,
2643
- guests: Object.keys(members.guests),
2644
- rankSpectators: members.rankSpectators,
2645
- spectators: Object.keys(members.spectators),
2646
- };
2647
- };
2648
-
2649
- class JkError extends Error {
2650
- constructor(code, custom) {
2651
- const message = custom?.message || ERROR[code].message;
2652
- super(message);
2653
- this.message = message;
2654
- this.code = code;
2655
- if (custom?.stack) {
2656
- this.stack = custom.stack;
2657
- }
2658
- if (custom?.data) {
2659
- this.data = custom.data;
2660
- }
2661
- }
2662
- }
2663
-
2664
- function removeExtension(fileName) {
2665
- const i = fileName.lastIndexOf('.');
2666
- return i !== -1 ? fileName.substring(0, i) : fileName;
2667
- }
2668
-
2669
- // https://dev.to/jsmccrumb/asynchronous-setinterval-4j69
2670
- const asyncIntervals = [];
2671
- const runAsyncInterval = async (cb, interval, intervalIndex) => {
2672
- await cb();
2673
- if (asyncIntervals[intervalIndex]) {
2674
- setTimeout(() => runAsyncInterval(cb, interval, intervalIndex), interval);
2675
- }
2676
- };
2677
- const setAsyncInterval = (cb, interval) => {
2678
- if (cb && typeof cb === 'function') {
2679
- const intervalIndex = asyncIntervals.length;
2680
- asyncIntervals.push(true);
2681
- void runAsyncInterval(cb, interval, intervalIndex);
2682
- return intervalIndex;
2683
- }
2684
- else {
2685
- throw new Error('Callback must be a function');
2686
- }
2687
- };
2688
- const clearAsyncInterval = (intervalIndex) => {
2689
- if (asyncIntervals[intervalIndex]) {
2690
- asyncIntervals[intervalIndex] = false;
2691
- }
2692
- };
2693
-
2694
- const getDataOfTestCase = (testCase, timeLimit, memoryLimit) => {
2695
- const { timeUsed, memoryUsed, exitCode } = getDataLog(testCase?.log);
2696
- const timeLimitExceeded = timeUsed > timeLimit;
2697
- const memoryLimitExceeded = memoryUsed > memoryLimit;
2698
- const runtimeError = exitCode !== 0;
2699
- const compilationError = testCase?.status === SubmissionRunStatus.COMPILATION_ERROR;
2700
- return {
2701
- compilationError,
2702
- timeUsed,
2703
- timeLimitExceeded: timeLimitExceeded,
2704
- memoryUsed,
2705
- memoryLimitExceeded: memoryLimitExceeded,
2706
- exitCode,
2707
- runtimeError,
2708
- failed: !!testCase?.log && (timeLimitExceeded || memoryLimitExceeded || runtimeError),
2709
- };
2710
- };
2711
- const getVerdictFromTestCase = (testCaseValue, timeLimit, memoryLimit) => {
2712
- const { compilationError, timeLimitExceeded, memoryLimitExceeded, runtimeError, timeUsed, memoryUsed, exitCode, } = getDataOfTestCase(testCaseValue, timeLimit, memoryLimit);
2713
- return {
2714
- verdict: compilationError
2715
- ? ProblemVerdict.CE
2716
- : timeLimitExceeded
2717
- ? ProblemVerdict.TLE
2718
- : memoryLimitExceeded
2719
- ? ProblemVerdict.MLE
2720
- : runtimeError
2721
- ? ProblemVerdict.RE
2722
- : testCaseValue.out === testCaseValue.testOut
2723
- ? ProblemVerdict.AC
2724
- : testCaseValue.withPE && testCaseValue.out.split(' ').join('').split('\n').join('') === testCaseValue.testOut.split(' ').join('').split('\n').join('')
2725
- ? ProblemVerdict.PE
2726
- : !testCaseValue.withPE && testCaseValue.out.split(' ').join('').split('\n').join('') === testCaseValue.testOut.split(' ').join('').split('\n').join('')
2727
- ? ProblemVerdict.AC
2728
- : ProblemVerdict.WA,
2729
- timeUsed,
2730
- memoryUsed,
2731
- exitCode,
2732
- };
2733
- };
2734
- const mergeVerdicts = (first, second) => {
2735
- let verdict = first.verdict;
2736
- if (second.verdict === ProblemVerdict.RE) {
2737
- verdict = ProblemVerdict.RE;
2738
- }
2739
- else if (second.verdict === ProblemVerdict.TLE && verdict != ProblemVerdict.RE) {
2740
- verdict = ProblemVerdict.TLE;
2741
- }
2742
- else if (second.verdict === ProblemVerdict.MLE
2743
- && verdict !== ProblemVerdict.TLE
2744
- && verdict !== ProblemVerdict.RE) {
2745
- verdict = ProblemVerdict.MLE;
2746
- }
2747
- else if (second.verdict === ProblemVerdict.WA
2748
- && verdict !== ProblemVerdict.MLE
2749
- && verdict !== ProblemVerdict.TLE
2750
- && verdict !== ProblemVerdict.RE) {
2751
- verdict = ProblemVerdict.WA;
2752
- }
2753
- else if (second.verdict === ProblemVerdict.PE
2754
- && verdict !== ProblemVerdict.WA
2755
- && verdict !== ProblemVerdict.MLE
2756
- && verdict !== ProblemVerdict.TLE
2757
- && verdict !== ProblemVerdict.RE) {
2758
- verdict = ProblemVerdict.PE;
2759
- }
2760
- else if (second.verdict === ProblemVerdict.PA
2761
- && verdict !== ProblemVerdict.PE
2762
- && verdict !== ProblemVerdict.WA
2763
- && verdict !== ProblemVerdict.MLE
2764
- && verdict !== ProblemVerdict.TLE
2765
- && verdict !== ProblemVerdict.RE) {
2766
- verdict = ProblemVerdict.PA;
2767
- }
2768
- else if (second.verdict === ProblemVerdict.AC
2769
- && verdict !== ProblemVerdict.PA
2770
- && verdict !== ProblemVerdict.PE
2771
- && verdict !== ProblemVerdict.WA
2772
- && verdict !== ProblemVerdict.MLE
2773
- && verdict !== ProblemVerdict.TLE
2774
- && verdict !== ProblemVerdict.RE) {
2775
- verdict = ProblemVerdict.AC;
2776
- }
2777
- return {
2778
- timeUsed: Math.max(first.timeUsed, second.timeUsed),
2779
- memoryUsed: Math.max(first.memoryUsed, second.memoryUsed),
2780
- exitCode: first.exitCode || second.exitCode,
2781
- verdict,
2782
- };
2783
- };
2784
- const getDataLog = (log) => {
2785
- const lines = log?.split?.('\n') || [];
2786
- let timeUsed = 0;
2787
- let memoryUsed = 0;
2788
- let exitCode = -1;
2789
- if (lines.length > 4) {
2790
- for (const line of lines) {
2791
- if (line.startsWith('time:')) {
2792
- timeUsed = +line.split(':')[1];
2793
- if (Number.isNaN(timeUsed)) {
2794
- timeUsed = 0;
2795
- }
2796
- timeUsed *= 1000;
2797
- }
2798
- else if (line.startsWith('max-rss:')) {
2799
- memoryUsed = parseInt(line.split(':')[1], 10); // en KB
2800
- }
2801
- else if (line.startsWith('exitcode:')) {
2802
- exitCode = parseInt(line.split(':')[1], 10);
2803
- }
2804
- }
2805
- }
2806
- else if (lines.length >= 3) {
2807
- timeUsed = +lines[0];
2808
- memoryUsed = +lines[1];
2809
- exitCode = +lines[2];
2810
- }
2811
- return {
2812
- timeUsed: Number.isNaN(timeUsed) ? 0 : timeUsed,
2813
- memoryUsed: Number.isNaN(memoryUsed) ? 0 : memoryUsed,
2814
- exitCode: Number.isNaN(exitCode) ? -1 : exitCode,
2815
- };
2816
- };
2817
-
2818
- const padStart = (n, maxLength, fillString = '0') => `${n}`.padStart(maxLength, fillString);
2819
- const padEnd = (n, maxLength, fillString = '0') => `${n}`.padEnd(maxLength, fillString);
2820
-
2821
- function memorySizeOf(obj) {
2822
- let bytes = 0;
2823
- function sizeOf(obj) {
2824
- if (obj !== null && obj !== undefined) {
2825
- switch (typeof obj) {
2826
- case "number":
2827
- bytes += 8;
2828
- break;
2829
- case "string":
2830
- bytes += obj.length * 2;
2831
- break;
2832
- case "boolean":
2833
- bytes += 4;
2834
- break;
2835
- case "object":
2836
- const objClass = Object.prototype.toString.call(obj).slice(8, -1);
2837
- if (objClass === "Object" || objClass === "Array") {
2838
- for (const key in obj) {
2839
- if (!obj.hasOwnProperty(key))
2840
- continue;
2841
- bytes += key.length * 2;
2842
- sizeOf(obj[key]);
2843
- }
2844
- }
2845
- else
2846
- bytes += obj.toString().length * 2;
2847
- break;
2848
- }
2849
- }
2850
- return bytes;
2851
- }
2852
- return sizeOf(obj);
2853
- }
2854
-
2855
- function toJkError(err) {
2856
- const error = new Error();
2857
- let code = err?.code;
2858
- if (!(code in ErrorCode)) {
2859
- code = ErrorCode.ERR500;
2860
- }
2861
- return new JkError(code, {
2862
- message: err?.message || error.message,
2863
- stack: err?.stack || error.stack,
2864
- data: err?.data || null,
2865
- });
2866
- }
2867
- function errorsResponse(message, ...errors) {
2868
- return {
2869
- success: false,
2870
- message: message,
2871
- errors: errors.map(error => ({
2872
- code: error.code,
2873
- message: error.message,
2874
- detail: error.stack || new Error().stack || '',
2875
- data: error.data,
2876
- })),
2877
- };
2878
- }
2879
- function contentResponse(message, content) {
2880
- return {
2881
- success: true,
2882
- message,
2883
- content,
2884
- };
2885
- }
2886
- function contentsResponse(message, contents, meta) {
2887
- return {
2888
- success: true,
2889
- message,
2890
- contents,
2891
- meta,
2892
- };
2893
- }
2894
- const cleanRequest = (responseText) => {
2895
- if (!isStringJson(responseText)) {
2896
- // this occurs when the endpoint don't exits or server is down
2897
- const response = {
2898
- success: false,
2899
- message: ERROR[ErrorCode.ERR9999].message,
2900
- errors: [{ code: ErrorCode.ERR9999, detail: '', message: ERROR[ErrorCode.ERR9999].message }],
2901
- };
2902
- consoleError({ message: 'response is not string json, success false on cleaning request', responseText, response });
2903
- // jukiApiManager.reportError({ message: 'success false on cleaning request', responseText, response });
2904
- return response;
2905
- }
2906
- const responseJson = JSON.parse(responseText);
2907
- if (typeof responseJson.success === 'boolean') {
2908
- if (responseJson.success === true && typeof responseJson.message === 'string' && responseJson.content) { // V1
2909
- return {
2910
- success: true,
2911
- message: responseJson.message,
2912
- content: responseJson.content,
2913
- };
2914
- }
2915
- else if (responseJson.success === true && typeof responseJson.message === 'string' && Array.isArray(responseJson.contents) && responseJson.meta) { // V1
2916
- return {
2917
- success: true,
2918
- message: responseJson.message,
2919
- contents: responseJson.contents,
2920
- meta: responseJson.meta,
2921
- };
2922
- }
2923
- else if (responseJson.success === false && typeof responseJson.message === 'string' && Array.isArray(responseJson.errors)) { // V1
2924
- const response = {
2925
- success: false,
2926
- message: responseJson.message,
2927
- errors: responseJson.errors,
2928
- };
2929
- consoleError({ message: 'success false on cleaning request', responseText, response });
2930
- // jukiApiManager.reportError({ message: 'success false on cleaning request', responseText, response });
2931
- return response;
2932
- }
2933
- }
2934
- const response = {
2935
- success: false,
2936
- message: ERROR[ErrorCode.ERR9998].message,
2937
- errors: [{ code: ErrorCode.ERR9998, detail: '', message: ERROR[ErrorCode.ERR9998].message }],
2938
- };
2939
- consoleError({ message: 'success false on cleaning request', responseText, response });
2940
- // jukiApiManager.reportError({ message: 'success false on cleaning request', responseText, response });
2941
- return response;
2942
- };
2943
- const getDefaultMeta = (contents, sort) => {
2944
- return { sort: sort ?? [], page: 1, size: contents.length, totalElements: contents.length, filter: {} };
2945
- };
2946
-
2947
- const isWebsocketSubscription = (event) => {
2948
- return Object.values(WebSocketSubscriptionEvent).includes(event?.event)
2949
- && typeof event?.clientId === 'string' && !!event.clientId;
2950
- };
2951
- // CHANNEL_PUBLISH_SUBSCRIPTIONS
2952
- const isSubscribeCodeRunStatusWebSocketEventDto = (event) => {
2953
- return isWebsocketSubscription(event)
2954
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_CODE_RUN_STATUS
2955
- && typeof event?.runId === 'string' && !!event.runId;
2956
- };
2957
- const isUnsubscribeCodeRunStatusWebSocketEventDto = (event) => {
2958
- return isWebsocketSubscription(event)
2959
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_CODE_RUN_STATUS
2960
- && typeof event?.runId === 'string' && !!event.runId;
2961
- };
2962
- const isSubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
2963
- return isWebsocketSubscription(event)
2964
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSION_RUN_STATUS
2965
- && typeof event?.submitId === 'string' && !!event.submitId;
2966
- };
2967
- const isUnsubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
2968
- return isWebsocketSubscription(event)
2969
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSION_RUN_STATUS
2970
- && typeof event?.submitId === 'string' && !!event.submitId;
2971
- };
2972
- const isSubscribeGetDataWebSocketEventDto = (event) => {
2973
- return isWebsocketSubscription(event)
2974
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_GET_DATA;
2975
- };
2976
- const isUnsubscribeGetDataWebSocketEventDto = (event) => {
2977
- return isWebsocketSubscription(event)
2978
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_GET_DATA;
2979
- };
2980
- const isSubscribeProblemCrawledWebSocketEventDto = (event) => {
2981
- return isWebsocketSubscription(event)
2982
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_PROBLEM_CRAWLED;
2983
- };
2984
- const isUnsubscribeProblemCrawledWebSocketEventDto = (event) => {
2985
- return isWebsocketSubscription(event)
2986
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_PROBLEM_CRAWLED;
2987
- };
2988
- const isSubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
2989
- return isWebsocketSubscription(event)
2990
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSIONS_CRAWL;
2991
- };
2992
- const isUnsubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
2993
- return isWebsocketSubscription(event)
2994
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSIONS_CRAWL;
2995
- };
2996
- const isSubscribeContestChangesWebSocketEventDto = (event) => {
2997
- return isWebsocketSubscription(event)
2998
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_CONTEST_CHANGES;
2999
- };
3000
- const isUnsubscribeContestChangesWebSocketEventDto = (event) => {
3001
- return isWebsocketSubscription(event)
3002
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_CONTEST_CHANGES;
3003
- };
3004
- const isSubscribeUserNotificationWebSocketEventDto = (event) => {
3005
- return isWebsocketSubscription(event)
3006
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_USER_NOTIFICATION;
3007
- };
3008
- const isUnsubscribeUserNotificationWebSocketEventDto = (event) => {
3009
- return isWebsocketSubscription(event)
3010
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_USER_NOTIFICATION;
3011
- };
3012
- const isNonEmptyString = (value) => typeof value === 'string' && !!value;
3013
- /**
3014
- * Exactly one of `problemKey` / `contestKey` / `userId` is set.
3015
- */
3016
- const isSubmissionsJudgingScope = (scope) => {
3017
- return [scope?.problemKey, scope?.contestKey, scope?.userId].filter(isNonEmptyString).length === 1;
3018
- };
3019
- const isSubscribeSubmissionsJudgingWebSocketEventDto = (event) => {
3020
- return isWebsocketSubscription(event)
3021
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSIONS_JUDGING
3022
- && isSubmissionsJudgingScope(event);
3023
- };
3024
- const isUnsubscribeSubmissionsJudgingWebSocketEventDto = (event) => {
3025
- return isWebsocketSubscription(event)
3026
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSIONS_JUDGING
3027
- && isSubmissionsJudgingScope(event);
3028
- };
3029
- // is WebSocketResponseEventDto, CHANNEL_SUBSCRIBE_CLIENT
3030
- const isWebSocketResponseEventDto = (event) => {
3031
- return Object.values(WebSocketResponseEvent).includes(event?.event)
3032
- && typeof event?.key === 'string'
3033
- && typeof event?.connectionId === 'string'
3034
- && typeof event?.createdAt === 'number' && !!event.createdAt;
3035
- };
3036
- const isCodeRunStatusMessageWebSocketResponseEventDto = (event) => {
3037
- return isWebSocketResponseEventDto(event)
3038
- && event?.event === WebSocketResponseEvent.CODE_RUN_STATUS
3039
- && typeof event?.runId === 'string' && !!event.runId
3040
- && event?.status in SubmissionRunStatus;
3041
- };
3042
- const isSubmissionRunStatusMessageWebSocketResponseEventDto = (event) => {
3043
- return isWebSocketResponseEventDto(event)
3044
- && event?.event === WebSocketResponseEvent.SUBMISSION_RUN_STATUS
3045
- && typeof event?.submitId === 'string' && !!event.submitId
3046
- && event?.status in SubmissionRunStatus
3047
- && event?.verdict in ProblemVerdict
3048
- && typeof event?.points === 'number';
3049
- };
3050
- const isSubmissionJudgingWebSocketResponseEventDto = (event) => {
3051
- return isWebSocketResponseEventDto(event)
3052
- && event?.event === WebSocketResponseEvent.SUBMISSION_JUDGING
3053
- && isNonEmptyString(event?.submitId)
3054
- && isNonEmptyString(event?.problemKey)
3055
- && (event?.contestKey === null || isNonEmptyString(event?.contestKey))
3056
- && isNonEmptyString(event?.userId)
3057
- && typeof event?.judging === 'boolean'
3058
- && event?.status in SubmissionRunStatus
3059
- && event?.verdict in ProblemVerdict
3060
- && typeof event?.points === 'number';
3061
- };
3062
- const isUserMessageWebSocketResponseEventDto = (event) => {
3063
- return isWebSocketResponseEventDto(event)
3064
- && event?.event === WebSocketResponseEvent.USER_MESSAGE
3065
- && typeof event?.user?.nickname === 'string' && !!event.user?.nickname
3066
- && typeof event?.user?.imageUrl === 'string' && !!event.user?.imageUrl
3067
- && typeof event?.user?.organization?.key === 'string' && !!event.user?.organization?.key
3068
- && !!event?.content;
3069
- };
3070
- const isSendDataWebSocketResponseEventDto = (event) => {
3071
- return [
3072
- WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST,
3073
- WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST,
3074
- WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST,
3075
- WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST,
3076
- WebSocketResponseEvent.SEND_DATA_RUN_COMMAND,
3077
- ].includes(event?.event)
3078
- && typeof event?.dataId === 'string' && !!event.dataId
3079
- && !!event?.content;
3080
- };
3081
- const isSendDataEcsTaskDefinitionListWebSocketResponseEventDto = (event) => {
3082
- return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3083
- && event?.event === WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST;
3084
- };
3085
- const isSendDataEc2InstancesListWebSocketResponseEventDto = (event) => {
3086
- return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3087
- && event?.event === WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST;
3088
- };
3089
- const isSendDataEcsTasksListWebSocketResponseEventDto = (event) => {
3090
- return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3091
- && event?.event === WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST;
3092
- };
3093
- const isSendDataSsmSessionsListWebSocketResponseEventDto = (event) => {
3094
- return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3095
- && event?.event === WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST;
3096
- };
3097
- const isSendDataRunCommandWebSocketResponseEventDto = (event) => {
3098
- return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3099
- && event?.event === WebSocketResponseEvent.SEND_DATA_RUN_COMMAND;
3100
- };
3101
- const isProblemCrawledWebSocketResponseEventDto = (event) => {
3102
- return isWebSocketResponseEventDto(event)
3103
- && event?.event === WebSocketResponseEvent.PROBLEM_CRAWLED
3104
- && !!event?.content;
3105
- };
3106
- const isSubmissionsCrawlWebSocketResponseEventDto = (event) => {
3107
- return isWebSocketResponseEventDto(event)
3108
- && event?.event === WebSocketResponseEvent.SUBMISSIONS_CRAWL
3109
- && !!event?.content;
3110
- };
3111
- const isContestChangesWebSocketResponseEventDto = (event) => {
3112
- return isWebSocketResponseEventDto(event)
3113
- && event?.event === WebSocketResponseEvent.CONTEST_CHANGES
3114
- && !!event?.content;
3115
- };
3116
- const isUserNotificationWebSocketResponseEventDto = (event) => {
3117
- return [
3118
- WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION,
3119
- WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION,
3120
- ].includes(event?.event)
3121
- && !!event?.content;
3122
- };
3123
- const isUserNotificationSubmissionWebSocketResponseEventDto = (event) => {
3124
- return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3125
- && event?.event === WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION;
3126
- };
3127
- const isUserNotificationContestClarificationWebSocketResponseEventDto = (event) => {
3128
- return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3129
- && event?.event === WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION;
3130
- };
3131
- // generic
3132
- const getWebSocketResponseEventKey = (event, clientId, id) => {
3133
- return `${event}-${clientId}-${id}`;
3134
- };
3135
- const isWebSocketChannelsMessageDto = (message) => {
3136
- return Array.isArray(message?.channels)
3137
- && message.channels.every((channel) => typeof channel === 'string' && !!channel)
3138
- && Object.values(WebSocketResponseEvent).includes(message?.event?.event);
3139
- };
3140
- /**
3141
- * Key used by the client to dispatch a response received on a TOPIC channel to its subscribers.
3142
- * It is the same key that `getKeyWebSocketEventDto` (base-ui) computes for the subscription.
3143
- * Returns null when the response is not addressed to this client.
3144
- */
3145
- const getWebSocketResponseEventKeyOfResponse = (response, clientId) => {
3146
- if (isCodeRunStatusMessageWebSocketResponseEventDto(response)) {
3147
- return getWebSocketResponseEventKey(WebSocketResponseEvent.CODE_RUN_STATUS, clientId, response.runId);
3148
- }
3149
- if (isSubmissionRunStatusMessageWebSocketResponseEventDto(response)) {
3150
- return getWebSocketResponseEventKey(WebSocketResponseEvent.SUBMISSION_RUN_STATUS, clientId, response.submitId);
3151
- }
3152
- if (isSendDataWebSocketResponseEventDto(response)) {
3153
- return getWebSocketResponseEventKey(WebSocketResponseEvent.SEND_DATA_, clientId, response.dataId);
3154
- }
3155
- if (isContestChangesWebSocketResponseEventDto(response)) {
3156
- return getWebSocketResponseEventKey(WebSocketResponseEvent.CONTEST_CHANGES, clientId, response.content.contestKey);
3157
- }
3158
- if (isProblemCrawledWebSocketResponseEventDto(response)) {
3159
- return getWebSocketResponseEventKey(WebSocketResponseEvent.PROBLEM_CRAWLED, clientId, response.content.problemKey);
3160
- }
3161
- if (isSubmissionsCrawlWebSocketResponseEventDto(response)) {
3162
- return getWebSocketResponseEventKey(WebSocketResponseEvent.SUBMISSIONS_CRAWL, clientId, join([response.content.contestKey, response.content.problemKeys]));
3163
- }
3164
- if (isUserNotificationWebSocketResponseEventDto(response)) {
3165
- return getWebSocketResponseEventKey(WebSocketResponseEvent.USER_NOTIFICATION_, clientId, '*');
3166
- }
3167
- if (isSubmissionJudgingWebSocketResponseEventDto(response)) {
3168
- // one key for every table: the same event is published on several channels (problem / contest / user) and the
3169
- // client deduplicates it, so it is dispatched once; each table filters by the submissions it lists
3170
- return getWebSocketResponseEventKey(WebSocketResponseEvent.SUBMISSION_JUDGING, clientId, '*');
3171
- }
3172
- return null;
3173
- };
3174
- /**
3175
- * TOPIC channel that the client has to attach to receive the events of a subscription,
3176
- * or null when the events arrive by the private channels (session / user) the client is always attached to.
3177
- * Ably rejects the attach if the token has no capability for the channel.
3178
- */
3179
- const getChannelOfWebSocketSubscribeEvent = (event) => {
3180
- if (isSubscribeSubmissionRunStatusWebSocketEventDto(event)) {
3181
- return CHANNEL_SUBMISSION(event.submitId);
3182
- }
3183
- // SUBSCRIBE_PROBLEM_CRAWLED: the event arrives by the private user channel of who requested the crawl
3184
- if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3185
- return CHANNEL_CONTEST(event.contestKey, ContestChannelRole.SPECTATORS);
3186
- }
3187
- if (isSubscribeSubmissionsJudgingWebSocketEventDto(event)) {
3188
- // the judging start/end is published on the spectators channel when it is visible to everyone; the hidden ones
3189
- // (frozen / quiet contests) arrive by the role channels of the contest (managers) and the private user channel
3190
- if ('problemKey' in event && event.problemKey) {
3191
- return CHANNEL_PROBLEM(event.problemKey, ProblemChannelRole.SPECTATORS);
3192
- }
3193
- if ('contestKey' in event && event.contestKey) {
3194
- return CHANNEL_CONTEST(event.contestKey, ContestChannelRole.SPECTATORS);
3195
- }
3196
- if ('userId' in event && event.userId) {
3197
- return CHANNEL_USER_ROLE(event.userId, UserChannelRole.SPECTATORS);
3198
- }
3199
- }
3200
- return null;
3201
- };
3202
- /**
3203
- * Contest whose role channels the client needs (the API grants them when the token is requested with this contest).
3204
- */
3205
- const getContestKeyOfWebSocketSubscribeEvent = (event) => {
3206
- if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3207
- return event.contestKey;
3208
- }
3209
- if (isSubscribeSubmissionsJudgingWebSocketEventDto(event) && 'contestKey' in event && event.contestKey) {
3210
- return event.contestKey;
3211
- }
3212
- return null;
3213
- };
3214
- /**
3215
- * Problem whose role channels the client needs (the API grants them when the token is requested with this problem).
3216
- */
3217
- const getProblemKeyOfWebSocketSubscribeEvent = (event) => {
3218
- if (isSubscribeSubmissionsJudgingWebSocketEventDto(event) && 'problemKey' in event && event.problemKey) {
3219
- return event.problemKey;
3220
- }
3221
- return null;
3222
- };
3223
-
3224
- function splitTime(timeRemaining) {
3225
- const remaining = [];
3226
- // const aYearMilliseconds = 1000 * 60 * 60 * 24 * 365;
3227
- // const remainingYears = Math.floor(timeRemaining / aYearMilliseconds);
3228
- // remaining.push({ remaining: remainingYears, label: 'years', milliseconds: aYearMilliseconds });
3229
- // const aWeekMilliseconds = 1000 * 60 * 60 * 24 * 7;
3230
- // const remainingWeeks = Math.floor((timeRemaining % aYearMilliseconds) / aWeekMilliseconds);
3231
- // remaining.push({ remaining: remainingWeeks, label: 'weeks', milliseconds: aWeekMilliseconds });
3232
- const aSecondMilliseconds = 1000;
3233
- const aMinuteMilliseconds = aSecondMilliseconds * 60;
3234
- const aHourMilliseconds = aMinuteMilliseconds * 60;
3235
- const aDayMilliseconds = aHourMilliseconds * 24;
3236
- const aWeekMilliseconds = aDayMilliseconds * 7;
3237
- const remainingWeeks = Math.floor(timeRemaining / aWeekMilliseconds);
3238
- remaining.push({
3239
- remaining: remainingWeeks,
3240
- label: remainingWeeks === 1 ? 'week' : 'weeks',
3241
- abbreviatedLabel: 'w',
3242
- milliseconds: aWeekMilliseconds,
3243
- digits: 2,
3244
- });
3245
- const remainingDays = Math.floor((timeRemaining % aWeekMilliseconds) / aDayMilliseconds);
3246
- remaining.push({
3247
- remaining: remainingDays,
3248
- label: remainingDays === 1 ? 'day' : 'days',
3249
- abbreviatedLabel: 'd',
3250
- milliseconds: aDayMilliseconds,
3251
- digits: 2,
3252
- });
3253
- const remainingHours = Math.floor((timeRemaining % aDayMilliseconds) / aHourMilliseconds);
3254
- remaining.push({
3255
- remaining: remainingHours,
3256
- label: remainingHours === 1 ? 'hour' : 'hours',
3257
- abbreviatedLabel: 'h',
3258
- milliseconds: aHourMilliseconds,
3259
- digits: 2,
3260
- });
3261
- const remainingMinutes = Math.floor((timeRemaining % aHourMilliseconds) / aMinuteMilliseconds);
3262
- remaining.push({
3263
- remaining: remainingMinutes,
3264
- label: remainingMinutes === 1 ? 'minute' : 'minutes',
3265
- abbreviatedLabel: 'm',
3266
- milliseconds: aMinuteMilliseconds,
3267
- digits: 2,
3268
- });
3269
- const remainingSeconds = Math.floor((timeRemaining % aMinuteMilliseconds) / aSecondMilliseconds);
3270
- remaining.push({
3271
- remaining: remainingSeconds,
3272
- label: remainingSeconds === 1 ? 'second' : 'seconds',
3273
- abbreviatedLabel: 's',
3274
- milliseconds: aSecondMilliseconds,
3275
- digits: 2,
3276
- });
3277
- const remainingMilliseconds = Math.floor(timeRemaining % aSecondMilliseconds);
3278
- remaining.push({
3279
- remaining: remainingMilliseconds,
3280
- label: remainingMilliseconds === 1 ? 'millisecond' : 'milliseconds',
3281
- abbreviatedLabel: 'ms',
3282
- milliseconds: 1,
3283
- digits: 3,
3284
- });
3285
- // while (remaining[0].remaining <= 0) {
3286
- // remaining.shift();
3287
- // if (remaining.length === 3) {
3288
- // break;
3289
- // }
3290
- // }
3291
- return remaining;
3292
- }
3293
-
3294
- const getUserKey = (userNickname, userOrganizationKey) => {
3295
- return userNickname + '|' + userOrganizationKey;
3296
- };
3297
- const getParamsOfUserKey = (userKey) => {
3298
- const [userNickname, userOrganizationKey] = userKey.split('|');
3299
- return { userNickname, userOrganizationKey };
3300
- };
3301
- const getClientId = (sessionId, uiId) => {
3302
- return `${sessionId}|${uiId}`;
3303
- };
3304
- const getParamsOfClientId = (clientId) => {
3305
- const [sessionId, uiId] = clientId.split('|');
3306
- return { sessionId, uiId };
3307
- };
3308
-
3309
- const getWorksheetsInPages = (initialSheets) => {
3310
- const sheets = [...initialSheets];
3311
- if (sheets[0]?.type !== WorksheetType.NEW_PAGE) {
3312
- sheets.unshift(NEW_PAGE_SHEET());
3313
- }
3314
- let newPage = sheets[0];
3315
- let content = [];
3316
- const sheetsByPages = [];
3317
- for (let i = 1; i < sheets.length; i++) {
3318
- const sheet = sheets[i];
3319
- if (sheet.type === WorksheetType.NEW_PAGE) {
3320
- sheetsByPages.push({
3321
- header: newPage,
3322
- content: [...content],
3323
- });
3324
- newPage = sheet;
3325
- content = [];
3326
- }
3327
- else {
3328
- content.push(sheet);
3329
- }
3330
- }
3331
- sheetsByPages.push({
3332
- header: newPage,
3333
- content: [...content],
3334
- });
3335
- return sheetsByPages;
3336
- };
3337
- const getSummaryWorksheetsInPages = (initialSheets) => {
3338
- const sheets = [...initialSheets];
3339
- if (sheets[0]?.type !== WorksheetType.NEW_PAGE) {
3340
- sheets.unshift(NEW_PAGE_SHEET());
3341
- }
3342
- let newPage = sheets[0];
3343
- let content = [];
3344
- const sheetsByPages = [];
3345
- for (let i = 1; i < sheets.length; i++) {
3346
- const sheet = sheets[i];
3347
- if (sheet.type === WorksheetType.NEW_PAGE) {
3348
- sheetsByPages.push({
3349
- header: newPage,
3350
- content: content.map(c => ({
3351
- id: c.id,
3352
- type: c.type,
3353
- title: c.title,
3354
- points: c.points,
3355
- })),
3356
- });
3357
- newPage = sheet;
3358
- content = [];
3359
- }
3360
- else {
3361
- content.push(sheet);
3362
- }
3363
- }
3364
- sheetsByPages.push({
3365
- header: newPage,
3366
- content: [...content],
3367
- });
3368
- return sheetsByPages;
3369
- };
3370
- const getTotalExercisesOfSummaryWorksheetsInPages = (content) => content.reduce((sum, { content }) => sum + content.reduce((sum, { type }) => sum + +(type === WorksheetType.QUIZ_OPTIONS || type === WorksheetType.QUIZ_PROBLEM || type === WorksheetType.QUIZ_TEXT), 0), 0);
3371
- const isBasicWorksheet = (value) => {
3372
- return typeof value?.id == 'string' && value.id
3373
- && Object.values(WorksheetType).includes(value?.type)
3374
- && typeof value?.title == 'string'
3375
- && typeof value?.points == 'number';
3376
- };
3377
- const isJkmdSheet = (value) => {
3378
- return isBasicWorksheet(value)
3379
- && value?.type === WorksheetType.JK_MD
3380
- && typeof value?.content == 'string';
3381
- };
3382
- const isCodeEditorSheet = (value) => {
3383
- return isBasicWorksheet(value)
3384
- && value?.type === WorksheetType.CODE_EDITOR
3385
- && typeof value?.sourceCode === 'object' && value?.sourceCode !== null
3386
- && value?.testCases === 'object' && value?.testCases !== null
3387
- && Array.isArray(value?.languages)
3388
- && typeof value?.height == 'number';
3389
- };
3390
- const isQuizProblemSheet = (value) => {
3391
- return isBasicWorksheet(value)
3392
- && value?.type === WorksheetType.QUIZ_PROBLEM
3393
- && Object.values(Judge).includes(value?.problemJudge) || typeof value?.problemJudge === 'string'
3394
- && typeof value?.problemKey == 'string'
3395
- && Array.isArray(value?.languages)
3396
- && typeof value?.height == 'number';
3397
- };
3398
- const isQuizOptionsSheet = (value) => {
3399
- return isBasicWorksheet(value)
3400
- && value?.type === WorksheetType.QUIZ_OPTIONS
3401
- && typeof value?.description == 'string'
3402
- && Array.isArray(value?.options)
3403
- && value?.options.every((option) => typeof option?.label == 'string' && typeof option?.correct == 'boolean' && typeof option?.id == 'string')
3404
- && typeof value?.multiple == 'boolean'
3405
- && (value?.scoringMode === 'TOTAL' || value?.scoringMode === 'PARTIAL');
3406
- };
3407
- const isQuizTextSheet = (value) => {
3408
- return isBasicWorksheet(value)
3409
- && value?.type === WorksheetType.QUIZ_TEXT
3410
- && typeof value?.description == 'string'
3411
- && typeof value?.answer == 'string'
3412
- && ['text', 'number', 'textarea'].includes(value?.inputType);
3413
- };
3414
-
3415
- export { ACCEPTED_PROGRAMMING_LANGUAGES, ASPECT_RATIO, AspectRatio, AssignmentClass, AssignmentState, AssignmentType, CHANNEL_CONTEST, CHANNEL_ORGANIZATION_PRESENCE, CHANNEL_PROBLEM, CHANNEL_SESSION, CHANNEL_SUBMISSION, CHANNEL_SUBMISSION_ALL, CHANNEL_USER, CHANNEL_USER_ROLE, CHANNEL_USER_SPECTATORS_ALL, CODE_LANGUAGE, CONTEST_ROLE, CONTEST_STATUS, COOKIE_JUKI_SESSION_ID, COURSE_ROLE, CodeLanguage, CollectionKey, ContestChannelRole, ContestEventAction, ContestProblemBlockedByType, ContestProblemPrerequisiteType, ContestStatus, ContestTimeStatus, CourseRole, CourseStatus, CourseType, DAY_NAMES, DEFAULT_JUKI_PROFILE_IMAGE, DataViewMode, EMPTY_DOCUMENT_MEMBERS, EMPTY_ENTITY_MEMBERS, EMPTY_USER_PERMISSIONS, ENTITY_ACCESS, ENTITY_STATE, ERROR, EmailSubscription, EmailValidationState, EntityAccess, EntityCollection, EntityMembersRank, EntityState, EntityStatus, ErrorCode, FILE_ROLE, FILE_TYPE, FileMemberRole, FileType, FilesJukiPub, GroupType, HEADER_JUKI_FORWARDED_HOST, HEADER_JUKI_INTERNAL_API_KEY, HEADER_JUKI_METADATA, HEADER_JUKI_SECRET_TOKEN, HEADER_JUKI_VISITOR_SESSION_ID, HOURS, HTTPMethod, JUDGE, JUKI_APP_EMAIL_TEMPLATE, JUKI_APP_ORGANIZATION_KEY, JkError, Judge, LANGUAGE, LOWERCASE_LETTERS, Language, LogLevel, LogOperation, MAX_DATE, MEMBER_ROLE, MILLISECONDS, MINUTES, MIN_DATE, MONTH_NAMES, MemberRole, MemberType, MenuViewMode, NEW_PAGE_SHEET, NUMBERS, NotificationType, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ORGANIZATION_PLAN, OrganizationLogoType, OrganizationPlan, PAGE, PAGE_SIZE, PAGE_SIZES, PALLETE, PROBLEM_INPUT, PROBLEM_MODE, PROBLEM_MODES, PROBLEM_OUTPUT, PROBLEM_ROLE, PROBLEM_TYPE, PROBLEM_TYPES, PROBLEM_VERDICT, PROBLEM_VERDICTS, ProblemChannelRole, ProblemInput, ProblemOutput, ProblemScoringMode, ProblemType, ProblemVerdict, ProfileSetting, QuizScoringMode, RUNNER_ACCEPTED_PROBLEM_MODES, RUNNER_ACCEPTED_PROBLEM_TYPES, RUNNER_ACCEPTED_PROGRAMMING_LANGUAGES, RUNNER_TYPE, Role, RunnerType, SECONDS, SEC_120, SEC_30, SEC_60, SEC_90, SEPARATOR_TOKEN, SUBMISSION_RUN_STATUS, SUPPORT_EMAIL, SYSTEM_ROLE, ScopeData, Status, SubmissionRunStatus, SystemRole, TEAM_ROLE, THEME, TeamRole, TeamStatus, Theme, TypeTestCase, UPPERCASE_LETTERS, USER_ROLE, USER_STATUS, UserChannelRole, UserRole, UserStatus, UserTeamStatus, WebSocketResponseEvent, WebSocketSubscriptionEvent, WorkingIn, WorksheetType, YEARS, _KEY, _SUB_SUB_TAB, _SUB_TAB, _TAB, _TYPE, areArraysDifferent, changeDay, changeHours, changeMilliseconds, changeMinutes, changeMonth, changeSeconds, changeYear, chunkString, cleanRequest, clearAsyncInterval, consoleError, consoleInfo, consoleWarn, contentResponse, contentsResponse, decreaseDay, decreaseMonth, decreaseYear, endOfDay, endOfHour, endOfMinute, endOfMonth, endOfSecond, endOfWeek, endOfYear, errorsResponse, getAssignmentCommentKey, getAssignmentUserCommentKey, getChannelOfWebSocketSubscribeEvent, getClientId, getContestChannelParams, getContestCommentKey, getContestKeyOfWebSocketSubscribeEvent, getDataLog, getDataOfTestCase, getDays, getDefaultMeta, getDocumentAccess, getHours, getMilliseconds, getMinutes, getMonths, getParamsOfClientId, getParamsOfUserKey, getPlainText, getProblemChannelParams, getProblemCommentKey, getProblemJudgeKey, getProblemKeyOfWebSocketSubscribeEvent, getRandomString, getSeconds, getSummaryWorksheetsInPages, getTotalExercisesOfSummaryWorksheetsInPages, getUserKey, getVerdictFromTestCase, getWebSocketResponseEventKey, getWebSocketResponseEventKeyOfResponse, getWorksheetsInPages, getYears, humanFileSize, increaseDay, increaseMonth, increaseYear, indexToLetters, isAfter, isBasicWorksheet, isBefore, isCodeEditorSheet, isCodeRunStatusMessageWebSocketResponseEventDto, isContestAssignment, isContestChangesWebSocketResponseEventDto, isCourseAssignment, isDayAfter, isDayBefore, isEndlessContest, isEqual, isFutureContest, isGlobalContest, isHoursAfter, isHoursBefore, isJkmdSheet, isMillisecondsAfter, isMillisecondsBefore, isMinutesAfter, isMinutesBefore, isMonthAfter, isMonthBefore, isObjectJson, isPastContest, isProblemCrawledWebSocketResponseEventDto, isQuizOptionsSheet, isQuizProblemSheet, isQuizTextSheet, isSameDay, isSameHour, isSameMillisecond, isSameMinute, isSameMonth, isSameSecond, isSameYear, isSecondsAfter, isSecondsBefore, isSendDataEc2InstancesListWebSocketResponseEventDto, isSendDataEcsTaskDefinitionListWebSocketResponseEventDto, isSendDataEcsTasksListWebSocketResponseEventDto, isSendDataRunCommandWebSocketResponseEventDto, isSendDataSsmSessionsListWebSocketResponseEventDto, isSendDataWebSocketResponseEventDto, isStringJson, isSubmissionJudgingWebSocketResponseEventDto, isSubmissionRunStatusMessageWebSocketResponseEventDto, isSubmissionsCrawlWebSocketResponseEventDto, isSubmissionsJudgingScope, isSubscribeCodeRunStatusWebSocketEventDto, isSubscribeContestChangesWebSocketEventDto, isSubscribeGetDataWebSocketEventDto, isSubscribeProblemCrawledWebSocketEventDto, isSubscribeSubmissionRunStatusWebSocketEventDto, isSubscribeSubmissionsCrawlWebSocketEventDto, isSubscribeSubmissionsJudgingWebSocketEventDto, isSubscribeUserNotificationWebSocketEventDto, isTeamMember, isToday, isUnsubscribeCodeRunStatusWebSocketEventDto, isUnsubscribeContestChangesWebSocketEventDto, isUnsubscribeGetDataWebSocketEventDto, isUnsubscribeProblemCrawledWebSocketEventDto, isUnsubscribeSubmissionRunStatusWebSocketEventDto, isUnsubscribeSubmissionsCrawlWebSocketEventDto, isUnsubscribeSubmissionsJudgingWebSocketEventDto, isUnsubscribeUserNotificationWebSocketEventDto, isUserMember, isUserMessageWebSocketResponseEventDto, isUserNotificationContestClarificationWebSocketResponseEventDto, isUserNotificationSubmissionWebSocketResponseEventDto, isUserNotificationWebSocketResponseEventDto, isValidDate, isWebSocketChannelsMessageDto, isWebSocketResponseEventDto, isWebsocketSubscription, isWithinInterval, isWorksheetAssignment, isYearAfter, isYearBefore, join, lettersToIndex, memorySizeOf, mergeVerdicts, mex, normalizeToLocalStartOfDay, normalizeToLocalStartOfHour, normalizeToLocalStartOfMinutes, normalizeToLocalStartOfSeconds, objectUpdate, objectsUpdate, padEnd, padStart, range, removeExtension, safeJsonParse, setAsyncInterval, split, splitTime, startOfDay, startOfHour, startOfMinute, startOfMonth, startOfSecond, startOfWeek, startOfYear, stringToArrayBuffer, toEntityMembersDto, toJkError };