fig-tree-evaluator 2.2.1 → 2.2.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 (43) hide show
  1. package/README.md +27 -17
  2. package/build/evaluate.js +138 -50
  3. package/build/helpers.d.ts +1 -0
  4. package/build/helpers.js +132 -46
  5. package/build/index.d.ts +0 -1
  6. package/build/index.js +91 -32
  7. package/build/operators/_operatorAliases.json +3 -0
  8. package/build/operators/_operatorUtils.js +109 -48
  9. package/build/operators/buildObject.js +84 -26
  10. package/build/operators/conditional.js +70 -18
  11. package/build/operators/count.js +48 -14
  12. package/build/operators/customFunctions.js +76 -21
  13. package/build/operators/divide.js +63 -26
  14. package/build/operators/equal.js +57 -23
  15. package/build/operators/getRequest.js +85 -31
  16. package/build/operators/graphQL.js +90 -40
  17. package/build/operators/greaterThan.js +54 -20
  18. package/build/operators/lessThan.js +54 -20
  19. package/build/operators/logicalAnd.js +61 -16
  20. package/build/operators/logicalOr.js +48 -14
  21. package/build/operators/match.js +101 -38
  22. package/build/operators/multiply.js +48 -14
  23. package/build/operators/notEqual.js +57 -23
  24. package/build/operators/objectProperties.d.ts +1 -1
  25. package/build/operators/objectProperties.js +78 -23
  26. package/build/operators/passThru.js +58 -15
  27. package/build/operators/pgSQL.js +118 -50
  28. package/build/operators/plus.js +70 -24
  29. package/build/operators/postRequest.js +70 -23
  30. package/build/operators/regex.js +70 -24
  31. package/build/operators/split.js +74 -29
  32. package/build/operators/stringSubstitution.js +79 -25
  33. package/build/operators/subtract.js +50 -16
  34. package/build/typeCheck.js +27 -22
  35. package/build/types.d.ts +2 -0
  36. package/package.json +2 -2
  37. package/build/.DS_Store +0 -0
  38. package/build/FigTreeEvaluator.d.ts +0 -13
  39. package/build/FigTreeEvaluator.js +0 -75
  40. package/build/evaluator.d.ts +0 -13
  41. package/build/evaluator.js +0 -75
  42. package/build/operators/objectFunctions.d.ts +0 -9
  43. package/build/operators/objectFunctions.js +0 -38
@@ -8,22 +8,56 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.COUNT = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const requiredProperties = ['values'];
16
- const operatorAliases = ['count', 'length'];
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.length;
22
- });
40
+ var logicalAnd_1 = require("./logicalAnd");
41
+ var _operatorUtils_1 = require("./_operatorUtils");
42
+ var requiredProperties = ['values'];
43
+ var operatorAliases = ['count', 'length'];
44
+ var propertyAliases = {};
45
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
46
+ var values;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)(expression.values, config)];
50
+ case 1:
51
+ values = _a.sent();
52
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
53
+ return [2, values.length];
54
+ }
55
+ });
56
+ }); };
23
57
  exports.COUNT = {
24
- requiredProperties,
25
- operatorAliases,
26
- propertyAliases,
27
- evaluate,
58
+ requiredProperties: requiredProperties,
59
+ operatorAliases: operatorAliases,
60
+ propertyAliases: propertyAliases,
61
+ evaluate: evaluate,
28
62
  parseChildren: logicalAnd_1.parseChildren,
29
63
  };
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,15 +19,51 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
19
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
20
  });
10
21
  };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
+ if (ar || !(i in from)) {
52
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
+ ar[i] = from[i];
54
+ }
55
+ }
56
+ return to.concat(ar || Array.prototype.slice.call(from));
57
+ };
11
58
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
60
  };
14
61
  Object.defineProperty(exports, "__esModule", { value: true });
