@studious-lms/server 1.14.0 → 1.15.0
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/.github/workflows/deploy.yml +1 -1
- package/dist/instrument.js +3 -3
- package/dist/instrument.js.map +1 -1
- package/dist/lib/inferDocumentFormat.d.ts +10 -0
- package/dist/lib/inferDocumentFormat.d.ts.map +1 -0
- package/dist/lib/inferDocumentFormat.js +48 -0
- package/dist/lib/inferDocumentFormat.js.map +1 -0
- package/dist/lib/legal.d.ts +3 -0
- package/dist/lib/legal.d.ts.map +1 -0
- package/dist/lib/legal.js +6 -0
- package/dist/lib/legal.js.map +1 -0
- package/dist/models/announcement.d.ts +47 -45
- package/dist/models/announcement.d.ts.map +1 -1
- package/dist/models/assignment.d.ts +75 -75
- package/dist/models/auth.d.ts +8 -0
- package/dist/models/auth.d.ts.map +1 -1
- package/dist/models/auth.js +4 -2
- package/dist/models/auth.js.map +1 -1
- package/dist/models/class.d.ts +13 -13
- package/dist/models/comment.d.ts +6 -6
- package/dist/models/conversation.d.ts +23 -23
- package/dist/models/event.d.ts +20 -18
- package/dist/models/event.d.ts.map +1 -1
- package/dist/models/file.d.ts +33 -9
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/labChat.d.ts +4 -4
- package/dist/models/marketing.d.ts +2 -15
- package/dist/models/marketing.d.ts.map +1 -1
- package/dist/models/marketing.js +12 -4
- package/dist/models/marketing.js.map +1 -1
- package/dist/models/message.d.ts +13 -13
- package/dist/models/newtonChat.d.ts +3 -3
- package/dist/models/notification.d.ts +4 -4
- package/dist/models/worksheet.d.ts +121 -121
- package/dist/pipelines/aiLabChat.d.ts +7 -1
- package/dist/pipelines/aiLabChat.d.ts.map +1 -1
- package/dist/pipelines/aiLabChat.js +153 -67
- package/dist/pipelines/aiLabChat.js.map +1 -1
- package/dist/pipelines/aiLabChatContract.d.ts +34 -195
- package/dist/pipelines/aiLabChatContract.d.ts.map +1 -1
- package/dist/pipelines/aiLabChatContract.js +9 -19
- package/dist/pipelines/aiLabChatContract.js.map +1 -1
- package/dist/pipelines/gradeWorksheet.d.ts +6 -6
- package/dist/pipelines/labChatPrompt.d.ts +8 -3
- package/dist/pipelines/labChatPrompt.d.ts.map +1 -1
- package/dist/pipelines/labChatPrompt.js +52 -14
- package/dist/pipelines/labChatPrompt.js.map +1 -1
- package/dist/pipelines/pdfToWorksheet.d.ts +1 -1
- package/dist/routers/_app.d.ts +750 -546
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/announcement.d.ts +40 -40
- package/dist/routers/assignment.d.ts +131 -121
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/auth.d.ts +2 -0
- package/dist/routers/auth.d.ts.map +1 -1
- package/dist/routers/auth.js +15 -2
- package/dist/routers/auth.js.map +1 -1
- package/dist/routers/class.d.ts +12 -8
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/comment.d.ts +5 -5
- package/dist/routers/conversation.d.ts +6 -6
- package/dist/routers/discussion.d.ts +3 -3
- package/dist/routers/embedding.d.ts +6 -2
- package/dist/routers/embedding.d.ts.map +1 -1
- package/dist/routers/embedding.js +44 -36
- package/dist/routers/embedding.js.map +1 -1
- package/dist/routers/event.d.ts +20 -18
- package/dist/routers/event.d.ts.map +1 -1
- package/dist/routers/file.d.ts +2 -2
- package/dist/routers/labChat.d.ts +3 -3
- package/dist/routers/marketing.d.ts +0 -13
- package/dist/routers/marketing.d.ts.map +1 -1
- package/dist/routers/notifications.d.ts +4 -4
- package/dist/routers/school.d.ts +4 -0
- package/dist/routers/school.d.ts.map +1 -1
- package/dist/routers/search.d.ts +2 -2
- package/dist/routers/user.d.ts +89 -0
- package/dist/routers/user.d.ts.map +1 -1
- package/dist/routers/user.js +19 -2
- package/dist/routers/user.js.map +1 -1
- package/dist/routers/worksheet.d.ts +44 -44
- package/dist/routes/aiStream.d.ts.map +1 -1
- package/dist/routes/aiStream.js +41 -11
- package/dist/routes/aiStream.js.map +1 -1
- package/dist/seedDatabase.d.ts +3 -1
- package/dist/seedDatabase.d.ts.map +1 -1
- package/dist/services/aiChatStream.d.ts +20 -0
- package/dist/services/aiChatStream.d.ts.map +1 -1
- package/dist/services/aiChatStream.js +110 -13
- package/dist/services/aiChatStream.js.map +1 -1
- package/dist/services/aiModifierTools.d.ts +0 -16
- package/dist/services/aiModifierTools.d.ts.map +1 -1
- package/dist/services/aiModifierTools.js +112 -3
- package/dist/services/aiModifierTools.js.map +1 -1
- package/dist/services/aiProposalTools.d.ts.map +1 -1
- package/dist/services/aiProposalTools.js +25 -25
- package/dist/services/aiProposalTools.js.map +1 -1
- package/dist/services/aiTools.js +3 -3
- package/dist/services/aiTools.js.map +1 -1
- package/dist/services/announcement.d.ts +34 -34
- package/dist/services/assignment.d.ts +121 -111
- package/dist/services/assignment.d.ts.map +1 -1
- package/dist/services/assignment.js +4 -2
- package/dist/services/assignment.js.map +1 -1
- package/dist/services/auth.d.ts +2 -0
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +13 -4
- package/dist/services/auth.js.map +1 -1
- package/dist/services/class.d.ts +10 -6
- package/dist/services/class.d.ts.map +1 -1
- package/dist/services/class.js +7 -3
- package/dist/services/class.js.map +1 -1
- package/dist/services/comment.d.ts +5 -5
- package/dist/services/conversation.d.ts +6 -6
- package/dist/services/discussion.d.ts.map +1 -1
- package/dist/services/discussion.js +9 -2
- package/dist/services/discussion.js.map +1 -1
- package/dist/services/embedding.d.ts +19 -1
- package/dist/services/embedding.d.ts.map +1 -1
- package/dist/services/embedding.js +154 -8
- package/dist/services/embedding.js.map +1 -1
- package/dist/services/event.d.ts +20 -18
- package/dist/services/event.d.ts.map +1 -1
- package/dist/services/file.d.ts +4 -4
- package/dist/services/folder.d.ts.map +1 -1
- package/dist/services/folder.js +32 -2
- package/dist/services/folder.js.map +1 -1
- package/dist/services/labChat.d.ts +3 -3
- package/dist/services/marketing.d.ts +1 -14
- package/dist/services/marketing.d.ts.map +1 -1
- package/dist/services/marketing.js +5 -5
- package/dist/services/marketing.js.map +1 -1
- package/dist/services/notification.d.ts +4 -4
- package/dist/services/openaiDocumentGen.d.ts +37 -0
- package/dist/services/openaiDocumentGen.d.ts.map +1 -0
- package/dist/services/openaiDocumentGen.js +262 -0
- package/dist/services/openaiDocumentGen.js.map +1 -0
- package/dist/services/school.d.ts +4 -0
- package/dist/services/school.d.ts.map +1 -1
- package/dist/services/search.d.ts +1 -1
- package/dist/services/search.d.ts.map +1 -1
- package/dist/services/search.js +27 -2
- package/dist/services/search.js.map +1 -1
- package/dist/services/userPrivacy.d.ts +86 -0
- package/dist/services/userPrivacy.d.ts.map +1 -0
- package/dist/services/userPrivacy.js +184 -0
- package/dist/services/userPrivacy.js.map +1 -0
- package/dist/services/worksheet.d.ts +66 -49
- package/dist/services/worksheet.d.ts.map +1 -1
- package/dist/services/worksheet.js +48 -3
- package/dist/services/worksheet.js.map +1 -1
- package/dist/utils/email.d.ts.map +1 -1
- package/dist/utils/email.js +7 -3
- package/dist/utils/email.js.map +1 -1
- package/dist/workers/processors/embedContent.d.ts.map +1 -1
- package/dist/workers/processors/embedContent.js +16 -25
- package/dist/workers/processors/embedContent.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260610140000_expand_embedding_source_types/migration.sql +4 -0
- package/prisma/migrations/20260611120000_add_user_terms_acceptance/migration.sql +3 -0
- package/prisma/schema.prisma +6 -0
- package/src/instrument.ts +1 -1
- package/src/lib/inferDocumentFormat.ts +58 -0
- package/src/lib/legal.ts +2 -0
- package/src/models/auth.ts +4 -0
- package/src/models/marketing.ts +10 -2
- package/src/pipelines/aiLabChat.ts +198 -74
- package/src/pipelines/aiLabChatContract.ts +7 -17
- package/src/pipelines/labChatPrompt.ts +64 -14
- package/src/routers/auth.ts +13 -0
- package/src/routers/embedding.ts +44 -39
- package/src/routers/user.ts +26 -0
- package/src/routes/aiStream.ts +47 -9
- package/src/services/aiChatStream.ts +133 -11
- package/src/services/aiModifierTools.ts +154 -1
- package/src/services/aiProposalTools.ts +27 -25
- package/src/services/aiTools.ts +1 -1
- package/src/services/assignment.ts +3 -0
- package/src/services/auth.ts +14 -2
- package/src/services/class.ts +7 -1
- package/src/services/discussion.ts +13 -0
- package/src/services/embedding.ts +167 -6
- package/src/services/folder.ts +31 -0
- package/src/services/marketing.ts +3 -3
- package/src/services/openaiDocumentGen.ts +319 -0
- package/src/services/search.ts +25 -1
- package/src/services/userPrivacy.ts +196 -0
- package/src/services/worksheet.ts +68 -1
- package/src/utils/email.ts +5 -1
- package/src/workers/processors/embedContent.ts +18 -22
- package/tests/helpers/registerInput.ts +20 -0
- package/tests/integration/globalSetup.ts +10 -18
- package/tests/integration/routers/auth.test.ts +13 -18
- package/tests/unit/lib/inferDocumentFormat.test.ts +33 -0
- package/tests/unit/services/aiChatStream.test.ts +92 -0
- package/tests/unit/services/openaiDocumentGen.test.ts +65 -0
|
@@ -101,10 +101,6 @@ export declare function findAssignmentWithDetails(id: string): import("@prisma/c
|
|
|
101
101
|
id: string;
|
|
102
102
|
name: string;
|
|
103
103
|
}[];
|
|
104
|
-
teacher: {
|
|
105
|
-
id: string;
|
|
106
|
-
username: string;
|
|
107
|
-
};
|
|
108
104
|
attachments: {
|
|
109
105
|
path: string;
|
|
110
106
|
type: string;
|
|
@@ -114,6 +110,10 @@ export declare function findAssignmentWithDetails(id: string): import("@prisma/c
|
|
|
114
110
|
uploadedAt: Date | null;
|
|
115
111
|
thumbnailId: string | null;
|
|
116
112
|
}[];
|
|
113
|
+
teacher: {
|
|
114
|
+
id: string;
|
|
115
|
+
username: string;
|
|
116
|
+
};
|
|
117
117
|
eventAttached: {
|
|
118
118
|
id: string;
|
|
119
119
|
location: string | null;
|
|
@@ -189,6 +189,7 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
189
189
|
submissionId: string | null;
|
|
190
190
|
thumbnailId: string | null;
|
|
191
191
|
annotationId: string | null;
|
|
192
|
+
conversationId: string | null;
|
|
192
193
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
193
194
|
uploadUrl: string | null;
|
|
194
195
|
uploadExpiresAt: Date | null;
|
|
@@ -200,7 +201,6 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
200
201
|
cleanupAt: Date | null;
|
|
201
202
|
classDraftId: string | null;
|
|
202
203
|
folderId: string | null;
|
|
203
|
-
conversationId: string | null;
|
|
204
204
|
messageId: string | null;
|
|
205
205
|
announcementId: string | null;
|
|
206
206
|
discussionId: string | null;
|
|
@@ -219,6 +219,7 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
219
219
|
submissionId: string | null;
|
|
220
220
|
thumbnailId: string | null;
|
|
221
221
|
annotationId: string | null;
|
|
222
|
+
conversationId: string | null;
|
|
222
223
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
223
224
|
uploadUrl: string | null;
|
|
224
225
|
uploadExpiresAt: Date | null;
|
|
@@ -230,7 +231,6 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
230
231
|
cleanupAt: Date | null;
|
|
231
232
|
classDraftId: string | null;
|
|
232
233
|
folderId: string | null;
|
|
233
|
-
conversationId: string | null;
|
|
234
234
|
messageId: string | null;
|
|
235
235
|
announcementId: string | null;
|
|
236
236
|
discussionId: string | null;
|
|
@@ -250,6 +250,7 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
250
250
|
submissionId: string | null;
|
|
251
251
|
thumbnailId: string | null;
|
|
252
252
|
annotationId: string | null;
|
|
253
|
+
conversationId: string | null;
|
|
253
254
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
254
255
|
uploadUrl: string | null;
|
|
255
256
|
uploadExpiresAt: Date | null;
|
|
@@ -261,7 +262,6 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
261
262
|
cleanupAt: Date | null;
|
|
262
263
|
classDraftId: string | null;
|
|
263
264
|
folderId: string | null;
|
|
264
|
-
conversationId: string | null;
|
|
265
265
|
messageId: string | null;
|
|
266
266
|
announcementId: string | null;
|
|
267
267
|
discussionId: string | null;
|
|
@@ -280,6 +280,7 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
280
280
|
submissionId: string | null;
|
|
281
281
|
thumbnailId: string | null;
|
|
282
282
|
annotationId: string | null;
|
|
283
|
+
conversationId: string | null;
|
|
283
284
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
284
285
|
uploadUrl: string | null;
|
|
285
286
|
uploadExpiresAt: Date | null;
|
|
@@ -291,7 +292,6 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
291
292
|
cleanupAt: Date | null;
|
|
292
293
|
classDraftId: string | null;
|
|
293
294
|
folderId: string | null;
|
|
294
|
-
conversationId: string | null;
|
|
295
295
|
messageId: string | null;
|
|
296
296
|
announcementId: string | null;
|
|
297
297
|
discussionId: string | null;
|
|
@@ -302,8 +302,8 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
302
302
|
id: string;
|
|
303
303
|
createdAt: Date;
|
|
304
304
|
assignmentId: string;
|
|
305
|
-
modifiedAt: Date;
|
|
306
305
|
studentId: string;
|
|
306
|
+
modifiedAt: Date;
|
|
307
307
|
extendedResponse: string | null;
|
|
308
308
|
gradeReceived: number | null;
|
|
309
309
|
recommendationState: import(".prisma/client").$Enums.SubmissionRecommendationState;
|
|
@@ -328,6 +328,7 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
328
328
|
submissionId: string | null;
|
|
329
329
|
thumbnailId: string | null;
|
|
330
330
|
annotationId: string | null;
|
|
331
|
+
conversationId: string | null;
|
|
331
332
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
332
333
|
uploadUrl: string | null;
|
|
333
334
|
uploadExpiresAt: Date | null;
|
|
@@ -339,7 +340,6 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
339
340
|
cleanupAt: Date | null;
|
|
340
341
|
classDraftId: string | null;
|
|
341
342
|
folderId: string | null;
|
|
342
|
-
conversationId: string | null;
|
|
343
343
|
messageId: string | null;
|
|
344
344
|
announcementId: string | null;
|
|
345
345
|
discussionId: string | null;
|
|
@@ -358,6 +358,7 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
358
358
|
submissionId: string | null;
|
|
359
359
|
thumbnailId: string | null;
|
|
360
360
|
annotationId: string | null;
|
|
361
|
+
conversationId: string | null;
|
|
361
362
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
362
363
|
uploadUrl: string | null;
|
|
363
364
|
uploadExpiresAt: Date | null;
|
|
@@ -369,7 +370,6 @@ export declare function findAssignmentForDelete(id: string, teacherId: string):
|
|
|
369
370
|
cleanupAt: Date | null;
|
|
370
371
|
classDraftId: string | null;
|
|
371
372
|
folderId: string | null;
|
|
372
|
-
conversationId: string | null;
|
|
373
373
|
messageId: string | null;
|
|
374
374
|
announcementId: string | null;
|
|
375
375
|
discussionId: string | null;
|
|
@@ -505,6 +505,7 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
505
505
|
submissionId: string | null;
|
|
506
506
|
thumbnailId: string | null;
|
|
507
507
|
annotationId: string | null;
|
|
508
|
+
conversationId: string | null;
|
|
508
509
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
509
510
|
uploadUrl: string | null;
|
|
510
511
|
uploadExpiresAt: Date | null;
|
|
@@ -516,29 +517,12 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
516
517
|
cleanupAt: Date | null;
|
|
517
518
|
classDraftId: string | null;
|
|
518
519
|
folderId: string | null;
|
|
519
|
-
conversationId: string | null;
|
|
520
520
|
messageId: string | null;
|
|
521
521
|
announcementId: string | null;
|
|
522
522
|
discussionId: string | null;
|
|
523
523
|
discussionReplyId: string | null;
|
|
524
524
|
schoolDevelopementProgramId: string | null;
|
|
525
525
|
}[];
|
|
526
|
-
student: {
|
|
527
|
-
id: string;
|
|
528
|
-
username: string;
|
|
529
|
-
profile: {
|
|
530
|
-
id: string;
|
|
531
|
-
userId: string;
|
|
532
|
-
displayName: string | null;
|
|
533
|
-
bio: string | null;
|
|
534
|
-
location: string | null;
|
|
535
|
-
website: string | null;
|
|
536
|
-
createdAt: Date;
|
|
537
|
-
updatedAt: Date;
|
|
538
|
-
profilePicture: string | null;
|
|
539
|
-
profilePictureThumbnail: string | null;
|
|
540
|
-
} | null;
|
|
541
|
-
};
|
|
542
526
|
annotations: {
|
|
543
527
|
path: string;
|
|
544
528
|
type: string;
|
|
@@ -551,6 +535,7 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
551
535
|
submissionId: string | null;
|
|
552
536
|
thumbnailId: string | null;
|
|
553
537
|
annotationId: string | null;
|
|
538
|
+
conversationId: string | null;
|
|
554
539
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
555
540
|
uploadUrl: string | null;
|
|
556
541
|
uploadExpiresAt: Date | null;
|
|
@@ -562,19 +547,34 @@ export declare function findSubmissionByAssignmentAndStudent(assignmentId: strin
|
|
|
562
547
|
cleanupAt: Date | null;
|
|
563
548
|
classDraftId: string | null;
|
|
564
549
|
folderId: string | null;
|
|
565
|
-
conversationId: string | null;
|
|
566
550
|
messageId: string | null;
|
|
567
551
|
announcementId: string | null;
|
|
568
552
|
discussionId: string | null;
|
|
569
553
|
discussionReplyId: string | null;
|
|
570
554
|
schoolDevelopementProgramId: string | null;
|
|
571
555
|
}[];
|
|
556
|
+
student: {
|
|
557
|
+
id: string;
|
|
558
|
+
username: string;
|
|
559
|
+
profile: {
|
|
560
|
+
id: string;
|
|
561
|
+
userId: string;
|
|
562
|
+
displayName: string | null;
|
|
563
|
+
bio: string | null;
|
|
564
|
+
location: string | null;
|
|
565
|
+
website: string | null;
|
|
566
|
+
createdAt: Date;
|
|
567
|
+
updatedAt: Date;
|
|
568
|
+
profilePicture: string | null;
|
|
569
|
+
profilePictureThumbnail: string | null;
|
|
570
|
+
} | null;
|
|
571
|
+
};
|
|
572
572
|
} & {
|
|
573
573
|
id: string;
|
|
574
574
|
createdAt: Date;
|
|
575
575
|
assignmentId: string;
|
|
576
|
-
modifiedAt: Date;
|
|
577
576
|
studentId: string;
|
|
577
|
+
modifiedAt: Date;
|
|
578
578
|
extendedResponse: string | null;
|
|
579
579
|
gradeReceived: number | null;
|
|
580
580
|
recommendationState: import(".prisma/client").$Enums.SubmissionRecommendationState;
|
|
@@ -676,6 +676,7 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
676
676
|
submissionId: string | null;
|
|
677
677
|
thumbnailId: string | null;
|
|
678
678
|
annotationId: string | null;
|
|
679
|
+
conversationId: string | null;
|
|
679
680
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
680
681
|
uploadUrl: string | null;
|
|
681
682
|
uploadExpiresAt: Date | null;
|
|
@@ -687,29 +688,12 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
687
688
|
cleanupAt: Date | null;
|
|
688
689
|
classDraftId: string | null;
|
|
689
690
|
folderId: string | null;
|
|
690
|
-
conversationId: string | null;
|
|
691
691
|
messageId: string | null;
|
|
692
692
|
announcementId: string | null;
|
|
693
693
|
discussionId: string | null;
|
|
694
694
|
discussionReplyId: string | null;
|
|
695
695
|
schoolDevelopementProgramId: string | null;
|
|
696
696
|
}[];
|
|
697
|
-
student: {
|
|
698
|
-
id: string;
|
|
699
|
-
username: string;
|
|
700
|
-
profile: {
|
|
701
|
-
id: string;
|
|
702
|
-
userId: string;
|
|
703
|
-
displayName: string | null;
|
|
704
|
-
bio: string | null;
|
|
705
|
-
location: string | null;
|
|
706
|
-
website: string | null;
|
|
707
|
-
createdAt: Date;
|
|
708
|
-
updatedAt: Date;
|
|
709
|
-
profilePicture: string | null;
|
|
710
|
-
profilePictureThumbnail: string | null;
|
|
711
|
-
} | null;
|
|
712
|
-
};
|
|
713
697
|
annotations: {
|
|
714
698
|
path: string;
|
|
715
699
|
type: string;
|
|
@@ -722,6 +706,7 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
722
706
|
submissionId: string | null;
|
|
723
707
|
thumbnailId: string | null;
|
|
724
708
|
annotationId: string | null;
|
|
709
|
+
conversationId: string | null;
|
|
725
710
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
726
711
|
uploadUrl: string | null;
|
|
727
712
|
uploadExpiresAt: Date | null;
|
|
@@ -733,19 +718,34 @@ export declare function findSubmissionByIdForClassMember(submissionId: string, c
|
|
|
733
718
|
cleanupAt: Date | null;
|
|
734
719
|
classDraftId: string | null;
|
|
735
720
|
folderId: string | null;
|
|
736
|
-
conversationId: string | null;
|
|
737
721
|
messageId: string | null;
|
|
738
722
|
announcementId: string | null;
|
|
739
723
|
discussionId: string | null;
|
|
740
724
|
discussionReplyId: string | null;
|
|
741
725
|
schoolDevelopementProgramId: string | null;
|
|
742
726
|
}[];
|
|
727
|
+
student: {
|
|
728
|
+
id: string;
|
|
729
|
+
username: string;
|
|
730
|
+
profile: {
|
|
731
|
+
id: string;
|
|
732
|
+
userId: string;
|
|
733
|
+
displayName: string | null;
|
|
734
|
+
bio: string | null;
|
|
735
|
+
location: string | null;
|
|
736
|
+
website: string | null;
|
|
737
|
+
createdAt: Date;
|
|
738
|
+
updatedAt: Date;
|
|
739
|
+
profilePicture: string | null;
|
|
740
|
+
profilePictureThumbnail: string | null;
|
|
741
|
+
} | null;
|
|
742
|
+
};
|
|
743
743
|
} & {
|
|
744
744
|
id: string;
|
|
745
745
|
createdAt: Date;
|
|
746
746
|
assignmentId: string;
|
|
747
|
-
modifiedAt: Date;
|
|
748
747
|
studentId: string;
|
|
748
|
+
modifiedAt: Date;
|
|
749
749
|
extendedResponse: string | null;
|
|
750
750
|
gradeReceived: number | null;
|
|
751
751
|
recommendationState: import(".prisma/client").$Enums.SubmissionRecommendationState;
|
|
@@ -844,6 +844,7 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
844
844
|
submissionId: string | null;
|
|
845
845
|
thumbnailId: string | null;
|
|
846
846
|
annotationId: string | null;
|
|
847
|
+
conversationId: string | null;
|
|
847
848
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
848
849
|
uploadUrl: string | null;
|
|
849
850
|
uploadExpiresAt: Date | null;
|
|
@@ -855,7 +856,6 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
855
856
|
cleanupAt: Date | null;
|
|
856
857
|
classDraftId: string | null;
|
|
857
858
|
folderId: string | null;
|
|
858
|
-
conversationId: string | null;
|
|
859
859
|
messageId: string | null;
|
|
860
860
|
announcementId: string | null;
|
|
861
861
|
discussionId: string | null;
|
|
@@ -874,6 +874,7 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
874
874
|
submissionId: string | null;
|
|
875
875
|
thumbnailId: string | null;
|
|
876
876
|
annotationId: string | null;
|
|
877
|
+
conversationId: string | null;
|
|
877
878
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
878
879
|
uploadUrl: string | null;
|
|
879
880
|
uploadExpiresAt: Date | null;
|
|
@@ -885,7 +886,6 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
885
886
|
cleanupAt: Date | null;
|
|
886
887
|
classDraftId: string | null;
|
|
887
888
|
folderId: string | null;
|
|
888
|
-
conversationId: string | null;
|
|
889
889
|
messageId: string | null;
|
|
890
890
|
announcementId: string | null;
|
|
891
891
|
discussionId: string | null;
|
|
@@ -896,8 +896,8 @@ export declare function findSubmissionForUpdate(submissionId: string, userId: st
|
|
|
896
896
|
id: string;
|
|
897
897
|
createdAt: Date;
|
|
898
898
|
assignmentId: string;
|
|
899
|
-
modifiedAt: Date;
|
|
900
899
|
studentId: string;
|
|
900
|
+
modifiedAt: Date;
|
|
901
901
|
extendedResponse: string | null;
|
|
902
902
|
gradeReceived: number | null;
|
|
903
903
|
recommendationState: import(".prisma/client").$Enums.SubmissionRecommendationState;
|
|
@@ -999,6 +999,7 @@ export declare function createSubmission(assignmentId: string, studentId: string
|
|
|
999
999
|
submissionId: string | null;
|
|
1000
1000
|
thumbnailId: string | null;
|
|
1001
1001
|
annotationId: string | null;
|
|
1002
|
+
conversationId: string | null;
|
|
1002
1003
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1003
1004
|
uploadUrl: string | null;
|
|
1004
1005
|
uploadExpiresAt: Date | null;
|
|
@@ -1010,17 +1011,12 @@ export declare function createSubmission(assignmentId: string, studentId: string
|
|
|
1010
1011
|
cleanupAt: Date | null;
|
|
1011
1012
|
classDraftId: string | null;
|
|
1012
1013
|
folderId: string | null;
|
|
1013
|
-
conversationId: string | null;
|
|
1014
1014
|
messageId: string | null;
|
|
1015
1015
|
announcementId: string | null;
|
|
1016
1016
|
discussionId: string | null;
|
|
1017
1017
|
discussionReplyId: string | null;
|
|
1018
1018
|
schoolDevelopementProgramId: string | null;
|
|
1019
1019
|
}[];
|
|
1020
|
-
student: {
|
|
1021
|
-
id: string;
|
|
1022
|
-
username: string;
|
|
1023
|
-
};
|
|
1024
1020
|
annotations: {
|
|
1025
1021
|
path: string;
|
|
1026
1022
|
type: string;
|
|
@@ -1033,6 +1029,7 @@ export declare function createSubmission(assignmentId: string, studentId: string
|
|
|
1033
1029
|
submissionId: string | null;
|
|
1034
1030
|
thumbnailId: string | null;
|
|
1035
1031
|
annotationId: string | null;
|
|
1032
|
+
conversationId: string | null;
|
|
1036
1033
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1037
1034
|
uploadUrl: string | null;
|
|
1038
1035
|
uploadExpiresAt: Date | null;
|
|
@@ -1044,19 +1041,22 @@ export declare function createSubmission(assignmentId: string, studentId: string
|
|
|
1044
1041
|
cleanupAt: Date | null;
|
|
1045
1042
|
classDraftId: string | null;
|
|
1046
1043
|
folderId: string | null;
|
|
1047
|
-
conversationId: string | null;
|
|
1048
1044
|
messageId: string | null;
|
|
1049
1045
|
announcementId: string | null;
|
|
1050
1046
|
discussionId: string | null;
|
|
1051
1047
|
discussionReplyId: string | null;
|
|
1052
1048
|
schoolDevelopementProgramId: string | null;
|
|
1053
1049
|
}[];
|
|
1050
|
+
student: {
|
|
1051
|
+
id: string;
|
|
1052
|
+
username: string;
|
|
1053
|
+
};
|
|
1054
1054
|
} & {
|
|
1055
1055
|
id: string;
|
|
1056
1056
|
createdAt: Date;
|
|
1057
1057
|
assignmentId: string;
|
|
1058
|
-
modifiedAt: Date;
|
|
1059
1058
|
studentId: string;
|
|
1059
|
+
modifiedAt: Date;
|
|
1060
1060
|
extendedResponse: string | null;
|
|
1061
1061
|
gradeReceived: number | null;
|
|
1062
1062
|
recommendationState: import(".prisma/client").$Enums.SubmissionRecommendationState;
|
|
@@ -1233,6 +1233,7 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
1233
1233
|
submissionId: string | null;
|
|
1234
1234
|
thumbnailId: string | null;
|
|
1235
1235
|
annotationId: string | null;
|
|
1236
|
+
conversationId: string | null;
|
|
1236
1237
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1237
1238
|
uploadUrl: string | null;
|
|
1238
1239
|
uploadExpiresAt: Date | null;
|
|
@@ -1244,7 +1245,6 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
1244
1245
|
cleanupAt: Date | null;
|
|
1245
1246
|
classDraftId: string | null;
|
|
1246
1247
|
folderId: string | null;
|
|
1247
|
-
conversationId: string | null;
|
|
1248
1248
|
messageId: string | null;
|
|
1249
1249
|
announcementId: string | null;
|
|
1250
1250
|
discussionId: string | null;
|
|
@@ -1263,6 +1263,7 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
1263
1263
|
submissionId: string | null;
|
|
1264
1264
|
thumbnailId: string | null;
|
|
1265
1265
|
annotationId: string | null;
|
|
1266
|
+
conversationId: string | null;
|
|
1266
1267
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1267
1268
|
uploadUrl: string | null;
|
|
1268
1269
|
uploadExpiresAt: Date | null;
|
|
@@ -1274,7 +1275,6 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
1274
1275
|
cleanupAt: Date | null;
|
|
1275
1276
|
classDraftId: string | null;
|
|
1276
1277
|
folderId: string | null;
|
|
1277
|
-
conversationId: string | null;
|
|
1278
1278
|
messageId: string | null;
|
|
1279
1279
|
announcementId: string | null;
|
|
1280
1280
|
discussionId: string | null;
|
|
@@ -1294,8 +1294,8 @@ export declare function findSubmissionsByAssignmentForTeacher(assignmentId: stri
|
|
|
1294
1294
|
id: string;
|
|
1295
1295
|
createdAt: Date;
|
|
1296
1296
|
assignmentId: string;
|
|
1297
|
-
modifiedAt: Date;
|
|
1298
1297
|
studentId: string;
|
|
1298
|
+
modifiedAt: Date;
|
|
1299
1299
|
extendedResponse: string | null;
|
|
1300
1300
|
gradeReceived: number | null;
|
|
1301
1301
|
recommendationState: import(".prisma/client").$Enums.SubmissionRecommendationState;
|
|
@@ -1394,6 +1394,7 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1394
1394
|
submissionId: string | null;
|
|
1395
1395
|
thumbnailId: string | null;
|
|
1396
1396
|
annotationId: string | null;
|
|
1397
|
+
conversationId: string | null;
|
|
1397
1398
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1398
1399
|
uploadUrl: string | null;
|
|
1399
1400
|
uploadExpiresAt: Date | null;
|
|
@@ -1405,7 +1406,6 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1405
1406
|
cleanupAt: Date | null;
|
|
1406
1407
|
classDraftId: string | null;
|
|
1407
1408
|
folderId: string | null;
|
|
1408
|
-
conversationId: string | null;
|
|
1409
1409
|
messageId: string | null;
|
|
1410
1410
|
announcementId: string | null;
|
|
1411
1411
|
discussionId: string | null;
|
|
@@ -1424,6 +1424,7 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1424
1424
|
submissionId: string | null;
|
|
1425
1425
|
thumbnailId: string | null;
|
|
1426
1426
|
annotationId: string | null;
|
|
1427
|
+
conversationId: string | null;
|
|
1427
1428
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1428
1429
|
uploadUrl: string | null;
|
|
1429
1430
|
uploadExpiresAt: Date | null;
|
|
@@ -1435,7 +1436,6 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1435
1436
|
cleanupAt: Date | null;
|
|
1436
1437
|
classDraftId: string | null;
|
|
1437
1438
|
folderId: string | null;
|
|
1438
|
-
conversationId: string | null;
|
|
1439
1439
|
messageId: string | null;
|
|
1440
1440
|
announcementId: string | null;
|
|
1441
1441
|
discussionId: string | null;
|
|
@@ -1455,6 +1455,7 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1455
1455
|
submissionId: string | null;
|
|
1456
1456
|
thumbnailId: string | null;
|
|
1457
1457
|
annotationId: string | null;
|
|
1458
|
+
conversationId: string | null;
|
|
1458
1459
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1459
1460
|
uploadUrl: string | null;
|
|
1460
1461
|
uploadExpiresAt: Date | null;
|
|
@@ -1466,7 +1467,6 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1466
1467
|
cleanupAt: Date | null;
|
|
1467
1468
|
classDraftId: string | null;
|
|
1468
1469
|
folderId: string | null;
|
|
1469
|
-
conversationId: string | null;
|
|
1470
1470
|
messageId: string | null;
|
|
1471
1471
|
announcementId: string | null;
|
|
1472
1472
|
discussionId: string | null;
|
|
@@ -1485,6 +1485,7 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1485
1485
|
submissionId: string | null;
|
|
1486
1486
|
thumbnailId: string | null;
|
|
1487
1487
|
annotationId: string | null;
|
|
1488
|
+
conversationId: string | null;
|
|
1488
1489
|
uploadStatus: import(".prisma/client").$Enums.UploadStatus;
|
|
1489
1490
|
uploadUrl: string | null;
|
|
1490
1491
|
uploadExpiresAt: Date | null;
|
|
@@ -1496,7 +1497,6 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1496
1497
|
cleanupAt: Date | null;
|
|
1497
1498
|
classDraftId: string | null;
|
|
1498
1499
|
folderId: string | null;
|
|
1499
|
-
conversationId: string | null;
|
|
1500
1500
|
messageId: string | null;
|
|
1501
1501
|
announcementId: string | null;
|
|
1502
1502
|
discussionId: string | null;
|
|
@@ -1507,8 +1507,8 @@ export declare function findSubmissionForTeacherUpdate(submissionId: string, tea
|
|
|
1507
1507
|
id: string;
|
|
1508
1508
|
createdAt: Date;
|
|
1509
1509
|
assignmentId: string;
|
|
1510
|
-
modifiedAt: Date;
|
|
1511
1510
|
studentId: string;
|
|
1511
|
+
modifiedAt: Date;
|
|
1512
1512
|
extendedResponse: string | null;
|
|
1513
1513
|
gradeReceived: number | null;
|
|
1514
1514
|
recommendationState: import(".prisma/client").$Enums.SubmissionRecommendationState;
|
|
@@ -1560,15 +1560,15 @@ export declare function attachAssignmentToEvent(assignmentId: string, eventId: s
|
|
|
1560
1560
|
id: string;
|
|
1561
1561
|
name: string;
|
|
1562
1562
|
} | null;
|
|
1563
|
-
teacher: {
|
|
1564
|
-
id: string;
|
|
1565
|
-
username: string;
|
|
1566
|
-
};
|
|
1567
1563
|
attachments: {
|
|
1568
1564
|
type: string;
|
|
1569
1565
|
id: string;
|
|
1570
1566
|
name: string;
|
|
1571
1567
|
}[];
|
|
1568
|
+
teacher: {
|
|
1569
|
+
id: string;
|
|
1570
|
+
username: string;
|
|
1571
|
+
};
|
|
1572
1572
|
eventAttached: {
|
|
1573
1573
|
id: string;
|
|
1574
1574
|
name: string | null;
|
|
@@ -1632,15 +1632,15 @@ export declare function detachAssignmentFromEvent(assignmentId: string): import(
|
|
|
1632
1632
|
id: string;
|
|
1633
1633
|
name: string;
|
|
1634
1634
|
} | null;
|
|
1635
|
-
teacher: {
|
|
1636
|
-
id: string;
|
|
1637
|
-
username: string;
|
|
1638
|
-
};
|
|
1639
1635
|
attachments: {
|
|
1640
1636
|
type: string;
|
|
1641
1637
|
id: string;
|
|
1642
1638
|
name: string;
|
|
1643
1639
|
}[];
|
|
1640
|
+
teacher: {
|
|
1641
|
+
id: string;
|
|
1642
|
+
username: string;
|
|
1643
|
+
};
|
|
1644
1644
|
eventAttached: {
|
|
1645
1645
|
id: string;
|
|
1646
1646
|
name: string | null;
|
package/dist/models/auth.d.ts
CHANGED
|
@@ -146,6 +146,8 @@ export declare function createUser(data: {
|
|
|
146
146
|
email: string;
|
|
147
147
|
password: string;
|
|
148
148
|
verified?: boolean;
|
|
149
|
+
termsAcceptedAt?: Date;
|
|
150
|
+
termsVersion?: string;
|
|
149
151
|
}): import("@prisma/client/runtime/library.js").DynamicModelExtensionFluentApi<import(".prisma/client").Prisma.TypeMap<import("@prisma/client/runtime/library.js").InternalArgs & {
|
|
150
152
|
result: {
|
|
151
153
|
userProfile: {
|
|
@@ -249,6 +251,8 @@ export declare function deleteUserById(id: string): import("@prisma/client/runti
|
|
|
249
251
|
email: string;
|
|
250
252
|
password: string;
|
|
251
253
|
verified: boolean;
|
|
254
|
+
termsAcceptedAt: Date | null;
|
|
255
|
+
termsVersion: string | null;
|
|
252
256
|
schoolId: string | null;
|
|
253
257
|
}>;
|
|
254
258
|
/** @returns Session by ID and type. */
|
|
@@ -352,6 +356,8 @@ export declare function updateUserVerified(userId: string, verified: boolean): i
|
|
|
352
356
|
email: string;
|
|
353
357
|
password: string;
|
|
354
358
|
verified: boolean;
|
|
359
|
+
termsAcceptedAt: Date | null;
|
|
360
|
+
termsVersion: string | null;
|
|
355
361
|
schoolId: string | null;
|
|
356
362
|
}>;
|
|
357
363
|
/** Update user password. */
|
|
@@ -385,6 +391,8 @@ export declare function updateUserPassword(userId: string, password: string): im
|
|
|
385
391
|
email: string;
|
|
386
392
|
password: string;
|
|
387
393
|
verified: boolean;
|
|
394
|
+
termsAcceptedAt: Date | null;
|
|
395
|
+
termsVersion: string | null;
|
|
388
396
|
schoolId: string | null;
|
|
389
397
|
}>;
|
|
390
398
|
/** Delete a session. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"/","sources":["models/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAuB7C,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAWlD;AAED,0CAA0C;AAC1C,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAYxE;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiB5C;AAED,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmBtC;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;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"/","sources":["models/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAuB7C,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAWlD;AAED,0CAA0C;AAC1C,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;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EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAO3E;AAED,gCAAgC;AAChC,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKnE;AAED,4BAA4B;AAC5B,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKlE;AAED,wBAAwB;AACxB,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,MAAM;;;;;;;GAKjD;AAED,iGAAiG;AACjG,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,MAAM,gBAqCzD;AAED,kDAAkD;AAClD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM;;KAKxD;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOlE;AAED,2DAA2D;AAC3D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOtE"}
|
package/dist/models/auth.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* findUserBySessionToken checks Redis first, then DB.
|
|
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]="1f454e5f-571d-5200-843d-700eec8d74e3")}catch(e){}}();
|
|
7
7
|
import { SessionType } from "@prisma/client";
|
|
8
8
|
import { getRedis } from "../lib/redis.js";
|
|
9
9
|
import { prisma } from "../lib/prisma.js";
|
|
@@ -94,6 +94,8 @@ export function createUser(data) {
|
|
|
94
94
|
email: data.email,
|
|
95
95
|
password: data.password,
|
|
96
96
|
verified: data.verified ?? false,
|
|
97
|
+
termsAcceptedAt: data.termsAcceptedAt,
|
|
98
|
+
termsVersion: data.termsVersion,
|
|
97
99
|
profile: { create: {} },
|
|
98
100
|
},
|
|
99
101
|
select: {
|
|
@@ -233,4 +235,4 @@ export function findClassWithTeacher(classId, teacherId) {
|
|
|
233
235
|
});
|
|
234
236
|
}
|
|
235
237
|
//# sourceMappingURL=auth.js.map
|
|
236
|
-
//# debugId=
|
|
238
|
+
//# debugId=1f454e5f-571d-5200-843d-700eec8d74e3
|
package/dist/models/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sources":["models/auth.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Auth model – user lookup, session CRUD, Redis session cache.\n * findUserBySessionToken checks Redis first, then DB.\n */\nimport { SessionType } from \"@prisma/client\";\nimport { getRedis } from \"../lib/redis.js\";\nimport { prisma } from \"../lib/prisma.js\";\nimport {\n classMemberOrSchoolAdminWhere,\n classTeacherOrSchoolAdminWhere,\n} from \"./access.js\";\n\nconst AUTH_SESSION_CACHE_PREFIX = \"auth-session:\";\n\nfunction getAuthSessionCacheKey(token: string) {\n return `${AUTH_SESSION_CACHE_PREFIX}${token}`;\n}\n\nfunction getSessionTtlSeconds(expiresAt?: Date | null) {\n if (!expiresAt) {\n return null;\n }\n\n const ttlSeconds = Math.floor((expiresAt.getTime() - Date.now()) / 1000);\n return ttlSeconds > 0 ? ttlSeconds : null;\n}\n\n/** @returns User by username (includes password for login). */\nexport function findUserByUsername(username: string) {\n return prisma.user.findFirst({\n where: { username },\n select: {\n id: true,\n username: true,\n password: true,\n email: true,\n verified: true,\n },\n });\n}\n\n/** @returns User by username or email. */\nexport function findUserByUsernameOrEmail(username: string, email: string) {\n return prisma.user.findFirst({\n where: {\n OR: [{ username }, { email }],\n },\n select: {\n id: true,\n username: true,\n email: true,\n verified: true,\n },\n });\n}\n\n/** @returns User by email with profile. */\nexport function findUserByEmail(email: string) {\n return prisma.user.findFirst({\n where: { email },\n select: {\n id: true,\n email: true,\n profile: {\n select: {\n displayName: true,\n bio: true,\n location: true,\n website: true,\n profilePicture: true,\n },\n },\n },\n });\n}\n\n/** @returns User by ID with profile. */\nexport function findUserById(id: string) {\n return prisma.user.findUnique({\n where: { id },\n select: {\n id: true,\n username: true,\n email: true,\n profile: {\n select: {\n displayName: true,\n bio: true,\n location: true,\n website: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n });\n}\n\n/** Create a user with empty profile. */\nexport function createUser(data: {\n username: string;\n email: string;\n password: string;\n verified?: boolean;\n}) {\n return prisma.user.create({\n data: {\n username: data.username,\n email: data.email,\n password: data.password,\n verified: data.verified ?? false,\n profile: { create: {} },\n },\n select: {\n id: true,\n username: true,\n email: true,\n },\n });\n}\n\n/** Create a session. */\nexport function createSession(data: {\n id: string;\n type: SessionType;\n expiresAt: Date;\n userId?: string;\n classId?: string;\n}) {\n return prisma.session.create({\n data,\n });\n}\n\n/** Delete all sessions for user. Invalidates Redis cache. */\nexport async function deleteSessionsByUserId(userId: string) {\n const sessions = await prisma.session.findMany({\n where: { userId },\n });\n for (const session of sessions) {\n await getRedis()?.del(getAuthSessionCacheKey(session.id));\n }\n return prisma.session.deleteMany({\n where: { userId },\n });\n}\n\n/** Delete password reset sessions expiring before date. */\nexport function deleteShortLivedSessionsByUserId(\n userId: string,\n expiresBefore: Date\n) {\n return prisma.session.deleteMany({\n where: {\n userId,\n type: SessionType.PASSWORD_RESET,\n expiresAt: { lte: expiresBefore },\n },\n });\n}\n\n/** Delete a user. */\nexport function deleteUserById(id: string) {\n return prisma.user.delete({\n where: { id },\n });\n}\n\n/** @returns Session by ID and type. */\nexport function findSessionByIdAndType(id: string, type: SessionType) {\n return prisma.session.findFirst({\n where: { id, type },\n });\n}\n\n/** @returns Session with user by ID and type. */\nexport function findSessionByIdWithUserAndType(id: string, type: SessionType) {\n return prisma.session.findFirst({\n where: { id, type },\n include: {\n user: { select: { id: true } },\n },\n });\n}\n\n/** Set user verified status. */\nexport function updateUserVerified(userId: string, verified: boolean) {\n return prisma.user.update({\n where: { id: userId },\n data: { verified },\n });\n}\n\n/** Update user password. */\nexport function updateUserPassword(userId: string, password: string) {\n return prisma.user.update({\n where: { id: userId },\n data: { password },\n });\n}\n\n/** Delete a session. */\nexport async function deleteSessionById(id: string) {\n await getRedis()?.del(getAuthSessionCacheKey(id));\n return prisma.session.delete({\n where: { id },\n });\n}\n\n/** @returns User from valid auth session token. Checks Redis first, then DB. Caches in Redis. */\nexport async function findUserBySessionToken(token: string) {\n const cacheKey = getAuthSessionCacheKey(token);\n const cachedUser = await getRedis()?.get(cacheKey);\n\n if (cachedUser) {\n return JSON.parse(cachedUser);\n }\n\n const session = await prisma.session.findFirst({\n where: {\n id: token,\n type: SessionType.AUTH,\n userId: { not: null },\n expiresAt: { gt: new Date() },\n },\n select: {\n expiresAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n });\n\n if (!session?.user) {\n return null;\n }\n\n const ttlSeconds = getSessionTtlSeconds(session.expiresAt);\n const r = getRedis();\n if (r && ttlSeconds) {\n await r.setex(cacheKey, ttlSeconds, JSON.stringify(session.user));\n }\n\n return session.user;\n}\n\n/** @returns Class IDs where user is a teacher. */\nexport function findTeacherClassesByUserId(userId: string) {\n return prisma.class.findMany({\n where: classTeacherOrSchoolAdminWhere(userId),\n select: { id: true },\n });\n}\n\n/** @returns Class if user is student or teacher. */\nexport function findClassWithMember(classId: string, userId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classMemberOrSchoolAdminWhere(userId),\n },\n });\n}\n\n/** @returns Class if user is a teacher or school admin. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(teacherId),\n },\n });\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAElD,SAAS,sBAAsB,CAAC,KAAa;IAC3C,OAAO,GAAG,yBAAyB,GAAG,KAAK,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAuB;IACnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACzE,OAAO,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;QAC3B,KAAK,EAAE,EAAE,QAAQ,EAAE;QACnB,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;SACf;KACF,CAAC,CAAC;AACL,CAAC;AAED,0C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AAC,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,0BAA0B,CAAC,MAAc;IACvD,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;QAC3B,KAAK,EAAE,8BAA8B,CAAC,MAAM,CAAC;QAC7C,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE;KACrB,CAAC,CAAC;AACL,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,MAAc;IACjE,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;QAC5B,KAAK,EAAE;YACL,EAAE,EAAE,OAAO;YACX,GAAG,6BAA6B,CAAC,MAAM,CAAC;SACzC;KACF,CAAC,CAAC;AACL,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,SAAiB;IACrE,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;QAC5B,KAAK,EAAE;YACL,EAAE,EAAE,OAAO;YACX,GAAG,8BAA8B,CAAC,SAAS,CAAC;SAC7C;KACF,CAAC,CAAC;AACL,CAAC","debug_id":"0a142abe-c24b-5549-932f-108cd325b0ee"}
|
|
1
|
+
{"version":3,"file":"auth.js","sources":["models/auth.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Auth model – user lookup, session CRUD, Redis session cache.\n * findUserBySessionToken checks Redis first, then DB.\n */\nimport { SessionType } from \"@prisma/client\";\nimport { getRedis } from \"../lib/redis.js\";\nimport { prisma } from \"../lib/prisma.js\";\nimport {\n classMemberOrSchoolAdminWhere,\n classTeacherOrSchoolAdminWhere,\n} from \"./access.js\";\n\nconst AUTH_SESSION_CACHE_PREFIX = \"auth-session:\";\n\nfunction getAuthSessionCacheKey(token: string) {\n return `${AUTH_SESSION_CACHE_PREFIX}${token}`;\n}\n\nfunction getSessionTtlSeconds(expiresAt?: Date | null) {\n if (!expiresAt) {\n return null;\n }\n\n const ttlSeconds = Math.floor((expiresAt.getTime() - Date.now()) / 1000);\n return ttlSeconds > 0 ? ttlSeconds : null;\n}\n\n/** @returns User by username (includes password for login). */\nexport function findUserByUsername(username: string) {\n return prisma.user.findFirst({\n where: { username },\n select: {\n id: true,\n username: true,\n password: true,\n email: true,\n verified: true,\n },\n });\n}\n\n/** @returns User by username or email. */\nexport function findUserByUsernameOrEmail(username: string, email: string) {\n return prisma.user.findFirst({\n where: {\n OR: [{ username }, { email }],\n },\n select: {\n id: true,\n username: true,\n email: true,\n verified: true,\n },\n });\n}\n\n/** @returns User by email with profile. */\nexport function findUserByEmail(email: string) {\n return prisma.user.findFirst({\n where: { email },\n select: {\n id: true,\n email: true,\n profile: {\n select: {\n displayName: true,\n bio: true,\n location: true,\n website: true,\n profilePicture: true,\n },\n },\n },\n });\n}\n\n/** @returns User by ID with profile. */\nexport function findUserById(id: string) {\n return prisma.user.findUnique({\n where: { id },\n select: {\n id: true,\n username: true,\n email: true,\n profile: {\n select: {\n displayName: true,\n bio: true,\n location: true,\n website: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n });\n}\n\n/** Create a user with empty profile. */\nexport function createUser(data: {\n username: string;\n email: string;\n password: string;\n verified?: boolean;\n termsAcceptedAt?: Date;\n termsVersion?: string;\n}) {\n return prisma.user.create({\n data: {\n username: data.username,\n email: data.email,\n password: data.password,\n verified: data.verified ?? false,\n termsAcceptedAt: data.termsAcceptedAt,\n termsVersion: data.termsVersion,\n profile: { create: {} },\n },\n select: {\n id: true,\n username: true,\n email: true,\n },\n });\n}\n\n/** Create a session. */\nexport function createSession(data: {\n id: string;\n type: SessionType;\n expiresAt: Date;\n userId?: string;\n classId?: string;\n}) {\n return prisma.session.create({\n data,\n });\n}\n\n/** Delete all sessions for user. Invalidates Redis cache. */\nexport async function deleteSessionsByUserId(userId: string) {\n const sessions = await prisma.session.findMany({\n where: { userId },\n });\n for (const session of sessions) {\n await getRedis()?.del(getAuthSessionCacheKey(session.id));\n }\n return prisma.session.deleteMany({\n where: { userId },\n });\n}\n\n/** Delete password reset sessions expiring before date. */\nexport function deleteShortLivedSessionsByUserId(\n userId: string,\n expiresBefore: Date\n) {\n return prisma.session.deleteMany({\n where: {\n userId,\n type: SessionType.PASSWORD_RESET,\n expiresAt: { lte: expiresBefore },\n },\n });\n}\n\n/** Delete a user. */\nexport function deleteUserById(id: string) {\n return prisma.user.delete({\n where: { id },\n });\n}\n\n/** @returns Session by ID and type. */\nexport function findSessionByIdAndType(id: string, type: SessionType) {\n return prisma.session.findFirst({\n where: { id, type },\n });\n}\n\n/** @returns Session with user by ID and type. */\nexport function findSessionByIdWithUserAndType(id: string, type: SessionType) {\n return prisma.session.findFirst({\n where: { id, type },\n include: {\n user: { select: { id: true } },\n },\n });\n}\n\n/** Set user verified status. */\nexport function updateUserVerified(userId: string, verified: boolean) {\n return prisma.user.update({\n where: { id: userId },\n data: { verified },\n });\n}\n\n/** Update user password. */\nexport function updateUserPassword(userId: string, password: string) {\n return prisma.user.update({\n where: { id: userId },\n data: { password },\n });\n}\n\n/** Delete a session. */\nexport async function deleteSessionById(id: string) {\n await getRedis()?.del(getAuthSessionCacheKey(id));\n return prisma.session.delete({\n where: { id },\n });\n}\n\n/** @returns User from valid auth session token. Checks Redis first, then DB. Caches in Redis. */\nexport async function findUserBySessionToken(token: string) {\n const cacheKey = getAuthSessionCacheKey(token);\n const cachedUser = await getRedis()?.get(cacheKey);\n\n if (cachedUser) {\n return JSON.parse(cachedUser);\n }\n\n const session = await prisma.session.findFirst({\n where: {\n id: token,\n type: SessionType.AUTH,\n userId: { not: null },\n expiresAt: { gt: new Date() },\n },\n select: {\n expiresAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n });\n\n if (!session?.user) {\n return null;\n }\n\n const ttlSeconds = getSessionTtlSeconds(session.expiresAt);\n const r = getRedis();\n if (r && ttlSeconds) {\n await r.setex(cacheKey, ttlSeconds, JSON.stringify(session.user));\n }\n\n return session.user;\n}\n\n/** @returns Class IDs where user is a teacher. */\nexport function findTeacherClassesByUserId(userId: string) {\n return prisma.class.findMany({\n where: classTeacherOrSchoolAdminWhere(userId),\n select: { id: true },\n });\n}\n\n/** @returns Class if user is student or teacher. */\nexport function findClassWithMember(classId: string, userId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classMemberOrSchoolAdminWhere(userId),\n },\n });\n}\n\n/** @returns Class if user is a teacher or school admin. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(teacherId),\n },\n });\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAElD,SAAS,sBAAsB,CAAC,KAAa;IAC3C,OAAO,GAAG,yBAAyB,GAAG,KAAK,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,oBAAoB,CAAC,SAAuB;IACnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACzE,OAAO,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,C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