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.
- package/dist/bruce-models.es5.js +80 -74
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +80 -74
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/calculator/calculator.js +77 -73
- package/dist/lib/calculator/calculator.js.map +1 -1
- package/dist/lib/entity/entity-attribute.js +2 -0
- package/dist/lib/entity/entity-attribute.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/calculator/calculator.d.ts +1 -1
- package/dist/types/entity/entity-attribute.d.ts +5 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -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
|
-
|
|
5234
|
-
//
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
return
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
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
|
-
|
|
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
|
-
|
|
5301
|
-
|
|
5302
|
-
return option.appliedValue;
|
|
5277
|
+
let isMapValueNum = !isNaN(+mapValue);
|
|
5278
|
+
if (isMapValueNum == null) {
|
|
5279
|
+
isMapValueNum = false;
|
|
5303
5280
|
}
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
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
|
-
|
|
5313
|
-
|
|
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.
|
|
16709
|
+
const VERSION = "7.0.5";
|
|
16704
16710
|
|
|
16705
16711
|
exports.VERSION = VERSION;
|
|
16706
16712
|
exports.AbstractApi = AbstractApi;
|