15
62
  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 = [
63
+ var object_property_extractor_1 = __importDefault(require("object-property-extractor"));
64
+ var _operatorUtils_1 = require("./_operatorUtils");
65
+ var requiredProperties = ['functionPath'];
66
+ var operatorAliases = [
20
67
  'customFunctions',
21
68
  'customFunction',
22
69
  'objectFunctions',
@@ -24,7 +71,7 @@ const operatorAliases = [
24
71
  'functions',
25
72
  'runFunction',
26
73
  ];
27
- const propertyAliases = {
74
+ var propertyAliases = {
28
75
  functionsPath: 'functionPath',
29
76
  functionName: 'functionPath',
30
77
  funcName: 'functionPath',
@@ -32,22 +79,30 @@ const propertyAliases = {
32
79
  arguments: 'args',
33
80
  variables: 'args',
34
81
  };
35
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
36
- var _a, _b;
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 { objects, 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)(objects, functionPath, null)) !== null && _b !== void 0 ? _b : (0, object_property_extractor_1.default)(config.options, functionPath));
41
- return yield func(...args);
42
- });
43
- const parseChildren = (expression) => {
44
- const [functionPath, ...args] = expression.children;
45
- return Object.assign(Object.assign({}, expression), { functionPath, args });
82
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
83
+ var _a, functionPath, args, _b, data, functions, func;
84
+ var _c, _d;
85
+ return __generator(this, function (_e) {
86
+ switch (_e.label) {
87
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)(__spreadArray([expression.functionPath], (expression.args || []), true), config)];
88
+ case 1:
89
+ _a = (_e.sent()), functionPath = _a[0], args = _a.slice(1);
90
+ config.typeChecker({ name: 'functionPath', value: functionPath, expectedType: 'string' });
91
+ _b = config.options, data = _b.data, functions = _b.functions;
92
+ func = ((_d = (_c = (0, object_property_extractor_1.default)(functions, functionPath, null)) !== null && _c !== void 0 ? _c : (0, object_property_extractor_1.default)(data, functionPath, null)) !== null && _d !== void 0 ? _d : (0, object_property_extractor_1.default)(config.options, functionPath));
93
+ return [4, func.apply(void 0, args)];
94
+ case 2: return [2, _e.sent()];
95
+ }
96
+ });
97
+ }); };
98
+ var parseChildren = function (expression) {
99
+ var _a = expression.children, functionPath = _a[0], args = _a.slice(1);
100
+ return __assign(__assign({}, expression), { functionPath: functionPath, args: args });
46
101
  };
47
102
  exports.CUSTOM_FUNCTIONS = {
48
- requiredProperties,
49
- operatorAliases,
50
- propertyAliases,
51
- evaluate,
52
- parseChildren,
103
+ requiredProperties: requiredProperties,
104
+ operatorAliases: operatorAliases,
105
+ propertyAliases: propertyAliases,
106
+ evaluate: evaluate,
107
+ parseChildren: parseChildren,
53
108
  };
@@ -8,35 +8,72 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.DIVIDE = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const __1 = require("..");
16
- const requiredProperties = [];
17
- const operatorAliases = ['/', 'divide', '÷'];
18
- const propertyAliases = { divide: 'dividend', by: 'divisor', divideBy: 'divisor' };
19
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
40
+ var logicalAnd_1 = require("./logicalAnd");
41
+ var _operatorUtils_1 = require("./_operatorUtils");
42
+ var __1 = require("..");
43
+ var requiredProperties = [];
44
+ var operatorAliases = ['/', 'divide', '÷'];
45
+ var propertyAliases = { divide: 'dividend', by: 'divisor', divideBy: 'divisor' };
46
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var values;
20
48
  var _a;
