import { BOUNDARY_LABEL, CONCERN_LABEL, CONSTRUCTS_LABEL, DOCUMENT_FINDINGS_LABEL, DOCUMENT_LABEL, FIELDS_LABEL, FORM_LABEL, HEADINGS_LABEL, LINE_MARK, MERMAID_LABEL, PATHS_LABEL, } from "#configuration/strings/folder.strings"; import { glossary, labelled, row } from "#domain/converters/ontology.converter"; import type { Block } from "#types/block.types"; import type { DocumentView } from "#types/anatomy.types"; import { NONE_LABEL } from "#configuration/strings/ontology.strings"; import { STATS_SEPARATOR } from "#configuration/constants/anatomy.constants"; export const documentChips = function documentChips(document: DocumentView | null): (string | null)[] { if (document === null) { return []; } return [ labelled(FORM_LABEL, document.form), labelled(CONCERN_LABEL, document.concern), document.boundary ? BOUNDARY_LABEL : null, ]; }; export const documentBlocks = function documentBlocks(document: DocumentView): Block[] { const metrics = [ { label: HEADINGS_LABEL, value: String(document.headings) }, { label: MERMAID_LABEL, value: String(document.mermaid) }, { label: PATHS_LABEL, value: String(document.paths) }, { label: CONSTRUCTS_LABEL, value: String(document.constructs) }, { label: FIELDS_LABEL, value: String(document.fields.length) }, ]; const rows = document.findings.map((finding) => row( finding.code + LINE_MARK + String(finding.line), `${finding.category}${STATS_SEPARATOR}${finding.text}`, ), ); return [ { caption: DOCUMENT_LABEL, kind: "metric" as const, metrics }, glossary(rows.length === 0 ? [row(DOCUMENT_FINDINGS_LABEL, NONE_LABEL)] : rows), ]; };