fig-tree-evaluator 2.7.0 → 2.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/README.md +195 -12
  2. package/build/FigTreeEvaluator.d.ts +10 -2
  3. package/build/FigTreeEvaluator.js +25 -4
  4. package/build/cache.d.ts +3 -1
  5. package/build/cache.js +10 -11
  6. package/build/evaluate.js +18 -14
  7. package/build/helpers.d.ts +9 -34
  8. package/build/helpers.js +5 -13
  9. package/build/index.d.ts +2 -2
  10. package/build/operators/AND/data.d.ts +4 -0
  11. package/build/operators/AND/data.js +22 -0
  12. package/build/operators/AND/index.d.ts +1 -0
  13. package/build/operators/AND/index.js +5 -0
  14. package/build/operators/AND/operator.d.ts +3 -0
  15. package/build/operators/{logicalAnd.js → AND/operator.js} +28 -8
  16. package/build/operators/BUILD_OBJECT/data.d.ts +4 -0
  17. package/build/operators/BUILD_OBJECT/data.js +22 -0
  18. package/build/operators/BUILD_OBJECT/index.d.ts +1 -0
  19. package/build/operators/BUILD_OBJECT/index.js +17 -0
  20. package/build/operators/BUILD_OBJECT/operator.d.ts +2 -0
  21. package/build/operators/{buildObject.js → BUILD_OBJECT/operator.js} +28 -12
  22. package/build/operators/CONDITIONAL/data.d.ts +4 -0
  23. package/build/operators/CONDITIONAL/data.js +36 -0
  24. package/build/operators/CONDITIONAL/index.d.ts +1 -0
  25. package/build/operators/CONDITIONAL/index.js +17 -0
  26. package/build/operators/CONDITIONAL/operator.d.ts +2 -0
  27. package/build/operators/CONDITIONAL/operator.js +59 -0
  28. package/build/operators/COUNT/data.d.ts +4 -0
  29. package/build/operators/COUNT/data.js +22 -0
  30. package/build/operators/COUNT/index.d.ts +1 -0
  31. package/build/operators/COUNT/index.js +17 -0
  32. package/build/operators/COUNT/operator.d.ts +2 -0
  33. package/build/operators/COUNT/operator.js +49 -0
  34. package/build/operators/CUSTOM_FUNCTIONS/data.d.ts +4 -0
  35. package/build/operators/CUSTOM_FUNCTIONS/data.js +43 -0
  36. package/build/operators/CUSTOM_FUNCTIONS/index.d.ts +1 -0
  37. package/build/operators/CUSTOM_FUNCTIONS/index.js +17 -0
  38. package/build/operators/CUSTOM_FUNCTIONS/operator.d.ts +2 -0
  39. package/build/operators/CUSTOM_FUNCTIONS/operator.js +65 -0
  40. package/build/operators/DIVIDE/data.d.ts +4 -0
  41. package/build/operators/DIVIDE/data.js +43 -0
  42. package/build/operators/DIVIDE/index.d.ts +1 -0
  43. package/build/operators/DIVIDE/index.js +17 -0
  44. package/build/operators/DIVIDE/operator.d.ts +2 -0
  45. package/build/operators/DIVIDE/operator.js +63 -0
  46. package/build/operators/EQUAL/data.d.ts +4 -0
  47. package/build/operators/EQUAL/data.js +29 -0
  48. package/build/operators/EQUAL/index.d.ts +1 -0
  49. package/build/operators/EQUAL/index.js +17 -0
  50. package/build/operators/EQUAL/operator.d.ts +2 -0
  51. package/build/operators/{equal.js → EQUAL/operator.js} +30 -10
  52. package/build/operators/GET/data.d.ts +4 -0
  53. package/build/operators/GET/data.js +50 -0
  54. package/build/operators/GET/index.d.ts +1 -0
  55. package/build/operators/GET/index.js +5 -0
  56. package/build/operators/GET/operator.d.ts +3 -0
  57. package/build/operators/GET/operator.js +91 -0
  58. package/build/operators/GRAPHQL/data.d.ts +4 -0
  59. package/build/operators/GRAPHQL/data.js +57 -0
  60. package/build/operators/GRAPHQL/index.d.ts +1 -0
  61. package/build/operators/GRAPHQL/index.js +17 -0
  62. package/build/operators/GRAPHQL/operator.d.ts +8 -0
  63. package/build/operators/{graphQL.js → GRAPHQL/operator.js} +47 -15
  64. package/build/operators/GREATER_THAN/data.d.ts +4 -0
  65. package/build/operators/GREATER_THAN/data.js +29 -0
  66. package/build/operators/GREATER_THAN/index.d.ts +1 -0
  67. package/build/operators/GREATER_THAN/index.js +17 -0
  68. package/build/operators/GREATER_THAN/operator.d.ts +2 -0
  69. package/build/operators/GREATER_THAN/operator.js +54 -0
  70. package/build/operators/LESS_THAN/data.d.ts +4 -0
  71. package/build/operators/LESS_THAN/data.js +29 -0
  72. package/build/operators/LESS_THAN/index.d.ts +1 -0
  73. package/build/operators/LESS_THAN/index.js +17 -0
  74. package/build/operators/{lessThan.d.ts → LESS_THAN/operator.d.ts} +1 -1
  75. package/build/operators/LESS_THAN/operator.js +54 -0
  76. package/build/operators/MATCH/data.d.ts +4 -0
  77. package/build/operators/MATCH/data.js +29 -0
  78. package/build/operators/MATCH/index.d.ts +1 -0
  79. package/build/operators/MATCH/index.js +17 -0
  80. package/build/operators/MATCH/operator.d.ts +2 -0
  81. package/build/operators/{match.js → MATCH/operator.js} +36 -17
  82. package/build/operators/MULTIPLY/data.d.ts +4 -0
  83. package/build/operators/MULTIPLY/data.js +22 -0
  84. package/build/operators/MULTIPLY/index.d.ts +1 -0
  85. package/build/operators/MULTIPLY/index.js +17 -0
  86. package/build/operators/{multiply.d.ts → MULTIPLY/operator.d.ts} +1 -1
  87. package/build/operators/MULTIPLY/operator.js +53 -0
  88. package/build/operators/NOT_EQUAL/data.d.ts +4 -0
  89. package/build/operators/NOT_EQUAL/data.js +29 -0
  90. package/build/operators/NOT_EQUAL/index.d.ts +1 -0
  91. package/build/operators/NOT_EQUAL/index.js +17 -0
  92. package/build/operators/{notEqual.d.ts → NOT_EQUAL/operator.d.ts} +1 -1
  93. package/build/operators/{notEqual.js → NOT_EQUAL/operator.js} +30 -10
  94. package/build/operators/OBJECT_PROPERTIES/data.d.ts +4 -0
  95. package/build/operators/OBJECT_PROPERTIES/data.js +37 -0
  96. package/build/operators/OBJECT_PROPERTIES/index.d.ts +1 -0
  97. package/build/operators/OBJECT_PROPERTIES/index.js +17 -0
  98. package/build/operators/OBJECT_PROPERTIES/operator.d.ts +2 -0
  99. package/build/operators/{objectProperties.js → OBJECT_PROPERTIES/operator.js} +32 -24
  100. package/build/operators/OR/data.d.ts +4 -0
  101. package/build/operators/OR/data.js +22 -0
  102. package/build/operators/OR/index.d.ts +1 -0
  103. package/build/operators/OR/index.js +17 -0
  104. package/build/operators/OR/operator.d.ts +2 -0
  105. package/build/operators/OR/operator.js +49 -0
  106. package/build/operators/PASSTHRU/data.d.ts +4 -0
  107. package/build/operators/PASSTHRU/data.js +22 -0
  108. package/build/operators/PASSTHRU/index.d.ts +1 -0
  109. package/build/operators/PASSTHRU/index.js +17 -0
  110. package/build/operators/PASSTHRU/operator.d.ts +2 -0
  111. package/build/operators/PASSTHRU/operator.js +53 -0
  112. package/build/operators/PG_SQL/data.d.ts +4 -0
  113. package/build/operators/PG_SQL/data.js +43 -0
  114. package/build/operators/PG_SQL/index.d.ts +1 -0
  115. package/build/operators/PG_SQL/index.js +17 -0
  116. package/build/operators/PG_SQL/operator.d.ts +2 -0
  117. package/build/operators/PG_SQL/operator.js +83 -0
  118. package/build/operators/PLUS/data.d.ts +4 -0
  119. package/build/operators/PLUS/data.js +29 -0
  120. package/build/operators/PLUS/index.d.ts +1 -0
  121. package/build/operators/PLUS/index.js +17 -0
  122. package/build/operators/PLUS/operator.d.ts +2 -0
  123. package/build/operators/{plus.js → PLUS/operator.js} +37 -13
  124. package/build/operators/POST/data.d.ts +4 -0
  125. package/build/operators/POST/data.js +50 -0
  126. package/build/operators/POST/index.d.ts +1 -0
  127. package/build/operators/POST/index.js +17 -0
  128. package/build/operators/POST/operator.d.ts +2 -0
  129. package/build/operators/POST/operator.js +72 -0
  130. package/build/operators/REGEX/data.d.ts +4 -0
  131. package/build/operators/REGEX/data.js +29 -0
  132. package/build/operators/REGEX/index.d.ts +1 -0
  133. package/build/operators/REGEX/index.js +17 -0
  134. package/build/operators/REGEX/operator.d.ts +2 -0
  135. package/build/operators/{regex.js → REGEX/operator.js} +29 -16
  136. package/build/operators/SPLIT/data.d.ts +4 -0
  137. package/build/operators/SPLIT/data.js +43 -0
  138. package/build/operators/SPLIT/index.d.ts +1 -0
  139. package/build/operators/SPLIT/index.js +17 -0
  140. package/build/operators/SPLIT/operator.d.ts +2 -0
  141. package/build/operators/{split.js → SPLIT/operator.js} +33 -15
  142. package/build/operators/STRING_SUBSTITUTION/data.d.ts +4 -0
  143. package/build/operators/STRING_SUBSTITUTION/data.js +29 -0
  144. package/build/operators/STRING_SUBSTITUTION/index.d.ts +1 -0
  145. package/build/operators/STRING_SUBSTITUTION/index.js +17 -0
  146. package/build/operators/STRING_SUBSTITUTION/operator.d.ts +2 -0
  147. package/build/operators/STRING_SUBSTITUTION/operator.js +59 -0
  148. package/build/operators/SUBTRACT/data.d.ts +4 -0
  149. package/build/operators/SUBTRACT/data.js +36 -0
  150. package/build/operators/SUBTRACT/index.d.ts +1 -0
  151. package/build/operators/SUBTRACT/index.js +17 -0
  152. package/build/operators/SUBTRACT/operator.d.ts +2 -0
  153. package/build/operators/SUBTRACT/operator.js +54 -0
  154. package/build/operators/_operatorAliases.json +1 -0
  155. package/build/operators/_operatorUtils.d.ts +19 -12
  156. package/build/operators/_operatorUtils.js +33 -15
  157. package/build/operators/index.d.ts +24 -24
  158. package/build/operators/index.js +24 -27
  159. package/build/shorthandSyntax.d.ts +2 -0
  160. package/build/shorthandSyntax.js +55 -0
  161. package/build/typeCheck.d.ts +8 -4
  162. package/build/typeCheck.js +25 -19
  163. package/build/types.d.ts +51 -34
  164. package/build/version.d.ts +1 -0
  165. package/build/version.js +4 -0
  166. package/package.json +10 -3
  167. package/build/operators/buildObject.d.ts +0 -11
  168. package/build/operators/conditional.d.ts +0 -7
  169. package/build/operators/conditional.js +0 -33
  170. package/build/operators/count.d.ts +0 -2
  171. package/build/operators/count.js +0 -29
  172. package/build/operators/customFunctions.d.ts +0 -9
  173. package/build/operators/customFunctions.js +0 -57
  174. package/build/operators/divide.d.ts +0 -12
  175. package/build/operators/divide.js +0 -41
  176. package/build/operators/equal.d.ts +0 -2
  177. package/build/operators/getRequest.d.ts +0 -12
  178. package/build/operators/getRequest.js +0 -51
  179. package/build/operators/graphQL.d.ts +0 -18
  180. package/build/operators/greaterThan.d.ts +0 -6
  181. package/build/operators/greaterThan.js +0 -35
  182. package/build/operators/lessThan.js +0 -35
  183. package/build/operators/logicalAnd.d.ts +0 -8
  184. package/build/operators/logicalOr.d.ts +0 -2
  185. package/build/operators/logicalOr.js +0 -29
  186. package/build/operators/match.d.ts +0 -7
  187. package/build/operators/multiply.js +0 -29
  188. package/build/operators/objectProperties.d.ts +0 -9
  189. package/build/operators/passThru.d.ts +0 -7
  190. package/build/operators/passThru.js +0 -30
  191. package/build/operators/pgSQL.d.ts +0 -24
  192. package/build/operators/pgSQL.js +0 -70
  193. package/build/operators/plus.d.ts +0 -10
  194. package/build/operators/postRequest.d.ts +0 -2
  195. package/build/operators/postRequest.js +0 -43
  196. package/build/operators/regex.d.ts +0 -7
  197. package/build/operators/split.d.ts +0 -11
  198. package/build/operators/stringSubstitution.d.ts +0 -7
  199. package/build/operators/stringSubstitution.js +0 -40
  200. package/build/operators/subtract.d.ts +0 -9
  201. package/build/operators/subtract.js +0 -32
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyAliases = void 0;
4
+ const _operatorUtils_1 = require("../_operatorUtils");
5
+ const description = 'Logical AND';
6
+ const aliases = ['and', '&', '&&'];
7
+ const parameters = [
8
+ {
9
+ name: 'values',
10
+ description: 'Returns true if all values are true',
11
+ aliases: [],
12
+ required: true,
13
+ type: 'array',
14
+ },
15
+ ];
16
+ exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
17
+ const operatorData = {
18
+ description,
19
+ aliases,
20
+ parameters,
21
+ };
22
+ exports.default = operatorData;
@@ -0,0 +1 @@
1
+ export { AND } from './operator';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AND = void 0;
4
+ var operator_1 = require("./operator");
5
+ Object.defineProperty(exports, "AND", { enumerable: true, get: function () { return operator_1.AND; } });
@@ -0,0 +1,3 @@
1
+ import { OperatorObject, ParseChildrenMethod } from '../../types';
2
+ export declare const parseChildren: ParseChildrenMethod;
3
+ export declare const AND: OperatorObject;
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -10,13 +33,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
33
  };
