@vqp/evaluation-jsonlogic
Version:
JSONLogic evaluation adapter for VQP
55 lines • 1.58 kB
TypeScript
/**
* JSONLogic Evaluation Adapter
* Implements QueryEvaluationPort using optimized JSONLogic engine
*/
import { QueryEvaluationPort } from '@vqp/core';
export interface JSONLogicAdapterConfig {
allowCustomOperations?: boolean;
securityMode?: 'strict' | 'permissive';
enableCache?: boolean;
maxCacheSize?: number;
}
/**
* JSONLogic adapter for query evaluation
* This adapter provides safe evaluation of JSONLogic expressions using optimized engine
*/
export declare class JSONLogicAdapter implements QueryEvaluationPort {
private config;
private dangerousOperations;
private optimizedLogic;
constructor(config?: JSONLogicAdapterConfig);
/**
* Evaluate JSONLogic expression against data
*/
evaluate(expression: any, data?: any): Promise<any>;
/**
* Check if expression is valid JSONLogic
*/
isValidExpression(expression: any): Promise<boolean>;
/**
* Extract variables used in expression
*/
extractVariables(expression: any): Promise<string[]>;
/**
* Sanitize expression for security
* Removes potentially dangerous operations
*/
sanitizeExpression(expression: any): Promise<any>;
/**
* Get configuration
*/
getConfig(): JSONLogicAdapterConfig;
/**
* Get cache statistics (for monitoring)
*/
getCacheStats(): {
logicCache: number;
varCache: number;
pathCache: number;
};
/**
* Clear caches (for memory management)
*/
clearCache(): void;
}
//# sourceMappingURL=jsonlogic-adapter.d.ts.map