@studious-lms/server 1.19.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/index.js +8 -2
  2. package/dist/index.js.map +1 -1
  3. package/dist/lib/pusher.d.ts +3 -1
  4. package/dist/lib/pusher.d.ts.map +1 -1
  5. package/dist/lib/pusher.js +5 -3
  6. package/dist/lib/pusher.js.map +1 -1
  7. package/dist/middleware/security.d.ts.map +1 -1
  8. package/dist/middleware/security.js +4 -4
  9. package/dist/middleware/security.js.map +1 -1
  10. package/dist/models/class.d.ts +1 -1
  11. package/dist/models/class.d.ts.map +1 -1
  12. package/dist/models/class.js +5 -4
  13. package/dist/models/class.js.map +1 -1
  14. package/dist/models/conversation.d.ts +17 -17
  15. package/dist/models/notification.d.ts +63 -11
  16. package/dist/models/notification.d.ts.map +1 -1
  17. package/dist/models/notification.js +24 -10
  18. package/dist/models/notification.js.map +1 -1
  19. package/dist/pipelines/aiLabChat.d.ts +1 -0
  20. package/dist/pipelines/aiLabChat.d.ts.map +1 -1
  21. package/dist/pipelines/aiLabChat.js +7 -2
  22. package/dist/pipelines/aiLabChat.js.map +1 -1
  23. package/dist/pipelines/aiNewtonChat.d.ts +2 -2
  24. package/dist/pipelines/aiNewtonChat.d.ts.map +1 -1
  25. package/dist/pipelines/aiNewtonChat.js +12 -4
  26. package/dist/pipelines/aiNewtonChat.js.map +1 -1
  27. package/dist/pipelines/gradeWorksheet.d.ts +3 -3
  28. package/dist/pipelines/gradeWorksheet.d.ts.map +1 -1
  29. package/dist/pipelines/gradeWorksheet.js +13 -9
  30. package/dist/pipelines/gradeWorksheet.js.map +1 -1
  31. package/dist/pipelines/pdfToWorksheet.d.ts +2 -0
  32. package/dist/pipelines/pdfToWorksheet.d.ts.map +1 -1
  33. package/dist/pipelines/pdfToWorksheet.js +3 -2
  34. package/dist/pipelines/pdfToWorksheet.js.map +1 -1
  35. package/dist/routers/_app.d.ts +174 -82
  36. package/dist/routers/_app.d.ts.map +1 -1
  37. package/dist/routers/announcement.d.ts.map +1 -1
  38. package/dist/routers/announcement.js +2 -2
  39. package/dist/routers/announcement.js.map +1 -1
  40. package/dist/routers/assignment.d.ts.map +1 -1
  41. package/dist/routers/assignment.js +12 -2
  42. package/dist/routers/assignment.js.map +1 -1
  43. package/dist/routers/notifications.d.ts +51 -41
  44. package/dist/routers/notifications.d.ts.map +1 -1
  45. package/dist/routers/notifications.js +22 -18
  46. package/dist/routers/notifications.js.map +1 -1
  47. package/dist/routers/school.d.ts +30 -0
  48. package/dist/routers/school.d.ts.map +1 -1
  49. package/dist/routers/school.js +11 -2
  50. package/dist/routers/school.js.map +1 -1
  51. package/dist/routers/user.d.ts +12 -0
  52. package/dist/routers/user.d.ts.map +1 -1
  53. package/dist/routers/user.js +11 -2
  54. package/dist/routers/user.js.map +1 -1
  55. package/dist/seedDatabase.d.ts +4 -0
  56. package/dist/seedDatabase.d.ts.map +1 -1
  57. package/dist/services/aiChatStream.d.ts +5 -0
  58. package/dist/services/aiChatStream.d.ts.map +1 -1
  59. package/dist/services/aiChatStream.js +32 -3
  60. package/dist/services/aiChatStream.js.map +1 -1
  61. package/dist/services/aiStream.d.ts +5 -0
  62. package/dist/services/aiStream.d.ts.map +1 -1
  63. package/dist/services/aiStream.js +29 -3
  64. package/dist/services/aiStream.js.map +1 -1
  65. package/dist/services/aiUsage.d.ts +72 -0
  66. package/dist/services/aiUsage.d.ts.map +1 -0
  67. package/dist/services/aiUsage.js +150 -0
  68. package/dist/services/aiUsage.js.map +1 -0
  69. package/dist/services/announcement.d.ts.map +1 -1
  70. package/dist/services/announcement.js +7 -2
  71. package/dist/services/announcement.js.map +1 -1
  72. package/dist/services/assignment.d.ts.map +1 -1
  73. package/dist/services/assignment.js +29 -4
  74. package/dist/services/assignment.js.map +1 -1
  75. package/dist/services/attendance.js +10 -2
  76. package/dist/services/attendance.js.map +1 -1
  77. package/dist/services/class.d.ts.map +1 -1
  78. package/dist/services/class.js +6 -2
  79. package/dist/services/class.js.map +1 -1
  80. package/dist/services/discussion.d.ts.map +1 -1
  81. package/dist/services/discussion.js +41 -12
  82. package/dist/services/discussion.js.map +1 -1
  83. package/dist/services/discussionSummary.d.ts.map +1 -1
  84. package/dist/services/discussionSummary.js +3 -2
  85. package/dist/services/discussionSummary.js.map +1 -1
  86. package/dist/services/notification.d.ts +79 -16
  87. package/dist/services/notification.d.ts.map +1 -1
  88. package/dist/services/notification.js +64 -16
  89. package/dist/services/notification.js.map +1 -1
  90. package/dist/services/studentProgress.d.ts.map +1 -1
  91. package/dist/services/studentProgress.js +6 -2
  92. package/dist/services/studentProgress.js.map +1 -1
  93. package/dist/services/userPrivacy.d.ts +4 -0
  94. package/dist/services/userPrivacy.d.ts.map +1 -1
  95. package/dist/services/userPrivacy.js +6 -2
  96. package/dist/services/userPrivacy.js.map +1 -1
  97. package/dist/services/worksheet.js +4 -4
  98. package/dist/services/worksheet.js.map +1 -1
  99. package/dist/utils/inference.d.ts +27 -0
  100. package/dist/utils/inference.d.ts.map +1 -1
  101. package/dist/utils/inference.js +23 -3
  102. package/dist/utils/inference.js.map +1 -1
  103. package/dist/workers/processors/aiLabChat.d.ts.map +1 -1
  104. package/dist/workers/processors/aiLabChat.js +4 -3
  105. package/dist/workers/processors/aiLabChat.js.map +1 -1
  106. package/dist/workers/processors/aiNewtonChat.d.ts.map +1 -1
  107. package/dist/workers/processors/aiNewtonChat.js +5 -5
  108. package/dist/workers/processors/aiNewtonChat.js.map +1 -1
  109. package/dist/workers/processors/gradeWorksheet.js +4 -4
  110. package/dist/workers/processors/gradeWorksheet.js.map +1 -1
  111. package/dist/workers/processors/pdfToWorksheet.d.ts.map +1 -1
  112. package/dist/workers/processors/pdfToWorksheet.js +7 -4
  113. package/dist/workers/processors/pdfToWorksheet.js.map +1 -1
  114. package/package.json +1 -1
  115. package/prisma/migrations/20260708011500_add_ai_usage_attribution/migration.sql +13 -0
  116. package/prisma/migrations/20260708013000_add_notification_type_and_entity/migration.sql +14 -0
  117. package/prisma/schema.prisma +29 -5
  118. package/src/index.ts +7 -0
  119. package/src/lib/pusher.ts +3 -1
  120. package/src/middleware/security.ts +2 -2
  121. package/src/models/class.ts +3 -2
  122. package/src/models/notification.ts +42 -13
  123. package/src/pipelines/aiLabChat.ts +6 -1
  124. package/src/pipelines/aiNewtonChat.ts +10 -0
  125. package/src/pipelines/gradeWorksheet.ts +25 -7
  126. package/src/pipelines/pdfToWorksheet.ts +3 -0
  127. package/src/routers/announcement.ts +0 -1
  128. package/src/routers/assignment.ts +10 -0
  129. package/src/routers/notifications.ts +26 -24
  130. package/src/routers/school.ts +12 -0
  131. package/src/routers/user.ts +12 -0
  132. package/src/services/aiChatStream.ts +35 -0
  133. package/src/services/aiStream.ts +34 -0
  134. package/src/services/aiUsage.ts +202 -0
  135. package/src/services/announcement.ts +5 -0
  136. package/src/services/assignment.ts +29 -2
  137. package/src/services/attendance.ts +12 -0
  138. package/src/services/class.ts +4 -0
  139. package/src/services/discussion.ts +50 -11
  140. package/src/services/discussionSummary.ts +1 -0
  141. package/src/services/notification.ts +83 -20
  142. package/src/services/studentProgress.ts +4 -0
  143. package/src/services/userPrivacy.ts +4 -0
  144. package/src/services/worksheet.ts +2 -2
  145. package/src/utils/inference.ts +40 -2
  146. package/src/workers/processors/aiLabChat.ts +2 -1
  147. package/src/workers/processors/aiNewtonChat.ts +3 -1
  148. package/src/workers/processors/gradeWorksheet.ts +2 -2
  149. package/src/workers/processors/pdfToWorksheet.ts +5 -2
  150. package/tests/integration/routers/notification.test.ts +68 -20
  151. package/tests/unit/services/aiUsage.test.ts +105 -0
