@juki-team/commons 0.1.43 → 0.1.45

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 (65) hide show
  1. package/dist/cjs/index.cjs +410 -543
  2. package/dist/esm/index.js +320 -489
  3. package/dist/types/constants/entity.d.ts +3 -3
  4. package/dist/types/constants/index.d.ts +1 -1
  5. package/dist/types/constants/organization.d.ts +9 -0
  6. package/dist/types/constants/websocket.d.ts +5 -18
  7. package/dist/types/dto/class.d.ts +34 -34
  8. package/dist/types/dto/code.d.ts +1 -1
  9. package/dist/types/dto/comments.d.ts +9 -9
  10. package/dist/types/dto/contest.d.ts +46 -42
  11. package/dist/types/dto/course.d.ts +13 -13
  12. package/dist/types/dto/entity.d.ts +30 -25
  13. package/dist/types/dto/excalidraw.d.ts +7 -7
  14. package/dist/types/dto/file.d.ts +10 -15
  15. package/dist/types/dto/image.d.ts +2 -2
  16. package/dist/types/dto/index.d.ts +1 -1
  17. package/dist/types/dto/judge.d.ts +5 -5
  18. package/dist/types/dto/markdown.d.ts +7 -7
  19. package/dist/types/dto/mermaid.d.ts +7 -7
  20. package/dist/types/dto/{company.d.ts → organization.d.ts} +16 -16
  21. package/dist/types/dto/problem.d.ts +22 -22
  22. package/dist/types/dto/scoreboard.d.ts +8 -18
  23. package/dist/types/dto/session.d.ts +9 -9
  24. package/dist/types/dto/socket.d.ts +43 -126
  25. package/dist/types/dto/statistics.d.ts +7 -7
  26. package/dist/types/dto/submission.d.ts +22 -22
  27. package/dist/types/dto/system.d.ts +7 -82
  28. package/dist/types/dto/url.d.ts +1 -1
  29. package/dist/types/dto/user.d.ts +22 -22
  30. package/dist/types/dto/virtual-user.d.ts +3 -25
  31. package/dist/types/dto/worksheet-submissions.d.ts +22 -22
  32. package/dist/types/dto/worksheet.d.ts +12 -12
  33. package/dist/types/helpers/class.d.ts +4 -4
  34. package/dist/types/helpers/comments.d.ts +1 -1
  35. package/dist/types/helpers/contest.d.ts +4 -4
  36. package/dist/types/helpers/date.d.ts +68 -0
  37. package/dist/types/helpers/document.d.ts +2 -2
  38. package/dist/types/helpers/index.d.ts +3 -0
  39. package/dist/types/helpers/number.d.ts +2 -0
  40. package/dist/types/helpers/responses.d.ts +1 -1
  41. package/dist/types/helpers/socket.d.ts +37 -50
  42. package/dist/types/helpers/time.d.ts +0 -11
  43. package/dist/types/helpers/user.d.ts +2 -2
  44. package/dist/types/index.d.ts +0 -1
  45. package/dist/types/types/class.d.ts +6 -6
  46. package/dist/types/types/comments.d.ts +2 -2
  47. package/dist/types/types/contest.d.ts +20 -23
  48. package/dist/types/types/entity.d.ts +13 -19
  49. package/dist/types/types/file.d.ts +6 -0
  50. package/dist/types/types/index.d.ts +3 -1
  51. package/dist/types/types/{company.d.ts → organization.d.ts} +2 -2
  52. package/dist/types/types/prisma.d.ts +2 -2
  53. package/dist/types/types/problems.d.ts +1 -1
  54. package/dist/types/types/scoreboard.d.ts +11 -0
  55. package/dist/types/types/sheet.d.ts +1 -1
  56. package/dist/types/types/socket.d.ts +12 -16
  57. package/dist/types/types/system.d.ts +76 -0
  58. package/dist/types/types/teams.d.ts +8 -8
  59. package/dist/types/types/virtual-user.d.ts +22 -0
  60. package/package.json +1 -1
  61. package/dist/types/constants/company.d.ts +0 -9
  62. package/dist/types/prototypes/Date.d.ts +0 -62
  63. package/dist/types/prototypes/Number.d.ts +0 -7
  64. package/dist/types/prototypes/index.d.ts +0 -3
  65. /package/dist/types/{prototypes/Error.d.ts → helpers/errors.d.ts} +0 -0
@@ -91,20 +91,20 @@ exports.EntityAccess = void 0;
91
91
  EntityAccess["EXPOSED"] = "EXPOSED";
92
92
  })(exports.EntityAccess || (exports.EntityAccess = {}));
93
93
 
94
- exports.CompanyPlan = void 0;
95
- (function (CompanyPlan) {
96
- CompanyPlan["FREE"] = "FREE";
97
- CompanyPlan["STANDARD"] = "STANDARD";
98
- CompanyPlan["PREMIUM"] = "PREMIUM";
99
- CompanyPlan["CUSTOM"] = "CUSTOM";
100
- })(exports.CompanyPlan || (exports.CompanyPlan = {}));
101
- exports.CompanyLogoType = void 0;
102
- (function (CompanyLogoType) {
103
- CompanyLogoType["HORIZONTAL_WHITE"] = "horizontal-white";
104
- CompanyLogoType["HORIZONTAL_COLOR"] = "horizontal-color";
105
- CompanyLogoType["VERTICAL_WHITE"] = "vertical-white";
106
- CompanyLogoType["VERTICAL_COLOR"] = "vertical-color";
107
- })(exports.CompanyLogoType || (exports.CompanyLogoType = {}));
94
+ exports.OrganizationPlan = void 0;
95
+ (function (OrganizationPlan) {
96
+ OrganizationPlan["FREE"] = "FREE";
97
+ OrganizationPlan["STANDARD"] = "STANDARD";
98
+ OrganizationPlan["PREMIUM"] = "PREMIUM";
99
+ OrganizationPlan["CUSTOM"] = "CUSTOM";
100
+ })(exports.OrganizationPlan || (exports.OrganizationPlan = {}));
101
+ exports.OrganizationLogoType = void 0;
102
+ (function (OrganizationLogoType) {
103
+ OrganizationLogoType["HORIZONTAL_WHITE"] = "horizontal-white";
104
+ OrganizationLogoType["HORIZONTAL_COLOR"] = "horizontal-color";
105
+ OrganizationLogoType["VERTICAL_WHITE"] = "vertical-white";
106
+ OrganizationLogoType["VERTICAL_COLOR"] = "vertical-color";
107
+ })(exports.OrganizationLogoType || (exports.OrganizationLogoType = {}));
108
108
 
109
109
  exports.ContestStatus = void 0;
110
110
  (function (ContestStatus) {
@@ -147,7 +147,7 @@ exports.EntityState = void 0;
147
147
  })(exports.EntityState || (exports.EntityState = {}));
148
148
  exports.EntityCollection = void 0;
149
149
  (function (EntityCollection) {
150
- EntityCollection["COMPANY"] = "COMPANY";
150
+ EntityCollection["ORGANIZATION"] = "ORGANIZATION";
151
151
  EntityCollection["PROBLEM"] = "PROBLEM";
152
152
  EntityCollection["CONTEST"] = "CONTEST";
153
153
  EntityCollection["JUDGE"] = "JUDGE";
@@ -156,7 +156,7 @@ exports.EntityCollection = void 0;
156
156
  })(exports.EntityCollection || (exports.EntityCollection = {}));
157
157
  exports.CollectionKey = void 0;
158
158
  (function (CollectionKey) {
159
- CollectionKey["COMPANY"] = "C";
159
+ CollectionKey["ORGANIZATION"] = "C";
160
160
  CollectionKey["USER"] = "U";
161
161
  CollectionKey["PROBLEM"] = "P";
162
162
  CollectionKey["CLASS"] = "K";
@@ -528,7 +528,7 @@ exports.ErrorCode = void 0;
528
528
  ErrorCode["ERR0818"] = "ERR0818";
529
529
  ErrorCode["ERR0819"] = "ERR0819";
530
530
  ErrorCode["ERR0820"] = "ERR0820";
531
- // Company Errors ERR99XXX',
531
+ // Organization Errors ERR99XXX',
532
532
  ErrorCode["ERR9900"] = "ERR9900";
533
533
  ErrorCode["ERR9910"] = "ERR9910";
534
534
  ErrorCode["ERR9911"] = "ERR9911";
@@ -574,14 +574,6 @@ exports.QuizScoringMode = void 0;
574
574
  QuizScoringMode["PARTIAL"] = "PARTIAL";
575
575
  })(exports.QuizScoringMode || (exports.QuizScoringMode = {}));
576
576
 
