runInstructions(options)

Default Export

Executes an array of declarative blueprint instruction keys sequentially on a provided base canvas using the supplied data.

Signature
runInstructions({
    instructions: string[],
    base: object,
    data: object,
    showLog?: boolean
}): object
Parameters
Parameter Type Required Description
instructions string[] Yes Array of instruction keys defined in declarative-instructions (e.g. ["buildColgroup", "buildHeader", "buildBody"]).
base object Yes The target canvas AST node (e.g., from spec.tableSimple, spec.selectBase, spec.formSimple) that will be mutated in place.
data object Yes Input data bag containing columns array and/or data rows array.
showLog boolean No When set to true, outputs debugging info for each step execution to console. Default: false.
Return Value

Returns the mutated base specification object containing the complete AST tree with all generated children and attributes.

Critical Architectural Rule: Never pass baseKey
runInstructions operates strictly on an in-memory base canvas object. It does not look up keys from declarative-spec. The orchestrator (e.g. json-renderers-run-instructions) is responsible for cloning the base spec (structuredClone(spec[definition.baseFromSpec])) and passing that reference in.

executeStep(key, state, showLog)

Named Export

Executes a single instruction step against the state context. Useful for step-by-step debugging, intermediate verification, or custom pipeline runners.

Signature
executeStep(
    key: string,
    state: { base: object, data: object },
    showLog: boolean = false
): object | any[]
Parameters
Parameter Type Required Description
key string Yes The exact blueprint key name from declarative-instructions.
state object Yes An object holding references to { base, data }.
showLog boolean No Enables console logging. Default: false.
Return Value

Returns the freshly generated subtree node(s) computed by the dimensional transformer function for that step.

Internal Helper Functions

Exported from src/v4/helpers.js:

resolveSource(sourcePath, state)

Resolves the root or nested data subset from state using either sourcePath.jsonPath via jsonpathly or direct sourcePath.filePath traversal.

writeResult(state, destinationPath, result, showLog)

Writes the calculated result spec directly to destinationPath on state using json-write-path. Safely skips when the destination container is not present.

TypeScript Interfaces

export interface StepRunnerOptions {
    instructions: string[];
    base: Record<string, any>;
    data: {
        columns?: Array<Record<string, any>>;
        data?: Array<Record<string, any>>;
        [key: string]: any;
    };
    showLog?: boolean;
}

export function runInstructions(options: StepRunnerOptions): Record<string, any>;
export function executeStep(key: string, state: Record<string, any>, showLog?: boolean): any;