@studious-lms/server 1.2.50 → 1.2.51

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.
@@ -4544,6 +4544,36 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4544
4544
  };
4545
4545
  meta: object;
4546
4546
  }>;
4547
+ addMember: import("@trpc/server").TRPCMutationProcedure<{
4548
+ input: {
4549
+ conversationId: string;
4550
+ memberId: string;
4551
+ };
4552
+ output: {
4553
+ type: import(".prisma/client").$Enums.ConversationType;
4554
+ id: string;
4555
+ name: string | null;
4556
+ createdAt: Date;
4557
+ updatedAt: Date;
4558
+ displayInChat: boolean;
4559
+ };
4560
+ meta: object;
4561
+ }>;
4562
+ removeMember: import("@trpc/server").TRPCMutationProcedure<{
4563
+ input: {
4564
+ conversationId: string;
4565
+ memberId: string;
4566
+ };
4567
+ output: {
4568
+ type: import(".prisma/client").$Enums.ConversationType;
4569
+ id: string;
4570
+ name: string | null;
4571
+ createdAt: Date;
4572
+ updatedAt: Date;
4573
+ displayInChat: boolean;
4574
+ };
4575
+ meta: object;
4576
+ }>;
4547
4577
  }>>;
4548
4578
  message: import("@trpc/server").TRPCBuiltRouter<{
4549
4579
  ctx: import("../trpc.js").Context;
@@ -10074,6 +10104,36 @@ export declare const createCaller: import("@trpc/server").TRPCRouterCaller<{
10074
10104
  };
10075
10105
  meta: object;
10076
10106
  }>;
10107
+ addMember: import("@trpc/server").TRPCMutationProcedure<{
10108
+ input: {
10109
+ conversationId: string;
10110
+ memberId: string;
10111
+ };
10112
+ output: {
10113
+ type: import(".prisma/client").$Enums.ConversationType;
10114
+ id: string;
10115
+ name: string | null;
10116
+ createdAt: Date;
10117
+ updatedAt: Date;
10118
+ displayInChat: boolean;
10119
+ };
10120
+ meta: object;
10121
+ }>;
10122
+ removeMember: import("@trpc/server").TRPCMutationProcedure<{
10123
+ input: {
10124
+ conversationId: string;
10125
+ memberId: string;
10126
+ };
10127
+ output: {
10128
+ type: import(".prisma/client").$Enums.ConversationType;
10129
+ id: string;
10130
+ name: string | null;
10131
+ createdAt: Date;
10132
+ updatedAt: Date;
10133
+ displayInChat: boolean;
10134
+ };
10135
+ meta: object;
10136
+ }>;
10077
10137
  }>>;
10078
10138
  message: import("@trpc/server").TRPCBuiltRouter<{
10079
10139
  ctx: import("../trpc.js").Context;
@@ -1 +1 @@
1
- {"version":3,"file":"_app.d.ts","sourceRoot":"/","sources":["routers/_app.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAiB1E,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAiC,CAAC"}
@@ -136,5 +136,35 @@ export declare const conversationRouter: import("@trpc/server").TRPCBuiltRouter<
136
136
  };
137
137
  meta: object;
138
138
  }>;
139
+ addMember: import("@trpc/server").TRPCMutationProcedure<{
140
+ input: {
141
+ conversationId: string;
142
+ memberId: string;
143
+ };
144
+ output: {
145
+ type: import(".prisma/client").$Enums.ConversationType;
146
+ id: string;
147
+ name: string | null;
148
+ createdAt: Date;
149
+ updatedAt: Date;
150
+ displayInChat: boolean;
151
+ };
152
+ meta: object;
153
+ }>;
154
+ removeMember: import("@trpc/server").TRPCMutationProcedure<{
155
+ input: {
156
+ conversationId: string;
157
+ memberId: string;
158
+ };
159
+ output: {
160
+ type: import(".prisma/client").$Enums.ConversationType;
161
+ id: string;
162
+ name: string | null;
163
+ createdAt: Date;
164
+ updatedAt: Date;
165
+ displayInChat: boolean;
166
+ };
167
+ meta: object;
168
+ }>;
139
169
  }>>;
140
170
  //# sourceMappingURL=conversation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"/","sources":["routers/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyT7B,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"/","sources":["routers/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwW7B,CAAC"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0653a9bb-09de-561c-b1dc-9cea19f1c8b2")}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]="1f7b92a6-0af0-5d8b-9470-dbfacbf4f6a3")}catch(e){}}();
3
3
  import { z } from 'zod';
4
4
  import { createTRPCRouter, protectedProcedure } from '../trpc.js';
5
5
  import { prisma } from '../lib/prisma.js';
@@ -288,6 +288,44 @@ export const conversationRouter = createTRPCRouter({
288
288
  }
289
289
  return conversation;
290
290
  }),
291
+ addMember: protectedProcedure
292
+ .input(z.object({ conversationId: z.string(), memberId: z.string() }))
293
+ .mutation(async ({ input, ctx }) => {
294
+ const userId = ctx.user.id;
295
+ const { conversationId, memberId } = input;
296
+ const conversation = await prisma.conversation.findFirst({
297
+ where: { id: conversationId, members: { some: { userId } } },
298
+ });
299
+ if (!conversation) {
300
+ throw new TRPCError({
301
+ code: 'NOT_FOUND',
302
+ message: 'Conversation not found or access denied',
303
+ });
304
+ }
305
+ await prisma.conversationMember.create({
306
+ data: { userId: memberId, conversationId, role: 'MEMBER' },
307
+ });
308
+ return conversation;
309
+ }),
310
+ removeMember: protectedProcedure
311
+ .input(z.object({ conversationId: z.string(), memberId: z.string() }))
312
+ .mutation(async ({ input, ctx }) => {
313
+ const userId = ctx.user.id;
314
+ const { conversationId, memberId } = input;
315
+ const conversation = await prisma.conversation.findFirst({
316
+ where: { id: conversationId, members: { some: { userId } } },
317
+ });
318
+ if (!conversation) {
319
+ throw new TRPCError({
320
+ code: 'NOT_FOUND',
321
+ message: 'Conversation not found or access denied',
322
+ });
323
+ }
324
+ await prisma.conversationMember.delete({
325
+ where: { userId_conversationId: { userId: memberId, conversationId } },
326
+ });
327
+ return conversation;
328
+ }),
291
329
  });
