@juki-team/commons 0.1.46 → 0.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/{types/constants → constants}/commons.d.ts +1 -1
  2. package/dist/constants/commons.js +648 -0
  3. package/dist/{types/constants → constants}/contest.d.ts +1 -1
  4. package/dist/constants/contest.js +28 -0
  5. package/dist/{types/constants → constants}/course.d.ts +1 -1
  6. package/dist/constants/course.js +12 -0
  7. package/dist/constants/date.js +23 -0
  8. package/dist/constants/email.js +34 -0
  9. package/dist/{types/constants → constants}/entity.d.ts +1 -1
  10. package/dist/constants/entity.js +18 -0
  11. package/dist/{types/constants → constants}/file.d.ts +1 -1
  12. package/dist/constants/file.js +45 -0
  13. package/dist/constants/index.d.ts +18 -0
  14. package/dist/constants/index.js +18 -0
  15. package/dist/{types/constants → constants}/judge.d.ts +1 -1
  16. package/dist/constants/judge.js +225 -0
  17. package/dist/{types/constants → constants}/organization.d.ts +1 -1
  18. package/dist/constants/organization.js +24 -0
  19. package/dist/{types/constants → constants}/problem.d.ts +1 -1
  20. package/dist/constants/problem.js +69 -0
  21. package/dist/constants/routing.js +7 -0
  22. package/dist/{types/constants → constants}/services.d.ts +1 -1
  23. package/dist/constants/services.js +157 -0
  24. package/dist/{types/constants → constants}/system.d.ts +1 -1
  25. package/dist/constants/system.js +9 -0
  26. package/dist/{types/constants → constants}/teams.d.ts +1 -1
  27. package/dist/constants/teams.js +17 -0
  28. package/dist/constants/time.js +9 -0
  29. package/dist/{types/constants → constants}/user.d.ts +2 -2
  30. package/dist/constants/user.js +40 -0
  31. package/dist/{types/constants → constants}/websocket.d.ts +7 -3
  32. package/dist/constants/websocket.js +56 -0
  33. package/dist/{types/constants → constants}/worksheet.d.ts +1 -1
  34. package/dist/constants/worksheet.js +66 -0
  35. package/dist/{types/dto → dto}/class.d.ts +3 -3
  36. package/dist/dto/class.js +1 -0
  37. package/dist/{types/dto → dto}/code.d.ts +1 -1
  38. package/dist/dto/code.js +1 -0
  39. package/dist/{types/dto → dto}/comments.d.ts +1 -1
  40. package/dist/dto/comments.js +1 -0
  41. package/dist/{types/dto → dto}/contest.d.ts +4 -4
  42. package/dist/dto/contest.js +7 -0
  43. package/dist/{types/dto → dto}/course.d.ts +4 -4
  44. package/dist/dto/course.js +1 -0
  45. package/dist/{types/dto → dto}/entity.d.ts +2 -2
  46. package/dist/dto/entity.js +5 -0
  47. package/dist/{types/dto → dto}/excalidraw.d.ts +3 -3
  48. package/dist/dto/excalidraw.js +1 -0
  49. package/dist/{types/dto → dto}/file.d.ts +2 -2
  50. package/dist/dto/file.js +1 -0
  51. package/dist/dto/image.js +1 -0
  52. package/dist/dto/index.d.ts +25 -0
  53. package/dist/dto/index.js +25 -0
  54. package/dist/{types/dto → dto}/judge.d.ts +1 -1
  55. package/dist/dto/judge.js +1 -0
  56. package/dist/{types/dto → dto}/markdown.d.ts +3 -3
  57. package/dist/dto/markdown.js +1 -0
  58. package/dist/{types/dto → dto}/mermaid.d.ts +3 -3
  59. package/dist/dto/mermaid.js +1 -0
  60. package/dist/{types/dto → dto}/organization.d.ts +3 -3
  61. package/dist/dto/organization.js +1 -0
  62. package/dist/{types/dto → dto}/problem.d.ts +3 -3
  63. package/dist/dto/problem.js +1 -0
  64. package/dist/{types/dto → dto}/scoreboard.d.ts +2 -2
  65. package/dist/dto/scoreboard.js +1 -0
  66. package/dist/{types/dto → dto}/session.d.ts +2 -2
  67. package/dist/dto/session.js +1 -0
  68. package/dist/{types/dto → dto}/socket.d.ts +5 -5
  69. package/dist/dto/socket.js +1 -0
  70. package/dist/{types/dto → dto}/statistics.d.ts +1 -1
  71. package/dist/dto/statistics.js +1 -0
  72. package/dist/{types/dto → dto}/submission.d.ts +3 -3
  73. package/dist/dto/submission.js +1 -0
  74. package/dist/{types/dto → dto}/system.d.ts +1 -1
  75. package/dist/dto/system.js +1 -0
  76. package/dist/dto/url.js +1 -0
  77. package/dist/{types/dto → dto}/user.d.ts +3 -3
  78. package/dist/dto/user.js +1 -0
  79. package/dist/{types/dto → dto}/virtual-user.d.ts +1 -1
  80. package/dist/dto/virtual-user.js +1 -0
  81. package/dist/{types/dto → dto}/worksheet-submissions.d.ts +3 -3
  82. package/dist/dto/worksheet-submissions.js +1 -0
  83. package/dist/{types/dto → dto}/worksheet.d.ts +3 -3
  84. package/dist/dto/worksheet.js +1 -0
  85. package/dist/{types/helpers → helpers}/class.d.ts +1 -1
  86. package/dist/helpers/class.js +10 -0
  87. package/dist/helpers/comments.js +4 -0
  88. package/dist/{types/helpers → helpers}/commons.d.ts +1 -1
  89. package/dist/helpers/commons.js +187 -0
  90. package/dist/{types/helpers → helpers}/contest.d.ts +1 -1
  91. package/dist/helpers/contest.js +21 -0
  92. package/dist/helpers/date.js +181 -0
  93. package/dist/{types/helpers → helpers}/document.d.ts +2 -2
  94. package/dist/helpers/document.js +51 -0
  95. package/dist/{types/helpers → helpers}/errors.d.ts +1 -1
  96. package/dist/helpers/errors.js +17 -0
  97. package/dist/helpers/file.js +4 -0
  98. package/dist/helpers/index.d.ts +17 -0
  99. package/dist/helpers/index.js +17 -0
  100. package/dist/helpers/interval.js +24 -0
  101. package/dist/{types/helpers → helpers}/judging.d.ts +1 -1
  102. package/dist/helpers/judging.js +124 -0
  103. package/dist/helpers/number.js +2 -0
  104. package/dist/helpers/object.js +33 -0
  105. package/dist/{types/helpers → helpers}/responses.d.ts +2 -2
  106. package/dist/helpers/responses.js +95 -0
  107. package/dist/{types/helpers → helpers}/socket.d.ts +3 -3
  108. package/dist/helpers/socket.js +279 -0
  109. package/dist/{types/helpers → helpers}/time.d.ts +1 -1
  110. package/dist/helpers/time.js +69 -0
  111. package/dist/{types/helpers → helpers}/user.d.ts +1 -1
  112. package/dist/helpers/user.js +14 -0
  113. package/dist/{types/helpers → helpers}/worksheet.d.ts +1 -1
  114. package/dist/helpers/worksheet.js +107 -0
  115. package/dist/index.d.ts +4 -0
  116. package/dist/index.js +4 -0
  117. package/dist/types/account.js +10 -0
  118. package/dist/types/{types/class.d.ts → class.d.ts} +2 -2
  119. package/dist/types/class.js +7 -0
  120. package/dist/types/comments.js +1 -0
  121. package/dist/types/{types/commons.d.ts → commons.d.ts} +1 -1
  122. package/dist/types/commons.js +69 -0
  123. package/dist/types/{types/contest.d.ts → contest.d.ts} +4 -4
  124. package/dist/types/contest.js +27 -0
  125. package/dist/types/{types/course.d.ts → course.d.ts} +1 -1
  126. package/dist/types/course.js +1 -0
  127. package/dist/types/entity.js +50 -0
  128. package/dist/types/{types/excalidraw.d.ts → excalidraw.d.ts} +1 -1
  129. package/dist/types/excalidraw.js +1 -0
  130. package/dist/types/{types/file.d.ts → file.d.ts} +2 -2
  131. package/dist/types/file.js +19 -0
  132. package/dist/types/{types/group.d.ts → group.d.ts} +1 -1
  133. package/dist/types/group.js +5 -0
  134. package/dist/types/index.d.ts +27 -4
  135. package/dist/types/index.js +27 -0
  136. package/dist/types/{types/judge.d.ts → judge.d.ts} +2 -2
  137. package/dist/types/judge.js +49 -0
  138. package/dist/types/{types/markdown.d.ts → markdown.d.ts} +1 -1
  139. package/dist/types/markdown.js +1 -0
  140. package/dist/types/{types/mermaid.d.ts → mermaid.d.ts} +1 -1
  141. package/dist/types/mermaid.js +1 -0
  142. package/dist/types/notification.js +8 -0
  143. package/dist/types/organization.js +14 -0
  144. package/dist/types/{types/prisma.d.ts → prisma.d.ts} +1 -1
  145. package/dist/types/prisma.js +106 -0
  146. package/dist/types/{types/problems.d.ts → problems.d.ts} +3 -3
  147. package/dist/types/problems.js +28 -0
  148. package/dist/types/scoreboard.js +1 -0
  149. package/dist/types/{types/services.d.ts → services.d.ts} +1 -1
  150. package/dist/types/services.js +152 -0
  151. package/dist/types/{types/sheet.d.ts → sheet.d.ts} +2 -2
  152. package/dist/types/sheet.js +16 -0
  153. package/dist/types/{types/socket.d.ts → socket.d.ts} +3 -2
  154. package/dist/types/socket.js +76 -0
  155. package/dist/types/submission.js +1 -0
  156. package/dist/types/system.js +1 -0
  157. package/dist/types/{types/teams.d.ts → teams.d.ts} +2 -2
  158. package/dist/types/teams.js +1 -0
  159. package/dist/types/{types/users.d.ts → users.d.ts} +2 -2
  160. package/dist/types/users.js +23 -0
  161. package/dist/types/virtual-user.js +8 -0
  162. package/dist/types/{types/worksheet.d.ts → worksheet.d.ts} +3 -3
  163. package/dist/types/worksheet.js +11 -0
  164. package/package.json +8 -11
  165. package/dist/cjs/index.cjs +0 -3695
  166. package/dist/esm/index.js +0 -3415
  167. package/dist/types/constants/index.d.ts +0 -18
  168. package/dist/types/dto/index.d.ts +0 -25
  169. package/dist/types/helpers/index.d.ts +0 -17
  170. package/dist/types/types/index.d.ts +0 -27
  171. /package/dist/{types/constants → constants}/date.d.ts +0 -0
  172. /package/dist/{types/constants → constants}/email.d.ts +0 -0
  173. /package/dist/{types/constants → constants}/routing.d.ts +0 -0
  174. /package/dist/{types/constants → constants}/time.d.ts +0 -0
  175. /package/dist/{types/dto → dto}/image.d.ts +0 -0
  176. /package/dist/{types/dto → dto}/url.d.ts +0 -0
  177. /package/dist/{types/helpers → helpers}/comments.d.ts +0 -0
  178. /package/dist/{types/helpers → helpers}/date.d.ts +0 -0
  179. /package/dist/{types/helpers → helpers}/file.d.ts +0 -0
  180. /package/dist/{types/helpers → helpers}/interval.d.ts +0 -0
  181. /package/dist/{types/helpers → helpers}/number.d.ts +0 -0
  182. /package/dist/{types/helpers → helpers}/object.d.ts +0 -0
  183. /package/dist/types/{types/account.d.ts → account.d.ts} +0 -0
  184. /package/dist/types/{types/comments.d.ts → comments.d.ts} +0 -0
  185. /package/dist/types/{types/entity.d.ts → entity.d.ts} +0 -0
  186. /package/dist/types/{types/notification.d.ts → notification.d.ts} +0 -0
  187. /package/dist/types/{types/organization.d.ts → organization.d.ts} +0 -0
  188. /package/dist/types/{types/scoreboard.d.ts → scoreboard.d.ts} +0 -0
  189. /package/dist/types/{types/submission.d.ts → submission.d.ts} +0 -0
  190. /package/dist/types/{types/system.d.ts → system.d.ts} +0 -0
  191. /package/dist/types/{types/virtual-user.d.ts → virtual-user.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { OrganizationPlan, ResourceInstance, ResourceLogger, Theme } from '../types';
2
- import { EmailDataResponseDto } from './system';
3
- import { UserOrganizationBasicInfoResponseDto, UserPermissions } from './user';
1
+ import { OrganizationPlan, ResourceInstance, ResourceLogger, Theme } from '../types/index.js';
2
+ import { EmailDataResponseDto } from './system.js';
3
+ import { UserOrganizationBasicInfoResponseDto, UserPermissions } from './user.js';
4
4
  export interface OrganizationJudgeResponseDto {
5
5
  key: string;
6
6
  name: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { EntityState, JudgeBaseDocument, ProblemBaseDocument, ProblemScoringMode, ProblemSettings, ProblemStatement, ProblemType, ProblemUser, TextLanguage } from '../types';
2
- import { EntityMembersDto, EntityMembersResponseDto } from './entity';
3
- import { EntityOwnerSystemSummaryListResponseDto, UserOrganizationBasicInfoResponseDto } from './user';
1
+ import { EntityState, JudgeBaseDocument, ProblemBaseDocument, ProblemScoringMode, ProblemSettings, ProblemStatement, ProblemType, ProblemUser, TextLanguage } from '../types/index.js';
2
+ import { EntityMembersDto, EntityMembersResponseDto } from './entity.js';
3
+ import { EntityOwnerSystemSummaryListResponseDto, UserOrganizationBasicInfoResponseDto } from './user.js';
4
4
  export interface ProblemJudgeSummaryListResponseDto extends Pick<JudgeBaseDocument, 'isExternal' | 'isSubmitSupported' | 'name' | 'key'> {
5
5
  isCustom: boolean;
6
6
  isMain: boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
- import { ScoreboardProblems } from '../types';
2
- import { UserSummaryListResponseDto } from './user';
1
+ import { ScoreboardProblems } from '../types/index.js';
2
+ import { UserSummaryListResponseDto } from './user.js';
3
3
  export interface ScoreboardResponseDto {
4
4
  user: UserSummaryListResponseDto;
5
5
  totalPenalty: number;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
- import { EntityOrganizationSystemSummaryListResponseDto } from './problem';
2
- import { UserBasicResponseDto } from './user';
1
+ import { EntityOrganizationSystemSummaryListResponseDto } from './problem.js';
2
+ import { UserBasicResponseDto } from './user.js';
3
3
  export interface SessionBasicResponseDto {
4
4
  id: string;
5
5
  deviceName: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { ClientId, Ec2Instance, InfoLogCaseStatus, ProblemVerdict, SsmSession, SubmissionRunStatus, TestInfo, WebSocketResponseEvent, WebSocketResponseEventKey, WebSocketSubscriptionEvent } from '../types';
2
- import { EcsTaskDefinitionSystemSummaryListResponseDto, EcsTaskSystemSummaryListResponseDto } from './system';
3
- import { UserOrganizationBasicInfoResponseDto } from './user';
1
+ import { ClientId, Ec2Instance, InfoLogCaseStatus, ProblemVerdict, SsmSession, SubmissionRunStatus, TestInfo, WebSocketResponseEvent, WebSocketResponseEventKey, WebSocketSubscriptionEvent } from '../types/index.js';
2
+ import { EcsTaskDefinitionSystemSummaryListResponseDto, EcsTaskSystemSummaryListResponseDto } from './system.js';
3
+ import { UserOrganizationBasicInfoResponseDto } from './user.js';
4
4
  export interface WebsocketSubscription {
5
5
  event: WebSocketSubscriptionEvent;
6
6
  clientId: ClientId;
@@ -72,7 +72,7 @@ export type SubmissionsJudgingScope = {
72
72
  } | {
73
73
  contestKey: string;
74
74
  } | {
75
- userId: string;
75
+ userKey: string;
76
76
  };
77
77
  export type SubscribeSubmissionsJudgingWebSocketEventDto = WebsocketSubscription & {
78
78
  event: WebSocketSubscriptionEvent.SUBSCRIBE_SUBMISSIONS_JUDGING;
@@ -114,7 +114,7 @@ export interface SubmissionJudgingWebSocketResponseEventDto extends WebSocketRes
114
114
  submitId: string;
115
115
  problemKey: string;
116
116
  contestKey: string | null;
117
- userId: string;
117
+ userKey: string;
118
118
  judging: boolean;
119
119
  status: SubmissionRunStatus;
120
120
  verdict: ProblemVerdict;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { UserOrganizationBasicInfoResponseDto } from './user';
1
+ import { UserOrganizationBasicInfoResponseDto } from './user.js';
2
2
  export type GroupByTimestampKey = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | number;
3
3
  export type StatisticsGrouped<T> = Partial<Record<GroupByTimestampKey, Record<number, T>>>;
4
4
  export interface StatisticsOrganizationResponseDto {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { CodeLanguage, ContestUser, DataLog, EntityState, ProblemScoringMode, ProblemType, ProblemVerdict, SubmissionRunStatus } from '../types';
2
- import { EntityOrganizationSummaryListResponseDto, EntityOrganizationSystemSummaryListResponseDto, ProblemJudgeSummaryListResponseDto } from './problem';
3
- import { UserOrganizationBasicInfoResponseDto } from './user';
1
+ import { CodeLanguage, ContestUser, DataLog, EntityState, ProblemScoringMode, ProblemType, ProblemVerdict, SubmissionRunStatus } from '../types/index.js';
2
+ import { EntityOrganizationSummaryListResponseDto, EntityOrganizationSystemSummaryListResponseDto, ProblemJudgeSummaryListResponseDto } from './problem.js';
3
+ import { UserOrganizationBasicInfoResponseDto } from './user.js';
4
4
  export interface SubmissionProblemSummaryListResponseDto {
5
5
  isAdministrator: boolean;
6
6
  isManager: boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { EcsTask, EcsTaskDefinition, SqsProperties } from '../types';
1
+ import { EcsTask, EcsTaskDefinition, SqsProperties } from '../types/index.js';
2
2
  export interface EcsTaskSystemSummaryListResponseDto extends EcsTask {
3
3
  isHighRunnerOrganizationKeys: string[];
4
4
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { ContestRole, CourseRole, FileRole, ProblemRole, RecordId, SystemRole, TeamRole, UserBasicInfo, UserHandles, UserRole, UserSettings, UserStatus } from '../types';
2
- import { OrganizationStyles } from './organization';
3
- import { EntityOrganizationSummaryListResponseDto, EntityOrganizationSystemSummaryListResponseDto } from './problem';
1
+ import { ContestRole, CourseRole, FileRole, ProblemRole, RecordId, SystemRole, TeamRole, UserBasicInfo, UserHandles, UserRole, UserSettings, UserStatus } from '../types/index.js';
2
+ import { OrganizationStyles } from './organization.js';
3
+ import { EntityOrganizationSummaryListResponseDto, EntityOrganizationSystemSummaryListResponseDto } from './problem.js';
4
4
  export interface EntityOwnerSystemSummaryListResponseDto {
5
5
  id: string;
6
6
  nickname: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { Cookie, Judge, WorkingIn } from '../types';
1
+ import { Cookie, Judge, WorkingIn } from '../types/index.js';
2
2
  export interface VirtualUserResponseDto {
3
3
  id: string;
4
4
  judge: Judge;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { CodeEditorSheet, CodeLanguage, JkmdSheet, QuizOptionsSheet, QuizProblemSheet, QuizTextSheet, UserBasic, WorksheetType } from '../types';
2
- import { SubmissionSummaryListResponseDto } from './submission';
3
- import { UserOrganizationBasicInfoResponseDto } from './user';
1
+ import { CodeEditorSheet, CodeLanguage, JkmdSheet, QuizOptionsSheet, QuizProblemSheet, QuizTextSheet, UserBasic, WorksheetType } from '../types/index.js';
2
+ import { SubmissionSummaryListResponseDto } from './submission.js';
3
+ import { UserOrganizationBasicInfoResponseDto } from './user.js';
4
4
  export type WorksheetResponseBasicInfoProcessed = {
5
5
  submittedAt: number;
6
6
  points: number;
@@ -0,0 +1 @@
1
+ import { WorksheetType, } from '../types/index.js';
@@ -1,6 +1,6 @@
1
- import { BodyWorksheet, SummaryWorksheetsInPages, WorksheetBaseDocument } from '../types';
2
- import { EntityMembersDto, EntityMembersResponseDto } from './entity';
3
- import { UserOrganizationBasicInfoResponseDto } from './user';
1
+ import { BodyWorksheet, SummaryWorksheetsInPages, WorksheetBaseDocument } from '../types/index.js';
2
+ import { EntityMembersDto, EntityMembersResponseDto } from './entity.js';
3
+ import { UserOrganizationBasicInfoResponseDto } from './user.js';
4
4
  export interface WorksheetUserResponseDto {
5
5
  isOwner: boolean;
6
6
  isManager: boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { AssignmentSessionCycleClassDataResponseDto, ContestAssignmentSessionCycleClassDataResponseDto, CourseAssignmentSessionCycleClassDataResponseDto, WorksheetAssignmentSessionCycleClassDataResponseDto } from '../dto';
1
+ import { AssignmentSessionCycleClassDataResponseDto, ContestAssignmentSessionCycleClassDataResponseDto, CourseAssignmentSessionCycleClassDataResponseDto, WorksheetAssignmentSessionCycleClassDataResponseDto } from '../dto/index.js';
2
2
  export declare const isWorksheetAssignment: (assignment: AssignmentSessionCycleClassDataResponseDto) => assignment is WorksheetAssignmentSessionCycleClassDataResponseDto;
3
3
  export declare const isCourseAssignment: (assignment: AssignmentSessionCycleClassDataResponseDto) => assignment is CourseAssignmentSessionCycleClassDataResponseDto;
4
4
  export declare const isContestAssignment: (assignment: AssignmentSessionCycleClassDataResponseDto) => assignment is ContestAssignmentSessionCycleClassDataResponseDto;
@@ -0,0 +1,10 @@
1
+ import { AssignmentClass } from '../types/index.js';
2
+ export const isWorksheetAssignment = (assignment) => {
3
+ return assignment.type === AssignmentClass.WORKSHEET;
4
+ };
5
+ export const isCourseAssignment = (assignment) => {
6
+ return assignment.type === AssignmentClass.COURSE;
7
+ };
8
+ export const isContestAssignment = (assignment) => {
9
+ return assignment.type === AssignmentClass.CONTEST;
10
+ };
@@ -0,0 +1,4 @@
1
+ export const getAssignmentCommentKey = (classKey, cycleKey, sessionKey, assignmentKey) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}`;
2
+ export const getAssignmentUserCommentKey = (classKey, cycleKey, sessionKey, assignmentKey, userNickname, userOrganization) => `class:${classKey}|cycle:${cycleKey}|session:${sessionKey}|assignment:${assignmentKey}|user_nickname:${userNickname}|user_organization:${userOrganization}`;
3
+ export const getProblemCommentKey = (problemKey) => `problem:${problemKey}`;
4
+ export const getContestCommentKey = (contestKey) => `contest:${contestKey}`;
@@ -1,4 +1,4 @@
1
- import { Judge } from '../types';
1
+ import { Judge } from '../types/index.js';
2
2
  export declare function isStringJson(str: any): str is string;
3
3
  export declare function safeJsonParse(str: any): any;
4
4
  export declare function isObjectJson(obj: any): boolean;
@@ -0,0 +1,187 @@
1
+ import { SEPARATOR_TOKEN, UPPERCASE_LETTERS } from '../constants/commons.js';
2
+ export function isStringJson(str) {
3
+ try {
4
+ if (typeof str === 'string') {
5
+ JSON.parse(str);
6
+ return true;
7
+ }
8
+ }
9
+ catch (e) {
10
+ return false;
11
+ }
12
+ return false;
13
+ }
14
+ export function safeJsonParse(str) {
15
+ try {
16
+ if (typeof str === 'string') {
17
+ return JSON.parse(str);
18
+ }
19
+ }
20
+ catch (e) {
21
+ return null;
22
+ }
23
+ return null;
24
+ }
25
+ export function isObjectJson(obj) {
26
+ try {
27
+ return typeof JSON.stringify(obj) === 'string';
28
+ }
29
+ catch (e) {
30
+ return false;
31
+ }
32
+ }
33
+ export function mex(array) {
34
+ let i = 0;
35
+ while (array.indexOf(i) !== -1) {
36
+ i++;
37
+ }
38
+ return i;
39
+ }
40
+ export function range(start, end) {
41
+ const result = [];
42
+ for (let i = start; i < end; i++) {
43
+ result.push(i);
44
+ }
45
+ return result;
46
+ }
47
+ export async function getPlainText(url) {
48
+ return await fetch(url)
49
+ .then(data => data.text())
50
+ .catch((error) => {
51
+ console.error('ERROR:', error);
52
+ return '';
53
+ });
54
+ }
55
+ export function objectUpdate(base, update) {
56
+ if (JSON.stringify(base) === JSON.stringify(update)) {
57
+ return base;
58
+ }
59
+ if (base !== null && update !== null && !Array.isArray(base) && typeof base === 'object' && typeof update === 'object') {
60
+ const mergeKeys = new Set([...Object.keys(base), ...Object.keys(update)]);
61
+ Array.from(mergeKeys).forEach(key => {
62
+ if (update[key] !== null && update[key] !== undefined && base[key] !== update[key]) {
63
+ base[key] = objectUpdate(base[key], update[key]);
64
+ }
65
+ });
66
+ return base;
67
+ }
68
+ if (update !== null && update !== undefined) {
69
+ return update;
70
+ }
71
+ return base;
72
+ }
73
+ export function objectsUpdate(base, ...objects) {
74
+ let newObject = { ...base };
75
+ objects.forEach((update) => {
76
+ newObject = objectUpdate(newObject, update);
77
+ });
78
+ return newObject;
79
+ }
80
+ export function consoleWarn(...warn) {
81
+ console.warn(new Date().toLocaleString(), ...warn);
82
+ }
83
+ export function consoleInfo(...info) {
84
+ console.info(new Date().toLocaleString(), ...info);
85
+ }
86
+ export function consoleError(...error) {
87
+ console.error(new Date().toLocaleString(), ...error);
88
+ }
89
+ export function indexToLetters(index) {
90
+ const d = Math.ceil(index / 26);
91
+ if (d === 1) {
92
+ return UPPERCASE_LETTERS.charAt(index - 1);
93
+ }
94
+ return UPPERCASE_LETTERS.charAt(d - 2) + UPPERCASE_LETTERS.charAt(index - (26 * (d - 1)) - 1);
95
+ }
96
+ export function lettersToIndex(index) {
97
+ if (index.length) {
98
+ if (index.length === 1) {
99
+ const d = UPPERCASE_LETTERS.indexOf(index);
100
+ if (d !== -1) {
101
+ return d + 1;
102
+ }
103
+ }
104
+ else if (index.length === 2) {
105
+ const a = index.charAt(0);
106
+ const b = index.charAt(1);
107
+ const numA = lettersToIndex(a);
108
+ const numB = lettersToIndex(b);
109
+ return numA * 26 + numB;
110
+ }
111
+ }
112
+ return 0;
113
+ }
114
+ export function getProblemJudgeKey(judge, key) {
115
+ return `${judge}-${key}`;
116
+ }
117
+ /**
118
+ * https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string
119
+ * Format bytes as human-readable text.
120
+ *
121
+ * @param bytes Number of bytes.
122
+ * @param si True to use metric (SI) units, aka powers of 1000. False to use
123
+ * binary (IEC), aka powers of 1024.
124
+ * @param dp Number of decimal places to display.
125
+ *
126
+ * @return Formatted string.
127
+ */
128
+ export function humanFileSize(bytes, si = false, dp = 1) {
129
+ const thresh = si ? 1000 : 1024;
130
+ if (Math.abs(bytes) < thresh) {
131
+ return bytes + ' B';
132
+ }
133
+ const units = si
134
+ ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
135
+ : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
136
+ let u = -1;
137
+ const r = 10 ** dp;
138
+ do {
139
+ bytes /= thresh;
140
+ ++u;
141
+ } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
142
+ return bytes.toFixed(dp) + ' ' + units[u];
143
+ }
144
+ export function stringToArrayBuffer(str) {
145
+ const buf = new ArrayBuffer(str.length); //convert str to arrayBuffer
146
+ const view = new Uint8Array(buf); //create Uint8Array as viewer
147
+ for (let i = 0; i < str.length; i++) {
148
+ view[i] = str.charCodeAt(i) & 0xFF; //convert to octet
149
+ }
150
+ return buf;
151
+ }
152
+ export function chunkString(str, size) {
153
+ const numChunks = Math.ceil(str.length / size);
154
+ const chunks = new Array(numChunks);
155
+ for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
156
+ chunks[i] = str.substr(o, size);
157
+ }
158
+ return chunks;
159
+ }
160
+ export function getRandomString(length) {
161
+ const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // 62
162
+ let retVal = '';
163
+ for (let i = 0; i < length; ++i) {
164
+ retVal += charset.charAt(Math.floor(Math.random() * charset.length));
165
+ }
166
+ return retVal;
167
+ }
168
+ export function join(array) {
169
+ return array.join(SEPARATOR_TOKEN);
170
+ }
171
+ export function split(text) {
172
+ return text.split(SEPARATOR_TOKEN);
173
+ }
174
+ export const areArraysDifferent = (a, b) => {
175
+ if (a === b) {
176
+ return false;
177
+ }
178
+ if (a.length !== b.length) {
179
+ return true;
180
+ }
181
+ for (let i = 0; i < b.length; i += 1) {
182
+ if (b[i] !== a[i]) {
183
+ return true;
184
+ }
185
+ }
186
+ return false;
187
+ };
@@ -1,4 +1,4 @@
1
- import { ContestSettings } from '../types';
1
+ import { ContestSettings } from '../types/index.js';
2
2
  export declare const isEndlessContest: (settings: Pick<ContestSettings, "startsAt" | "frozenAt" | "silencedAt" | "endsAt" | "penalty"> | undefined) => boolean;
3
3
  export declare const isGlobalContest: (settings: Pick<ContestSettings, "startsAt" | "frozenAt" | "silencedAt" | "endsAt" | "penalty"> | undefined) => boolean;
4
4
  export declare const isPastContest: (settings: Pick<ContestSettings, "endsAt"> | undefined) => boolean;
@@ -0,0 +1,21 @@
1
+ import { MAX_DATE, MIN_DATE } from '../constants/index.js';
2
+ export const isEndlessContest = (settings) => {
3
+ return settings?.startsAt === MIN_DATE.getTime()
4
+ && settings?.frozenAt === MAX_DATE.getTime()
5
+ && settings?.silencedAt === MAX_DATE.getTime()
6
+ && settings?.endsAt === MAX_DATE.getTime()
7
+ && settings?.penalty === 0;
8
+ };
9
+ export const isGlobalContest = (settings) => {
10
+ return settings?.startsAt === 0
11
+ && settings?.frozenAt === 0
12
+ && settings?.silencedAt === 0
13
+ && settings?.endsAt === 0
14
+ && settings?.penalty === 0;
15
+ };
16
+ export const isPastContest = (settings) => {
17
+ return Date.now() > (settings?.endsAt ?? 0);
18
+ };
19
+ export const isFutureContest = (settings) => {
20
+ return (settings?.startsAt ?? 0) > Date.now();
21
+ };
@@ -0,0 +1,181 @@
1
+ import { ONE_DAY, ONE_HOUR, ONE_MINUTE } from '../constants/index.js';
2
+ export const changeYear = (date, year) => {
3
+ const newDate = new Date(date);
4
+ newDate.setFullYear(year);
5
+ return newDate;
6
+ };
7
+ export const changeMonth = (date, monthIndex) => {
8
+ const newDate = new Date(date);
9
+ newDate.setMonth(monthIndex);
10
+ return newDate;
11
+ };
12
+ export const changeDay = (date, day) => {
13
+ const newDate = new Date(date);
14
+ newDate.setDate(day);
15
+ return newDate;
16
+ };
17
+ export const changeHours = (date, hours) => {
18
+ const newDate = new Date(date);
19
+ newDate.setHours(hours);
20
+ return newDate;
21
+ };
22
+ export const changeMinutes = (date, minutes) => {
23
+ const newDate = new Date(date);
24
+ newDate.setMinutes(minutes);
25
+ return newDate;
26
+ };
27
+ export const changeSeconds = (date, seconds) => {
28
+ const newDate = new Date(date);
29
+ newDate.setSeconds(seconds);
30
+ return newDate;
31
+ };
32
+ export const changeMilliseconds = (date, milliseconds) => {
33
+ const newDate = new Date(date);
34
+ newDate.setMilliseconds(milliseconds);
35
+ return newDate;
36
+ };
37
+ export const decreaseYear = (date, count = 1) => changeYear(date, date.getFullYear() - count);
38
+ export const increaseYear = (date, count = 1) => changeYear(date, date.getFullYear() + count);
39
+ export const decreaseMonth = (date) => {
40
+ const newDate = new Date(date);
41
+ newDate.setMonth(newDate.getMonth() - 1);
42
+ return newDate;
43
+ };
44
+ export const increaseMonth = (date) => {
45
+ const newDate = new Date(date);
46
+ newDate.setMonth(newDate.getMonth() + 1);
47
+ return newDate;
48
+ };
49
+ export const decreaseDay = (date) => {
50
+ const newDate = new Date(date);
51
+ newDate.setDate(newDate.getDate() - 1);
52
+ return newDate;
53
+ };
54
+ export const increaseDay = (date) => {
55
+ const newDate = new Date(date);
56
+ newDate.setDate(newDate.getDate() + 1);
57
+ return newDate;
58
+ };
59
+ export const startOfDay = (date) => {
60
+ const newDate = new Date(date);
61
+ newDate.setHours(0, 0, 0, 0);
62
+ return newDate;
63
+ };
64
+ export const endOfDay = (date) => {
65
+ const newDate = new Date(date);
66
+ newDate.setHours(23, 59, 59, 999);
67
+ return newDate;
68
+ };
69
+ export const startOfMonth = (date) => {
70
+ const newDate = new Date(date);
71
+ newDate.setDate(1);
72
+ return startOfDay(newDate);
73
+ };
74
+ export const endOfMonth = (date) => {
75
+ const nextMonth = startOfMonth(increaseMonth(date));
76
+ return new Date(nextMonth.getTime() - 1);
77
+ };
78
+ export const startOfYear = (date) => {
79
+ const newDate = new Date(date);
80
+ newDate.setMonth(0);
81
+ return startOfMonth(newDate);
82
+ };
83
+ export const endOfYear = (date) => {
84
+ const nextYear = startOfYear(increaseYear(date));
85
+ return new Date(nextYear.getTime() - 1);
86
+ };
87
+ export const startOfWeek = (date) => {
88
+ const newDate = new Date(date);
89
+ while (newDate.getDay()) {
90
+ newDate.setDate(newDate.getDate() - 1);
91
+ }
92
+ return startOfDay(newDate);
93
+ };
94
+ export const endOfWeek = (date) => {
95
+ const newDate = new Date(date);
96
+ while (newDate.getDay() < 6) {
97
+ newDate.setDate(newDate.getDate() + 1);
98
+ }
99
+ return endOfDay(newDate);
100
+ };
101
+ export const startOfHour = (date) => {
102
+ const newDate = new Date(date);
103
+ newDate.setMinutes(0, 0, 0);
104
+ return newDate;
105
+ };
106
+ export const endOfHour = (date) => {
107
+ const newDate = new Date(date);
108
+ newDate.setMinutes(59, 59, 999);
109
+ return newDate;
110
+ };
111
+ export const startOfMinute = (date) => {
112
+ const newDate = new Date(date);
113
+ newDate.setSeconds(0, 0);
114
+ return newDate;
115
+ };
116
+ export const endOfMinute = (date) => {
117
+ const newDate = new Date(date);
118
+ newDate.setSeconds(59, 999);
119
+ return newDate;
120
+ };
121
+ export const startOfSecond = (date) => {
122
+ const newDate = new Date(date);
123
+ newDate.setMilliseconds(0);
124
+ return newDate;
125
+ };
126
+ export const endOfSecond = (date) => {
127
+ const newDate = new Date(date);
128
+ newDate.setMilliseconds(999);
129
+ return newDate;
130
+ };
131
+ export const isEqual = (a, b) => a.getTime() === b.getTime();
132
+ export const isSameYear = (a, b) => a.getFullYear() === b.getFullYear();
133
+ export const isSameMonth = (a, b) => isSameYear(a, b) && a.getMonth() === b.getMonth();
134
+ export const isSameDay = (a, b) => isSameMonth(a, b) && a.getDate() === b.getDate();
135
+ export const isSameHour = (a, b) => isSameDay(a, b) && a.getHours() === b.getHours();
136
+ export const isSameMinute = (a, b) => isSameHour(a, b) && a.getMinutes() === b.getMinutes();
137
+ export const isSameSecond = (a, b) => isSameMinute(a, b) && a.getSeconds() === b.getSeconds();
138
+ export const isSameMillisecond = (a, b) => isEqual(a, b);
139
+ export const isToday = (date) => isSameDay(date, new Date());
140
+ export const isValidDate = (date) => date instanceof Date && !Number.isNaN(date.getTime());
141
+ export const isAfter = (a, b) => a.getTime() > b.getTime();
142
+ export const isBefore = (a, b) => a.getTime() < b.getTime();
143
+ export const isYearAfter = (a, b) => a.getFullYear() > b.getFullYear();
144
+ export const isMonthAfter = (a, b) => isYearAfter(a, b) || (isSameYear(a, b) && a.getMonth() > b.getMonth());
145
+ export const isDayAfter = (a, b) => isMonthAfter(a, b) || (isSameMonth(a, b) && a.getDate() > b.getDate());
146
+ export const isHoursAfter = (a, b) => isDayAfter(a, b) || (isSameDay(a, b) && a.getHours() > b.getHours());
147
+ export const isMinutesAfter = (a, b) => isHoursAfter(a, b) || (isSameHour(a, b) && a.getMinutes() > b.getMinutes());
148
+ export const isSecondsAfter = (a, b) => isMinutesAfter(a, b) || (isSameMinute(a, b) && a.getSeconds() > b.getSeconds());
149
+ export const isMillisecondsAfter = (a, b) => isSecondsAfter(a, b) || (isSameSecond(a, b) && a.getMilliseconds() > b.getMilliseconds());
150
+ export const isYearBefore = (a, b) => a.getFullYear() < b.getFullYear();
151
+ export const isMonthBefore = (a, b) => isYearBefore(a, b) || (isSameYear(a, b) && a.getMonth() < b.getMonth());
152
+ export const isDayBefore = (a, b) => isMonthBefore(a, b) || (isSameMonth(a, b) && a.getDate() < b.getDate());
153
+ export const isHoursBefore = (a, b) => isDayBefore(a, b) || (isSameDay(a, b) && a.getHours() < b.getHours());
154
+ export const isMinutesBefore = (a, b) => isHoursBefore(a, b) || (isSameHour(a, b) && a.getMinutes() < b.getMinutes());
155
+ export const isSecondsBefore = (a, b) => isMinutesBefore(a, b) || (isSameMinute(a, b) && a.getSeconds() < b.getSeconds());
156
+ export const isMillisecondsBefore = (a, b) => isSecondsBefore(a, b) || (isSameSecond(a, b) && a.getMilliseconds() < b.getMilliseconds());
157
+ export const isWithinInterval = (date, { start, end }, cmp = '[]') => (cmp.charAt(0) === '[' ? isEqual(date, start) || isAfter(date, start) : isAfter(date, start)) &&
158
+ (cmp.charAt(1) === ']' ? isEqual(date, end) || isBefore(date, end) : isBefore(date, end));
159
+ export const normalizeToLocalStartOfDay = (timestamp) => {
160
+ const d = new Date(timestamp);
161
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
162
+ };
163
+ export const normalizeToLocalStartOfHour = (timestamp) => {
164
+ const d = new Date(timestamp);
165
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
166
+ };
167
+ export const normalizeToLocalStartOfMinutes = (timestamp) => {
168
+ const d = new Date(timestamp);
169
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes());
170
+ };
171
+ export const normalizeToLocalStartOfSeconds = (timestamp) => {
172
+ const d = new Date(timestamp);
173
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds());
174
+ };
175
+ export const getYears = (d) => d.getFullYear();
176
+ export const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
177
+ export const getDays = (d) => Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
178
+ export const getHours = (d) => Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
179
+ export const getMinutes = (d) => Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
180
+ export const getSeconds = (d) => Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
181
+ export const getMilliseconds = (d) => d.getTime();
@@ -1,5 +1,5 @@
1
- import { EntityMembersDto, EntityMembersResponseDto } from '../dto';
2
- import { EntityAccess, EntityMembers, EntityTeamsMemberUserData, EntityUsersMemberUserData } from '../types';
1
+ import { EntityMembersDto, EntityMembersResponseDto } from '../dto/index.js';
2
+ import { EntityAccess, EntityMembers, EntityTeamsMemberUserData, EntityUsersMemberUserData } from '../types/index.js';
3
3
  export declare const getDocumentAccess: (document: {
4
4
  members: Pick<EntityMembers, "rankAdministrators" | "rankManagers" | "rankGuests" | "rankSpectators" | "rankParticipants">;
5
5
  } | undefined) => EntityAccess;