feat(pdf): @faunosteo/pdf engine — explicit inputs, envelope v1 attachment, layered reader, xmldom composition, allowlist SVG sanitiser, WinAnsi guard, rasterizer adapter; goldens reproduced
This commit is contained in:
1 parent
e7419cb4cb
commit
c17956031d
46 files changed
+4396
-1
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import {
|
||||
buildSheetSnapshot,
|
||||
readReportDocument,
|
||||
ReportSchema,
|
||||
type Report,
|
||||
type SheetSnapshot,
|
||||
} from '@faunosteo/domain'
|
||||
import { loadDraftSheet, readFixtureJson, type DraftSheet } from './draft'
|
||||
import {
|
||||
leavesAsV2Report,
|
||||
legacyLeaves,
|
||||
loadLegacyBaseline,
|
||||
} from './legacy-leaves'
|
||||
|
||||
/** The three Phase 0 reports, built with the Phase 0 recipe. */
|
||||
export const REPORT_NAMES = ['v2full', 'demo', 'v2unresolved'] as const
|
||||
export type ReportName = (typeof REPORT_NAMES)[number]
|
||||
|
||||
export interface GoldenReports {
|
||||
draft: DraftSheet
|
||||
reports: Record<ReportName, Report>
|
||||
snapshots: Record<ReportName, SheetSnapshot>
|
||||
/** Unresolved findings of `v2unresolved` as the migration counted them. */
|
||||
unresolvedOfV2Unresolved: number
|
||||
}
|
||||
|
||||
/** sphenoid + ssb (the families the migration cannot place) plus one leaf that resolves. */
|
||||
function buildV2Unresolved(draft: DraftSheet) {
|
||||
const leaves = legacyLeaves(loadLegacyBaseline())
|
||||
const unresolvedFamilies = leaves.filter(
|
||||
(l) => l.zoneId === 'sphenoid' || l.zoneId === 'ssb',
|
||||
)
|
||||
const resolved = leaves.find((l) => l.zoneId === 'frontal')!
|
||||
return readReportDocument(
|
||||
leavesAsV2Report([...unresolvedFamilies, resolved]),
|
||||
draft.migrationMap,
|
||||
)
|
||||
}
|
||||
|
||||
export function loadGoldenReports(): GoldenReports {
|
||||
const draft = loadDraftSheet()
|
||||
const unresolved = buildV2Unresolved(draft)
|
||||
const reports: Record<ReportName, Report> = {
|
||||
v2full: readReportDocument(
|
||||
readFixtureJson('report-v2.full.json'),
|
||||
draft.migrationMap,
|
||||
).report,
|
||||
demo: ReportSchema.parse(readFixtureJson('report-v3.demo.json')),
|
||||
v2unresolved: unresolved.report,
|
||||
}
|
||||
const snapshots = Object.fromEntries(
|
||||
REPORT_NAMES.map((name) => [
|
||||
name,
|
||||
buildSheetSnapshot(draft, reports[name]),
|
||||
]),
|
||||
) as Record<ReportName, SheetSnapshot>
|
||||
return {
|
||||
draft,
|
||||
reports,
|
||||
snapshots,
|
||||
unresolvedOfV2Unresolved: unresolved.unresolvedFindings,
|
||||
}
|
||||
}
|
||||
|
||||
/** The 612-leaf legacy report migrated through the draft map (T5). */
|
||||
export function allLeavesMigrated(draft: DraftSheet) {
|
||||
return readReportDocument(
|
||||
leavesAsV2Report(legacyLeaves(loadLegacyBaseline())),
|
||||
draft.migrationMap,
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user