@studious-lms/server 1.2.45 → 1.2.47
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/.env.example +45 -0
- package/.env.test.example +37 -0
- package/README.md +34 -7
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +12110 -0
- package/coverage/coverage-final.json +44 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +221 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/server/index.html +116 -0
- package/coverage/server/src/exportType.ts.html +109 -0
- package/coverage/server/src/index.html +161 -0
- package/coverage/server/src/index.ts.html +1702 -0
- package/coverage/server/src/instrument.ts.html +130 -0
- package/coverage/server/src/lib/config/env.ts.html +448 -0
- package/coverage/server/src/lib/config/index.html +116 -0
- package/coverage/server/src/lib/fileUpload.ts.html +1138 -0
- package/coverage/server/src/lib/googleCloudStorage.ts.html +334 -0
- package/coverage/server/src/lib/index.html +206 -0
- package/coverage/server/src/lib/jsonConversion.ts.html +2323 -0
- package/coverage/server/src/lib/jsonStyles.ts.html +193 -0
- package/coverage/server/src/lib/notificationHandler.ts.html +193 -0
- package/coverage/server/src/lib/pusher.ts.html +121 -0
- package/coverage/server/src/lib/thumbnailGenerator.ts.html +592 -0
- package/coverage/server/src/middleware/auth.ts.html +646 -0
- package/coverage/server/src/middleware/index.html +146 -0
- package/coverage/server/src/middleware/logging.ts.html +244 -0
- package/coverage/server/src/middleware/security.ts.html +271 -0
- package/coverage/server/src/routers/_app.ts.html +232 -0
- package/coverage/server/src/routers/agenda.ts.html +319 -0
- package/coverage/server/src/routers/announcement.ts.html +3481 -0
- package/coverage/server/src/routers/assignment.ts.html +7633 -0
- package/coverage/server/src/routers/attendance.ts.html +1030 -0
- package/coverage/server/src/routers/auth.ts.html +1081 -0
- package/coverage/server/src/routers/class.ts.html +3535 -0
- package/coverage/server/src/routers/comment.ts.html +991 -0
- package/coverage/server/src/routers/conversation.ts.html +982 -0
- package/coverage/server/src/routers/event.ts.html +1609 -0
- package/coverage/server/src/routers/file.ts.html +1144 -0
- package/coverage/server/src/routers/folder.ts.html +2797 -0
- package/coverage/server/src/routers/index.html +386 -0
- package/coverage/server/src/routers/labChat.ts.html +3073 -0
- package/coverage/server/src/routers/marketing.ts.html +340 -0
- package/coverage/server/src/routers/message.ts.html +1912 -0
- package/coverage/server/src/routers/notifications.ts.html +364 -0
- package/coverage/server/src/routers/section.ts.html +1120 -0
- package/coverage/server/src/routers/user.ts.html +862 -0
- package/coverage/server/src/routers/worksheet.ts.html +1729 -0
- package/coverage/server/src/trpc.ts.html +397 -0
- package/coverage/server/src/types/index.html +116 -0
- package/coverage/server/src/types/trpc.ts.html +127 -0
- package/coverage/server/src/utils/aiUser.ts.html +280 -0
- package/coverage/server/src/utils/email.ts.html +121 -0
- package/coverage/server/src/utils/generateInviteCode.ts.html +106 -0
- package/coverage/server/src/utils/index.html +206 -0
- package/coverage/server/src/utils/inference.ts.html +709 -0
- package/coverage/server/src/utils/logger.ts.html +664 -0
- package/coverage/server/src/utils/prismaErrorHandler.ts.html +907 -0
- package/coverage/server/src/utils/prismaWrapper.ts.html +355 -0
- package/coverage/server/vitest.config.ts.html +196 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -52
- package/dist/index.js.map +1 -1
- package/dist/instrument.js +15 -8
- package/dist/instrument.js.map +1 -1
- package/dist/lib/config/env.d.ts +169 -0
- package/dist/lib/config/env.d.ts.map +1 -0
- package/dist/lib/config/env.js +115 -0
- package/dist/lib/config/env.js.map +1 -0
- package/dist/lib/fileUpload.d.ts.map +1 -1
- package/dist/lib/fileUpload.js +5 -4
- package/dist/lib/fileUpload.js.map +1 -1
- package/dist/lib/googleCloudStorage.d.ts.map +1 -1
- package/dist/lib/googleCloudStorage.js +7 -8
- package/dist/lib/googleCloudStorage.js.map +1 -1
- package/dist/lib/jsonConversion.d.ts.map +1 -1
- package/dist/lib/jsonConversion.js +14 -16
- package/dist/lib/jsonConversion.js.map +1 -1
- package/dist/lib/notificationHandler.d.ts +2 -2
- package/dist/lib/prisma.d.ts +2 -2
- package/dist/lib/prisma.d.ts.map +1 -1
- package/dist/lib/prisma.js +22 -3
- package/dist/lib/prisma.js.map +1 -1
- package/dist/lib/pusher.d.ts.map +1 -1
- package/dist/lib/pusher.js +8 -7
- package/dist/lib/pusher.js.map +1 -1
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +7 -5
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/security.d.ts +5 -0
- package/dist/middleware/security.d.ts.map +1 -0
- package/dist/middleware/security.js +77 -0
- package/dist/middleware/security.js.map +1 -0
- package/dist/routers/_app.d.ts +368 -108
- 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/agenda.d.ts.map +1 -1
- package/dist/routers/agenda.js +12 -9
- package/dist/routers/agenda.js.map +1 -1
- package/dist/routers/announcement.d.ts +8 -0
- package/dist/routers/announcement.d.ts.map +1 -1
- package/dist/routers/announcement.js +6 -4
- package/dist/routers/announcement.js.map +1 -1
- package/dist/routers/assignment.d.ts +17 -4
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +51 -19
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/attendance.d.ts +1 -0
- package/dist/routers/attendance.d.ts.map +1 -1
- package/dist/routers/attendance.js +4 -4
- package/dist/routers/attendance.js.map +1 -1
- package/dist/routers/auth.d.ts +20 -0
- package/dist/routers/auth.d.ts.map +1 -1
- package/dist/routers/auth.js +132 -15
- package/dist/routers/auth.js.map +1 -1
- package/dist/routers/class.d.ts +10 -0
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +49 -5
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +2 -0
- package/dist/routers/comment.d.ts.map +1 -1
- package/dist/routers/conversation.d.ts +2 -0
- package/dist/routers/conversation.d.ts.map +1 -1
- package/dist/routers/conversation.js +46 -31
- package/dist/routers/conversation.js.map +1 -1
- package/dist/routers/file.d.ts.map +1 -1
- package/dist/routers/file.js +30 -7
- package/dist/routers/file.js.map +1 -1
- package/dist/routers/labChat.d.ts +2 -0
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +5 -322
- package/dist/routers/labChat.js.map +1 -1
- package/dist/routers/marketing.d.ts +1 -1
- package/dist/routers/message.d.ts +1 -0
- package/dist/routers/message.d.ts.map +1 -1
- package/dist/routers/message.js +3 -2
- package/dist/routers/message.js.map +1 -1
- package/dist/routers/newtonChat.d.ts +55 -0
- package/dist/routers/newtonChat.d.ts.map +1 -0
- package/dist/routers/newtonChat.js +262 -0
- package/dist/routers/newtonChat.js.map +1 -0
- package/dist/routers/notifications.d.ts +4 -4
- package/dist/routers/section.d.ts +19 -4
- package/dist/routers/section.d.ts.map +1 -1
- package/dist/routers/section.js +26 -8
- package/dist/routers/section.js.map +1 -1
- package/dist/routers/user.d.ts.map +1 -1
- package/dist/routers/user.js +5 -4
- package/dist/routers/user.js.map +1 -1
- package/dist/routers/worksheet.d.ts +44 -41
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/routers/worksheet.js +25 -34
- package/dist/routers/worksheet.js.map +1 -1
- package/dist/seedDatabase.d.ts +1 -1
- package/dist/seedDatabase.js +275 -284
- package/dist/seedDatabase.js.map +1 -1
- package/dist/server/pipelines/aiLabChat.d.ts +21 -0
- package/dist/server/pipelines/aiLabChat.d.ts.map +1 -0
- package/dist/server/pipelines/aiLabChat.js +456 -0
- package/dist/server/pipelines/aiLabChat.js.map +1 -0
- package/dist/server/pipelines/aiNewtonChat.d.ts +30 -0
- package/dist/server/pipelines/aiNewtonChat.d.ts.map +1 -0
- package/dist/server/pipelines/aiNewtonChat.js +280 -0
- package/dist/server/pipelines/aiNewtonChat.js.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts +15 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.js +139 -0
- package/dist/server/pipelines/gradeWorksheet.js.map +1 -0
- package/dist/trpc.d.ts.map +1 -1
- package/dist/trpc.js +2 -2
- package/dist/trpc.js.map +1 -1
- package/dist/utils/email.d.ts +9 -1
- package/dist/utils/email.d.ts.map +1 -1
- package/dist/utils/email.js +20 -5
- package/dist/utils/email.js.map +1 -1
- package/dist/utils/inference.d.ts +5 -0
- package/dist/utils/inference.d.ts.map +1 -1
- package/dist/utils/inference.js +71 -7
- package/dist/utils/inference.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +3 -3
- package/dist/utils/logger.js.map +1 -1
- package/docker-compose.yml +14 -0
- package/package.json +13 -4
- package/prisma/schema.prisma +34 -5
- package/scripts/test-pre-push.ts +14 -0
- package/src/index.ts +98 -54
- package/src/instrument.ts +13 -6
- package/src/lib/config/env.ts +126 -0
- package/src/lib/fileUpload.ts +3 -2
- package/src/lib/googleCloudStorage.ts +6 -6
- package/src/lib/jsonConversion.ts +12 -14
- package/src/lib/prisma.ts +23 -2
- package/src/lib/pusher.ts +6 -5
- package/src/middleware/auth.ts +5 -3
- package/src/middleware/security.ts +80 -0
- package/src/routers/_app.ts +2 -0
- package/src/routers/agenda.ts +10 -7
- package/src/routers/announcement.ts +4 -2
- package/src/routers/assignment.ts +74 -41
- package/src/routers/attendance.ts +2 -2
- package/src/routers/auth.ts +143 -14
- package/src/routers/class.ts +52 -3
- package/src/routers/conversation.ts +49 -29
- package/src/routers/file.ts +29 -5
- package/src/routers/labChat.ts +3 -367
- package/src/routers/message.ts +1 -1
- package/src/routers/newtonChat.ts +299 -0
- package/src/routers/section.ts +26 -6
- package/src/routers/user.ts +3 -2
- package/src/routers/worksheet.ts +26 -38
- package/src/seedDatabase.ts +290 -283
- package/src/server/pipelines/aiLabChat.ts +507 -0
- package/src/server/pipelines/aiNewtonChat.ts +338 -0
- package/src/server/pipelines/gradeWorksheet.ts +151 -0
- package/src/trpc.ts +2 -0
- package/src/utils/email.ts +30 -3
- package/src/utils/inference.ts +85 -5
- package/src/utils/logger.ts +2 -1
- package/tests/announcement.test.ts +164 -0
- package/tests/assignment.test.ts +296 -0
- package/tests/attendance.test.ts +168 -0
- package/tests/auth.test.ts +33 -10
- package/tests/class.test.ts +34 -9
- package/tests/event.test.ts +228 -0
- package/tests/section.test.ts +216 -0
- package/tests/setup.ts +70 -16
- package/tests/user.test.ts +158 -0
- package/vitest.config.ts +26 -0
- package/API_SPECIFICATION.md +0 -1597
- package/BASE64_REMOVAL_SUMMARY.md +0 -164
- package/CHAT_API_SPEC.md +0 -579
- package/LAB_CHAT_API_SPEC.md +0 -518
- package/dist/routers/school.d.ts +0 -208
- package/dist/routers/school.d.ts.map +0 -1
- package/dist/routers/school.js +0 -483
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sources":["routers/class.ts"],"sourceRoot":"/","sourcesContent":["import { z } from \"zod\";\nimport { createTRPCRouter, protectedProcedure, protectedTeacherProcedure, protectedClassMemberProcedure } from \"../trpc.js\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { TRPCError } from \"@trpc/server\";\nimport { generateInviteCode } from \"../utils/generateInviteCode.js\";\n\nexport const classRouter = createTRPCRouter({\n getAll: protectedProcedure\n \n .query(async ({ ctx }) => {\n const [teacherClasses, studentClasses] = await Promise.all([\n prisma.class.findMany({\n where: {\n teachers: {\n some: {\n id: ctx.user?.id,\n },\n },\n },\n include: {\n assignments: {\n where: {\n dueDate: {\n lte: new Date(new Date().setHours(23, 59, 59, 999)),\n },\n template: false,\n },\n select: {\n id: true,\n title: true,\n type: true,\n dueDate: true,\n },\n },\n },\n }),\n prisma.class.findMany({\n where: {\n students: {\n some: {\n id: ctx.user?.id,\n },\n },\n },\n include: {\n assignments: {\n where: {\n dueDate: { \n lte: new Date(new Date().setHours(23, 59, 59, 999)),\n },\n template: false,\n },\n select: {\n id: true,\n title: true,\n type: true,\n dueDate: true,\n },\n },\n },\n }),\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 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 color: cls.color,\n })),\n };\n }),\n get: protectedProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const isTeacher = await prisma.class.findFirst({\n where: {\n id: classId,\n teachers: {\n some: { id: ctx.user?.id },\n },\n },\n });\n\n const classData = await prisma.class.findUnique({\n where: {\n id: classId,\n },\n include: {\n teachers: {\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 students: {\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 announcements: {\n orderBy: {\n createdAt: 'desc',\n },\n select: {\n id: true,\n remarks: true,\n createdAt: true,\n modifiedAt: true,\n teacher: {\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 },\n },\n assignments: {\n ...(!isTeacher && {\n where: {OR: [\n {\n assignedTo: {\n some: {\n id: ctx.user?.id,\n },\n },\n },\n {\n assignedTo: {\n none: {},\n },\n },\n ],}\n }),\n select: {\n type: true,\n id: true,\n title: true,\n dueDate: true,\n createdAt: true,\n weight: true,\n order: true,\n graded: true,\n maxGrade: true,\n instructions: true,\n inProgress: true,\n template: false,\n section: {\n select: {\n id: true,\n name: true,\n },\n },\n markScheme: {\n select: {\n id: true,\n structured: true,\n },\n },\n gradingBoundary: {\n select: {\n id: true,\n structured: true,\n },\n },\n submissions: {\n ...(!isTeacher && {\n where: {\n studentId: ctx.user?.id,\n },\n }),\n select: {\n studentId: true,\n id: true,\n submitted: true,\n gradeReceived: true,\n rubricState: true,\n teacherComments: true,\n returned: true,\n submittedAt: true,\n },\n },\n },\n },\n },\n });\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(submission => submission.studentId === ctx.user?.id)?.submitted,\n returned: assignment.submissions.find(submission => submission.studentId === ctx.user?.id)?.returned,\n })),\n }\n\n const sections = await prisma.section.findMany({\n where: {\n classId: classId,\n },\n });\n\n return {\n class: {\n ...formattedClassData,\n sections,\n },\n };\n }),\n update: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n name: z.string().optional(),\n section: z.string().optional(),\n subject: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, ...updateData } = input;\n \n const updatedClass = await prisma.class.update({\n where: {\n id: classId,\n },\n data: updateData,\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n }\n });\n\n return {\n updatedClass,\n }\n }),\n create: protectedProcedure\n .input(z.object({\n students: z.array(z.string()).optional(),\n teachers: z.array(z.string()).optional(),\n name: z.string(),\n section: z.string(),\n subject: z.string(),\n color: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { students, teachers, name, section, subject, color } = input;\n \n if (teachers && teachers.length > 0 && students && students.length > 0) {\n const newClass = await prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: {\n connect: teachers.map(teacher => ({ id: teacher })),\n },\n students: {\n connect: students.map(student => ({ id: student })),\n },\n },\n include: {\n teachers: true,\n students: true,\n },\n });\n return newClass;\n }\n\n const newClass = await prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: {\n connect: {\n id: ctx.user?.id,\n },\n },\n },\n });\n \n return newClass;\n }),\n delete: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n id: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n // Verify user is the teacher of this class\n const classToDelete = await prisma.class.findFirst({\n where: {\n id: input.id,\n },\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: {\n id: input.id,\n },\n });\n\n return {\n deletedClass: {\n id: input.id,\n }\n }\n }),\n addStudent: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n studentId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, studentId } = input;\n\n const student = await prisma.user.findUnique({\n where: {\n id: studentId,\n },\n });\n\n if (!student) {\n throw new Error(\"Student not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: {\n id: classId,\n },\n data: {\n students: {\n connect: {\n id: studentId,\n },\n },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n }\n });\n\n return {\n updatedClass,\n newStudent: student,\n }\n }),\n changeRole: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n userId: z.string(),\n type: z.enum(['teacher', 'student']),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, userId, type } = input;\n\n const user = await prisma.user.findUnique({\n where: { id: userId },\n select: {\n id: true,\n username: true,\n },\n });\n\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: {\n ...user,\n type,\n },\n };\n }),\n removeMember: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n userId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, userId } = input;\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n teachers: {\n disconnect: { id: userId },\n },\n students: {\n disconnect: { id: userId },\n },\n },\n });\n\n return {\n updatedClass,\n removedUserId: userId,\n };\n }),\n join: protectedProcedure\n .input(z.object({\n classCode: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classCode } = input;\n\n const session = await prisma.session.findFirst({\n where: {\n id: classCode,\n },\n });\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: {\n connect: { id: ctx.user?.id },\n },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return {\n joinedClass: updatedClass,\n }\n }),\n getInviteCode: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const session = await prisma.session.findFirst({\n where: {\n classId,\n },\n });\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 expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours from now\n }\n });\n return {\n code: newSession.id,\n }\n }\n\n return {\n code: session?.id,\n };\n }),\n createInviteCode: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId } = input;\n\n await prisma.session.deleteMany({\n where: {\n classId,\n },\n });\n\n // Create a new session for the invite code\n const session = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours from now\n }\n });\n\n return {\n code: session.id,\n };\n }),\n getGrades: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n userId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId, userId } = input;\n\n const isTeacher = await prisma.class.findFirst({\n where: {\n id: classId,\n teachers: {\n some: { id: ctx.user?.id }\n }\n }\n });\n // If student, only allow viewing their own grades\n if (ctx.user?.id !== userId && !isTeacher) {\n throw new TRPCError({\n code: 'UNAUTHORIZED',\n message: 'You can only view your own grades',\n });\n }\n\n const grades = await prisma.submission.findMany({\n where: {\n studentId: userId,\n assignment: {\n classId: classId,\n graded: true\n }\n },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n markSchemeId: true,\n markScheme: {\n select: {\n structured: true,\n }\n },\n gradingBoundaryId: true,\n gradingBoundary: {\n select: {\n structured: true,\n }\n },\n }\n },\n }\n });\n\n return {\n grades,\n };\n }),\n updateGrade: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n assignmentId: z.string(),\n submissionId: z.string(),\n gradeReceived: z.number().nullable(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, assignmentId, submissionId, gradeReceived } = input;\n\n // Update the grade\n const updatedSubmission = await prisma.submission.update({\n where: {\n id: submissionId,\n assignmentId: assignmentId,\n },\n data: {\n gradeReceived,\n },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n }\n }\n }\n });\n\n return updatedSubmission;\n }),\n getEvents: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const events = await prisma.event.findMany({\n where: {\n class: {\n id: classId,\n }\n },\n select: {\n name: true,\n startTime: true,\n endTime: true,\n }\n });\n\n return events;\n }),\n listMarkSchemes: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const markSchemes = await prisma.markScheme.findMany({\n where: {\n class: {\n id: classId,\n },\n },\n });\n\n return markSchemes;\n }),\n createMarkScheme: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const markScheme = await prisma.markScheme.create({\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return markScheme;\n }),\n updateMarkScheme: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n markSchemeId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, markSchemeId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const markScheme = await prisma.markScheme.update({\n where: { id: markSchemeId },\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return markScheme;\n }),\n deleteMarkScheme: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n markSchemeId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, markSchemeId } = input;\n\n const markScheme = await prisma.markScheme.delete({\n where: { id: markSchemeId },\n });\n\n return markScheme;\n }),\n listGradingBoundaries: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const gradingBoundaries = await prisma.gradingBoundary.findMany({\n where: {\n class: {\n id: classId,\n },\n },\n });\n\n return gradingBoundaries;\n }),\n createGradingBoundary: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const gradingBoundary = await prisma.gradingBoundary.create({\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return gradingBoundary;\n }),\n updateGradingBoundary: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n gradingBoundaryId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, gradingBoundaryId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const gradingBoundary = await prisma.gradingBoundary.update({\n where: { id: gradingBoundaryId },\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return gradingBoundary;\n }),\n deleteGradingBoundary: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n gradingBoundaryId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, gradingBoundaryId } = input;\n\n const gradingBoundary = await prisma.gradingBoundary.delete({\n where: { id: gradingBoundaryId },\n });\n\n return gradingBoundary;\n }),\n getSyllabus: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({input}) => {\n const {classId} = input;\n\n const syllabus = (await prisma.class.findUnique({\n where: {\n id: classId,\n },\n }))?.syllabus;\n\n const markSchemes = await prisma.markScheme.findMany({\n where: {\n classId,\n }\n });\n\n const gradingBoundaries = await prisma.gradingBoundary.findMany({\n where: {\n classId,\n }\n });\n\n return {syllabus, gradingBoundaries, markSchemes};\n }),\n updateSyllabus: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n contents: z.string(),\n }))\n .mutation(async ({ input }) => {\n const { contents, classId } = input;\n\n if (!contents) throw new TRPCError({\n code: 'BAD_REQUEST',\n message: \"Missing key contents\",\n });\n\n const updated = await prisma.class.update({\n where: {\n id: classId\n },\n data: {\n syllabus: contents,\n }\n });\n\n return updated;\n }),\n // Lab Management Endpoints (Assignment-based)\n listLabDrafts: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const labDrafts = await prisma.assignment.findMany({\n where: {\n classId: classId,\n teacherId: ctx.user?.id,\n inProgress: true,\n },\n orderBy: {\n modifiedAt: 'desc',\n },\n });\n\n return labDrafts;\n }),\n createLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n title: z.string(),\n type: z.enum(['LAB', 'HOMEWORK', 'QUIZ', 'TEST', 'PROJECT', 'ESSAY', 'DISCUSSION', 'PRESENTATION', 'OTHER']),\n instructions: z.string(),\n dueDate: z.date().optional(),\n maxGrade: z.number().optional(),\n weight: z.number().optional(),\n graded: z.boolean().optional(),\n sectionId: z.string().optional(),\n markSchemeId: z.string().optional(),\n gradingBoundaryId: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, ...draftData } = input;\n\n const labDraft = await prisma.assignment.create({\n data: {\n classId: classId,\n teacherId: ctx.user?.id!,\n inProgress: true,\n graded: draftData.graded ?? false,\n maxGrade: draftData.maxGrade ?? 0,\n weight: draftData.weight ?? 1,\n dueDate: draftData.dueDate || new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // Default 1 week from now\n title: draftData.title,\n instructions: draftData.instructions,\n type: draftData.type,\n ...(draftData.sectionId && { sectionId: draftData.sectionId }),\n ...(draftData.markSchemeId && { markSchemeId: draftData.markSchemeId }),\n ...(draftData.gradingBoundaryId && { gradingBoundaryId: draftData.gradingBoundaryId }),\n },\n });\n\n return labDraft;\n }),\n updateLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n draftId: z.string(),\n title: z.string().optional(),\n instructions: z.string().optional(),\n dueDate: z.date().optional(),\n maxGrade: z.number().optional(),\n weight: z.number().optional(),\n graded: z.boolean().optional(),\n sectionId: z.string().optional(),\n markSchemeId: z.string().optional(),\n gradingBoundaryId: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, draftId, ...updateData } = input;\n\n const labDraft = await prisma.assignment.update({\n where: {\n id: draftId,\n classId: classId,\n teacherId: ctx.user?.id!,\n inProgress: true,\n },\n data: {\n ...(updateData.title && { title: updateData.title }),\n ...(updateData.instructions && { instructions: updateData.instructions }),\n ...(updateData.dueDate && { dueDate: updateData.dueDate }),\n ...(updateData.maxGrade !== undefined && { maxGrade: updateData.maxGrade }),\n ...(updateData.weight !== undefined && { weight: updateData.weight }),\n ...(updateData.graded !== undefined && { graded: updateData.graded }),\n ...(updateData.sectionId !== undefined && { sectionId: updateData.sectionId }),\n ...(updateData.markSchemeId !== undefined && { markSchemeId: updateData.markSchemeId }),\n ...(updateData.gradingBoundaryId !== undefined && { gradingBoundaryId: updateData.gradingBoundaryId }),\n modifiedAt: new Date(),\n },\n });\n\n return labDraft;\n }),\n deleteLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n draftId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, draftId } = input;\n\n const labDraft = await prisma.assignment.delete({\n where: {\n id: draftId,\n classId: classId,\n teacherId: ctx.user?.id!,\n inProgress: true,\n },\n });\n\n return labDraft;\n }),\n publishLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n draftId: z.string(),\n dueDate: z.date().optional(),\n maxGrade: z.number().optional(),\n weight: z.number().optional(),\n graded: z.boolean().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, draftId, ...publishData } = input;\n\n // Get the lab draft\n const labDraft = await prisma.assignment.findUnique({\n where: {\n id: draftId,\n classId: classId,\n teacherId: ctx.user?.id!,\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 // Publish the draft by updating it to not be in progress\n const publishedAssignment = await prisma.assignment.update({\n where: { id: draftId },\n data: {\n inProgress: false,\n dueDate: publishData.dueDate || labDraft.dueDate,\n maxGrade: publishData.maxGrade || labDraft.maxGrade || 100,\n weight: publishData.weight || labDraft.weight || 1,\n graded: publishData.graded !== undefined ? publishData.graded : true,\n modifiedAt: new Date(),\n },\n });\n\n return publishedAssignment;\n }),\n getFiles: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n // Get all assignments with their files and submissions\n const assignments = await prisma.assignment.findMany({\n where: {\n classId: classId,\n },\n include: {\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n thumbnailId: true,\n uploadedAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n submissions: {\n include: {\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n thumbnailId: true,\n uploadedAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n annotations: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n thumbnailId: true,\n uploadedAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n student: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n teacher: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n orderBy: {\n createdAt: 'desc',\n },\n });\n\n // Organize files by assignment structure\n const organizedFiles = 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 return organizedFiles;\n }),\n});"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC5H,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;IAC1C,MAAM,EAAE,kBAAkB;SAEvB,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QACvB,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACzD,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;gBACpB,KAAK,EAAE;oBACH,QAAQ,EAAE;wBACR,IAAI,EAAE;4BACJ,EAAE,EAAE,GAAG,CAAC,IAAI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Root":"/","sourcesContent":["import { z } from \"zod\";\nimport { createTRPCRouter, protectedProcedure, protectedTeacherProcedure, protectedClassMemberProcedure } from \"../trpc.js\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { TRPCError } from \"@trpc/server\";\nimport { generateInviteCode } from \"../utils/generateInviteCode.js\";\n\nexport const classRouter = createTRPCRouter({\n getAll: protectedProcedure\n \n .query(async ({ ctx }) => {\n const [teacherClasses, studentClasses] = await Promise.all([\n prisma.class.findMany({\n where: {\n teachers: {\n some: {\n id: ctx.user?.id,\n },\n },\n },\n include: {\n assignments: {\n where: {\n dueDate: {\n lte: new Date(new Date().setHours(23, 59, 59, 999)),\n },\n template: false,\n },\n select: {\n id: true,\n title: true,\n type: true,\n dueDate: true,\n },\n },\n },\n }),\n prisma.class.findMany({\n where: {\n students: {\n some: {\n id: ctx.user?.id,\n },\n },\n },\n include: {\n assignments: {\n where: {\n dueDate: { \n lte: new Date(new Date().setHours(23, 59, 59, 999)),\n },\n template: false,\n },\n select: {\n id: true,\n title: true,\n type: true,\n dueDate: true,\n },\n },\n },\n }),\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 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 color: cls.color,\n })),\n };\n }),\n get: protectedProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const isTeacher = await prisma.class.findFirst({\n where: {\n id: classId,\n teachers: {\n some: { id: ctx.user?.id },\n },\n },\n });\n\n const classData = await prisma.class.findUnique({\n where: {\n id: classId,\n },\n include: {\n teachers: {\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 students: {\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 announcements: {\n orderBy: {\n createdAt: 'desc',\n },\n select: {\n id: true,\n remarks: true,\n createdAt: true,\n modifiedAt: true,\n teacher: {\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 },\n },\n assignments: {\n ...(!isTeacher && {\n where: {OR: [\n {\n assignedTo: {\n some: {\n id: ctx.user?.id,\n },\n },\n },\n {\n assignedTo: {\n none: {},\n },\n },\n ],}\n }),\n select: {\n type: true,\n id: true,\n title: true,\n dueDate: true,\n createdAt: true,\n weight: true,\n order: true,\n graded: true,\n maxGrade: true,\n instructions: true,\n inProgress: true,\n template: false,\n section: {\n select: {\n id: true,\n name: true,\n },\n },\n markScheme: {\n select: {\n id: true,\n structured: true,\n },\n },\n gradingBoundary: {\n select: {\n id: true,\n structured: true,\n },\n },\n submissions: {\n ...(!isTeacher && {\n where: {\n studentId: ctx.user?.id,\n },\n }),\n select: {\n studentId: true,\n id: true,\n submitted: true,\n gradeReceived: true,\n rubricState: true,\n teacherComments: true,\n returned: true,\n submittedAt: true,\n },\n },\n },\n },\n },\n });\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(submission => submission.studentId === ctx.user?.id)?.submitted,\n returned: assignment.submissions.find(submission => submission.studentId === ctx.user?.id)?.returned,\n })),\n }\n\n const sections = await prisma.section.findMany({\n where: {\n classId: classId,\n },\n });\n\n return {\n class: {\n ...formattedClassData,\n sections,\n },\n };\n }),\n update: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n name: z.string().optional(),\n section: z.string().optional(),\n subject: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, ...updateData } = input;\n \n const updatedClass = await prisma.class.update({\n where: {\n id: classId,\n },\n data: updateData,\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n }\n });\n\n return {\n updatedClass,\n }\n }),\n create: protectedProcedure\n .input(z.object({\n students: z.array(z.string()).optional(),\n teachers: z.array(z.string()).optional(),\n name: z.string(),\n section: z.string(),\n subject: z.string(),\n color: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { students, teachers, name, section, subject, color } = input;\n \n if (teachers && teachers.length > 0 && students && students.length > 0) {\n const newClass = await prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: {\n connect: teachers.map(teacher => ({ id: teacher })),\n },\n students: {\n connect: students.map(student => ({ id: student })),\n },\n },\n include: {\n teachers: true,\n students: true,\n },\n });\n return newClass;\n }\n\n const newClass = await prisma.class.create({\n data: {\n name,\n section,\n subject,\n color,\n teachers: {\n connect: {\n id: ctx.user?.id,\n },\n },\n },\n });\n \n return newClass;\n }),\n delete: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n id: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n // Verify user is the teacher of this class\n const classToDelete = await prisma.class.findFirst({\n where: {\n id: input.id,\n },\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: {\n id: input.id,\n },\n });\n\n return {\n deletedClass: {\n id: input.id,\n }\n }\n }),\n addStudent: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n studentId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, studentId } = input;\n\n const student = await prisma.user.findUnique({\n where: {\n id: studentId,\n },\n });\n\n if (!student) {\n throw new Error(\"Student not found\");\n }\n\n const updatedClass = await prisma.class.update({\n where: {\n id: classId,\n },\n data: {\n students: {\n connect: {\n id: studentId,\n },\n },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n }\n });\n\n return {\n updatedClass,\n newStudent: student,\n }\n }),\n changeRole: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n userId: z.string(),\n type: z.enum(['teacher', 'student']),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, userId, type } = input;\n\n const user = await prisma.user.findUnique({\n where: { id: userId },\n select: {\n id: true,\n username: true,\n },\n });\n\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: {\n ...user,\n type,\n },\n };\n }),\n removeMember: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n userId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, userId } = input;\n\n const updatedClass = await prisma.class.update({\n where: { id: classId },\n data: {\n teachers: {\n disconnect: { id: userId },\n },\n students: {\n disconnect: { id: userId },\n },\n },\n });\n\n return {\n updatedClass,\n removedUserId: userId,\n };\n }),\n leaveClass: protectedProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId } = input;\n const userId = ctx.user?.id;\n\n if (!userId) {\n throw new TRPCError({\n code: 'UNAUTHORIZED',\n message: 'User not authenticated',\n });\n }\n\n const classData = await prisma.class.findFirst({\n where: {\n id: classId,\n students: {\n some: { id: userId },\n },\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: {\n disconnect: { id: userId },\n },\n },\n });\n\n return {\n success: true,\n leftClassId: classId,\n };\n }),\n join: protectedProcedure\n .input(z.object({\n classCode: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classCode } = input;\n\n // Case-insensitive search for invite code\n const session = await prisma.session.findFirst({\n where: {\n id: {\n equals: classCode,\n mode: 'insensitive',\n },\n },\n });\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: {\n connect: { id: ctx.user?.id },\n },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n },\n });\n\n return {\n joinedClass: updatedClass,\n }\n }),\n getInviteCode: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const session = await prisma.session.findFirst({\n where: {\n classId,\n },\n });\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 expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours from now\n }\n });\n return {\n code: newSession.id,\n }\n }\n\n return {\n code: session?.id,\n };\n }),\n createInviteCode: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId } = input;\n\n await prisma.session.deleteMany({\n where: {\n classId,\n },\n });\n\n // Create a new session for the invite code\n const session = await prisma.session.create({\n data: {\n id: generateInviteCode(),\n classId,\n expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours from now\n }\n });\n\n return {\n code: session.id,\n };\n }),\n getGrades: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n userId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId, userId } = input;\n\n const isTeacher = await prisma.class.findFirst({\n where: {\n id: classId,\n teachers: {\n some: { id: ctx.user?.id }\n }\n }\n });\n // If student, only allow viewing their own grades\n if (ctx.user?.id !== userId && !isTeacher) {\n throw new TRPCError({\n code: 'UNAUTHORIZED',\n message: 'You can only view your own grades',\n });\n }\n\n const grades = await prisma.submission.findMany({\n where: {\n studentId: userId,\n assignment: {\n classId: classId,\n graded: true\n }\n },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n markSchemeId: true,\n markScheme: {\n select: {\n structured: true,\n }\n },\n gradingBoundaryId: true,\n gradingBoundary: {\n select: {\n structured: true,\n }\n },\n }\n },\n }\n });\n\n return {\n grades,\n };\n }),\n updateGrade: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n assignmentId: z.string(),\n submissionId: z.string(),\n gradeReceived: z.number().nullable(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, assignmentId, submissionId, gradeReceived } = input;\n\n // Update the grade\n const updatedSubmission = await prisma.submission.update({\n where: {\n id: submissionId,\n assignmentId: assignmentId,\n },\n data: {\n gradeReceived,\n },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n }\n }\n }\n });\n\n return updatedSubmission;\n }),\n getEvents: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const events = await prisma.event.findMany({\n where: {\n class: {\n id: classId,\n }\n },\n select: {\n name: true,\n startTime: true,\n endTime: true,\n }\n });\n\n return events;\n }),\n listMarkSchemes: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const markSchemes = await prisma.markScheme.findMany({\n where: {\n class: {\n id: classId,\n },\n },\n });\n\n return markSchemes;\n }),\n createMarkScheme: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const markScheme = await prisma.markScheme.create({\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return markScheme;\n }),\n updateMarkScheme: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n markSchemeId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, markSchemeId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const markScheme = await prisma.markScheme.update({\n where: { id: markSchemeId },\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return markScheme;\n }),\n deleteMarkScheme: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n markSchemeId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, markSchemeId } = input;\n\n const markScheme = await prisma.markScheme.delete({\n where: { id: markSchemeId },\n });\n\n return markScheme;\n }),\n listGradingBoundaries: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const gradingBoundaries = await prisma.gradingBoundary.findMany({\n where: {\n class: {\n id: classId,\n },\n },\n });\n\n return gradingBoundaries;\n }),\n createGradingBoundary: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const gradingBoundary = await prisma.gradingBoundary.create({\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return gradingBoundary;\n }),\n updateGradingBoundary: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n gradingBoundaryId: z.string(),\n structure: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, gradingBoundaryId, structure } = input;\n\n const validatedStructure = structure.replace(/\\\\n/g, '\\n');\n\n const gradingBoundary = await prisma.gradingBoundary.update({\n where: { id: gradingBoundaryId },\n data: {\n class: {\n connect: {\n id: classId,\n },\n },\n structured: validatedStructure,\n },\n });\n\n return gradingBoundary;\n }),\n deleteGradingBoundary: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n gradingBoundaryId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, gradingBoundaryId } = input;\n\n const gradingBoundary = await prisma.gradingBoundary.delete({\n where: { id: gradingBoundaryId },\n });\n\n return gradingBoundary;\n }),\n getSyllabus: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({input}) => {\n const {classId} = input;\n\n const syllabus = (await prisma.class.findUnique({\n where: {\n id: classId,\n },\n }))?.syllabus;\n\n const markSchemes = await prisma.markScheme.findMany({\n where: {\n classId,\n }\n });\n\n const gradingBoundaries = await prisma.gradingBoundary.findMany({\n where: {\n classId,\n }\n });\n\n return {syllabus, gradingBoundaries, markSchemes};\n }),\n updateSyllabus: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n contents: z.string(),\n }))\n .mutation(async ({ input }) => {\n const { contents, classId } = input;\n\n if (!contents) throw new TRPCError({\n code: 'BAD_REQUEST',\n message: \"Missing key contents\",\n });\n\n const updated = await prisma.class.update({\n where: {\n id: classId\n },\n data: {\n syllabus: contents,\n }\n });\n\n return updated;\n }),\n // Lab Management Endpoints (Assignment-based)\n listLabDrafts: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n const labDrafts = await prisma.assignment.findMany({\n where: {\n classId: classId,\n teacherId: ctx.user?.id,\n inProgress: true,\n },\n orderBy: {\n modifiedAt: 'desc',\n },\n });\n\n return labDrafts;\n }),\n createLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n title: z.string(),\n type: z.enum(['LAB', 'HOMEWORK', 'QUIZ', 'TEST', 'PROJECT', 'ESSAY', 'DISCUSSION', 'PRESENTATION', 'OTHER']),\n instructions: z.string(),\n dueDate: z.date().optional(),\n maxGrade: z.number().optional(),\n weight: z.number().optional(),\n graded: z.boolean().optional(),\n sectionId: z.string().optional(),\n markSchemeId: z.string().optional(),\n gradingBoundaryId: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, ...draftData } = input;\n\n const labDraft = await prisma.assignment.create({\n data: {\n classId: classId,\n teacherId: ctx.user?.id!,\n inProgress: true,\n graded: draftData.graded ?? false,\n maxGrade: draftData.maxGrade ?? 0,\n weight: draftData.weight ?? 1,\n dueDate: draftData.dueDate || new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // Default 1 week from now\n title: draftData.title,\n instructions: draftData.instructions,\n type: draftData.type,\n ...(draftData.sectionId && { sectionId: draftData.sectionId }),\n ...(draftData.markSchemeId && { markSchemeId: draftData.markSchemeId }),\n ...(draftData.gradingBoundaryId && { gradingBoundaryId: draftData.gradingBoundaryId }),\n },\n });\n\n return labDraft;\n }),\n updateLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n draftId: z.string(),\n title: z.string().optional(),\n instructions: z.string().optional(),\n dueDate: z.date().optional(),\n maxGrade: z.number().optional(),\n weight: z.number().optional(),\n graded: z.boolean().optional(),\n sectionId: z.string().optional(),\n markSchemeId: z.string().optional(),\n gradingBoundaryId: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, draftId, ...updateData } = input;\n\n const labDraft = await prisma.assignment.update({\n where: {\n id: draftId,\n classId: classId,\n teacherId: ctx.user?.id!,\n inProgress: true,\n },\n data: {\n ...(updateData.title && { title: updateData.title }),\n ...(updateData.instructions && { instructions: updateData.instructions }),\n ...(updateData.dueDate && { dueDate: updateData.dueDate }),\n ...(updateData.maxGrade !== undefined && { maxGrade: updateData.maxGrade }),\n ...(updateData.weight !== undefined && { weight: updateData.weight }),\n ...(updateData.graded !== undefined && { graded: updateData.graded }),\n ...(updateData.sectionId !== undefined && { sectionId: updateData.sectionId }),\n ...(updateData.markSchemeId !== undefined && { markSchemeId: updateData.markSchemeId }),\n ...(updateData.gradingBoundaryId !== undefined && { gradingBoundaryId: updateData.gradingBoundaryId }),\n modifiedAt: new Date(),\n },\n });\n\n return labDraft;\n }),\n deleteLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n draftId: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, draftId } = input;\n\n const labDraft = await prisma.assignment.delete({\n where: {\n id: draftId,\n classId: classId,\n teacherId: ctx.user?.id!,\n inProgress: true,\n },\n });\n\n return labDraft;\n }),\n publishLabDraft: protectedTeacherProcedure\n .input(z.object({\n classId: z.string(),\n draftId: z.string(),\n dueDate: z.date().optional(),\n maxGrade: z.number().optional(),\n weight: z.number().optional(),\n graded: z.boolean().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { classId, draftId, ...publishData } = input;\n\n // Get the lab draft\n const labDraft = await prisma.assignment.findUnique({\n where: {\n id: draftId,\n classId: classId,\n teacherId: ctx.user?.id!,\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 // Publish the draft by updating it to not be in progress\n const publishedAssignment = await prisma.assignment.update({\n where: { id: draftId },\n data: {\n inProgress: false,\n dueDate: publishData.dueDate || labDraft.dueDate,\n maxGrade: publishData.maxGrade || labDraft.maxGrade || 100,\n weight: publishData.weight || labDraft.weight || 1,\n graded: publishData.graded !== undefined ? publishData.graded : true,\n modifiedAt: new Date(),\n },\n });\n\n return publishedAssignment;\n }),\n getFiles: protectedClassMemberProcedure\n .input(z.object({\n classId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const { classId } = input;\n\n // Get all assignments with their files and submissions\n const assignments = await prisma.assignment.findMany({\n where: {\n classId: classId,\n },\n include: {\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n thumbnailId: true,\n uploadedAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n submissions: {\n include: {\n attachments: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n thumbnailId: true,\n uploadedAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n annotations: {\n select: {\n id: true,\n name: true,\n type: true,\n size: true,\n path: true,\n thumbnailId: true,\n uploadedAt: true,\n user: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n student: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n },\n teacher: {\n select: {\n id: true,\n username: true,\n },\n },\n },\n orderBy: {\n createdAt: 'desc',\n },\n });\n\n // Organize files by assignment structure\n const organizedFiles = 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 return organizedFiles;\n }),\n});"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC5H,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;IAC1C,MAAM,EAAE,kBAAkB;SAEvB,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QACvB,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACzD,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;gBACpB,KAAK,EAAE;oBACH,QAAQ,EAAE;wBACR,IAAI,EAAE;4BACJ,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE;yBACnB;qBACF;iBACF;gBACD,OAAO,EAAE;oBACP,WAAW,EAAE;wBACX,KAAK,EAAE;4BACL,OAAO,EAAE;gCACP,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE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BACF;wBACD,OAAO,EAAE;4BACP,MAAM,EAAE;gCACN,EAAE,EAAE,IAAI;gCACR,QAAQ,EAAE,IAAI;6BACf;yBACF;qBACF;iBACF;gBACD,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN,EAAE,EAAE,IAAI;wBACR,QAAQ,EAAE,IAAI;qBACf;iBACF;aACF;YACD,OAAO,EAAE;gBACP,SAAS,EAAE,MAAM;aAClB;SACF,CAAC,CAAC;QAEH,yCAAyC;QACzC,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACpD,EAAE,EAAE,UAAU,CAAC,EAAE;YACjB,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,OAAO,EAAE,UAAU,CAAC,OAAO;YAC3B,kBAAkB,EAAE,UAAU,CAAC,WAAW;YAC1C,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;gBAClD,EAAE,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;gBACzB,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ;gBACrC,WAAW,EAAE,UAAU,CAAC,WAAW;gBACnC,WAAW,EAAE,UAAU,CAAC,WAAW;aACpC,CAAC,CAAC;SACJ,CAAC,CAAC,CAAC;QAEJ,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;CACP,CAAC,CAAC","debug_id":"90bd2ed8-f6aa-5bb5-b0f5-4d2643587610"}
|
|
@@ -101,6 +101,7 @@ export declare const commentRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
101
101
|
} | null;
|
|
102
102
|
};
|
|
103
103
|
} & {
|
|
104
|
+
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
104
105
|
id: string;
|
|
105
106
|
content: string;
|
|
106
107
|
createdAt: Date;
|
|
@@ -118,6 +119,7 @@ export declare const commentRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
118
119
|
parentCommentId: string;
|
|
119
120
|
};
|
|
120
121
|
output: {
|
|
122
|
+
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
121
123
|
id: string;
|
|
122
124
|
content: string;
|
|
123
125
|
createdAt: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.d.ts","sourceRoot":"/","sources":["routers/comment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCzB,CAAC;AAEF,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"comment.d.ts","sourceRoot":"/","sources":["routers/comment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmQxB,CAAC"}
|
|
@@ -55,6 +55,8 @@ export declare const conversationRouter: import("@trpc/server").TRPCBuiltRouter<
|
|
|
55
55
|
} | null;
|
|
56
56
|
};
|
|
57
57
|
} & {
|
|
58
|
+
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
59
|
+
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
58
60
|
id: string;
|
|
59
61
|
content: string;
|
|
60
62
|
createdAt: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"/","sources":["routers/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"/","sources":["routers/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyT7B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!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]="
|
|
2
|
+
!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]="0653a9bb-09de-561c-b1dc-9cea19f1c8b2")}catch(e){}}();
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { createTRPCRouter, protectedProcedure } from '../trpc.js';
|
|
5
5
|
import { prisma } from '../lib/prisma.js';
|
|
@@ -134,49 +134,63 @@ export const conversationRouter = createTRPCRouter({
|
|
|
134
134
|
}
|
|
135
135
|
// For DMs, check if conversation already exists
|
|
136
136
|
if (type === 'DM') {
|
|
137
|
-
|
|
137
|
+
// Get the target user's ID from their username
|
|
138
|
+
const targetUser = await prisma.user.findFirst({
|
|
139
|
+
where: { username: memberIds[0] },
|
|
140
|
+
select: { id: true, username: true },
|
|
141
|
+
});
|
|
142
|
+
if (!targetUser) {
|
|
143
|
+
throw new TRPCError({
|
|
144
|
+
code: 'BAD_REQUEST',
|
|
145
|
+
message: `User "${memberIds[0]}" not found`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Find all DM conversations where current user is a member
|
|
149
|
+
const existingDMs = await prisma.conversation.findMany({
|
|
138
150
|
where: {
|
|
139
151
|
type: 'DM',
|
|
140
152
|
members: {
|
|
141
|
-
|
|
142
|
-
userId
|
|
143
|
-
in: [userId, memberIds[0]],
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
AND: {
|
|
148
|
-
members: {
|
|
149
|
-
some: {
|
|
150
|
-
userId,
|
|
151
|
-
},
|
|
153
|
+
some: {
|
|
154
|
+
userId,
|
|
152
155
|
},
|
|
153
156
|
},
|
|
154
157
|
},
|
|
155
158
|
include: {
|
|
156
159
|
members: {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
select: {
|
|
160
|
-
id: true,
|
|
161
|
-
username: true,
|
|
162
|
-
profile: {
|
|
163
|
-
select: {
|
|
164
|
-
displayName: true,
|
|
165
|
-
profilePicture: true,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
160
|
+
select: {
|
|
161
|
+
userId: true,
|
|
170
162
|
},
|
|
171
163
|
},
|
|
172
164
|
},
|
|
173
165
|
});
|
|
166
|
+
// Check if any of these conversations has exactly 2 members (current user + target user)
|
|
167
|
+
const existingDM = existingDMs.find(conv => {
|
|
168
|
+
const memberUserIds = conv.members.map(m => m.userId);
|
|
169
|
+
return memberUserIds.length === 2 &&
|
|
170
|
+
memberUserIds.includes(userId) &&
|
|
171
|
+
memberUserIds.includes(targetUser.id);
|
|
172
|
+
});
|
|
174
173
|
if (existingDM) {
|
|
175
|
-
|
|
174
|
+
// Conversation already exists, throw error with friendly message
|
|
175
|
+
throw new TRPCError({
|
|
176
|
+
code: 'BAD_REQUEST',
|
|
177
|
+
message: `A conversation with ${targetUser.username} already exists`,
|
|
178
|
+
});
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
// Verify all members exist
|
|
179
|
-
const
|
|
182
|
+
const membersWithIds = await prisma.user.findMany({
|
|
183
|
+
where: {
|
|
184
|
+
id: {
|
|
185
|
+
in: memberIds,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
select: {
|
|
189
|
+
id: true,
|
|
190
|
+
username: true,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
const membersWithUsernames = await prisma.user.findMany({
|
|
180
194
|
where: {
|
|
181
195
|
username: {
|
|
182
196
|
in: memberIds,
|
|
@@ -187,6 +201,7 @@ export const conversationRouter = createTRPCRouter({
|
|
|
187
201
|
username: true,
|
|
188
202
|
},
|
|
189
203
|
});
|
|
204
|
+
const members = [...membersWithIds, ...membersWithUsernames];
|
|
190
205
|
if (members.length !== memberIds.length) {
|
|
191
206
|
throw new TRPCError({
|
|
192
207
|
code: 'BAD_REQUEST',
|
|
@@ -204,8 +219,8 @@ export const conversationRouter = createTRPCRouter({
|
|
|
204
219
|
userId,
|
|
205
220
|
role: type === 'GROUP' ? 'ADMIN' : 'MEMBER',
|
|
206
221
|
},
|
|
207
|
-
...
|
|
208
|
-
userId:
|
|
222
|
+
...members.map((member) => ({
|
|
223
|
+
userId: member.id,
|
|
209
224
|
role: 'MEMBER',
|
|
210
225
|
})),
|
|
211
226
|
],
|
|
@@ -275,4 +290,4 @@ export const conversationRouter = createTRPCRouter({
|
|
|
275
290
|
}),
|
|
276
291
|
});
|
|
277
292
|
//# sourceMappingURL=conversation.js.map
|
|
278
|
-
//# debugId=
|
|
293
|
+
//# debugId=0653a9bb-09de-561c-b1dc-9cea19f1c8b2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.js","sources":["routers/conversation.ts"],"sourceRoot":"/","sourcesContent":["import { z } from 'zod';\nimport { createTRPCRouter, protectedProcedure } from '../trpc.js';\nimport { prisma } from '../lib/prisma.js';\nimport { TRPCError } from '@trpc/server';\n\nexport const conversationRouter = createTRPCRouter({\n list: protectedProcedure.query(async ({ ctx }) => {\n const userId = ctx.user!.id;\n\n const conversations = await prisma.conversation.findMany({\n where: {\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n labChat: {\n select: {\n id: true,\n title: true,\n },\n },\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n messages: {\n orderBy: {\n createdAt: 'desc',\n },\n take: 1,\n include: {\n sender: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n },\n },\n },\n },\n },\n },\n },\n orderBy: {\n updatedAt: 'desc',\n },\n });\n\n // Calculate unread counts for each conversation\n const conversationsWithUnread = await Promise.all(\n conversations.map(async (conversation) => {\n const userMembership = conversation.members.find(m => m.userId === userId);\n const lastViewedAt = userMembership?.lastViewedAt;\n const lastViewedMentionAt = userMembership?.lastViewedMentionAt;\n \n // Count regular unread messages\n const unreadCount = await prisma.message.count({\n where: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(lastViewedAt && {\n createdAt: { gt: lastViewedAt }\n }),\n },\n });\n\n // Count unread mentions\n // Use the later of lastViewedAt or lastViewedMentionAt\n // This means if user viewed conversation after mention, mention is considered read\n const mentionCutoffTime = lastViewedMentionAt && lastViewedAt \n ? (lastViewedMentionAt > lastViewedAt ? lastViewedMentionAt : lastViewedAt)\n : (lastViewedMentionAt || lastViewedAt);\n \n const unreadMentionCount = await prisma.mention.count({\n where: {\n userId,\n message: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(mentionCutoffTime && {\n createdAt: { gt: mentionCutoffTime }\n }),\n },\n },\n });\n\n return {\n id: conversation.id,\n type: conversation.type,\n name: conversation.name,\n createdAt: conversation.createdAt,\n updatedAt: conversation.updatedAt,\n labChat: conversation.labChat,\n members: conversation.members,\n lastMessage: conversation.messages[0] || null,\n unreadCount,\n unreadMentionCount,\n };\n })\n );\n\n return conversationsWithUnread;\n }),\n\n create: protectedProcedure\n .input(\n z.object({\n type: z.enum(['DM', 'GROUP']),\n name: z.string().optional(),\n memberIds: z.array(z.string()),\n })\n )\n .mutation(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { type, name, memberIds } = input;\n\n // Validate input\n if (type === 'GROUP' && !name) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'Group conversations must have a name',\n });\n }\n\n if (type === 'DM' && memberIds.length !== 1) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'DM conversations must have exactly one other member',\n });\n }\n\n // For DMs, check if conversation already exists\n if (type === 'DM') {\n const existingDM = await prisma.conversation.findFirst({\n where: {\n type: 'DM',\n members: {\n every: {\n userId: {\n in: [userId, memberIds[0]],\n },\n },\n },\n AND: {\n members: {\n some: {\n userId,\n },\n },\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n if (existingDM) {\n return existingDM;\n }\n }\n\n // Verify all members exist\n const members = await prisma.user.findMany({\n where: {\n username: {\n in: memberIds,\n },\n },\n select: {\n id: true,\n username: true,\n },\n });\n\n if (members.length !== memberIds.length) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'One or more members not found',\n });\n }\n\n // Create conversation with members\n const conversation = await prisma.conversation.create({\n data: {\n type,\n name,\n members: {\n create: [\n {\n userId,\n role: type === 'GROUP' ? 'ADMIN' : 'MEMBER',\n },\n ...memberIds.map((memberId) => ({\n userId: members.find((member) => member.username === memberId)!.id,\n role: 'MEMBER' as const,\n })),\n ],\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n return conversation;\n }),\n\n get: protectedProcedure\n .input(z.object({ conversationId: z.string() }))\n .query(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { conversationId } = input;\n\n const conversation = await prisma.conversation.findFirst({\n where: {\n id: conversationId,\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n if (!conversation) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: 'Conversation not found or access denied',\n });\n }\n\n return conversation;\n }),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;IACjD,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC;QAE5B,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;YACvD,KAAK,EAAE;gBACL,OAAO,EAAE;oBACP,IAAI,EAAE;wBACJ,MAAM;qBACP;iBACF;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN,EAAE,EAAE,IAAI;wBACR,KAAK,EAAE,IAAI;qBACZ;iBACF;gBACD,OAAO,EAAE;oBACP,OAAO,EAAE;wBACP,IAAI,EAAE;4BACJ,MAAM,EAAE;gCACN,EAAE,EAAE,IAAI;gCACR,QAAQ,EAAE,IAAI;gCACd,OAAO,EAAE;oCACP,MAAM,EAAE;wCACN,WAAW,EAAE,IAAI;wCACjB,cAAc,EAAE,IAAI;qCACrB;iCACF;6BACF;yBACF;qBACF;iBACF;gBACD,QAAQ,EAAE;oBACR,OAAO,EAAE;w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AY,CAAC;IACtB,CAAC,CAAC;IAEJ,GAAG,EAAE,kBAAkB;SACpB,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SAC/C,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QAEjC,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC;YACvD,KAAK,EAAE;gBACL,EAAE,EAAE,cAAc;gBAClB,OAAO,EAAE;oBACP,IAAI,EAAE;wBACJ,MAAM;qBACP;iBACF;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,OAAO,EAAE;wBACP,IAAI,EAAE;4BACJ,MAAM,EAAE;gCACN,EAAE,EAAE,IAAI;gCACR,QAAQ,EAAE,IAAI;gCACd,OAAO,EAAE;oCACP,MAAM,EAAE;wCACN,WAAW,EAAE,IAAI;wCACjB,cAAc,EAAE,IAAI;qCACrB;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,SAAS,CAAC;gBAClB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,yCAAyC;aACnD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;CACL,CAAC,CAAC","debug_id":"7484364a-2b0f-5c90-8987-fd0fa062e9c8"}
|
|
1
|
+
{"version":3,"file":"conversation.js","sources":["routers/conversation.ts"],"sourceRoot":"/","sourcesContent":["import { z } from 'zod';\nimport { createTRPCRouter, protectedProcedure } from '../trpc.js';\nimport { prisma } from '../lib/prisma.js';\nimport { TRPCError } from '@trpc/server';\n\nexport const conversationRouter = createTRPCRouter({\n list: protectedProcedure.query(async ({ ctx }) => {\n const userId = ctx.user!.id;\n\n const conversations = await prisma.conversation.findMany({\n where: {\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n labChat: {\n select: {\n id: true,\n title: true,\n },\n },\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n messages: {\n orderBy: {\n createdAt: 'desc',\n },\n take: 1,\n include: {\n sender: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n },\n },\n },\n },\n },\n },\n },\n orderBy: {\n updatedAt: 'desc',\n },\n });\n\n // Calculate unread counts for each conversation\n const conversationsWithUnread = await Promise.all(\n conversations.map(async (conversation) => {\n const userMembership = conversation.members.find(m => m.userId === userId);\n const lastViewedAt = userMembership?.lastViewedAt;\n const lastViewedMentionAt = userMembership?.lastViewedMentionAt;\n \n // Count regular unread messages\n const unreadCount = await prisma.message.count({\n where: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(lastViewedAt && {\n createdAt: { gt: lastViewedAt }\n }),\n },\n });\n\n // Count unread mentions\n // Use the later of lastViewedAt or lastViewedMentionAt\n // This means if user viewed conversation after mention, mention is considered read\n const mentionCutoffTime = lastViewedMentionAt && lastViewedAt \n ? (lastViewedMentionAt > lastViewedAt ? lastViewedMentionAt : lastViewedAt)\n : (lastViewedMentionAt || lastViewedAt);\n \n const unreadMentionCount = await prisma.mention.count({\n where: {\n userId,\n message: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(mentionCutoffTime && {\n createdAt: { gt: mentionCutoffTime }\n }),\n },\n },\n });\n\n return {\n id: conversation.id,\n type: conversation.type,\n name: conversation.name,\n createdAt: conversation.createdAt,\n updatedAt: conversation.updatedAt,\n labChat: conversation.labChat,\n members: conversation.members,\n lastMessage: conversation.messages[0] || null,\n unreadCount,\n unreadMentionCount,\n };\n })\n );\n\n return conversationsWithUnread;\n }),\n\n create: protectedProcedure\n .input(\n z.object({\n type: z.enum(['DM', 'GROUP']),\n name: z.string().optional(),\n memberIds: z.array(z.string()),\n })\n )\n .mutation(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { type, name, memberIds } = input;\n\n // Validate input\n if (type === 'GROUP' && !name) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'Group conversations must have a name',\n });\n }\n\n if (type === 'DM' && memberIds.length !== 1) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'DM conversations must have exactly one other member',\n });\n }\n\n // For DMs, check if conversation already exists\n if (type === 'DM') {\n // Get the target user's ID from their username\n const targetUser = await prisma.user.findFirst({\n where: { username: memberIds[0] },\n select: { id: true, username: true },\n });\n\n if (!targetUser) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: `User \"${memberIds[0]}\" not found`,\n });\n }\n\n // Find all DM conversations where current user is a member\n const existingDMs = await prisma.conversation.findMany({\n where: {\n type: 'DM',\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n members: {\n select: {\n userId: true,\n },\n },\n },\n });\n\n // Check if any of these conversations has exactly 2 members (current user + target user)\n const existingDM = existingDMs.find(conv => {\n const memberUserIds = conv.members.map(m => m.userId);\n return memberUserIds.length === 2 &&\n memberUserIds.includes(userId) &&\n memberUserIds.includes(targetUser.id);\n });\n\n if (existingDM) {\n // Conversation already exists, throw error with friendly message\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: `A conversation with ${targetUser.username} already exists`,\n });\n }\n }\n\n // Verify all members exist\n const membersWithIds = await prisma.user.findMany({\n where: {\n id: {\n in: memberIds,\n },\n },\n select: {\n id: true,\n username: true,\n },\n });\n\n const membersWithUsernames = await prisma.user.findMany({\n where: {\n username: {\n in: memberIds,\n },\n },\n select: {\n id: true,\n username: true,\n },\n });\n\n const members = [...membersWithIds, ...membersWithUsernames];\n\n if (members.length !== memberIds.length) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'One or more members not found',\n });\n }\n\n // Create conversation with members\n const conversation = await prisma.conversation.create({\n data: {\n type,\n name,\n members: {\n create: [\n {\n userId,\n role: type === 'GROUP' ? 'ADMIN' : 'MEMBER',\n },\n ...members.map((member) => ({\n userId: member.id,\n role: 'MEMBER' as const,\n })),\n ],\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n return conversation;\n }),\n\n get: protectedProcedure\n .input(z.object({ conversationId: z.string() }))\n .query(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { conversationId } = input;\n\n const conversation = await prisma.conversation.findFirst({\n where: {\n id: conversationId,\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n if (!conversation) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: 'Conversation not found or access denied',\n });\n }\n\n return conversation;\n }),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;IACjD,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC;QAE5B,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;YACvD,KAAK,EAAE;gBACL,OAAO,EAAE;oBACP,IAAI,EAAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"/","sources":["routers/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiXrB,CAAC"}
|
package/dist/routers/file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!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]="
|
|
2
|
+
!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]="dcd6fb91-1e37-5e3a-a751-065b78566254")}catch(e){}}();
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { createTRPCRouter, protectedProcedure, protectedTeacherProcedure } from "../trpc.js";
|
|
5
5
|
import { TRPCError } from "@trpc/server";
|
|
@@ -71,6 +71,16 @@ export const fileRouter = createTRPCRouter({
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
},
|
|
75
|
+
announcement: {
|
|
76
|
+
include: {
|
|
77
|
+
class: {
|
|
78
|
+
include: {
|
|
79
|
+
students: true,
|
|
80
|
+
teachers: true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
74
84
|
}
|
|
75
85
|
}
|
|
76
86
|
});
|
|
@@ -86,17 +96,28 @@ export const fileRouter = createTRPCRouter({
|
|
|
86
96
|
// Check if user is a teacher of the class
|
|
87
97
|
if (file.assignment?.class) {
|
|
88
98
|
classId = file.assignment.class.id;
|
|
89
|
-
|
|
99
|
+
const isTeacher = file.assignment.class.teachers.some(teacher => teacher.id === userId);
|
|
100
|
+
const isStudent = file.assignment.class.students.some(student => student.id === userId);
|
|
101
|
+
logger.info(`Assignment file access check - userId: ${userId}, isTeacher: ${isTeacher}, isStudent: ${isStudent}`);
|
|
102
|
+
hasAccess = isTeacher || isStudent;
|
|
103
|
+
}
|
|
104
|
+
// Check if user has access to announcement files (teachers or students in the class)
|
|
105
|
+
if (file.announcement?.class) {
|
|
106
|
+
classId = file.announcement.class.id;
|
|
107
|
+
const isTeacher = file.announcement.class.teachers.some((teacher) => teacher.id === userId);
|
|
108
|
+
const isStudent = file.announcement.class.students.some((student) => student.id === userId);
|
|
109
|
+
logger.info(`Announcement file access check - userId: ${userId}, isTeacher: ${isTeacher}, isStudent: ${isStudent}`);
|
|
110
|
+
hasAccess = hasAccess || isTeacher || isStudent;
|
|
90
111
|
}
|
|
91
112
|
if (file.submission?.assignment?.classId) {
|
|
92
113
|
classId = file.submission.assignment.classId;
|
|
93
|
-
hasAccess = file.submission?.studentId === userId || false;
|
|
114
|
+
hasAccess = hasAccess || file.submission?.studentId === userId || false;
|
|
94
115
|
if (!hasAccess)
|
|
95
116
|
hasAccess = file.submission.assignment.class.teachers.some(teacher => teacher.id === userId) || false;
|
|
96
117
|
}
|
|
97
118
|
if (file.annotations?.assignment?.classId) {
|
|
98
119
|
classId = file.annotations?.assignment.classId;
|
|
99
|
-
hasAccess = file.annotations?.studentId === userId || false;
|
|
120
|
+
hasAccess = hasAccess || file.annotations?.studentId === userId || false;
|
|
100
121
|
if (!hasAccess)
|
|
101
122
|
hasAccess = file.annotations.assignment.class.teachers.some(teacher => teacher.id === userId) || false;
|
|
102
123
|
}
|
|
@@ -106,8 +127,10 @@ export const fileRouter = createTRPCRouter({
|
|
|
106
127
|
}
|
|
107
128
|
// Check if file is in a folder and user has access to the class
|
|
108
129
|
if (file.folder?.class) {
|
|
109
|
-
|
|
110
|
-
|
|
130
|
+
const isTeacher = file.folder.class.teachers.some(teacher => teacher.id === userId);
|
|
131
|
+
const isStudent = file.folder.class.students.some(student => student.id === userId);
|
|
132
|
+
hasAccess = hasAccess || isTeacher;
|
|
133
|
+
hasAccess = hasAccess || isStudent;
|
|
111
134
|
}
|
|
112
135
|
if (!hasAccess) {
|
|
113
136
|
throw new TRPCError({
|
|
@@ -320,4 +343,4 @@ export const fileRouter = createTRPCRouter({
|
|
|
320
343
|
}),
|
|
321
344
|
});
|
|
322
345
|
//# sourceMappingURL=file.js.map
|
|
323
|
-
//# debugId=
|
|
346
|
+
//# debugId=dcd6fb91-1e37-5e3a-a751-065b78566254
|