@jmespath-community/jmespath
Version:
Typescript implementation of the JMESPath Community specification
88 lines (87 loc) • 2.78 kB
TypeScript
import type { ExpressionNode } from './AST.type';
import type { JSONValue } from './JSON.type';
import type { TreeInterpreter } from './TreeInterpreter';
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,
TYPE_ARRAY_OBJECT = 10,
TYPE_ARRAY_ARRAY = 11
}
export interface InputSignature {
types: InputArgument[];
variadic?: boolean;
optional?: boolean;
}
export type RuntimeFunction<T extends any[], U> = (resolvedArgs: T) => U;
export interface FunctionSignature {
_func: RuntimeFunction<any, JSONValue>;
_signature: InputSignature[];
}
export interface FunctionTable {
[functionName: string]: FunctionSignature;
}
export declare class Runtime {
_interpreter: TreeInterpreter;
_functionTable: FunctionTable;
TYPE_NAME_TABLE: {
[InputArgument: number]: string;
};
constructor(interpreter: TreeInterpreter);
registerFunction(name: string, customFunction: RuntimeFunction<(JSONValue | ExpressionNode)[], JSONValue>, signature: InputSignature[]): void;
callFunction(name: string, resolvedArgs: (JSONValue | ExpressionNode)[]): JSONValue;
private validateInputSignatures;
private validateArgs;
private typeMatches;
private getTypeName;
createKeyFunction(exprefNode: ExpressionNode, allowedTypes: InputArgument[]): (x: JSONValue) => JSONValue;
private functionAbs;
private functionAvg;
private functionCeil;
private functionContains;
private functionEndsWith;
private functionFindFirst;
private functionFindLast;
private functionFloor;
private functionFromItems;
private functionGroupBy;
private functionItems;
private functionJoin;
private functionKeys;
private functionLength;
private functionLower;
private functionMap;
private functionMax;
private functionMaxBy;
private functionMerge;
private functionMin;
private functionMinBy;
private functionNotNull;
private functionPadLeft;
private functionPadRight;
private functionReplace;
private functionSplit;
private functionReverse;
private functionSort;
private functionSortBy;
private functionStartsWith;
private functionSum;
private functionToArray;
private functionToNumber;
private functionToString;
private functionTrim;
private functionTrimLeft;
private functionTrimRight;
private functionType;
private functionUpper;
private functionValues;
private functionZip;
private functionTable;
}