fig-tree-evaluator 2.8.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.
- package/README.md +1 -0
- package/build/FigTreeEvaluator.d.ts +6 -16
- package/build/FigTreeEvaluator.js +8 -4
- package/build/cache.d.ts +3 -1
- package/build/cache.js +10 -11
- package/build/evaluate.js +3 -5
- package/build/helpers.d.ts +8 -34
- package/build/helpers.js +1 -10
- package/build/index.d.ts +2 -2
- package/build/operators/AND/data.d.ts +0 -1
- package/build/operators/AND/data.js +1 -2
- package/build/operators/AND/index.d.ts +1 -1
- package/build/operators/AND/operator.d.ts +2 -6
- package/build/operators/AND/operator.js +1 -2
- package/build/operators/BUILD_OBJECT/data.d.ts +0 -1
- package/build/operators/BUILD_OBJECT/data.js +1 -2
- package/build/operators/BUILD_OBJECT/operator.d.ts +1 -9
- package/build/operators/BUILD_OBJECT/operator.js +1 -2
- package/build/operators/CONDITIONAL/data.d.ts +0 -1
- package/build/operators/CONDITIONAL/data.js +1 -2
- package/build/operators/CONDITIONAL/operator.d.ts +1 -5
- package/build/operators/CONDITIONAL/operator.js +7 -2
- package/build/operators/COUNT/data.d.ts +0 -1
- package/build/operators/COUNT/data.js +1 -2
- package/build/operators/COUNT/operator.js +1 -2
- package/build/operators/CUSTOM_FUNCTIONS/data.d.ts +0 -1
- package/build/operators/CUSTOM_FUNCTIONS/data.js +9 -3
- package/build/operators/CUSTOM_FUNCTIONS/operator.d.ts +1 -7
- package/build/operators/CUSTOM_FUNCTIONS/operator.js +7 -6
- package/build/operators/DIVIDE/data.d.ts +0 -1
- package/build/operators/DIVIDE/data.js +2 -3
- package/build/operators/DIVIDE/operator.d.ts +1 -11
- package/build/operators/DIVIDE/operator.js +5 -4
- package/build/operators/EQUAL/data.d.ts +0 -1
- package/build/operators/EQUAL/data.js +1 -2
- package/build/operators/EQUAL/operator.js +1 -2
- package/build/operators/GET/data.d.ts +0 -1
- package/build/operators/GET/data.js +1 -2
- package/build/operators/GET/index.d.ts +1 -1
- package/build/operators/GET/operator.d.ts +2 -10
- package/build/operators/GET/operator.js +16 -14
- package/build/operators/GRAPHQL/data.d.ts +0 -1
- package/build/operators/GRAPHQL/data.js +1 -2
- package/build/operators/GRAPHQL/operator.d.ts +1 -10
- package/build/operators/GRAPHQL/operator.js +20 -9
- package/build/operators/GREATER_THAN/data.d.ts +0 -1
- package/build/operators/GREATER_THAN/data.js +1 -2
- package/build/operators/GREATER_THAN/operator.d.ts +0 -4
- package/build/operators/GREATER_THAN/operator.js +1 -2
- package/build/operators/LESS_THAN/data.d.ts +0 -1
- package/build/operators/LESS_THAN/data.js +1 -2
- package/build/operators/LESS_THAN/operator.js +1 -2
- package/build/operators/MATCH/data.d.ts +0 -1
- package/build/operators/MATCH/data.js +1 -2
- package/build/operators/MATCH/operator.d.ts +1 -5
- package/build/operators/MATCH/operator.js +12 -6
- package/build/operators/MULTIPLY/data.d.ts +0 -1
- package/build/operators/MULTIPLY/data.js +1 -2
- package/build/operators/MULTIPLY/operator.js +5 -2
- package/build/operators/NOT_EQUAL/data.d.ts +0 -1
- package/build/operators/NOT_EQUAL/data.js +1 -2
- package/build/operators/NOT_EQUAL/operator.js +1 -2
- package/build/operators/OBJECT_PROPERTIES/data.d.ts +0 -1
- package/build/operators/OBJECT_PROPERTIES/data.js +1 -2
- package/build/operators/OBJECT_PROPERTIES/operator.d.ts +1 -7
- package/build/operators/OBJECT_PROPERTIES/operator.js +1 -2
- package/build/operators/OR/data.d.ts +0 -1
- package/build/operators/OR/data.js +1 -2
- package/build/operators/OR/operator.js +1 -2
- package/build/operators/PASSTHRU/data.d.ts +0 -1
- package/build/operators/PASSTHRU/data.js +1 -2
- package/build/operators/PASSTHRU/operator.d.ts +1 -5
- package/build/operators/PASSTHRU/operator.js +2 -1
- package/build/operators/PG_SQL/data.d.ts +0 -1
- package/build/operators/PG_SQL/data.js +9 -3
- package/build/operators/PG_SQL/operator.d.ts +1 -23
- package/build/operators/PG_SQL/operator.js +22 -30
- package/build/operators/PLUS/data.d.ts +0 -1
- package/build/operators/PLUS/data.js +2 -3
- package/build/operators/PLUS/operator.d.ts +1 -8
- package/build/operators/PLUS/operator.js +5 -5
- package/build/operators/POST/data.d.ts +0 -1
- package/build/operators/POST/data.js +1 -2
- package/build/operators/POST/operator.js +14 -6
- package/build/operators/REGEX/data.d.ts +0 -1
- package/build/operators/REGEX/data.js +1 -2
- package/build/operators/REGEX/operator.d.ts +1 -5
- package/build/operators/REGEX/operator.js +1 -2
- package/build/operators/SPLIT/data.d.ts +0 -1
- package/build/operators/SPLIT/data.js +1 -2
- package/build/operators/SPLIT/operator.d.ts +1 -9
- package/build/operators/SPLIT/operator.js +1 -2
- package/build/operators/STRING_SUBSTITUTION/data.d.ts +0 -1
- package/build/operators/STRING_SUBSTITUTION/data.js +1 -2
- package/build/operators/STRING_SUBSTITUTION/operator.d.ts +1 -5
- package/build/operators/STRING_SUBSTITUTION/operator.js +5 -6
- package/build/operators/SUBTRACT/data.d.ts +0 -1
- package/build/operators/SUBTRACT/data.js +1 -2
- package/build/operators/SUBTRACT/operator.d.ts +1 -8
- package/build/operators/SUBTRACT/operator.js +4 -3
- package/build/operators/_operatorUtils.d.ts +16 -17
- package/build/operators/_operatorUtils.js +17 -17
- package/build/shorthandSyntax.js +1 -1
- package/build/typeCheck.d.ts +8 -4
- package/build/typeCheck.js +25 -20
- package/build/types.d.ts +32 -33
- package/build/version.d.ts +1 -0
- package/build/version.js +4 -0
- package/package.json +10 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Test multiple values are equal';
|
|
6
6
|
const aliases = ['=', 'eq', 'equal', 'equals'];
|
|
@@ -20,7 +20,6 @@ const parameters = [
|
|
|
20
20
|
type: 'boolean',
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
24
23
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
25
24
|
const operatorData = {
|
|
26
25
|
description,
|
|
@@ -40,7 +40,7 @@ const data_1 = __importStar(require("./data"));
|
|
|
40
40
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
41
|
var _a;
|
|
42
42
|
const [values, nullMatch] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config));
|
|
43
|
-
config.typeChecker(
|
|
43
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values, nullEqualsUndefined: nullMatch }));
|
|
44
44
|
const nullEqualsUndefined = nullMatch !== undefined
|
|
45
45
|
? nullMatch
|
|
46
46
|
: ((_a = config.options) === null || _a === void 0 ? void 0 : _a.nullEqualsUndefined) !== undefined
|
|
@@ -51,7 +51,6 @@ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, funct
|
|
|
51
51
|
return values.every((value) => (0, lite_1.dequal)(value, values[0]));
|
|
52
52
|
});
|
|
53
53
|
exports.EQUAL = {
|
|
54
|
-
requiredProperties: data_1.requiredProperties,
|
|
55
54
|
propertyAliases: data_1.propertyAliases,
|
|
56
55
|
operatorData: data_1.default,
|
|
57
56
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'HTTP GET Request';
|
|
6
6
|
const aliases = ['get', 'api'];
|
|
@@ -41,7 +41,6 @@ const parameters = [
|
|
|
41
41
|
type: 'boolean',
|
|
42
42
|
},
|
|
43
43
|
];
|
|
44
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
45
44
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
46
45
|
const operatorData = {
|
|
47
46
|
description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { GET
|
|
1
|
+
export { GET } from './operator';
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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>;
|
|
1
|
+
import { OperatorObject, ParseChildrenMethod } from '../../types';
|
|
2
|
+
export declare const parseChildrenGET: ParseChildrenMethod;
|
|
11
3
|
export declare const GET: OperatorObject;
|
|
@@ -36,7 +36,7 @@ exports.GET = exports.parseChildrenGET = void 0;
|
|
|
36
36
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
37
37
|
const data_1 = __importStar(require("./data"));
|
|
38
38
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
var _a, _b, _c
|
|
39
|
+
var _a, _b, _c;
|
|
40
40
|
const [urlObj, parameters, returnProperty, headers, useCache] = (yield (0, _operatorUtils_1.evaluateArray)([
|
|
41
41
|
expression.url,
|
|
42
42
|
expression.parameters,
|
|
@@ -45,20 +45,23 @@ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, funct
|
|
|
45
45
|
expression.useCache,
|
|
46
46
|
], config));
|
|
47
47
|
const { url, headers: headersObj } = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null };
|
|
48
|
-
config.typeChecker(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
config.typeChecker([
|
|
49
|
+
...(0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, {
|
|
50
|
+
url,
|
|
51
|
+
returnProperty,
|
|
52
|
+
headers,
|
|
53
|
+
parameters,
|
|
54
|
+
useCache,
|
|
55
|
+
}),
|
|
56
|
+
{
|
|
57
|
+
name: 'headers',
|
|
58
|
+
value: headersObj,
|
|
59
|
+
expectedType: ['object', 'null'],
|
|
60
|
+
},
|
|
61
|
+
]);
|
|
59
62
|
const baseUrl = (_a = config.options.baseEndpoint) !== null && _a !== void 0 ? _a : '';
|
|
60
63
|
const httpHeaders = Object.assign(Object.assign(Object.assign({}, (_b = config.options) === null || _b === void 0 ? void 0 : _b.headers), headersObj), headers);
|
|
61
|
-
const shouldUseCache = (
|
|
64
|
+
const shouldUseCache = (_c = useCache !== null && useCache !== void 0 ? useCache : config.options.useCache) !== null && _c !== void 0 ? _c : true;
|
|
62
65
|
const result = yield config.cache.useCache(shouldUseCache, (url, params, headers, returnProperty) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
66
|
const response = yield (0, _operatorUtils_1.axiosRequest)({
|
|
64
67
|
url,
|
|
@@ -81,7 +84,6 @@ const parseChildren = (expression, config) => __awaiter(void 0, void 0, void 0,
|
|
|
81
84
|
});
|
|
82
85
|
exports.parseChildrenGET = parseChildren;
|
|
83
86
|
exports.GET = {
|
|
84
|
-
requiredProperties: data_1.requiredProperties,
|
|
85
87
|
propertyAliases: data_1.propertyAliases,
|
|
86
88
|
operatorData: data_1.default,
|
|
87
89
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'GraphQL request';
|
|
6
6
|
const aliases = ['graphQl', 'graphql', 'gql'];
|
|
@@ -48,7 +48,6 @@ const parameters = [
|
|
|
48
48
|
type: 'boolean',
|
|
49
49
|
},
|
|
50
50
|
];
|
|
51
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
52
51
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
53
52
|
const operatorData = {
|
|
54
53
|
description,
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requiredProperties } from './data';
|
|
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
|
-
};
|
|
1
|
+
import { OperatorObject } from '../../types';
|
|
11
2
|
export interface GraphQLConnection {
|
|
12
3
|
endpoint: string;
|
|
13
4
|
headers?: {
|
|
@@ -36,38 +36,49 @@ exports.GRAPHQL = void 0;
|
|
|
36
36
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
37
37
|
const data_1 = __importStar(require("./data"));
|
|
38
38
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
var _a, _b, _c, _d, _e, _f
|
|
40
|
-
const [query, urlObj, variables, returnNode, headers] = (yield (0, _operatorUtils_1.evaluateArray)([
|
|
39
|
+
var _a, _b, _c, _d, _e, _f;
|
|
40
|
+
const [query, urlObj, variables, returnNode, headers, useCache] = (yield (0, _operatorUtils_1.evaluateArray)([
|
|
41
41
|
expression.query,
|
|
42
42
|
expression.url,
|
|
43
43
|
expression.variables,
|
|
44
44
|
expression.returnNode,
|
|
45
45
|
expression.headers,
|
|
46
|
+
expression.useCache,
|
|
46
47
|
], config));
|
|
47
48
|
const { url, headers: headersObj } = urlObj instanceof Object ? urlObj : { url: urlObj, headers: null };
|
|
48
|
-
config.typeChecker(
|
|
49
|
+
config.typeChecker([
|
|
50
|
+
...(0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, {
|
|
51
|
+
url,
|
|
52
|
+
query,
|
|
53
|
+
variables,
|
|
54
|
+
returnNode,
|
|
55
|
+
headers,
|
|
56
|
+
useCache,
|
|
57
|
+
}),
|
|
58
|
+
{ name: 'headers', value: headersObj, expectedType: ['object', 'null'] },
|
|
59
|
+
]);
|
|
49
60
|
const endpoint = !url || url.toLowerCase() === 'graphqlendpoint' ? '' : url;
|
|
50
61
|
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 : '';
|
|
51
62
|
const fullUrl = (0, _operatorUtils_1.isFullUrl)(endpoint) ? endpoint : (0, _operatorUtils_1.joinUrlParts)(baseEndpoint, endpoint);
|
|
52
63
|
const data = { query, variables };
|
|
53
|
-
const shouldUseCache = (
|
|
64
|
+
const shouldUseCache = (_d = useCache !== null && useCache !== void 0 ? useCache : config.options.useCache) !== null && _d !== void 0 ? _d : true;
|
|
54
65
|
const result = yield config.cache.useCache(shouldUseCache, (url, data, headers, returnNode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
66
|
const response = yield (0, _operatorUtils_1.axiosRequest)({ url, method: 'post', data, headers });
|
|
56
67
|
return (0, _operatorUtils_1.extractAndSimplify)(response.data, returnNode);
|
|
57
|
-
}), fullUrl, data, Object.assign(Object.assign(Object.assign(Object.assign({}, (
|
|
68
|
+
}), fullUrl, data, Object.assign(Object.assign(Object.assign(Object.assign({}, (_e = config.options.graphQLConnection) === null || _e === void 0 ? void 0 : _e.headers), (_f = config.options) === null || _f === void 0 ? void 0 : _f.headers), headersObj), headers), returnNode);
|
|
58
69
|
return result;
|
|
59
70
|
});
|
|
60
71
|
const parseChildren = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
72
|
const [query, url = '', fieldNames, ...rest] = (yield (0, _operatorUtils_1.evaluateArray)(expression.children, config));
|
|
62
|
-
const
|
|
63
|
-
const
|
|
73
|
+
const fieldKeys = Array.isArray(fieldNames) ? fieldNames : [fieldNames];
|
|
74
|
+
const values = rest.slice(0, fieldKeys.length);
|
|
75
|
+
const variables = (0, _operatorUtils_1.zipArraysToObject)(fieldKeys, values);
|
|
64
76
|
const output = Object.assign(Object.assign({}, expression), { query, url, variables });
|
|
65
|
-
if (rest.length >
|
|
77
|
+
if (rest.length > fieldKeys.length)
|
|
66
78
|
output.returnNode = rest.pop();
|
|
67
79
|
return output;
|
|
68
80
|
});
|
|
69
81
|
exports.GRAPHQL = {
|
|
70
|
-
requiredProperties: data_1.requiredProperties,
|
|
71
82
|
propertyAliases: data_1.propertyAliases,
|
|
72
83
|
operatorData: data_1.default,
|
|
73
84
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Test if a value is greater than (or equal to) another value';
|
|
6
6
|
const aliases = ['>', 'greaterThan', 'higher', 'larger'];
|
|
@@ -20,7 +20,6 @@ const parameters = [
|
|
|
20
20
|
type: 'boolean',
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
24
23
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
25
24
|
const operatorData = {
|
|
26
25
|
description,
|
|
@@ -38,7 +38,7 @@ const _operatorUtils_1 = require("../_operatorUtils");
|
|
|
38
38
|
const data_1 = __importStar(require("./data"));
|
|
39
39
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const [values, strict = true] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.strict], config));
|
|
41
|
-
config.typeChecker(
|
|
41
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values, strict }));
|
|
42
42
|
if (values.length < 2)
|
|
43
43
|
throw new Error('- Not enough values provided');
|
|
44
44
|
const [first, second] = values;
|
|
@@ -47,7 +47,6 @@ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, funct
|
|
|
47
47
|
return first > second;
|
|
48
48
|
});
|
|
49
49
|
exports.GREATER_THAN = {
|
|
50
|
-
requiredProperties: data_1.requiredProperties,
|
|
51
50
|
propertyAliases: data_1.propertyAliases,
|
|
52
51
|
operatorData: data_1.default,
|
|
53
52
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Test if a value is smaller than (or equal to) another value';
|
|
6
6
|
const aliases = ['<', 'lessThan', 'lower', 'smaller'];
|
|
@@ -20,7 +20,6 @@ const parameters = [
|
|
|
20
20
|
type: 'boolean',
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
24
23
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
25
24
|
const operatorData = {
|
|
26
25
|
description,
|
|
@@ -38,7 +38,7 @@ const _operatorUtils_1 = require("../_operatorUtils");
|
|
|
38
38
|
const data_1 = __importStar(require("./data"));
|
|
39
39
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const [values, strict = true] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.strict], config));
|
|
41
|
-
config.typeChecker(
|
|
41
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values, strict }));
|
|
42
42
|
if (values.length < 2)
|
|
43
43
|
throw new Error('- Not enough values provided');
|
|
44
44
|
const [first, second] = values;
|
|
@@ -47,7 +47,6 @@ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, funct
|
|
|
47
47
|
return first < second;
|
|
48
48
|
});
|
|
49
49
|
exports.LESS_THAN = {
|
|
50
|
-
requiredProperties: data_1.requiredProperties,
|
|
51
50
|
propertyAliases: data_1.propertyAliases,
|
|
52
51
|
operatorData: data_1.default,
|
|
53
52
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Return different values depending on a matching expression';
|
|
6
6
|
const aliases = ['match', 'switch'];
|
|
@@ -20,7 +20,6 @@ const parameters = [
|
|
|
20
20
|
type: ['object', 'array'],
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
24
23
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
25
24
|
const operatorData = {
|
|
26
25
|
description,
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requiredProperties } from './data';
|
|
3
|
-
export type MatchNode = {
|
|
4
|
-
[key in typeof requiredProperties[number]]: EvaluatorNode;
|
|
5
|
-
} & BaseOperatorNode;
|
|
1
|
+
import { OperatorObject } from '../../types';
|
|
6
2
|
export declare const MATCH: OperatorObject;
|
|
@@ -38,12 +38,19 @@ const evaluate_1 = require("../../evaluate");
|
|
|
38
38
|
const helpers_1 = require("../../helpers");
|
|
39
39
|
const data_1 = __importStar(require("./data"));
|
|
40
40
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
var _a;
|
|
41
42
|
const matchExpression = (yield (0, evaluate_1.evaluatorFunction)(expression.matchExpression, config));
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
config.typeChecker({
|
|
44
|
+
name: 'matchExpression',
|
|
45
|
+
value: matchExpression,
|
|
46
|
+
expectedType: ['string', 'number', 'boolean'],
|
|
47
|
+
});
|
|
48
|
+
const branches = Array.isArray(expression.branches)
|
|
49
|
+
? (0, _operatorUtils_1.singleArrayToObject)(expression.branches)
|
|
50
|
+
: (_a = expression.branches) !== null && _a !== void 0 ? _a : {};
|
|
51
|
+
const branchObject = ((0, helpers_1.isOperatorNode)(branches) ? yield (0, evaluate_1.evaluatorFunction)(branches, config) : branches);
|
|
52
|
+
if (!(0, helpers_1.isObject)(branchObject))
|
|
53
|
+
throw new Error("Branches don't evaluate to an object");
|
|
47
54
|
if (matchExpression in branchObject)
|
|
48
55
|
return yield (0, evaluate_1.evaluatorFunction)(branchObject[matchExpression], config);
|
|
49
56
|
if ('fallback' in branchObject)
|
|
@@ -58,7 +65,6 @@ const parseChildren = (expression, config) => __awaiter(void 0, void 0, void 0,
|
|
|
58
65
|
return Object.assign(Object.assign({}, expression), { matchExpression, branches });
|
|
59
66
|
});
|
|
60
67
|
exports.MATCH = {
|
|
61
|
-
requiredProperties: data_1.requiredProperties,
|
|
62
68
|
propertyAliases: data_1.propertyAliases,
|
|
63
69
|
operatorData: data_1.default,
|
|
64
70
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Multiply several numerical values together';
|
|
6
6
|
const aliases = ['*', 'x', 'multiply', 'times'];
|
|
@@ -13,7 +13,6 @@ const parameters = [
|
|
|
13
13
|
type: 'array',
|
|
14
14
|
},
|
|
15
15
|
];
|
|
16
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
17
16
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
18
17
|
const operatorData = {
|
|
19
18
|
description,
|
|
@@ -38,11 +38,14 @@ const _operatorUtils_1 = require("../_operatorUtils");
|
|
|
38
38
|
const data_1 = __importStar(require("./data"));
|
|
39
39
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
|
|
41
|
-
config.typeChecker(
|
|
41
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values }));
|
|
42
|
+
if (values.length === 0)
|
|
43
|
+
return 0;
|
|
44
|
+
if (values.some((e) => typeof e !== 'number'))
|
|
45
|
+
throw new Error('- Not all values are numbers');
|
|
42
46
|
return values.reduce((acc, number) => acc * number);
|
|
43
47
|
});
|
|
44
48
|
exports.MULTIPLY = {
|
|
45
|
-
requiredProperties: data_1.requiredProperties,
|
|
46
49
|
propertyAliases: data_1.propertyAliases,
|
|
47
50
|
operatorData: data_1.default,
|
|
48
51
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Test if any values are different';
|
|
6
6
|
const aliases = ['!=', '!', 'ne', 'notEqual'];
|
|
@@ -20,7 +20,6 @@ const parameters = [
|
|
|
20
20
|
type: 'boolean',
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
24
23
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
25
24
|
const operatorData = {
|
|
26
25
|
description,
|
|
@@ -40,7 +40,7 @@ const data_1 = __importStar(require("./data"));
|
|
|
40
40
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
41
|
var _a;
|
|
42
42
|
const [values, nullMatch] = (yield (0, _operatorUtils_1.evaluateArray)([expression.values, expression.nullEqualsUndefined], config));
|
|
43
|
-
config.typeChecker(
|
|
43
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values, nullEqualsUndefined: nullMatch }));
|
|
44
44
|
const nullEqualsUndefined = nullMatch !== undefined
|
|
45
45
|
? nullMatch
|
|
46
46
|
: ((_a = config.options) === null || _a === void 0 ? void 0 : _a.nullEqualsUndefined) !== undefined
|
|
@@ -51,7 +51,6 @@ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, funct
|
|
|
51
51
|
return values.some((val) => !(0, lite_1.dequal)(val, values[0]));
|
|
52
52
|
});
|
|
53
53
|
exports.NOT_EQUAL = {
|
|
54
|
-
requiredProperties: data_1.requiredProperties,
|
|
55
54
|
propertyAliases: data_1.propertyAliases,
|
|
56
55
|
operatorData: data_1.default,
|
|
57
56
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Extract values from data objects';
|
|
6
6
|
const aliases = [
|
|
@@ -28,7 +28,6 @@ const parameters = [
|
|
|
28
28
|
type: 'object',
|
|
29
29
|
},
|
|
30
30
|
];
|
|
31
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
32
31
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
33
32
|
const operatorData = {
|
|
34
33
|
description,
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { requiredProperties } from './data';
|
|
3
|
-
export type ObjPropNode = {
|
|
4
|
-
[key in typeof requiredProperties[number]]: EvaluatorNode;
|
|
5
|
-
} & BaseOperatorNode & {
|
|
6
|
-
additionalData: object;
|
|
7
|
-
};
|
|
1
|
+
import { OperatorObject } from '../../types';
|
|
8
2
|
export declare const OBJECT_PROPERTIES: OperatorObject;
|
|
@@ -42,7 +42,7 @@ const data_1 = __importStar(require("./data"));
|
|
|
42
42
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
43
|
var _a, _b, _c, _d;
|
|
44
44
|
const [property, additionalData] = (yield (0, _operatorUtils_1.evaluateArray)([expression.property, expression.additionalData], config));
|
|
45
|
-
config.typeChecker(
|
|
45
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { property, additionalData }));
|
|
46
46
|
const inputObject = additionalData
|
|
47
47
|
? Object.assign(Object.assign({}, ((_b = (_a = config.options) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {})), additionalData) : (_d = (_c = config.options) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : {};
|
|
48
48
|
return (0, object_property_extractor_1.default)(inputObject, property);
|
|
@@ -55,7 +55,6 @@ const parseChildren = (expression) => {
|
|
|
55
55
|
return returnValue;
|
|
56
56
|
};
|
|
57
57
|
exports.OBJECT_PROPERTIES = {
|
|
58
|
-
requiredProperties: data_1.requiredProperties,
|
|
59
58
|
propertyAliases: data_1.propertyAliases,
|
|
60
59
|
operatorData: data_1.default,
|
|
61
60
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Logical OR';
|
|
6
6
|
const aliases = ['or', '|', '||'];
|
|
@@ -13,7 +13,6 @@ const parameters = [
|
|
|
13
13
|
type: 'array',
|
|
14
14
|
},
|
|
15
15
|
];
|
|
16
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
17
16
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
18
17
|
const operatorData = {
|
|
19
18
|
description,
|
|
@@ -38,11 +38,10 @@ const _operatorUtils_1 = require("../_operatorUtils");
|
|
|
38
38
|
const data_1 = __importStar(require("./data"));
|
|
39
39
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
|
|
41
|
-
config.typeChecker(
|
|
41
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values }));
|
|
42
42
|
return values.reduce((acc, val) => acc || !!val, false);
|
|
43
43
|
});
|
|
44
44
|
exports.OR = {
|
|
45
|
-
requiredProperties: data_1.requiredProperties,
|
|
46
45
|
propertyAliases: data_1.propertyAliases,
|
|
47
46
|
operatorData: data_1.default,
|
|
48
47
|
evaluate,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.propertyAliases =
|
|
3
|
+
exports.propertyAliases = void 0;
|
|
4
4
|
const _operatorUtils_1 = require("../_operatorUtils");
|
|
5
5
|
const description = 'Pass through a value unchanged (or change its type)';
|
|
6
6
|
const aliases = ['_', 'passThru', 'passthru', 'pass', 'ignore', 'coerce', 'convert'];
|
|
@@ -13,7 +13,6 @@ const parameters = [
|
|
|
13
13
|
type: 'any',
|
|
14
14
|
},
|
|
15
15
|
];
|
|
16
|
-
exports.requiredProperties = (0, _operatorUtils_1.getRequiredProperties)(parameters);
|
|
17
16
|
exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
|
|
18
17
|
const operatorData = {
|
|
19
18
|
description,
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import { OperatorObject
|
|
2
|
-
import { requiredProperties } from './data';
|
|
3
|
-
export type PassThruNode = {
|
|
4
|
-
[key in typeof requiredProperties[number]]: EvaluatorNode;
|
|
5
|
-
} & BaseOperatorNode;
|
|
1
|
+
import { OperatorObject } from '../../types';
|
|
6
2
|
export declare const PASSTHRU: OperatorObject;
|
|
@@ -34,8 +34,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.PASSTHRU = void 0;
|
|
36
36
|
const evaluate_1 = require("../../evaluate");
|
|
37
|
+
const _operatorUtils_1 = require("../_operatorUtils");
|
|
37
38
|
const data_1 = __importStar(require("./data"));
|
|
38
39
|
const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { value: expression.value }));
|
|
39
41
|
return yield (0, evaluate_1.evaluatorFunction)(expression.value, config);
|
|
40
42
|
});
|
|
41
43
|
const parseChildren = (expression) => {
|
|
@@ -44,7 +46,6 @@ const parseChildren = (expression) => {
|
|
|
44
46
|
return Object.assign(Object.assign({}, expression), { value });
|
|
45
47
|
};
|
|
46
48
|
exports.PASSTHRU = {
|
|
47
|
-
requiredProperties: data_1.requiredProperties,
|
|
48
49
|
propertyAliases: data_1.propertyAliases,
|
|
49
50
|
operatorData: data_1.default,
|
|
50
51
|
evaluate,
|