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.
Type Parameters
Section titled “Type Parameters”T = { }
Accessors
Section titled “Accessors”extractions
Section titled “extractions”Get Signature
Section titled “Get Signature”get extractions(): readonly
Extraction[]
Defined in: emit/emit-builder.ts:74
Get all recorded extractions
Returns
Section titled “Returns”readonly Extraction[]
Methods
Section titled “Methods”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.
Type Parameters
Section titled “Type Parameters”K extends string
S extends Spec
Parameters
Section titled “Parameters”K
Output path (dot-separated for nested, e.g. “config.host”)
S
Extraction spec from PathBuilder
Returns
Section titled “Returns”EmitBuilder<{ [K in string | number | symbol]: (T & Record<K, InferOutput<S>>)[K] }>
addIfEmpty()
Section titled “addIfEmpty()”addIfEmpty(
path,spec):EmitBuilder<T>
Defined in: emit/emit-builder.ts:138
Set a value only if the path is currently empty/undefined.
Parameters
Section titled “Parameters”string
Output path
Extraction spec
Returns
Section titled “Returns”EmitBuilder<T>
addLiteral()
Section titled “addLiteral()”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).
Type Parameters
Section titled “Type Parameters”K extends string
V
Parameters
Section titled “Parameters”K
Output path
V
Literal value to set
Returns
Section titled “Returns”EmitBuilder<{ [K in string | number | symbol]: (T & Record<K, V>)[K] }>
addWhen()
Section titled “addWhen()”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.
Parameters
Section titled “Parameters”string
Output path
Extraction spec
_condition
Section titled “_condition”(current) => boolean
description
Section titled “description”string
Description for AST introspection
Returns
Section titled “Returns”EmitBuilder<T>
append()
Section titled “append()”append(
path,spec):EmitBuilder<T>
Defined in: emit/emit-builder.ts:208
Append a value to an array at path.
Parameters
Section titled “Parameters”string
Output path to array
Extraction spec for value to append
Returns
Section titled “Returns”EmitBuilder<T>
describe()
Section titled “describe()”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.
Parameters
Section titled “Parameters”string
Output path (must match a previously added extraction)
Metadata annotations (description, title, examples, etc.)
Returns
Section titled “Returns”EmitBuilder<T>
merge()
Section titled “merge()”merge(
path,spec):EmitBuilder<T>
Defined in: emit/emit-builder.ts:190
Deep merge an object with existing value at path.
Parameters
Section titled “Parameters”string
Output path
Extraction spec (should produce an object)
Returns
Section titled “Returns”EmitBuilder<T>
prepend()
Section titled “prepend()”prepend(
path,spec):EmitBuilder<T>
Defined in: emit/emit-builder.ts:222
Prepend a value to an array at path.
Parameters
Section titled “Parameters”string
Output path to array
Extraction spec for value to prepend
Returns
Section titled “Returns”EmitBuilder<T>
update()
Section titled “update()”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.
Parameters
Section titled “Parameters”string
Output path
(value) => unknown
Transformation function
description
Section titled “description”string
Description for AST introspection
Returns
Section titled “Returns”EmitBuilder<T>
create()
Section titled “create()”
staticcreate():EmitBuilder<{ }>
Defined in: emit/emit-builder.ts:68
Create a new empty builder
Returns
Section titled “Returns”EmitBuilder<{ }>