@studious-lms/server 1.4.6 → 1.4.9

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 (177) hide show
  1. package/.github/workflows/npm.yml +28 -0
  2. package/dist/models/access.d.ts +112 -0
  3. package/dist/models/access.d.ts.map +1 -0
  4. package/dist/models/access.js +49 -0
  5. package/dist/models/access.js.map +1 -0
  6. package/dist/models/announcement.d.ts +17 -2
  7. package/dist/models/announcement.d.ts.map +1 -1
  8. package/dist/models/announcement.js +21 -4
  9. package/dist/models/announcement.js.map +1 -1
  10. package/dist/models/assignment.d.ts +69 -37
  11. package/dist/models/assignment.d.ts.map +1 -1
  12. package/dist/models/assignment.js +124 -15
  13. package/dist/models/assignment.js.map +1 -1
  14. package/dist/models/attendance.d.ts +1 -1
  15. package/dist/models/attendance.d.ts.map +1 -1
  16. package/dist/models/attendance.js +6 -5
  17. package/dist/models/attendance.js.map +1 -1
  18. package/dist/models/auth.d.ts +5 -5
  19. package/dist/models/auth.d.ts.map +1 -1
  20. package/dist/models/auth.js +7 -11
  21. package/dist/models/auth.js.map +1 -1
  22. package/dist/models/class.d.ts +26 -26
  23. package/dist/models/class.d.ts.map +1 -1
  24. package/dist/models/class.js +7 -11
  25. package/dist/models/class.js.map +1 -1
  26. package/dist/models/comment.d.ts +134 -70
  27. package/dist/models/comment.d.ts.map +1 -1
  28. package/dist/models/comment.js +30 -42
  29. package/dist/models/comment.js.map +1 -1
  30. package/dist/models/conversation.d.ts +7 -7
  31. package/dist/models/event.d.ts +52 -3
  32. package/dist/models/event.d.ts.map +1 -1
  33. package/dist/models/event.js +56 -6
  34. package/dist/models/event.js.map +1 -1
  35. package/dist/models/file.d.ts +178 -103
  36. package/dist/models/file.d.ts.map +1 -1
  37. package/dist/models/file.js +54 -14
  38. package/dist/models/file.js.map +1 -1
  39. package/dist/models/folder.d.ts +22 -22
  40. package/dist/models/folder.d.ts.map +1 -1
  41. package/dist/models/folder.js +5 -4
  42. package/dist/models/folder.js.map +1 -1
  43. package/dist/models/labChat.d.ts +20 -20
  44. package/dist/models/labChat.d.ts.map +1 -1
  45. package/dist/models/labChat.js +8 -10
  46. package/dist/models/labChat.js.map +1 -1
  47. package/dist/models/marketing.d.ts +1 -1
  48. package/dist/models/message.d.ts +6 -6
  49. package/dist/models/newtonChat.d.ts +5 -5
  50. package/dist/models/school.d.ts +361 -0
  51. package/dist/models/school.d.ts.map +1 -0
  52. package/dist/models/school.js +314 -0
  53. package/dist/models/school.js.map +1 -0
  54. package/dist/models/section.d.ts +1 -1
  55. package/dist/models/section.d.ts.map +1 -1
  56. package/dist/models/section.js +5 -4
  57. package/dist/models/section.js.map +1 -1
  58. package/dist/models/user.d.ts +4 -4
  59. package/dist/models/worksheet.d.ts +163 -141
  60. package/dist/models/worksheet.d.ts.map +1 -1
  61. package/dist/models/worksheet.js +42 -17
  62. package/dist/models/worksheet.js.map +1 -1
  63. package/dist/pipelines/gradeWorksheet.d.ts +2 -2
  64. package/dist/pipelines/pdfToWorksheet.d.ts +1 -1
  65. package/dist/routers/_app.d.ts +1271 -327
  66. package/dist/routers/_app.d.ts.map +1 -1
  67. package/dist/routers/_app.js +4 -2
  68. package/dist/routers/_app.js.map +1 -1
  69. package/dist/routers/announcement.d.ts +5 -5
  70. package/dist/routers/announcement.d.ts.map +1 -1
  71. package/dist/routers/announcement.js +25 -5
  72. package/dist/routers/announcement.js.map +1 -1
  73. package/dist/routers/assignment.d.ts +79 -44
  74. package/dist/routers/assignment.d.ts.map +1 -1
  75. package/dist/routers/assignment.js +32 -12
  76. package/dist/routers/assignment.js.map +1 -1
  77. package/dist/routers/class.d.ts +40 -20
  78. package/dist/routers/class.d.ts.map +1 -1
  79. package/dist/routers/class.js +3 -2
  80. package/dist/routers/class.js.map +1 -1
  81. package/dist/routers/comment.d.ts +5 -5
  82. package/dist/routers/conversation.d.ts +6 -6
  83. package/dist/routers/event.d.ts +21 -2
  84. package/dist/routers/event.d.ts.map +1 -1
  85. package/dist/routers/file.d.ts +2 -2
  86. package/dist/routers/folder.d.ts +24 -24
  87. package/dist/routers/labChat.d.ts +7 -7
  88. package/dist/routers/school.d.ts +384 -0
  89. package/dist/routers/school.d.ts.map +1 -0
  90. package/dist/routers/school.js +79 -0
  91. package/dist/routers/school.js.map +1 -0
  92. package/dist/routers/search.d.ts +1 -1
  93. package/dist/routers/worksheet.d.ts +36 -20
  94. package/dist/routers/worksheet.d.ts.map +1 -1
  95. package/dist/routers/worksheet.js +10 -3
  96. package/dist/routers/worksheet.js.map +1 -1
  97. package/dist/services/announcement.d.ts.map +1 -1
  98. package/dist/services/announcement.js +10 -6
  99. package/dist/services/announcement.js.map +1 -1
  100. package/dist/services/assignment.d.ts +66 -36
  101. package/dist/services/assignment.d.ts.map +1 -1
  102. package/dist/services/assignment.js +37 -3
  103. package/dist/services/assignment.js.map +1 -1
  104. package/dist/services/class.d.ts +39 -19
  105. package/dist/services/class.d.ts.map +1 -1
  106. package/dist/services/class.js +52 -15
  107. package/dist/services/class.js.map +1 -1
  108. package/dist/services/comment.d.ts +5 -5
  109. package/dist/services/comment.d.ts.map +1 -1
  110. package/dist/services/comment.js +8 -3
  111. package/dist/services/comment.js.map +1 -1
  112. package/dist/services/conversation.d.ts +6 -6
  113. package/dist/services/event.d.ts +21 -2
  114. package/dist/services/event.d.ts.map +1 -1
  115. package/dist/services/event.js +11 -7
  116. package/dist/services/event.js.map +1 -1
  117. package/dist/services/file.d.ts +2 -2
  118. package/dist/services/file.d.ts.map +1 -1
  119. package/dist/services/file.js +17 -8
  120. package/dist/services/file.js.map +1 -1
  121. package/dist/services/folder.d.ts +24 -24
  122. package/dist/services/labChat.d.ts +7 -7
  123. package/dist/services/school.d.ts +299 -0
  124. package/dist/services/school.d.ts.map +1 -0
  125. package/dist/services/school.js +225 -0
  126. package/dist/services/school.js.map +1 -0
  127. package/dist/services/worksheet.d.ts +31 -20
  128. package/dist/services/worksheet.d.ts.map +1 -1
  129. package/dist/services/worksheet.js +37 -3
  130. package/dist/services/worksheet.js.map +1 -1
  131. package/package.json +1 -1
  132. package/prisma/migrations/20260504071500_school_memberships/migration.sql +81 -0
  133. package/prisma/schema.prisma +66 -2
  134. package/src/models/access.ts +48 -0
  135. package/src/models/announcement.ts +19 -2
  136. package/src/models/assignment.ts +149 -13
  137. package/src/models/attendance.ts +4 -3
  138. package/src/models/auth.ts +8 -9
  139. package/src/models/class.ts +8 -9
  140. package/src/models/comment.ts +29 -40
  141. package/src/models/event.ts +54 -4
  142. package/src/models/file.ts +53 -12
  143. package/src/models/folder.ts +3 -2
  144. package/src/models/labChat.ts +9 -8
  145. package/src/models/school.ts +361 -0
  146. package/src/models/section.ts +3 -2
  147. package/src/models/worksheet.ts +61 -12
  148. package/src/routers/_app.ts +2 -0
  149. package/src/routers/announcement.ts +30 -4
  150. package/src/routers/assignment.ts +46 -9
  151. package/src/routers/class.ts +1 -0
  152. package/src/routers/school.ts +122 -0
  153. package/src/routers/worksheet.ts +18 -0
  154. package/src/services/announcement.ts +12 -4
  155. package/src/services/assignment.ts +47 -1
  156. package/src/services/class.ts +61 -14
  157. package/src/services/comment.ts +10 -1
  158. package/src/services/event.ts +23 -6
  159. package/src/services/file.ts +20 -6
  160. package/src/services/school.ts +308 -0
  161. package/src/services/worksheet.ts +46 -0
  162. package/dist/lib/notificationHandler.d.ts +0 -25
  163. package/dist/lib/notificationHandler.d.ts.map +0 -1
  164. package/dist/lib/notificationHandler.js +0 -32
  165. package/dist/lib/notificationHandler.js.map +0 -1
  166. package/dist/server/pipelines/aiLabChat.d.ts +0 -21
  167. package/dist/server/pipelines/aiLabChat.d.ts.map +0 -1
  168. package/dist/server/pipelines/aiLabChat.js +0 -456
  169. package/dist/server/pipelines/aiLabChat.js.map +0 -1
  170. package/dist/server/pipelines/aiNewtonChat.d.ts +0 -30
  171. package/dist/server/pipelines/aiNewtonChat.d.ts.map +0 -1
  172. package/dist/server/pipelines/aiNewtonChat.js +0 -285
  173. package/dist/server/pipelines/aiNewtonChat.js.map +0 -1
  174. package/dist/server/pipelines/gradeWorksheet.d.ts +0 -30
  175. package/dist/server/pipelines/gradeWorksheet.d.ts.map +0 -1
  176. package/dist/server/pipelines/gradeWorksheet.js +0 -248
  177. package/dist/server/pipelines/gradeWorksheet.js.map +0 -1
