fig-tree-evaluator 2.7.0 → 2.8.3

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.
Files changed (201) hide show
  1. package/README.md +195 -12
  2. package/build/FigTreeEvaluator.d.ts +10 -2
  3. package/build/FigTreeEvaluator.js +25 -4
  4. package/build/cache.d.ts +3 -1
  5. package/build/cache.js +10 -11
  6. package/build/evaluate.js +18 -14
  7. package/build/helpers.d.ts +9 -34
  8. package/build/helpers.js +5 -13
  9. package/build/index.d.ts +2 -2
  10. package/build/operators/AND/data.d.ts +4 -0
  11. package/build/operators/AND/data.js +22 -0
  12. package/build/operators/AND/index.d.ts +1 -0
  13. package/build/operators/AND/index.js +5 -0
  14. package/build/operators/AND/operator.d.ts +3 -0
  15. package/build/operators/{logicalAnd.js → AND/operator.js} +28 -8
  16. package/build/operators/BUILD_OBJECT/data.d.ts +4 -0
  17. package/build/operators/BUILD_OBJECT/data.js +22 -0
  18. package/build/operators/BUILD_OBJECT/index.d.ts +1 -0
  19. package/build/operators/BUILD_OBJECT/index.js +17 -0
  20. package/build/operators/BUILD_OBJECT/operator.d.ts +2 -0
  21. package/build/operators/{buildObject.js → BUILD_OBJECT/operator.js} +28 -12
  22. package/build/operators/CONDITIONAL/data.d.ts +4 -0
  23. package/build/operators/CONDITIONAL/data.js +36 -0
  24. package/build/operators/CONDITIONAL/index.d.ts +1 -0
  25. package/build/operators/CONDITIONAL/index.js +17 -0
  26. package/build/operators/CONDITIONAL/operator.d.ts +2 -0
  27. package/build/operators/CONDITIONAL/operator.js +59 -0
  28. package/build/operators/COUNT/data.d.ts +4 -0
  29. package/build/operators/COUNT/data.js +22 -0
  30. package/build/operators/COUNT/index.d.ts +1 -0
  31. package/build/operators/COUNT/index.js +17 -0
  32. package/build/operators/COUNT/operator.d.ts +2 -0
  33. package/build/operators/COUNT/operator.js +49 -0
  34. package/build/operators/CUSTOM_FUNCTIONS/data.d.ts +4 -0
  35. package/build/operators/CUSTOM_FUNCTIONS/data.js +43 -0
  36. package/build/operators/CUSTOM_FUNCTIONS/index.d.ts +1 -0
  37. package/build/operators/CUSTOM_FUNCTIONS/index.js +17 -0
  38. package/build/operators/CUSTOM_FUNCTIONS/operator.d.ts +2 -0
  39. package/build/operators/CUSTOM_FUNCTIONS/operator.js +65 -0
  40. package/build/operators/DIVIDE/data.d.ts +4 -0
  41. package/build/operators/DIVIDE/data.js +43 -0
  42. package/build/operators/DIVIDE/index.d.ts +1 -0
  43. package/build/operators/DIVIDE/index.js +17 -0
  44. package/build/operators/DIVIDE/operator.d.ts +2 -0
  45. package/build/operators/DIVIDE/operator.js +63 -0
  46. package/build/operators/EQUAL/data.d.ts +4 -0
  47. package/build/operators/EQUAL/data.js +29 -0
  48. package/build/operators/EQUAL/index.d.ts +1 -0
  49. package/build/operators/EQUAL/index.js +17 -0
  50. package/build/operators/EQUAL/operator.d.ts +2 -0
  51. package/build/operators/{equal.js → EQUAL/operator.js} +30 -10
  52. package/build/operators/GET/data.d.ts +4 -0
  53. package/build/operators/GET/data.js +50 -0
  54. package/build/operators/GET/index.d.ts +1 -0
  55. package/build/operators/GET/index.js +5 -0
  56. package/build/operators/GET/operator.d.ts +3 -0
  57. package/build/operators/GET/operator.js +91 -0
  58. package/build/operators/GRAPHQL/data.d.ts +4 -0
  59. package/build/operators/GRAPHQL/data.js +57 -0
  60. package/build/operators/GRAPHQL/index.d.ts +1 -0
  61. package/build/operators/GRAPHQL/index.js +17 -0
  62. package/build/operators/GRAPHQL/operator.d.ts +8 -0
  63. package/build/operators/{graphQL.js → GRAPHQL/operator.js} +47 -15
  64. package/build/operators/GREATER_THAN/data.d.ts +4 -0
  65. package/build/operators/GREATER_THAN/data.js +29 -0
  66. package/build/operators/GREATER_THAN/index.d.ts +1 -0
  67. package/build/operators/GREATER_THAN/index.js +17 -0
  68. package/build/operators/GREATER_THAN/operator.d.ts +2 -0
  69. package/build/operators/GREATER_THAN/operator.js +54 -0
  70. package/build/operators/LESS_THAN/data.d.ts +4 -0
  71. package/build/operators/LESS_THAN/data.js +29 -0
  72. package/build/operators/LESS_THAN/index.d.ts +1 -0
  73. package/build/operators/LESS_THAN/index.js +17 -0
  74. package/build/operators/{lessThan.d.ts → LESS_THAN/operator.d.ts} +1 -1
  75. package/build/operators/LESS_THAN/operator.js +54 -0
  76. package/build/operators/MATCH/data.d.ts +4 -0
  77. package/build/operators/MATCH/data.js +29 -0
  78. package/build/operators/MATCH/index.d.ts +1 -0
  79. package/build/operators/MATCH/index.js +17 -0
  80. package/build/operators/MATCH/operator.d.ts +2 -0
  81. package/build/operators/{match.js → MATCH/operator.js} +36 -17
  82. package/build/operators/MULTIPLY/data.d.ts +4 -0
  83. package/build/operators/MULTIPLY/data.js +22 -0
  84. package/build/operators/MULTIPLY/index.d.ts +1 -0
  85. package/build/operators/MULTIPLY/index.js +17 -0
  86. package/build/operators/{multiply.d.ts → MULTIPLY/operator.d.ts} +1 -1
  87. package/build/operators/MULTIPLY/operator.js +53 -0
  88. package/build/operators/NOT_EQUAL/data.d.ts +4 -0
  89. package/build/operators/NOT_EQUAL/data.js +29 -0
  90. package/build/operators/NOT_EQUAL/index.d.ts +1 -0
  91. package/build/operators/NOT_EQUAL/index.js +17 -0
  92. package/build/operators/{notEqual.d.ts → NOT_EQUAL/operator.d.ts} +1 -1
  93. package/build/operators/{notEqual.js → NOT_EQUAL/operator.js} +30 -10
  94. package/build/operators/OBJECT_PROPERTIES/data.d.ts +4 -0
  95. package/build/operators/OBJECT_PROPERTIES/data.js +37 -0
  96. package/build/operators/OBJECT_PROPERTIES/index.d.ts +1 -0
  97. package/build/operators/OBJECT_PROPERTIES/index.js +17 -0
  98. package/build/operators/OBJECT_PROPERTIES/operator.d.ts +2 -0
  99. package/build/operators/{objectProperties.js → OBJECT_PROPERTIES/operator.js} +32 -24
  100. package/build/operators/OR/data.d.ts +4 -0
  101. package/build/operators/OR/data.js +22 -0
  102. package/build/operators/OR/index.d.ts +1 -0
  103. package/build/operators/OR/index.js +17 -0
  104. package/build/operators/OR/operator.d.ts +2 -0
  105. package/build/operators/OR/operator.js +49 -0
  106. package/build/operators/PASSTHRU/data.d.ts +4 -0
  107. package/build/operators/PASSTHRU/data.js +22 -0
  108. package/build/operators/PASSTHRU/index.d.ts +1 -0
  109. package/build/operators/PASSTHRU/index.js +17 -0
  110. package/build/operators/PASSTHRU/operator.d.ts +2 -0
  111. package/build/operators/PASSTHRU/operator.js +53 -0
  112. package/build/operators/PG_SQL/data.d.ts +4 -0
  113. package/build/operators/PG_SQL/data.js +43 -0
  114. package/build/operators/PG_SQL/index.d.ts +1 -0
  115. package/build/operators/PG_SQL/index.js +17 -0
  116. package/build/operators/PG_SQL/operator.d.ts +2 -0
  117. package/build/operators/PG_SQL/operator.js +83 -0
  118. package/build/operators/PLUS/data.d.ts +4 -0
  119. package/build/operators/PLUS/data.js +29 -0
  120. package/build/operators/PLUS/index.d.ts +1 -0
  121. package/build/operators/PLUS/index.js +17 -0
  122. package/build/operators/PLUS/operator.d.ts +2 -0
  123. package/build/operators/{plus.js → PLUS/operator.js} +37 -13
  124. package/build/operators/POST/data.d.ts +4 -0
  125. package/build/operators/POST/data.js +50 -0
  126. package/build/operators/POST/index.d.ts +1 -0
  127. package/build/operators/POST/index.js +17 -0
  128. package/build/operators/POST/operator.d.ts +2 -0
  129. package/build/operators/POST/operator.js +72 -0
  130. package/build/operators/REGEX/data.d.ts +4 -0
  131. package/build/operators/REGEX/data.js +29 -0
  132. package/build/operators/REGEX/index.d.ts +1 -0
  133. package/build/operators/REGEX/index.js +17 -0
  134. package/build/operators/REGEX/operator.d.ts +2 -0
  135. package/build/operators/{regex.js → REGEX/operator.js} +29 -16
  136. package/build/operators/SPLIT/data.d.ts +4 -0
  137. package/build/operators/SPLIT/data.js +43 -0
  138. package/build/operators/SPLIT/index.d.ts +1 -0
  139. package/build/operators/SPLIT/index.js +17 -0
  140. package/build/operators/SPLIT/operator.d.ts +2 -0
  141. package/build/operators/{split.js → SPLIT/operator.js} +33 -15
  142. package/build/operators/STRING_SUBSTITUTION/data.d.ts +4 -0
  143. package/build/operators/STRING_SUBSTITUTION/data.js +29 -0
  144. package/build/operators/STRING_SUBSTITUTION/index.d.ts +1 -0
  145. package/build/operators/STRING_SUBSTITUTION/index.js +17 -0
  146. package/build/operators/STRING_SUBSTITUTION/operator.d.ts +2 -0
  147. package/build/operators/STRING_SUBSTITUTION/operator.js +59 -0
  148. package/build/operators/SUBTRACT/data.d.ts +4 -0
  149. package/build/operators/SUBTRACT/data.js +36 -0
  150. package/build/operators/SUBTRACT/index.d.ts +1 -0
  151. package/build/operators/SUBTRACT/index.js +17 -0
  152. package/build/operators/SUBTRACT/operator.d.ts +2 -0
  153. package/build/operators/SUBTRACT/operator.js +54 -0
  154. package/build/operators/_operatorAliases.json +1 -0
  155. package/build/operators/_operatorUtils.d.ts +19 -12
  156. package/build/operators/_operatorUtils.js +33 -15
  157. package/build/operators/index.d.ts +24 -24
  158. package/build/operators/index.js +24 -27
  159. package/build/shorthandSyntax.d.ts +2 -0
  160. package/build/shorthandSyntax.js +55 -0
  161. package/build/typeCheck.d.ts +8 -4
  162. package/build/typeCheck.js +25 -19
  163. package/build/types.d.ts +51 -34
  164. package/build/version.d.ts +1 -0
  165. package/build/version.js +4 -0
  166. package/package.json +10 -3
  167. package/build/operators/buildObject.d.ts +0 -11
  168. package/build/operators/conditional.d.ts +0 -7
  169. package/build/operators/conditional.js +0 -33
  170. package/build/operators/count.d.ts +0 -2
  171. package/build/operators/count.js +0 -29
  172. package/build/operators/customFunctions.d.ts +0 -9
  173. package/build/operators/customFunctions.js +0 -57
  174. package/build/operators/divide.d.ts +0 -12
  175. package/build/operators/divide.js +0 -41
  176. package/build/operators/equal.d.ts +0 -2
  177. package/build/operators/getRequest.d.ts +0 -12
  178. package/build/operators/getRequest.js +0 -51
  179. package/build/operators/graphQL.d.ts +0 -18
  180. package/build/operators/greaterThan.d.ts +0 -6
  181. package/build/operators/greaterThan.js +0 -35
  182. package/build/operators/lessThan.js +0 -35
  183. package/build/operators/logicalAnd.d.ts +0 -8
  184. package/build/operators/logicalOr.d.ts +0 -2
  185. package/build/operators/logicalOr.js +0 -29
  186. package/build/operators/match.d.ts +0 -7
  187. package/build/operators/multiply.js +0 -29
  188. package/build/operators/objectProperties.d.ts +0 -9
  189. package/build/operators/passThru.d.ts +0 -7
  190. package/build/operators/passThru.js +0 -30
  191. package/build/operators/pgSQL.d.ts +0 -24
  192. package/build/operators/pgSQL.js +0 -70
  193. package/build/operators/plus.d.ts +0 -10
  194. package/build/operators/postRequest.d.ts +0 -2
  195. package/build/operators/postRequest.js +0 -43
  196. package/build/operators/regex.d.ts +0 -7
  197. package/build/operators/split.d.ts +0 -11
  198. package/build/operators/stringSubstitution.d.ts +0 -7
  199. package/build/operators/stringSubstitution.js +0 -40
  200. package/build/operators/subtract.d.ts +0 -9
  201. package/build/operators/subtract.js +0 -32
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CUSTOM_FUNCTIONS = void 0;
16
- const object_property_extractor_1 = __importDefault(require("object-property-extractor"));
17
- const _operatorUtils_1 = require("./_operatorUtils");
18
- const requiredProperties = ['functionPath'];
19
- const operatorAliases = [
20
- 'customFunctions',
21
- 'customFunction',
22
- 'objectFunctions',
23
- 'function',
24
- 'functions',
25
- 'runFunction',
26
- ];
27
- const propertyAliases = {
28
- functionsPath: 'functionPath',
29
- functionName: 'functionPath',
30
- funcName: 'functionPath',
31
- path: 'functionPath',
32
- arguments: 'args',
33
- variables: 'args',
34
- };
35
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
36
- var _a, _b, _c, _d;
37
- const [functionPath, ...args] = (yield (0, _operatorUtils_1.evaluateArray)([expression.functionPath, ...(expression.args || [])], config));
38
- config.typeChecker({ name: 'functionPath', value: functionPath, expectedType: 'string' });
39
- const { data, functions } = config.options;
40
- const func = ((_b = (_a = (0, object_property_extractor_1.default)(functions, functionPath, null)) !== null && _a !== void 0 ? _a : (0, object_property_extractor_1.default)(data, functionPath, null)) !== null && _b !== void 0 ? _b : (0, object_property_extractor_1.default)(config.options, functionPath));
41
- const shouldUseCache = (_d = (_c = expression.useCache) !== null && _c !== void 0 ? _c : config.options.useCache) !== null && _d !== void 0 ? _d : false;
42
- const result = yield config.cache.useCache(shouldUseCache, (_, ...args) => __awaiter(void 0, void 0, void 0, function* () {
43
- return yield func(...args);
44
- }), functionPath, ...args);
45
- return result;
46
- });
47
- const parseChildren = (expression) => {
48
- const [functionPath, ...args] = expression.children;
49
- return Object.assign(Object.assign({}, expression), { functionPath, args });
50
- };
51
- exports.CUSTOM_FUNCTIONS = {
52
- requiredProperties,
53
- operatorAliases,
54
- propertyAliases,
55
- evaluate,
56
- parseChildren,
57
- };
@@ -1,12 +0,0 @@
1
- import { BasicExtendedNode } from './logicalAnd';
2
- import { EvaluatorNode, OperatorObject, BaseOperatorNode } from '../types';
3
- interface DivisionNodeWithProps extends BaseOperatorNode {
4
- dividend: EvaluatorNode;
5
- divisor: EvaluatorNode;
6
- }
7
- type DivisionOutput = 'quotient' | 'remainder';
8
- export type DivisionNode = BasicExtendedNode & DivisionNodeWithProps & {
9
- output?: DivisionOutput;
10
- };
11
- export declare const DIVIDE: OperatorObject;
12
- export {};
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DIVIDE = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const requiredProperties = [];
16
- const operatorAliases = ['/', 'divide', '÷'];
17
- const propertyAliases = { divide: 'dividend', by: 'divisor', divideBy: 'divisor' };
18
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
19
- var _a;
20
- const [values, output] = (yield (0, _operatorUtils_1.evaluateArray)([(_a = expression.values) !== null && _a !== void 0 ? _a : [expression.dividend, expression.divisor], expression.output], config));
21
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' }, { name: 'output', value: output, expectedType: ['string', 'undefined'] });
22
- if (values.length < 2)
23
- throw new Error('- Not enough values provided');
24
- if (!values[1])
25
- throw new Error('Division by zero!');
26
- switch (output) {
27
- case 'quotient':
28
- return Math.floor(values[0] / values[1]);
29
- case 'remainder':
30
- return values[0] % values[1];
31
- default:
32
- return values[0] / values[1];
33
- }
34
- });
35
- exports.DIVIDE = {
36
- requiredProperties,
37
- operatorAliases,
38
- propertyAliases,
39
- evaluate,
40
- parseChildren: logicalAnd_1.parseChildren,
41
- };
@@ -1,2 +0,0 @@
1
- import { OperatorObject } from '../types';
2
- export declare const EQUAL: OperatorObject;
@@ -1,12 +0,0 @@
1
- import { BaseOperatorNode, EvaluatorNode, FigTreeConfig, CombinedOperatorNode, GenericObject, OperatorObject } from '../types';
2
- declare const requiredProperties: readonly ["url"];
3
- export type APINode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode & {
6
- parameters?: EvaluatorNode;
7
- returnProperty?: EvaluatorNode;
8
- headers?: GenericObject;
9
- };
10
- export declare const parseChildrenGET: (expression: CombinedOperatorNode, config: FigTreeConfig) => Promise<APINode>;
11
- export declare const GET: OperatorObject;
12
- export {};
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.GET = exports.parseChildrenGET = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const requiredProperties = ['url'];
15
- const operatorAliases = ['get', 'api'];
16
- const propertyAliases = { endpoint: 'url', outputProperty: 'returnProperty' };
17
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
- var _a, _b, _c, _d;
19
- const [urlObj, params, returnProperty, headers] = (yield (0, _operatorUtils_1.evaluateArray)([expression.url, expression.parameters, expression.returnProperty, expression.headers], config));
20
- const { url, headers: headersObj } = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null };
21
- config.typeChecker({ name: 'url', value: url, expectedType: 'string' }, { name: 'headers', value: headersObj, expectedType: ['object', 'null'] }, { name: 'headers', value: headers, expectedType: ['object', 'undefined'] }, { name: 'parameters', value: params, expectedType: ['object', 'undefined'] }, { name: 'returnProperty', value: returnProperty, expectedType: ['string', 'undefined'] });
22
- const baseUrl = (_a = config.options.baseEndpoint) !== null && _a !== void 0 ? _a : '';
23
- const httpHeaders = Object.assign(Object.assign(Object.assign({}, (_b = config.options) === null || _b === void 0 ? void 0 : _b.headers), headersObj), headers);
24
- const shouldUseCache = (_d = (_c = expression.useCache) !== null && _c !== void 0 ? _c : config.options.useCache) !== null && _d !== void 0 ? _d : true;
25
- const result = yield config.cache.useCache(shouldUseCache, (url, params, headers, returnProperty) => __awaiter(void 0, void 0, void 0, function* () {
26
- const response = yield (0, _operatorUtils_1.axiosRequest)({
27
- url,
28
- params,
29
- headers,
30
- });
31
- return (0, _operatorUtils_1.extractAndSimplify)(response, returnProperty);
32
- }), (0, _operatorUtils_1.isFullUrl)(url) ? url : (0, _operatorUtils_1.joinUrlParts)(baseUrl, url), params, httpHeaders, returnProperty);
33
- return result;
34
- });
35
- const parseChildren = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
36
- const [url = '', fieldNames, ...rest] = (yield (0, _operatorUtils_1.evaluateArray)(expression.children, config));
37
- const values = rest.slice(0, fieldNames.length);
38
- const parameters = (0, _operatorUtils_1.zipArraysToObject)(fieldNames, values);
39
- const output = Object.assign(Object.assign({}, expression), { url, parameters });
40
- if (rest.length > fieldNames.length)
41
- output.returnProperty = rest.pop();
42
- return output;
43
- });
44
- exports.parseChildrenGET = parseChildren;
45
- exports.GET = {
46
- requiredProperties,
47
- operatorAliases,
48
- propertyAliases,
49
- evaluate,
50
- parseChildren,
51
- };
@@ -1,18 +0,0 @@
1
- import { BaseOperatorNode, EvaluatorNode, GenericObject, OperatorObject } from '../types';
2
- declare const requiredProperties: readonly ["query"];
3
- export type GraphQLNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode & {
6
- url?: EvaluatorNode;
7
- variables?: EvaluatorNode;
8
- returnNode?: EvaluatorNode;
9
- headers?: GenericObject;
10
- };
11
- export interface GraphQLConnection {
12
- endpoint: string;
13
- headers?: {
14
- [key: string]: string;
15
- };
16
- }
17
- export declare const GRAPHQL: OperatorObject;
18
- export {};
@@ -1,6 +0,0 @@
1
- import { OperatorObject } from '../types';
2
- import { BasicExtendedNode } from './logicalAnd';
3
- export type ComparatorNode = BasicExtendedNode & {
4
- strict?: boolean;
5
- };
6
- export declare const GREATER_THAN: OperatorObject;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.GREATER_THAN = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const logicalAnd_1 = require("./logicalAnd");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['>', 'greaterThan', 'higher', 'larger'];
17
- const aliasExtensions = [{ '>=': { strict: false } }];
18
- const propertyAliases = {};
19
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
20
- const [values, strict = true] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.strict], config));
21
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
22
- if (values.length < 2)
23
- throw new Error('- Not enough values provided');
24
- const [first, second] = values;
25
- if (first === second && !strict)
26
- return true;
27
- return first > second;
28
- });
29
- exports.GREATER_THAN = {
30
- requiredProperties,
31
- operatorAliases,
32
- propertyAliases,
33
- evaluate,
34
- parseChildren: logicalAnd_1.parseChildren,
35
- };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.LESS_THAN = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const logicalAnd_1 = require("./logicalAnd");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['<', 'lessThan', 'lower', 'smaller'];
17
- const aliasExtensions = [{ '<=': { strict: false } }];
18
- const propertyAliases = {};
19
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
20
- const [values, strict = true] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.strict], config));
21
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
22
- if (values.length < 2)
23
- throw new Error('- Not enough values provided');
24
- const [first, second] = values;
25
- if (first === second && !strict)
26
- return true;
27
- return first < second;
28
- });
29
- exports.LESS_THAN = {
30
- requiredProperties,
31
- operatorAliases,
32
- propertyAliases,
33
- evaluate,
34
- parseChildren: logicalAnd_1.parseChildren,
35
- };
@@ -1,8 +0,0 @@
1
- import { EvaluatorNode, BaseOperatorNode, CombinedOperatorNode, OperatorObject } from '../types';
2
- declare const requiredProperties: readonly ["values"];
3
- export type BasicExtendedNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode[];
5
- } & BaseOperatorNode;
6
- export declare const parseChildren: (expression: CombinedOperatorNode) => BasicExtendedNode;
7
- export declare const AND: OperatorObject;
8
- export {};
@@ -1,2 +0,0 @@
1
- import { OperatorObject } from '../types';
2
- export declare const OR: OperatorObject;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.OR = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['or', '|', '||'];
17
- const propertyAliases = {};
18
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
19
- const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
20
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
21
- return values.reduce((acc, val) => acc || !!val, false);
22
- });
23
- exports.OR = {
24
- requiredProperties,
25
- operatorAliases,
26
- propertyAliases,
27
- evaluate,
28
- parseChildren: logicalAnd_1.parseChildren,
29
- };
@@ -1,7 +0,0 @@
1
- import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
- declare const requiredProperties: readonly ["matchExpression"];
3
- export type MatchNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode;
6
- export declare const MATCH: OperatorObject;
7
- export {};
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MULTIPLY = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['*', 'x', 'multiply', 'times'];
17
- const propertyAliases = {};
18
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
19
- const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
20
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
21
- return values.reduce((acc, number) => acc * number);
22
- });
23
- exports.MULTIPLY = {
24
- requiredProperties,
25
- operatorAliases,
26
- propertyAliases,
27
- evaluate,
28
- parseChildren: logicalAnd_1.parseChildren,
29
- };
@@ -1,9 +0,0 @@
1
- import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
- declare const requiredProperties: string[];
3
- export type ObjPropNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode & {
6
- additionalData: object;
7
- };
8
- export declare const OBJECT_PROPERTIES: OperatorObject;
9
- export {};
@@ -1,7 +0,0 @@
1
- import { OperatorObject, EvaluatorNode, BaseOperatorNode } from '../types';
2
- declare const requiredProperties: readonly ["value"];
3
- export type PassThruNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode[];
5
- } & BaseOperatorNode;
6
- export declare const PASSTHRU: OperatorObject;
7
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PASSTHRU = void 0;
13
- const evaluate_1 = require("../evaluate");
14
- const requiredProperties = ['value'];
15
- const operatorAliases = ['_', 'passThru', 'pass', 'ignore', 'coerce', 'convert'];
16
- const propertyAliases = { _: 'value', data: 'value' };
17
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
- return yield (0, evaluate_1.evaluatorFunction)(expression.value, config);
19
- });
20
- const parseChildren = (expression) => {
21
- const [...children] = expression.children;
22
- return Object.assign(Object.assign({}, expression), { value: children });
23
- };
24
- exports.PASSTHRU = {
25
- requiredProperties,
26
- operatorAliases,
27
- propertyAliases,
28
- evaluate,
29
- parseChildren,
30
- };
@@ -1,24 +0,0 @@
1
- import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
- declare const requiredProperties: readonly ["query"];
3
- export type PGNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode & {
6
- values?: EvaluatorNode[];
7
- type?: 'string';
8
- };
9
- export interface PGConnection {
10
- query: (expression: {
11
- text: string;
12
- values?: any[];
13
- rowMode?: string;
14
- }) => Promise<QueryResult>;
15
- }
16
- interface QueryRowResult {
17
- [columns: string]: any;
18
- }
19
- export interface QueryResult {
20
- rows: QueryRowResult[];
21
- error?: string;
22
- }
23
- export declare const PG_SQL: OperatorObject;
24
- export {};
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PG_SQL = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const requiredProperties = ['query'];
15
- const operatorAliases = ['pgSql', 'sql', 'postgres', 'pg', 'pgDb'];
16
- const propertyAliases = { replacements: 'values', queryType: 'type' };
17
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
- var _a, _b, _c;
19
- const [query, type, ...values] = (yield (0, _operatorUtils_1.evaluateArray)([expression.query, expression.type, ...(expression.values || [])], config));
20
- config.typeChecker({ name: 'query', value: query, expectedType: 'string' }, { name: 'values', value: values, expectedType: 'array' }, { name: 'type', value: type, expectedType: ['string', 'undefined'] });
21
- if (!((_a = config.options) === null || _a === void 0 ? void 0 : _a.pgConnection))
22
- throw new Error('No Postgres database connection provided');
23
- const shouldUseCache = (_c = (_b = expression.useCache) !== null && _b !== void 0 ? _b : config.options.useCache) !== null && _c !== void 0 ? _c : true;
24
- try {
25
- const result = config.cache.useCache(shouldUseCache, (query, type, ...values) => __awaiter(void 0, void 0, void 0, function* () {
26
- return yield processPgSQL([query, ...values], config.options.pgConnection, type);
27
- }), query, type, ...values);
28
- return result;
29
- }
30
- catch (err) {
31
- throw err;
32
- }
33
- });
34
- const parseChildren = (expression) => {
35
- const [query, ...values] = expression.children;
36
- return Object.assign(Object.assign({}, expression), { query, values });
37
- };
38
- const processPgSQL = (queryArray, connection, queryType) => __awaiter(void 0, void 0, void 0, function* () {
39
- const expression = {
40
- text: queryArray[0],
41
- values: queryArray.slice(1),
42
- rowMode: queryType ? 'array' : '',
43
- };
44
- try {
45
- const res = yield connection.query(expression);
46
- if (res === null || res === void 0 ? void 0 : res.error)
47
- throw new Error(res.error);
48
- switch (queryType) {
49
- case 'array':
50
- return res.rows.flat();
51
- case 'string':
52
- return res.rows.flat().join(' ');
53
- case 'number':
54
- const result = res.rows.flat();
55
- return Number.isNaN(Number(result)) ? result : Number(result);
56
- default:
57
- return res.rows;
58
- }
59
- }
60
- catch (err) {
61
- throw err;
62
- }
63
- });
64
- exports.PG_SQL = {
65
- requiredProperties,
66
- operatorAliases,
67
- propertyAliases,
68
- evaluate,
69
- parseChildren,
70
- };
@@ -1,10 +0,0 @@
1
- import { OperatorObject, EvaluatorNode } from '../types';
2
- import { BasicExtendedNode } from './logicalAnd';
3
- declare const requiredProperties: readonly ["values"];
4
- export type AdditionNode = {
5
- [key in typeof requiredProperties[number]]: EvaluatorNode;
6
- } & BasicExtendedNode & {
7
- type?: 'string' | 'array';
8
- };
9
- export declare const PLUS: OperatorObject;
10
- export {};
@@ -1,2 +0,0 @@
1
- import { OperatorObject } from '../types';
2
- export declare const POST: OperatorObject;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.POST = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const getRequest_1 = require("./getRequest");
15
- const requiredProperties = ['url'];
16
- const operatorAliases = ['post'];
17
- const propertyAliases = { endpoint: 'url', outputProperty: 'returnProperty' };
18
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
19
- var _a, _b, _c, _d;
20
- const [urlObj, data, returnProperty, headers] = (yield (0, _operatorUtils_1.evaluateArray)([expression.url, expression.parameters, expression.returnProperty, expression.headers], config));
21
- const { url, headers: headersObj } = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null };
22
- config.typeChecker({ name: 'url', value: url, expectedType: 'string' }, { name: 'headers', value: headersObj, expectedType: ['object', 'null'] }, { name: 'data', value: data, expectedType: ['object', 'undefined'] }, { name: 'returnProperty', value: returnProperty, expectedType: ['string', 'undefined'] });
23
- const baseUrl = (_a = config.options.baseEndpoint) !== null && _a !== void 0 ? _a : '';
24
- const httpHeaders = Object.assign(Object.assign(Object.assign({}, (_b = config.options) === null || _b === void 0 ? void 0 : _b.headers), headersObj), headers);
25
- const shouldUseCache = (_d = (_c = expression.useCache) !== null && _c !== void 0 ? _c : config.options.useCache) !== null && _d !== void 0 ? _d : true;
26
- const result = yield config.cache.useCache(shouldUseCache, (url, data, headers, returnProperty) => __awaiter(void 0, void 0, void 0, function* () {
27
- const response = yield (0, _operatorUtils_1.axiosRequest)({
28
- url,
29
- data,
30
- headers,
31
- method: 'post',
32
- });
33
- return (0, _operatorUtils_1.extractAndSimplify)(response, returnProperty);
34
- }), (0, _operatorUtils_1.isFullUrl)(url) ? url : (0, _operatorUtils_1.joinUrlParts)(baseUrl, url), data, httpHeaders, returnProperty);
35
- return result;
36
- });
37
- exports.POST = {
38
- requiredProperties,
39
- operatorAliases,
40
- propertyAliases,
41
- evaluate,
42
- parseChildren: getRequest_1.parseChildrenGET,
43
- };
@@ -1,7 +0,0 @@
1
- import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
- declare const requiredProperties: readonly ["testString", "pattern"];
3
- export type RegexNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode;
6
- export declare const REGEX: OperatorObject;
7
- export {};
@@ -1,11 +0,0 @@
1
- import { OperatorObject, EvaluatorNode, BaseOperatorNode } from '../types';
2
- declare const requiredProperties: readonly ["value"];
3
- export type SplitNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode & {
6
- delimiter?: EvaluatorNode;
7
- trimWhiteSpace: EvaluatorNode;
8
- excludeTrailing: EvaluatorNode;
9
- };
10
- export declare const SPLIT: OperatorObject;
11
- export {};
@@ -1,7 +0,0 @@
1
- import { BaseOperatorNode, EvaluatorNode, OperatorObject } from '../types';
2
- declare const requiredProperties: readonly ["string", "substitutions"];
3
- export type StringSubNode = {
4
- [key in typeof requiredProperties[number]]: EvaluatorNode;
5
- } & BaseOperatorNode;
6
- export declare const STRING_SUBSTITUTION: OperatorObject;
7
- export {};
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.STRING_SUBSTITUTION = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const requiredProperties = ['string', 'substitutions'];
15
- const operatorAliases = ['stringSubstitution', 'substitute', 'stringSub', 'replace'];
16
- const propertyAliases = { replacements: 'substitutions' };
17
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
- const [string, ...substitutions] = (yield (0, _operatorUtils_1.evaluateArray)([expression.string, ...expression.substitutions], config));
19
- config.typeChecker({ name: 'string', value: string, expectedType: 'string' });
20
- config.typeChecker({ name: 'substitutions', value: substitutions, expectedType: 'array' });
21
- const regex = /(%[\d]+)/g;
22
- const parameters = (string.match(regex) || []).sort((a, b) => Number(a.slice(1)) - Number(b.slice(1)));
23
- const uniqueParameters = new Set(parameters);
24
- const replacementsObj = (0, _operatorUtils_1.zipArraysToObject)(Array.from(uniqueParameters), substitutions);
25
- return string
26
- .split(regex)
27
- .map((fragment) => (fragment in replacementsObj ? replacementsObj[fragment] : fragment))
28
- .join('');
29
- });
30
- const parseChildren = (expression) => {
31
- const [string, ...substitutions] = expression.children;
32
- return Object.assign(Object.assign({}, expression), { string, substitutions });
33
- };
34
- exports.STRING_SUBSTITUTION = {
35
- requiredProperties,
36
- operatorAliases,
37
- propertyAliases,
38
- evaluate,
39
- parseChildren,
40
- };