@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
package/dist/esm/index.js CHANGED
@@ -89,20 +89,20 @@ var EntityAccess;
89
89
  EntityAccess["EXPOSED"] = "EXPOSED";
90
90
  })(EntityAccess || (EntityAccess = {}));
91
91
 
92
- var CompanyPlan;
93
- (function (CompanyPlan) {
94
- CompanyPlan["FREE"] = "FREE";
95
- CompanyPlan["STANDARD"] = "STANDARD";
96
- CompanyPlan["PREMIUM"] = "PREMIUM";
97
- CompanyPlan["CUSTOM"] = "CUSTOM";
98
- })(CompanyPlan || (CompanyPlan = {}));
99
- var CompanyLogoType;
100
- (function (CompanyLogoType) {
101
- CompanyLogoType["HORIZONTAL_WHITE"] = "horizontal-white";
102
- CompanyLogoType["HORIZONTAL_COLOR"] = "horizontal-color";
103
- CompanyLogoType["VERTICAL_WHITE"] = "vertical-white";
104
- CompanyLogoType["VERTICAL_COLOR"] = "vertical-color";
105
- })(CompanyLogoType || (CompanyLogoType = {}));
92
+ var OrganizationPlan;
93
+ (function (OrganizationPlan) {
94
+ OrganizationPlan["FREE"] = "FREE";
95
+ OrganizationPlan["STANDARD"] = "STANDARD";
96
+ OrganizationPlan["PREMIUM"] = "PREMIUM";
97
+ OrganizationPlan["CUSTOM"] = "CUSTOM";
98
+ })(OrganizationPlan || (OrganizationPlan = {}));
99
+ var OrganizationLogoType;
100
+ (function (OrganizationLogoType) {
101
+ OrganizationLogoType["HORIZONTAL_WHITE"] = "horizontal-white";
102
+ OrganizationLogoType["HORIZONTAL_COLOR"] = "horizontal-color";
103
+ OrganizationLogoType["VERTICAL_WHITE"] = "vertical-white";
104
+ OrganizationLogoType["VERTICAL_COLOR"] = "vertical-color";
105
+ })(OrganizationLogoType || (OrganizationLogoType = {}));
106
106
 
107
107
  var ContestStatus;
108
108
  (function (ContestStatus) {
@@ -145,7 +145,7 @@ var EntityState;
145
145
  })(EntityState || (EntityState = {}));
146
146
  var EntityCollection;
147
147
  (function (EntityCollection) {
148
- EntityCollection["COMPANY"] = "COMPANY";
148
+ EntityCollection["ORGANIZATION"] = "ORGANIZATION";
149
149
  EntityCollection["PROBLEM"] = "PROBLEM";
150
150
  EntityCollection["CONTEST"] = "CONTEST";
151
151
  EntityCollection["JUDGE"] = "JUDGE";
@@ -154,7 +154,7 @@ var EntityCollection;
154
154
  })(EntityCollection || (EntityCollection = {}));
155
155
  var CollectionKey;
156
156
  (function (CollectionKey) {
157
- CollectionKey["COMPANY"] = "C";
157
+ CollectionKey["ORGANIZATION"] = "C";
158
158
  CollectionKey["USER"] = "U";
159
159
  CollectionKey["PROBLEM"] = "P";
160
160
  CollectionKey["CLASS"] = "K";
@@ -526,7 +526,7 @@ var ErrorCode;
526
526
  ErrorCode["ERR0818"] = "ERR0818";
527
527
  ErrorCode["ERR0819"] = "ERR0819";
528
528
  ErrorCode["ERR0820"] = "ERR0820";
529
- // Company Errors ERR99XXX',
529
+ // Organization Errors ERR99XXX',
530
530
  ErrorCode["ERR9900"] = "ERR9900";
531
531
  ErrorCode["ERR9910"] = "ERR9910";
532
532
  ErrorCode["ERR9911"] = "ERR9911";
@@ -572,14 +572,10 @@ var QuizScoringMode;
572
572
  QuizScoringMode["PARTIAL"] = "PARTIAL";
573
573
  })(QuizScoringMode || (QuizScoringMode = {}));
574
574
 
575
- var WebSocketMessageEvent;
576
- (function (WebSocketMessageEvent) {
577
- WebSocketMessageEvent["PING"] = "PING";
578
- WebSocketMessageEvent["CLIENT_TRACK_LOCATION"] = "CLIENT_TRACK_LOCATION";
579
- WebSocketMessageEvent["CLIENT_TRACK_SCREENSHOT"] = "CLIENT_TRACK_SCREENSHOT";
580
- WebSocketMessageEvent["CLIENT_TRACK_DEVICE"] = "CLIENT_TRACK_DEVICE";
581
- WebSocketMessageEvent["CHAT_COMPLETIONS"] = "CHAT_COMPLETIONS";
582
- })(WebSocketMessageEvent || (WebSocketMessageEvent = {}));
575
+ /**
576
+ * Subscriptions of the client. With the TOPIC channels they are not sent to the server anymore:
577
+ * they only say which channel the client attaches (`getChannelOfWebSocketSubscribeEvent`) and the dispatch key.
578
+ */
583
579
  var WebSocketSubscriptionEvent;
584
580
  (function (WebSocketSubscriptionEvent) {
585
581
  WebSocketSubscriptionEvent["SUBSCRIBE_CODE_RUN_STATUS"] = "SUBSCRIBE_CODE_RUN_STATUS";
@@ -594,17 +590,11 @@ var WebSocketSubscriptionEvent;
594
590
  WebSocketSubscriptionEvent["UNSUBSCRIBE_SUBMISSIONS_CRAWL"] = "UNSUBSCRIBE_SUBMISSIONS_CRAWL";
595
591
  WebSocketSubscriptionEvent["SUBSCRIBE_CONTEST_CHANGES"] = "SUBSCRIBE_CONTEST_CHANGES";
596
592
  WebSocketSubscriptionEvent["UNSUBSCRIBE_CONTEST_CHANGES"] = "UNSUBSCRIBE_CONTEST_CHANGES";
597
- WebSocketSubscriptionEvent["SUBSCRIBE_CLIENT_TRACK"] = "SUBSCRIBE_CLIENT_TRACK";
598
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CLIENT_TRACK"] = "UNSUBSCRIBE_CLIENT_TRACK";
599
593
  WebSocketSubscriptionEvent["SUBSCRIBE_USER_NOTIFICATION"] = "SUBSCRIBE_USER_NOTIFICATION";
600
594
  WebSocketSubscriptionEvent["UNSUBSCRIBE_USER_NOTIFICATION"] = "UNSUBSCRIBE_USER_NOTIFICATION";
601
- // an administrator watching the data (screenshots, location, device) sent by another client
602
- WebSocketSubscriptionEvent["SUBSCRIBE_CLIENT_TRACK_DATA"] = "SUBSCRIBE_CLIENT_TRACK_DATA";
603
- WebSocketSubscriptionEvent["UNSUBSCRIBE_CLIENT_TRACK_DATA"] = "UNSUBSCRIBE_CLIENT_TRACK_DATA";
604
595
  })(WebSocketSubscriptionEvent || (WebSocketSubscriptionEvent = {}));
605
596
  var WebSocketResponseEvent;
