Skip to content

EmitBuilder

Defined in: emit/emit-builder.ts:57

Builder for constructing output by extracting from input.

Each method records an extraction operation that will be executed at runtime. The extractions are stored in order and can be introspected from the AST.

Type parameter T tracks the accumulated output shape. For complex nested types, use build<ExpectedType>() to assert the final shape.

T = { }

get extractions(): readonly Extraction[]

Defined in: emit/emit-builder.ts:74

Get all recorded extractions

readonly Extraction[]

add<K, S>(path, spec): EmitBuilder<{ [K in string | number | symbol]: (T & Record<K, InferOutput<S>>)[K] }>

Defined in: emit/emit-builder.ts:88

Set a value at a path. Overwrites if path already exists.

K extends string

S extends Spec

K

Output path (dot-separated for nested, e.g. “config.host”)

S

Extraction spec from PathBuilder

EmitBuilder<{ [K in string | number | symbol]: (T & Record<K, InferOutput<S>>)[K] }>


addIfEmpty(path, spec): EmitBuilder<T>

Defined in: emit/emit-builder.ts:138

Set a value only if the path is currently empty/undefined.

string

Output path

Spec

Extraction spec

EmitBuilder<T>


addLiteral<K, V>(path, value): EmitBuilder<{ [K in string | number | symbol]: (T & Record<K, V>)[K] }>

Defined in: emit/emit-builder.ts:102

Set a literal value at a path (not extracted from input).

K extends string

V

K

Output path

V

Literal value to set

EmitBuilder<{ [K in string | number | symbol]: (T & Record<K, V>)[K] }>


addWhen(path, spec, _condition, description): EmitBuilder<T>

Defined in: emit/emit-builder.ts:162

Set a value if a condition on the existing value is true.

string

Output path

Spec

Extraction spec

(current) => boolean

string

Description for AST introspection

EmitBuilder<T>


append(path, spec): EmitBuilder<T>

Defined in: emit/emit-builder.ts:208

Append a value to an array at path.

string

Output path to array

Spec

Extraction spec for value to append

EmitBuilder<T>


describe(path, meta): EmitBuilder<T>

Defined in: emit/emit-builder.ts:119

Attach metadata annotations to an existing extraction at the given path. Metadata is applied to the property’s JSON Schema during schema derivation. If the path does not match any existing extraction, this is a no-op.

string

Output path (must match a previously added extraction)

OutputMeta

Metadata annotations (description, title, examples, etc.)

EmitBuilder<T>


merge(path, spec): EmitBuilder<T>

Defined in: emit/emit-builder.ts:190

Deep merge an object with existing value at path.

string

Output path

Spec

Extraction spec (should produce an object)

EmitBuilder<T>


prepend(path, spec): EmitBuilder<T>

Defined in: emit/emit-builder.ts:222

Prepend a value to an array at path.

string

Output path to array

Spec

Extraction spec for value to prepend

EmitBuilder<T>


update(path, fn, description): EmitBuilder<T>

Defined in: emit/emit-builder.ts:242

Apply a post-processing function to a value at path. The function is executed after extraction.

string

Output path

(value) => unknown

Transformation function

string

Description for AST introspection

EmitBuilder<T>


static create(): EmitBuilder<{ }>

Defined in: emit/emit-builder.ts:68

Create a new empty builder

EmitBuilder<{ }>