# core/loaders/registry.loader.ts

> 24 lines of code and 5 definitions.

Tree: GovLab Stats
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/stats#file-stats-core-loaders-registry-loader-ts
Source text: https://banes-lab.com/source/stats/core/loaders/registry.loader.ts.txt

Listed in [core/loaders](https://banes-lab.com/api/source/stats/core/loaders.md), after [core/loaders/pattern.loader.ts](https://banes-lab.com/source/stats/core/loaders/pattern.loader.ts.md) and before [core/loaders/report.loader.ts](https://banes-lab.com/source/stats/core/loaders/report.loader.ts.md).

## Definitions

- `withDisposition` (lexical_declaration, line 12, exported)
- `readRegistry` (lexical_declaration, line 8, exported)
- `registry` (lexical_declaration, line 9, exported)
- `records` (lexical_declaration, line 10, exported)
- `nonPlugin` (lexical_declaration, line 11, exported)

## Contained in

- [core/loaders](https://banes-lab.com/anatomy/stats/folder-stats-core-loaders.md)

## Uses

- [core/selectors/field.selector.ts](https://banes-lab.com/source/stats/core/selectors/field.selector.ts.md)

## Linked from

- [core/loaders](https://banes-lab.com/anatomy/stats/folder-stats-core-loaders.md)
- [core/selectors](https://banes-lab.com/anatomy/stats/folder-stats-core-selectors.md)

## Source

```typescript
import { arrayField, field, stringField } from "#core/selectors/field.selector";
import { DISPOSITION } from "#configuration/constants/rule.constants";
import type { RegistryCounts } from "#types/rule.types";
import path from "node:path";
import { readJson } from "#core/loaders/data.loader";
import { relativePath } from "@ssot/paths";

export const readRegistry = function readRegistry(root: string): RegistryCounts {
    const registry = readJson(path.join(root, relativePath("govlab.quality.data.registry")));
    const records = arrayField(registry, "records");
    const nonPlugin = records.filter((record) => field(record, "isPlugin") !== true);
    const withDisposition = function withDisposition(name: string): unknown[] {
        return nonPlugin.filter((record) => stringField(record, "disposition") === name);
    };
    return {
        advisory: withDisposition(DISPOSITION.advisory).length,
        excluded: withDisposition(DISPOSITION.excluded).length,
        fullGate: withDisposition(DISPOSITION.fullGate).map((record) => ({
            ecosystem: stringField(record, "ecosystem"),
            tool: stringField(record, "tool"),
        })),
        plugins: records.length - nonPlugin.length,
        selectable: withDisposition(DISPOSITION.selectable).length,
    };
};
```
