fig-tree-evaluator 2.4.3 → 2.5.1

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.
@@ -1,15 +1,4 @@
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
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,132 +8,63 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
9
  });
21
10
  };
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
- };
58
11
  Object.defineProperty(exports, "__esModule", { value: true });
59
12
  exports.PG_SQL = void 0;
60
- var _operatorUtils_1 = require("./_operatorUtils");
61
- var requiredProperties = ['query'];
62
- var operatorAliases = ['pgSql', 'sql', 'postgres', 'pg', 'pgDb'];
63
- var propertyAliases = { replacements: 'values' };
64
- var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
65
- var _a, query, values, shouldUseCache, result;
66
- var _b;
67
- var _c, _d, _e;
68
- return __generator(this, function (_f) {
69
- switch (_f.label) {
70
- case 0: return [4, (0, _operatorUtils_1.evaluateArray)(__spreadArray([expression.query], (expression.values || []), true), config)];
71
- case 1:
72
- _a = (_f.sent()), query = _a[0], values = _a.slice(1);
73
- config.typeChecker({ name: 'query', value: query, expectedType: 'string' }, { name: 'values', value: values, expectedType: 'array' });
74
- if (!((_c = config.options) === null || _c === void 0 ? void 0 : _c.pgConnection))
75
- throw new Error('No Postgres database connection provided');
76
- shouldUseCache = (_e = (_d = expression.useCache) !== null && _d !== void 0 ? _d : config.options.useCache) !== null && _e !== void 0 ? _e : true;
77
- try {
78
- result = (_b = config.cache).useCache.apply(_b, __spreadArray([shouldUseCache,
79
- function (query) {
80
- var values = [];
81
- for (var _i = 1; _i < arguments.length; _i++) {
82
- values[_i - 1] = arguments[_i];
83
- }
84
- return __awaiter(void 0, void 0, void 0, function () {
85
- return __generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0: return [4, processPgSQL(__spreadArray([query], values, true), config.options.pgConnection, expression === null || expression === void 0 ? void 0 : expression.type)];
88
- case 1: return [2, _a.sent()];
89
- }
90
- });
91
- });
92
- },
93
- query], values, false));
94
- return [2, result];
95
- }
96
- catch (err) {
97
- throw err;
98
- }
99
- return [2];
100
- }
101
- });
102
- }); };
103
- var parseChildren = function (expression) {
104
- var _a = expression.children, query = _a[0], values = _a.slice(1);
105
- return __assign(__assign({}, expression), { query: query, values: values });
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 });
106
37
  };
107
- var processPgSQL = function (queryArray, connection, queryType) { return __awaiter(void 0, void 0, void 0, function () {
108
- var expression, res, result, err_1;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- expression = {
113
- text: queryArray[0],
114
- values: queryArray.slice(1),
115
- rowMode: queryType ? 'array' : '',
116
- };
117
- _a.label = 1;
118
- case 1:
119
- _a.trys.push([1, 3, , 4]);
120
- return [4, connection.query(expression)];
121
- case 2:
122
- res = _a.sent();
123
- if (res === null || res === void 0 ? void 0 : res.error)
124
- throw new Error(res.error);
125
- switch (queryType) {
126
- case 'array':
127
- return [2, res.rows.flat()];
128
- case 'string':
129
- return [2, res.rows.flat().join(' ')];
130
- case 'number':
131
- result = res.rows.flat();
132
- return [2, Number.isNaN(Number(result)) ? result : Number(result)];
133
- default:
134
- return [2, res.rows];
135
- }
136
- return [3, 4];
137
- case 3:
138
- err_1 = _a.sent();
139
- throw err_1;
140
- case 4: return [2];
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;
141
58
  }
142
- });
143
- }); };
59
+ }
60
+ catch (err) {
61
+ throw err;
62
+ }
63
+ });
144
64
  exports.PG_SQL = {
145
- requiredProperties: requiredProperties,
146
- operatorAliases: operatorAliases,
147
- propertyAliases: propertyAliases,
148
- evaluate: evaluate,
149
- parseChildren: parseChildren,
65
+ requiredProperties,
66
+ operatorAliases,
67
+ propertyAliases,
68
+ evaluate,
69
+ parseChildren,
150
70
  };
@@ -1,15 +1,4 @@
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
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,67 +8,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
9
  });
21
10
  };
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
11
  Object.defineProperty(exports, "__esModule", { value: true });
50
12
  exports.PLUS = void 0;