21
- const values = (yield (0, _operatorUtils_1.evaluateArray)((_a = expression.values) !== null && _a !== void 0 ? _a : [expression.dividend, expression.divisor], config));
22
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
23
- if (values.length < 2)
24
- throw new Error('- Not enough values provided');
25
- if (!values[1])
26
- throw new Error('Division by zero!');
27
- switch (yield (0, __1.evaluateExpression)(expression.output)) {
28
- case 'quotient':
29
- return Math.floor(values[0] / values[1]);
30
- case 'remainder':
31
- return values[0] % values[1];
32
- default:
33
- return values[0] / values[1];
34
- }
35
- });
49
+ return __generator(this, function (_b) {
50
+ switch (_b.label) {
51
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)((_a = expression.values) !== null && _a !== void 0 ? _a : [expression.dividend, expression.divisor], config)];
52
+ case 1:
53
+ values = (_b.sent());
54
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
55
+ if (values.length < 2)
56
+ throw new Error('- Not enough values provided');
57
+ if (!values[1])
58
+ throw new Error('Division by zero!');
59
+ return [4, (0, __1.evaluateExpression)(expression.output)];
60
+ case 2:
61
+ switch (_b.sent()) {
62
+ case 'quotient':
63
+ return [2, Math.floor(values[0] / values[1])];
64
+ case 'remainder':
65
+ return [2, values[0] % values[1]];
66
+ default:
67
+ return [2, values[0] / values[1]];
68
+ }
69
+ return [2];
70
+ }
71
+ });
72
+ }); };
36
73
  exports.DIVIDE = {
37
- requiredProperties,
38
- operatorAliases,
39
- propertyAliases,
40
- evaluate,
74
+ requiredProperties: requiredProperties,
75
+ operatorAliases: operatorAliases,
76
+ propertyAliases: propertyAliases,
77
+ evaluate: evaluate,
41
78
  parseChildren: logicalAnd_1.parseChildren,
42
79
  };
@@ -8,31 +8,65 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.EQUAL = void 0;
13
- const logicalAnd_1 = require("./logicalAnd");
14
- const _operatorUtils_1 = require("./_operatorUtils");
15
- const lite_1 = require("dequal/lite");
16
- const requiredProperties = ['values'];
17
- const operatorAliases = ['=', 'eq', 'equal', 'equals'];
18
- const propertyAliases = {};
19
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
20
- var _a;
21
- const [values, nullMatch] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config));
22
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
23
- const nullEqualsUndefined = nullMatch !== undefined
24
- ? nullMatch
25
- : ((_a = config.options) === null || _a === void 0 ? void 0 : _a.nullEqualsUndefined) !== undefined
26
- ? config.options.nullEqualsUndefined
27
- : false;
28
- if (nullEqualsUndefined && (values[0] === null || values[0] === undefined))
29
- return values.every((value) => value === null || value === undefined);
30
- return values.every((value) => (0, lite_1.dequal)(value, values[0]));
31
- });
40
+ var logicalAnd_1 = require("./logicalAnd");
41
+ var _operatorUtils_1 = require("./_operatorUtils");
42
+ var lite_1 = require("dequal/lite");
43
+ var requiredProperties = ['values'];
44
+ var operatorAliases = ['=', 'eq', 'equal', 'equals'];
45
+ var propertyAliases = {};
46
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var _a, values, nullMatch, nullEqualsUndefined;
48
+ var _b;
49
+ return __generator(this, function (_c) {
50
+ switch (_c.label) {
51
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config)];
52
+ case 1:
53
+ _a = (_c.sent()), values = _a[0], nullMatch = _a[1];
54
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
55
+ nullEqualsUndefined = nullMatch !== undefined
56
+ ? nullMatch
57
+ : ((_b = config.options) === null || _b === void 0 ? void 0 : _b.nullEqualsUndefined) !== undefined
58
+ ? config.options.nullEqualsUndefined
59
+ : false;
60
+ if (nullEqualsUndefined && (values[0] === null || values[0] === undefined))
61
+ return [2, values.every(function (value) { return value === null || value === undefined; })];
62
+ return [2, values.every(function (value) { return (0, lite_1.dequal)(value, values[0]); })];
63
+ }
64
+ });
65
+ }); };
32
66
  exports.EQUAL = {
33
- requiredProperties,
34
- operatorAliases,
35
- propertyAliases,
36
- evaluate,
67
+ requiredProperties: requiredProperties,
68
+ operatorAliases: operatorAliases,
69
+ propertyAliases: propertyAliases,
70
+ evaluate: evaluate,
37
71
  parseChildren: logicalAnd_1.parseChildren,
38
72
  };
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,40 +19,83 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
19
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
20
  });
