/** * This module is the single place in the code base that deals with FEEL * values. * * A {@link FeelFunction} is pure data (its wrapped implementation and the * names of its parameters) plus the {@link FeelFunction#invoke} behavior * that binds positional or named arguments to those parameters. Coercion of * arbitrary values into functions — including the range-as-membership-test * shortcut — is centralized in {@link wrapFunction}, and the parameter names * of a plain JS function are recovered through {@link parseParameterNames}. */ /** * Signal returned in place of a result when a function invocation fails. * * It carries the {@link InvocationFailure#warning} type to emit plus the * message template and interpolation values; the interpreter surfaces it * as the corresponding warning and evaluates the invocation to `null`, so * the signal never leaks into an enclosing expression. * * Two flavors exist: a structural {@link parameterMismatch} (wrong * parameter count or names, raised by {@link FeelFunction#invoke}) and a * semantic {@link invalidArguments} (well-typed but unusable input, raised * by a builtin body). */ export declare class InvocationFailure { readonly warning: string; readonly template: string; readonly values: Record; constructor(warning: string, template: string, values?: Record); } /** * Create an {@link InvocationFailure} for a builtin to return when it * rejects otherwise well-typed input. */ export declare function invalidArguments(template: string, values?: Record): InvocationFailure; /** * Create an {@link InvocationFailure} for an invocation whose arguments do * not match the target's parameters (wrong count or unknown names). */ export declare function parameterMismatch(target: unknown, params: unknown): InvocationFailure; /** * Whether the value is an {@link InvocationFailure} signal. */ export declare function isInvocationFailure(value: unknown): value is InvocationFailure; export declare class FeelFunction { fn: (...args: any[]) => any; parameterNames: string[]; constructor(fn: (...args: any[]) => any, parameterNames: string[]); invoke(contextOrArgs: any): any; } /** * Whether the value is a FEEL . */ export declare function isFunction(obj: any): obj is FeelFunction; /** * Recover the parameter names of a plain JS function, either from an * explicit `$args` annotation or by parsing its source. */ export declare function parseParameterNames(fn: any): any; /** * Coerce a value into a {@link FeelFunction}. * * Passes through existing functions, turns a {@link FeelRange} into a * membership test and wraps a plain JS function (recovering its parameter * names when not given). Returns `null` for anything that cannot be * invoked. * * @param {Function} fn * @param {string[]} [parameterNames] * * @return {FeelFunction} */ export declare function wrapFunction(fn: any, parameterNames?: any): FeelFunction;