@studious-lms/server 1.4.6 → 1.4.7

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 (148) hide show
  1. package/dist/models/access.d.ts +112 -0
  2. package/dist/models/access.d.ts.map +1 -0
  3. package/dist/models/access.js +49 -0
  4. package/dist/models/access.js.map +1 -0
  5. package/dist/models/announcement.d.ts +17 -2
  6. package/dist/models/announcement.d.ts.map +1 -1
  7. package/dist/models/announcement.js +21 -4
  8. package/dist/models/announcement.js.map +1 -1
  9. package/dist/models/assignment.d.ts +37 -37
  10. package/dist/models/assignment.d.ts.map +1 -1
  11. package/dist/models/assignment.js +15 -15
  12. package/dist/models/assignment.js.map +1 -1
  13. package/dist/models/attendance.d.ts +1 -1
  14. package/dist/models/attendance.d.ts.map +1 -1
  15. package/dist/models/attendance.js +6 -5
  16. package/dist/models/attendance.js.map +1 -1
  17. package/dist/models/auth.d.ts +5 -5
  18. package/dist/models/auth.d.ts.map +1 -1
  19. package/dist/models/auth.js +7 -11
  20. package/dist/models/auth.js.map +1 -1
  21. package/dist/models/class.d.ts +26 -26
  22. package/dist/models/class.d.ts.map +1 -1
  23. package/dist/models/class.js +7 -11
  24. package/dist/models/class.js.map +1 -1
  25. package/dist/models/comment.d.ts +134 -70
  26. package/dist/models/comment.d.ts.map +1 -1
  27. package/dist/models/comment.js +30 -42
  28. package/dist/models/comment.js.map +1 -1
  29. package/dist/models/conversation.d.ts +7 -7
  30. package/dist/models/event.d.ts +52 -3
  31. package/dist/models/event.d.ts.map +1 -1
  32. package/dist/models/event.js +56 -6
  33. package/dist/models/event.js.map +1 -1
  34. package/dist/models/file.d.ts +178 -103
  35. package/dist/models/file.d.ts.map +1 -1
  36. package/dist/models/file.js +54 -14
  37. package/dist/models/file.js.map +1 -1
  38. package/dist/models/folder.d.ts +22 -22
  39. package/dist/models/folder.d.ts.map +1 -1
  40. package/dist/models/folder.js +5 -4
  41. package/dist/models/folder.js.map +1 -1
  42. package/dist/models/labChat.d.ts +20 -20
  43. package/dist/models/labChat.d.ts.map +1 -1
  44. package/dist/models/labChat.js +8 -10
  45. package/dist/models/labChat.js.map +1 -1
  46. package/dist/models/marketing.d.ts +1 -1
  47. package/dist/models/message.d.ts +6 -6
  48. package/dist/models/newtonChat.d.ts +5 -5
  49. package/dist/models/school.d.ts +361 -0
  50. package/dist/models/school.d.ts.map +1 -0
  51. package/dist/models/school.js +314 -0
  52. package/dist/models/school.js.map +1 -0
  53. package/dist/models/section.d.ts +1 -1
  54. package/dist/models/section.d.ts.map +1 -1
  55. package/dist/models/section.js +5 -4
  56. package/dist/models/section.js.map +1 -1
  57. package/dist/models/user.d.ts +4 -4
  58. package/dist/models/worksheet.d.ts +65 -65
  59. package/dist/models/worksheet.d.ts.map +1 -1
  60. package/dist/models/worksheet.js +6 -14
  61. package/dist/models/worksheet.js.map +1 -1
  62. package/dist/pipelines/gradeWorksheet.d.ts +2 -2
  63. package/dist/pipelines/pdfToWorksheet.d.ts +1 -1
  64. package/dist/routers/_app.d.ts +2855 -2051
  65. package/dist/routers/_app.d.ts.map +1 -1
  66. package/dist/routers/_app.js +4 -2
  67. package/dist/routers/_app.js.map +1 -1
  68. package/dist/routers/announcement.d.ts +5 -5
  69. package/dist/routers/announcement.d.ts.map +1 -1
  70. package/dist/routers/announcement.js +25 -5
  71. package/dist/routers/announcement.js.map +1 -1
  72. package/dist/routers/assignment.d.ts +44 -44
  73. package/dist/routers/assignment.d.ts.map +1 -1
  74. package/dist/routers/assignment.js +24 -11
  75. package/dist/routers/assignment.js.map +1 -1
  76. package/dist/routers/class.d.ts +21 -20
  77. package/dist/routers/class.d.ts.map +1 -1
  78. package/dist/routers/class.js +3 -2
  79. package/dist/routers/class.js.map +1 -1
  80. package/dist/routers/comment.d.ts +5 -5
  81. package/dist/routers/conversation.d.ts +6 -6
  82. package/dist/routers/event.d.ts +21 -2
  83. package/dist/routers/event.d.ts.map +1 -1
  84. package/dist/routers/file.d.ts +2 -2
  85. package/dist/routers/folder.d.ts +24 -24
  86. package/dist/routers/labChat.d.ts +7 -7
  87. package/dist/routers/school.d.ts +384 -0
  88. package/dist/routers/school.d.ts.map +1 -0
  89. package/dist/routers/school.js +79 -0
  90. package/dist/routers/school.js.map +1 -0
  91. package/dist/routers/search.d.ts +1 -1
  92. package/dist/routers/worksheet.d.ts +21 -21
  93. package/dist/services/announcement.d.ts.map +1 -1
  94. package/dist/services/announcement.js +10 -6
  95. package/dist/services/announcement.js.map +1 -1
  96. package/dist/services/assignment.d.ts +36 -36
  97. package/dist/services/class.d.ts +20 -19
  98. package/dist/services/class.d.ts.map +1 -1
  99. package/dist/services/class.js +22 -3
  100. package/dist/services/class.js.map +1 -1
  101. package/dist/services/comment.d.ts +5 -5
  102. package/dist/services/comment.d.ts.map +1 -1
  103. package/dist/services/comment.js +8 -3
  104. package/dist/services/comment.js.map +1 -1
  105. package/dist/services/conversation.d.ts +6 -6
  106. package/dist/services/event.d.ts +21 -2
  107. package/dist/services/event.d.ts.map +1 -1
  108. package/dist/services/event.js +11 -7
  109. package/dist/services/event.js.map +1 -1
  110. package/dist/services/file.d.ts +2 -2
  111. package/dist/services/file.d.ts.map +1 -1
  112. package/dist/services/file.js +17 -8
  113. package/dist/services/file.js.map +1 -1
  114. package/dist/services/folder.d.ts +24 -24
  115. package/dist/services/labChat.d.ts +7 -7
  116. package/dist/services/school.d.ts +299 -0
  117. package/dist/services/school.d.ts.map +1 -0
  118. package/dist/services/school.js +225 -0
  119. package/dist/services/school.js.map +1 -0
  120. package/dist/services/worksheet.d.ts +21 -21
  121. package/package.json +1 -1
  122. package/prisma/migrations/20260504071500_school_memberships/migration.sql +81 -0
  123. package/prisma/schema.prisma +66 -2
  124. package/src/models/access.ts +48 -0
  125. package/src/models/announcement.ts +19 -2
  126. package/src/models/assignment.ts +17 -13
  127. package/src/models/attendance.ts +4 -3
  128. package/src/models/auth.ts +8 -9
  129. package/src/models/class.ts +8 -9
  130. package/src/models/comment.ts +29 -40
  131. package/src/models/event.ts +54 -4
  132. package/src/models/file.ts +53 -12
  133. package/src/models/folder.ts +3 -2
  134. package/src/models/labChat.ts +9 -8
  135. package/src/models/school.ts +361 -0
  136. package/src/models/section.ts +3 -2
  137. package/src/models/worksheet.ts +7 -12
  138. package/src/routers/_app.ts +2 -0
  139. package/src/routers/announcement.ts +30 -4
  140. package/src/routers/assignment.ts +27 -9
  141. package/src/routers/class.ts +1 -0
  142. package/src/routers/school.ts +122 -0
  143. package/src/services/announcement.ts +12 -4
  144. package/src/services/class.ts +25 -2
  145. package/src/services/comment.ts +10 -1
  146. package/src/services/event.ts +23 -6
  147. package/src/services/file.ts +20 -6
  148. package/src/services/school.ts +308 -0