@@ -1 +1 @@
1
- {"version":3,"file":"class.js","sources":["models/class.ts"],"sourceRoot":"/","sourcesContent":["\n/**\n * Class model – classes, members, assignments, grades, mark schemes,\n * grading boundaries, syllabus, lab drafts, invite codes.\n */\n\nimport { Assignment, Class, Folder, GradingBoundary, MarkScheme, Section, SessionType, Worksheet } from \"@prisma/client\";\nimport type { WorksheetQuestion } from \"@prisma/client\";\nimport type { AppPrismaClient, AppTransactionClient } from \"../lib/prisma.js\";\n\nimport { prisma } from \"../lib/prisma.js\";\nimport { v4 as uuidv4 } from 'uuid';\nimport { copyFile } from \"../lib/googleCloudStorage.js\";\nimport {\n classMemberOrSchoolAdminWhere,\n classTeacherOrSchoolAdminWhere,\n} from \"./access.js\";\n\nconst classIncludeForGetAll = {\n assignments: {\n where: {\n template: false,\n },\n select: {\n id: true,\n title: true,\n type: true,\n dueDate: true,\n submissions: {\n select: {\n studentId: true,\n submitted: true,\n returned: 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 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 school: {\n select: {\n id: true,\n name: true,\n },\n },\n department: {\n select: {\n id: true,\n name: true,\n color: true,\n },\n },\n} as const;\n\n/** @returns Classes where user is a teacher. */\nexport function findTeacherClasses(userId: string) {\n return prisma.class.findMany({\n where: classTeacherOrSchoolAdminWhere(userId),\n include: classIncludeForGetAll,\n });\n}\n\n/** @returns Classes where user is a student. */\nexport function findStudentClasses(userId: string) {\n return prisma.class.findMany({\n where: { students: { some: { id: userId } } },\n include: classIncludeForGetAll,\n });\n}\n\n/** @returns Class if user is a teacher or school admin. */\nexport function isTeacherInClass(classId: string, userId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(userId),\n },\n });\n}\n\nconst classIncludeForGet = {\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: { createdAt: \"desc\" as const },\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 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 section: {\n select: { id: true, name: true },\n },\n markScheme: {\n select: { id: true, structured: true },\n },\n gradingBoundary: {\n select: { id: true, structured: true },\n },\n submissions: {\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 discussionsEnabled: true,\n studentsCanCreateDiscussions: true,\n studentsCanReply: true,\n} as const;\n\nconst assignmentSelect = {\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 section: { select: { id: true, name: true } },\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n submissions: {\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} as const;\n\n/** @returns Class with assignments. Students see only assigned; teachers see all. */\nexport function findClassWithAssignments(\n classId: string,\n options: { isTeacher: boolean; userId?: string }\n) {\n const assignmentWhere = !options.isTeacher &&\n options.userId\n ? {\n OR: [\n { assignedTo: { some: { id: options.userId } } },\n { assignedTo: { none: {} } },\n ],\n }\n : undefined;\n\n const submissionWhere =\n !options.isTeacher && options.userId\n ? { studentId: options.userId }\n : undefined;\n\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...(options.userId\n ? classMemberOrSchoolAdminWhere(options.userId)\n : {}),\n },\n include: {\n teachers: classIncludeForGet.teachers,\n students: classIncludeForGet.students,\n announcements: classIncludeForGet.announcements,\n assignments: {\n ...(assignmentWhere && { where: assignmentWhere }),\n select: {\n ...assignmentSelect,\n submissions: {\n ...(submissionWhere && { where: submissionWhere }),\n select: assignmentSelect.submissions.select,\n },\n },\n },\n },\n });\n}\n\n/** @returns Class by ID (minimal). */\nexport function findClassByIdBasic(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n });\n}\n\n/** @returns Sections for a class. */\nexport function findSectionsByClassId(classId: string) {\n return prisma.section.findMany({\n where: { classId },\n });\n}\n\n/** @returns User by ID (id, username only). */\nexport function findUserById(userId: string) {\n return prisma.user.findUnique({\n where: { id: userId },\n select: { id: true, username: true },\n });\n}\n\n/** @returns Session by class invite code. */\nexport function findSessionByClassCode(classCode: string) {\n return prisma.session.findFirst({\n where: {\n id: { equals: classCode, mode: \"insensitive\" },\n type: SessionType.CLASS_INVITE,\n },\n });\n}\n\n/** @returns Session for a class. */\nexport function findSessionByClassId(classId: string) {\n return prisma.session.findFirst({\n where: { classId },\n });\n}\n\n/** @returns User's graded submissions for grade calculation. */\nexport function findSubmissionsForGrades(userId: string, classId: string) {\n return prisma.submission.findMany({\n where: {\n studentId: userId,\n assignment: { classId, graded: true },\n },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n markSchemeId: true,\n dueDate: true,\n markScheme: { select: { structured: true } },\n gradingBoundaryId: true,\n gradingBoundary: { select: { structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Events for a class. */\nexport function findEventsByClassId(classId: string) {\n return prisma.event.findMany({\n where: { class: { id: classId } },\n select: { name: true, startTime: true, endTime: true },\n });\n}\n\n/** @returns Mark schemes for a class. */\nexport function findMarkSchemesByClassId(classId: string) {\n return prisma.markScheme.findMany({\n where: { class: { id: classId } },\n });\n}\n\n/** @returns Grading boundaries for a class. */\nexport function findGradingBoundariesByClassId(classId: string) {\n return prisma.gradingBoundary.findMany({\n where: { class: { id: classId } },\n });\n}\n\n/** @returns Class syllabus. */\nexport function findClassSyllabus(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n select: { syllabus: true },\n });\n}\n\n/** @returns In-progress lab drafts for a teacher. */\nexport function findLabDraftsByClass(classId: string, teacherId: string) {\n return prisma.assignment.findMany({\n where: {\n classId,\n teacherId,\n inProgress: true,\n },\n orderBy: { modifiedAt: \"desc\" as const },\n });\n}\n\n/** @returns Assignments with attachments and submissions. */\nexport function findAssignmentsWithFiles(classId: string) {\n return prisma.assignment.findMany({\n where: { classId },\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: { select: { id: true, username: true } },\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: { select: { id: true, username: true } },\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: { select: { id: true, username: true } },\n },\n },\n student: { select: { id: true, username: true } },\n },\n },\n teacher: { select: { id: true, username: true } },\n },\n orderBy: { createdAt: \"desc\" as const },\n });\n}\n\nasync function recursivelyIncludeFiles(folderId: string) {\n if (!folderId.length) {\n return null;\n }\n\n const folder = await prisma.folder.findUnique({\n where: { id: folderId },\n include: {\n files: {\n select: { id: true, name: true, type: true, size: true, path: true },\n },\n childFolders: {\n select: { id: true },\n },\n },\n });\n if (!folder) {\n return null;\n }\n return {\n ...folder,\n files: folder.files.map(file => file.id),\n childFolders: await Promise.all(folder.childFolders.map(folder => recursivelyIncludeFiles(folder.id))),\n };\n}\n\n/** Copy all files in folder tree to GCS (outside transaction). Returns map of sourcePath -> newPath. */\nasync function recursivelyCopyFilesToGcs(folderId: string): Promise<Map<string, string>> {\n const pathMap = new Map<string, string>();\n if (!folderId.length) return pathMap;\n\n const folder = await prisma.folder.findUnique({\n where: { id: folderId },\n include: {\n files: { select: { path: true, name: true } },\n childFolders: { select: { id: true } },\n },\n });\n if (!folder) return pathMap;\n\n for (const file of folder.files) {\n const ext = file.name.split('.').pop() || '';\n const newPath = `imported/${uuidv4()}${ext ? `.${ext}` : ''}`;\n await copyFile(file.path, newPath);\n pathMap.set(file.path, newPath);\n }\n for (const child of folder.childFolders) {\n const childMap = await recursivelyCopyFilesToGcs(child.id);\n childMap.forEach((v, k) => pathMap.set(k, v));\n }\n return pathMap;\n}\n\nasync function recursivelyCreateFiles(\n tx: AppPrismaClient | AppTransactionClient,\n folderId: string,\n targetFolderId: string | undefined,\n pathMap: Map<string, string>\n) {\n if (!folderId.length) return;\n\n const parentFolder = await tx.folder.findUnique({\n where: { id: folderId },\n include: {\n files: { select: { id: true, name: true, type: true, size: true, path: true } },\n childFolders: { select: { id: true, name: true, color: true, parentFolderId: true } },\n },\n });\n if (!parentFolder) return;\n\n for (const file of parentFolder.files) {\n const newPath = pathMap.get(file.path);\n if (!newPath) continue;\n await tx.file.create({\n data: {\n name: file.name,\n type: file.type,\n size: file.size,\n path: newPath,\n uploadStatus: 'COMPLETED',\n ...(targetFolderId && { folder: { connect: { id: targetFolderId } } }),\n },\n });\n }\n\n for (const childFolder of parentFolder.childFolders) {\n const newFolder = await tx.folder.create({\n data: {\n name: childFolder.name,\n color: childFolder.color,\n parentFolderId: targetFolderId ?? parentFolder.id,\n },\n });\n await recursivelyCreateFiles(tx, childFolder.id, newFolder.id, pathMap);\n }\n}\n\n\nexport async function findFullExportableClass(classId: string) {\n const baseClass = await prisma.class.findUnique({\n where: { id: classId },\n include: {\n assignments: {\n select: {\n ...assignmentSelect,\n submissions: false,\n worksheets: { select: { id: true } },\n teacherId: true,\n classId: true,\n sectionId: true,\n markSchemeId: true,\n gradingBoundaryId: true,\n eventId: true,\n acceptFiles: true,\n acceptExtendedResponse: true,\n acceptWorksheet: true,\n gradeWithAI: true,\n aiPolicyLevel: true,\n },\n },\n classFiles: {\n select: {\n id: true,\n },\n },\n worksheets: {\n select: {\n id: true,\n name: true,\n classId: true,\n questions: {\n select: {\n type: true,\n question: true,\n answer: true,\n points: true,\n options: true,\n markScheme: true,\n order: true,\n worksheetId: true,\n },\n },\n },\n },\n markSchemes: {\n select: {\n id: true,\n classId: true,\n structured: true,\n },\n },\n gradingBoundaries: {\n select: {\n id: true,\n classId: true,\n structured: true,\n },\n },\n sections: {\n select: {\n id: true,\n name: true,\n classId: true,\n color: true,\n order: true,\n },\n },\n },\n });\n\n if (!baseClass) {\n return null;\n }\n\n const classFiles = await recursivelyIncludeFiles(baseClass.classFiles?.id ?? \"\");\n\n const formattedClass = {\n ...baseClass,\n classFiles,\n };\n\n return formattedClass;\n}\n\nexport async function createClassByImport(classId: string, userId: string, year: number, classData: Class & { classFiles: Folder | null }): Promise<string | null> {\n const pathMap = classData.classFiles?.id\n ? await recursivelyCopyFilesToGcs(classData.classFiles.id)\n : new Map<string, string>();\n\n const newClassId = await prisma.$transaction(async (tx) => {\n const createdClass = await tx.class.create({\n data: {\n name: classData.name,\n subject: classData.subject,\n color: classData.color,\n symbol: classData.symbol,\n section: classData.section,\n syllabus: classData.syllabus,\n teachers: { connect: { id: userId } },\n classFiles: { create: { name: \"Class Files\" } },\n },\n include: {\n classFiles: true,\n },\n });\n\n const oldSectionIdToNew = new Map<string, string>();\n const oldMarkSchemeIdToNew = new Map<string, string>();\n const oldGradingBoundaryIdToNew = new Map<string, string>();\n const oldWorksheetIdToNew = new Map<string, string>();\n\n const sections = (classData as unknown as Class & { sections: Section[] }).sections ?? [];\n await Promise.all(\n sections.map(async (section, index) => {\n const newSection = await tx.section.create({\n data: {\n name: section.name,\n classId: createdClass.id,\n color: section.color,\n order: section.order ?? index,\n },\n });\n oldSectionIdToNew.set(section.id, newSection.id);\n return newSection;\n })\n );\n\n const markSchemes = (classData as unknown as Class & { markSchemes: MarkScheme[] }).markSchemes ?? [];\n await Promise.all(\n markSchemes.map(async (ms) => {\n const newMs = await tx.markScheme.create({\n data: { classId: createdClass.id, structured: ms.structured },\n });\n oldMarkSchemeIdToNew.set(ms.id, newMs.id);\n return newMs;\n })\n );\n\n const gradingBoundaries = (classData as unknown as Class & { gradingBoundaries: GradingBoundary[] }).gradingBoundaries ?? [];\n await Promise.all(\n gradingBoundaries.map(async (gb) => {\n const newGb = await tx.gradingBoundary.create({\n data: { classId: createdClass.id, structured: gb.structured },\n });\n oldGradingBoundaryIdToNew.set(gb.id, newGb.id);\n return newGb;\n })\n );\n\n const worksheets = (classData as unknown as Class & { worksheets: Array<Worksheet & { questions: WorksheetQuestion[] }> }).worksheets ?? [];\n for (const worksheet of worksheets) {\n const newWorksheet = await tx.worksheet.create({\n data: {\n name: worksheet.name,\n classId: createdClass.id,\n questions: {\n create: (worksheet.questions ?? []).map((q, i) => ({\n type: q.type,\n question: q.question,\n answer: q.answer,\n points: q.points ?? 0,\n options: q.options ?? {},\n markScheme: q.markScheme ?? {},\n order: q.order ?? i,\n })),\n },\n },\n });\n oldWorksheetIdToNew.set(worksheet.id, newWorksheet.id);\n }\n\n const assignments = (classData as unknown as Class & { assignments: Array<Assignment & { worksheets?: { id: string }[] }> }).assignments ?? [];\n for (const assignment of assignments) {\n const date = new Date(assignment.dueDate);\n date.setFullYear(year);\n const worksheetIds = (assignment as { worksheets?: { id: string }[] }).worksheets?.map((w) => oldWorksheetIdToNew.get(w.id)).filter(Boolean) as string[] | undefined;\n await tx.assignment.create({\n data: {\n title: assignment.title,\n type: assignment.type,\n dueDate: date,\n instructions: assignment.instructions,\n teacherId: userId,\n classId: createdClass.id,\n sectionId: assignment.sectionId ? oldSectionIdToNew.get(assignment.sectionId) ?? undefined : undefined,\n markSchemeId: assignment.markSchemeId ? oldMarkSchemeIdToNew.get(assignment.markSchemeId) ?? undefined : undefined,\n gradingBoundaryId: assignment.gradingBoundaryId ? oldGradingBoundaryIdToNew.get(assignment.gradingBoundaryId) ?? undefined : undefined,\n weight: assignment.weight ?? 1,\n maxGrade: assignment.maxGrade ?? 0,\n graded: assignment.graded ?? false,\n inProgress: assignment.inProgress ?? false,\n template: assignment.template ?? false,\n acceptFiles: assignment.acceptFiles ?? false,\n acceptExtendedResponse: assignment.acceptExtendedResponse ?? false,\n acceptWorksheet: assignment.acceptWorksheet ?? false,\n gradeWithAI: assignment.gradeWithAI ?? false,\n aiPolicyLevel: assignment.aiPolicyLevel ?? 0,\n ...(worksheetIds?.length && { worksheets: { connect: worksheetIds.map((id) => ({ id })) } }),\n },\n });\n }\n\n if (classData.classFiles?.id) {\n await recursivelyCreateFiles(tx, classData.classFiles.id, createdClass.classFiles?.id, pathMap);\n }\n\n return createdClass.id;\n }, { timeout: 30000 });\n\n return newClassId;\n}\n"],"names":[],"mappings":"AACA;;;GAGG;;;AAEH,OAAO,EAAmE,WAAW,EAAa,MAAM,gBAAgB,CAAC;AAIzH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,MAAM,qBAAqB,GAAG;IAC5B,WAAW,EAAE;QACX,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK;SAChB;QACD,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI;YACb,WAAW,EAAE;gBACX,MAAM,EAAE;oBACN,SAAS,EAAE,IAAI;oBACf,SAAS,EAAE,IAAI;oBACf,QAAQ,EAAE,IAAI;iBACf;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,uBAAuB,E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AAE,UAAU,CAAC,WAAW,IAAI,KAAK;oBAC5C,sBAAsB,EAAE,UAAU,CAAC,sBAAsB,IAAI,KAAK;oBAClE,eAAe,EAAE,UAAU,CAAC,eAAe,IAAI,KAAK;oBACpD,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,KAAK;oBAC5C,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,CAAC;oBAC5C,GAAG,CAAC,YAAY,EAAE,MAAM,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;iBAC7F;aACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,SAAS,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC;YAC7B,MAAM,sBAAsB,CAAC,EAAE,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,EAAE,YAAY,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAClG,CAAC;QAED,OAAO,YAAY,CAAC,EAAE,CAAC;IACzB,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvB,OAAO,UAAU,CAAC;AACpB,CAAC","debug_id":"1dcfe7f5-6cc6-5283-8f6e-986e2f2c2972"}
1
+ {"version":3,"file":"class.js","sources":["models/class.ts"],"sourceRoot":"/","sourcesContent":["\n/**\n * Class model – classes, members, assignments, grades, mark schemes,\n * grading boundaries, syllabus, lab drafts, invite codes.\n */\n\nimport { Assignment, Class, Folder, GradingBoundary, MarkScheme, Section, SessionType, Worksheet } from \"@prisma/client\";\nimport type { WorksheetQuestion } from \"@prisma/client\";\nimport type { AppPrismaClient, AppTransactionClient } from \"../lib/prisma.js\";\n\nimport { prisma } from \"../lib/prisma.js\";\nimport { v4 as uuidv4 } from 'uuid';\nimport { copyFile } from \"../lib/googleCloudStorage.js\";\nimport {\n classMemberOrSchoolAdminWhere,\n classTeacherOrSchoolAdminWhere,\n} from \"./access.js\";\n\nconst classIncludeForGetAll = {\n assignments: {\n where: {\n template: false,\n },\n select: {\n id: true,\n title: true,\n type: true,\n dueDate: true,\n submissions: {\n select: {\n studentId: true,\n submitted: true,\n returned: 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 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 school: {\n select: {\n id: true,\n name: true,\n },\n },\n department: {\n select: {\n id: true,\n name: true,\n color: true,\n },\n },\n} as const;\n\n/** @returns Classes where user is a teacher. */\nexport function findTeacherClasses(userId: string) {\n return prisma.class.findMany({\n where: classTeacherOrSchoolAdminWhere(userId),\n include: classIncludeForGetAll,\n });\n}\n\n/** @returns Classes where user is a student. */\nexport function findStudentClasses(userId: string) {\n return prisma.class.findMany({\n where: { students: { some: { id: userId } } },\n include: classIncludeForGetAll,\n });\n}\n\n/** @returns Class if user is a teacher or school admin. */\nexport function isTeacherInClass(classId: string, userId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(userId),\n },\n });\n}\n\nconst classIncludeForGet = {\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: { createdAt: \"desc\" as const },\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 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 section: {\n select: { id: true, name: true },\n },\n markScheme: {\n select: { id: true, structured: true },\n },\n gradingBoundary: {\n select: { id: true, structured: true },\n },\n submissions: {\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 discussionsEnabled: true,\n studentsCanCreateDiscussions: true,\n studentsCanReply: true,\n} as const;\n\nconst assignmentSelect = {\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 section: { select: { id: true, name: true } },\n markScheme: { select: { id: true, structured: true } },\n gradingBoundary: { select: { id: true, structured: true } },\n submissions: {\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} as const;\n\n/** @returns Class with assignments. Students see only assigned; teachers see all. */\nexport function findClassWithAssignments(\n classId: string,\n options: { isTeacher: boolean; userId?: string }\n) {\n const assignmentWhere = !options.isTeacher &&\n options.userId\n ? {\n OR: [\n { assignedTo: { some: { id: options.userId } } },\n { assignedTo: { none: {} } },\n ],\n }\n : undefined;\n\n const submissionWhere =\n !options.isTeacher && options.userId\n ? { studentId: options.userId }\n : undefined;\n\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...(options.userId\n ? classMemberOrSchoolAdminWhere(options.userId)\n : {}),\n },\n include: {\n teachers: classIncludeForGet.teachers,\n students: classIncludeForGet.students,\n announcements: classIncludeForGet.announcements,\n assignments: {\n ...(assignmentWhere && { where: assignmentWhere }),\n select: {\n ...assignmentSelect,\n submissions: {\n ...(submissionWhere && { where: submissionWhere }),\n select: assignmentSelect.submissions.select,\n },\n },\n },\n },\n });\n}\n\n/** @returns Class by ID (minimal). */\nexport function findClassByIdBasic(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n });\n}\n\n/** @returns Sections for a class. */\nexport function findSectionsByClassId(classId: string) {\n return prisma.section.findMany({\n where: { classId },\n });\n}\n\n/** @returns User by ID (id, username only). */\nexport function findUserById(userId: string) {\n return prisma.user.findUnique({\n where: { id: userId },\n select: { id: true, username: true },\n });\n}\n\n/** @returns Session by class invite code. */\nexport function findSessionByClassCode(classCode: string) {\n return prisma.session.findFirst({\n where: {\n id: { equals: classCode, mode: \"insensitive\" },\n type: SessionType.CLASS_INVITE,\n },\n });\n}\n\n/** @returns Invite session for a class. */\nexport function findSessionByClassId(classId: string) {\n return prisma.session.findFirst({\n where: { classId, type: SessionType.CLASS_INVITE },\n orderBy: { expiresAt: \"desc\" },\n });\n}\n\n/** @returns User's graded submissions for grade calculation. */\nexport function findSubmissionsForGrades(userId: string, classId: string) {\n return prisma.submission.findMany({\n where: {\n studentId: userId,\n assignment: { classId, graded: true },\n },\n include: {\n assignment: {\n select: {\n id: true,\n title: true,\n maxGrade: true,\n weight: true,\n markSchemeId: true,\n dueDate: true,\n markScheme: { select: { structured: true } },\n gradingBoundaryId: true,\n gradingBoundary: { select: { structured: true } },\n },\n },\n },\n });\n}\n\n/** @returns Events for a class. */\nexport function findEventsByClassId(classId: string) {\n return prisma.event.findMany({\n where: { class: { id: classId } },\n select: { name: true, startTime: true, endTime: true },\n });\n}\n\n/** @returns Mark schemes for a class. */\nexport function findMarkSchemesByClassId(classId: string) {\n return prisma.markScheme.findMany({\n where: { class: { id: classId } },\n });\n}\n\n/** @returns Grading boundaries for a class. */\nexport function findGradingBoundariesByClassId(classId: string) {\n return prisma.gradingBoundary.findMany({\n where: { class: { id: classId } },\n });\n}\n\n/** @returns Class syllabus. */\nexport function findClassSyllabus(classId: string) {\n return prisma.class.findUnique({\n where: { id: classId },\n select: { syllabus: true },\n });\n}\n\n/** @returns In-progress lab drafts for a teacher. */\nexport function findLabDraftsByClass(classId: string, teacherId: string) {\n return prisma.assignment.findMany({\n where: {\n classId,\n teacherId,\n inProgress: true,\n },\n orderBy: { modifiedAt: \"desc\" as const },\n });\n}\n\n/** @returns Assignments with attachments and submissions. */\nexport function findAssignmentsWithFiles(classId: string) {\n return prisma.assignment.findMany({\n where: { classId },\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: { select: { id: true, username: true } },\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: { select: { id: true, username: true } },\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: { select: { id: true, username: true } },\n },\n },\n student: { select: { id: true, username: true } },\n },\n },\n teacher: { select: { id: true, username: true } },\n },\n orderBy: { createdAt: \"desc\" as const },\n });\n}\n\nasync function recursivelyIncludeFiles(folderId: string) {\n if (!folderId.length) {\n return null;\n }\n\n const folder = await prisma.folder.findUnique({\n where: { id: folderId },\n include: {\n files: {\n select: { id: true, name: true, type: true, size: true, path: true },\n },\n childFolders: {\n select: { id: true },\n },\n },\n });\n if (!folder) {\n return null;\n }\n return {\n ...folder,\n files: folder.files.map(file => file.id),\n childFolders: await Promise.all(folder.childFolders.map(folder => recursivelyIncludeFiles(folder.id))),\n };\n}\n\n/** Copy all files in folder tree to GCS (outside transaction). Returns map of sourcePath -> newPath. */\nasync function recursivelyCopyFilesToGcs(folderId: string): Promise<Map<string, string>> {\n const pathMap = new Map<string, string>();\n if (!folderId.length) return pathMap;\n\n const folder = await prisma.folder.findUnique({\n where: { id: folderId },\n include: {\n files: { select: { path: true, name: true } },\n childFolders: { select: { id: true } },\n },\n });\n if (!folder) return pathMap;\n\n for (const file of folder.files) {\n const ext = file.name.split('.').pop() || '';\n const newPath = `imported/${uuidv4()}${ext ? `.${ext}` : ''}`;\n await copyFile(file.path, newPath);\n pathMap.set(file.path, newPath);\n }\n for (const child of folder.childFolders) {\n const childMap = await recursivelyCopyFilesToGcs(child.id);\n childMap.forEach((v, k) => pathMap.set(k, v));\n }\n return pathMap;\n}\n\nasync function recursivelyCreateFiles(\n tx: AppPrismaClient | AppTransactionClient,\n folderId: string,\n targetFolderId: string | undefined,\n pathMap: Map<string, string>\n) {\n if (!folderId.length) return;\n\n const parentFolder = await tx.folder.findUnique({\n where: { id: folderId },\n include: {\n files: { select: { id: true, name: true, type: true, size: true, path: true } },\n childFolders: { select: { id: true, name: true, color: true, parentFolderId: true } },\n },\n });\n if (!parentFolder) return;\n\n for (const file of parentFolder.files) {\n const newPath = pathMap.get(file.path);\n if (!newPath) continue;\n await tx.file.create({\n data: {\n name: file.name,\n type: file.type,\n size: file.size,\n path: newPath,\n uploadStatus: 'COMPLETED',\n ...(targetFolderId && { folder: { connect: { id: targetFolderId } } }),\n },\n });\n }\n\n for (const childFolder of parentFolder.childFolders) {\n const newFolder = await tx.folder.create({\n data: {\n name: childFolder.name,\n color: childFolder.color,\n parentFolderId: targetFolderId ?? parentFolder.id,\n },\n });\n await recursivelyCreateFiles(tx, childFolder.id, newFolder.id, pathMap);\n }\n}\n\n\nexport async function findFullExportableClass(classId: string) {\n const baseClass = await prisma.class.findUnique({\n where: { id: classId },\n include: {\n assignments: {\n select: {\n ...assignmentSelect,\n submissions: false,\n worksheets: { select: { id: true } },\n teacherId: true,\n classId: true,\n sectionId: true,\n markSchemeId: true,\n gradingBoundaryId: true,\n eventId: true,\n acceptFiles: true,\n acceptExtendedResponse: true,\n acceptWorksheet: true,\n gradeWithAI: true,\n aiPolicyLevel: true,\n },\n },\n classFiles: {\n select: {\n id: true,\n },\n },\n worksheets: {\n select: {\n id: true,\n name: true,\n classId: true,\n questions: {\n select: {\n type: true,\n question: true,\n answer: true,\n points: true,\n options: true,\n markScheme: true,\n order: true,\n worksheetId: true,\n },\n },\n },\n },\n markSchemes: {\n select: {\n id: true,\n classId: true,\n structured: true,\n },\n },\n gradingBoundaries: {\n select: {\n id: true,\n classId: true,\n structured: true,\n },\n },\n sections: {\n select: {\n id: true,\n name: true,\n classId: true,\n color: true,\n order: true,\n },\n },\n },\n });\n\n if (!baseClass) {\n return null;\n }\n\n const classFiles = await recursivelyIncludeFiles(baseClass.classFiles?.id ?? \"\");\n\n const formattedClass = {\n ...baseClass,\n classFiles,\n };\n\n return formattedClass;\n}\n\nexport async function createClassByImport(classId: string, userId: string, year: number, classData: Class & { classFiles: Folder | null }): Promise<string | null> {\n const pathMap = classData.classFiles?.id\n ? await recursivelyCopyFilesToGcs(classData.classFiles.id)\n : new Map<string, string>();\n\n const newClassId = await prisma.$transaction(async (tx) => {\n const createdClass = await tx.class.create({\n data: {\n name: classData.name,\n subject: classData.subject,\n color: classData.color,\n symbol: classData.symbol,\n section: classData.section,\n syllabus: classData.syllabus,\n teachers: { connect: { id: userId } },\n classFiles: { create: { name: \"Class Files\" } },\n },\n include: {\n classFiles: true,\n },\n });\n\n const oldSectionIdToNew = new Map<string, string>();\n const oldMarkSchemeIdToNew = new Map<string, string>();\n const oldGradingBoundaryIdToNew = new Map<string, string>();\n const oldWorksheetIdToNew = new Map<string, string>();\n\n const sections = (classData as unknown as Class & { sections: Section[] }).sections ?? [];\n await Promise.all(\n sections.map(async (section, index) => {\n const newSection = await tx.section.create({\n data: {\n name: section.name,\n classId: createdClass.id,\n color: section.color,\n order: section.order ?? index,\n },\n });\n oldSectionIdToNew.set(section.id, newSection.id);\n return newSection;\n })\n );\n\n const markSchemes = (classData as unknown as Class & { markSchemes: MarkScheme[] }).markSchemes ?? [];\n await Promise.all(\n markSchemes.map(async (ms) => {\n const newMs = await tx.markScheme.create({\n data: { classId: createdClass.id, structured: ms.structured },\n });\n oldMarkSchemeIdToNew.set(ms.id, newMs.id);\n return newMs;\n })\n );\n\n const gradingBoundaries = (classData as unknown as Class & { gradingBoundaries: GradingBoundary[] }).gradingBoundaries ?? [];\n await Promise.all(\n gradingBoundaries.map(async (gb) => {\n const newGb = await tx.gradingBoundary.create({\n data: { classId: createdClass.id, structured: gb.structured },\n });\n oldGradingBoundaryIdToNew.set(gb.id, newGb.id);\n return newGb;\n })\n );\n\n const worksheets = (classData as unknown as Class & { worksheets: Array<Worksheet & { questions: WorksheetQuestion[] }> }).worksheets ?? [];\n for (const worksheet of worksheets) {\n const newWorksheet = await tx.worksheet.create({\n data: {\n name: worksheet.name,\n classId: createdClass.id,\n questions: {\n create: (worksheet.questions ?? []).map((q, i) => ({\n type: q.type,\n question: q.question,\n answer: q.answer,\n points: q.points ?? 0,\n options: q.options ?? {},\n markScheme: q.markScheme ?? {},\n order: q.order ?? i,\n })),\n },\n },\n });\n oldWorksheetIdToNew.set(worksheet.id, newWorksheet.id);\n }\n\n const assignments = (classData as unknown as Class & { assignments: Array<Assignment & { worksheets?: { id: string }[] }> }).assignments ?? [];\n for (const assignment of assignments) {\n const date = new Date(assignment.dueDate);\n date.setFullYear(year);\n const worksheetIds = (assignment as { worksheets?: { id: string }[] }).worksheets?.map((w) => oldWorksheetIdToNew.get(w.id)).filter(Boolean) as string[] | undefined;\n await tx.assignment.create({\n data: {\n title: assignment.title,\n type: assignment.type,\n dueDate: date,\n instructions: assignment.instructions,\n teacherId: userId,\n classId: createdClass.id,\n sectionId: assignment.sectionId ? oldSectionIdToNew.get(assignment.sectionId) ?? undefined : undefined,\n markSchemeId: assignment.markSchemeId ? oldMarkSchemeIdToNew.get(assignment.markSchemeId) ?? undefined : undefined,\n gradingBoundaryId: assignment.gradingBoundaryId ? oldGradingBoundaryIdToNew.get(assignment.gradingBoundaryId) ?? undefined : undefined,\n weight: assignment.weight ?? 1,\n maxGrade: assignment.maxGrade ?? 0,\n graded: assignment.graded ?? false,\n inProgress: assignment.inProgress ?? false,\n template: assignment.template ?? false,\n acceptFiles: assignment.acceptFiles ?? false,\n acceptExtendedResponse: assignment.acceptExtendedResponse ?? false,\n acceptWorksheet: assignment.acceptWorksheet ?? false,\n gradeWithAI: assignment.gradeWithAI ?? false,\n aiPolicyLevel: assignment.aiPolicyLevel ?? 0,\n ...(worksheetIds?.length && { worksheets: { connect: worksheetIds.map((id) => ({ id })) } }),\n },\n });\n }\n\n if (classData.classFiles?.id) {\n await recursivelyCreateFiles(tx, classData.classFiles.id, createdClass.classFiles?.id, pathMap);\n }\n\n return createdClass.id;\n }, { timeout: 30000 });\n\n return newClassId;\n}\n"],"names":[],"mappings":"AACA;;;GAGG;;;AAEH,OAAO,EAAmE,WAAW,EAAa,MAAM,gBAAgB,CAAC;AAIzH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,MAAM,qBAAqB,GAAG;IAC5B,WAAW,EAAE;QACX,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK;SAChB;QACD,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI;YACb,WAAW,EAAE;gBACX,MAAM,EAAE;oBACN,SAAS,EAAE,IAAI;oBACf,SAAS,EAAE,IAAI;oBACf,QAAQ,EAAE,IAAI;iBACf;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,uBAAuB,EAAE,IAAI;iBAC9B;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,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UAAU,CAAC,sBAAsB,IAAI,KAAK;oBAClE,eAAe,EAAE,UAAU,CAAC,eAAe,IAAI,KAAK;oBACpD,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,KAAK;oBAC5C,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,CAAC;oBAC5C,GAAG,CAAC,YAAY,EAAE,MAAM,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;iBAC7F;aACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,SAAS,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC;YAC7B,MAAM,sBAAsB,CAAC,EAAE,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,EAAE,YAAY,CAAC,UAAU,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;QAClG,CAAC;QAED,OAAO,YAAY,CAAC,EAAE,CAAC;IACzB,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvB,OAAO,UAAU,CAAC;AACpB,CAAC","debug_id":"31c8c868-440e-51cf-a8ce-a43ecdff8984"}
@@ -4,42 +4,42 @@ export declare function findConversationsByUserId(userId: string): import("@pris
4
4
  id: string;
5
5
  title: string;
6
6
  } | null;
