@studious-lms/server 1.16.1 → 1.17.0
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/routers/_app.d.ts +204 -0
- package/dist/routers/_app.d.ts.map +1 -1
- package/dist/routers/school.d.ts +102 -0
- package/dist/routers/school.d.ts.map +1 -1
- package/dist/routers/school.js +11 -3
- package/dist/routers/school.js.map +1 -1
- package/dist/services/school.d.ts +112 -0
- package/dist/services/school.d.ts.map +1 -1
- package/dist/services/school.js +213 -2
- package/dist/services/school.js.map +1 -1
- package/package.json +1 -1
- package/src/routers/school.ts +12 -0
- package/src/services/school.ts +231 -0
package/dist/services/school.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* School service - school admin workflow, memberships, and invites.
|
|
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]="db6efcf6-9a7f-5dfa-a71c-f6706018a154")}catch(e){}}();
|
|
6
6
|
import { SessionType } from "@prisma/client";
|
|
7
7
|
import { TRPCError } from "@trpc/server";
|
|
8
8
|
import { hash } from "bcryptjs";
|
|
@@ -408,6 +408,217 @@ export async function getStudentTimeline(userId, input) {
|
|
|
408
408
|
attendance: attendanceShaped,
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Role-aware overview used by `/view/[userId]`.
|
|
413
|
+
*
|
|
414
|
+
* - For STUDENT members it returns the same timeline as `getStudentTimeline`
|
|
415
|
+
* (events, assignments, attendance) so teachers/admins can audit progress.
|
|
416
|
+
* - For TEACHER/ADMIN members it returns their teaching agenda: every event in
|
|
417
|
+
* a class they teach plus their personal events, alongside the classes they
|
|
418
|
+
* run with enrolment counts.
|
|
419
|
+
*
|
|
420
|
+
* Permissions:
|
|
421
|
+
* - School admins can view anyone in the institution.
|
|
422
|
+
* - A teacher can view a STUDENT they share a class with.
|
|
423
|
+
* - A teacher/admin can always view their own overview.
|
|
424
|
+
*/
|
|
425
|
+
export async function getMemberTimeline(userId, input) {
|
|
426
|
+
const callerIsAdmin = Boolean(await findActiveSchoolAdminMembership(input.schoolId, userId));
|
|
427
|
+
const membership = await prisma.schoolMembership.findFirst({
|
|
428
|
+
where: {
|
|
429
|
+
schoolId: input.schoolId,
|
|
430
|
+
userId: input.memberId,
|
|
431
|
+
status: "ACTIVE",
|
|
432
|
+
},
|
|
433
|
+
select: {
|
|
434
|
+
role: true,
|
|
435
|
+
user: {
|
|
436
|
+
select: {
|
|
437
|
+
id: true,
|
|
438
|
+
username: true,
|
|
439
|
+
profile: { select: { displayName: true, profilePicture: true } },
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
if (!membership) {
|
|
445
|
+
throw new TRPCError({
|
|
446
|
+
code: "NOT_FOUND",
|
|
447
|
+
message: "This person is not in this institution",
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
const range = {
|
|
451
|
+
...(input.from ? { gte: input.from } : {}),
|
|
452
|
+
...(input.to ? { lte: input.to } : {}),
|
|
453
|
+
};
|
|
454
|
+
const hasRange = Object.keys(range).length > 0;
|
|
455
|
+
if (membership.role === "STUDENT") {
|
|
456
|
+
if (!callerIsAdmin) {
|
|
457
|
+
const sharedClass = await prisma.class.findFirst({
|
|
458
|
+
where: {
|
|
459
|
+
schoolId: input.schoolId,
|
|
460
|
+
teachers: { some: { id: userId } },
|
|
461
|
+
students: { some: { id: input.memberId } },
|
|
462
|
+
},
|
|
463
|
+
select: { id: true },
|
|
464
|
+
});
|
|
465
|
+
if (!sharedClass) {
|
|
466
|
+
throw new TRPCError({
|
|
467
|
+
code: "FORBIDDEN",
|
|
468
|
+
message: "You don't share a class with this student",
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const [events, assignments, attendance] = await Promise.all([
|
|
473
|
+
prisma.event.findMany({
|
|
474
|
+
where: {
|
|
475
|
+
userId: input.memberId,
|
|
476
|
+
...(hasRange ? { startTime: range } : {}),
|
|
477
|
+
},
|
|
478
|
+
select: {
|
|
479
|
+
id: true,
|
|
480
|
+
name: true,
|
|
481
|
+
startTime: true,
|
|
482
|
+
endTime: true,
|
|
483
|
+
location: true,
|
|
484
|
+
remarks: true,
|
|
485
|
+
color: true,
|
|
486
|
+
class: { select: { id: true, name: true, color: true } },
|
|
487
|
+
},
|
|
488
|
+
orderBy: { startTime: "asc" },
|
|
489
|
+
}),
|
|
490
|
+
prisma.assignment.findMany({
|
|
491
|
+
where: {
|
|
492
|
+
class: { students: { some: { id: input.memberId } } },
|
|
493
|
+
template: false,
|
|
494
|
+
...(hasRange ? { dueDate: range } : {}),
|
|
495
|
+
},
|
|
496
|
+
select: {
|
|
497
|
+
id: true,
|
|
498
|
+
title: true,
|
|
499
|
+
dueDate: true,
|
|
500
|
+
type: true,
|
|
501
|
+
graded: true,
|
|
502
|
+
maxGrade: true,
|
|
503
|
+
weight: true,
|
|
504
|
+
class: {
|
|
505
|
+
select: {
|
|
506
|
+
id: true,
|
|
507
|
+
name: true,
|
|
508
|
+
section: true,
|
|
509
|
+
subject: true,
|
|
510
|
+
color: true,
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
submissions: {
|
|
514
|
+
where: { studentId: input.memberId },
|
|
515
|
+
select: {
|
|
516
|
+
id: true,
|
|
517
|
+
submitted: true,
|
|
518
|
+
submittedAt: true,
|
|
519
|
+
returned: true,
|
|
520
|
+
gradeReceived: true,
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
orderBy: { dueDate: "asc" },
|
|
525
|
+
}),
|
|
526
|
+
prisma.attendance.findMany({
|
|
527
|
+
where: {
|
|
528
|
+
OR: [
|
|
529
|
+
{ present: { some: { id: input.memberId } } },
|
|
530
|
+
{ late: { some: { id: input.memberId } } },
|
|
531
|
+
{ absent: { some: { id: input.memberId } } },
|
|
532
|
+
],
|
|
533
|
+
...(hasRange ? { date: range } : {}),
|
|
534
|
+
},
|
|
535
|
+
select: {
|
|
536
|
+
id: true,
|
|
537
|
+
date: true,
|
|
538
|
+
class: { select: { id: true, name: true, color: true } },
|
|
539
|
+
present: { where: { id: input.memberId }, select: { id: true } },
|
|
540
|
+
late: { where: { id: input.memberId }, select: { id: true } },
|
|
541
|
+
absent: { where: { id: input.memberId }, select: { id: true } },
|
|
542
|
+
},
|
|
543
|
+
orderBy: { date: "asc" },
|
|
544
|
+
}),
|
|
545
|
+
]);
|
|
546
|
+
const attendanceShaped = attendance.map((record) => ({
|
|
547
|
+
id: record.id,
|
|
548
|
+
date: record.date,
|
|
549
|
+
class: record.class,
|
|
550
|
+
status: record.present.length
|
|
551
|
+
? "PRESENT"
|
|
552
|
+
: record.late.length
|
|
553
|
+
? "LATE"
|
|
554
|
+
: "ABSENT",
|
|
555
|
+
}));
|
|
556
|
+
return {
|
|
557
|
+
role: "STUDENT",
|
|
558
|
+
member: membership.user,
|
|
559
|
+
events,
|
|
560
|
+
assignments,
|
|
561
|
+
attendance: attendanceShaped,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
// TEACHER or ADMIN: only admins (or the member themselves) may view.
|
|
565
|
+
if (!callerIsAdmin && userId !== input.memberId) {
|
|
566
|
+
throw new TRPCError({
|
|
567
|
+
code: "FORBIDDEN",
|
|
568
|
+
message: "Only school admins can view this member",
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
const [events, classes] = await Promise.all([
|
|
572
|
+
prisma.event.findMany({
|
|
573
|
+
where: {
|
|
574
|
+
OR: [
|
|
575
|
+
{ userId: input.memberId },
|
|
576
|
+
{ class: { teachers: { some: { id: input.memberId } } } },
|
|
577
|
+
],
|
|
578
|
+
...(hasRange ? { startTime: range } : {}),
|
|
579
|
+
},
|
|
580
|
+
select: {
|
|
581
|
+
id: true,
|
|
582
|
+
name: true,
|
|
583
|
+
startTime: true,
|
|
584
|
+
endTime: true,
|
|
585
|
+
location: true,
|
|
586
|
+
remarks: true,
|
|
587
|
+
color: true,
|
|
588
|
+
class: { select: { id: true, name: true, color: true } },
|
|
589
|
+
},
|
|
590
|
+
orderBy: { startTime: "asc" },
|
|
591
|
+
}),
|
|
592
|
+
prisma.class.findMany({
|
|
593
|
+
where: {
|
|
594
|
+
schoolId: input.schoolId,
|
|
595
|
+
teachers: { some: { id: input.memberId } },
|
|
596
|
+
},
|
|
597
|
+
select: {
|
|
598
|
+
id: true,
|
|
599
|
+
name: true,
|
|
600
|
+
section: true,
|
|
601
|
+
subject: true,
|
|
602
|
+
color: true,
|
|
603
|
+
_count: { select: { students: true } },
|
|
604
|
+
},
|
|
605
|
+
orderBy: { name: "asc" },
|
|
606
|
+
}),
|
|
607
|
+
]);
|
|
608
|
+
return {
|
|
609
|
+
role: membership.role,
|
|
610
|
+
member: membership.user,
|
|
611
|
+
events,
|
|
612
|
+
classes: classes.map((c) => ({
|
|
613
|
+
id: c.id,
|
|
614
|
+
name: c.name,
|
|
615
|
+
section: c.section,
|
|
616
|
+
subject: c.subject,
|
|
617
|
+
color: c.color,
|
|
618
|
+
studentCount: c._count.students,
|
|
619
|
+
})),
|
|
620
|
+
};
|
|
621
|
+
}
|
|
411
622
|
export async function createInvite(userId, input) {
|
|
412
623
|
await requireSchoolAdmin(input.schoolId, userId);
|
|
413
624
|
// The institution invite flow is "new account only": if the email is
|
|
@@ -541,4 +752,4 @@ export async function acceptInvite(userId, token) {
|
|
|
541
752
|
return { membership };
|
|
542
753
|
}
|
|
543
754
|
//# sourceMappingURL=school.js.map
|
|
544
|
-
//# debugId=
|
|
755
|
+
//# debugId=db6efcf6-9a7f-5dfa-a71c-f6706018a154
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"school.js","sources":["services/school.ts"],"sourceRoot":"/","sourcesContent":["/**\n * School service - school admin workflow, memberships, and invites.\n */\nimport { SchoolMembershipRole, SessionType } from \"@prisma/client\";\nimport { TRPCError } from \"@trpc/server\";\nimport { hash } from \"bcryptjs\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { env } from \"../lib/config/env.js\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { sendMail } from \"../utils/email.js\";\nimport { generateUniqueUsername } from \"../utils/generateUsername.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n createSession,\n createUser,\n findUserByEmail,\n findUserById,\n findUserByUsername,\n} from \"../models/auth.js\";\nimport { upsertUserProfile } from \"../models/user.js\";\nimport {\n acceptSchoolInvite,\n countActiveAdmins,\n createSchoolInvite,\n createSchoolWithAdmin,\n findActiveSchoolAdminMembership,\n findPendingInviteByToken,\n findSchoolMembership,\n getSchoolById,\n getSchoolOverview,\n listSchoolClasses,\n listSchoolInvites,\n listSchoolMembers,\n listUserSchoolMemberships,\n removeSchoolMembershipPreservingContent,\n revokeSchoolInvite,\n updateSchoolMembershipRole,\n updateSchoolRecord,\n upsertSchoolMembership,\n} from \"../models/school.js\";\n\nasync function requireSchoolAdmin(schoolId: string, userId: string) {\n const membership = await findActiveSchoolAdminMembership(schoolId, userId);\n if (!membership) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Only school admins can perform this action\",\n });\n }\n return membership;\n}\n\nasync function requireSchoolMember(schoolId: string, userId: string) {\n const membership = await findSchoolMembership(schoolId, userId);\n if (!membership || membership.status !== \"ACTIVE\") {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You are not a member of this school\",\n });\n }\n return membership;\n}\n\nexport async function getCurrentSchool(userId: string, schoolId?: string) {\n const memberships = await listUserSchoolMemberships(userId);\n const activeMembership = schoolId\n ? memberships.find((membership) => membership.schoolId === schoolId)\n : memberships[0];\n\n const activeSchool = activeMembership?.school\n ? {\n id: activeMembership.school.id,\n name: activeMembership.school.name,\n description: activeMembership.school.description ?? null,\n subdomain: activeMembership.school.subdomain ?? null,\n logoId: activeMembership.school.logoId ?? null,\n // The path is the GCS object key — the frontend resolves it to a\n // signed URL through trpc.file.getSignedUrl when needed.\n logoPath: activeMembership.school.logo?.path ?? null,\n logoType: activeMembership.school.logo?.type ?? null,\n }\n : null;\n\n return {\n activeSchool,\n activeRole: activeMembership?.role ?? null,\n memberships,\n };\n}\n\nexport async function createSchoolRecord(\n userId: string,\n input: {\n name: string;\n description?: string;\n subdomain?: string;\n logoId?: string;\n }\n) {\n const school = await createSchoolWithAdmin({\n userId,\n name: input.name,\n subdomain: input.subdomain,\n logoId: input.logoId,\n });\n\n if (input.description) {\n await updateSchoolRecord(school.id, { description: input.description });\n }\n\n return { school };\n}\n\nexport async function updateSchoolDetails(\n userId: string,\n input: {\n schoolId: string;\n name?: string;\n description?: string | null;\n subdomain?: string | null;\n logoId?: string | null;\n }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const updated = await updateSchoolRecord(input.schoolId, {\n name: input.name,\n description: input.description,\n subdomain: input.subdomain,\n logoId: input.logoId,\n });\n return { school: updated };\n}\n\nexport async function getAdminOverview(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n const school = await getSchoolOverview(schoolId);\n if (!school) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"School not found\" });\n }\n\n const roleCounts = school.memberships.reduce(\n (counts, membership) => {\n counts[membership.role] += 1;\n return counts;\n },\n { ADMIN: 0, TEACHER: 0, STUDENT: 0 } satisfies Record<SchoolMembershipRole, number>\n );\n\n return {\n school: {\n id: school.id,\n name: school.name,\n subdomain: school.subdomain,\n counts: {\n classes: school._count.classes,\n members: school._count.memberships,\n pendingInvites: school._count.invites,\n ...roleCounts,\n },\n recentClasses: school.classes,\n recentInvites: school.invites,\n },\n };\n}\n\nexport async function listClasses(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n return { classes: await listSchoolClasses(schoolId) };\n}\n\nexport async function createSchoolClass(\n userId: string,\n input: {\n schoolId: string;\n name: string;\n section: string;\n subject: string;\n color?: string;\n departmentId?: string;\n teachers?: string[];\n students?: string[];\n }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n\n if (input.departmentId) {\n const dept = await prisma.department.findUnique({\n where: { id: input.departmentId },\n select: { schoolId: true },\n });\n if (!dept || dept.schoolId !== input.schoolId) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Department does not belong to this institution\",\n });\n }\n }\n\n const createdClass = await prisma.class.create({\n data: {\n name: input.name,\n section: input.section,\n subject: input.subject,\n color: input.color,\n schoolId: input.schoolId,\n departmentId: input.departmentId,\n teachers: input.teachers?.length\n ? { connect: input.teachers.map((id) => ({ id })) }\n : undefined,\n students: input.students?.length\n ? { connect: input.students.map((id) => ({ id })) }\n : undefined,\n },\n include: { teachers: true, students: true },\n });\n\n return { class: createdClass };\n}\n\nexport async function listMembers(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n return { members: await listSchoolMembers(schoolId) };\n}\n\nexport async function addMember(\n userId: string,\n input: { schoolId: string; memberUserId: string; role: SchoolMembershipRole }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const membership = await upsertSchoolMembership({\n schoolId: input.schoolId,\n userId: input.memberUserId,\n role: input.role,\n });\n return { membership };\n}\n\nexport async function updateMemberRole(\n userId: string,\n input: { schoolId: string; memberUserId: string; role: SchoolMembershipRole }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const current = await findSchoolMembership(input.schoolId, input.memberUserId);\n if (!current) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Member not found\" });\n }\n\n if (current.role === \"ADMIN\" && input.role !== \"ADMIN\") {\n const adminCount = await countActiveAdmins(input.schoolId);\n if (adminCount <= 1) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"A school must have at least one active admin\",\n });\n }\n }\n\n const membership = await updateSchoolMembershipRole(\n input.schoolId,\n input.memberUserId,\n input.role\n );\n return { membership };\n}\n\nexport async function removeMember(\n userId: string,\n input: { schoolId: string; memberUserId: string }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const current = await findSchoolMembership(input.schoolId, input.memberUserId);\n if (!current) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Member not found\" });\n }\n\n if (current.role === \"ADMIN\" && current.status === \"ACTIVE\") {\n const adminCount = await countActiveAdmins(input.schoolId);\n if (adminCount <= 1) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"A school must have at least one active admin\",\n });\n }\n }\n\n await removeSchoolMembershipPreservingContent(input.schoolId, input.memberUserId);\n return { success: true };\n}\n\nexport async function listInvites(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n return { invites: await listSchoolInvites(schoolId) };\n}\n\n/**\n * Issue a direct-upload URL for a school-level asset (e.g. logo). The file\n * is created unattached and is owned by the requester until they associate\n * it via school.create or school.update.\n */\nexport async function getSchoolAssetUploadUrl(\n userId: string,\n input: { fileName: string; fileType: string; fileSize: number }\n) {\n const { createDirectUploadFiles } = await import(\"../lib/fileUpload.js\");\n const [uploadFile] = await createDirectUploadFiles(\n [\n {\n name: input.fileName,\n type: input.fileType,\n size: input.fileSize,\n },\n ],\n userId\n );\n return uploadFile;\n}\n\nexport async function confirmSchoolAssetUpload(\n userId: string,\n fileId: string,\n uploadSuccess: boolean\n) {\n const { confirmDirectUpload } = await import(\"../lib/fileUpload.js\");\n await confirmDirectUpload(fileId, uploadSuccess);\n return { success: true };\n}\n\n/**\n * Lightweight ID-only listing used to mask external user names in the UI.\n * Any active institution member can fetch this.\n */\nexport async function listMemberIds(userId: string, schoolId: string) {\n await requireSchoolMember(schoolId, userId);\n const rows = await prisma.schoolMembership.findMany({\n where: { schoolId, status: \"ACTIVE\" },\n select: { userId: true },\n });\n return rows.map((r) => r.userId);\n}\n\n/** Search active institution members by username, displayName, or email. */\nexport async function searchMembers(\n userId: string,\n schoolId: string,\n query: string,\n limit = 10,\n role?: \"ADMIN\" | \"TEACHER\" | \"STUDENT\"\n) {\n await requireSchoolMember(schoolId, userId);\n const trimmed = query.trim();\n if (!trimmed) return [];\n return prisma.user.findMany({\n where: {\n id: { not: userId },\n schoolMemberships: {\n some: {\n schoolId,\n status: \"ACTIVE\",\n ...(role ? { role } : {}),\n },\n },\n OR: [\n { username: { contains: trimmed, mode: \"insensitive\" } },\n { email: { contains: trimmed, mode: \"insensitive\" } },\n {\n profile: {\n displayName: { contains: trimmed, mode: \"insensitive\" },\n },\n },\n ],\n },\n take: limit,\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n schoolMemberships: {\n where: { schoolId, status: \"ACTIVE\" },\n select: { role: true },\n },\n },\n orderBy: { username: \"asc\" },\n });\n}\n\n/**\n * Combined student timeline: calendar events + assignments + attendance.\n * Visible to school admins (any student) and to teachers who share at least\n * one class with the student.\n */\nexport async function getStudentTimeline(\n userId: string,\n input: {\n schoolId: string;\n studentId: string;\n from?: Date;\n to?: Date;\n }\n) {\n const isAdmin = await findActiveSchoolAdminMembership(\n input.schoolId,\n userId\n );\n\n // Permission: admin OR shares a class.\n if (!isAdmin) {\n const sharedClass = await prisma.class.findFirst({\n where: {\n schoolId: input.schoolId,\n teachers: { some: { id: userId } },\n students: { some: { id: input.studentId } },\n },\n select: { id: true },\n });\n if (!sharedClass) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You don't share a class with this student\",\n });\n }\n }\n\n // Make sure student is in the institution.\n const studentMembership = await prisma.schoolMembership.findFirst({\n where: { schoolId: input.schoolId, userId: input.studentId, status: \"ACTIVE\" },\n select: { role: true, user: { select: { id: true, username: true, profile: { select: { displayName: true, profilePicture: true } } } } },\n });\n if (!studentMembership) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Student is not in this institution\",\n });\n }\n\n const range = {\n ...(input.from ? { gte: input.from } : {}),\n ...(input.to ? { lte: input.to } : {}),\n };\n const hasRange = Object.keys(range).length > 0;\n\n const [events, assignments, attendance] = await Promise.all([\n prisma.event.findMany({\n where: {\n userId: input.studentId,\n ...(hasRange ? { startTime: range } : {}),\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n class: { select: { id: true, name: true, color: true } },\n },\n orderBy: { startTime: \"asc\" },\n }),\n prisma.assignment.findMany({\n where: {\n class: {\n students: { some: { id: input.studentId } },\n },\n template: false,\n ...(hasRange ? { dueDate: range } : {}),\n },\n select: {\n id: true,\n title: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n weight: true,\n class: {\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n color: true,\n },\n },\n submissions: {\n where: { studentId: input.studentId },\n select: {\n id: true,\n submitted: true,\n submittedAt: true,\n returned: true,\n gradeReceived: true,\n },\n },\n },\n orderBy: { dueDate: \"asc\" },\n }),\n prisma.attendance.findMany({\n where: {\n OR: [\n { present: { some: { id: input.studentId } } },\n { late: { some: { id: input.studentId } } },\n { absent: { some: { id: input.studentId } } },\n ],\n ...(hasRange ? { date: range } : {}),\n },\n select: {\n id: true,\n date: true,\n class: { select: { id: true, name: true, color: true } },\n present: { where: { id: input.studentId }, select: { id: true } },\n late: { where: { id: input.studentId }, select: { id: true } },\n absent: { where: { id: input.studentId }, select: { id: true } },\n },\n orderBy: { date: \"asc\" },\n }),\n ]);\n\n const attendanceShaped = attendance.map((record) => ({\n id: record.id,\n date: record.date,\n class: record.class,\n status: record.present.length\n ? (\"PRESENT\" as const)\n : record.late.length\n ? (\"LATE\" as const)\n : (\"ABSENT\" as const),\n }));\n\n return {\n student: studentMembership.user,\n events,\n assignments,\n attendance: attendanceShaped,\n };\n}\n\nexport async function createInvite(\n userId: string,\n input: {\n schoolId: string;\n email: string;\n role: SchoolMembershipRole;\n /** Optional display name set by the inviting admin. If omitted the user\n * picks their own when they complete the password reset flow. */\n displayName?: string;\n /** Optional username; if omitted we generate a friendly random one. */\n username?: string;\n }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n\n // The institution invite flow is \"new account only\": if the email is\n // already in use we reject. This keeps the join experience simple — every\n // new institution member always lands on a password reset link.\n const existingUser = await findUserByEmail(input.email);\n if (existingUser) {\n throw new TRPCError({\n code: \"CONFLICT\",\n message:\n \"An account with this email already exists. Ask them to log in and you can add them via search.\",\n });\n }\n\n let username: string;\n if (input.username) {\n const taken = await findUserByUsername(input.username);\n if (taken) {\n throw new TRPCError({\n code: \"CONFLICT\",\n message: \"Username already taken\",\n });\n }\n username = input.username;\n } else {\n username = await generateUniqueUsername(async (candidate) => {\n const existing = await findUserByUsername(candidate);\n return Boolean(existing);\n });\n }\n\n const placeholderPassword = await hash(uuidv4(), 10);\n const user = await createUser({\n username,\n email: input.email,\n password: placeholderPassword,\n verified: true,\n });\n const createdUser = { id: user.id, username: user.username };\n\n if (input.displayName) {\n await upsertUserProfile(user.id, { displayName: input.displayName });\n }\n\n const resetSession = await createSession({\n id: uuidv4(),\n type: SessionType.PASSWORD_RESET,\n userId: user.id,\n expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 14),\n });\n const passwordResetToken = resetSession.id;\n\n const token = uuidv4();\n const invite = await createSchoolInvite({\n schoolId: input.schoolId,\n invitedById: userId,\n email: input.email,\n role: input.role,\n token,\n expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 14),\n });\n\n await acceptSchoolInvite(invite.id, createdUser.id);\n\n const passwordResetUrl = `${env.NEXT_PUBLIC_APP_URL}/reset-password/${passwordResetToken}`;\n const emailLines = [\n `You've been added to ${invite.school.name} on Studious.`,\n \"\",\n `We created an account for you with the username \"${createdUser.username}\".`,\n input.displayName\n ? `Your name is set to \"${input.displayName}\" — you can change it after signing in.`\n : `You can set your name once you sign in for the first time.`,\n \"\",\n `Set your password to get started: ${passwordResetUrl}`,\n ];\n\n try {\n await sendMail({\n from: \"hello@studious.sh\",\n to: input.email,\n subject: `Join ${invite.school.name} on Studious`,\n text: emailLines.join(\"\\n\"),\n });\n } catch (err) {\n logger.error(\"Failed to send school invite email\", {\n schoolId: input.schoolId,\n email: input.email,\n err,\n });\n }\n\n return {\n invite,\n createdUser,\n passwordResetUrl,\n };\n}\n\nexport async function revokeInvite(\n userId: string,\n input: { schoolId: string; inviteId: string }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n return { invite: await revokeSchoolInvite(input.inviteId, input.schoolId) };\n}\n\nexport async function getInvite(token: string) {\n const invite = await findPendingInviteByToken(token);\n if (!invite || invite.status !== \"PENDING\") {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Invite not found\" });\n }\n if (invite.expiresAt < new Date()) {\n throw new TRPCError({ code: \"UNAUTHORIZED\", message: \"Invite expired\" });\n }\n return {\n invite: {\n id: invite.id,\n email: invite.email,\n role: invite.role,\n school: invite.school,\n expiresAt: invite.expiresAt,\n },\n };\n}\n\nexport async function acceptInvite(userId: string, token: string) {\n const invite = await findPendingInviteByToken(token);\n if (!invite || invite.status !== \"PENDING\") {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Invite not found\" });\n }\n if (invite.expiresAt < new Date()) {\n throw new TRPCError({ code: \"UNAUTHORIZED\", message: \"Invite expired\" });\n }\n\n const user = await findUserById(userId);\n if (!user) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"User not found\" });\n }\n if (user.email.toLowerCase() !== invite.email.toLowerCase()) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"This invite was sent to a different account\",\n });\n }\n\n const membership = await acceptSchoolInvite(invite.id, userId);\n return { membership };\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAwB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;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,SAAS,CAAC;YAClB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,6CAA6C;SACvD,CAAC,CAAC;IACL,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC/D,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC","debug_id":"7f618a77-4221-5aac-8804-f13e3208068a"}
|
|
1
|
+
{"version":3,"file":"school.js","sources":["services/school.ts"],"sourceRoot":"/","sourcesContent":["/**\n * School service - school admin workflow, memberships, and invites.\n */\nimport { SchoolMembershipRole, SessionType } from \"@prisma/client\";\nimport { TRPCError } from \"@trpc/server\";\nimport { hash } from \"bcryptjs\";\nimport { v4 as uuidv4 } from \"uuid\";\nimport { env } from \"../lib/config/env.js\";\nimport { prisma } from \"../lib/prisma.js\";\nimport { sendMail } from \"../utils/email.js\";\nimport { generateUniqueUsername } from \"../utils/generateUsername.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n createSession,\n createUser,\n findUserByEmail,\n findUserById,\n findUserByUsername,\n} from \"../models/auth.js\";\nimport { upsertUserProfile } from \"../models/user.js\";\nimport {\n acceptSchoolInvite,\n countActiveAdmins,\n createSchoolInvite,\n createSchoolWithAdmin,\n findActiveSchoolAdminMembership,\n findPendingInviteByToken,\n findSchoolMembership,\n getSchoolById,\n getSchoolOverview,\n listSchoolClasses,\n listSchoolInvites,\n listSchoolMembers,\n listUserSchoolMemberships,\n removeSchoolMembershipPreservingContent,\n revokeSchoolInvite,\n updateSchoolMembershipRole,\n updateSchoolRecord,\n upsertSchoolMembership,\n} from \"../models/school.js\";\n\nasync function requireSchoolAdmin(schoolId: string, userId: string) {\n const membership = await findActiveSchoolAdminMembership(schoolId, userId);\n if (!membership) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Only school admins can perform this action\",\n });\n }\n return membership;\n}\n\nasync function requireSchoolMember(schoolId: string, userId: string) {\n const membership = await findSchoolMembership(schoolId, userId);\n if (!membership || membership.status !== \"ACTIVE\") {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You are not a member of this school\",\n });\n }\n return membership;\n}\n\nexport async function getCurrentSchool(userId: string, schoolId?: string) {\n const memberships = await listUserSchoolMemberships(userId);\n const activeMembership = schoolId\n ? memberships.find((membership) => membership.schoolId === schoolId)\n : memberships[0];\n\n const activeSchool = activeMembership?.school\n ? {\n id: activeMembership.school.id,\n name: activeMembership.school.name,\n description: activeMembership.school.description ?? null,\n subdomain: activeMembership.school.subdomain ?? null,\n logoId: activeMembership.school.logoId ?? null,\n // The path is the GCS object key — the frontend resolves it to a\n // signed URL through trpc.file.getSignedUrl when needed.\n logoPath: activeMembership.school.logo?.path ?? null,\n logoType: activeMembership.school.logo?.type ?? null,\n }\n : null;\n\n return {\n activeSchool,\n activeRole: activeMembership?.role ?? null,\n memberships,\n };\n}\n\nexport async function createSchoolRecord(\n userId: string,\n input: {\n name: string;\n description?: string;\n subdomain?: string;\n logoId?: string;\n }\n) {\n const school = await createSchoolWithAdmin({\n userId,\n name: input.name,\n subdomain: input.subdomain,\n logoId: input.logoId,\n });\n\n if (input.description) {\n await updateSchoolRecord(school.id, { description: input.description });\n }\n\n return { school };\n}\n\nexport async function updateSchoolDetails(\n userId: string,\n input: {\n schoolId: string;\n name?: string;\n description?: string | null;\n subdomain?: string | null;\n logoId?: string | null;\n }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const updated = await updateSchoolRecord(input.schoolId, {\n name: input.name,\n description: input.description,\n subdomain: input.subdomain,\n logoId: input.logoId,\n });\n return { school: updated };\n}\n\nexport async function getAdminOverview(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n const school = await getSchoolOverview(schoolId);\n if (!school) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"School not found\" });\n }\n\n const roleCounts = school.memberships.reduce(\n (counts, membership) => {\n counts[membership.role] += 1;\n return counts;\n },\n { ADMIN: 0, TEACHER: 0, STUDENT: 0 } satisfies Record<SchoolMembershipRole, number>\n );\n\n return {\n school: {\n id: school.id,\n name: school.name,\n subdomain: school.subdomain,\n counts: {\n classes: school._count.classes,\n members: school._count.memberships,\n pendingInvites: school._count.invites,\n ...roleCounts,\n },\n recentClasses: school.classes,\n recentInvites: school.invites,\n },\n };\n}\n\nexport async function listClasses(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n return { classes: await listSchoolClasses(schoolId) };\n}\n\nexport async function createSchoolClass(\n userId: string,\n input: {\n schoolId: string;\n name: string;\n section: string;\n subject: string;\n color?: string;\n departmentId?: string;\n teachers?: string[];\n students?: string[];\n }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n\n if (input.departmentId) {\n const dept = await prisma.department.findUnique({\n where: { id: input.departmentId },\n select: { schoolId: true },\n });\n if (!dept || dept.schoolId !== input.schoolId) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Department does not belong to this institution\",\n });\n }\n }\n\n const createdClass = await prisma.class.create({\n data: {\n name: input.name,\n section: input.section,\n subject: input.subject,\n color: input.color,\n schoolId: input.schoolId,\n departmentId: input.departmentId,\n teachers: input.teachers?.length\n ? { connect: input.teachers.map((id) => ({ id })) }\n : undefined,\n students: input.students?.length\n ? { connect: input.students.map((id) => ({ id })) }\n : undefined,\n },\n include: { teachers: true, students: true },\n });\n\n return { class: createdClass };\n}\n\nexport async function listMembers(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n return { members: await listSchoolMembers(schoolId) };\n}\n\nexport async function addMember(\n userId: string,\n input: { schoolId: string; memberUserId: string; role: SchoolMembershipRole }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const membership = await upsertSchoolMembership({\n schoolId: input.schoolId,\n userId: input.memberUserId,\n role: input.role,\n });\n return { membership };\n}\n\nexport async function updateMemberRole(\n userId: string,\n input: { schoolId: string; memberUserId: string; role: SchoolMembershipRole }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const current = await findSchoolMembership(input.schoolId, input.memberUserId);\n if (!current) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Member not found\" });\n }\n\n if (current.role === \"ADMIN\" && input.role !== \"ADMIN\") {\n const adminCount = await countActiveAdmins(input.schoolId);\n if (adminCount <= 1) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"A school must have at least one active admin\",\n });\n }\n }\n\n const membership = await updateSchoolMembershipRole(\n input.schoolId,\n input.memberUserId,\n input.role\n );\n return { membership };\n}\n\nexport async function removeMember(\n userId: string,\n input: { schoolId: string; memberUserId: string }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n const current = await findSchoolMembership(input.schoolId, input.memberUserId);\n if (!current) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Member not found\" });\n }\n\n if (current.role === \"ADMIN\" && current.status === \"ACTIVE\") {\n const adminCount = await countActiveAdmins(input.schoolId);\n if (adminCount <= 1) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"A school must have at least one active admin\",\n });\n }\n }\n\n await removeSchoolMembershipPreservingContent(input.schoolId, input.memberUserId);\n return { success: true };\n}\n\nexport async function listInvites(userId: string, schoolId: string) {\n await requireSchoolAdmin(schoolId, userId);\n return { invites: await listSchoolInvites(schoolId) };\n}\n\n/**\n * Issue a direct-upload URL for a school-level asset (e.g. logo). The file\n * is created unattached and is owned by the requester until they associate\n * it via school.create or school.update.\n */\nexport async function getSchoolAssetUploadUrl(\n userId: string,\n input: { fileName: string; fileType: string; fileSize: number }\n) {\n const { createDirectUploadFiles } = await import(\"../lib/fileUpload.js\");\n const [uploadFile] = await createDirectUploadFiles(\n [\n {\n name: input.fileName,\n type: input.fileType,\n size: input.fileSize,\n },\n ],\n userId\n );\n return uploadFile;\n}\n\nexport async function confirmSchoolAssetUpload(\n userId: string,\n fileId: string,\n uploadSuccess: boolean\n) {\n const { confirmDirectUpload } = await import(\"../lib/fileUpload.js\");\n await confirmDirectUpload(fileId, uploadSuccess);\n return { success: true };\n}\n\n/**\n * Lightweight ID-only listing used to mask external user names in the UI.\n * Any active institution member can fetch this.\n */\nexport async function listMemberIds(userId: string, schoolId: string) {\n await requireSchoolMember(schoolId, userId);\n const rows = await prisma.schoolMembership.findMany({\n where: { schoolId, status: \"ACTIVE\" },\n select: { userId: true },\n });\n return rows.map((r) => r.userId);\n}\n\n/** Search active institution members by username, displayName, or email. */\nexport async function searchMembers(\n userId: string,\n schoolId: string,\n query: string,\n limit = 10,\n role?: \"ADMIN\" | \"TEACHER\" | \"STUDENT\"\n) {\n await requireSchoolMember(schoolId, userId);\n const trimmed = query.trim();\n if (!trimmed) return [];\n return prisma.user.findMany({\n where: {\n id: { not: userId },\n schoolMemberships: {\n some: {\n schoolId,\n status: \"ACTIVE\",\n ...(role ? { role } : {}),\n },\n },\n OR: [\n { username: { contains: trimmed, mode: \"insensitive\" } },\n { email: { contains: trimmed, mode: \"insensitive\" } },\n {\n profile: {\n displayName: { contains: trimmed, mode: \"insensitive\" },\n },\n },\n ],\n },\n take: limit,\n select: {\n id: true,\n username: true,\n profile: {\n select: {\n displayName: true,\n profilePicture: true,\n profilePictureThumbnail: true,\n },\n },\n schoolMemberships: {\n where: { schoolId, status: \"ACTIVE\" },\n select: { role: true },\n },\n },\n orderBy: { username: \"asc\" },\n });\n}\n\n/**\n * Combined student timeline: calendar events + assignments + attendance.\n * Visible to school admins (any student) and to teachers who share at least\n * one class with the student.\n */\nexport async function getStudentTimeline(\n userId: string,\n input: {\n schoolId: string;\n studentId: string;\n from?: Date;\n to?: Date;\n }\n) {\n const isAdmin = await findActiveSchoolAdminMembership(\n input.schoolId,\n userId\n );\n\n // Permission: admin OR shares a class.\n if (!isAdmin) {\n const sharedClass = await prisma.class.findFirst({\n where: {\n schoolId: input.schoolId,\n teachers: { some: { id: userId } },\n students: { some: { id: input.studentId } },\n },\n select: { id: true },\n });\n if (!sharedClass) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You don't share a class with this student\",\n });\n }\n }\n\n // Make sure student is in the institution.\n const studentMembership = await prisma.schoolMembership.findFirst({\n where: { schoolId: input.schoolId, userId: input.studentId, status: \"ACTIVE\" },\n select: { role: true, user: { select: { id: true, username: true, profile: { select: { displayName: true, profilePicture: true } } } } },\n });\n if (!studentMembership) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"Student is not in this institution\",\n });\n }\n\n const range = {\n ...(input.from ? { gte: input.from } : {}),\n ...(input.to ? { lte: input.to } : {}),\n };\n const hasRange = Object.keys(range).length > 0;\n\n const [events, assignments, attendance] = await Promise.all([\n prisma.event.findMany({\n where: {\n userId: input.studentId,\n ...(hasRange ? { startTime: range } : {}),\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n class: { select: { id: true, name: true, color: true } },\n },\n orderBy: { startTime: \"asc\" },\n }),\n prisma.assignment.findMany({\n where: {\n class: {\n students: { some: { id: input.studentId } },\n },\n template: false,\n ...(hasRange ? { dueDate: range } : {}),\n },\n select: {\n id: true,\n title: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n weight: true,\n class: {\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n color: true,\n },\n },\n submissions: {\n where: { studentId: input.studentId },\n select: {\n id: true,\n submitted: true,\n submittedAt: true,\n returned: true,\n gradeReceived: true,\n },\n },\n },\n orderBy: { dueDate: \"asc\" },\n }),\n prisma.attendance.findMany({\n where: {\n OR: [\n { present: { some: { id: input.studentId } } },\n { late: { some: { id: input.studentId } } },\n { absent: { some: { id: input.studentId } } },\n ],\n ...(hasRange ? { date: range } : {}),\n },\n select: {\n id: true,\n date: true,\n class: { select: { id: true, name: true, color: true } },\n present: { where: { id: input.studentId }, select: { id: true } },\n late: { where: { id: input.studentId }, select: { id: true } },\n absent: { where: { id: input.studentId }, select: { id: true } },\n },\n orderBy: { date: \"asc\" },\n }),\n ]);\n\n const attendanceShaped = attendance.map((record) => ({\n id: record.id,\n date: record.date,\n class: record.class,\n status: record.present.length\n ? (\"PRESENT\" as const)\n : record.late.length\n ? (\"LATE\" as const)\n : (\"ABSENT\" as const),\n }));\n\n return {\n student: studentMembership.user,\n events,\n assignments,\n attendance: attendanceShaped,\n };\n}\n\n/**\n * Role-aware overview used by `/view/[userId]`.\n *\n * - For STUDENT members it returns the same timeline as `getStudentTimeline`\n * (events, assignments, attendance) so teachers/admins can audit progress.\n * - For TEACHER/ADMIN members it returns their teaching agenda: every event in\n * a class they teach plus their personal events, alongside the classes they\n * run with enrolment counts.\n *\n * Permissions:\n * - School admins can view anyone in the institution.\n * - A teacher can view a STUDENT they share a class with.\n * - A teacher/admin can always view their own overview.\n */\nexport async function getMemberTimeline(\n userId: string,\n input: {\n schoolId: string;\n memberId: string;\n from?: Date;\n to?: Date;\n }\n) {\n const callerIsAdmin = Boolean(\n await findActiveSchoolAdminMembership(input.schoolId, userId)\n );\n\n const membership = await prisma.schoolMembership.findFirst({\n where: {\n schoolId: input.schoolId,\n userId: input.memberId,\n status: \"ACTIVE\",\n },\n select: {\n role: true,\n user: {\n select: {\n id: true,\n username: true,\n profile: { select: { displayName: true, profilePicture: true } },\n },\n },\n },\n });\n if (!membership) {\n throw new TRPCError({\n code: \"NOT_FOUND\",\n message: \"This person is not in this institution\",\n });\n }\n\n const range = {\n ...(input.from ? { gte: input.from } : {}),\n ...(input.to ? { lte: input.to } : {}),\n };\n const hasRange = Object.keys(range).length > 0;\n\n if (membership.role === \"STUDENT\") {\n if (!callerIsAdmin) {\n const sharedClass = await prisma.class.findFirst({\n where: {\n schoolId: input.schoolId,\n teachers: { some: { id: userId } },\n students: { some: { id: input.memberId } },\n },\n select: { id: true },\n });\n if (!sharedClass) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"You don't share a class with this student\",\n });\n }\n }\n\n const [events, assignments, attendance] = await Promise.all([\n prisma.event.findMany({\n where: {\n userId: input.memberId,\n ...(hasRange ? { startTime: range } : {}),\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n class: { select: { id: true, name: true, color: true } },\n },\n orderBy: { startTime: \"asc\" },\n }),\n prisma.assignment.findMany({\n where: {\n class: { students: { some: { id: input.memberId } } },\n template: false,\n ...(hasRange ? { dueDate: range } : {}),\n },\n select: {\n id: true,\n title: true,\n dueDate: true,\n type: true,\n graded: true,\n maxGrade: true,\n weight: true,\n class: {\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n color: true,\n },\n },\n submissions: {\n where: { studentId: input.memberId },\n select: {\n id: true,\n submitted: true,\n submittedAt: true,\n returned: true,\n gradeReceived: true,\n },\n },\n },\n orderBy: { dueDate: \"asc\" },\n }),\n prisma.attendance.findMany({\n where: {\n OR: [\n { present: { some: { id: input.memberId } } },\n { late: { some: { id: input.memberId } } },\n { absent: { some: { id: input.memberId } } },\n ],\n ...(hasRange ? { date: range } : {}),\n },\n select: {\n id: true,\n date: true,\n class: { select: { id: true, name: true, color: true } },\n present: { where: { id: input.memberId }, select: { id: true } },\n late: { where: { id: input.memberId }, select: { id: true } },\n absent: { where: { id: input.memberId }, select: { id: true } },\n },\n orderBy: { date: \"asc\" },\n }),\n ]);\n\n const attendanceShaped = attendance.map((record) => ({\n id: record.id,\n date: record.date,\n class: record.class,\n status: record.present.length\n ? (\"PRESENT\" as const)\n : record.late.length\n ? (\"LATE\" as const)\n : (\"ABSENT\" as const),\n }));\n\n return {\n role: \"STUDENT\" as const,\n member: membership.user,\n events,\n assignments,\n attendance: attendanceShaped,\n };\n }\n\n // TEACHER or ADMIN: only admins (or the member themselves) may view.\n if (!callerIsAdmin && userId !== input.memberId) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"Only school admins can view this member\",\n });\n }\n\n const [events, classes] = await Promise.all([\n prisma.event.findMany({\n where: {\n OR: [\n { userId: input.memberId },\n { class: { teachers: { some: { id: input.memberId } } } },\n ],\n ...(hasRange ? { startTime: range } : {}),\n },\n select: {\n id: true,\n name: true,\n startTime: true,\n endTime: true,\n location: true,\n remarks: true,\n color: true,\n class: { select: { id: true, name: true, color: true } },\n },\n orderBy: { startTime: \"asc\" },\n }),\n prisma.class.findMany({\n where: {\n schoolId: input.schoolId,\n teachers: { some: { id: input.memberId } },\n },\n select: {\n id: true,\n name: true,\n section: true,\n subject: true,\n color: true,\n _count: { select: { students: true } },\n },\n orderBy: { name: \"asc\" },\n }),\n ]);\n\n return {\n role: membership.role as \"TEACHER\" | \"ADMIN\",\n member: membership.user,\n events,\n classes: classes.map((c) => ({\n id: c.id,\n name: c.name,\n section: c.section,\n subject: c.subject,\n color: c.color,\n studentCount: c._count.students,\n })),\n };\n}\n\nexport async function createInvite(\n userId: string,\n input: {\n schoolId: string;\n email: string;\n role: SchoolMembershipRole;\n /** Optional display name set by the inviting admin. If omitted the user\n * picks their own when they complete the password reset flow. */\n displayName?: string;\n /** Optional username; if omitted we generate a friendly random one. */\n username?: string;\n }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n\n // The institution invite flow is \"new account only\": if the email is\n // already in use we reject. This keeps the join experience simple — every\n // new institution member always lands on a password reset link.\n const existingUser = await findUserByEmail(input.email);\n if (existingUser) {\n throw new TRPCError({\n code: \"CONFLICT\",\n message:\n \"An account with this email already exists. Ask them to log in and you can add them via search.\",\n });\n }\n\n let username: string;\n if (input.username) {\n const taken = await findUserByUsername(input.username);\n if (taken) {\n throw new TRPCError({\n code: \"CONFLICT\",\n message: \"Username already taken\",\n });\n }\n username = input.username;\n } else {\n username = await generateUniqueUsername(async (candidate) => {\n const existing = await findUserByUsername(candidate);\n return Boolean(existing);\n });\n }\n\n const placeholderPassword = await hash(uuidv4(), 10);\n const user = await createUser({\n username,\n email: input.email,\n password: placeholderPassword,\n verified: true,\n });\n const createdUser = { id: user.id, username: user.username };\n\n if (input.displayName) {\n await upsertUserProfile(user.id, { displayName: input.displayName });\n }\n\n const resetSession = await createSession({\n id: uuidv4(),\n type: SessionType.PASSWORD_RESET,\n userId: user.id,\n expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 14),\n });\n const passwordResetToken = resetSession.id;\n\n const token = uuidv4();\n const invite = await createSchoolInvite({\n schoolId: input.schoolId,\n invitedById: userId,\n email: input.email,\n role: input.role,\n token,\n expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 14),\n });\n\n await acceptSchoolInvite(invite.id, createdUser.id);\n\n const passwordResetUrl = `${env.NEXT_PUBLIC_APP_URL}/reset-password/${passwordResetToken}`;\n const emailLines = [\n `You've been added to ${invite.school.name} on Studious.`,\n \"\",\n `We created an account for you with the username \"${createdUser.username}\".`,\n input.displayName\n ? `Your name is set to \"${input.displayName}\" — you can change it after signing in.`\n : `You can set your name once you sign in for the first time.`,\n \"\",\n `Set your password to get started: ${passwordResetUrl}`,\n ];\n\n try {\n await sendMail({\n from: \"hello@studious.sh\",\n to: input.email,\n subject: `Join ${invite.school.name} on Studious`,\n text: emailLines.join(\"\\n\"),\n });\n } catch (err) {\n logger.error(\"Failed to send school invite email\", {\n schoolId: input.schoolId,\n email: input.email,\n err,\n });\n }\n\n return {\n invite,\n createdUser,\n passwordResetUrl,\n };\n}\n\nexport async function revokeInvite(\n userId: string,\n input: { schoolId: string; inviteId: string }\n) {\n await requireSchoolAdmin(input.schoolId, userId);\n return { invite: await revokeSchoolInvite(input.inviteId, input.schoolId) };\n}\n\nexport async function getInvite(token: string) {\n const invite = await findPendingInviteByToken(token);\n if (!invite || invite.status !== \"PENDING\") {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Invite not found\" });\n }\n if (invite.expiresAt < new Date()) {\n throw new TRPCError({ code: \"UNAUTHORIZED\", message: \"Invite expired\" });\n }\n return {\n invite: {\n id: invite.id,\n email: invite.email,\n role: invite.role,\n school: invite.school,\n expiresAt: invite.expiresAt,\n },\n };\n}\n\nexport async function acceptInvite(userId: string, token: string) {\n const invite = await findPendingInviteByToken(token);\n if (!invite || invite.status !== \"PENDING\") {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"Invite not found\" });\n }\n if (invite.expiresAt < new Date()) {\n throw new TRPCError({ code: \"UNAUTHORIZED\", message: \"Invite expired\" });\n }\n\n const user = await findUserById(userId);\n if (!user) {\n throw new TRPCError({ code: \"NOT_FOUND\", message: \"User not found\" });\n }\n if (user.email.toLowerCase() !== invite.email.toLowerCase()) {\n throw new TRPCError({\n code: \"FORBIDDEN\",\n message: \"This invite was sent to a different account\",\n });\n }\n\n const membership = await acceptSchoolInvite(invite.id, userId);\n return { membership };\n}\n"],"names":[],"mappings":"AAAA;;GAEG;;;AACH,OAAO,EAAwB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,UAAU,EACV,eAAe,EACf,YAAY,EACZ,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,+BAA+B,EAC/B,wBAAwB,EACxB,oBAAoB,EAEpB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,uCAAuC,EACvC,kBAAkB,EAClB,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,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CAAC,CAAC;IACxE,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QAC5D,MAAM,IAAI,SAAS,CAAC;YAClB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,6CAA6C;SACvD,CAAC,CAAC;IACL,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC/D,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC","debug_id":"db6efcf6-9a7f-5dfa-a71c-f6706018a154"}
|
package/package.json
CHANGED
package/src/routers/school.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
getAdminOverview,
|
|
15
15
|
getCurrentSchool,
|
|
16
16
|
getInvite,
|
|
17
|
+
getMemberTimeline,
|
|
17
18
|
getSchoolAssetUploadUrl,
|
|
18
19
|
getStudentTimeline,
|
|
19
20
|
listClasses,
|
|
@@ -126,6 +127,17 @@ export const schoolRouter = createTRPCRouter({
|
|
|
126
127
|
getStudentTimeline(ctx.user!.id, input)
|
|
127
128
|
),
|
|
128
129
|
|
|
130
|
+
getMemberTimeline: protectedProcedure
|
|
131
|
+
.input(
|
|
132
|
+
z.object({
|
|
133
|
+
schoolId: z.string(),
|
|
134
|
+
memberId: z.string(),
|
|
135
|
+
from: z.date().optional(),
|
|
136
|
+
to: z.date().optional(),
|
|
137
|
+
})
|
|
138
|
+
)
|
|
139
|
+
.query(({ ctx, input }) => getMemberTimeline(ctx.user!.id, input)),
|
|
140
|
+
|
|
129
141
|
getAdminOverview: protectedProcedure
|
|
130
142
|
.input(schoolIdSchema)
|
|
131
143
|
.query(({ ctx, input }) => getAdminOverview(ctx.user!.id, input.schoolId)),
|