@@ -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,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,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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,EAA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;wCACV,MAAM,EAAE;4CACN,KAAK,EAAE;gDACL,MAAM,EAAE,sBAAsB;6CAC/B;yCACF;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;YACD,aAAa,EAAE;gBACb,OAAO,EAAE;oBACP,YAAY,EAAE;wBACZ,MAAM,EAAE;4BACN,KAAK,EAAE;gCACL,MAAM,EAAE,sBAAsB;6BAC/B;yBACF;qBACF;oBACD,UAAU,EAAE;wBACV,MAAM,EAAE;4BACN,KAAK,EAAE;gCACL,MAAM,EAAE,sBAAsB;6BAC/B;yBACF;qBACF;oBACD,UAAU,EAAE;wBACV,MAAM,EAAE;4BACN,SAAS,EAAE,IAAI;4BACf,UAAU,EAAE;gCACV,MAAM,EAAE;oCACN,KAAK,EAAE;wCACL,MAAM,EAAE,sBAAsB;qCAC/B;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,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;
@@ -9,7 +9,26 @@ export declare function findEventById(id: string): import(".prisma/client").Pris
9
9
  role: import(".prisma/client").$Enums.UserRole;
10
10
  schoolId: string | null;
11
11
  } | null;
12
- class: {
12
+ class: ({
13
+ school: ({
14
+ users: {
15
+ id: string;
16
+ }[];
17
+ memberships: {
18
+ userId: string;
19
+ }[];
20
+ } & {
21
+ name: string;
22
+ id: string;
23
+ logoId: string | null;
24
+ subdomain: string | null;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ }) | null;
28
+ teachers: {
29
+ id: string;
30
+ }[];
31
+ } & {
13
32
  name: string;
14
33
  id: string;
15
34
  schoolId: string | null;
@@ -17,7 +36,7 @@ export declare function findEventById(id: string): import(".prisma/client").Pris
17
36
  color: string | null;
18
37
  section: string;
19
38
  syllabus: string | null;
20
- } | null;
39
+ }) | null;
21
40
  assignmentsAttached: {
22
41
  type: import(".prisma/client").$Enums.AssignmentType;
23
42
  id: string;
@@ -58,7 +77,7 @@ export declare function findEventById(id: string): import(".prisma/client").Pris
58
77
  };
