fig-tree-evaluator 2.2.1 → 2.2.2

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 (40) hide show
  1. package/README.md +14 -5
  2. package/build/evaluate.js +138 -50
  3. package/build/helpers.d.ts +1 -0
  4. package/build/helpers.js +131 -45
  5. package/build/index.js +82 -28
  6. package/build/operators/_operatorUtils.js +109 -48
  7. package/build/operators/buildObject.js +84 -26
  8. package/build/operators/conditional.js +70 -18
  9. package/build/operators/count.js +48 -14
  10. package/build/operators/customFunctions.js +76 -21
  11. package/build/operators/divide.js +63 -26
  12. package/build/operators/equal.js +57 -23
  13. package/build/operators/getRequest.js +85 -31
  14. package/build/operators/graphQL.js +90 -40
  15. package/build/operators/greaterThan.js +54 -20
  16. package/build/operators/lessThan.js +54 -20
  17. package/build/operators/logicalAnd.js +61 -16
  18. package/build/operators/logicalOr.js +48 -14
  19. package/build/operators/match.js +101 -38
  20. package/build/operators/multiply.js +48 -14
  21. package/build/operators/notEqual.js +57 -23
  22. package/build/operators/objectProperties.js +66 -21
  23. package/build/operators/passThru.js +58 -15
  24. package/build/operators/pgSQL.js +118 -50
  25. package/build/operators/plus.js +70 -24
  26. package/build/operators/postRequest.js +70 -23
  27. package/build/operators/regex.js +70 -24
  28. package/build/operators/split.js +74 -29
  29. package/build/operators/stringSubstitution.js +79 -25
  30. package/build/operators/subtract.js +50 -16
  31. package/build/typeCheck.js +27 -22
  32. package/build/types.d.ts +1 -0
  33. package/package.json +2 -2
  34. package/build/.DS_Store +0 -0
  35. package/build/FigTreeEvaluator.d.ts +0 -13
  36. package/build/FigTreeEvaluator.js +0 -75
  37. package/build/evaluator.d.ts +0 -13
  38. package/build/evaluator.js +0 -75
  39. package/build/operators/objectFunctions.d.ts +0 -9
  40. package/build/operators/objectFunctions.js +0 -38
@@ -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
  };