11
34
  Object.defineProperty(exports, "__esModule", { value: true });
12
35
  exports.AND = exports.parseChildren = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const requiredProperties = ['values'];
15
- const operatorAliases = ['and', '&', '&&'];
16
- const propertyAliases = {};
36
+ const _operatorUtils_1 = require("../_operatorUtils");
37
+ const data_1 = __importStar(require("./data"));
17
38
  const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
18
39
  const values = (yield (0, _operatorUtils_1.evaluateArray)(expression.values, config));
19
- config.typeChecker({ name: 'values', value: values, expectedType: 'array' });
40
+ config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values }));
20
41
  return values.reduce((acc, val) => acc && !!val, true);
21
42
  });
22
43
  const parseChildren = (expression) => {
@@ -25,9 +46,8 @@ const parseChildren = (expression) => {
25
46
  };
26
47
  exports.parseChildren = parseChildren;
27
48
  exports.AND = {
28
- requiredProperties,
29
- operatorAliases,
30
- propertyAliases,
49
+ propertyAliases: data_1.propertyAliases,
50
+ operatorData: data_1.default,
31
51
  evaluate,
32
52
  parseChildren: exports.parseChildren,
33
53
  };
@@ -0,0 +1,4 @@
1
+ import { OperatorData } from '../../types';
2
+ export declare const propertyAliases: Record<string, string>;
3
+ declare const operatorData: OperatorData;
4
+ export default operatorData;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyAliases = void 0;
4
+ const _operatorUtils_1 = require("../_operatorUtils");
5
+ const aliases = ['buildObject', 'build', 'object'];
6
+ const description = 'Construct an object using objects defining keys and values';
7
+ const parameters = [
8
+ {
9
+ name: 'properties',
10
+ description: 'An array of objects, each with a "key" property and a "value" property',
11
+ aliases: ['values', 'keyValPairs', 'keyValuePairs'],
12
+ required: true,
13
+ type: 'array',
14
+ },
15
+ ];
16
+ exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
17
+ const operatorData = {
18
+ description,
19
+ aliases,
20
+ parameters,
21
+ };
22
+ exports.default = operatorData;
@@ -0,0 +1 @@
1
+ export * from './operator';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./operator"), exports);
@@ -0,0 +1,2 @@
1
+ import { OperatorObject } from '../../types';
2
+ export declare const BUILD_OBJECT: OperatorObject;
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -10,21 +33,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
33
  };