7
- messages: ({
8
- sender: {
7
+ members: ({
8
+ user: {
9
9
  id: string;
10
10
  username: string;
11
11
  profile: {
12
+ profilePicture: string | null;
12
13
  displayName: string | null;
13
14
  } | null;
14
15
  };
15
16
  } & {
16
- status: import(".prisma/client").$Enums.JobStatus | null;
17
- meta: import("@prisma/client/runtime/library.js").JsonValue | null;
18
17
  id: string;
19
- createdAt: Date;
20
- content: string;
21
- senderId: string;
18
+ userId: string;
19
+ role: import(".prisma/client").$Enums.ConversationRole;
22
20
  conversationId: string;
23
- runJobId: string | null;
21
+ joinedAt: Date;
22
+ hiddenAt: Date | null;
23
+ lastViewedAt: Date | null;
24
+ lastViewedMentionAt: Date | null;
24
25
  })[];
25
- members: ({
26
- user: {
26
+ messages: ({
27
+ sender: {
27
28
  id: string;
28
29
  username: string;
29
30
  profile: {
30
- profilePicture: string | null;
31
31
  displayName: string | null;
32
32
  } | null;
33
33
  };
34
34
  } & {
35
+ status: import(".prisma/client").$Enums.JobStatus | null;
36
+ meta: import("@prisma/client/runtime/library.js").JsonValue | null;
35
37
  id: string;
36
- userId: string;
37
- role: import(".prisma/client").$Enums.ConversationRole;
38
+ createdAt: Date;
39
+ content: string;
40
+ senderId: string;
38
41
  conversationId: string;
39
- joinedAt: Date;
40
- hiddenAt: Date | null;
41
- lastViewedAt: Date | null;
42
- lastViewedMentionAt: Date | null;
42
+ runJobId: string | null;
43
43
  })[];
44
44
  } & {
45
45
  type: import(".prisma/client").$Enums.ConversationType;
@@ -1,5 +1,19 @@
1
- /** @returns Notifications for a receiver, newest first. */
2
- export declare function findNotificationsByReceiverId(receiverId: string): import("@prisma/client/runtime/library.js").PrismaPromise<({
1
+ /**
2
+ * Notification model – in-app notifications, create, mark read.
3
+ */
4
+ import type { NotificationType } from "@prisma/client";
5
+ export type NotificationCreateData = {
6
+ receiverId: string;
7
+ title: string;
8
+ content: string;
9
+ senderId?: string | null;
10
+ type?: NotificationType;
11
+ entityType?: string | null;
12
+ entityId?: string | null;
13
+ classId?: string | null;
14
+ };
15
+ /** @returns A page of notifications for a receiver, newest first. */
16
+ export declare function findNotificationsByReceiverIdPaginated(receiverId: string, limit: number, cursor?: string | null): import("@prisma/client/runtime/library.js").PrismaPromise<({
3
17
  sender: {
4
18
  username: string;
5
19
  } | null;
@@ -7,13 +21,17 @@ export declare function findNotificationsByReceiverId(receiverId: string): impor
7
21
  username: string;
8
22
  };
9
23
  } & {
24
+ type: import(".prisma/client").$Enums.NotificationType;
10
25
  id: string;
11
26
  createdAt: Date;
27
+ classId: string | null;
12
28
  title: string;
13
29
  content: string;
14
30
  senderId: string | null;
15
31
  read: boolean;
16
32
  receiverId: string;
33
+ entityType: string | null;
34
+ entityId: string | null;
17
35
  })[]>;
18
36
  /** @returns Notification by ID. */
19
37
  export declare function findNotificationByIdForReceiver(id: string, receiverId: string): import("@prisma/client/runtime/library.js").DynamicModelExtensionFluentApi<import(".prisma/client").Prisma.TypeMap<import("@prisma/client/runtime/library.js").InternalArgs & {
@@ -48,20 +66,22 @@ export declare function findNotificationByIdForReceiver(id: string, receiverId:
48
66
  username: string;
49
67
  };
50
68
  } & {
69
+ type: import(".prisma/client").$Enums.NotificationType;
51
70
  id: string;
52
71
  createdAt: Date;
72
+ classId: string | null;
53
73
  title: string;
54
74
  content: string;
55
75
  senderId: string | null;
56
76
  read: boolean;
57
77
  receiverId: string;
78
+ entityType: string | null;
79
+ entityId: string | null;
58
80
  }) | null>;
81
+ /** @returns Number of unread notifications for a receiver. */
82
+ export declare function countUnreadNotifications(receiverId: string): import("@prisma/client/runtime/library.js").PrismaPromise<number>;
59
83
  /** Create a notification for one receiver. */
60
- export declare function createNotification(data: {
61
- receiverId: string;
62
- title: string;
63
- content: string;
64
- }): import("@prisma/client/runtime/library.js").DynamicModelExtensionFluentApi<import(".prisma/client").Prisma.TypeMap<import("@prisma/client/runtime/library.js").InternalArgs & {
84
+ export declare function createNotification(data: NotificationCreateData): import("@prisma/client/runtime/library.js").DynamicModelExtensionFluentApi<import(".prisma/client").Prisma.TypeMap<import("@prisma/client/runtime/library.js").InternalArgs & {
65
85
  result: {
66
86
  userProfile: {
67
87
  profilePicture: () => {
@@ -86,20 +106,46 @@ export declare function createNotification(data: {
86
106
  query: {};
87
107
  client: {};
88
108
  }, {}>, "Notification", "create", never> & import("@prisma/client/runtime/library.js").PrismaPromise<{
109
+ sender: {
110
+ username: string;
111
+ } | null;
112
+ receiver: {
113
+ username: string;
114
+ };
115
+ } & {
116
+ type: import(".prisma/client").$Enums.NotificationType;
89
117
  id: string;
90
118
  createdAt: Date;
119
+ classId: string | null;
91
120
  title: string;
92
121
  content: string;
93
122
  senderId: string | null;
94
123
  read: boolean;
95
124
  receiverId: string;
125
+ entityType: string | null;
126
+ entityId: string | null;
96
127
  }>;
97
- /** Create multiple notifications in one call. */
98
- export declare function createManyNotifications(data: Array<{
99
- receiverId: string;
128
+ /** Create multiple notifications in one call and return the created rows. */
129
+ export declare function createManyNotifications(data: NotificationCreateData[]): import("@prisma/client/runtime/library.js").PrismaPromise<({
130
+ sender: {
131
+ username: string;
132
+ } | null;
133
+ receiver: {
134
+ username: string;
135
+ };
136
+ } & {
137
+ type: import(".prisma/client").$Enums.NotificationType;
138
+ id: string;
139
+ createdAt: Date;
140
+ classId: string | null;
100
141
  title: string;
101
142
  content: string;
102
- }>): import("@prisma/client/runtime/library.js").PrismaPromise<import("@prisma/client/runtime/library.js").GetBatchResult>;
143
+ senderId: string | null;
144
+ read: boolean;
145
+ receiverId: string;
146
+ entityType: string | null;
147
+ entityId: string | null;
148
+ })[]>;
103
149
  /** Mark a receiver's notification as read. */
104
150
  export declare function markNotificationAsReadForReceiver(id: string, receiverId: string): Promise<({
105
151
  sender: {
@@ -109,12 +155,18 @@ export declare function markNotificationAsReadForReceiver(id: string, receiverId
109
155
  username: string;
110
156
  };
111
157
  } & {
158
+ type: import(".prisma/client").$Enums.NotificationType;
112
159
  id: string;
113
160
  createdAt: Date;
161
+ classId: string | null;
114
162
  title: string;
115
163
  content: string;
116
164
  senderId: string | null;
117
165
  read: boolean;
118
166
  receiverId: string;
167
+ entityType: string | null;
168
+ entityId: string | null;
119
169
  }) | null>;
170
+ /** Mark all of a receiver's notifications as read. */
171
+ export declare function markAllNotificationsAsReadForReceiver(receiverId: string): import("@prisma/client/runtime/library.js").PrismaPromise<import("@prisma/client/runtime/library.js").GetBatchResult>;
120
172
  //# sourceMappingURL=notification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.d.ts","sourceRoot":"/","sources":["models/notification.ts"],"names":[],"mappings":"AAUA,2DAA2D;AAC3D,wBAAgB,6BAA6B,C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AM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;MASvB;AAED,mCAAmC;AACnC,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAK7E;AAED,8DAA8D;AAC9D,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,qEAI1D;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK9D;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,sBAAsB,EAAE;;;;;;;;;;;;;;;;;;;MAKrE;AAED,8CAA8C;AAC9C,wBAAsB,iCAAiC,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;WAWrF;AAED,sDAAsD;AACtD,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,MAAM,yHAKvE"}
@@ -1,18 +1,17 @@
1
- /**
2
- * Notification model – in-app notifications, create, mark read.
3
- */
4
1
 
5
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="27013af7-e219-59da-9f3e-6a1ad17ccb17")}catch(e){}}();
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]="d98f6f33-ebe4-5b34-9c40-97b99be0c8fd")}catch(e){}}();
6
3
  import { prisma } from "../lib/prisma.js";
7
4
  const notificationInclude = {
8
5
  sender: { select: { username: true } },
9
6
  receiver: { select: { username: true } },
10
7
  };
11
- /** @returns Notifications for a receiver, newest first. */
12
- export function findNotificationsByReceiverId(receiverId) {
8
+ /** @returns A page of notifications for a receiver, newest first. */
9
+ export function findNotificationsByReceiverIdPaginated(receiverId, limit, cursor) {
13
10
  return prisma.notification.findMany({
14
11
  where: { receiverId },
15
- orderBy: { createdAt: "desc" },
12
+ orderBy: [{ createdAt: "desc" }, { id: "desc" }],
13
+ take: limit + 1,
14
+ ...(cursor ? { cursor: { id: cursor }, skip: 1 } : {}),
16
15
  include: notificationInclude,
17
16
  });
18
17
  }
@@ -23,16 +22,24 @@ export function findNotificationByIdForReceiver(id, receiverId) {
23
22
  include: notificationInclude,
24
23
  });
25
24
  }
25
+ /** @returns Number of unread notifications for a receiver. */
26
+ export function countUnreadNotifications(receiverId) {
27
+ return prisma.notification.count({
28
+ where: { receiverId, read: false },
29
+ });
30
+ }
26
31
  /** Create a notification for one receiver. */
27
32
  export function createNotification(data) {
28
33
  return prisma.notification.create({
29
34
  data,
35
+ include: notificationInclude,
30
36
  });
31
37
  }
32
- /** Create multiple notifications in one call. */
38
+ /** Create multiple notifications in one call and return the created rows. */
33
39
  export function createManyNotifications(data) {
34
- return prisma.notification.createMany({
40
+ return prisma.notification.createManyAndReturn({
35
41
  data,
42
+ include: notificationInclude,
36
43
  });
37
44
  }
38
45
  /** Mark a receiver's notification as read. */
@@ -46,5 +53,12 @@ export async function markNotificationAsReadForReceiver(id, receiverId) {
46
53
  }
47
54
  return findNotificationByIdForReceiver(id, receiverId);
48
55
  }
56
+ /** Mark all of a receiver's notifications as read. */
57
+ export function markAllNotificationsAsReadForReceiver(receiverId) {
58
+ return prisma.notification.updateMany({
59
+ where: { receiverId, read: false },
60
+ data: { read: true },
61
+ });
62
+ }
49
63
  //# sourceMappingURL=notification.js.map
50
- //# debugId=27013af7-e219-59da-9f3e-6a1ad17ccb17
64
+ //# debugId=d98f6f33-ebe4-5b34-9c40-97b99be0c8fd
@@ -1 +1 @@
1
- {"version":3,"file":"notification.js","sources":["models/notification.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Notification model – in-app notifications, create, mark read.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst notificationInclude = {\n sender: { select: { username: true } },\n receiver: { select: { username: true } },\n};\n\n/** @returns Notifications for a receiver, newest first. */\nexport function findNotificationsByReceiverId(receiverId: string) {\n return prisma.notification.findMany({\n where: { receiverId },\n orderBy: { createdAt: \"desc\" },\n include: notificationInclude,\n });\n}\n\n/** @returns Notification by ID. */\nexport function findNotificationByIdForReceiver(id: string, receiverId: string) {\n return prisma.notification.findFirst({\n where: { id, receiverId },\n include: notificationInclude,\n });\n}\n\n/** Create a notification for one receiver. */\nexport function createNotification(data: {\n receiverId: string;\n title: string;\n content: string;\n}) {\n return prisma.notification.create({\n data,\n });\n}\n\n/** Create multiple notifications in one call. */\nexport function createManyNotifications(\n data: Array<{ receiverId: string; title: string; content: string }>\n) {\n return prisma.notification.createMany({\n data,\n });\n}\n\n/** Mark a receiver's notification as read. */\nexport async function markNotificationAsReadForReceiver(id: string, receiverId: string) {\n const result = await prisma.notification.updateMany({\n where: { id, receiverId },\n data: { read: true },\n });\n\n if (result.count === 0) {\n return null;\n }\n\n return findNotificationByIdForReceiver(id, receiverId);\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,mBAAmB,GAAG;IAC1B,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACtC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;CACzC,CAAC;AAEF,2DAA2D;AAC3D,MAAM,UAAU,6BAA6B,CAAC,UAAkB;IAC9D,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;QAClC,KAAK,EAAE,EAAE,UAAU,EAAE;QACrB,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;QAC9B,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;AACL,CAAC;AAED,mCAAmC;AACnC,MAAM,UAAU,+BAA+B,CAAC,EAAU,EAAE,UAAkB;IAC5E,OAAO,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC;QACnC,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;QACzB,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;AACL,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,kBAAkB,CAAC,IAIlC;IACC,OAAO,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC;QAChC,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,uBAAuB,CACrC,IAAmE;IAEnE,OAAO,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC;QACpC,IAAI;KACL,CAAC,CAAC;AACL,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,EAAU,EAAE,UAAkB;IACpF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC;QAClD,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;QACzB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KACrB,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,+BAA+B,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC","debug_id":"27013af7-e219-59da-9f3e-6a1ad17ccb17"}
1
+ {"version":3,"file":"notification.js","sources":["models/notification.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Notification model – in-app notifications, create, mark read.\n */\nimport type { NotificationType } from \"@prisma/client\";\nimport { prisma } from \"../lib/prisma.js\";\n\nconst notificationInclude = {\n sender: { select: { username: true } },\n receiver: { select: { username: true } },\n};\n\nexport type NotificationCreateData = {\n receiverId: string;\n title: string;\n content: string;\n senderId?: string | null;\n type?: NotificationType;\n entityType?: string | null;\n entityId?: string | null;\n classId?: string | null;\n};\n\n/** @returns A page of notifications for a receiver, newest first. */\nexport function findNotificationsByReceiverIdPaginated(\n receiverId: string,\n limit: number,\n cursor?: string | null\n) {\n return prisma.notification.findMany({\n where: { receiverId },\n orderBy: [{ createdAt: \"desc\" }, { id: \"desc\" }],\n take: limit + 1,\n ...(cursor ? { cursor: { id: cursor }, skip: 1 } : {}),\n include: notificationInclude,\n });\n}\n\n/** @returns Notification by ID. */\nexport function findNotificationByIdForReceiver(id: string, receiverId: string) {\n return prisma.notification.findFirst({\n where: { id, receiverId },\n include: notificationInclude,\n });\n}\n\n/** @returns Number of unread notifications for a receiver. */\nexport function countUnreadNotifications(receiverId: string) {\n return prisma.notification.count({\n where: { receiverId, read: false },\n });\n}\n\n/** Create a notification for one receiver. */\nexport function createNotification(data: NotificationCreateData) {\n return prisma.notification.create({\n data,\n include: notificationInclude,\n });\n}\n\n/** Create multiple notifications in one call and return the created rows. */\nexport function createManyNotifications(data: NotificationCreateData[]) {\n return prisma.notification.createManyAndReturn({\n data,\n include: notificationInclude,\n });\n}\n\n/** Mark a receiver's notification as read. */\nexport async function markNotificationAsReadForReceiver(id: string, receiverId: string) {\n const result = await prisma.notification.updateMany({\n where: { id, receiverId },\n data: { read: true },\n });\n\n if (result.count === 0) {\n return null;\n }\n\n return findNotificationByIdForReceiver(id, receiverId);\n}\n\n/** Mark all of a receiver's notifications as read. */\nexport function markAllNotificationsAsReadForReceiver(receiverId: string) {\n return prisma.notification.updateMany({\n where: { receiverId, read: false },\n data: { read: true },\n });\n}\n"],"names":[],"mappings":";;AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,mBAAmB,GAAG;IAC1B,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EA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uB,CAAC,IAA8B;IACpE,OAAO,MAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC;QAC7C,IAAI;QACJ,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;AACL,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,EAAU,EAAE,UAAkB;IACpF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC;QAClD,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;QACzB,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KACrB,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,+BAA+B,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,qCAAqC,CAAC,UAAkB;IACtE,OAAO,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC;QACpC,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE;QAClC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KACrB,CAAC,CAAC;AACL,CAAC","debug_id":"d98f6f33-ebe4-5b34-9c40-97b99be0c8fd"}
@@ -104,6 +104,7 @@ export declare const generateAndSendLabIntroduction: (labChatId: string, convers
104
104
  export declare const generateAndSendLabResponse: (labChatId: string, teacherMessage: string, emitOptions: {
105
105
  classId: string;
106
106
  aiMessageId: string;
107
+ userId?: string | null;
107
108
  }) => Promise<void>;
108
109
  export {};
109
110
  //# sourceMappingURL=aiLabChat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aiLabChat.d.ts","sourceRoot":"/","sources":["pipelines/aiLabChat.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,E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ClB,OAAO,CAAC,IAAI,CAgBd,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,GACrC,WAAW,MAAM,EACjB,gBAAgB,MAAM,EACtB,aAAa;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,KAC5E,OAAO,CAAC,IAAI,CAyUd,CAAA"}
@@ -3,7 +3,7 @@
3
3
  * Can create worksheets, sections, assignments, and generated files from AI output.
4
4
  */
5
5
 
6
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="34f3e5c6-5811-5644-b688-13b9a35600d2")}catch(e){}}();
6
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3084d592-a0a1-5867-bf8b-f4f57ced0b40")}catch(e){}}();
7
7
  import { isAIUser } from "../utils/aiUser.js";
8
8
  import { prisma } from "../lib/prisma.js";
9
9
  import { pusher, chatChannel, teacherChannel } from "../lib/pusher.js";
@@ -379,6 +379,11 @@ export const generateAndSendLabResponse = async (labChatId, teacherMessage, emit
379
379
  model: AI_CHAT_MODEL,
380
380
  system,
381
381
  messages,
382
+ usageReason: 'lab_chat_response',
383
+ attribution: {
384
+ userId: emitOptions.userId ?? fullLabChat.createdById,
385
+ classId: emitOptions.classId,
386
+ },
382
387
  tools,
383
388
  temperature: 0.7,
384
389
  maxOutputTokens: 4096,
@@ -557,4 +562,4 @@ export const generateAndSendLabResponse = async (labChatId, teacherMessage, emit
557
562
  }
558
563
  };
559
564
  //# sourceMappingURL=aiLabChat.js.map
560
- //# debugId=34f3e5c6-5811-5644-b688-13b9a35600d2
565
+ //# debugId=3084d592-a0a1-5867-bf8b-f4f57ced0b40