577
- exports.WebSocketMessageEvent = void 0;
578
- (function (WebSocketMessageEvent) {
579
- WebSocketMessageEvent["PING"] = "PING";
580
- WebSocketMessageEvent["CLIENT_TRACK_LOCATION"] = "CLIENT_TRACK_LOCATION";
581
- WebSocketMessageEvent["CLIENT_TRACK_SCREENSHOT"] = "CLIENT_TRACK_SCREENSHOT";
582
- WebSocketMessageEvent["CLIENT_TRACK_DEVICE"] = "CLIENT_TRACK_DEVICE";
583
- WebSocketMessageEvent["CHAT_COMPLETIONS"] = "CHAT_COMPLETIONS";
584
- })(exports.WebSocketMessageEvent || (exports.WebSocketMessageEvent = {}));
585
577
  /**
586
578
  * Subscriptions of the client. With the TOPIC channels they are not sent to the server anymore:
587
579
  * they only say which channel the client attaches (`getChannelOfWebSocketSubscribeEvent`) and the dispatch key.
@@ -600,17 +592,11 @@ exports.WebSocketSubscriptionEvent = void 0;
600
592
  WebSocketSubscriptionEvent["UNSUBSCRIBE_SUBMISSIONS_CRAWL"] = "UNSUBSCRIBE_SUBMISSIONS_CRAWL";
601
593
  WebSocketSubscriptionEvent["SUBSCRIBE_CONTEST_CHANGES"] = "SUBSCRIBE_CONTEST_CHANGES";
602
594
  WebSocketSubscriptionEvent["UNSUBSCRIBE_CONTEST_CHANGES"] = "UNSUBSCRIBE_CONTEST_CHANGES";
603
- WebSocketSubscriptionEvent["SUBSCRIBE_CLIENT_TRACK"] = "SUBSCRIBE_CLIENT_TRACK";
604
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CLIENT_TRACK"] = "UNSUBSCRIBE_CLIENT_TRACK";
605
595
  WebSocketSubscriptionEvent["SUBSCRIBE_USER_NOTIFICATION"] = "SUBSCRIBE_USER_NOTIFICATION";
606
596
  WebSocketSubscriptionEvent["UNSUBSCRIBE_USER_NOTIFICATION"] = "UNSUBSCRIBE_USER_NOTIFICATION";
607
- // an administrator watching the data (screenshots, location, device) sent by another client
608
- WebSocketSubscriptionEvent["SUBSCRIBE_CLIENT_TRACK_DATA"] = "SUBSCRIBE_CLIENT_TRACK_DATA";
609
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CLIENT_TRACK_DATA"] = "UNSUBSCRIBE_CLIENT_TRACK_DATA";
610
597
  })(exports.WebSocketSubscriptionEvent || (exports.WebSocketSubscriptionEvent = {}));
611
598
  exports.WebSocketResponseEvent = void 0;
612
599
  (function (WebSocketResponseEvent) {
613
- WebSocketResponseEvent["PONG"] = "PONG";
614
600
  WebSocketResponseEvent["CODE_RUN_STATUS"] = "CODE_RUN_STATUS";
615
601
  WebSocketResponseEvent["SUBMISSION_RUN_STATUS"] = "SUBMISSION_RUN_STATUS";
616
602
  WebSocketResponseEvent["USER_MESSAGE"] = "USER_MESSAGE";
@@ -620,12 +606,9 @@ exports.WebSocketResponseEvent = void 0;
620
606
  WebSocketResponseEvent["SEND_DATA_EC2_INSTANCES_LIST"] = "SEND_DATA_EC2_INSTANCES_LIST";
621
607
  WebSocketResponseEvent["SEND_DATA_SSM_SESSIONS_LIST"] = "SEND_DATA_SSM_SESSIONS_LIST";
622
608
  WebSocketResponseEvent["SEND_DATA_RUN_COMMAND"] = "SEND_DATA_RUN_COMMAND";
623
- WebSocketResponseEvent["SEND_DATA_CLIENT_TRACK"] = "SEND_DATA_CLIENT_TRACK";
624
- WebSocketResponseEvent["SEND_DATA_CHAT_COMPLETIONS"] = "SEND_DATA_CHAT_COMPLETIONS";
625
609
  WebSocketResponseEvent["PROBLEM_CRAWLED"] = "PROBLEM_CRAWLED";
626
610
  WebSocketResponseEvent["SUBMISSIONS_CRAWL"] = "SUBMISSIONS_CRAWL";
627
611
  WebSocketResponseEvent["CONTEST_CHANGES"] = "CONTEST_CHANGES";
628
- WebSocketResponseEvent["CLIENT_TRACK"] = "CLIENT_TRACK";
629
612
  WebSocketResponseEvent["USER_NOTIFICATION_"] = "USER_NOTIFICATION_";
630
613
  WebSocketResponseEvent["USER_NOTIFICATION_SUBMISSION"] = "USER_NOTIFICATION_SUBMISSION";
631
614
  WebSocketResponseEvent["USER_NOTIFICATION_CONTEST_CLARIFICATION"] = "USER_NOTIFICATION_CONTEST_CLARIFICATION";
@@ -1337,25 +1320,25 @@ const HEADER_JUKI_SECRET_TOKEN = 'x-juki-secret-token';
1337
1320
  const HEADER_JUKI_INTERNAL_API_KEY = 'x-juki-internal-api-key';
1338
1321
  const COOKIE_JUKI_SESSION_ID = 'juki-session-id';
1339
1322
 
1340
- const JUKI_APP_COMPANY_KEY = 'juki-app';
1341
- const COMPANY_PLAN = {
1342
- [exports.CompanyPlan.FREE]: {
1343
- value: exports.CompanyPlan.FREE,
1323
+ const JUKI_APP_ORGANIZATION_KEY = 'juki-app';
1324
+ const ORGANIZATION_PLAN = {
1325
+ [exports.OrganizationPlan.FREE]: {
1326
+ value: exports.OrganizationPlan.FREE,
1344
1327
  label: 'free',
1345
1328
  description: 'the resources, runners and compilers, are shared with the juki.app giving priority to juki.app',
1346
1329
  },
1347
- [exports.CompanyPlan.STANDARD]: {
1348
- value: exports.CompanyPlan.STANDARD,
1330
+ [exports.OrganizationPlan.STANDARD]: {
1331
+ value: exports.OrganizationPlan.STANDARD,
1349
1332
  label: 'standard',
1350
1333
  description: 'the resources are dedicated, 1 runner and 1 compiler',
1351
1334
  },
1352
- [exports.CompanyPlan.PREMIUM]: {
1353
- value: exports.CompanyPlan.PREMIUM,
1335
+ [exports.OrganizationPlan.PREMIUM]: {
1336
+ value: exports.OrganizationPlan.PREMIUM,
1354
1337
  label: 'premium',
1355
1338
  description: 'the resources are dedicated and on demand use with at least 1 runner and 1 compiler',
1356
1339
  },
1357
- [exports.CompanyPlan.CUSTOM]: {
1358
- value: exports.CompanyPlan.CUSTOM,
1340
+ [exports.OrganizationPlan.CUSTOM]: {
1341
+ value: exports.OrganizationPlan.CUSTOM,
1359
1342
  label: 'custom',
1360
1343
  description: 'the resources are dedicated and on demand use with at least 1 (settable) runner and 1 (settable) compiler',
1361
1344
  },
@@ -1978,18 +1961,18 @@ const ERROR = {
1978
1961
  [exports.ErrorCode.ERR9997]: { value: exports.ErrorCode.ERR9997, message: 'aborted request', status: 400 },
1979
1962
  [exports.ErrorCode.ERR9998]: { value: exports.ErrorCode.ERR9998, message: 'error on response', status: 400 },
1980
1963
  [exports.ErrorCode.ERR9999]: { value: exports.ErrorCode.ERR9999, message: 'service no found', status: 400 },
1981
- // COMPANY ERRORS ERR99XX
1982
- [exports.ErrorCode.ERR9900]: { value: exports.ErrorCode.ERR9900, message: 'internal server error on company service', status: 500 },
1983
- // Company server errors
1984
- [exports.ErrorCode.ERR9910]: { value: exports.ErrorCode.ERR9910, message: 'company not created', status: 500 },
1985
- [exports.ErrorCode.ERR9911]: { value: exports.ErrorCode.ERR9911, message: 'company not found', status: 500 },
1986
- [exports.ErrorCode.ERR9912]: { value: exports.ErrorCode.ERR9912, message: 'company not updated', status: 500 },
1987
- [exports.ErrorCode.ERR9913]: { value: exports.ErrorCode.ERR9913, message: 'company not deleted', status: 500 },
1988
- // Company user permission error
1989
- [exports.ErrorCode.ERR9914]: { value: exports.ErrorCode.ERR9914, message: 'not allowed to create the company', status: 400 },
1990
- [exports.ErrorCode.ERR9915]: { value: exports.ErrorCode.ERR9915, message: 'not allowed to view the company', status: 400 },
1991
- [exports.ErrorCode.ERR9916]: { value: exports.ErrorCode.ERR9916, message: 'not allowed to updated the company', status: 400 },
1992
- [exports.ErrorCode.ERR9917]: { value: exports.ErrorCode.ERR9917, message: 'not allowed to deleted the company', status: 400 },
1964
+ // ORGANIZATION ERRORS ERR99XX
1965
+ [exports.ErrorCode.ERR9900]: { value: exports.ErrorCode.ERR9900, message: 'internal server error on organization service', status: 500 },
1966
+ // Organization server errors
1967
+ [exports.ErrorCode.ERR9910]: { value: exports.ErrorCode.ERR9910, message: 'organization not created', status: 500 },
1968
+ [exports.ErrorCode.ERR9911]: { value: exports.ErrorCode.ERR9911, message: 'organization not found', status: 500 },
1969
+ [exports.ErrorCode.ERR9912]: { value: exports.ErrorCode.ERR9912, message: 'organization not updated', status: 500 },
1970
+ [exports.ErrorCode.ERR9913]: { value: exports.ErrorCode.ERR9913, message: 'organization not deleted', status: 500 },
1971
+ // Organization user permission error
1972
+ [exports.ErrorCode.ERR9914]: { value: exports.ErrorCode.ERR9914, message: 'not allowed to create the organization', status: 400 },
1973
+ [exports.ErrorCode.ERR9915]: { value: exports.ErrorCode.ERR9915, message: 'not allowed to view the organization', status: 400 },
1974
+ [exports.ErrorCode.ERR9916]: { value: exports.ErrorCode.ERR9916, message: 'not allowed to updated the organization', status: 400 },
1975
+ [exports.ErrorCode.ERR9917]: { value: exports.ErrorCode.ERR9917, message: 'not allowed to deleted the organization', status: 400 },
1993
1976
  // USER ERRORS ERR00XX
1994
1977
  [exports.ErrorCode.ERR0000]: { value: exports.ErrorCode.ERR0000, message: 'internal server error on users service', status: 500 },
1995
1978
  // User server errors
@@ -2235,7 +2218,7 @@ const EMPTY_USER_PERMISSIONS = {
2235
2218
  create: false,
2236
2219
  manage: false,
2237
2220
  },
2238
- company: {
2221
+ organization: {
2239
2222
  manage: false,
2240
2223
  administrate: false,
2241
2224
  },
@@ -2244,23 +2227,12 @@ const EMPTY_USER_PERMISSIONS = {
2244
2227
  },
2245
2228
  };
2246
2229
 
2247
- // LEGACY channels (fan-out per client through the subscriptions registry in Redis)
2248
- /** @deprecated the subscriptions registry was replaced by the TOPIC channels granted in the Ably token */
2249
- const CHANNEL_PUBLISH_SUBSCRIPTIONS = 'pub:subscriptions';
2250
- /** @deprecated not used, the events arrive by the TOPIC channels */
2251
- const CHANNEL_SUBSCRIBE_NOTIFICATIONS = 'sub:notifications';
2252
- /** @deprecated the events arrive by the TOPIC channels */
2253
- const CHANNEL_SUBSCRIBE_CLIENT = (clientId) => `sub:client:${clientId}`;
2254
- /** messages from the clients to the backend (chat completions, client track screenshots) */
2255
- const CHANNEL_PUBLISH_MESSAGES = 'pub:messages';
2256
- /** @deprecated global presence channel (limited to 200 members by Ably), replaced by CHANNEL_COMPANY_PRESENCE */
2257
- const CHANNEL_PRESENCE_CLIENT = 'pre:client';
2258
2230
  // TOPIC channels
2259
2231
  // The backend publishes each event once on the channel of its topic and Ably does the fan-out.
2260
2232
  // Who can subscribe to each channel is decided by the API in the Ably token (capability), never by the client.
2261
2233
  // Dynamic segments are encoded so a key can never inject a `:` (the Ably segment separator used by the wildcards).
2262
2234
  const segment = (value) => encodeURIComponent(value);
2263
- /** private: events of one session (code runs, requested data, client track commands) */
2235
+ /** private: events of one session (code runs, requested data) */
2264
2236
  const CHANNEL_SESSION = (sessionId) => `session:${segment(sessionId)}`;
2265
2237
  /** private: events of one user (own submissions while the contest is frozen, notifications) */
2266
2238
  const CHANNEL_USER = (userId) => `user:${segment(userId)}`;
@@ -2270,20 +2242,17 @@ const CHANNEL_SUBMISSION = (submitId) => `submission:${segment(submitId)}`;
2270
2242
  const CHANNEL_PROBLEM = (problemKey) => `problem:${segment(problemKey)}`;
2271
2243
  /** per role: events of a contest for one role (and the roles above it, see `ContestChannelRole`) */
2272
2244
  const CHANNEL_CONTEST = (contestKey, role) => `contest:${segment(contestKey)}:${role}`;
2273
- /** system administrators only: data sent by a tracked client (screenshots, location, device) */
2274
- const CHANNEL_CLIENT_TRACK = (trackedClientId) => `client-track:${segment(trackedClientId)}`;
2275
2245
  /**
2276
- * presence of the clients (tabs) of the logged users of a company (by its key), data: `UserPresenceData`.
2277
- * The clients only enter (capability `presence`), only the administrators of the company receive it
2246
+ * presence of the clients (tabs) of the logged users of a organization (by its key), data: `UserPresenceData`.
2247
+ * The clients only enter (capability `presence`), only the administrators of the organization receive it
2278
2248
  * (capability `presence-subscribe`). Ably limits the presence members per channel (200 by default,
2279
2249
  * more with server-side batching enabled on the `presence` namespace).
2280
2250
  * The identity of a member is its `clientId` (`sessionId|uiId`, verified by Ably), never its data.
2281
2251
  */
