assets, move memories to proper location

This commit is contained in:
2026-05-14 07:36:23 -04:00
parent 0bec3c574a
commit 1b917321cf
52 changed files with 3352 additions and 297 deletions

View File

@@ -1,4 +1,4 @@
import { PDFDocument, rgb, StandardFonts } from 'pdfkit';
import PDFKit from 'pdfkit';
import { ReportDataPayload } from '@shieldai/types';
interface PdfContext {
@@ -27,14 +27,14 @@ function getScoreColor(score: number): string {
export class PdfGenerator {
async generate(context: PdfContext): Promise<Buffer> {
return new Promise((resolve, reject) => {
const doc = new PDFDocument({
const doc = new PDFKit({
size: 'A4',
margins: { top: 40, bottom: 40, left: 40, right: 40 },
});
const chunks: Buffer[] = [];
doc.on('data', (chunk) => chunks.push(chunk));
doc.on('data', (chunk: Buffer) => chunks.push(chunk));
doc.on('end', () => resolve(Buffer.concat(chunks)));
doc.on('error', reject);
@@ -46,7 +46,7 @@ export class PdfGenerator {
.rect(0, 0, w, 120)
.fill('#1e40af')
.fillColor('white')
.font(StandardFonts.HelveticaBold)
.font('Helvetica-Bold')
.fontSize(24)
.text(context.reportTitle, 40, 30, { align: 'center' })
.fontSize(12)
@@ -63,7 +63,7 @@ export class PdfGenerator {
doc
.fillColor(scoreColor)
.fontSize(48)
.font(StandardFonts.HelveticaBold)
.font('Helvetica-Bold')
.text(`${score}/100`, 40, y, { align: 'center' });
y += 60;
@@ -73,7 +73,7 @@ export class PdfGenerator {
doc
.fillColor('#64748b')
.fontSize(11)
.font(StandardFonts.Helvetica)
.font('Helvetica')
.text(changeText, 40, y, { align: 'center' });
y += 20;
}
@@ -125,10 +125,10 @@ export class PdfGenerator {
.rect(40, y, 4, 30)
.fill(priorityColor)
.fillColor('#1a202c')
.font(StandardFonts.HelveticaBold)
.font('Helvetica-Bold')
.fontSize(12)
.text(rec.title, 50, y + 2, { width: w - 100 })
.font(StandardFonts.Helvetica)
.font('Helvetica')
.fontSize(10)
.fillColor('#475569')
.text(rec.description, 50, y + 18, { width: w - 100 });
@@ -142,7 +142,7 @@ export class PdfGenerator {
.fill('#f5f7fa')
.fillColor('#94a3b8')
.fontSize(10)
.font(StandardFonts.Helvetica)
.font('Helvetica')
.text('ShieldAI — Your Digital Identity Protection', 40, h - 45, { align: 'center' })
.text(`Report ID: ${context.reportId}`, 40, h - 30, { align: 'center' });
@@ -150,7 +150,7 @@ export class PdfGenerator {
});
}
private drawSectionHeader(doc: PDFDocument, title: string, y: number): number {
private drawSectionHeader(doc: PDFKit.PDFDocument, title: string, y: number): number {
if (y > 680) {
doc.addPage();
y = 40;
@@ -159,7 +159,7 @@ export class PdfGenerator {
doc
.fillColor('#1e40af')
.fontSize(16)
.font(StandardFonts.HelveticaBold)
.font('Helvetica-Bold')
.text(title, 40, y)
.rect(40, y + 18, 480, 2)
.fill('#e2e8f0');
@@ -168,7 +168,7 @@ export class PdfGenerator {
}
private drawStatGrid(
doc: PDFDocument,
doc: PDFKit.PDFDocument,
stats: Array<{ label: string; value: number; color: string }>,
y: number
): number {
@@ -185,11 +185,11 @@ export class PdfGenerator {
.fill('#f8fafc')
.fillColor(stat.color)
.fontSize(20)
.font(StandardFonts.HelveticaBold)
.font('Helvetica-Bold')
.text(String(stat.value), x + 4, y + 8, { width: colWidth - 16, align: 'center' })
.fillColor('#64748b')
.fontSize(9)
.font(StandardFonts.Helvetica)
.font('Helvetica')
.text(stat.label, x + 4, y + 35, { width: colWidth - 16, align: 'center' });
}
y += 70;