# types/code.types.ts

> 91 lines of code and 14 definitions.

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

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

## Definitions

- `CodeSymbol` (interface_declaration, line 1, exported)
- `ImportBinding` (interface_declaration, line 15, exported)
- `IngestFile` (interface_declaration, line 20, exported)
- `ModuleUnit` (interface_declaration, line 26, exported)
- `SymbolStat` (interface_declaration, line 31, exported)
- `TypeStat` (interface_declaration, line 45, exported)
- `CodeInsight` (interface_declaration, line 50, exported)
- `Distribution` (interface_declaration, line 58, exported)
- `CallEdge` (interface_declaration, line 63, exported)
- `ExternalCall` (interface_declaration, line 70, exported)
- `CodeGraph` (interface_declaration, line 77, exported)
- `CodeFinding` (interface_declaration, line 82, exported)
- `DiagnoseInput` (interface_declaration, line 95, exported)
- `ModuleEdge` (interface_declaration, line 101, exported)

## Contained in

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

## Source

```typescript
export interface CodeSymbol {
    role: string;
    name: string;
    line: number;
    enclosing: string;
    kind: string;
    file: string;
    member: boolean;
    exported: boolean;
    callable: boolean;
    hash: string;
    size: number;
}

export interface ImportBinding {
    importedNames: string[];
    source: string;
}

export interface IngestFile {
    records: Record<string, unknown>[];
    symbols: CodeSymbol[];
    imports: ImportBinding[];
}

export interface ModuleUnit {
    moduleDir: string;
    imports: readonly ImportBinding[];
}

export interface SymbolStat {
    name: string;
    role: string;
    inDegree: number;
    outDegree: number;
    flow: string;
    line: number;
    kind: string;
    file: string;
    exported: boolean;
    callable: boolean;
    local: boolean;
}

export interface TypeStat {
    type: string;
    count: number;
}

export interface CodeInsight {
    symbols: SymbolStat[];
    invariants: TypeStat[];
    variants: TypeStat[];
    definitions: number;
    edges: number;
}

export interface Distribution {
    invariants: TypeStat[];
    variants: TypeStat[];
}

export interface CallEdge {
    from: string;
    to: string;
    file: string;
    line: number;
}

export interface ExternalCall {
    caller: string;
    name: string;
    file: string;
    line: number;
}

export interface CodeGraph {
    edges: CallEdge[];
    external: ExternalCall[];
}

export interface CodeFinding {
    kind: string;
    severity: string;
    confidence: string;
    relevance: number;
    name: string;
    file: string;
    line: number;
    detail: string;
    remedy: string;
    members: string[];
}

export interface DiagnoseInput {
    graph: CodeGraph;
    records: readonly Record<string, unknown>[];
    testUses: ReadonlySet<string>;
}

export interface ModuleEdge {
    from: string;
    to: string;
}
```
