Fix build errors: add missing Prisma models/fields and resolve TypeScript type errors

Schema: Add 11 new models (RoundTemplate, MentorNote, MentorMilestone,
MentorMilestoneCompletion, EvaluationDiscussion, DiscussionComment,
Message, MessageRecipient, MessageTemplate, Webhook, WebhookDelivery,
DigestLog) and missing fields on existing models (Project.isDraft,
ProjectFile.version, LiveVotingSession.allowAudienceVotes, User.digestFrequency,
AuditLog.sessionId, MentorAssignment.completionStatus, etc).
Add AUDIT_CONFIG/LOCALIZATION/DIGEST/ANALYTICS enum values.

Code: Fix implicit any types, route type casts, enum casts, null safety,
composite key handling, and relation field names across 11 source files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 14:04:02 +01:00
parent 24fdd2f6be
commit 04d0deced1
12 changed files with 383 additions and 51 deletions

View File

@@ -676,6 +676,7 @@ export const applicationRouter = router({
// Create new draft project
const project = await ctx.prisma.project.create({
data: {
programId: round.programId,
roundId: round.id,
title: input.title || 'Untitled Draft',
isDraft: true,
@@ -795,8 +796,8 @@ export const applicationRouter = router({
title: data.projectName,
teamName: data.teamName,
description: data.description,
competitionCategory: data.competitionCategory,
oceanIssue: data.oceanIssue,
competitionCategory: data.competitionCategory as CompetitionCategory,
oceanIssue: data.oceanIssue as OceanIssue,
country: data.country,
geographicZone: data.city ? `${data.city}, ${data.country}` : data.country,
institution: data.institution,
@@ -838,7 +839,7 @@ export const applicationRouter = router({
return {
success: true,
projectId: updated.id,
message: `Thank you for applying to ${project.round.program.name}!`,
message: `Thank you for applying to ${project.round?.program.name ?? 'the program'}!`,
}
}),

View File

@@ -863,7 +863,7 @@ export const evaluationRouter = router({
const settings = (round.settingsJson as Record<string, unknown>) || {}
const anonymizationLevel = (settings.anonymization_level as string) || 'fully_anonymous'
const anonymizedComments = discussion.comments.map((c, idx) => {
const anonymizedComments = discussion.comments.map((c: { id: string; userId: string; user: { name: string | null }; content: string; createdAt: Date }, idx: number) => {
let authorLabel: string
if (anonymizationLevel === 'named' || c.userId === ctx.user.id) {
authorLabel = c.user.name || 'Juror'
@@ -871,7 +871,7 @@ export const evaluationRouter = router({
const name = c.user.name || ''
authorLabel = name
.split(' ')
.map((n) => n[0])
.map((n: string) => n[0])
.join('')
.toUpperCase() || 'J'
} else {

View File

@@ -405,8 +405,8 @@ export const liveVotingRouter = router({
.map((jurySc) => {
const project = projects.find((p) => p.id === jurySc.projectId)
const audienceSc = audienceMap.get(jurySc.projectId)
const juryAvg = jurySc._avg.score || 0
const audienceAvg = audienceSc?._avg.score || 0
const juryAvg = jurySc._avg?.score || 0
const audienceAvg = audienceSc?._avg?.score || 0
const weightedTotal = audienceWeight > 0 && audienceSc
? juryAvg * juryWeight + audienceAvg * audienceWeight
: juryAvg

View File

@@ -981,9 +981,9 @@ export const mentorRouter = router({
})
const myAssignmentIds = new Set(myAssignments.map((a) => a.id))
return milestones.map((milestone) => ({
return milestones.map((milestone: typeof milestones[number]) => ({
...milestone,
myCompletions: milestone.completions.filter((c) =>
myCompletions: milestone.completions.filter((c: { mentorAssignmentId: string }) =>
myAssignmentIds.has(c.mentorAssignmentId)
),
}))
@@ -1036,7 +1036,7 @@ export const mentorRouter = router({
const completedMilestones = await ctx.prisma.mentorMilestoneCompletion.findMany({
where: {
mentorAssignmentId: input.mentorAssignmentId,
milestoneId: { in: requiredMilestones.map((m) => m.id) },
milestoneId: { in: requiredMilestones.map((m: { id: string }) => m.id) },
},
select: { milestoneId: true },
})
@@ -1057,7 +1057,7 @@ export const mentorRouter = router({
userId: ctx.user.id,
action: 'COMPLETE_MILESTONE',
entityType: 'MentorMilestoneCompletion',
entityId: completion.id,
entityId: `${completion.milestoneId}_${completion.mentorAssignmentId}`,
detailsJson: {
milestoneId: input.milestoneId,
mentorAssignmentId: input.mentorAssignmentId,
@@ -1243,7 +1243,7 @@ export const mentorRouter = router({
mentor: { select: { id: true, name: true, email: true } },
project: { select: { id: true, title: true } },
notes: { select: { id: true } },
milestoneCompletions: { select: { id: true } },
milestoneCompletions: { select: { milestoneId: true } },
},
})

View File

@@ -247,7 +247,7 @@ export const messageRouter = router({
subject: input.subject,
body: input.body,
variables: input.variables ?? undefined,
createdBy: ctx.user.id,
createdById: ctx.user.id,
},
})