donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
47 lines • 2.41 kB
TypeScript
/**
* Regular expression to match template JSON-path expressions inside of {{...}}
*/
export declare const TEMPLATE_DATA_PATTERN: RegExp;
/**
* Resolve a JSONPath expression against the context
* @param expression - The JSONPath expression to evaluate
* @param dataSource - The data context to evaluate against
* @returns The resolved value or undefined if not found
*/
export declare function resolveExpression(expression: string, dataSource: Record<string, unknown>): any;
/**
* Interpolate template strings using JSONPath expressions, handling nested expressions
* @param template - The template string with {{...}} expressions
* @param dataSource - The data context to interpolate from
* @param recursionDepth - Current recursion depth (for loop detection)
* @param maxRecursionDepth - Maximum allowed recursion depth
* @param processed - Set of already processed templates (for loop detection)
* @returns The interpolated string
*/
export declare function interpolateString(template: string, dataSource: Record<string, unknown>, recursionDepth?: number, maxRecursionDepth?: number, processed?: Set<string>): string;
/**
* Interpolate the parameters object using JSONPath expressions. Any string values
* and keys in the object will be replaced with the corresponding values from the data source.
* Nested objects and arrays will be processed recursively.
*
* @param parameters - The original parameters object
* @param dataSource - The data context to interpolate from
* @returns A new parameters object with interpolated string values and keys
*/
export declare function interpolateObject(parameters: Record<string, any>, dataSource: Record<string, unknown>, recursionDepth?: number, maxRecursionDepth?: number, processedObjects?: WeakSet<object>): any;
/**
* Extracts interpolation expressions from a template string.
*
* @param template - The template string with {{...}} expressions
* @returns An array of the extracted expressions without the {{ }} delimiters
*
* @example
* // Returns ["env.USER_NAME"]
* extractInterpolationExpressions("Hello {{env.USER_NAME}}, how are you?");
*
* @example
* // Returns ["env.API_KEY", "calls[0].result"]
* extractInterpolationExpressions("Use {{env.API_KEY}} to access {{calls[0].result}}");
*/
export declare function extractInterpolationExpressions(template: string): string[];
//# sourceMappingURL=TemplateInterpolator.d.ts.map