@juki-team/commons 0.1.32 → 0.1.40

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 (254) hide show
  1. package/dist/cjs/index.cjs +3567 -0
  2. package/dist/esm/index.js +3347 -0
  3. package/dist/{constants → types/constants}/commons.d.ts +8 -8
  4. package/dist/{constants → types/constants}/company.d.ts +3 -3
  5. package/dist/{constants → types/constants}/contest.d.ts +3 -3
  6. package/dist/{constants → types/constants}/course.d.ts +2 -2
  7. package/dist/{constants → types/constants}/entity.d.ts +1 -1
  8. package/dist/{constants → types/constants}/file.d.ts +5 -6
  9. package/dist/types/constants/index.d.ts +18 -0
  10. package/dist/{constants → types/constants}/judge.d.ts +9 -11
  11. package/dist/{constants → types/constants}/problem.d.ts +8 -9
  12. package/dist/types/constants/services.d.ts +8 -0
  13. package/dist/{constants → types/constants}/system.d.ts +2 -2
  14. package/dist/{constants → types/constants}/teams.d.ts +3 -4
  15. package/dist/types/constants/user.d.ts +16 -0
  16. package/dist/{constants → types/constants}/websocket.d.ts +1 -1
  17. package/dist/{constants → types/constants}/worksheet.d.ts +2 -2
  18. package/dist/{dto → types/dto}/class.d.ts +4 -4
  19. package/dist/{dto → types/dto}/code.d.ts +1 -1
  20. package/dist/{dto → types/dto}/comments.d.ts +3 -3
  21. package/dist/types/dto/company.d.ts +67 -0
  22. package/dist/{dto → types/dto}/contest.d.ts +8 -9
  23. package/dist/{dto → types/dto}/course.d.ts +5 -5
  24. package/dist/{dto → types/dto}/entity.d.ts +3 -3
  25. package/dist/{dto → types/dto}/excalidraw.d.ts +4 -4
  26. package/dist/{dto → types/dto}/file.d.ts +2 -2
  27. package/dist/types/dto/index.d.ts +25 -0
  28. package/dist/{dto → types/dto}/judge.d.ts +1 -1
  29. package/dist/{dto → types/dto}/markdown.d.ts +4 -4
  30. package/dist/{dto → types/dto}/mermaid.d.ts +4 -4
  31. package/dist/{dto → types/dto}/problem.d.ts +4 -5
  32. package/dist/{dto → types/dto}/scoreboard.d.ts +1 -1
  33. package/dist/{dto → types/dto}/session.d.ts +2 -2
  34. package/dist/{dto → types/dto}/socket.d.ts +7 -8
  35. package/dist/{dto → types/dto}/statistics.d.ts +2 -2
  36. package/dist/{dto → types/dto}/submission.d.ts +4 -5
  37. package/dist/{dto → types/dto}/system.d.ts +18 -18
  38. package/dist/{dto → types/dto}/user.d.ts +14 -14
  39. package/dist/{dto → types/dto}/virtual-user.d.ts +1 -2
  40. package/dist/{dto → types/dto}/worksheet-submissions.d.ts +4 -4
  41. package/dist/{dto → types/dto}/worksheet.d.ts +4 -4
  42. package/dist/{helpers → types/helpers}/class.d.ts +1 -1
  43. package/dist/{helpers → types/helpers}/commons.d.ts +11 -9
  44. package/dist/{helpers → types/helpers}/contest.d.ts +1 -1
  45. package/dist/{helpers → types/helpers}/document.d.ts +2 -2
  46. package/dist/types/helpers/index.d.ts +14 -0
  47. package/dist/types/helpers/interval.d.ts +2 -0
  48. package/dist/{helpers → types/helpers}/judging.d.ts +2 -3
  49. package/dist/types/helpers/object.d.ts +1 -0
  50. package/dist/types/helpers/responses.d.ts +8 -0
  51. package/dist/types/helpers/socket.d.ts +45 -0
  52. package/dist/{helpers → types/helpers}/time.d.ts +1 -1
  53. package/dist/{helpers → types/helpers}/user.d.ts +1 -1
  54. package/dist/types/helpers/worksheet.d.ts +10 -0
  55. package/dist/types/index.d.ts +5 -23
  56. package/dist/{prototypes → types/prototypes}/Error.d.ts +3 -3
  57. package/dist/types/prototypes/Number.d.ts +7 -0
  58. package/dist/types/prototypes/index.d.ts +3 -0
  59. package/dist/types/{class.d.ts → types/class.d.ts} +2 -2
  60. package/dist/types/{commons.d.ts → types/commons.d.ts} +3 -3
  61. package/dist/types/types/company.d.ts +29 -0
  62. package/dist/types/{contest.d.ts → types/contest.d.ts} +26 -9
  63. package/dist/types/{course.d.ts → types/course.d.ts} +1 -1
  64. package/dist/types/{entity.d.ts → types/entity.d.ts} +4 -4
  65. package/dist/types/{excalidraw.d.ts → types/excalidraw.d.ts} +3 -3
  66. package/dist/types/{file.d.ts → types/file.d.ts} +9 -4
  67. package/dist/types/{group.d.ts → types/group.d.ts} +5 -2
  68. package/dist/types/types/index.d.ts +25 -0
  69. package/dist/types/{judge.d.ts → types/judge.d.ts} +32 -3
  70. package/dist/types/{markdown.d.ts → types/markdown.d.ts} +1 -1
  71. package/dist/types/{mermaid.d.ts → types/mermaid.d.ts} +1 -1
  72. package/dist/types/types/prisma.d.ts +284 -0
  73. package/dist/types/{problems.d.ts → types/problems.d.ts} +13 -4
  74. package/dist/types/types/services.d.ts +213 -0
  75. package/dist/types/{sheet.d.ts → types/sheet.d.ts} +2 -3
  76. package/dist/types/{socket.d.ts → types/socket.d.ts} +3 -3
  77. package/dist/types/{teams.d.ts → types/teams.d.ts} +2 -25
  78. package/dist/types/{users.d.ts → types/users.d.ts} +4 -10
  79. package/dist/types/types/virtual-user.d.ts +7 -0
  80. package/dist/types/{worksheet.d.ts → types/worksheet.d.ts} +3 -3
  81. package/package.json +19 -21
  82. package/biome.shared.json +0 -102
  83. package/dist/constants/commons.js +0 -658
  84. package/dist/constants/company.js +0 -24
  85. package/dist/constants/contest.js +0 -29
  86. package/dist/constants/course.js +0 -12
  87. package/dist/constants/date.js +0 -23
  88. package/dist/constants/email.js +0 -34
  89. package/dist/constants/entity.js +0 -18
  90. package/dist/constants/file.js +0 -46
  91. package/dist/constants/index.d.ts +0 -18
  92. package/dist/constants/index.js +0 -18
  93. package/dist/constants/judge.js +0 -221
  94. package/dist/constants/problem.js +0 -72
  95. package/dist/constants/routing.js +0 -7
  96. package/dist/constants/services.d.ts +0 -5
  97. package/dist/constants/services.js +0 -131
  98. package/dist/constants/system.js +0 -9
  99. package/dist/constants/teams.js +0 -18
  100. package/dist/constants/time.js +0 -9
  101. package/dist/constants/user.d.ts +0 -10
  102. package/dist/constants/user.js +0 -35
  103. package/dist/constants/websocket.js +0 -5
  104. package/dist/constants/worksheet.js +0 -66
  105. package/dist/dto/class.js +0 -1
  106. package/dist/dto/code.js +0 -1
  107. package/dist/dto/comments.js +0 -1
  108. package/dist/dto/contest.js +0 -7
  109. package/dist/dto/course.js +0 -1
  110. package/dist/dto/entity.js +0 -5
  111. package/dist/dto/excalidraw.js +0 -1
  112. package/dist/dto/file.js +0 -1
  113. package/dist/dto/image.js +0 -1
  114. package/dist/dto/index.d.ts +0 -24
  115. package/dist/dto/index.js +0 -24
  116. package/dist/dto/judge.js +0 -1
  117. package/dist/dto/markdown.js +0 -1
  118. package/dist/dto/mermaid.js +0 -1
  119. package/dist/dto/organization.d.ts +0 -102
  120. package/dist/dto/organization.js +0 -1
  121. package/dist/dto/problem.js +0 -1
  122. package/dist/dto/scoreboard.js +0 -1
  123. package/dist/dto/session.js +0 -1
  124. package/dist/dto/socket.js +0 -1
  125. package/dist/dto/statistics.js +0 -1
  126. package/dist/dto/submission.js +0 -1
  127. package/dist/dto/system.js +0 -1
  128. package/dist/dto/url.js +0 -1
  129. package/dist/dto/user.js +0 -1
  130. package/dist/dto/virtual-user.js +0 -1
  131. package/dist/dto/worksheet-submissions.js +0 -1
  132. package/dist/dto/worksheet.js +0 -1
  133. package/dist/helpers/class.js +0 -10
  134. package/dist/helpers/comments.js +0 -4
  135. package/dist/helpers/commons.js +0 -191
  136. package/dist/helpers/contest.js +0 -21
  137. package/dist/helpers/document.js +0 -38
  138. package/dist/helpers/file.js +0 -4
  139. package/dist/helpers/index.d.ts +0 -14
  140. package/dist/helpers/index.js +0 -14
  141. package/dist/helpers/interval.d.ts +0 -2
  142. package/dist/helpers/interval.js +0 -22
  143. package/dist/helpers/judging.js +0 -107
  144. package/dist/helpers/object.d.ts +0 -1
  145. package/dist/helpers/object.js +0 -32
  146. package/dist/helpers/responses.d.ts +0 -8
  147. package/dist/helpers/responses.js +0 -78
  148. package/dist/helpers/socket.d.ts +0 -45
  149. package/dist/helpers/socket.js +0 -238
  150. package/dist/helpers/time.js +0 -101
  151. package/dist/helpers/user.js +0 -14
  152. package/dist/helpers/worksheet.d.ts +0 -10
  153. package/dist/helpers/worksheet.js +0 -131
  154. package/dist/index.d.ts +0 -6
  155. package/dist/index.js +0 -6
  156. package/dist/prisma/enums/AssignmentClassType.d.ts +0 -7
  157. package/dist/prisma/enums/AssignmentClassType.js +0 -6
  158. package/dist/prisma/enums/ContestEventAction.d.ts +0 -10
  159. package/dist/prisma/enums/ContestEventAction.js +0 -9
  160. package/dist/prisma/enums/ContestProblemPrerequisiteType.d.ts +0 -5
  161. package/dist/prisma/enums/ContestProblemPrerequisiteType.js +0 -4
  162. package/dist/prisma/enums/ContestRole.d.ts +0 -11
  163. package/dist/prisma/enums/ContestRole.js +0 -10
  164. package/dist/prisma/enums/ContestStatus.d.ts +0 -6
  165. package/dist/prisma/enums/ContestStatus.js +0 -5
  166. package/dist/prisma/enums/CourseRole.d.ts +0 -12
  167. package/dist/prisma/enums/CourseRole.js +0 -11
  168. package/dist/prisma/enums/EntityObjectType.d.ts +0 -13
  169. package/dist/prisma/enums/EntityObjectType.js +0 -12
  170. package/dist/prisma/enums/EntityRole.d.ts +0 -8
  171. package/dist/prisma/enums/EntityRole.js +0 -7
  172. package/dist/prisma/enums/EntitySubjectType.d.ts +0 -7
  173. package/dist/prisma/enums/EntitySubjectType.js +0 -6
  174. package/dist/prisma/enums/FileRole.d.ts +0 -9
  175. package/dist/prisma/enums/FileRole.js +0 -8
  176. package/dist/prisma/enums/FileType.d.ts +0 -5
  177. package/dist/prisma/enums/FileType.js +0 -4
  178. package/dist/prisma/enums/GroupType.d.ts +0 -5
  179. package/dist/prisma/enums/GroupType.js +0 -4
  180. package/dist/prisma/enums/JudgeType.d.ts +0 -12
  181. package/dist/prisma/enums/JudgeType.js +0 -11
  182. package/dist/prisma/enums/OrganizationPlan.d.ts +0 -7
  183. package/dist/prisma/enums/OrganizationPlan.js +0 -6
  184. package/dist/prisma/enums/ProblemRole.d.ts +0 -11
  185. package/dist/prisma/enums/ProblemRole.js +0 -10
  186. package/dist/prisma/enums/ProblemScoringMode.d.ts +0 -6
  187. package/dist/prisma/enums/ProblemScoringMode.js +0 -5
  188. package/dist/prisma/enums/ProblemType.d.ts +0 -6
  189. package/dist/prisma/enums/ProblemType.js +0 -5
  190. package/dist/prisma/enums/ProblemVerdict.d.ts +0 -14
  191. package/dist/prisma/enums/ProblemVerdict.js +0 -13
  192. package/dist/prisma/enums/ShareLinkVisibility.d.ts +0 -5
  193. package/dist/prisma/enums/ShareLinkVisibility.js +0 -4
  194. package/dist/prisma/enums/SubmissionRunStatus.d.ts +0 -18
  195. package/dist/prisma/enums/SubmissionRunStatus.js +0 -17
  196. package/dist/prisma/enums/SystemRole.d.ts +0 -9
  197. package/dist/prisma/enums/SystemRole.js +0 -8
  198. package/dist/prisma/enums/TeamRole.d.ts +0 -9
  199. package/dist/prisma/enums/TeamRole.js +0 -8
  200. package/dist/prisma/enums/TelemetryType.d.ts +0 -9
  201. package/dist/prisma/enums/TelemetryType.js +0 -8
  202. package/dist/prisma/enums/UserRole.d.ts +0 -10
  203. package/dist/prisma/enums/UserRole.js +0 -9
  204. package/dist/prisma/enums/WorkingIn.d.ts +0 -8
  205. package/dist/prisma/enums/WorkingIn.js +0 -7
  206. package/dist/prisma/enums/WorksheetContentType.d.ts +0 -10
  207. package/dist/prisma/enums/WorksheetContentType.js +0 -9
  208. package/dist/prisma/enums/index.d.ts +0 -26
  209. package/dist/prisma/enums/index.js +0 -26
  210. package/dist/prototypes/Date.js +0 -218
  211. package/dist/prototypes/Error.js +0 -17
  212. package/dist/prototypes/Number.d.ts +0 -7
  213. package/dist/prototypes/Number.js +0 -8
  214. package/dist/prototypes/index.d.ts +0 -3
  215. package/dist/prototypes/index.js +0 -3
  216. package/dist/types/account.js +0 -10
  217. package/dist/types/class.js +0 -7
  218. package/dist/types/comments.js +0 -1
  219. package/dist/types/commons.js +0 -69
  220. package/dist/types/company.d.ts +0 -6
  221. package/dist/types/company.js +0 -7
  222. package/dist/types/contest.js +0 -6
  223. package/dist/types/course.js +0 -1
  224. package/dist/types/entity.js +0 -50
  225. package/dist/types/excalidraw.js +0 -1
  226. package/dist/types/file.js +0 -13
  227. package/dist/types/group.js +0 -1
  228. package/dist/types/index.js +0 -23
  229. package/dist/types/judge.js +0 -17
  230. package/dist/types/markdown.js +0 -1
  231. package/dist/types/mermaid.js +0 -1
  232. package/dist/types/notification.js +0 -8
  233. package/dist/types/problems.js +0 -16
  234. package/dist/types/services.d.ts +0 -214
  235. package/dist/types/services.js +0 -147
  236. package/dist/types/sheet.js +0 -16
  237. package/dist/types/socket.js +0 -49
  238. package/dist/types/submission.js +0 -1
  239. package/dist/types/teams.js +0 -28
  240. package/dist/types/users.js +0 -33
  241. package/dist/types/worksheet.js +0 -11
  242. /package/dist/{constants → types/constants}/date.d.ts +0 -0
  243. /package/dist/{constants → types/constants}/email.d.ts +0 -0
  244. /package/dist/{constants → types/constants}/routing.d.ts +0 -0
  245. /package/dist/{constants → types/constants}/time.d.ts +0 -0
  246. /package/dist/{dto → types/dto}/image.d.ts +0 -0
  247. /package/dist/{dto → types/dto}/url.d.ts +0 -0
  248. /package/dist/{helpers → types/helpers}/comments.d.ts +0 -0
  249. /package/dist/{helpers → types/helpers}/file.d.ts +0 -0
  250. /package/dist/{prototypes → types/prototypes}/Date.d.ts +0 -0
  251. /package/dist/types/{account.d.ts → types/account.d.ts} +0 -0
  252. /package/dist/types/{comments.d.ts → types/comments.d.ts} +0 -0
  253. /package/dist/types/{notification.d.ts → types/notification.d.ts} +0 -0
  254. /package/dist/types/{submission.d.ts → types/submission.d.ts} +0 -0
