kangaroo-expression
Version:
Secure expression evaluator with AST-based execution - A fast, safe, and powerful JavaScript-like expression language
57 lines • 2.48 kB
TypeScript
import type { ExpressionContext, EvaluationResult, SecurityValidation, ParsedExpression } from './core';
import type { SafeFunction, FunctionCategory } from './functions';
export type { ExpressionContext, EvaluationResult, SecurityValidation, SecurityViolation, ParsedExpression, EvaluatorOptions, SupportedNodeType, ASTNodeHandler, SecurityRule } from './core';
export type { SafeFunction, FunctionCategory, FunctionRegistry, FunctionRegistryStats, ValidationResult, SerializedFunctionRegistry, FunctionCallContext, AdvancedSafeFunction } from './functions';
export type { TypeRegistry, TypeConfig, TypeSchema, TypePropertySchema, SerializationStrategy, RegisteredType } from './type-registry';
export interface ExpressionEvaluator {
evaluate(expression: string, context?: ExpressionContext): Promise<EvaluationResult> | EvaluationResult;
validate(expression: string): Promise<SecurityValidation> | SecurityValidation;
parse(expression: string): Promise<ParsedExpression | null> | ParsedExpression | null;
extractDependencies(expression: string): Promise<string[]> | string[];
addFunction(func: SafeFunction): void;
removeFunction(name: string): void;
listFunctions(category?: FunctionCategory): SafeFunction[];
}
export interface TemplateResult {
success: boolean;
result?: string;
error?: string;
processedExpressions?: Array<{
original: string;
evaluated: any;
startIndex: number;
endIndex: number;
}>;
}
export interface ComplexityAnalysis {
score: number;
breakdown: Record<string, number>;
maxDepth: number;
functionCalls: number;
propertyAccesses: number;
estimatedTime: number;
risk: 'low' | 'medium' | 'high';
}
export interface PerformanceMetrics {
parseTime: number;
validationTime: number;
executionTime: number;
totalTime: number;
memoryUsage?: number;
cache?: {
hit: boolean;
key: string;
};
}
export type EvaluationErrorType = 'syntax' | 'security' | 'runtime' | 'type' | 'complexity' | 'timeout' | 'memory' | 'unknown';
export interface CallbackContext extends ExpressionContext {
[paramName: string]: any;
}
export type ArrayOperation = 'filter' | 'map' | 'find' | 'some' | 'every' | 'reduce' | 'sort' | 'forEach';
export interface ArrayOperationConfig {
maxArraySize?: number;
maxCallbackTime?: number;
allowNested?: boolean;
memoryLimit?: number;
}
//# sourceMappingURL=index.d.ts.map