bruce-models 7.1.18 → 7.1.20
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 +150 -110
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +150 -110
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/calculator/calculator.js +136 -106
- package/dist/lib/calculator/calculator.js.map +1 -1
- package/dist/lib/entity/entity.js +13 -3
- package/dist/lib/entity/entity.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/calculator/calculator.d.ts +1 -1
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -3876,7 +3876,15 @@
|
|
|
3876
3876
|
});
|
|
3877
3877
|
const cache = api.GetCacheItem(key, reqParams);
|
|
3878
3878
|
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
3879
|
-
|
|
3879
|
+
const cachedData = cache.data;
|
|
3880
|
+
if (cachedData instanceof Promise || (typeof cachedData === "object" && typeof cachedData.then === "function")) {
|
|
3881
|
+
return cachedData;
|
|
3882
|
+
}
|
|
3883
|
+
else {
|
|
3884
|
+
return Promise.resolve({
|
|
3885
|
+
entity: cachedData
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3880
3888
|
}
|
|
3881
3889
|
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
3882
3890
|
try {
|
|
@@ -4155,8 +4163,10 @@
|
|
|
4155
4163
|
const req = crashRiskReqs[i];
|
|
4156
4164
|
try {
|
|
4157
4165
|
const data = yield req;
|
|
4158
|
-
|
|
4159
|
-
|
|
4166
|
+
// Handle both wrapped and direct-Entity blobs.
|
|
4167
|
+
const entity = (data === null || data === void 0 ? void 0 : data.entity) || ((data === null || data === void 0 ? void 0 : data.Bruce) ? data : null);
|
|
4168
|
+
if (entity) {
|
|
4169
|
+
entities.push(entity);
|
|
4160
4170
|
}
|
|
4161
4171
|
}
|
|
4162
4172
|
catch (e) {
|
|
@@ -5178,136 +5188,166 @@
|
|
|
5178
5188
|
if (type == "number" && field.type == EValueType.Color) {
|
|
5179
5189
|
field.type = EValueType.Input;
|
|
5180
5190
|
}
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
value = assertColor(value);
|
|
5188
|
-
if (value && type == "string") {
|
|
5189
|
-
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5191
|
+
// Custom resolution.
|
|
5192
|
+
if (field.value instanceof Function) {
|
|
5193
|
+
value = field.value(data, tags);
|
|
5194
|
+
if (type == "number") {
|
|
5195
|
+
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5196
|
+
value = Number(value);
|
|
5190
5197
|
}
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
if (type === "number") {
|
|
5194
|
-
break;
|
|
5198
|
+
else if (typeof value != "number") {
|
|
5199
|
+
value = null;
|
|
5195
5200
|
}
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
if (value
|
|
5199
|
-
value =
|
|
5201
|
+
}
|
|
5202
|
+
else if (type == "string") {
|
|
5203
|
+
if (typeof value == "number") {
|
|
5204
|
+
value = String(value);
|
|
5200
5205
|
}
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5206
|
+
else if (typeof value == "object") {
|
|
5207
|
+
if (isColor(value)) {
|
|
5208
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5209
|
+
}
|
|
5210
|
+
else {
|
|
5211
|
+
value = null;
|
|
5212
|
+
}
|
|
5205
5213
|
}
|
|
5206
|
-
|
|
5214
|
+
}
|
|
5215
|
+
else if (type == "color") {
|
|
5207
5216
|
value = assertColor(value);
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5219
|
+
else {
|
|
5220
|
+
switch (field.type) {
|
|
5221
|
+
case EValueType.Color:
|
|
5222
|
+
if (type === "number") {
|
|
5223
|
+
break;
|
|
5224
|
+
}
|
|
5225
|
+
value = field.value;
|
|
5226
|
+
value = assertColor(value);
|
|
5227
|
+
if (value && type == "string") {
|
|
5228
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5229
|
+
}
|
|
5214
5230
|
break;
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
if (tag.Color) {
|
|
5219
|
-
value = exports.Color.ColorFromStr(tag.Color);
|
|
5220
|
-
value = assertColor(value);
|
|
5221
|
-
if (value) {
|
|
5222
|
-
break;
|
|
5223
|
-
}
|
|
5231
|
+
case EValueType.Gradient:
|
|
5232
|
+
if (type === "number") {
|
|
5233
|
+
break;
|
|
5224
5234
|
}
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
}
|
|
5230
|
-
break;
|
|
5231
|
-
// Input can be an arbitrary value.
|
|
5232
|
-
// Eg: Result is a colour, a number, a string.
|
|
5233
|
-
// This means we first calculate the value, then validate it in the context of the desired type.
|
|
5234
|
-
case EValueType.Input:
|
|
5235
|
-
value = GetInputValue(field.value, data);
|
|
5236
|
-
if (value != null) {
|
|
5237
|
-
if (type == "number") {
|
|
5238
|
-
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5239
|
-
value = Number(value);
|
|
5240
|
-
}
|
|
5241
|
-
else if (typeof value != "number") {
|
|
5242
|
-
value = null;
|
|
5243
|
-
}
|
|
5235
|
+
value = GetGradientValue(field.value, data, shouldRangesDefaultToMin);
|
|
5236
|
+
value = assertColor(value);
|
|
5237
|
+
if (value && type == "string") {
|
|
5238
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5244
5239
|
}
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5240
|
+
break;
|
|
5241
|
+
case EValueType.RandomColor:
|
|
5242
|
+
if (type === "number") {
|
|
5243
|
+
break;
|
|
5244
|
+
}
|
|
5245
|
+
value = exports.Color.RandomColor();
|
|
5246
|
+
value = assertColor(value);
|
|
5247
|
+
if (value && type == "string") {
|
|
5248
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5249
|
+
}
|
|
5250
|
+
break;
|
|
5251
|
+
case EValueType.TagColor:
|
|
5252
|
+
if (type === "number") {
|
|
5253
|
+
break;
|
|
5254
|
+
}
|
|
5255
|
+
for (let i = 0; i < tags.length; i++) {
|
|
5256
|
+
const tag = tags[i];
|
|
5257
|
+
if (tag.Color) {
|
|
5258
|
+
value = exports.Color.ColorFromStr(tag.Color);
|
|
5259
|
+
value = assertColor(value);
|
|
5260
|
+
if (value) {
|
|
5261
|
+
break;
|
|
5262
|
+
}
|
|
5248
5263
|
}
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5264
|
+
}
|
|
5265
|
+
if (value && type == "string") {
|
|
5266
|
+
const cColor = value;
|
|
5267
|
+
value = `rgba(${cColor.red},${cColor.green},${cColor.blue},${cColor.alpha})`;
|
|
5268
|
+
}
|
|
5269
|
+
break;
|
|
5270
|
+
// Input can be an arbitrary value.
|
|
5271
|
+
// Eg: Result is a colour, a number, a string.
|
|
5272
|
+
// This means we first calculate the value, then validate it in the context of the desired type.
|
|
5273
|
+
case EValueType.Input:
|
|
5274
|
+
value = GetInputValue(field.value, data);
|
|
5275
|
+
if (value != null) {
|
|
5276
|
+
if (type == "number") {
|
|
5277
|
+
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5278
|
+
value = Number(value);
|
|
5252
5279
|
}
|
|
5253
|
-
else {
|
|
5280
|
+
else if (typeof value != "number") {
|
|
5254
5281
|
value = null;
|
|
5255
5282
|
}
|
|
5256
5283
|
}
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
if (type == "number") {
|
|
5270
|
-
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5271
|
-
value = Number(value);
|
|
5284
|
+
else if (type == "string") {
|
|
5285
|
+
if (typeof value == "number") {
|
|
5286
|
+
value = String(value);
|
|
5287
|
+
}
|
|
5288
|
+
else if (typeof value == "object") {
|
|
5289
|
+
if (isColor(value)) {
|
|
5290
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5291
|
+
}
|
|
5292
|
+
else {
|
|
5293
|
+
value = null;
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5272
5296
|
}
|
|
5273
|
-
else if (
|
|
5274
|
-
value =
|
|
5297
|
+
else if (type == "color") {
|
|
5298
|
+
value = assertColor(value);
|
|
5275
5299
|
}
|
|
5276
5300
|
}
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5301
|
+
break;
|
|
5302
|
+
// Mapping can be an arbitrary value.
|
|
5303
|
+
// Eg: mapping a value to a Client File ID, or a colour, or a number.
|
|
5304
|
+
// This means we first calculate the value, then validate it in the context of the desired type.
|
|
5305
|
+
case EValueType.Mapping:
|
|
5306
|
+
value = GetMappingValue(field.value, data);
|
|
5307
|
+
if (value != null) {
|
|
5308
|
+
if (type == "number") {
|
|
5309
|
+
if (typeof value == "string" && value != "" && value != null && value != undefined) {
|
|
5310
|
+
value = Number(value);
|
|
5284
5311
|
}
|
|
5285
|
-
else {
|
|
5312
|
+
else if (typeof value != "number") {
|
|
5286
5313
|
value = null;
|
|
5287
5314
|
}
|
|
5288
5315
|
}
|
|
5316
|
+
else if (type == "string") {
|
|
5317
|
+
if (typeof value == "number") {
|
|
5318
|
+
value = String(value);
|
|
5319
|
+
}
|
|
5320
|
+
else if (typeof value == "object") {
|
|
5321
|
+
if (isColor(value)) {
|
|
5322
|
+
value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
|
|
5323
|
+
}
|
|
5324
|
+
else {
|
|
5325
|
+
value = null;
|
|
5326
|
+
}
|
|
5327
|
+
}
|
|
5328
|
+
}
|
|
5329
|
+
else if (type == "color") {
|
|
5330
|
+
value = assertColor(typeof value === "number" ? String(value) : value);
|
|
5331
|
+
}
|
|
5289
5332
|
}
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5333
|
+
break;
|
|
5334
|
+
}
|
|
5335
|
+
// Extra layer of validation.
|
|
5336
|
+
// This is a backup in case some branch above failed to convert into the right type.
|
|
5337
|
+
if (type == "number") {
|
|
5338
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
5339
|
+
value = null;
|
|
5293
5340
|
}
|
|
5294
|
-
break;
|
|
5295
|
-
}
|
|
5296
|
-
// Extra layer of validation.
|
|
5297
|
-
// This is a backup in case some branch above failed to convert into the right type.
|
|
5298
|
-
if (type == "number") {
|
|
5299
|
-
if (typeof value !== "number" || isNaN(value)) {
|
|
5300
|
-
value = null;
|
|
5301
5341
|
}
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5342
|
+
else if (type == "color") {
|
|
5343
|
+
if (typeof value !== "object" || !value) {
|
|
5344
|
+
value = null;
|
|
5345
|
+
}
|
|
5306
5346
|
}
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5347
|
+
else if (type == "string") {
|
|
5348
|
+
if (typeof value !== "string" || !value) {
|
|
5349
|
+
value = null;
|
|
5350
|
+
}
|
|
5311
5351
|
}
|
|
5312
5352
|
}
|
|
5313
5353
|
if (value != null) {
|
|
@@ -17130,7 +17170,7 @@
|
|
|
17130
17170
|
})(exports.ChangeSet || (exports.ChangeSet = {}));
|
|
17131
17171
|
|
|
17132
17172
|
// This is updated with the package.json version on build.
|
|
17133
|
-
const VERSION = "7.1.
|
|
17173
|
+
const VERSION = "7.1.20";
|
|
17134
17174
|
|
|
17135
17175
|
exports.VERSION = VERSION;
|
|
17136
17176
|
exports.AbstractApi = AbstractApi;
|