@juki-team/commons 0.2.0 → 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.
- package/dist/constants/commons.d.ts +1 -1
- package/dist/constants/commons.js +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/dto/index.d.ts +2 -1
- package/dist/dto/index.js +2 -1
- package/dist/helpers/array.d.ts +3 -0
- package/dist/helpers/array.js +28 -0
- package/dist/helpers/console.d.ts +3 -0
- package/dist/helpers/console.js +9 -0
- package/dist/{date/index.d.ts → helpers/date.d.ts} +11 -0
- package/dist/{date/index.js → helpers/date.js} +24 -0
- package/dist/helpers/document.d.ts +1 -11
- package/dist/helpers/document.js +1 -21
- package/dist/helpers/duration.d.ts +2 -0
- package/dist/helpers/duration.js +57 -0
- package/dist/helpers/entity.d.ts +11 -0
- package/dist/helpers/entity.js +20 -0
- package/dist/helpers/file.d.ts +6 -1
- package/dist/helpers/file.js +23 -2
- package/dist/helpers/http.d.ts +1 -0
- package/dist/helpers/http.js +8 -0
- package/dist/helpers/index.d.ts +12 -3
- package/dist/helpers/index.js +12 -3
- package/dist/helpers/json.d.ts +3 -0
- package/dist/helpers/json.js +31 -0
- package/dist/helpers/object.d.ts +2 -0
- package/dist/helpers/object.js +28 -0
- package/dist/helpers/problem.d.ts +2 -0
- package/dist/helpers/problem.js +1 -0
- package/dist/helpers/responses.d.ts +1 -1
- package/dist/helpers/responses.js +3 -2
- package/dist/helpers/string.d.ts +7 -0
- package/dist/helpers/string.js +52 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/prisma/enums/index.d.ts +11 -11
- package/dist/prisma/enums/index.js +11 -11
- package/dist/types/assignment.d.ts +28 -0
- package/dist/types/assignment.js +7 -0
- package/dist/types/class.d.ts +1 -27
- package/dist/types/class.js +1 -7
- package/dist/types/code.d.ts +39 -0
- package/dist/types/{commons.js → code.js} +0 -28
- package/dist/types/contest.d.ts +2 -2
- package/dist/types/device.d.ts +7 -0
- package/dist/types/device.js +1 -0
- package/dist/types/duration.d.ts +7 -0
- package/dist/types/duration.js +1 -0
- package/dist/types/entity.d.ts +12 -0
- package/dist/types/entity.js +14 -0
- package/dist/types/id.d.ts +3 -0
- package/dist/types/id.js +1 -0
- package/dist/types/index.d.ts +10 -5
- package/dist/types/index.js +10 -5
- package/dist/types/judge.d.ts +1 -1
- package/dist/types/{problems.d.ts → problem.d.ts} +2 -1
- package/dist/types/services.d.ts +1 -1
- package/dist/types/socket.d.ts +1 -1
- package/dist/types/state.d.ts +12 -0
- package/dist/types/state.js +14 -0
- package/dist/types/teams.d.ts +1 -1
- package/dist/types/text.d.ts +4 -0
- package/dist/types/text.js +1 -0
- package/dist/types/{users.d.ts → user.d.ts} +1 -1
- package/dist/types/{users.js → user.js} +1 -1
- package/dist/types/worksheet.d.ts +105 -2
- package/dist/types/worksheet.js +16 -0
- package/package.json +6 -19
- package/dist/helpers/commons.d.ts +0 -33
- package/dist/helpers/commons.js +0 -191
- package/dist/helpers/time.d.ts +0 -13
- package/dist/helpers/time.js +0 -101
- package/dist/types/commons.d.ts +0 -84
- package/dist/types/sheet.d.ts +0 -104
- package/dist/types/sheet.js +0 -16
- /package/dist/constants/{time.d.ts → duration.d.ts} +0 -0
- /package/dist/constants/{time.js → duration.js} +0 -0
- /package/dist/dto/{virtual-user.d.ts → virtualUser.d.ts} +0 -0
- /package/dist/dto/{virtual-user.js → virtualUser.js} +0 -0
- /package/dist/dto/{worksheet-submissions.d.ts → worksheetSubmission.d.ts} +0 -0
- /package/dist/dto/{worksheet-submissions.js → worksheetSubmission.js} +0 -0
- /package/dist/helpers/{class.d.ts → assignment.d.ts} +0 -0
- /package/dist/helpers/{class.js → assignment.js} +0 -0
- /package/dist/{errors/index.d.ts → helpers/errors.d.ts} +0 -0
- /package/dist/{errors/index.js → helpers/errors.js} +0 -0
- /package/dist/{number/index.d.ts → helpers/number.d.ts} +0 -0
- /package/dist/{number/index.js → helpers/number.js} +0 -0
- /package/dist/types/{problems.js → problem.js} +0 -0
- /package/dist/types/{account.d.ts → profile.d.ts} +0 -0
- /package/dist/types/{account.js → profile.js} +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Judge } from '../types/index.js';
|
|
2
|
-
export declare function isStringJson(str: unknown): str is string;
|
|
3
|
-
export declare function safeJsonParse(str: unknown): unknown;
|
|
4
|
-
export declare function isObjectJson(obj: unknown): boolean;
|
|
5
|
-
export declare function mex(array: number[]): number;
|
|
6
|
-
export declare function range(start: number, end: number): number[];
|
|
7
|
-
export declare function getPlainText(url: string): Promise<string>;
|
|
8
|
-
export declare function objectUpdate(base: unknown, update: unknown): unknown;
|
|
9
|
-
export declare function objectsUpdate(base: Record<string, unknown>, ...objects: Record<string, unknown>[]): Record<string, unknown>;
|
|
10
|
-
export declare function consoleWarn(...warn: unknown[]): void;
|
|
11
|
-
export declare function consoleInfo(...info: unknown[]): void;
|
|
12
|
-
export declare function consoleError(...error: unknown[]): void;
|
|
13
|
-
export declare function indexToLetters(index: number): string;
|
|
14
|
-
export declare function lettersToIndex(index: string): number;
|
|
15
|
-
export declare function getProblemJudgeKey(judge: Judge, key: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string
|
|
18
|
-
* Format bytes as human-readable text.
|
|
19
|
-
*
|
|
20
|
-
* @param bytes Number of bytes.
|
|
21
|
-
* @param si True to use metric (SI) units, aka powers of 1000. False to use
|
|
22
|
-
* binary (IEC), aka powers of 1024.
|
|
23
|
-
* @param dp Number of decimal places to display.
|
|
24
|
-
*
|
|
25
|
-
* @return Formatted string.
|
|
26
|
-
*/
|
|
27
|
-
export declare function humanFileSize(bytes: number, si?: boolean, dp?: number): string;
|
|
28
|
-
export declare function stringToArrayBuffer(str: string): ArrayBuffer;
|
|
29
|
-
export declare function chunkString(str: string, size: number): string[];
|
|
30
|
-
export declare function getRandomString(length: number): string;
|
|
31
|
-
export declare function join(array: (string | null | Date)[]): string;
|
|
32
|
-
export declare function split(text: string): string[];
|
|
33
|
-
export declare const areArraysDifferent: <T>(a: T[], b: T[]) => boolean;
|
package/dist/helpers/commons.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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
|
-
function mergeRecords(b, u) {
|
|
56
|
-
const mergeKeys = new Set([...Object.keys(b), ...Object.keys(u)]);
|
|
57
|
-
for (const key of mergeKeys) {
|
|
58
|
-
if (u[key] !== null && u[key] !== undefined && b[key] !== u[key]) {
|
|
59
|
-
b[key] = objectUpdate(b[key], u[key]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return b;
|
|
63
|
-
}
|
|
64
|
-
export function objectUpdate(base, update) {
|
|
65
|
-
if (JSON.stringify(base) === JSON.stringify(update)) {
|
|
66
|
-
return base;
|
|
67
|
-
}
|
|
68
|
-
if (base !== null && update !== null && !Array.isArray(base) && typeof base === 'object' && typeof update === 'object') {
|
|
69
|
-
return mergeRecords(base, update);
|
|
70
|
-
}
|
|
71
|
-
if (update !== null && update !== undefined) {
|
|
72
|
-
return update;
|
|
73
|
-
}
|
|
74
|
-
return base;
|
|
75
|
-
}
|
|
76
|
-
export function objectsUpdate(base, ...objects) {
|
|
77
|
-
let newObject = { ...base };
|
|
78
|
-
for (const update of objects) {
|
|
79
|
-
newObject = objectUpdate(newObject, update);
|
|
80
|
-
}
|
|
81
|
-
return newObject;
|
|
82
|
-
}
|
|
83
|
-
export function consoleWarn(...warn) {
|
|
84
|
-
console.warn(new Date().toLocaleString(), ...warn);
|
|
85
|
-
}
|
|
86
|
-
export function consoleInfo(...info) {
|
|
87
|
-
console.info(new Date().toLocaleString(), ...info);
|
|
88
|
-
}
|
|
89
|
-
export function consoleError(...error) {
|
|
90
|
-
console.error(new Date().toLocaleString(), ...error);
|
|
91
|
-
}
|
|
92
|
-
export function indexToLetters(index) {
|
|
93
|
-
const d = Math.ceil(index / 26);
|
|
94
|
-
if (d === 1) {
|
|
95
|
-
return UPPERCASE_LETTERS.charAt(index - 1);
|
|
96
|
-
}
|
|
97
|
-
return UPPERCASE_LETTERS.charAt(d - 2) + UPPERCASE_LETTERS.charAt(index - 26 * (d - 1) - 1);
|
|
98
|
-
}
|
|
99
|
-
export function lettersToIndex(index) {
|
|
100
|
-
if (index.length) {
|
|
101
|
-
if (index.length === 1) {
|
|
102
|
-
const d = UPPERCASE_LETTERS.indexOf(index);
|
|
103
|
-
if (d !== -1) {
|
|
104
|
-
return d + 1;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (index.length === 2) {
|
|
108
|
-
const a = index.charAt(0);
|
|
109
|
-
const b = index.charAt(1);
|
|
110
|
-
const numA = lettersToIndex(a);
|
|
111
|
-
const numB = lettersToIndex(b);
|
|
112
|
-
return numA * 26 + numB;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return 0;
|
|
116
|
-
}
|
|
117
|
-
export function getProblemJudgeKey(judge, key) {
|
|
118
|
-
return `${judge}-${key}`;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string
|
|
122
|
-
* Format bytes as human-readable text.
|
|
123
|
-
*
|
|
124
|
-
* @param bytes Number of bytes.
|
|
125
|
-
* @param si True to use metric (SI) units, aka powers of 1000. False to use
|
|
126
|
-
* binary (IEC), aka powers of 1024.
|
|
127
|
-
* @param dp Number of decimal places to display.
|
|
128
|
-
*
|
|
129
|
-
* @return Formatted string.
|
|
130
|
-
*/
|
|
131
|
-
export function humanFileSize(bytes, si = false, dp = 1) {
|
|
132
|
-
const thresh = si ? 1000 : 1024;
|
|
133
|
-
if (Math.abs(bytes) < thresh) {
|
|
134
|
-
return `${bytes} B`;
|
|
135
|
-
}
|
|
136
|
-
const units = si
|
|
137
|
-
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
138
|
-
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
139
|
-
let u = -1;
|
|
140
|
-
let value = bytes;
|
|
141
|
-
const r = 10 ** dp;
|
|
142
|
-
do {
|
|
143
|
-
value /= thresh;
|
|
144
|
-
++u;
|
|
145
|
-
} while (Math.round(Math.abs(value) * r) / r >= thresh && u < units.length - 1);
|
|
146
|
-
return `${value.toFixed(dp)} ${units[u]}`;
|
|
147
|
-
}
|
|
148
|
-
export function stringToArrayBuffer(str) {
|
|
149
|
-
const buf = new ArrayBuffer(str.length); //convert str to arrayBuffer
|
|
150
|
-
const view = new Uint8Array(buf); //create Uint8Array as viewer
|
|
151
|
-
for (let i = 0; i < str.length; i++) {
|
|
152
|
-
view[i] = str.charCodeAt(i) & 0xff; //convert to octet
|
|
153
|
-
}
|
|
154
|
-
return buf;
|
|
155
|
-
}
|
|
156
|
-
export function chunkString(str, size) {
|
|
157
|
-
const numChunks = Math.ceil(str.length / size);
|
|
158
|
-
const chunks = new Array(numChunks);
|
|
159
|
-
for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
|
|
160
|
-
chunks[i] = str.substr(o, size);
|
|
161
|
-
}
|
|
162
|
-
return chunks;
|
|
163
|
-
}
|
|
164
|
-
export function getRandomString(length) {
|
|
165
|
-
const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // 62
|
|
166
|
-
let retVal = '';
|
|
167
|
-
for (let i = 0; i < length; ++i) {
|
|
168
|
-
retVal += charset.charAt(Math.floor(Math.random() * charset.length));
|
|
169
|
-
}
|
|
170
|
-
return retVal;
|
|
171
|
-
}
|
|
172
|
-
export function join(array) {
|
|
173
|
-
return array.join(SEPARATOR_TOKEN);
|
|
174
|
-
}
|
|
175
|
-
export function split(text) {
|
|
176
|
-
return text.split(SEPARATOR_TOKEN);
|
|
177
|
-
}
|
|
178
|
-
export const areArraysDifferent = (a, b) => {
|
|
179
|
-
if (a === b) {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
if (a.length !== b.length) {
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
for (let i = 0; i < b.length; i += 1) {
|
|
186
|
-
if (b[i] !== a[i]) {
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
};
|
package/dist/helpers/time.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { SplitTime } from '../types/index.js';
|
|
2
|
-
export declare function splitTime(timeRemaining: number): [SplitTime, SplitTime, SplitTime, SplitTime, SplitTime, SplitTime];
|
|
3
|
-
export declare function normalizeToLocalStartOfDay(timestamp: number | Date): Date;
|
|
4
|
-
export declare function normalizeToLocalStartOfHour(timestamp: number | Date): Date;
|
|
5
|
-
export declare function normalizeToLocalStartOfMinutes(timestamp: number | Date): Date;
|
|
6
|
-
export declare function normalizeToLocalStartOfSeconds(timestamp: number | Date): Date;
|
|
7
|
-
export declare const getYears: (d: Date) => number;
|
|
8
|
-
export declare const getMonths: (d: Date) => number;
|
|
9
|
-
export declare const getDays: (d: Date) => number;
|
|
10
|
-
export declare const getHours: (d: Date) => number;
|
|
11
|
-
export declare const getMinutes: (d: Date) => number;
|
|
12
|
-
export declare const getSeconds: (d: Date) => number;
|
|
13
|
-
export declare const getMilliseconds: (d: Date) => number;
|
package/dist/helpers/time.js
DELETED
|
@@ -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();
|
package/dist/types/commons.d.ts
DELETED
|
@@ -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
|
-
};
|
package/dist/types/sheet.d.ts
DELETED
|
@@ -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;
|
package/dist/types/sheet.js
DELETED
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|