# core/loaders/seed.loader.ts

> 42 lines of code and 9 definitions.

Tree: Build tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/build#file-build-core-loaders-seed-loader-ts
Source text: https://banes-lab.com/assets/sources/source.fe5090b1235c8c5c0d56e468cea089d4763f48b1eedd10481c8fe1e8f222a77d.generated.txt

## Definitions

- `seedsTarget` (lexical_declaration, line 38, exported)
- `isSeedReport` (lexical_declaration, line 42)
- `readSeeds` (lexical_declaration, line 46, exported)
- `loadFaces` (lexical_declaration, line 12, exported)
- `readModelTemplate` (lexical_declaration, line 16, exported)
- `readModels` (lexical_declaration, line 20, exported)
- `folder` (lexical_declaration, line 21, exported)
- `readOperatorProfile` (lexical_declaration, line 31, exported)
- `parsed` (lexical_declaration, line 47, exported)

## Used by

- [runtime/entrypoints/leak.entrypoint.ts](https://banes-lab.com/source/build/runtime/entrypoints/leak.entrypoint.ts.md)

## Source

```typescript
import type { Faces, SeedReport } from "#types/lesson.types";
import { MODELS_FOLDER, MODEL_TEMPLATE, OPERATOR_PROFILE, UTF8 } from "#configuration/constants/source.constants";
import { absolutePath, relativePath } from "@ssot/paths";
import { readFileSync, readdirSync } from "node:fs";
import { MODEL_EXTENSION } from "#configuration/constants/seed.constants";
import type { SourceText } from "#types/inventory.types";
import { createAlgoGrammar } from "@govlab/context/algo";
import { createArchRelations } from "@govlab/context/arch";
import { join } from "node:path";
import { readJsonOrNull } from "#core/persistence/report.persistence";

export const loadFaces = function loadFaces(): Faces {
    return { algo: createAlgoGrammar(), arch: createArchRelations() };
};

export const readModelTemplate = function readModelTemplate(): string {
    return readFileSync(absolutePath("collaboration", MODEL_TEMPLATE), UTF8);
};

export const readModels = function readModels(): SourceText[] {
    const folder = absolutePath("collaboration", MODELS_FOLDER);
    return readdirSync(folder)
        .filter((name) => name.endsWith(MODEL_EXTENSION))
        .sort((a, b) => a.localeCompare(b))
        .map((name) => ({
            path: relativePath("collaboration", MODELS_FOLDER, name),
            text: readFileSync(join(folder, name), UTF8),
        }));
};

export const readOperatorProfile = function readOperatorProfile(): SourceText {
    return {
        path: relativePath("docArch.references", OPERATOR_PROFILE),
        text: readFileSync(absolutePath("docArch.references", OPERATOR_PROFILE), UTF8),
    };
};

export const seedsTarget = function seedsTarget(): string {
    return absolutePath("govlabHost.reports.content.seeds");
};

const isSeedReport = function isSeedReport(value: unknown): value is SeedReport {
    return typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "seeds"));
};

export const readSeeds = function readSeeds(): SeedReport | null {
    const parsed = readJsonOrNull(seedsTarget());
    return isSeedReport(parsed) ? parsed : null;
};
```
