/** * Document templates shown in WordPress. Content, fields and article * references come from the shared templates (checked against * docs/cra-facts.md). The plugin sets titles in sentence case and keeps every * template free: they are filled in locally in the browser. */ import { DOCUMENT_TEMPLATES } from '@cra-compliance/shared'; import type { DocumentTemplate } from '@cra-compliance/types'; const TITLES: Record = { 'vulnerability-disclosure-policy': 'Vulnerability disclosure policy', 'incident-response-plan': 'Incident response plan', 'eu-declaration-conformity': 'EU Declaration of Conformity', sbom: 'Software bill of materials (SBOM)', 'security-txt': 'security.txt', 'technical-documentation': 'Technical documentation', 'risk-assessment': 'Cybersecurity risk assessment', 'support-update-policy': 'Security update and support policy', 'annex-ii-user-information': 'Annex II user information', 'module-a-conformity-assessment': 'Module A assessment record', }; /** Templates that support obligations already in application (Article 14 reporting). */ export const APPLIES_NOW_TEMPLATES = new Set(['incident-response-plan']); export const TEMPLATES: DocumentTemplate[] = DOCUMENT_TEMPLATES.map((template) => ({ ...template, title: TITLES[template.id] ?? template.title, premium_only: false, })); export function findTemplate(id: string | null | undefined): DocumentTemplate | undefined { return id ? TEMPLATES.find((template) => template.id === id) : undefined; } /** First sentence of a description, for compact cards. */ export function summary(text: string): string { const match = text.match(/^(.+?[.!?])(\s|$)/); return match ? match[1] : text; }