51
- var _operatorUtils_1 = require("./_operatorUtils");
52
- var logicalAnd_1 = require("./logicalAnd");
53
- var requiredProperties = ['values'];
54
- var operatorAliases = ['+', 'plus', 'add', 'concat', 'join', 'merge'];
55
- var propertyAliases = {};
56
- var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
57
- var values;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0:
61
- if (expression.values.length === 0)
62
- return [2, expression.values];
63
- return [4, (0, _operatorUtils_1.evaluateArray)(expression.values, config)];
64
- case 1:
65
- values = (_a.sent());
66
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
67
- if ((expression === null || expression === void 0 ? void 0 : expression.type) === 'string')
68
- return [2, values.reduce(function (acc, child) { return acc.concat(child); }, '')];
69
- if ((expression === null || expression === void 0 ? void 0 : expression.type) === 'array')
70
- return [2, values.reduce(function (acc, child) { return acc.concat(child); }, [])];
71
- if (values.every(function (child) { return typeof child === 'string' || Array.isArray(child); }))
72
- return [2, values.reduce(function (acc, child) { return acc.concat(child); })];
73
- if (values.every(function (child) { return child instanceof Object && !Array.isArray(child); }))
74
- return [2, values.reduce(function (acc, child) { return (__assign(__assign({}, acc), child)); }, {})];
75
- return [2, values.reduce(function (acc, child) { return acc + child; })];
76
- }
77
- });
78
- }); };
13
+ const _operatorUtils_1 = require("./_operatorUtils");
14
+ const logicalAnd_1 = require("./logicalAnd");
15
+ const requiredProperties = ['values'];
16
+ const operatorAliases = ['+', 'plus', 'add', 'concat', 'join', 'merge'];
17
+ const propertyAliases = {};
18
+ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
19
+ if (expression.values.length === 0)
20
+ return expression.values;
21
+ const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
22
+ config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
23
+ if ((expression === null || expression === void 0 ? void 0 : expression.type) === 'string')
24
+ return values.reduce((acc, child) => acc.concat(child), '');
25
+ if ((expression === null || expression === void 0 ? void 0 : expression.type) === 'array')
26
+ return values.reduce((acc, child) => acc.concat(child), []);
27
+ if (values.every((child) => typeof child === 'string' || Array.isArray(child)))
28
+ return values.reduce((acc, child) => acc.concat(child));
29
+ if (values.every((child) => child instanceof Object && !Array.isArray(child)))
30
+ return values.reduce((acc, child) => (Object.assign(Object.assign({}, acc), child)), {});
31
+ return values.reduce((acc, child) => acc + child);
32
+ });
79
33
  exports.PLUS = {
80
- requiredProperties: requiredProperties,
81
- operatorAliases: operatorAliases,
82
- propertyAliases: propertyAliases,
83
- evaluate: evaluate,
34
+ requiredProperties,
35
+ operatorAliases,
36
+ propertyAliases,
37
+ evaluate,
84
38
  parseChildren: logicalAnd_1.parseChildren,
85
39
  };
@@ -1,15 +1,4 @@
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
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,79 +8,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
9
  });
21
10
  };
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
11
  Object.defineProperty(exports, "__esModule", { value: true });
50
12
  exports.POST = void 0;
51
- var _operatorUtils_1 = require("./_operatorUtils");
52
- var getRequest_1 = require("./getRequest");
53
- var requiredProperties = ['url'];
54
- var operatorAliases = ['post'];
55
- var propertyAliases = { endpoint: 'url', outputProperty: 'returnProperty' };
56
- var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
57
- var _a, urlObj, data, returnProperty, headers, _b, url, headersObj, baseUrl, httpHeaders, shouldUseCache, result;
58
- var _c, _d, _e, _f;
59
- return __generator(this, function (_g) {
60
- switch (_g.label) {
61
- case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.url, expression.parameters, expression.returnProperty, expression.headers], config)];
62
- case 1:
63
- _a = (_g.sent()), urlObj = _a[0], data = _a[1], returnProperty = _a[2], headers = _a[3];
64
- _b = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null }, url = _b.url, headersObj = _b.headers;
65
- 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'] });
66
- baseUrl = (_c = config.options.baseEndpoint) !== null && _c !== void 0 ? _c : '';
67
- httpHeaders = __assign(__assign(__assign({}, (_d = config.options) === null || _d === void 0 ? void 0 : _d.headers), headersObj), headers);
68
- shouldUseCache = (_f = (_e = expression.useCache) !== null && _e !== void 0 ? _e : config.options.useCache) !== null && _f !== void 0 ? _f : true;
69
- return [4, config.cache.useCache(shouldUseCache, function (url, data, headers, returnProperty) { return __awaiter(void 0, void 0, void 0, function () {
70
- var response;
71
- return __generator(this, function (_a) {
72
- switch (_a.label) {
73
- case 0: return [4, (0, _operatorUtils_1.axiosRequest)({
74
- url: url,
75
- data: data,
76
- headers: headers,
77
- method: 'post',
78
- })];
79
- case 1:
80
- response = _a.sent();
81
- return [2, (0, _operatorUtils_1.extractAndSimplify)(response, returnProperty)];
82
- }
83
- });
84
- }); }, (0, _operatorUtils_1.isFullUrl)(url) ? url : (0, _operatorUtils_1.joinUrlParts)(baseUrl, url), data, httpHeaders, returnProperty)];
85
- case 2:
86
- result = _g.sent();
87
- return [2, result];
88
- }
89
- });
90
- }); };
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
+ });
91
37
  exports.POST = {
92
- requiredProperties: requiredProperties,
93
- operatorAliases: operatorAliases,
94
- propertyAliases: propertyAliases,
95
- evaluate: evaluate,
38
+ requiredProperties,
39
+ operatorAliases,
40
+ propertyAliases,
41
+ evaluate,
96
42
  parseChildren: getRequest_1.parseChildrenGET,
97
43
  };