2282
- const CHANNEL_COMPANY_PRESENCE = (companyKey) => `presence:company:${segment(companyKey)}`;
2252
+ const CHANNEL_ORGANIZATION_PRESENCE = (organizationKey) => `presence:organization:${segment(organizationKey)}`;
2283
2253
  // capability resources (wildcards) of the public channels
2284
2254
  const CHANNEL_SUBMISSION_ALL = 'submission:*';
2285
2255
  const CHANNEL_PROBLEM_ALL = 'problem:*';
2286
- const CHANNEL_CLIENT_TRACK_ALL = 'client-track:*';
2287
2256
  /**
2288
2257
  * Returns the contest and role of a `CHANNEL_CONTEST` channel name, or null if it is not one.
2289
2258
  */
@@ -2385,31 +2354,212 @@ const isContestAssignment = (assignment) => {
2385
2354
  };
2386
2355
 
2387
2356
  const getAssignmentCommentKey = (classKey, cycleKey, sessionKey, assignmentKey) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}`;
2388
- const getAssignmentUserCommentKey = (classKey, cycleKey, sessionKey, assignmentKey, userNickname, userCompany) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}|user_nickname:${userNickname}|user_company:${userCompany}`;
2357
+ const getAssignmentUserCommentKey = (classKey, cycleKey, sessionKey, assignmentKey, userNickname, userOrganization) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}|user_nickname:${userNickname}|user_organization:${userOrganization}`;
2389
2358
  const getProblemCommentKey = (problemKey) => `problem:${problemKey}`;
2390
2359
  const getContestCommentKey = (contestKey) => `contest:${contestKey}`;
2391
2360
 
2392
2361
  const isEndlessContest = (settings) => {
2393
- return settings?.startTimestamp === MIN_DATE.getTime()
2394
- && settings?.frozenTimestamp === MAX_DATE.getTime()
2395
- && settings?.quietTimestamp === MAX_DATE.getTime()
2396
- && settings?.endTimestamp === MAX_DATE.getTime()
2362
+ return settings?.startsAt === MIN_DATE.getTime()
2363
+ && settings?.frozenAt === MAX_DATE.getTime()
2364
+ && settings?.silencedAt === MAX_DATE.getTime()
2365
+ && settings?.endsAt === MAX_DATE.getTime()
2397
2366
  && settings?.penalty === 0;
2398
2367
  };
2399
2368
  const isGlobalContest = (settings) => {
2400
- return settings?.startTimestamp === 0
2401
- && settings?.frozenTimestamp === 0
2402
- && settings?.quietTimestamp === 0
2403
- && settings?.endTimestamp === 0
2369
+ return settings?.startsAt === 0
2370
+ && settings?.frozenAt === 0
2371
+ && settings?.silencedAt === 0
2372
+ && settings?.endsAt === 0
2404
2373
  && settings?.penalty === 0;
2405
2374
  };
2406
2375
  const isPastContest = (settings) => {
2407
- return Date.now() > (settings?.endTimestamp ?? 0);
2376
+ return Date.now() > (settings?.endsAt ?? 0);
2408
2377
  };
2409
2378
  const isFutureContest = (settings) => {
2410
- return (settings?.startTimestamp ?? 0) > Date.now();
2379
+ return (settings?.startsAt ?? 0) > Date.now();
2411
2380
  };
2412
2381
 
2382
+ const changeYear = (date, year) => {
2383
+ const newDate = new Date(date);
2384
+ newDate.setFullYear(year);
2385
+ return newDate;
2386
+ };
2387
+ const changeMonth = (date, monthIndex) => {
2388
+ const newDate = new Date(date);
2389
+ newDate.setMonth(monthIndex);
2390
+ return newDate;
2391
+ };
2392
+ const changeDay = (date, day) => {
2393
+ const newDate = new Date(date);
2394
+ newDate.setDate(day);
2395
+ return newDate;
2396
+ };
2397
+ const changeHours = (date, hours) => {
2398
+ const newDate = new Date(date);
2399
+ newDate.setHours(hours);
2400
+ return newDate;
2401
+ };
2402
+ const changeMinutes = (date, minutes) => {
2403
+ const newDate = new Date(date);
2404
+ newDate.setMinutes(minutes);
2405
+ return newDate;
2406
+ };
2407
+ const changeSeconds = (date, seconds) => {
2408
+ const newDate = new Date(date);
2409
+ newDate.setSeconds(seconds);
2410
+ return newDate;
2411
+ };
2412
+ const changeMilliseconds = (date, milliseconds) => {
2413
+ const newDate = new Date(date);
2414
+ newDate.setMilliseconds(milliseconds);
2415
+ return newDate;
2416
+ };
2417
+ const decreaseYear = (date, count = 1) => changeYear(date, date.getFullYear() - count);
2418
+ const increaseYear = (date, count = 1) => changeYear(date, date.getFullYear() + count);
2419
+ const decreaseMonth = (date) => {
2420
+ const newDate = new Date(date);
2421
+ newDate.setMonth(newDate.getMonth() - 1);
2422
+ return newDate;
2423
+ };
2424
+ const increaseMonth = (date) => {
2425
+ const newDate = new Date(date);
2426
+ newDate.setMonth(newDate.getMonth() + 1);
2427
+ return newDate;
2428
+ };
2429
+ const decreaseDay = (date) => {
2430
+ const newDate = new Date(date);
2431
+ newDate.setDate(newDate.getDate() - 1);
2432
+ return newDate;
2433
+ };
2434
+ const increaseDay = (date) => {
2435
+ const newDate = new Date(date);
2436
+ newDate.setDate(newDate.getDate() + 1);
2437
+ return newDate;
2438
+ };
2439
+ const startOfDay = (date) => {
2440
+ const newDate = new Date(date);
2441
+ newDate.setHours(0, 0, 0, 0);
2442
+ return newDate;
2443
+ };
2444
+ const endOfDay = (date) => {
2445
+ const newDate = new Date(date);
2446
+ newDate.setHours(23, 59, 59, 999);
2447
+ return newDate;
2448
+ };
2449
+ const startOfMonth = (date) => {
2450
+ const newDate = new Date(date);
2451
+ newDate.setDate(1);
2452
+ return startOfDay(newDate);
2453
+ };
2454
+ const endOfMonth = (date) => {
2455
+ const nextMonth = startOfMonth(increaseMonth(date));
2456
+ return new Date(nextMonth.getTime() - 1);
2457
+ };
2458
+ const startOfYear = (date) => {
2459
+ const newDate = new Date(date);
2460
+ newDate.setMonth(0);
2461
+ return startOfMonth(newDate);
2462
+ };
2463
+ const endOfYear = (date) => {
2464
+ const nextYear = startOfYear(increaseYear(date));
2465
+ return new Date(nextYear.getTime() - 1);
2466
+ };
2467
+ const startOfWeek = (date) => {
2468
+ const newDate = new Date(date);
2469
+ while (newDate.getDay()) {
2470
+ newDate.setDate(newDate.getDate() - 1);
2471
+ }
2472
+ return startOfDay(newDate);
2473
+ };
2474
+ const endOfWeek = (date) => {
2475
+ const newDate = new Date(date);
2476
+ while (newDate.getDay() < 6) {
2477
+ newDate.setDate(newDate.getDate() + 1);
2478
+ }
2479
+ return endOfDay(newDate);
2480
+ };
2481
+ const startOfHour = (date) => {
2482
+ const newDate = new Date(date);
2483
+ newDate.setMinutes(0, 0, 0);
2484
+ return newDate;
2485
+ };
2486
+ const endOfHour = (date) => {
2487
+ const newDate = new Date(date);
2488
+ newDate.setMinutes(59, 59, 999);
2489
+ return newDate;
2490
+ };
2491
+ const startOfMinute = (date) => {
2492
+ const newDate = new Date(date);
2493
+ newDate.setSeconds(0, 0);
2494
+ return newDate;
2495
+ };
2496
+ const endOfMinute = (date) => {
2497
+ const newDate = new Date(date);
2498
+ newDate.setSeconds(59, 999);
2499
+ return newDate;
2500
+ };
2501
+ const startOfSecond = (date) => {
2502
+ const newDate = new Date(date);
2503
+ newDate.setMilliseconds(0);
2504
+ return newDate;
2505
+ };
2506
+ const endOfSecond = (date) => {
2507
+ const newDate = new Date(date);
2508
+ newDate.setMilliseconds(999);
2509
+ return newDate;
2510
+ };
2511
+ const isEqual = (a, b) => a.getTime() === b.getTime();
2512
+ const isSameYear = (a, b) => a.getFullYear() === b.getFullYear();
2513
+ const isSameMonth = (a, b) => isSameYear(a, b) && a.getMonth() === b.getMonth();
2514
+ const isSameDay = (a, b) => isSameMonth(a, b) && a.getDate() === b.getDate();
2515
+ const isSameHour = (a, b) => isSameDay(a, b) && a.getHours() === b.getHours();
2516
+ const isSameMinute = (a, b) => isSameHour(a, b) && a.getMinutes() === b.getMinutes();
2517
+ const isSameSecond = (a, b) => isSameMinute(a, b) && a.getSeconds() === b.getSeconds();
2518
+ const isSameMillisecond = (a, b) => isEqual(a, b);
2519
+ const isToday = (date) => isSameDay(date, new Date());
2520
+ const isValidDate = (date) => date instanceof Date && !Number.isNaN(date.getTime());
2521
+ const isAfter = (a, b) => a.getTime() > b.getTime();
2522
+ const isBefore = (a, b) => a.getTime() < b.getTime();
2523
+ const isYearAfter = (a, b) => a.getFullYear() > b.getFullYear();
2524
+ const isMonthAfter = (a, b) => isYearAfter(a, b) || (isSameYear(a, b) && a.getMonth() > b.getMonth());
2525
+ const isDayAfter = (a, b) => isMonthAfter(a, b) || (isSameMonth(a, b) && a.getDate() > b.getDate());
2526
+ const isHoursAfter = (a, b) => isDayAfter(a, b) || (isSameDay(a, b) && a.getHours() > b.getHours());
2527
+ const isMinutesAfter = (a, b) => isHoursAfter(a, b) || (isSameHour(a, b) && a.getMinutes() > b.getMinutes());
2528
+ const isSecondsAfter = (a, b) => isMinutesAfter(a, b) || (isSameMinute(a, b) && a.getSeconds() > b.getSeconds());
2529
+ const isMillisecondsAfter = (a, b) => isSecondsAfter(a, b) || (isSameSecond(a, b) && a.getMilliseconds() > b.getMilliseconds());
2530
+ const isYearBefore = (a, b) => a.getFullYear() < b.getFullYear();
2531
+ const isMonthBefore = (a, b) => isYearBefore(a, b) || (isSameYear(a, b) && a.getMonth() < b.getMonth());
2532
+ const isDayBefore = (a, b) => isMonthBefore(a, b) || (isSameMonth(a, b) && a.getDate() < b.getDate());
2533
+ const isHoursBefore = (a, b) => isDayBefore(a, b) || (isSameDay(a, b) && a.getHours() < b.getHours());
2534
+ const isMinutesBefore = (a, b) => isHoursBefore(a, b) || (isSameHour(a, b) && a.getMinutes() < b.getMinutes());
2535
+ const isSecondsBefore = (a, b) => isMinutesBefore(a, b) || (isSameMinute(a, b) && a.getSeconds() < b.getSeconds());
2536
+ const isMillisecondsBefore = (a, b) => isSecondsBefore(a, b) || (isSameSecond(a, b) && a.getMilliseconds() < b.getMilliseconds());
2537
+ const isWithinInterval = (date, { start, end }, cmp = '[]') => (cmp.charAt(0) === '[' ? isEqual(date, start) || isAfter(date, start) : isAfter(date, start)) &&
2538
+ (cmp.charAt(1) === ']' ? isEqual(date, end) || isBefore(date, end) : isBefore(date, end));
2539
+ const normalizeToLocalStartOfDay = (timestamp) => {
2540
+ const d = new Date(timestamp);
2541
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
2542
+ };
2543
+ const normalizeToLocalStartOfHour = (timestamp) => {
2544
+ const d = new Date(timestamp);
2545
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
2546
+ };
2547
+ const normalizeToLocalStartOfMinutes = (timestamp) => {
2548
+ const d = new Date(timestamp);
2549
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes());
2550
+ };
2551
+ const normalizeToLocalStartOfSeconds = (timestamp) => {
2552
+ const d = new Date(timestamp);
2553
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
2554
+ };
2555
+ const getYears = (d) => d.getFullYear();
2556
+ const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
2557
+ const getDays = (d) => Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
2558
+ const getHours = (d) => Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
2559
+ const getMinutes = (d) => Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
2560
+ const getSeconds = (d) => Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
2561
+ const getMilliseconds = (d) => d.getTime();
2562
+
2413
2563
  const getDocumentAccess = (document) => {
2414
2564
  switch (true) {
2415
2565
  case (document?.members?.rankAdministrators === exports.EntityMembersRank.NONE || document?.members?.rankAdministrators === exports.EntityMembersRank.CLOSE)
@@ -2446,7 +2596,7 @@ const isUserMember = (member) => {
2446
2596
  const isTeamMember = (member) => {
2447
2597
  return typeof member.teamId === 'string';
2448
2598
  };
2449
- const toEntityMembersDTO = (members) => {
2599
+ const toEntityMembersDto = (members) => {
2450
2600
  return {
2451
2601
  rankAdministrators: members.rankAdministrators,
2452
2602
  administrators: Object.keys(members.administrators),
@@ -2461,6 +2611,21 @@ const toEntityMembersDTO = (members) => {
2461
2611
  };
2462
2612
  };
2463
2613
 
2614
+ class JkError extends Error {
2615
+ constructor(code, custom) {
2616
+ const message = custom?.message || ERROR[code].message;
2617
+ super(message);
2618
+ this.message = message;
2619
+ this.code = code;
2620
+ if (custom?.stack) {
2621
+ this.stack = custom.stack;
2622
+ }
2623
+ if (custom?.data) {
2624
+ this.data = custom.data;
2625
+ }
2626
+ }
2627
+ }
2628
+
2464
2629
  function removeExtension(fileName) {
2465
2630
  const i = fileName.lastIndexOf('.');
2466
2631
  return i !== -1 ? fileName.substring(0, i) : fileName;
@@ -2615,6 +2780,9 @@ const getDataLog = (log) => {
2615
2780
  };
2616
2781
  };
2617
2782
 
2783
+ const padStart = (n, maxLength, fillString = '0') => `${n}`.padStart(maxLength, fillString);
2784
+ const padEnd = (n, maxLength, fillString = '0') => `${n}`.padEnd(maxLength, fillString);
2785
+
2618
2786
  function memorySizeOf(obj) {
2619
2787
  let bytes = 0;
2620
2788
  function sizeOf(obj) {
@@ -2649,247 +2817,6 @@ function memorySizeOf(obj) {
2649
2817
  return sizeOf(obj);
2650
2818
  }
2651
2819
 
2652
- /* eslint-disable no-extend-native */
2653
- Date.prototype.changeYear = function (year) {
2654
- const newDate = new Date(this);
2655
- newDate.setFullYear(year);
2656
- return newDate;
2657
- };
2658
- Date.prototype.changeMonth = function (monthIndex) {
2659
- const newDate = new Date(this);
2660
- newDate.setMonth(monthIndex);
2661
- return newDate;
2662
- };
2663
- Date.prototype.changeDay = function (date) {
2664
- const newDate = new Date(this);
2665
- newDate.setDate(date);
2666
- return newDate;
2667
- };
2668
- Date.prototype.changeHours = function (hours) {
2669
- const newDate = new Date(this);
2670
- newDate.setHours(hours);
2671
- return newDate;
2672
- };
2673
- Date.prototype.changeMinutes = function (minutes) {
2674
- const newDate = new Date(this);
2675
- newDate.setMinutes(minutes);
2676
- return newDate;
2677
- };
2678
- Date.prototype.changeSeconds = function (seconds) {
2679
- const newDate = new Date(this);
2680
- newDate.setSeconds(seconds);
2681
- return newDate;
2682
- };
2683
- Date.prototype.changeMilliseconds = function (milliseconds) {
2684
- const newDate = new Date(this);
2685
- newDate.setMilliseconds(milliseconds);
2686
- return newDate;
2687
- };
2688
- Date.prototype.decreaseYear = function (count = 1) {
2689
- return this.changeYear(this.getFullYear() - count);
2690
- };
2691
- Date.prototype.increaseYear = function (count = 1) {
2692
- return this.changeYear(this.getFullYear() + count);
2693
- };
2694
- Date.prototype.decreaseMonth = function () {
2695
- const newDate = new Date(this);
2696
- newDate.setMonth(newDate.getMonth() - 1);
2697
- return newDate;
2698
- };
2699
- Date.prototype.increaseMonth = function () {
2700
- const newDate = new Date(this);
2701
- newDate.setMonth(newDate.getMonth() + 1);
2702
- return newDate;
2703
- };
2704
- Date.prototype.increaseDay = function () {
2705
- const newDate = new Date(this);
2706
- newDate.setDate(newDate.getDate() + 1);
2707
- return newDate;
2708
- };
2709
- Date.prototype.decreaseDay = function () {
2710
- const newDate = new Date(this);
2711
- newDate.setDate(newDate.getDate() - 1);
2712
- return newDate;
2713
- };
2714
- Date.prototype.startOfYear = function () {
2715
- const newDate = new Date(this);
2716
- newDate.setMonth(0);
2717
- return newDate.startOfMonth();
2718
- };
2719
- Date.prototype.endOfYear = function () {
2720
- const nextMonth = this.increaseYear().startOfYear();
2721
- return new Date(nextMonth.getTime() - 1);
2722
- };
2723
- Date.prototype.startOfMonth = function () {
2724
- const newDate = new Date(this);
2725
- newDate.setDate(1);
2726
- return newDate.startOfDay();
2727
- };
2728
- Date.prototype.endOfMonth = function () {
2729
- const nextMonth = this.increaseMonth().startOfMonth();
2730
- return new Date(nextMonth.getTime() - 1);
2731
- };
2732
- Date.prototype.startOfWeek = function () {
2733
- const newDate = new Date(this);
2734
- while (newDate.getDay()) {
2735
- newDate.setDate(newDate.getDate() - 1);
2736
- }
2737
- return newDate.startOfDay();
2738
- };
2739
- Date.prototype.endOfWeek = function () {
2740
- const newDate = new Date(this);
2741
- while (newDate.getDay() < 6) {
2742
- newDate.setDate(newDate.getDate() - 1);
2743
- }
2744
- return newDate.endOfDay();
2745
- };
2746
- Date.prototype.startOfDay = function () {
2747
- const newDate = new Date(this);
2748
- newDate.setHours(0, 0, 0, 0);
2749
- return newDate;
2750
- };
2751
- Date.prototype.endOfDay = function () {
2752
- const newDate = new Date(this);
2753
- newDate.setHours(23, 59, 59, 999);
2754
- return newDate;
2755
- };
2756
- Date.prototype.startOfHour = function () {
2757
- const newDate = new Date(this);
2758
- newDate.setMinutes(0, 0, 0);
2759
- return newDate;
2760
- };
2761
- Date.prototype.endOfHour = function () {
2762
- const newDate = new Date(this);
2763
- newDate.setMinutes(59, 59, 999);
2764
- return newDate;
2765
- };
2766
- Date.prototype.startOfMinute = function () {
2767
- const newDate = new Date(this);
2768
- newDate.setSeconds(0, 0);
2769
- return newDate;
2770
- };
2771
- Date.prototype.endOfMinute = function () {
2772
- const newDate = new Date(this);
2773
- newDate.setSeconds(59, 999);
2774
- return newDate;
2775
- };
2776
- Date.prototype.startOfSecond = function () {
2777
- const newDate = new Date(this);
2778
- newDate.setMilliseconds(0);
2779
- return newDate;
2780
- };
2781
- Date.prototype.endOfSecond = function () {
2782
- const newDate = new Date(this);
2783
- newDate.setMilliseconds(999);
2784
- return newDate;
2785
- };
2786
- Date.prototype.isToday = function () {
2787
- const today = new Date();
2788
- return this.isSameDay(today);
2789
- };
2790
- Date.prototype.isEqual = function (date) {
2791
- return this.getTime() === date.getTime();
2792
- };
2793
- Date.prototype.isSameYear = function (date) {
2794
- return this.getFullYear() === date.getFullYear();
2795
- };
2796
- Date.prototype.isSameMonth = function (date) {
2797
- return this.isSameYear(date) && this.getMonth() === date.getMonth();
2798
- };
2799
- Date.prototype.isSameDay = function (date) {
2800
- return this.isSameMonth(date) && this.getDate() === date.getDate();
2801
- };
2802
- Date.prototype.isSameHour = function (date) {
2803
- return this.isSameDay(date) && this.getHours() === date.getHours();
2804
- };
2805
- Date.prototype.isSameMinute = function (date) {
2806
- return this.isSameHour(date) && this.getMinutes() === date.getMinutes();
2807
- };
2808
- Date.prototype.isSameSecond = function (date) {
2809
- return this.isSameMinute(date) && this.getSeconds() === date.getSeconds();
2810
- };
2811
- Date.prototype.isSameMillisecond = function (date) {
2812
- return this.isEqual(date);
2813
- };
2814
- Date.prototype.isValidDate = function () {
2815
- return this instanceof Date && !isNaN(this.getTime());
2816
- };
2817
- Date.prototype.isYearAfter = function (date) {
2818
- return this.getFullYear() > date.getFullYear();
2819
- };
2820
- Date.prototype.isMonthAfter = function (date) {
2821
- return this.isYearAfter(date) || (this.isSameYear(date) && this.getMonth() > date.getMonth());
2822
- };
2823
- Date.prototype.isDayAfter = function (date) {
2824
- return this.isMonthAfter(date) || (this.isSameMonth(date) && this.getDate() > date.getDate());
2825
- };
2826
- Date.prototype.isHoursAfter = function (date) {
2827
- return this.isDayAfter(date) || (this.isSameDay(date) && this.getHours() > date.getHours());
2828
- };
2829
- Date.prototype.isMinutesAfter = function (date) {
2830
- return this.isHoursAfter(date) || (this.isSameHour(date) && this.getMinutes() > date.getMinutes());
2831
- };
2832
- Date.prototype.isSecondsAfter = function (date) {
2833
- return this.isMinutesAfter(date) || (this.isSameMinute(date) && this.getSeconds() > date.getSeconds());
2834
- };
2835
- Date.prototype.isMillisecondsAfter = function (date) {
2836
- return this.isSecondsAfter(date) || (this.isSameSecond(date) && this.getMilliseconds() > date.getMilliseconds());
2837
- };
2838
- Date.prototype.isAfter = function (date) {
2839
- return this.getTime() > date.getTime();
2840
- };
2841
- Date.prototype.isYearBefore = function (date) {
2842
- return this.getFullYear() < date.getFullYear();
2843
- };
2844
- Date.prototype.isMonthBefore = function (date) {
2845
- return this.isYearBefore(date) || (this.isSameYear(date) && this.getMonth() < date.getMonth());
2846
- };
2847
- Date.prototype.isDayBefore = function (date) {
2848
- return this.isMonthBefore(date) || (this.isSameMonth(date) && this.getDate() < date.getDate());
2849
- };
2850
- Date.prototype.isHoursBefore = function (date) {
2851
- return this.isDayBefore(date) || (this.isSameDay(date) && this.getHours() < date.getHours());
2852
- };
2853
- Date.prototype.isMinutesBefore = function (date) {
2854
- return this.isHoursBefore(date) || (this.isSameHour(date) && this.getMinutes() < date.getMinutes());
2855
- };
2856
- Date.prototype.isSecondsBefore = function (date) {
2857
- return this.isMinutesBefore(date) || (this.isSameMinute(date) && this.getSeconds() < date.getSeconds());
2858
- };
2859
- Date.prototype.isMillisecondsBefore = function (date) {
2860
- return this.isSecondsBefore(date) || (this.isSameSecond(date) && this.getMilliseconds() < date.getMilliseconds());
2861
- };
2862
- Date.prototype.isBefore = function (date) {
2863
- return this.getTime() < date.getTime();
2864
- };
2865
- Date.prototype.isWithinInterval = function ({ start, end }, cmp = '[]') {
2866
- return (cmp.charAt(0) === '[' ? this.isEqual(start) || this.isAfter(start) : this.isAfter(start)) &&
2867
- (cmp.charAt(1) === '[' ? this.isEqual(end) || this.isBefore(end) : this.isBefore(end));
2868
- };
2869
-
2870
- class JkError extends Error {
2871
- constructor(code, custom) {
2872
- const message = custom?.message || ERROR[code].message;
2873
- super(message);
2874
- this.message = message;
2875
- this.code = code;
2876
- if (custom?.stack) {
2877
- this.stack = custom.stack;
2878
- }
2879
- if (custom?.data) {
2880
- this.data = custom.data;
2881
- }
2882
- }
2883
- }
2884
-
2885
- /* eslint-disable no-extend-native */
2886
- Number.prototype.padStart = function (maxLength, fillString = '0') {
2887
- return (this + '').padStart(maxLength, fillString);
2888
- };
2889
- Number.prototype.padEnd = function (maxLength, fillString = '0') {
2890
- return (this + '').padEnd(maxLength, fillString);
2891
- };
2892
-
2893
2820
  function toJkError(err) {
2894
2821
  const error = new Error();
2895
2822
  let code = err?.code;
@@ -2983,256 +2910,194 @@ const getDefaultMeta = (contents, sort) => {
2983
2910
  };
2984
2911
 
2985
2912
  const isWebsocketSubscription = (event) => {
2986
- return (Object.values(exports.WebSocketSubscriptionEvent).includes(event?.event) || Object.values(exports.WebSocketMessageEvent).includes(event?.event))
2913
+ return Object.values(exports.WebSocketSubscriptionEvent).includes(event?.event)
2987
2914
  && typeof event?.clientId === 'string' && !!event.clientId;
2988
2915
  };
2989
- // Custom CHANNEL_PUBLISH_MESSAGES
2990
- const isPingWebSocketEventDTO = (event) => {
2991
- return isWebsocketSubscription(event)
2992
- && event?.event === exports.WebSocketMessageEvent.PING;
2993
- };
2994
- const isClientTrackLocationWebSocketEventDTO = (event) => {
2995
- return isWebsocketSubscription(event)
2996
- && event?.event === exports.WebSocketMessageEvent.CLIENT_TRACK_LOCATION;
2997
- };
2998
- const isClientTrackScreenshotWebSocketEventDTO = (event) => {
2999
- return isWebsocketSubscription(event)
3000
- && event?.event === exports.WebSocketMessageEvent.CLIENT_TRACK_SCREENSHOT;
3001
- };
3002
- const isClientTrackDeviceWebSocketEventDTO = (event) => {
3003
- return isWebsocketSubscription(event)
3004
- && event?.event === exports.WebSocketMessageEvent.CLIENT_TRACK_DEVICE;
3005
- };
3006
- const isChatCompletionsWebSocketEventDTO = (event) => {
3007
- return isWebsocketSubscription(event)
3008
- && event?.event === exports.WebSocketMessageEvent.CHAT_COMPLETIONS;
3009
- };
3010
2916
  // CHANNEL_PUBLISH_SUBSCRIPTIONS
3011
- const isSubscribeCodeRunStatusWebSocketEventDTO = (event) => {
2917
+ const isSubscribeCodeRunStatusWebSocketEventDto = (event) => {
3012
2918
  return isWebsocketSubscription(event)
3013
2919
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CODE_RUN_STATUS
3014
2920
  && typeof event?.runId === 'string' && !!event.runId;
3015
2921
  };
3016
- const isUnsubscribeCodeRunStatusWebSocketEventDTO = (event) => {
2922
+ const isUnsubscribeCodeRunStatusWebSocketEventDto = (event) => {
3017
2923
  return isWebsocketSubscription(event)
3018
2924
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CODE_RUN_STATUS
3019
2925
  && typeof event?.runId === 'string' && !!event.runId;
3020
2926
  };
3021
- const isSubscribeSubmissionRunStatusWebSocketEventDTO = (event) => {
2927
+ const isSubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
3022
2928
  return isWebsocketSubscription(event)
3023
2929
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSION_RUN_STATUS
3024
2930
  && typeof event?.submitId === 'string' && !!event.submitId;
3025
2931
  };
3026
- const isUnsubscribeSubmissionRunStatusWebSocketEventDTO = (event) => {
2932
+ const isUnsubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
3027
2933
  return isWebsocketSubscription(event)
3028
2934
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSION_RUN_STATUS
3029
2935
  && typeof event?.submitId === 'string' && !!event.submitId;
3030
2936
  };
3031
- const isSubscribeGetDataWebSocketEventDTO = (event) => {
2937
+ const isSubscribeGetDataWebSocketEventDto = (event) => {
3032
2938
  return isWebsocketSubscription(event)
3033
2939
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_GET_DATA;
3034
2940
  };
3035
- const isUnsubscribeGetDataWebSocketEventDTO = (event) => {
2941
+ const isUnsubscribeGetDataWebSocketEventDto = (event) => {
3036
2942
  return isWebsocketSubscription(event)
3037
2943
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_GET_DATA;
3038
2944
  };
3039
- const isSubscribeProblemCrawledWebSocketEventDTO = (event) => {
2945
+ const isSubscribeProblemCrawledWebSocketEventDto = (event) => {
3040
2946
  return isWebsocketSubscription(event)
3041
2947
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_PROBLEM_CRAWLED;
3042
2948
  };
3043
- const isUnsubscribeProblemCrawledWebSocketEventDTO = (event) => {
2949
+ const isUnsubscribeProblemCrawledWebSocketEventDto = (event) => {
3044
2950
  return isWebsocketSubscription(event)
3045
2951
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_PROBLEM_CRAWLED;
3046
2952
  };
3047
- const isSubscribeSubmissionsCrawlWebSocketEventDTO = (event) => {
2953
+ const isSubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
3048
2954
  return isWebsocketSubscription(event)
3049
2955
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSIONS_CRAWL;
3050
2956
  };
3051
- const isUnsubscribeSubmissionsCrawlWebSocketEventDTO = (event) => {
2957
+ const isUnsubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
3052
2958
  return isWebsocketSubscription(event)
3053
2959
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSIONS_CRAWL;
3054
2960
  };
3055
- const isSubscribeContestChangesWebSocketEventDTO = (event) => {
2961
+ const isSubscribeContestChangesWebSocketEventDto = (event) => {
3056
2962
  return isWebsocketSubscription(event)
3057
2963
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CONTEST_CHANGES;
3058
2964
  };
3059
- const isUnsubscribeContestChangesWebSocketEventDTO = (event) => {
2965
+ const isUnsubscribeContestChangesWebSocketEventDto = (event) => {
3060
2966
  return isWebsocketSubscription(event)
3061
2967
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CONTEST_CHANGES;
3062
2968
  };
3063
- const isSubscribeClientTrackWebSocketEventDTO = (event) => {
3064
- return isWebsocketSubscription(event)
3065
- && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CLIENT_TRACK;
3066
- };
3067
- const isUnsubscribeClientTrackWebSocketEventDTO = (event) => {
3068
- return isWebsocketSubscription(event)
3069
- && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CLIENT_TRACK;
3070
- };
3071
- const isSubscribeUserNotificationWebSocketEventDTO = (event) => {
2969
+ const isSubscribeUserNotificationWebSocketEventDto = (event) => {
3072
2970
  return isWebsocketSubscription(event)
3073
2971
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_USER_NOTIFICATION;
3074
2972
  };
3075
- const isUnsubscribeUserNotificationWebSocketEventDTO = (event) => {
2973
+ const isUnsubscribeUserNotificationWebSocketEventDto = (event) => {
3076
2974
  return isWebsocketSubscription(event)
3077
2975
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_USER_NOTIFICATION;
3078
2976
  };
3079
- const isSubscribeClientTrackDataWebSocketEventDTO = (event) => {
3080
- return isWebsocketSubscription(event)
3081
- && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CLIENT_TRACK_DATA
3082
- && typeof event?.trackedClientId === 'string' && !!event.trackedClientId;
3083
- };
3084
- const isUnsubscribeClientTrackDataWebSocketEventDTO = (event) => {
3085
- return isWebsocketSubscription(event)
3086
- && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CLIENT_TRACK_DATA
3087
- && typeof event?.trackedClientId === 'string' && !!event.trackedClientId;
3088
- };
3089
- // is WebSocketResponseEventDTO, CHANNEL_SUBSCRIBE_CLIENT
3090
- const isWebSocketResponseEventDTO = (event) => {
2977
+ // is WebSocketResponseEventDto, CHANNEL_SUBSCRIBE_CLIENT
2978
+ const isWebSocketResponseEventDto = (event) => {
3091
2979
  return Object.values(exports.WebSocketResponseEvent).includes(event?.event)
3092
2980
  && typeof event?.key === 'string'
3093
2981
  && typeof event?.connectionId === 'string'
3094
- && typeof event?.messageTimestamp === 'number' && !!event.messageTimestamp;
3095
- };
3096
- const isPongWebSocketResponseEventDTO = (event) => {
3097
- return isWebSocketResponseEventDTO(event)
3098
- && event?.event === exports.WebSocketResponseEvent.PONG
3099
- && !!event?.data;
2982
+ && typeof event?.createdAt === 'number' && !!event.createdAt;
3100
2983
  };
3101
- const isCodeRunStatusMessageWebSocketResponseEventDTO = (event) => {
3102
- return isWebSocketResponseEventDTO(event)
2984
+ const isCodeRunStatusMessageWebSocketResponseEventDto = (event) => {
2985
+ return isWebSocketResponseEventDto(event)
3103
2986
  && event?.event === exports.WebSocketResponseEvent.CODE_RUN_STATUS
3104
2987
  && typeof event?.runId === 'string' && !!event.runId
3105
2988
  && event?.status in exports.SubmissionRunStatus;
3106
2989
  };
3107
- const isSubmissionRunStatusMessageWebSocketResponseEventDTO = (event) => {
3108
- return isWebSocketResponseEventDTO(event)
2990
+ const isSubmissionRunStatusMessageWebSocketResponseEventDto = (event) => {
2991
+ return isWebSocketResponseEventDto(event)
3109
2992
  && event?.event === exports.WebSocketResponseEvent.SUBMISSION_RUN_STATUS
3110
2993
  && typeof event?.submitId === 'string' && !!event.submitId
3111
2994
  && event?.status in exports.SubmissionRunStatus
3112
2995
  && event?.verdict in exports.ProblemVerdict
3113
2996
  && typeof event?.points === 'number';
3114
2997
  };
3115
- const isUserMessageWebSocketResponseEventDTO = (event) => {
3116
- return isWebSocketResponseEventDTO(event)
2998
+ const isUserMessageWebSocketResponseEventDto = (event) => {
2999
+ return isWebSocketResponseEventDto(event)
3117
3000
  && event?.event === exports.WebSocketResponseEvent.USER_MESSAGE
3118
3001
  && typeof event?.user?.nickname === 'string' && !!event.user?.nickname
3119
3002
  && typeof event?.user?.imageUrl === 'string' && !!event.user?.imageUrl
3120
- && typeof event?.user?.company?.key === 'string' && !!event.user?.company?.key
3003
+ && typeof event?.user?.organization?.key === 'string' && !!event.user?.organization?.key
3121
3004
  && !!event?.content;
3122
3005
  };
3123
- const isSendDataWebSocketResponseEventDTO = (event) => {
3006
+ const isSendDataWebSocketResponseEventDto = (event) => {
3124
3007
  return [
3125
3008
  exports.WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST,
3126
3009
  exports.WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST,
3127
3010
  exports.WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST,
3128
3011
  exports.WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST,
3129
3012
  exports.WebSocketResponseEvent.SEND_DATA_RUN_COMMAND,
3130
- exports.WebSocketResponseEvent.SEND_DATA_CLIENT_TRACK,
3131
- exports.WebSocketResponseEvent.SEND_DATA_CHAT_COMPLETIONS,
3132
3013
  ].includes(event?.event)
3133
3014
  && typeof event?.dataId === 'string' && !!event.dataId
3134
3015
  && !!event?.content;
3135
3016
  };
3136
- const isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO = (event) => {
3137
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3017
+ const isSendDataEcsTaskDefinitionListWebSocketResponseEventDto = (event) => {
3018
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3138
3019
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST;
3139
3020
  };
3140
- const isSendDataEc2InstancesListWebSocketResponseEventDTO = (event) => {
3141
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3021
+ const isSendDataEc2InstancesListWebSocketResponseEventDto = (event) => {
3022
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3142
3023
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST;
3143
3024
  };
3144
- const isSendDataEcsTasksListWebSocketResponseEventDTO = (event) => {
3145
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3025
+ const isSendDataEcsTasksListWebSocketResponseEventDto = (event) => {
3026
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3146
3027
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST;
3147
3028
  };
3148
- const isSendDataSsmSessionsListWebSocketResponseEventDTO = (event) => {
3149
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3029
+ const isSendDataSsmSessionsListWebSocketResponseEventDto = (event) => {
3030
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3150
3031
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST;
3151
3032
  };
3152
- const isSendDataRunCommandWebSocketResponseEventDTO = (event) => {
3153
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3033
+ const isSendDataRunCommandWebSocketResponseEventDto = (event) => {
3034
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3154
3035
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_RUN_COMMAND;
3155
3036
  };
3156
- const isSendDataClientTrackWebSocketResponseEventDTO = (event) => {
3157
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3158
- && event?.event === exports.WebSocketResponseEvent.SEND_DATA_CLIENT_TRACK;
3159
- };
3160
- const isSenDataChatCompletionsWebSocketResponseEventDTO = (event) => {
3161
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3162
- && event?.event === exports.WebSocketResponseEvent.SEND_DATA_CHAT_COMPLETIONS;
3163
- };
3164
- const isProblemCrawledWebSocketResponseEventDTO = (event) => {
3165
- return isWebSocketResponseEventDTO(event)
3037
+ const isProblemCrawledWebSocketResponseEventDto = (event) => {
3038
+ return isWebSocketResponseEventDto(event)
3166
3039
  && event?.event === exports.WebSocketResponseEvent.PROBLEM_CRAWLED
3167
3040
  && !!event?.content;
3168
3041
  };
3169
- const isSubmissionsCrawlWebSocketResponseEventDTO = (event) => {
3170
- return isWebSocketResponseEventDTO(event)
3042
+ const isSubmissionsCrawlWebSocketResponseEventDto = (event) => {
3043
+ return isWebSocketResponseEventDto(event)
3171
3044
  && event?.event === exports.WebSocketResponseEvent.SUBMISSIONS_CRAWL
3172
3045
  && !!event?.content;
3173
3046
  };
3174
- const isContestChangesWebSocketResponseEventDTO = (event) => {
3175
- return isWebSocketResponseEventDTO(event)
3047
+ const isContestChangesWebSocketResponseEventDto = (event) => {
3048
+ return isWebSocketResponseEventDto(event)
3176
3049
  && event?.event === exports.WebSocketResponseEvent.CONTEST_CHANGES
3177
3050
  && !!event?.content;
3178
3051
  };
3179
- const isClientTrackWebSocketResponseEventDTO = (event) => {
3180
- return isWebSocketResponseEventDTO(event)
3181
- && event?.event === exports.WebSocketResponseEvent.CLIENT_TRACK;
3182
- };
3183
- const isUserNotificationWebSocketResponseEventDTO = (event) => {
3052
+ const isUserNotificationWebSocketResponseEventDto = (event) => {
3184
3053
  return [
3185
3054
  exports.WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION,
3186
3055
  exports.WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION,
3187
3056
  ].includes(event?.event)
3188
3057
  && !!event?.content;
3189
3058
  };
3190
- const isUserNotificationSubmissionWebSocketResponseEventDTO = (event) => {
3191
- return isWebSocketResponseEventDTO(event) && isUserNotificationWebSocketResponseEventDTO(event)
3059
+ const isUserNotificationSubmissionWebSocketResponseEventDto = (event) => {
3060
+ return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3192
3061
  && event?.event === exports.WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION;
3193
3062
  };
3194
- const isUserNotificationContestClarificationWebSocketResponseEventDTO = (event) => {
3195
- return isWebSocketResponseEventDTO(event) && isUserNotificationWebSocketResponseEventDTO(event)
3063
+ const isUserNotificationContestClarificationWebSocketResponseEventDto = (event) => {
3064
+ return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3196
3065
  && event?.event === exports.WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION;
3197
3066
  };
3198
3067
  // generic
3199
3068
  const getWebSocketResponseEventKey = (event, clientId, id) => {
3200
3069
  return `${event}-${clientId}-${id}`;
3201
3070
  };
3202
- const isWebSocketChannelsMessageDTO = (message) => {
3071
+ const isWebSocketChannelsMessageDto = (message) => {
3203
3072
  return Array.isArray(message?.channels)
3204
3073
  && message.channels.every((channel) => typeof channel === 'string' && !!channel)
3205
3074
  && Object.values(exports.WebSocketResponseEvent).includes(message?.event?.event);
3206
3075
  };
3207
3076
  /**
3208
3077
  * Key used by the client to dispatch a response received on a TOPIC channel to its subscribers.
3209
- * It is the same key that `getKeyWebSocketEventDTO` (base-ui) computes for the subscription.
3078
+ * It is the same key that `getKeyWebSocketEventDto` (base-ui) computes for the subscription.
3210
3079
  * Returns null when the response is not addressed to this client.
3211
3080
  */
3212
3081
  const getWebSocketResponseEventKeyOfResponse = (response, clientId) => {
3213
- if (isCodeRunStatusMessageWebSocketResponseEventDTO(response)) {
3082
+ if (isCodeRunStatusMessageWebSocketResponseEventDto(response)) {
3214
3083
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.CODE_RUN_STATUS, clientId, response.runId);
3215
3084
  }
3216
- if (isSubmissionRunStatusMessageWebSocketResponseEventDTO(response)) {
3085
+ if (isSubmissionRunStatusMessageWebSocketResponseEventDto(response)) {
3217
3086
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.SUBMISSION_RUN_STATUS, clientId, response.submitId);
3218
3087
  }
3219
- if (isSendDataWebSocketResponseEventDTO(response)) {
3088
+ if (isSendDataWebSocketResponseEventDto(response)) {
3220
3089
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.SEND_DATA_, clientId, response.dataId);
3221
3090
  }
3222
- if (isContestChangesWebSocketResponseEventDTO(response)) {
3091
+ if (isContestChangesWebSocketResponseEventDto(response)) {
3223
3092
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.CONTEST_CHANGES, clientId, response.content.contestKey);
3224
3093
  }
3225
- if (isProblemCrawledWebSocketResponseEventDTO(response)) {
3094
+ if (isProblemCrawledWebSocketResponseEventDto(response)) {
3226
3095
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.PROBLEM_CRAWLED, clientId, response.content.problemKey);
3227
3096
  }
3228
- if (isSubmissionsCrawlWebSocketResponseEventDTO(response)) {
3097
+ if (isSubmissionsCrawlWebSocketResponseEventDto(response)) {
3229
3098
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.SUBMISSIONS_CRAWL, clientId, join([response.content.contestKey, response.content.problemKeys]));
3230
3099
  }
3231
- if (isClientTrackWebSocketResponseEventDTO(response)) {
3232
- // the command is sent to the session channel, `key` holds the targeted client
3233
- return response.key === clientId ? getWebSocketResponseEventKey(exports.WebSocketResponseEvent.CLIENT_TRACK, clientId, '*') : null;
3234
- }
3235
- if (isUserNotificationWebSocketResponseEventDTO(response)) {
3100
+ if (isUserNotificationWebSocketResponseEventDto(response)) {
3236
3101
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.USER_NOTIFICATION_, clientId, '*');
3237
3102
  }
3238
3103
  return null;
@@ -3243,25 +3108,22 @@ const getWebSocketResponseEventKeyOfResponse = (response, clientId) => {
3243
3108
  * Ably rejects the attach if the token has no capability for the channel.
3244
3109
  */
3245
3110
  const getChannelOfWebSocketSubscribeEvent = (event) => {
3246
- if (isSubscribeSubmissionRunStatusWebSocketEventDTO(event)) {
3111
+ if (isSubscribeSubmissionRunStatusWebSocketEventDto(event)) {
3247
3112
  return CHANNEL_SUBMISSION(event.submitId);
3248
3113
  }
3249
- if (isSubscribeProblemCrawledWebSocketEventDTO(event)) {
3114
+ if (isSubscribeProblemCrawledWebSocketEventDto(event)) {
3250
3115
  return CHANNEL_PROBLEM(event.problemKey);
3251
3116
  }
3252
- if (isSubscribeContestChangesWebSocketEventDTO(event) || isSubscribeSubmissionsCrawlWebSocketEventDTO(event)) {
3117
+ if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3253
3118
  return CHANNEL_CONTEST(event.contestKey, exports.ContestChannelRole.SPECTATORS);
3254
3119
  }
3255
- if (isSubscribeClientTrackDataWebSocketEventDTO(event)) {
3256
- return CHANNEL_CLIENT_TRACK(event.trackedClientId);
3257
- }
3258
3120
  return null;
3259
3121
  };
3260
3122
  /**
3261
3123
  * Contest whose role channels the client needs (the API grants them when the token is requested with this contest).
3262
3124
  */
3263
3125
  const getContestKeyOfWebSocketSubscribeEvent = (event) => {
3264
- if (isSubscribeContestChangesWebSocketEventDTO(event) || isSubscribeSubmissionsCrawlWebSocketEventDTO(event)) {
3126
+ if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3265
3127
  return event.contestKey;
3266
3128
  }
3267
3129
  return null;
@@ -3336,44 +3198,13 @@ function splitTime(timeRemaining) {
3336
3198
  // }
3337
3199
  return remaining;
3338
3200
  }
3339
- function normalizeToLocalStartOfDay(timestamp) {
3340
- const date = new Date(timestamp);
3341
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
3342
- }
3343
- function normalizeToLocalStartOfHour(timestamp) {
3344
- const date = new Date(timestamp);
3345
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours());
3346
- }
3347
- function normalizeToLocalStartOfMinutes(timestamp) {
3348
- const date = new Date(timestamp);
3349
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
3350
- }
3351
- function normalizeToLocalStartOfSeconds(timestamp) {
3352
- const date = new Date(timestamp);
3353
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
3354
- }
3355
- const getYears = (d) => d.getFullYear();
3356
- const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
3357
- const getDays = (d) => {
3358
- return Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
3359
- };
3360
- const getHours = (d) => {
3361
- return Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
3362
- };
3363
- const getMinutes = (d) => {
3364
- return Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
3365
- };
3366
- const getSeconds = (d) => {
3367
- return Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
3368
- };
3369
- const getMilliseconds = (d) => d.getTime();
3370
3201
 
3371
- const getUserKey = (userNickname, userCompanyKey) => {
3372
- return userNickname + '|' + userCompanyKey;
3202
+ const getUserKey = (userNickname, userOrganizationKey) => {
3203
+ return userNickname + '|' + userOrganizationKey;
3373
3204
  };
3374
3205
  const getParamsOfUserKey = (userKey) => {
3375
- const [userNickname, userCompanyKey] = userKey.split('|');
3376
- return { userNickname, userCompanyKey };
3206
+ const [userNickname, userOrganizationKey] = userKey.split('|');
3207
+ return { userNickname, userOrganizationKey };
3377
3208
  };
3378
3209
  const getClientId = (sessionId, uiId) => {
3379
3210
  return `${sessionId}|${uiId}`;
@@ -3493,23 +3324,15 @@ exports.ACCEPTED_PROGRAMMING_LANGUAGES = ACCEPTED_PROGRAMMING_LANGUAGES;
3493
3324
  exports.ASPECT_RATIO = ASPECT_RATIO;
3494
3325
  exports.AssignmentState = AssignmentState;
3495
3326
  exports.AssignmentType = AssignmentType;
3496
- exports.CHANNEL_CLIENT_TRACK = CHANNEL_CLIENT_TRACK;
3497
- exports.CHANNEL_CLIENT_TRACK_ALL = CHANNEL_CLIENT_TRACK_ALL;
3498
- exports.CHANNEL_COMPANY_PRESENCE = CHANNEL_COMPANY_PRESENCE;
3499
3327
  exports.CHANNEL_CONTEST = CHANNEL_CONTEST;
3500
- exports.CHANNEL_PRESENCE_CLIENT = CHANNEL_PRESENCE_CLIENT;
3328
+ exports.CHANNEL_ORGANIZATION_PRESENCE = CHANNEL_ORGANIZATION_PRESENCE;
3501
3329
  exports.CHANNEL_PROBLEM = CHANNEL_PROBLEM;
3502
3330
  exports.CHANNEL_PROBLEM_ALL = CHANNEL_PROBLEM_ALL;
3503
- exports.CHANNEL_PUBLISH_MESSAGES = CHANNEL_PUBLISH_MESSAGES;
3504
- exports.CHANNEL_PUBLISH_SUBSCRIPTIONS = CHANNEL_PUBLISH_SUBSCRIPTIONS;
3505
3331
  exports.CHANNEL_SESSION = CHANNEL_SESSION;
3506
3332
  exports.CHANNEL_SUBMISSION = CHANNEL_SUBMISSION;
3507
3333
  exports.CHANNEL_SUBMISSION_ALL = CHANNEL_SUBMISSION_ALL;
3508
- exports.CHANNEL_SUBSCRIBE_CLIENT = CHANNEL_SUBSCRIBE_CLIENT;
3509
- exports.CHANNEL_SUBSCRIBE_NOTIFICATIONS = CHANNEL_SUBSCRIBE_NOTIFICATIONS;
3510
3334
  exports.CHANNEL_USER = CHANNEL_USER;
3511
3335
  exports.CODE_LANGUAGE = CODE_LANGUAGE;
3512
- exports.COMPANY_PLAN = COMPANY_PLAN;
3513
3336
  exports.CONTEST_ROLE = CONTEST_ROLE;
3514
3337
  exports.CONTEST_STATUS = CONTEST_STATUS;
3515
3338
  exports.COOKIE_JUKI_SESSION_ID = COOKIE_JUKI_SESSION_ID;
@@ -3536,8 +3359,8 @@ exports.HEADER_JUKI_SECRET_TOKEN = HEADER_JUKI_SECRET_TOKEN;
3536
3359
  exports.HEADER_JUKI_VISITOR_SESSION_ID = HEADER_JUKI_VISITOR_SESSION_ID;
3537
3360
  exports.HOURS = HOURS;
3538
3361
  exports.JUDGE = JUDGE;
3539
- exports.JUKI_APP_COMPANY_KEY = JUKI_APP_COMPANY_KEY;
3540
3362
  exports.JUKI_APP_EMAIL_TEMPLATE = JUKI_APP_EMAIL_TEMPLATE;
3363
+ exports.JUKI_APP_ORGANIZATION_KEY = JUKI_APP_ORGANIZATION_KEY;
3541
3364
  exports.JkError = JkError;
3542
3365
  exports.LANGUAGE = LANGUAGE;
3543
3366
  exports.LOWERCASE_LETTERS = LOWERCASE_LETTERS;
@@ -3556,6 +3379,7 @@ exports.ONE_HOUR = ONE_HOUR;
3556
3379
  exports.ONE_MINUTE = ONE_MINUTE;
3557
3380
  exports.ONE_SECOND = ONE_SECOND;
3558
3381
  exports.ONE_WEEK = ONE_WEEK;
3382
+ exports.ORGANIZATION_PLAN = ORGANIZATION_PLAN;
3559
3383
  exports.PAGE = PAGE;
3560
3384
  exports.PAGE_SIZE = PAGE_SIZE;
3561
3385
  exports.PAGE_SIZES = PAGE_SIZES;
@@ -3601,6 +3425,13 @@ exports._SUB_TAB = _SUB_TAB;
3601
3425
  exports._TAB = _TAB;
3602
3426
  exports._TYPE = _TYPE;
3603
3427
  exports.areArraysDifferent = areArraysDifferent;
3428
+ exports.changeDay = changeDay;
3429
+ exports.changeHours = changeHours;
3430
+ exports.changeMilliseconds = changeMilliseconds;
3431
+ exports.changeMinutes = changeMinutes;
3432
+ exports.changeMonth = changeMonth;
3433
+ exports.changeSeconds = changeSeconds;
3434
+ exports.changeYear = changeYear;
3604
3435
  exports.chunkString = chunkString;
3605
3436
  exports.cleanRequest = cleanRequest;
3606
3437
  exports.clearAsyncInterval = clearAsyncInterval;
@@ -3609,6 +3440,16 @@ exports.consoleInfo = consoleInfo;
3609
3440
  exports.consoleWarn = consoleWarn;
3610
3441
  exports.contentResponse = contentResponse;
3611
3442
  exports.contentsResponse = contentsResponse;
3443
+ exports.decreaseDay = decreaseDay;
3444
+ exports.decreaseMonth = decreaseMonth;
3445
+ exports.decreaseYear = decreaseYear;
3446
+ exports.endOfDay = endOfDay;
3447
+ exports.endOfHour = endOfHour;
3448
+ exports.endOfMinute = endOfMinute;
3449
+ exports.endOfMonth = endOfMonth;
3450
+ exports.endOfSecond = endOfSecond;
3451
+ exports.endOfWeek = endOfWeek;
3452
+ exports.endOfYear = endOfYear;
3612
3453
  exports.errorsResponse = errorsResponse;
3613
3454
  exports.getAssignmentCommentKey = getAssignmentCommentKey;
3614
3455
  exports.getAssignmentUserCommentKey = getAssignmentUserCommentKey;
@@ -3642,69 +3483,86 @@ exports.getWebSocketResponseEventKeyOfResponse = getWebSocketResponseEventKeyOfR
3642
3483
  exports.getWorksheetsInPages = getWorksheetsInPages;
3643
3484
  exports.getYears = getYears;
3644
3485
  exports.humanFileSize = humanFileSize;
3486
+ exports.increaseDay = increaseDay;
3487
+ exports.increaseMonth = increaseMonth;
3488
+ exports.increaseYear = increaseYear;
3645
3489
  exports.indexToLetters = indexToLetters;
3490
+ exports.isAfter = isAfter;
3646
3491
  exports.isBasicWorksheet = isBasicWorksheet;
3647
- exports.isChatCompletionsWebSocketEventDTO = isChatCompletionsWebSocketEventDTO;
3648
- exports.isClientTrackDeviceWebSocketEventDTO = isClientTrackDeviceWebSocketEventDTO;
3649
- exports.isClientTrackLocationWebSocketEventDTO = isClientTrackLocationWebSocketEventDTO;
3650
- exports.isClientTrackScreenshotWebSocketEventDTO = isClientTrackScreenshotWebSocketEventDTO;
3651
- exports.isClientTrackWebSocketResponseEventDTO = isClientTrackWebSocketResponseEventDTO;
3492
+ exports.isBefore = isBefore;
3652
3493
  exports.isCodeEditorSheet = isCodeEditorSheet;
3653
- exports.isCodeRunStatusMessageWebSocketResponseEventDTO = isCodeRunStatusMessageWebSocketResponseEventDTO;
3494
+ exports.isCodeRunStatusMessageWebSocketResponseEventDto = isCodeRunStatusMessageWebSocketResponseEventDto;
3654
3495
  exports.isContestAssignment = isContestAssignment;
3655
- exports.isContestChangesWebSocketResponseEventDTO = isContestChangesWebSocketResponseEventDTO;
3496
+ exports.isContestChangesWebSocketResponseEventDto = isContestChangesWebSocketResponseEventDto;
3656
3497
  exports.isCourseAssignment = isCourseAssignment;
3498
+ exports.isDayAfter = isDayAfter;
3499
+ exports.isDayBefore = isDayBefore;
3657
3500
  exports.isEndlessContest = isEndlessContest;
3501
+ exports.isEqual = isEqual;
3658
3502
  exports.isFutureContest = isFutureContest;
3659
3503
  exports.isGlobalContest = isGlobalContest;
3504
+ exports.isHoursAfter = isHoursAfter;
3505
+ exports.isHoursBefore = isHoursBefore;
3660
3506
  exports.isJkmdSheet = isJkmdSheet;
3507
+ exports.isMillisecondsAfter = isMillisecondsAfter;
3508
+ exports.isMillisecondsBefore = isMillisecondsBefore;
3509
+ exports.isMinutesAfter = isMinutesAfter;
3510
+ exports.isMinutesBefore = isMinutesBefore;
3511
+ exports.isMonthAfter = isMonthAfter;
3512
+ exports.isMonthBefore = isMonthBefore;
3661
3513
  exports.isObjectJson = isObjectJson;
3662
3514
  exports.isPastContest = isPastContest;
3663
- exports.isPingWebSocketEventDTO = isPingWebSocketEventDTO;
3664
- exports.isPongWebSocketResponseEventDTO = isPongWebSocketResponseEventDTO;
3665
- exports.isProblemCrawledWebSocketResponseEventDTO = isProblemCrawledWebSocketResponseEventDTO;
3515
+ exports.isProblemCrawledWebSocketResponseEventDto = isProblemCrawledWebSocketResponseEventDto;
3666
3516
  exports.isQuizOptionsSheet = isQuizOptionsSheet;
3667
3517
  exports.isQuizProblemSheet = isQuizProblemSheet;
3668
3518
  exports.isQuizTextSheet = isQuizTextSheet;
3669
- exports.isSenDataChatCompletionsWebSocketResponseEventDTO = isSenDataChatCompletionsWebSocketResponseEventDTO;
3670
- exports.isSendDataClientTrackWebSocketResponseEventDTO = isSendDataClientTrackWebSocketResponseEventDTO;
3671
- exports.isSendDataEc2InstancesListWebSocketResponseEventDTO = isSendDataEc2InstancesListWebSocketResponseEventDTO;
3672
- exports.isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO = isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO;
3673
- exports.isSendDataEcsTasksListWebSocketResponseEventDTO = isSendDataEcsTasksListWebSocketResponseEventDTO;
3674
- exports.isSendDataRunCommandWebSocketResponseEventDTO = isSendDataRunCommandWebSocketResponseEventDTO;
3675
- exports.isSendDataSsmSessionsListWebSocketResponseEventDTO = isSendDataSsmSessionsListWebSocketResponseEventDTO;
3676
- exports.isSendDataWebSocketResponseEventDTO = isSendDataWebSocketResponseEventDTO;
3519
+ exports.isSameDay = isSameDay;
3520
+ exports.isSameHour = isSameHour;
3521
+ exports.isSameMillisecond = isSameMillisecond;
3522
+ exports.isSameMinute = isSameMinute;
3523
+ exports.isSameMonth = isSameMonth;
3524
+ exports.isSameSecond = isSameSecond;
3525
+ exports.isSameYear = isSameYear;
3526
+ exports.isSecondsAfter = isSecondsAfter;
3527
+ exports.isSecondsBefore = isSecondsBefore;
3528
+ exports.isSendDataEc2InstancesListWebSocketResponseEventDto = isSendDataEc2InstancesListWebSocketResponseEventDto;
3529
+ exports.isSendDataEcsTaskDefinitionListWebSocketResponseEventDto = isSendDataEcsTaskDefinitionListWebSocketResponseEventDto;
3530
+ exports.isSendDataEcsTasksListWebSocketResponseEventDto = isSendDataEcsTasksListWebSocketResponseEventDto;
3531
+ exports.isSendDataRunCommandWebSocketResponseEventDto = isSendDataRunCommandWebSocketResponseEventDto;
3532
+ exports.isSendDataSsmSessionsListWebSocketResponseEventDto = isSendDataSsmSessionsListWebSocketResponseEventDto;
3533
+ exports.isSendDataWebSocketResponseEventDto = isSendDataWebSocketResponseEventDto;
3677
3534
  exports.isStringJson = isStringJson;
3678
- exports.isSubmissionRunStatusMessageWebSocketResponseEventDTO = isSubmissionRunStatusMessageWebSocketResponseEventDTO;
3679
- exports.isSubmissionsCrawlWebSocketResponseEventDTO = isSubmissionsCrawlWebSocketResponseEventDTO;
3680
- exports.isSubscribeClientTrackDataWebSocketEventDTO = isSubscribeClientTrackDataWebSocketEventDTO;
3681
- exports.isSubscribeClientTrackWebSocketEventDTO = isSubscribeClientTrackWebSocketEventDTO;
3682
- exports.isSubscribeCodeRunStatusWebSocketEventDTO = isSubscribeCodeRunStatusWebSocketEventDTO;
3683
- exports.isSubscribeContestChangesWebSocketEventDTO = isSubscribeContestChangesWebSocketEventDTO;
3684
- exports.isSubscribeGetDataWebSocketEventDTO = isSubscribeGetDataWebSocketEventDTO;
3685
- exports.isSubscribeProblemCrawledWebSocketEventDTO = isSubscribeProblemCrawledWebSocketEventDTO;
3686
- exports.isSubscribeSubmissionRunStatusWebSocketEventDTO = isSubscribeSubmissionRunStatusWebSocketEventDTO;
3687
- exports.isSubscribeSubmissionsCrawlWebSocketEventDTO = isSubscribeSubmissionsCrawlWebSocketEventDTO;
3688
- exports.isSubscribeUserNotificationWebSocketEventDTO = isSubscribeUserNotificationWebSocketEventDTO;
3535
+ exports.isSubmissionRunStatusMessageWebSocketResponseEventDto = isSubmissionRunStatusMessageWebSocketResponseEventDto;
3536
+ exports.isSubmissionsCrawlWebSocketResponseEventDto = isSubmissionsCrawlWebSocketResponseEventDto;
3537
+ exports.isSubscribeCodeRunStatusWebSocketEventDto = isSubscribeCodeRunStatusWebSocketEventDto;
3538
+ exports.isSubscribeContestChangesWebSocketEventDto = isSubscribeContestChangesWebSocketEventDto;
3539
+ exports.isSubscribeGetDataWebSocketEventDto = isSubscribeGetDataWebSocketEventDto;
3540
+ exports.isSubscribeProblemCrawledWebSocketEventDto = isSubscribeProblemCrawledWebSocketEventDto;
3541
+ exports.isSubscribeSubmissionRunStatusWebSocketEventDto = isSubscribeSubmissionRunStatusWebSocketEventDto;
3542
+ exports.isSubscribeSubmissionsCrawlWebSocketEventDto = isSubscribeSubmissionsCrawlWebSocketEventDto;
3543
+ exports.isSubscribeUserNotificationWebSocketEventDto = isSubscribeUserNotificationWebSocketEventDto;
3689
3544
  exports.isTeamMember = isTeamMember;
3690
- exports.isUnsubscribeClientTrackDataWebSocketEventDTO = isUnsubscribeClientTrackDataWebSocketEventDTO;
3691
- exports.isUnsubscribeClientTrackWebSocketEventDTO = isUnsubscribeClientTrackWebSocketEventDTO;
3692
- exports.isUnsubscribeCodeRunStatusWebSocketEventDTO = isUnsubscribeCodeRunStatusWebSocketEventDTO;
3693
- exports.isUnsubscribeContestChangesWebSocketEventDTO = isUnsubscribeContestChangesWebSocketEventDTO;
3694
- exports.isUnsubscribeGetDataWebSocketEventDTO = isUnsubscribeGetDataWebSocketEventDTO;
3695
- exports.isUnsubscribeProblemCrawledWebSocketEventDTO = isUnsubscribeProblemCrawledWebSocketEventDTO;
3696
- exports.isUnsubscribeSubmissionRunStatusWebSocketEventDTO = isUnsubscribeSubmissionRunStatusWebSocketEventDTO;
3697
- exports.isUnsubscribeSubmissionsCrawlWebSocketEventDTO = isUnsubscribeSubmissionsCrawlWebSocketEventDTO;
3698
- exports.isUnsubscribeUserNotificationWebSocketEventDTO = isUnsubscribeUserNotificationWebSocketEventDTO;
3545
+ exports.isToday = isToday;
3546
+ exports.isUnsubscribeCodeRunStatusWebSocketEventDto = isUnsubscribeCodeRunStatusWebSocketEventDto;
3547
+ exports.isUnsubscribeContestChangesWebSocketEventDto = isUnsubscribeContestChangesWebSocketEventDto;
3548
+ exports.isUnsubscribeGetDataWebSocketEventDto = isUnsubscribeGetDataWebSocketEventDto;
3549
+ exports.isUnsubscribeProblemCrawledWebSocketEventDto = isUnsubscribeProblemCrawledWebSocketEventDto;
3550
+ exports.isUnsubscribeSubmissionRunStatusWebSocketEventDto = isUnsubscribeSubmissionRunStatusWebSocketEventDto;
3551
+ exports.isUnsubscribeSubmissionsCrawlWebSocketEventDto = isUnsubscribeSubmissionsCrawlWebSocketEventDto;
3552
+ exports.isUnsubscribeUserNotificationWebSocketEventDto = isUnsubscribeUserNotificationWebSocketEventDto;
3699
3553
  exports.isUserMember = isUserMember;
3700
- exports.isUserMessageWebSocketResponseEventDTO = isUserMessageWebSocketResponseEventDTO;
3701
- exports.isUserNotificationContestClarificationWebSocketResponseEventDTO = isUserNotificationContestClarificationWebSocketResponseEventDTO;
3702
- exports.isUserNotificationSubmissionWebSocketResponseEventDTO = isUserNotificationSubmissionWebSocketResponseEventDTO;
3703
- exports.isUserNotificationWebSocketResponseEventDTO = isUserNotificationWebSocketResponseEventDTO;
3704
- exports.isWebSocketChannelsMessageDTO = isWebSocketChannelsMessageDTO;
3705
- exports.isWebSocketResponseEventDTO = isWebSocketResponseEventDTO;
3554
+ exports.isUserMessageWebSocketResponseEventDto = isUserMessageWebSocketResponseEventDto;
3555
+ exports.isUserNotificationContestClarificationWebSocketResponseEventDto = isUserNotificationContestClarificationWebSocketResponseEventDto;
3556
+ exports.isUserNotificationSubmissionWebSocketResponseEventDto = isUserNotificationSubmissionWebSocketResponseEventDto;
3557
+ exports.isUserNotificationWebSocketResponseEventDto = isUserNotificationWebSocketResponseEventDto;
3558
+ exports.isValidDate = isValidDate;
3559
+ exports.isWebSocketChannelsMessageDto = isWebSocketChannelsMessageDto;
3560
+ exports.isWebSocketResponseEventDto = isWebSocketResponseEventDto;
3706
3561
  exports.isWebsocketSubscription = isWebsocketSubscription;
3562
+ exports.isWithinInterval = isWithinInterval;
3707
3563
  exports.isWorksheetAssignment = isWorksheetAssignment;
3564
+ exports.isYearAfter = isYearAfter;
3565
+ exports.isYearBefore = isYearBefore;
3708
3566
  exports.join = join;
3709
3567
  exports.lettersToIndex = lettersToIndex;
3710
3568
  exports.memorySizeOf = memorySizeOf;
@@ -3716,12 +3574,21 @@ exports.normalizeToLocalStartOfMinutes = normalizeToLocalStartOfMinutes;
3716
3574
  exports.normalizeToLocalStartOfSeconds = normalizeToLocalStartOfSeconds;
3717
3575
  exports.objectUpdate = objectUpdate;
3718
3576
  exports.objectsUpdate = objectsUpdate;
3577
+ exports.padEnd = padEnd;
3578
+ exports.padStart = padStart;
3719
3579
  exports.range = range;
3720
3580
  exports.removeExtension = removeExtension;
3721
3581
  exports.safeJsonParse = safeJsonParse;
3722
3582
  exports.setAsyncInterval = setAsyncInterval;
3723
3583
  exports.split = split;
3724
3584
  exports.splitTime = splitTime;
3585
+ exports.startOfDay = startOfDay;
3586
+ exports.startOfHour = startOfHour;
3587
+ exports.startOfMinute = startOfMinute;
3588
+ exports.startOfMonth = startOfMonth;
3589
+ exports.startOfSecond = startOfSecond;
3590
+ exports.startOfWeek = startOfWeek;
3591
+ exports.startOfYear = startOfYear;
3725
3592
  exports.stringToArrayBuffer = stringToArrayBuffer;
3726
- exports.toEntityMembersDTO = toEntityMembersDTO;
3593
+ exports.toEntityMembersDto = toEntityMembersDto;
3727
3594
  exports.toJkError = toJkError;