@juki-team/commons 0.1.32 → 0.2.1

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 (97) hide show
  1. package/dist/constants/commons.d.ts +1 -1
  2. package/dist/constants/commons.js +1 -1
  3. package/dist/constants/index.d.ts +1 -1
  4. package/dist/constants/index.js +1 -1
  5. package/dist/dto/index.d.ts +2 -1
  6. package/dist/dto/index.js +2 -1
  7. package/dist/helpers/array.d.ts +3 -0
  8. package/dist/helpers/array.js +28 -0
  9. package/dist/helpers/console.d.ts +3 -0
  10. package/dist/helpers/console.js +9 -0
  11. package/dist/helpers/date.d.ts +68 -0
  12. package/dist/helpers/date.js +181 -0
  13. package/dist/helpers/document.d.ts +1 -11
  14. package/dist/helpers/document.js +1 -21
  15. package/dist/helpers/duration.d.ts +2 -0
  16. package/dist/helpers/duration.js +57 -0
  17. package/dist/helpers/entity.d.ts +11 -0
  18. package/dist/helpers/entity.js +20 -0
  19. package/dist/helpers/file.d.ts +6 -1
  20. package/dist/helpers/file.js +23 -2
  21. package/dist/helpers/http.d.ts +1 -0
  22. package/dist/helpers/http.js +8 -0
  23. package/dist/helpers/index.d.ts +12 -3
  24. package/dist/helpers/index.js +12 -3
  25. package/dist/helpers/json.d.ts +3 -0
  26. package/dist/helpers/json.js +31 -0
  27. package/dist/helpers/number.d.ts +2 -0
  28. package/dist/helpers/number.js +2 -0
  29. package/dist/helpers/object.d.ts +2 -0
  30. package/dist/helpers/object.js +28 -0
  31. package/dist/helpers/problem.d.ts +2 -0
  32. package/dist/helpers/problem.js +1 -0
  33. package/dist/helpers/responses.d.ts +1 -1
  34. package/dist/helpers/responses.js +3 -2
  35. package/dist/helpers/string.d.ts +7 -0
  36. package/dist/helpers/string.js +52 -0
  37. package/dist/index.d.ts +0 -1
  38. package/dist/index.js +0 -1
  39. package/dist/prisma/enums/index.d.ts +11 -11
  40. package/dist/prisma/enums/index.js +11 -11
  41. package/dist/types/assignment.d.ts +28 -0
  42. package/dist/types/assignment.js +7 -0
  43. package/dist/types/class.d.ts +1 -27
  44. package/dist/types/class.js +1 -7
  45. package/dist/types/code.d.ts +39 -0
  46. package/dist/types/{commons.js → code.js} +0 -28
  47. package/dist/types/contest.d.ts +2 -2
  48. package/dist/types/device.d.ts +7 -0
  49. package/dist/types/device.js +1 -0
  50. package/dist/types/duration.d.ts +7 -0
  51. package/dist/types/duration.js +1 -0
  52. package/dist/types/entity.d.ts +12 -0
  53. package/dist/types/entity.js +14 -0
  54. package/dist/types/id.d.ts +3 -0
  55. package/dist/types/id.js +1 -0
  56. package/dist/types/index.d.ts +10 -5
  57. package/dist/types/index.js +10 -5
  58. package/dist/types/judge.d.ts +1 -1
  59. package/dist/types/{problems.d.ts → problem.d.ts} +2 -1
  60. package/dist/types/services.d.ts +1 -1
  61. package/dist/types/socket.d.ts +1 -1
  62. package/dist/types/state.d.ts +12 -0
  63. package/dist/types/state.js +14 -0
  64. package/dist/types/teams.d.ts +1 -1
  65. package/dist/types/text.d.ts +4 -0
  66. package/dist/types/text.js +1 -0
  67. package/dist/types/{users.d.ts → user.d.ts} +1 -1
  68. package/dist/types/{users.js → user.js} +1 -1
  69. package/dist/types/worksheet.d.ts +105 -2
  70. package/dist/types/worksheet.js +16 -0
  71. package/package.json +21 -4
  72. package/dist/helpers/commons.d.ts +0 -33
  73. package/dist/helpers/commons.js +0 -191
  74. package/dist/helpers/time.d.ts +0 -13
  75. package/dist/helpers/time.js +0 -101
  76. package/dist/prototypes/Date.d.ts +0 -62
  77. package/dist/prototypes/Date.js +0 -218
  78. package/dist/prototypes/Number.d.ts +0 -7
  79. package/dist/prototypes/Number.js +0 -8
  80. package/dist/prototypes/index.d.ts +0 -3
  81. package/dist/prototypes/index.js +0 -3
  82. package/dist/types/commons.d.ts +0 -84
  83. package/dist/types/sheet.d.ts +0 -104
  84. package/dist/types/sheet.js +0 -16
  85. /package/dist/constants/{time.d.ts → duration.d.ts} +0 -0
  86. /package/dist/constants/{time.js → duration.js} +0 -0
  87. /package/dist/dto/{virtual-user.d.ts → virtualUser.d.ts} +0 -0
  88. /package/dist/dto/{virtual-user.js → virtualUser.js} +0 -0
  89. /package/dist/dto/{worksheet-submissions.d.ts → worksheetSubmission.d.ts} +0 -0
  90. /package/dist/dto/{worksheet-submissions.js → worksheetSubmission.js} +0 -0
  91. /package/dist/helpers/{class.d.ts → assignment.d.ts} +0 -0
  92. /package/dist/helpers/{class.js → assignment.js} +0 -0
  93. /package/dist/{prototypes/Error.d.ts → helpers/errors.d.ts} +0 -0
  94. /package/dist/{prototypes/Error.js → helpers/errors.js} +0 -0
  95. /package/dist/types/{problems.js → problem.js} +0 -0
  96. /package/dist/types/{account.d.ts → profile.d.ts} +0 -0
  97. /package/dist/types/{account.js → profile.js} +0 -0
