/** * @fileoverview Pipeline variable references, as specified in `spec/pipeline-variables.md`. * * A step input string is a reference only when the whole string is one of `$prev`, `$first`, * `$steps[N]`, `$steps.` or `$input`, optionally followed by `.`. Every other string * is a literal, and a leading `$$` sends a literal `$`. Paths reach only own keys of plain JSON * objects and in-bounds array indices, never prototypes, getters or `__`-prefixed keys. A * reference that cannot be resolved is absent: omitted from objects, `null` in arrays, and never * equal to anything in a `when` condition. * * Separated from `pipeline.ts` to keep both modules within the repository file-size convention. */ import type { PipelineCondition, PipelineContext } from './pipeline.js'; /** Step inputs and the request `input` may nest at most this many objects and arrays. */ export declare const MAX_NESTING_DEPTH = 64; /** Strings longer than this are literals and are never resolved. */ export declare const MAX_REFERENCE_LENGTH = 1024; /** True for objects whose prototype is `Object.prototype` or `null` (what JSON produces). */ export declare function isPlainObject(value: unknown): value is Record; /** * Copy step data so that steps never share objects. * * Uses `structuredClone`. Data that cannot be structured-cloned (for example, objects holding * functions) falls back to its JSON view; data with no JSON view either is returned as is. */ export declare function copyPipelineData(value: unknown): unknown; /** * Resolve one step input string against the pipeline context. * * - A reference (`$prev`, `$first`, `$steps[N]`, `$steps.`, `$input`, each optionally * followed by `.`) resolves to that data, or to `undefined` (absent) when it cannot be * resolved: unknown alias, index out of bounds, missing key, skipped or failed step, a * `__`-prefixed segment, or no request `input`. * - A string starting with `$$` is a literal with one leading `$` removed. * - Any other string (`$9.99`, `$HOME`, `$prevx`, or anything longer than 1024 characters) is * returned unchanged. * * `$input` is the pipeline request's own `input` field, never the host's execution context. * A path follows only own keys of plain JSON objects and in-bounds array indices; a purely * numeric segment (`items.2`) indexes an array. Prototype properties such as `constructor` * never match. * * @param ref - A step input string (e.g. '$prev.user.name', '$steps.order.items[0]', '$$literal') * @param context - Pipeline execution context * @returns The resolved value, the literal string, or undefined when a reference is unresolved * * @example * ```typescript * resolveVariable('$prev.user.name', context); // data of the previous step * resolveVariable('$steps.order.items[0]', context); // first item of the step aliased 'order' * resolveVariable('$9.99', context); // '$9.99' (not a reference) * resolveVariable('$$prev', context); // '$prev' (escaped literal) * ``` */ export declare function resolveVariable(ref: string, context: PipelineContext): unknown; /** * Resolve every reference in a step input (see {@link resolveVariable}). * * Walks arrays and plain objects; other values pass through unchanged. An unresolved reference * is omitted as an object property and becomes `null` as an array element. Resolved values are * copies, so a handler that mutates its input cannot change another step's data. * * @param input - Step input potentially containing references * @param context - Pipeline execution context * @returns The input with all references resolved * @throws Error when arrays and objects nest deeper than 64 levels; `executePipeline` rejects * such inputs with `VALIDATION_ERROR` before any step runs */ export declare function resolveVariables(input: unknown, context: PipelineContext): unknown; /** * Get a nested value from plain JSON data using dot notation. * * Only own keys of plain objects and in-bounds array indices are followed; `__`-prefixed keys, * prototype properties and getters are never read. * * @param obj - The data to traverse * @param path - Dot-separated path (e.g., 'user.profile.name', 'items[1]', 'items.1') * @returns The value at the path, or undefined if not found * * @example * ```typescript * getNestedValue({ user: { name: 'Alice' } }, 'user.name'); // => 'Alice' * getNestedValue({ items: [1, 2, 3] }, 'items[1]'); // => 2 * getNestedValue({}, 'constructor'); // => undefined * ``` */ export declare function getNestedValue(obj: unknown, path: string): unknown; /** * Evaluate a pipeline condition against the current context. * * The first operand of every comparison is a reference. A string that is not a reference, or a * reference that cannot be resolved, is absent: `$exists` is false (as it is for `null`), and * `$eq`, `$ne`, `$gt`, `$gte`, `$lt` and `$lte` are false when either operand is absent. `$eq` and * `$ne` compare JSON values structurally. * * @param condition - The condition to evaluate * @param context - Pipeline execution context * @returns true if the condition is met, false otherwise */ export declare function evaluateCondition(condition: PipelineCondition, context: PipelineContext): boolean; //# sourceMappingURL=pipeline-variables.d.ts.map