@juki-team/commons 0.1.11

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 (95) hide show
  1. package/README.md +3 -0
  2. package/dist/cjs/index.cjs +3567 -0
  3. package/dist/esm/index.js +3347 -0
  4. package/dist/types/constants/commons.d.ts +62 -0
  5. package/dist/types/constants/company.d.ts +9 -0
  6. package/dist/types/constants/contest.d.ts +15 -0
  7. package/dist/types/constants/course.d.ts +8 -0
  8. package/dist/types/constants/date.d.ts +9 -0
  9. package/dist/types/constants/email.d.ts +2 -0
  10. package/dist/types/constants/entity.d.ts +3 -0
  11. package/dist/types/constants/file.d.ts +27 -0
  12. package/dist/types/constants/index.d.ts +18 -0
  13. package/dist/types/constants/judge.d.ts +35 -0
  14. package/dist/types/constants/problem.d.ts +36 -0
  15. package/dist/types/constants/routing.d.ts +7 -0
  16. package/dist/types/constants/services.d.ts +8 -0
  17. package/dist/types/constants/system.d.ts +8 -0
  18. package/dist/types/constants/teams.d.ts +14 -0
  19. package/dist/types/constants/time.d.ts +9 -0
  20. package/dist/types/constants/user.d.ts +16 -0
  21. package/dist/types/constants/websocket.d.ts +6 -0
  22. package/dist/types/constants/worksheet.d.ts +11 -0
  23. package/dist/types/dto/class.d.ts +115 -0
  24. package/dist/types/dto/code.d.ts +13 -0
  25. package/dist/types/dto/comments.d.ts +21 -0
  26. package/dist/types/dto/company.d.ts +67 -0
  27. package/dist/types/dto/contest.d.ts +94 -0
  28. package/dist/types/dto/course.d.ts +34 -0
  29. package/dist/types/dto/entity.d.ts +92 -0
  30. package/dist/types/dto/excalidraw.d.ts +12 -0
  31. package/dist/types/dto/file.d.ts +34 -0
  32. package/dist/types/dto/image.d.ts +6 -0
  33. package/dist/types/dto/index.d.ts +25 -0
  34. package/dist/types/dto/judge.d.ts +16 -0
  35. package/dist/types/dto/markdown.d.ts +12 -0
  36. package/dist/types/dto/mermaid.d.ts +12 -0
  37. package/dist/types/dto/problem.d.ts +66 -0
  38. package/dist/types/dto/scoreboard.d.ts +35 -0
  39. package/dist/types/dto/session.d.ts +15 -0
  40. package/dist/types/dto/socket.d.ts +256 -0
  41. package/dist/types/dto/statistics.d.ts +43 -0
  42. package/dist/types/dto/submission.d.ts +94 -0
  43. package/dist/types/dto/system.d.ts +91 -0
  44. package/dist/types/dto/url.d.ts +8 -0
  45. package/dist/types/dto/user.d.ts +109 -0
  46. package/dist/types/dto/virtual-user.d.ts +38 -0
  47. package/dist/types/dto/worksheet-submissions.d.ts +64 -0
  48. package/dist/types/dto/worksheet.d.ts +39 -0
  49. package/dist/types/helpers/class.d.ts +4 -0
  50. package/dist/types/helpers/comments.d.ts +4 -0
  51. package/dist/types/helpers/commons.d.ts +35 -0
  52. package/dist/types/helpers/contest.d.ts +5 -0
  53. package/dist/types/helpers/document.d.ts +14 -0
  54. package/dist/types/helpers/file.d.ts +1 -0
  55. package/dist/types/helpers/index.d.ts +14 -0
  56. package/dist/types/helpers/interval.d.ts +2 -0
  57. package/dist/types/helpers/judging.d.ts +24 -0
  58. package/dist/types/helpers/object.d.ts +1 -0
  59. package/dist/types/helpers/responses.d.ts +8 -0
  60. package/dist/types/helpers/socket.d.ts +45 -0
  61. package/dist/types/helpers/time.d.ts +13 -0
  62. package/dist/types/helpers/user.d.ts +11 -0
  63. package/dist/types/helpers/worksheet.d.ts +10 -0
  64. package/dist/types/index.d.ts +5 -0
  65. package/dist/types/prototypes/Date.d.ts +62 -0
  66. package/dist/types/prototypes/Error.d.ts +10 -0
  67. package/dist/types/prototypes/Number.d.ts +7 -0
  68. package/dist/types/prototypes/index.d.ts +3 -0
  69. package/dist/types/types/account.d.ts +9 -0
  70. package/dist/types/types/class.d.ts +67 -0
  71. package/dist/types/types/comments.d.ts +17 -0
  72. package/dist/types/types/commons.d.ts +84 -0
  73. package/dist/types/types/company.d.ts +29 -0
  74. package/dist/types/types/contest.d.ts +161 -0
  75. package/dist/types/types/course.d.ts +13 -0
  76. package/dist/types/types/entity.d.ts +116 -0
  77. package/dist/types/types/excalidraw.d.ts +9 -0
  78. package/dist/types/types/file.d.ts +27 -0
  79. package/dist/types/types/group.d.ts +12 -0
  80. package/dist/types/types/index.d.ts +25 -0
  81. package/dist/types/types/judge.d.ts +75 -0
  82. package/dist/types/types/markdown.d.ts +8 -0
  83. package/dist/types/types/mermaid.d.ts +8 -0
  84. package/dist/types/types/notification.d.ts +7 -0
  85. package/dist/types/types/prisma.d.ts +284 -0
  86. package/dist/types/types/problems.d.ts +102 -0
  87. package/dist/types/types/services.d.ts +213 -0
  88. package/dist/types/types/sheet.d.ts +103 -0
  89. package/dist/types/types/socket.d.ts +49 -0
  90. package/dist/types/types/submission.d.ts +5 -0
  91. package/dist/types/types/teams.d.ts +73 -0
  92. package/dist/types/types/users.d.ts +59 -0
  93. package/dist/types/types/virtual-user.d.ts +7 -0
  94. package/dist/types/types/worksheet.d.ts +42 -0
  95. package/package.json +38 -0
