/** * Query Evaluator - Executes parsed path expressions against TONL documents * * Takes an AST from the path parser and evaluates it against actual data, * returning the matched values. */ import type { PathNode } from './types.js'; import type { TONLValue } from '../types.js'; import { QueryCache } from './cache.js'; /** * Query Evaluator - evaluates path expressions against documents */ export declare class QueryEvaluator { private context; private cache; constructor(document: TONLValue, options?: { maxDepth?: number; enableCache?: boolean; cache?: QueryCache; }); /** * Evaluate a path expression and return results * * @param ast - Parsed AST nodes * @returns Matched value(s) or undefined if not found */ evaluate(ast: PathNode[]): any; /** * Recursively evaluate a path starting from a specific node */ private evaluatePath; /** * Check if a path exists in the document * * @param ast - Parsed AST nodes * @returns True if the path exists, false otherwise */ exists(ast: PathNode[]): boolean; /** * Get the type of value at a path * * @param ast - Parsed AST nodes * @returns Type string or undefined if path doesn't exist */ typeOf(ast: PathNode[]): string | undefined; /** * Evaluate a single AST node against current value */ private evaluateNode; /** * Evaluate property access (e.g., user.name) * SECURITY: Protected against prototype pollution (BF004) */ private evaluateProperty; /** * Evaluate array index access (e.g., users[0]) * SECURITY: Protected against integer overflow (BF008) */ private evaluateIndex; /** * Evaluate wildcard (e.g., users[*] or data.*) * * Returns an array of all values */ private evaluateWildcard; /** * Evaluate recursive descent (e.g., $..email) * * Searches for matching properties at any depth */ private evaluateRecursive; /** * Evaluate array slice (e.g., users[0:5]) */ /** * Evaluate array slice (e.g., users[0:5] or users[::2]) * SECURITY: Protected against integer overflow and infinite loops (BF008) */ private evaluateSlice; /** * Evaluate filter expression (e.g., users[?(@.age > 18)]) */ private evaluateFilter; /** * Generate cache key from AST nodes */ private generateCacheKey; /** * Get cache statistics */ getCacheStats(): import("./cache.js").CacheStats; /** * Clear the evaluator's cache */ clearCache(): void; } /** * Convenience function to evaluate a path expression * * @param document - The document to query * @param ast - Parsed AST nodes * @param options - Evaluation options * @returns Matched value(s) */ export declare function evaluate(document: TONLValue, ast: PathNode[], options?: { maxDepth?: number; enableCache?: boolean; }): any; /** * Check if a path exists in a document */ export declare function exists(document: TONLValue, ast: PathNode[]): boolean; /** * Get the type of value at a path */ export declare function typeOf(document: TONLValue, ast: PathNode[]): string | undefined; //# sourceMappingURL=evaluator.d.ts.map