Planner
Defined in: plan/planner.ts:222
Fluent builder for constructing execution plans.
Planner is a mutable, single-use builder. The typical workflow is:
- Create a new Planner
- Chain method calls to define the pipeline
- Call compile() to produce an immutable Plan
Example
Section titled “Example”const plan = new Planner() .in(loadFile('config.json')) .mapIn(parseJson()) .emit((out, $) => out .add('host', $.get('host').string()) .add('port', $.get('port').number()) ) .compile()
const result = await run(plan, { readFile: fs.readFile })// result.value: { host: string, port: number }Type Parameters
Section titled “Type Parameters”In = never
Current input type flowing through the pipeline
Out = { }
Current accumulated output type
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Planner<
In,Out>():Planner<In,Out>
Returns
Section titled “Returns”Planner<In, Out>
Methods
Section titled “Methods”compile()
Section titled “compile()”compile():
Plan<Out>
Defined in: plan/planner.ts:437
Compile the planner into an immutable execution plan.
Must be called after at least one emit() to define the output. The returned Plan is immutable and can be executed multiple times.
Returns
Section titled “Returns”Plan<Out>
Compiled Plan ready for execution
Throws
Section titled “Throws”Error if called without emit() (no output defined)
Example
Section titled “Example”const plan = new Planner() .in(load({ name: 'test' })) .emit((out, $) => out.add('result', $.get('name').string())) .compile()
// Execute the planconst result = await run(plan)emit()
Section titled “emit()”emit<
B>(builder):Planner<In,B>
Defined in: plan/planner.ts:331
Declaratively emit values to the output using a builder pattern.
Multiple emit() calls can be chained to accumulate values from different inputs.
Type Parameters
Section titled “Type Parameters”B
Parameters
Section titled “Parameters”builder
Section titled “builder”(out, $) => EmitBuilder<B>
Returns
Section titled “Returns”Planner<In, B>
Example
Section titled “Example”new Planner() .in(loadFile('config.json')) .mapIn(parseJson()) .emit((out, $) => out .add('host', $.get('host').string()) .add('port', $.get('port').number()) .addLiteral('version', '1.0.0') ) .in(loadFile('users.json')) .mapIn(parseJson()) .emit((out, $) => out .add('users', $.get('data').array(u => u.get('name').string())) ) .compile()Call Signature
Section titled “Call Signature”in<
T>(input):Planner<DataSpecProxy<T>,Out>
Defined in: plan/planner.ts:251
Define the input source for the pipeline.
Type Parameters
Section titled “Type Parameters”T
The type produced by this input
Parameters
Section titled “Parameters”DirectInput<T>
Input specification (FileInput, FilesInput, DirectInput, or SourcesInput)
Returns
Section titled “Returns”Planner<DataSpecProxy<T>, Out>
This planner for chaining
Example
Section titled “Example”new Planner() .in(loadFile('data.json')) // Load from file .in(load({ key: 'value' })) // Or use inline data .in(sources({ a: load(1) })) // Or combine multiple sourcesCall Signature
Section titled “Call Signature”in<
T>(input):Planner<SpecBuilder,Out>
Defined in: plan/planner.ts:252
Define the input source for the pipeline.
Type Parameters
Section titled “Type Parameters”T extends Record<string, unknown>
The type produced by this input
Parameters
Section titled “Parameters”SourcesInput<T>
Input specification (FileInput, FilesInput, DirectInput, or SourcesInput)
Returns
Section titled “Returns”Planner<SpecBuilder, Out>
This planner for chaining
Example
Section titled “Example”new Planner() .in(loadFile('data.json')) // Load from file .in(load({ key: 'value' })) // Or use inline data .in(sources({ a: load(1) })) // Or combine multiple sourcesCall Signature
Section titled “Call Signature”in<
T>(input):Planner<SpecBuilder,Out>
Defined in: plan/planner.ts:255
Define the input source for the pipeline.
Type Parameters
Section titled “Type Parameters”T
The type produced by this input
Parameters
Section titled “Parameters”Input<T>
Input specification (FileInput, FilesInput, DirectInput, or SourcesInput)
Returns
Section titled “Returns”Planner<SpecBuilder, Out>
This planner for chaining
Example
Section titled “Example”new Planner() .in(loadFile('data.json')) // Load from file .in(load({ key: 'value' })) // Or use inline data .in(sources({ a: load(1) })) // Or combine multiple sourcesmapIn()
Section titled “mapIn()”Call Signature
Section titled “Call Signature”mapIn<
SB>(transform):Planner<SB,Out>
Defined in: plan/planner.ts:287
Apply a transform to the current input.
Type Parameters
Section titled “Type Parameters”SB
Parameters
Section titled “Parameters”transform
Section titled “transform”Transform AST specification
Returns
Section titled “Returns”Planner<SB, Out>
This planner for chaining
Throws
Section titled “Throws”Error if called before in()
Example
Section titled “Example”new Planner() .in(loadFile('data.json')) .mapIn(parseJson()) // Apply JSON parsing transformCall Signature
Section titled “Call Signature”mapIn(
transform):Planner<SpecBuilder,Out>
Defined in: plan/planner.ts:288
Apply a transform to the current input.
Parameters
Section titled “Parameters”transform
Section titled “transform”Transform AST specification
Returns
Section titled “Returns”Planner<SpecBuilder, Out>
This planner for chaining
Throws
Section titled “Throws”Error if called before in()
Example
Section titled “Example”new Planner() .in(loadFile('data.json')) .mapIn(parseJson()) // Apply JSON parsing transformmapOut()
Section titled “mapOut()”mapOut<
NewOut>(builder):Planner<In,NewOut>
Defined in: plan/planner.ts:383
Apply structural transformations to the output after extraction.
Each .mapOut() call adds a new AST node that transforms the accumulated output.
Multiple .mapOut() calls chain sequentially.
Type Parameters
Section titled “Type Parameters”NewOut
Section titled “NewOut”NewOut = unknown
Parameters
Section titled “Parameters”builder
Section titled “builder”(out) => OutputTransformBuilder<NewOut>
Returns
Section titled “Returns”Planner<In, NewOut>
Example
Section titled “Example”new Planner() .in(load({ items: [{cat: 'A', v: 1}, {cat: 'B', v: 2}] })) .emit((out, $) => out.add('items', $.get('items').array(i => ({ kind: 'object', properties: { cat: i.get('cat').string(), v: i.get('v').number() } })))) .mapOut($ => $.groupBy(o => o.items, 'cat')) .compile()merge()
Section titled “merge()”
staticmerge<T>(…plans):Plan<MergeOutputs<T>>
Defined in: plan/planner.ts:477
Merge multiple plans into a single plan with combined output. Later plans take precedence in case of key conflicts.
Type Parameters
Section titled “Type Parameters”T extends Plan<unknown>[]
Parameters
Section titled “Parameters”…T
Returns
Section titled “Returns”Plan<MergeOutputs<T>>
Example
Section titled “Example”const configPlan = new Planner() .in(load('config.json')) .mapIn(parseJson()) .emit((out, $) => out.add('host', $.get('host').string())) .compile()
const usersPlan = new Planner() .in(load('users.json')) .mapIn(parseJson()) .emit((out, $) => out.add('users', $.get('data').strings())) .compile()
const combined = Planner.merge(configPlan, usersPlan)// Result type: { host: string } & { users: string[] }mergeAs()
Section titled “mergeAs()”
staticmergeAs<T>(plans):Plan<{ [K in string | number | symbol]: T[K] extends Plan<O> ? O : never }>
Defined in: plan/planner.ts:493
Merge multiple plans with each plan’s output nested under a key.
Type Parameters
Section titled “Type Parameters”T extends Record<string, Plan<unknown>>
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”Plan<{ [K in string | number | symbol]: T[K] extends Plan<O> ? O : never }>
Example
Section titled “Example”const combined = Planner.mergeAs({ config: configPlan, users: usersPlan,})// Result type: { config: { host: string }, users: { users: string[] } }