fig-tree-evaluator
Advanced tools
Comparing version 2.1.1 to 2.1.5
@@ -19,4 +19,4 @@ import { OutputType, EvaluatorNode, CombinedOperatorNode, Operator, EvaluatorOutput, FigTreeOptions, OperatorNodeUnion, FigTreeConfig } from './types'; | ||
export declare const convertOutputMethods: { | ||
[key in OutputType]: <T>(value: T) => EvaluatorOutput | T[]; | ||
[key in OutputType]: (value: EvaluatorOutput) => EvaluatorOutput | EvaluatorOutput[]; | ||
}; | ||
export declare const errorMessage: (err: unknown) => string; |
import { EvaluatorNode, FigTreeOptions } from './types'; | ||
export declare const getVersion: () => any; | ||
declare class FigTreeEvaluator { | ||
@@ -11,4 +12,5 @@ private options; | ||
updateOptions(options: FigTreeOptions): void; | ||
getVersion: () => any; | ||
} | ||
export default FigTreeEvaluator; | ||
export declare const evaluateExpression: (expression: EvaluatorNode, options?: FigTreeOptions) => Promise<import("./types").EvaluatorOutput>; |
@@ -38,3 +38,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.evaluateExpression = void 0; | ||
exports.evaluateExpression = exports.getVersion = void 0; | ||
const evaluate_1 = require("./evaluate"); | ||
@@ -45,2 +45,5 @@ const typeCheck_1 = require("./typeCheck"); | ||
const helpers_1 = require("./helpers"); | ||
const pkg = require('../package.json'); | ||
const getVersion = () => pkg.version; | ||
exports.getVersion = getVersion; | ||
class FigTreeEvaluator { | ||
@@ -54,2 +57,3 @@ constructor(options = {}) { | ||
}; | ||
this.getVersion = exports.getVersion; | ||
this.options = options; | ||
@@ -56,0 +60,0 @@ this.operators = operators; |
import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["properties"]; | ||
export declare type BuildObjectNode = { | ||
export type BuildObjectNode = { | ||
[key in typeof requiredProperties[number]]: BuildObjectElement[]; | ||
} & BaseOperatorNode; | ||
declare type BuildObjectElement = { | ||
type BuildObjectElement = { | ||
key: EvaluatorNode; | ||
@@ -8,0 +8,0 @@ value: EvaluatorNode; |
import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["condition", "valueIfTrue", "valueIfFalse"]; | ||
export declare type ConditionalNode = { | ||
export type ConditionalNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode; |
import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["functionPath"]; | ||
export declare type FunctionNode = { | ||
export type FunctionNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode & { |
@@ -7,3 +7,3 @@ import { BasicExtendedNode } from './logicalAnd'; | ||
} | ||
export declare type DivisionNode = BasicExtendedNode & DivisionNodeWithProps & { | ||
export type DivisionNode = BasicExtendedNode & DivisionNodeWithProps & { | ||
output?: 'quotient' | 'remainder'; | ||
@@ -10,0 +10,0 @@ }; |
import { BaseOperatorNode, EvaluatorNode, FigTreeConfig, CombinedOperatorNode, GenericObject, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["url"]; | ||
export declare type APINode = { | ||
export type APINode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode & { |
import { BaseOperatorNode, EvaluatorNode, GenericObject, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["query"]; | ||
export declare type GraphQLNode = { | ||
export type GraphQLNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode & { |
import { OperatorObject } from '../types'; | ||
import { BasicExtendedNode } from './logicalAnd'; | ||
export declare type ComparatorNode = BasicExtendedNode & { | ||
export type ComparatorNode = BasicExtendedNode & { | ||
strict?: boolean; | ||
}; | ||
export declare const GREATER_THAN: OperatorObject; |
import { EvaluatorNode, BaseOperatorNode, CombinedOperatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["values"]; | ||
export declare type BasicExtendedNode = { | ||
export type BasicExtendedNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode[]; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode; |
import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: string[]; | ||
export declare type ObjPropNode = { | ||
export type ObjPropNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode & { |
import { OperatorObject, EvaluatorNode, BaseOperatorNode } from '../types'; | ||
declare const requiredProperties: readonly ["value"]; | ||
export declare type PassThruNode = { | ||
export type PassThruNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode[]; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode; |
import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["query"]; | ||
export declare type PGNode = { | ||
export type PGNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode & { |
import { OperatorObject, EvaluatorNode } from '../types'; | ||
import { BasicExtendedNode } from './logicalAnd'; | ||
declare const requiredProperties: readonly ["values"]; | ||
export declare type AdditionNode = { | ||
export type AdditionNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -6,0 +6,0 @@ } & BasicExtendedNode & { |
import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["testString", "pattern"]; | ||
export declare type RegexNode = { | ||
export type RegexNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode; |
import { OperatorObject, EvaluatorNode, BaseOperatorNode } from '../types'; | ||
declare const requiredProperties: readonly ["value"]; | ||
export declare type SplitNode = { | ||
export type SplitNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode & { |
import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types'; | ||
declare const requiredProperties: readonly ["string", "substitutions"]; | ||
export declare type StringSubNode = { | ||
export type StringSubNode = { | ||
[key in typeof requiredProperties[number]]: EvaluatorNode; | ||
@@ -5,0 +5,0 @@ } & BaseOperatorNode; |
@@ -7,4 +7,4 @@ import { BasicExtendedNode } from './logicalAnd'; | ||
} | ||
export declare type SubtractionNode = BasicExtendedNode & SubtractionNodeWithProps; | ||
export type SubtractionNode = BasicExtendedNode & SubtractionNodeWithProps; | ||
export declare const SUBTRACT: OperatorObject; | ||
export {}; |
@@ -1,3 +0,3 @@ | ||
declare type ExpectedType = 'string' | 'boolean' | 'number' | 'array' | 'undefined' | 'null' | 'object'; | ||
export declare type TypeCheckInput = { | ||
type ExpectedType = 'string' | 'boolean' | 'number' | 'array' | 'undefined' | 'null' | 'object'; | ||
export type TypeCheckInput = { | ||
value: unknown; | ||
@@ -4,0 +4,0 @@ name?: string; |
import { BasicExtendedNode, SubtractionNode, DivisionNode, ComparatorNode, ConditionalNode, RegexNode, StringSubNode, SplitNode, ObjPropNode, APINode, PGNode, GraphQLNode, BuildObjectNode, FunctionNode, PassThruNode, PGConnection, GraphQLConnection } from './operators'; | ||
import { TypeCheckInput } from './typeCheck'; | ||
export declare const Operators: readonly ["AND", "OR", "EQUAL", "NOT_EQUAL", "PLUS", "SUBTRACT", "MULTIPLY", "DIVIDE", "GREATER_THAN", "LESS_THAN", "CONDITIONAL", "REGEX", "OBJECT_PROPERTIES", "STRING_SUBSTITUTION", "SPLIT", "COUNT", "GET", "POST", "PG_SQL", "GRAPHQL", "BUILD_OBJECT", "CUSTOM_FUNCTIONS", "PASSTHRU"]; | ||
export declare type Operator = typeof Operators[number]; | ||
export declare type GenericObject = { | ||
export type Operator = typeof Operators[number]; | ||
export type GenericObject = { | ||
[key: string]: any; | ||
@@ -35,3 +35,3 @@ }; | ||
} | ||
export declare type OutputType = 'string' | 'number' | 'boolean' | 'bool' | 'array'; | ||
export type OutputType = 'string' | 'number' | 'boolean' | 'bool' | 'array'; | ||
export interface BaseOperatorNode { | ||
@@ -44,7 +44,7 @@ operator: Operator; | ||
} | ||
export declare type CombinedOperatorNode = BaseOperatorNode & BasicExtendedNode & SubtractionNode & DivisionNode & ComparatorNode & ConditionalNode & RegexNode & StringSubNode & SplitNode & ObjPropNode & APINode & PGNode & GraphQLNode & BuildObjectNode & FunctionNode & PassThruNode; | ||
export declare type OperatorNodeUnion = BasicExtendedNode | SubtractionNode | DivisionNode | ComparatorNode | ConditionalNode | RegexNode | StringSubNode | SplitNode | ObjPropNode | PGNode | GraphQLNode | APINode | BuildObjectNode | FunctionNode | PassThruNode; | ||
export declare type EvaluatorOutput = string | boolean | number | GenericObject | null | undefined | any[]; | ||
export declare type EvaluatorNode = CombinedOperatorNode | EvaluatorOutput; | ||
export declare type OperatorObject = { | ||
export type CombinedOperatorNode = BaseOperatorNode & BasicExtendedNode & SubtractionNode & DivisionNode & ComparatorNode & ConditionalNode & RegexNode & StringSubNode & SplitNode & ObjPropNode & APINode & PGNode & GraphQLNode & BuildObjectNode & FunctionNode & PassThruNode; | ||
export type OperatorNodeUnion = BasicExtendedNode | SubtractionNode | DivisionNode | ComparatorNode | ConditionalNode | RegexNode | StringSubNode | SplitNode | ObjPropNode | PGNode | GraphQLNode | APINode | BuildObjectNode | FunctionNode | PassThruNode; | ||
export type EvaluatorOutput = string | boolean | number | GenericObject | null | undefined | any[]; | ||
export type EvaluatorNode = CombinedOperatorNode | EvaluatorOutput; | ||
export type OperatorObject = { | ||
requiredProperties: readonly string[]; | ||
@@ -58,4 +58,4 @@ operatorAliases: string[]; | ||
}; | ||
export declare type OperatorReference = { | ||
export type OperatorReference = { | ||
[key in Operator]: OperatorObject; | ||
}; |
{ | ||
"name": "fig-tree-evaluator", | ||
"version": "2.1.1", | ||
"version": "2.1.5", | ||
"description": "Module to evaluate JSON-structured expression trees", | ||
@@ -33,3 +33,4 @@ "main": "build/index.js", | ||
"dev": "cp -n src/dev/playground_example.ts src/dev/playground.ts || ts-node src/dev/playground.ts", | ||
"demo": "cd demo && yarn start" | ||
"demo": "cd demo && yarn start", | ||
"prepublish": "yarn build" | ||
}, | ||
@@ -36,0 +37,0 @@ "dependencies": { |
146333
2021