# domain/converters/failure.converter.ts

> 45 lines of code and 2 definitions.

Tree: Site tree
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/tree#file-domain-converters-failure-converter-ts
Source text: https://banes-lab.com/source/tree/domain/converters/failure.converter.ts.txt

Listed in [domain/converters](https://banes-lab.com/api/source/tree/domain/converters.md), after [domain/converters/evidence.converter.ts](https://banes-lab.com/source/tree/domain/converters/evidence.converter.ts.md) and before [domain/converters/grammar.section.converter.ts](https://banes-lab.com/source/tree/domain/converters/grammar.section.converter.ts.md).

## Definitions

- `shapeSubsection` (lexical_declaration, line 19)
- `failureShapeSection` (lexical_declaration, line 36, exported)

## Uses

- [domain/converters/check.converter.ts](https://banes-lab.com/source/tree/domain/converters/check.converter.ts.md)
- [domain/converters/ontology.converter.ts](https://banes-lab.com/source/tree/domain/converters/ontology.converter.ts.md)

## Used by

- [domain/converters/catalog.converter.ts](https://banes-lab.com/source/tree/domain/converters/catalog.converter.ts.md)

## Source

```typescript
import {
    BREAKS_LABEL,
    FAILURE_SHAPE_INTRO,
    FAILURE_SHAPE_TITLE,
    FIX_LABEL,
    SEEN_IN_LABEL,
    SHAPE_LABEL,
} from "#configuration/strings/reason.strings";
import { FACE_SEPARATOR, REASON_FACE } from "@govlab/constants";
import { FAILURE_SHAPE_SECTION_ID, REASON_ANCHOR } from "#core/ids/ontology.ids";
import type { FailureShapeView, ReasonView } from "#types/reason.types";
import type { Section, Subsection } from "#types/document.types";
import { canonOf, checkBlocks } from "#domain/converters/check.converter";
import { glossary, linkOf, linkRow, row } from "#domain/converters/ontology.converter";
import { CANON_LABEL } from "#configuration/strings/ontology.strings";
import { REASON_SECTION_ICON } from "#configuration/icons/ontology.icons";
import type { ResolutionView } from "#types/ontology.types";

const shapeSubsection = function shapeSubsection(shape: FailureShapeView, resolution: ResolutionView): Subsection {
    return {
        blocks: [
            glossary([
                row(SHAPE_LABEL, shape.shape),
                row(FIX_LABEL, shape.fix),
                row(BREAKS_LABEL, linkOf(shape.breaks)),
                ...linkRow(SEEN_IN_LABEL, shape.instances),
                row(CANON_LABEL, canonOf(shape.canon)),
            ]),
            ...checkBlocks(resolution, REASON_FACE + FACE_SEPARATOR + shape.anchor),
        ],
        id: REASON_ANCHOR + shape.anchor,
        title: shape.name,
    };
};

export const failureShapeSection = function failureShapeSection(
    reason: ReasonView,
    resolution: ResolutionView,
): Section {
    return {
        icon: REASON_SECTION_ICON,
        id: FAILURE_SHAPE_SECTION_ID,
        intro: FAILURE_SHAPE_INTRO,
        subsections: reason.failureShapes.map((shape) => shapeSubsection(shape, resolution)),
        title: FAILURE_SHAPE_TITLE,
    };
};
```
