Fix type errors in report routes (redundant parseInt, JsonValue cast) (FRE-4575)
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
|
||||
import { reportService } from '@shieldai/report';
|
||||
import { prisma } from '@shieldai/db';
|
||||
import { ReportType, ReportStatus } from '@shieldai/types';
|
||||
import { ReportType, ReportStatus, ReportDataPayload } from '@shieldai/types';
|
||||
|
||||
interface AuthRequest extends FastifyRequest {
|
||||
user?: {
|
||||
@@ -63,7 +63,7 @@ export async function reportRoutes(fastify: FastifyInstance) {
|
||||
const limit = parseInt(query.limit || '20', 10);
|
||||
const offset = parseInt(query.offset || '0', 10);
|
||||
|
||||
const reports = await reportService.getReportHistory(userId, parseInt(limit), parseInt(offset));
|
||||
const reports = await reportService.getReportHistory(userId, limit, offset);
|
||||
return reply.code(200).send({ reports, count: reports.length });
|
||||
});
|
||||
|
||||
@@ -136,18 +136,21 @@ export async function reportRoutes(fastify: FastifyInstance) {
|
||||
}
|
||||
|
||||
const { pdfGenerator } = await import('@shieldai/report');
|
||||
const pdfBuffer = await pdfGenerator.generate({
|
||||
reportTitle: report.title,
|
||||
periodStart: '',
|
||||
periodEnd: '',
|
||||
generatedAt: new Date().toISOString(),
|
||||
data: report.dataPayload ? JSON.parse(report.dataPayload) : {
|
||||
const pdfData = report.dataPayload
|
||||
? (typeof report.dataPayload === 'string' ? JSON.parse(report.dataPayload) : report.dataPayload as unknown as ReportDataPayload)
|
||||
: {
|
||||
exposureSummary: { totalExposures: 0, newExposures: 0, resolvedExposures: 0, criticalExposures: 0, warningExposures: 0, infoExposures: 0, exposuresBySource: {} },
|
||||
spamStats: { callsBlocked: 0, textsBlocked: 0, callsFlagged: 0, textsFlagged: 0, falsePositives: 0, totalSpamEvents: 0 },
|
||||
voiceStats: { analysesRun: 0, threatsDetected: 0, enrollmentsActive: 0, syntheticDetections: 0, voiceMismatchEvents: 0 },
|
||||
recommendations: [],
|
||||
protectionScore: 0,
|
||||
},
|
||||
};
|
||||
const pdfBuffer = await pdfGenerator.generate({
|
||||
reportTitle: report.title,
|
||||
periodStart: '',
|
||||
periodEnd: '',
|
||||
generatedAt: new Date().toISOString(),
|
||||
data: pdfData,
|
||||
reportId,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user