@@ -1,218 +0,0 @@
1
- /* eslint-disable no-extend-native */
2
- Date.prototype.changeYear = function (year) {
3
- const newDate = new Date(this);
4
- newDate.setFullYear(year);
5
- return newDate;
6
- };
7
- Date.prototype.changeMonth = function (monthIndex) {
8
- const newDate = new Date(this);
9
- newDate.setMonth(monthIndex);
10
- return newDate;
11
- };
12
- Date.prototype.changeDay = function (date) {
13
- const newDate = new Date(this);
14
- newDate.setDate(date);
15
- return newDate;
16
- };
17
- Date.prototype.changeHours = function (hours) {
18
- const newDate = new Date(this);
19
- newDate.setHours(hours);
20
- return newDate;
21
- };
22
- Date.prototype.changeMinutes = function (minutes) {
23
- const newDate = new Date(this);
24
- newDate.setMinutes(minutes);
25
- return newDate;
26
- };
27
- Date.prototype.changeSeconds = function (seconds) {
28
- const newDate = new Date(this);
29
- newDate.setSeconds(seconds);
30
- return newDate;
31
- };
32
- Date.prototype.changeMilliseconds = function (milliseconds) {
33
- const newDate = new Date(this);
34
- newDate.setMilliseconds(milliseconds);
35
- return newDate;
36
- };
37
- Date.prototype.decreaseYear = function (count = 1) {
38
- return this.changeYear(this.getFullYear() - count);
39
- };
40
- Date.prototype.increaseYear = function (count = 1) {
41
- return this.changeYear(this.getFullYear() + count);
42
- };
43
- Date.prototype.decreaseMonth = function () {
44
- const newDate = new Date(this);
45
- newDate.setMonth(newDate.getMonth() - 1);
46
- return newDate;
47
- };
48
- Date.prototype.increaseMonth = function () {
49
- const newDate = new Date(this);
50
- newDate.setMonth(newDate.getMonth() + 1);
51
- return newDate;
52
- };
53
- Date.prototype.increaseDay = function () {
54
- const newDate = new Date(this);
55
- newDate.setDate(newDate.getDate() + 1);
56
- return newDate;
57
- };
58
- Date.prototype.decreaseDay = function () {
59
- const newDate = new Date(this);
60
- newDate.setDate(newDate.getDate() - 1);
61
- return newDate;
62
- };
63
- Date.prototype.startOfYear = function () {
64
- const newDate = new Date(this);
65
- newDate.setMonth(0);
66
- return newDate.startOfMonth();
67
- };
68
- Date.prototype.endOfYear = function () {
69
- const nextMonth = this.increaseYear().startOfYear();
70
- return new Date(nextMonth.getTime() - 1);
71
- };
72
- Date.prototype.startOfMonth = function () {
73
- const newDate = new Date(this);
74
- newDate.setDate(1);
75
- return newDate.startOfDay();
76
- };
77
- Date.prototype.endOfMonth = function () {
78
- const nextMonth = this.increaseMonth().startOfMonth();
79
- return new Date(nextMonth.getTime() - 1);
80
- };
81
- Date.prototype.startOfWeek = function () {
82
- const newDate = new Date(this);
83
- while (newDate.getDay()) {
84
- newDate.setDate(newDate.getDate() - 1);
85
- }
86
- return newDate.startOfDay();
87
- };
88
- Date.prototype.endOfWeek = function () {
89
- const newDate = new Date(this);
90
- while (newDate.getDay() < 6) {
91
- newDate.setDate(newDate.getDate() - 1);
92
- }
93
- return newDate.endOfDay();
94
- };
95
- Date.prototype.startOfDay = function () {
96
- const newDate = new Date(this);
97
- newDate.setHours(0, 0, 0, 0);
98
- return newDate;
99
- };
100
- Date.prototype.endOfDay = function () {
101
- const newDate = new Date(this);
102
- newDate.setHours(23, 59, 59, 999);
103
- return newDate;
104
- };
105
- Date.prototype.startOfHour = function () {
106
- const newDate = new Date(this);
107
- newDate.setMinutes(0, 0, 0);
108
- return newDate;
109
- };
110
- Date.prototype.endOfHour = function () {
111
- const newDate = new Date(this);
112
- newDate.setMinutes(59, 59, 999);
113
- return newDate;
114
- };
115
- Date.prototype.startOfMinute = function () {
116
- const newDate = new Date(this);
117
- newDate.setSeconds(0, 0);
118
- return newDate;
119
- };
120
- Date.prototype.endOfMinute = function () {
121
- const newDate = new Date(this);
122
- newDate.setSeconds(59, 999);
123
- return newDate;
124
- };
125
- Date.prototype.startOfSecond = function () {
126
- const newDate = new Date(this);
127
- newDate.setMilliseconds(0);
128
- return newDate;
129
- };
130
- Date.prototype.endOfSecond = function () {
131
- const newDate = new Date(this);
132
- newDate.setMilliseconds(999);
133
- return newDate;
134
- };
135
- Date.prototype.isToday = function () {
136
- const today = new Date();
137
- return this.isSameDay(today);
138
- };
139
- Date.prototype.isEqual = function (date) {
140
- return this.getTime() === date.getTime();
141
- };
142
- Date.prototype.isSameYear = function (date) {
143
- return this.getFullYear() === date.getFullYear();
144
- };
145
- Date.prototype.isSameMonth = function (date) {
146
- return this.isSameYear(date) && this.getMonth() === date.getMonth();
147
- };
148
- Date.prototype.isSameDay = function (date) {
149
- return this.isSameMonth(date) && this.getDate() === date.getDate();
150
- };
151
- Date.prototype.isSameHour = function (date) {
152
- return this.isSameDay(date) && this.getHours() === date.getHours();
153
- };
154
- Date.prototype.isSameMinute = function (date) {
155
- return this.isSameHour(date) && this.getMinutes() === date.getMinutes();
156
- };
157
- Date.prototype.isSameSecond = function (date) {
158
- return this.isSameMinute(date) && this.getSeconds() === date.getSeconds();
159
- };
160
- Date.prototype.isSameMillisecond = function (date) {
161
- return this.isEqual(date);
162
- };
163
- Date.prototype.isValidDate = function () {
164
- return this instanceof Date && !Number.isNaN(this.getTime());
165
- };
166
- Date.prototype.isYearAfter = function (date) {
167
- return this.getFullYear() > date.getFullYear();
168
- };
169
- Date.prototype.isMonthAfter = function (date) {
170
- return this.isYearAfter(date) || (this.isSameYear(date) && this.getMonth() > date.getMonth());
171
- };
172
- Date.prototype.isDayAfter = function (date) {
173
- return this.isMonthAfter(date) || (this.isSameMonth(date) && this.getDate() > date.getDate());
174
- };
175
- Date.prototype.isHoursAfter = function (date) {
176
- return this.isDayAfter(date) || (this.isSameDay(date) && this.getHours() > date.getHours());
177
- };
178
- Date.prototype.isMinutesAfter = function (date) {
179
- return this.isHoursAfter(date) || (this.isSameHour(date) && this.getMinutes() > date.getMinutes());
180
- };
181
- Date.prototype.isSecondsAfter = function (date) {
182
- return this.isMinutesAfter(date) || (this.isSameMinute(date) && this.getSeconds() > date.getSeconds());
183
- };
184
- Date.prototype.isMillisecondsAfter = function (date) {
185
- return this.isSecondsAfter(date) || (this.isSameSecond(date) && this.getMilliseconds() > date.getMilliseconds());
186
- };
187
- Date.prototype.isAfter = function (date) {
188
- return this.getTime() > date.getTime();
189
- };
190
- Date.prototype.isYearBefore = function (date) {
191
- return this.getFullYear() < date.getFullYear();
192
- };
193
- Date.prototype.isMonthBefore = function (date) {
194
- return this.isYearBefore(date) || (this.isSameYear(date) && this.getMonth() < date.getMonth());
195
- };
196
- Date.prototype.isDayBefore = function (date) {
197
- return this.isMonthBefore(date) || (this.isSameMonth(date) && this.getDate() < date.getDate());
198
- };
199
- Date.prototype.isHoursBefore = function (date) {
200
- return this.isDayBefore(date) || (this.isSameDay(date) && this.getHours() < date.getHours());
201
- };
202
- Date.prototype.isMinutesBefore = function (date) {
203
- return this.isHoursBefore(date) || (this.isSameHour(date) && this.getMinutes() < date.getMinutes());
204
- };
205
- Date.prototype.isSecondsBefore = function (date) {
206
- return this.isMinutesBefore(date) || (this.isSameMinute(date) && this.getSeconds() < date.getSeconds());
207
- };
208
- Date.prototype.isMillisecondsBefore = function (date) {
209
- return this.isSecondsBefore(date) || (this.isSameSecond(date) && this.getMilliseconds() < date.getMilliseconds());
210
- };
211
- Date.prototype.isBefore = function (date) {
212
- return this.getTime() < date.getTime();
213
- };
214
- Date.prototype.isWithinInterval = function ({ start, end }, cmp = '[]') {
215
- return ((cmp.charAt(0) === '[' ? this.isEqual(start) || this.isAfter(start) : this.isAfter(start)) &&
216
- (cmp.charAt(1) === '[' ? this.isEqual(end) || this.isBefore(end) : this.isBefore(end)));
217
- };
218
- export {};
@@ -1,7 +0,0 @@
1
- declare global {
2
- interface Number {
3
- padStart(maxLength: number, fillString?: string): string;
4
- padEnd(maxLength: number, fillString?: string): string;
5
- }
6
- }
7
- export {};
@@ -1,8 +0,0 @@
1
- /* eslint-disable no-extend-native */
2
- Number.prototype.padStart = function (maxLength, fillString = '0') {
3
- return `${this}`.padStart(maxLength, fillString);
4
- };
5
- Number.prototype.padEnd = function (maxLength, fillString = '0') {
6
- return `${this}`.padEnd(maxLength, fillString);
7
- };
8
- export {};
@@ -1,3 +0,0 @@
1
- export * from './Date.js';
2
- export * from './Error.js';
3
- export * from './Number.js';
@@ -1,3 +0,0 @@
1
- export * from './Date.js';
2
- export * from './Error.js';
3
- export * from './Number.js';
@@ -1,84 +0,0 @@
1
- import type { Language } from './users.js';
2
- export declare enum CodeLanguage {
3
- C_11 = "c11",
4
- CPP_11 = "cpp11",
5
- CPP_20 = "cpp20",
6
- JAVA_21 = "java21",
7
- PYTHON_3 = "python3",
8
- PYTHON_PYPY_3 = "pypy3",
9
- JAVASCRIPT_NODE_JS_22 = "nodejs22",
10
- PYTHON_2 = "python2",
11
- PYTHON_PYPY_2 = "pypy2",
12
- ICPC_C = "ICPC_C",
13
- C = "C",
14
- CPP = "CPP",
15
- ICPC_CPP = "ICPC_CPP",
16
- CPP11 = "CPP11",
17
- CPP14 = "CPP14",
18
- CPP17 = "CPP17",
19
- JAVA = "JAVA",
20
- ICPC_PYTHON = "ICPC_PYTHON",
21
- PYTHON = "PYTHON",
22
- PYTHON2 = "PYTHON2",
23
- PYTHON3 = "PYTHON3",
24
- JAVASCRIPT = "JAVASCRIPT",
25
- TYPESCRIPT = "TYPESCRIPT",
26
- JSX = "JSX",
27
- TSX = "TSX",
28
- MDX = "MDX",
29
- PSEUDOCODE_PSEINT = "PSEUDOCODE_PSEINT",
30
- LATEX = "LATEX",
31
- JSON = "JSON",
32
- HTML = "HTML",
33
- TEXT = "TEXT",
34
- DIFF = "DIFF",
35
- MARKDOWN = "MARKDOWN",
36
- ARDUINO = "ARDUINO",
37
- DOT = "DOT",
38
- MERMAID = "MERMAID",
39
- BASH = "BASH"
40
- }
41
- export declare enum ScopeData {
42
- USER = "USER",
43
- PROBLEM = "PROBLEM",
44
- CONTEST = "CONTEST",
45
- ATTEMPT = "ATTEMPT"
46
- }
47
- export declare enum Status {
48
- SUCCESS = "SUCCESS",
49
- ERROR = "ERROR",
50
- LOADING = "LOADING",
51
- NONE = "NONE"
52
- }
53
- export declare enum EntityStatus {
54
- PUBLIC = "PUBLIC",// Active for the users
55
- RESERVED = "RESERVED",// On preparation
56
- PRIVATE = "PRIVATE",
57
- ARCHIVED = "ARCHIVED"
58
- }
59
- export declare enum EntityAccess {
60
- PRIVATE = "PRIVATE",
61
- RESTRICTED = "RESTRICTED",
62
- PUBLIC = "PUBLIC",
63
- EXPOSED = "EXPOSED"
64
- }
65
- export type TextLanguage = {
66
- [Key in Language]: string;
67
- };
68
- export type SplitTime = {
69
- remaining: number;
70
- label: string;
71
- milliseconds: number;
72
- abbreviatedLabel: string;
73
- digits: number;
74
- };
75
- export type RecordId = string | `${string & {
76
- length: 24;
77
- }}`;
78
- export type Device = {
79
- label: string;
80
- isMobile: boolean;
81
- isBrowser: boolean;
82
- type: string;
83
- osLabel: string;
84
- };
@@ -1,104 +0,0 @@
1
- import type { SubmissionRunStatus } from '../prisma/enums/index.js';
2
- import type { CodeLanguage } from './commons.js';
3
- export declare enum WorksheetType {
4
- JK_MD = "JK_MD",
5
- CODE_EDITOR = "CODE_EDITOR",
6
- LIST = "LIST",
7
- GRAPH = "GRAPH",
8
- QUIZ_PROBLEM = "QUIZ_PROBLEM",
9
- QUIZ_TEXT = "QUIZ_TEXT",
10
- QUIZ_OPTIONS = "QUIZ_OPTIONS",
11
- NEW_PAGE = "NEW_PAGE"
12
- }
13
- export type BasicWorksheet = {
14
- id: string;
15
- type: WorksheetType;
16
- title: string;
17
- points: number;
18
- };
19
- export type JkmdSheet = BasicWorksheet & {
20
- type: WorksheetType.JK_MD;
21
- content: string;
22
- };
23
- export type SubmissionTestCase = {
24
- out: string;
25
- err: string;
26
- log: string;
27
- status: SubmissionRunStatus;
28
- };
29
- export interface CodeEditorTestCase extends SubmissionTestCase {
30
- key: string;
31
- in: string;
32
- testOut: string;
33
- withPE: boolean;
34
- sample: boolean;
35
- hidden: boolean;
36
- index: number;
37
- messageTimestamp: number;
38
- }
39
- export type CodeEditorFile<T> = {
40
- description: string;
41
- folderPath: string;
42
- source: string;
43
- language: T;
44
- index: number;
45
- name: string;
46
- hidden: boolean;
47
- readonly: boolean;
48
- protected: boolean;
49
- active: boolean;
50
- };
51
- export type CodeEditorFiles<T> = {
52
- [key: string]: CodeEditorFile<T>;
53
- };
54
- export type CodeEditorTestCases = {
55
- [key: string]: CodeEditorTestCase;
56
- };
57
- export type CodeEditorSheet = BasicWorksheet & {
58
- type: WorksheetType.CODE_EDITOR;
59
- files: CodeEditorFiles<CodeLanguage>;
60
- testCases: CodeEditorTestCases;
61
- languages: CodeLanguage[];
62
- height: number;
63
- };
64
- export type GraphSheet = BasicWorksheet & {
65
- type: WorksheetType.GRAPH;
66
- dots: string[];
67
- };
68
- export type QuizProblemSheet = BasicWorksheet & {
69
- type: WorksheetType.QUIZ_PROBLEM;
70
- problemKey: string;
71
- languages: CodeLanguage[];
72
- height: number;
73
- };
74
- export type QuizTextSheet = BasicWorksheet & {
75
- type: WorksheetType.QUIZ_TEXT;
76
- description: string;
77
- answer: string;
78
- inputType: 'text' | 'number' | 'textarea';
79
- };
80
- export declare enum QuizScoringMode {
81
- TOTAL = "TOTAL",
82
- PARTIAL = "PARTIAL"
83
- }
84
- export type QuizOptionsSheet = BasicWorksheet & {
85
- type: WorksheetType.QUIZ_OPTIONS;
86
- description: string;
87
- options: {
88
- label: string;
89
- correct: boolean;
90
- id: string;
91
- }[];
92
- multiple: boolean;
93
- scoringMode: QuizScoringMode;
94
- };
95
- export type ListSheet = BasicWorksheet & {
96
- type: WorksheetType.LIST;
97
- header: string;
98
- content: (JkmdSheet | CodeEditorSheet | GraphSheet | QuizProblemSheet | QuizTextSheet | QuizOptionsSheet)[];
99
- children: ListSheet[];
100
- };
101
- export type NewPageSheet = BasicWorksheet & {
102
- type: WorksheetType.NEW_PAGE;
103
- };
104
- export type BodyWorksheet = JkmdSheet | CodeEditorSheet | ListSheet | GraphSheet | QuizProblemSheet | QuizTextSheet | QuizOptionsSheet | NewPageSheet;
@@ -1,16 +0,0 @@
1
- export var WorksheetType;
2
- (function (WorksheetType) {
3
- WorksheetType["JK_MD"] = "JK_MD";
4
- WorksheetType["CODE_EDITOR"] = "CODE_EDITOR";
5
- WorksheetType["LIST"] = "LIST";
6
- WorksheetType["GRAPH"] = "GRAPH";
7
- WorksheetType["QUIZ_PROBLEM"] = "QUIZ_PROBLEM";
8
- WorksheetType["QUIZ_TEXT"] = "QUIZ_TEXT";
9
- WorksheetType["QUIZ_OPTIONS"] = "QUIZ_OPTIONS";
10
- WorksheetType["NEW_PAGE"] = "NEW_PAGE";
11
- })(WorksheetType || (WorksheetType = {}));
12
- export var QuizScoringMode;
13
- (function (QuizScoringMode) {
14
- QuizScoringMode["TOTAL"] = "TOTAL";
15
- QuizScoringMode["PARTIAL"] = "PARTIAL";
16
- })(QuizScoringMode || (QuizScoringMode = {}));
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes