# runtime/entrypoints/inventory.entrypoint.ts

> 23 lines of code and 7 definitions.

Tree: Build tree
Language: typescript
Layer: runtime
Canonical: https://banes-lab.com/anatomy/build#file-build-runtime-entrypoints-inventory-entrypoint-ts
Source text: https://banes-lab.com/assets/sources/source.929a553ef51c39a9dde7982bc6f27785d175ed0b2272c25078aa7ae87b9fed8d.generated.txt

## Definitions

- `sources` (lexical_declaration, line 13)
- `inventorySources` (lexical_declaration, line 14)
- `records` (lexical_declaration, line 15)
- `found` (lexical_declaration, line 16)
- `lines` (lexical_declaration, line 17)
- `inventory` (lexical_declaration, line 23)
- `target` (lexical_declaration, line 24)

## Source

```typescript
import type { Inventory, InventorySource } from "#types/inventory.types";
import { LINES_SUFFIX, READ_SOURCE, RECORDS_SUFFIX, WROTE } from "#configuration/strings/derivation.strings";
import { inventoryTarget, readInventorySources } from "#core/loaders/inventory.loader";
import { lineCount, scanRules } from "#core/converters/inventory.converter";
import { INVENTORY_COMMAND } from "#configuration/constants/contract.constants";
import { INVENTORY_SUMMARY } from "#configuration/strings/contract.strings";
import { persistJson } from "#core/persistence/report.persistence";
import { resolveArgv } from "@govlab/argv";
import { say } from "#core/reporters/derivation.reporter";

resolveArgv({ command: INVENTORY_COMMAND, flags: [], summary: INVENTORY_SUMMARY });

const sources = await readInventorySources();
const inventorySources: InventorySource[] = [];
const records = sources.flatMap((source) => {
    const found = scanRules(source.text, source.path);
    const lines = lineCount(source.text);
    inventorySources.push({ lines, path: source.path, records: found.length });
    say(`${READ_SOURCE}${source.path}: ${String(lines)}${LINES_SUFFIX}${String(found.length)}${RECORDS_SUFFIX}`);
    return found;
});

const inventory: Inventory = { records, sources: inventorySources };
const target = inventoryTarget();
await persistJson(target, inventory);
say(`${WROTE}${target}`);
```
