fig-tree-evaluator 1.9.2 → 1.9.4

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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # fig-tree-evaluator
2
2
 
3
+ ![Logo](images/FigTreeEvaluator_logo_1000.png)
4
+
3
5
  **FigTree Evaluator** is a module to evaluate JSON-structured expression trees.
4
6
 
5
7
  A typical use case would be for evaluating **configuration** files, where you need to store dynamic values or arbitrary logic without allowing users to inject executable code. For example, a [form-builder app](https://github.com/openmsupply/conforma-web-app) might need to allow complex conditional logic for form element visibility based on previous responses, or for validation beyond what is available in standard validation libraries.
package/build/helpers.js CHANGED
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.errorMessage = exports.convertOutputMethods = exports.checkRequiredNodes = exports.mapPropertyAliases = exports.fallbackOrError = exports.truncateString = exports.getOperatorName = exports.isOperatorNode = exports.parseIfJson = void 0;
7
- const mapKeys_1 = __importDefault(require("lodash/mapKeys"));
8
- const camelCase_1 = __importDefault(require("lodash/camelCase"));
4
+ const change_case_1 = require("change-case");
9
5
  const parseIfJson = (input) => {
10
6
  if (typeof input !== 'string')
11
7
  return input;
@@ -21,7 +17,7 @@ exports.parseIfJson = parseIfJson;
21
17
  const isOperatorNode = (input) => input instanceof Object && 'operator' in input;
22
18
  exports.isOperatorNode = isOperatorNode;
23
19
  const standardiseOperatorName = (name) => {
24
- const camelCaseName = (0, camelCase_1.default)(name);
20
+ const camelCaseName = (0, change_case_1.camelCase)(name);
25
21
  return camelCaseName ? camelCaseName : name;
26
22
  };
27
23
  const getOperatorName = (operator, operatorAliases) => operatorAliases[standardiseOperatorName(operator)];
@@ -37,8 +33,13 @@ const fallbackOrError = (fallback, errorMessage, returnErrorAsString = false) =>
37
33
  throw new Error((0, exports.truncateString)(errorMessage));
38
34
  };
39
35
  exports.fallbackOrError = fallbackOrError;
40
- const mapPropertyAliases = (propertyAliases, expression) => (0, mapKeys_1.default)(expression, (_, key) => key in propertyAliases ? propertyAliases[key] : key);
36
+ const mapPropertyAliases = (propertyAliases, expression) => mapObjectKeys(expression, (key) => key in propertyAliases ? propertyAliases[key] : key);
41
37
  exports.mapPropertyAliases = mapPropertyAliases;
38
+ const mapObjectKeys = (inputObj, mapFunction) => {
39
+ const keyVals = Object.entries(inputObj);
40
+ const mappedKeys = keyVals.map(([key, value]) => [mapFunction(key), value]);
41
+ return Object.fromEntries(mappedKeys);
42
+ };
42
43
  const checkRequiredNodes = (requiredProps, expression) => {
43
44
  const missingProps = requiredProps.filter((prop) => !(prop in expression));
44
45
  if (missingProps.length === 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fig-tree-evaluator",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
4
4
  "description": "Module to evaluate JSON-structured expression trees",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -14,7 +14,6 @@
14
14
  "@testing-library/jest-dom": "^5.14.1",
15
15
  "@testing-library/react": "^13.0.0",
16
16
  "@types/jest": "^27.5.1",
17
- "@types/lodash": "^4.14.182",
18
17
  "@types/node": "^17.0.38",
19
18
  "@types/pg": "^8.6.5",
20
19
  "dotenv": "^16.0.1",
@@ -35,7 +34,7 @@
35
34
  },
36
35
  "dependencies": {
37
36
  "axios": "^0.27.2",
38
- "lodash": "^4.17.21",
37
+ "change-case": "^4.1.2",
39
38
  "object-property-extractor": "^1.0.3"
40
39
  },
41
40
  "bugs": {