- tom-generator/export/zip.ts: extract private helpers to zip-helpers.ts (544→342 LOC) - tom-generator/export/docx.ts: extract private helpers to docx-helpers.ts (525→378 LOC) - tom-generator/export/pdf.ts: extract private helpers to pdf-helpers.ts (517→446 LOC) - tom-generator/demo-data/index.ts: extract DEMO_RISK_PROFILES + DEMO_EVIDENCE_DOCUMENTS to demo-data-part2.ts (518→360 LOC) - einwilligungen/generator/privacy-policy-sections.ts: extract sections 5-7 to part2 (559→313 LOC) - einwilligungen/export/pdf.ts: extract HTML/CSS helpers to pdf-helpers.ts (505→296 LOC) - vendor-compliance/context.tsx: extract API action hooks to context-actions.tsx (509→286 LOC) All originals re-export from sibling files — zero consumer import changes needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
88 lines
3.2 KiB
TypeScript
88 lines
3.2 KiB
TypeScript
// =============================================================================
|
|
// TOM Generator PDF Export - Helper Functions
|
|
// Private helpers extracted from pdf.ts to stay under 500 LOC hard cap
|
|
// =============================================================================
|
|
|
|
import { DerivedTOM, CONTROL_CATEGORIES } from '../types'
|
|
import { getControlById } from '../controls/loader'
|
|
import type { PDFExportOptions } from './pdf'
|
|
|
|
// =============================================================================
|
|
// HELPER FUNCTIONS
|
|
// =============================================================================
|
|
|
|
export function generateCategorySummary(
|
|
toms: DerivedTOM[],
|
|
opts: PDFExportOptions
|
|
): string[][] {
|
|
const summary: string[][] = []
|
|
|
|
for (const category of CONTROL_CATEGORIES) {
|
|
const categoryTOMs = toms.filter((tom) => {
|
|
const control = getControlById(tom.controlId)
|
|
return control?.category === category.id
|
|
})
|
|
|
|
if (categoryTOMs.length === 0) continue
|
|
|
|
const required = categoryTOMs.filter((t) => t.applicability === 'REQUIRED').length
|
|
const implemented = categoryTOMs.filter((t) => t.implementationStatus === 'IMPLEMENTED').length
|
|
|
|
summary.push([
|
|
category.name[opts.language],
|
|
String(categoryTOMs.length),
|
|
String(required),
|
|
String(implemented),
|
|
])
|
|
}
|
|
|
|
return summary
|
|
}
|
|
|
|
export function formatProtectionLevel(level: string, language: 'de' | 'en'): string {
|
|
const levels: Record<string, Record<'de' | 'en', string>> = {
|
|
NORMAL: { de: 'Normal', en: 'Normal' },
|
|
HIGH: { de: 'Hoch', en: 'High' },
|
|
VERY_HIGH: { de: 'Sehr hoch', en: 'Very High' },
|
|
}
|
|
return levels[level]?.[language] || level
|
|
}
|
|
|
|
export function formatType(type: string, language: 'de' | 'en'): string {
|
|
const types: Record<string, Record<'de' | 'en', string>> = {
|
|
TECHNICAL: { de: 'Technisch', en: 'Technical' },
|
|
ORGANIZATIONAL: { de: 'Organisatorisch', en: 'Organizational' },
|
|
}
|
|
return types[type]?.[language] || type
|
|
}
|
|
|
|
export function formatImplementationStatus(status: string, language: 'de' | 'en'): string {
|
|
const statuses: Record<string, Record<'de' | 'en', string>> = {
|
|
NOT_IMPLEMENTED: { de: 'Nicht umgesetzt', en: 'Not Implemented' },
|
|
PARTIAL: { de: 'Teilweise', en: 'Partial' },
|
|
IMPLEMENTED: { de: 'Umgesetzt', en: 'Implemented' },
|
|
}
|
|
return statuses[status]?.[language] || status
|
|
}
|
|
|
|
export function formatApplicability(applicability: string, language: 'de' | 'en'): string {
|
|
const apps: Record<string, Record<'de' | 'en', string>> = {
|
|
REQUIRED: { de: 'Erforderlich', en: 'Required' },
|
|
RECOMMENDED: { de: 'Empfohlen', en: 'Recommended' },
|
|
OPTIONAL: { de: 'Optional', en: 'Optional' },
|
|
NOT_APPLICABLE: { de: 'N/A', en: 'N/A' },
|
|
}
|
|
return apps[applicability]?.[language] || applicability
|
|
}
|
|
|
|
export function getCIAMeaning(rating: number, language: 'de' | 'en'): string {
|
|
const meanings: Record<number, Record<'de' | 'en', string>> = {
|
|
1: { de: 'Sehr gering', en: 'Very Low' },
|
|
2: { de: 'Gering', en: 'Low' },
|
|
3: { de: 'Mittel', en: 'Medium' },
|
|
4: { de: 'Hoch', en: 'High' },
|
|
5: { de: 'Sehr hoch', en: 'Very High' },
|
|
}
|
|
return meanings[rating]?.[language] || String(rating)
|
|
}
|