292
330
  //# sourceMappingURL=conversation.js.map
293
- //# debugId=0653a9bb-09de-561c-b1dc-9cea19f1c8b2
331
+ //# debugId=1f7b92a6-0af0-5d8b-9470-dbfacbf4f6a3
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.js","sources":["routers/conversation.ts"],"sourceRoot":"/","sourcesContent":["import { z } from 'zod';\nimport { createTRPCRouter, protectedProcedure } from '../trpc.js';\nimport { prisma } from '../lib/prisma.js';\nimport { TRPCError } from '@trpc/server';\n\nexport const conversationRouter = createTRPCRouter({\n list: protectedProcedure.query(async ({ ctx }) => {\n const userId = ctx.user!.id;\n\n const conversations = await prisma.conversation.findMany({\n where: {\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n labChat: {\n select: {\n id: true,\n title: true,\n },\n },\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n messages: {\n orderBy: {\n createdAt: 'desc',\n },\n take: 1,\n include: {\n sender: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n },\n },\n },\n },\n },\n },\n },\n orderBy: {\n updatedAt: 'desc',\n },\n });\n\n // Calculate unread counts for each conversation\n const conversationsWithUnread = await Promise.all(\n conversations.map(async (conversation) => {\n const userMembership = conversation.members.find(m => m.userId === userId);\n const lastViewedAt = userMembership?.lastViewedAt;\n const lastViewedMentionAt = userMembership?.lastViewedMentionAt;\n \n // Count regular unread messages\n const unreadCount = await prisma.message.count({\n where: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(lastViewedAt && {\n createdAt: { gt: lastViewedAt }\n }),\n },\n });\n\n // Count unread mentions\n // Use the later of lastViewedAt or lastViewedMentionAt\n // This means if user viewed conversation after mention, mention is considered read\n const mentionCutoffTime = lastViewedMentionAt && lastViewedAt \n ? (lastViewedMentionAt > lastViewedAt ? lastViewedMentionAt : lastViewedAt)\n : (lastViewedMentionAt || lastViewedAt);\n \n const unreadMentionCount = await prisma.mention.count({\n where: {\n userId,\n message: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(mentionCutoffTime && {\n createdAt: { gt: mentionCutoffTime }\n }),\n },\n },\n });\n\n return {\n id: conversation.id,\n type: conversation.type,\n name: conversation.name,\n createdAt: conversation.createdAt,\n updatedAt: conversation.updatedAt,\n labChat: conversation.labChat,\n members: conversation.members,\n lastMessage: conversation.messages[0] || null,\n unreadCount,\n unreadMentionCount,\n };\n })\n );\n\n return conversationsWithUnread;\n }),\n\n create: protectedProcedure\n .input(\n z.object({\n type: z.enum(['DM', 'GROUP']),\n name: z.string().optional(),\n memberIds: z.array(z.string()),\n })\n )\n .mutation(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { type, name, memberIds } = input;\n\n // Validate input\n if (type === 'GROUP' && !name) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'Group conversations must have a name',\n });\n }\n\n if (type === 'DM' && memberIds.length !== 1) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'DM conversations must have exactly one other member',\n });\n }\n\n // For DMs, check if conversation already exists\n if (type === 'DM') {\n // Get the target user's ID from their username\n const targetUser = await prisma.user.findFirst({\n where: { username: memberIds[0] },\n select: { id: true, username: true },\n });\n\n if (!targetUser) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: `User \"${memberIds[0]}\" not found`,\n });\n }\n\n // Find all DM conversations where current user is a member\n const existingDMs = await prisma.conversation.findMany({\n where: {\n type: 'DM',\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n members: {\n select: {\n userId: true,\n },\n },\n },\n });\n\n // Check if any of these conversations has exactly 2 members (current user + target user)\n const existingDM = existingDMs.find(conv => {\n const memberUserIds = conv.members.map(m => m.userId);\n return memberUserIds.length === 2 &&\n memberUserIds.includes(userId) &&\n memberUserIds.includes(targetUser.id);\n });\n\n if (existingDM) {\n // Conversation already exists, throw error with friendly message\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: `A conversation with ${targetUser.username} already exists`,\n });\n }\n }\n\n // Verify all members exist\n const membersWithIds = await prisma.user.findMany({\n where: {\n id: {\n in: memberIds,\n },\n },\n select: {\n id: true,\n username: true,\n },\n });\n\n const membersWithUsernames = await prisma.user.findMany({\n where: {\n username: {\n in: memberIds,\n },\n },\n select: {\n id: true,\n username: true,\n },\n });\n\n const members = [...membersWithIds, ...membersWithUsernames];\n\n if (members.length !== memberIds.length) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'One or more members not found',\n });\n }\n\n // Create conversation with members\n const conversation = await prisma.conversation.create({\n data: {\n type,\n name,\n members: {\n create: [\n {\n userId,\n role: type === 'GROUP' ? 'ADMIN' : 'MEMBER',\n },\n ...members.map((member) => ({\n userId: member.id,\n role: 'MEMBER' as const,\n })),\n ],\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n return conversation;\n }),\n\n get: protectedProcedure\n .input(z.object({ conversationId: z.string() }))\n .query(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { conversationId } = input;\n\n const conversation = await prisma.conversation.findFirst({\n where: {\n id: conversationId,\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n if (!conversation) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: 'Conversation not found or access denied',\n });\n }\n\n return conversation;\n }),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;IACjD,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC;QAE5B,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC;YACvD,KAAK,EAAE;gBACL,OAAO,EAAE;oBACP,IAAI,EAAE;wBACJ,MAAM;qBACP;iBACF;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN,EAAE,EAAE,IAAI;wBACR,KAAK,EAAE,IAAI;qBACZ;iBAC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EAAE,EAAE,CAAC,CAAC;SAC/C,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QAEjC,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC;YACvD,KAAK,EAAE;gBACL,EAAE,EAAE,cAAc;gBAClB,OAAO,EAAE;oBACP,IAAI,EAAE;wBACJ,MAAM;qBACP;iBACF;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,OAAO,EAAE;wBACP,IAAI,EAAE;4BACJ,MAAM,EAAE;gCACN,EAAE,EAAE,IAAI;gCACR,QAAQ,EAAE,IAAI;gCACd,OAAO,EAAE;oCACP,MAAM,EAAE;wCACN,WAAW,EAAE,IAAI;wCACjB,cAAc,EAAE,IAAI;qCACrB;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,SAAS,CAAC;gBAClB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,yCAAyC;aACnD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;CACL,CAAC,CAAC","debug_id":"0653a9bb-09de-561c-b1dc-9cea19f1c8b2"}
1
+ {"version":3,"file":"conversation.js","sources":["routers/conversation.ts"],"sourceRoot":"/","sourcesContent":["import { z } from 'zod';\nimport { createTRPCRouter, protectedProcedure } from '../trpc.js';\nimport { prisma } from '../lib/prisma.js';\nimport { TRPCError } from '@trpc/server';\n\nexport const conversationRouter = createTRPCRouter({\n list: protectedProcedure.query(async ({ ctx }) => {\n const userId = ctx.user!.id;\n\n const conversations = await prisma.conversation.findMany({\n where: {\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n labChat: {\n select: {\n id: true,\n title: true,\n },\n },\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n messages: {\n orderBy: {\n createdAt: 'desc',\n },\n take: 1,\n include: {\n sender: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n },\n },\n },\n },\n },\n },\n },\n orderBy: {\n updatedAt: 'desc',\n },\n });\n\n // Calculate unread counts for each conversation\n const conversationsWithUnread = await Promise.all(\n conversations.map(async (conversation) => {\n const userMembership = conversation.members.find(m => m.userId === userId);\n const lastViewedAt = userMembership?.lastViewedAt;\n const lastViewedMentionAt = userMembership?.lastViewedMentionAt;\n \n // Count regular unread messages\n const unreadCount = await prisma.message.count({\n where: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(lastViewedAt && {\n createdAt: { gt: lastViewedAt }\n }),\n },\n });\n\n // Count unread mentions\n // Use the later of lastViewedAt or lastViewedMentionAt\n // This means if user viewed conversation after mention, mention is considered read\n const mentionCutoffTime = lastViewedMentionAt && lastViewedAt \n ? (lastViewedMentionAt > lastViewedAt ? lastViewedMentionAt : lastViewedAt)\n : (lastViewedMentionAt || lastViewedAt);\n \n const unreadMentionCount = await prisma.mention.count({\n where: {\n userId,\n message: {\n conversationId: conversation.id,\n senderId: { not: userId },\n ...(mentionCutoffTime && {\n createdAt: { gt: mentionCutoffTime }\n }),\n },\n },\n });\n\n return {\n id: conversation.id,\n type: conversation.type,\n name: conversation.name,\n createdAt: conversation.createdAt,\n updatedAt: conversation.updatedAt,\n labChat: conversation.labChat,\n members: conversation.members,\n lastMessage: conversation.messages[0] || null,\n unreadCount,\n unreadMentionCount,\n };\n })\n );\n\n return conversationsWithUnread;\n }),\n\n create: protectedProcedure\n .input(\n z.object({\n type: z.enum(['DM', 'GROUP']),\n name: z.string().optional(),\n memberIds: z.array(z.string()),\n })\n )\n .mutation(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { type, name, memberIds } = input;\n\n // Validate input\n if (type === 'GROUP' && !name) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'Group conversations must have a name',\n });\n }\n\n if (type === 'DM' && memberIds.length !== 1) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'DM conversations must have exactly one other member',\n });\n }\n\n // For DMs, check if conversation already exists\n if (type === 'DM') {\n // Get the target user's ID from their username\n const targetUser = await prisma.user.findFirst({\n where: { username: memberIds[0] },\n select: { id: true, username: true },\n });\n\n if (!targetUser) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: `User \"${memberIds[0]}\" not found`,\n });\n }\n\n // Find all DM conversations where current user is a member\n const existingDMs = await prisma.conversation.findMany({\n where: {\n type: 'DM',\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n members: {\n select: {\n userId: true,\n },\n },\n },\n });\n\n // Check if any of these conversations has exactly 2 members (current user + target user)\n const existingDM = existingDMs.find(conv => {\n const memberUserIds = conv.members.map(m => m.userId);\n return memberUserIds.length === 2 &&\n memberUserIds.includes(userId) &&\n memberUserIds.includes(targetUser.id);\n });\n\n if (existingDM) {\n // Conversation already exists, throw error with friendly message\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: `A conversation with ${targetUser.username} already exists`,\n });\n }\n }\n\n // Verify all members exist\n const membersWithIds = await prisma.user.findMany({\n where: {\n id: {\n in: memberIds,\n },\n },\n select: {\n id: true,\n username: true,\n },\n });\n\n const membersWithUsernames = await prisma.user.findMany({\n where: {\n username: {\n in: memberIds,\n },\n },\n select: {\n id: true,\n username: true,\n },\n });\n\n const members = [...membersWithIds, ...membersWithUsernames];\n\n if (members.length !== memberIds.length) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'One or more members not found',\n });\n }\n\n // Create conversation with members\n const conversation = await prisma.conversation.create({\n data: {\n type,\n name,\n members: {\n create: [\n {\n userId,\n role: type === 'GROUP' ? 'ADMIN' : 'MEMBER',\n },\n ...members.map((member) => ({\n userId: member.id,\n role: 'MEMBER' as const,\n })),\n ],\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n return conversation;\n }),\n\n get: protectedProcedure\n .input(z.object({ conversationId: z.string() }))\n .query(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { conversationId } = input;\n\n const conversation = await prisma.conversation.findFirst({\n where: {\n id: conversationId,\n members: {\n some: {\n userId,\n },\n },\n },\n include: {\n members: {\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n },\n },\n },\n });\n\n if (!conversation) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: 'Conversation not found or access denied',\n });\n }\n\n return conversation;\n }),\n addMember: protectedProcedure\n .input(z.object({ conversationId: z.string(), memberId: z.string() }))\n .mutation(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { conversationId, memberId } = input;\n\n const conversation = await prisma.conversation.findFirst({\n where: { id: conversationId, members: { some: { userId } } },\n });\n\n if (!conversation) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: 'Conversation not found or access denied',\n });\n }\n\n await prisma.conversationMember.create({\n data: { userId: memberId, conversationId, role: 'MEMBER' },\n });\n\n return conversation;\n }),\n\n removeMember: protectedProcedure\n .input(z.object({ conversationId: z.string(), memberId: z.string() }))\n .mutation(async ({ input, ctx }) => {\n const userId = ctx.user!.id;\n const { conversationId, memberId } = input;\n\n const conversation = await prisma.conversation.findFirst({\n where: { id: conversationId, members: { some: { userId } } },\n });\n\n if (!conversation) {\n throw new TRPCError({\n code: 'NOT_FOUND',\n message: 'Conversation not found or access denied',\n });\n }\n\n await prisma.conversationMember.delete({\n where: { userId_conversationId: { userId: memberId, conversationId } },\n });\n\n return conversation;\n }),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM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AAE,6BAA6B,MAAM;;;;;;;;;;;;;EAuB9G,CAAC"}
1
+ {"version":3,"file":"gradeWorksheet.d.ts","sourceRoot":"/","sources":["server/pipelines/gradeWorksheet.ts"],"names":[],"mappings":"AA+IA,eAAO,MAAM,sBAAsB,GAAU,qBAAqB,MAAM,kBAsDvE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,qBAAqB,MAAM,EAAE,6BAA6B,MAAM;;;;;;;;;;;;;EAyBzG,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,qBAAqB,MAAM,EAAE,6BAA6B,MAAM;;;;;;;;;;;;;EAgD9G,CAAC"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8de476c6-24be-55c4-ade4-500ee17dbfc4")}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]="dca8f58c-f587-5706-98e0-1eafd2fa5e2f")}catch(e){}}();
3
3
  import { GenerationStatus, WorksheetQuestionType } from "@prisma/client";
4
4
  import { prisma } from "../../lib/prisma.js";
5
5
  import { logger } from "../../utils/logger.js";
@@ -15,7 +15,7 @@ const removeAllPreviousAIComments = async (worksheetQuestionProgressId) => {
15
15
  },
16
16
  });
