# types/graph.types.ts

> 100 lines of code and 22 definitions.

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

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

## Definitions

- `CodeNodeKind` (type_alias_declaration, line 1, exported)
- `CodeEdgeKind` (type_alias_declaration, line 14, exported)
- `CodeSource` (interface_declaration, line 16, exported)
- `CodeNode` (interface_declaration, line 21, exported)
- `CodeEdge` (interface_declaration, line 28, exported)
- `DetectedTransition` (interface_declaration, line 35, exported)
- `DetectedState` (interface_declaration, line 41, exported)
- `DetectedMessage` (interface_declaration, line 47, exported)
- `DetectedProtocol` (interface_declaration, line 53, exported)
- `CodeGraph` (interface_declaration, line 59, exported)
- `CanonicalNodes` (interface_declaration, line 66, exported)
- `TypeNodeKind` (type_alias_declaration, line 71, exported)
- `TypeEdgeKind` (type_alias_declaration, line 73, exported)
- `TypeNode` (interface_declaration, line 75, exported)
- `TypeEdge` (interface_declaration, line 83, exported)
- `TypeGraph` (interface_declaration, line 90, exported)
- `ScriptNodeKind` (type_alias_declaration, line 95, exported)
- `ScriptNode` (interface_declaration, line 97, exported)
- `ScriptEdge` (interface_declaration, line 103, exported)
- `ScriptGraph` (interface_declaration, line 108, exported)
- `CappedEdges` (interface_declaration, line 113, exported)
- `CappedGraph` (interface_declaration, line 118, exported)

## Contained in

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

## Source

```typescript
export type CodeNodeKind =
    | "collaborator"
    | "decision"
    | "entry"
    | "exit"
    | "factory"
    | "fail-sink"
    | "gate"
    | "hook"
    | "method"
    | "registry"
    | "store";

export type CodeEdgeKind = "branch" | "call" | "data-flow" | "dependency" | "hook-register" | "loop" | "teardown";

export interface CodeSource {
    file: string;
    line: number;
}

export interface CodeNode {
    id: string;
    kind: CodeNodeKind;
    label: string;
    source: CodeSource;
}

export interface CodeEdge {
    from: string;
    to: string;
    kind: CodeEdgeKind;
    label?: string | undefined;
}

export interface DetectedTransition {
    from: string;
    to: string;
    label?: string | undefined;
}

export interface DetectedState {
    states: string[];
    initial: string | null;
    transitions: DetectedTransition[];
}

export interface DetectedMessage {
    to: string;
    text: string;
    async: boolean;
}

export interface DetectedProtocol {
    self: string;
    participants: string[];
    messages: DetectedMessage[];
}

export interface CodeGraph {
    nodes: CodeNode[];
    edges: CodeEdge[];
    state?: DetectedState | null;
    protocol?: DetectedProtocol | null;
}

export interface CanonicalNodes {
    idMap: Map<string, string>;
    nodes: CodeNode[];
}

export type TypeNodeKind = "class" | "enum" | "interface" | "type-alias";

export type TypeEdgeKind = "extends" | "has" | "implements" | "uses";

export interface TypeNode {
    id: string;
    kind: TypeNodeKind;
    label: string;
    members: string[];
    source: CodeSource;
}

export interface TypeEdge {
    from: string;
    to: string;
    kind: TypeEdgeKind;
    label?: string | undefined;
}

export interface TypeGraph {
    nodes: TypeNode[];
    edges: TypeEdge[];
}

export type ScriptNodeKind = "file" | "script" | "tool";

export interface ScriptNode {
    id: string;
    label: string;
    kind: ScriptNodeKind;
}

export interface ScriptEdge {
    from: string;
    to: string;
}

export interface ScriptGraph {
    nodes: ScriptNode[];
    edges: ScriptEdge[];
}

export interface CappedEdges {
    edges: CodeEdge[];
    truncated: boolean;
}

export interface CappedGraph extends CappedEdges {
    allCount: number;
    nodes: CodeNode[];
}
```
