Add Protection Report Generator with HTML/PDF output and scheduled delivery (FRE-4575)
- Report service: data collection from all three engines, HTML rendering (Handlebars), PDF generation (pdfkit) - REST API: /reports endpoints for generate, history, view, PDF download, scheduling - BullMQ workers: queued report generation with retry, monthly/annual scheduler triggers - DB: SecurityReport model with Prisma schema and type exports - Email: report_ready template in shared-notifications - All dependencies wired through existing packages Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -35,6 +35,7 @@ model User {
|
||||
spamRules SpamRule[]
|
||||
normalizedAlerts NormalizedAlert[]
|
||||
correlationGroups CorrelationGroup[]
|
||||
securityReports SecurityReport[]
|
||||
|
||||
// Audit
|
||||
createdAt DateTime @default(now())
|
||||
@@ -521,3 +522,50 @@ model CorrelationGroup {
|
||||
@@index([userId, status])
|
||||
@@index([createdAt])
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Report Generation Models
|
||||
// ============================================
|
||||
|
||||
enum ReportType {
|
||||
MONTHLY_PLUS
|
||||
ANNUAL_PREMIUM
|
||||
}
|
||||
|
||||
enum ReportStatus {
|
||||
PENDING
|
||||
GENERATING
|
||||
COMPLETED
|
||||
FAILED
|
||||
DELIVERED
|
||||
}
|
||||
|
||||
model SecurityReport {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
subscriptionId String
|
||||
reportType ReportType
|
||||
status ReportStatus @default(PENDING)
|
||||
periodStart DateTime
|
||||
periodEnd DateTime
|
||||
title String
|
||||
summary String?
|
||||
htmlContent String?
|
||||
pdfUrl String?
|
||||
dataPayload Json?
|
||||
error String?
|
||||
scheduledFor DateTime?
|
||||
deliveredAt DateTime?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@index([userId])
|
||||
@@index([subscriptionId])
|
||||
@@index([reportType])
|
||||
@@index([status])
|
||||
@@index([periodStart, periodEnd])
|
||||
@@index([createdAt])
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ export type {
|
||||
SpamRule,
|
||||
AuditLog,
|
||||
KPISnapshot,
|
||||
SecurityReport,
|
||||
UserRole,
|
||||
FamilyMemberRole,
|
||||
SubscriptionTier,
|
||||
@@ -65,6 +66,8 @@ export type {
|
||||
FeedbackType,
|
||||
RuleType,
|
||||
RuleAction,
|
||||
ReportType,
|
||||
ReportStatus,
|
||||
} from '@prisma/client';
|
||||
|
||||
export * as PrismaModels from '@prisma/client';
|
||||
|
||||
Reference in New Issue
Block a user