@studious-lms/server 1.4.1 → 1.4.3
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/.coderabbit.yaml +4 -1
- package/.env.example +6 -0
- package/.env.test.example +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -76
- package/dist/index.js.map +1 -1
- package/dist/lib/config/cors.d.ts +16 -0
- package/dist/lib/config/cors.d.ts.map +1 -0
- package/dist/lib/config/cors.js +75 -0
- package/dist/lib/config/cors.js.map +1 -0
- package/dist/lib/config/env.d.ts +14 -0
- package/dist/lib/config/env.d.ts.map +1 -1
- package/dist/lib/config/env.js +9 -2
- package/dist/lib/config/env.js.map +1 -1
- package/dist/lib/fileUpload.d.ts +10 -2
- package/dist/lib/fileUpload.d.ts.map +1 -1
- package/dist/lib/fileUpload.js +38 -6
- package/dist/lib/fileUpload.js.map +1 -1
- package/dist/lib/prisma.d.ts +14 -2
- package/dist/lib/prisma.d.ts.map +1 -1
- package/dist/lib/prisma.js +27 -8
- package/dist/lib/prisma.js.map +1 -1
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +18 -5
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/security.d.ts.map +1 -1
- package/dist/middleware/security.js +3 -3
- package/dist/middleware/security.js.map +1 -1
- package/dist/models/agenda.d.ts +16 -16
- package/dist/models/announcement.d.ts +59 -23
- package/dist/models/announcement.d.ts.map +1 -1
- package/dist/models/assignment.d.ts +363 -276
- package/dist/models/assignment.d.ts.map +1 -1
- package/dist/models/attendance.d.ts +63 -21
- package/dist/models/attendance.d.ts.map +1 -1
- package/dist/models/auth.d.ts +115 -26
- package/dist/models/auth.d.ts.map +1 -1
- package/dist/models/auth.js +53 -30
- package/dist/models/auth.js.map +1 -1
- package/dist/models/class.d.ts +115 -65
- package/dist/models/class.d.ts.map +1 -1
- package/dist/models/class.js +16 -4
- package/dist/models/class.js.map +1 -1
- package/dist/models/comment.d.ts +52 -16
- package/dist/models/comment.d.ts.map +1 -1
- package/dist/models/conversation.d.ts +46 -16
- package/dist/models/conversation.d.ts.map +1 -1
- package/dist/models/event.d.ts +107 -53
- package/dist/models/event.d.ts.map +1 -1
- package/dist/models/file.d.ts +213 -165
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/folder.d.ts +161 -77
- package/dist/models/folder.d.ts.map +1 -1
- package/dist/models/labChat.d.ts +73 -31
- package/dist/models/labChat.d.ts.map +1 -1
- package/dist/models/marketing.d.ts +25 -7
- package/dist/models/marketing.d.ts.map +1 -1
- package/dist/models/message.d.ts +31 -13
- package/dist/models/message.d.ts.map +1 -1
- package/dist/models/newtonChat.d.ts +34 -10
- package/dist/models/newtonChat.d.ts.map +1 -1
- package/dist/models/notification.d.ts +29 -10
- package/dist/models/notification.d.ts.map +1 -1
- package/dist/models/notification.js +13 -9
- package/dist/models/notification.js.map +1 -1
- package/dist/models/section.d.ts +71 -23
- package/dist/models/section.d.ts.map +1 -1
- package/dist/models/user.d.ts +27 -9
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/worksheet.d.ts +606 -106
- package/dist/models/worksheet.d.ts.map +1 -1
- package/dist/models/worksheet.js +168 -2
- package/dist/models/worksheet.js.map +1 -1
- package/dist/pipelines/aiLabChat.d.ts +22 -2
- package/dist/pipelines/aiLabChat.d.ts.map +1 -1
- package/dist/pipelines/aiLabChat.js +133 -95
- package/dist/pipelines/aiLabChat.js.map +1 -1
- package/dist/pipelines/aiLabChatContract.d.ts +25 -25
- package/dist/pipelines/aiNewtonChat.d.ts.map +1 -1
- package/dist/pipelines/aiNewtonChat.js +25 -14
- package/dist/pipelines/aiNewtonChat.js.map +1 -1
- package/dist/pipelines/gradeWorksheet.d.ts +8 -8
- package/dist/pipelines/gradeWorksheet.d.ts.map +1 -1
- package/dist/pipelines/gradeWorksheet.js +12 -5
- package/dist/pipelines/gradeWorksheet.js.map +1 -1
- package/dist/pipelines/labChatPrompt.d.ts +27 -0
- package/dist/pipelines/labChatPrompt.d.ts.map +1 -1
- package/dist/pipelines/labChatPrompt.js +143 -69
- package/dist/pipelines/labChatPrompt.js.map +1 -1
- package/dist/routers/_app.d.ts +1579 -1257
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/agenda.d.ts +16 -16
- package/dist/routers/announcement.d.ts +19 -19
- package/dist/routers/assignment.d.ts +307 -291
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +3 -2
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/attendance.d.ts +7 -7
- package/dist/routers/auth.d.ts +1 -1
- package/dist/routers/class.d.ts +79 -72
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +3 -3
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +6 -6
- package/dist/routers/conversation.d.ts +11 -11
- package/dist/routers/event.d.ts +35 -35
- package/dist/routers/file.d.ts +12 -12
- package/dist/routers/folder.d.ts +54 -54
- package/dist/routers/labChat.d.ts +18 -12
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +5 -3
- package/dist/routers/labChat.js.map +1 -1
- package/dist/routers/marketing.d.ts +2 -2
- package/dist/routers/message.d.ts +33 -2
- package/dist/routers/message.d.ts.map +1 -1
- package/dist/routers/message.js +27 -4
- package/dist/routers/message.js.map +1 -1
- package/dist/routers/newtonChat.d.ts +7 -1
- package/dist/routers/newtonChat.d.ts.map +1 -1
- package/dist/routers/newtonChat.js +5 -4
- package/dist/routers/newtonChat.js.map +1 -1
- package/dist/routers/notifications.d.ts +13 -6
- package/dist/routers/notifications.d.ts.map +1 -1
- package/dist/routers/notifications.js +4 -4
- package/dist/routers/notifications.js.map +1 -1
- package/dist/routers/section.d.ts +7 -7
- package/dist/routers/studentProgress.d.ts +86 -0
- package/dist/routers/studentProgress.d.ts.map +1 -1
- package/dist/routers/studentProgress.js +14 -4
- package/dist/routers/studentProgress.js.map +1 -1
- package/dist/routers/user.d.ts +1 -1
- package/dist/routers/worksheet.d.ts +64 -62
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/routers/worksheet.js +18 -16
- package/dist/routers/worksheet.js.map +1 -1
- package/dist/seedDatabase.d.ts +1 -1
- package/dist/services/agenda.d.ts +16 -16
- package/dist/services/announcement.d.ts +8 -8
- package/dist/services/assignment.d.ts +299 -283
- package/dist/services/assignment.d.ts.map +1 -1
- package/dist/services/assignment.js +24 -5
- package/dist/services/assignment.js.map +1 -1
- package/dist/services/attendance.d.ts +7 -7
- package/dist/services/auth.d.ts +2 -2
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +19 -12
- package/dist/services/auth.js.map +1 -1
- package/dist/services/class.d.ts +74 -68
- package/dist/services/class.d.ts.map +1 -1
- package/dist/services/class.js +6 -3
- package/dist/services/class.js.map +1 -1
- package/dist/services/comment.d.ts +6 -6
- package/dist/services/conversation.d.ts +11 -11
- package/dist/services/event.d.ts +31 -31
- package/dist/services/file.d.ts +12 -12
- package/dist/services/file.d.ts.map +1 -1
- package/dist/services/file.js +7 -2
- package/dist/services/file.js.map +1 -1
- package/dist/services/folder.d.ts +52 -52
- package/dist/services/labChat.d.ts +18 -12
- package/dist/services/labChat.d.ts.map +1 -1
- package/dist/services/labChat.js +30 -18
- package/dist/services/labChat.js.map +1 -1
- package/dist/services/marketing.d.ts +2 -2
- package/dist/services/message.d.ts +30 -0
- package/dist/services/message.d.ts.map +1 -1
- package/dist/services/message.js +97 -21
- package/dist/services/message.js.map +1 -1
- package/dist/services/newtonChat.d.ts +6 -1
- package/dist/services/newtonChat.d.ts.map +1 -1
- package/dist/services/newtonChat.js +36 -18
- package/dist/services/newtonChat.js.map +1 -1
- package/dist/services/notification.d.ts +16 -9
- package/dist/services/notification.d.ts.map +1 -1
- package/dist/services/notification.js +24 -9
- package/dist/services/notification.js.map +1 -1
- package/dist/services/section.d.ts +6 -6
- package/dist/services/studentProgress.d.ts +75 -0
- package/dist/services/studentProgress.d.ts.map +1 -1
- package/dist/services/studentProgress.js +300 -107
- package/dist/services/studentProgress.js.map +1 -1
- package/dist/services/worksheet.d.ts +64 -64
- package/dist/services/worksheet.d.ts.map +1 -1
- package/dist/services/worksheet.js +138 -54
- package/dist/services/worksheet.js.map +1 -1
- package/dist/trpc.d.ts.map +1 -1
- package/dist/trpc.js +11 -17
- package/dist/trpc.js.map +1 -1
- package/dist/utils/inference.d.ts +9 -12
- package/dist/utils/inference.d.ts.map +1 -1
- package/dist/utils/inference.js +135 -95
- package/dist/utils/inference.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260410124000_add_submission_recommendation_state/migration.sql +14 -0
- package/prisma/migrations/20260415103500_add_session_type/migration.sql +33 -0
- package/prisma/migrations/20260415133000_add_ai_usage_logs/migration.sql +19 -0
- package/prisma/schema.prisma +41 -1
- package/scripts/test-pre-push.ts +6 -2
- package/src/index.ts +119 -79
- package/src/lib/config/cors.ts +96 -0
- package/src/lib/config/env.ts +12 -1
- package/src/lib/fileUpload.ts +55 -5
- package/src/lib/prisma.ts +25 -6
- package/src/middleware/auth.ts +19 -4
- package/src/middleware/security.ts +1 -1
- package/src/models/auth.ts +59 -29
- package/src/models/class.ts +15 -4
- package/src/models/notification.ts +13 -7
- package/src/models/worksheet.ts +202 -0
- package/src/pipelines/aiLabChat.ts +183 -104
- package/src/pipelines/aiNewtonChat.ts +24 -14
- package/src/pipelines/gradeWorksheet.ts +10 -2
- package/src/pipelines/labChatPrompt.ts +196 -68
- package/src/routers/assignment.ts +1 -0
- package/src/routers/class.ts +2 -2
- package/src/routers/labChat.ts +3 -1
- package/src/routers/message.ts +38 -1
- package/src/routers/newtonChat.ts +4 -2
- package/src/routers/notifications.ts +2 -2
- package/src/routers/studentProgress.ts +25 -1
- package/src/routers/worksheet.ts +31 -19
- package/src/services/assignment.ts +30 -2
- package/src/services/auth.ts +26 -12
- package/src/services/class.ts +4 -1
- package/src/services/file.ts +6 -0
- package/src/services/labChat.ts +42 -18
- package/src/services/message.ts +163 -18
- package/src/services/newtonChat.ts +49 -18
- package/src/services/notification.ts +27 -8
- package/src/services/studentProgress.ts +425 -121
- package/src/services/worksheet.ts +191 -51
- package/src/trpc.ts +12 -18
- package/src/utils/inference.ts +205 -112
- package/tests/globalSetup.ts +13 -4
- package/tests/lib/cors.test.ts +103 -0
- package/tests/pipelines/aiLabChat.test.ts +64 -84
- package/tests/routers/auth.test.ts +120 -17
- package/tests/routers/class.test.ts +7 -1
- package/tests/routers/message.test.ts +236 -9
- package/tests/routers/newtonChat.test.ts +81 -0
- package/tests/routers/notification.test.ts +12 -0
- package/tests/routers/studentProgress.test.ts +2 -31
- package/tests/routers/worksheet.test.ts +194 -0
- package/tests/setup.ts +22 -5
- package/tests/utils/aiLabChatPrompt.test.ts +114 -6
- package/tests/utils/inference.test.ts +218 -0
- package/tests/utils/studentProgress.test.ts +361 -0
- package/vitest.unit.config.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment.d.ts","sourceRoot":"/","sources":["models/assignment.ts"],"names":[],"mappings":"AAyCA,iCAAiC;AACjC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"assignment.d.ts","sourceRoot":"/","sources":["models/assignment.ts"],"names":[],"mappings":"AAyCA,iCAAiC;AACjC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAI5C;AAED,qDAAqD;AACrD,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKnD;AAED,uDAAuD;AACvD,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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findClassWithStudents(classId: string): import(".prisma/
|
|
|
5
5
|
id: string;
|
|
6
6
|
username: string;
|
|
7
7
|
profile: {
|
|
8
|
+
location: string | null;
|
|
8
9
|
displayName: string | null;
|
|
9
10
|
bio: string | null;
|
|
10
|
-
location: string | null;
|
|
11
11
|
website: string | null;
|
|
12
12
|
profilePicture: string | null;
|
|
13
13
|
profilePictureThumbnail: string | null;
|
|
14
14
|
} | null;
|
|
15
15
|
}[];
|
|
16
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
16
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
17
|
+
datasources: {
|
|
18
|
+
db: {
|
|
19
|
+
url: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
17
23
|
/** @returns Class if user is a teacher. */
|
|
18
24
|
export declare function findClassWithTeacher(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
25
|
+
name: string;
|
|
19
26
|
id: string;
|
|
20
27
|
schoolId: string | null;
|
|
21
|
-
name: string;
|
|
22
28
|
subject: string;
|
|
23
29
|
color: string | null;
|
|
24
30
|
section: string;
|
|
25
31
|
syllabus: string | null;
|
|
26
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
32
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
33
|
+
datasources: {
|
|
34
|
+
db: {
|
|
35
|
+
url: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
27
39
|
/** @returns Events for a class. */
|
|
28
40
|
export declare function findEventsByClassId(classId: string): import(".prisma/client").Prisma.PrismaPromise<{
|
|
41
|
+
name: string | null;
|
|
29
42
|
id: string;
|
|
30
43
|
userId: string | null;
|
|
31
|
-
location: string | null;
|
|
32
|
-
classId: string | null;
|
|
33
|
-
name: string | null;
|
|
34
44
|
color: string | null;
|
|
45
|
+
classId: string | null;
|
|
35
46
|
startTime: Date;
|
|
36
47
|
endTime: Date;
|
|
48
|
+
location: string | null;
|
|
37
49
|
remarks: string | null;
|
|
38
50
|
}[]>;
|
|
39
51
|
/** @returns Attendance record for an event. */
|
|
@@ -42,31 +54,43 @@ export declare function findAttendanceByEventId(eventId: string): import(".prism
|
|
|
42
54
|
classId: string;
|
|
43
55
|
eventId: string | null;
|
|
44
56
|
date: Date;
|
|
45
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
57
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
58
|
+
datasources: {
|
|
59
|
+
db: {
|
|
60
|
+
url: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
46
64
|
/** @returns Attendance for class and event (eventId null = class-level). */
|
|
47
65
|
export declare function findAttendanceByClassAndEvent(classId: string, eventId: string | null): import(".prisma/client").Prisma.Prisma__AttendanceClient<{
|
|
48
66
|
id: string;
|
|
49
67
|
classId: string;
|
|
50
68
|
eventId: string | null;
|
|
51
69
|
date: Date;
|
|
52
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
70
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
71
|
+
datasources: {
|
|
72
|
+
db: {
|
|
73
|
+
url: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
}>;
|
|
53
77
|
/** @returns Attendance records for class, optionally filtered by event. */
|
|
54
78
|
export declare function findManyAttendance(classId: string, eventId?: string): import(".prisma/client").Prisma.PrismaPromise<({
|
|
55
79
|
event: {
|
|
56
|
-
id: string;
|
|
57
|
-
location: string | null;
|
|
58
80
|
name: string | null;
|
|
81
|
+
id: string;
|
|
59
82
|
color: string | null;
|
|
60
83
|
startTime: Date;
|
|
61
84
|
endTime: Date;
|
|
85
|
+
location: string | null;
|
|
62
86
|
} | null;
|
|
63
87
|
present: {
|
|
64
88
|
id: string;
|
|
65
89
|
username: string;
|
|
66
90
|
profile: {
|
|
91
|
+
location: string | null;
|
|
67
92
|
displayName: string | null;
|
|
68
93
|
bio: string | null;
|
|
69
|
-
location: string | null;
|
|
70
94
|
website: string | null;
|
|
71
95
|
profilePicture: string | null;
|
|
72
96
|
profilePictureThumbnail: string | null;
|
|
@@ -76,9 +100,9 @@ export declare function findManyAttendance(classId: string, eventId?: string): i
|
|
|
76
100
|
id: string;
|
|
77
101
|
username: string;
|
|
78
102
|
profile: {
|
|
103
|
+
location: string | null;
|
|
79
104
|
displayName: string | null;
|
|
80
105
|
bio: string | null;
|
|
81
|
-
location: string | null;
|
|
82
106
|
website: string | null;
|
|
83
107
|
profilePicture: string | null;
|
|
84
108
|
profilePictureThumbnail: string | null;
|
|
@@ -88,9 +112,9 @@ export declare function findManyAttendance(classId: string, eventId?: string): i
|
|
|
88
112
|
id: string;
|
|
89
113
|
username: string;
|
|
90
114
|
profile: {
|
|
115
|
+
location: string | null;
|
|
91
116
|
displayName: string | null;
|
|
92
117
|
bio: string | null;
|
|
93
|
-
location: string | null;
|
|
94
118
|
website: string | null;
|
|
95
119
|
profilePicture: string | null;
|
|
96
120
|
profilePictureThumbnail: string | null;
|
|
@@ -111,11 +135,11 @@ export declare function createAttendance(data: {
|
|
|
111
135
|
absentIds?: string[];
|
|
112
136
|
}): import(".prisma/client").Prisma.Prisma__AttendanceClient<{
|
|
113
137
|
event: {
|
|
114
|
-
id: string;
|
|
115
|
-
location: string | null;
|
|
116
138
|
name: string | null;
|
|
139
|
+
id: string;
|
|
117
140
|
startTime: Date;
|
|
118
141
|
endTime: Date;
|
|
142
|
+
location: string | null;
|
|
119
143
|
} | null;
|
|
120
144
|
present: {
|
|
121
145
|
id: string;
|
|
@@ -134,7 +158,13 @@ export declare function createAttendance(data: {
|
|
|
134
158
|
classId: string;
|
|
135
159
|
eventId: string | null;
|
|
136
160
|
date: Date;
|
|
137
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
161
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
162
|
+
datasources: {
|
|
163
|
+
db: {
|
|
164
|
+
url: string;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
}>;
|
|
138
168
|
/** Create attendance for a specific event. */
|
|
139
169
|
export declare function createAttendanceForEvent(data: {
|
|
140
170
|
classId: string;
|
|
@@ -145,7 +175,13 @@ export declare function createAttendanceForEvent(data: {
|
|
|
145
175
|
classId: string;
|
|
146
176
|
eventId: string | null;
|
|
147
177
|
date: Date;
|
|
148
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
178
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
179
|
+
datasources: {
|
|
180
|
+
db: {
|
|
181
|
+
url: string;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
}>;
|
|
149
185
|
/** Update attendance present/late/absent lists. */
|
|
150
186
|
export declare function updateAttendance(id: string, data: {
|
|
151
187
|
presentIds: string[];
|
|
@@ -153,11 +189,11 @@ export declare function updateAttendance(id: string, data: {
|
|
|
153
189
|
absentIds: string[];
|
|
154
190
|
}): import(".prisma/client").Prisma.Prisma__AttendanceClient<{
|
|
155
191
|
event: {
|
|
156
|
-
id: string;
|
|
157
|
-
location: string | null;
|
|
158
192
|
name: string | null;
|
|
193
|
+
id: string;
|
|
159
194
|
startTime: Date;
|
|
160
195
|
endTime: Date;
|
|
196
|
+
location: string | null;
|
|
161
197
|
} | null;
|
|
162
198
|
present: {
|
|
163
199
|
id: string;
|
|
@@ -176,5 +212,11 @@ export declare function updateAttendance(id: string, data: {
|
|
|
176
212
|
classId: string;
|
|
177
213
|
eventId: string | null;
|
|
178
214
|
date: Date;
|
|
179
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
215
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
216
|
+
datasources: {
|
|
217
|
+
db: {
|
|
218
|
+
url: string;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
}>;
|
|
180
222
|
//# sourceMappingURL=attendance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attendance.d.ts","sourceRoot":"/","sources":["models/attendance.ts"],"names":[],"mappings":"AAiFA,mDAAmD;AACnD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"attendance.d.ts","sourceRoot":"/","sources":["models/attendance.ts"],"names":[],"mappings":"AAiFA,mDAAmD;AACnD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;GAuBpD;AAED,2CAA2C;AAC3C,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;GAOtE;AAED,mCAAmC;AACnC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;KAIlD;AAED,+CAA+C;AAC/C,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;GAItD;AAED,4EAA4E;AAC5E,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;GAOpF;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MASnE;AAED,mCAAmC;AACnC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgBA;AAED,8CAA8C;AAC9C,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;;;;;;;;;;;GAQA;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAWvE"}
|
package/dist/models/auth.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth model – user lookup, session CRUD, Redis session cache.
|
|
3
|
+
* findUserBySessionToken checks Redis first, then DB.
|
|
4
|
+
*/
|
|
5
|
+
import { SessionType } from "@prisma/client";
|
|
1
6
|
/** @returns User by username (includes password for login). */
|
|
2
7
|
export declare function findUserByUsername(username: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
3
8
|
id: string;
|
|
@@ -5,40 +10,64 @@ export declare function findUserByUsername(username: string): import(".prisma/cl
|
|
|
5
10
|
email: string;
|
|
6
11
|
password: string;
|
|
7
12
|
verified: boolean;
|
|
8
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
13
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
14
|
+
datasources: {
|
|
15
|
+
db: {
|
|
16
|
+
url: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
9
20
|
/** @returns User by username or email. */
|
|
10
21
|
export declare function findUserByUsernameOrEmail(username: string, email: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
11
22
|
id: string;
|
|
12
23
|
username: string;
|
|
13
24
|
email: string;
|
|
14
25
|
verified: boolean;
|
|
15
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
26
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
27
|
+
datasources: {
|
|
28
|
+
db: {
|
|
29
|
+
url: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}>;
|
|
16
33
|
/** @returns User by email with profile. */
|
|
17
34
|
export declare function findUserByEmail(email: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
18
35
|
id: string;
|
|
19
36
|
email: string;
|
|
20
37
|
role: import(".prisma/client").$Enums.UserRole;
|
|
21
38
|
profile: {
|
|
39
|
+
location: string | null;
|
|
22
40
|
displayName: string | null;
|
|
23
41
|
bio: string | null;
|
|
24
|
-
location: string | null;
|
|
25
42
|
website: string | null;
|
|
26
43
|
profilePicture: string | null;
|
|
27
44
|
} | null;
|
|
28
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
45
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
46
|
+
datasources: {
|
|
47
|
+
db: {
|
|
48
|
+
url: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
29
52
|
/** @returns User by ID with profile. */
|
|
30
53
|
export declare function findUserById(id: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
31
54
|
id: string;
|
|
32
55
|
username: string;
|
|
33
56
|
profile: {
|
|
57
|
+
location: string | null;
|
|
34
58
|
displayName: string | null;
|
|
35
59
|
bio: string | null;
|
|
36
|
-
location: string | null;
|
|
37
60
|
website: string | null;
|
|
38
61
|
profilePicture: string | null;
|
|
39
62
|
profilePictureThumbnail: string | null;
|
|
40
63
|
} | null;
|
|
41
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
64
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
65
|
+
datasources: {
|
|
66
|
+
db: {
|
|
67
|
+
url: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}>;
|
|
42
71
|
/** Create a user with empty profile. */
|
|
43
72
|
export declare function createUser(data: {
|
|
44
73
|
username: string;
|
|
@@ -49,22 +78,37 @@ export declare function createUser(data: {
|
|
|
49
78
|
id: string;
|
|
50
79
|
username: string;
|
|
51
80
|
email: string;
|
|
52
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
81
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
82
|
+
datasources: {
|
|
83
|
+
db: {
|
|
84
|
+
url: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
53
88
|
/** Create a session. */
|
|
54
89
|
export declare function createSession(data: {
|
|
55
90
|
id: string;
|
|
56
|
-
|
|
91
|
+
type: SessionType;
|
|
57
92
|
expiresAt: Date;
|
|
93
|
+
userId?: string;
|
|
94
|
+
classId?: string;
|
|
58
95
|
}): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
96
|
+
type: import(".prisma/client").$Enums.SessionType;
|
|
59
97
|
id: string;
|
|
60
98
|
userId: string | null;
|
|
61
99
|
createdAt: Date | null;
|
|
62
100
|
expiresAt: Date | null;
|
|
63
101
|
classId: string | null;
|
|
64
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
102
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
103
|
+
datasources: {
|
|
104
|
+
db: {
|
|
105
|
+
url: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}>;
|
|
65
109
|
/** Delete all sessions for user. Invalidates Redis cache. */
|
|
66
110
|
export declare function deleteSessionsByUserId(userId: string): Promise<import(".prisma/client").Prisma.BatchPayload>;
|
|
67
|
-
/** Delete
|
|
111
|
+
/** Delete password reset sessions expiring before date. */
|
|
68
112
|
export declare function deleteShortLivedSessionsByUserId(userId: string, expiresBefore: Date): import(".prisma/client").Prisma.PrismaPromise<import(".prisma/client").Prisma.BatchPayload>;
|
|
69
113
|
/** Delete a user. */
|
|
70
114
|
export declare function deleteUserById(id: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
@@ -75,27 +119,47 @@ export declare function deleteUserById(id: string): import(".prisma/client").Pri
|
|
|
75
119
|
verified: boolean;
|
|
76
120
|
role: import(".prisma/client").$Enums.UserRole;
|
|
77
121
|
schoolId: string | null;
|
|
78
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
79
|
-
|
|
80
|
-
|
|
122
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
123
|
+
datasources: {
|
|
124
|
+
db: {
|
|
125
|
+
url: string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
}>;
|
|
129
|
+
/** @returns Session by ID and type. */
|
|
130
|
+
export declare function findSessionByIdAndType(id: string, type: SessionType): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
131
|
+
type: import(".prisma/client").$Enums.SessionType;
|
|
81
132
|
id: string;
|
|
82
133
|
userId: string | null;
|
|
83
134
|
createdAt: Date | null;
|
|
84
135
|
expiresAt: Date | null;
|
|
85
136
|
classId: string | null;
|
|
86
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
87
|
-
|
|
88
|
-
|
|
137
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
138
|
+
datasources: {
|
|
139
|
+
db: {
|
|
140
|
+
url: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
}>;
|
|
144
|
+
/** @returns Session with user by ID and type. */
|
|
145
|
+
export declare function findSessionByIdWithUserAndType(id: string, type: SessionType): import(".prisma/client").Prisma.Prisma__SessionClient<({
|
|
89
146
|
user: {
|
|
90
147
|
id: string;
|
|
91
148
|
} | null;
|
|
92
149
|
} & {
|
|
150
|
+
type: import(".prisma/client").$Enums.SessionType;
|
|
93
151
|
id: string;
|
|
94
152
|
userId: string | null;
|
|
95
153
|
createdAt: Date | null;
|
|
96
154
|
expiresAt: Date | null;
|
|
97
155
|
classId: string | null;
|
|
98
|
-
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
156
|
+
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
157
|
+
datasources: {
|
|
158
|
+
db: {
|
|
159
|
+
url: string;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
}>;
|
|
99
163
|
/** Set user verified status. */
|
|
100
164
|
export declare function updateUserVerified(userId: string, verified: boolean): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
101
165
|
id: string;
|
|
@@ -105,7 +169,13 @@ export declare function updateUserVerified(userId: string, verified: boolean): i
|
|
|
105
169
|
verified: boolean;
|
|
106
170
|
role: import(".prisma/client").$Enums.UserRole;
|
|
107
171
|
schoolId: string | null;
|
|
108
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
172
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
173
|
+
datasources: {
|
|
174
|
+
db: {
|
|
175
|
+
url: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
}>;
|
|
109
179
|
/** Update user password. */
|
|
110
180
|
export declare function updateUserPassword(userId: string, password: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
111
181
|
id: string;
|
|
@@ -115,16 +185,23 @@ export declare function updateUserPassword(userId: string, password: string): im
|
|
|
115
185
|
verified: boolean;
|
|
116
186
|
role: import(".prisma/client").$Enums.UserRole;
|
|
117
187
|
schoolId: string | null;
|
|
118
|
-
}, never, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
188
|
+
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
189
|
+
datasources: {
|
|
190
|
+
db: {
|
|
191
|
+
url: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
}>;
|
|
119
195
|
/** Delete a session. */
|
|
120
|
-
export declare function deleteSessionById(id: string):
|
|
196
|
+
export declare function deleteSessionById(id: string): Promise<{
|
|
197
|
+
type: import(".prisma/client").$Enums.SessionType;
|
|
121
198
|
id: string;
|
|
122
199
|
userId: string | null;
|
|
123
200
|
createdAt: Date | null;
|
|
124
201
|
expiresAt: Date | null;
|
|
125
202
|
classId: string | null;
|
|
126
|
-
}
|
|
127
|
-
/** @returns User from session token. Checks Redis first, then DB. Caches in Redis. */
|
|
203
|
+
}>;
|
|
204
|
+
/** @returns User from valid auth session token. Checks Redis first, then DB. Caches in Redis. */
|
|
128
205
|
export declare function findUserBySessionToken(token: string): Promise<any>;
|
|
129
206
|
/** @returns Class IDs where user is a teacher. */
|
|
130
207
|
export declare function findTeacherClassesByUserId(userId: string): import(".prisma/client").Prisma.PrismaPromise<{
|
|
@@ -132,22 +209,34 @@ export declare function findTeacherClassesByUserId(userId: string): import(".pri
|
|
|
132
209
|
}[]>;
|
|
133
210
|
/** @returns Class if user is student or teacher. */
|
|
134
211
|
export declare function findClassWithMember(classId: string, userId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
212
|
+
name: string;
|
|
135
213
|
id: string;
|
|
136
214
|
schoolId: string | null;
|
|
137
|
-
name: string;
|
|
138
215
|
subject: string;
|
|
139
216
|
color: string | null;
|
|
140
217
|
section: string;
|
|
141
218
|
syllabus: string | null;
|
|
142
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
219
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
220
|
+
datasources: {
|
|
221
|
+
db: {
|
|
222
|
+
url: string;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
}>;
|
|
143
226
|
/** @returns Class if user is a teacher. */
|
|
144
227
|
export declare function findClassWithTeacher(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
228
|
+
name: string;
|
|
145
229
|
id: string;
|
|
146
230
|
schoolId: string | null;
|
|
147
|
-
name: string;
|
|
148
231
|
subject: string;
|
|
149
232
|
color: string | null;
|
|
150
233
|
section: string;
|
|
151
234
|
syllabus: string | null;
|
|
152
|
-
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs,
|
|
235
|
+
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
236
|
+
datasources: {
|
|
237
|
+
db: {
|
|
238
|
+
url: string;
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
}>;
|
|
153
242
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"/","sources":["models/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"/","sources":["models/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAmB7C,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;GAWlD;AAED,0CAA0C;AAC1C,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;;;;;;;;GAYxE;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;GAkB5C;AAED,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;GAkBtC;AAED,wCAAwC;AACxC,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;;;;;;;;;GAeA;AAED,wBAAwB;AACxB,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAA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
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
6
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="caa0301d-42ed-55b1-a0ef-383918fe715a")}catch(e){}}();
|
|
7
|
+
import { SessionType } from "@prisma/client";
|
|
7
8
|
import { getRedis } from "../lib/redis.js";
|
|
8
9
|
import { prisma } from "../lib/prisma.js";
|
|
10
|
+
const AUTH_SESSION_CACHE_PREFIX = "auth-session:";
|
|
11
|
+
function getAuthSessionCacheKey(token) {
|
|
12
|
+
return `${AUTH_SESSION_CACHE_PREFIX}${token}`;
|
|
13
|
+
}
|
|
14
|
+
function getSessionTtlSeconds(expiresAt) {
|
|
15
|
+
if (!expiresAt) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const ttlSeconds = Math.floor((expiresAt.getTime() - Date.now()) / 1000);
|
|
19
|
+
return ttlSeconds > 0 ? ttlSeconds : null;
|
|
20
|
+
}
|
|
9
21
|
/** @returns User by username (includes password for login). */
|
|
10
22
|
export function findUserByUsername(username) {
|
|
11
23
|
return prisma.user.findFirst({
|
|
@@ -102,18 +114,18 @@ export async function deleteSessionsByUserId(userId) {
|
|
|
102
114
|
where: { userId },
|
|
103
115
|
});
|
|
104
116
|
for (const session of sessions) {
|
|
105
|
-
await getRedis()?.del(
|
|
117
|
+
await getRedis()?.del(getAuthSessionCacheKey(session.id));
|
|
106
118
|
}
|
|
107
119
|
return prisma.session.deleteMany({
|
|
108
120
|
where: { userId },
|
|
109
121
|
});
|
|
110
122
|
}
|
|
111
|
-
/** Delete
|
|
123
|
+
/** Delete password reset sessions expiring before date. */
|
|
112
124
|
export function deleteShortLivedSessionsByUserId(userId, expiresBefore) {
|
|
113
125
|
return prisma.session.deleteMany({
|
|
114
126
|
where: {
|
|
115
127
|
userId,
|
|
116
|
-
|
|
128
|
+
type: SessionType.PASSWORD_RESET,
|
|
117
129
|
expiresAt: { lte: expiresBefore },
|
|
118
130
|
},
|
|
119
131
|
});
|
|
@@ -124,16 +136,16 @@ export function deleteUserById(id) {
|
|
|
124
136
|
where: { id },
|
|
125
137
|
});
|
|
126
138
|
}
|
|
127
|
-
/** @returns Session by ID. */
|
|
128
|
-
export function
|
|
129
|
-
return prisma.session.
|
|
130
|
-
where: { id },
|
|
139
|
+
/** @returns Session by ID and type. */
|
|
140
|
+
export function findSessionByIdAndType(id, type) {
|
|
141
|
+
return prisma.session.findFirst({
|
|
142
|
+
where: { id, type },
|
|
131
143
|
});
|
|
132
144
|
}
|
|
133
|
-
/** @returns Session with user. */
|
|
134
|
-
export function
|
|
135
|
-
return prisma.session.
|
|
136
|
-
where: { id },
|
|
145
|
+
/** @returns Session with user by ID and type. */
|
|
146
|
+
export function findSessionByIdWithUserAndType(id, type) {
|
|
147
|
+
return prisma.session.findFirst({
|
|
148
|
+
where: { id, type },
|
|
137
149
|
include: {
|
|
138
150
|
user: { select: { id: true } },
|
|
139
151
|
},
|
|
@@ -154,34 +166,45 @@ export function updateUserPassword(userId, password) {
|
|
|
154
166
|
});
|
|
155
167
|
}
|
|
156
168
|
/** Delete a session. */
|
|
157
|
-
export function deleteSessionById(id) {
|
|
169
|
+
export async function deleteSessionById(id) {
|
|
170
|
+
await getRedis()?.del(getAuthSessionCacheKey(id));
|
|
158
171
|
return prisma.session.delete({
|
|
159
172
|
where: { id },
|
|
160
173
|
});
|
|
161
174
|
}
|
|
162
|
-
/** @returns User from session token. Checks Redis first, then DB. Caches in Redis. */
|
|
175
|
+
/** @returns User from valid auth session token. Checks Redis first, then DB. Caches in Redis. */
|
|
163
176
|
export async function findUserBySessionToken(token) {
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
const cacheKey = getAuthSessionCacheKey(token);
|
|
178
|
+
const cachedUser = await getRedis()?.get(cacheKey);
|
|
179
|
+
if (cachedUser) {
|
|
180
|
+
return JSON.parse(cachedUser);
|
|
181
|
+
}
|
|
182
|
+
const session = await prisma.session.findFirst({
|
|
168
183
|
where: {
|
|
169
|
-
|
|
184
|
+
id: token,
|
|
185
|
+
type: SessionType.AUTH,
|
|
186
|
+
userId: { not: null },
|
|
187
|
+
expiresAt: { gt: new Date() },
|
|
170
188
|
},
|
|
171
189
|
select: {
|
|
172
|
-
|
|
173
|
-
|
|
190
|
+
expiresAt: true,
|
|
191
|
+
user: {
|
|
192
|
+
select: {
|
|
193
|
+
id: true,
|
|
194
|
+
username: true,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
174
197
|
},
|
|
175
198
|
});
|
|
176
|
-
if (user) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
199
|
+
if (!session?.user) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
const ttlSeconds = getSessionTtlSeconds(session.expiresAt);
|
|
203
|
+
const r = getRedis();
|
|
204
|
+
if (r && ttlSeconds) {
|
|
205
|
+
await r.setex(cacheKey, ttlSeconds, JSON.stringify(session.user));
|
|
183
206
|
}
|
|
184
|
-
return
|
|
207
|
+
return session.user;
|
|
185
208
|
}
|
|
186
209
|
/** @returns Class IDs where user is a teacher. */
|
|
187
210
|
export function findTeacherClassesByUserId(userId) {
|
|
@@ -214,4 +237,4 @@ export function findClassWithTeacher(classId, teacherId) {
|
|
|
214
237
|
});
|
|
215
238
|
}
|
|
216
239
|
//# sourceMappingURL=auth.js.map
|
|
217
|
-
//# debugId=
|
|
240
|
+
//# debugId=caa0301d-42ed-55b1-a0ef-383918fe715a
|