17
17
  };
18
- const gradeWorksheetQuestion = async (worksheetResponseId) => {
18
+ const gradeWorksheetQuestion = async (worksheetResponseId, worksheetQuestionProgressId) => {
19
19
  const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
20
20
  where: { id: worksheetResponseId },
21
21
  include: {
@@ -28,12 +28,7 @@ const gradeWorksheetQuestion = async (worksheetResponseId) => {
28
28
  }
29
29
  const studentQuestionProgress = await prisma.studentQuestionProgress.findFirst({
30
30
  where: {
31
- studentWorksheetResponseId: worksheetResponseId,
32
- status: {
33
- not: {
34
- in: DO_NOT_INFERENCE_STATUSES,
35
- },
36
- },
31
+ id: worksheetQuestionProgressId,
37
32
  },
38
33
  include: {
39
34
  question: true,
@@ -44,7 +39,7 @@ const gradeWorksheetQuestion = async (worksheetResponseId) => {
44
39
  logger.error('Student question progress not found');
45
40
  throw new Error('Student question progress not found');
46
41
  }
47
- pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `status-pending`, {
42
+ pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-pending`, {
48
43
  id: studentQuestionProgress.id,
49
44
  });
50
45
  const question = studentQuestionProgress.question;
@@ -172,7 +167,7 @@ export const gradeWorksheetPipeline = async (worksheetResponseId) => {
172
167
  if (studentQuestionProgress.status !== GenerationStatus.PENDING) {
173
168
  return;
174
169
  }
175
- gradeWorksheetQuestion(response.id);
170
+ gradeWorksheetQuestion(worksheetResponseId, response.id);
176
171
  }
177
172
  ;
178
173
  };
@@ -200,22 +195,47 @@ export const cancelGradePipeline = async (worksheetResponseId, worksheetQuestion
200
195
  };
201
196
  export const regradeWorksheetPipeline = async (worksheetResponseId, worksheetQuestionProgressId) => {
202
197
  logger.info('Regrading worksheet response', { worksheetResponseId, worksheetQuestionProgressId });
203
- const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
204
- where: { id: worksheetResponseId, },
205
- include: {
206
- worksheet: true,
207
- },
208
- });
209
- if (!worksheetResponse) {
210
- logger.error('Worksheet response not found');
211
- throw new Error('Worksheet response not found');
198
+ try {
199
+ const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
200
+ where: { id: worksheetResponseId, },
201
+ include: {
202
+ worksheet: true,
203
+ },
204
+ });
205
+ await removeAllPreviousAIComments(worksheetQuestionProgressId);
206
+ if (!worksheetResponse) {
207
+ logger.error('Worksheet response not found');
208
+ throw new Error('Worksheet response not found');
209
+ }
210
+ const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({
211
+ where: { id: worksheetQuestionProgressId },
212
+ data: { status: GenerationStatus.PENDING },
213
+ });
214
+ console.log(updatedStudentQuestionProgress);
215
+ gradeWorksheetQuestion(worksheetResponseId, worksheetQuestionProgressId);
216
+ return updatedStudentQuestionProgress;
217
+ }
218
+ catch (error) {
219
+ await prisma.studentQuestionProgress.update({
220
+ where: { id: worksheetQuestionProgressId },
221
+ data: { status: GenerationStatus.FAILED },
222
+ });
223
+ const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
224
+ where: { id: worksheetResponseId, },
225
+ include: {
226
+ worksheet: true,
227
+ },
228
+ });
229
+ if (!worksheetResponse) {
230
+ logger.error('Worksheet response not found');
231
+ throw new Error('Worksheet response not found');
232
+ }
233
+ pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-failed`, {
234
+ id: worksheetQuestionProgressId,
235
+ });
236
+ logger.error('Failed to regrade worksheet response', { error, worksheetResponseId, worksheetQuestionProgressId });
237
+ throw error;
212
238
  }
213
- const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({
214
- where: { id: worksheetQuestionProgressId },
215
- data: { status: GenerationStatus.PENDING },
216
- });
217
- gradeWorksheetQuestion(worksheetQuestionProgressId);
218
- return updatedStudentQuestionProgress;
219
239
  };
220
240
  //# sourceMappingURL=gradeWorksheet.js.map
221
- //# debugId=8de476c6-24be-55c4-ade4-500ee17dbfc4
241
+ //# debugId=dca8f58c-f587-5706-98e0-1eafd2fa5e2f
@@ -1 +1 @@
1
- {"version":3,"file":"gradeWorksheet.js","sources":["server/pipelines/gradeWorksheet.ts"],"sourceRoot":"/","sourcesContent":["import { GenerationStatus, WorksheetQuestionType } from \"@prisma/client\";\nimport { prisma } from \"../../lib/prisma.js\";\nimport { logger } from \"../../utils/logger.js\";\nimport z from \"zod\";\nimport { inference } from \"../../utils/inference.js\";\nimport { getAIUserId } from \"../../utils/aiUser.js\";\nimport { pusher } from \"../../lib/pusher.js\";\n\n\nconst removeAllPreviousAIComments = async (worksheetQuestionProgressId: string) => {\n await prisma.comment.deleteMany({\n where: {\n studentQuestionProgressId: worksheetQuestionProgressId,\n authorId: getAIUserId(),\n },\n });\n};\n\nconst gradeWorksheetQuestion = async (worksheetResponseId: string) => {\n\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId },\n include: {\n worksheet: true,\n },\n });\n\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n\n\n const studentQuestionProgress = await prisma.studentQuestionProgress.findFirst({\n where: {\n studentWorksheetResponseId: worksheetResponseId,\n status: {\n not: {\n in: DO_NOT_INFERENCE_STATUSES,\n },\n },\n },\n include: {\n question: true,\n comments: true,\n },\n });\n\n if (!studentQuestionProgress) {\n logger.error('Student question progress not found');\n throw new Error('Student question progress not found');\n }\n\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `status-pending`, {\n id: studentQuestionProgress.id,\n });\n\n const question = studentQuestionProgress.question;\n const comments = studentQuestionProgress.comments;\n const responseText = studentQuestionProgress.response;\n\n\n try {\n const apiResponse = await inference(\n `Grade the following worksheet response:\n \n Question: ${question.question}\n Response: ${responseText}\n\n Comments: ${comments.map((comment) => comment.content).join('\\n')}\n Mark Scheme: ${JSON.stringify(question.markScheme)}\n \n Justify your reasoning by including comment(s) and mark the question please. \n Return ONLY JSON in the following format (fill in the values as per the question):\n {\n \"isCorrect\": <boolean>,\n \"points\": <number>,\n \"markschemeState\": [\n { \"id\": <string>, \"correct\": <boolean> }\n ],\n \"comments\": [<string>, ...]\n }\n `,\n z.object({\n isCorrect: z.boolean(),\n points: z.number(),\n markschemeState: z.array(z.object({\n id: z.string(),\n correct: z.boolean(),\n })), // @note: this has to be converted to [id: string]: correct boolean\n comments: z.array(z.string()),\n }),\n ).catch((error) => {\n logger.error('Failed to grade worksheet response', { error });\n throw error;\n });\n\n const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: studentQuestionProgress.id, status: {\n not: {\n in: ['CANCELLED'],\n },\n } },\n data: {\n status: GenerationStatus.COMPLETED,\n isCorrect: (apiResponse as { isCorrect: boolean }).isCorrect,\n points: (apiResponse as { points: number }).points,\n markschemeState: (apiResponse as {\n markschemeState: { id: string; correct: boolean }[];\n }).markschemeState.reduce((acc, curr) => {\n acc[\"item-\" + curr.id] = curr.correct;\n return acc;\n }, {} as Record<string, boolean>),\n comments: {\n create: (apiResponse as {\n comments: string[];\n }).comments.map((commentContent) => ({\n content: commentContent,\n authorId: getAIUserId(),\n })),\n },\n },\n });\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-completed`, {\n id: updatedStudentQuestionProgress.id,\n });\n\n return updatedStudentQuestionProgress;\n } catch (error) {\n logger.error('Failed to grade worksheet response', { error, worksheetResponseId });\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-failed`, {\n id: studentQuestionProgress.id,\n });\n await prisma.studentQuestionProgress.update({\n where: { id: studentQuestionProgress.id },\n data: { status: GenerationStatus.FAILED },\n });\n throw error;\n }\n}\n\n/**\n * Grades and regrades worksheet (can fixed failed responses)\n * @param worksheetResponseId worksheet response id\n * @returns updated worksheet response\n */\n\nconst DO_NOT_INFERENCE_STATUSES = [GenerationStatus.CANCELLED, GenerationStatus.PENDING, GenerationStatus.COMPLETED];\n\nexport const gradeWorksheetPipeline = async (worksheetResponseId: string) => {\n logger.info('Grading worksheet response', { worksheetResponseId });\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId },\n include: {\n worksheet: true,\n responses: {\n where: {\n status: {\n not: {\n in: DO_NOT_INFERENCE_STATUSES,\n },\n },\n question: {\n type: {\n not: {\n in: [WorksheetQuestionType.MULTIPLE_CHOICE, WorksheetQuestionType.TRUE_FALSE],\n }\n },\n },\n },\n include: {\n question: true,\n comments: true,\n },\n },\n },\n });\n\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n\n // Use for...of instead of forEach to properly handle async operations\n for (const response of worksheetResponse.responses) {\n logger.info('Grading question', { questionId: response.questionId });\n\n const studentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: response.id, status: {\n not: {\n in: DO_NOT_INFERENCE_STATUSES,\n }\n } },\n data: { status: GenerationStatus.PENDING },\n });\n\n if (studentQuestionProgress.status !== GenerationStatus.PENDING) {\n return;\n }\n\n gradeWorksheetQuestion(response.id);\n\n };\n};\n\nexport const cancelGradePipeline = async (worksheetResponseId: string, worksheetQuestionProgressId: string) => {\n logger.info('Cancelling auto grading', { worksheetResponseId, worksheetQuestionProgressId });\n\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId },\n include: {\n worksheet: true,\n },\n });\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: worksheetQuestionProgressId },\n data: { status: GenerationStatus.CANCELLED },\n });\n\n await removeAllPreviousAIComments(worksheetQuestionProgressId);\n\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-cancelled`, {\n id: updatedStudentQuestionProgress.id,\n });\n\n return updatedStudentQuestionProgress;\n};\n\nexport const regradeWorksheetPipeline = async (worksheetResponseId: string, worksheetQuestionProgressId: string) => {\n logger.info('Regrading worksheet response', { worksheetResponseId, worksheetQuestionProgressId });\n\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId, },\n include: {\n worksheet: true,\n },\n });\n\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n\n const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: worksheetQuestionProgressId },\n data: { status: GenerationStatus.PENDING },\n });\n\n gradeWorksheetQuestion(worksheetQuestionProgressId);\n\n return updatedStudentQuestionProgress;\n};\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,2BAA2B,GAAG,KAAK,EAAE,2BAAmC,EAAE,EAAE;IAC9E,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;QAC5B,KAAK,EAAE;YACH,yBAAyB,EAAE,2BAA2B;YACtD,QAAQ,EAAE,WAAW,EAAE;SAC1B;KACJ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,KAAK,EAAE,mBAA2B,EAAE,EAAE;IAEjE,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,UAAU,CAAC;QACvE,KAAK,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE;QAClC,OAAO,EAAE;YACL,SAAS,EAAE,IAAI;SAClB;KACJ,CAAC,CAAC;IAEH,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;IAGD,MAAM,uBAAuB,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC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iB,EAAE,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,8BAA8B,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC;QAC/E,KAAK,EAAE,EAAE,EAAE,EAAE,2BAA2B,EAAE;QAC1C,IAAI,EAAE,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE;KAC7C,CAAC,CAAC;IAEH,sBAAsB,CAAC,2BAA2B,CAAC,CAAC;IAEpD,OAAO,8BAA8B,CAAC;AAC1C,CAAC,CAAC","debug_id":"8de476c6-24be-55c4-ade4-500ee17dbfc4"}
1
+ {"version":3,"file":"gradeWorksheet.js","sources":["server/pipelines/gradeWorksheet.ts"],"sourceRoot":"/","sourcesContent":["import { GenerationStatus, WorksheetQuestionType } from \"@prisma/client\";\nimport { prisma } from \"../../lib/prisma.js\";\nimport { logger } from \"../../utils/logger.js\";\nimport z from \"zod\";\nimport { inference } from \"../../utils/inference.js\";\nimport { getAIUserId } from \"../../utils/aiUser.js\";\nimport { pusher } from \"../../lib/pusher.js\";\n\n\nconst removeAllPreviousAIComments = async (worksheetQuestionProgressId: string) => {\n await prisma.comment.deleteMany({\n where: {\n studentQuestionProgressId: worksheetQuestionProgressId,\n authorId: getAIUserId(),\n },\n });\n};\n\nconst gradeWorksheetQuestion = async (worksheetResponseId: string, worksheetQuestionProgressId: string) => {\n\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId },\n include: {\n worksheet: true,\n },\n });\n\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n } \n\n const studentQuestionProgress = await prisma.studentQuestionProgress.findFirst({\n where: {\n id: worksheetQuestionProgressId,\n },\n include: {\n question: true,\n comments: true,\n },\n });\n\n if (!studentQuestionProgress) {\n logger.error('Student question progress not found');\n throw new Error('Student question progress not found');\n }\n\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-pending`, {\n id: studentQuestionProgress.id,\n });\n\n const question = studentQuestionProgress.question;\n const comments = studentQuestionProgress.comments;\n const responseText = studentQuestionProgress.response;\n\n\n try {\n const apiResponse = await inference(\n `Grade the following worksheet response:\n \n Question: ${question.question}\n Response: ${responseText}\n\n Comments: ${comments.map((comment) => comment.content).join('\\n')}\n Mark Scheme: ${JSON.stringify(question.markScheme)}\n \n Justify your reasoning by including comment(s) and mark the question please. \n Return ONLY JSON in the following format (fill in the values as per the question):\n {\n \"isCorrect\": <boolean>,\n \"points\": <number>,\n \"markschemeState\": [\n { \"id\": <string>, \"correct\": <boolean> }\n ],\n \"comments\": [<string>, ...]\n }\n `,\n z.object({\n isCorrect: z.boolean(),\n points: z.number(),\n markschemeState: z.array(z.object({\n id: z.string(),\n correct: z.boolean(),\n })), // @note: this has to be converted to [id: string]: correct boolean\n comments: z.array(z.string()),\n }),\n ).catch((error) => {\n logger.error('Failed to grade worksheet response', { error });\n throw error;\n });\n\n const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: studentQuestionProgress.id, status: {\n not: {\n in: ['CANCELLED'],\n },\n } },\n data: {\n status: GenerationStatus.COMPLETED,\n isCorrect: (apiResponse as { isCorrect: boolean }).isCorrect,\n points: (apiResponse as { points: number }).points,\n markschemeState: (apiResponse as {\n markschemeState: { id: string; correct: boolean }[];\n }).markschemeState.reduce((acc, curr) => {\n acc[\"item-\" + curr.id] = curr.correct;\n return acc;\n }, {} as Record<string, boolean>),\n comments: {\n create: (apiResponse as {\n comments: string[];\n }).comments.map((commentContent) => ({\n content: commentContent,\n authorId: getAIUserId(),\n })),\n },\n },\n });\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-completed`, {\n id: updatedStudentQuestionProgress.id,\n });\n\n return updatedStudentQuestionProgress;\n } catch (error) {\n logger.error('Failed to grade worksheet response', { error, worksheetResponseId });\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-failed`, {\n id: studentQuestionProgress.id,\n });\n await prisma.studentQuestionProgress.update({\n where: { id: studentQuestionProgress.id },\n data: { status: GenerationStatus.FAILED },\n });\n throw error;\n }\n}\n\n/**\n * Grades and regrades worksheet (can fixed failed responses)\n * @param worksheetResponseId worksheet response id\n * @returns updated worksheet response\n */\n\nconst DO_NOT_INFERENCE_STATUSES = [GenerationStatus.CANCELLED, GenerationStatus.PENDING, GenerationStatus.COMPLETED];\n\nexport const gradeWorksheetPipeline = async (worksheetResponseId: string) => {\n logger.info('Grading worksheet response', { worksheetResponseId });\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId },\n include: {\n worksheet: true,\n responses: {\n where: {\n status: {\n not: {\n in: DO_NOT_INFERENCE_STATUSES,\n },\n },\n question: {\n type: {\n not: {\n in: [WorksheetQuestionType.MULTIPLE_CHOICE, WorksheetQuestionType.TRUE_FALSE],\n }\n },\n },\n },\n include: {\n question: true,\n comments: true,\n },\n },\n },\n });\n\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n\n // Use for...of instead of forEach to properly handle async operations\n for (const response of worksheetResponse.responses) {\n logger.info('Grading question', { questionId: response.questionId });\n\n const studentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: response.id, status: {\n not: {\n in: DO_NOT_INFERENCE_STATUSES,\n }\n } },\n data: { status: GenerationStatus.PENDING },\n });\n\n if (studentQuestionProgress.status !== GenerationStatus.PENDING) {\n return;\n }\n\n gradeWorksheetQuestion(worksheetResponseId, response.id);\n\n };\n};\n\nexport const cancelGradePipeline = async (worksheetResponseId: string, worksheetQuestionProgressId: string) => {\n logger.info('Cancelling auto grading', { worksheetResponseId, worksheetQuestionProgressId });\n\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId },\n include: {\n worksheet: true,\n },\n });\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: worksheetQuestionProgressId },\n data: { status: GenerationStatus.CANCELLED },\n });\n\n await removeAllPreviousAIComments(worksheetQuestionProgressId);\n\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-cancelled`, {\n id: updatedStudentQuestionProgress.id,\n });\n\n return updatedStudentQuestionProgress;\n};\n\nexport const regradeWorksheetPipeline = async (worksheetResponseId: string, worksheetQuestionProgressId: string) => {\n logger.info('Regrading worksheet response', { worksheetResponseId, worksheetQuestionProgressId });\n try {\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId, },\n include: {\n worksheet: true,\n },\n });\n \n await removeAllPreviousAIComments(worksheetQuestionProgressId);\n\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n\n const updatedStudentQuestionProgress = await prisma.studentQuestionProgress.update({\n where: { id: worksheetQuestionProgressId },\n data: { status: GenerationStatus.PENDING },\n });\n\nconsole.log(updatedStudentQuestionProgress);\n\n gradeWorksheetQuestion(worksheetResponseId, worksheetQuestionProgressId);\n\n return updatedStudentQuestionProgress;\n } catch (error) {\n await prisma.studentQuestionProgress.update({\n where: { id: worksheetQuestionProgressId },\n data: { status: GenerationStatus.FAILED },\n });\n const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({\n where: { id: worksheetResponseId, },\n include: {\n worksheet: true,\n },\n });\n if (!worksheetResponse) {\n logger.error('Worksheet response not found');\n throw new Error('Worksheet response not found');\n }\n pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-failed`, {\n id: worksheetQuestionProgressId,\n });\n logger.error('Failed to regrade worksheet response', { error, worksheetResponseId, worksheetQuestion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f587-5706-98e0-1eafd2fa5e2f"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studious-lms/server",
3
- "version": "1.2.50",
3
+ "version": "1.2.51",
4
4
  "description": "Backend server for Studious application",
5
5
  "main": "dist/exportType.js",
6
6
  "types": "dist/exportType.d.ts",
@@ -314,6 +314,53 @@ export const conversationRouter = createTRPCRouter({
314
314
  });
315
315
  }
316
316
 
317
+ return conversation;
318
+ }),
319
+ addMember: protectedProcedure
320
+ .input(z.object({ conversationId: z.string(), memberId: z.string() }))
321
+ .mutation(async ({ input, ctx }) => {
322
+ const userId = ctx.user!.id;
323
+ const { conversationId, memberId } = input;
324
+
325
+ const conversation = await prisma.conversation.findFirst({
326
+ where: { id: conversationId, members: { some: { userId } } },
327
+ });
328
+
329
+ if (!conversation) {
330
+ throw new TRPCError({
331
+ code: 'NOT_FOUND',
332
+ message: 'Conversation not found or access denied',
333
+ });
334
+ }
335
+
336
+ await prisma.conversationMember.create({
337
+ data: { userId: memberId, conversationId, role: 'MEMBER' },
338
+ });
339
+
340
+ return conversation;
341
+ }),
342
+
343
+ removeMember: protectedProcedure
344
+ .input(z.object({ conversationId: z.string(), memberId: z.string() }))
345
+ .mutation(async ({ input, ctx }) => {
346
+ const userId = ctx.user!.id;
347
+ const { conversationId, memberId } = input;
348
+
349
+ const conversation = await prisma.conversation.findFirst({
350
+ where: { id: conversationId, members: { some: { userId } } },
351
+ });
352
+
353
+ if (!conversation) {
354
+ throw new TRPCError({
355
+ code: 'NOT_FOUND',
356
+ message: 'Conversation not found or access denied',
357
+ });
358
+ }
359
+
360
+ await prisma.conversationMember.delete({
361
+ where: { userId_conversationId: { userId: memberId, conversationId } },
362
+ });
363
+
317
364
  return conversation;
318
365
  }),
319
366
  });
@@ -16,7 +16,7 @@ const removeAllPreviousAIComments = async (worksheetQuestionProgressId: string)
16
16
  });
