@studious-lms/server 1.2.44 → 1.2.46
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 +6 -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 +304 -98
- 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 +7 -4
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +35 -18
- 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 +7 -0
- package/dist/routers/comment.d.ts.map +1 -1
- package/dist/routers/comment.js +9 -2
- package/dist/routers/comment.js.map +1 -1
- package/dist/routers/conversation.d.ts +1 -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 +1 -0
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +2 -3
- package/dist/routers/labChat.js.map +1 -1
- package/dist/routers/marketing.d.ts +1 -1
- package/dist/routers/newtonChat.d.ts +55 -0
- package/dist/routers/newtonChat.d.ts.map +1 -0
- package/dist/routers/newtonChat.js +438 -0
- package/dist/routers/newtonChat.js.map +1 -0
- package/dist/routers/notifications.d.ts +4 -4
- package/dist/routers/section.d.ts +9 -4
- package/dist/routers/section.d.ts.map +1 -1
- package/dist/routers/section.js +8 -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 +30 -36
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/routers/worksheet.js +11 -33
- 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 +10 -0
- package/dist/server/pipelines/aiLabChat.d.ts.map +1 -0
- package/dist/server/pipelines/aiLabChat.js +83 -0
- package/dist/server/pipelines/aiLabChat.js.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts +2 -0
- package/dist/server/pipelines/gradeWorksheet.d.ts.map +1 -0
- package/dist/server/pipelines/gradeWorksheet.js +138 -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 +3 -0
- package/dist/utils/inference.d.ts.map +1 -1
- package/dist/utils/inference.js +41 -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 +32 -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 +4 -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 +58 -40
- package/src/routers/attendance.ts +2 -2
- package/src/routers/auth.ts +143 -14
- package/src/routers/class.ts +52 -3
- package/src/routers/comment.ts +7 -0
- package/src/routers/conversation.ts +49 -29
- package/src/routers/file.ts +29 -5
- package/src/routers/labChat.ts +0 -1
- package/src/routers/newtonChat.ts +520 -0
- package/src/routers/section.ts +6 -6
- package/src/routers/user.ts +3 -2
- package/src/routers/worksheet.ts +9 -37
- package/src/seedDatabase.ts +290 -283
- package/src/server/pipelines/aiLabChat.ts +92 -0
- package/src/server/pipelines/gradeWorksheet.ts +152 -0
- package/src/trpc.ts +2 -0
- package/src/utils/email.ts +30 -3
- package/src/utils/inference.ts +50 -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,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,EAAE,EAAE,GAAG,CAAC,CAAC;6BAC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;qCACf;iCACF;6BACF;yBACF;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":"e1b81886-864f-565b-bfd4-84d4f7de1529"}
|
|
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 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,EAAE,EAAE,GAAG,CAAC,CAAC;6BACpD;4BACD,QAAQ,EAAE,KAAK;yBAChB;wBACD,MAAM,EAAE;4BACN,EAAE,EAAE,IAAI;4BACR,KAAK,EAAE,IAAI;4BACX,IAAI,EAAE,IAAI;4BACV,OAAO,EAAE,IAAI;yBACd;qBACF;iBACF;aACF,CAAC;YACF,MAAM,CAAC,KAAK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ACP,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"}
|
|
@@ -94,8 +94,14 @@ export declare const commentRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
94
94
|
author: {
|
|
95
95
|
id: string;
|
|
96
96
|
username: string;
|
|
97
|
+
profile: {
|
|
98
|
+
displayName: string | null;
|
|
99
|
+
profilePicture: string | null;
|
|
100
|
+
profilePictureThumbnail: string | null;
|
|
101
|
+
} | null;
|
|
97
102
|
};
|
|
98
103
|
} & {
|
|
104
|
+
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
99
105
|
id: string;
|
|
100
106
|
content: string;
|
|
101
107
|
createdAt: Date;
|
|
@@ -113,6 +119,7 @@ export declare const commentRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
113
119
|
parentCommentId: string;
|
|
114
120
|
};
|
|
115
121
|
output: {
|
|
122
|
+
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
116
123
|
id: string;
|
|
117
124
|
content: string;
|
|
118
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"}
|
package/dist/routers/comment.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]="d03138fb-c066-50f2-b192-9eb9b9e92ced")}catch(e){}}();
|
|
3
3
|
import { createTRPCRouter, protectedProcedure } from "../trpc.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { prisma } from "../lib/prisma.js";
|
|
@@ -74,6 +74,13 @@ export const commentRouter = createTRPCRouter({
|
|
|
74
74
|
select: {
|
|
75
75
|
id: true,
|
|
76
76
|
username: true,
|
|
77
|
+
profile: {
|
|
78
|
+
select: {
|
|
79
|
+
displayName: true,
|
|
80
|
+
profilePicture: true,
|
|
81
|
+
profilePictureThumbnail: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
77
84
|
},
|
|
78
85
|
},
|
|
79
86
|
}
|
|
@@ -268,4 +275,4 @@ export const commentRouter = createTRPCRouter({
|
|
|
268
275
|
}),
|
|
269
276
|
});
|
|
270
277
|
//# sourceMappingURL=comment.js.map
|
|
271
|
-
//# debugId=
|
|
278
|
+
//# debugId=d03138fb-c066-50f2-b192-9eb9b9e92ced
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.js","sources":["routers/comment.ts"],"sourceRoot":"/","sourcesContent":["import { createTRPCRouter, protectedProcedure } from \"../trpc.js\";\nimport { z } from \"zod\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { TRPCError } from \"@trpc/server\";\n\nexport const commentSelect = {\n id: true,\n content: true,\n createdAt: true,\n modifiedAt: true,\n author: {\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 reactions: {\n select: {\n type: true,\n user: {\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};\n\nexport const commentRouter = createTRPCRouter({\n get: protectedProcedure\n .input(z.object({\n id: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const comment = await prisma.comment.findUnique({\n where: { id: input.id },\n select: {\n ...commentSelect,\n }\n });\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n\n return comment;\n }),\n getReplies: protectedProcedure\n .input(z.object({\n commentId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const replies = await prisma.comment.findMany({\n where: { parentCommentId: input.commentId\n },\n include: {\n author: {\n select: {\n id: true,\n username: true,\n },\n },\n }\n });\n return replies;\n }),\n replyToComment: protectedProcedure\n .input(z.object({\n parentCommentId: z.string(),\n content: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { parentCommentId, content } = input;\n\n const newComment = await prisma.comment.create({\n data: {\n parentCommentId,\n content,\n authorId: ctx.user!.id,\n },\n });\n\n return newComment;\n }), \n addReaction: protectedProcedure\n .input(z.object({\n id: z.string(),\n type: z.enum(['THUMBSUP', 'CELEBRATE', 'CARE', 'HEART', 'IDEA', 'HAPPY']),\n }))\n .mutation(async ({ ctx, input }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"User must be authenticated\",\n });\n }\n\n // Exactly one of announcementId or commentId must be provided\n const comment = await prisma.comment.findUnique({\n where: { id: input.id },\n });\n\n const userId = ctx.user.id;\n\n // Verify the announcement or comment exists and belongs to the class\n if (comment) {\n const announcement = await prisma.announcement.findFirst({\n where: {\n id: input.id,\n },\n });\n\n // Upsert reaction: update if exists, create if not\n const reaction = await prisma.reaction.upsert({\n where: {\n userId_commentId: {\n userId,\n commentId: input.id,\n },\n },\n update: {\n type: input.type,\n },\n create: {\n type: input.type,\n userId,\n commentId: input.id,\n },\n include: {\n user: {\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\n return { reaction };\n }\n\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Unexpected error\",\n });\n }),\n\nremoveReaction: protectedProcedure\n .input(z.object({\n commentId: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"User must be authenticated\",\n });\n }\n\n // Exactly one of announcementId or commentId must be provided\n if (!input.commentId) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Either announcementId or commentId must be provided\",\n });\n }\n\n const userId = ctx.user.id;\n\n const reaction = await prisma.reaction.findUnique({\n where: {\n userId_commentId: {\n userId,\n commentId: input.commentId,\n },\n },\n });\n\n if (!reaction) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Reaction not found\",\n });\n }\n\n await prisma.reaction.delete({\n where: { id: reaction.id },\n });\n\n return { success: true };\n\n }),\n\ngetReactions: protectedProcedure\n .input(z.object({\n commentId: z.string().optional(),\n }))\n .query(async ({ ctx, input }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"User must be authenticated\",\n });\n }\n\n // Exactly one of announcementId or commentId must be provided\n if (!input.commentId) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Either announcementId or commentId must be provided\",\n });\n }\n\n const userId = ctx.user.id;\n\n // Verify comment exists\n const comment = await prisma.comment.findUnique({\n where: { id: input.commentId },\n include: {\n announcement: {\n select: {\n classId: true,\n },\n },\n },\n });\n\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n\n // Get reaction counts by type\n const reactionCounts = await prisma.reaction.groupBy({\n by: ['type'],\n where: { commentId: input.commentId },\n _count: { type: true },\n });\n\n // Get current user's reaction\n const userReaction = await prisma.reaction.findUnique({\n where: {\n userId_commentId: {\n userId,\n commentId: input.commentId,\n },\n },\n });\n\n // Format counts\n const counts = {\n THUMBSUP: 0,\n CELEBRATE: 0,\n CARE: 0,\n HEART: 0,\n IDEA: 0,\n HAPPY: 0,\n };\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,OAAO,EAAE,gBAAgB,EAA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,EAAE,CAAC,CAAC;SACzE,CAAC;IACV,CAAC,CAAC;CACL,CAAC,CAAC","debug_id":"1130e004-af99-533a-acec-d4188967559d"}
|
|
1
|
+
{"version":3,"file":"comment.js","sources":["routers/comment.ts"],"sourceRoot":"/","sourcesContent":["import { createTRPCRouter, protectedProcedure } from \"../trpc.js\";\nimport { z } from \"zod\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { TRPCError } from \"@trpc/server\";\n\nexport const commentSelect = {\n id: true,\n content: true,\n createdAt: true,\n modifiedAt: true,\n author: {\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 reactions: {\n select: {\n type: true,\n user: {\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};\n\nexport const commentRouter = createTRPCRouter({\n get: protectedProcedure\n .input(z.object({\n id: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const comment = await prisma.comment.findUnique({\n where: { id: input.id },\n select: {\n ...commentSelect,\n }\n });\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n\n return comment;\n }),\n getReplies: protectedProcedure\n .input(z.object({\n commentId: z.string(),\n }))\n .query(async ({ ctx, input }) => {\n const replies = await prisma.comment.findMany({\n where: { parentCommentId: input.commentId\n },\n include: {\n author: {\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 return replies;\n }),\n replyToComment: protectedProcedure\n .input(z.object({\n parentCommentId: z.string(),\n content: z.string(),\n }))\n .mutation(async ({ ctx, input }) => {\n const { parentCommentId, content } = input;\n\n const newComment = await prisma.comment.create({\n data: {\n parentCommentId,\n content,\n authorId: ctx.user!.id,\n },\n });\n\n return newComment;\n }), \n addReaction: protectedProcedure\n .input(z.object({\n id: z.string(),\n type: z.enum(['THUMBSUP', 'CELEBRATE', 'CARE', 'HEART', 'IDEA', 'HAPPY']),\n }))\n .mutation(async ({ ctx, input }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"User must be authenticated\",\n });\n }\n\n // Exactly one of announcementId or commentId must be provided\n const comment = await prisma.comment.findUnique({\n where: { id: input.id },\n });\n\n const userId = ctx.user.id;\n\n // Verify the announcement or comment exists and belongs to the class\n if (comment) {\n const announcement = await prisma.announcement.findFirst({\n where: {\n id: input.id,\n },\n });\n\n // Upsert reaction: update if exists, create if not\n const reaction = await prisma.reaction.upsert({\n where: {\n userId_commentId: {\n userId,\n commentId: input.id,\n },\n },\n update: {\n type: input.type,\n },\n create: {\n type: input.type,\n userId,\n commentId: input.id,\n },\n include: {\n user: {\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\n return { reaction };\n }\n\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Unexpected error\",\n });\n }),\n\nremoveReaction: protectedProcedure\n .input(z.object({\n commentId: z.string().optional(),\n }))\n .mutation(async ({ ctx, input }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"User must be authenticated\",\n });\n }\n\n // Exactly one of announcementId or commentId must be provided\n if (!input.commentId) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Either announcementId or commentId must be provided\",\n });\n }\n\n const userId = ctx.user.id;\n\n const reaction = await prisma.reaction.findUnique({\n where: {\n userId_commentId: {\n userId,\n commentId: input.commentId,\n },\n },\n });\n\n if (!reaction) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Reaction not found\",\n });\n }\n\n await prisma.reaction.delete({\n where: { id: reaction.id },\n });\n\n return { success: true };\n\n }),\n\ngetReactions: protectedProcedure\n .input(z.object({\n commentId: z.string().optional(),\n }))\n .query(async ({ ctx, input }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"User must be authenticated\",\n });\n }\n\n // Exactly one of announcementId or commentId must be provided\n if (!input.commentId) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Either announcementId or commentId must be provided\",\n });\n }\n\n const userId = ctx.user.id;\n\n // Verify comment exists\n const comment = await prisma.comment.findUnique({\n where: { id: input.commentId },\n include: {\n announcement: {\n select: {\n classId: true,\n },\n },\n },\n });\n\n if (!comment) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Comment not found\",\n });\n }\n\n // Get reaction counts by type\n const reactionCounts = await prisma.reaction.groupBy({\n by: ['type'],\n where: { commentId: input.commentId },\n _count: { type: true },\n });\n\n // Get current user's reaction\n const userReaction = await prisma.reaction.findUnique({\n where: {\n userId_commentId: {\n userId,\n commentId: input.commentId,\n },\n },\n });\n\n // Format counts\n const counts = {\n THUMBSUP: 0,\n CELEBRATE: 0,\n CARE: 0,\n HEART: 0,\n IDEA: 0,\n HAPPY: 0,\n };\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,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,EAAE,EAAE,IAAI;IACR,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE;QACJ,MAAM,EAAE;YACJ,EAAE,EAAE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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
|