# toGeneratorEnrichment

FUNCTION in `@skmtc/core 0.63.4`

Read this generator's **generator-scoped** enrichment - the
run-constant leaf at
`skmtc.config.json#settings.enrichments[generatorId]._generator`, validated
through the generator's own schema (typically declared as
`toGeneratorEnrichmentSchema` on its entry, and reused here).

The return type is inferred from `schema`, so the read is fully typed
with no cast. Whether the block is required or optional is the
schema's decision: a generator that needs config passes a required
`v.object({...})` (a missing block then throws); one with all-optional
config passes `v.optional(v.object({...}))`.

## Signature

```ts
import { toGeneratorEnrichment } from '@skmtc/core'

toGeneratorEnrichment<EnrichmentType>(
  context: EnrichmentReadContext,
  generatorId: string,
  schema: v.GenericSchema<EnrichmentType>
): EnrichmentType
```

## Parameters

- `context` (EnrichmentReadContext, required)
  - `settings` (ClientSettings | undefined, required)
- `generatorId` (string, required)
- `schema` (v.GenericSchema<EnrichmentType>, required)

## Returns

`EnrichmentType`

## Throws

- `Error`: on a malformed block, naming each wrong value's place in `skmtc.config.json`. The item is recorded as `error`, and the run fails once every generator has run, exactly as for a bad subject leaf.
