# types/ontology.types.ts

> 68 lines of code and 10 definitions.

Tree: Bane's Lab Build Scripts
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/build-scripts#file-build-scripts-types-ontology-types-ts
Source text: https://banes-lab.com/source/build-scripts/types/ontology.types.ts.txt

Listed in [types](https://banes-lab.com/api/source/build-scripts/types.md), after [types/metric.types.ts](https://banes-lab.com/source/build-scripts/types/metric.types.ts.md) and before [types/page.types.ts](https://banes-lab.com/source/build-scripts/types/page.types.ts.md).

## Definitions

- `RefIndex` (type_alias_declaration, line 14, exported)
- `ReasonSources` (interface_declaration, line 16, exported)
- `ReverseIndex` (type_alias_declaration, line 22, exported)
- `Resolver` (interface_declaration, line 24, exported)
- `ReferenceFaces` (type_alias_declaration, line 44, exported)
- `OntologySources` (interface_declaration, line 46, exported)
- `OntologyFiles` (interface_declaration, line 53, exported)
- `BuiltOntology` (interface_declaration, line 59, exported)
- `VocabularyUsers` (interface_declaration, line 65, exported)
- `OntologyBuild` (interface_declaration, line 74, exported)

## Contained in

- [types](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-types.md)

## Source

```typescript
import type {
    ContractDomainView,
    LayerEdgeView,
    OntologySnapshot,
    PrincipleCategoryView,
    TensionView,
    TermCategoryView,
} from "@banes-lab/web/types/ontology.types.js";
import type { EdgeRef } from "@banes-lab/web/types/link.types.js";
import type { GovlabContext } from "@govlab/context";
import type { ReferenceIndex } from "@banes-lab/web/types/reference.types.js";
import type { TestSurfaceView } from "@banes-lab/web/types/reason.types.js";

export type RefIndex = ReadonlyMap<string, readonly EdgeRef[]>;

export interface ReasonSources {
    readonly context: GovlabContext;
    readonly index: ReverseIndex;
    readonly resolve: Resolver;
}

export type ReverseIndex = ReadonlyMap<string, RefIndex>;

export interface Resolver {
    readonly algo: (label: string) => EdgeRef;
    readonly arch: (label: string) => EdgeRef;
    readonly archCategory: (label: string) => EdgeRef;
    readonly archId: (id: string) => EdgeRef;
    readonly labels: (phrases: readonly string[]) => readonly EdgeRef[];
    readonly edgeSource: (id: string) => EdgeRef;
    readonly force: (force: string, known: ReadonlySet<string>) => EdgeRef;
    readonly kind: (kind: string) => EdgeRef;
    readonly layer: (id: string) => EdgeRef;
    readonly lexCategory: (slug: string) => EdgeRef;
    readonly pag: (local: string) => EdgeRef;
    readonly reason: (id: string) => EdgeRef;
    readonly reasonAs: (kind: string, id: string) => EdgeRef;
    readonly vocabulary: (id: string, value: string) => EdgeRef;
    readonly stage: (id: string) => EdgeRef;
    readonly target: (raw: string) => EdgeRef;
    readonly tension: (a: EdgeRef, b: EdgeRef) => EdgeRef;
}

export type ReferenceFaces = ReadonlyMap<string, ReferenceIndex>;

export interface OntologySources {
    readonly context: GovlabContext;
    readonly forces: ReadonlySet<string>;
    readonly index: ReverseIndex;
    readonly resolve: Resolver;
}

export interface OntologyFiles {
    readonly ontology: string;
    readonly reference: string;
    readonly vocabulary: string;
}

export interface BuiltOntology {
    readonly collections: ReferenceFaces;
    readonly context: GovlabContext;
    readonly snapshot: OntologySnapshot;
}

export interface VocabularyUsers {
    readonly contracts: readonly ContractDomainView[];
    readonly principles: readonly PrincipleCategoryView[];
    readonly surfaces: readonly TestSurfaceView[];
    readonly tensions: readonly TensionView[];
    readonly terms: readonly TermCategoryView[];
    readonly topology: readonly LayerEdgeView[];
}

export interface OntologyBuild {
    readonly ontology: BuiltOntology;
    readonly phrases: number;
    readonly references: number;
}
```