@@ -42,6 +42,7 @@ export declare const commentSelect: {
42
42
  /** @returns Comment by ID with author and reactions. */
43
43
  export declare function findCommentById(id: string): import(".prisma/client").Prisma.Prisma__CommentClient<{
44
44
  id: string;
45
+ createdAt: Date;
45
46
  assignmentId: string | null;
46
47
  submissionId: string | null;
47
48
  announcementId: string | null;
@@ -57,7 +58,6 @@ export declare function findCommentById(id: string): import(".prisma/client").Pr
57
58
  } | null;
58
59
  };
59
60
  }[];
60
- createdAt: Date;
61
61
  modifiedAt: Date | null;
62
62
  content: string;
63
63
  parentCommentId: string | null;
@@ -91,10 +91,10 @@ export declare function findRepliesByCommentId(commentId: string): import(".pris
91
91
  } & {
92
92
  status: import(".prisma/client").$Enums.GenerationStatus | null;
93
93
  id: string;
94
+ createdAt: Date;
94
95
  assignmentId: string | null;
95
96
  submissionId: string | null;
96
97
  announcementId: string | null;
97
- createdAt: Date;
98
98
  modifiedAt: Date | null;
99
99
  content: string;
100
100
  authorId: string;
@@ -113,10 +113,10 @@ export declare function createComment(data: {
113
113
  }): import(".prisma/client").Prisma.Prisma__CommentClient<{
114
114
  status: import(".prisma/client").$Enums.GenerationStatus | null;
115
115
  id: string;
116
+ createdAt: Date;
116
117
  assignmentId: string | null;
117
118
  submissionId: string | null;
118
119
  announcementId: string | null;
119
- createdAt: Date;
120
120
  modifiedAt: Date | null;
121
121
  content: string;
122
122
  authorId: string;
@@ -133,9 +133,9 @@ export declare function createComment(data: {
133
133
  export declare function findReactionByUserAndComment(userId: string, commentId: string): import(".prisma/client").Prisma.Prisma__ReactionClient<{
134
134
  type: import(".prisma/client").$Enums.ReactionType;
135
135
  id: string;
136
+ createdAt: Date;
136
137
  userId: string;
137
138
  announcementId: string | null;
138
- createdAt: Date;
139
139
  commentId: string | null;
140
140
  } | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
141
141
  datasources: {
@@ -162,9 +162,9 @@ export declare function upsertReaction(data: {
162
162
  } & {
163
163
  type: import(".prisma/client").$Enums.ReactionType;
164
164
  id: string;
165
+ createdAt: Date;
165
166
  userId: string;
166
167
  announcementId: string | null;
167
- createdAt: Date;
168
168
  commentId: string | null;
169
169
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
170
170
  datasources: {
@@ -177,9 +177,9 @@ export declare function upsertReaction(data: {
177
177
  export declare function deleteReactionById(id: string): import(".prisma/client").Prisma.Prisma__ReactionClient<{
178
178
  type: import(".prisma/client").$Enums.ReactionType;
179
179
  id: string;
180
+ createdAt: Date;
180
181
  userId: string;
181
182
  announcementId: string | null;
182
- createdAt: Date;
183
183
  commentId: string | null;
184
184
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
185
185
  datasources: {
@@ -196,10 +196,10 @@ export declare function findCommentWithAnnouncement(commentId: string): import("
196
196
  } & {
197
197
  status: import(".prisma/client").$Enums.GenerationStatus | null;
198
198
  id: string;
199
+ createdAt: Date;
199
200
  assignmentId: string | null;
200
201
  submissionId: string | null;
201
202
  announcementId: string | null;
202
- createdAt: Date;
203
203
  modifiedAt: Date | null;
204
204
  content: string;
205
205
  authorId: string;
@@ -214,124 +214,188 @@ export declare function findCommentWithAnnouncement(commentId: string): import("
214
214
  }>;
215
215
  /** @returns Comment with the owning class context for authorization. */
216
216
  export declare function findCommentWithContext(commentId: string): import(".prisma/client").Prisma.Prisma__CommentClient<({
217
- studentQuestionProgress: {
218
- studentId: string;
219
- studentWorksheetResponse: {
220
- submission: {
221
- studentId: string;
222
- assignment: {
223
- class: {
224
- id: string;
225
- students: {
226
- id: string;
227
- }[];
228
- teachers: {
229
- id: string;
230
- }[];
231
- };
232
- };
217
+ assignment: {
218
+ class: {
219
+ school: {
220
+ users: {
221
+ id: string;
222
+ }[];
223
+ memberships: {
224
+ userId: string;
225
+ }[];
233
226
  } | null;
234
- } | null;
227
+ id: string;
228
+ teachers: {
229
+ id: string;
230
+ }[];
231
+ students: {
232
+ id: string;
233
+ }[];
234
+ };
235
235
  } | null;
236
236
  submission: {
237
- studentId: string;
238
237
  assignment: {
239
238
  class: {
239
+ school: {
240
+ users: {
241
+ id: string;
242
+ }[];
243
+ memberships: {
244
+ userId: string;
245
+ }[];
246
+ } | null;
240
247
  id: string;
241
- students: {
248
+ teachers: {
242
249
  id: string;
243
250
  }[];
244
- teachers: {
251
+ students: {
245
252
  id: string;
246
253
  }[];
247
254
  };
248
255
  };
256
+ studentId: string;
249
257
  } | null;
250
- assignment: {
258
+ announcement: {
251
259
  class: {
260
+ school: {
261
+ users: {
262
+ id: string;
263
+ }[];
264
+ memberships: {
265
+ userId: string;
266
+ }[];
267
+ } | null;
252
268
  id: string;
253
- students: {
254
- id: string;
255
- }[];
256
269
  teachers: {
257
270
  id: string;
258
271
  }[];
259
- };
260
- } | null;
261
- announcement: {
262
- class: {
263
- id: string;
264
272
  students: {
265
273
  id: string;
266
274
  }[];
267
- teachers: {
268
- id: string;
269
- }[];
270
275
  };
271
276
  } | null;
272
- parentComment: ({
273
- studentQuestionProgress: {
274
- studentId: string;
275
- studentWorksheetResponse: {
276
- submission: {
277
- studentId: string;
278
- assignment: {
279
- class: {
280
- id: string;
281
- students: {
277
+ studentQuestionProgress: {
278
+ studentId: string;
279
+ studentWorksheetResponse: {
280
+ submission: {
281
+ assignment: {
282
+ class: {
283
+ school: {
284
+ users: {
282
285
  id: string;
283
286
  }[];
284
- teachers: {
285
- id: string;
287
+ memberships: {
288
+ userId: string;
286
289
  }[];
287
- };
290
+ } | null;
291
+ id: string;
292
+ teachers: {
293
+ id: string;
294
+ }[];
295
+ students: {
296
+ id: string;
297
+ }[];
288
298
  };
289
- } | null;
299
+ };
300
+ studentId: string;
290
301
  } | null;
291
302
  } | null;
303
+ } | null;
304
+ parentComment: ({
305
+ assignment: {
306
+ class: {
307
+ school: {
308
+ users: {
309
+ id: string;
310
+ }[];
311
+ memberships: {
312
+ userId: string;
313
+ }[];
314
+ } | null;
315
+ id: string;
316
+ teachers: {
317
+ id: string;
318
+ }[];
319
+ students: {
320
+ id: string;
321
+ }[];
322
+ };
323
+ } | null;
292
324
  submission: {
293
- studentId: string;
294
325
  assignment: {
295
326
  class: {
327
+ school: {
328
+ users: {
329
+ id: string;
330
+ }[];
331
+ memberships: {
332
+ userId: string;
333
+ }[];
334
+ } | null;
296
335
  id: string;
297
- students: {
336
+ teachers: {
298
337
  id: string;
299
338
  }[];
300
- teachers: {
339
+ students: {
301
340
  id: string;
302
341
  }[];
303
342
  };
304
343
  };
344
+ studentId: string;
305
345
  } | null;
306
- assignment: {
346
+ announcement: {
307
347
  class: {
348
+ school: {
349
+ users: {
350
+ id: string;
351
+ }[];
352
+ memberships: {
353
+ userId: string;
354
+ }[];
355
+ } | null;
308
356
  id: string;
309
- students: {
310
- id: string;
311
- }[];
312
357
  teachers: {
313
358
  id: string;
314
359
  }[];
315
- };
316
- } | null;
317
- announcement: {
318
- class: {
319
- id: string;
320
360
  students: {
321
361
  id: string;
322
362
  }[];
323
- teachers: {
324
- id: string;
325
- }[];
326
363
  };
327
364
  } | null;
365
+ studentQuestionProgress: {
366
+ studentId: string;
367
+ studentWorksheetResponse: {
368
+ submission: {
369
+ assignment: {
370
+ class: {
371
+ school: {
372
+ users: {
373
+ id: string;
374
+ }[];
375
+ memberships: {
376
+ userId: string;
377
+ }[];
378
+ } | null;
379
+ id: string;
380
+ teachers: {
381
+ id: string;
382
+ }[];
383
+ students: {
384
+ id: string;
385
+ }[];
386
+ };
387
+ };
388
+ studentId: string;
389
+ } | null;
390
+ } | null;
391
+ } | null;
328
392
  } & {
329
393
  status: import(".prisma/client").$Enums.GenerationStatus | null;
330
394
  id: string;
395
+ createdAt: Date;
331
396
  assignmentId: string | null;
332
397
  submissionId: string | null;
333
398
  announcementId: string | null;
334
- createdAt: Date;
335
399
  modifiedAt: Date | null;
336
400
  content: string;
337
401
  authorId: string;
@@ -341,10 +405,10 @@ export declare function findCommentWithContext(commentId: string): import(".pris
341
405
  } & {
342
406
  status: import(".prisma/client").$Enums.GenerationStatus | null;
343
407
  id: string;
408
+ createdAt: Date;
344
409
  assignmentId: string | null;
345
410
  submissionId: string | null;
346
411
  announcementId: string | null;
347
- createdAt: Date;
348
412
  modifiedAt: Date | null;
349
413
  content: string;
350
414
  authorId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"comment.d.ts","sourceRoot":"/","sources":["models/comment.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChB,CAAC;AAEX,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKzC;AAED,qCAAqC;AACrC,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;MAmBvD;AAED,gCAAgC;AAChC,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;;;;;;;;;;;;;;;;;;GAIA;AAED,6CAA6C;AAC7C,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;GAM7E;AAED,2CAA2C;AAC3C,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,E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AAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;;;;;;;;;;;;;;;;;;GAIA;AAED,6CAA6C;AAC7C,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;GAM7E;AAED,2CAA2C;AAC3C,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;;;;;;;;;;;;;;;;;;;;;;;GA0BA;AAED,yBAAyB;AACzB,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;GAI5C;AAED,kDAAkD;AAClD,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;GAO5D;AAED,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGvD;AAED,sDAAsD;AACtD,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM;;;;;;;;GAM7D"}
@@ -2,7 +2,7 @@
2
2
  * Comment model – comments, replies, and reactions.
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]="f7121ae4-2705-5c41-8439-e02632b5f35c")}catch(e){}}();
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]="4e10262a-c8cd-5388-9b97-3cf8d34902b6")}catch(e){}}();
6
6
  import { prisma } from "../lib/prisma.js";
7
7
  export const commentSelect = {
8
8
  id: true,
@@ -45,6 +45,26 @@ export const commentSelect = {
45
45
  },
46
46
  },
47
47
  };
48
+ const commentClassAuthSelect = {
49
+ id: true,
50
+ teachers: { select: { id: true } },
51
+ students: { select: { id: true } },
52
+ school: {
53
+ select: {
54
+ users: {
55
+ where: { role: "ADMIN" },
56
+ select: { id: true },
57
+ },
58
+ memberships: {
59
+ where: {
60
+ role: "ADMIN",
61
+ status: "ACTIVE",
62
+ },
63
+ select: { userId: true },
64
+ },
65
+ },
66
+ },
67
+ };
48
68
  /** @returns Comment by ID with author and reactions. */
49
69
  export function findCommentById(id) {
50
70
  return prisma.comment.findUnique({
@@ -138,22 +158,14 @@ export function findCommentWithContext(commentId) {
138
158
  announcement: {
139
159
  select: {
140
160
  class: {
141
- select: {
142
- id: true,
143
- teachers: { select: { id: true } },
144
- students: { select: { id: true } },
145
- },
161
+ select: commentClassAuthSelect,
146
162
  },
147
163
  },
148
164
  },
149
165
  assignment: {
150
166
  select: {
151
167
  class: {
152
- select: {
153
- id: true,
154
- teachers: { select: { id: true } },
155
- students: { select: { id: true } },
156
- },
168
+ select: commentClassAuthSelect,
157
169
  },
158
170
  },
159
171
  },
@@ -163,11 +175,7 @@ export function findCommentWithContext(commentId) {
163
175
  assignment: {
164
176
  select: {
165
177
  class: {
166
- select: {
167
- id: true,
168
- teachers: { select: { id: true } },
169
- students: { select: { id: true } },
170
- },
178
+ select: commentClassAuthSelect,
171
179
  },
172
180
  },
173
181
  },
@@ -184,11 +192,7 @@ export function findCommentWithContext(commentId) {
184
192
  assignment: {
185
193
  select: {
186
194
  class: {
187
- select: {
188
- id: true,
189
- teachers: { select: { id: true } },
190
- students: { select: { id: true } },
191
- },
195
+ select: commentClassAuthSelect,
192
196
  },
193
197
  },
194
198
  },
@@ -203,22 +207,14 @@ export function findCommentWithContext(commentId) {
203
207
  announcement: {
204
208
  select: {
205
209
  class: {
206
- select: {
207
- id: true,
208
- teachers: { select: { id: true } },
209
- students: { select: { id: true } },
210
- },
210
+ select: commentClassAuthSelect,
211
211
  },
212
212
  },
213
213
  },
214
214
  assignment: {
215
215
  select: {
216
216
  class: {
217
- select: {
218
- id: true,
219
- teachers: { select: { id: true } },
220
- students: { select: { id: true } },
221
- },
217
+ select: commentClassAuthSelect,
222
218
  },
223
219
  },
224
220
  },
@@ -228,11 +224,7 @@ export function findCommentWithContext(commentId) {
228
224
  assignment: {
229
225
  select: {
230
226
  class: {
231
- select: {
232
- id: true,
233
- teachers: { select: { id: true } },
234
- students: { select: { id: true } },
235
- },
227
+ select: commentClassAuthSelect,
236
228
  },
237
229
  },
238
230
  },
@@ -249,11 +241,7 @@ export function findCommentWithContext(commentId) {
249
241
  assignment: {
250
242
  select: {
251
243
  class: {
252
- select: {
253
- id: true,
254
- teachers: { select: { id: true } },
255
- students: { select: { id: true } },
256
- },
244
+ select: commentClassAuthSelect,
257
245
  },
258
246
  },
259
247
  },
@@ -277,4 +265,4 @@ export function getReactionCountsByCommentId(commentId) {
277
265
  });
278
266
  }
279
267
  //# sourceMappingURL=comment.js.map
280
- //# debugId=f7121ae4-2705-5c41-8439-e02632b5f35c
268
+ //# debugId=4e10262a-c8cd-5388-9b97-3cf8d34902b6
@@ -1 +1 @@
1
- {"version":3,"file":"comment.js","sources":["models/comment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Comment model – comments, replies, and reactions.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport type { ReactionType } from \"@prisma/client\";\n\nexport const commentSelect = {\n id: true,\n content: true,\n announcementId: true,\n assignmentId: true,\n submissionId: true,\n parentCommentId: true,\n createdAt: true,\n modifiedAt: true,\n author: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n reactions: {\n select: {\n type: true,\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n },\n },\n} as const;\n\n/** @returns Comment by ID with author and reactions. */\nexport function findCommentById(id: string) {\n return prisma.comment.findUnique({\n where: { id },\n select: commentSelect,\n });\n}\n\n/** @returns Replies to a comment. */\nexport function findRepliesByCommentId(commentId: string) {\n return prisma.comment.findMany({\n where: { parentCommentId: commentId },\n include: {\n author: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n },\n });\n}\n\n/** Create a comment (reply). */\nexport function createComment(data: {\n parentCommentId: string;\n content: string;\n authorId: string;\n announcementId?: string | null;\n assignmentId?: string | null;\n submissionId?: string | null;\n studentQuestionProgressId?: string | null;\n}) {\n return prisma.comment.create({\n data,\n });\n}\n\n/** @returns User's reaction on a comment. */\nexport function findReactionByUserAndComment(userId: string, commentId: string) {\n return prisma.reaction.findUnique({\n where: {\n userId_commentId: { userId, commentId },\n },\n });\n}\n\n/** Add or update reaction on a comment. */\nexport function upsertReaction(data: {\n userId: string;\n commentId: string;\n type: string;\n}) {\n return prisma.reaction.upsert({\n where: {\n userId_commentId: {\n userId: data.userId,\n commentId: data.commentId,\n },\n },\n update: { type: data.type as ReactionType },\n create: { ...data, type: data.type as ReactionType },\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n },\n });\n}\n\n/** Delete a reaction. */\nexport function deleteReactionById(id: string) {\n return prisma.reaction.delete({\n where: { id },\n });\n}\n\n/** @returns Comment with announcement classId. */\nexport function findCommentWithAnnouncement(commentId: string) {\n return prisma.comment.findUnique({\n where: { id: commentId },\n include: {\n announcement: { select: { classId: true } },\n },\n });\n}\n\n/** @returns Comment with the owning class context for authorization. */\nexport function findCommentWithContext(commentId: string) {\n return prisma.comment.findUnique({\n where: { id: commentId },\n include: {\n announcement: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n assignment: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n },\n },\n studentQuestionProgress: {\n select: {\n studentId: true,\n studentWorksheetResponse: {\n select: {\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n parentComment: {\n include: {\n announcement: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n assignment: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n },\n },\n studentQuestionProgress: {\n select: {\n studentId: true,\n studentWorksheetResponse: {\n select: {\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n });\n}\n\n/** @returns Reaction counts by type for a comment. */\nexport function getReactionCountsByCommentId(commentId: string) {\n return prisma.reaction.groupBy({\n by: [\"type\"],\n where: { commentId },\n _count: { type: true },\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,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AAE;wBACV,MAAM,EAAE;4BACN,SAAS,EAAE,IAAI;4BACf,UAAU,EAAE;gCACV,MAAM,EAAE;oCACN,KAAK,EAAE;wCACL,MAAM,EAAE;4CACN,EAAE,EAAE,IAAI;4CACR,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;4CAClC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;yCACnC;qCACF;iCACF;6BACF;yBACF;qBACF;oBACD,uBAAuB,EAAE;wBACvB,MAAM,EAAE;4BACN,SAAS,EAAE,IAAI;4BACf,wBAAwB,EAAE;gCACxB,MAAM,EAAE;oCACN,UAAU,EAAE;wCACV,MAAM,EAAE;4CACN,SAAS,EAAE,IAAI;4CACf,UAAU,EAAE;gDACV,MAAM,EAAE;oDACN,KAAK,EAAE;wDACL,MAAM,EAAE;4DACN,EAAE,EAAE,IAAI;4DACR,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;4DAClC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;yDACnC;qDACF;iDACF;6CACF;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,4BAA4B,CAAC,SAAiB;IAC5D,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC7B,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,KAAK,EAAE,EAAE,SAAS,EAAE;QACpB,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KACvB,CAAC,CAAC;AACL,CAAC","debug_id":"f7121ae4-2705-5c41-8439-e02632b5f35c"}
1
+ {"version":3,"file":"comment.js","sources":["models/comment.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Comment model – comments, replies, and reactions.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport type { ReactionType } from \"@prisma/client\";\n\nexport const commentSelect = {\n id: true,\n content: true,\n announcementId: true,\n assignmentId: true,\n submissionId: true,\n parentCommentId: true,\n createdAt: true,\n modifiedAt: true,\n author: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n reactions: {\n select: {\n type: true,\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n },\n },\n} as const;\n\nconst commentClassAuthSelect = {\n id: true,\n teachers: { select: { id: true } },\n students: { select: { id: true } },\n school: {\n select: {\n users: {\n where: { role: \"ADMIN\" as const },\n select: { id: true },\n },\n memberships: {\n where: {\n role: \"ADMIN\" as const,\n status: \"ACTIVE\" as const,\n },\n select: { userId: true },\n },\n },\n },\n} as const;\n\n/** @returns Comment by ID with author and reactions. */\nexport function findCommentById(id: string) {\n return prisma.comment.findUnique({\n where: { id },\n select: commentSelect,\n });\n}\n\n/** @returns Replies to a comment. */\nexport function findRepliesByCommentId(commentId: string) {\n return prisma.comment.findMany({\n where: { parentCommentId: commentId },\n include: {\n author: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n },\n });\n}\n\n/** Create a comment (reply). */\nexport function createComment(data: {\n parentCommentId: string;\n content: string;\n authorId: string;\n announcementId?: string | null;\n assignmentId?: string | null;\n submissionId?: string | null;\n studentQuestionProgressId?: string | null;\n}) {\n return prisma.comment.create({\n data,\n });\n}\n\n/** @returns User's reaction on a comment. */\nexport function findReactionByUserAndComment(userId: string, commentId: string) {\n return prisma.reaction.findUnique({\n where: {\n userId_commentId: { userId, commentId },\n },\n });\n}\n\n/** Add or update reaction on a comment. */\nexport function upsertReaction(data: {\n userId: string;\n commentId: string;\n type: string;\n}) {\n return prisma.reaction.upsert({\n where: {\n userId_commentId: {\n userId: data.userId,\n commentId: data.commentId,\n },\n },\n update: { type: data.type as ReactionType },\n create: { ...data, type: data.type as ReactionType },\n include: {\n user: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n },\n },\n },\n });\n}\n\n/** Delete a reaction. */\nexport function deleteReactionById(id: string) {\n return prisma.reaction.delete({\n where: { id },\n });\n}\n\n/** @returns Comment with announcement classId. */\nexport function findCommentWithAnnouncement(commentId: string) {\n return prisma.comment.findUnique({\n where: { id: commentId },\n include: {\n announcement: { select: { classId: true } },\n },\n });\n}\n\n/** @returns Comment with the owning class context for authorization. */\nexport function findCommentWithContext(commentId: string) {\n return prisma.comment.findUnique({\n where: { id: commentId },\n include: {\n announcement: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n assignment: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n },\n },\n studentQuestionProgress: {\n select: {\n studentId: true,\n studentWorksheetResponse: {\n select: {\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n },\n },\n },\n },\n },\n },\n parentComment: {\n include: {\n announcement: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n assignment: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n },\n },\n studentQuestionProgress: {\n select: {\n studentId: true,\n studentWorksheetResponse: {\n select: {\n submission: {\n select: {\n studentId: true,\n assignment: {\n select: {\n class: {\n select: commentClassAuthSelect,\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n },\n });\n}\n\n/** @returns Reaction counts by type for a comment. */\nexport function getReactionCountsByCommentId(commentId: string) {\n return prisma.reaction.groupBy({\n by: [\"type\"],\n where: { commentId },\n _count: { type: true },\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,EAAE,EAAE,IAAI;IACR,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,IAAI;IACrB,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE;QACN,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,MAAM,EAAE;oBACN,WAAW,EAAE,IAAI;oBACjB,cAAc,EAAE,IAAI;oBACpB,uBAAuB,EAAE,IAAI;iBAC9B;aACF;SACF;KACF;IACD,SAAS,EAAE;QACT,MAAM,EAAE;YACN,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACJ,MAAM,EAAE;oBACN,EAAE,EAAE,IAAI;oBACR,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE;wBACP,MAAM,EAAE;4BACN,WAAW,EAAE,IAAI;4BACjB,cAAc,EAAE,IAAI;4BACpB,uBAAuB,EAAE,IAAI;yBAC9B;qBACF;iBACF;aACF;SACF;KACF;CACO,CAAC;AAEX,MAAM,sBAAsB,GAAG;IAC7B,EAAE,EAAE,IAAI;IACR,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IAClC,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IAClC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,KAAK,EAAE;gBACL,KAAK,EAAE,EAAE,IAAI,EAAE,OAAgB,EAAE;gBACjC,MAAM,EAAE,EAAE,EAAE,E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N,KAAK,EAAE;wDACL,MAAM,EAAE,sBAAsB;qDAC/B;iDACF;6CACF;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,4BAA4B,CAAC,SAAiB;IAC5D,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC7B,EAAE,EAAE,CAAC,MAAM,CAAC;QACZ,KAAK,EAAE,EAAE,SAAS,EAAE;QACpB,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;KACvB,CAAC,CAAC;AACL,CAAC","debug_id":"4e10262a-c8cd-5388-9b97-3cf8d34902b6"}
@@ -15,9 +15,9 @@ export declare function findConversationsByUserId(userId: string): import(".pris
15
15
  };
16
16
  } & {
17
17
  id: string;
18
+ role: import(".prisma/client").$Enums.ConversationRole;
18
19
  userId: string;
19
20
  conversationId: string;
20
- role: import(".prisma/client").$Enums.ConversationRole;
21
21
  joinedAt: Date;
22
22
  hiddenAt: Date | null;
23
23
  lastViewedAt: Date | null;
@@ -35,8 +35,8 @@ export declare function findConversationsByUserId(userId: string): import(".pris
35
35
  status: import(".prisma/client").$Enums.GenerationStatus | null;
36
36
  meta: import("@prisma/client/runtime/library.js").JsonValue | null;
37
37
  id: string;
38
- conversationId: string;
39
38
  createdAt: Date;
39
+ conversationId: string;
40
40
  content: string;
41
41
  senderId: string;
42
42
  })[];
@@ -101,9 +101,9 @@ export declare function createConversation(data: {
101
101
  };
102
102
  } & {
103
103
  id: string;
104
+ role: import(".prisma/client").$Enums.ConversationRole;
104
105
  userId: string;
105
106
  conversationId: string;
106
- role: import(".prisma/client").$Enums.ConversationRole;
107
107
  joinedAt: Date;
108
108
  hiddenAt: Date | null;
109
109
  lastViewedAt: Date | null;
@@ -136,9 +136,9 @@ export declare function findConversationByIdAndMember(conversationId: string, us
136
136
  };
137
137
  } & {
138
138
  id: string;
139
+ role: import(".prisma/client").$Enums.ConversationRole;
139
140
  userId: string;
140
141
  conversationId: string;
141
- role: import(".prisma/client").$Enums.ConversationRole;
142
142
  joinedAt: Date;
143
143
  hiddenAt: Date | null;
144
144
  lastViewedAt: Date | null;
@@ -165,9 +165,9 @@ export declare function createConversationMember(data: {
165
165
  role: string;
166
166
  }): import(".prisma/client").Prisma.Prisma__ConversationMemberClient<{
167
167
  id: string;
168
+ role: import(".prisma/client").$Enums.ConversationRole;
168
169
  userId: string;
169
170
  conversationId: string;
170
- role: import(".prisma/client").$Enums.ConversationRole;
171
171
  joinedAt: Date;
172
172
  hiddenAt: Date | null;
173
173
  lastViewedAt: Date | null;
@@ -182,9 +182,9 @@ export declare function createConversationMember(data: {
182
182
  /** Hide a conversation for a single member until new activity occurs. */
183
183
  export declare function hideConversationMember(userId: string, conversationId: string): import(".prisma/client").Prisma.Prisma__ConversationMemberClient<{
184
184
  id: string;
185
+ role: import(".prisma/client").$Enums.ConversationRole;
185
186
  userId: string;
186
187
  conversationId: string;
187
- role: import(".prisma/client").$Enums.ConversationRole;
188
188
  joinedAt: Date;
189
189
  hiddenAt: Date | null;
190
190
  lastViewedAt: Date | null;
@@ -199,9 +199,9 @@ export declare function hideConversationMember(userId: string, conversationId: s
199
199
  /** Remove a member from a conversation. */
200
200
  export declare function deleteConversationMember(userId: string, conversationId: string): import(".prisma/client").Prisma.Prisma__ConversationMemberClient<{
201
201
  id: string;
202
+ role: import(".prisma/client").$Enums.ConversationRole;
202
203
  userId: string;
203
204
  conversationId: string;
204
- role: import(".prisma/client").$Enums.ConversationRole;
205
205
  joinedAt: Date;
206
206
  hiddenAt: Date | null;
207
207
  lastViewedAt: Date | null;