17
17
  };
18
18
 
19
- const gradeWorksheetQuestion = async (worksheetResponseId: string) => {
19
+ const gradeWorksheetQuestion = async (worksheetResponseId: string, worksheetQuestionProgressId: string) => {
20
20
 
21
21
  const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
22
22
  where: { id: worksheetResponseId },
@@ -28,17 +28,11 @@ const gradeWorksheetQuestion = async (worksheetResponseId: string) => {
28
28
  if (!worksheetResponse) {
29
29
  logger.error('Worksheet response not found');
30
30
  throw new Error('Worksheet response not found');
31
- }
32
-
31
+ }
33
32
 
34
33
  const studentQuestionProgress = await prisma.studentQuestionProgress.findFirst({
35
34
  where: {
36
- studentWorksheetResponseId: worksheetResponseId,
37
- status: {
38
- not: {
39
- in: DO_NOT_INFERENCE_STATUSES,
40
- },
41
- },
35
+ id: worksheetQuestionProgressId,
42
36
  },
43
37
  include: {
44
38
  question: true,
@@ -51,7 +45,7 @@ const gradeWorksheetQuestion = async (worksheetResponseId: string) => {
51
45
  throw new Error('Student question progress not found');
52
46
  }
53
47
 
54
- pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `status-pending`, {
48
+ pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-pending`, {
55
49
  id: studentQuestionProgress.id,
56
50
  });
57
51
 
@@ -198,7 +192,7 @@ export const gradeWorksheetPipeline = async (worksheetResponseId: string) => {
198
192
  return;
199
193
  }
200
194
 
201
- gradeWorksheetQuestion(response.id);
195
+ gradeWorksheetQuestion(worksheetResponseId, response.id);
202
196
 
203
197
  };
204
198
  };
@@ -232,13 +226,15 @@ export const cancelGradePipeline = async (worksheetResponseId: string, worksheet
232
226
 
233
227
  export const regradeWorksheetPipeline = async (worksheetResponseId: string, worksheetQuestionProgressId: string) => {
234
228
  logger.info('Regrading worksheet response', { worksheetResponseId, worksheetQuestionProgressId });
235
-
229
+ try {
236
230
  const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
237
231
  where: { id: worksheetResponseId, },
238
232
  include: {
239
233
  worksheet: true,
240
234
  },
241
235
  });
236
+
237
+ await removeAllPreviousAIComments(worksheetQuestionProgressId);
242
238
 
243
239
  if (!worksheetResponse) {
244
240
  logger.error('Worksheet response not found');
@@ -250,7 +246,30 @@ export const regradeWorksheetPipeline = async (worksheetResponseId: string, work
250
246
  data: { status: GenerationStatus.PENDING },
251
247
  });
252
248
 
253
- gradeWorksheetQuestion(worksheetQuestionProgressId);
249
+ console.log(updatedStudentQuestionProgress);
250
+
251
+ gradeWorksheetQuestion(worksheetResponseId, worksheetQuestionProgressId);
254
252
 
255
253
  return updatedStudentQuestionProgress;
254
+ } catch (error) {
255
+ await prisma.studentQuestionProgress.update({
256
+ where: { id: worksheetQuestionProgressId },
257
+ data: { status: GenerationStatus.FAILED },
258
+ });
259
+ const worksheetResponse = await prisma.studentWorksheetResponse.findUnique({
260
+ where: { id: worksheetResponseId, },
261
+ include: {
262
+ worksheet: true,
263
+ },
264
+ });
265
+ if (!worksheetResponse) {
266
+ logger.error('Worksheet response not found');
267
+ throw new Error('Worksheet response not found');
268
+ }
269
+ pusher.trigger(`class-${worksheetResponse.worksheet.classId}-worksheetSubmission-${worksheetResponse.id}`, `set-failed`, {
270
+ id: worksheetQuestionProgressId,
271
+ });
272
+ logger.error('Failed to regrade worksheet response', { error, worksheetResponseId, worksheetQuestionProgressId });
273
+ throw error;
274
+ }
256
275
  };