11
34
  Object.defineProperty(exports, "__esModule", { value: true });
12
35
  exports.BUILD_OBJECT = void 0;
13
- const _operatorUtils_1 = require("./_operatorUtils");
14
- const requiredProperties = ['properties'];
15
- const operatorAliases = ['buildObject', 'build', 'object'];
16
- const propertyAliases = {
17
- values: 'properties',
18
- keyValPairs: 'properties',
19
- keyValuePairs: 'properties',
20
- };
36
+ const _operatorUtils_1 = require("../_operatorUtils");
37
+ const data_1 = __importStar(require("./data"));
21
38
  const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
22
39
  const evaluatePair = (nodes) => __awaiter(void 0, void 0, void 0, function* () {
23
40
  const [key, value] = (yield (0, _operatorUtils_1.evaluateArray)(nodes, config));
24
41
  config.typeChecker({ name: 'key', value: key, expectedType: ['string', 'number', 'boolean'] });
25
42
  return [key, value];
26
43
  });
27
- config.typeChecker({ name: 'properties', value: expression.properties, expectedType: 'array' });
44
+ config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { properties: expression.properties }));
28
45
  const evaluated = expression.properties
29
46
  .filter((element) => element instanceof Object && 'key' in element && 'value' in element)
30
47
  .map(({ key, value }) => evaluatePair([key, value]));
