# types/lexicon.types.ts

> 59 lines of code and 8 definitions.

Tree: GovLab Context
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/context#file-context-types-lexicon-types-ts
Source text: https://banes-lab.com/source/context/types/lexicon.types.ts.txt

Listed in [types](https://banes-lab.com/api/source/context/types.md), after [types/layer.types.ts](https://banes-lab.com/source/context/types/layer.types.ts.md) and before [types/ontology.types.ts](https://banes-lab.com/source/context/types/ontology.types.ts.md).

## Definitions

- `ExampleShape` (type_alias_declaration, line 7, exported)
- `TermRecord` (interface_declaration, line 9, exported)
- `TermCategory` (interface_declaration, line 23, exported)
- `Term` (interface_declaration, line 31, exported)
- `LexiconOptions` (interface_declaration, line 40, exported)
- `TermFilter` (interface_declaration, line 46, exported)
- `Lexicon` (interface_declaration, line 52, exported)
- `PlacedFile` (interface_declaration, line 61, exported)

## Contained in

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

## Source

```typescript
import type { DistinctDeclaration, Exemplar } from "#types/field.types";
import type { CheckFacet } from "#types/check.types";
import type { EXAMPLE_SHAPE_VOCABULARY } from "#configuration/constants/lexicon.constants";
import type { Logger } from "#types/ontology.types";
import type { UnreadKey } from "#types/record.types";

export type ExampleShape = (typeof EXAMPLE_SHAPE_VOCABULARY)[number]["value"];

export interface TermRecord {
    id?: string;
    name: string;
    kind: string;
    definition: string;
    aliases?: string[];
    seeAlso?: string[];
    enforcedBy?: string[];
    check?: CheckFacet;
    distinctFrom?: DistinctDeclaration[];
    example?: string;
    exemplar?: Exemplar;
}

export interface TermCategory {
    category: string;
    check?: CheckFacet;
    enforcedBy?: string[];
    exampleShape?: ExampleShape;
    records: TermRecord[];
}

export interface Term extends TermRecord {
    id: string;
    aliases: string[];
    seeAlso: string[];
    enforcedBy: string[];
    category: string;
    exampleShape?: ExampleShape;
}

export interface LexiconOptions {
    logger?: Logger | undefined;
    data?: TermCategory[];
    canonicalizeId?: ((term: string) => string) | undefined;
}

export interface TermFilter {
    kind?: string;
    category?: string;
    enforcedBy?: string;
}

export interface Lexicon {
    get: (id: string) => Term | null;
    all: () => Term[];
    ids: () => string[];
    resolve: (target: string) => Term | null;
    query: (filter?: TermFilter) => Term[];
    unreadKeys: () => UnreadKey[];
}

export interface PlacedFile {
    readonly folder: string;
    readonly subject: string;
    readonly variant: string | null;
    readonly tag: string;
    readonly extension: string;
}
```
