fig-tree-evaluator 2.1.1 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,6 @@ export declare const replaceAliasNodeValues: (value: EvaluatorOutput, { resolved
16
16
  export declare const checkRequiredNodes: (requiredProps: readonly string[], expression: CombinedOperatorNode) => string | false;
17
17
  export declare const mergeOptions: (origOptions: FigTreeOptions, newOptions: FigTreeOptions) => FigTreeOptions;
18
18
  export declare const convertOutputMethods: {
19
- [key in OutputType]: <T>(value: T) => EvaluatorOutput | T[];
19
+ [key in OutputType]: (value: EvaluatorOutput) => EvaluatorOutput | EvaluatorOutput[];
20
20
  };
21
21
  export declare const errorMessage: (err: unknown) => string;
package/build/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { EvaluatorNode, FigTreeOptions } from './types';
2
+ export declare const getVersion: () => any;
2
3
  declare class FigTreeEvaluator {
3
4
  private options;
4
5
  private operators;
@@ -8,6 +9,7 @@ declare class FigTreeEvaluator {
8
9
  evaluate(expression: EvaluatorNode, options?: FigTreeOptions): Promise<import("./types").EvaluatorOutput>;
9
10
  getOptions(): FigTreeOptions;
10
11
  updateOptions(options: FigTreeOptions): void;
12
+ getVersion: () => any;
11
13
  }
12
14
  export default FigTreeEvaluator;
13
15
  export declare const evaluateExpression: (expression: EvaluatorNode, options?: FigTreeOptions) => Promise<import("./types").EvaluatorOutput>;
package/build/index.js CHANGED
@@ -35,12 +35,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.evaluateExpression = void 0;
38
+ exports.evaluateExpression = exports.getVersion = void 0;
39
39
  const evaluate_1 = require("./evaluate");
40
40
  const typeCheck_1 = require("./typeCheck");
41
41
  const _operatorAliases_json_1 = __importDefault(require("./operators/_operatorAliases.json"));
42
42
  const operators = __importStar(require("./operators"));
43
43
  const helpers_1 = require("./helpers");
44
+ const pkg = require('../package.json');
45
+ const getVersion = () => pkg.version;
46
+ exports.getVersion = getVersion;
44
47
  class FigTreeEvaluator {
45
48
  constructor(options = {}) {
46
49
  this.typeChecker = (...args) => {
@@ -49,6 +52,7 @@ class FigTreeEvaluator {
49
52
  return;
50
53
  throw new Error(result);
51
54
  };
55
+ this.getVersion = exports.getVersion;
52
56
  this.options = options;
53
57
  this.operators = operators;
54
58
  this.operatorAliases = _operatorAliases_json_1.default;
@@ -1,9 +1,9 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["properties"];
3
- export declare type BuildObjectNode = {
3
+ export type BuildObjectNode = {
4
4
  [key in typeof requiredProperties[number]]: BuildObjectElement[];
5
5
  } & BaseOperatorNode;
6
- declare type BuildObjectElement = {
6
+ type BuildObjectElement = {
7
7
  key: EvaluatorNode;
8
8
  value: EvaluatorNode;
9
9
  };
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["condition", "valueIfTrue", "valueIfFalse"];
3
- export declare type ConditionalNode = {
3
+ export type ConditionalNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode;
6
6
  export declare const CONDITIONAL: OperatorObject;
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["functionPath"];
3
- export declare type FunctionNode = {
3
+ export type FunctionNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode & {
6
6
  args: EvaluatorNode[];
@@ -4,7 +4,7 @@ interface DivisionNodeWithProps extends BaseOperatorNode {
4
4
  dividend: EvaluatorNode;
5
5
  divisor: EvaluatorNode;
6
6
  }
7
- export declare type DivisionNode = BasicExtendedNode & DivisionNodeWithProps & {
7
+ export type DivisionNode = BasicExtendedNode & DivisionNodeWithProps & {
8
8
  output?: 'quotient' | 'remainder';
9
9
  };
10
10
  export declare const DIVIDE: OperatorObject;
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, FigTreeConfig, CombinedOperatorNode, GenericObject, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["url"];
3
- export declare type APINode = {
3
+ export type APINode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode & {
6
6
  parameters?: EvaluatorNode;
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, GenericObject, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["query"];
3
- export declare type GraphQLNode = {
3
+ export type GraphQLNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode & {
6
6
  url?: EvaluatorNode;
@@ -1,6 +1,6 @@
1
1
  import { OperatorObject } from '../types';
2
2
  import { BasicExtendedNode } from './logicalAnd';
3
- export declare type ComparatorNode = BasicExtendedNode & {
3
+ export type ComparatorNode = BasicExtendedNode & {
4
4
  strict?: boolean;
5
5
  };
6
6
  export declare const GREATER_THAN: OperatorObject;
@@ -1,6 +1,6 @@
1
1
  import { EvaluatorNode, BaseOperatorNode, CombinedOperatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["values"];
3
- export declare type BasicExtendedNode = {
3
+ export type BasicExtendedNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode[];
5
5
  } & BaseOperatorNode;
6
6
  export declare const parseChildren: (expression: CombinedOperatorNode) => BasicExtendedNode;
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: string[];
3
- export declare type ObjPropNode = {
3
+ export type ObjPropNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode & {
6
6
  additionalObjects: object;
@@ -1,6 +1,6 @@
1
1
  import { OperatorObject, EvaluatorNode, BaseOperatorNode } from '../types';
2
2
  declare const requiredProperties: readonly ["value"];
3
- export declare type PassThruNode = {
3
+ export type PassThruNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode[];
5
5
  } & BaseOperatorNode;
6
6
  export declare const PASSTHRU: OperatorObject;
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["query"];
3
- export declare type PGNode = {
3
+ export type PGNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode & {
6
6
  values?: EvaluatorNode[];
@@ -1,7 +1,7 @@
1
1
  import { OperatorObject, EvaluatorNode } from '../types';
2
2
  import { BasicExtendedNode } from './logicalAnd';
3
3
  declare const requiredProperties: readonly ["values"];
4
- export declare type AdditionNode = {
4
+ export type AdditionNode = {
5
5
  [key in typeof requiredProperties[number]]: EvaluatorNode;
6
6
  } & BasicExtendedNode & {
7
7
  type?: 'string' | 'array';
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["testString", "pattern"];
3
- export declare type RegexNode = {
3
+ export type RegexNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode;
6
6
  export declare const REGEX: OperatorObject;
@@ -1,6 +1,6 @@
1
1
  import { OperatorObject, EvaluatorNode, BaseOperatorNode } from '../types';
2
2
  declare const requiredProperties: readonly ["value"];
3
- export declare type SplitNode = {
3
+ export type SplitNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode & {
6
6
  delimiter?: EvaluatorNode;
@@ -1,6 +1,6 @@
1
1
  import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
2
  declare const requiredProperties: readonly ["string", "substitutions"];
3
- export declare type StringSubNode = {
3
+ export type StringSubNode = {
4
4
  [key in typeof requiredProperties[number]]: EvaluatorNode;
5
5
  } & BaseOperatorNode;
6
6
  export declare const STRING_SUBSTITUTION: OperatorObject;
@@ -4,6 +4,6 @@ interface SubtractionNodeWithProps extends BaseOperatorNode {
4
4
  subtract: EvaluatorNode;
5
5
  from: EvaluatorNode;
6
6
  }
7
- export declare type SubtractionNode = BasicExtendedNode & SubtractionNodeWithProps;
7
+ export type SubtractionNode = BasicExtendedNode & SubtractionNodeWithProps;
8
8
  export declare const SUBTRACT: OperatorObject;
9
9
  export {};
@@ -1,5 +1,5 @@
1
- declare type ExpectedType = 'string' | 'boolean' | 'number' | 'array' | 'undefined' | 'null' | 'object';
2
- export declare type TypeCheckInput = {
1
+ type ExpectedType = 'string' | 'boolean' | 'number' | 'array' | 'undefined' | 'null' | 'object';
2
+ export type TypeCheckInput = {
3
3
  value: unknown;
4
4
  name?: string;
5
5
  not?: boolean;
package/build/types.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { BasicExtendedNode, SubtractionNode, DivisionNode, ComparatorNode, ConditionalNode, RegexNode, StringSubNode, SplitNode, ObjPropNode, APINode, PGNode, GraphQLNode, BuildObjectNode, FunctionNode, PassThruNode, PGConnection, GraphQLConnection } from './operators';
2
2
  import { TypeCheckInput } from './typeCheck';
3
3
  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"];
4
- export declare type Operator = typeof Operators[number];
5
- export declare type GenericObject = {
4
+ export type Operator = typeof Operators[number];
5
+ export type GenericObject = {
6
6
  [key: string]: any;
7
7
  };
8
8
  export interface FigTreeOptions {
@@ -32,7 +32,7 @@ export interface FigTreeConfig {
32
32
  [key: string]: EvaluatorOutput;
33
33
  };
34
34
  }
35
- export declare type OutputType = 'string' | 'number' | 'boolean' | 'bool' | 'array';
35
+ export type OutputType = 'string' | 'number' | 'boolean' | 'bool' | 'array';
36
36
  export interface BaseOperatorNode {
37
37
  operator: Operator;
38
38
  outputType?: OutputType;
@@ -40,11 +40,11 @@ export interface BaseOperatorNode {
40
40
  fallback?: any;
41
41
  [key: string]: EvaluatorNode;
42
42
  }
43
- export declare type CombinedOperatorNode = BaseOperatorNode & BasicExtendedNode & SubtractionNode & DivisionNode & ComparatorNode & ConditionalNode & RegexNode & StringSubNode & SplitNode & ObjPropNode & APINode & PGNode & GraphQLNode & BuildObjectNode & FunctionNode & PassThruNode;
44
- export declare type OperatorNodeUnion = BasicExtendedNode | SubtractionNode | DivisionNode | ComparatorNode | ConditionalNode | RegexNode | StringSubNode | SplitNode | ObjPropNode | PGNode | GraphQLNode | APINode | BuildObjectNode | FunctionNode | PassThruNode;
45
- export declare type EvaluatorOutput = string | boolean | number | GenericObject | null | undefined | any[];
46
- export declare type EvaluatorNode = CombinedOperatorNode | EvaluatorOutput;
47
- export declare type OperatorObject = {
43
+ export type CombinedOperatorNode = BaseOperatorNode & BasicExtendedNode & SubtractionNode & DivisionNode & ComparatorNode & ConditionalNode & RegexNode & StringSubNode & SplitNode & ObjPropNode & APINode & PGNode & GraphQLNode & BuildObjectNode & FunctionNode & PassThruNode;
44
+ export type OperatorNodeUnion = BasicExtendedNode | SubtractionNode | DivisionNode | ComparatorNode | ConditionalNode | RegexNode | StringSubNode | SplitNode | ObjPropNode | PGNode | GraphQLNode | APINode | BuildObjectNode | FunctionNode | PassThruNode;
45
+ export type EvaluatorOutput = string | boolean | number | GenericObject | null | undefined | any[];
46
+ export type EvaluatorNode = CombinedOperatorNode | EvaluatorOutput;
47
+ export type OperatorObject = {
48
48
  requiredProperties: readonly string[];
49
49
  operatorAliases: string[];
50
50
  propertyAliases: {
@@ -53,6 +53,6 @@ export declare type OperatorObject = {
53
53
  evaluate: (expression: CombinedOperatorNode, config: FigTreeConfig) => Promise<EvaluatorOutput>;
54
54
  parseChildren: (expression: CombinedOperatorNode, config: FigTreeConfig) => OperatorNodeUnion | Promise<OperatorNodeUnion>;
55
55
  };
56
- export declare type OperatorReference = {
56
+ export type OperatorReference = {
57
57
  [key in Operator]: OperatorObject;
58
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fig-tree-evaluator",
3
- "version": "2.1.1",
3
+ "version": "2.1.5",
4
4
  "description": "Module to evaluate JSON-structured expression trees",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -30,7 +30,8 @@
30
30
  "generate": "ts-node ./codegen/buildOperatorAliasReference.ts",
31
31
  "build": "yarn generate && rimraf ./lib && tsc",
32
32
  "dev": "cp -n src/dev/playground_example.ts src/dev/playground.ts || ts-node src/dev/playground.ts",
33
- "demo": "cd demo && yarn start"
33
+ "demo": "cd demo && yarn start",
34
+ "prepublish": "yarn build"
34
35
  },
35
36
  "dependencies": {
36
37
  "axios": "^0.27.2",