fix: standardize nullable field handling in session mapping

- Use undefined for optional boolean fields (escalated, forwardedHr)
- Use null for fields explicitly typed as '| null' in ChatSession interface
- Use undefined for optional-only fields (messagesSent, initialMsg)
- Ensures type consistency throughout mapPrismaSessionToChatSession function
This commit is contained in:
2025-07-13 16:17:16 +02:00
parent c6900cdf2f
commit 40c80f5fe1

View File

@ -53,13 +53,13 @@ function mapPrismaSessionToChatSession(prismaSession: {
country: prismaSession.country ?? null, country: prismaSession.country ?? null,
ipAddress: prismaSession.ipAddress ?? null, ipAddress: prismaSession.ipAddress ?? null,
sentiment: prismaSession.sentiment ?? null, sentiment: prismaSession.sentiment ?? null,
messagesSent: prismaSession.messagesSent ?? undefined, // Maintain consistency with other nullable fields messagesSent: prismaSession.messagesSent ?? undefined,
avgResponseTime: prismaSession.avgResponseTime ?? null, avgResponseTime: prismaSession.avgResponseTime ?? null,
escalated: prismaSession.escalated ?? false, escalated: prismaSession.escalated ?? undefined,
forwardedHr: prismaSession.forwardedHr ?? false, forwardedHr: prismaSession.forwardedHr ?? undefined,
initialMsg: prismaSession.initialMsg ?? undefined, initialMsg: prismaSession.initialMsg ?? undefined,
fullTranscriptUrl: prismaSession.fullTranscriptUrl ?? undefined, fullTranscriptUrl: prismaSession.fullTranscriptUrl ?? null,
summary: prismaSession.summary ?? undefined, // New field summary: prismaSession.summary ?? null,
transcriptContent: undefined, // Not available in Session model transcriptContent: undefined, // Not available in Session model
messages: messages:
prismaSession.messages?.map((msg) => ({ prismaSession.messages?.map((msg) => ({