@@ -1,101 +0,0 @@
1
- import { ONE_DAY, ONE_HOUR, ONE_MINUTE } from '../constants/index.js';
2
- export function splitTime(timeRemaining) {
3
- const remaining = [];
4
- // const aYearMilliseconds = 1000 * 60 * 60 * 24 * 365;
5
- // const remainingYears = Math.floor(timeRemaining / aYearMilliseconds);
6
- // remaining.push({ remaining: remainingYears, label: 'years', milliseconds: aYearMilliseconds });
7
- // const aWeekMilliseconds = 1000 * 60 * 60 * 24 * 7;
8
- // const remainingWeeks = Math.floor((timeRemaining % aYearMilliseconds) / aWeekMilliseconds);
9
- // remaining.push({ remaining: remainingWeeks, label: 'weeks', milliseconds: aWeekMilliseconds });
10
- const aSecondMilliseconds = 1000;
11
- const aMinuteMilliseconds = aSecondMilliseconds * 60;
12
- const aHourMilliseconds = aMinuteMilliseconds * 60;
13
- const aDayMilliseconds = aHourMilliseconds * 24;
14
- const aWeekMilliseconds = aDayMilliseconds * 7;
15
- const remainingWeeks = Math.floor(timeRemaining / aWeekMilliseconds);
16
- remaining.push({
17
- remaining: remainingWeeks,
18
- label: remainingWeeks === 1 ? 'week' : 'weeks',
19
- abbreviatedLabel: 'w',
20
- milliseconds: aWeekMilliseconds,
21
- digits: 2,
22
- });
23
- const remainingDays = Math.floor((timeRemaining % aWeekMilliseconds) / aDayMilliseconds);
24
- remaining.push({
25
- remaining: remainingDays,
26
- label: remainingDays === 1 ? 'day' : 'days',
27
- abbreviatedLabel: 'd',
28
- milliseconds: aDayMilliseconds,
29
- digits: 2,
30
- });
31
- const remainingHours = Math.floor((timeRemaining % aDayMilliseconds) / aHourMilliseconds);
32
- remaining.push({
33
- remaining: remainingHours,
34
- label: remainingHours === 1 ? 'hour' : 'hours',
35
- abbreviatedLabel: 'h',
36
- milliseconds: aHourMilliseconds,
37
- digits: 2,
38
- });
39
- const remainingMinutes = Math.floor((timeRemaining % aHourMilliseconds) / aMinuteMilliseconds);
40
- remaining.push({
41
- remaining: remainingMinutes,
42
- label: remainingMinutes === 1 ? 'minute' : 'minutes',
43
- abbreviatedLabel: 'm',
44
- milliseconds: aMinuteMilliseconds,
45
- digits: 2,
46
- });
47
- const remainingSeconds = Math.floor((timeRemaining % aMinuteMilliseconds) / aSecondMilliseconds);
48
- remaining.push({
49
- remaining: remainingSeconds,
50
- label: remainingSeconds === 1 ? 'second' : 'seconds',
51
- abbreviatedLabel: 's',
52
- milliseconds: aSecondMilliseconds,
53
- digits: 2,
54
- });
55
- const remainingMilliseconds = Math.floor(timeRemaining % aSecondMilliseconds);
56
- remaining.push({
57
- remaining: remainingMilliseconds,
58
- label: remainingMilliseconds === 1 ? 'millisecond' : 'milliseconds',
59
- abbreviatedLabel: 'ms',
60
- milliseconds: 1,
61
- digits: 3,
62
- });
63
- // while (remaining[0].remaining <= 0) {
64
- // remaining.shift();
65
- // if (remaining.length === 3) {
66
- // break;
67
- // }
68
- // }
69
- return remaining;
70
- }
71
- export function normalizeToLocalStartOfDay(timestamp) {
72
- const date = new Date(timestamp);
73
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
74
- }
75
- export function normalizeToLocalStartOfHour(timestamp) {
76
- const date = new Date(timestamp);
77
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours());
78
- }
79
- export function normalizeToLocalStartOfMinutes(timestamp) {
80
- const date = new Date(timestamp);
81
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
82
- }
83
- export function normalizeToLocalStartOfSeconds(timestamp) {
84
- const date = new Date(timestamp);
85
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes());
86
- }
87
- export const getYears = (d) => d.getFullYear();
88
- export const getMonths = (d) => d.getFullYear() * 12 + d.getMonth();
89
- export const getDays = (d) => {
90
- return Math.floor(normalizeToLocalStartOfDay(d).getTime() / ONE_DAY);
91
- };
92
- export const getHours = (d) => {
93
- return Math.floor(normalizeToLocalStartOfHour(d).getTime() / ONE_HOUR);
94
- };
95
- export const getMinutes = (d) => {
96
- return Math.floor(normalizeToLocalStartOfMinutes(d).getTime() / ONE_MINUTE);
97
- };
98
- export const getSeconds = (d) => {
99
- return Math.floor(normalizeToLocalStartOfSeconds(d).getTime() / 1000);
100
- };
101
- export const getMilliseconds = (d) => d.getTime();
@@ -1,14 +0,0 @@
1
- export const getUserKey = (userNickname, userCompanyKey) => {
2
- return `${userNickname}|${userCompanyKey}`;
3
- };
4
- export const getParamsOfUserKey = (userKey) => {
5
- const [userNickname, userCompanyKey] = userKey.split('|');
6
- return { userNickname, userCompanyKey };
7
- };
8
- export const getClientId = (sessionId, uiId) => {
9
- return `${sessionId}|${uiId}`;
10
- };
11
- export const getParamsOfClientId = (clientId) => {
12
- const [sessionId, uiId] = clientId.split('|');
13
- return { sessionId, uiId };
14
- };
@@ -1,10 +0,0 @@
1
- import { type BasicWorksheet, type BodyWorksheet, type CodeEditorSheet, type JkmdSheet, type QuizOptionsSheet, type QuizProblemSheet, type QuizTextSheet, type SummaryWorksheetsInPages, type WorksheetsInPages } from '../types/index.js';
2
- export declare const getWorksheetsInPages: (initialSheets: BodyWorksheet[]) => WorksheetsInPages;
3
- export declare const getSummaryWorksheetsInPages: (initialSheets: BodyWorksheet[]) => SummaryWorksheetsInPages;
4
- export declare const getTotalExercisesOfSummaryWorksheetsInPages: (content: SummaryWorksheetsInPages) => number;
5
- export declare const isBasicWorksheet: (value: unknown) => value is BasicWorksheet;
6
- export declare const isJkmdSheet: (value: unknown) => value is JkmdSheet;
7
- export declare const isCodeEditorSheet: (value: unknown) => value is CodeEditorSheet;
8
- export declare const isQuizProblemSheet: (value: unknown) => value is QuizProblemSheet;
9
- export declare const isQuizOptionsSheet: (value: unknown) => value is QuizOptionsSheet;
10
- export declare const isQuizTextSheet: (value: unknown) => value is QuizTextSheet;
@@ -1,131 +0,0 @@
1
- import { NEW_PAGE_SHEET } from '../constants/worksheet.js';
2
- import { Judge, WorksheetType, } from '../types/index.js';
3
- export const getWorksheetsInPages = (initialSheets) => {
4
- const sheets = [...initialSheets];
5
- if (sheets[0]?.type !== WorksheetType.NEW_PAGE) {
6
- sheets.unshift(NEW_PAGE_SHEET());
7
- }
8
- let newPage = sheets[0];
9
- let content = [];
10
- const sheetsByPages = [];
11
- for (let i = 1; i < sheets.length; i++) {
12
- const sheet = sheets[i];
13
- if (sheet.type === WorksheetType.NEW_PAGE) {
14
- sheetsByPages.push({
15
- header: newPage,
16
- content: [...content],
17
- });
18
- newPage = sheet;
19
- content = [];
20
- }
21
- else {
22
- content.push(sheet);
23
- }
24
- }
25
- sheetsByPages.push({
26
- header: newPage,
27
- content: [...content],
28
- });
29
- return sheetsByPages;
30
- };
31
- export const getSummaryWorksheetsInPages = (initialSheets) => {
32
- const sheets = [...initialSheets];
33
- if (sheets[0]?.type !== WorksheetType.NEW_PAGE) {
34
- sheets.unshift(NEW_PAGE_SHEET());
35
- }
36
- let newPage = sheets[0];
37
- let content = [];
38
- const sheetsByPages = [];
39
- for (let i = 1; i < sheets.length; i++) {
40
- const sheet = sheets[i];
41
- if (sheet.type === WorksheetType.NEW_PAGE) {
42
- sheetsByPages.push({
43
- header: newPage,
44
- content: content.map((c) => ({
45
- id: c.id,
46
- type: c.type,
47
- title: c.title,
48
- points: c.points,
49
- })),
50
- });
51
- newPage = sheet;
52
- content = [];
53
- }
54
- else {
55
- content.push(sheet);
56
- }
57
- }
58
- sheetsByPages.push({
59
- header: newPage,
60
- content: [...content],
61
- });
62
- return sheetsByPages;
63
- };
64
- export const getTotalExercisesOfSummaryWorksheetsInPages = (content) => content.reduce((sum, { content }) => sum +
65
- content.reduce((sum, { type }) => sum +
66
- +(type === WorksheetType.QUIZ_OPTIONS || type === WorksheetType.QUIZ_PROBLEM || type === WorksheetType.QUIZ_TEXT), 0), 0);
67
- export const isBasicWorksheet = (value) => {
68
- if (typeof value !== 'object' || value === null)
69
- return false;
70
- const v = value;
71
- return (typeof v.id === 'string' &&
72
- !!v.id &&
73
- Object.values(WorksheetType).includes(v.type) &&
74
- typeof v.title === 'string' &&
75
- typeof v.points === 'number');
76
- };
77
- export const isJkmdSheet = (value) => {
78
- if (!isBasicWorksheet(value))
79
- return false;
80
- const v = value;
81
- return value.type === WorksheetType.JK_MD && typeof v.content === 'string';
82
- };
83
- export const isCodeEditorSheet = (value) => {
84
- if (!isBasicWorksheet(value))
85
- return false;
86
- const v = value;
87
- return (value.type === WorksheetType.CODE_EDITOR &&
88
- typeof v.sourceCode === 'object' &&
89
- v.sourceCode !== null &&
90
- typeof v.testCases === 'object' &&
91
- v.testCases !== null &&
92
- Array.isArray(v.languages) &&
93
- typeof v.height === 'number');
94
- };
95
- export const isQuizProblemSheet = (value) => {
96
- if (typeof value !== 'object' || value === null)
97
- return false;
98
- const v = value;
99
- return ((isBasicWorksheet(value) &&
100
- value.type === WorksheetType.QUIZ_PROBLEM &&
101
- Object.values(Judge).includes(v.problemJudge)) ||
102
- (typeof v.problemJudge === 'string' &&
103
- typeof v.problemKey === 'string' &&
104
- Array.isArray(v.languages) &&
105
- typeof v.height === 'number'));
106
- };
107
- export const isQuizOptionsSheet = (value) => {
108
- if (!isBasicWorksheet(value))
109
- return false;
110
- const v = value;
111
- return (value.type === WorksheetType.QUIZ_OPTIONS &&
112
- typeof v.description === 'string' &&
113
- Array.isArray(v.options) &&
114
- v.options.every((option) => {
115
- if (typeof option !== 'object' || option === null)
116
- return false;
117
- const o = option;
118
- return typeof o.label === 'string' && typeof o.correct === 'boolean' && typeof o.id === 'string';
119
- }) &&
120
- typeof v.multiple === 'boolean' &&
121
- (v.scoringMode === 'TOTAL' || v.scoringMode === 'PARTIAL'));
122
- };
123
- export const isQuizTextSheet = (value) => {
124
- if (!isBasicWorksheet(value))
125
- return false;
126
- const v = value;
127
- return (value.type === WorksheetType.QUIZ_TEXT &&
128
- typeof v.description === 'string' &&
129
- typeof v.answer === 'string' &&
130
- (v.inputType === 'text' || v.inputType === 'number' || v.inputType === 'textarea'));
131
- };
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './constants/index.js';
2
- export * from './dto/index.js';
3
- export * from './helpers/index.js';
4
- export * from './prisma/enums/index.js';
5
- export * from './prototypes/index.js';
6
- export * from './types/index.js';
package/dist/index.js DELETED
@@ -1,6 +0,0 @@
1
- export * from './constants/index.js';
2
- export * from './dto/index.js';
3
- export * from './helpers/index.js';
4
- export * from './prisma/enums/index.js';
5
- export * from './prototypes/index.js';
6
- export * from './types/index.js';
@@ -1,7 +0,0 @@
1
- export declare const AssignmentClassType: {
2
- readonly NONE: "NONE";
3
- readonly COURSE: "COURSE";
4
- readonly WORKSHEET: "WORKSHEET";
5
- readonly CONTEST: "CONTEST";
6
- };
7
- export type AssignmentClassType = (typeof AssignmentClassType)[keyof typeof AssignmentClassType];
@@ -1,6 +0,0 @@
1
- export const AssignmentClassType = {
2
- NONE: 'NONE',
3
- COURSE: 'COURSE',
4
- WORKSHEET: 'WORKSHEET',
5
- CONTEST: 'CONTEST',
6
- };
@@ -1,10 +0,0 @@
1
- export declare const ContestEventAction: {
2
- readonly DATA_UPDATE: "DATA_UPDATE";
3
- readonly SCOREBOARD_RECALCULATE: "SCOREBOARD_RECALCULATE";
4
- readonly SCOREBOARD_UNLOCK: "SCOREBOARD_UNLOCK";
5
- readonly SCOREBOARD_LOCK: "SCOREBOARD_LOCK";
6
- readonly ENABLE_UPSOLVING: "ENABLE_UPSOLVING";
7
- readonly DISABLE_UPSOLVING: "DISABLE_UPSOLVING";
8
- readonly PARTICIPANT_JOIN: "PARTICIPANT_JOIN";
9
- };
10
- export type ContestEventAction = (typeof ContestEventAction)[keyof typeof ContestEventAction];
@@ -1,9 +0,0 @@
1
- export const ContestEventAction = {
2
- DATA_UPDATE: 'DATA_UPDATE',
3
- SCOREBOARD_RECALCULATE: 'SCOREBOARD_RECALCULATE',
4
- SCOREBOARD_UNLOCK: 'SCOREBOARD_UNLOCK',
5
- SCOREBOARD_LOCK: 'SCOREBOARD_LOCK',
6
- ENABLE_UPSOLVING: 'ENABLE_UPSOLVING',
7
- DISABLE_UPSOLVING: 'DISABLE_UPSOLVING',
8
- PARTICIPANT_JOIN: 'PARTICIPANT_JOIN',
9
- };
@@ -1,5 +0,0 @@
1
- export declare const ContestProblemPrerequisiteType: {
2
- readonly INDIVIDUALLY: "INDIVIDUALLY";
3
- readonly CONTEST: "CONTEST";
4
- };
5
- export type ContestProblemPrerequisiteType = (typeof ContestProblemPrerequisiteType)[keyof typeof ContestProblemPrerequisiteType];
@@ -1,4 +0,0 @@
1
- export const ContestProblemPrerequisiteType = {
2
- INDIVIDUALLY: 'INDIVIDUALLY',
3
- CONTEST: 'CONTEST',
4
- };
@@ -1,11 +0,0 @@
1
- export declare const ContestRole: {
2
- readonly RESTRICTED: "RESTRICTED";
3
- readonly GUEST: "GUEST";
4
- readonly REGULAR: "REGULAR";
5
- readonly CREATOR: "CREATOR";
6
- readonly MANAGER: "MANAGER";
7
- readonly MASTER: "MASTER";
8
- readonly ADMIN: "ADMIN";
9
- readonly SUPER_ADMIN: "SUPER_ADMIN";
10
- };
11
- export type ContestRole = (typeof ContestRole)[keyof typeof ContestRole];
@@ -1,10 +0,0 @@
1
- export const ContestRole = {
2
- RESTRICTED: 'RESTRICTED',
3
- GUEST: 'GUEST',
4
- REGULAR: 'REGULAR',
5
- CREATOR: 'CREATOR',
6
- MANAGER: 'MANAGER',
7
- MASTER: 'MASTER',
8
- ADMIN: 'ADMIN',
9
- SUPER_ADMIN: 'SUPER_ADMIN',
10
- };
@@ -1,6 +0,0 @@
1
- export declare const ContestStatus: {
2
- readonly PUBLIC: "PUBLIC";
3
- readonly RESERVED: "RESERVED";
4
- readonly ARCHIVED: "ARCHIVED";
5
- };
6
- export type ContestStatus = (typeof ContestStatus)[keyof typeof ContestStatus];
@@ -1,5 +0,0 @@
1
- export const ContestStatus = {
2
- PUBLIC: 'PUBLIC',
3
- RESERVED: 'RESERVED',
4
- ARCHIVED: 'ARCHIVED',
5
- };
@@ -1,12 +0,0 @@
1
- export declare const CourseRole: {
2
- readonly RESTRICTED: "RESTRICTED";
3
- readonly GUEST: "GUEST";
4
- readonly REGULAR: "REGULAR";
5
- readonly CREATOR: "CREATOR";
6
- readonly SUPER_CREATOR: "SUPER_CREATOR";
7
- readonly MANAGER: "MANAGER";
8
- readonly MASTER: "MASTER";
9
- readonly ADMIN: "ADMIN";
10
- readonly SUPER_ADMIN: "SUPER_ADMIN";
11
- };
12
- export type CourseRole = (typeof CourseRole)[keyof typeof CourseRole];
@@ -1,11 +0,0 @@
1
- export const CourseRole = {
2
- RESTRICTED: 'RESTRICTED',
3
- GUEST: 'GUEST',
4
- REGULAR: 'REGULAR',
5
- CREATOR: 'CREATOR',
6
- SUPER_CREATOR: 'SUPER_CREATOR',
7
- MANAGER: 'MANAGER',
8
- MASTER: 'MASTER',
9
- ADMIN: 'ADMIN',
10
- SUPER_ADMIN: 'SUPER_ADMIN',
11
- };
@@ -1,13 +0,0 @@
1
- export declare const EntityObjectType: {
2
- readonly PROBLEM: "PROBLEM";
3
- readonly CONTEST: "CONTEST";
4
- readonly COURSE: "COURSE";
5
- readonly CLASS: "CLASS";
6
- readonly GROUP: "GROUP";
7
- readonly WORKSHEET: "WORKSHEET";
8
- readonly FILE: "FILE";
9
- readonly EXCALIDRAW: "EXCALIDRAW";
10
- readonly MARKDOWN: "MARKDOWN";
11
- readonly MERMAID: "MERMAID";
12
- };
13
- export type EntityObjectType = (typeof EntityObjectType)[keyof typeof EntityObjectType];
@@ -1,12 +0,0 @@
1
- export const EntityObjectType = {
2
- PROBLEM: 'PROBLEM',
3
- CONTEST: 'CONTEST',
4
- COURSE: 'COURSE',
5
- CLASS: 'CLASS',
6
- GROUP: 'GROUP',
7
- WORKSHEET: 'WORKSHEET',
8
- FILE: 'FILE',
9
- EXCALIDRAW: 'EXCALIDRAW',
10
- MARKDOWN: 'MARKDOWN',
11
- MERMAID: 'MERMAID',
12
- };
@@ -1,8 +0,0 @@
1
- export declare const EntityRole: {
2
- readonly ADMINISTRATOR: "ADMINISTRATOR";
3
- readonly MANAGER: "MANAGER";
4
- readonly PARTICIPANT: "PARTICIPANT";
5
- readonly SPECTATOR: "SPECTATOR";
6
- readonly GUEST: "GUEST";
7
- };
8
- export type EntityRole = (typeof EntityRole)[keyof typeof EntityRole];
@@ -1,7 +0,0 @@
1
- export const EntityRole = {
2
- ADMINISTRATOR: 'ADMINISTRATOR',
3
- MANAGER: 'MANAGER',
4
- PARTICIPANT: 'PARTICIPANT',
5
- SPECTATOR: 'SPECTATOR',
6
- GUEST: 'GUEST',
7
- };
@@ -1,7 +0,0 @@
1
- export declare const EntitySubjectType: {
2
- readonly USER: "USER";
3
- readonly GROUP: "GROUP";
4
- readonly PUBLIC: "PUBLIC";
5
- readonly SHARE_LINK: "SHARE_LINK";
6
- };
7
- export type EntitySubjectType = (typeof EntitySubjectType)[keyof typeof EntitySubjectType];
@@ -1,6 +0,0 @@
1
- export const EntitySubjectType = {
2
- USER: 'USER',
3
- GROUP: 'GROUP',
4
- PUBLIC: 'PUBLIC', // wildcard — anyone. subjectId must be 0
5
- SHARE_LINK: 'SHARE_LINK',
6
- };
@@ -1,9 +0,0 @@
1
- export declare const FileRole: {
2
- readonly RESTRICTED: "RESTRICTED";
3
- readonly GUEST: "GUEST";
4
- readonly REGULAR: "REGULAR";
5
- readonly MASTER: "MASTER";
6
- readonly ADMIN: "ADMIN";
7
- readonly SUPER_ADMIN: "SUPER_ADMIN";
8
- };
9
- export type FileRole = (typeof FileRole)[keyof typeof FileRole];
@@ -1,8 +0,0 @@
1
- export const FileRole = {
2
- RESTRICTED: 'RESTRICTED',
3
- GUEST: 'GUEST',
4
- REGULAR: 'REGULAR',
5
- MASTER: 'MASTER',
6
- ADMIN: 'ADMIN',
7
- SUPER_ADMIN: 'SUPER_ADMIN',
8
- };
@@ -1,5 +0,0 @@
1
- export declare const FileType: {
2
- readonly FOLDER: "FOLDER";
3
- readonly FILE: "FILE";
4
- };
5
- export type FileType = (typeof FileType)[keyof typeof FileType];
@@ -1,4 +0,0 @@
1
- export const FileType = {
2
- FOLDER: 'FOLDER',
3
- FILE: 'FILE',
4
- };
@@ -1,5 +0,0 @@
1
- export declare const GroupType: {
2
- readonly CLASS: "CLASS";
3
- readonly TEAM: "TEAM";
4
- };
5
- export type GroupType = (typeof GroupType)[keyof typeof GroupType];
@@ -1,4 +0,0 @@
1
- export const GroupType = {
2
- CLASS: 'CLASS',
3
- TEAM: 'TEAM',
4
- };
@@ -1,12 +0,0 @@
1
- export declare const JudgeType: {
2
- readonly JUKI_JUDGE: "JUKI_JUDGE";
3
- readonly CODEFORCES: "CODEFORCES";
4
- readonly CODEFORCES_GYM: "CODEFORCES_GYM";
5
- readonly JV_UMSA: "JV_UMSA";
6
- readonly UVA_ONLINE_JUDGE: "UVA_ONLINE_JUDGE";
7
- readonly AT_CODER: "AT_CODER";
8
- readonly CODECHEF: "CODECHEF";
9
- readonly TOPCODER: "TOPCODER";
10
- readonly LEETCODE: "LEETCODE";
11
- };
12
- export type JudgeType = (typeof JudgeType)[keyof typeof JudgeType];
@@ -1,11 +0,0 @@
1
- export const JudgeType = {
2
- JUKI_JUDGE: 'JUKI_JUDGE',
3
- CODEFORCES: 'CODEFORCES',
4
- CODEFORCES_GYM: 'CODEFORCES_GYM',
5
- JV_UMSA: 'JV_UMSA',
6
- UVA_ONLINE_JUDGE: 'UVA_ONLINE_JUDGE',
7
- AT_CODER: 'AT_CODER',
8
- CODECHEF: 'CODECHEF',
9
- TOPCODER: 'TOPCODER',
10
- LEETCODE: 'LEETCODE',
11
- };
@@ -1,7 +0,0 @@
1
- export declare const OrganizationPlan: {
2
- readonly FREE: "FREE";
3
- readonly STANDARD: "STANDARD";
4
- readonly PREMIUM: "PREMIUM";
5
- readonly CUSTOM: "CUSTOM";
6
- };
7
- export type OrganizationPlan = (typeof OrganizationPlan)[keyof typeof OrganizationPlan];
@@ -1,6 +0,0 @@
1
- export const OrganizationPlan = {
2
- FREE: 'FREE',
3
- STANDARD: 'STANDARD',
4
- PREMIUM: 'PREMIUM',
5
- CUSTOM: 'CUSTOM',
6
- };
@@ -1,11 +0,0 @@
1
- export declare const ProblemRole: {
2
- readonly RESTRICTED: "RESTRICTED";
3
- readonly GUEST: "GUEST";
4
- readonly REGULAR: "REGULAR";
5
- readonly CREATOR: "CREATOR";
6
- readonly MANAGER: "MANAGER";
7
- readonly MASTER: "MASTER";
8
- readonly ADMIN: "ADMIN";
9
- readonly SUPER_ADMIN: "SUPER_ADMIN";
10
- };
11
- export type ProblemRole = (typeof ProblemRole)[keyof typeof ProblemRole];
@@ -1,10 +0,0 @@
1
- export const ProblemRole = {
2
- RESTRICTED: 'RESTRICTED',
3
- GUEST: 'GUEST',
4
- REGULAR: 'REGULAR',
5
- CREATOR: 'CREATOR',
6
- MANAGER: 'MANAGER',
7
- MASTER: 'MASTER',
8
- ADMIN: 'ADMIN',
9
- SUPER_ADMIN: 'SUPER_ADMIN',
10
- };
@@ -1,6 +0,0 @@
1
- export declare const ProblemScoringMode: {
2
- readonly SUBTASK: "SUBTASK";
3
- readonly TOTAL: "TOTAL";
4
- readonly PARTIAL: "PARTIAL";
5
- };
6
- export type ProblemScoringMode = (typeof ProblemScoringMode)[keyof typeof ProblemScoringMode];
@@ -1,5 +0,0 @@
1
- export const ProblemScoringMode = {
2
- SUBTASK: 'SUBTASK',
3
- TOTAL: 'TOTAL',
4
- PARTIAL: 'PARTIAL',
5
- };
@@ -1,6 +0,0 @@
1
- export declare const ProblemType: {
2
- readonly STANDARD: "STANDARD";
3
- readonly DYNAMIC: "DYNAMIC";
4
- readonly INTERACTIVE: "INTERACTIVE";
5
- };
6
- export type ProblemType = (typeof ProblemType)[keyof typeof ProblemType];
@@ -1,5 +0,0 @@
1
- export const ProblemType = {
2
- STANDARD: 'STANDARD',
3
- DYNAMIC: 'DYNAMIC',
4
- INTERACTIVE: 'INTERACTIVE',
5
- };
@@ -1,14 +0,0 @@
1
- export declare const ProblemVerdict: {
2
- readonly NONE: "NONE";
3
- readonly PENDING: "PENDING";
4
- readonly HIDDEN: "HIDDEN";
5
- readonly CE: "CE";
6
- readonly RE: "RE";
7
- readonly TLE: "TLE";
8
- readonly MLE: "MLE";
9
- readonly WA: "WA";
10
- readonly PE: "PE";
11
- readonly PA: "PA";
12
- readonly AC: "AC";
13
- };
14
- export type ProblemVerdict = (typeof ProblemVerdict)[keyof typeof ProblemVerdict];
@@ -1,13 +0,0 @@
1
- export const ProblemVerdict = {
2
- NONE: 'NONE',
3
- PENDING: 'PENDING',
4
- HIDDEN: 'HIDDEN',
5
- CE: 'CE',
6
- RE: 'RE',
7
- TLE: 'TLE',
8
- MLE: 'MLE',
9
- WA: 'WA',
10
- PE: 'PE',
11
- PA: 'PA',
12
- AC: 'AC',
13
- };
@@ -1,5 +0,0 @@
1
- export declare const ShareLinkVisibility: {
2
- readonly PUBLIC: "PUBLIC";
3
- readonly RESTRICTED: "RESTRICTED";
4
- };
5
- export type ShareLinkVisibility = (typeof ShareLinkVisibility)[keyof typeof ShareLinkVisibility];
@@ -1,4 +0,0 @@
1
- export const ShareLinkVisibility = {
2
- PUBLIC: 'PUBLIC', // anyone with the link
3
- RESTRICTED: 'RESTRICTED', // only allowedUserIds
4
- };