606
597
  (function (WebSocketResponseEvent) {
607
- WebSocketResponseEvent["PONG"] = "PONG";
608
598
  WebSocketResponseEvent["CODE_RUN_STATUS"] = "CODE_RUN_STATUS";
609
599
  WebSocketResponseEvent["SUBMISSION_RUN_STATUS"] = "SUBMISSION_RUN_STATUS";
610
600
  WebSocketResponseEvent["USER_MESSAGE"] = "USER_MESSAGE";
@@ -614,12 +604,9 @@ var WebSocketResponseEvent;
614
604
  WebSocketResponseEvent["SEND_DATA_EC2_INSTANCES_LIST"] = "SEND_DATA_EC2_INSTANCES_LIST";
615
605
  WebSocketResponseEvent["SEND_DATA_SSM_SESSIONS_LIST"] = "SEND_DATA_SSM_SESSIONS_LIST";
616
606
  WebSocketResponseEvent["SEND_DATA_RUN_COMMAND"] = "SEND_DATA_RUN_COMMAND";
617
- WebSocketResponseEvent["SEND_DATA_CLIENT_TRACK"] = "SEND_DATA_CLIENT_TRACK";
618
- WebSocketResponseEvent["SEND_DATA_CHAT_COMPLETIONS"] = "SEND_DATA_CHAT_COMPLETIONS";
619
607
  WebSocketResponseEvent["PROBLEM_CRAWLED"] = "PROBLEM_CRAWLED";
620
608
  WebSocketResponseEvent["SUBMISSIONS_CRAWL"] = "SUBMISSIONS_CRAWL";
621
609
  WebSocketResponseEvent["CONTEST_CHANGES"] = "CONTEST_CHANGES";
622
- WebSocketResponseEvent["CLIENT_TRACK"] = "CLIENT_TRACK";
623
610
  WebSocketResponseEvent["USER_NOTIFICATION_"] = "USER_NOTIFICATION_";
624
611
  WebSocketResponseEvent["USER_NOTIFICATION_SUBMISSION"] = "USER_NOTIFICATION_SUBMISSION";
625
612
  WebSocketResponseEvent["USER_NOTIFICATION_CONTEST_CLARIFICATION"] = "USER_NOTIFICATION_CONTEST_CLARIFICATION";
@@ -1331,25 +1318,25 @@ const HEADER_JUKI_SECRET_TOKEN = 'x-juki-secret-token';
1331
1318
  const HEADER_JUKI_INTERNAL_API_KEY = 'x-juki-internal-api-key';
1332
1319
  const COOKIE_JUKI_SESSION_ID = 'juki-session-id';
1333
1320
 
1334
- const JUKI_APP_COMPANY_KEY = 'juki-app';
1335
- const COMPANY_PLAN = {
1336
- [CompanyPlan.FREE]: {
1337
- value: CompanyPlan.FREE,
1321
+ const JUKI_APP_ORGANIZATION_KEY = 'juki-app';
1322
+ const ORGANIZATION_PLAN = {
1323
+ [OrganizationPlan.FREE]: {
1324
+ value: OrganizationPlan.FREE,
1338
1325
  label: 'free',
1339
1326
  description: 'the resources, runners and compilers, are shared with the juki.app giving priority to juki.app',
1340
1327
  },
1341
- [CompanyPlan.STANDARD]: {
1342
- value: CompanyPlan.STANDARD,
1328
+ [OrganizationPlan.STANDARD]: {
1329
+ value: OrganizationPlan.STANDARD,
1343
1330
  label: 'standard',
1344
1331
  description: 'the resources are dedicated, 1 runner and 1 compiler',
1345
1332
  },
1346
- [CompanyPlan.PREMIUM]: {
1347
- value: CompanyPlan.PREMIUM,
1333
+ [OrganizationPlan.PREMIUM]: {
1334
+ value: OrganizationPlan.PREMIUM,
1348
1335
  label: 'premium',
1349
1336
  description: 'the resources are dedicated and on demand use with at least 1 runner and 1 compiler',
1350
1337
  },
1351
- [CompanyPlan.CUSTOM]: {
1352
- value: CompanyPlan.CUSTOM,
1338
+ [OrganizationPlan.CUSTOM]: {
1339
+ value: OrganizationPlan.CUSTOM,
1353
1340
  label: 'custom',
1354
1341
  description: 'the resources are dedicated and on demand use with at least 1 (settable) runner and 1 (settable) compiler',
1355
1342
  },
@@ -1972,18 +1959,18 @@ const ERROR = {
1972
1959
  [ErrorCode.ERR9997]: { value: ErrorCode.ERR9997, message: 'aborted request', status: 400 },
1973
1960
  [ErrorCode.ERR9998]: { value: ErrorCode.ERR9998, message: 'error on response', status: 400 },
1974
1961
  [ErrorCode.ERR9999]: { value: ErrorCode.ERR9999, message: 'service no found', status: 400 },
1975
- // COMPANY ERRORS ERR99XX
1976
- [ErrorCode.ERR9900]: { value: ErrorCode.ERR9900, message: 'internal server error on company service', status: 500 },
1977
- // Company server errors
1978
- [ErrorCode.ERR9910]: { value: ErrorCode.ERR9910, message: 'company not created', status: 500 },
1979
- [ErrorCode.ERR9911]: { value: ErrorCode.ERR9911, message: 'company not found', status: 500 },
1980
- [ErrorCode.ERR9912]: { value: ErrorCode.ERR9912, message: 'company not updated', status: 500 },
1981
- [ErrorCode.ERR9913]: { value: ErrorCode.ERR9913, message: 'company not deleted', status: 500 },
1982
- // Company user permission error
1983
- [ErrorCode.ERR9914]: { value: ErrorCode.ERR9914, message: 'not allowed to create the company', status: 400 },
1984
- [ErrorCode.ERR9915]: { value: ErrorCode.ERR9915, message: 'not allowed to view the company', status: 400 },
1985
- [ErrorCode.ERR9916]: { value: ErrorCode.ERR9916, message: 'not allowed to updated the company', status: 400 },
1986
- [ErrorCode.ERR9917]: { value: ErrorCode.ERR9917, message: 'not allowed to deleted the company', status: 400 },
1962
+ // ORGANIZATION ERRORS ERR99XX
1963
+ [ErrorCode.ERR9900]: { value: ErrorCode.ERR9900, message: 'internal server error on organization service', status: 500 },
1964
+ // Organization server errors
1965
+ [ErrorCode.ERR9910]: { value: ErrorCode.ERR9910, message: 'organization not created', status: 500 },
1966
+ [ErrorCode.ERR9911]: { value: ErrorCode.ERR9911, message: 'organization not found', status: 500 },
1967
+ [ErrorCode.ERR9912]: { value: ErrorCode.ERR9912, message: 'organization not updated', status: 500 },
1968
+ [ErrorCode.ERR9913]: { value: ErrorCode.ERR9913, message: 'organization not deleted', status: 500 },
1969
+ // Organization user permission error
1970
+ [ErrorCode.ERR9914]: { value: ErrorCode.ERR9914, message: 'not allowed to create the organization', status: 400 },
1971
+ [ErrorCode.ERR9915]: { value: ErrorCode.ERR9915, message: 'not allowed to view the organization', status: 400 },
1972
+ [ErrorCode.ERR9916]: { value: ErrorCode.ERR9916, message: 'not allowed to updated the organization', status: 400 },
1973
+ [ErrorCode.ERR9917]: { value: ErrorCode.ERR9917, message: 'not allowed to deleted the organization', status: 400 },
1987
1974
  // USER ERRORS ERR00XX
1988
1975
  [ErrorCode.ERR0000]: { value: ErrorCode.ERR0000, message: 'internal server error on users service', status: 500 },
1989
1976
  // User server errors
@@ -2229,7 +2216,7 @@ const EMPTY_USER_PERMISSIONS = {
2229
2216
  create: false,
2230
2217
  manage: false,
2231
2218
  },
2232
- company: {
2219
+ organization: {
2233
2220
  manage: false,
2234
2221
  administrate: false,
2235
2222
  },
@@ -2238,18 +2225,12 @@ const EMPTY_USER_PERMISSIONS = {
2238
2225
  },
2239
2226
  };
2240
2227
 
2241
- // LEGACY channels (fan-out per client through the subscriptions registry in Redis)
2242
- const CHANNEL_PUBLISH_SUBSCRIPTIONS = 'pub:subscriptions';
2243
- const CHANNEL_SUBSCRIBE_NOTIFICATIONS = 'sub:notifications';
2244
- const CHANNEL_SUBSCRIBE_CLIENT = (clientId) => `sub:client:${clientId}`;
2245
- const CHANNEL_PUBLISH_MESSAGES = 'pub:messages';
2246
- const CHANNEL_PRESENCE_CLIENT = 'pre:client';
2247
2228
  // TOPIC channels
2248
2229
  // The backend publishes each event once on the channel of its topic and Ably does the fan-out.
2249
2230
  // Who can subscribe to each channel is decided by the API in the Ably token (capability), never by the client.
2250
2231
  // Dynamic segments are encoded so a key can never inject a `:` (the Ably segment separator used by the wildcards).
2251
2232
  const segment = (value) => encodeURIComponent(value);
2252
- /** private: events of one session (code runs, requested data, client track commands) */
2233
+ /** private: events of one session (code runs, requested data) */
2253
2234
  const CHANNEL_SESSION = (sessionId) => `session:${segment(sessionId)}`;
2254
2235
  /** private: events of one user (own submissions while the contest is frozen, notifications) */
2255
2236
  const CHANNEL_USER = (userId) => `user:${segment(userId)}`;
@@ -2259,12 +2240,17 @@ const CHANNEL_SUBMISSION = (submitId) => `submission:${segment(submitId)}`;
2259
2240
  const CHANNEL_PROBLEM = (problemKey) => `problem:${segment(problemKey)}`;
2260
2241
  /** per role: events of a contest for one role (and the roles above it, see `ContestChannelRole`) */
2261
2242
  const CHANNEL_CONTEST = (contestKey, role) => `contest:${segment(contestKey)}:${role}`;
2262
- /** system administrators only: data sent by a tracked client (screenshots, location, device) */
2263
- const CHANNEL_CLIENT_TRACK = (trackedClientId) => `client-track:${segment(trackedClientId)}`;
2243
+ /**
2244
+ * presence of the clients (tabs) of the logged users of a organization (by its key), data: `UserPresenceData`.
2245
+ * The clients only enter (capability `presence`), only the administrators of the organization receive it
2246
+ * (capability `presence-subscribe`). Ably limits the presence members per channel (200 by default,
2247
+ * more with server-side batching enabled on the `presence` namespace).
2248
+ * The identity of a member is its `clientId` (`sessionId|uiId`, verified by Ably), never its data.
2249
+ */
2250
+ const CHANNEL_ORGANIZATION_PRESENCE = (organizationKey) => `presence:organization:${segment(organizationKey)}`;
2264
2251
  // capability resources (wildcards) of the public channels
2265
2252
  const CHANNEL_SUBMISSION_ALL = 'submission:*';
2266
2253
  const CHANNEL_PROBLEM_ALL = 'problem:*';
2267
- const CHANNEL_CLIENT_TRACK_ALL = 'client-track:*';
2268
2254
  /**
2269
2255
  * Returns the contest and role of a `CHANNEL_CONTEST` channel name, or null if it is not one.
2270
2256
  */
@@ -2366,31 +2352,212 @@ const isContestAssignment = (assignment) => {
2366
2352
  };
2367
2353
 
2368
2354
  const getAssignmentCommentKey = (classKey, cycleKey, sessionKey, assignmentKey) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}`;
2369
- const getAssignmentUserCommentKey = (classKey, cycleKey, sessionKey, assignmentKey, userNickname, userCompany) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}|user_nickname:${userNickname}|user_company:${userCompany}`;
2355
+ const getAssignmentUserCommentKey = (classKey, cycleKey, sessionKey, assignmentKey, userNickname, userOrganization) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}|user_nickname:${userNickname}|user_organization:${userOrganization}`;
2370
2356
  const getProblemCommentKey = (problemKey) => `problem:${problemKey}`;
2371
2357
  const getContestCommentKey = (contestKey) => `contest:${contestKey}`;
2372
2358
 
2373
2359
  const isEndlessContest = (settings) => {
2374
- return settings?.startTimestamp === MIN_DATE.getTime()
2375
- && settings?.frozenTimestamp === MAX_DATE.getTime()
2376
- && settings?.quietTimestamp === MAX_DATE.getTime()
2377
- && settings?.endTimestamp === MAX_DATE.getTime()
2360
+ return settings?.startsAt === MIN_DATE.getTime()
2361
+ && settings?.frozenAt === MAX_DATE.getTime()
2362
+ && settings?.silencedAt === MAX_DATE.getTime()
2363
+ && settings?.endsAt === MAX_DATE.getTime()
2378
2364
  && settings?.penalty === 0;
2379
2365
  };
2380
2366
  const isGlobalContest = (settings) => {
2381
- return settings?.startTimestamp === 0
2382
- && settings?.frozenTimestamp === 0
2383
- && settings?.quietTimestamp === 0
2384
- && settings?.endTimestamp === 0
2367
+ return settings?.startsAt === 0
2368
+ && settings?.frozenAt === 0
2369
+ && settings?.silencedAt === 0
2370
+ && settings?.endsAt === 0
2385
2371
  && settings?.penalty === 0;
2386
2372
  };
2387
2373
  const isPastContest = (settings) => {
2388
- return Date.now() > (settings?.endTimestamp ?? 0);
2374
+ return Date.now() > (settings?.endsAt ?? 0);
2389
2375
  };
2390
2376
  const isFutureContest = (settings) => {
2391
- return (settings?.startTimestamp ?? 0) > Date.now();
2377
+ return (settings?.startsAt ?? 0) > Date.now();
2392
2378
  };
2393
2379
 
2380
+ const changeYear = (date, year) => {
2381
+ const newDate = new Date(date);
2382
+ newDate.setFullYear(year);
2383
+ return newDate;
2384
+ };
2385
+ const changeMonth = (date, monthIndex) => {
2386
+ const newDate = new Date(date);
2387
+ newDate.setMonth(monthIndex);
2388
+ return newDate;
2389
+ };
2390
+ const changeDay = (date, day) => {
2391
+ const newDate = new Date(date);
2392
+ newDate.setDate(day);
2393
+ return newDate;
2394
+ };
2395
+ const changeHours = (date, hours) => {
2396
+ const newDate = new Date(date);
2397
+ newDate.setHours(hours);
2398
+ return newDate;
2399
+ };
2400
+ const changeMinutes = (date, minutes) => {
2401
+ const newDate = new Date(date);
2402
+ newDate.setMinutes(minutes);
2403
+ return newDate;
2404
+ };
2405
+ const changeSeconds = (date, seconds) => {
2406
+ const newDate = new Date(date);
2407
+ newDate.setSeconds(seconds);
2408
+ return newDate;
2409
+ };
2410
+ const changeMilliseconds = (date, milliseconds) => {
2411
+ const newDate = new Date(date);
2412
+ newDate.setMilliseconds(milliseconds);
2413
+ return newDate;
2414
+ };
2415
+ const decreaseYear = (date, count = 1) => changeYear(date, date.getFullYear() - count);
2416
+ const increaseYear = (date, count = 1) => changeYear(date, date.getFullYear() + count);
2417
+ const decreaseMonth = (date) => {
2418
+ const newDate = new Date(date);
2419
+ newDate.setMonth(newDate.getMonth() - 1);
2420
+ return newDate;
2421
+ };
2422
+ const increaseMonth = (date) => {
2423
+ const newDate = new Date(date);
2424
+ newDate.setMonth(newDate.getMonth() + 1);
2425
+ return newDate;
2426
+ };
2427
+ const decreaseDay = (date) => {
2428
+ const newDate = new Date(date);
2429
+ newDate.setDate(newDate.getDate() - 1);
2430
+ return newDate;
2431
+ };
2432
+ const increaseDay = (date) => {
2433
+ const newDate = new Date(date);
2434
+ newDate.setDate(newDate.getDate() + 1);
2435
+ return newDate;
2436
+ };
2437
+ const startOfDay = (date) => {
2438
+ const newDate = new Date(date);
2439
+ newDate.setHours(0, 0, 0, 0);
2440
+ return newDate;
2441
+ };
2442
+ const endOfDay = (date) => {
2443
+ const newDate = new Date(date);
2444
+ newDate.setHours(23, 59, 59, 999);
2445
+ return newDate;
2446
+ };
2447
+ const startOfMonth = (date) => {
2448
+ const newDate = new Date(date);
2449
+ newDate.setDate(1);
2450
+ return startOfDay(newDate);
2451
+ };
2452
+ const endOfMonth = (date) => {
2453
+ const nextMonth = startOfMonth(increaseMonth(date));
2454
+ return new Date(nextMonth.getTime() - 1);
2455
+ };
2456
+ const startOfYear = (date) => {
2457
+ const newDate = new Date(date);
2458
+ newDate.setMonth(0);
2459
+ return startOfMonth(newDate);
2460
+ };
2461
+ const endOfYear = (date) => {
2462
+ const nextYear = startOfYear(increaseYear(date));
2463
+ return new Date(nextYear.getTime() - 1);
2464
+ };
2465
+ const startOfWeek = (date) => {
2466
+ const newDate = new Date(date);
2467
+ while (newDate.getDay()) {
2468
+ newDate.setDate(newDate.getDate() - 1);
2469
+ }
2470
+ return startOfDay(newDate);
2471
+ };
2472
+ const endOfWeek = (date) => {
2473
+ const newDate = new Date(date);
2474
+ while (newDate.getDay() < 6) {
2475
+ newDate.setDate(newDate.getDate() + 1);
2476
+ }
2477
+ return endOfDay(newDate);
2478
+ };
2479
+ const startOfHour = (date) => {
2480
+ const newDate = new Date(date);
2481
+ newDate.setMinutes(0, 0, 0);
2482
+ return newDate;
2483
+ };
2484
+ const endOfHour = (date) => {
2485
+ const newDate = new Date(date);
2486
+ newDate.setMinutes(59, 59, 999);
2487
+ return newDate;
2488
+ };
2489
+ const startOfMinute = (date) => {
2490
+ const newDate = new Date(date);
2491
+ newDate.setSeconds(0, 0);
2492
+ return newDate;
2493
+ };
2494
+ const endOfMinute = (date) => {
2495
+ const newDate = new Date(date);
2496
+ newDate.setSeconds(59, 999);
2497
+ return newDate;
2498
+ };
2499
+ const startOfSecond = (date) => {
2500
+ const newDate = new Date(date);
2501
+ newDate.setMilliseconds(0);
2502
+ return newDate;
2503
+ };
2504
+ const endOfSecond = (date) => {
2505
+ const newDate = new Date(date);
2506
+ newDate.setMilliseconds(999);
2507
+ return newDate;
2508
+ };
2509
+ const isEqual = (a, b) => a.getTime() === b.getTime();
2510
+ const isSameYear = (a, b) => a.getFullYear() === b.getFullYear();
2511
+ const isSameMonth = (a, b) => isSameYear(a, b) && a.getMonth() === b.getMonth();
2512
+ const isSameDay = (a, b) => isSameMonth(a, b) && a.getDate() === b.getDate();
2513
+ const isSameHour = (a, b) => isSameDay(a, b) && a.getHours() === b.getHours();
2514
+ const isSameMinute = (a, b) => isSameHour(a, b) && a.getMinutes() === b.getMinutes();
2515
+ const isSameSecond = (a, b) => isSameMinute(a, b) && a.getSeconds() === b.getSeconds();
2516
+ const isSameMillisecond = (a, b) => isEqual(a, b);
2517
+ const isToday = (date) => isSameDay(date, new Date());
2518
+ const isValidDate = (date) => date instanceof Date && !Number.isNaN(date.getTime());
2519
+ const isAfter = (a, b) => a.getTime() > b.getTime();
2520
+ const isBefore = (a, b) => a.getTime() < b.getTime();
2521
+ const isYearAfter = (a, b) => a.getFullYear() > b.getFullYear();
2522
+ const isMonthAfter = (a, b) => isYearAfter(a, b) || (isSameYear(a, b) && a.getMonth() > b.getMonth());
2523
+ const isDayAfter = (a, b) => isMonthAfter(a, b) || (isSameMonth(a, b) && a.getDate() > b.getDate());
2524
+ const isHoursAfter = (a, b) => isDayAfter(a, b) || (isSameDay(a, b) && a.getHours() > b.getHours());
2525
+ const isMinutesAfter = (a, b) => isHoursAfter(a, b) || (isSameHour(a, b) && a.getMinutes() > b.getMinutes());
2526
+ const isSecondsAfter = (a, b) => isMinutesAfter(a, b) || (isSameMinute(a, b) && a.getSeconds() > b.getSeconds());
2527
+ const isMillisecondsAfter = (a, b) => isSecondsAfter(a, b) || (isSameSecond(a, b) && a.getMilliseconds() > b.getMilliseconds());
2528
+ const isYearBefore = (a, b) => a.getFullYear() < b.getFullYear();
2529
+ const isMonthBefore = (a, b) => isYearBefore(a, b) || (isSameYear(a, b) && a.getMonth() < b.getMonth());
2530
+ const isDayBefore = (a, b) => isMonthBefore(a, b) || (isSameMonth(a, b) && a.getDate() < b.getDate());
2531
+ const isHoursBefore = (a, b) => isDayBefore(a, b) || (isSameDay(a, b) && a.getHours() < b.getHours());
2532
+ const isMinutesBefore = (a, b) => isHoursBefore(a, b) || (isSameHour(a, b) && a.getMinutes() < b.getMinutes());
2533
+ const isSecondsBefore = (a, b) => isMinutesBefore(a, b) || (isSameMinute(a, b) && a.getSeconds() < b.getSeconds());
2534
+ const isMillisecondsBefore = (a, b) => isSecondsBefore(a, b) || (isSameSecond(a, b) && a.getMilliseconds() < b.getMilliseconds());
2535
+ const isWithinInterval = (date, { start, end }, cmp = '[]') => (cmp.charAt(0) === '[' ? isEqual(date, start) || isAfter(date, start) : isAfter(date, start)) &&
2536
+ (cmp.charAt(1) === ']' ? isEqual(date, end) || isBefore(date, end) : isBefore(date, end));
2537
+ const normalizeToLocalStartOfDay = (timestamp) => {
2538
+ const d = new Date(timestamp);
2539
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
2540
+ };
2541
+ const normalizeToLocalStartOfHour = (timestamp) => {
2542
+ const d = new Date(timestamp);
2543
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
2544
+ };
2545
+ const normalizeToLocalStartOfMinutes = (timestamp) => {
2546
+ const d = new Date(timestamp);
2547
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes());
2548
+ };
2549
+ const normalizeToLocalStartOfSeconds = (timestamp) => {
2550
+ const d = new Date(timestamp);
2551
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
2552
+ };
2553
+ const getYears = (d) => d.getFullYear();
2554
+ const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
2555
+ const getDays = (d) => Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
2556
+ const getHours = (d) => Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
2557
+ const getMinutes = (d) => Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
2558
+ const getSeconds = (d) => Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
2559
+ const getMilliseconds = (d) => d.getTime();
2560
+
2394
2561
  const getDocumentAccess = (document) => {
2395
2562
  switch (true) {
2396
2563
  case (document?.members?.rankAdministrators === EntityMembersRank.NONE || document?.members?.rankAdministrators === EntityMembersRank.CLOSE)
@@ -2427,7 +2594,7 @@ const isUserMember = (member) => {
2427
2594
  const isTeamMember = (member) => {
2428
2595
  return typeof member.teamId === 'string';
2429
2596
  };
2430
- const toEntityMembersDTO = (members) => {
2597
+ const toEntityMembersDto = (members) => {
2431
2598
  return {
2432
2599
  rankAdministrators: members.rankAdministrators,
2433
2600
  administrators: Object.keys(members.administrators),
@@ -2442,6 +2609,21 @@ const toEntityMembersDTO = (members) => {
2442
2609
  };
2443
2610
  };
2444
2611
 
2612
+ class JkError extends Error {
2613
+ constructor(code, custom) {
2614
+ const message = custom?.message || ERROR[code].message;
2615
+ super(message);
2616
+ this.message = message;
2617
+ this.code = code;
2618
+ if (custom?.stack) {
2619
+ this.stack = custom.stack;
2620
+ }
2621
+ if (custom?.data) {
2622
+ this.data = custom.data;
2623
+ }
2624
+ }
2625
+ }
2626
+
2445
2627
  function removeExtension(fileName) {
2446
2628
  const i = fileName.lastIndexOf('.');
2447
2629
  return i !== -1 ? fileName.substring(0, i) : fileName;
@@ -2596,6 +2778,9 @@ const getDataLog = (log) => {
2596
2778
  };
2597
2779
  };
2598
2780
 
2781
+ const padStart = (n, maxLength, fillString = '0') => `${n}`.padStart(maxLength, fillString);
2782
+ const padEnd = (n, maxLength, fillString = '0') => `${n}`.padEnd(maxLength, fillString);
2783
+
2599
2784
  function memorySizeOf(obj) {
2600
2785
  let bytes = 0;
2601
2786
  function sizeOf(obj) {
@@ -2630,247 +2815,6 @@ function memorySizeOf(obj) {
2630
2815
  return sizeOf(obj);
2631
2816
  }
2632
2817
 
2633
- /* eslint-disable no-extend-native */
2634
- Date.prototype.changeYear = function (year) {
2635
- const newDate = new Date(this);
2636
- newDate.setFullYear(year);
2637
- return newDate;
2638
- };
2639
- Date.prototype.changeMonth = function (monthIndex) {
2640
- const newDate = new Date(this);
2641
- newDate.setMonth(monthIndex);
2642
- return newDate;
2643
- };
2644
- Date.prototype.changeDay = function (date) {
2645
- const newDate = new Date(this);
2646
- newDate.setDate(date);
2647
- return newDate;
2648
- };
2649
- Date.prototype.changeHours = function (hours) {
2650
- const newDate = new Date(this);
2651
- newDate.setHours(hours);
2652
- return newDate;
2653
- };
2654
- Date.prototype.changeMinutes = function (minutes) {
2655
- const newDate = new Date(this);
2656
- newDate.setMinutes(minutes);
2657
- return newDate;
2658
- };
2659
- Date.prototype.changeSeconds = function (seconds) {
2660
- const newDate = new Date(this);
2661
- newDate.setSeconds(seconds);
2662
- return newDate;
2663
- };
2664
- Date.prototype.changeMilliseconds = function (milliseconds) {
2665
- const newDate = new Date(this);
2666
- newDate.setMilliseconds(milliseconds);
2667
- return newDate;
2668
- };
2669
- Date.prototype.decreaseYear = function (count = 1) {
2670
- return this.changeYear(this.getFullYear() - count);
2671
- };
2672
- Date.prototype.increaseYear = function (count = 1) {
2673
- return this.changeYear(this.getFullYear() + count);
2674
- };
2675
- Date.prototype.decreaseMonth = function () {
2676
- const newDate = new Date(this);
2677
- newDate.setMonth(newDate.getMonth() - 1);
2678
- return newDate;
2679
- };
2680
- Date.prototype.increaseMonth = function () {
2681
- const newDate = new Date(this);
2682
- newDate.setMonth(newDate.getMonth() + 1);
2683
- return newDate;
2684
- };
2685
- Date.prototype.increaseDay = function () {
2686
- const newDate = new Date(this);
2687
- newDate.setDate(newDate.getDate() + 1);
2688
- return newDate;
2689
- };
2690
- Date.prototype.decreaseDay = function () {
2691
- const newDate = new Date(this);
2692
- newDate.setDate(newDate.getDate() - 1);
2693
- return newDate;
2694
- };
2695
- Date.prototype.startOfYear = function () {
2696
- const newDate = new Date(this);
2697
- newDate.setMonth(0);
2698
- return newDate.startOfMonth();
2699
- };
2700
- Date.prototype.endOfYear = function () {
2701
- const nextMonth = this.increaseYear().startOfYear();
2702
- return new Date(nextMonth.getTime() - 1);
2703
- };
2704
- Date.prototype.startOfMonth = function () {
2705
- const newDate = new Date(this);
2706
- newDate.setDate(1);
2707
- return newDate.startOfDay();
2708
- };
2709
- Date.prototype.endOfMonth = function () {
2710
- const nextMonth = this.increaseMonth().startOfMonth();
2711
- return new Date(nextMonth.getTime() - 1);
2712
- };
2713
- Date.prototype.startOfWeek = function () {
2714
- const newDate = new Date(this);
2715
- while (newDate.getDay()) {
2716
- newDate.setDate(newDate.getDate() - 1);
2717
- }
2718
- return newDate.startOfDay();
2719
- };
2720
- Date.prototype.endOfWeek = function () {
2721
- const newDate = new Date(this);
2722
- while (newDate.getDay() < 6) {
2723
- newDate.setDate(newDate.getDate() - 1);
2724
- }
2725
- return newDate.endOfDay();
2726
- };
2727
- Date.prototype.startOfDay = function () {
2728
- const newDate = new Date(this);
2729
- newDate.setHours(0, 0, 0, 0);
2730
- return newDate;
2731
- };
2732
- Date.prototype.endOfDay = function () {
2733
- const newDate = new Date(this);
2734
- newDate.setHours(23, 59, 59, 999);
2735
- return newDate;
2736
- };
2737
- Date.prototype.startOfHour = function () {
2738
- const newDate = new Date(this);
2739
- newDate.setMinutes(0, 0, 0);
2740
- return newDate;
2741
- };
2742
- Date.prototype.endOfHour = function () {
2743
- const newDate = new Date(this);
2744
- newDate.setMinutes(59, 59, 999);
2745
- return newDate;
2746
- };
2747
- Date.prototype.startOfMinute = function () {
2748
- const newDate = new Date(this);
2749
- newDate.setSeconds(0, 0);
2750
- return newDate;
2751
- };
2752
- Date.prototype.endOfMinute = function () {
2753
- const newDate = new Date(this);
2754
- newDate.setSeconds(59, 999);
2755
- return newDate;
2756
- };
2757
- Date.prototype.startOfSecond = function () {
2758
- const newDate = new Date(this);
2759
- newDate.setMilliseconds(0);
2760
- return newDate;
2761
- };
2762
- Date.prototype.endOfSecond = function () {
2763
- const newDate = new Date(this);
2764
- newDate.setMilliseconds(999);
2765
- return newDate;
2766
- };
2767
- Date.prototype.isToday = function () {
2768
- const today = new Date();
2769
- return this.isSameDay(today);
2770
- };
2771
- Date.prototype.isEqual = function (date) {
2772
- return this.getTime() === date.getTime();
2773
- };
2774
- Date.prototype.isSameYear = function (date) {
2775
- return this.getFullYear() === date.getFullYear();
2776
- };
2777
- Date.prototype.isSameMonth = function (date) {
2778
- return this.isSameYear(date) && this.getMonth() === date.getMonth();
2779
- };
2780
- Date.prototype.isSameDay = function (date) {
2781
- return this.isSameMonth(date) && this.getDate() === date.getDate();
2782
- };
2783
- Date.prototype.isSameHour = function (date) {
2784
- return this.isSameDay(date) && this.getHours() === date.getHours();
2785
- };
2786
- Date.prototype.isSameMinute = function (date) {
2787
- return this.isSameHour(date) && this.getMinutes() === date.getMinutes();
2788
- };
2789
- Date.prototype.isSameSecond = function (date) {
2790
- return this.isSameMinute(date) && this.getSeconds() === date.getSeconds();
2791
- };
2792
- Date.prototype.isSameMillisecond = function (date) {
2793
- return this.isEqual(date);
2794
- };
2795
- Date.prototype.isValidDate = function () {
2796
- return this instanceof Date && !isNaN(this.getTime());
2797
- };
2798
- Date.prototype.isYearAfter = function (date) {
2799
- return this.getFullYear() > date.getFullYear();
2800
- };
2801
- Date.prototype.isMonthAfter = function (date) {
2802
- return this.isYearAfter(date) || (this.isSameYear(date) && this.getMonth() > date.getMonth());
2803
- };
2804
- Date.prototype.isDayAfter = function (date) {
2805
- return this.isMonthAfter(date) || (this.isSameMonth(date) && this.getDate() > date.getDate());
2806
- };
2807
- Date.prototype.isHoursAfter = function (date) {
2808
- return this.isDayAfter(date) || (this.isSameDay(date) && this.getHours() > date.getHours());
2809
- };
2810
- Date.prototype.isMinutesAfter = function (date) {
2811
- return this.isHoursAfter(date) || (this.isSameHour(date) && this.getMinutes() > date.getMinutes());
2812
- };
2813
- Date.prototype.isSecondsAfter = function (date) {
2814
- return this.isMinutesAfter(date) || (this.isSameMinute(date) && this.getSeconds() > date.getSeconds());
2815
- };
2816
- Date.prototype.isMillisecondsAfter = function (date) {
2817
- return this.isSecondsAfter(date) || (this.isSameSecond(date) && this.getMilliseconds() > date.getMilliseconds());
2818
- };
2819
- Date.prototype.isAfter = function (date) {
2820
- return this.getTime() > date.getTime();
2821
- };
2822
- Date.prototype.isYearBefore = function (date) {
2823
- return this.getFullYear() < date.getFullYear();
2824
- };
2825
- Date.prototype.isMonthBefore = function (date) {
2826
- return this.isYearBefore(date) || (this.isSameYear(date) && this.getMonth() < date.getMonth());
2827
- };
2828
- Date.prototype.isDayBefore = function (date) {
2829
- return this.isMonthBefore(date) || (this.isSameMonth(date) && this.getDate() < date.getDate());
2830
- };
2831
- Date.prototype.isHoursBefore = function (date) {
2832
- return this.isDayBefore(date) || (this.isSameDay(date) && this.getHours() < date.getHours());
2833
- };
2834
- Date.prototype.isMinutesBefore = function (date) {
2835
- return this.isHoursBefore(date) || (this.isSameHour(date) && this.getMinutes() < date.getMinutes());
2836
- };
2837
- Date.prototype.isSecondsBefore = function (date) {
2838
- return this.isMinutesBefore(date) || (this.isSameMinute(date) && this.getSeconds() < date.getSeconds());
2839
- };
2840
- Date.prototype.isMillisecondsBefore = function (date) {
2841
- return this.isSecondsBefore(date) || (this.isSameSecond(date) && this.getMilliseconds() < date.getMilliseconds());
2842
- };
2843
- Date.prototype.isBefore = function (date) {
2844
- return this.getTime() < date.getTime();
2845
- };
2846
- Date.prototype.isWithinInterval = function ({ start, end }, cmp = '[]') {
2847
- return (cmp.charAt(0) === '[' ? this.isEqual(start) || this.isAfter(start) : this.isAfter(start)) &&
2848
- (cmp.charAt(1) === '[' ? this.isEqual(end) || this.isBefore(end) : this.isBefore(end));
2849
- };
2850
-
2851
- class JkError extends Error {
2852
- constructor(code, custom) {
2853
- const message = custom?.message || ERROR[code].message;
2854
- super(message);
2855
- this.message = message;
2856
- this.code = code;
2857
- if (custom?.stack) {
2858
- this.stack = custom.stack;
2859
- }
2860
- if (custom?.data) {
2861
- this.data = custom.data;
2862
- }
2863
- }
2864
- }
2865
-
2866
- /* eslint-disable no-extend-native */
2867
- Number.prototype.padStart = function (maxLength, fillString = '0') {
2868
- return (this + '').padStart(maxLength, fillString);
2869
- };
2870
- Number.prototype.padEnd = function (maxLength, fillString = '0') {
2871
- return (this + '').padEnd(maxLength, fillString);
2872
- };
2873
-
2874
2818
  function toJkError(err) {
2875
2819
  const error = new Error();
2876
2820
  let code = err?.code;
@@ -2964,256 +2908,194 @@ const getDefaultMeta = (contents, sort) => {
2964
2908
  };
2965
2909
 
2966
2910
  const isWebsocketSubscription = (event) => {
2967
- return (Object.values(WebSocketSubscriptionEvent).includes(event?.event) || Object.values(WebSocketMessageEvent).includes(event?.event))
2911
+ return Object.values(WebSocketSubscriptionEvent).includes(event?.event)
2968
2912
  && typeof event?.clientId === 'string' && !!event.clientId;
2969
2913
  };
2970
- // Custom CHANNEL_PUBLISH_MESSAGES
2971
- const isPingWebSocketEventDTO = (event) => {
2972
- return isWebsocketSubscription(event)
2973
- && event?.event === WebSocketMessageEvent.PING;
2974
- };
2975
- const isClientTrackLocationWebSocketEventDTO = (event) => {
2976
- return isWebsocketSubscription(event)
2977
- && event?.event === WebSocketMessageEvent.CLIENT_TRACK_LOCATION;
2978
- };
2979
- const isClientTrackScreenshotWebSocketEventDTO = (event) => {
2980
- return isWebsocketSubscription(event)
2981
- && event?.event === WebSocketMessageEvent.CLIENT_TRACK_SCREENSHOT;
2982
- };
2983
- const isClientTrackDeviceWebSocketEventDTO = (event) => {
2984
- return isWebsocketSubscription(event)
2985
- && event?.event === WebSocketMessageEvent.CLIENT_TRACK_DEVICE;
2986
- };
2987
- const isChatCompletionsWebSocketEventDTO = (event) => {
2988
- return isWebsocketSubscription(event)
2989
- && event?.event === WebSocketMessageEvent.CHAT_COMPLETIONS;
2990
- };
2991
2914
  // CHANNEL_PUBLISH_SUBSCRIPTIONS
2992
- const isSubscribeCodeRunStatusWebSocketEventDTO = (event) => {
2915
+ const isSubscribeCodeRunStatusWebSocketEventDto = (event) => {
2993
2916
  return isWebsocketSubscription(event)
2994
2917
  && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_CODE_RUN_STATUS
2995
2918
  && typeof event?.runId === 'string' && !!event.runId;
2996
2919
  };
2997
- const isUnsubscribeCodeRunStatusWebSocketEventDTO = (event) => {
2920
+ const isUnsubscribeCodeRunStatusWebSocketEventDto = (event) => {
2998
2921
  return isWebsocketSubscription(event)
2999
2922
  && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_CODE_RUN_STATUS
3000
2923
  && typeof event?.runId === 'string' && !!event.runId;
3001
2924
  };
3002
- const isSubscribeSubmissionRunStatusWebSocketEventDTO = (event) => {
2925
+ const isSubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
3003
2926
  return isWebsocketSubscription(event)
3004
2927
  && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSION_RUN_STATUS
3005
2928
  && typeof event?.submitId === 'string' && !!event.submitId;
3006
2929
  };
3007
- const isUnsubscribeSubmissionRunStatusWebSocketEventDTO = (event) => {
2930
+ const isUnsubscribeSubmissionRunStatusWebSocketEventDto = (event) => {
3008
2931
  return isWebsocketSubscription(event)
3009
2932
  && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSION_RUN_STATUS
3010
2933
  && typeof event?.submitId === 'string' && !!event.submitId;
3011
2934
  };
3012
- const isSubscribeGetDataWebSocketEventDTO = (event) => {
2935
+ const isSubscribeGetDataWebSocketEventDto = (event) => {
3013
2936
  return isWebsocketSubscription(event)
3014
2937
  && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_GET_DATA;
3015
2938
  };
3016
- const isUnsubscribeGetDataWebSocketEventDTO = (event) => {
2939
+ const isUnsubscribeGetDataWebSocketEventDto = (event) => {
3017
2940
  return isWebsocketSubscription(event)
3018
2941
  && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_GET_DATA;
3019
2942
  };
3020
- const isSubscribeProblemCrawledWebSocketEventDTO = (event) => {
2943
+ const isSubscribeProblemCrawledWebSocketEventDto = (event) => {
3021
2944
  return isWebsocketSubscription(event)
3022
2945
  && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_PROBLEM_CRAWLED;
3023
2946
  };
3024
- const isUnsubscribeProblemCrawledWebSocketEventDTO = (event) => {
2947
+ const isUnsubscribeProblemCrawledWebSocketEventDto = (event) => {
3025
2948
  return isWebsocketSubscription(event)
3026
2949
  && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_PROBLEM_CRAWLED;
3027
2950
  };
3028
- const isSubscribeSubmissionsCrawlWebSocketEventDTO = (event) => {
2951
+ const isSubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
3029
2952
  return isWebsocketSubscription(event)
3030
2953
  && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSIONS_CRAWL;
3031
2954
  };
3032
- const isUnsubscribeSubmissionsCrawlWebSocketEventDTO = (event) => {
2955
+ const isUnsubscribeSubmissionsCrawlWebSocketEventDto = (event) => {
3033
2956
  return isWebsocketSubscription(event)
3034
2957
  && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_SUBMISSIONS_CRAWL;
3035
2958
  };
3036
- const isSubscribeContestChangesWebSocketEventDTO = (event) => {
2959
+ const isSubscribeContestChangesWebSocketEventDto = (event) => {
3037
2960
  return isWebsocketSubscription(event)
3038
2961
  && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_CONTEST_CHANGES;
3039
2962
  };
3040
- const isUnsubscribeContestChangesWebSocketEventDTO = (event) => {
2963
+ const isUnsubscribeContestChangesWebSocketEventDto = (event) => {
3041
2964
  return isWebsocketSubscription(event)
3042
2965
  && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_CONTEST_CHANGES;
3043
2966
  };
3044
- const isSubscribeClientTrackWebSocketEventDTO = (event) => {
3045
- return isWebsocketSubscription(event)
3046
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_CLIENT_TRACK;
3047
- };
3048
- const isUnsubscribeClientTrackWebSocketEventDTO = (event) => {
3049
- return isWebsocketSubscription(event)
3050
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_CLIENT_TRACK;
3051
- };
3052
- const isSubscribeUserNotificationWebSocketEventDTO = (event) => {
2967
+ const isSubscribeUserNotificationWebSocketEventDto = (event) => {
3053
2968
  return isWebsocketSubscription(event)
3054
2969
  && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_USER_NOTIFICATION;
3055
2970
  };
3056
- const isUnsubscribeUserNotificationWebSocketEventDTO = (event) => {
2971
+ const isUnsubscribeUserNotificationWebSocketEventDto = (event) => {
3057
2972
  return isWebsocketSubscription(event)
3058
2973
  && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_USER_NOTIFICATION;
3059
2974
  };
3060
- const isSubscribeClientTrackDataWebSocketEventDTO = (event) => {
3061
- return isWebsocketSubscription(event)
3062
- && event?.event === WebSocketSubscriptionEvent.SUBSCRIBE_CLIENT_TRACK_DATA
3063
- && typeof event?.trackedClientId === 'string' && !!event.trackedClientId;
3064
- };
3065
- const isUnsubscribeClientTrackDataWebSocketEventDTO = (event) => {
3066
- return isWebsocketSubscription(event)
3067
- && event?.event === WebSocketSubscriptionEvent.UNSUBSCRIBE_CLIENT_TRACK_DATA
3068
- && typeof event?.trackedClientId === 'string' && !!event.trackedClientId;
3069
- };
3070
- // is WebSocketResponseEventDTO, CHANNEL_SUBSCRIBE_CLIENT
3071
- const isWebSocketResponseEventDTO = (event) => {
2975
+ // is WebSocketResponseEventDto, CHANNEL_SUBSCRIBE_CLIENT
2976
+ const isWebSocketResponseEventDto = (event) => {
3072
2977
  return Object.values(WebSocketResponseEvent).includes(event?.event)
3073
2978
  && typeof event?.key === 'string'
3074
2979
  && typeof event?.connectionId === 'string'
3075
- && typeof event?.messageTimestamp === 'number' && !!event.messageTimestamp;
2980
+ && typeof event?.createdAt === 'number' && !!event.createdAt;
3076
2981
  };
3077
- const isPongWebSocketResponseEventDTO = (event) => {
3078
- return isWebSocketResponseEventDTO(event)
3079
- && event?.event === WebSocketResponseEvent.PONG
3080
- && !!event?.data;
3081
- };
3082
- const isCodeRunStatusMessageWebSocketResponseEventDTO = (event) => {
3083
- return isWebSocketResponseEventDTO(event)
2982
+ const isCodeRunStatusMessageWebSocketResponseEventDto = (event) => {
2983
+ return isWebSocketResponseEventDto(event)
3084
2984
  && event?.event === WebSocketResponseEvent.CODE_RUN_STATUS
3085
2985
  && typeof event?.runId === 'string' && !!event.runId
3086
2986
  && event?.status in SubmissionRunStatus;
3087
2987
  };
3088
- const isSubmissionRunStatusMessageWebSocketResponseEventDTO = (event) => {
3089
- return isWebSocketResponseEventDTO(event)
2988
+ const isSubmissionRunStatusMessageWebSocketResponseEventDto = (event) => {
2989
+ return isWebSocketResponseEventDto(event)
3090
2990
  && event?.event === WebSocketResponseEvent.SUBMISSION_RUN_STATUS
3091
2991
  && typeof event?.submitId === 'string' && !!event.submitId
3092
2992
  && event?.status in SubmissionRunStatus
3093
2993
  && event?.verdict in ProblemVerdict
3094
2994
  && typeof event?.points === 'number';
3095
2995
  };
3096
- const isUserMessageWebSocketResponseEventDTO = (event) => {
3097
- return isWebSocketResponseEventDTO(event)
2996
+ const isUserMessageWebSocketResponseEventDto = (event) => {
2997
+ return isWebSocketResponseEventDto(event)
3098
2998
  && event?.event === WebSocketResponseEvent.USER_MESSAGE
3099
2999
  && typeof event?.user?.nickname === 'string' && !!event.user?.nickname
3100
3000
  && typeof event?.user?.imageUrl === 'string' && !!event.user?.imageUrl
3101
- && typeof event?.user?.company?.key === 'string' && !!event.user?.company?.key
3001
+ && typeof event?.user?.organization?.key === 'string' && !!event.user?.organization?.key
3102
3002
  && !!event?.content;
3103
3003
  };
3104
- const isSendDataWebSocketResponseEventDTO = (event) => {
3004
+ const isSendDataWebSocketResponseEventDto = (event) => {
3105
3005
  return [
3106
3006
  WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST,
3107
3007
  WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST,
3108
3008
  WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST,
3109
3009
  WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST,
3110
3010
  WebSocketResponseEvent.SEND_DATA_RUN_COMMAND,
3111
- WebSocketResponseEvent.SEND_DATA_CLIENT_TRACK,
3112
- WebSocketResponseEvent.SEND_DATA_CHAT_COMPLETIONS,
3113
3011
  ].includes(event?.event)
3114
3012
  && typeof event?.dataId === 'string' && !!event.dataId
3115
3013
  && !!event?.content;
3116
3014
  };
3117
- const isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO = (event) => {
3118
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3015
+ const isSendDataEcsTaskDefinitionListWebSocketResponseEventDto = (event) => {
3016
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3119
3017
  && event?.event === WebSocketResponseEvent.SEND_DATA_ECS_TASK_DEFINITIONS_LIST;
3120
3018
  };
3121
- const isSendDataEc2InstancesListWebSocketResponseEventDTO = (event) => {
3122
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3019
+ const isSendDataEc2InstancesListWebSocketResponseEventDto = (event) => {
3020
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3123
3021
  && event?.event === WebSocketResponseEvent.SEND_DATA_EC2_INSTANCES_LIST;
3124
3022
  };
3125
- const isSendDataEcsTasksListWebSocketResponseEventDTO = (event) => {
3126
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3023
+ const isSendDataEcsTasksListWebSocketResponseEventDto = (event) => {
3024
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3127
3025
  && event?.event === WebSocketResponseEvent.SEND_DATA_ECS_TASKS_LIST;
3128
3026
  };
3129
- const isSendDataSsmSessionsListWebSocketResponseEventDTO = (event) => {
3130
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3027
+ const isSendDataSsmSessionsListWebSocketResponseEventDto = (event) => {
3028
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3131
3029
  && event?.event === WebSocketResponseEvent.SEND_DATA_SSM_SESSIONS_LIST;
3132
3030
  };
3133
- const isSendDataRunCommandWebSocketResponseEventDTO = (event) => {
3134
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3031
+ const isSendDataRunCommandWebSocketResponseEventDto = (event) => {
3032
+ return isWebSocketResponseEventDto(event) && isSendDataWebSocketResponseEventDto(event)
3135
3033
  && event?.event === WebSocketResponseEvent.SEND_DATA_RUN_COMMAND;
3136
3034
  };
3137
- const isSendDataClientTrackWebSocketResponseEventDTO = (event) => {
3138
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3139
- && event?.event === WebSocketResponseEvent.SEND_DATA_CLIENT_TRACK;
3140
- };
3141
- const isSenDataChatCompletionsWebSocketResponseEventDTO = (event) => {
3142
- return isWebSocketResponseEventDTO(event) && isSendDataWebSocketResponseEventDTO(event)
3143
- && event?.event === WebSocketResponseEvent.SEND_DATA_CHAT_COMPLETIONS;
3144
- };
3145
- const isProblemCrawledWebSocketResponseEventDTO = (event) => {
3146
- return isWebSocketResponseEventDTO(event)
3035
+ const isProblemCrawledWebSocketResponseEventDto = (event) => {
3036
+ return isWebSocketResponseEventDto(event)
3147
3037
  && event?.event === WebSocketResponseEvent.PROBLEM_CRAWLED
3148
3038
  && !!event?.content;
3149
3039
  };
3150
- const isSubmissionsCrawlWebSocketResponseEventDTO = (event) => {
3151
- return isWebSocketResponseEventDTO(event)
3040
+ const isSubmissionsCrawlWebSocketResponseEventDto = (event) => {
3041
+ return isWebSocketResponseEventDto(event)
3152
3042
  && event?.event === WebSocketResponseEvent.SUBMISSIONS_CRAWL
3153
3043
  && !!event?.content;
3154
3044
  };
3155
- const isContestChangesWebSocketResponseEventDTO = (event) => {
3156
- return isWebSocketResponseEventDTO(event)
3045
+ const isContestChangesWebSocketResponseEventDto = (event) => {
3046
+ return isWebSocketResponseEventDto(event)
3157
3047
  && event?.event === WebSocketResponseEvent.CONTEST_CHANGES
3158
3048
  && !!event?.content;
3159
3049
  };
3160
- const isClientTrackWebSocketResponseEventDTO = (event) => {
3161
- return isWebSocketResponseEventDTO(event)
3162
- && event?.event === WebSocketResponseEvent.CLIENT_TRACK;
3163
- };
3164
- const isUserNotificationWebSocketResponseEventDTO = (event) => {
3050
+ const isUserNotificationWebSocketResponseEventDto = (event) => {
3165
3051
  return [
3166
3052
  WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION,
3167
3053
  WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION,
3168
3054
  ].includes(event?.event)
3169
3055
  && !!event?.content;
3170
3056
  };
3171
- const isUserNotificationSubmissionWebSocketResponseEventDTO = (event) => {
3172
- return isWebSocketResponseEventDTO(event) && isUserNotificationWebSocketResponseEventDTO(event)
3057
+ const isUserNotificationSubmissionWebSocketResponseEventDto = (event) => {
3058
+ return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3173
3059
  && event?.event === WebSocketResponseEvent.USER_NOTIFICATION_SUBMISSION;
3174
3060
  };
3175
- const isUserNotificationContestClarificationWebSocketResponseEventDTO = (event) => {
3176
- return isWebSocketResponseEventDTO(event) && isUserNotificationWebSocketResponseEventDTO(event)
3061
+ const isUserNotificationContestClarificationWebSocketResponseEventDto = (event) => {
3062
+ return isWebSocketResponseEventDto(event) && isUserNotificationWebSocketResponseEventDto(event)
3177
3063
  && event?.event === WebSocketResponseEvent.USER_NOTIFICATION_CONTEST_CLARIFICATION;
3178
3064
  };
3179
3065
  // generic
3180
3066
  const getWebSocketResponseEventKey = (event, clientId, id) => {
3181
3067
  return `${event}-${clientId}-${id}`;
3182
3068
  };
3183
- const isWebSocketChannelsMessageDTO = (message) => {
3069
+ const isWebSocketChannelsMessageDto = (message) => {
3184
3070
  return Array.isArray(message?.channels)
3185
3071
  && message.channels.every((channel) => typeof channel === 'string' && !!channel)
3186
3072
  && Object.values(WebSocketResponseEvent).includes(message?.event?.event);
3187
3073
  };
3188
3074
  /**
3189
3075
  * Key used by the client to dispatch a response received on a TOPIC channel to its subscribers.
3190
- * It is the same key that `getKeyWebSocketEventDTO` (base-ui) computes for the subscription.
3076
+ * It is the same key that `getKeyWebSocketEventDto` (base-ui) computes for the subscription.
3191
3077
  * Returns null when the response is not addressed to this client.
3192
3078
  */
3193
3079
  const getWebSocketResponseEventKeyOfResponse = (response, clientId) => {
3194
- if (isCodeRunStatusMessageWebSocketResponseEventDTO(response)) {
3080
+ if (isCodeRunStatusMessageWebSocketResponseEventDto(response)) {
3195
3081
  return getWebSocketResponseEventKey(WebSocketResponseEvent.CODE_RUN_STATUS, clientId, response.runId);
3196
3082
  }
3197
- if (isSubmissionRunStatusMessageWebSocketResponseEventDTO(response)) {
3083
+ if (isSubmissionRunStatusMessageWebSocketResponseEventDto(response)) {
3198
3084
  return getWebSocketResponseEventKey(WebSocketResponseEvent.SUBMISSION_RUN_STATUS, clientId, response.submitId);
3199
3085
  }
3200
- if (isSendDataWebSocketResponseEventDTO(response)) {
3086
+ if (isSendDataWebSocketResponseEventDto(response)) {
3201
3087
  return getWebSocketResponseEventKey(WebSocketResponseEvent.SEND_DATA_, clientId, response.dataId);
3202
3088
  }
3203
- if (isContestChangesWebSocketResponseEventDTO(response)) {
3089
+ if (isContestChangesWebSocketResponseEventDto(response)) {
3204
3090
  return getWebSocketResponseEventKey(WebSocketResponseEvent.CONTEST_CHANGES, clientId, response.content.contestKey);
3205
3091
  }
3206
- if (isProblemCrawledWebSocketResponseEventDTO(response)) {
3092
+ if (isProblemCrawledWebSocketResponseEventDto(response)) {
3207
3093
  return getWebSocketResponseEventKey(WebSocketResponseEvent.PROBLEM_CRAWLED, clientId, response.content.problemKey);
3208
3094
  }
3209
- if (isSubmissionsCrawlWebSocketResponseEventDTO(response)) {
3095
+ if (isSubmissionsCrawlWebSocketResponseEventDto(response)) {
3210
3096
  return getWebSocketResponseEventKey(WebSocketResponseEvent.SUBMISSIONS_CRAWL, clientId, join([response.content.contestKey, response.content.problemKeys]));
3211
3097
  }
3212
- if (isClientTrackWebSocketResponseEventDTO(response)) {
3213
- // the command is sent to the session channel, `key` holds the targeted client
3214
- return response.key === clientId ? getWebSocketResponseEventKey(WebSocketResponseEvent.CLIENT_TRACK, clientId, '*') : null;
3215
- }
3216
- if (isUserNotificationWebSocketResponseEventDTO(response)) {
3098
+ if (isUserNotificationWebSocketResponseEventDto(response)) {
3217
3099
  return getWebSocketResponseEventKey(WebSocketResponseEvent.USER_NOTIFICATION_, clientId, '*');
3218
3100
  }
3219
3101
  return null;
@@ -3224,25 +3106,22 @@ const getWebSocketResponseEventKeyOfResponse = (response, clientId) => {
3224
3106
  * Ably rejects the attach if the token has no capability for the channel.
3225
3107
  */
3226
3108
  const getChannelOfWebSocketSubscribeEvent = (event) => {
3227
- if (isSubscribeSubmissionRunStatusWebSocketEventDTO(event)) {
3109
+ if (isSubscribeSubmissionRunStatusWebSocketEventDto(event)) {
3228
3110
  return CHANNEL_SUBMISSION(event.submitId);
3229
3111
  }
3230
- if (isSubscribeProblemCrawledWebSocketEventDTO(event)) {
3112
+ if (isSubscribeProblemCrawledWebSocketEventDto(event)) {
3231
3113
  return CHANNEL_PROBLEM(event.problemKey);
3232
3114
  }
3233
- if (isSubscribeContestChangesWebSocketEventDTO(event) || isSubscribeSubmissionsCrawlWebSocketEventDTO(event)) {
3115
+ if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3234
3116
  return CHANNEL_CONTEST(event.contestKey, ContestChannelRole.SPECTATORS);
3235
3117
  }
3236
- if (isSubscribeClientTrackDataWebSocketEventDTO(event)) {
3237
- return CHANNEL_CLIENT_TRACK(event.trackedClientId);
3238
- }
3239
3118
  return null;
3240
3119
  };
3241
3120
  /**
3242
3121
  * Contest whose role channels the client needs (the API grants them when the token is requested with this contest).
3243
3122
  */
3244
3123
  const getContestKeyOfWebSocketSubscribeEvent = (event) => {
3245
- if (isSubscribeContestChangesWebSocketEventDTO(event) || isSubscribeSubmissionsCrawlWebSocketEventDTO(event)) {
3124
+ if (isSubscribeContestChangesWebSocketEventDto(event) || isSubscribeSubmissionsCrawlWebSocketEventDto(event)) {
3246
3125
  return event.contestKey;
3247
3126
  }
3248
3127
  return null;
@@ -3317,44 +3196,13 @@ function splitTime(timeRemaining) {
3317
3196
  // }
3318
3197
  return remaining;
3319
3198
  }
3320
- function normalizeToLocalStartOfDay(timestamp) {
3321
- const date = new Date(timestamp);
3322
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
3323
- }
3324
- function normalizeToLocalStartOfHour(timestamp) {
3325
- const date = new Date(timestamp);
3326
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours());
3327
- }
3328
- function normalizeToLocalStartOfMinutes(timestamp) {
3329
- const date = new Date(timestamp);
3330
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
3331
- }
3332
- function normalizeToLocalStartOfSeconds(timestamp) {
3333
- const date = new Date(timestamp);
3334
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
3335
- }
3336
- const getYears = (d) => d.getFullYear();
3337
- const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
3338
- const getDays = (d) => {
3339
- return Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
3340
- };
3341
- const getHours = (d) => {
3342
- return Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
3343
- };
3344
- const getMinutes = (d) => {
3345
- return Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
3346
- };
3347
- const getSeconds = (d) => {
3348
- return Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
3349
- };
3350
- const getMilliseconds = (d) => d.getTime();
3351
3199
 
3352
- const getUserKey = (userNickname, userCompanyKey) => {
3353
- return userNickname + '|' + userCompanyKey;
3200
+ const getUserKey = (userNickname, userOrganizationKey) => {
3201
+ return userNickname + '|' + userOrganizationKey;
3354
3202
  };
3355
3203
  const getParamsOfUserKey = (userKey) => {
3356
- const [userNickname, userCompanyKey] = userKey.split('|');
3357
- return { userNickname, userCompanyKey };
3204
+ const [userNickname, userOrganizationKey] = userKey.split('|');
3205
+ return { userNickname, userOrganizationKey };
3358
3206
  };
3359
3207
  const getClientId = (sessionId, uiId) => {
3360
3208
  return `${sessionId}|${uiId}`;
@@ -3470,4 +3318,4 @@ const isQuizTextSheet = (value) => {
3470
3318
  && ['text', 'number', 'textarea'].includes(value?.inputType);
3471
3319
  };
3472
3320
 
3473
- export { ACCEPTED_PROGRAMMING_LANGUAGES, ASPECT_RATIO, AspectRatio, AssignmentClass, AssignmentState, AssignmentType, CHANNEL_CLIENT_TRACK, CHANNEL_CLIENT_TRACK_ALL, CHANNEL_CONTEST, CHANNEL_PRESENCE_CLIENT, CHANNEL_PROBLEM, CHANNEL_PROBLEM_ALL, CHANNEL_PUBLISH_MESSAGES, CHANNEL_PUBLISH_SUBSCRIPTIONS, CHANNEL_SESSION, CHANNEL_SUBMISSION, CHANNEL_SUBMISSION_ALL, CHANNEL_SUBSCRIBE_CLIENT, CHANNEL_SUBSCRIBE_NOTIFICATIONS, CHANNEL_USER, CODE_LANGUAGE, COMPANY_PLAN, CONTEST_ROLE, CONTEST_STATUS, COOKIE_JUKI_SESSION_ID, COURSE_ROLE, CodeLanguage, CollectionKey, CompanyLogoType, CompanyPlan, ContestChannelRole, ContestEventAction, ContestProblemBlockedByType, ContestProblemPrerequisiteType, ContestStatus, ContestTimeStatus, CourseRole, CourseStatus, CourseType, DAY_NAMES, DEFAULT_JUKI_PROFILE_IMAGE, DataViewMode, EMPTY_DOCUMENT_MEMBERS, EMPTY_ENTITY_MEMBERS, EMPTY_USER_PERMISSIONS, ENTITY_ACCESS, ENTITY_STATE, ERROR, EmailSubscription, EmailValidationState, EntityAccess, EntityCollection, EntityMembersRank, EntityState, EntityStatus, ErrorCode, FILE_ROLE, FILE_TYPE, FileMemberRole, FileType, FilesJukiPub, GroupType, HEADER_JUKI_FORWARDED_HOST, HEADER_JUKI_INTERNAL_API_KEY, HEADER_JUKI_METADATA, HEADER_JUKI_SECRET_TOKEN, HEADER_JUKI_VISITOR_SESSION_ID, HOURS, HTTPMethod, JUDGE, JUKI_APP_COMPANY_KEY, JUKI_APP_EMAIL_TEMPLATE, JkError, Judge, LANGUAGE, LOWERCASE_LETTERS, Language, LogLevel, LogOperation, MAX_DATE, MEMBER_ROLE, MILLISECONDS, MINUTES, MIN_DATE, MONTH_NAMES, MemberRole, MemberType, MenuViewMode, NEW_PAGE_SHEET, NUMBERS, NotificationType, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, PAGE, PAGE_SIZE, PAGE_SIZES, PALLETE, PROBLEM_INPUT, PROBLEM_MODE, PROBLEM_MODES, PROBLEM_OUTPUT, PROBLEM_ROLE, PROBLEM_TYPE, PROBLEM_TYPES, PROBLEM_VERDICT, PROBLEM_VERDICTS, ProblemInput, ProblemOutput, ProblemScoringMode, ProblemType, ProblemVerdict, ProfileSetting, QuizScoringMode, RUNNER_ACCEPTED_PROBLEM_MODES, RUNNER_ACCEPTED_PROBLEM_TYPES, RUNNER_ACCEPTED_PROGRAMMING_LANGUAGES, RUNNER_TYPE, Role, RunnerType, SECONDS, SEC_120, SEC_30, SEC_60, SEC_90, SEPARATOR_TOKEN, SUBMISSION_RUN_STATUS, SUPPORT_EMAIL, SYSTEM_ROLE, ScopeData, Status, SubmissionRunStatus, SystemRole, TEAM_ROLE, THEME, TeamRole, TeamStatus, Theme, TypeTestCase, UPPERCASE_LETTERS, USER_ROLE, USER_STATUS, UserRole, UserStatus, UserTeamStatus, WebSocketMessageEvent, WebSocketResponseEvent, WebSocketSubscriptionEvent, WorkingIn, WorksheetType, YEARS, _KEY, _SUB_SUB_TAB, _SUB_TAB, _TAB, _TYPE, areArraysDifferent, chunkString, cleanRequest, clearAsyncInterval, consoleError, consoleInfo, consoleWarn, contentResponse, contentsResponse, errorsResponse, getAssignmentCommentKey, getAssignmentUserCommentKey, getChannelOfWebSocketSubscribeEvent, getClientId, getContestChannelParams, getContestCommentKey, getContestKeyOfWebSocketSubscribeEvent, getDataLog, getDataOfTestCase, getDays, getDefaultMeta, getDocumentAccess, getHours, getMilliseconds, getMinutes, getMonths, getParamsOfClientId, getParamsOfUserKey, getPlainText, getProblemCommentKey, getProblemJudgeKey, getRandomString, getSeconds, getSummaryWorksheetsInPages, getTotalExercisesOfSummaryWorksheetsInPages, getUserKey, getVerdictFromTestCase, getWebSocketResponseEventKey, getWebSocketResponseEventKeyOfResponse, getWorksheetsInPages, getYears, humanFileSize, indexToLetters, isBasicWorksheet, isChatCompletionsWebSocketEventDTO, isClientTrackDeviceWebSocketEventDTO, isClientTrackLocationWebSocketEventDTO, isClientTrackScreenshotWebSocketEventDTO, isClientTrackWebSocketResponseEventDTO, isCodeEditorSheet, isCodeRunStatusMessageWebSocketResponseEventDTO, isContestAssignment, isContestChangesWebSocketResponseEventDTO, isCourseAssignment, isEndlessContest, isFutureContest, isGlobalContest, isJkmdSheet, isObjectJson, isPastContest, isPingWebSocketEventDTO, isPongWebSocketResponseEventDTO, isProblemCrawledWebSocketResponseEventDTO, isQuizOptionsSheet, isQuizProblemSheet, isQuizTextSheet, isSenDataChatCompletionsWebSocketResponseEventDTO, isSendDataClientTrackWebSocketResponseEventDTO, isSendDataEc2InstancesListWebSocketResponseEventDTO, isSendDataEcsTaskDefinitionListWebSocketResponseEventDTO, isSendDataEcsTasksListWebSocketResponseEventDTO, isSendDataRunCommandWebSocketResponseEventDTO, isSendDataSsmSessionsListWebSocketResponseEventDTO, isSendDataWebSocketResponseEventDTO, isStringJson, isSubmissionRunStatusMessageWebSocketResponseEventDTO, isSubmissionsCrawlWebSocketResponseEventDTO, isSubscribeClientTrackDataWebSocketEventDTO, isSubscribeClientTrackWebSocketEventDTO, isSubscribeCodeRunStatusWebSocketEventDTO, isSubscribeContestChangesWebSocketEventDTO, isSubscribeGetDataWebSocketEventDTO, isSubscribeProblemCrawledWebSocketEventDTO, isSubscribeSubmissionRunStatusWebSocketEventDTO, isSubscribeSubmissionsCrawlWebSocketEventDTO, isSubscribeUserNotificationWebSocketEventDTO, isTeamMember, isUnsubscribeClientTrackDataWebSocketEventDTO, isUnsubscribeClientTrackWebSocketEventDTO, isUnsubscribeCodeRunStatusWebSocketEventDTO, isUnsubscribeContestChangesWebSocketEventDTO, isUnsubscribeGetDataWebSocketEventDTO, isUnsubscribeProblemCrawledWebSocketEventDTO, isUnsubscribeSubmissionRunStatusWebSocketEventDTO, isUnsubscribeSubmissionsCrawlWebSocketEventDTO, isUnsubscribeUserNotificationWebSocketEventDTO, isUserMember, isUserMessageWebSocketResponseEventDTO, isUserNotificationContestClarificationWebSocketResponseEventDTO, isUserNotificationSubmissionWebSocketResponseEventDTO, isUserNotificationWebSocketResponseEventDTO, isWebSocketChannelsMessageDTO, isWebSocketResponseEventDTO, isWebsocketSubscription, isWorksheetAssignment, join, lettersToIndex, memorySizeOf, mergeVerdicts, mex, normalizeToLocalStartOfDay, normalizeToLocalStartOfHour, normalizeToLocalStartOfMinutes, normalizeToLocalStartOfSeconds, objectUpdate, objectsUpdate, range, removeExtension, safeJsonParse, setAsyncInterval, split, splitTime, stringToArrayBuffer, toEntityMembersDTO, toJkError };
3321
+ export { ACCEPTED_PROGRAMMING_LANGUAGES, ASPECT_RATIO, AspectRatio, AssignmentClass, AssignmentState, AssignmentType, CHANNEL_CONTEST, CHANNEL_ORGANIZATION_PRESENCE, CHANNEL_PROBLEM, CHANNEL_PROBLEM_ALL, CHANNEL_SESSION, CHANNEL_SUBMISSION, CHANNEL_SUBMISSION_ALL, CHANNEL_USER, CODE_LANGUAGE, CONTEST_ROLE, CONTEST_STATUS, COOKIE_JUKI_SESSION_ID, COURSE_ROLE, CodeLanguage, CollectionKey, ContestChannelRole, ContestEventAction, ContestProblemBlockedByType, ContestProblemPrerequisiteType, ContestStatus, ContestTimeStatus, CourseRole, CourseStatus, CourseType, DAY_NAMES, DEFAULT_JUKI_PROFILE_IMAGE, DataViewMode, EMPTY_DOCUMENT_MEMBERS, EMPTY_ENTITY_MEMBERS, EMPTY_USER_PERMISSIONS, ENTITY_ACCESS, ENTITY_STATE, ERROR, EmailSubscription, EmailValidationState, EntityAccess, EntityCollection, EntityMembersRank, EntityState, EntityStatus, ErrorCode, FILE_ROLE, FILE_TYPE, FileMemberRole, FileType, FilesJukiPub, GroupType, HEADER_JUKI_FORWARDED_HOST, HEADER_JUKI_INTERNAL_API_KEY, HEADER_JUKI_METADATA, HEADER_JUKI_SECRET_TOKEN, HEADER_JUKI_VISITOR_SESSION_ID, HOURS, HTTPMethod, JUDGE, JUKI_APP_EMAIL_TEMPLATE, JUKI_APP_ORGANIZATION_KEY, JkError, Judge, LANGUAGE, LOWERCASE_LETTERS, Language, LogLevel, LogOperation, MAX_DATE, MEMBER_ROLE, MILLISECONDS, MINUTES, MIN_DATE, MONTH_NAMES, MemberRole, MemberType, MenuViewMode, NEW_PAGE_SHEET, NUMBERS, NotificationType, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ORGANIZATION_PLAN, OrganizationLogoType, OrganizationPlan, PAGE, PAGE_SIZE, PAGE_SIZES, PALLETE, PROBLEM_INPUT, PROBLEM_MODE, PROBLEM_MODES, PROBLEM_OUTPUT, PROBLEM_ROLE, PROBLEM_TYPE, PROBLEM_TYPES, PROBLEM_VERDICT, PROBLEM_VERDICTS, ProblemInput, ProblemOutput, ProblemScoringMode, ProblemType, ProblemVerdict, ProfileSetting, QuizScoringMode, RUNNER_ACCEPTED_PROBLEM_MODES, RUNNER_ACCEPTED_PROBLEM_TYPES, RUNNER_ACCEPTED_PROGRAMMING_LANGUAGES, RUNNER_TYPE, Role, RunnerType, SECONDS, SEC_120, SEC_30, SEC_60, SEC_90, SEPARATOR_TOKEN, SUBMISSION_RUN_STATUS, SUPPORT_EMAIL, SYSTEM_ROLE, ScopeData, Status, SubmissionRunStatus, SystemRole, TEAM_ROLE, THEME, TeamRole, TeamStatus, Theme, TypeTestCase, UPPERCASE_LETTERS, USER_ROLE, USER_STATUS, UserRole, UserStatus, UserTeamStatus, WebSocketResponseEvent, WebSocketSubscriptionEvent, WorkingIn, WorksheetType, YEARS, _KEY, _SUB_SUB_TAB, _SUB_TAB, _TAB, _TYPE, areArraysDifferent, changeDay, changeHours, changeMilliseconds, changeMinutes, changeMonth, changeSeconds, changeYear, chunkString, cleanRequest, clearAsyncInterval, consoleError, consoleInfo, consoleWarn, contentResponse, contentsResponse, decreaseDay, decreaseMonth, decreaseYear, endOfDay, endOfHour, endOfMinute, endOfMonth, endOfSecond, endOfWeek, endOfYear, errorsResponse, getAssignmentCommentKey, getAssignmentUserCommentKey, getChannelOfWebSocketSubscribeEvent, getClientId, getContestChannelParams, getContestCommentKey, getContestKeyOfWebSocketSubscribeEvent, getDataLog, getDataOfTestCase, getDays, getDefaultMeta, getDocumentAccess, getHours, getMilliseconds, getMinutes, getMonths, getParamsOfClientId, getParamsOfUserKey, getPlainText, getProblemCommentKey, getProblemJudgeKey, getRandomString, getSeconds, getSummaryWorksheetsInPages, getTotalExercisesOfSummaryWorksheetsInPages, getUserKey, getVerdictFromTestCase, getWebSocketResponseEventKey, getWebSocketResponseEventKeyOfResponse, getWorksheetsInPages, getYears, humanFileSize, increaseDay, increaseMonth, increaseYear, indexToLetters, isAfter, isBasicWorksheet, isBefore, isCodeEditorSheet, isCodeRunStatusMessageWebSocketResponseEventDto, isContestAssignment, isContestChangesWebSocketResponseEventDto, isCourseAssignment, isDayAfter, isDayBefore, isEndlessContest, isEqual, isFutureContest, isGlobalContest, isHoursAfter, isHoursBefore, isJkmdSheet, isMillisecondsAfter, isMillisecondsBefore, isMinutesAfter, isMinutesBefore, isMonthAfter, isMonthBefore, isObjectJson, isPastContest, isProblemCrawledWebSocketResponseEventDto, isQuizOptionsSheet, isQuizProblemSheet, isQuizTextSheet, isSameDay, isSameHour, isSameMillisecond, isSameMinute, isSameMonth, isSameSecond, isSameYear, isSecondsAfter, isSecondsBefore, isSendDataEc2InstancesListWebSocketResponseEventDto, isSendDataEcsTaskDefinitionListWebSocketResponseEventDto, isSendDataEcsTasksListWebSocketResponseEventDto, isSendDataRunCommandWebSocketResponseEventDto, isSendDataSsmSessionsListWebSocketResponseEventDto, isSendDataWebSocketResponseEventDto, isStringJson, isSubmissionRunStatusMessageWebSocketResponseEventDto, isSubmissionsCrawlWebSocketResponseEventDto, isSubscribeCodeRunStatusWebSocketEventDto, isSubscribeContestChangesWebSocketEventDto, isSubscribeGetDataWebSocketEventDto, isSubscribeProblemCrawledWebSocketEventDto, isSubscribeSubmissionRunStatusWebSocketEventDto, isSubscribeSubmissionsCrawlWebSocketEventDto, isSubscribeUserNotificationWebSocketEventDto, isTeamMember, isToday, isUnsubscribeCodeRunStatusWebSocketEventDto, isUnsubscribeContestChangesWebSocketEventDto, isUnsubscribeGetDataWebSocketEventDto, isUnsubscribeProblemCrawledWebSocketEventDto, isUnsubscribeSubmissionRunStatusWebSocketEventDto, isUnsubscribeSubmissionsCrawlWebSocketEventDto, isUnsubscribeUserNotificationWebSocketEventDto, isUserMember, isUserMessageWebSocketResponseEventDto, isUserNotificationContestClarificationWebSocketResponseEventDto, isUserNotificationSubmissionWebSocketResponseEventDto, isUserNotificationWebSocketResponseEventDto, isValidDate, isWebSocketChannelsMessageDto, isWebSocketResponseEventDto, isWebsocketSubscription, isWithinInterval, isWorksheetAssignment, isYearAfter, isYearBefore, join, lettersToIndex, memorySizeOf, mergeVerdicts, mex, normalizeToLocalStartOfDay, normalizeToLocalStartOfHour, normalizeToLocalStartOfMinutes, normalizeToLocalStartOfSeconds, objectUpdate, objectsUpdate, padEnd, padStart, range, removeExtension, safeJsonParse, setAsyncInterval, split, splitTime, startOfDay, startOfHour, startOfMinute, startOfMonth, startOfSecond, startOfWeek, startOfYear, stringToArrayBuffer, toEntityMembersDto, toJkError };