@juki-team/commons 0.1.42 → 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 +419 -534
  2. package/dist/esm/index.js +329 -481
  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 +10 -10
  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 +50 -124
  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 +16 -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,10 @@ 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 = {}));
577
+ /**
578
+ * Subscriptions of the client. With the TOPIC channels they are not sent to the server anymore:
579
+ * they only say which channel the client attaches (`getChannelOfWebSocketSubscribeEvent`) and the dispatch key.
580
+ */
585
581
  exports.WebSocketSubscriptionEvent = void 0;
586
582
  (function (WebSocketSubscriptionEvent) {
587
583
  WebSocketSubscriptionEvent["SUBSCRIBE_CODE_RUN_STATUS"] = "SUBSCRIBE_CODE_RUN_STATUS";
@@ -596,17 +592,11 @@ exports.WebSocketSubscriptionEvent = void 0;
596
592
  WebSocketSubscriptionEvent["UNSUBSCRIBE_SUBMISSIONS_CRAWL"] = "UNSUBSCRIBE_SUBMISSIONS_CRAWL";
597
593
  WebSocketSubscriptionEvent["SUBSCRIBE_CONTEST_CHANGES"] = "SUBSCRIBE_CONTEST_CHANGES";
598
594
  WebSocketSubscriptionEvent["UNSUBSCRIBE_CONTEST_CHANGES"] = "UNSUBSCRIBE_CONTEST_CHANGES";
599
- WebSocketSubscriptionEvent["SUBSCRIBE_CLIENT_TRACK"] = "SUBSCRIBE_CLIENT_TRACK";
600
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CLIENT_TRACK"] = "UNSUBSCRIBE_CLIENT_TRACK";
601
595
  WebSocketSubscriptionEvent["SUBSCRIBE_USER_NOTIFICATION"] = "SUBSCRIBE_USER_NOTIFICATION";
602
596
  WebSocketSubscriptionEvent["UNSUBSCRIBE_USER_NOTIFICATION"] = "UNSUBSCRIBE_USER_NOTIFICATION";
603
- // an administrator watching the data (screenshots, location, device) sent by another client
604
- WebSocketSubscriptionEvent["SUBSCRIBE_CLIENT_TRACK_DATA"] = "SUBSCRIBE_CLIENT_TRACK_DATA";
605
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CLIENT_TRACK_DATA"] = "UNSUBSCRIBE_CLIENT_TRACK_DATA";
606
597
  })(exports.WebSocketSubscriptionEvent || (exports.WebSocketSubscriptionEvent = {}));
607
598
  exports.WebSocketResponseEvent = void 0;
