# types/catalog.types.ts

> 137 lines of code and 25 definitions.

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

Listed in [types](https://banes-lab.com/api/source/quality/types.md), after [types/canon.types.ts](https://banes-lab.com/source/quality/types/canon.types.ts.md) and before [types/comment.types.ts](https://banes-lab.com/source/quality/types/comment.types.ts.md).

## Definitions

- `ToolKnob` (interface_declaration, line 1, exported)
- `Exemplar` (interface_declaration, line 8, exported)
- `QualityConcept` (interface_declaration, line 14, exported)
- `QualityConcernRecord` (interface_declaration, line 21, exported)
- `QualityRuleRecord` (interface_declaration, line 33, exported)
- `QualityToolRecord` (interface_declaration, line 46, exported)
- `QualityConcern` (interface_declaration, line 54, exported)
- `QualityRule` (interface_declaration, line 58, exported)
- `QualityTool` (interface_declaration, line 62, exported)
- `QualityData` (interface_declaration, line 66, exported)
- `CatalogRule` (type_alias_declaration, line 73, exported)
- `KnobSpec` (interface_declaration, line 75, exported)
- `KnobEntry` (type_alias_declaration, line 83, exported)
- `CatalogProduct` (interface_declaration, line 85, exported)
- `ProducerRefresh` (type_alias_declaration, line 91, exported)
- `CatalogProducer` (interface_declaration, line 93, exported)
- `CatalogRequest` (interface_declaration, line 100, exported)
- `CatalogWriter` (interface_declaration, line 105, exported)
- `ToolTally` (interface_declaration, line 111, exported)
- `ConceptEntry` (interface_declaration, line 118, exported)
- `RuleKnob` (interface_declaration, line 129, exported)
- `ConcernControl` (interface_declaration, line 136, exported)
- `CatalogState` (interface_declaration, line 146, exported)
- `CatalogKey` (type_alias_declaration, line 154, exported)
- `CatalogStep` (interface_declaration, line 156, exported)

## Contained in

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

## Source

```typescript
export interface ToolKnob {
    knob: string;
    type: string;
    default: boolean | number | string | null;
    threshold: boolean;
}

export interface Exemplar {
    before: string;
    after: string;
    lang: string;
}

export interface QualityConcept {
    id: string;
    dimension: string;
    total: number;
    exemplar?: Exemplar;
}

export interface QualityConcernRecord {
    name: string;
    value: boolean | number;
    severity: string;
    numeric: boolean;
    toolCount: number;
    ruleCount: number;
    valueDerivation?: string;
    knobPerTool?: Record<string, string>;
    configOptions?: string[];
}

export interface QualityRuleRecord {
    name: string;
    tool: string;
    ecosystem: string;
    ruleId: string;
    ruleName: string;
    concern: string;
    category: string;
    url: string;
    canonical?: string[];
    knobs?: ToolKnob[];
}

export interface QualityToolRecord {
    name: string;
    ecosystem: string;
    ruleCount: number;
    knobCount: number;
    detectionOnly: boolean;
}

export interface QualityConcern extends QualityConcernRecord {
    id: string;
}

export interface QualityRule extends QualityRuleRecord {
    id: string;
}

export interface QualityTool extends QualityToolRecord {
    id: string;
}

export interface QualityData {
    concerns: QualityConcernRecord[];
    rules: QualityRuleRecord[];
    tools: QualityToolRecord[];
    concepts: QualityConcept[];
}

export type CatalogRule = Record<string, unknown> & { ruleId: string };

export interface KnobSpec {
    default: unknown;
    knob: string;
    threshold: boolean;
    type?: string;
    fixed?: boolean;
}

export type KnobEntry = [string, string, KnobSpec];

export interface CatalogProduct {
    source: string;
    rules: CatalogRule[];
    summary: Record<string, unknown>;
}

export type ProducerRefresh = "build" | "manual";

export interface CatalogProducer {
    name: string;
    refresh: ProducerRefresh;
    produce: () => Promise<CatalogProduct[]>;
    knobs?: () => Promise<KnobEntry[]>;
}

export interface CatalogRequest {
    rules: readonly string[];
    knobs: readonly string[];
}

export interface CatalogWriter {
    json: (file: string, data: unknown) => Promise<void>;
    text: (file: string, text: string) => Promise<void>;
    markdown: (file: string, text: string) => Promise<void>;
}

export interface ToolTally {
    ecosystem: string;
    rules: number;
    tool: string;
    version: string;
}

export interface ConceptEntry {
    byEcosystem: Record<string, number>;
    byTool: Record<string, number>;
    dimension: string;
    id: string;
    sample: string[];
    tools: number;
    total: number;
    exemplar?: unknown;
}

export interface RuleKnob {
    default: unknown;
    knob: string;
    threshold: boolean;
    type?: string;
}

export interface ConcernControl {
    rules: number;
    severity: string;
    tools: number;
    value: boolean | number;
    valueDerivation?: string;
    knobPerTool?: Record<string, string>;
    configOptions?: string[];
}

export interface CatalogState {
    rules?: CatalogRule[];
    classified?: CatalogRule[];
    catalog?: CatalogRule[];
    concepts?: ConceptEntry[];
    ruleKnobs?: Record<string, RuleKnob[]>;
}

export type CatalogKey = keyof CatalogState;

export interface CatalogStep {
    name: string;
    needs: readonly CatalogKey[];
    gives: readonly CatalogKey[];
    run: (state: CatalogState, writer: CatalogWriter) => Promise<Partial<CatalogState>>;
}
```
