# core/loaders/seed.loader.ts

> 41 lines of code and 9 definitions.

Tree: Bane's Lab Content
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/content#file-content-core-loaders-seed-loader-ts
Source text: https://banes-lab.com/source/content/core/loaders/seed.loader.ts.txt

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

## Definitions

- `seedsTarget` (lexical_declaration, line 37, exported)
- `isSeedReport` (lexical_declaration, line 41)
- `readSeeds` (lexical_declaration, line 45, exported)
- `loadFaces` (lexical_declaration, line 11, exported)
- `readModelTemplate` (lexical_declaration, line 15, exported)
- `readModels` (lexical_declaration, line 19, exported)
- `folder` (lexical_declaration, line 20, exported)
- `readOperatorProfile` (lexical_declaration, line 30, exported)
- `parsed` (lexical_declaration, line 46, exported)

## Contained in

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

## Used by

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

## Linked from

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

## Source

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

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

export const readModelTemplate = function readModelTemplate(): string {
    return readFileSync(absolutePath("app.coordination", "templates/model.template.md"), UTF8);
};

export const readModels = function readModels(): SourceText[] {
    const folder = absolutePath("app.coordination", MODELS_FOLDER);
    return readdirSync(folder)
        .filter((name) => name.endsWith(MODEL_EXTENSION))
        .sort((a, b) => a.localeCompare(b))
        .map((name) => ({
            path: relativePath("app.coordination", 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;
};
```