@@ -0,0 +1,103 @@
1
+ import { CodeLanguage } from './commons';
2
+ import { SubmissionRunStatus } from './judge';
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
+ };
50
+ export type CodeEditorFiles<T> = {
51
+ [key: string]: CodeEditorFile<T>;
52
+ };
53
+ export type CodeEditorTestCases = {
54
+ [key: string]: CodeEditorTestCase;
55
+ };
56
+ export type CodeEditorSheet = BasicWorksheet & {
57
+ type: WorksheetType.CODE_EDITOR;
58
+ files: CodeEditorFiles<CodeLanguage>;
59
+ testCases: CodeEditorTestCases;
60
+ languages: CodeLanguage[];
61
+ height: number;
62
+ };
63
+ export type GraphSheet = BasicWorksheet & {
64
+ type: WorksheetType.GRAPH;
65
+ dots: string[];
66
+ };
67
+ export type QuizProblemSheet = BasicWorksheet & {
68
+ type: WorksheetType.QUIZ_PROBLEM;
69
+ problemKey: string;
70
+ languages: CodeLanguage[];
71
+ height: number;
72
+ };
73
+ export type QuizTextSheet = BasicWorksheet & {
74
+ type: WorksheetType.QUIZ_TEXT;
75
+ description: string;
76
+ answer: string;
77
+ inputType: 'text' | 'number' | 'textarea';
78
+ };
79
+ export declare enum QuizScoringMode {
80
+ TOTAL = "TOTAL",
81
+ PARTIAL = "PARTIAL"
82
+ }
83
+ export type QuizOptionsSheet = BasicWorksheet & {
84
+ type: WorksheetType.QUIZ_OPTIONS;
85
+ description: string;
86
+ options: {
87
+ label: string;
88
+ correct: boolean;
89
+ id: string;
90
+ }[];
91
+ multiple: boolean;
92
+ scoringMode: QuizScoringMode;
93
+ };
94
+ export type ListSheet = BasicWorksheet & {
95
+ type: WorksheetType.LIST;
96
+ header: string;
97
+ content: (JkmdSheet | CodeEditorSheet | GraphSheet | QuizProblemSheet | QuizTextSheet | QuizOptionsSheet)[];
98
+ children: ListSheet[];
99
+ };
100
+ export type NewPageSheet = BasicWorksheet & {
101
+ type: WorksheetType.NEW_PAGE;
102
+ };
103
+ export type BodyWorksheet = JkmdSheet | CodeEditorSheet | ListSheet | GraphSheet | QuizProblemSheet | QuizTextSheet | QuizOptionsSheet | NewPageSheet;
@@ -0,0 +1,49 @@
1
+ import { RecordId } from './commons';
2
+ export declare enum WebSocketMessageEvent {
3
+ PING = "PING",
4
+ CLIENT_TRACK_LOCATION = "CLIENT_TRACK_LOCATION",
5
+ CLIENT_TRACK_SCREENSHOT = "CLIENT_TRACK_SCREENSHOT",
6
+ CLIENT_TRACK_DEVICE = "CLIENT_TRACK_DEVICE",
7
+ CHAT_COMPLETIONS = "CHAT_COMPLETIONS"
8
+ }
9
+ export declare enum WebSocketSubscriptionEvent {
10
+ SUBSCRIBE_CODE_RUN_STATUS = "SUBSCRIBE_CODE_RUN_STATUS",
11
+ UNSUBSCRIBE_CODE_RUN_STATUS = "UNSUBSCRIBE_CODE_RUN_STATUS",
12
+ SUBSCRIBE_SUBMISSION_RUN_STATUS = "SUBSCRIBE_SUBMISSION_RUN_STATUS",
13
+ UNSUBSCRIBE_SUBMISSION_RUN_STATUS = "UNSUBSCRIBE_SUBMISSION_RUN_STATUS",
14
+ SUBSCRIBE_GET_DATA = "SUBSCRIBE_GET_DATA",
15
+ UNSUBSCRIBE_GET_DATA = "SUBSCRIBE_GET_DATA",
16
+ SUBSCRIBE_PROBLEM_CRAWLED = "SUBSCRIBE_PROBLEM_CRAWLED",
17
+ UNSUBSCRIBE_PROBLEM_CRAWLED = "UNSUBSCRIBE_PROBLEM_CRAWLED",
18
+ SUBSCRIBE_SUBMISSIONS_CRAWL = "SUBSCRIBE_SUBMISSIONS_CRAWL",
19
+ UNSUBSCRIBE_SUBMISSIONS_CRAWL = "UNSUBSCRIBE_SUBMISSIONS_CRAWL",
20
+ SUBSCRIBE_CONTEST_CHANGES = "SUBSCRIBE_CONTEST_CHANGES",
21
+ UNSUBSCRIBE_CONTEST_CHANGES = "UNSUBSCRIBE_CONTEST_CHANGES",
22
+ SUBSCRIBE_CLIENT_TRACK = "SUBSCRIBE_CLIENT_TRACK",
23
+ UNSUBSCRIBE_CLIENT_TRACK = "UNSUBSCRIBE_CLIENT_TRACK",
24
+ SUBSCRIBE_USER_NOTIFICATION = "SUBSCRIBE_USER_NOTIFICATION",
25
+ UNSUBSCRIBE_USER_NOTIFICATION = "UNSUBSCRIBE_USER_NOTIFICATION"
26
+ }
27
+ export declare enum WebSocketResponseEvent {
28
+ PONG = "PONG",
29
+ CODE_RUN_STATUS = "CODE_RUN_STATUS",
30
+ SUBMISSION_RUN_STATUS = "SUBMISSION_RUN_STATUS",
31
+ USER_MESSAGE = "USER_MESSAGE",
32
+ SEND_DATA_ = "SEND_DATA_",
33
+ SEND_DATA_ECS_TASK_DEFINITIONS_LIST = "SEND_DATA_ECS_TASK_DEFINITIONS_LIST",
34
+ SEND_DATA_ECS_TASKS_LIST = "SEND_DATA_ECS_TASKS_LIST",
35
+ SEND_DATA_EC2_INSTANCES_LIST = "SEND_DATA_EC2_INSTANCES_LIST",
36
+ SEND_DATA_SSM_SESSIONS_LIST = "SEND_DATA_SSM_SESSIONS_LIST",
37
+ SEND_DATA_RUN_COMMAND = "SEND_DATA_RUN_COMMAND",
38
+ SEND_DATA_CLIENT_TRACK = "SEND_DATA_CLIENT_TRACK",
39
+ SEND_DATA_CHAT_COMPLETIONS = "SEND_DATA_CHAT_COMPLETIONS",
40
+ PROBLEM_CRAWLED = "PROBLEM_CRAWLED",
41
+ SUBMISSIONS_CRAWL = "SUBMISSIONS_CRAWL",
42
+ CONTEST_CHANGES = "CONTEST_CHANGES",
43
+ CLIENT_TRACK = "CLIENT_TRACK",
44
+ USER_NOTIFICATION_ = "USER_NOTIFICATION_",
45
+ USER_NOTIFICATION_SUBMISSION = "USER_NOTIFICATION_SUBMISSION",
46
+ USER_NOTIFICATION_CONTEST_CLARIFICATION = "USER_NOTIFICATION_CONTEST_CLARIFICATION"
47
+ }
48
+ export type ClientId = `${RecordId}|${string}`;
49
+ export type WebSocketResponseEventKey = `${WebSocketResponseEvent}-${ClientId}-${string}`;
@@ -0,0 +1,5 @@
1
+ export type DataLog = {
2
+ timeUsed: number;
3
+ memoryUsed: number;
4
+ exitCode: number;
5
+ };
@@ -0,0 +1,73 @@
1
+ import { MemberRole, AssignmentType, TeamStatus, UserTeamStatus } from './prisma';
2
+ import { UserBasic, UserProfile } from './users';
3
+ export interface TeamMember {
4
+ user: UserProfile;
5
+ role: MemberRole;
6
+ status: UserTeamStatus;
7
+ }
8
+ export interface Assignment {
9
+ id: number;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ users: [];
13
+ name: string;
14
+ type: AssignmentType;
15
+ content: string;
16
+ }
17
+ export interface Comment {
18
+ id: number;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ comment: string;
22
+ }
23
+ export interface Task {
24
+ id: number;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ comments: Comment[];
28
+ assigned: UserBasic[];
29
+ subtasks: [];
30
+ title: string;
31
+ description: string;
32
+ dueDate: Date;
33
+ }
34
+ export interface Training {
35
+ id: number;
36
+ tasks: Task[];
37
+ name: string;
38
+ startDate: Date;
39
+ endDate: Date;
40
+ }
41
+ export interface Team {
42
+ id: number;
43
+ createdAt: Date;
44
+ name: string;
45
+ aboutTeam: string;
46
+ country: string;
47
+ city: string;
48
+ institution: string;
49
+ imageUrl: string;
50
+ status: TeamStatus;
51
+ members: TeamMember[];
52
+ training: Training[];
53
+ }
54
+ export interface TrainingBasic {
55
+ id: number;
56
+ numberOfTasks: number;
57
+ name: string;
58
+ startDate: Date;
59
+ endDate: Date;
60
+ }
61
+ export interface TeamBasic {
62
+ id: number;
63
+ createdAt: Date;
64
+ name: string;
65
+ aboutTeam: string;
66
+ country: string;
67
+ city: string;
68
+ institution: string;
69
+ imageUrl: string;
70
+ status: TeamStatus;
71
+ members: TeamMember[];
72
+ training: Training[];
73
+ }
@@ -0,0 +1,59 @@
1
+ import { ProfileSetting } from './account';
2
+ import { CourseRole, Language, SystemRole, TeamRole, Theme, UserRole } from './prisma';
3
+ export interface UserBasicInfo {
4
+ nickname: string;
5
+ imageUrl: string;
6
+ }
7
+ export interface UserBasic extends UserBasicInfo {
8
+ givenName: string;
9
+ familyName: string;
10
+ email: string;
11
+ }
12
+ export interface UserProfile extends UserBasic {
13
+ aboutMe: string;
14
+ country: string;
15
+ city: string;
16
+ institution: string;
17
+ telegramUsername: string;
18
+ }
19
+ export type UserHandles = {
20
+ [key: string]: string;
21
+ };
22
+ export declare enum DataViewMode {
23
+ CARDS = "CARDS",
24
+ ROWS = "ROWS"
25
+ }
26
+ export declare enum MenuViewMode {
27
+ HORIZONTAL = "HORIZONTAL",
28
+ VERTICAL = "VERTICAL"
29
+ }
30
+ export type UserSettings = {
31
+ [ProfileSetting.LANGUAGE]: Language;
32
+ [ProfileSetting.THEME]: Theme;
33
+ [ProfileSetting.DATA_VIEW_MODE]: DataViewMode;
34
+ [ProfileSetting.MENU_VIEW_MODE]: MenuViewMode;
35
+ [ProfileSetting.NEWSLETTER_SUBSCRIPTION]: boolean;
36
+ [ProfileSetting.TIME_ZONE]: string;
37
+ [ProfileSetting.FONT_SIZE]: number;
38
+ };
39
+ export declare enum Role {
40
+ SUPER_ADMIN = "SUPER_ADMIN",
41
+ ADMIN = "ADMIN",
42
+ MASTER = "MASTER",
43
+ MANAGER = "MANAGER",
44
+ CREATOR = "CREATOR",
45
+ REGULAR = "REGULAR",
46
+ LIMITED = "LIMITED",
47
+ GUEST = "GUEST",
48
+ RESTRICTED = "RESTRICTED"
49
+ }
50
+ export type ProblemRole = Role.RESTRICTED | Role.GUEST | Role.REGULAR | Role.CREATOR | Role.MANAGER | Role.MASTER | Role.ADMIN | Role.SUPER_ADMIN;
51
+ export type ContestRole = Role.RESTRICTED | Role.GUEST | Role.REGULAR | Role.CREATOR | Role.MANAGER | Role.MASTER | Role.ADMIN | Role.SUPER_ADMIN;
52
+ export type UserRoles = {
53
+ systemRole: SystemRole;
54
+ userRole: UserRole;
55
+ contestRole: ContestRole;
56
+ problemRole: ProblemRole;
57
+ teamRole: TeamRole;
58
+ courseRole: CourseRole;
59
+ };
@@ -0,0 +1,7 @@
1
+ export declare enum WorkingIn {
2
+ NOTHING = "NOTHING",
3
+ SEND_SUBMISSION = "SEND_SUBMISSION",
4
+ TRACKING_SUBMISSION = "TRACKING_SUBMISSION",
5
+ CRAWLING_LANGUAGES = "CRAWLING_LANGUAGES",
6
+ CRAWLING_PROBLEM_DATA = "CRAWLING_PROBLEM_DATA"
7
+ }
@@ -0,0 +1,42 @@
1
+ import { EntityMembers } from './entity';
2
+ import { Theme } from './prisma';
3
+ import { BasicWorksheet, BodyWorksheet, NewPageSheet } from './sheet';
4
+ export declare enum AspectRatio {
5
+ RATIO_21_9 = "21:9",
6
+ RATIO_20_9 = "20:9",
7
+ RATIO_16_9 = "16:9",
8
+ RATIO_16_10 = "16:10",
9
+ RATIO_3_2 = "3:2",
10
+ RATIO_4_3 = "4:3",
11
+ RATIO_5_4 = "5:4",
12
+ RATIO_1_1 = "1:1"
13
+ }
14
+ export interface WorksheetBaseDocument {
15
+ key: string;
16
+ folderId: string;
17
+ name: string;
18
+ description: string;
19
+ content: BodyWorksheet[];
20
+ members: EntityMembers;
21
+ quiz: {
22
+ enable: boolean;
23
+ automaticFeedback: boolean;
24
+ };
25
+ slides: {
26
+ enable: boolean;
27
+ titleBackgroundImage: string;
28
+ backgroundImage: string;
29
+ fontSize: number;
30
+ theme: Theme;
31
+ colorTextHighlight: string;
32
+ aspectRatio: AspectRatio;
33
+ };
34
+ }
35
+ export type WorksheetsInPages = {
36
+ header: NewPageSheet;
37
+ content: BodyWorksheet[];
38
+ }[];
39
+ export type SummaryWorksheetsInPages = {
40
+ header: NewPageSheet;
41
+ content: BasicWorksheet[];
42
+ }[];
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@juki-team/commons",
3
+ "version": "0.1.11",
4
+ "author": "juki-team",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/cjs/index.cjs",
8
+ "module": "dist/esm/index.js",
9
+ "types": "dist/types/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/types/index.d.ts",
13
+ "import": "./dist/esm/index.js",
14
+ "require": "./dist/cjs/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "repository": "https://github.com/juki-team/commons.git",
21
+ "scripts": {
22
+ "docs": "typedoc src/index.ts",
23
+ "watch": "rollup -cw",
24
+ "build": "rm -rf docs && rm -rf dist && rollup -c && yarn docs",
25
+ "git:commit-push": "f() { param=${1}; message=${param:-chore}; echo ${message}; git add .; echo $message | git commit -F -; yarn publish --patch --no-git-tag-version; version=\"v$(node -p \"require('./package.json').version\")\"; git add .; echo $version | git commit -F -; git push origin main; echo $version | git tag -a $(echo $version) -F -; git push origin --tags; }; f",
26
+ "git:push": "f() { yarn publish --patch --no-git-tag-version; version=\"v$(node -p \"require('./package.json').version\")\"; git add .; echo $version | git commit -F -; git push origin main; echo $version | git tag -a $(echo $version) -F -; git push origin --tags; }; f",
27
+ "push-commit": "f() { yarn build && yarn git-push \"${1}\"; }; f",
28
+ "push": "yarn build && yarn git:push"
29
+ },
30
+ "devDependencies": {
31
+ "@types/uuid": "^11.0.0",
32
+ "prettier": "^3.8.1",
33
+ "rollup": "^4.57.1",
34
+ "rollup-plugin-typescript2": "^0.36.0",
35
+ "typedoc": "^0.28.16",
36
+ "typescript": "^5.9.3"
37
+ }
38
+ }