@@ -40,9 +57,8 @@ const parseChildren = (expression) => {
40
57
  return Object.assign(Object.assign({}, expression), { properties });
41
58
  };
42
59
  exports.BUILD_OBJECT = {
43
- requiredProperties,
44
- operatorAliases,
45
- propertyAliases,
60
+ propertyAliases: data_1.propertyAliases,
61
+ operatorData: data_1.default,
46
62
  evaluate,
47
63
  parseChildren,
48
64
  };
@@ -0,0 +1,4 @@
1
+ import { OperatorData } from '../../types';
2
+ export declare const propertyAliases: Record<string, string>;
3
+ declare const operatorData: OperatorData;
4
+ export default operatorData;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyAliases = void 0;
4
+ const _operatorUtils_1 = require("../_operatorUtils");
5
+ const description = 'Return a value based on a condition';
6
+ const aliases = ['?', 'conditional', 'ifThen'];
7
+ const parameters = [
8
+ {
9
+ name: 'condition',
10
+ description: 'The expression to check for truthiness',
11
+ aliases: [],
12
+ required: true,
13
+ type: 'any',
14
+ },
15
+ {
16
+ name: 'valueIfTrue',
17
+ description: 'Value to return if condition is true',
18
+ aliases: ['ifTrue'],
19
+ required: true,
20
+ type: 'any',
21
+ },
22
+ {
23
+ name: 'valueIfFalse',
24
+ description: 'Value to return if condition is false',
25
+ aliases: ['ifFalse', 'ifNot'],
26
+ required: true,
27
+ type: 'any',
28
+ },
29
+ ];
30
+ exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
31
+ const operatorData = {
32
+ description,
33
+ aliases,
34
+ parameters,
35
+ };
36
+ exports.default = operatorData;
@@ -0,0 +1 @@
1
+ export * from './operator';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./operator"), exports);
@@ -0,0 +1,2 @@
1
+ import { OperatorObject } from '../../types';
2
+ export declare const CONDITIONAL: OperatorObject;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.CONDITIONAL = void 0;
36
+ const evaluate_1 = require("../../evaluate");
37
+ const _operatorUtils_1 = require("../_operatorUtils");
38
+ const data_1 = __importStar(require("./data"));
39
+ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
40
+ config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, {
41
+ condition: expression.condition,
42
+ valueIfTrue: expression.valueIfTrue,
43
+ valueIfFalse: expression.valueIfFalse,
44
+ }));
45
+ const condition = yield (0, evaluate_1.evaluatorFunction)(expression.condition, config);
46
+ return condition
47
+ ? yield (0, evaluate_1.evaluatorFunction)(expression.valueIfTrue, config)
48
+ : yield (0, evaluate_1.evaluatorFunction)(expression.valueIfFalse, config);
49
+ });
50
+ const parseChildren = (expression) => {
51
+ const [condition, valueIfTrue, valueIfFalse] = expression.children;
52
+ return Object.assign(Object.assign({}, expression), { condition, valueIfTrue, valueIfFalse });
53
+ };
54
+ exports.CONDITIONAL = {
55
+ propertyAliases: data_1.propertyAliases,
56
+ operatorData: data_1.default,
57
+ evaluate,
58
+ parseChildren,
59
+ };
@@ -0,0 +1,4 @@
1
+ import { OperatorData } from '../../types';
2
+ export declare const propertyAliases: Record<string, string>;
3
+ declare const operatorData: OperatorData;
4
+ export default operatorData;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyAliases = void 0;
4
+ const _operatorUtils_1 = require("../_operatorUtils");
5
+ const description = 'Count elements in an array';
6
+ const aliases = ['count', 'length'];
7
+ const parameters = [
8
+ {
9
+ name: 'values',
10
+ description: 'An array to count',
11
+ aliases: [],
12
+ required: true,
13
+ type: 'array',
14
+ },
15
+ ];
16
+ exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
17
+ const operatorData = {
18
+ description,
19
+ aliases,
20
+ parameters,
21
+ };
22
+ exports.default = operatorData;
@@ -0,0 +1 @@
1
+ export * from './operator';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./operator"), exports);
@@ -0,0 +1,2 @@
1
+ import { OperatorObject } from '../../types';
2
+ export declare const COUNT: OperatorObject;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.COUNT = void 0;
36
+ const operator_1 = require("../AND/operator");
37
+ const _operatorUtils_1 = require("../_operatorUtils");
38
+ const data_1 = __importStar(require("./data"));
39
+ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
40
+ const values = yield (0, _operatorUtils_1.evaluateArray)(expression.values, config);
41
+ config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { values }));
42
+ return values.length;
43
+ });
44
+ exports.COUNT = {
45
+ propertyAliases: data_1.propertyAliases,
46
+ operatorData: data_1.default,
47
+ evaluate,
48
+ parseChildren: operator_1.parseChildren,
49
+ };
@@ -0,0 +1,4 @@
1
+ import { OperatorData } from '../../types';
2
+ export declare const propertyAliases: Record<string, string>;
3
+ declare const operatorData: OperatorData;
4
+ export default operatorData;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyAliases = void 0;
4
+ const _operatorUtils_1 = require("../_operatorUtils");
5
+ const description = 'Call a custom function (defined in options)';
6
+ const aliases = [
7
+ 'customFunctions',
8
+ 'customFunction',
9
+ 'objectFunctions',
10
+ 'function',
11
+ 'functions',
12
+ 'runFunction',
13
+ ];
14
+ const parameters = [
15
+ {
16
+ name: 'functionPath',
17
+ description: 'Path (in options.functions) to the required function',
18
+ aliases: ['functionsPath', 'functionName', 'funcName', 'path', 'name'],
19
+ required: true,
20
+ type: 'string',
21
+ },
22
+ {
23
+ name: 'args',
24
+ description: 'Arguments for the function',
25
+ aliases: ['arguments', 'variables'],
26
+ required: false,
27
+ type: 'array',
28
+ },
29
+ {
30
+ name: 'useCache',
31
+ description: 'Whether or not the FigTree cache is used',
32
+ aliases: [],
33
+ required: false,
34
+ type: 'boolean',
35
+ },
36
+ ];
37
+ exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
38
+ const operatorData = {
39
+ description,
40
+ aliases,
41
+ parameters,
42
+ };
43
+ exports.default = operatorData;
@@ -0,0 +1 @@
1
+ export * from './operator';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./operator"), exports);
@@ -0,0 +1,2 @@
1
+ import { OperatorObject } from '../../types';
2
+ export declare const CUSTOM_FUNCTIONS: OperatorObject;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.CUSTOM_FUNCTIONS = void 0;
39
+ const object_property_extractor_1 = __importDefault(require("object-property-extractor"));
40
+ const _operatorUtils_1 = require("../_operatorUtils");
41
+ const data_1 = __importStar(require("./data"));
42
+ const evaluate = (expression, config) => __awaiter(void 0, void 0, void 0, function* () {
43
+ var _a, _b, _c;
44
+ const [functionPath, args = [], useCache] = (yield (0, _operatorUtils_1.evaluateArray)([expression.functionPath, expression.args, expression.useCache], config));
45
+ config.typeChecker((0, _operatorUtils_1.getTypeCheckInput)(data_1.default.parameters, { functionPath, args }));
46
+ const { data, functions } = config.options;
47
+ const func = (_b = (_a = (0, object_property_extractor_1.default)(functions, functionPath, null)) !== null && _a !== void 0 ? _a : (0, object_property_extractor_1.default)(data, functionPath, null)) !== null && _b !== void 0 ? _b : (0, object_property_extractor_1.default)(config.options, functionPath, null);
48
+ if (!func || typeof func !== 'function')
49
+ throw new Error(`- No function found: "${functionPath}"`);
50
+ const shouldUseCache = (_c = useCache !== null && useCache !== void 0 ? useCache : config.options.useCache) !== null && _c !== void 0 ? _c : false;
51
+ const result = yield config.cache.useCache(shouldUseCache, (_, ...args) => __awaiter(void 0, void 0, void 0, function* () {
52
+ return yield func(...args);
53
+ }), functionPath, ...args);
54
+ return result;
55
+ });
56
+ const parseChildren = (expression) => {
57
+ const [functionPath, ...args] = expression.children;
58
+ return Object.assign(Object.assign({}, expression), { functionPath, args });
59
+ };
60
+ exports.CUSTOM_FUNCTIONS = {
61
+ propertyAliases: data_1.propertyAliases,
62
+ operatorData: data_1.default,
63
+ evaluate,
64
+ parseChildren,
65
+ };
@@ -0,0 +1,4 @@
1
+ import { OperatorData } from '../../types';
2
+ export declare const propertyAliases: Record<string, string>;
3
+ declare const operatorData: OperatorData;
4
+ export default operatorData;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.propertyAliases = void 0;
4
+ const _operatorUtils_1 = require("../_operatorUtils");
5
+ const description = 'Divide one numerical value by another';
6
+ const aliases = ['/', 'divide', '÷'];
7
+ const parameters = [
8
+ {
9
+ name: 'values',
10
+ description: 'Array of values - 1st element will be divided by the first',
11
+ aliases: [],
12
+ required: false,
13
+ type: 'array',
14
+ },
15
+ {
16
+ name: 'dividend',
17
+ description: 'The number that will be divided',
18
+ aliases: ['divide'],
19
+ required: false,
20
+ type: 'number',
21
+ },
22
+ {
23
+ name: 'divisor',
24
+ description: 'The number that dividend will be divided by',
25
+ aliases: ['by', 'divideBy'],
26
+ required: false,
27
+ type: 'number',
28
+ },
29
+ {
30
+ name: 'output',
31
+ description: 'Whether to output a quotient, remainder or decimal',
32
+ aliases: [],
33
+ required: false,
34
+ type: { literal: ['quotient', 'remainder'] },
35
+ },
36
+ ];
37
+ exports.propertyAliases = (0, _operatorUtils_1.getPropertyAliases)(parameters);
38
+ const operatorData = {
39
+ description,
40
+ aliases,
41
+ parameters,
42
+ };
43
+ exports.default = operatorData;
@@ -0,0 +1 @@
1
+ export * from './operator';