@studious-lms/server 1.4.1 → 1.4.3
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/.coderabbit.yaml +4 -1
- package/.env.example +6 -0
- package/.env.test.example +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -76
- package/dist/index.js.map +1 -1
- package/dist/lib/config/cors.d.ts +16 -0
- package/dist/lib/config/cors.d.ts.map +1 -0
- package/dist/lib/config/cors.js +75 -0
- package/dist/lib/config/cors.js.map +1 -0
- package/dist/lib/config/env.d.ts +14 -0
- package/dist/lib/config/env.d.ts.map +1 -1
- package/dist/lib/config/env.js +9 -2
- package/dist/lib/config/env.js.map +1 -1
- package/dist/lib/fileUpload.d.ts +10 -2
- package/dist/lib/fileUpload.d.ts.map +1 -1
- package/dist/lib/fileUpload.js +38 -6
- package/dist/lib/fileUpload.js.map +1 -1
- package/dist/lib/prisma.d.ts +14 -2
- package/dist/lib/prisma.d.ts.map +1 -1
- package/dist/lib/prisma.js +27 -8
- package/dist/lib/prisma.js.map +1 -1
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +18 -5
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/security.d.ts.map +1 -1
- package/dist/middleware/security.js +3 -3
- package/dist/middleware/security.js.map +1 -1
- package/dist/models/agenda.d.ts +16 -16
- package/dist/models/announcement.d.ts +59 -23
- package/dist/models/announcement.d.ts.map +1 -1
- package/dist/models/assignment.d.ts +363 -276
- package/dist/models/assignment.d.ts.map +1 -1
- package/dist/models/attendance.d.ts +63 -21
- package/dist/models/attendance.d.ts.map +1 -1
- package/dist/models/auth.d.ts +115 -26
- package/dist/models/auth.d.ts.map +1 -1
- package/dist/models/auth.js +53 -30
- package/dist/models/auth.js.map +1 -1
- package/dist/models/class.d.ts +115 -65
- package/dist/models/class.d.ts.map +1 -1
- package/dist/models/class.js +16 -4
- package/dist/models/class.js.map +1 -1
- package/dist/models/comment.d.ts +52 -16
- package/dist/models/comment.d.ts.map +1 -1
- package/dist/models/conversation.d.ts +46 -16
- package/dist/models/conversation.d.ts.map +1 -1
- package/dist/models/event.d.ts +107 -53
- package/dist/models/event.d.ts.map +1 -1
- package/dist/models/file.d.ts +213 -165
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/folder.d.ts +161 -77
- package/dist/models/folder.d.ts.map +1 -1
- package/dist/models/labChat.d.ts +73 -31
- package/dist/models/labChat.d.ts.map +1 -1
- package/dist/models/marketing.d.ts +25 -7
- package/dist/models/marketing.d.ts.map +1 -1
- package/dist/models/message.d.ts +31 -13
- package/dist/models/message.d.ts.map +1 -1
- package/dist/models/newtonChat.d.ts +34 -10
- package/dist/models/newtonChat.d.ts.map +1 -1
- package/dist/models/notification.d.ts +29 -10
- package/dist/models/notification.d.ts.map +1 -1
- package/dist/models/notification.js +13 -9
- package/dist/models/notification.js.map +1 -1
- package/dist/models/section.d.ts +71 -23
- package/dist/models/section.d.ts.map +1 -1
- package/dist/models/user.d.ts +27 -9
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/worksheet.d.ts +606 -106
- package/dist/models/worksheet.d.ts.map +1 -1
- package/dist/models/worksheet.js +168 -2
- package/dist/models/worksheet.js.map +1 -1
- package/dist/pipelines/aiLabChat.d.ts +22 -2
- package/dist/pipelines/aiLabChat.d.ts.map +1 -1
- package/dist/pipelines/aiLabChat.js +133 -95
- package/dist/pipelines/aiLabChat.js.map +1 -1
- package/dist/pipelines/aiLabChatContract.d.ts +25 -25
- package/dist/pipelines/aiNewtonChat.d.ts.map +1 -1
- package/dist/pipelines/aiNewtonChat.js +25 -14
- package/dist/pipelines/aiNewtonChat.js.map +1 -1
- package/dist/pipelines/gradeWorksheet.d.ts +8 -8
- package/dist/pipelines/gradeWorksheet.d.ts.map +1 -1
- package/dist/pipelines/gradeWorksheet.js +12 -5
- package/dist/pipelines/gradeWorksheet.js.map +1 -1
- package/dist/pipelines/labChatPrompt.d.ts +27 -0
- package/dist/pipelines/labChatPrompt.d.ts.map +1 -1
- package/dist/pipelines/labChatPrompt.js +143 -69
- package/dist/pipelines/labChatPrompt.js.map +1 -1
- package/dist/routers/_app.d.ts +1579 -1257
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/agenda.d.ts +16 -16
- package/dist/routers/announcement.d.ts +19 -19
- package/dist/routers/assignment.d.ts +307 -291
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +3 -2
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/attendance.d.ts +7 -7
- package/dist/routers/auth.d.ts +1 -1
- package/dist/routers/class.d.ts +79 -72
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +3 -3
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +6 -6
- package/dist/routers/conversation.d.ts +11 -11
- package/dist/routers/event.d.ts +35 -35
- package/dist/routers/file.d.ts +12 -12
- package/dist/routers/folder.d.ts +54 -54
- package/dist/routers/labChat.d.ts +18 -12
- package/dist/routers/labChat.d.ts.map +1 -1
- package/dist/routers/labChat.js +5 -3
- package/dist/routers/labChat.js.map +1 -1
- package/dist/routers/marketing.d.ts +2 -2
- package/dist/routers/message.d.ts +33 -2
- package/dist/routers/message.d.ts.map +1 -1
- package/dist/routers/message.js +27 -4
- package/dist/routers/message.js.map +1 -1
- package/dist/routers/newtonChat.d.ts +7 -1
- package/dist/routers/newtonChat.d.ts.map +1 -1
- package/dist/routers/newtonChat.js +5 -4
- package/dist/routers/newtonChat.js.map +1 -1
- package/dist/routers/notifications.d.ts +13 -6
- package/dist/routers/notifications.d.ts.map +1 -1
- package/dist/routers/notifications.js +4 -4
- package/dist/routers/notifications.js.map +1 -1
- package/dist/routers/section.d.ts +7 -7
- package/dist/routers/studentProgress.d.ts +86 -0
- package/dist/routers/studentProgress.d.ts.map +1 -1
- package/dist/routers/studentProgress.js +14 -4
- package/dist/routers/studentProgress.js.map +1 -1
- package/dist/routers/user.d.ts +1 -1
- package/dist/routers/worksheet.d.ts +64 -62
- package/dist/routers/worksheet.d.ts.map +1 -1
- package/dist/routers/worksheet.js +18 -16
- package/dist/routers/worksheet.js.map +1 -1
- package/dist/seedDatabase.d.ts +1 -1
- package/dist/services/agenda.d.ts +16 -16
- package/dist/services/announcement.d.ts +8 -8
- package/dist/services/assignment.d.ts +299 -283
- package/dist/services/assignment.d.ts.map +1 -1
- package/dist/services/assignment.js +24 -5
- package/dist/services/assignment.js.map +1 -1
- package/dist/services/attendance.d.ts +7 -7
- package/dist/services/auth.d.ts +2 -2
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/services/auth.js +19 -12
- package/dist/services/auth.js.map +1 -1
- package/dist/services/class.d.ts +74 -68
- package/dist/services/class.d.ts.map +1 -1
- package/dist/services/class.js +6 -3
- package/dist/services/class.js.map +1 -1
- package/dist/services/comment.d.ts +6 -6
- package/dist/services/conversation.d.ts +11 -11
- package/dist/services/event.d.ts +31 -31
- package/dist/services/file.d.ts +12 -12
- package/dist/services/file.d.ts.map +1 -1
- package/dist/services/file.js +7 -2
- package/dist/services/file.js.map +1 -1
- package/dist/services/folder.d.ts +52 -52
- package/dist/services/labChat.d.ts +18 -12
- package/dist/services/labChat.d.ts.map +1 -1
- package/dist/services/labChat.js +30 -18
- package/dist/services/labChat.js.map +1 -1
- package/dist/services/marketing.d.ts +2 -2
- package/dist/services/message.d.ts +30 -0
- package/dist/services/message.d.ts.map +1 -1
- package/dist/services/message.js +97 -21
- package/dist/services/message.js.map +1 -1
- package/dist/services/newtonChat.d.ts +6 -1
- package/dist/services/newtonChat.d.ts.map +1 -1
- package/dist/services/newtonChat.js +36 -18
- package/dist/services/newtonChat.js.map +1 -1
- package/dist/services/notification.d.ts +16 -9
- package/dist/services/notification.d.ts.map +1 -1
- package/dist/services/notification.js +24 -9
- package/dist/services/notification.js.map +1 -1
- package/dist/services/section.d.ts +6 -6
- package/dist/services/studentProgress.d.ts +75 -0
- package/dist/services/studentProgress.d.ts.map +1 -1
- package/dist/services/studentProgress.js +300 -107
- package/dist/services/studentProgress.js.map +1 -1
- package/dist/services/worksheet.d.ts +64 -64
- package/dist/services/worksheet.d.ts.map +1 -1
- package/dist/services/worksheet.js +138 -54
- package/dist/services/worksheet.js.map +1 -1
- package/dist/trpc.d.ts.map +1 -1
- package/dist/trpc.js +11 -17
- package/dist/trpc.js.map +1 -1
- package/dist/utils/inference.d.ts +9 -12
- package/dist/utils/inference.d.ts.map +1 -1
- package/dist/utils/inference.js +135 -95
- package/dist/utils/inference.js.map +1 -1
- package/package.json +1 -1
- package/prisma/migrations/20260410124000_add_submission_recommendation_state/migration.sql +14 -0
- package/prisma/migrations/20260415103500_add_session_type/migration.sql +33 -0
- package/prisma/migrations/20260415133000_add_ai_usage_logs/migration.sql +19 -0
- package/prisma/schema.prisma +41 -1
- package/scripts/test-pre-push.ts +6 -2
- package/src/index.ts +119 -79
- package/src/lib/config/cors.ts +96 -0
- package/src/lib/config/env.ts +12 -1
- package/src/lib/fileUpload.ts +55 -5
- package/src/lib/prisma.ts +25 -6
- package/src/middleware/auth.ts +19 -4
- package/src/middleware/security.ts +1 -1
- package/src/models/auth.ts +59 -29
- package/src/models/class.ts +15 -4
- package/src/models/notification.ts +13 -7
- package/src/models/worksheet.ts +202 -0
- package/src/pipelines/aiLabChat.ts +183 -104
- package/src/pipelines/aiNewtonChat.ts +24 -14
- package/src/pipelines/gradeWorksheet.ts +10 -2
- package/src/pipelines/labChatPrompt.ts +196 -68
- package/src/routers/assignment.ts +1 -0
- package/src/routers/class.ts +2 -2
- package/src/routers/labChat.ts +3 -1
- package/src/routers/message.ts +38 -1
- package/src/routers/newtonChat.ts +4 -2
- package/src/routers/notifications.ts +2 -2
- package/src/routers/studentProgress.ts +25 -1
- package/src/routers/worksheet.ts +31 -19
- package/src/services/assignment.ts +30 -2
- package/src/services/auth.ts +26 -12
- package/src/services/class.ts +4 -1
- package/src/services/file.ts +6 -0
- package/src/services/labChat.ts +42 -18
- package/src/services/message.ts +163 -18
- package/src/services/newtonChat.ts +49 -18
- package/src/services/notification.ts +27 -8
- package/src/services/studentProgress.ts +425 -121
- package/src/services/worksheet.ts +191 -51
- package/src/trpc.ts +12 -18
- package/src/utils/inference.ts +205 -112
- package/tests/globalSetup.ts +13 -4
- package/tests/lib/cors.test.ts +103 -0
- package/tests/pipelines/aiLabChat.test.ts +64 -84
- package/tests/routers/auth.test.ts +120 -17
- package/tests/routers/class.test.ts +7 -1
- package/tests/routers/message.test.ts +236 -9
- package/tests/routers/newtonChat.test.ts +81 -0
- package/tests/routers/notification.test.ts +12 -0
- package/tests/routers/studentProgress.test.ts +2 -31
- package/tests/routers/worksheet.test.ts +194 -0
- package/tests/setup.ts +22 -5
- package/tests/utils/aiLabChatPrompt.test.ts +114 -6
- package/tests/utils/inference.test.ts +218 -0
- package/tests/utils/studentProgress.test.ts +361 -0
- package/vitest.unit.config.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sources":["services/file.ts"],"sourceRoot":"/","sourcesContent":["/**\n * File service – signed URLs, move, rename, delete. Handles permission checks\n * for assignment, submission, announcement, folder, and user-owned files.\n */\nimport { TRPCError } from \"@trpc/server\";\nimport { getSignedUrl, deleteFile } from \"../lib/googleCloudStorage.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n findFileById,\n findFileWithFolder,\n findFileWithFolderAndThumbnail,\n findFolderById,\n updateFileFolder,\n updateFileName,\n deleteFileById,\n} from \"../models/file.js\";\n\n/** Generate a signed URL for file download. Validates user has access. */\nexport async function getFileSignedUrl(userId: string, fileId: string) {\n const file = await findFileById(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File does not exist\",\n });\n }\n\n let hasAccess = false;\n\n if (file.assignment?.class) {\n const isTeacher = file.assignment.class.teachers.some(\n (t) => t.id === userId\n );\n const isStudent = file.assignment.class.students.some(\n (s) => s.id === userId\n );\n logger.info(\n `Assignment file access check - userId: ${userId}, isTeacher: ${isTeacher}, isStudent: ${isStudent}`\n );\n hasAccess = isTeacher || isStudent;\n }\n\n if ((file as any).announcement?.class) {\n const ann = (file as any).announcement;\n const isTeacher = ann.class.teachers.some((t: any) => t.id === userId);\n const isStudent = ann.class.students.some((s: any) => s.id === userId);\n hasAccess = hasAccess || isTeacher || isStudent;\n }\n\n if (file.submission?.assignment?.classId) {\n hasAccess =\n hasAccess ||\n file.submission.studentId === userId ||\n file.submission.assignment.class.teachers.some((t) => t.id === userId);\n }\n\n if (file.annotations?.assignment?.classId) {\n hasAccess =\n hasAccess ||\n file.annotations.studentId === userId ||\n file.annotations.assignment.class.teachers.some((t) => t.id === userId);\n }\n\n if (file.userId === userId) {\n hasAccess = true;\n }\n\n if (file.folder?.class) {\n const isTeacher = file.folder.class.teachers.some((t) => t.id === userId);\n const isStudent = file.folder.class.students.some((s) => s.id === userId);\n hasAccess = hasAccess || isTeacher || isStudent;\n }\n\n if (!hasAccess) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You do not have access to this file\",\n });\n }\n\n try {\n const signedUrl = await getSignedUrl(file.path);\n return { url: signedUrl };\n } catch (error) {\n logger.error(\"Error generating signed URL:\", error as Record<string, unknown>);\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to generate download URL\",\n });\n }\n}\n\nexport async function moveFile(\n fileId: string,\n targetFolderId: string\n) {\n const file = await findFileWithFolder(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File not found\",\n });\n }\n\n const targetFolder = await findFolderById(targetFolderId);\n if (!targetFolder) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Target folder not found\",\n });\n }\n\n return updateFileFolder(fileId, targetFolderId);\n}\n\nexport async function renameFile(\n fileId: string,\n newName: string\n) {\n const file = await findFileWithFolder(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File not found\",\n });\n }\n\n if (!newName.trim()) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"File name cannot be empty\",\n });\n }\n\n return updateFileName(fileId, newName.trim());\n}\n\nexport async function deleteFileRecord(fileId: string, classId: string) {\n const file = await findFileWithFolderAndThumbnail(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File not found\",\n });\n }\n\n if (file.folder?.classId !== classId) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"File does not belong to this class\",\n });\n }\n\n try {\n if (file.uploadStatus === \"COMPLETED\") {\n await deleteFile(file.path);\n if (file.thumbnail) {\n await deleteFile(file.thumbnail.path);\n }\n }\n } catch (error) {\n logger.warn(`Failed to delete file ${file.path}:`, error as Record<string, unknown>);\n }\n\n await deleteFileById(fileId);\n return { success: true };\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,8BAA8B,EAC9B,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"file.js","sources":["services/file.ts"],"sourceRoot":"/","sourcesContent":["/**\n * File service – signed URLs, move, rename, delete. Handles permission checks\n * for assignment, submission, announcement, folder, and user-owned files.\n */\nimport { TRPCError } from \"@trpc/server\";\nimport { getSignedUrl, deleteFile } from \"../lib/googleCloudStorage.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n findFileById,\n findFileWithFolder,\n findFileWithFolderAndThumbnail,\n findFolderById,\n updateFileFolder,\n updateFileName,\n deleteFileById,\n} from \"../models/file.js\";\nimport { findConversationMembership } from \"../models/message.js\";\n\n/** Generate a signed URL for file download. Validates user has access. */\nexport async function getFileSignedUrl(userId: string, fileId: string) {\n const file = await findFileById(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File does not exist\",\n });\n }\n\n let hasAccess = false;\n\n if (file.assignment?.class) {\n const isTeacher = file.assignment.class.teachers.some(\n (t) => t.id === userId\n );\n const isStudent = file.assignment.class.students.some(\n (s) => s.id === userId\n );\n logger.info(\n `Assignment file access check - userId: ${userId}, isTeacher: ${isTeacher}, isStudent: ${isStudent}`\n );\n hasAccess = isTeacher || isStudent;\n }\n\n if ((file as any).announcement?.class) {\n const ann = (file as any).announcement;\n const isTeacher = ann.class.teachers.some((t: any) => t.id === userId);\n const isStudent = ann.class.students.some((s: any) => s.id === userId);\n hasAccess = hasAccess || isTeacher || isStudent;\n }\n\n if (file.submission?.assignment?.classId) {\n hasAccess =\n hasAccess ||\n file.submission.studentId === userId ||\n file.submission.assignment.class.teachers.some((t) => t.id === userId);\n }\n\n if (file.annotations?.assignment?.classId) {\n hasAccess =\n hasAccess ||\n file.annotations.studentId === userId ||\n file.annotations.assignment.class.teachers.some((t) => t.id === userId);\n }\n\n if (file.userId === userId) {\n hasAccess = true;\n }\n\n if (file.conversationId) {\n const membership = await findConversationMembership(file.conversationId, userId);\n hasAccess = hasAccess || Boolean(membership);\n }\n\n if (file.folder?.class) {\n const isTeacher = file.folder.class.teachers.some((t) => t.id === userId);\n const isStudent = file.folder.class.students.some((s) => s.id === userId);\n hasAccess = hasAccess || isTeacher || isStudent;\n }\n\n if (!hasAccess) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You do not have access to this file\",\n });\n }\n\n try {\n const signedUrl = await getSignedUrl(file.path);\n return { url: signedUrl };\n } catch (error) {\n logger.error(\"Error generating signed URL:\", error as Record<string, unknown>);\n throw new TRPCError({\n code: \"INTERNAL_SERVER_ERROR\",\n message: \"Failed to generate download URL\",\n });\n }\n}\n\nexport async function moveFile(\n fileId: string,\n targetFolderId: string\n) {\n const file = await findFileWithFolder(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File not found\",\n });\n }\n\n const targetFolder = await findFolderById(targetFolderId);\n if (!targetFolder) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Target folder not found\",\n });\n }\n\n return updateFileFolder(fileId, targetFolderId);\n}\n\nexport async function renameFile(\n fileId: string,\n newName: string\n) {\n const file = await findFileWithFolder(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File not found\",\n });\n }\n\n if (!newName.trim()) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"File name cannot be empty\",\n });\n }\n\n return updateFileName(fileId, newName.trim());\n}\n\nexport async function deleteFileRecord(fileId: string, classId: string) {\n const file = await findFileWithFolderAndThumbnail(fileId);\n if (!file) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"File not found\",\n });\n }\n\n if (file.folder?.classId !== classId) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"File does not belong to this class\",\n });\n }\n\n try {\n if (file.uploadStatus === \"COMPLETED\") {\n await deleteFile(file.path);\n if (file.thumbnail) {\n await deleteFile(file.thumbnail.path);\n }\n }\n } catch (error) {\n logger.warn(`Failed to delete file ${file.path}:`, error as Record<string, unknown>);\n }\n\n await deleteFileById(fileId);\n return { success: true };\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,8BAA8B,EAC9B,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,gBAAgB,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IAAI,CAAC,IAAI,GAAG,EAAE,KAAgC,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC","debug_id":"c9a35639-e642-5ed5-b260-9bacbf8cb7e9"}
|
|
@@ -7,133 +7,134 @@ export declare function createFolderRecord(userId: string, input: {
|
|
|
7
7
|
}): Promise<{
|
|
8
8
|
files: {
|
|
9
9
|
type: string;
|
|
10
|
+
name: string;
|
|
11
|
+
id: string;
|
|
12
|
+
size: number | null;
|
|
13
|
+
uploadedAt: Date | null;
|
|
10
14
|
user: {
|
|
11
15
|
id: string;
|
|
12
16
|
username: string;
|
|
13
17
|
} | null;
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
size: number | null;
|
|
17
|
-
uploadedAt: Date | null;
|
|
18
18
|
}[];
|
|
19
19
|
childFolders: {
|
|
20
|
+
name: string;
|
|
20
21
|
id: string;
|
|
21
22
|
_count: {
|
|
22
23
|
files: number;
|
|
23
24
|
childFolders: number;
|
|
24
25
|
};
|
|
25
|
-
name: string;
|
|
26
26
|
color: string | null;
|
|
27
27
|
}[];
|
|
28
28
|
} & {
|
|
29
|
-
id: string;
|
|
30
|
-
classId: string | null;
|
|
31
29
|
name: string;
|
|
30
|
+
id: string;
|
|
32
31
|
color: string | null;
|
|
32
|
+
classId: string | null;
|
|
33
33
|
parentFolderId: string | null;
|
|
34
34
|
}>;
|
|
35
35
|
/** Get folder with its contents (subfolders and files). */
|
|
36
36
|
export declare function getFolder(folderId: string): Promise<{
|
|
37
37
|
files: {
|
|
38
38
|
type: string;
|
|
39
|
+
name: string;
|
|
40
|
+
id: string;
|
|
41
|
+
size: number | null;
|
|
42
|
+
uploadedAt: Date | null;
|
|
39
43
|
user: {
|
|
40
44
|
id: string;
|
|
41
45
|
username: string;
|
|
42
46
|
} | null;
|
|
43
|
-
id: string;
|
|
44
|
-
name: string;
|
|
45
|
-
size: number | null;
|
|
46
|
-
uploadedAt: Date | null;
|
|
47
47
|
}[];
|
|
48
48
|
childFolders: {
|
|
49
|
+
name: string;
|
|
49
50
|
id: string;
|
|
50
51
|
_count: {
|
|
51
52
|
files: number;
|
|
52
53
|
childFolders: number;
|
|
53
54
|
};
|
|
54
|
-
name: string;
|
|
55
55
|
color: string | null;
|
|
56
56
|
}[];
|
|
57
57
|
parentFolder: {
|
|
58
|
-
id: string;
|
|
59
58
|
name: string;
|
|
59
|
+
id: string;
|
|
60
60
|
} | null;
|
|
61
61
|
} & {
|
|
62
|
-
id: string;
|
|
63
|
-
classId: string | null;
|
|
64
62
|
name: string;
|
|
63
|
+
id: string;
|
|
65
64
|
color: string | null;
|
|
65
|
+
classId: string | null;
|
|
66
66
|
parentFolderId: string | null;
|
|
67
67
|
}>;
|
|
68
68
|
export declare function getChildFolders(classId: string): Promise<({
|
|
69
69
|
files: {
|
|
70
70
|
type: string;
|
|
71
|
+
name: string;
|
|
72
|
+
id: string;
|
|
73
|
+
size: number | null;
|
|
74
|
+
uploadedAt: Date | null;
|
|
71
75
|
user: {
|
|
72
76
|
id: string;
|
|
73
77
|
username: string;
|
|
74
78
|
} | null;
|
|
75
|
-
id: string;
|
|
76
|
-
name: string;
|
|
77
|
-
size: number | null;
|
|
78
|
-
uploadedAt: Date | null;
|
|
79
79
|
}[];
|
|
80
80
|
childFolders: {
|
|
81
|
+
name: string;
|
|
81
82
|
id: string;
|
|
82
83
|
_count: {
|
|
83
84
|
files: number;
|
|
84
85
|
childFolders: number;
|
|
85
86
|
};
|
|
86
|
-
name: string;
|
|
87
87
|
color: string | null;
|
|
88
88
|
}[];
|
|
89
89
|
} & {
|
|
90
|
-
id: string;
|
|
91
|
-
classId: string | null;
|
|
92
90
|
name: string;
|
|
91
|
+
id: string;
|
|
93
92
|
color: string | null;
|
|
93
|
+
classId: string | null;
|
|
94
94
|
parentFolderId: string | null;
|
|
95
95
|
})[]>;
|
|
96
96
|
export declare function getFolderChildren(folderId: string, classId: string): Promise<({
|
|
97
97
|
files: {
|
|
98
98
|
type: string;
|
|
99
|
+
name: string;
|
|
100
|
+
id: string;
|
|
101
|
+
size: number | null;
|
|
102
|
+
uploadedAt: Date | null;
|
|
99
103
|
user: {
|
|
100
104
|
id: string;
|
|
101
105
|
username: string;
|
|
102
106
|
} | null;
|
|
103
|
-
id: string;
|
|
104
|
-
name: string;
|
|
105
|
-
size: number | null;
|
|
106
|
-
uploadedAt: Date | null;
|
|
107
107
|
}[];
|
|
108
108
|
childFolders: {
|
|
109
|
+
name: string;
|
|
109
110
|
id: string;
|
|
110
111
|
_count: {
|
|
111
112
|
files: number;
|
|
112
113
|
childFolders: number;
|
|
113
114
|
};
|
|
114
|
-
name: string;
|
|
115
115
|
color: string | null;
|
|
116
116
|
}[];
|
|
117
117
|
} & {
|
|
118
|
-
id: string;
|
|
119
|
-
classId: string | null;
|
|
120
118
|
name: string;
|
|
119
|
+
id: string;
|
|
121
120
|
color: string | null;
|
|
121
|
+
classId: string | null;
|
|
122
122
|
parentFolderId: string | null;
|
|
123
123
|
})[]>;
|
|
124
124
|
export declare function getRootFolder(classId: string): Promise<{
|
|
125
125
|
files: {
|
|
126
126
|
type: string;
|
|
127
|
+
name: string;
|
|
128
|
+
id: string;
|
|
129
|
+
size: number | null;
|
|
130
|
+
uploadedAt: Date | null;
|
|
127
131
|
user: {
|
|
128
132
|
id: string;
|
|
129
133
|
username: string;
|
|
130
134
|
} | null;
|
|
131
|
-
id: string;
|
|
132
|
-
name: string;
|
|
133
|
-
size: number | null;
|
|
134
|
-
uploadedAt: Date | null;
|
|
135
135
|
}[];
|
|
136
136
|
childFolders: {
|
|
137
|
+
name: string;
|
|
137
138
|
id: string;
|
|
138
139
|
files: {
|
|
139
140
|
id: string;
|
|
@@ -142,17 +143,16 @@ export declare function getRootFolder(classId: string): Promise<{
|
|
|
142
143
|
files: number;
|
|
143
144
|
childFolders: number;
|
|
144
145
|
};
|
|
145
|
-
name: string;
|
|
146
146
|
color: string | null;
|
|
147
147
|
childFolders: {
|
|
148
148
|
id: string;
|
|
149
149
|
}[];
|
|
150
150
|
}[];
|
|
151
151
|
} & {
|
|
152
|
-
id: string;
|
|
153
|
-
classId: string | null;
|
|
154
152
|
name: string;
|
|
153
|
+
id: string;
|
|
155
154
|
color: string | null;
|
|
155
|
+
classId: string | null;
|
|
156
156
|
parentFolderId: string | null;
|
|
157
157
|
}>;
|
|
158
158
|
export declare function uploadFilesToFolder(userId: string, classId: string, folderId: string, files: {
|
|
@@ -171,64 +171,64 @@ export declare function deleteFolderRecord(userId: string, classId: string, fold
|
|
|
171
171
|
export declare function moveFolder(userId: string, folderId: string, targetParentFolderId: string, classId: string): Promise<{
|
|
172
172
|
files: {
|
|
173
173
|
type: string;
|
|
174
|
+
name: string;
|
|
175
|
+
id: string;
|
|
176
|
+
size: number | null;
|
|
177
|
+
uploadedAt: Date | null;
|
|
174
178
|
user: {
|
|
175
179
|
id: string;
|
|
176
180
|
username: string;
|
|
177
181
|
} | null;
|
|
178
|
-
id: string;
|
|
179
|
-
name: string;
|
|
180
|
-
size: number | null;
|
|
181
|
-
uploadedAt: Date | null;
|
|
182
182
|
}[];
|
|
183
183
|
childFolders: {
|
|
184
|
+
name: string;
|
|
184
185
|
id: string;
|
|
185
186
|
_count: {
|
|
186
187
|
files: number;
|
|
187
188
|
childFolders: number;
|
|
188
189
|
};
|
|
189
|
-
name: string;
|
|
190
190
|
color: string | null;
|
|
191
191
|
}[];
|
|
192
192
|
} & {
|
|
193
|
-
id: string;
|
|
194
|
-
classId: string | null;
|
|
195
193
|
name: string;
|
|
194
|
+
id: string;
|
|
196
195
|
color: string | null;
|
|
196
|
+
classId: string | null;
|
|
197
197
|
parentFolderId: string | null;
|
|
198
198
|
}>;
|
|
199
199
|
export declare function updateFolderRecord(folderId: string, name: string, color: string | undefined, classId: string): Promise<{
|
|
200
200
|
files: {
|
|
201
201
|
type: string;
|
|
202
|
+
name: string;
|
|
203
|
+
id: string;
|
|
204
|
+
size: number | null;
|
|
205
|
+
uploadedAt: Date | null;
|
|
202
206
|
user: {
|
|
203
207
|
id: string;
|
|
204
208
|
username: string;
|
|
205
209
|
} | null;
|
|
206
|
-
id: string;
|
|
207
|
-
name: string;
|
|
208
|
-
size: number | null;
|
|
209
|
-
uploadedAt: Date | null;
|
|
210
210
|
}[];
|
|
211
211
|
childFolders: {
|
|
212
|
+
name: string;
|
|
212
213
|
id: string;
|
|
213
214
|
_count: {
|
|
214
215
|
files: number;
|
|
215
216
|
childFolders: number;
|
|
216
217
|
};
|
|
217
|
-
name: string;
|
|
218
218
|
color: string | null;
|
|
219
219
|
}[];
|
|
220
220
|
} & {
|
|
221
|
-
id: string;
|
|
222
|
-
classId: string | null;
|
|
223
221
|
name: string;
|
|
222
|
+
id: string;
|
|
224
223
|
color: string | null;
|
|
224
|
+
classId: string | null;
|
|
225
225
|
parentFolderId: string | null;
|
|
226
226
|
}>;
|
|
227
227
|
export declare function getFolderParents(folderId: string): Promise<({
|
|
228
|
-
id: string;
|
|
229
|
-
classId: string | null;
|
|
230
228
|
name: string;
|
|
229
|
+
id: string;
|
|
231
230
|
color: string | null;
|
|
231
|
+
classId: string | null;
|
|
232
232
|
parentFolderId: string | null;
|
|
233
233
|
} | null)[]>;
|
|
234
234
|
export declare function getFolderUploadUrls(userId: string, classId: string, folderId: string, files: {
|
|
@@ -5,8 +5,8 @@ export declare function createLabChat(userId: string, input: {
|
|
|
5
5
|
context: string;
|
|
6
6
|
}): Promise<{
|
|
7
7
|
class: {
|
|
8
|
-
id: string;
|
|
9
8
|
name: string;
|
|
9
|
+
id: string;
|
|
10
10
|
subject: string;
|
|
11
11
|
section: string;
|
|
12
12
|
};
|
|
@@ -22,19 +22,19 @@ export declare function createLabChat(userId: string, input: {
|
|
|
22
22
|
};
|
|
23
23
|
} & {
|
|
24
24
|
id: string;
|
|
25
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
26
25
|
userId: string;
|
|
27
26
|
conversationId: string;
|
|
27
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
28
28
|
joinedAt: Date;
|
|
29
29
|
lastViewedAt: Date | null;
|
|
30
30
|
lastViewedMentionAt: Date | null;
|
|
31
31
|
})[];
|
|
32
32
|
} & {
|
|
33
33
|
type: import(".prisma/client").$Enums.ConversationType;
|
|
34
|
+
name: string | null;
|
|
34
35
|
id: string;
|
|
35
36
|
createdAt: Date;
|
|
36
37
|
updatedAt: Date;
|
|
37
|
-
name: string | null;
|
|
38
38
|
displayInChat: boolean;
|
|
39
39
|
};
|
|
40
40
|
createdBy: {
|
|
@@ -47,18 +47,18 @@ export declare function createLabChat(userId: string, input: {
|
|
|
47
47
|
} & {
|
|
48
48
|
context: string;
|
|
49
49
|
id: string;
|
|
50
|
+
conversationId: string;
|
|
50
51
|
createdAt: Date;
|
|
51
|
-
updatedAt: Date;
|
|
52
52
|
classId: string;
|
|
53
53
|
title: string;
|
|
54
|
-
|
|
54
|
+
updatedAt: Date;
|
|
55
55
|
createdById: string;
|
|
56
56
|
}>;
|
|
57
57
|
export declare function getLabChat(userId: string, labChatId: string): Promise<{
|
|
58
58
|
pendingGenerationMessageId: string | null;
|
|
59
59
|
class: {
|
|
60
|
-
id: string;
|
|
61
60
|
name: string;
|
|
61
|
+
id: string;
|
|
62
62
|
subject: string;
|
|
63
63
|
section: string;
|
|
64
64
|
};
|
|
@@ -74,19 +74,19 @@ export declare function getLabChat(userId: string, labChatId: string): Promise<{
|
|
|
74
74
|
};
|
|
75
75
|
} & {
|
|
76
76
|
id: string;
|
|
77
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
78
77
|
userId: string;
|
|
79
78
|
conversationId: string;
|
|
79
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
80
80
|
joinedAt: Date;
|
|
81
81
|
lastViewedAt: Date | null;
|
|
82
82
|
lastViewedMentionAt: Date | null;
|
|
83
83
|
})[];
|
|
84
84
|
} & {
|
|
85
85
|
type: import(".prisma/client").$Enums.ConversationType;
|
|
86
|
+
name: string | null;
|
|
86
87
|
id: string;
|
|
87
88
|
createdAt: Date;
|
|
88
89
|
updatedAt: Date;
|
|
89
|
-
name: string | null;
|
|
90
90
|
displayInChat: boolean;
|
|
91
91
|
};
|
|
92
92
|
createdBy: {
|
|
@@ -99,11 +99,11 @@ export declare function getLabChat(userId: string, labChatId: string): Promise<{
|
|
|
99
99
|
};
|
|
100
100
|
context: string;
|
|
101
101
|
id: string;
|
|
102
|
+
conversationId: string;
|
|
102
103
|
createdAt: Date;
|
|
103
|
-
updatedAt: Date;
|
|
104
104
|
classId: string;
|
|
105
105
|
title: string;
|
|
106
|
-
|
|
106
|
+
updatedAt: Date;
|
|
107
107
|
createdById: string;
|
|
108
108
|
}>;
|
|
109
109
|
export declare function listLabChats(userId: string, classId: string): Promise<{
|
|
@@ -130,11 +130,11 @@ export declare function listLabChats(userId: string, classId: string): Promise<{
|
|
|
130
130
|
};
|
|
131
131
|
} & {
|
|
132
132
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
133
|
+
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
133
134
|
id: string;
|
|
135
|
+
conversationId: string;
|
|
134
136
|
createdAt: Date;
|
|
135
|
-
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
136
137
|
content: string;
|
|
137
|
-
conversationId: string;
|
|
138
138
|
senderId: string;
|
|
139
139
|
};
|
|
140
140
|
messageCount: number;
|
|
@@ -143,6 +143,7 @@ export declare function postToLabChat(userId: string, input: {
|
|
|
143
143
|
labChatId: string;
|
|
144
144
|
content: string;
|
|
145
145
|
mentionedUserIds?: string[];
|
|
146
|
+
fileIds?: string[];
|
|
146
147
|
}): Promise<{
|
|
147
148
|
id: string;
|
|
148
149
|
content: string;
|
|
@@ -157,6 +158,11 @@ export declare function postToLabChat(userId: string, input: {
|
|
|
157
158
|
profilePicture: string | null;
|
|
158
159
|
} | null;
|
|
159
160
|
};
|
|
161
|
+
attachments: {
|
|
162
|
+
type: string;
|
|
163
|
+
name: string;
|
|
164
|
+
id: string;
|
|
165
|
+
}[];
|
|
160
166
|
mentionedUserIds: string[];
|
|
161
167
|
}>;
|
|
162
168
|
export declare function deleteLabChat(userId: string, labChatId: string): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labChat.d.ts","sourceRoot":"/","sources":["services/labChat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"labChat.d.ts","sourceRoot":"/","sources":["services/labChat.ts"],"names":[],"mappings":"AA2BA,sFAAsF;AACtF,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsH3D;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCjE;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqBjE;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;;;;;;;;;;;;;;;;;;;;GAuIF;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;GAiDpE;AAED,8FAA8F;AAC9F,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;GAiFxE"}
|
package/dist/services/labChat.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* trigger AI responses, and broadcast via Pusher.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
6
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a2cfffda-ee2d-53e3-a8f9-ea08a785e468")}catch(e){}}();
|
|
7
7
|
import { TRPCError } from "@trpc/server";
|
|
8
8
|
import { GenerationStatus } from "@prisma/client";
|
|
9
9
|
import { prisma } from "../lib/prisma.js";
|
|
@@ -12,6 +12,7 @@ import { findClassWithTeachersForLab, findLabChatByMember, findLabChatByTeacher,
|
|
|
12
12
|
import { generateAndSendLabIntroduction, generateAndSendLabResponse } from "../pipelines/aiLabChat.js";
|
|
13
13
|
import { isAIUser } from "../utils/aiUser.js";
|
|
14
14
|
import { logger } from "../utils/logger.js";
|
|
15
|
+
import { claimMessageAttachments, ensureMessageHasContentOrAttachments, } from "./message.js";
|
|
15
16
|
/** Create a lab chat with conversation and teacher members. Broadcasts via Pusher. */
|
|
16
17
|
export async function createLabChat(userId, input) {
|
|
17
18
|
const { classId, title, context } = input;
|
|
@@ -175,7 +176,7 @@ export async function listLabChats(userId, classId) {
|
|
|
175
176
|
}));
|
|
176
177
|
}
|
|
177
178
|
export async function postToLabChat(userId, input) {
|
|
178
|
-
const { labChatId, content, mentionedUserIds = [] } = input;
|
|
179
|
+
const { labChatId, content, mentionedUserIds = [], fileIds = [] } = input;
|
|
179
180
|
const labChat = await findLabChatForPost(labChatId, userId);
|
|
180
181
|
if (!labChat) {
|
|
181
182
|
throw new TRPCError({
|
|
@@ -192,14 +193,32 @@ export async function postToLabChat(userId, input) {
|
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
195
|
}
|
|
196
|
+
ensureMessageHasContentOrAttachments(content, fileIds);
|
|
197
|
+
const normalizedContent = content.trim();
|
|
195
198
|
const result = await prisma.$transaction(async (tx) => {
|
|
196
199
|
const message = await tx.message.create({
|
|
197
200
|
data: {
|
|
198
|
-
content,
|
|
201
|
+
content: normalizedContent,
|
|
199
202
|
senderId: userId,
|
|
200
203
|
conversationId: labChat.conversationId,
|
|
201
204
|
...(isAIUser(userId) ? {} : { status: GenerationStatus.PENDING }),
|
|
202
205
|
},
|
|
206
|
+
});
|
|
207
|
+
await claimMessageAttachments(tx, userId, labChat.conversationId, message.id, fileIds);
|
|
208
|
+
if (mentionedUserIds.length > 0) {
|
|
209
|
+
await tx.mention.createMany({
|
|
210
|
+
data: mentionedUserIds.map((mentionedUserId) => ({
|
|
211
|
+
messageId: message.id,
|
|
212
|
+
userId: mentionedUserId,
|
|
213
|
+
})),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
await tx.labChat.update({
|
|
217
|
+
where: { id: labChatId },
|
|
218
|
+
data: { updatedAt: new Date() },
|
|
219
|
+
});
|
|
220
|
+
return tx.message.findUniqueOrThrow({
|
|
221
|
+
where: { id: message.id },
|
|
203
222
|
include: {
|
|
204
223
|
sender: {
|
|
205
224
|
select: {
|
|
@@ -213,21 +232,11 @@ export async function postToLabChat(userId, input) {
|
|
|
213
232
|
},
|
|
214
233
|
},
|
|
215
234
|
},
|
|
235
|
+
attachments: {
|
|
236
|
+
select: { id: true, name: true, type: true },
|
|
237
|
+
},
|
|
216
238
|
},
|
|
217
239
|
});
|
|
218
|
-
if (mentionedUserIds.length > 0) {
|
|
219
|
-
await tx.mention.createMany({
|
|
220
|
-
data: mentionedUserIds.map((mentionedUserId) => ({
|
|
221
|
-
messageId: message.id,
|
|
222
|
-
userId: mentionedUserId,
|
|
223
|
-
})),
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
await tx.labChat.update({
|
|
227
|
-
where: { id: labChatId },
|
|
228
|
-
data: { updatedAt: new Date() },
|
|
229
|
-
});
|
|
230
|
-
return message;
|
|
231
240
|
});
|
|
232
241
|
try {
|
|
233
242
|
await pusher.trigger(chatChannel(labChat.conversationId), "new-message", {
|
|
@@ -237,7 +246,9 @@ export async function postToLabChat(userId, input) {
|
|
|
237
246
|
conversationId: result.conversationId,
|
|
238
247
|
createdAt: result.createdAt,
|
|
239
248
|
sender: result.sender,
|
|
249
|
+
attachments: result.attachments ?? [],
|
|
240
250
|
mentionedUserIds,
|
|
251
|
+
meta: {},
|
|
241
252
|
});
|
|
242
253
|
}
|
|
243
254
|
catch (error) {
|
|
@@ -254,7 +265,7 @@ export async function postToLabChat(userId, input) {
|
|
|
254
265
|
catch (error) {
|
|
255
266
|
console.error("Failed to broadcast lab response pending:", error);
|
|
256
267
|
}
|
|
257
|
-
generateAndSendLabResponse(labChatId,
|
|
268
|
+
generateAndSendLabResponse(labChatId, normalizedContent, {
|
|
258
269
|
classId: labChat.classId,
|
|
259
270
|
messageId: result.id,
|
|
260
271
|
}).catch((error) => logger.error("Failed to generate lab response", {
|
|
@@ -271,6 +282,7 @@ export async function postToLabChat(userId, input) {
|
|
|
271
282
|
conversationId: result.conversationId,
|
|
272
283
|
createdAt: result.createdAt,
|
|
273
284
|
sender: result.sender,
|
|
285
|
+
attachments: result.attachments ?? [],
|
|
274
286
|
mentionedUserIds,
|
|
275
287
|
};
|
|
276
288
|
}
|
|
@@ -394,4 +406,4 @@ export async function rerunLastResponse(userId, labChatId) {
|
|
|
394
406
|
return { success: true };
|
|
395
407
|
}
|
|
396
408
|
//# sourceMappingURL=labChat.js.map
|
|
397
|
-
//# debugId=
|
|
409
|
+
//# debugId=a2cfffda-ee2d-53e3-a8f9-ea08a785e468
|