@metrichor/jmespath
Version:
Typescript implementation of the JMESPath spec (100% compliant)
70 lines (69 loc) • 2.1 kB
TypeScript
import type { TreeInterpreter } from './TreeInterpreter';
import type { ExpressionNode } from './Lexer';
import type { JSONValue } from '.';
export declare enum InputArgument {
TYPE_NUMBER = 0,
TYPE_ANY = 1,
TYPE_STRING = 2,
TYPE_ARRAY = 3,
TYPE_OBJECT = 4,
TYPE_BOOLEAN = 5,
TYPE_EXPREF = 6,
TYPE_NULL = 7,
TYPE_ARRAY_NUMBER = 8,
TYPE_ARRAY_STRING = 9
}
export interface InputSignature {
types: InputArgument[];
variadic?: boolean;
optional?: boolean;
}
export declare type RuntimeFunction<T, U> = (resolvedArgs: T) => U;
export interface FunctionSignature {
_func: RuntimeFunction<any, any>;
_signature: InputSignature[];
}
export interface FunctionTable {
[functionName: string]: FunctionSignature;
}
export declare class Runtime {
_interpreter?: TreeInterpreter;
TYPE_NAME_TABLE: {
[InputArgument: number]: string;
};
constructor(interpreter: TreeInterpreter);
registerFunction(name: string, customFunction: RuntimeFunction<any, any>, signature: InputSignature[]): void;
callFunction(name: string, resolvedArgs: any): unknown;
private validateInputSignatures;
private validateArgs;
private typeMatches;
private getTypeName;
createKeyFunction(exprefNode: ExpressionNode, allowedTypes: InputArgument[]): ((x: JSONValue) => JSONValue) | undefined;
private functionAbs;
private functionAvg;
private functionCeil;
private functionContains;
private functionEndsWith;
private functionFloor;
private functionJoin;
private functionKeys;
private functionLength;
private functionMap;
private functionMax;
private functionMaxBy;
private functionMerge;
private functionMin;
private functionMinBy;
private functionNotNull;
private functionReverse;
private functionSort;
private functionSortBy;
private functionStartsWith;
private functionSum;
private functionToArray;
private functionToNumber;
private functionToString;
private functionType;
private functionValues;
private functionTable;
}