feat: implement security report generation backend (task 21)
- Add report-schedules DB schema table - Create reports tRPC router with getReports, generateReport, getReport, deleteReport, getScheduledReports, updateSchedule procedures - Create reports service with async report generation lifecycle - Create report generator (compileData, renderHTML, generatePDF, uploadPDF) - Add HTML templates for monthly-plus, annual-premium, weekly-digest - Add Valibot schemas for input validation - Wire router into root.ts and update DB schema exports/relations - Install puppeteer for HTML-to-PDF conversion - Write unit tests for router (11 tests) and service (12 tests)
This commit is contained in:
26
web/src/server/api/schemas/reports.ts
Normal file
26
web/src/server/api/schemas/reports.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { object, string, picklist, optional, number, boolean, minLength } from "valibot";
|
||||
|
||||
export const GenerateReportSchema = object({
|
||||
reportType: picklist(["MONTHLY_PLUS", "ANNUAL_PREMIUM", "WEEKLY_DIGEST"]),
|
||||
periodStart: optional(string()),
|
||||
periodEnd: optional(string()),
|
||||
});
|
||||
|
||||
export const ReportFilterSchema = object({
|
||||
page: optional(number(), 1),
|
||||
limit: optional(number(), 20),
|
||||
});
|
||||
|
||||
export const ReportDetailsSchema = object({
|
||||
reportId: string([minLength(1)]),
|
||||
});
|
||||
|
||||
export const DeleteReportSchema = object({
|
||||
reportId: string([minLength(1)]),
|
||||
});
|
||||
|
||||
export const UpdateScheduleSchema = object({
|
||||
enabled: boolean(),
|
||||
frequency: picklist(["weekly", "monthly", "quarterly"]),
|
||||
reportType: picklist(["MONTHLY_PLUS", "ANNUAL_PREMIUM", "WEEKLY_DIGEST"]),
|
||||
});
|
||||
Reference in New Issue
Block a user