@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.
Files changed (248) hide show
  1. package/.coderabbit.yaml +4 -1
  2. package/.env.example +6 -0
  3. package/.env.test.example +2 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +101 -76
  6. package/dist/index.js.map +1 -1
  7. package/dist/lib/config/cors.d.ts +16 -0
  8. package/dist/lib/config/cors.d.ts.map +1 -0
  9. package/dist/lib/config/cors.js +75 -0
  10. package/dist/lib/config/cors.js.map +1 -0
  11. package/dist/lib/config/env.d.ts +14 -0
  12. package/dist/lib/config/env.d.ts.map +1 -1
  13. package/dist/lib/config/env.js +9 -2
  14. package/dist/lib/config/env.js.map +1 -1
  15. package/dist/lib/fileUpload.d.ts +10 -2
  16. package/dist/lib/fileUpload.d.ts.map +1 -1
  17. package/dist/lib/fileUpload.js +38 -6
  18. package/dist/lib/fileUpload.js.map +1 -1
  19. package/dist/lib/prisma.d.ts +14 -2
  20. package/dist/lib/prisma.d.ts.map +1 -1
  21. package/dist/lib/prisma.js +27 -8
  22. package/dist/lib/prisma.js.map +1 -1
  23. package/dist/middleware/auth.d.ts.map +1 -1
  24. package/dist/middleware/auth.js +18 -5
  25. package/dist/middleware/auth.js.map +1 -1
  26. package/dist/middleware/security.d.ts.map +1 -1
  27. package/dist/middleware/security.js +3 -3
  28. package/dist/middleware/security.js.map +1 -1
  29. package/dist/models/agenda.d.ts +16 -16
  30. package/dist/models/announcement.d.ts +59 -23
  31. package/dist/models/announcement.d.ts.map +1 -1
  32. package/dist/models/assignment.d.ts +363 -276
  33. package/dist/models/assignment.d.ts.map +1 -1
  34. package/dist/models/attendance.d.ts +63 -21
  35. package/dist/models/attendance.d.ts.map +1 -1
  36. package/dist/models/auth.d.ts +115 -26
  37. package/dist/models/auth.d.ts.map +1 -1
  38. package/dist/models/auth.js +53 -30
  39. package/dist/models/auth.js.map +1 -1
  40. package/dist/models/class.d.ts +115 -65
  41. package/dist/models/class.d.ts.map +1 -1
  42. package/dist/models/class.js +16 -4
  43. package/dist/models/class.js.map +1 -1
  44. package/dist/models/comment.d.ts +52 -16
  45. package/dist/models/comment.d.ts.map +1 -1
  46. package/dist/models/conversation.d.ts +46 -16
  47. package/dist/models/conversation.d.ts.map +1 -1
  48. package/dist/models/event.d.ts +107 -53
  49. package/dist/models/event.d.ts.map +1 -1
  50. package/dist/models/file.d.ts +213 -165
  51. package/dist/models/file.d.ts.map +1 -1
  52. package/dist/models/folder.d.ts +161 -77
  53. package/dist/models/folder.d.ts.map +1 -1
  54. package/dist/models/labChat.d.ts +73 -31
  55. package/dist/models/labChat.d.ts.map +1 -1
  56. package/dist/models/marketing.d.ts +25 -7
  57. package/dist/models/marketing.d.ts.map +1 -1
  58. package/dist/models/message.d.ts +31 -13
  59. package/dist/models/message.d.ts.map +1 -1
  60. package/dist/models/newtonChat.d.ts +34 -10
  61. package/dist/models/newtonChat.d.ts.map +1 -1
  62. package/dist/models/notification.d.ts +29 -10
  63. package/dist/models/notification.d.ts.map +1 -1
  64. package/dist/models/notification.js +13 -9
  65. package/dist/models/notification.js.map +1 -1
  66. package/dist/models/section.d.ts +71 -23
  67. package/dist/models/section.d.ts.map +1 -1
  68. package/dist/models/user.d.ts +27 -9
  69. package/dist/models/user.d.ts.map +1 -1
  70. package/dist/models/worksheet.d.ts +606 -106
  71. package/dist/models/worksheet.d.ts.map +1 -1
  72. package/dist/models/worksheet.js +168 -2
  73. package/dist/models/worksheet.js.map +1 -1
  74. package/dist/pipelines/aiLabChat.d.ts +22 -2
  75. package/dist/pipelines/aiLabChat.d.ts.map +1 -1
  76. package/dist/pipelines/aiLabChat.js +133 -95
  77. package/dist/pipelines/aiLabChat.js.map +1 -1
  78. package/dist/pipelines/aiLabChatContract.d.ts +25 -25
  79. package/dist/pipelines/aiNewtonChat.d.ts.map +1 -1
  80. package/dist/pipelines/aiNewtonChat.js +25 -14
  81. package/dist/pipelines/aiNewtonChat.js.map +1 -1
  82. package/dist/pipelines/gradeWorksheet.d.ts +8 -8
  83. package/dist/pipelines/gradeWorksheet.d.ts.map +1 -1
  84. package/dist/pipelines/gradeWorksheet.js +12 -5
  85. package/dist/pipelines/gradeWorksheet.js.map +1 -1
  86. package/dist/pipelines/labChatPrompt.d.ts +27 -0
  87. package/dist/pipelines/labChatPrompt.d.ts.map +1 -1
  88. package/dist/pipelines/labChatPrompt.js +143 -69
  89. package/dist/pipelines/labChatPrompt.js.map +1 -1
  90. package/dist/routers/_app.d.ts +1579 -1257
  91. package/dist/routers/_app.d.ts.map +1 -1
  92. package/dist/routers/agenda.d.ts +16 -16
  93. package/dist/routers/announcement.d.ts +19 -19
  94. package/dist/routers/assignment.d.ts +307 -291
  95. package/dist/routers/assignment.d.ts.map +1 -1
  96. package/dist/routers/assignment.js +3 -2
  97. package/dist/routers/assignment.js.map +1 -1
  98. package/dist/routers/attendance.d.ts +7 -7
  99. package/dist/routers/auth.d.ts +1 -1
  100. package/dist/routers/class.d.ts +79 -72
  101. package/dist/routers/class.d.ts.map +1 -1
  102. package/dist/routers/class.js +3 -3
  103. package/dist/routers/class.js.map +1 -1
  104. package/dist/routers/comment.d.ts +6 -6
  105. package/dist/routers/conversation.d.ts +11 -11
  106. package/dist/routers/event.d.ts +35 -35
  107. package/dist/routers/file.d.ts +12 -12
  108. package/dist/routers/folder.d.ts +54 -54
  109. package/dist/routers/labChat.d.ts +18 -12
  110. package/dist/routers/labChat.d.ts.map +1 -1
  111. package/dist/routers/labChat.js +5 -3
  112. package/dist/routers/labChat.js.map +1 -1
  113. package/dist/routers/marketing.d.ts +2 -2
  114. package/dist/routers/message.d.ts +33 -2
  115. package/dist/routers/message.d.ts.map +1 -1
  116. package/dist/routers/message.js +27 -4
  117. package/dist/routers/message.js.map +1 -1
  118. package/dist/routers/newtonChat.d.ts +7 -1
  119. package/dist/routers/newtonChat.d.ts.map +1 -1
  120. package/dist/routers/newtonChat.js +5 -4
  121. package/dist/routers/newtonChat.js.map +1 -1
  122. package/dist/routers/notifications.d.ts +13 -6
  123. package/dist/routers/notifications.d.ts.map +1 -1
  124. package/dist/routers/notifications.js +4 -4
  125. package/dist/routers/notifications.js.map +1 -1
  126. package/dist/routers/section.d.ts +7 -7
  127. package/dist/routers/studentProgress.d.ts +86 -0
  128. package/dist/routers/studentProgress.d.ts.map +1 -1
  129. package/dist/routers/studentProgress.js +14 -4
  130. package/dist/routers/studentProgress.js.map +1 -1
  131. package/dist/routers/user.d.ts +1 -1
  132. package/dist/routers/worksheet.d.ts +64 -62
  133. package/dist/routers/worksheet.d.ts.map +1 -1
  134. package/dist/routers/worksheet.js +18 -16
  135. package/dist/routers/worksheet.js.map +1 -1
  136. package/dist/seedDatabase.d.ts +1 -1
  137. package/dist/services/agenda.d.ts +16 -16
  138. package/dist/services/announcement.d.ts +8 -8
  139. package/dist/services/assignment.d.ts +299 -283
  140. package/dist/services/assignment.d.ts.map +1 -1
  141. package/dist/services/assignment.js +24 -5
  142. package/dist/services/assignment.js.map +1 -1
  143. package/dist/services/attendance.d.ts +7 -7
  144. package/dist/services/auth.d.ts +2 -2
  145. package/dist/services/auth.d.ts.map +1 -1
  146. package/dist/services/auth.js +19 -12
  147. package/dist/services/auth.js.map +1 -1
  148. package/dist/services/class.d.ts +74 -68
  149. package/dist/services/class.d.ts.map +1 -1
  150. package/dist/services/class.js +6 -3
  151. package/dist/services/class.js.map +1 -1
  152. package/dist/services/comment.d.ts +6 -6
  153. package/dist/services/conversation.d.ts +11 -11
  154. package/dist/services/event.d.ts +31 -31
  155. package/dist/services/file.d.ts +12 -12
  156. package/dist/services/file.d.ts.map +1 -1
  157. package/dist/services/file.js +7 -2
  158. package/dist/services/file.js.map +1 -1
  159. package/dist/services/folder.d.ts +52 -52
  160. package/dist/services/labChat.d.ts +18 -12
  161. package/dist/services/labChat.d.ts.map +1 -1
  162. package/dist/services/labChat.js +30 -18
  163. package/dist/services/labChat.js.map +1 -1
  164. package/dist/services/marketing.d.ts +2 -2
  165. package/dist/services/message.d.ts +30 -0
  166. package/dist/services/message.d.ts.map +1 -1
  167. package/dist/services/message.js +97 -21
  168. package/dist/services/message.js.map +1 -1
  169. package/dist/services/newtonChat.d.ts +6 -1
  170. package/dist/services/newtonChat.d.ts.map +1 -1
  171. package/dist/services/newtonChat.js +36 -18
  172. package/dist/services/newtonChat.js.map +1 -1
  173. package/dist/services/notification.d.ts +16 -9
  174. package/dist/services/notification.d.ts.map +1 -1
  175. package/dist/services/notification.js +24 -9
  176. package/dist/services/notification.js.map +1 -1
  177. package/dist/services/section.d.ts +6 -6
  178. package/dist/services/studentProgress.d.ts +75 -0
  179. package/dist/services/studentProgress.d.ts.map +1 -1
  180. package/dist/services/studentProgress.js +300 -107
  181. package/dist/services/studentProgress.js.map +1 -1
  182. package/dist/services/worksheet.d.ts +64 -64
  183. package/dist/services/worksheet.d.ts.map +1 -1
  184. package/dist/services/worksheet.js +138 -54
  185. package/dist/services/worksheet.js.map +1 -1
  186. package/dist/trpc.d.ts.map +1 -1
  187. package/dist/trpc.js +11 -17
  188. package/dist/trpc.js.map +1 -1
  189. package/dist/utils/inference.d.ts +9 -12
  190. package/dist/utils/inference.d.ts.map +1 -1
  191. package/dist/utils/inference.js +135 -95
  192. package/dist/utils/inference.js.map +1 -1
  193. package/package.json +1 -1
  194. package/prisma/migrations/20260410124000_add_submission_recommendation_state/migration.sql +14 -0
  195. package/prisma/migrations/20260415103500_add_session_type/migration.sql +33 -0
  196. package/prisma/migrations/20260415133000_add_ai_usage_logs/migration.sql +19 -0
  197. package/prisma/schema.prisma +41 -1
  198. package/scripts/test-pre-push.ts +6 -2
  199. package/src/index.ts +119 -79
  200. package/src/lib/config/cors.ts +96 -0
  201. package/src/lib/config/env.ts +12 -1
  202. package/src/lib/fileUpload.ts +55 -5
  203. package/src/lib/prisma.ts +25 -6
  204. package/src/middleware/auth.ts +19 -4
  205. package/src/middleware/security.ts +1 -1
  206. package/src/models/auth.ts +59 -29
  207. package/src/models/class.ts +15 -4
  208. package/src/models/notification.ts +13 -7
  209. package/src/models/worksheet.ts +202 -0
  210. package/src/pipelines/aiLabChat.ts +183 -104
  211. package/src/pipelines/aiNewtonChat.ts +24 -14
  212. package/src/pipelines/gradeWorksheet.ts +10 -2
  213. package/src/pipelines/labChatPrompt.ts +196 -68
  214. package/src/routers/assignment.ts +1 -0
  215. package/src/routers/class.ts +2 -2
  216. package/src/routers/labChat.ts +3 -1
  217. package/src/routers/message.ts +38 -1
  218. package/src/routers/newtonChat.ts +4 -2
  219. package/src/routers/notifications.ts +2 -2
  220. package/src/routers/studentProgress.ts +25 -1
  221. package/src/routers/worksheet.ts +31 -19
  222. package/src/services/assignment.ts +30 -2
  223. package/src/services/auth.ts +26 -12
  224. package/src/services/class.ts +4 -1
  225. package/src/services/file.ts +6 -0
  226. package/src/services/labChat.ts +42 -18
  227. package/src/services/message.ts +163 -18
  228. package/src/services/newtonChat.ts +49 -18
  229. package/src/services/notification.ts +27 -8
  230. package/src/services/studentProgress.ts +425 -121
  231. package/src/services/worksheet.ts +191 -51
  232. package/src/trpc.ts +12 -18
  233. package/src/utils/inference.ts +205 -112
  234. package/tests/globalSetup.ts +13 -4
  235. package/tests/lib/cors.test.ts +103 -0
  236. package/tests/pipelines/aiLabChat.test.ts +64 -84
  237. package/tests/routers/auth.test.ts +120 -17
  238. package/tests/routers/class.test.ts +7 -1
  239. package/tests/routers/message.test.ts +236 -9
  240. package/tests/routers/newtonChat.test.ts +81 -0
  241. package/tests/routers/notification.test.ts +12 -0
  242. package/tests/routers/studentProgress.test.ts +2 -31
  243. package/tests/routers/worksheet.test.ts +194 -0
  244. package/tests/setup.ts +22 -5
  245. package/tests/utils/aiLabChatPrompt.test.ts +114 -6
  246. package/tests/utils/inference.test.ts +218 -0
  247. package/tests/utils/studentProgress.test.ts +361 -0
  248. package/vitest.unit.config.ts +1 -0