@@ -1,15 +1,4 @@
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
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,40 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
9
  });
21
10
  };
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
11
  Object.defineProperty(exports, "__esModule", { value: true });
50
12
  exports.REGEX = void 0;
51
- var _operatorUtils_1 = require("./_operatorUtils");
52
- var helpers_1 = require("../helpers");
53
- var requiredProperties = ['testString', 'pattern'];
54
- var operatorAliases = ['regex', 'patternMatch', 'regexp', 'matchPattern'];
55
- var propertyAliases = {
13
+ const _operatorUtils_1 = require("./_operatorUtils");
14
+ const helpers_1 = require("../helpers");
15
+ const requiredProperties = ['testString', 'pattern'];
16
+ const operatorAliases = ['regex', 'patternMatch', 'regexp', 'matchPattern'];
17
+ const propertyAliases = {
56
18
  string: 'testString',
57
19
  value: 'testString',
58
20
  regex: 'pattern',
@@ -60,33 +22,25 @@ var propertyAliases = {
60
22
  regExp: 'pattern',
61
23
  re: 'pattern',
62
24
  };
63
- var evaluate = function (expression, config) { return __awaiter(void 0, void 0, void 0, function () {
64
- var _a, testString, pattern, re;
65
- return __generator(this, function (_b) {
66
- switch (_b.label) {
67
- case 0: return [4, (0, _operatorUtils_1.evaluateArray)([expression.testString, expression.pattern], config)];
68
- case 1:
69
- _a = (_b.sent()), testString = _a[0], pattern = _a[1];
70
- config.typeChecker({ name: 'testString', value: testString, expectedType: 'string' }, { name: 'pattern', value: pattern, expectedType: 'string' });
71
- try {
72
- re = new RegExp(pattern);
73
- return [2, re.test(testString)];
74
- }
75
- catch (err) {
76
- throw new Error('Regex error:' + (0, helpers_1.errorMessage)(err));
77
- }
78
- return [2];
79
- }
80
- });
81
- }); };
82
- var parseChildren = function (expression) {
83
- var _a = expression.children, testString = _a[0], pattern = _a[1];
84
- return __assign(__assign({}, expression), { testString: testString, pattern: pattern });
25
+ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const [testString, pattern] = (yield (0, _operatorUtils_1.evaluateArray)([expression.testString, expression.pattern], config));
27
+ config.typeChecker({ name: 'testString', value: testString, expectedType: 'string' }, { name: 'pattern', value: pattern, expectedType: 'string' });
28
+ try {
29
+ const re = new RegExp(pattern);
30
+ return re.test(testString);
31
+ }
32
+ catch (err) {
33
+ throw new Error('Regex error:' + (0, helpers_1.errorMessage)(err));
34
+ }
35
+ });
36
+ const parseChildren = (expression) => {
37
+ const [testString, pattern] = expression.children;
38
+ return Object.assign(Object.assign({}, expression), { testString, pattern });
85
39
  };
86
40
  exports.REGEX = {
87
- requiredProperties: requiredProperties,
88
- operatorAliases: operatorAliases,
89
- propertyAliases: propertyAliases,
90
- evaluate: evaluate,
91
- parseChildren: parseChildren,
41
+ requiredProperties,
42
+ operatorAliases,
43
+ propertyAliases,
44
+ evaluate,
45
+ parseChildren,
92
46
  };