10
21
  };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
11
49
  Object.defineProperty(exports, "__esModule", { value: true });
12
50
  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;
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 response = yield (0, _operatorUtils_1.axiosRequest)({
25
- url: (0, _operatorUtils_1.isFullUrl)(url) ? url : (0, _operatorUtils_1.joinUrlParts)(baseUrl, url),
26
- params,
27
- headers: httpHeaders,
51
+ var _operatorUtils_1 = require("./_operatorUtils");
52
+ var requiredProperties = ['url'];
53
+ var operatorAliases = ['get', 'api'];
54
+ var propertyAliases = { endpoint: 'url', outputProperty: 'returnProperty' };
55
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var _a, urlObj, params, returnProperty, headers, _b, url, headersObj, baseUrl, httpHeaders, response;
57
+ var _c, _d;
58
+ return __generator(this, function (_e) {
59
+ switch (_e.label) {
60
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.url, expression.parameters, expression.returnProperty, expression.headers], config)];
61
+ case 1:
62
+ _a = (_e.sent()), urlObj = _a[0], params = _a[1], returnProperty = _a[2], headers = _a[3];
63
+ _b = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null }, url = _b.url, headersObj = _b.headers;
64
+ 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'] });
65
+ baseUrl = (_c = config.options.baseEndpoint) !== null && _c !== void 0 ? _c : '';
66
+ httpHeaders = __assign(__assign(__assign({}, (_d = config.options) === null || _d === void 0 ? void 0 : _d.headers), headersObj), headers);
67
+ return [4, (0, _operatorUtils_1.axiosRequest)({
68
+ url: (0, _operatorUtils_1.isFullUrl)(url) ? url : (0, _operatorUtils_1.joinUrlParts)(baseUrl, url),
69
+ params: params,
70
+ headers: httpHeaders,
71
+ })];
72
+ case 2:
73
+ response = _e.sent();
74
+ return [2, (0, _operatorUtils_1.extractAndSimplify)(response, returnProperty)];
75
+ }
76
+ });
77
+ }); };
78
+ var parseChildren = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
79
+ var _a, _b, url, fieldNames, rest, values, parameters, output;
80
+ return __generator(this, function (_c) {
81
+ switch (_c.label) {
82
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)(expression.children, config)];
83
+ case 1:
84
+ _a = (_c.sent()), _b = _a[0], url = _b === void 0 ? '' : _b, fieldNames = _a[1], rest = _a.slice(2);
85
+ values = rest.slice(0, fieldNames.length);
86
+ parameters = (0, _operatorUtils_1.zipArraysToObject)(fieldNames, values);
87
+ output = __assign(__assign({}, expression), { url: url, parameters: parameters });
88
+ if (rest.length > fieldNames.length)
89
+ output.returnProperty = rest.pop();
90
+ return [2, output];
91
+ }
28
92
  });
29
- return (0, _operatorUtils_1.extractAndSimplify)(response, returnProperty);
30
- });
31
- const parseChildren = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
32
- const [url = '', fieldNames, ...rest] = (yield (0, _operatorUtils_1.evaluateArray)(expression.children, config));
33
- const values = rest.slice(0, fieldNames.length);
34
- const parameters = (0, _operatorUtils_1.zipArraysToObject)(fieldNames, values);
35
- const output = Object.assign(Object.assign({}, expression), { url, parameters });
36
- if (rest.length > fieldNames.length)
37
- output.returnProperty = rest.pop();
38
- return output;
39
- });
93
+ }); };
40
94
  exports.parseChildrenGET = parseChildren;
41
95
  exports.GET = {
42
- requiredProperties,
43
- operatorAliases,
44
- propertyAliases,
45
- evaluate,
46
- parseChildren,
96
+ requiredProperties: requiredProperties,
97
+ operatorAliases: operatorAliases,
98
+ propertyAliases: propertyAliases,
99
+ evaluate: evaluate,
100
+ parseChildren: parseChildren,
47
101
  };