@studious-lms/server 1.4.6 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/access.d.ts +112 -0
- package/dist/models/access.d.ts.map +1 -0
- package/dist/models/access.js +49 -0
- package/dist/models/access.js.map +1 -0
- package/dist/models/announcement.d.ts +17 -2
- package/dist/models/announcement.d.ts.map +1 -1
- package/dist/models/announcement.js +21 -4
- package/dist/models/announcement.js.map +1 -1
- package/dist/models/assignment.d.ts +37 -37
- package/dist/models/assignment.d.ts.map +1 -1
- package/dist/models/assignment.js +15 -15
- package/dist/models/assignment.js.map +1 -1
- package/dist/models/attendance.d.ts +1 -1
- package/dist/models/attendance.d.ts.map +1 -1
- package/dist/models/attendance.js +6 -5
- package/dist/models/attendance.js.map +1 -1
- package/dist/models/auth.d.ts +5 -5
- package/dist/models/auth.d.ts.map +1 -1
- package/dist/models/auth.js +7 -11
- package/dist/models/auth.js.map +1 -1
- package/dist/models/class.d.ts +26 -26
- package/dist/models/class.d.ts.map +1 -1
- package/dist/models/class.js +7 -11
- package/dist/models/class.js.map +1 -1
- package/dist/models/comment.d.ts +134 -70
- package/dist/models/comment.d.ts.map +1 -1
- package/dist/models/comment.js +30 -42
- package/dist/models/comment.js.map +1 -1
- package/dist/models/conversation.d.ts +7 -7
- package/dist/models/event.d.ts +52 -3
- package/dist/models/event.d.ts.map +1 -1
- package/dist/models/event.js +56 -6
- package/dist/models/event.js.map +1 -1
- package/dist/models/file.d.ts +178 -103
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/file.js +54 -14
- package/dist/models/file.js.map +1 -1
- package/dist/models/folder.d.ts +22 -22
- package/dist/models/folder.d.ts.map +1 -1
- package/dist/models/folder.js +5 -4
- package/dist/models/folder.js.map +1 -1
- package/dist/models/labChat.d.ts +20 -20
- package/dist/models/labChat.d.ts.map +1 -1
- package/dist/models/labChat.js +8 -10
- package/dist/models/labChat.js.map +1 -1
- package/dist/models/marketing.d.ts +1 -1
- package/dist/models/message.d.ts +6 -6
- package/dist/models/newtonChat.d.ts +5 -5
- package/dist/models/school.d.ts +361 -0
- package/dist/models/school.d.ts.map +1 -0
- package/dist/models/school.js +314 -0
- package/dist/models/school.js.map +1 -0
- package/dist/models/section.d.ts +1 -1
- package/dist/models/section.d.ts.map +1 -1
- package/dist/models/section.js +5 -4
- package/dist/models/section.js.map +1 -1
- package/dist/models/user.d.ts +4 -4
- package/dist/models/worksheet.d.ts +65 -65
- package/dist/models/worksheet.d.ts.map +1 -1
- package/dist/models/worksheet.js +6 -14
- package/dist/models/worksheet.js.map +1 -1
- package/dist/pipelines/gradeWorksheet.d.ts +2 -2
- package/dist/pipelines/pdfToWorksheet.d.ts +1 -1
- package/dist/routers/_app.d.ts +2855 -2051
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/_app.js +4 -2
- package/dist/routers/_app.js.map +1 -1
- package/dist/routers/announcement.d.ts +5 -5
- package/dist/routers/announcement.d.ts.map +1 -1
- package/dist/routers/announcement.js +25 -5
- package/dist/routers/announcement.js.map +1 -1
- package/dist/routers/assignment.d.ts +44 -44
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +24 -11
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/class.d.ts +21 -20
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +3 -2
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +5 -5
- package/dist/routers/conversation.d.ts +6 -6
- package/dist/routers/event.d.ts +21 -2
- package/dist/routers/event.d.ts.map +1 -1
- package/dist/routers/file.d.ts +2 -2
- package/dist/routers/folder.d.ts +24 -24
- package/dist/routers/labChat.d.ts +7 -7
- package/dist/routers/school.d.ts +384 -0
- package/dist/routers/school.d.ts.map +1 -0
- package/dist/routers/school.js +79 -0
- package/dist/routers/school.js.map +1 -0
- package/dist/routers/search.d.ts +1 -1
- package/dist/routers/worksheet.d.ts +21 -21
- package/dist/services/announcement.d.ts.map +1 -1
- package/dist/services/announcement.js +10 -6
- package/dist/services/announcement.js.map +1 -1
- package/dist/services/assignment.d.ts +36 -36
- package/dist/services/class.d.ts +20 -19
- package/dist/services/class.d.ts.map +1 -1
- package/dist/services/class.js +22 -3
- package/dist/services/class.js.map +1 -1
- package/dist/services/comment.d.ts +5 -5
- package/dist/services/comment.d.ts.map +1 -1
- package/dist/services/comment.js +8 -3
- package/dist/services/comment.js.map +1 -1
- package/dist/services/conversation.d.ts +6 -6
- package/dist/services/event.d.ts +21 -2
- package/dist/services/event.d.ts.map +1 -1
- package/dist/services/event.js +11 -7
- package/dist/services/event.js.map +1 -1
- package/dist/services/file.d.ts +2 -2
- package/dist/services/file.d.ts.map +1 -1
- package/dist/services/file.js +17 -8
- package/dist/services/file.js.map +1 -1
- package/dist/services/folder.d.ts +24 -24
- package/dist/services/labChat.d.ts +7 -7
- package/dist/services/school.d.ts +299 -0
- package/dist/services/school.d.ts.map +1 -0
- package/dist/services/school.js +225 -0
- package/dist/services/school.js.map +1 -0
- package/dist/services/worksheet.d.ts +21 -21
- package/package.json +1 -1
- package/prisma/migrations/20260504071500_school_memberships/migration.sql +81 -0
- package/prisma/schema.prisma +66 -2
- package/src/models/access.ts +48 -0
- package/src/models/announcement.ts +19 -2
- package/src/models/assignment.ts +17 -13
- package/src/models/attendance.ts +4 -3
- package/src/models/auth.ts +8 -9
- package/src/models/class.ts +8 -9
- package/src/models/comment.ts +29 -40
- package/src/models/event.ts +54 -4
- package/src/models/file.ts +53 -12
- package/src/models/folder.ts +3 -2
- package/src/models/labChat.ts +9 -8
- package/src/models/school.ts +361 -0
- package/src/models/section.ts +3 -2
- package/src/models/worksheet.ts +7 -12
- package/src/routers/_app.ts +2 -0
- package/src/routers/announcement.ts +30 -4
- package/src/routers/assignment.ts +27 -9
- package/src/routers/class.ts +1 -0
- package/src/routers/school.ts +122 -0
- package/src/services/announcement.ts +12 -4
- package/src/services/class.ts +25 -2
- package/src/services/comment.ts +10 -1
- package/src/services/event.ts +23 -6
- package/src/services/file.ts +20 -6
- package/src/services/school.ts +308 -0
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Assignment model – assignments, submissions, attachments.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
!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]="
|
|
5
|
+
!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]="42061a1a-7f8e-55c4-a836-0e727f41fe0d")}catch(e){}}();
|
|
6
6
|
import { prisma } from "../lib/prisma.js";
|
|
7
|
+
import { classMemberOrSchoolAdminWhere, classTeacherOrSchoolAdminWhere, schoolAdminForClassWhere, } from "./access.js";
|
|
7
8
|
const assignmentGetInclude = {
|
|
8
9
|
submissions: {
|
|
9
10
|
select: {
|
|
@@ -55,7 +56,13 @@ export function findAssignmentWithDetails(id) {
|
|
|
55
56
|
/** @returns Assignment with attachments for delete. */
|
|
56
57
|
export function findAssignmentForDelete(id, teacherId) {
|
|
57
58
|
return prisma.assignment.findFirst({
|
|
58
|
-
where: {
|
|
59
|
+
where: {
|
|
60
|
+
id,
|
|
61
|
+
OR: [
|
|
62
|
+
{ teacherId },
|
|
63
|
+
{ class: schoolAdminForClassWhere(teacherId) },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
59
66
|
include: {
|
|
60
67
|
attachments: { include: { thumbnail: true } },
|
|
61
68
|
submissions: {
|
|
@@ -110,12 +117,7 @@ export function findSubmissionByIdForClassMember(submissionId, classId, userId)
|
|
|
110
117
|
id: submissionId,
|
|
111
118
|
assignment: {
|
|
112
119
|
classId,
|
|
113
|
-
class:
|
|
114
|
-
OR: [
|
|
115
|
-
{ teachers: { some: { id: userId } } },
|
|
116
|
-
{ students: { some: { id: userId } } },
|
|
117
|
-
],
|
|
118
|
-
},
|
|
120
|
+
class: classMemberOrSchoolAdminWhere(userId),
|
|
119
121
|
},
|
|
120
122
|
},
|
|
121
123
|
include: {
|
|
@@ -142,9 +144,7 @@ export function findSubmissionForUpdate(submissionId, userId) {
|
|
|
142
144
|
{ studentId: userId },
|
|
143
145
|
{
|
|
144
146
|
assignment: {
|
|
145
|
-
class:
|
|
146
|
-
teachers: { some: { id: userId } },
|
|
147
|
-
},
|
|
147
|
+
class: classTeacherOrSchoolAdminWhere(userId),
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
150
|
],
|
|
@@ -195,7 +195,7 @@ export function findAssignmentWithClassForTeacher(assignmentId, teacherId) {
|
|
|
195
195
|
return prisma.assignment.findFirst({
|
|
196
196
|
where: {
|
|
197
197
|
id: assignmentId,
|
|
198
|
-
class:
|
|
198
|
+
class: classTeacherOrSchoolAdminWhere(teacherId),
|
|
199
199
|
},
|
|
200
200
|
include: { class: true },
|
|
201
201
|
});
|
|
@@ -206,7 +206,7 @@ export function findSubmissionsByAssignmentForTeacher(assignmentId, teacherId) {
|
|
|
206
206
|
where: {
|
|
207
207
|
assignment: {
|
|
208
208
|
id: assignmentId,
|
|
209
|
-
class:
|
|
209
|
+
class: classTeacherOrSchoolAdminWhere(teacherId),
|
|
210
210
|
},
|
|
211
211
|
},
|
|
212
212
|
include: {
|
|
@@ -240,7 +240,7 @@ export function findSubmissionForTeacherUpdate(submissionId, teacherId) {
|
|
|
240
240
|
where: {
|
|
241
241
|
id: submissionId,
|
|
242
242
|
assignment: {
|
|
243
|
-
class:
|
|
243
|
+
class: classTeacherOrSchoolAdminWhere(teacherId),
|
|
244
244
|
},
|
|
245
245
|
},
|
|
246
246
|
include: {
|
|
@@ -306,4 +306,4 @@ export function detachAssignmentFromEvent(assignmentId) {
|
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
308
|
//# sourceMappingURL=assignment.js.map
|
|
309
|
-
//# debugId=
|
|
309
|
+
//# debugId=42061a1a-7f8e-55c4-a836-0e727f41fe0d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assignment.js","sources":["models/assignment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Assignment model – assignments, submissions, attachments.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst assignmentGetInclude = {\n submissions: {\n select: {\n student: { select: { id: true, username: true } },\n },\n },\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n uploadedAt: true,\n thumbnailId: true,\n },\n },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n worksheets: { select: { id: true, name: true } },\n class: { select: { id: true, name: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n },\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n} as const;\n\n/** @returns Assignment by ID. */\nexport function findAssignmentById(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n });\n}\n\n/** @returns Assignment with full details for get. */\nexport function findAssignmentWithDetails(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n include: assignmentGetInclude,\n });\n}\n\n/** @returns Assignment with attachments for delete. */\nexport function findAssignmentForDelete(id: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: { id, teacherId },\n include: {\n attachments: { include: { thumbnail: true } },\n submissions: {\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n },\n },\n },\n });\n}\n\n/** @returns Assignments due today. */\nexport function findAssignmentsDueToday() {\n return prisma.assignment.findMany({\n where: {\n dueDate: { equals: new Date() },\n },\n select: {\n id: true,\n title: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n class: { select: { id: true, name: true } },\n },\n });\n}\n\n/** @returns Submission by assignment and student. */\nexport function findSubmissionByAssignmentAndStudent(assignmentId: string, studentId: string) {\n return prisma.submission.findFirst({\n where: { assignmentId, studentId },\n include: {\n attachments: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n annotations: true,\n },\n });\n}\n\n/** @returns Submission by ID for class member. */\nexport function findSubmissionByIdForClassMember(submissionId: string, classId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n classId,\n class: {\n OR: [\n { teachers: { some: { id: userId } } },\n { students: { some: { id: userId } } },\n ],\n },\n },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for update (student or teacher). */\nexport function findSubmissionForUpdate(submissionId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n OR: [\n { studentId: userId },\n {\n assignment: {\n class: {\n teachers: { some: { id: userId } },\n },\n },\n },\n ],\n },\n include: {\n attachments: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** Create a submission. */\nexport function createSubmission(assignmentId: string, studentId: string) {\n return prisma.submission.create({\n data: {\n assignment: { connect: { id: assignmentId } },\n student: { connect: { id: studentId } },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Sections for a class. */\nexport function findSectionsByClassId(classId: string) {\n return prisma.section.findMany({\n where: { classId },\n select: { id: true, name: true },\n });\n}\n\n/** @returns Assignment with class for teacher (auth check). */\nexport function findAssignmentWithClassForTeacher(assignmentId: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: {\n id: assignmentId,\n class: { teachers: { some: { id: teacherId } } },\n },\n include: { class: true },\n });\n}\n\n/** @returns Submissions for assignment (teacher view). */\nexport function findSubmissionsByAssignmentForTeacher(assignmentId: string, teacherId: string) {\n return prisma.submission.findMany({\n where: {\n assignment: {\n id: assignmentId,\n class: { teachers: { some: { id: teacherId } } },\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n student: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for teacher update. */\nexport function findSubmissionForTeacherUpdate(submissionId: string, teacherId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n class: { teachers: { some: { id: teacherId } } },\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Events in class that don't have this assignment attached. */\nexport function findAvailableEventsForAssignment(classId: string, assignmentId: string) {\n return prisma.event.findMany({\n where: {\n classId,\n assignmentsAttached: { none: { id: assignmentId } },\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n orderBy: { startTime: \"asc\" },\n });\n}\n\nconst assignmentAttachEventInclude = {\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n color: true,\n },\n },\n};\n\n/** Attach assignment to event. */\nexport function attachAssignmentToEvent(assignmentId: string, eventId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { connect: { id: eventId } } },\n include: assignmentAttachEventInclude,\n });\n}\n\n/** Detach assignment from event. */\nexport function detachAssignmentFromEvent(assignmentId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { disconnect: true } },\n include: assignmentAttachEventInclude,\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;SAClD;KACF;IACD,WAAW,EAAE;QACX,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;SAClB;KACF;IACD,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC7C,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACjD,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAChD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC3C,aAAa,EAAE;QACb,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,S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AAE,EAAE,YAAY,EAAE;QAC3B,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QAC7C,OAAO,EAAE,4BAA4B;KACtC,CAAC,CAAC;AACL,CAAC","debug_id":"10c32a4f-1c74-5df0-80e6-79f3cc1525fa"}
|
|
1
|
+
{"version":3,"file":"assignment.js","sources":["models/assignment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Assignment model – assignments, submissions, attachments.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport {\n classMemberOrSchoolAdminWhere,\n classTeacherOrSchoolAdminWhere,\n schoolAdminForClassWhere,\n} from \"./access.js\";\n\nconst assignmentGetInclude = {\n submissions: {\n select: {\n student: { select: { id: true, username: true } },\n },\n },\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n uploadedAt: true,\n thumbnailId: true,\n },\n },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n worksheets: { select: { id: true, name: true } },\n class: { select: { id: true, name: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n },\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n} as const;\n\n/** @returns Assignment by ID. */\nexport function findAssignmentById(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n });\n}\n\n/** @returns Assignment with full details for get. */\nexport function findAssignmentWithDetails(id: string) {\n return prisma.assignment.findUnique({\n where: { id },\n include: assignmentGetInclude,\n });\n}\n\n/** @returns Assignment with attachments for delete. */\nexport function findAssignmentForDelete(id: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: {\n id,\n OR: [\n { teacherId },\n { class: schoolAdminForClassWhere(teacherId) },\n ],\n },\n include: {\n attachments: { include: { thumbnail: true } },\n submissions: {\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n },\n },\n },\n });\n}\n\n/** @returns Assignments due today. */\nexport function findAssignmentsDueToday() {\n return prisma.assignment.findMany({\n where: {\n dueDate: { equals: new Date() },\n },\n select: {\n id: true,\n title: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n class: { select: { id: true, name: true } },\n },\n });\n}\n\n/** @returns Submission by assignment and student. */\nexport function findSubmissionByAssignmentAndStudent(assignmentId: string, studentId: string) {\n return prisma.submission.findFirst({\n where: { assignmentId, studentId },\n include: {\n attachments: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n annotations: true,\n },\n });\n}\n\n/** @returns Submission by ID for class member. */\nexport function findSubmissionByIdForClassMember(submissionId: string, classId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n classId,\n class: classMemberOrSchoolAdminWhere(userId),\n },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true, profile: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for update (student or teacher). */\nexport function findSubmissionForUpdate(submissionId: string, userId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n OR: [\n { studentId: userId },\n {\n assignment: {\n class: classTeacherOrSchoolAdminWhere(userId),\n },\n },\n ],\n },\n include: {\n attachments: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** Create a submission. */\nexport function createSubmission(assignmentId: string, studentId: string) {\n return prisma.submission.create({\n data: {\n assignment: { connect: { id: assignmentId } },\n student: { connect: { id: studentId } },\n },\n include: {\n attachments: true,\n annotations: true,\n student: { select: { id: true, username: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n worksheets: { select: { id: true, name: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Sections for a class. */\nexport function findSectionsByClassId(classId: string) {\n return prisma.section.findMany({\n where: { classId },\n select: { id: true, name: true },\n });\n}\n\n/** @returns Assignment with class for teacher (auth check). */\nexport function findAssignmentWithClassForTeacher(assignmentId: string, teacherId: string) {\n return prisma.assignment.findFirst({\n where: {\n id: assignmentId,\n class: classTeacherOrSchoolAdminWhere(teacherId),\n },\n include: { class: true },\n });\n}\n\n/** @returns Submissions for assignment (teacher view). */\nexport function findSubmissionsByAssignmentForTeacher(assignmentId: string, teacherId: string) {\n return prisma.submission.findMany({\n where: {\n assignment: {\n id: assignmentId,\n class: classTeacherOrSchoolAdminWhere(teacherId),\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n student: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Submission by ID for teacher update. */\nexport function findSubmissionForTeacherUpdate(submissionId: string, teacherId: string) {\n return prisma.submission.findFirst({\n where: {\n id: submissionId,\n assignment: {\n class: classTeacherOrSchoolAdminWhere(teacherId),\n },\n },\n include: {\n attachments: { include: { thumbnail: true } },\n annotations: { include: { thumbnail: true } },\n assignment: {\n include: {\n class: true,\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Events in class that don't have this assignment attached. */\nexport function findAvailableEventsForAssignment(classId: string, assignmentId: string) {\n return prisma.event.findMany({\n where: {\n classId,\n assignmentsAttached: { none: { id: assignmentId } },\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n },\n orderBy: { startTime: \"asc\" },\n });\n}\n\nconst assignmentAttachEventInclude = {\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n eventAttached: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n color: true,\n },\n },\n};\n\n/** Attach assignment to event. */\nexport function attachAssignmentToEvent(assignmentId: string, eventId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { connect: { id: eventId } } },\n include: assignmentAttachEventInclude,\n });\n}\n\n/** Detach assignment from event. */\nexport function detachAssignmentFromEvent(assignmentId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { disconnect: true } },\n include: assignmentAttachEventInclude,\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;SAClD;KACF;IACD,WAAW,EAAE;QACX,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;SAClB;KACF;IACD,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC7C,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACjD,U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QAC3B,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QAC7C,OAAO,EAAE,4BAA4B;KACtC,CAAC,CAAC;AACL,CAAC","debug_id":"42061a1a-7f8e-55c4-a836-0e727f41fe0d"}
|
|
@@ -20,7 +20,7 @@ export declare function findClassWithStudents(classId: string): import(".prisma/
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
}>;
|
|
23
|
-
/** @returns Class if user is a teacher. */
|
|
23
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
24
24
|
export declare function findClassWithTeacher(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
25
25
|
name: string;
|
|
26
26
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attendance.d.ts","sourceRoot":"/","sources":["models/attendance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attendance.d.ts","sourceRoot":"/","sources":["models/attendance.ts"],"names":[],"mappings":"AAkFA,mDAAmD;AACnD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;GAuBpD;AAED,2DAA2D;AAC3D,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"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Attendance model – attendance records, present/late/absent students per event.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
!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]="
|
|
5
|
+
!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]="311ac412-3d37-5b5d-9c46-79a70ef935e2")}catch(e){}}();
|
|
6
6
|
import { prisma } from "../lib/prisma.js";
|
|
7
|
+
import { classTeacherOrSchoolAdminWhere } from "./access.js";
|
|
7
8
|
const attendanceInclude = {
|
|
8
9
|
event: {
|
|
9
10
|
select: {
|
|
@@ -103,12 +104,12 @@ export function findClassWithStudents(classId) {
|
|
|
103
104
|
},
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
|
-
/** @returns Class if user is a teacher. */
|
|
107
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
107
108
|
export function findClassWithTeacher(classId, teacherId) {
|
|
108
|
-
return prisma.class.
|
|
109
|
+
return prisma.class.findFirst({
|
|
109
110
|
where: {
|
|
110
111
|
id: classId,
|
|
111
|
-
|
|
112
|
+
...classTeacherOrSchoolAdminWhere(teacherId),
|
|
112
113
|
},
|
|
113
114
|
});
|
|
114
115
|
}
|
|
@@ -185,4 +186,4 @@ export function updateAttendance(id, data) {
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
//# sourceMappingURL=attendance.js.map
|
|
188
|
-
//# debugId=
|
|
189
|
+
//# debugId=311ac412-3d37-5b5d-9c46-79a70ef935e2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attendance.js","sources":["models/attendance.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Attendance model – attendance records, present/late/absent students per event.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst attendanceInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n color: true,\n },\n },\n present: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n late: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n absent: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n} as const;\n\nconst attendanceUpdateInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n },\n },\n present: { select: { id: true, username: true } },\n late: { select: { id: true, username: true } },\n absent: { select: { id: true, username: true } },\n} as const;\n\n/** @returns Class with students for attendance. */\nexport function findClassWithStudents(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n select: {\n id: true,\n students: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n },\n });\n}\n\n/** @returns Class if user is a teacher. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.
|
|
1
|
+
{"version":3,"file":"attendance.js","sources":["models/attendance.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Attendance model – attendance records, present/late/absent students per event.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport { classTeacherOrSchoolAdminWhere } from \"./access.js\";\n\nconst attendanceInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n color: true,\n },\n },\n present: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n late: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n absent: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\n} as const;\n\nconst attendanceUpdateInclude = {\n event: {\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n },\n },\n present: { select: { id: true, username: true } },\n late: { select: { id: true, username: true } },\n absent: { select: { id: true, username: true } },\n} as const;\n\n/** @returns Class with students for attendance. */\nexport function findClassWithStudents(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n select: {\n id: true,\n students: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n bio: true,\n location: true,\n website: true,\n },\n },\n },\n },\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\n/** @returns Events for a class. */\nexport function findEventsByClassId(classId: string) {\n return prisma.event.findMany({\n where: { classId },\n });\n}\n\n/** @returns Attendance record for an event. */\nexport function findAttendanceByEventId(eventId: string) {\n return prisma.attendance.findFirst({\n where: { eventId },\n });\n}\n\n/** @returns Attendance for class and event (eventId null = class-level). */\nexport function findAttendanceByClassAndEvent(classId: string, eventId: string | null) {\n return prisma.attendance.findFirst({\n where: {\n classId,\n eventId,\n },\n });\n}\n\n/** @returns Attendance records for class, optionally filtered by event. */\nexport function findManyAttendance(classId: string, eventId?: string) {\n return prisma.attendance.findMany({\n where: {\n classId,\n ...(eventId ? { eventId } : {}),\n },\n include: attendanceInclude,\n orderBy: { date: \"desc\" },\n });\n}\n\n/** Create an attendance record. */\nexport function createAttendance(data: {\n classId: string;\n eventId?: string | null;\n presentIds: string[];\n lateIds?: string[];\n absentIds?: string[];\n}) {\n return prisma.attendance.create({\n data: {\n classId: data.classId,\n eventId: data.eventId ?? undefined,\n date: new Date(),\n present: { connect: data.presentIds.map((id) => ({ id })) },\n late: data.lateIds?.length\n ? { connect: data.lateIds.map((id) => ({ id })) }\n : undefined,\n absent: data.absentIds?.length\n ? { connect: data.absentIds.map((id) => ({ id })) }\n : undefined,\n },\n include: attendanceUpdateInclude,\n });\n}\n\n/** Create attendance for a specific event. */\nexport function createAttendanceForEvent(data: {\n classId: string;\n eventId: string;\n presentIds: string[];\n}) {\n return prisma.attendance.create({\n data: {\n class: { connect: { id: data.classId } },\n event: { connect: { id: data.eventId } },\n present: { connect: data.presentIds.map((id) => ({ id })) },\n },\n });\n}\n\n/** Update attendance present/late/absent lists. */\nexport function updateAttendance(\n id: string,\n data: { presentIds: string[]; lateIds: string[]; absentIds: string[] }\n) {\n return prisma.attendance.update({\n where: { id },\n data: {\n present: { set: data.presentIds.map((id) => ({ id })) },\n late: { set: data.lateIds.map((id) => ({ id })) },\n absent: { set: data.absentIds.map((id) => ({ id })) },\n },\n include: attendanceUpdateInclude,\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE;QACL,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;SACZ;KACF;IACD,OAAO,EAAE;QACP,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,uBAAuB,EAAE,IAAI;oBAC7B,GAAG,EAAE,IAAI;oBACT,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,IAAI;iBACd;aACF;SACF;KACF;IACD,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,uBAAuB,EAAE,IAAI;oBAC7B,GAAG,EAAE,IA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,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;SAC5D;KACF,CAAC,CAAC;AACL,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,gBAAgB,CAC9B,EAAU,EACV,IAAsE;IAEtE,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;QAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;QACb,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;YACvD,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;YACjD,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;SACtD;QACD,OAAO,EAAE,uBAAuB;KACjC,CAAC,CAAC;AACL,CAAC","debug_id":"311ac412-3d37-5b5d-9c46-79a70ef935e2"}
|
package/dist/models/auth.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ export declare function createSession(data: {
|
|
|
95
95
|
}): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
96
96
|
type: import(".prisma/client").$Enums.SessionType;
|
|
97
97
|
id: string;
|
|
98
|
-
userId: string | null;
|
|
99
98
|
createdAt: Date | null;
|
|
99
|
+
userId: string | null;
|
|
100
100
|
expiresAt: Date | null;
|
|
101
101
|
classId: string | null;
|
|
102
102
|
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -130,8 +130,8 @@ export declare function deleteUserById(id: string): import(".prisma/client").Pri
|
|
|
130
130
|
export declare function findSessionByIdAndType(id: string, type: SessionType): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
131
131
|
type: import(".prisma/client").$Enums.SessionType;
|
|
132
132
|
id: string;
|
|
133
|
-
userId: string | null;
|
|
134
133
|
createdAt: Date | null;
|
|
134
|
+
userId: string | null;
|
|
135
135
|
expiresAt: Date | null;
|
|
136
136
|
classId: string | null;
|
|
137
137
|
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -149,8 +149,8 @@ export declare function findSessionByIdWithUserAndType(id: string, type: Session
|
|
|
149
149
|
} & {
|
|
150
150
|
type: import(".prisma/client").$Enums.SessionType;
|
|
151
151
|
id: string;
|
|
152
|
-
userId: string | null;
|
|
153
152
|
createdAt: Date | null;
|
|
153
|
+
userId: string | null;
|
|
154
154
|
expiresAt: Date | null;
|
|
155
155
|
classId: string | null;
|
|
156
156
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -196,8 +196,8 @@ export declare function updateUserPassword(userId: string, password: string): im
|
|
|
196
196
|
export declare function deleteSessionById(id: string): Promise<{
|
|
197
197
|
type: import(".prisma/client").$Enums.SessionType;
|
|
198
198
|
id: string;
|
|
199
|
-
userId: string | null;
|
|
200
199
|
createdAt: Date | null;
|
|
200
|
+
userId: string | null;
|
|
201
201
|
expiresAt: Date | null;
|
|
202
202
|
classId: string | null;
|
|
203
203
|
}>;
|
|
@@ -223,7 +223,7 @@ export declare function findClassWithMember(classId: string, userId: string): im
|
|
|
223
223
|
};
|
|
224
224
|
};
|
|
225
225
|
}>;
|
|
226
|
-
/** @returns Class if user is a teacher. */
|
|
226
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
227
227
|
export declare function findClassWithTeacher(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
228
228
|
name: string;
|
|
229
229
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot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gB,cAAc,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;GAIxC;AAED,uCAAuC;AACvC,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW;;;;;;;;;;;;;GAInE;AAED,iDAAiD;AACjD,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW;;;;;;;;;;;;;;;;;GAO3E;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;;;;;;;;;;;;;;GAOlE;AAED,2DAA2D;AAC3D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;GAOtE"}
|
package/dist/models/auth.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
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]="9d0c401e-c311-5478-a223-1750b9b4c0a4")}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";
|
|
10
|
+
import { classMemberOrSchoolAdminWhere, classTeacherOrSchoolAdminWhere, } from "./access.js";
|
|
10
11
|
const AUTH_SESSION_CACHE_PREFIX = "auth-session:";
|
|
11
12
|
function getAuthSessionCacheKey(token) {
|
|
12
13
|
return `${AUTH_SESSION_CACHE_PREFIX}${token}`;
|
|
@@ -209,9 +210,7 @@ export async function findUserBySessionToken(token) {
|
|
|
209
210
|
/** @returns Class IDs where user is a teacher. */
|
|
210
211
|
export function findTeacherClassesByUserId(userId) {
|
|
211
212
|
return prisma.class.findMany({
|
|
212
|
-
where:
|
|
213
|
-
teachers: { some: { id: userId } },
|
|
214
|
-
},
|
|
213
|
+
where: classTeacherOrSchoolAdminWhere(userId),
|
|
215
214
|
select: { id: true },
|
|
216
215
|
});
|
|
217
216
|
}
|
|
@@ -220,21 +219,18 @@ export function findClassWithMember(classId, userId) {
|
|
|
220
219
|
return prisma.class.findFirst({
|
|
221
220
|
where: {
|
|
222
221
|
id: classId,
|
|
223
|
-
|
|
224
|
-
{ students: { some: { id: userId } } },
|
|
225
|
-
{ teachers: { some: { id: userId } } },
|
|
226
|
-
],
|
|
222
|
+
...classMemberOrSchoolAdminWhere(userId),
|
|
227
223
|
},
|
|
228
224
|
});
|
|
229
225
|
}
|
|
230
|
-
/** @returns Class if user is a teacher. */
|
|
226
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
231
227
|
export function findClassWithTeacher(classId, teacherId) {
|
|
232
228
|
return prisma.class.findFirst({
|
|
233
229
|
where: {
|
|
234
230
|
id: classId,
|
|
235
|
-
|
|
231
|
+
...classTeacherOrSchoolAdminWhere(teacherId),
|
|
236
232
|
},
|
|
237
233
|
});
|
|
238
234
|
}
|
|
239
235
|
//# sourceMappingURL=auth.js.map
|
|
240
|
-
//# debugId=
|
|
236
|
+
//# debugId=9d0c401e-c311-5478-a223-1750b9b4c0a4
|
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\";\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 role: 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 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: {\n teachers: { some: { id: userId } },\n },\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 OR: [\n { students: { some: { id: userId } } },\n { teachers: { some: { id: userId } } },\n ],\n },\n });\n}\n\n/** @returns Class if user is a teacher. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n teachers: { some: { id: 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;AAE1C,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAElD,SAAS,sBAAsB,CAAC,KAAa;IAC3C,OAAO,GAAG,y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AQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;gBACtC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;aACvC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,oBAAoB,CAAC,OAAe,EAAE,SAAiB;IACrE,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;QAC5B,KAAK,EAAE;YACL,EAAE,EAAE,OAAO;YACX,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE;SACtC;KACF,CAAC,CAAC;AACL,CAAC","debug_id":"caa0301d-42ed-55b1-a0ef-383918fe715a"}
|
|
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 role: 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 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 ...classTeacherO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,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":"9d0c401e-c311-5478-a223-1750b9b4c0a4"}
|
package/dist/models/class.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function findTeacherClasses(userId: string): import(".prisma/clie
|
|
|
11
11
|
title: string;
|
|
12
12
|
dueDate: Date;
|
|
13
13
|
}[];
|
|
14
|
-
|
|
14
|
+
teachers: {
|
|
15
15
|
id: string;
|
|
16
16
|
username: string;
|
|
17
17
|
profile: {
|
|
@@ -20,7 +20,7 @@ export declare function findTeacherClasses(userId: string): import(".prisma/clie
|
|
|
20
20
|
profilePictureThumbnail: string | null;
|
|
21
21
|
} | null;
|
|
22
22
|
}[];
|
|
23
|
-
|
|
23
|
+
students: {
|
|
24
24
|
id: string;
|
|
25
25
|
username: string;
|
|
26
26
|
profile: {
|
|
@@ -46,7 +46,7 @@ export declare function findStudentClasses(userId: string): import(".prisma/clie
|
|
|
46
46
|
title: string;
|
|
47
47
|
dueDate: Date;
|
|
48
48
|
}[];
|
|
49
|
-
|
|
49
|
+
teachers: {
|
|
50
50
|
id: string;
|
|
51
51
|
username: string;
|
|
52
52
|
profile: {
|
|
@@ -55,7 +55,7 @@ export declare function findStudentClasses(userId: string): import(".prisma/clie
|
|
|
55
55
|
profilePictureThumbnail: string | null;
|
|
56
56
|
} | null;
|
|
57
57
|
}[];
|
|
58
|
-
|
|
58
|
+
students: {
|
|
59
59
|
id: string;
|
|
60
60
|
username: string;
|
|
61
61
|
profile: {
|
|
@@ -73,7 +73,7 @@ export declare function findStudentClasses(userId: string): import(".prisma/clie
|
|
|
73
73
|
section: string;
|
|
74
74
|
syllabus: string | null;
|
|
75
75
|
})[]>;
|
|
76
|
-
/** @returns Class if user is a teacher. */
|
|
76
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
77
77
|
export declare function isTeacherInClass(classId: string, userId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
78
78
|
name: string;
|
|
79
79
|
id: string;
|
|
@@ -97,6 +97,11 @@ export declare function findClassWithAssignments(classId: string, options: {
|
|
|
97
97
|
assignments: {
|
|
98
98
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
99
99
|
id: string;
|
|
100
|
+
createdAt: Date | null;
|
|
101
|
+
section: {
|
|
102
|
+
name: string;
|
|
103
|
+
id: string;
|
|
104
|
+
} | null;
|
|
100
105
|
submissions: {
|
|
101
106
|
id: string;
|
|
102
107
|
studentId: string;
|
|
@@ -107,11 +112,6 @@ export declare function findClassWithAssignments(classId: string, options: {
|
|
|
107
112
|
submitted: boolean | null;
|
|
108
113
|
returned: boolean | null;
|
|
109
114
|
}[];
|
|
110
|
-
section: {
|
|
111
|
-
name: string;
|
|
112
|
-
id: string;
|
|
113
|
-
} | null;
|
|
114
|
-
createdAt: Date | null;
|
|
115
115
|
title: string;
|
|
116
116
|
instructions: string;
|
|
117
117
|
dueDate: Date;
|
|
@@ -144,7 +144,7 @@ export declare function findClassWithAssignments(classId: string, options: {
|
|
|
144
144
|
} | null;
|
|
145
145
|
};
|
|
146
146
|
}[];
|
|
147
|
-
|
|
147
|
+
teachers: {
|
|
148
148
|
id: string;
|
|
149
149
|
username: string;
|
|
150
150
|
profile: {
|
|
@@ -153,7 +153,7 @@ export declare function findClassWithAssignments(classId: string, options: {
|
|
|
153
153
|
profilePictureThumbnail: string | null;
|
|
154
154
|
} | null;
|
|
155
155
|
}[];
|
|
156
|
-
|
|
156
|
+
students: {
|
|
157
157
|
id: string;
|
|
158
158
|
username: string;
|
|
159
159
|
profile: {
|
|
@@ -216,8 +216,8 @@ export declare function findUserById(userId: string): import(".prisma/client").P
|
|
|
216
216
|
export declare function findSessionByClassCode(classCode: string): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
217
217
|
type: import(".prisma/client").$Enums.SessionType;
|
|
218
218
|
id: string;
|
|
219
|
-
userId: string | null;
|
|
220
219
|
createdAt: Date | null;
|
|
220
|
+
userId: string | null;
|
|
221
221
|
expiresAt: Date | null;
|
|
222
222
|
classId: string | null;
|
|
223
223
|
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -231,8 +231,8 @@ export declare function findSessionByClassCode(classCode: string): import(".pris
|
|
|
231
231
|
export declare function findSessionByClassId(classId: string): import(".prisma/client").Prisma.Prisma__SessionClient<{
|
|
232
232
|
type: import(".prisma/client").$Enums.SessionType;
|
|
233
233
|
id: string;
|
|
234
|
-
userId: string | null;
|
|
235
234
|
createdAt: Date | null;
|
|
235
|
+
userId: string | null;
|
|
236
236
|
expiresAt: Date | null;
|
|
237
237
|
classId: string | null;
|
|
238
238
|
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -261,8 +261,8 @@ export declare function findSubmissionsForGrades(userId: string, classId: string
|
|
|
261
261
|
};
|
|
262
262
|
} & {
|
|
263
263
|
id: string;
|
|
264
|
-
assignmentId: string;
|
|
265
264
|
createdAt: Date;
|
|
265
|
+
assignmentId: string;
|
|
266
266
|
modifiedAt: Date;
|
|
267
267
|
studentId: string;
|
|
268
268
|
extendedResponse: string | null;
|
|
@@ -339,26 +339,26 @@ export declare function findAssignmentsWithFiles(classId: string): import(".pris
|
|
|
339
339
|
type: string;
|
|
340
340
|
name: string;
|
|
341
341
|
id: string;
|
|
342
|
-
size: number | null;
|
|
343
|
-
uploadedAt: Date | null;
|
|
344
|
-
thumbnailId: string | null;
|
|
345
342
|
user: {
|
|
346
343
|
id: string;
|
|
347
344
|
username: string;
|
|
348
345
|
} | null;
|
|
346
|
+
size: number | null;
|
|
347
|
+
uploadedAt: Date | null;
|
|
348
|
+
thumbnailId: string | null;
|
|
349
349
|
}[];
|
|
350
350
|
attachments: {
|
|
351
351
|
path: string;
|
|
352
352
|
type: string;
|
|
353
353
|
name: string;
|
|
354
354
|
id: string;
|
|
355
|
-
size: number | null;
|
|
356
|
-
uploadedAt: Date | null;
|
|
357
|
-
thumbnailId: string | null;
|
|
358
355
|
user: {
|
|
359
356
|
id: string;
|
|
360
357
|
username: string;
|
|
361
358
|
} | null;
|
|
359
|
+
size: number | null;
|
|
360
|
+
uploadedAt: Date | null;
|
|
361
|
+
thumbnailId: string | null;
|
|
362
362
|
}[];
|
|
363
363
|
student: {
|
|
364
364
|
id: string;
|
|
@@ -366,8 +366,8 @@ export declare function findAssignmentsWithFiles(classId: string): import(".pris
|
|
|
366
366
|
};
|
|
367
367
|
} & {
|
|
368
368
|
id: string;
|
|
369
|
-
assignmentId: string;
|
|
370
369
|
createdAt: Date;
|
|
370
|
+
assignmentId: string;
|
|
371
371
|
modifiedAt: Date;
|
|
372
372
|
studentId: string;
|
|
373
373
|
extendedResponse: string | null;
|
|
@@ -390,13 +390,13 @@ export declare function findAssignmentsWithFiles(classId: string): import(".pris
|
|
|
390
390
|
type: string;
|
|
391
391
|
name: string;
|
|
392
392
|
id: string;
|
|
393
|
-
size: number | null;
|
|
394
|
-
uploadedAt: Date | null;
|
|
395
|
-
thumbnailId: string | null;
|
|
396
393
|
user: {
|
|
397
394
|
id: string;
|
|
398
395
|
username: string;
|
|
399
396
|
} | null;
|
|
397
|
+
size: number | null;
|
|
398
|
+
uploadedAt: Date | null;
|
|
399
|
+
thumbnailId: string | null;
|
|
400
400
|
}[];
|
|
401
401
|
} & {
|
|
402
402
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
@@ -429,11 +429,11 @@ export declare function findFullExportableClass(classId: string): Promise<{
|
|
|
429
429
|
assignments: {
|
|
430
430
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
431
431
|
id: string;
|
|
432
|
+
createdAt: Date | null;
|
|
432
433
|
section: {
|
|
433
434
|
name: string;
|
|
434
435
|
id: string;
|
|
435
436
|
} | null;
|
|
436
|
-
createdAt: Date | null;
|
|
437
437
|
classId: string;
|
|
438
438
|
title: string;
|
|
439
439
|
instructions: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"/","sources":["models/class.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,EAAc,KAAK,EAAE,MAAM,EAAgE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"/","sources":["models/class.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,EAAc,KAAK,EAAE,MAAM,EAAgE,MAAM,gBAAgB,CAAC;AAoDzH,gDAAgD;AAChD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAKhD;AAED,gDAAgD;AAChD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAKhD;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;GAO/D;AAsHD,qFAAqF;AACrF,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,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