@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
package/dist/services/class.d.ts
CHANGED
|
@@ -74,6 +74,11 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
74
74
|
returned: boolean | null | undefined;
|
|
75
75
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
76
76
|
id: string;
|
|
77
|
+
createdAt: Date | null;
|
|
78
|
+
section: {
|
|
79
|
+
name: string;
|
|
80
|
+
id: string;
|
|
81
|
+
} | null;
|
|
77
82
|
submissions: {
|
|
78
83
|
id: string;
|
|
79
84
|
studentId: string;
|
|
@@ -84,11 +89,6 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
84
89
|
submitted: boolean | null;
|
|
85
90
|
returned: boolean | null;
|
|
86
91
|
}[];
|
|
87
|
-
section: {
|
|
88
|
-
name: string;
|
|
89
|
-
id: string;
|
|
90
|
-
} | null;
|
|
91
|
-
createdAt: Date | null;
|
|
92
92
|
title: string;
|
|
93
93
|
instructions: string;
|
|
94
94
|
dueDate: Date;
|
|
@@ -121,7 +121,7 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
121
121
|
} | null;
|
|
122
122
|
};
|
|
123
123
|
}[];
|
|
124
|
-
|
|
124
|
+
teachers: {
|
|
125
125
|
id: string;
|
|
126
126
|
username: string;
|
|
127
127
|
profile: {
|
|
@@ -130,7 +130,7 @@ export declare function getClass(userId: string, classId: string): Promise<{
|
|
|
130
130
|
profilePictureThumbnail: string | null;
|
|
131
131
|
} | null;
|
|
132
132
|
}[];
|
|
133
|
-
|
|
133
|
+
students: {
|
|
134
134
|
id: string;
|
|
135
135
|
username: string;
|
|
136
136
|
profile: {
|
|
@@ -167,6 +167,7 @@ export declare function createClass(userId: string, input: {
|
|
|
167
167
|
section: string;
|
|
168
168
|
subject: string;
|
|
169
169
|
color?: string;
|
|
170
|
+
schoolId?: string;
|
|
170
171
|
}): Promise<{
|
|
171
172
|
name: string;
|
|
172
173
|
id: string;
|
|
@@ -258,8 +259,8 @@ export declare function getGrades(userId: string, classId: string, targetUserId:
|
|
|
258
259
|
};
|
|
259
260
|
} & {
|
|
260
261
|
id: string;
|
|
261
|
-
assignmentId: string;
|
|
262
262
|
createdAt: Date;
|
|
263
|
+
assignmentId: string;
|
|
263
264
|
modifiedAt: Date;
|
|
264
265
|
studentId: string;
|
|
265
266
|
extendedResponse: string | null;
|
|
@@ -283,8 +284,8 @@ export declare function updateGrade(assignmentId: string, submissionId: string,
|
|
|
283
284
|
};
|
|
284
285
|
} & {
|
|
285
286
|
id: string;
|
|
286
|
-
assignmentId: string;
|
|
287
287
|
createdAt: Date;
|
|
288
|
+
assignmentId: string;
|
|
288
289
|
modifiedAt: Date;
|
|
289
290
|
studentId: string;
|
|
290
291
|
extendedResponse: string | null;
|
|
@@ -523,13 +524,13 @@ export declare function getFiles(classId: string): Promise<{
|
|
|
523
524
|
type: string;
|
|
524
525
|
name: string;
|
|
525
526
|
id: string;
|
|
526
|
-
size: number | null;
|
|
527
|
-
uploadedAt: Date | null;
|
|
528
|
-
thumbnailId: string | null;
|
|
529
527
|
user: {
|
|
530
528
|
id: string;
|
|
531
529
|
username: string;
|
|
532
530
|
} | null;
|
|
531
|
+
size: number | null;
|
|
532
|
+
uploadedAt: Date | null;
|
|
533
|
+
thumbnailId: string | null;
|
|
533
534
|
}[];
|
|
534
535
|
students: {
|
|
535
536
|
id: string;
|
|
@@ -539,26 +540,26 @@ export declare function getFiles(classId: string): Promise<{
|
|
|
539
540
|
type: string;
|
|
540
541
|
name: string;
|
|
541
542
|
id: string;
|
|
542
|
-
size: number | null;
|
|
543
|
-
uploadedAt: Date | null;
|
|
544
|
-
thumbnailId: string | null;
|
|
545
543
|
user: {
|
|
546
544
|
id: string;
|
|
547
545
|
username: string;
|
|
548
546
|
} | null;
|
|
547
|
+
size: number | null;
|
|
548
|
+
uploadedAt: Date | null;
|
|
549
|
+
thumbnailId: string | null;
|
|
549
550
|
}[];
|
|
550
551
|
annotations: {
|
|
551
552
|
path: string;
|
|
552
553
|
type: string;
|
|
553
554
|
name: string;
|
|
554
555
|
id: string;
|
|
555
|
-
size: number | null;
|
|
556
|
-
uploadedAt: Date | null;
|
|
557
|
-
thumbnailId: string | null;
|
|
558
556
|
user: {
|
|
559
557
|
id: string;
|
|
560
558
|
username: string;
|
|
561
559
|
} | null;
|
|
560
|
+
size: number | null;
|
|
561
|
+
uploadedAt: Date | null;
|
|
562
|
+
thumbnailId: string | null;
|
|
562
563
|
}[];
|
|
563
564
|
}[];
|
|
564
565
|
}[]>;
|
|
@@ -567,11 +568,11 @@ export declare function exportClass(classId: string, userId: string): Promise<{
|
|
|
567
568
|
assignments: {
|
|
568
569
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
569
570
|
id: string;
|
|
571
|
+
createdAt: Date | null;
|
|
570
572
|
section: {
|
|
571
573
|
name: string;
|
|
572
574
|
id: string;
|
|
573
575
|
} | null;
|
|
574
|
-
createdAt: Date | null;
|
|
575
576
|
classId: string;
|
|
576
577
|
title: string;
|
|
577
578
|
instructions: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"/","sources":["services/class.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"/","sources":["services/class.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE/C,sFAAsF;AACtF,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BjD;AAED,0EAA0E;AAC1E,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkC7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AAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,GAAG;IAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,mBAmBhI"}
|
package/dist/services/class.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* syllabus, lab drafts, and invite codes.
|
|
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]="c5ccb222-b8b2-53d6-9959-bb2ae34ed195")}catch(e){}}();
|
|
7
7
|
import { SessionType } from "@prisma/client";
|
|
8
8
|
import { TRPCError } from "@trpc/server";
|
|
9
9
|
import { prisma } from "../lib/prisma.js";
|
|
10
10
|
import { generateInviteCode } from "../utils/generateInviteCode.js";
|
|
11
11
|
import { findTeacherClasses, findStudentClasses, isTeacherInClass, findClassWithAssignments, findSectionsByClassId, findUserById, findSessionByClassCode, findSessionByClassId, findSubmissionsForGrades, findEventsByClassId, findMarkSchemesByClassId, findGradingBoundariesByClassId, findClassSyllabus, findLabDraftsByClass, findAssignmentsWithFiles, findFullExportableClass, createClassByImport, } from "../models/class.js";
|
|
12
|
+
import { listUserSchoolMemberships } from "../models/school.js";
|
|
12
13
|
/** Get all classes where user is teacher or student, with assignments and members. */
|
|
13
14
|
export async function getAllClasses(userId) {
|
|
14
15
|
const [teacherClasses, studentClasses] = await Promise.all([
|
|
@@ -79,7 +80,23 @@ export async function updateClass(classId, data) {
|
|
|
79
80
|
return { updatedClass };
|
|
80
81
|
}
|
|
81
82
|
export async function createClass(userId, input) {
|
|
82
|
-
const { students, teachers, name, section, subject, color } = input;
|
|
83
|
+
const { students, teachers, name, section, subject, color, schoolId } = input;
|
|
84
|
+
if (schoolId) {
|
|
85
|
+
const memberships = await listUserSchoolMemberships(userId);
|
|
86
|
+
const membership = memberships.find((item) => item.schoolId === schoolId);
|
|
87
|
+
if (!membership) {
|
|
88
|
+
throw new TRPCError({
|
|
89
|
+
code: "FORBIDDEN",
|
|
90
|
+
message: "You are not a member of this school",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (membership.role === "STUDENT") {
|
|
94
|
+
throw new TRPCError({
|
|
95
|
+
code: "FORBIDDEN",
|
|
96
|
+
message: "Students cannot create school classes",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
83
100
|
if (teachers && teachers.length > 0 && students && students.length > 0) {
|
|
84
101
|
return prisma.class.create({
|
|
85
102
|
data: {
|
|
@@ -87,6 +104,7 @@ export async function createClass(userId, input) {
|
|
|
87
104
|
section,
|
|
88
105
|
subject,
|
|
89
106
|
color,
|
|
107
|
+
schoolId,
|
|
90
108
|
teachers: { connect: teachers.map((id) => ({ id })) },
|
|
91
109
|
students: { connect: students.map((id) => ({ id })) },
|
|
92
110
|
},
|
|
@@ -99,6 +117,7 @@ export async function createClass(userId, input) {
|
|
|
99
117
|
section,
|
|
100
118
|
subject,
|
|
101
119
|
color,
|
|
120
|
+
schoolId,
|
|
102
121
|
teachers: { connect: { id: userId } },
|
|
103
122
|
},
|
|
104
123
|
});
|
|
@@ -486,4 +505,4 @@ export async function importClass(classId, userId, year, classData) {
|
|
|
486
505
|
}
|
|
487
506
|
}
|
|
488
507
|
//# sourceMappingURL=class.js.map
|
|
489
|
-
//# debugId=
|
|
508
|
+
//# debugId=c5ccb222-b8b2-53d6-9959-bb2ae34ed195
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sources":["services/class.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Class service – CRUD for classes, members, grades, mark schemes, grading boundaries,\n * syllabus, lab drafts, and invite codes.\n */\nimport { SessionType } from \"@prisma/client\";\nimport { TRPCError } from \"@trpc/server\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { generateInviteCode } from \"../utils/generateInviteCode.js\";\nimport {\n findTeacherClasses,\n findStudentClasses,\n isTeacherInClass,\n findClassWithAssignments,\n findSectionsByClassId,\n findUserById,\n findSessionByClassCode,\n findSessionByClassId,\n findSubmissionsForGrades,\n findEventsByClassId,\n findMarkSchemesByClassId,\n findGradingBoundariesByClassId,\n findClassSyllabus,\n findLabDraftsByClass,\n findAssignmentsWithFiles,\n findFullExportableClass,\n createClassByImport,\n} from \"../models/class.js\";\nimport { Class, Folder } from \"@prisma/client\";\n\n/** Get all classes where user is teacher or student, with assignments and members. */\nexport async function getAllClasses(userId: string) {\n const [teacherClasses, studentClasses] = await Promise.all([\n findTeacherClasses(userId),\n findStudentClasses(userId),\n ]);\n\n return {\n teacherInClass: teacherClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n studentInClass: studentClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n };\n}\n\n/** Get single class with assignments, sections, and submission status. */\nexport async function getClass(userId: string, classId: string) {\n const isTeacher = await isTeacherInClass(classId, userId ?? \"\");\n\n const classData = await findClassWithAssignments(classId, {\n isTeacher: !!isTeacher,\n userId: userId ?? undefined,\n });\n\n if (!classData) {\n throw new Error(\"Class not found\");\n }\n\n const formattedClassData = {\n ...classData,\n assignments: classData.assignments.map((assignment) => ({\n ...assignment,\n late: assignment.dueDate < new Date(),\n submitted: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.submitted,\n returned: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.returned,\n })),\n };\n\n const sections = await findSectionsByClassId(classId);\n\n return {\n class: {\n ...formattedClassData,\n sections,\n },\n };\n}\n\nexport async function updateClass(\n classId: string,\n data: { name?: string; section?: string; subject?: string }\n) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data,\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n return { updatedClass };\n}\n\nexport async function createClass(\n userId: string,\n input: {\n students?: string[];\n teachers?: string[];\n name: string;\n section: string;\n subject: string;\n color?: string;\n }\n) {\n const { students, teachers, name, section, subject, color } = input;\n\n if (teachers && teachers.length > 0 && students && students.length > 0) {\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: { connect: teachers.map((id) => ({ id })) },\n students: { connect: students.map((id) => ({ id })) },\n },\n include: { teachers: true, students: true },\n });\n }\n\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: { connect: { id: userId } },\n },\n });\n}\n\nexport async function deleteClass(classId: string) {\n const classToDelete = await prisma.class.findFirst({\n where: { id: classId },\n });\n\n if (!classToDelete) {\n throw new Error(\"Class not found or you don't have permission to delete it\");\n }\n\n await prisma.class.delete({\n where: { id: classId },\n });\n\n return { deletedClass: { id: classId } };\n}\n\nexport async function addStudent(classId: string, studentId: string) {\n const student = await findUserById(studentId);\n if (!student) {\n throw new Error(\"Student not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n students: { connect: { id: studentId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { updatedClass, newStudent: student };\n}\n\nexport async function changeRole(\n classId: string,\n userId: string,\n type: \"teacher\" | \"student\"\n) {\n const user = await findUserById(userId);\n if (!user) {\n throw new Error(\"User not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n [type === \"teacher\" ? \"teachers\" : \"students\"]: {\n connect: { id: userId },\n },\n [type === \"teacher\" ? \"students\" : \"teachers\"]: {\n disconnect: { id: userId },\n },\n },\n });\n\n return {\n updatedClass,\n user: { ...user, type },\n };\n}\n\nexport async function removeMember(classId: string, userId: string) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n teachers: { disconnect: { id: userId } },\n students: { disconnect: { id: userId } },\n },\n });\n return { updatedClass, removedUserId: userId };\n}\n\nexport async function leaveClass(userId: string, classId: string) {\n const classData = await prisma.class.findFirst({\n where: {\n id: classId,\n students: { some: { id: userId } },\n },\n });\n\n if (!classData) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Class not found or you are not a student in this class\",\n });\n }\n\n await prisma.class.update({\n where: { id: classId },\n data: {\n students: { disconnect: { id: userId } },\n },\n });\n\n return { success: true, leftClassId: classId };\n}\n\nexport async function joinClass(userId: string, classCode: string) {\n const session = await findSessionByClassCode(classCode);\n\n if (!session || !session.classId) {\n throw new Error(\"Class not found\");\n }\n\n if (session.expiresAt && session.expiresAt < new Date()) {\n throw new Error(\"Session expired\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: session.classId },\n data: {\n students: { connect: { id: userId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { joinedClass: updatedClass };\n}\n\nexport async function getInviteCode(classId: string) {\n const session = await findSessionByClassId(classId);\n\n if ((session?.expiresAt && session.expiresAt < new Date()) || !session) {\n const newSession = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n return { code: newSession.id };\n }\n\n return { code: session?.id };\n}\n\nexport async function createInviteCode(classId: string) {\n await prisma.session.deleteMany({\n where: { classId, type: SessionType.CLASS_INVITE },\n });\n\n const session = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n\n return { code: session.id };\n}\n\nexport async function getGrades(\n userId: string,\n classId: string,\n targetUserId: string\n) {\n const isTeacher = await isTeacherInClass(classId, userId);\n if (userId !== targetUserId && !isTeacher) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"You can only view your own grades\",\n });\n }\n\n const grades = await findSubmissionsForGrades(targetUserId, classId);\n return { grades };\n}\n\nexport async function updateGrade(\n assignmentId: string,\n submissionId: string,\n gradeReceived: number | null\n) {\n const updatedSubmission = await prisma.submission.update({\n where: { id: submissionId, assignmentId },\n data: { gradeReceived },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n },\n },\n },\n });\n return updatedSubmission;\n}\n\nexport async function getEvents(classId: string) {\n return findEventsByClassId(classId);\n}\n\nexport async function listMarkSchemes(classId: string) {\n return findMarkSchemesByClassId(classId);\n}\n\nexport async function createMarkScheme(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateMarkScheme(\n markSchemeId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.update({\n where: { id: markSchemeId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteMarkScheme(markSchemeId: string) {\n return prisma.markScheme.delete({\n where: { id: markSchemeId },\n });\n}\n\nexport async function listGradingBoundaries(classId: string) {\n return findGradingBoundariesByClassId(classId);\n}\n\nexport async function createGradingBoundary(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateGradingBoundary(\n gradingBoundaryId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.update({\n where: { id: gradingBoundaryId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteGradingBoundary(gradingBoundaryId: string) {\n return prisma.gradingBoundary.delete({\n where: { id: gradingBoundaryId },\n });\n}\n\nexport async function getSyllabus(classId: string) {\n const classData = await findClassSyllabus(classId);\n const markSchemes = await findMarkSchemesByClassId(classId);\n const gradingBoundaries = await findGradingBoundariesByClassId(classId);\n return {\n syllabus: classData?.syllabus,\n gradingBoundaries,\n markSchemes,\n };\n}\n\nexport async function updateSyllabus(classId: string, contents: string) {\n if (!contents) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Missing key contents\",\n });\n }\n return prisma.class.update({\n where: { id: classId },\n data: { syllabus: contents },\n });\n}\n\nexport async function listLabDrafts(classId: string, teacherId: string) {\n return findLabDraftsByClass(classId, teacherId);\n}\n\nexport async function createLabDraft(\n classId: string,\n teacherId: string,\n input: {\n title: string;\n type: string;\n instructions: string;\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n sectionId?: string;\n markSchemeId?: string;\n gradingBoundaryId?: string;\n }\n) {\n return prisma.assignment.create({\n data: {\n classId,\n teacherId,\n inProgress: true,\n graded: input.graded ?? false,\n maxGrade: input.maxGrade ?? 0,\n weight: input.weight ?? 1,\n dueDate:\n input.dueDate ||\n new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),\n title: input.title,\n instructions: input.instructions,\n type: input.type as any,\n ...(input.sectionId && { sectionId: input.sectionId }),\n ...(input.markSchemeId && { markSchemeId: input.markSchemeId }),\n ...(input.gradingBoundaryId && {\n gradingBoundaryId: input.gradingBoundaryId,\n }),\n },\n });\n}\n\nexport async function updateLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: Record<string, unknown>\n) {\n const updateData: Record<string, unknown> = {\n modifiedAt: new Date(),\n };\n if (input.title !== undefined) updateData.title = input.title;\n if (input.instructions !== undefined)\n updateData.instructions = input.instructions;\n if (input.dueDate !== undefined) updateData.dueDate = input.dueDate;\n if (input.maxGrade !== undefined) updateData.maxGrade = input.maxGrade;\n if (input.weight !== undefined) updateData.weight = input.weight;\n if (input.graded !== undefined) updateData.graded = input.graded;\n if (input.sectionId !== undefined) updateData.sectionId = input.sectionId;\n if (input.markSchemeId !== undefined)\n updateData.markSchemeId = input.markSchemeId;\n if (input.gradingBoundaryId !== undefined)\n updateData.gradingBoundaryId = input.gradingBoundaryId;\n\n return prisma.assignment.update({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n data: updateData as any,\n });\n}\n\nexport async function deleteLabDraft(\n classId: string,\n teacherId: string,\n draftId: string\n) {\n return prisma.assignment.delete({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n}\n\nexport async function publishLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: {\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n }\n) {\n const labDraft = await prisma.assignment.findUnique({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n\n if (!labDraft) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Lab draft not found\",\n });\n }\n\n return prisma.assignment.update({\n where: { id: draftId },\n data: {\n inProgress: false,\n dueDate: input.dueDate || labDraft.dueDate,\n maxGrade: input.maxGrade || labDraft.maxGrade || 100,\n weight: input.weight || labDraft.weight || 1,\n graded: input.graded !== undefined ? input.graded : true,\n modifiedAt: new Date(),\n },\n });\n}\n\nexport async function getFiles(classId: string) {\n const assignments = await findAssignmentsWithFiles(classId);\n return assignments.map((assignment) => ({\n id: assignment.id,\n title: assignment.title,\n teacher: assignment.teacher,\n teacherAttachments: assignment.attachments,\n students: assignment.submissions.map((submission) => ({\n id: submission.student.id,\n username: submission.student.username,\n attachments: submission.attachments,\n annotations: submission.annotations,\n })),\n }));\n}\n\nexport async function exportClass(classId: string, userId: string) {\n const classExport = await findFullExportableClass(classId);\n if (!classExport) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to export class\",\n });\n }\n\n return classExport;\n}\n\nexport async function importClass(classId: string, userId: string, year: number, classData: Class & { classFiles: Folder | null }) {\n try {\n const newClassId = await createClassByImport(classId, userId, year, classData);\n if (!newClassId) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to import class\",\n });\n }\n return newClassId;\n } catch (err) {\n if (err instanceof TRPCError) throw err;\n const message = err instanceof Error ? err.message : \"Unknown error\";\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: `Failed to import class: ${message}`,\n cause: err,\n });\n }\n}"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,8BAA8B,EAC9B,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc;IAChD,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzD,kBAAkB,CAAC,MAAM,CAAC;QAC1B,kBAAkB,CAAC,MAAM,CAAC;KAC3B,CAAC,CAAC;IAEH,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,GAA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AA2B,OAAO,EAAE;YAC7C,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;IACL,CAAC;AACH,CAAC","debug_id":"b0980742-2fbe-5c12-897f-ba5bf6ed98c4"}
|
|
1
|
+
{"version":3,"file":"class.js","sources":["services/class.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Class service – CRUD for classes, members, grades, mark schemes, grading boundaries,\n * syllabus, lab drafts, and invite codes.\n */\nimport { SessionType } from \"@prisma/client\";\nimport { TRPCError } from \"@trpc/server\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { generateInviteCode } from \"../utils/generateInviteCode.js\";\nimport {\n findTeacherClasses,\n findStudentClasses,\n isTeacherInClass,\n findClassWithAssignments,\n findSectionsByClassId,\n findUserById,\n findSessionByClassCode,\n findSessionByClassId,\n findSubmissionsForGrades,\n findEventsByClassId,\n findMarkSchemesByClassId,\n findGradingBoundariesByClassId,\n findClassSyllabus,\n findLabDraftsByClass,\n findAssignmentsWithFiles,\n findFullExportableClass,\n createClassByImport,\n} from \"../models/class.js\";\nimport { listUserSchoolMemberships } from \"../models/school.js\";\nimport { Class, Folder } from \"@prisma/client\";\n\n/** Get all classes where user is teacher or student, with assignments and members. */\nexport async function getAllClasses(userId: string) {\n const [teacherClasses, studentClasses] = await Promise.all([\n findTeacherClasses(userId),\n findStudentClasses(userId),\n ]);\n\n return {\n teacherInClass: teacherClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n studentInClass: studentClasses.map((cls) => ({\n id: cls.id,\n name: cls.name,\n section: cls.section,\n subject: cls.subject,\n dueToday: cls.assignments,\n assignments: cls.assignments,\n members: [...cls.students, ...cls.teachers],\n color: cls.color,\n })),\n };\n}\n\n/** Get single class with assignments, sections, and submission status. */\nexport async function getClass(userId: string, classId: string) {\n const isTeacher = await isTeacherInClass(classId, userId ?? \"\");\n\n const classData = await findClassWithAssignments(classId, {\n isTeacher: !!isTeacher,\n userId: userId ?? undefined,\n });\n\n if (!classData) {\n throw new Error(\"Class not found\");\n }\n\n const formattedClassData = {\n ...classData,\n assignments: classData.assignments.map((assignment) => ({\n ...assignment,\n late: assignment.dueDate < new Date(),\n submitted: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.submitted,\n returned: assignment.submissions.find(\n (s) => s.studentId === userId\n )?.returned,\n })),\n };\n\n const sections = await findSectionsByClassId(classId);\n\n return {\n class: {\n ...formattedClassData,\n sections,\n },\n };\n}\n\nexport async function updateClass(\n classId: string,\n data: { name?: string; section?: string; subject?: string }\n) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data,\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n return { updatedClass };\n}\n\nexport async function createClass(\n userId: string,\n input: {\n students?: string[];\n teachers?: string[];\n name: string;\n section: string;\n subject: string;\n color?: string;\n schoolId?: string;\n }\n) {\n const { students, teachers, name, section, subject, color, schoolId } = input;\n\n if (schoolId) {\n const memberships = await listUserSchoolMemberships(userId);\n const membership = memberships.find((item) => item.schoolId === schoolId);\n\n if (!membership) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You are not a member of this school\",\n });\n }\n\n if (membership.role === \"STUDENT\") {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Students cannot create school classes\",\n });\n }\n }\n\n if (teachers && teachers.length > 0 && students && students.length > 0) {\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n schoolId,\n teachers: { connect: teachers.map((id) => ({ id })) },\n students: { connect: students.map((id) => ({ id })) },\n },\n include: { teachers: true, students: true },\n });\n }\n\n return prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n schoolId,\n teachers: { connect: { id: userId } },\n },\n });\n}\n\nexport async function deleteClass(classId: string) {\n const classToDelete = await prisma.class.findFirst({\n where: { id: classId },\n });\n\n if (!classToDelete) {\n throw new Error(\"Class not found or you don't have permission to delete it\");\n }\n\n await prisma.class.delete({\n where: { id: classId },\n });\n\n return { deletedClass: { id: classId } };\n}\n\nexport async function addStudent(classId: string, studentId: string) {\n const student = await findUserById(studentId);\n if (!student) {\n throw new Error(\"Student not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n students: { connect: { id: studentId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { updatedClass, newStudent: student };\n}\n\nexport async function changeRole(\n classId: string,\n userId: string,\n type: \"teacher\" | \"student\"\n) {\n const user = await findUserById(userId);\n if (!user) {\n throw new Error(\"User not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n [type === \"teacher\" ? \"teachers\" : \"students\"]: {\n connect: { id: userId },\n },\n [type === \"teacher\" ? \"students\" : \"teachers\"]: {\n disconnect: { id: userId },\n },\n },\n });\n\n return {\n updatedClass,\n user: { ...user, type },\n };\n}\n\nexport async function removeMember(classId: string, userId: string) {\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n teachers: { disconnect: { id: userId } },\n students: { disconnect: { id: userId } },\n },\n });\n return { updatedClass, removedUserId: userId };\n}\n\nexport async function leaveClass(userId: string, classId: string) {\n const classData = await prisma.class.findFirst({\n where: {\n id: classId,\n students: { some: { id: userId } },\n },\n });\n\n if (!classData) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Class not found or you are not a student in this class\",\n });\n }\n\n await prisma.class.update({\n where: { id: classId },\n data: {\n students: { disconnect: { id: userId } },\n },\n });\n\n return { success: true, leftClassId: classId };\n}\n\nexport async function joinClass(userId: string, classCode: string) {\n const session = await findSessionByClassCode(classCode);\n\n if (!session || !session.classId) {\n throw new Error(\"Class not found\");\n }\n\n if (session.expiresAt && session.expiresAt < new Date()) {\n throw new Error(\"Session expired\");\n }\n\n const updatedClass = await prisma.class.update({\n where: { id: session.classId },\n data: {\n students: { connect: { id: userId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return { joinedClass: updatedClass };\n}\n\nexport async function getInviteCode(classId: string) {\n const session = await findSessionByClassId(classId);\n\n if ((session?.expiresAt && session.expiresAt < new Date()) || !session) {\n const newSession = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n return { code: newSession.id };\n }\n\n return { code: session?.id };\n}\n\nexport async function createInviteCode(classId: string) {\n await prisma.session.deleteMany({\n where: { classId, type: SessionType.CLASS_INVITE },\n });\n\n const session = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n type: SessionType.CLASS_INVITE,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),\n },\n });\n\n return { code: session.id };\n}\n\nexport async function getGrades(\n userId: string,\n classId: string,\n targetUserId: string\n) {\n const isTeacher = await isTeacherInClass(classId, userId);\n if (userId !== targetUserId && !isTeacher) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"You can only view your own grades\",\n });\n }\n\n const grades = await findSubmissionsForGrades(targetUserId, classId);\n return { grades };\n}\n\nexport async function updateGrade(\n assignmentId: string,\n submissionId: string,\n gradeReceived: number | null\n) {\n const updatedSubmission = await prisma.submission.update({\n where: { id: submissionId, assignmentId },\n data: { gradeReceived },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n },\n },\n },\n });\n return updatedSubmission;\n}\n\nexport async function getEvents(classId: string) {\n return findEventsByClassId(classId);\n}\n\nexport async function listMarkSchemes(classId: string) {\n return findMarkSchemesByClassId(classId);\n}\n\nexport async function createMarkScheme(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateMarkScheme(\n markSchemeId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.markScheme.update({\n where: { id: markSchemeId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteMarkScheme(markSchemeId: string) {\n return prisma.markScheme.delete({\n where: { id: markSchemeId },\n });\n}\n\nexport async function listGradingBoundaries(classId: string) {\n return findGradingBoundariesByClassId(classId);\n}\n\nexport async function createGradingBoundary(classId: string, structure: string) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.create({\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function updateGradingBoundary(\n gradingBoundaryId: string,\n classId: string,\n structure: string\n) {\n const validatedStructure = structure.replace(/\\\\n/g, \"\\n\");\n return prisma.gradingBoundary.update({\n where: { id: gradingBoundaryId },\n data: {\n class: { connect: { id: classId } },\n structured: validatedStructure,\n },\n });\n}\n\nexport async function deleteGradingBoundary(gradingBoundaryId: string) {\n return prisma.gradingBoundary.delete({\n where: { id: gradingBoundaryId },\n });\n}\n\nexport async function getSyllabus(classId: string) {\n const classData = await findClassSyllabus(classId);\n const markSchemes = await findMarkSchemesByClassId(classId);\n const gradingBoundaries = await findGradingBoundariesByClassId(classId);\n return {\n syllabus: classData?.syllabus,\n gradingBoundaries,\n markSchemes,\n };\n}\n\nexport async function updateSyllabus(classId: string, contents: string) {\n if (!contents) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Missing key contents\",\n });\n }\n return prisma.class.update({\n where: { id: classId },\n data: { syllabus: contents },\n });\n}\n\nexport async function listLabDrafts(classId: string, teacherId: string) {\n return findLabDraftsByClass(classId, teacherId);\n}\n\nexport async function createLabDraft(\n classId: string,\n teacherId: string,\n input: {\n title: string;\n type: string;\n instructions: string;\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n sectionId?: string;\n markSchemeId?: string;\n gradingBoundaryId?: string;\n }\n) {\n return prisma.assignment.create({\n data: {\n classId,\n teacherId,\n inProgress: true,\n graded: input.graded ?? false,\n maxGrade: input.maxGrade ?? 0,\n weight: input.weight ?? 1,\n dueDate:\n input.dueDate ||\n new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),\n title: input.title,\n instructions: input.instructions,\n type: input.type as any,\n ...(input.sectionId && { sectionId: input.sectionId }),\n ...(input.markSchemeId && { markSchemeId: input.markSchemeId }),\n ...(input.gradingBoundaryId && {\n gradingBoundaryId: input.gradingBoundaryId,\n }),\n },\n });\n}\n\nexport async function updateLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: Record<string, unknown>\n) {\n const updateData: Record<string, unknown> = {\n modifiedAt: new Date(),\n };\n if (input.title !== undefined) updateData.title = input.title;\n if (input.instructions !== undefined)\n updateData.instructions = input.instructions;\n if (input.dueDate !== undefined) updateData.dueDate = input.dueDate;\n if (input.maxGrade !== undefined) updateData.maxGrade = input.maxGrade;\n if (input.weight !== undefined) updateData.weight = input.weight;\n if (input.graded !== undefined) updateData.graded = input.graded;\n if (input.sectionId !== undefined) updateData.sectionId = input.sectionId;\n if (input.markSchemeId !== undefined)\n updateData.markSchemeId = input.markSchemeId;\n if (input.gradingBoundaryId !== undefined)\n updateData.gradingBoundaryId = input.gradingBoundaryId;\n\n return prisma.assignment.update({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n data: updateData as any,\n });\n}\n\nexport async function deleteLabDraft(\n classId: string,\n teacherId: string,\n draftId: string\n) {\n return prisma.assignment.delete({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n}\n\nexport async function publishLabDraft(\n classId: string,\n teacherId: string,\n draftId: string,\n input: {\n dueDate?: Date;\n maxGrade?: number;\n weight?: number;\n graded?: boolean;\n }\n) {\n const labDraft = await prisma.assignment.findUnique({\n where: {\n id: draftId,\n classId,\n teacherId,\n inProgress: true,\n },\n });\n\n if (!labDraft) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Lab draft not found\",\n });\n }\n\n return prisma.assignment.update({\n where: { id: draftId },\n data: {\n inProgress: false,\n dueDate: input.dueDate || labDraft.dueDate,\n maxGrade: input.maxGrade || labDraft.maxGrade || 100,\n weight: input.weight || labDraft.weight || 1,\n graded: input.graded !== undefined ? input.graded : true,\n modifiedAt: new Date(),\n },\n });\n}\n\nexport async function getFiles(classId: string) {\n const assignments = await findAssignmentsWithFiles(classId);\n return assignments.map((assignment) => ({\n id: assignment.id,\n title: assignment.title,\n teacher: assignment.teacher,\n teacherAttachments: assignment.attachments,\n students: assignment.submissions.map((submission) => ({\n id: submission.student.id,\n username: submission.student.username,\n attachments: submission.attachments,\n annotations: submission.annotations,\n })),\n }));\n}\n\nexport async function exportClass(classId: string, userId: string) {\n const classExport = await findFullExportableClass(classId);\n if (!classExport) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to export class\",\n });\n }\n\n return classExport;\n}\n\nexport async function importClass(classId: string, userId: string, year: number, classData: Class & { classFiles: Folder | null }) {\n try {\n const newClassId = await createClassByImport(classId, userId, year, classData);\n if (!newClassId) {\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to import class\",\n });\n }\n return newClassId;\n } catch (err) {\n if (err instanceof TRPCError) throw err;\n const message = err instanceof Error ? err.message : \"Unknown error\";\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: `Failed to import class: ${message}`,\n cause: err,\n });\n }\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,YAA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ed195"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Get a comment by ID. */
|
|
2
2
|
export declare function getComment(userId: string, id: string): Promise<{
|
|
3
3
|
id: string;
|
|
4
|
+
createdAt: Date;
|
|
4
5
|
assignmentId: string | null;
|
|
5
6
|
submissionId: string | null;
|
|
6
7
|
announcementId: string | null;
|
|
@@ -16,7 +17,6 @@ export declare function getComment(userId: string, id: string): Promise<{
|
|
|
16
17
|
} | null;
|
|
17
18
|
};
|
|
18
19
|
}[];
|
|
19
|
-
createdAt: Date;
|
|
20
20
|
modifiedAt: Date | null;
|
|
21
21
|
content: string;
|
|
22
22
|
parentCommentId: string | null;
|
|
@@ -44,10 +44,10 @@ export declare function getReplies(userId: string, commentId: string): Promise<(
|
|
|
44
44
|
} & {
|
|
45
45
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
46
46
|
id: string;
|
|
47
|
+
createdAt: Date;
|
|
47
48
|
assignmentId: string | null;
|
|
48
49
|
submissionId: string | null;
|
|
49
50
|
announcementId: string | null;
|
|
50
|
-
createdAt: Date;
|
|
51
51
|
modifiedAt: Date | null;
|
|
52
52
|
content: string;
|
|
53
53
|
authorId: string;
|
|
@@ -58,10 +58,10 @@ export declare function getReplies(userId: string, commentId: string): Promise<(
|
|
|
58
58
|
export declare function replyToComment(userId: string, parentCommentId: string, content: string): Promise<{
|
|
59
59
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
60
60
|
id: string;
|
|
61
|
+
createdAt: Date;
|
|
61
62
|
assignmentId: string | null;
|
|
62
63
|
submissionId: string | null;
|
|
63
64
|
announcementId: string | null;
|
|
64
|
-
createdAt: Date;
|
|
65
65
|
modifiedAt: Date | null;
|
|
66
66
|
content: string;
|
|
67
67
|
authorId: string;
|
|
@@ -72,10 +72,10 @@ export declare function replyToComment(userId: string, parentCommentId: string,
|
|
|
72
72
|
export declare function updateComment(userId: string, id: string, content: string): Promise<{
|
|
73
73
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
74
74
|
id: string;
|
|
75
|
+
createdAt: Date;
|
|
75
76
|
assignmentId: string | null;
|
|
76
77
|
submissionId: string | null;
|
|
77
78
|
announcementId: string | null;
|
|
78
|
-
createdAt: Date;
|
|
79
79
|
modifiedAt: Date | null;
|
|
80
80
|
content: string;
|
|
81
81
|
authorId: string;
|
|
@@ -101,9 +101,9 @@ export declare function addReaction(userId: string, commentId: string, type: str
|
|
|
101
101
|
} & {
|
|
102
102
|
type: import(".prisma/client").$Enums.ReactionType;
|
|
103
103
|
id: string;
|
|
104
|
+
createdAt: Date;
|
|
104
105
|
userId: string;
|
|
105
106
|
announcementId: string | null;
|
|
106
|
-
createdAt: Date;
|
|
107
107
|
commentId: string | null;
|
|
108
108
|
};
|
|
109
109
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.d.ts","sourceRoot":"/","sources":["services/comment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"comment.d.ts","sourceRoot":"/","sources":["services/comment.ts"],"names":[],"mappings":"AA6FA,2BAA2B;AAC3B,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAU1D;AAED,oCAAoC;AACpC,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;MAGjE;AAED,6CAA6C;AAC7C,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM;;;;;;;;;;;;GAYhB;AAED,6CAA6C;AAC7C,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;GAa9E;AAED,6EAA6E;AAC7E,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;GAW7D;AAED,qDAAqD;AACrD,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAMb;AAED,6CAA6C;AAC7C,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;GAWrE;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;GAuBnE"}
|
package/dist/services/comment.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Comment service – get comments, replies, and reactions.
|
|
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]="3b159ee4-0b57-5fbd-abfa-06234f7273dd")}catch(e){}}();
|
|
6
6
|
import { TRPCError } from "@trpc/server";
|
|
7
7
|
import { prisma } from "../lib/prisma.js";
|
|
8
8
|
import { findCommentById, findRepliesByCommentId, createComment, findReactionByUserAndComment, upsertReaction, deleteReactionById, findCommentWithContext, getReactionCountsByCommentId, } from "../models/comment.js";
|
|
@@ -27,12 +27,17 @@ function getPrivateStudentId(comment) {
|
|
|
27
27
|
null);
|
|
28
28
|
}
|
|
29
29
|
function isClassTeacher(comment, userId) {
|
|
30
|
-
|
|
30
|
+
const classData = getCommentClass(comment);
|
|
31
|
+
return Boolean(classData?.teachers?.some((teacher) => teacher.id === userId) ||
|
|
32
|
+
classData?.school?.memberships?.some((admin) => admin.userId === userId) ||
|
|
33
|
+
classData?.school?.users?.some((admin) => admin.id === userId));
|
|
31
34
|
}
|
|
32
35
|
function isClassMember(comment, userId) {
|
|
33
36
|
const classData = getCommentClass(comment);
|
|
34
37
|
return (classData?.teachers?.some((teacher) => teacher.id === userId) ||
|
|
35
38
|
classData?.students?.some((student) => student.id === userId) ||
|
|
39
|
+
classData?.school?.memberships?.some((admin) => admin.userId === userId) ||
|
|
40
|
+
classData?.school?.users?.some((admin) => admin.id === userId) ||
|
|
36
41
|
false);
|
|
37
42
|
}
|
|
38
43
|
function canReadComment(comment, userId) {
|
|
@@ -158,4 +163,4 @@ export async function getReactions(userId, commentId) {
|
|
|
158
163
|
};
|
|
159
164
|
}
|
|
160
165
|
//# sourceMappingURL=comment.js.map
|
|
161
|
-
//# debugId=
|
|
166
|
+
//# debugId=3b159ee4-0b57-5fbd-abfa-06234f7273dd
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.js","sources":["services/comment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Comment service – get comments, replies, and reactions.\n */\nimport { TRPCError } from \"@trpc/server\";\nimport { prisma } from \"../lib/prisma.js\";\nimport {\n findCommentById,\n findRepliesByCommentId,\n createComment,\n findReactionByUserAndComment,\n upsertReaction,\n deleteReactionById,\n findCommentWithContext,\n getReactionCountsByCommentId,\n} from \"../models/comment.js\";\n\nfunction getCommentClass(comment: any) {\n return (\n comment.announcement?.class ??\n comment.assignment?.class ??\n comment.submission?.assignment?.class ??\n comment.studentQuestionProgress?.studentWorksheetResponse?.submission?.assignment?.class ??\n comment.parentComment?.announcement?.class ??\n comment.parentComment?.assignment?.class ??\n comment.parentComment?.submission?.assignment?.class ??\n comment.parentComment?.studentQuestionProgress?.studentWorksheetResponse?.submission?.assignment?.class ??\n null\n );\n}\n\nfunction getPrivateStudentId(comment: any) {\n return (\n comment.submission?.studentId ??\n comment.studentQuestionProgress?.studentWorksheetResponse?.submission?.studentId ??\n comment.studentQuestionProgress?.studentId ??\n comment.parentComment?.submission?.studentId ??\n comment.parentComment?.studentQuestionProgress?.studentWorksheetResponse?.submission?.studentId ??\n comment.parentComment?.studentQuestionProgress?.studentId ??\n null\n );\n}\n\nfunction isClassTeacher(comment: any, userId: string) {\n return getCommentClass(comment)?.teachers?.some((teacher: { id: string }) => teacher.id === userId) ?? false;\n}\n\nfunction isClassMember(comment: any, userId: string) {\n const classData = getCommentClass(comment);\n return (\n classData?.teachers?.some((teacher: { id: string }) => teacher.id === userId) ||\n classData?.students?.some((student: { id: string }) => student.id === userId) ||\n false\n );\n}\n\nfunction canReadComment(comment: any, userId: string) {\n const privateStudentId = getPrivateStudentId(comment);\n if (privateStudentId) {\n return privateStudentId === userId || isClassTeacher(comment, userId);\n }\n return isClassMember(comment, userId);\n}\n\nfunction canDeleteComment(comment: any, userId: string) {\n return comment.authorId === userId || isClassTeacher(comment, userId);\n}\n\nasync function requireCommentAccess(commentId: string, userId: string) {\n const comment = await findCommentWithContext(commentId);\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n if (!canReadComment(comment, userId)) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You do not have access to this comment\",\n });\n }\n return comment;\n}\n\n/** Get a comment by ID. */\nexport async function getComment(userId: string, id: string) {\n await requireCommentAccess(id, userId);\n const comment = await findCommentById(id);\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n return comment;\n}\n\n/** Get all replies to a comment. */\nexport async function getReplies(userId: string, commentId: string) {\n await requireCommentAccess(commentId, userId);\n return findRepliesByCommentId(commentId);\n}\n\n/** Create a reply to an existing comment. */\nexport async function replyToComment(\n userId: string,\n parentCommentId: string,\n content: string\n) {\n const parentComment = await requireCommentAccess(parentCommentId, userId);\n return createComment({\n parentCommentId,\n content,\n authorId: userId,\n announcementId: parentComment.announcementId,\n assignmentId: parentComment.assignmentId,\n submissionId: parentComment.submissionId,\n studentQuestionProgressId: parentComment.studentQuestionProgressId,\n });\n}\n\n/** Update a comment authored by the user. */\nexport async function updateComment(userId: string, id: string, content: string) {\n const comment = await requireCommentAccess(id, userId);\n if (comment.authorId !== userId) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Only the comment author can update this comment\",\n });\n }\n\n return prisma.comment.update({\n where: { id },\n data: { content },\n });\n}\n\n/** Delete a comment authored by the user or moderated by a class teacher. */\nexport async function deleteComment(userId: string, id: string) {\n const comment = await requireCommentAccess(id, userId);\n if (!canDeleteComment(comment, userId)) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Only the comment author or class teachers can delete comments\",\n });\n }\n\n await prisma.comment.delete({ where: { id } });\n return { success: true };\n}\n\n/** Add or update a reaction (emoji) on a comment. */\nexport async function addReaction(\n userId: string,\n commentId: string,\n type: string\n) {\n await requireCommentAccess(commentId, userId);\n\n const reaction = await upsertReaction({ userId, commentId, type });\n return { reaction };\n}\n\n/** Remove user's reaction from a comment. */\nexport async function removeReaction(userId: string, commentId: string) {\n await requireCommentAccess(commentId, userId);\n const reaction = await findReactionByUserAndComment(userId, commentId);\n if (!reaction) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Reaction not found\",\n });\n }\n await deleteReactionById(reaction.id);\n return { success: true };\n}\n\nexport async function getReactions(userId: string, commentId: string) {\n await requireCommentAccess(commentId, userId);\n\n const reactionCounts = await getReactionCountsByCommentId(commentId);\n const userReaction = await findReactionByUserAndComment(userId, commentId);\n\n const counts = {\n THUMBSUP: 0,\n CELEBRATE: 0,\n CARE: 0,\n HEART: 0,\n IDEA: 0,\n HAPPY: 0,\n };\n reactionCounts.forEach((item) => {\n counts[item.type as keyof typeof counts] = item._count.type;\n });\n\n return {\n counts,\n userReaction: userReaction?.type || null,\n total: reactionCounts.reduce((sum, item) => sum + item._count.type, 0),\n };\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM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340cd4-2a5e-59d9-8448-05f1acff840a"}
|
|
1
|
+
{"version":3,"file":"comment.js","sources":["services/comment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Comment service – get comments, replies, and reactions.\n */\nimport { TRPCError } from \"@trpc/server\";\nimport { prisma } from \"../lib/prisma.js\";\nimport {\n findCommentById,\n findRepliesByCommentId,\n createComment,\n findReactionByUserAndComment,\n upsertReaction,\n deleteReactionById,\n findCommentWithContext,\n getReactionCountsByCommentId,\n} from \"../models/comment.js\";\n\nfunction getCommentClass(comment: any) {\n return (\n comment.announcement?.class ??\n comment.assignment?.class ??\n comment.submission?.assignment?.class ??\n comment.studentQuestionProgress?.studentWorksheetResponse?.submission?.assignment?.class ??\n comment.parentComment?.announcement?.class ??\n comment.parentComment?.assignment?.class ??\n comment.parentComment?.submission?.assignment?.class ??\n comment.parentComment?.studentQuestionProgress?.studentWorksheetResponse?.submission?.assignment?.class ??\n null\n );\n}\n\nfunction getPrivateStudentId(comment: any) {\n return (\n comment.submission?.studentId ??\n comment.studentQuestionProgress?.studentWorksheetResponse?.submission?.studentId ??\n comment.studentQuestionProgress?.studentId ??\n comment.parentComment?.submission?.studentId ??\n comment.parentComment?.studentQuestionProgress?.studentWorksheetResponse?.submission?.studentId ??\n comment.parentComment?.studentQuestionProgress?.studentId ??\n null\n );\n}\n\nfunction isClassTeacher(comment: any, userId: string) {\n const classData = getCommentClass(comment);\n return Boolean(\n classData?.teachers?.some((teacher: { id: string }) => teacher.id === userId) ||\n classData?.school?.memberships?.some(\n (admin: { userId: string }) => admin.userId === userId\n ) ||\n classData?.school?.users?.some((admin: { id: string }) => admin.id === userId)\n );\n}\n\nfunction isClassMember(comment: any, userId: string) {\n const classData = getCommentClass(comment);\n return (\n classData?.teachers?.some((teacher: { id: string }) => teacher.id === userId) ||\n classData?.students?.some((student: { id: string }) => student.id === userId) ||\n classData?.school?.memberships?.some((admin: { userId: string }) => admin.userId === userId) ||\n classData?.school?.users?.some((admin: { id: string }) => admin.id === userId) ||\n false\n );\n}\n\nfunction canReadComment(comment: any, userId: string) {\n const privateStudentId = getPrivateStudentId(comment);\n if (privateStudentId) {\n return privateStudentId === userId || isClassTeacher(comment, userId);\n }\n return isClassMember(comment, userId);\n}\n\nfunction canDeleteComment(comment: any, userId: string) {\n return comment.authorId === userId || isClassTeacher(comment, userId);\n}\n\nasync function requireCommentAccess(commentId: string, userId: string) {\n const comment = await findCommentWithContext(commentId);\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n if (!canReadComment(comment, userId)) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You do not have access to this comment\",\n });\n }\n return comment;\n}\n\n/** Get a comment by ID. */\nexport async function getComment(userId: string, id: string) {\n await requireCommentAccess(id, userId);\n const comment = await findCommentById(id);\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n return comment;\n}\n\n/** Get all replies to a comment. */\nexport async function getReplies(userId: string, commentId: string) {\n await requireCommentAccess(commentId, userId);\n return findRepliesByCommentId(commentId);\n}\n\n/** Create a reply to an existing comment. */\nexport async function replyToComment(\n userId: string,\n parentCommentId: string,\n content: string\n) {\n const parentComment = await requireCommentAccess(parentCommentId, userId);\n return createComment({\n parentCommentId,\n content,\n authorId: userId,\n announcementId: parentComment.announcementId,\n assignmentId: parentComment.assignmentId,\n submissionId: parentComment.submissionId,\n studentQuestionProgressId: parentComment.studentQuestionProgressId,\n });\n}\n\n/** Update a comment authored by the user. */\nexport async function updateComment(userId: string, id: string, content: string) {\n const comment = await requireCommentAccess(id, userId);\n if (comment.authorId !== userId) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Only the comment author can update this comment\",\n });\n }\n\n return prisma.comment.update({\n where: { id },\n data: { content },\n });\n}\n\n/** Delete a comment authored by the user or moderated by a class teacher. */\nexport async function deleteComment(userId: string, id: string) {\n const comment = await requireCommentAccess(id, userId);\n if (!canDeleteComment(comment, userId)) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Only the comment author or class teachers can delete comments\",\n });\n }\n\n await prisma.comment.delete({ where: { id } });\n return { success: true };\n}\n\n/** Add or update a reaction (emoji) on a comment. */\nexport async function addReaction(\n userId: string,\n commentId: string,\n type: string\n) {\n await requireCommentAccess(commentId, userId);\n\n const reaction = await upsertReaction({ userId, commentId, type });\n return { reaction };\n}\n\n/** Remove user's reaction from a comment. */\nexport async function removeReaction(userId: string, commentId: string) {\n await requireCommentAccess(commentId, userId);\n const reaction = await findReactionByUserAndComment(userId, commentId);\n if (!reaction) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Reaction not found\",\n });\n }\n await deleteReactionById(reaction.id);\n return { success: true };\n}\n\nexport async function getReactions(userId: string, commentId: string) {\n await requireCommentAccess(commentId, userId);\n\n const reactionCounts = await getReactionCountsByCommentId(commentId);\n const userReaction = await findReactionByUserAndComment(userId, commentId);\n\n const counts = {\n THUMBSUP: 0,\n CELEBRATE: 0,\n CARE: 0,\n HEART: 0,\n IDEA: 0,\n HAPPY: 0,\n };\n reactionCounts.forEach((item) => {\n counts[item.type as keyof typeof counts] = item._count.type;\n });\n\n return {\n counts,\n userReaction: userReaction?.type || null,\n total: reactionCounts.reduce((sum, item) => sum + item._count.type, 0),\n };\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,4BAA4B,EAC5B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,SAAS,eAAe,CAAC,OAAY;IACnC,OAAO,CACL,OAAO,CAAC,YAAY,EAAE,KAAK;QAC3B,OAAO,CAAC,UAAU,EAAE,KAAK;QACzB,OAAO,CAAC,UAA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IAAI;QACxC,KAAK,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC","debug_id":"3b159ee4-0b57-5fbd-abfa-06234f7273dd"}
|
|
@@ -20,9 +20,9 @@ export declare function listConversations(userId: string): Promise<{
|
|
|
20
20
|
};
|
|
21
21
|
} & {
|
|
22
22
|
id: string;
|
|
23
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
23
24
|
userId: string;
|
|
24
25
|
conversationId: string;
|
|
25
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
26
26
|
joinedAt: Date;
|
|
27
27
|
hiddenAt: Date | null;
|
|
28
28
|
lastViewedAt: Date | null;
|
|
@@ -40,8 +40,8 @@ export declare function listConversations(userId: string): Promise<{
|
|
|
40
40
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
41
41
|
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
42
42
|
id: string;
|
|
43
|
-
conversationId: string;
|
|
44
43
|
createdAt: Date;
|
|
44
|
+
conversationId: string;
|
|
45
45
|
content: string;
|
|
46
46
|
senderId: string;
|
|
47
47
|
};
|
|
@@ -64,9 +64,9 @@ export declare function createConversationRecord(userId: string, type: "DM" | "G
|
|
|
64
64
|
};
|
|
65
65
|
} & {
|
|
66
66
|
id: string;
|
|
67
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
67
68
|
userId: string;
|
|
68
69
|
conversationId: string;
|
|
69
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
70
70
|
joinedAt: Date;
|
|
71
71
|
hiddenAt: Date | null;
|
|
72
72
|
lastViewedAt: Date | null;
|
|
@@ -92,9 +92,9 @@ export declare function getConversation(userId: string, conversationId: string):
|
|
|
92
92
|
};
|
|
93
93
|
} & {
|
|
94
94
|
id: string;
|
|
95
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
95
96
|
userId: string;
|
|
96
97
|
conversationId: string;
|
|
97
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
98
98
|
joinedAt: Date;
|
|
99
99
|
hiddenAt: Date | null;
|
|
100
100
|
lastViewedAt: Date | null;
|
|
@@ -120,9 +120,9 @@ export declare function addMemberToConversation(userId: string, conversationId:
|
|
|
120
120
|
};
|
|
121
121
|
} & {
|
|
122
122
|
id: string;
|
|
123
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
123
124
|
userId: string;
|
|
124
125
|
conversationId: string;
|
|
125
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
126
126
|
joinedAt: Date;
|
|
127
127
|
hiddenAt: Date | null;
|
|
128
128
|
lastViewedAt: Date | null;
|
|
@@ -148,9 +148,9 @@ export declare function removeMemberFromConversation(userId: string, conversatio
|
|
|
148
148
|
};
|
|
149
149
|
} & {
|
|
150
150
|
id: string;
|
|
151
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
151
152
|
userId: string;
|
|
152
153
|
conversationId: string;
|
|
153
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
154
154
|
joinedAt: Date;
|
|
155
155
|
hiddenAt: Date | null;
|
|
156
156
|
lastViewedAt: Date | null;
|
package/dist/services/event.d.ts
CHANGED
|
@@ -10,7 +10,26 @@ export declare function getEvent(userId: string, id: string): Promise<{
|
|
|
10
10
|
role: import(".prisma/client").$Enums.UserRole;
|
|
11
11
|
schoolId: string | null;
|
|
12
12
|
} | null;
|
|
13
|
-
class: {
|
|
13
|
+
class: ({
|
|
14
|
+
school: ({
|
|
15
|
+
users: {
|
|
16
|
+
id: string;
|
|
17
|
+
}[];
|
|
18
|
+
memberships: {
|
|
19
|
+
userId: string;
|
|
20
|
+
}[];
|
|
21
|
+
} & {
|
|
22
|
+
name: string;
|
|
23
|
+
id: string;
|
|
24
|
+
logoId: string | null;
|
|
25
|
+
subdomain: string | null;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
}) | null;
|
|
29
|
+
teachers: {
|
|
30
|
+
id: string;
|
|
31
|
+
}[];
|
|
32
|
+
} & {
|
|
14
33
|
name: string;
|
|
15
34
|
id: string;
|
|
16
35
|
schoolId: string | null;
|
|
@@ -18,7 +37,7 @@ export declare function getEvent(userId: string, id: string): Promise<{
|
|
|
18
37
|
color: string | null;
|
|
19
38
|
section: string;
|
|
20
39
|
syllabus: string | null;
|
|
21
|
-
} | null;
|
|
40
|
+
}) | null;
|
|
22
41
|
assignmentsAttached: {
|
|
23
42
|
type: import(".prisma/client").$Enums.AssignmentType;
|
|
24
43
|
id: string;
|