bruce-models 7.0.3 → 7.0.5

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.
@@ -2720,6 +2720,8 @@
2720
2720
  EType["Entity"] = "Entity";
2721
2721
  // Url attribute.
2722
2722
  EType["Url"] = "Url";
2723
+ // Serial number that increments for each new entity/missing-attr-value.
2724
+ EType["Serial"] = "Serial";
2723
2725
  })(EType = EntityAttribute.EType || (EntityAttribute.EType = {}));
2724
2726
  /**
2725
2727
  * Describes url open behavior.
@@ -5230,92 +5232,96 @@
5230
5232
  }
5231
5233
  for (let i = 0; i < value.values.length; i++) {
5232
5234
  const option = value.values[i];
5233
- let mapValue = option.fieldValue;
5234
- // If mapValue is prefixed with "JS:", we evaluate it as JavaScript.
5235
- // This lets us do things like JS:Boolean("${}") as a quick way to map 'existence' to a target value.
5236
- if (typeof mapValue === "string" && mapValue.startsWith("JS:")) {
5237
- try {
5238
- let jsEval = mapValue.replace("JS:", "").trim();
5239
- const attrPathStr = exports.PathUtils.Wrap(attrPath);
5240
- jsEval = jsEval.replace("${}", "${" + attrPathStr + "}");
5241
- jsEval = exports.BruceVariable.SwapValues({
5242
- str: jsEval,
5243
- entity: entity
5244
- });
5245
- // https://rollupjs.org/guide/en/#avoiding-eval
5246
- // This stops eval warning.
5247
- const eval2 = eval;
5248
- mapValue = eval2(jsEval);
5249
- // We currently expect eval to return a validity bool.
5250
- // So it either matches and we return it, or it doesn't and we continue.
5251
- if (mapValue) {
5252
- return option.appliedValue;
5253
- }
5254
- else {
5255
- continue;
5256
- }
5257
- }
5258
- catch (exception) {
5259
- const e = exception;
5260
- let suppress = false;
5261
- if (e && typeof e == "object") {
5262
- const msg = e.message;
5263
- suppress = !!msg && (msg.includes("Unexpected end") || msg.includes("got end of script"));
5264
- }
5265
- if (!suppress) {
5266
- console.error(e);
5267
- }
5268
- // Eval failed, therefor not a valid mapping-row.
5269
- continue;
5270
- }
5271
- }
5272
- let isMapValueNum = !isNaN(+mapValue);
5273
- if (isMapValueNum == null) {
5274
- isMapValueNum = false;
5275
- }
5276
- if (isValueNum && (isMapValueNum || (typeof mapValue === "string" && mapValue.includes("-")))) {
5277
- if (+mapValue == +eValue) {
5278
- return option.appliedValue;
5279
- }
5280
- const mapSplit = mapValue.split("-");
5281
- if (mapSplit.length == 2) {
5282
- const min = mapSplit[0];
5283
- const max = mapSplit[1];
5284
- if (min != "") {
5285
- if (+eValue < +min) {
5286
- continue;
5235
+ const fieldValues = Array.isArray(option.fieldValue) ? option.fieldValue : [option.fieldValue];
5236
+ // Check each field value in the array.
5237
+ for (let j = 0; j < fieldValues.length; j++) {
5238
+ let mapValue = fieldValues[j];
5239
+ // If mapValue is prefixed with "JS:", we evaluate it as JavaScript.
5240
+ // This lets us do things like JS:Boolean("${}") as a quick way to map 'existence' to a target value.
5241
+ if (typeof mapValue === "string" && mapValue.startsWith("JS:")) {
5242
+ try {
5243
+ let jsEval = mapValue.replace("JS:", "").trim();
5244
+ const attrPathStr = exports.PathUtils.Wrap(attrPath);
5245
+ jsEval = jsEval.replace("${}", "${" + attrPathStr + "}");
5246
+ jsEval = exports.BruceVariable.SwapValues({
5247
+ str: jsEval,
5248
+ entity: entity
5249
+ });
5250
+ // https://rollupjs.org/guide/en/#avoiding-eval
5251
+ // This stops eval warning.
5252
+ const eval2 = eval;
5253
+ mapValue = eval2(jsEval);
5254
+ // We currently expect eval to return a validity bool.
5255
+ // So it either matches and we return it, or it doesn't and we continue.
5256
+ if (mapValue) {
5257
+ return option.appliedValue;
5287
5258
  }
5288
- }
5289
- if (max != "") {
5290
- if (+eValue > +max) {
5259
+ else {
5291
5260
  continue;
5292
5261
  }
5293
5262
  }
5294
- if (min == "" && max == "") {
5263
+ catch (exception) {
5264
+ const e = exception;
5265
+ let suppress = false;
5266
+ if (e && typeof e == "object") {
5267
+ const msg = e.message;
5268
+ suppress = !!msg && (msg.includes("Unexpected end") || msg.includes("got end of script"));
5269
+ }
5270
+ if (!suppress) {
5271
+ console.error(e);
5272
+ }
5273
+ // Eval failed, therefor not a valid mapping-row.
5295
5274
  continue;
5296
5275
  }
5297
- return option.appliedValue;
5298
5276
  }
5299
- }
5300
- else {
5301
- if (mapValue == eValue) {
5302
- return option.appliedValue;
5277
+ let isMapValueNum = !isNaN(+mapValue);
5278
+ if (isMapValueNum == null) {
5279
+ isMapValueNum = false;
5303
5280
  }
5304
- // Case where Entity value is a boolean but the mapping value is a string.
5305
- // Common as mapping value is typically a user-entered string.
5306
- else if (typeof eValue === "boolean" && typeof mapValue === "string") {
5307
- const eValueStr = eValue ? "true" : "false";
5308
- if (mapValue.toLowerCase() == eValueStr) {
5281
+ if (isValueNum && (isMapValueNum || (typeof mapValue === "string" && mapValue.includes("-")))) {
5282
+ if (+mapValue == +eValue) {
5283
+ return option.appliedValue;
5284
+ }
5285
+ const mapSplit = mapValue.split("-");
5286
+ if (mapSplit.length == 2) {
5287
+ const min = mapSplit[0];
5288
+ const max = mapSplit[1];
5289
+ if (min != "") {
5290
+ if (+eValue < +min) {
5291
+ continue;
5292
+ }
5293
+ }
5294
+ if (max != "") {
5295
+ if (+eValue > +max) {
5296
+ continue;
5297
+ }
5298
+ }
5299
+ if (min == "" && max == "") {
5300
+ continue;
5301
+ }
5309
5302
  return option.appliedValue;
5310
5303
  }
5311
5304
  }
5312
- // Handling possible case where the opposite is true.
5313
- // Have not seen this happen yet, but preparing for any future cases.
5314
- else if (typeof mapValue === "boolean" && typeof eValue === "string") {
5315
- const mapValueStr = mapValue ? "true" : "false";
5316
- if (mapValueStr == eValue.toLowerCase()) {
5305
+ else {
5306
+ if (mapValue == eValue) {
5317
5307
  return option.appliedValue;
5318
5308
  }
5309
+ // Case where Entity value is a boolean but the mapping value is a string.
5310
+ // Common as mapping value is typically a user-entered string.
5311
+ else if (typeof eValue === "boolean" && typeof mapValue === "string") {
5312
+ const eValueStr = eValue ? "true" : "false";
5313
+ if (mapValue.toLowerCase() == eValueStr) {
5314
+ return option.appliedValue;
5315
+ }
5316
+ }
5317
+ // Handling possible case where the opposite is true.
5318
+ // Have not seen this happen yet, but preparing for any future cases.
5319
+ else if (typeof mapValue === "boolean" && typeof eValue === "string") {
5320
+ const mapValueStr = mapValue ? "true" : "false";
5321
+ if (mapValueStr == eValue.toLowerCase()) {
5322
+ return option.appliedValue;
5323
+ }
5324
+ }
5319
5325
  }
5320
5326
  }
5321
5327
  }
@@ -16700,7 +16706,7 @@
16700
16706
  }
16701
16707
 
16702
16708
  // This is updated with the package.json version on build.
16703
- const VERSION = "7.0.3";
16709
+ const VERSION = "7.0.5";
16704
16710
 
16705
16711
  exports.VERSION = VERSION;
16706
16712
  exports.AbstractApi = AbstractApi;