bruce-models 6.4.9 → 6.5.0

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.
@@ -4991,7 +4991,45 @@
4991
4991
  }
4992
4992
  for (let i = 0; i < value.values.length; i++) {
4993
4993
  const option = value.values[i];
4994
- const mapValue = option.fieldValue;
4994
+ let mapValue = option.fieldValue;
4995
+ // If mapValue is prefixed with "JS:", we evaluate it as JavaScript.
4996
+ // This lets us do things like JS:Boolean("${}") as a quick way to map 'existence' to a target value.
4997
+ if (typeof mapValue === "string" && mapValue.startsWith("JS:")) {
4998
+ try {
4999
+ let jsEval = mapValue.replace("JS:", "").trim();
5000
+ const attrPathStr = exports.PathUtils.Wrap(attrPath);
5001
+ jsEval = jsEval.replace("${}", "${" + attrPathStr + "}");
5002
+ jsEval = exports.BruceVariable.SwapValues({
5003
+ str: jsEval,
5004
+ entity: entity
5005
+ });
5006
+ // https://rollupjs.org/guide/en/#avoiding-eval
5007
+ // This stops eval warning.
5008
+ const eval2 = eval;
5009
+ mapValue = eval2(jsEval);
5010
+ // We currently expect eval to return a validity bool.
5011
+ // So it either matches and we return it, or it doesn't and we continue.
5012
+ if (mapValue) {
5013
+ return option.appliedValue;
5014
+ }
5015
+ else {
5016
+ continue;
5017
+ }
5018
+ }
5019
+ catch (exception) {
5020
+ const e = exception;
5021
+ let suppress = false;
5022
+ if (e && typeof e == "object") {
5023
+ const msg = e.message;
5024
+ suppress = !!msg && (msg.includes("Unexpected end") || msg.includes("got end of script"));
5025
+ }
5026
+ if (!suppress) {
5027
+ console.error(e);
5028
+ }
5029
+ // Eval failed, therefor not a valid mapping-row.
5030
+ continue;
5031
+ }
5032
+ }
4995
5033
  let isMapValueNum = !isNaN(+mapValue);
4996
5034
  if (isMapValueNum == null) {
4997
5035
  isMapValueNum = false;
@@ -5028,7 +5066,7 @@
5028
5066
  // Common as mapping value is typically a user-entered string.
5029
5067
  else if (typeof eValue === "boolean" && typeof mapValue === "string") {
5030
5068
  const eValueStr = eValue ? "true" : "false";
5031
- if (mapValue == eValueStr) {
5069
+ if (mapValue.toLowerCase() == eValueStr) {
5032
5070
  return option.appliedValue;
5033
5071
  }
5034
5072
  }
@@ -5036,7 +5074,7 @@
5036
5074
  // Have not seen this happen yet, but preparing for any future cases.
5037
5075
  else if (typeof mapValue === "boolean" && typeof eValue === "string") {
5038
5076
  const mapValueStr = mapValue ? "true" : "false";
5039
- if (mapValueStr == eValue) {
5077
+ if (mapValueStr == eValue.toLowerCase()) {
5040
5078
  return option.appliedValue;
5041
5079
  }
5042
5080
  }
@@ -15795,7 +15833,7 @@
15795
15833
  })(exports.Tracking || (exports.Tracking = {}));
15796
15834
 
15797
15835
  // This is updated with the package.json version on build.
15798
- const VERSION = "6.4.9";
15836
+ const VERSION = "6.5.0";
15799
15837
 
15800
15838
  exports.VERSION = VERSION;
15801
15839
  exports.AbstractApi = AbstractApi;