@@ -3,12 +3,13 @@
3
3
  * tutor session, post messages, trigger AI responses. Broadcasts 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]="9dd67dc8-f3fd-5e09-bcb7-92d22feea12e")}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]="4008c70c-b11c-5552-91e3-8c82551e82a2")}catch(e){}}();
7
7
  import { TRPCError } from "@trpc/server";
8
8
  import { logger } from "../utils/logger.js";
9
9
  import { chatChannel, pusher } from "../lib/pusher.js";
10
10
  import { isAIUser } from "../utils/aiUser.js";
11
11
  import { generateAndSendNewtonIntroduction, generateAndSendNewtonResponse } from "../pipelines/aiNewtonChat.js";
12
+ import { claimMessageAttachments, ensureMessageHasContentOrAttachments, } from "./message.js";
12
13
  import { findClassWithStudent, findSubmissionByAssignmentAndStudent, findNewtonChatByIdAndMember, findConversationMembersByUserIds, } from "../models/newtonChat.js";
13
14
  import { prisma } from "../lib/prisma.js";
14
15
  /** Get or create Newton tutor conversation for a submission. Student-only. */
@@ -88,7 +89,7 @@ export async function getTutorConversation(userId, assignmentId, classId) {
88
89
  newtonChatId: result.id,
89
90
  };
