@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.
- package/dist/models/access.d.ts +112 -0
- package/dist/models/access.d.ts.map +1 -0
- package/dist/models/access.js +49 -0
- package/dist/models/access.js.map +1 -0
- package/dist/models/announcement.d.ts +17 -2
- package/dist/models/announcement.d.ts.map +1 -1
- package/dist/models/announcement.js +21 -4
- package/dist/models/announcement.js.map +1 -1
- package/dist/models/assignment.d.ts +37 -37
- package/dist/models/assignment.d.ts.map +1 -1
- package/dist/models/assignment.js +15 -15
- package/dist/models/assignment.js.map +1 -1
- package/dist/models/attendance.d.ts +1 -1
- package/dist/models/attendance.d.ts.map +1 -1
- package/dist/models/attendance.js +6 -5
- package/dist/models/attendance.js.map +1 -1
- package/dist/models/auth.d.ts +5 -5
- package/dist/models/auth.d.ts.map +1 -1
- package/dist/models/auth.js +7 -11
- package/dist/models/auth.js.map +1 -1
- package/dist/models/class.d.ts +26 -26
- package/dist/models/class.d.ts.map +1 -1
- package/dist/models/class.js +7 -11
- package/dist/models/class.js.map +1 -1
- package/dist/models/comment.d.ts +134 -70
- package/dist/models/comment.d.ts.map +1 -1
- package/dist/models/comment.js +30 -42
- package/dist/models/comment.js.map +1 -1
- package/dist/models/conversation.d.ts +7 -7
- package/dist/models/event.d.ts +52 -3
- package/dist/models/event.d.ts.map +1 -1
- package/dist/models/event.js +56 -6
- package/dist/models/event.js.map +1 -1
- package/dist/models/file.d.ts +178 -103
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/file.js +54 -14
- package/dist/models/file.js.map +1 -1
- package/dist/models/folder.d.ts +22 -22
- package/dist/models/folder.d.ts.map +1 -1
- package/dist/models/folder.js +5 -4
- package/dist/models/folder.js.map +1 -1
- package/dist/models/labChat.d.ts +20 -20
- package/dist/models/labChat.d.ts.map +1 -1
- package/dist/models/labChat.js +8 -10
- package/dist/models/labChat.js.map +1 -1
- package/dist/models/marketing.d.ts +1 -1
- package/dist/models/message.d.ts +6 -6
- package/dist/models/newtonChat.d.ts +5 -5
- package/dist/models/school.d.ts +361 -0
- package/dist/models/school.d.ts.map +1 -0
- package/dist/models/school.js +314 -0
- package/dist/models/school.js.map +1 -0
- package/dist/models/section.d.ts +1 -1
- package/dist/models/section.d.ts.map +1 -1
- package/dist/models/section.js +5 -4
- package/dist/models/section.js.map +1 -1
- package/dist/models/user.d.ts +4 -4
- package/dist/models/worksheet.d.ts +65 -65
- package/dist/models/worksheet.d.ts.map +1 -1
- package/dist/models/worksheet.js +6 -14
- package/dist/models/worksheet.js.map +1 -1
- package/dist/pipelines/gradeWorksheet.d.ts +2 -2
- package/dist/pipelines/pdfToWorksheet.d.ts +1 -1
- package/dist/routers/_app.d.ts +2855 -2051
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/_app.js +4 -2
- package/dist/routers/_app.js.map +1 -1
- package/dist/routers/announcement.d.ts +5 -5
- package/dist/routers/announcement.d.ts.map +1 -1
- package/dist/routers/announcement.js +25 -5
- package/dist/routers/announcement.js.map +1 -1
- package/dist/routers/assignment.d.ts +44 -44
- package/dist/routers/assignment.d.ts.map +1 -1
- package/dist/routers/assignment.js +24 -11
- package/dist/routers/assignment.js.map +1 -1
- package/dist/routers/class.d.ts +21 -20
- package/dist/routers/class.d.ts.map +1 -1
- package/dist/routers/class.js +3 -2
- package/dist/routers/class.js.map +1 -1
- package/dist/routers/comment.d.ts +5 -5
- package/dist/routers/conversation.d.ts +6 -6
- package/dist/routers/event.d.ts +21 -2
- package/dist/routers/event.d.ts.map +1 -1
- package/dist/routers/file.d.ts +2 -2
- package/dist/routers/folder.d.ts +24 -24
- package/dist/routers/labChat.d.ts +7 -7
- package/dist/routers/school.d.ts +384 -0
- package/dist/routers/school.d.ts.map +1 -0
- package/dist/routers/school.js +79 -0
- package/dist/routers/school.js.map +1 -0
- package/dist/routers/search.d.ts +1 -1
- package/dist/routers/worksheet.d.ts +21 -21
- package/dist/services/announcement.d.ts.map +1 -1
- package/dist/services/announcement.js +10 -6
- package/dist/services/announcement.js.map +1 -1
- package/dist/services/assignment.d.ts +36 -36
- package/dist/services/class.d.ts +20 -19
- package/dist/services/class.d.ts.map +1 -1
- package/dist/services/class.js +22 -3
- package/dist/services/class.js.map +1 -1
- package/dist/services/comment.d.ts +5 -5
- package/dist/services/comment.d.ts.map +1 -1
- package/dist/services/comment.js +8 -3
- package/dist/services/comment.js.map +1 -1
- package/dist/services/conversation.d.ts +6 -6
- package/dist/services/event.d.ts +21 -2
- package/dist/services/event.d.ts.map +1 -1
- package/dist/services/event.js +11 -7
- package/dist/services/event.js.map +1 -1
- package/dist/services/file.d.ts +2 -2
- package/dist/services/file.d.ts.map +1 -1
- package/dist/services/file.js +17 -8
- package/dist/services/file.js.map +1 -1
- package/dist/services/folder.d.ts +24 -24
- package/dist/services/labChat.d.ts +7 -7
- package/dist/services/school.d.ts +299 -0
- package/dist/services/school.d.ts.map +1 -0
- package/dist/services/school.js +225 -0
- package/dist/services/school.js.map +1 -0
- package/dist/services/worksheet.d.ts +21 -21
- package/package.json +1 -1
- package/prisma/migrations/20260504071500_school_memberships/migration.sql +81 -0
- package/prisma/schema.prisma +66 -2
- package/src/models/access.ts +48 -0
- package/src/models/announcement.ts +19 -2
- package/src/models/assignment.ts +17 -13
- package/src/models/attendance.ts +4 -3
- package/src/models/auth.ts +8 -9
- package/src/models/class.ts +8 -9
- package/src/models/comment.ts +29 -40
- package/src/models/event.ts +54 -4
- package/src/models/file.ts +53 -12
- package/src/models/folder.ts +3 -2
- package/src/models/labChat.ts +9 -8
- package/src/models/school.ts +361 -0
- package/src/models/section.ts +3 -2
- package/src/models/worksheet.ts +7 -12
- package/src/routers/_app.ts +2 -0
- package/src/routers/announcement.ts +30 -4
- package/src/routers/assignment.ts +27 -9
- package/src/routers/class.ts +1 -0
- package/src/routers/school.ts +122 -0
- package/src/services/announcement.ts +12 -4
- package/src/services/class.ts +25 -2
- package/src/services/comment.ts +10 -1
- package/src/services/event.ts +23 -6
- package/src/services/file.ts +20 -6
- package/src/services/school.ts +308 -0
package/dist/models/folder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @returns Class if user is a teacher. */
|
|
1
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
2
2
|
export declare function findClassWithTeacher(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
3
3
|
name: string;
|
|
4
4
|
id: string;
|
|
@@ -85,21 +85,21 @@ export declare function createFolder(data: {
|
|
|
85
85
|
type: string;
|
|
86
86
|
name: string;
|
|
87
87
|
id: string;
|
|
88
|
-
size: number | null;
|
|
89
|
-
uploadedAt: Date | null;
|
|
90
88
|
user: {
|
|
91
89
|
id: string;
|
|
92
90
|
username: string;
|
|
93
91
|
} | null;
|
|
92
|
+
size: number | null;
|
|
93
|
+
uploadedAt: Date | null;
|
|
94
94
|
}[];
|
|
95
95
|
childFolders: {
|
|
96
96
|
name: string;
|
|
97
97
|
id: string;
|
|
98
|
+
color: string | null;
|
|
98
99
|
_count: {
|
|
99
100
|
files: number;
|
|
100
101
|
childFolders: number;
|
|
101
102
|
};
|
|
102
|
-
color: string | null;
|
|
103
103
|
}[];
|
|
104
104
|
} & {
|
|
105
105
|
name: string;
|
|
@@ -120,21 +120,21 @@ export declare function findFolderWithContents(folderId: string): import(".prism
|
|
|
120
120
|
type: string;
|
|
121
121
|
name: string;
|
|
122
122
|
id: string;
|
|
123
|
-
size: number | null;
|
|
124
|
-
uploadedAt: Date | null;
|
|
125
123
|
user: {
|
|
126
124
|
id: string;
|
|
127
125
|
username: string;
|
|
128
126
|
} | null;
|
|
127
|
+
size: number | null;
|
|
128
|
+
uploadedAt: Date | null;
|
|
129
129
|
}[];
|
|
130
130
|
childFolders: {
|
|
131
131
|
name: string;
|
|
132
132
|
id: string;
|
|
133
|
+
color: string | null;
|
|
133
134
|
_count: {
|
|
134
135
|
files: number;
|
|
135
136
|
childFolders: number;
|
|
136
137
|
};
|
|
137
|
-
color: string | null;
|
|
138
138
|
}[];
|
|
139
139
|
parentFolder: {
|
|
140
140
|
name: string;
|
|
@@ -159,21 +159,21 @@ export declare function findChildFolders(parentFolderId: string): import(".prism
|
|
|
159
159
|
type: string;
|
|
160
160
|
name: string;
|
|
161
161
|
id: string;
|
|
162
|
-
size: number | null;
|
|
163
|
-
uploadedAt: Date | null;
|
|
164
162
|
user: {
|
|
165
163
|
id: string;
|
|
166
164
|
username: string;
|
|
167
165
|
} | null;
|
|
166
|
+
size: number | null;
|
|
167
|
+
uploadedAt: Date | null;
|
|
168
168
|
}[];
|
|
169
169
|
childFolders: {
|
|
170
170
|
name: string;
|
|
171
171
|
id: string;
|
|
172
|
+
color: string | null;
|
|
172
173
|
_count: {
|
|
173
174
|
files: number;
|
|
174
175
|
childFolders: number;
|
|
175
176
|
};
|
|
176
|
-
color: string | null;
|
|
177
177
|
}[];
|
|
178
178
|
} & {
|
|
179
179
|
name: string;
|
|
@@ -188,24 +188,24 @@ export declare function findRootFolderWithContents(classId: string): import(".pr
|
|
|
188
188
|
type: string;
|
|
189
189
|
name: string;
|
|
190
190
|
id: string;
|
|
191
|
-
size: number | null;
|
|
192
|
-
uploadedAt: Date | null;
|
|
193
191
|
user: {
|
|
194
192
|
id: string;
|
|
195
193
|
username: string;
|
|
196
194
|
} | null;
|
|
195
|
+
size: number | null;
|
|
196
|
+
uploadedAt: Date | null;
|
|
197
197
|
}[];
|
|
198
198
|
childFolders: {
|
|
199
199
|
name: string;
|
|
200
200
|
id: string;
|
|
201
|
-
|
|
202
|
-
id: string;
|
|
203
|
-
}[];
|
|
201
|
+
color: string | null;
|
|
204
202
|
_count: {
|
|
205
203
|
files: number;
|
|
206
204
|
childFolders: number;
|
|
207
205
|
};
|
|
208
|
-
|
|
206
|
+
files: {
|
|
207
|
+
id: string;
|
|
208
|
+
}[];
|
|
209
209
|
childFolders: {
|
|
210
210
|
id: string;
|
|
211
211
|
}[];
|
|
@@ -281,21 +281,21 @@ export declare function updateFolderParent(folderId: string, parentFolderId: str
|
|
|
281
281
|
type: string;
|
|
282
282
|
name: string;
|
|
283
283
|
id: string;
|
|
284
|
-
size: number | null;
|
|
285
|
-
uploadedAt: Date | null;
|
|
286
284
|
user: {
|
|
287
285
|
id: string;
|
|
288
286
|
username: string;
|
|
289
287
|
} | null;
|
|
288
|
+
size: number | null;
|
|
289
|
+
uploadedAt: Date | null;
|
|
290
290
|
}[];
|
|
291
291
|
childFolders: {
|
|
292
292
|
name: string;
|
|
293
293
|
id: string;
|
|
294
|
+
color: string | null;
|
|
294
295
|
_count: {
|
|
295
296
|
files: number;
|
|
296
297
|
childFolders: number;
|
|
297
298
|
};
|
|
298
|
-
color: string | null;
|
|
299
299
|
}[];
|
|
300
300
|
} & {
|
|
301
301
|
name: string;
|
|
@@ -319,21 +319,21 @@ export declare function updateFolder(folderId: string, data: {
|
|
|
319
319
|
type: string;
|
|
320
320
|
name: string;
|
|
321
321
|
id: string;
|
|
322
|
-
size: number | null;
|
|
323
|
-
uploadedAt: Date | null;
|
|
324
322
|
user: {
|
|
325
323
|
id: string;
|
|
326
324
|
username: string;
|
|
327
325
|
} | null;
|
|
326
|
+
size: number | null;
|
|
327
|
+
uploadedAt: Date | null;
|
|
328
328
|
}[];
|
|
329
329
|
childFolders: {
|
|
330
330
|
name: string;
|
|
331
331
|
id: string;
|
|
332
|
+
color: string | null;
|
|
332
333
|
_count: {
|
|
333
334
|
files: number;
|
|
334
335
|
childFolders: number;
|
|
335
336
|
};
|
|
336
|
-
color: string | null;
|
|
337
337
|
}[];
|
|
338
338
|
} & {
|
|
339
339
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder.d.ts","sourceRoot":"/","sources":["models/folder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"folder.d.ts","sourceRoot":"/","sources":["models/folder.ts"],"names":[],"mappings":"AAsBA,2DAA2D;AAC3D,wBAAgB,oBAAoB,CAAC,OA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M;;;;;;;;;;;;GAIhD;AAED,iCAAiC;AACjC,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAS1E;AAED,oCAAoC;AACpC,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUxC;AAED,0CAA0C;AAC1C,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;;;GAIpD;AAED,6BAA6B;AAC7B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;GAIjD"}
|
package/dist/models/folder.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Folder model – class folders, hierarchy, contents. Teacher permission checks.
|
|
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]="
|
|
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]="09a4aeb2-aef9-585f-9480-2197a905014d")}catch(e){}}();
|
|
6
6
|
import { prisma } from "../lib/prisma.js";
|
|
7
|
+
import { classTeacherOrSchoolAdminWhere } from "./access.js";
|
|
7
8
|
const fileSelect = {
|
|
8
9
|
id: true,
|
|
9
10
|
name: true,
|
|
@@ -18,12 +19,12 @@ const childFolderSelect = {
|
|
|
18
19
|
color: true,
|
|
19
20
|
_count: { select: { files: true, childFolders: true } },
|
|
20
21
|
};
|
|
21
|
-
/** @returns Class if user is a teacher. */
|
|
22
|
+
/** @returns Class if user is a teacher or school admin. */
|
|
22
23
|
export function findClassWithTeacher(classId, teacherId) {
|
|
23
24
|
return prisma.class.findFirst({
|
|
24
25
|
where: {
|
|
25
26
|
id: classId,
|
|
26
|
-
|
|
27
|
+
...classTeacherOrSchoolAdminWhere(teacherId),
|
|
27
28
|
},
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -199,4 +200,4 @@ export function findFolderParents(folderId) {
|
|
|
199
200
|
});
|
|
200
201
|
}
|
|
201
202
|
//# sourceMappingURL=folder.js.map
|
|
202
|
-
//# debugId=
|
|
203
|
+
//# debugId=09a4aeb2-aef9-585f-9480-2197a905014d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder.js","sources":["models/folder.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Folder model – class folders, hierarchy, contents. Teacher permission checks.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst fileSelect = {\n id: true,\n name: true,\n type: true,\n size: true,\n uploadedAt: true,\n user: { select: { id: true, username: true } },\n};\n\nconst childFolderSelect = {\n id: true,\n name: true,\n color: true,\n _count: { select: { files: true, childFolders: true } },\n};\n\n/** @returns Class if user is a teacher. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n teachers: { some: { id: teacherId } },\n },\n });\n}\n\n/** @returns Folder by ID. */\nexport function findFolderById(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\n });\n}\n\n/** @returns Folder with class. */\nexport function findFolderByIdWithClass(folderId: string) {\n return prisma.folder.findUnique({\n where: { id: folderId },\n include: { class: true },\n });\n}\n\n/** @returns Root folder for a class. */\nexport function findRootFolderByClassId(classId: string) {\n return prisma.folder.findFirst({\n where: {\n classId,\n parentFolderId: null,\n },\n });\n}\n\n/** Get or create root folder for a class. */\nexport async function findOrCreateRootFolder(classId: string) {\n let parent = await findRootFolderByClassId(classId);\n if (!parent) {\n parent = await prisma.folder.create({\n data: {\n name: \"Class Files\",\n class: { connect: { id: classId } },\n },\n });\n }\n return parent;\n}\n\n/** Create a folder. */\nexport function createFolder(data: {\n name: string;\n parentFolderId?: string | null;\n classId?: string;\n color?: string;\n}) {\n return prisma.folder.create({\n data: {\n name: data.name,\n ...(data.parentFolderId && {\n parentFolder: { connect: { id: data.parentFolderId } },\n }),\n ...(data.classId && { class: { connect: { id: data.classId } } }),\n ...(data.color && { color: data.color }),\n },\n include: {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: childFolderSelect,\n orderBy: { name: \"asc\" as const },\n },\n },\n });\n}\n\nconst folderIncludeWithFiles = {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: childFolderSelect,\n orderBy: { name: \"asc\" as const },\n },\n parentFolder: { select: { id: true, name: true } },\n};\n\n/** @returns Folder with files and child folders. */\nexport function findFolderWithContents(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\n include: folderIncludeWithFiles,\n });\n}\n\n/** @returns Direct child folders. */\nexport function findChildFolders(parentFolderId: string) {\n return prisma.folder.findMany({\n where: { parentFolderId },\n include: {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: childFolderSelect,\n orderBy: { name: \"asc\" as const },\n },\n },\n orderBy: { name: \"asc\" },\n });\n}\n\n/** @returns Root folder with contents for a class. */\nexport function findRootFolderWithContents(classId: string) {\n return prisma.folder.findFirst({\n where: { classId, parentFolderId: null },\n include: {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: {\n ...childFolderSelect,\n files: { select: { id: true } },\n childFolders: { select: { id: true } },\n },\n orderBy: { name: \"asc\" as const },\n },\n },\n });\n}\n\n/** @returns Folder with file/folder counts. */\nexport function findFolderWithCount(folderId: string, classId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId, classId },\n include: {\n _count: { select: { files: true, childFolders: true } },\n },\n });\n}\n\n/** @returns Folder with file/folder counts. */\nexport function findFolderByIdWithCount(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\n include: {\n _count: { select: { files: true, childFolders: true } },\n },\n });\n}\n\n/** Delete a folder. */\nexport function deleteFolderById(folderId: string) {\n return prisma.folder.delete({\n where: { id: folderId },\n });\n}\n\n/** Move folder to new parent. */\nexport function updateFolderParent(folderId: string, parentFolderId: string) {\n return prisma.folder.update({\n where: { id: folderId },\n data: { parentFolderId },\n include: {\n files: { select: fileSelect },\n childFolders: { select: childFolderSelect },\n },\n });\n}\n\n/** Update folder name and color. */\nexport function updateFolder(\n folderId: string,\n data: { name?: string; color?: string }\n) {\n return prisma.folder.update({\n where: { id: folderId },\n data,\n include: {\n files: { select: fileSelect },\n childFolders: { select: childFolderSelect },\n },\n });\n}\n\n/** @returns Folder for path traversal. */\nexport function findFolderByIdForTraversal(id: string) {\n return prisma.folder.findUnique({\n where: { id },\n });\n}\n\n/** @returns Folder by ID. */\nexport function findFolderParents(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\n });\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,IAAI;IAChB,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;CAC/C,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,EAAE,MAAM,EAAE,EA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B,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE;QACvB,IAAI;QACJ,OAAO,EAAE;YACP,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;YAC7B,YAAY,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;SAC5C;KACF,CAAC,CAAC;AACL,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,0BAA0B,CAAC,EAAU;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;QAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;KACd,CAAC,CAAC;AACL,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QAC7B,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE;KACxB,CAAC,CAAC;AACL,CAAC","debug_id":"f914d30a-5901-54ec-9a00-fba86348df0a"}
|
|
1
|
+
{"version":3,"file":"folder.js","sources":["models/folder.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Folder model – class folders, hierarchy, contents. Teacher permission checks.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport { classTeacherOrSchoolAdminWhere } from \"./access.js\";\n\nconst fileSelect = {\n id: true,\n name: true,\n type: true,\n size: true,\n uploadedAt: true,\n user: { select: { id: true, username: true } },\n};\n\nconst childFolderSelect = {\n id: true,\n name: true,\n color: true,\n _count: { select: { files: true, childFolders: true } },\n};\n\n/** @returns Class if user is a teacher or school admin. */\nexport function findClassWithTeacher(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(teacherId),\n },\n });\n}\n\n/** @returns Folder by ID. */\nexport function findFolderById(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\n });\n}\n\n/** @returns Folder with class. */\nexport function findFolderByIdWithClass(folderId: string) {\n return prisma.folder.findUnique({\n where: { id: folderId },\n include: { class: true },\n });\n}\n\n/** @returns Root folder for a class. */\nexport function findRootFolderByClassId(classId: string) {\n return prisma.folder.findFirst({\n where: {\n classId,\n parentFolderId: null,\n },\n });\n}\n\n/** Get or create root folder for a class. */\nexport async function findOrCreateRootFolder(classId: string) {\n let parent = await findRootFolderByClassId(classId);\n if (!parent) {\n parent = await prisma.folder.create({\n data: {\n name: \"Class Files\",\n class: { connect: { id: classId } },\n },\n });\n }\n return parent;\n}\n\n/** Create a folder. */\nexport function createFolder(data: {\n name: string;\n parentFolderId?: string | null;\n classId?: string;\n color?: string;\n}) {\n return prisma.folder.create({\n data: {\n name: data.name,\n ...(data.parentFolderId && {\n parentFolder: { connect: { id: data.parentFolderId } },\n }),\n ...(data.classId && { class: { connect: { id: data.classId } } }),\n ...(data.color && { color: data.color }),\n },\n include: {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: childFolderSelect,\n orderBy: { name: \"asc\" as const },\n },\n },\n });\n}\n\nconst folderIncludeWithFiles = {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: childFolderSelect,\n orderBy: { name: \"asc\" as const },\n },\n parentFolder: { select: { id: true, name: true } },\n};\n\n/** @returns Folder with files and child folders. */\nexport function findFolderWithContents(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\n include: folderIncludeWithFiles,\n });\n}\n\n/** @returns Direct child folders. */\nexport function findChildFolders(parentFolderId: string) {\n return prisma.folder.findMany({\n where: { parentFolderId },\n include: {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: childFolderSelect,\n orderBy: { name: \"asc\" as const },\n },\n },\n orderBy: { name: \"asc\" },\n });\n}\n\n/** @returns Root folder with contents for a class. */\nexport function findRootFolderWithContents(classId: string) {\n return prisma.folder.findFirst({\n where: { classId, parentFolderId: null },\n include: {\n files: {\n select: fileSelect,\n orderBy: { uploadedAt: \"desc\" as const },\n },\n childFolders: {\n select: {\n ...childFolderSelect,\n files: { select: { id: true } },\n childFolders: { select: { id: true } },\n },\n orderBy: { name: \"asc\" as const },\n },\n },\n });\n}\n\n/** @returns Folder with file/folder counts. */\nexport function findFolderWithCount(folderId: string, classId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId, classId },\n include: {\n _count: { select: { files: true, childFolders: true } },\n },\n });\n}\n\n/** @returns Folder with file/folder counts. */\nexport function findFolderByIdWithCount(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\n include: {\n _count: { select: { files: true, childFolders: true } },\n },\n });\n}\n\n/** Delete a folder. */\nexport function deleteFolderById(folderId: string) {\n return prisma.folder.delete({\n where: { id: folderId },\n });\n}\n\n/** Move folder to new parent. */\nexport function updateFolderParent(folderId: string, parentFolderId: string) {\n return prisma.folder.update({\n where: { id: folderId },\n data: { parentFolderId },\n include: {\n files: { select: fileSelect },\n childFolders: { select: childFolderSelect },\n },\n });\n}\n\n/** Update folder name and color. */\nexport function updateFolder(\n folderId: string,\n data: { name?: string; color?: string }\n) {\n return prisma.folder.update({\n where: { id: folderId },\n data,\n include: {\n files: { select: fileSelect },\n childFolders: { select: childFolderSelect },\n },\n });\n}\n\n/** @returns Folder for path traversal. */\nexport function findFolderByIdForTraversal(id: string) {\n return prisma.folder.findUnique({\n where: { id },\n });\n}\n\n/** @returns Folder by ID. */\nexport function findFolderParents(folderId: string) {\n return prisma.folder.findFirst({\n where: { id: folderId },\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,UAAU,GAAG;IACjB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,IAAI;IAChB,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,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iBAAiB,EAAE;SAC5C;KACF,CAAC,CAAC;AACL,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,YAAY,CAC1B,QAAgB,EAChB,IAAuC;IAEvC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1B,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE;QACvB,IAAI;QACJ,OAAO,EAAE;YACP,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;YAC7B,YAAY,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;SAC5C;KACF,CAAC,CAAC;AACL,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,0BAA0B,CAAC,EAAU;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;QAC9B,KAAK,EAAE,EAAE,EAAE,EAAE;KACd,CAAC,CAAC;AACL,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QAC7B,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE;KACxB,CAAC,CAAC;AACL,CAAC","debug_id":"09a4aeb2-aef9-585f-9480-2197a905014d"}
|
package/dist/models/labChat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @returns Class with students and teachers for lab creation. */
|
|
2
2
|
export declare function findClassWithTeachersForLab(classId: string, teacherId: string): import(".prisma/client").Prisma.Prisma__ClassClient<({
|
|
3
|
-
|
|
3
|
+
teachers: {
|
|
4
4
|
id: string;
|
|
5
5
|
username: string;
|
|
6
6
|
profile: {
|
|
@@ -8,7 +8,7 @@ export declare function findClassWithTeachersForLab(classId: string, teacherId:
|
|
|
8
8
|
profilePicture: string | null;
|
|
9
9
|
} | null;
|
|
10
10
|
}[];
|
|
11
|
-
|
|
11
|
+
students: {
|
|
12
12
|
id: string;
|
|
13
13
|
username: string;
|
|
14
14
|
profile: {
|
|
@@ -51,9 +51,9 @@ export declare function findLabChatByMember(labChatId: string, userId: string):
|
|
|
51
51
|
};
|
|
52
52
|
} & {
|
|
53
53
|
id: string;
|
|
54
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
54
55
|
userId: string;
|
|
55
56
|
conversationId: string;
|
|
56
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
57
57
|
joinedAt: Date;
|
|
58
58
|
hiddenAt: Date | null;
|
|
59
59
|
lastViewedAt: Date | null;
|
|
@@ -78,11 +78,11 @@ export declare function findLabChatByMember(labChatId: string, userId: string):
|
|
|
78
78
|
} & {
|
|
79
79
|
context: string;
|
|
80
80
|
id: string;
|
|
81
|
-
conversationId: string;
|
|
82
81
|
createdAt: Date;
|
|
82
|
+
updatedAt: Date;
|
|
83
|
+
conversationId: string;
|
|
83
84
|
classId: string;
|
|
84
85
|
title: string;
|
|
85
|
-
updatedAt: Date;
|
|
86
86
|
createdById: string;
|
|
87
87
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
88
88
|
datasources: {
|
|
@@ -91,7 +91,7 @@ export declare function findLabChatByMember(labChatId: string, userId: string):
|
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
}>;
|
|
94
|
-
/** @returns Lab chat if user is class teacher. */
|
|
94
|
+
/** @returns Lab chat if user is class teacher or school admin. */
|
|
95
95
|
export declare function findLabChatByTeacher(labChatId: string, userId: string): import(".prisma/client").Prisma.Prisma__LabChatClient<({
|
|
96
96
|
conversation: {
|
|
97
97
|
id: string;
|
|
@@ -99,11 +99,11 @@ export declare function findLabChatByTeacher(labChatId: string, userId: string):
|
|
|
99
99
|
} & {
|
|
100
100
|
context: string;
|
|
101
101
|
id: string;
|
|
102
|
-
conversationId: string;
|
|
103
102
|
createdAt: Date;
|
|
103
|
+
updatedAt: Date;
|
|
104
|
+
conversationId: string;
|
|
104
105
|
classId: string;
|
|
105
106
|
title: string;
|
|
106
|
-
updatedAt: Date;
|
|
107
107
|
createdById: string;
|
|
108
108
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
109
109
|
datasources: {
|
|
@@ -132,9 +132,9 @@ export declare function findLabChatById(labChatId: string): import(".prisma/clie
|
|
|
132
132
|
};
|
|
133
133
|
} & {
|
|
134
134
|
id: string;
|
|
135
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
135
136
|
userId: string;
|
|
136
137
|
conversationId: string;
|
|
137
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
138
138
|
joinedAt: Date;
|
|
139
139
|
hiddenAt: Date | null;
|
|
140
140
|
lastViewedAt: Date | null;
|
|
@@ -159,11 +159,11 @@ export declare function findLabChatById(labChatId: string): import(".prisma/clie
|
|
|
159
159
|
} & {
|
|
160
160
|
context: string;
|
|
161
161
|
id: string;
|
|
162
|
-
conversationId: string;
|
|
163
162
|
createdAt: Date;
|
|
163
|
+
updatedAt: Date;
|
|
164
|
+
conversationId: string;
|
|
164
165
|
classId: string;
|
|
165
166
|
title: string;
|
|
166
|
-
updatedAt: Date;
|
|
167
167
|
createdById: string;
|
|
168
168
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
169
169
|
datasources: {
|
|
@@ -172,7 +172,7 @@ export declare function findLabChatById(labChatId: string): import(".prisma/clie
|
|
|
172
172
|
};
|
|
173
173
|
};
|
|
174
174
|
}>;
|
|
175
|
-
/** @returns Class if user is student or
|
|
175
|
+
/** @returns Class if user is student, teacher, or school admin. */
|
|
176
176
|
export declare function findClassMembership(classId: string, userId: string): import(".prisma/client").Prisma.Prisma__ClassClient<{
|
|
177
177
|
name: string;
|
|
178
178
|
id: string;
|
|
@@ -206,8 +206,8 @@ export declare function findLabChatsByClass(classId: string): import(".prisma/cl
|
|
|
206
206
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
207
207
|
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
208
208
|
id: string;
|
|
209
|
-
conversationId: string;
|
|
210
209
|
createdAt: Date;
|
|
210
|
+
conversationId: string;
|
|
211
211
|
content: string;
|
|
212
212
|
senderId: string;
|
|
213
213
|
})[];
|
|
@@ -229,11 +229,11 @@ export declare function findLabChatsByClass(classId: string): import(".prisma/cl
|
|
|
229
229
|
} & {
|
|
230
230
|
context: string;
|
|
231
231
|
id: string;
|
|
232
|
-
conversationId: string;
|
|
233
232
|
createdAt: Date;
|
|
233
|
+
updatedAt: Date;
|
|
234
|
+
conversationId: string;
|
|
234
235
|
classId: string;
|
|
235
236
|
title: string;
|
|
236
|
-
updatedAt: Date;
|
|
237
237
|
createdById: string;
|
|
238
238
|
})[]>;
|
|
239
239
|
/** @returns Lab chat if user can post (member or teacher). */
|
|
@@ -244,11 +244,11 @@ export declare function findLabChatForPost(labChatId: string, userId: string): i
|
|
|
244
244
|
} & {
|
|
245
245
|
context: string;
|
|
246
246
|
id: string;
|
|
247
|
-
conversationId: string;
|
|
248
247
|
createdAt: Date;
|
|
248
|
+
updatedAt: Date;
|
|
249
|
+
conversationId: string;
|
|
249
250
|
classId: string;
|
|
250
251
|
title: string;
|
|
251
|
-
updatedAt: Date;
|
|
252
252
|
createdById: string;
|
|
253
253
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
254
254
|
datasources: {
|
|
@@ -261,11 +261,11 @@ export declare function findLabChatForPost(labChatId: string, userId: string): i
|
|
|
261
261
|
export declare function findLabChatForDelete(labChatId: string, userId: string): import(".prisma/client").Prisma.Prisma__LabChatClient<{
|
|
262
262
|
context: string;
|
|
263
263
|
id: string;
|
|
264
|
-
conversationId: string;
|
|
265
264
|
createdAt: Date;
|
|
265
|
+
updatedAt: Date;
|
|
266
|
+
conversationId: string;
|
|
266
267
|
classId: string;
|
|
267
268
|
title: string;
|
|
268
|
-
updatedAt: Date;
|
|
269
269
|
createdById: string;
|
|
270
270
|
} | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
271
271
|
datasources: {
|
|
@@ -277,9 +277,9 @@ export declare function findLabChatForDelete(labChatId: string, userId: string):
|
|
|
277
277
|
/** @returns Conversation members for mentioned user IDs. */
|
|
278
278
|
export declare function findMentionedMemberships(conversationId: string, userIds: string[]): import(".prisma/client").Prisma.PrismaPromise<{
|
|
279
279
|
id: string;
|
|
280
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
280
281
|
userId: string;
|
|
281
282
|
conversationId: string;
|
|
282
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
283
283
|
joinedAt: Date;
|
|
284
284
|
hiddenAt: Date | null;
|
|
285
285
|
lastViewedAt: Date | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labChat.d.ts","sourceRoot":"/","sources":["models/labChat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"labChat.d.ts","sourceRoot":"/","sources":["models/labChat.ts"],"names":[],"mappings":"AAoDA,kEAAkE;AAClE,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiC7E;AAED,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAUpE;AAED,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAYrE;AAED,+BAA+B;AAC/B,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKhD;AAED,mEAAmE;AACnE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;GAOlE;AAED,sCAAsC;AACtC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAwClD;AAED,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;GAYnE;AAED,sDAAsD;AACtD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;GAOrE;AAED,4DAA4D;AAC5D,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EAAE;;;;;;;;;KAQlB"}
|
package/dist/models/labChat.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Lab chat model – AI lab conversations, members, posts. Teacher/student access.
|
|
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]="
|
|
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]="f519e035-445f-5c41-80c4-de7dd81d94e2")}catch(e){}}();
|
|
6
6
|
import { prisma } from "../lib/prisma.js";
|
|
7
|
+
import { classMemberOrSchoolAdminWhere, classTeacherOrSchoolAdminWhere, } from "./access.js";
|
|
7
8
|
const labChatInclude = {
|
|
8
9
|
conversation: {
|
|
9
10
|
include: {
|
|
@@ -51,7 +52,7 @@ export function findClassWithTeachersForLab(classId, teacherId) {
|
|
|
51
52
|
return prisma.class.findFirst({
|
|
52
53
|
where: {
|
|
53
54
|
id: classId,
|
|
54
|
-
|
|
55
|
+
...classTeacherOrSchoolAdminWhere(teacherId),
|
|
55
56
|
},
|
|
56
57
|
include: {
|
|
57
58
|
students: {
|
|
@@ -93,13 +94,13 @@ export function findLabChatByMember(labChatId, userId) {
|
|
|
93
94
|
include: labChatInclude,
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
|
-
/** @returns Lab chat if user is class teacher. */
|
|
97
|
+
/** @returns Lab chat if user is class teacher or school admin. */
|
|
97
98
|
export function findLabChatByTeacher(labChatId, userId) {
|
|
98
99
|
return prisma.labChat.findFirst({
|
|
99
100
|
where: {
|
|
100
101
|
id: labChatId,
|
|
101
102
|
class: {
|
|
102
|
-
|
|
103
|
+
...classTeacherOrSchoolAdminWhere(userId),
|
|
103
104
|
},
|
|
104
105
|
},
|
|
105
106
|
include: {
|
|
@@ -114,15 +115,12 @@ export function findLabChatById(labChatId) {
|
|
|
114
115
|
include: labChatInclude,
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
|
-
/** @returns Class if user is student or
|
|
118
|
+
/** @returns Class if user is student, teacher, or school admin. */
|
|
118
119
|
export function findClassMembership(classId, userId) {
|
|
119
120
|
return prisma.class.findFirst({
|
|
120
121
|
where: {
|
|
121
122
|
id: classId,
|
|
122
|
-
|
|
123
|
-
{ students: { some: { id: userId } } },
|
|
124
|
-
{ teachers: { some: { id: userId } } },
|
|
125
|
-
],
|
|
123
|
+
...classMemberOrSchoolAdminWhere(userId),
|
|
126
124
|
},
|
|
127
125
|
});
|
|
128
126
|
}
|
|
@@ -201,4 +199,4 @@ export function findMentionedMemberships(conversationId, userIds) {
|
|
|
201
199
|
});
|
|
202
200
|
}
|
|
203
201
|
//# sourceMappingURL=labChat.js.map
|
|
204
|
-
//# debugId=
|
|
202
|
+
//# debugId=f519e035-445f-5c41-80c4-de7dd81d94e2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labChat.js","sources":["models/labChat.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Lab chat model – AI lab conversations, members, posts. Teacher/student access.\n */\nimport { prisma } from \"../lib/prisma.js\";\n\nconst labChatInclude = {\n conversation: {\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 createdBy: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n class: {\n select: {\n id: true,\n name: true,\n subject: true,\n section: true,\n },\n },\n};\n\n/** @returns Class with students and teachers for lab creation. */\nexport function findClassWithTeachersForLab(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n
|
|
1
|
+
{"version":3,"file":"labChat.js","sources":["models/labChat.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Lab chat model – AI lab conversations, members, posts. Teacher/student access.\n */\nimport { prisma } from \"../lib/prisma.js\";\nimport {\n classMemberOrSchoolAdminWhere,\n classTeacherOrSchoolAdminWhere,\n} from \"./access.js\";\n\nconst labChatInclude = {\n conversation: {\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 createdBy: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n class: {\n select: {\n id: true,\n name: true,\n subject: true,\n section: true,\n },\n },\n};\n\n/** @returns Class with students and teachers for lab creation. */\nexport function findClassWithTeachersForLab(classId: string, teacherId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classTeacherOrSchoolAdminWhere(teacherId),\n },\n include: {\n students: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n },\n },\n },\n },\n teachers: {\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/** @returns Lab chat if user is a conversation member. */\nexport function findLabChatByMember(labChatId: string, userId: string) {\n return prisma.labChat.findFirst({\n where: {\n id: labChatId,\n conversation: {\n members: { some: { userId } },\n },\n },\n include: labChatInclude,\n });\n}\n\n/** @returns Lab chat if user is class teacher or school admin. */\nexport function findLabChatByTeacher(labChatId: string, userId: string) {\n return prisma.labChat.findFirst({\n where: {\n id: labChatId,\n class: {\n ...classTeacherOrSchoolAdminWhere(userId),\n },\n },\n include: {\n conversation: { select: { id: true } },\n },\n });\n}\n\n/** @returns Lab chat by ID. */\nexport function findLabChatById(labChatId: string) {\n return prisma.labChat.findFirst({\n where: { id: labChatId },\n include: labChatInclude,\n });\n}\n\n/** @returns Class if user is student, teacher, or school admin. */\nexport function findClassMembership(classId: string, userId: string) {\n return prisma.class.findFirst({\n where: {\n id: classId,\n ...classMemberOrSchoolAdminWhere(userId),\n },\n });\n}\n\n/** @returns Lab chats for a class. */\nexport function findLabChatsByClass(classId: string) {\n return prisma.labChat.findMany({\n where: { classId },\n include: {\n createdBy: {\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n },\n },\n },\n },\n conversation: {\n include: {\n messages: {\n orderBy: { createdAt: \"desc\" as const },\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 _count: { select: { messages: true } },\n },\n },\n },\n orderBy: { createdAt: \"desc\" as const },\n });\n}\n\n/** @returns Lab chat if user can post (member or teacher). */\nexport function findLabChatForPost(labChatId: string, userId: string) {\n return prisma.labChat.findFirst({\n where: {\n id: labChatId,\n conversation: {\n members: { some: { userId } },\n },\n },\n include: {\n conversation: { select: { id: true } },\n },\n });\n}\n\n/** @returns Lab chat if user can delete (teacher). */\nexport function findLabChatForDelete(labChatId: string, userId: string) {\n return prisma.labChat.findFirst({\n where: {\n id: labChatId,\n createdById: userId,\n },\n });\n}\n\n/** @returns Conversation members for mentioned user IDs. */\nexport function findMentionedMemberships(\n conversationId: string,\n userIds: string[]\n) {\n return prisma.conversationMember.findMany({\n where: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;SACvC;KACF,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,oBAAoB,CAAC,SAAiB,EAAE,MAAc;IACpE,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;QAC9B,KAAK,EAAE;YACL,EAAE,EAAE,SAAS;YACb,WAAW,EAAE,MAAM;SACpB;KACF,CAAC,CAAC;AACL,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,wBAAwB,CACtC,cAAsB,EACtB,OAAiB;IAEjB,OAAO,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC;QACxC,KAAK,EAAE;YACL,cAAc;YACd,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE;SACxB;KACF,CAAC,CAAC;AACL,CAAC","debug_id":"f519e035-445f-5c41-80c4-de7dd81d94e2"}
|
|
@@ -77,8 +77,8 @@ export declare function createEarlyAccessRequest(data: {
|
|
|
77
77
|
institutionSize: string;
|
|
78
78
|
}): import(".prisma/client").Prisma.Prisma__EarlyAccessRequestClient<{
|
|
79
79
|
id: string;
|
|
80
|
-
email: string;
|
|
81
80
|
createdAt: Date;
|
|
81
|
+
email: string;
|
|
82
82
|
institutionSize: string;
|
|
83
83
|
}, never, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
84
84
|
datasources: {
|
package/dist/models/message.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @returns User's membership in a conversation. */
|
|
2
2
|
export declare function findConversationMembership(conversationId: string, userId: string): import(".prisma/client").Prisma.Prisma__ConversationMemberClient<{
|
|
3
3
|
id: string;
|
|
4
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
4
5
|
userId: string;
|
|
5
6
|
conversationId: string;
|
|
6
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
7
7
|
joinedAt: Date;
|
|
8
8
|
hiddenAt: Date | null;
|
|
9
9
|
lastViewedAt: Date | null;
|
|
@@ -30,9 +30,9 @@ export declare function findMessages(conversationId: string, options: {
|
|
|
30
30
|
};
|
|
31
31
|
} & {
|
|
32
32
|
id: string;
|
|
33
|
+
createdAt: Date;
|
|
33
34
|
userId: string;
|
|
34
35
|
messageId: string;
|
|
35
|
-
createdAt: Date;
|
|
36
36
|
})[];
|
|
37
37
|
attachments: {
|
|
38
38
|
type: string;
|
|
@@ -51,17 +51,17 @@ export declare function findMessages(conversationId: string, options: {
|
|
|
51
51
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
52
52
|
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
53
53
|
id: string;
|
|
54
|
-
conversationId: string;
|
|
55
54
|
createdAt: Date;
|
|
55
|
+
conversationId: string;
|
|
56
56
|
content: string;
|
|
57
57
|
senderId: string;
|
|
58
58
|
})[]>;
|
|
59
59
|
/** @returns Memberships for mentioned users. */
|
|
60
60
|
export declare function findMentionedMemberships(conversationId: string, userIds: string[]): import(".prisma/client").Prisma.PrismaPromise<{
|
|
61
61
|
id: string;
|
|
62
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
62
63
|
userId: string;
|
|
63
64
|
conversationId: string;
|
|
64
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
65
65
|
joinedAt: Date;
|
|
66
66
|
hiddenAt: Date | null;
|
|
67
67
|
lastViewedAt: Date | null;
|
|
@@ -81,8 +81,8 @@ export declare function findMessageById(messageId: string): import(".prisma/clie
|
|
|
81
81
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
82
82
|
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
83
83
|
id: string;
|
|
84
|
-
conversationId: string;
|
|
85
84
|
createdAt: Date;
|
|
85
|
+
conversationId: string;
|
|
86
86
|
content: string;
|
|
87
87
|
senderId: string;
|
|
88
88
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -102,8 +102,8 @@ export declare function findMessageByIdMinimal(messageId: string): import(".pris
|
|
|
102
102
|
status: import(".prisma/client").$Enums.GenerationStatus | null;
|
|
103
103
|
meta: import("@prisma/client/runtime/library.js").JsonValue | null;
|
|
104
104
|
id: string;
|
|
105
|
-
conversationId: string;
|
|
106
105
|
createdAt: Date;
|
|
106
|
+
conversationId: string;
|
|
107
107
|
content: string;
|
|
108
108
|
senderId: string;
|
|
109
109
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
@@ -17,8 +17,8 @@ export declare function findClassWithStudent(classId: string, studentId: string)
|
|
|
17
17
|
/** @returns Submission for assignment and student. */
|
|
18
18
|
export declare function findSubmissionByAssignmentAndStudent(assignmentId: string, studentId: string): import(".prisma/client").Prisma.Prisma__SubmissionClient<{
|
|
19
19
|
id: string;
|
|
20
|
-
assignmentId: string;
|
|
21
20
|
createdAt: Date;
|
|
21
|
+
assignmentId: string;
|
|
22
22
|
modifiedAt: Date;
|
|
23
23
|
studentId: string;
|
|
24
24
|
extendedResponse: string | null;
|
|
@@ -51,8 +51,8 @@ export declare function findNewtonChatByIdAndMember(newtonChatId: string, userId
|
|
|
51
51
|
};
|
|
52
52
|
} & {
|
|
53
53
|
id: string;
|
|
54
|
-
assignmentId: string;
|
|
55
54
|
createdAt: Date;
|
|
55
|
+
assignmentId: string;
|
|
56
56
|
modifiedAt: Date;
|
|
57
57
|
studentId: string;
|
|
58
58
|
extendedResponse: string | null;
|
|
@@ -71,11 +71,11 @@ export declare function findNewtonChatByIdAndMember(newtonChatId: string, userId
|
|
|
71
71
|
};
|
|
72
72
|
} & {
|
|
73
73
|
id: string;
|
|
74
|
+
createdAt: Date;
|
|
75
|
+
updatedAt: Date;
|
|
74
76
|
submissionId: string;
|
|
75
77
|
conversationId: string;
|
|
76
|
-
createdAt: Date;
|
|
77
78
|
title: string;
|
|
78
|
-
updatedAt: Date;
|
|
79
79
|
}) | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, {
|
|
80
80
|
datasources: {
|
|
81
81
|
db: {
|
|
@@ -86,9 +86,9 @@ export declare function findNewtonChatByIdAndMember(newtonChatId: string, userId
|
|
|
86
86
|
/** @returns Conversation members for given user IDs. */
|
|
87
87
|
export declare function findConversationMembersByUserIds(conversationId: string, userIds: string[]): import(".prisma/client").Prisma.PrismaPromise<{
|
|
88
88
|
id: string;
|
|
89
|
+
role: import(".prisma/client").$Enums.ConversationRole;
|
|
89
90
|
userId: string;
|
|
90
91
|
conversationId: string;
|
|
91
|
-
role: import(".prisma/client").$Enums.ConversationRole;
|
|
92
92
|
joinedAt: Date;
|
|
93
93
|
hiddenAt: Date | null;
|
|
94
94
|
lastViewedAt: Date | null;
|