@@ -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,48 +19,87 @@ 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.GRAPHQL = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const requiredProperties = ['query'];
15
- const operatorAliases = ['graphQl', 'graphql', 'gql'];
16
- const propertyAliases = { endpoint: 'url', outputNode: 'returnNode', returnProperty: 'returnNode' };
17
- const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
- var _a, _b, _c, _d, _e;
19
- const [query, urlObj, variables, returnNode, headers] = (yield (0, _operatorUtils_1.evaluateArray)([
20
- expression.query,
21
- expression.url,
22
- expression.variables,
23
- expression.returnNode,
24
- expression.headers,
25
- ], config));
26
- const { url, headers: headersObj } = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null };
27
- config.typeChecker({ name: 'url', value: url, expectedType: ['string', 'undefined', 'null'] }, { name: 'query', value: query, expectedType: 'string' }, { name: 'headers', value: headersObj, expectedType: ['object', 'null'] }, { name: 'variables', value: variables, expectedType: ['object', 'undefined'] }, { name: 'returnNode', value: returnNode, expectedType: ['string', 'undefined'] });
28
- const endpoint = !url || url.toLowerCase() === 'graphqlendpoint' ? '' : url;
29
- const baseEndpoint = (_c = (_b = (_a = config.options.graphQLConnection) === null || _a === void 0 ? void 0 : _a.endpoint) !== null && _b !== void 0 ? _b : config.options.baseEndpoint) !== null && _c !== void 0 ? _c : '';
30
- const fullUrl = (0, _operatorUtils_1.isFullUrl)(endpoint) ? endpoint : (0, _operatorUtils_1.joinUrlParts)(baseEndpoint, endpoint);
31
- const data = { query, variables };
32
- const response = yield (0, _operatorUtils_1.axiosRequest)({
33
- url: fullUrl,
34
- method: 'post',
35
- data,
36
- headers: Object.assign(Object.assign(Object.assign(Object.assign({}, (_d = config.options.graphQLConnection) === null || _d === void 0 ? void 0 : _d.headers), (_e = config.options) === null || _e === void 0 ? void 0 : _e.headers), headersObj), headers),
51
+ var _operatorUtils_1 = require("./_operatorUtils");
52
+ var requiredProperties = ['query'];
53
+ var operatorAliases = ['graphQl', 'graphql', 'gql'];
54
+ var propertyAliases = { endpoint: 'url', outputNode: 'returnNode', returnProperty: 'returnNode' };
55
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var _a, query, urlObj, variables, returnNode, headers, _b, url, headersObj, endpoint, baseEndpoint, fullUrl, data, response;
57
+ var _c, _d, _e, _f, _g;
58
+ return __generator(this, function (_h) {
59
+ switch (_h.label) {
60
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)([
61
+ expression.query,
62
+ expression.url,
63
+ expression.variables,
64
+ expression.returnNode,
65
+ expression.headers,
66
+ ], config)];
67
+ case 1:
68
+ _a = (_h.sent()), query = _a[0], urlObj = _a[1], variables = _a[2], returnNode = _a[3], headers = _a[4];
69
+ _b = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null }, url = _b.url, headersObj = _b.headers;
70
+ config.typeChecker({ name: 'url', value: url, expectedType: ['string', 'undefined', 'null'] }, { name: 'query', value: query, expectedType: 'string' }, { name: 'headers', value: headersObj, expectedType: ['object', 'null'] }, { name: 'variables', value: variables, expectedType: ['object', 'undefined'] }, { name: 'returnNode', value: returnNode, expectedType: ['string', 'undefined'] });
71
+ endpoint = !url || url.toLowerCase() === 'graphqlendpoint' ? '' : url;
72
+ baseEndpoint = (_e = (_d = (_c = config.options.graphQLConnection) === null || _c === void 0 ? void 0 : _c.endpoint) !== null && _d !== void 0 ? _d : config.options.baseEndpoint) !== null && _e !== void 0 ? _e : '';
73
+ fullUrl = (0, _operatorUtils_1.isFullUrl)(endpoint) ? endpoint : (0, _operatorUtils_1.joinUrlParts)(baseEndpoint, endpoint);
74
+ data = { query: query, variables: variables };
75
+ return [4, (0, _operatorUtils_1.axiosRequest)({
76
+ url: fullUrl,
77
+ method: 'post',
78
+ data: data,
79
+ headers: __assign(__assign(__assign(__assign({}, (_f = config.options.graphQLConnection) === null || _f === void 0 ? void 0 : _f.headers), (_g = config.options) === null || _g === void 0 ? void 0 : _g.headers), headersObj), headers),
80
+ })];
81
+ case 2:
82
+ response = _h.sent();
83
+ return [2, (0, _operatorUtils_1.extractAndSimplify)(response.data, returnNode)];
84
+ }
85
+ });
86
+ }); };
87
+ var parseChildren = function (expression) { return __awaiter(void 0, void 0, void 0, function () {
88
+ var _a, query, _b, url, fieldNames, rest, values, variables, output;
89
+ return __generator(this, function (_c) {
90
+ _a = expression.children, query = _a[0], _b = _a[1], url = _b === void 0 ? '' : _b, fieldNames = _a[2], rest = _a.slice(3);
91
+ values = rest.slice(0, fieldNames.length);
92
+ variables = (0, _operatorUtils_1.zipArraysToObject)(fieldNames, values);
93
+ output = __assign(__assign({}, expression), { query: query, url: url, variables: variables });
94
+ if (rest.length > fieldNames.length)
95
+ output.returnNode = rest.pop();
96
+ return [2, output];
37
97
  });
38
- return (0, _operatorUtils_1.extractAndSimplify)(response.data, returnNode);
39
- });
40
- const parseChildren = (expression) => __awaiter(void 0, void 0, void 0, function* () {
41
- const [query, url = '', fieldNames, ...rest] = expression.children;
42
- const values = rest.slice(0, fieldNames.length);
43
- const variables = (0, _operatorUtils_1.zipArraysToObject)(fieldNames, values);
44
- const output = Object.assign(Object.assign({}, expression), { query, url, variables });
45
- if (rest.length > fieldNames.length)
46
- output.returnNode = rest.pop();
47
- return output;
48
- });
98
+ }); };
49
99
  exports.GRAPHQL = {
50
- requiredProperties,
51
- operatorAliases,
52
- propertyAliases,
53
- evaluate,
54
- parseChildren,
100
+ requiredProperties: requiredProperties,
101
+ operatorAliases: operatorAliases,
102
+ propertyAliases: propertyAliases,
103
+ evaluate: evaluate,
104
+ parseChildren: parseChildren,
55
105
  };
@@ -8,28 +8,62 @@ 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.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
- });
40
+ var _operatorUtils_1 = require("./_operatorUtils");
41
+ var logicalAnd_1 = require("./logicalAnd");
42
+ var requiredProperties = ['values'];
43
+ var operatorAliases = ['>', 'greaterThan', 'higher', 'larger'];
44
+ var aliasExtensions = [{ '>=': { strict: false } }];
45
+ var propertyAliases = {};
46
+ var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var _a, values, _b, strict, first, second;
48
+ return __generator(this, function (_c) {
49
+ switch (_c.label) {
50
+ case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.values, expression.strict], config)];
51
+ case 1:
52
+ _a = (_c.sent()), values = _a[0], _b = _a[1], strict = _b === void 0 ? true : _b;
53
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
54
+ if (values.length < 2)
55
+ throw new Error('- Not enough values provided');
56
+ first = values[0], second = values[1];
57
+ if (first === second && !strict)
58
+ return [2, true];
59
+ return [2, first > second];
60
+ }
61
+ });
62
+ }); };
29
63
  exports.GREATER_THAN = {
30
- requiredProperties,
31
- operatorAliases,
32
- propertyAliases,
33
- evaluate,
64
+ requiredProperties: requiredProperties,
65
+ operatorAliases: operatorAliases,
66
+ propertyAliases: propertyAliases,
67
+ evaluate: evaluate,
34
68
  parseChildren: logicalAnd_1.parseChildren,
35
69
  };