90
91
  }
91
- export async function postToNewtonChat(userId, newtonChatId, content, mentionedUserIds = []) {
92
+ export async function postToNewtonChat(userId, newtonChatId, content, mentionedUserIds = [], fileIds = []) {
92
93
  const newtonChat = await findNewtonChatByIdAndMember(newtonChatId, userId);
93
94
  if (!newtonChat) {
94
95
  throw new TRPCError({
@@ -105,13 +106,37 @@ export async function postToNewtonChat(userId, newtonChatId, content, mentionedU
105
106
  });
106
107
  }
107
108
  }
109
+ ensureMessageHasContentOrAttachments(content, fileIds);
110
+ const normalizedContent = content.trim();
111
+ if (!normalizedContent) {
112
+ throw new TRPCError({
113
+ code: "BAD_REQUEST",
114
+ message: "Newton chat messages must include text content",
115
+ });
116
+ }
108
117
  const result = await prisma.$transaction(async (tx) => {
109
118
  const message = await tx.message.create({
110
119
  data: {
111
- content,
120
+ content: normalizedContent,
112
121
  senderId: userId,
113
122
  conversationId: newtonChat.conversationId,
114
123
  },
124
+ });
125
+ await claimMessageAttachments(tx, userId, newtonChat.conversationId, message.id, fileIds);
126
+ if (mentionedUserIds.length > 0) {
127
+ await tx.mention.createMany({
128
+ data: mentionedUserIds.map((mentionedUserId) => ({
129
+ messageId: message.id,
130
+ userId: mentionedUserId,
131
+ })),
132
+ });
133
+ }
134
+ await tx.newtonChat.update({
135
+ where: { id: newtonChatId },
136
+ data: { updatedAt: new Date() },
137
+ });
138
+ return tx.message.findUniqueOrThrow({
139
+ where: { id: message.id },
115
140
  include: {
116
141
  sender: {
117
142
  select: {
@@ -125,21 +150,11 @@ export async function postToNewtonChat(userId, newtonChatId, content, mentionedU
125
150
  },
126
151
  },
127
152
  },
153
+ attachments: {
154
+ select: { id: true, name: true, type: true },
155
+ },
128
156
  },
129
157
  });
130
- if (mentionedUserIds.length > 0) {
131
- await tx.mention.createMany({
132
- data: mentionedUserIds.map((mentionedUserId) => ({
133
- messageId: message.id,
134
- userId: mentionedUserId,
135
- })),
136
- });
137
- }
138
- await tx.newtonChat.update({
139
- where: { id: newtonChatId },
140
- data: { updatedAt: new Date() },
141
- });
142
- return message;
143
158
  });
144
159
  try {
145
160
  await pusher.trigger(chatChannel(newtonChat.conversationId), "new-message", {
@@ -149,14 +164,16 @@ export async function postToNewtonChat(userId, newtonChatId, content, mentionedU
149
164
  conversationId: result.conversationId,
150
165
  createdAt: result.createdAt,
151
166
  sender: result.sender,
167
+ attachments: result.attachments ?? [],
152
168
  mentionedUserIds,
169
+ meta: {},
153
170
  });
154
171
  }
155
172
  catch (error) {
156
173
  console.error("Failed to broadcast newton chat message:", error);
157
174
  }
158
175
  if (!isAIUser(userId)) {
159
- generateAndSendNewtonResponse(newtonChatId, content, newtonChat.conversationId, newtonChat.submission).catch((error) => {
176
+ generateAndSendNewtonResponse(newtonChatId, normalizedContent, newtonChat.conversationId, newtonChat.submission).catch((error) => {
160
177
  logger.error("Failed to generate AI response:", { error });
161
178
  });
162
179
  }
@@ -167,8 +184,9 @@ export async function postToNewtonChat(userId, newtonChatId, content, mentionedU
167
184
  conversationId: result.conversationId,
168
185
  createdAt: result.createdAt,
169
186
  sender: result.sender,
187
+ attachments: result.attachments ?? [],
170
188
  mentionedUserIds,
171
189
  };
172
190
  }
173
191
  //# sourceMappingURL=newtonChat.js.map
174
- //# debugId=9dd67dc8-f3fd-5e09-bcb7-92d22feea12e
192
+ //# debugId=4008c70c-b11c-5552-91e3-8c82551e82a2
@@ -1 +1 @@
1
- {"version":3,"file":"newtonChat.js","sources":["services/newtonChat.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Newton chat service – AI tutor conversations for assignments. Get or create\n * tutor session, post messages, trigger AI responses. Broadcasts via Pusher.\n */\nimport { TRPCError } from \"@trpc/server\";\nimport { logger } from \"../utils/logger.js\";\nimport { chatChannel, pusher } from \"../lib/pusher.js\";\nimport { isAIUser } from \"../utils/aiUser.js\";\nimport { generateAndSendNewtonIntroduction, generateAndSendNewtonResponse } from \"../pipelines/aiNewtonChat.js\";\nimport {\n findClassWithStudent,\n findSubmissionByAssignmentAndStudent,\n findNewtonChatByIdAndMember,\n findConversationMembersByUserIds,\n} from \"../models/newtonChat.js\";\nimport { prisma } from \"../lib/prisma.js\";\n\n/** Get or create Newton tutor conversation for a submission. Student-only. */\nexport async function getTutorConversation(\n userId: string,\n assignmentId: string,\n classId: string\n) {\n const classMembership = await findClassWithStudent(classId, userId);\n if (!classMembership) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Not a student in this class\",\n });\n }\n\n const submission = await findSubmissionByAssignmentAndStudent(\n assignmentId,\n userId\n );\n if (!submission) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Submission not found. Please create a submission first.\",\n });\n }\n\n const result = await prisma.$transaction(async (tx) => {\n const existingNewtonChat = await tx.newtonChat.findFirst({\n where: { submissionId: submission.id },\n include: {\n conversation: {\n include: {\n members: {\n where: { userId },\n },\n },\n },\n },\n orderBy: { createdAt: \"desc\" },\n });\n\n if (existingNewtonChat && existingNewtonChat.conversation.members.length > 0) {\n return existingNewtonChat;\n }\n\n if (existingNewtonChat) {\n await tx.conversationMember.create({\n data: {\n userId,\n conversationId: existingNewtonChat.conversationId,\n role: \"MEMBER\",\n },\n });\n return existingNewtonChat;\n }\n\n const conversation = await tx.conversation.create({\n data: {\n type: \"DM\",\n name: \"Session with Newton Tutor\",\n displayInChat: false,\n },\n });\n\n await tx.conversationMember.create({\n data: {\n userId,\n conversationId: conversation.id,\n role: \"MEMBER\",\n },\n });\n\n const newtonChat = await tx.newtonChat.create({\n data: {\n submissionId: submission.id,\n conversationId: conversation.id,\n title: \"Session with Newton Tutor\",\n },\n });\n\n generateAndSendNewtonIntroduction(\n newtonChat.id,\n newtonChat.conversationId,\n submission.id\n ).catch((error) => {\n logger.error(\"Failed to generate AI introduction:\", {\n error,\n newtonChatId: newtonChat.id,\n });\n });\n\n return newtonChat;\n });\n\n return {\n conversationId: result.conversationId,\n newtonChatId: result.id,\n };\n}\n\nexport async function postToNewtonChat(\n userId: string,\n newtonChatId: string,\n content: string,\n mentionedUserIds: string[] = []\n) {\n const newtonChat = await findNewtonChatByIdAndMember(newtonChatId, userId);\n if (!newtonChat) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Newton chat not found or access denied\",\n });\n }\n\n if (mentionedUserIds.length > 0) {\n const mentionedMemberships = await findConversationMembersByUserIds(\n newtonChat.conversationId,\n mentionedUserIds\n );\n if (mentionedMemberships.length !== mentionedUserIds.length) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Some mentioned users are not members of this conversation\",\n });\n }\n }\n\n const result = await prisma.$transaction(async (tx) => {\n const message = await tx.message.create({\n data: {\n content,\n senderId: userId,\n conversationId: newtonChat.conversationId,\n },\n include: {\n sender: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n });\n\n if (mentionedUserIds.length > 0) {\n await tx.mention.createMany({\n data: mentionedUserIds.map((mentionedUserId) => ({\n messageId: message.id,\n userId: mentionedUserId,\n })),\n });\n }\n\n await tx.newtonChat.update({\n where: { id: newtonChatId },\n data: { updatedAt: new Date() },\n });\n\n return message;\n });\n\n try {\n await pusher.trigger(\n chatChannel(newtonChat.conversationId),\n \"new-message\",\n {\n id: result.id,\n content: result.content,\n senderId: result.senderId,\n conversationId: result.conversationId,\n createdAt: result.createdAt,\n sender: result.sender,\n mentionedUserIds,\n }\n );\n } catch (error) {\n console.error(\"Failed to broadcast newton chat message:\", error);\n }\n\n if (!isAIUser(userId)) {\n generateAndSendNewtonResponse(\n newtonChatId,\n content,\n newtonChat.conversationId,\n newtonChat.submission\n ).catch((error) => {\n logger.error(\"Failed to generate AI response:\", { error });\n });\n }\n\n return {\n id: result.id,\n content: result.content,\n senderId: result.senderId,\n conversationId: result.conversationId,\n createdAt: result.createdAt,\n sender: result.sender,\n mentionedUserIds,\n };\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,iCAAiC,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAChH,OAAO,EACL,oBAAoB,EACpB,oCAAoC,EACpC,2BAA2B,EAC3B,gCAAgC,GACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EA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,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,gBAAgB;KACjB,CAAC;AACJ,CAAC","debug_id":"9dd67dc8-f3fd-5e09-bcb7-92d22feea12e"}
1
+ {"version":3,"file":"newtonChat.js","sources":["services/newtonChat.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Newton chat service – AI tutor conversations for assignments. Get or create\n * tutor session, post messages, trigger AI responses. Broadcasts via Pusher.\n */\nimport { TRPCError } from \"@trpc/server\";\nimport { logger } from \"../utils/logger.js\";\nimport { chatChannel, pusher } from \"../lib/pusher.js\";\nimport { isAIUser } from \"../utils/aiUser.js\";\nimport { generateAndSendNewtonIntroduction, generateAndSendNewtonResponse } from \"../pipelines/aiNewtonChat.js\";\nimport {\n claimMessageAttachments,\n ensureMessageHasContentOrAttachments,\n} from \"./message.js\";\nimport {\n findClassWithStudent,\n findSubmissionByAssignmentAndStudent,\n findNewtonChatByIdAndMember,\n findConversationMembersByUserIds,\n} from \"../models/newtonChat.js\";\nimport { prisma } from \"../lib/prisma.js\";\n\n/** Get or create Newton tutor conversation for a submission. Student-only. */\nexport async function getTutorConversation(\n userId: string,\n assignmentId: string,\n classId: string\n) {\n const classMembership = await findClassWithStudent(classId, userId);\n if (!classMembership) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Not a student in this class\",\n });\n }\n\n const submission = await findSubmissionByAssignmentAndStudent(\n assignmentId,\n userId\n );\n if (!submission) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Submission not found. Please create a submission first.\",\n });\n }\n\n const result = await prisma.$transaction(async (tx) => {\n const existingNewtonChat = await tx.newtonChat.findFirst({\n where: { submissionId: submission.id },\n include: {\n conversation: {\n include: {\n members: {\n where: { userId },\n },\n },\n },\n },\n orderBy: { createdAt: \"desc\" },\n });\n\n if (existingNewtonChat && existingNewtonChat.conversation.members.length > 0) {\n return existingNewtonChat;\n }\n\n if (existingNewtonChat) {\n await tx.conversationMember.create({\n data: {\n userId,\n conversationId: existingNewtonChat.conversationId,\n role: \"MEMBER\",\n },\n });\n return existingNewtonChat;\n }\n\n const conversation = await tx.conversation.create({\n data: {\n type: \"DM\",\n name: \"Session with Newton Tutor\",\n displayInChat: false,\n },\n });\n\n await tx.conversationMember.create({\n data: {\n userId,\n conversationId: conversation.id,\n role: \"MEMBER\",\n },\n });\n\n const newtonChat = await tx.newtonChat.create({\n data: {\n submissionId: submission.id,\n conversationId: conversation.id,\n title: \"Session with Newton Tutor\",\n },\n });\n\n generateAndSendNewtonIntroduction(\n newtonChat.id,\n newtonChat.conversationId,\n submission.id\n ).catch((error) => {\n logger.error(\"Failed to generate AI introduction:\", {\n error,\n newtonChatId: newtonChat.id,\n });\n });\n\n return newtonChat;\n });\n\n return {\n conversationId: result.conversationId,\n newtonChatId: result.id,\n };\n}\n\nexport async function postToNewtonChat(\n userId: string,\n newtonChatId: string,\n content: string,\n mentionedUserIds: string[] = [],\n fileIds: string[] = []\n) {\n const newtonChat = await findNewtonChatByIdAndMember(newtonChatId, userId);\n if (!newtonChat) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Newton chat not found or access denied\",\n });\n }\n\n if (mentionedUserIds.length > 0) {\n const mentionedMemberships = await findConversationMembersByUserIds(\n newtonChat.conversationId,\n mentionedUserIds\n );\n if (mentionedMemberships.length !== mentionedUserIds.length) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Some mentioned users are not members of this conversation\",\n });\n }\n }\n\n ensureMessageHasContentOrAttachments(content, fileIds);\n const normalizedContent = content.trim();\n\n if (!normalizedContent) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Newton chat messages must include text content\",\n });\n }\n\n const result = await prisma.$transaction(async (tx) => {\n const message = await tx.message.create({\n data: {\n content: normalizedContent,\n senderId: userId,\n conversationId: newtonChat.conversationId,\n },\n });\n\n await claimMessageAttachments(\n tx,\n userId,\n newtonChat.conversationId,\n message.id,\n fileIds\n );\n\n if (mentionedUserIds.length > 0) {\n await tx.mention.createMany({\n data: mentionedUserIds.map((mentionedUserId) => ({\n messageId: message.id,\n userId: mentionedUserId,\n })),\n });\n }\n\n await tx.newtonChat.update({\n where: { id: newtonChatId },\n data: { updatedAt: new Date() },\n });\n\n return tx.message.findUniqueOrThrow({\n where: { id: message.id },\n include: {\n sender: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n attachments: {\n select: { id: true, name: true, type: true },\n },\n },\n });\n });\n\n try {\n await pusher.trigger(\n chatChannel(newtonChat.conversationId),\n \"new-message\",\n {\n id: result.id,\n content: result.content,\n senderId: result.senderId,\n conversationId: result.conversationId,\n createdAt: result.createdAt,\n sender: result.sender,\n attachments: result.attachments ?? [],\n mentionedUserIds,\n meta: {},\n }\n );\n } catch (error) {\n console.error(\"Failed to broadcast newton chat message:\", error);\n }\n\n if (!isAIUser(userId)) {\n generateAndSendNewtonResponse(\n newtonChatId,\n normalizedContent,\n newtonChat.conversationId,\n newtonChat.submission\n ).catch((error) => {\n logger.error(\"Failed to generate AI response:\", { error });\n });\n }\n\n return {\n id: result.id,\n content: result.content,\n senderId: result.senderId,\n conversationId: result.conversationId,\n createdAt: result.createdAt,\n sender: result.sender,\n attachments: result.attachments ?? [],\n mentionedUserIds,\n };\n}\n"],"names":[],"mappings":"AAAA;;;GAGG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,iCAAiC,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAChH,OAAO,EACL,uBAAuB,EACvB,oCAAoC,GACrC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oBAAoB,E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QAAQ;YACzB,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;YACrC,gBAAgB;YAChB,IAAI,EAAE,EAAE;SACT,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,6BAA6B,CAC3B,YAAY,EACZ,iBAAiB,EACjB,UAAU,CAAC,cAAc,EACzB,UAAU,CAAC,UAAU,CACtB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChB,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;QACrC,gBAAgB;KACjB,CAAC;AACJ,CAAC","debug_id":"4008c70c-b11c-5552-91e3-8c82551e82a2"}
@@ -11,12 +11,12 @@ export declare function listNotifications(userId: string): Promise<({
11
11
  createdAt: Date;
12
12
  title: string;
13
13
  content: string;
14
- read: boolean;
15
14
  senderId: string | null;
16
15
  receiverId: string;
16
+ read: boolean;
17
17
  })[]>;
18
- /** Get a single notification by ID. */
19
- export declare function getNotification(id: string): Promise<({
18
+ /** Get a single notification by ID for its receiver. */
19
+ export declare function getNotification(userId: string, id: string): Promise<{
20
20
  sender: {
21
21
  username: string;
22
22
  } | null;
@@ -28,10 +28,10 @@ export declare function getNotification(id: string): Promise<({
28
28
  createdAt: Date;
29
29
  title: string;
30
30
  content: string;
31
- read: boolean;
32
31
  senderId: string | null;
33
32
  receiverId: string;
34
- }) | null>;
33
+ read: boolean;
34
+ }>;
35
35
  /** Send a notification to one user. */
36
36
  export declare function sendNotification(input: {
37
37
  receiverId: string;
@@ -42,9 +42,9 @@ export declare function sendNotification(input: {
42
42
  createdAt: Date;
43
43
  title: string;
44
44
  content: string;
45
- read: boolean;
46
45
  senderId: string | null;
47
46
  receiverId: string;
47
+ read: boolean;
48
48
  }>;
49
49
  /** Send the same notification to multiple users. */
50
50
  export declare function sendToMultiple(input: {
@@ -52,14 +52,21 @@ export declare function sendToMultiple(input: {
52
52
  title: string;
53
53
  content: string;
54
54
  }): Promise<import(".prisma/client").Prisma.BatchPayload>;
55
- /** Mark a notification as read. */
56
- export declare function markAsRead(id: string): Promise<{
55
+ /** Mark a notification as read for its receiver. */
56
+ export declare function markAsRead(userId: string, id: string): Promise<{
57
+ sender: {
58
+ username: string;
59
+ } | null;
60
+ receiver: {
61
+ username: string;
62
+ };
63
+ } & {
57
64
  id: string;
58
65
  createdAt: Date;
59
66
  title: string;
60
67
  content: string;
61
- read: boolean;
62
68
  senderId: string | null;
63
69
  receiverId: string;
70
+ read: boolean;
64
71
  }>;
65
72
  //# sourceMappingURL=notification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notification.d.ts","sourceRoot":"/","sources":["services/notification.ts"],"names":[],"mappings":"AAWA,qCAAqC;AACrC,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;MAErD;AAED,uCAAuC;AACvC,wBAAsB,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;WAE/C;AAED,uCAAuC;AACvC,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;;;;;;;;GAEA;AAED,oDAAoD;AACpD,wBAAsB,cAAc,CAAC,KAAK,EAAE;IAC1C,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,yDASA;AAED,mCAAmC;AACnC,wBAAsB,UAAU,CAAC,EAAE,EAAE,MAAM;;;;;;;;GAE1C"}
1
+ {"version":3,"file":"notification.d.ts","sourceRoot":"/","sources":["services/notification.ts"],"names":[],"mappings":"AAYA,qCAAqC;AACrC,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;MAErD;AAED,wDAAwD;AACxD,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;GAW/D;AAED,uCAAuC;AACvC,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;;;;;;;;GAEA;AAED,oDAAoD;AACpD,wBAAsB,cAAc,CAAC,KAAK,EAAE;IAC1C,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,yDASA;AAED,oDAAoD;AACpD,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;GAW1D"}
@@ -2,15 +2,23 @@
2
2
  * Notification service – list, send, and mark notifications as read.
3
3
  */
4
4
 
5
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5a0ab2a2-7806-5031-8d1e-f60eb3ade5dc")}catch(e){}}();
6
- import { findNotificationsByReceiverId, findNotificationById, createNotification, createManyNotifications, markNotificationAsRead, } from "../models/notification.js";
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]="ac3dc2fd-32e2-54b8-b578-714114e22f1d")}catch(e){}}();
6
+ import { TRPCError } from "@trpc/server";
7
+ import { findNotificationsByReceiverId, findNotificationByIdForReceiver, createNotification, createManyNotifications, markNotificationAsReadForReceiver, } from "../models/notification.js";
7
8
  /** List notifications for a user. */
8
9
  export async function listNotifications(userId) {
9
10
  return findNotificationsByReceiverId(userId);
10
11
  }
11
- /** Get a single notification by ID. */
12
- export async function getNotification(id) {
13
- return findNotificationById(id);
12
+ /** Get a single notification by ID for its receiver. */
13
+ export async function getNotification(userId, id) {
14
+ const notification = await findNotificationByIdForReceiver(id, userId);
15
+ if (!notification) {
16
+ throw new TRPCError({
17
+ code: "NOT_FOUND",
18
+ message: "Notification not found",
19
+ });
20
+ }
21
+ return notification;
14
22
  }
15
23
  /** Send a notification to one user. */
16
24
  export async function sendNotification(input) {
@@ -25,9 +33,16 @@ export async function sendToMultiple(input) {
25
33
  })));
26
34
  return result;
27
35
  }
28
- /** Mark a notification as read. */
29
- export async function markAsRead(id) {
30
- return markNotificationAsRead(id);
36
+ /** Mark a notification as read for its receiver. */
37
+ export async function markAsRead(userId, id) {
38
+ const notification = await markNotificationAsReadForReceiver(id, userId);
39
+ if (!notification) {
40
+ throw new TRPCError({
41
+ code: "NOT_FOUND",
42
+ message: "Notification not found",
43
+ });
44
+ }
45
+ return notification;
31
46
  }
32
47
  //# sourceMappingURL=notification.js.map
33
- //# debugId=5a0ab2a2-7806-5031-8d1e-f60eb3ade5dc
48
+ //# debugId=ac3dc2fd-32e2-54b8-b578-714114e22f1d
@@ -1 +1 @@
1
- {"version":3,"file":"notification.js","sources":["services/notification.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Notification service – list, send, and mark notifications as read.\n */\nimport {\n findNotificationsByReceiverId,\n findNotificationById,\n createNotification,\n createManyNotifications,\n markNotificationAsRead,\n} from \"../models/notification.js\";\n\n/** List notifications for a user. */\nexport async function listNotifications(userId: string) {\n return findNotificationsByReceiverId(userId);\n}\n\n/** Get a single notification by ID. */\nexport async function getNotification(id: string) {\n return findNotificationById(id);\n}\n\n/** Send a notification to one user. */\nexport async function sendNotification(input: {\n receiverId: string;\n title: string;\n content: string;\n}) {\n return createNotification(input);\n}\n\n/** Send the same notification to multiple users. */\nexport async function sendToMultiple(input: {\n receiverIds: string[];\n title: string;\n content: string;\n}) {\n const result = await createManyNotifications(\n input.receiverIds.map((receiverId) => ({\n receiverId,\n title: input.title,\n content: input.content,\n }))\n );\n return result;\n}\n\n/** Mark a notification as read. */\nexport async function markAsRead(id: string) {\n return markNotificationAsRead(id);\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAEnC,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAc;IACpD,OAAO,6BAA6B,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,uCAAuC;AACvC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAU;IAC9C,OAAO,oBAAoB,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,uCAAuC;AACvC,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAItC;IACC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAIpC;IACC,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAC1C,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACrC,UAAU;QACV,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC,CACJ,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,mCAAmC;AACnC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,EAAU;IACzC,OAAO,sBAAsB,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","debug_id":"5a0ab2a2-7806-5031-8d1e-f60eb3ade5dc"}
1
+ {"version":3,"file":"notification.js","sources":["services/notification.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Notification service – list, send, and mark notifications as read.\n */\nimport { TRPCError } from \"@trpc/server\";\nimport {\n findNotificationsByReceiverId,\n findNotificationByIdForReceiver,\n createNotification,\n createManyNotifications,\n markNotificationAsReadForReceiver,\n} from \"../models/notification.js\";\n\n/** List notifications for a user. */\nexport async function listNotifications(userId: string) {\n return findNotificationsByReceiverId(userId);\n}\n\n/** Get a single notification by ID for its receiver. */\nexport async function getNotification(userId: string, id: string) {\n const notification = await findNotificationByIdForReceiver(id, userId);\n\n if (!notification) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Notification not found\",\n });\n }\n\n return notification;\n}\n\n/** Send a notification to one user. */\nexport async function sendNotification(input: {\n receiverId: string;\n title: string;\n content: string;\n}) {\n return createNotification(input);\n}\n\n/** Send the same notification to multiple users. */\nexport async function sendToMultiple(input: {\n receiverIds: string[];\n title: string;\n content: string;\n}) {\n const result = await createManyNotifications(\n input.receiverIds.map((receiverId) => ({\n receiverId,\n title: input.title,\n content: input.content,\n }))\n );\n return result;\n}\n\n/** Mark a notification as read for its receiver. */\nexport async function markAsRead(userId: string, id: string) {\n const notification = await markNotificationAsReadForReceiver(id, userId);\n\n if (!notification) {\n throw new TRPCError({\n code: \"NO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AAG,MAAM,iCAAiC,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAEzE,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,SAAS,CAAC;YAClB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,wBAAwB;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","debug_id":"ac3dc2fd-32e2-54b8-b578-714114e22f1d"}
@@ -7,10 +7,10 @@ export declare function createSectionRecord(userId: string, input: {
7
7
  name: string;
8
8
  color?: string;
9
9
  }): Promise<{
10
- id: string;
11
- classId: string;
12
10
  name: string;
11
+ id: string;
13
12
  color: string | null;
13
+ classId: string;
14
14
  order: number | null;
15
15
  }>;
16
16
  export declare function reorderSection(userId: string, input: {
@@ -19,10 +19,10 @@ export declare function reorderSection(userId: string, input: {
19
19
  position: "start" | "end" | "before" | "after";
20
20
  targetId?: string;
21
21
  }): Promise<{
22
- id: string;
23
- classId: string;
24
22
  name: string;
23
+ id: string;
25
24
  color: string | null;
25
+ classId: string;
26
26
  order: number | null;
27
27
  } | null>;
28
28
  export declare function updateSectionRecord(userId: string, input: {
@@ -31,10 +31,10 @@ export declare function updateSectionRecord(userId: string, input: {
31
31
  name: string;
32
32
  color?: string;
33
33
  }): Promise<{
34
- id: string;
35
- classId: string;
36
34
  name: string;
35
+ id: string;
37
36
  color: string | null;
37
+ classId: string;
38
38
  order: number | null;
39
39
  }>;
40
40
  export declare function reOrderSection(userId: string, input: {
@@ -2,6 +2,7 @@ type ProgressChatMessage = {
2
2
  role: "user" | "assistant";
3
3
  content: string;
4
4
  };
5
+ type RecommendationType = "missing" | "low_score" | "awaiting_feedback";
5
6
  export declare function getStudentProgressRecommendations(viewerId: string, classId: string, studentId: string): Promise<{
6
7
  student: {
7
8
  id: string;
@@ -21,6 +22,7 @@ export declare function getStudentProgressRecommendations(viewerId: string, clas
21
22
  submissionId: string;
22
23
  title: string;
23
24
  type: import(".prisma/client").$Enums.AssignmentType;
25
+ sectionId: string | null;
24
26
  sectionName: string | null;
25
27
  dueDate: Date;
26
28
  gradeReceived: number | null;
@@ -28,10 +30,83 @@ export declare function getStudentProgressRecommendations(viewerId: string, clas
28
30
  percentage: number | null;
29
31
  submitted: boolean;
30
32
  returned: boolean;
33
+ recommendationType: RecommendationType;
31
34
  reasons: string[];
35
+ suggestedAssignment: {
36
+ title: string;
37
+ instructions: string;
38
+ type: import(".prisma/client").$Enums.AssignmentType;
39
+ maxGrade: number;
40
+ weight: number;
41
+ graded: boolean;
42
+ sectionId: string | null;
43
+ sourceAssignmentId: string;
44
+ };
32
45
  }[];
33
46
  nextSteps: string[];
34
47
  }>;
48
+ export declare function getClassProgressRecommendations(viewerId: string, classId: string): Promise<{
49
+ class: {
50
+ id: string;
51
+ name: string;
52
+ subject: string;
53
+ };
54
+ summary: {
55
+ studentsWithConcerns: number;
56
+ totalRecommendations: number;
57
+ totalMissingAssignments: number;
58
+ totalLowScoreAssignments: number;
59
+ };
60
+ students: {
61
+ student: {
62
+ id: string;
63
+ username: string;
64
+ displayName: string;
65
+ };
66
+ summary: {
67
+ overallGrade: number | null;
68
+ trend: number;
69
+ completedAssignments: number;
70
+ totalAssignments: number;
71
+ missingCount: number;
72
+ lowScoreCount: number;
73
+ };
74
+ recommendations: {
75
+ assignmentId: string;
76
+ submissionId: string;
77
+ title: string;
78
+ type: import(".prisma/client").$Enums.AssignmentType;
79
+ sectionId: string | null;
80
+ sectionName: string | null;
81
+ dueDate: Date;
82
+ gradeReceived: number | null;
83
+ maxGrade: number | null;
84
+ percentage: number | null;
85
+ submitted: boolean;
86
+ returned: boolean;
87
+ recommendationType: RecommendationType;
88
+ reasons: string[];
89
+ suggestedAssignment: {
90
+ title: string;
91
+ instructions: string;
92
+ type: import(".prisma/client").$Enums.AssignmentType;
93
+ maxGrade: number;
94
+ weight: number;
95
+ graded: boolean;
96
+ sectionId: string | null;
97
+ sourceAssignmentId: string;
98
+ };
99
+ }[];
100
+ nextSteps: string[];
101
+ }[];
102
+ }>;
103
+ export declare function dismissStudentRecommendation(viewerId: string, input: {
104
+ classId: string;
105
+ studentId: string;
106
+ submissionId: string;
107
+ }): Promise<{
108
+ success: boolean;
109
+ }>;
35
110
  export declare function chatAboutStudentProgress(viewerId: string, input: {
36
111
  classId: string;
37
112
  studentId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"studentProgress.d.ts","sourceRoot":"/","sources":["services/studentProgress.ts"],"names":[],"mappings":"AAUA,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA2IF,wBAAsB,iCAAiC,CACrD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoHlB;AAgBD,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;IACL,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACjC;;;GA+FF"}
1
+ {"version":3,"file":"studentProgress.d.ts","sourceRoot":"/","sources":["services/studentProgress.ts"],"names":[],"mappings":"AAUA,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA2BF,KAAK,kBAAkB,GACnB,SAAS,GACT,WAAW,GACX,mBAAmB,CAAC;AAyXxB,wBAAsB,iCAAiC,CACrD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBlB;AAED,wBAAsB,+BAA+B,CACnD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAA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