Skip to content

OutputBuilder

Defined in: plan/output-builder.ts:74

Immutable builder for constructing output objects.

Each method returns a new builder instance with updated type information. Call build() to get the final output value.

const builder = createOutputBuilder()
.add('name', 'Alice')
.add('age', 30)
const result = builder.build()
// result: { name: string, age: number }
// With metadata annotations
const builder = createOutputBuilder()
.add('name', 'Alice')
.meta('name', { description: 'User full name', examples: ['Alice', 'Bob'] })
.add('email', 'alice@example.com')
.meta('email', { format: 'email' })
const allMeta = builder.getAllMeta()
// Map { 'name' => { description: '...', examples: [...] }, 'email' => { format: 'email' } }

T

The current accumulated type

add<K, V>(key, value): OutputBuilder<T & { [P in string]: V }>

Defined in: plan/output-builder.ts:84

Add a key-value pair to the output.

K extends string

The key type (string literal)

V

The value type

K

Property name to add

V

Value to set

OutputBuilder<T & { [P in string]: V }>

New builder with the added property


build(): T

Defined in: plan/output-builder.ts:125

Get the final accumulated value.

T

The built output object


getAllMeta(): ReadonlyMap<string, OutputMeta>

Defined in: plan/output-builder.ts:118

Get all metadata as a readonly map.

ReadonlyMap<string, OutputMeta>

Map of property names to metadata


getMeta<K>(key): OutputMeta | undefined

Defined in: plan/output-builder.ts:111

Get metadata for a specific property.

K extends string

K

Property name

OutputMeta | undefined

Metadata if set, undefined otherwise


meta<K>(key, metadata): OutputBuilder<T>

Defined in: plan/output-builder.ts:103

Add metadata annotations for a property. Used for JSON schema export and other derivations.

K extends string

K

Property name to annotate

OutputMeta

Metadata annotations

OutputBuilder<T>

New builder with the added metadata


set<V>(value): OutputBuilder<V>

Defined in: plan/output-builder.ts:93

Replace the entire accumulated value.

V

The new value type

V

Value to set

OutputBuilder<V>

New builder with the new value