608
599
  (function (WebSocketResponseEvent) {
609
- WebSocketResponseEvent["PONG"] = "PONG";
610
600
  WebSocketResponseEvent["CODE_RUN_STATUS"] = "CODE_RUN_STATUS";
611
601
  WebSocketResponseEvent["SUBMISSION_RUN_STATUS"] = "SUBMISSION_RUN_STATUS";
612
602
  WebSocketResponseEvent["USER_MESSAGE"] = "USER_MESSAGE";
@@ -616,12 +606,9 @@ exports.WebSocketResponseEvent = void 0;
616
606
  WebSocketResponseEvent["SEND_DATA_EC2_INSTANCES_LIST"] = "SEND_DATA_EC2_INSTANCES_LIST";
617
607
  WebSocketResponseEvent["SEND_DATA_SSM_SESSIONS_LIST"] = "SEND_DATA_SSM_SESSIONS_LIST";
618
608
  WebSocketResponseEvent["SEND_DATA_RUN_COMMAND"] = "SEND_DATA_RUN_COMMAND";
619
- WebSocketResponseEvent["SEND_DATA_CLIENT_TRACK"] = "SEND_DATA_CLIENT_TRACK";
620
- WebSocketResponseEvent["SEND_DATA_CHAT_COMPLETIONS"] = "SEND_DATA_CHAT_COMPLETIONS";
621
609
  WebSocketResponseEvent["PROBLEM_CRAWLED"] = "PROBLEM_CRAWLED";
622
610
  WebSocketResponseEvent["SUBMISSIONS_CRAWL"] = "SUBMISSIONS_CRAWL";
623
611
  WebSocketResponseEvent["CONTEST_CHANGES"] = "CONTEST_CHANGES";
624
- WebSocketResponseEvent["CLIENT_TRACK"] = "CLIENT_TRACK";
625
612
  WebSocketResponseEvent["USER_NOTIFICATION_"] = "USER_NOTIFICATION_";
626
613
  WebSocketResponseEvent["USER_NOTIFICATION_SUBMISSION"] = "USER_NOTIFICATION_SUBMISSION";
627
614
  WebSocketResponseEvent["USER_NOTIFICATION_CONTEST_CLARIFICATION"] = "USER_NOTIFICATION_CONTEST_CLARIFICATION";
@@ -1333,25 +1320,25 @@ const HEADER_JUKI_SECRET_TOKEN = 'x-juki-secret-token';
1333
1320
  const HEADER_JUKI_INTERNAL_API_KEY = 'x-juki-internal-api-key';
1334
1321
  const COOKIE_JUKI_SESSION_ID = 'juki-session-id';
1335
1322
 
1336
- const JUKI_APP_COMPANY_KEY = 'juki-app';
1337
- const COMPANY_PLAN = {
1338
- [exports.CompanyPlan.FREE]: {
1339
- 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,
1340
1327
  label: 'free',
1341
1328
  description: 'the resources, runners and compilers, are shared with the juki.app giving priority to juki.app',
1342
1329
  },
1343
- [exports.CompanyPlan.STANDARD]: {
1344
- value: exports.CompanyPlan.STANDARD,
1330
+ [exports.OrganizationPlan.STANDARD]: {
1331
+ value: exports.OrganizationPlan.STANDARD,
1345
1332
  label: 'standard',
1346
1333
  description: 'the resources are dedicated, 1 runner and 1 compiler',
1347
1334
  },
1348
- [exports.CompanyPlan.PREMIUM]: {
1349
- value: exports.CompanyPlan.PREMIUM,
1335
+ [exports.OrganizationPlan.PREMIUM]: {
1336
+ value: exports.OrganizationPlan.PREMIUM,
1350
1337
  label: 'premium',
1351
1338
  description: 'the resources are dedicated and on demand use with at least 1 runner and 1 compiler',
1352
1339
  },
1353
- [exports.CompanyPlan.CUSTOM]: {
1354
- value: exports.CompanyPlan.CUSTOM,
1340
+ [exports.OrganizationPlan.CUSTOM]: {
1341
+ value: exports.OrganizationPlan.CUSTOM,
1355
1342
  label: 'custom',
1356
1343
  description: 'the resources are dedicated and on demand use with at least 1 (settable) runner and 1 (settable) compiler',
1357
1344
  },
@@ -1974,18 +1961,18 @@ const ERROR = {
1974
1961
  [exports.ErrorCode.ERR9997]: { value: exports.ErrorCode.ERR9997, message: 'aborted request', status: 400 },
1975
1962
  [exports.ErrorCode.ERR9998]: { value: exports.ErrorCode.ERR9998, message: 'error on response', status: 400 },
1976
1963
  [exports.ErrorCode.ERR9999]: { value: exports.ErrorCode.ERR9999, message: 'service no found', status: 400 },
1977
- // COMPANY ERRORS ERR99XX
1978
- [exports.ErrorCode.ERR9900]: { value: exports.ErrorCode.ERR9900, message: 'internal server error on company service', status: 500 },
1979
- // Company server errors
1980
- [exports.ErrorCode.ERR9910]: { value: exports.ErrorCode.ERR9910, message: 'company not created', status: 500 },
1981
- [exports.ErrorCode.ERR9911]: { value: exports.ErrorCode.ERR9911, message: 'company not found', status: 500 },
1982
- [exports.ErrorCode.ERR9912]: { value: exports.ErrorCode.ERR9912, message: 'company not updated', status: 500 },
1983
- [exports.ErrorCode.ERR9913]: { value: exports.ErrorCode.ERR9913, message: 'company not deleted', status: 500 },
1984
- // Company user permission error
1985
- [exports.ErrorCode.ERR9914]: { value: exports.ErrorCode.ERR9914, message: 'not allowed to create the company', status: 400 },
1986
- [exports.ErrorCode.ERR9915]: { value: exports.ErrorCode.ERR9915, message: 'not allowed to view the company', status: 400 },
1987
- [exports.ErrorCode.ERR9916]: { value: exports.ErrorCode.ERR9916, message: 'not allowed to updated the company', status: 400 },
1988
- [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 },
1989
1976
  // USER ERRORS ERR00XX
1990
1977
  [exports.ErrorCode.ERR0000]: { value: exports.ErrorCode.ERR0000, message: 'internal server error on users service', status: 500 },
1991
1978
  // User server errors
@@ -2231,7 +2218,7 @@ const EMPTY_USER_PERMISSIONS = {
2231
2218
  create: false,
2232
2219
  manage: false,
2233
2220
  },
2234
- company: {
2221
+ organization: {
2235
2222
  manage: false,
2236
2223
  administrate: false,
2237
2224
  },
@@ -2240,18 +2227,12 @@ const EMPTY_USER_PERMISSIONS = {
2240
2227
  },
2241
2228
  };
2242
2229
 
2243
- // LEGACY channels (fan-out per client through the subscriptions registry in Redis)
2244
- const CHANNEL_PUBLISH_SUBSCRIPTIONS = 'pub:subscriptions';
2245
- const CHANNEL_SUBSCRIBE_NOTIFICATIONS = 'sub:notifications';
2246
- const CHANNEL_SUBSCRIBE_CLIENT = (clientId) => `sub:client:${clientId}`;
2247
- const CHANNEL_PUBLISH_MESSAGES = 'pub:messages';
2248
- const CHANNEL_PRESENCE_CLIENT = 'pre:client';
2249
2230
  // TOPIC channels
2250
2231
  // The backend publishes each event once on the channel of its topic and Ably does the fan-out.
2251
2232
  // Who can subscribe to each channel is decided by the API in the Ably token (capability), never by the client.
2252
2233
  // Dynamic segments are encoded so a key can never inject a `:` (the Ably segment separator used by the wildcards).
2253
2234
  const segment = (value) => encodeURIComponent(value);
2254
- /** private: events of one session (code runs, requested data, client track commands) */
2235
+ /** private: events of one session (code runs, requested data) */
2255
2236
  const CHANNEL_SESSION = (sessionId) => `session:${segment(sessionId)}`;
2256
2237
  /** private: events of one user (own submissions while the contest is frozen, notifications) */
2257
2238
  const CHANNEL_USER = (userId) => `user:${segment(userId)}`;
@@ -2261,12 +2242,17 @@ const CHANNEL_SUBMISSION = (submitId) => `submission:${segment(submitId)}`;
2261
2242
  const CHANNEL_PROBLEM = (problemKey) => `problem:${segment(problemKey)}`;
2262
2243
  /** per role: events of a contest for one role (and the roles above it, see `ContestChannelRole`) */
2263
2244
  const CHANNEL_CONTEST = (contestKey, role) => `contest:${segment(contestKey)}:${role}`;
2264
- /** system administrators only: data sent by a tracked client (screenshots, location, device) */
2265
- const CHANNEL_CLIENT_TRACK = (trackedClientId) => `client-track:${segment(trackedClientId)}`;
2245
+ /**
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
2248
+ * (capability `presence-subscribe`). Ably limits the presence members per channel (200 by default,
2249
+ * more with server-side batching enabled on the `presence` namespace).
2250
+ * The identity of a member is its `clientId` (`sessionId|uiId`, verified by Ably), never its data.
2251
+ */
2252
+ const CHANNEL_ORGANIZATION_PRESENCE = (organizationKey) => `presence:organization:${segment(organizationKey)}`;
2266
2253
  // capability resources (wildcards) of the public channels
2267
2254
  const CHANNEL_SUBMISSION_ALL = 'submission:*';
2268
2255
  const CHANNEL_PROBLEM_ALL = 'problem:*';
2269
- const CHANNEL_CLIENT_TRACK_ALL = 'client-track:*';
2270
2256
  /**
2271
2257
  * Returns the contest and role of a `CHANNEL_CONTEST` channel name, or null if it is not one.
2272
2258
  */
@@ -2368,31 +2354,212 @@ const isContestAssignment = (assignment) => {
2368
2354
  };
2369
2355
 
2370
2356
  const getAssignmentCommentKey = (classKey, cycleKey, sessionKey, assignmentKey) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}`;
2371
- 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}`;
2372
2358
  const getProblemCommentKey = (problemKey) => `problem:${problemKey}`;
2373
2359
  const getContestCommentKey = (contestKey) => `contest:${contestKey}`;
2374
2360
 
2375
2361
  const isEndlessContest = (settings) => {
2376
- return settings?.startTimestamp === MIN_DATE.getTime()
2377
- && settings?.frozenTimestamp === MAX_DATE.getTime()
2378
- && settings?.quietTimestamp === MAX_DATE.getTime()
2379
- && 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()
2380
2366
  && settings?.penalty === 0;
2381
2367
  };
2382
2368
  const isGlobalContest = (settings) => {
2383
- return settings?.startTimestamp === 0
2384
- && settings?.frozenTimestamp === 0
2385
- && settings?.quietTimestamp === 0
2386
- && settings?.endTimestamp === 0
2369
+ return settings?.startsAt === 0
2370
+ && settings?.frozenAt === 0
2371
+ && settings?.silencedAt === 0
2372
+ && settings?.endsAt === 0
2387
2373
  && settings?.penalty === 0;
2388
2374
  };
2389
2375
  const isPastContest = (settings) => {
2390
- return Date.now() > (settings?.endTimestamp ?? 0);
2376
+ return Date.now() > (settings?.endsAt ?? 0);
2391
2377
  };
2392
2378
  const isFutureContest = (settings) => {
2393
- return (settings?.startTimestamp ?? 0) > Date.now();
2379
+ return (settings?.startsAt ?? 0) > Date.now();
2394
2380
  };
2395
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
+
2396
2563
  const getDocumentAccess = (document) => {
2397
2564
  switch (true) {
2398
2565
  case (document?.members?.rankAdministrators === exports.EntityMembersRank.NONE || document?.members?.rankAdministrators === exports.EntityMembersRank.CLOSE)
@@ -2429,7 +2596,7 @@ const isUserMember = (member) => {
2429
2596
  const isTeamMember = (member) => {
2430
2597
  return typeof member.teamId === 'string';
2431
2598
  };
2432
- const toEntityMembersDTO = (members) => {
2599
+ const toEntityMembersDto = (members) => {
2433
2600
  return {
2434
2601
  rankAdministrators: members.rankAdministrators,
2435
2602
  administrators: Object.keys(members.administrators),
@@ -2444,6 +2611,21 @@ const toEntityMembersDTO = (members) => {
2444
2611
  };
2445
2612
  };
2446
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
+
2447
2629
  function removeExtension(fileName) {
2448
2630
  const i = fileName.lastIndexOf('.');
2449
2631
  return i !== -1 ? fileName.substring(0, i) : fileName;
@@ -2598,6 +2780,9 @@ const getDataLog = (log) => {
2598
2780
  };
2599
2781
  };
2600
2782
 
2783
+ const padStart = (n, maxLength, fillString = '0') => `${n}`.padStart(maxLength, fillString);
2784
+ const padEnd = (n, maxLength, fillString = '0') => `${n}`.padEnd(maxLength, fillString);
2785
+
2601
2786
  function memorySizeOf(obj) {
2602
2787
  let bytes = 0;
2603
2788
  function sizeOf(obj) {
@@ -2632,247 +2817,6 @@ function memorySizeOf(obj) {
2632
2817
  return sizeOf(obj);
2633
2818
  }
2634
2819
 
2635
- /* eslint-disable no-extend-native */
2636
- Date.prototype.changeYear = function (year) {
2637
- const newDate = new Date(this);
2638
- newDate.setFullYear(year);
2639
- return newDate;
2640
- };
2641
- Date.prototype.changeMonth = function (monthIndex) {
2642
- const newDate = new Date(this);
2643
- newDate.setMonth(monthIndex);
2644
- return newDate;
2645
- };
2646
- Date.prototype.changeDay = function (date) {
2647
- const newDate = new Date(this);
2648
- newDate.setDate(date);
2649
- return newDate;
2650
- };
2651
- Date.prototype.changeHours = function (hours) {
2652
- const newDate = new Date(this);
2653
- newDate.setHours(hours);
2654
- return newDate;
2655
- };
2656
- Date.prototype.changeMinutes = function (minutes) {
2657
- const newDate = new Date(this);
2658
- newDate.setMinutes(minutes);
2659
- return newDate;
2660
- };
2661
- Date.prototype.changeSeconds = function (seconds) {
2662
- const newDate = new Date(this);
2663
- newDate.setSeconds(seconds);
2664
- return newDate;
2665
- };
2666
- Date.prototype.changeMilliseconds = function (milliseconds) {
2667
- const newDate = new Date(this);
2668
- newDate.setMilliseconds(milliseconds);
2669
- return newDate;
2670
- };
2671
- Date.prototype.decreaseYear = function (count = 1) {
2672
- return this.changeYear(this.getFullYear() - count);
2673
- };
2674
- Date.prototype.increaseYear = function (count = 1) {
2675
- return this.changeYear(this.getFullYear() + count);
2676
- };
2677
- Date.prototype.decreaseMonth = function () {
2678
- const newDate = new Date(this);
2679
- newDate.setMonth(newDate.getMonth() - 1);
2680
- return newDate;
2681
- };
2682
- Date.prototype.increaseMonth = function () {
2683
- const newDate = new Date(this);
2684
- newDate.setMonth(newDate.getMonth() + 1);
2685
- return newDate;
2686
- };
2687
- Date.prototype.increaseDay = function () {
2688
- const newDate = new Date(this);
2689
- newDate.setDate(newDate.getDate() + 1);
2690
- return newDate;
2691
- };
2692
- Date.prototype.decreaseDay = function () {
2693
- const newDate = new Date(this);
2694
- newDate.setDate(newDate.getDate() - 1);
2695
- return newDate;
2696
- };
2697
- Date.prototype.startOfYear = function () {
2698
- const newDate = new Date(this);
2699
- newDate.setMonth(0);
2700
- return newDate.startOfMonth();
2701
- };
2702
- Date.prototype.endOfYear = function () {
2703
- const nextMonth = this.increaseYear().startOfYear();
2704
- return new Date(nextMonth.getTime() - 1);
2705
- };
2706
- Date.prototype.startOfMonth = function () {
2707
- const newDate = new Date(this);
2708
- newDate.setDate(1);
2709
- return newDate.startOfDay();
2710
- };
2711
- Date.prototype.endOfMonth = function () {
2712
- const nextMonth = this.increaseMonth().startOfMonth();
2713
- return new Date(nextMonth.getTime() - 1);
2714
- };
2715
- Date.prototype.startOfWeek = function () {
2716
- const newDate = new Date(this);
2717
- while (newDate.getDay()) {
2718
- newDate.setDate(newDate.getDate() - 1);
2719
- }
2720
- return newDate.startOfDay();
2721
- };
2722
- Date.prototype.endOfWeek = function () {
2723
- const newDate = new Date(this);
2724
- while (newDate.getDay() < 6) {
2725
- newDate.setDate(newDate.getDate() - 1);
2726
- }
2727
- return newDate.endOfDay();
2728
- };
2729
- Date.prototype.startOfDay = function () {
2730
- const newDate = new Date(this);
2731
- newDate.setHours(0, 0, 0, 0);
2732
- return newDate;
2733
- };
2734
- Date.prototype.endOfDay = function () {
2735
- const newDate = new Date(this);
2736
- newDate.setHours(23, 59, 59, 999);
2737
- return newDate;
2738
- };
2739
- Date.prototype.startOfHour = function () {
2740
- const newDate = new Date(this);
2741
- newDate.setMinutes(0, 0, 0);
2742
- return newDate;
2743
- };
2744
- Date.prototype.endOfHour = function () {
2745
- const newDate = new Date(this);
2746
- newDate.setMinutes(59, 59, 999);
2747
- return newDate;
2748
- };
2749
- Date.prototype.startOfMinute = function () {
2750
- const newDate = new Date(this);
2751
- newDate.setSeconds(0, 0);
2752
- return newDate;
2753
- };
2754
- Date.prototype.endOfMinute = function () {
2755
- const newDate = new Date(this);
2756
- newDate.setSeconds(59, 999);
2757
- return newDate;
2758
- };
2759
- Date.prototype.startOfSecond = function () {
2760
- const newDate = new Date(this);
2761
- newDate.setMilliseconds(0);
2762
- return newDate;
2763
- };
2764
- Date.prototype.endOfSecond = function () {
2765
- const newDate = new Date(this);
2766
- newDate.setMilliseconds(999);
2767
- return newDate;
2768
- };
2769
- Date.prototype.isToday = function () {
2770
- const today = new Date();
2771
- return this.isSameDay(today);
2772
- };
2773
- Date.prototype.isEqual = function (date) {
2774
- return this.getTime() === date.getTime();
2775
- };
2776
- Date.prototype.isSameYear = function (date) {
2777
- return this.getFullYear() === date.getFullYear();
2778
- };
2779
- Date.prototype.isSameMonth = function (date) {
2780
- return this.isSameYear(date) && this.getMonth() === date.getMonth();
2781
- };
2782
- Date.prototype.isSameDay = function (date) {
2783
- return this.isSameMonth(date) && this.getDate() === date.getDate();
2784
- };
2785
- Date.prototype.isSameHour = function (date) {
2786
- return this.isSameDay(date) && this.getHours() === date.getHours();
2787
- };
2788
- Date.prototype.isSameMinute = function (date) {
2789
- return this.isSameHour(date) && this.getMinutes() === date.getMinutes();
2790
- };
2791
- Date.prototype.isSameSecond = function (date) {
2792
- return this.isSameMinute(date) && this.getSeconds() === date.getSeconds();
2793
- };
2794
- Date.prototype.isSameMillisecond = function (date) {
2795
- return this.isEqual(date);
2796
- };
2797
- Date.prototype.isValidDate = function () {
2798
- return this instanceof Date && !isNaN(this.getTime());
2799
- };
2800
- Date.prototype.isYearAfter = function (date) {
2801
- return this.getFullYear() > date.getFullYear();
2802
- };
2803
- Date.prototype.isMonthAfter = function (date) {
2804
- return this.isYearAfter(date) || (this.isSameYear(date) && this.getMonth() > date.getMonth());
2805
- };
2806
- Date.prototype.isDayAfter = function (date) {
2807
- return this.isMonthAfter(date) || (this.isSameMonth(date) && this.getDate() > date.getDate());
2808
- };
2809
- Date.prototype.isHoursAfter = function (date) {
2810
- return this.isDayAfter(date) || (this.isSameDay(date) && this.getHours() > date.getHours());
2811
- };
2812
- Date.prototype.isMinutesAfter = function (date) {
2813
- return this.isHoursAfter(date) || (this.isSameHour(date) && this.getMinutes() > date.getMinutes());
2814
- };
2815
- Date.prototype.isSecondsAfter = function (date) {
2816
- return this.isMinutesAfter(date) || (this.isSameMinute(date) && this.getSeconds() > date.getSeconds());
2817
- };
2818
- Date.prototype.isMillisecondsAfter = function (date) {
2819
- return this.isSecondsAfter(date) || (this.isSameSecond(date) && this.getMilliseconds() > date.getMilliseconds());
2820
- };
2821
- Date.prototype.isAfter = function (date) {
2822
- return this.getTime() > date.getTime();
2823
- };
2824
- Date.prototype.isYearBefore = function (date) {
2825
- return this.getFullYear() < date.getFullYear();
2826
- };
2827
- Date.prototype.isMonthBefore = function (date) {
2828
- return this.isYearBefore(date) || (this.isSameYear(date) && this.getMonth() < date.getMonth());
2829
- };
2830
- Date.prototype.isDayBefore = function (date) {
2831
- return this.isMonthBefore(date) || (this.isSameMonth(date) && this.getDate() < date.getDate());
2832
- };
2833
- Date.prototype.isHoursBefore = function (date) {
2834
- return this.isDayBefore(date) || (this.isSameDay(date) && this.getHours() < date.getHours());
2835
- };
2836
- Date.prototype.isMinutesBefore = function (date) {
2837
- return this.isHoursBefore(date) || (this.isSameHour(date) && this.getMinutes() < date.getMinutes());
2838
- };
2839
- Date.prototype.isSecondsBefore = function (date) {
2840
- return this.isMinutesBefore(date) || (this.isSameMinute(date) && this.getSeconds() < date.getSeconds());
2841
- };
2842
- Date.prototype.isMillisecondsBefore = function (date) {
2843
- return this.isSecondsBefore(date) || (this.isSameSecond(date) && this.getMilliseconds() < date.getMilliseconds());
2844
- };
2845
- Date.prototype.isBefore = function (date) {
2846
- return this.getTime() < date.getTime();
2847
- };
2848
- Date.prototype.isWithinInterval = function ({ start, end }, cmp = '[]') {
2849
- return (cmp.charAt(0) === '[' ? this.isEqual(start) || this.isAfter(start) : this.isAfter(start)) &&
2850
- (cmp.charAt(1) === '[' ? this.isEqual(end) || this.isBefore(end) : this.isBefore(end));
2851
- };
2852
-
2853
- class JkError extends Error {
2854
- constructor(code, custom) {
2855
- const message = custom?.message || ERROR[code].message;
2856
- super(message);
2857
- this.message = message;
2858
- this.code = code;
2859
- if (custom?.stack) {
2860
- this.stack = custom.stack;
2861
- }
2862
- if (custom?.data) {
2863
- this.data = custom.data;
2864
- }
2865
- }
2866
- }
2867
-
2868
- /* eslint-disable no-extend-native */
2869
- Number.prototype.padStart = function (maxLength, fillString = '0') {
2870
- return (this + '').padStart(maxLength, fillString);
2871
- };
2872
- Number.prototype.padEnd = function (maxLength, fillString = '0') {
2873
- return (this + '').padEnd(maxLength, fillString);
2874
- };
2875
-
2876
2820
  function toJkError(err) {
2877
2821
  const error = new Error();
2878
2822
  let code = err?.code;
@@ -2966,256 +2910,194 @@ const getDefaultMeta = (contents, sort) => {
2966
2910
  };
2967
2911
 
2968
2912
  const isWebsocketSubscription = (event) => {
2969
- return (Object.values(exports.WebSocketSubscriptionEvent).includes(event?.event) || Object.values(exports.WebSocketMessageEvent).includes(event?.event))
2913
+ return Object.values(exports.WebSocketSubscriptionEvent).includes(event?.event)
2970
2914
  && typeof event?.clientId === 'string' && !!event.clientId;
2971
2915
  };
2972
- // Custom CHANNEL_PUBLISH_MESSAGES
2973
- const isPingWebSocketEventDTO = (event) => {
2974
- return isWebsocketSubscription(event)
2975
- && event?.event === exports.WebSocketMessageEvent.PING;
2976
- };
2977
- const isClientTrackLocationWebSocketEventDTO = (event) => {
2978
- return isWebsocketSubscription(event)
2979
- && event?.event === exports.WebSocketMessageEvent.CLIENT_TRACK_LOCATION;
2980
- };
2981
- const isClientTrackScreenshotWebSocketEventDTO = (event) => {
2982
- return isWebsocketSubscription(event)
2983
- && event?.event === exports.WebSocketMessageEvent.CLIENT_TRACK_SCREENSHOT;
2984
- };
2985
- const isClientTrackDeviceWebSocketEventDTO = (event) => {
2986
- return isWebsocketSubscription(event)
2987
- && event?.event === exports.WebSocketMessageEvent.CLIENT_TRACK_DEVICE;
2988
- };
2989
- const isChatCompletionsWebSocketEventDTO = (event) => {
2990
- return isWebsocketSubscription(event)
2991
- && event?.event === exports.WebSocketMessageEvent.CHAT_COMPLETIONS;
2992
- };
2993
2916
  // CHANNEL_PUBLISH_SUBSCRIPTIONS
2994
- const isSubscribeCodeRunStatusWebSocketEventDTO = (event) => {
2917
+ const isSubscribeCodeRunStatusWebSocketEventDto = (event) => {
2995
2918
  return isWebsocketSubscription(event)
2996
2919
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CODE_RUN_STATUS
2997
2920
  && typeof event?.runId === 'string' && !!event.runId;
2998
2921
  };
2999
- const isUnsubscribeCodeRunStatusWebSocketEventDTO = (event) => {
2922
+ const isUnsubscribeCodeRunStatusWebSocketEventDto = (event) => {
3000
2923
  return isWebsocketSubscription(event)
3001
2924
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CODE_RUN_STATUS
3002
2925
  && typeof event?.runId === 'string' && !!event.runId;
3003
2926
  };
3004
- const isSubscribeSubmissionRunStatusWebSocketEventDTO = (event) => {
2927
+ const isSubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
3005
2928
  return isWebsocketSubscription(event)
3006
2929
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSION_RUN_STATUS
3007
2930
  && typeof event?.submitId === 'string' && !!event.submitId;
3008
2931
  };
3009
- const isUnsubscribeSubmissionRunStatusWebSocketEventDTO = (event) => {
2932
+ const isUnsubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
3010
2933
  return isWebsocketSubscription(event)
3011
2934
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSION_RUN_STATUS
3012
2935
  && typeof event?.submitId === 'string' && !!event.submitId;
3013
2936
  };
3014
- const isSubscribeGetDataWebSocketEventDTO = (event) => {
2937
+ const isSubscribeGetDataWebSocketEventDto = (event) => {
3015
2938
  return isWebsocketSubscription(event)
3016
2939
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_GET_DATA;
3017
2940
  };
3018
- const isUnsubscribeGetDataWebSocketEventDTO = (event) => {
2941
+ const isUnsubscribeGetDataWebSocketEventDto = (event) => {
3019
2942
  return isWebsocketSubscription(event)
3020
2943
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_GET_DATA;
3021
2944
  };
3022
- const isSubscribeProblemCrawledWebSocketEventDTO = (event) => {
2945
+ const isSubscribeProblemCrawledWebSocketEventDto = (event) => {
3023
2946
  return isWebsocketSubscription(event)
3024
2947
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_PROBLEM_CRAWLED;
3025
2948
  };
3026
- const isUnsubscribeProblemCrawledWebSocketEventDTO = (event) => {
2949
+ const isUnsubscribeProblemCrawledWebSocketEventDto = (event) => {
3027
2950
  return isWebsocketSubscription(event)
3028
2951
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_PROBLEM_CRAWLED;
3029
2952
  };
3030
- const isSubscribeSubmissionsCrawlWebSocketEventDTO = (event) => {
2953
+ const isSubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
3031
2954
  return isWebsocketSubscription(event)
3032
2955
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSIONS_CRAWL;
3033
2956
  };
3034
- const isUnsubscribeSubmissionsCrawlWebSocketEventDTO = (event) => {
2957
+ const isUnsubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
3035
2958
  return isWebsocketSubscription(event)
3036
2959
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSIONS_CRAWL;
3037
2960
  };
3038
- const isSubscribeContestChangesWebSocketEventDTO = (event) => {
2961
+ const isSubscribeContestChangesWebSocketEventDto = (event) => {
3039
2962
  return isWebsocketSubscription(event)
3040
2963
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CONTEST_CHANGES;
3041
2964
  };
3042
- const isUnsubscribeContestChangesWebSocketEventDTO = (event) => {
2965
+ const isUnsubscribeContestChangesWebSocketEventDto = (event) => {
3043
2966
  return isWebsocketSubscription(event)
3044
2967
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CONTEST_CHANGES;
3045
2968
  };
3046
- const isSubscribeClientTrackWebSocketEventDTO = (event) => {
3047
- return isWebsocketSubscription(event)
3048
- && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CLIENT_TRACK;
3049
- };
3050
- const isUnsubscribeClientTrackWebSocketEventDTO = (event) => {
3051
- return isWebsocketSubscription(event)
3052
- && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CLIENT_TRACK;
3053
- };
3054
- const isSubscribeUserNotificationWebSocketEventDTO = (event) => {
2969
+ const isSubscribeUserNotificationWebSocketEventDto = (event) => {
3055
2970
  return isWebsocketSubscription(event)
3056
2971
  && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_USER_NOTIFICATION;
3057
2972
  };
3058
- const isUnsubscribeUserNotificationWebSocketEventDTO = (event) => {
2973
+ const isUnsubscribeUserNotificationWebSocketEventDto = (event) => {
3059
2974
  return isWebsocketSubscription(event)
3060
2975
  && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_USER_NOTIFICATION;
3061
2976
  };
3062
- const isSubscribeClientTrackDataWebSocketEventDTO = (event) => {
3063
- return isWebsocketSubscription(event)
3064
- && event?.event === exports.WebSocketSubscriptionEvent.SUBSCRIBE_CLIENT_TRACK_DATA
3065
- && typeof event?.trackedClientId === 'string' && !!event.trackedClientId;
3066
- };
3067
- const isUnsubscribeClientTrackDataWebSocketEventDTO = (event) => {
3068
- return isWebsocketSubscription(event)
3069
- && event?.event === exports.WebSocketSubscriptionEvent.UNSUBSCRIBE_CLIENT_TRACK_DATA
3070
- && typeof event?.trackedClientId === 'string' && !!event.trackedClientId;
3071
- };
3072
- // is WebSocketResponseEventDTO, CHANNEL_SUBSCRIBE_CLIENT
3073
- const isWebSocketResponseEventDTO = (event) => {
2977
+ // is WebSocketResponseEventDto, CHANNEL_SUBSCRIBE_CLIENT
2978
+ const isWebSocketResponseEventDto = (event) => {
3074
2979
  return Object.values(exports.WebSocketResponseEvent).includes(event?.event)
3075
2980
  && typeof event?.key === 'string'
3076
2981
  && typeof event?.connectionId === 'string'
3077
- && typeof event?.messageTimestamp === 'number' && !!event.messageTimestamp;
2982
+ && typeof event?.createdAt === 'number' && !!event.createdAt;
3078
2983
  };
3079
- const isPongWebSocketResponseEventDTO = (event) => {
3080
- return isWebSocketResponseEventDTO(event)
3081
- && event?.event === exports.WebSocketResponseEvent.PONG
3082
- && !!event?.data;
3083
- };
3084
- const isCodeRunStatusMessageWebSocketResponseEventDTO = (event) => {
3085
- return isWebSocketResponseEventDTO(event)
2984
+ const isCodeRunStatusMessageWebSocketResponseEventDto = (event) => {
2985
+ return isWebSocketResponseEventDto(event)
3086
2986
  && event?.event === exports.WebSocketResponseEvent.CODE_RUN_STATUS
3087
2987
  && typeof event?.runId === 'string' && !!event.runId
3088
2988
  && event?.status in exports.SubmissionRunStatus;
3089
2989
  };
3090
- const isSubmissionRunStatusMessageWebSocketResponseEventDTO = (event) => {
3091
- return isWebSocketResponseEventDTO(event)
2990
+ const isSubmissionRunStatusMessageWebSocketResponseEventDto = (event) => {
2991
+ return isWebSocketResponseEventDto(event)
3092
2992
  && event?.event === exports.WebSocketResponseEvent.SUBMISSION_RUN_STATUS
3093
2993
  && typeof event?.submitId === 'string' && !!event.submitId
3094
2994
  && event?.status in exports.SubmissionRunStatus
3095
2995
  && event?.verdict in exports.ProblemVerdict
3096
2996
  && typeof event?.points === 'number';
3097
2997
  };
3098
- const isUserMessageWebSocketResponseEventDTO = (event) => {
3099
- return isWebSocketResponseEventDTO(event)
2998
+ const isUserMessageWebSocketResponseEventDto = (event) => {
2999
+ return isWebSocketResponseEventDto(event)
3100
3000
  && event?.event === exports.WebSocketResponseEvent.USER_MESSAGE
3101
3001
  && typeof event?.user?.nickname === 'string' && !!event.user?.nickname
3102
3002
  && typeof event?.user?.imageUrl === 'string' && !!event.user?.imageUrl
3103
- && typeof event?.user?.company?.key === 'string' && !!event.user?.company?.key
3003
+ && typeof event?.user?.organization?.key === 'string' && !!event.user?.organization?.key
3104
3004
  && !!event?.content;
3105
3005
  };
3106
- const isSendDataWebSocketResponseEventDTO = (event) => {
3006
+ const isSendDataWebSocketResponseEventDto = (event) => {
3107
3007
  return [
3108
3008
  exports.WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST,
3109
3009
  exports.WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST,
3110
3010
  exports.WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST,
3111
3011
  exports.WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST,
3112
3012
  exports.WebSocketResponseEvent.SEND_DATA_RUN_COMMAND,
3113
- exports.WebSocketResponseEvent.SEND_DATA_CLIENT_TRACK,
3114
- exports.WebSocketResponseEvent.SEND_DATA_CHAT_COMPLETIONS,
3115
3013
  ].includes(event?.event)
3116
3014
  && typeof event?.dataId === 'string' && !!event.dataId
3117
3015
  && !!event?.content;
3118
3016
  };
3119
- const isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO = (event) => {
3120
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3017
+ const isSendDataEcsTaskDefinitionListWebSocketResponseEventDto = (event) => {
3018
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3121
3019
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST;
3122
3020
  };
3123
- const isSendDataEc2InstancesListWebSocketResponseEventDTO = (event) => {
3124
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3021
+ const isSendDataEc2InstancesListWebSocketResponseEventDto = (event) => {
3022
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3125
3023
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST;
3126
3024
  };
3127
- const isSendDataEcsTasksListWebSocketResponseEventDTO = (event) => {
3128
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3025
+ const isSendDataEcsTasksListWebSocketResponseEventDto = (event) => {
3026
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3129
3027
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST;
3130
3028
  };
3131
- const isSendDataSsmSessionsListWebSocketResponseEventDTO = (event) => {
3132
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3029
+ const isSendDataSsmSessionsListWebSocketResponseEventDto = (event) => {
3030
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3133
3031
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST;
3134
3032
  };
3135
- const isSendDataRunCommandWebSocketResponseEventDTO = (event) => {
3136
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3033
+ const isSendDataRunCommandWebSocketResponseEventDto = (event) => {
3034
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3137
3035
  && event?.event === exports.WebSocketResponseEvent.SEND_DATA_RUN_COMMAND;
3138
3036
  };
3139
- const isSendDataClientTrackWebSocketResponseEventDTO = (event) => {
3140
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3141
- && event?.event === exports.WebSocketResponseEvent.SEND_DATA_CLIENT_TRACK;
3142
- };
3143
- const isSenDataChatCompletionsWebSocketResponseEventDTO = (event) => {
3144
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3145
- && event?.event === exports.WebSocketResponseEvent.SEND_DATA_CHAT_COMPLETIONS;
3146
- };
3147
- const isProblemCrawledWebSocketResponseEventDTO = (event) => {
3148
- return isWebSocketResponseEventDTO(event)
3037
+ const isProblemCrawledWebSocketResponseEventDto = (event) => {
3038
+ return isWebSocketResponseEventDto(event)
3149
3039
  && event?.event === exports.WebSocketResponseEvent.PROBLEM_CRAWLED
3150
3040
  && !!event?.content;
3151
3041
  };
3152
- const isSubmissionsCrawlWebSocketResponseEventDTO = (event) => {
3153
- return isWebSocketResponseEventDTO(event)
3042
+ const isSubmissionsCrawlWebSocketResponseEventDto = (event) => {
3043
+ return isWebSocketResponseEventDto(event)
3154
3044
  && event?.event === exports.WebSocketResponseEvent.SUBMISSIONS_CRAWL
3155
3045
  && !!event?.content;
3156
3046
  };
3157
- const isContestChangesWebSocketResponseEventDTO = (event) => {
3158
- return isWebSocketResponseEventDTO(event)
3047
+ const isContestChangesWebSocketResponseEventDto = (event) => {
3048
+ return isWebSocketResponseEventDto(event)
3159
3049
  && event?.event === exports.WebSocketResponseEvent.CONTEST_CHANGES
3160
3050
  && !!event?.content;
3161
3051
  };
3162
- const isClientTrackWebSocketResponseEventDTO = (event) => {
3163
- return isWebSocketResponseEventDTO(event)
3164
- && event?.event === exports.WebSocketResponseEvent.CLIENT_TRACK;
3165
- };
3166
- const isUserNotificationWebSocketResponseEventDTO = (event) => {
3052
+ const isUserNotificationWebSocketResponseEventDto = (event) => {
3167
3053
  return [
3168
3054
  exports.WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION,
3169
3055
  exports.WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION,
3170
3056
  ].includes(event?.event)
3171
3057
  && !!event?.content;
3172
3058
  };
3173
- const isUserNotificationSubmissionWebSocketResponseEventDTO = (event) => {
3174
- return isWebSocketResponseEventDTO(event) && isUserNotificationWebSocketResponseEventDTO(event)
3059
+ const isUserNotificationSubmissionWebSocketResponseEventDto = (event) => {
3060
+ return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3175
3061
  && event?.event === exports.WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION;
3176
3062
  };
3177
- const isUserNotificationContestClarificationWebSocketResponseEventDTO = (event) => {
3178
- return isWebSocketResponseEventDTO(event) && isUserNotificationWebSocketResponseEventDTO(event)
3063
+ const isUserNotificationContestClarificationWebSocketResponseEventDto = (event) => {
3064
+ return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3179
3065
  && event?.event === exports.WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION;
3180
3066
  };
3181
3067
  // generic
3182
3068
  const getWebSocketResponseEventKey = (event, clientId, id) => {
3183
3069
  return `${event}-${clientId}-${id}`;
3184
3070
  };
3185
- const isWebSocketChannelsMessageDTO = (message) => {
3071
+ const isWebSocketChannelsMessageDto = (message) => {
3186
3072
  return Array.isArray(message?.channels)
3187
3073
  && message.channels.every((channel) => typeof channel === 'string' && !!channel)
3188
3074
  && Object.values(exports.WebSocketResponseEvent).includes(message?.event?.event);
3189
3075
  };
3190
3076
  /**
3191
3077
  * Key used by the client to dispatch a response received on a TOPIC channel to its subscribers.
3192
- * 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.
3193
3079
  * Returns null when the response is not addressed to this client.
3194
3080
  */
3195
3081
  const getWebSocketResponseEventKeyOfResponse = (response, clientId) => {
3196
- if (isCodeRunStatusMessageWebSocketResponseEventDTO(response)) {
3082
+ if (isCodeRunStatusMessageWebSocketResponseEventDto(response)) {
3197
3083
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.CODE_RUN_STATUS, clientId, response.runId);
3198
3084
  }
3199
- if (isSubmissionRunStatusMessageWebSocketResponseEventDTO(response)) {
3085
+ if (isSubmissionRunStatusMessageWebSocketResponseEventDto(response)) {
3200
3086
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.SUBMISSION_RUN_STATUS, clientId, response.submitId);
3201
3087
  }
3202
- if (isSendDataWebSocketResponseEventDTO(response)) {
3088
+ if (isSendDataWebSocketResponseEventDto(response)) {
3203
3089
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.SEND_DATA_, clientId, response.dataId);
3204
3090
  }
3205
- if (isContestChangesWebSocketResponseEventDTO(response)) {
3091
+ if (isContestChangesWebSocketResponseEventDto(response)) {
3206
3092
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.CONTEST_CHANGES, clientId, response.content.contestKey);
3207
3093
  }
3208
- if (isProblemCrawledWebSocketResponseEventDTO(response)) {
3094
+ if (isProblemCrawledWebSocketResponseEventDto(response)) {
3209
3095
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.PROBLEM_CRAWLED, clientId, response.content.problemKey);
3210
3096
  }
3211
- if (isSubmissionsCrawlWebSocketResponseEventDTO(response)) {
3097
+ if (isSubmissionsCrawlWebSocketResponseEventDto(response)) {
3212
3098
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.SUBMISSIONS_CRAWL, clientId, join([response.content.contestKey, response.content.problemKeys]));
3213
3099
  }
3214
- if (isClientTrackWebSocketResponseEventDTO(response)) {
3215
- // the command is sent to the session channel, `key` holds the targeted client
3216
- return response.key === clientId ? getWebSocketResponseEventKey(exports.WebSocketResponseEvent.CLIENT_TRACK, clientId, '*') : null;
3217
- }
3218
- if (isUserNotificationWebSocketResponseEventDTO(response)) {
3100
+ if (isUserNotificationWebSocketResponseEventDto(response)) {
3219
3101
  return getWebSocketResponseEventKey(exports.WebSocketResponseEvent.USER_NOTIFICATION_, clientId, '*');
3220
3102
  }
3221
3103
  return null;
@@ -3226,25 +3108,22 @@ const getWebSocketResponseEventKeyOfResponse = (response, clientId) => {
3226
3108
  * Ably rejects the attach if the token has no capability for the channel.
3227
3109
  */
3228
3110
  const getChannelOfWebSocketSubscribeEvent = (event) => {
3229
- if (isSubscribeSubmissionRunStatusWebSocketEventDTO(event)) {
3111
+ if (isSubscribeSubmissionRunStatusWebSocketEventDto(event)) {
3230
3112
  return CHANNEL_SUBMISSION(event.submitId);
3231
3113
  }
3232
- if (isSubscribeProblemCrawledWebSocketEventDTO(event)) {
3114
+ if (isSubscribeProblemCrawledWebSocketEventDto(event)) {
3233
3115
  return CHANNEL_PROBLEM(event.problemKey);
3234
3116
  }
3235
- if (isSubscribeContestChangesWebSocketEventDTO(event) || isSubscribeSubmissionsCrawlWebSocketEventDTO(event)) {
3117
+ if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3236
3118
  return CHANNEL_CONTEST(event.contestKey, exports.ContestChannelRole.SPECTATORS);
3237
3119
  }
3238
- if (isSubscribeClientTrackDataWebSocketEventDTO(event)) {
3239
- return CHANNEL_CLIENT_TRACK(event.trackedClientId);
3240
- }
3241
3120
  return null;
3242
3121
  };
3243
3122
  /**
3244
3123
  * Contest whose role channels the client needs (the API grants them when the token is requested with this contest).
3245
3124
  */
3246
3125
  const getContestKeyOfWebSocketSubscribeEvent = (event) => {
3247
- if (isSubscribeContestChangesWebSocketEventDTO(event) || isSubscribeSubmissionsCrawlWebSocketEventDTO(event)) {
3126
+ if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3248
3127
  return event.contestKey;
3249
3128
  }
3250
3129
  return null;
@@ -3319,44 +3198,13 @@ function splitTime(timeRemaining) {
3319
3198
  // }
3320
3199
  return remaining;
3321
3200
  }
3322
- function normalizeToLocalStartOfDay(timestamp) {
3323
- const date = new Date(timestamp);
3324
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
3325
- }
3326
- function normalizeToLocalStartOfHour(timestamp) {
3327
- const date = new Date(timestamp);
3328
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours());
3329
- }
3330
- function normalizeToLocalStartOfMinutes(timestamp) {
3331
- const date = new Date(timestamp);
3332
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
3333
- }
3334
- function normalizeToLocalStartOfSeconds(timestamp) {
3335
- const date = new Date(timestamp);
3336
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
3337
- }
3338
- const getYears = (d) => d.getFullYear();
3339
- const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
3340
- const getDays = (d) => {
3341
- return Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
3342
- };
3343
- const getHours = (d) => {
3344
- return Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
3345
- };
3346
- const getMinutes = (d) => {
3347
- return Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
3348
- };
3349
- const getSeconds = (d) => {
3350
- return Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
3351
- };
3352
- const getMilliseconds = (d) => d.getTime();
3353
3201
 
3354
- const getUserKey = (userNickname, userCompanyKey) => {
3355
- return userNickname + '|' + userCompanyKey;
3202
+ const getUserKey = (userNickname, userOrganizationKey) => {
3203
+ return userNickname + '|' + userOrganizationKey;
3356
3204
  };
3357
3205
  const getParamsOfUserKey = (userKey) => {
3358
- const [userNickname, userCompanyKey] = userKey.split('|');
3359
- return { userNickname, userCompanyKey };
3206
+ const [userNickname, userOrganizationKey] = userKey.split('|');
3207
+ return { userNickname, userOrganizationKey };
3360
3208
  };
3361
3209
  const getClientId = (sessionId, uiId) => {
3362
3210
  return `${sessionId}|${uiId}`;
@@ -3476,22 +3324,15 @@ exports.ACCEPTED_PROGRAMMING_LANGUAGES = ACCEPTED_PROGRAMMING_LANGUAGES;
3476
3324
  exports.ASPECT_RATIO = ASPECT_RATIO;
3477
3325
  exports.AssignmentState = AssignmentState;
3478
3326
  exports.AssignmentType = AssignmentType;
3479
- exports.CHANNEL_CLIENT_TRACK = CHANNEL_CLIENT_TRACK;
3480
- exports.CHANNEL_CLIENT_TRACK_ALL = CHANNEL_CLIENT_TRACK_ALL;
3481
3327
  exports.CHANNEL_CONTEST = CHANNEL_CONTEST;
3482
- exports.CHANNEL_PRESENCE_CLIENT = CHANNEL_PRESENCE_CLIENT;
3328
+ exports.CHANNEL_ORGANIZATION_PRESENCE = CHANNEL_ORGANIZATION_PRESENCE;
3483
3329
  exports.CHANNEL_PROBLEM = CHANNEL_PROBLEM;
3484
3330
  exports.CHANNEL_PROBLEM_ALL = CHANNEL_PROBLEM_ALL;
3485
- exports.CHANNEL_PUBLISH_MESSAGES = CHANNEL_PUBLISH_MESSAGES;
3486
- exports.CHANNEL_PUBLISH_SUBSCRIPTIONS = CHANNEL_PUBLISH_SUBSCRIPTIONS;
3487
3331
  exports.CHANNEL_SESSION = CHANNEL_SESSION;
3488
3332
  exports.CHANNEL_SUBMISSION = CHANNEL_SUBMISSION;
3489
3333
  exports.CHANNEL_SUBMISSION_ALL = CHANNEL_SUBMISSION_ALL;
3490
- exports.CHANNEL_SUBSCRIBE_CLIENT = CHANNEL_SUBSCRIBE_CLIENT;
3491
- exports.CHANNEL_SUBSCRIBE_NOTIFICATIONS = CHANNEL_SUBSCRIBE_NOTIFICATIONS;
3492
3334
  exports.CHANNEL_USER = CHANNEL_USER;
3493
3335
  exports.CODE_LANGUAGE = CODE_LANGUAGE;
3494
- exports.COMPANY_PLAN = COMPANY_PLAN;
3495
3336
  exports.CONTEST_ROLE = CONTEST_ROLE;
3496
3337
  exports.CONTEST_STATUS = CONTEST_STATUS;
3497
3338
  exports.COOKIE_JUKI_SESSION_ID = COOKIE_JUKI_SESSION_ID;
@@ -3518,8 +3359,8 @@ exports.HEADER_JUKI_SECRET_TOKEN = HEADER_JUKI_SECRET_TOKEN;
3518
3359
  exports.HEADER_JUKI_VISITOR_SESSION_ID = HEADER_JUKI_VISITOR_SESSION_ID;
3519
3360
  exports.HOURS = HOURS;
3520
3361
  exports.JUDGE = JUDGE;
3521
- exports.JUKI_APP_COMPANY_KEY = JUKI_APP_COMPANY_KEY;
3522
3362
  exports.JUKI_APP_EMAIL_TEMPLATE = JUKI_APP_EMAIL_TEMPLATE;
3363
+ exports.JUKI_APP_ORGANIZATION_KEY = JUKI_APP_ORGANIZATION_KEY;
3523
3364
  exports.JkError = JkError;
3524
3365
  exports.LANGUAGE = LANGUAGE;
3525
3366
  exports.LOWERCASE_LETTERS = LOWERCASE_LETTERS;
@@ -3538,6 +3379,7 @@ exports.ONE_HOUR = ONE_HOUR;
3538
3379
  exports.ONE_MINUTE = ONE_MINUTE;
3539
3380
  exports.ONE_SECOND = ONE_SECOND;
3540
3381
  exports.ONE_WEEK = ONE_WEEK;
3382
+ exports.ORGANIZATION_PLAN = ORGANIZATION_PLAN;
3541
3383
  exports.PAGE = PAGE;
3542
3384
  exports.PAGE_SIZE = PAGE_SIZE;
3543
3385
  exports.PAGE_SIZES = PAGE_SIZES;
@@ -3583,6 +3425,13 @@ exports._SUB_TAB = _SUB_TAB;
3583
3425
  exports._TAB = _TAB;
3584
3426
  exports._TYPE = _TYPE;
3585
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;
3586
3435
  exports.chunkString = chunkString;
3587
3436
  exports.cleanRequest = cleanRequest;
3588
3437
  exports.clearAsyncInterval = clearAsyncInterval;
@@ -3591,6 +3440,16 @@ exports.consoleInfo = consoleInfo;
3591
3440
  exports.consoleWarn = consoleWarn;
3592
3441
  exports.contentResponse = contentResponse;
3593
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;
3594
3453
  exports.errorsResponse = errorsResponse;
3595
3454
  exports.getAssignmentCommentKey = getAssignmentCommentKey;
3596
3455
  exports.getAssignmentUserCommentKey = getAssignmentUserCommentKey;
@@ -3624,69 +3483,86 @@ exports.getWebSocketResponseEventKeyOfResponse = getWebSocketResponseEventKeyOfR
3624
3483
  exports.getWorksheetsInPages = getWorksheetsInPages;
3625
3484
  exports.getYears = getYears;
3626
3485
  exports.humanFileSize = humanFileSize;
3486
+ exports.increaseDay = increaseDay;
3487
+ exports.increaseMonth = increaseMonth;
3488
+ exports.increaseYear = increaseYear;
3627
3489
  exports.indexToLetters = indexToLetters;
3490
+ exports.isAfter = isAfter;
3628
3491
  exports.isBasicWorksheet = isBasicWorksheet;
3629
- exports.isChatCompletionsWebSocketEventDTO = isChatCompletionsWebSocketEventDTO;
3630
- exports.isClientTrackDeviceWebSocketEventDTO = isClientTrackDeviceWebSocketEventDTO;
3631
- exports.isClientTrackLocationWebSocketEventDTO = isClientTrackLocationWebSocketEventDTO;
3632
- exports.isClientTrackScreenshotWebSocketEventDTO = isClientTrackScreenshotWebSocketEventDTO;
3633
- exports.isClientTrackWebSocketResponseEventDTO = isClientTrackWebSocketResponseEventDTO;
3492
+ exports.isBefore = isBefore;
3634
3493
  exports.isCodeEditorSheet = isCodeEditorSheet;
3635
- exports.isCodeRunStatusMessageWebSocketResponseEventDTO = isCodeRunStatusMessageWebSocketResponseEventDTO;
3494
+ exports.isCodeRunStatusMessageWebSocketResponseEventDto = isCodeRunStatusMessageWebSocketResponseEventDto;
3636
3495
  exports.isContestAssignment = isContestAssignment;
3637
- exports.isContestChangesWebSocketResponseEventDTO = isContestChangesWebSocketResponseEventDTO;
3496
+ exports.isContestChangesWebSocketResponseEventDto = isContestChangesWebSocketResponseEventDto;
3638
3497
  exports.isCourseAssignment = isCourseAssignment;
3498
+ exports.isDayAfter = isDayAfter;
3499
+ exports.isDayBefore = isDayBefore;
3639
3500
  exports.isEndlessContest = isEndlessContest;
3501
+ exports.isEqual = isEqual;
3640
3502
  exports.isFutureContest = isFutureContest;
3641
3503
  exports.isGlobalContest = isGlobalContest;
3504
+ exports.isHoursAfter = isHoursAfter;
3505
+ exports.isHoursBefore = isHoursBefore;
3642
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;
3643
3513
  exports.isObjectJson = isObjectJson;
3644
3514
  exports.isPastContest = isPastContest;
3645
- exports.isPingWebSocketEventDTO = isPingWebSocketEventDTO;
3646
- exports.isPongWebSocketResponseEventDTO = isPongWebSocketResponseEventDTO;
3647
- exports.isProblemCrawledWebSocketResponseEventDTO = isProblemCrawledWebSocketResponseEventDTO;
3515
+ exports.isProblemCrawledWebSocketResponseEventDto = isProblemCrawledWebSocketResponseEventDto;
3648
3516
  exports.isQuizOptionsSheet = isQuizOptionsSheet;
3649
3517
  exports.isQuizProblemSheet = isQuizProblemSheet;
3650
3518
  exports.isQuizTextSheet = isQuizTextSheet;
3651
- exports.isSenDataChatCompletionsWebSocketResponseEventDTO = isSenDataChatCompletionsWebSocketResponseEventDTO;
3652
- exports.isSendDataClientTrackWebSocketResponseEventDTO = isSendDataClientTrackWebSocketResponseEventDTO;
3653
- exports.isSendDataEc2InstancesListWebSocketResponseEventDTO = isSendDataEc2InstancesListWebSocketResponseEventDTO;
3654
- exports.isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO = isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO;
3655
- exports.isSendDataEcsTasksListWebSocketResponseEventDTO = isSendDataEcsTasksListWebSocketResponseEventDTO;
3656
- exports.isSendDataRunCommandWebSocketResponseEventDTO = isSendDataRunCommandWebSocketResponseEventDTO;
3657
- exports.isSendDataSsmSessionsListWebSocketResponseEventDTO = isSendDataSsmSessionsListWebSocketResponseEventDTO;
3658
- 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;
3659
3534
  exports.isStringJson = isStringJson;
3660
- exports.isSubmissionRunStatusMessageWebSocketResponseEventDTO = isSubmissionRunStatusMessageWebSocketResponseEventDTO;
3661
- exports.isSubmissionsCrawlWebSocketResponseEventDTO = isSubmissionsCrawlWebSocketResponseEventDTO;
3662
- exports.isSubscribeClientTrackDataWebSocketEventDTO = isSubscribeClientTrackDataWebSocketEventDTO;
3663
- exports.isSubscribeClientTrackWebSocketEventDTO = isSubscribeClientTrackWebSocketEventDTO;
3664
- exports.isSubscribeCodeRunStatusWebSocketEventDTO = isSubscribeCodeRunStatusWebSocketEventDTO;
3665
- exports.isSubscribeContestChangesWebSocketEventDTO = isSubscribeContestChangesWebSocketEventDTO;
3666
- exports.isSubscribeGetDataWebSocketEventDTO = isSubscribeGetDataWebSocketEventDTO;
3667
- exports.isSubscribeProblemCrawledWebSocketEventDTO = isSubscribeProblemCrawledWebSocketEventDTO;
3668
- exports.isSubscribeSubmissionRunStatusWebSocketEventDTO = isSubscribeSubmissionRunStatusWebSocketEventDTO;
3669
- exports.isSubscribeSubmissionsCrawlWebSocketEventDTO = isSubscribeSubmissionsCrawlWebSocketEventDTO;
3670
- 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;
3671
3544
  exports.isTeamMember = isTeamMember;
3672
- exports.isUnsubscribeClientTrackDataWebSocketEventDTO = isUnsubscribeClientTrackDataWebSocketEventDTO;
3673
- exports.isUnsubscribeClientTrackWebSocketEventDTO = isUnsubscribeClientTrackWebSocketEventDTO;
3674
- exports.isUnsubscribeCodeRunStatusWebSocketEventDTO = isUnsubscribeCodeRunStatusWebSocketEventDTO;
3675
- exports.isUnsubscribeContestChangesWebSocketEventDTO = isUnsubscribeContestChangesWebSocketEventDTO;
3676
- exports.isUnsubscribeGetDataWebSocketEventDTO = isUnsubscribeGetDataWebSocketEventDTO;
3677
- exports.isUnsubscribeProblemCrawledWebSocketEventDTO = isUnsubscribeProblemCrawledWebSocketEventDTO;
3678
- exports.isUnsubscribeSubmissionRunStatusWebSocketEventDTO = isUnsubscribeSubmissionRunStatusWebSocketEventDTO;
3679
- exports.isUnsubscribeSubmissionsCrawlWebSocketEventDTO = isUnsubscribeSubmissionsCrawlWebSocketEventDTO;
3680
- 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;
3681
3553
  exports.isUserMember = isUserMember;
3682
- exports.isUserMessageWebSocketResponseEventDTO = isUserMessageWebSocketResponseEventDTO;
3683
- exports.isUserNotificationContestClarificationWebSocketResponseEventDTO = isUserNotificationContestClarificationWebSocketResponseEventDTO;
3684
- exports.isUserNotificationSubmissionWebSocketResponseEventDTO = isUserNotificationSubmissionWebSocketResponseEventDTO;
3685
- exports.isUserNotificationWebSocketResponseEventDTO = isUserNotificationWebSocketResponseEventDTO;
3686
- exports.isWebSocketChannelsMessageDTO = isWebSocketChannelsMessageDTO;
3687
- 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;
3688
3561
  exports.isWebsocketSubscription = isWebsocketSubscription;
3562
+ exports.isWithinInterval = isWithinInterval;
3689
3563
  exports.isWorksheetAssignment = isWorksheetAssignment;
3564
+ exports.isYearAfter = isYearAfter;
3565
+ exports.isYearBefore = isYearBefore;
3690
3566
  exports.join = join;
3691
3567
  exports.lettersToIndex = lettersToIndex;
3692
3568
  exports.memorySizeOf = memorySizeOf;
@@ -3698,12 +3574,21 @@ exports.normalizeToLocalStartOfMinutes = normalizeToLocalStartOfMinutes;
3698
3574
  exports.normalizeToLocalStartOfSeconds = normalizeToLocalStartOfSeconds;
3699
3575
  exports.objectUpdate = objectUpdate;
3700
3576
  exports.objectsUpdate = objectsUpdate;
3577
+ exports.padEnd = padEnd;
3578
+ exports.padStart = padStart;
3701
3579
  exports.range = range;
3702
3580
  exports.removeExtension = removeExtension;
3703
3581
  exports.safeJsonParse = safeJsonParse;
3704
3582
  exports.setAsyncInterval = setAsyncInterval;
3705
3583
  exports.split = split;
3706
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;
3707
3592
  exports.stringToArrayBuffer = stringToArrayBuffer;
3708
- exports.toEntityMembersDTO = toEntityMembersDTO;
3593
+ exports.toEntityMembersDto = toEntityMembersDto;
3709
3594
  exports.toJkError = toJkError;