59
78
  };
60
79
  }>;
61
- /** @returns Class if user is a teacher. */
80
+ /** @returns Class if user is a teacher or school admin. */
62
81
  export declare function findClassWithTeachers(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
63
82
  name: string;
64
83
  id: string;
@@ -152,6 +171,21 @@ export declare function deleteEventById(id: string): import(".prisma/client").Pr
152
171
  /** @returns Event with class and teachers. */
153
172
  export declare function findEventWithClass(eventId: string): import(".prisma/client").Prisma.Prisma__EventClient<({
154
173
  class: ({
174
+ school: ({
175
+ users: {
176
+ id: string;
177
+ }[];
178
+ memberships: {
179
+ userId: string;
180
+ }[];
181
+ } & {
182
+ name: string;
183
+ id: string;
184
+ logoId: string | null;
185
+ subdomain: string | null;
186
+ createdAt: Date;
187
+ updatedAt: Date;
188
+ }) | null;
155
189
  teachers: {
156
190
  id: string;
157
191
  }[];
@@ -184,6 +218,21 @@ export declare function findEventWithClass(eventId: string): import(".prisma/cli
184
218
  /** @returns Assignment with class and teachers. */
185
219
  export declare function findAssignmentWithClass(assignmentId: string): import(".prisma/client").Prisma.Prisma__AssignmentClient<({
186
220
  class: {
221
+ school: ({
222
+ users: {
223
+ id: string;
224
+ }[];
225
+ memberships: {
226
+ userId: string;
227
+ }[];
228
+ } & {
229
+ name: string;
230
+ id: string;
231
+ logoId: string | null;
232
+ subdomain: string | null;
233
+ createdAt: Date;
234
+ updatedAt: Date;
235
+ }) | null;
187
236
  teachers: {
188
237
  id: string;
189
238
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"/","sources":["models/event.ts"],"names":[],"mappings":"AA4CA,mEAAmE;AACnE,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKvC;AAED,2CAA2C;AAC3C,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;GAOvE;AAED,+BAA+B;AAC/B,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAChC,IAA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AgB,kBAAkB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BjD;AAED,mDAAmD;AACnD,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0B3D;AAED,qCAAqC;AACrC,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAOhB;AAED,wCAAwC;AACxC,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAM7D;AAED,sDAAsD;AACtD,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;KAqB/D"}
@@ -2,10 +2,30 @@
2
2
  * Event model – calendar events, assignment attachment/detachment.
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]="77f54214-a354-5d29-87fa-c904eb74a338")}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]="cf3ed911-c40a-5919-97ae-6a9c13344647")}catch(e){}}();
6
6
  import { prisma } from "../lib/prisma.js";
7
+ import { classTeacherOrSchoolAdminWhere } from "./access.js";
7
8
  const eventGetInclude = {
8
- class: true,
9
+ class: {
10
+ include: {
11
+ teachers: { select: { id: true } },
12
+ school: {
13
+ include: {
14
+ users: {
15
+ where: { role: "ADMIN" },
16
+ select: { id: true },
17
+ },
18
+ memberships: {
19
+ where: {
20
+ role: "ADMIN",
21
+ status: "ACTIVE",
22
+ },
23
+ select: { userId: true },
24
+ },
25
+ },
26
+ },
27
+ },
28
+ },
9
29
  user: true,
10
30
  assignmentsAttached: {
11
31
  select: {
@@ -47,12 +67,12 @@ export function findEventById(id) {
47
67
  include: eventGetInclude,
48
68
  });
49
69
  }
50
- /** @returns Class if user is a teacher. */
70
+ /** @returns Class if user is a teacher or school admin. */
51
71
  export function findClassWithTeachers(classId, teacherId) {
52
- return prisma.class.findUnique({
72
+ return prisma.class.findFirst({
53
73
  where: {
54
74
  id: classId,
55
- teachers: { some: { id: teacherId } },
75
+ ...classTeacherOrSchoolAdminWhere(teacherId),
56
76
  },
57
77
  });
58
78
  }
@@ -84,6 +104,21 @@ export function findEventWithClass(eventId) {
84
104
  class: {
85
105
  include: {
86
106
  teachers: { select: { id: true } },
107
+ school: {
108
+ include: {
109
+ users: {
110
+ where: { role: "ADMIN" },
111
+ select: { id: true },
112
+ },
113
+ memberships: {
114
+ where: {
115
+ role: "ADMIN",
116
+ status: "ACTIVE",
117
+ },
118
+ select: { userId: true },
119
+ },
120
+ },
121
+ },
87
122
  },
88
123
  },
89
124
  },
@@ -97,6 +132,21 @@ export function findAssignmentWithClass(assignmentId) {
97
132
  class: {
98
133
  include: {
99
134
  teachers: { select: { id: true } },
135
+ school: {
136
+ include: {
137
+ users: {
138
+ where: { role: "ADMIN" },
139
+ select: { id: true },
140
+ },
141
+ memberships: {
142
+ where: {
143
+ role: "ADMIN",
144
+ status: "ACTIVE",
145
+ },
146
+ select: { userId: true },
147
+ },
148
+ },
149
+ },
100
150
  },
101
151
  },
102
152
  },
@@ -142,4 +192,4 @@ export function findAvailableAssignmentsForClass(classId) {
142
192
  });
143
193
  }
144
194
  //# sourceMappingURL=event.js.map
145
- //# debugId=77f54214-a354-5d29-87fa-c904eb74a338
195
+ //# debugId=cf3ed911-c40a-5919-97ae-6a9c13344647
@@ -1 +1 @@
1
- {"version":3,"file":"event.js","sources":["models/event.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Event model – calendar events, assignment attachment/detachment.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst eventGetInclude = {\n class: true,\n user: true,\n assignmentsAttached: {\n select: {\n id: true,\n title: true,\n instructions: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n weight: true,\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n },\n },\n};\n\nconst eventCreateSelect = {\n id: true,\n name: true,\n location: true,\n remarks: true,\n startTime: true,\n endTime: true,\n color: true,\n classId: true,\n userId: true,\n class: { select: { id: true, name: true } },\n};\n\nconst assignmentUpdateInclude = {\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n};\n\n/** @returns Event by ID with class, user, attached assignments. */\nexport function findEventById(id: string) {\n return prisma.event.findUnique({\n where: { id },\n include: eventGetInclude,\n });\n}\n\n/** @returns Class if user is a teacher. */\nexport function findClassWithTeachers(classId: string, teacherId: string) {\n return prisma.class.findUnique({\n where: {\n id: classId,\n teachers: { some: { id: teacherId } },\n },\n });\n}\n\n/** Create a calendar event. */\nexport function createEvent(data: {\n name?: string;\n location?: string;\n remarks?: string;\n startTime: Date;\n endTime: Date;\n userId: string;\n color?: string;\n classId?: string;\n}) {\n return prisma.event.create({\n data,\n select: eventCreateSelect,\n });\n}\n\n/** Update an event. */\nexport function updateEvent(\n id: string,\n data: {\n name?: string;\n location?: string;\n remarks?: string;\n startTime?: Date;\n endTime?: Date;\n color?: string;\n classId?: string;\n }\n) {\n return prisma.event.update({\n where: { id },\n data,\n });\n}\n\n/** Delete an event. */\nexport function deleteEventById(id: string) {\n return prisma.event.delete({\n where: { id },\n });\n}\n\n/** @returns Event with class and teachers. */\nexport function findEventWithClass(eventId: string) {\n return prisma.event.findUnique({\n where: { id: eventId },\n include: {\n class: {\n include: {\n teachers: { select: { id: true } },\n },\n },\n },\n });\n}\n\n/** @returns Assignment with class and teachers. */\nexport function findAssignmentWithClass(assignmentId: string) {\n return prisma.assignment.findUnique({\n where: { id: assignmentId },\n include: {\n class: {\n include: {\n teachers: { select: { id: true } },\n },\n },\n },\n });\n}\n\n/** Attach assignment to an event. */\nexport function attachAssignmentToEvent(\n assignmentId: string,\n eventId: string\n) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { connect: { id: eventId } } },\n include: assignmentUpdateInclude,\n });\n}\n\n/** Detach assignment from its event. */\nexport function detachAssignmentFromEvent(assignmentId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { disconnect: true } },\n include: assignmentUpdateInclude,\n });\n}\n\n/** @returns Assignments not attached to any event. */\nexport function findAvailableAssignmentsForClass(classId: string) {\n return prisma.assignment.findMany({\n where: {\n classId,\n eventId: null,\n },\n select: {\n id: true,\n title: true,\n instructions: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n weight: true,\n section: { select: { id: true, name: true } },\n attachments: { select: { id: true, name: true, type: true } },\n teacher: { select: { id: true, username: true } },\n },\n orderBy: { createdAt: \"desc\" },\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,IAAI;IACV,mBAAmB,EAAE;QACnB,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,IAAI;YAClB,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IA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IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YAC7D,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;SAClD;QACD,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;KAC/B,CAAC,CAAC;AACL,CAAC","debug_id":"77f54214-a354-5d29-87fa-c904eb74a338"}
1
+ {"version":3,"file":"event.js","sources":["models/event.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Event model – calendar events, assignment attachment/detachment.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport { classTeacherOrSchoolAdminWhere } from \"./access.js\";\n\nconst eventGetInclude = {\n class: {\n include: {\n teachers: { select: { id: true } },\n school: {\n include: {\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 },\n },\n user: true,\n assignmentsAttached: {\n select: {\n id: true,\n title: true,\n instructions: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n weight: true,\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n },\n },\n};\n\nconst eventCreateSelect = {\n id: true,\n name: true,\n location: true,\n remarks: true,\n startTime: true,\n endTime: true,\n color: true,\n classId: true,\n userId: true,\n class: { select: { id: true, name: true } },\n};\n\nconst assignmentUpdateInclude = {\n attachments: { select: { id: true, name: true, type: true } },\n section: { select: { id: true, name: true } },\n teacher: { select: { id: true, username: true } },\n};\n\n/** @returns Event by ID with class, user, attached assignments. */\nexport function findEventById(id: string) {\n return prisma.event.findUnique({\n where: { id },\n include: eventGetInclude,\n });\n}\n\n/** @returns Class if user is a teacher or school admin. */\nexport function findClassWithTeachers(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(teacherId),\n },\n });\n}\n\n/** Create a calendar event. */\nexport function createEvent(data: {\n name?: string;\n location?: string;\n remarks?: string;\n startTime: Date;\n endTime: Date;\n userId: string;\n color?: string;\n classId?: string;\n}) {\n return prisma.event.create({\n data,\n select: eventCreateSelect,\n });\n}\n\n/** Update an event. */\nexport function updateEvent(\n id: string,\n data: {\n name?: string;\n location?: string;\n remarks?: string;\n startTime?: Date;\n endTime?: Date;\n color?: string;\n classId?: string;\n }\n) {\n return prisma.event.update({\n where: { id },\n data,\n });\n}\n\n/** Delete an event. */\nexport function deleteEventById(id: string) {\n return prisma.event.delete({\n where: { id },\n });\n}\n\n/** @returns Event with class and teachers. */\nexport function findEventWithClass(eventId: string) {\n return prisma.event.findUnique({\n where: { id: eventId },\n include: {\n class: {\n include: {\n teachers: { select: { id: true } },\n school: {\n include: {\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 },\n },\n },\n });\n}\n\n/** @returns Assignment with class and teachers. */\nexport function findAssignmentWithClass(assignmentId: string) {\n return prisma.assignment.findUnique({\n where: { id: assignmentId },\n include: {\n class: {\n include: {\n teachers: { select: { id: true } },\n school: {\n include: {\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 },\n },\n },\n });\n}\n\n/** Attach assignment to an event. */\nexport function attachAssignmentToEvent(\n assignmentId: string,\n eventId: string\n) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { connect: { id: eventId } } },\n include: assignmentUpdateInclude,\n });\n}\n\n/** Detach assignment from its event. */\nexport function detachAssignmentFromEvent(assignmentId: string) {\n return prisma.assignment.update({\n where: { id: assignmentId },\n data: { eventAttached: { disconnect: true } },\n include: assignmentUpdateInclude,\n });\n}\n\n/** @returns Assignments not attached to any event. */\nexport function findAvailableAssignmentsForClass(classId: string) {\n return prisma.assignment.findMany({\n where: {\n classId,\n eventId: null,\n },\n select: {\n id: true,\n title: true,\n instructions: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n weight: true,\n section: { select: { id: true, name: true } },\n attachments: { select: { id: true, name: true, type: true } },\n teacher: { select: { id: true, username: true } },\n },\n orderBy: { createdAt: \"desc\" },\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE;QACL,OAAO,EAAE;YACP,QAAQ,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;YAClC,MAAM,EAAE;gBACN,OAAO,EAAE;oBACP,KAAK,EAAE;wBACL,KAAK,EAAE,EAAE,IAAI,EAAE,OAAgB,EAAE;wBACjC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE;qBACrB;oBACD,WAAW,EAAE;wBACX,KAAK,EAAE;4BACL,IAAI,EAAE,OAAgB;4BACtB,MAAM,EAAE,QAAiB;yBAC1B;wBACD,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;qBACzB;iBACF;aACF;SACF;KACF;IACD,IAAI,EAAE,IAAI;IACV,mBAAmB,EAAE;QACnB,MAAM,EAAE;YACN,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,IAAI;YAClB,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,E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