# types/graph.types.ts

> 147 lines of code and 23 definitions.

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

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

## Definitions

- `SiteScope` (interface_declaration, line 14, exported)
- `ChunkRules` (interface_declaration, line 20, exported)
- `Graph` (interface_declaration, line 29, exported)
- `Undeclared` (interface_declaration, line 34, exported)
- `SourceIds` (interface_declaration, line 40, exported)
- `Vocabulary` (interface_declaration, line 48, exported)
- `FieldRule` (interface_declaration, line 54, exported)
- `FieldUse` (interface_declaration, line 59, exported)
- `UnresolvedTarget` (interface_declaration, line 64, exported)
- `OntologyGraph` (interface_declaration, line 70, exported)
- `Merged` (interface_declaration, line 78, exported)
- `EdgeIndex` (interface_declaration, line 82, exported)
- `TooltipGap` (interface_declaration, line 87, exported)
- `GraphReport` (interface_declaration, line 93, exported)
- `GraphLines` (interface_declaration, line 106, exported)
- `GraphFiles` (interface_declaration, line 115, exported)
- `RouteEdges` (interface_declaration, line 123, exported)
- `GraphContext` (interface_declaration, line 128, exported)
- `ConcernSource` (interface_declaration, line 143, exported)
- `ConcernScope` (interface_declaration, line 150, exported)
- `GraphProducer` (interface_declaration, line 157, exported)
- `GraphBuild` (interface_declaration, line 162, exported)
- `SiteCodes` (interface_declaration, line 167, exported)

## Contained in

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

## Source

```typescript
import type { GraphChunk, GraphEdge, GraphNode, RelationPair } from "@banes-lab/web/types/graph.types.js";
import type { Linker, Population } from "#types/catalog.types";
import type { AnatomyFolder } from "@banes-lab/web/types/anatomy.types.js";
import type { BuiltOntology } from "#types/ontology.types";
import type { Discovery } from "#types/site.types";
import type { EdgeRef } from "@banes-lab/web/types/link.types.js";
import type { EvidenceNode } from "@banes-lab/web/types/evidence.types.js";
import type { SearchAsset } from "@banes-lab/web/types/search.types.js";
import type { SectionPlan } from "#types/section.types";
import type { SourceTree } from "#types/source.types";
import type { Term } from "@govlab/context";
import type { WebModules } from "#types/loader.types";

export interface SiteScope {
    readonly linker: Linker;
    readonly plans: readonly SectionPlan[];
    readonly web: WebModules;
}

export interface ChunkRules {
    readonly contains: string;
    readonly keptRelations: ReadonlySet<string>;
    readonly keyOf: (ref: string) => string;
    readonly pairs: readonly RelationPair[];
    readonly rollsUp: ReadonlySet<string>;
    readonly skipsSource: (ref: string) => boolean;
}

export interface Graph {
    readonly edges: readonly GraphEdge[];
    readonly nodes: readonly GraphNode[];
}

export interface Undeclared {
    readonly face: string;
    readonly kind: string;
    readonly relation: string;
}

export interface SourceIds {
    readonly fileId: (path: string) => string;
    readonly folderHref: (path: string) => string;
    readonly folderId: (path: string) => string;
    readonly localPath: (path: string) => string;
    readonly nodeHref: (file: string, line: number | null) => string;
}

export interface Vocabulary {
    readonly calls: string;
    readonly contains: string;
    readonly pairs: readonly RelationPair[];
}

export interface FieldRule {
    readonly flip: boolean;
    readonly relation: string | null;
}

export interface FieldUse extends Undeclared {
    readonly flip: boolean;
    readonly stored: string | null;
}

export interface UnresolvedTarget {
    readonly from: string;
    readonly label: string;
    readonly relation: string;
}

export interface OntologyGraph extends Graph {
    readonly ambiguous: readonly Undeclared[];
    readonly fields: readonly FieldUse[];
    readonly populations: readonly Population[];
    readonly undeclared: readonly Undeclared[];
    readonly unresolved: readonly UnresolvedTarget[];
}

export interface Merged extends Graph {
    readonly duplicates: readonly (readonly [GraphNode, GraphNode])[];
}

export interface EdgeIndex {
    readonly incoming: (ref: string, relation: string) => readonly EdgeRef[];
    readonly outgoing: (ref: string, relation: string) => readonly EdgeRef[];
}

export interface TooltipGap {
    readonly from: string;
    readonly relation: string;
    readonly to: string;
}

export interface GraphReport {
    readonly ambiguous: readonly Undeclared[];
    readonly dangling: readonly GraphEdge[];
    readonly duplicates: readonly { readonly dropped: GraphNode; readonly kept: GraphNode }[];
    readonly fields: readonly FieldUse[];
    readonly graph: Graph;
    readonly populations: readonly Population[];
    readonly tooltipGaps: readonly TooltipGap[];
    readonly uncovered: readonly string[];
    readonly undeclared: readonly Undeclared[];
    readonly unresolved: readonly UnresolvedTarget[];
}

export interface GraphLines {
    readonly chunks: number;
    readonly records: number;
    readonly report: GraphReport;
    readonly routes: number;
    readonly search: SearchAsset;
    readonly stops: number;
}

export interface GraphFiles {
    readonly graph: string;
    readonly learning: string;
    readonly report: string;
    readonly search: string;
    readonly tabs: string;
}

export interface RouteEdges {
    readonly edges: readonly GraphEdge[];
    readonly unresolved: readonly UnresolvedTarget[];
}

export interface GraphContext {
    readonly built: BuiltOntology;
    readonly codes: SiteCodes;
    readonly discovery: Discovery;
    readonly evidenceSubjects: readonly string[];
    readonly evidenceTarget: (node: EvidenceNode) => string | null;
    readonly ids: SourceIds;
    readonly numbers: ReadonlyMap<string, string>;
    readonly ontology: OntologyGraph;
    readonly route: RouteEdges;
    readonly scope: SiteScope;
    readonly trees: readonly SourceTree[];
    readonly vocabulary: Vocabulary;
}

export interface ConcernSource {
    readonly built: { readonly context: { readonly lex: { readonly all: () => readonly Term[] } } };
    readonly ids: Pick<SourceIds, "fileId">;
    readonly ontology: { readonly nodes: readonly Pick<GraphNode, "ref">[] };
    readonly trees: readonly { readonly snapshot: { readonly tree: AnatomyFolder } }[];
}

export interface ConcernScope {
    readonly fileRef: (path: string) => string;
    readonly records: ReadonlySet<string>;
    readonly roots: readonly AnatomyFolder[];
    readonly terms: readonly Term[];
}

export interface GraphProducer {
    readonly name: string;
    readonly produce: (context: GraphContext) => Graph;
}

export interface GraphBuild {
    readonly chunks: ReadonlyMap<string, GraphChunk>;
    readonly report: GraphReport;
}

export interface SiteCodes {
    readonly pages: ReadonlyMap<string, string>;
    readonly tabs: ReadonlyMap<string, string>;
}
```
