import { IEvalResult } from './syntax-tree/expression'; import { Parameter } from './syntax-tree/parameter'; import { Operators } from './syntax-tree/operators'; declare type FieldType = { /** * Name of the field. The name is without the '$' prefix. The prefix ('$') needs to be added in the expression, to select the field. * * @type {string} */ name: string; /** * Will be called, to evaluate the fields value for each mentioning of the field * */ eval: () => IEvalResult; }; declare type OperationType = { leftType: string; rightType: string; operator: Operators; eval: (leftResult: any, rightResult: any) => IEvalResult; }; declare type FunctionType = { /** * Name of th function. Can be later accessed on other expressions with ```.()``` * * @type {string} */ name: string; /** * type on which the function should be assigned to. * * @type {string} */ scopeType: string; /** * evaluates the function. * @param {any} scopeResult the result of the scope expression, where the function has ben called on. * @param {Parameter[]} parameters all parameters, passed to the function. */ eval: (scopeResult: any, parameters: Parameter[]) => IEvalResult; }; /** * Defines a set of functionality for the custom expressions. * * @export * @class Functionality */ export declare class Functionality { fields: FieldType[]; operations: OperationType[]; functions: FunctionType[]; constructor(shouldAddDefaults?: boolean); /** * adds a field to the functionality. * * @param {FieldType} a * @memberof Functionality */ addField(a: FieldType): void; /** * adds a function to the functionality. * * @param {FunctionType} a * @memberof Functionality */ addFunctions(a: FunctionType): void; /** * adds a operation to the functionality. * * @param {OperationType} a * @memberof Functionality */ addOperation(a: OperationType): void; /** * finds a field with the given name * * @param {string} name * @returns {FieldType} * @memberof Functionality */ getField(name: string): FieldType; /** * finds a function with the given name and matching type. * * @param {string} name * @param {string} type * @returns {FunctionType} * @memberof Functionality */ getFunction(name: string, type: string): FunctionType; /** * finds the operation with the mating types and operator. * * @param {string} leftType * @param {string} rightType * @param {Operators} operator * @returns {OperationType} * @memberof Functionality */ getOperation(leftType: string, rightType: string, operator: Operators): OperationType; } export {};