Skip to content

EmitBuilder

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

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:81

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:95

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

K extends string

S extends SpecLike

K

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

S

Extraction spec from SpecBuilder

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


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

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

Add multiple extractions at once from a record of specs.

S extends Record<string, SpecLike>

S

Record mapping output path keys to extraction specs

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


addIfEmpty(path, spec): EmitBuilder<T>

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

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:131

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:196

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:242

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:151

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:224

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:256

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:276

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:75

Create a new empty builder

EmitBuilder<{ }>