# core/factories/evidence.factory.ts

> 47 lines of code and 9 definitions.

Tree: Site tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/tree#file-core-factories-evidence-factory-ts
Source text: https://banes-lab.com/source/tree/core/factories/evidence.factory.ts.txt

Listed in [core/factories](https://banes-lab.com/api/source/tree/core/factories.md), after [core/factories/element.factory.ts](https://banes-lab.com/source/tree/core/factories/element.factory.ts.md).

## Definitions

- `recordSubject` (lexical_declaration, line 4, exported)
- `chapterSubject` (lexical_declaration, line 8, exported)
- `groundedBy` (lexical_declaration, line 24, exported)
- `groundedChapters` (lexical_declaration, line 32, exported)
- `absentChapters` (lexical_declaration, line 41, exported)
- `absentRecords` (lexical_declaration, line 50, exported)
- `definitionNode` (lexical_declaration, line 12, exported)
- `fileNode` (lexical_declaration, line 16, exported)
- `folderNode` (lexical_declaration, line 20, exported)

## Source

```typescript
import type { AbsenceReason, DeclaredAbsence, Evidence, EvidenceNode, EvidenceSubject } from "#types/evidence.types";
import { FACE_SEPARATOR } from "@govlab/constants";

export const recordSubject = function recordSubject(face: string, id: string): EvidenceSubject {
    return { kind: "record", ref: face + FACE_SEPARATOR + id };
};

export const chapterSubject = function chapterSubject(page: string, tab: string, section: string): EvidenceSubject {
    return { kind: "chapter", page, section, tab };
};

export const definitionNode = function definitionNode(name: string, file: string | null = null): EvidenceNode {
    return { file, kind: "definition", name };
};

export const fileNode = function fileNode(name: string): EvidenceNode {
    return { kind: "file", name };
};

export const folderNode = function folderNode(...words: readonly string[]): EvidenceNode {
    return { kind: "folder", words };
};

export const groundedBy = function groundedBy(
    nodes: readonly EvidenceNode[],
    face: string,
    ids: readonly string[],
): readonly Evidence[] {
    return ids.map((id) => ({ nodes, subject: recordSubject(face, id) }));
};

export const groundedChapters = function groundedChapters(
    nodes: readonly EvidenceNode[],
    page: string,
    tab: string,
    sections: readonly string[],
): readonly Evidence[] {
    return sections.map((section) => ({ nodes, subject: chapterSubject(page, tab, section) }));
};

export const absentChapters = function absentChapters(
    reason: AbsenceReason,
    page: string,
    tab: string,
    sections: readonly string[],
): readonly DeclaredAbsence[] {
    return sections.map((section) => ({ reason, subject: chapterSubject(page, tab, section) }));
};

export const absentRecords = function absentRecords(
    reason: AbsenceReason,
    face: string,
    ids: readonly string[],
): readonly DeclaredAbsence[] {
    return ids.map((id) => ({ reason, subject: recordSubject(face, id) }));
};
```
