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.
@@ -3925,7 +3925,15 @@ var Entity;
3925
3925
  });
3926
3926
  const cache = api.GetCacheItem(key, reqParams);
3927
3927
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
3928
- return cache.data;
3928
+ const cachedData = cache.data;
3929
+ if (cachedData instanceof Promise || (typeof cachedData === "object" && typeof cachedData.then === "function")) {
3930
+ return cachedData;
3931
+ }
3932
+ else {
3933
+ return Promise.resolve({
3934
+ entity: cachedData
3935
+ });
3936
+ }
3929
3937
  }
3930
3938
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
3931
3939
  try {
@@ -4204,8 +4212,10 @@ var Entity;
4204
4212
  const req = crashRiskReqs[i];
4205
4213
  try {
4206
4214
  const data = yield req;
4207
- if (data === null || data === void 0 ? void 0 : data.entity) {
4208
- entities.push(data.entity);
4215
+ // Handle both wrapped and direct-Entity blobs.
4216
+ const entity = (data === null || data === void 0 ? void 0 : data.entity) || ((data === null || data === void 0 ? void 0 : data.Bruce) ? data : null);
4217
+ if (entity) {
4218
+ entities.push(entity);
4209
4219
  }
4210
4220
  }
4211
4221
  catch (e) {
@@ -5239,136 +5249,166 @@ var Calculator;
5239
5249
  if (type == "number" && field.type == EValueType.Color) {
5240
5250
  field.type = EValueType.Input;
5241
5251
  }
5242
- switch (field.type) {
5243
- case EValueType.Color:
5244
- if (type === "number") {
5245
- break;
5246
- }
5247
- value = field.value;
5248
- value = assertColor(value);
5249
- if (value && type == "string") {
5250
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5252
+ // Custom resolution.
5253
+ if (field.value instanceof Function) {
5254
+ value = field.value(data, tags);
5255
+ if (type == "number") {
5256
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
5257
+ value = Number(value);
5251
5258
  }
5252
- break;
5253
- case EValueType.Gradient:
5254
- if (type === "number") {
5255
- break;
5259
+ else if (typeof value != "number") {
5260
+ value = null;
5256
5261
  }
5257
- value = GetGradientValue(field.value, data, shouldRangesDefaultToMin);
5258
- value = assertColor(value);
5259
- if (value && type == "string") {
5260
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5262
+ }
5263
+ else if (type == "string") {
5264
+ if (typeof value == "number") {
5265
+ value = String(value);
5261
5266
  }
5262
- break;
5263
- case EValueType.RandomColor:
5264
- if (type === "number") {
5265
- break;
5267
+ else if (typeof value == "object") {
5268
+ if (isColor(value)) {
5269
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5270
+ }
5271
+ else {
5272
+ value = null;
5273
+ }
5266
5274
  }
5267
- value = Color.RandomColor();
5275
+ }
5276
+ else if (type == "color") {
5268
5277
  value = assertColor(value);
5269
- if (value && type == "string") {
5270
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5271
- }
5272
- break;
5273
- case EValueType.TagColor:
5274
- if (type === "number") {
5278
+ }
5279
+ }
5280
+ else {
5281
+ switch (field.type) {
5282
+ case EValueType.Color:
5283
+ if (type === "number") {
5284
+ break;
5285
+ }
5286
+ value = field.value;
5287
+ value = assertColor(value);
5288
+ if (value && type == "string") {
5289
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5290
+ }
5275
5291
  break;
5276
- }
5277
- for (let i = 0; i < tags.length; i++) {
5278
- const tag = tags[i];
5279
- if (tag.Color) {
5280
- value = Color.ColorFromStr(tag.Color);
5281
- value = assertColor(value);
5282
- if (value) {
5283
- break;
5284
- }
5292
+ case EValueType.Gradient:
5293
+ if (type === "number") {
5294
+ break;
5285
5295
  }
5286
- }
5287
- if (value && type == "string") {
5288
- const cColor = value;
5289
- value = `rgba(${cColor.red},${cColor.green},${cColor.blue},${cColor.alpha})`;
5290
- }
5291
- break;
5292
- // Input can be an arbitrary value.
5293
- // Eg: Result is a colour, a number, a string.
5294
- // This means we first calculate the value, then validate it in the context of the desired type.
5295
- case EValueType.Input:
5296
- value = GetInputValue(field.value, data);
5297
- if (value != null) {
5298
- if (type == "number") {
5299
- if (typeof value == "string" && value != "" && value != null && value != undefined) {
5300
- value = Number(value);
5301
- }
5302
- else if (typeof value != "number") {
5303
- value = null;
5304
- }
5296
+ value = GetGradientValue(field.value, data, shouldRangesDefaultToMin);
5297
+ value = assertColor(value);
5298
+ if (value && type == "string") {
5299
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5305
5300
  }
5306
- else if (type == "string") {
5307
- if (typeof value == "number") {
5308
- value = String(value);
5301
+ break;
5302
+ case EValueType.RandomColor:
5303
+ if (type === "number") {
5304
+ break;
5305
+ }
5306
+ value = Color.RandomColor();
5307
+ value = assertColor(value);
5308
+ if (value && type == "string") {
5309
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5310
+ }
5311
+ break;
5312
+ case EValueType.TagColor:
5313
+ if (type === "number") {
5314
+ break;
5315
+ }
5316
+ for (let i = 0; i < tags.length; i++) {
5317
+ const tag = tags[i];
5318
+ if (tag.Color) {
5319
+ value = Color.ColorFromStr(tag.Color);
5320
+ value = assertColor(value);
5321
+ if (value) {
5322
+ break;
5323
+ }
5309
5324
  }
5310
- else if (typeof value == "object") {
5311
- if (isColor(value)) {
5312
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5325
+ }
5326
+ if (value && type == "string") {
5327
+ const cColor = value;
5328
+ value = `rgba(${cColor.red},${cColor.green},${cColor.blue},${cColor.alpha})`;
5329
+ }
5330
+ break;
5331
+ // Input can be an arbitrary value.
5332
+ // Eg: Result is a colour, a number, a string.
5333
+ // This means we first calculate the value, then validate it in the context of the desired type.
5334
+ case EValueType.Input:
5335
+ value = GetInputValue(field.value, data);
5336
+ if (value != null) {
5337
+ if (type == "number") {
5338
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
5339
+ value = Number(value);
5313
5340
  }
5314
- else {
5341
+ else if (typeof value != "number") {
5315
5342
  value = null;
5316
5343
  }
5317
5344
  }
5318
- }
5319
- else if (type == "color") {
5320
- value = assertColor(value);
5321
- }
5322
- }
5323
- break;
5324
- // Mapping can be an arbitrary value.
5325
- // Eg: mapping a value to a Client File ID, or a colour, or a number.
5326
- // This means we first calculate the value, then validate it in the context of the desired type.
5327
- case EValueType.Mapping:
5328
- value = GetMappingValue(field.value, data);
5329
- if (value != null) {
5330
- if (type == "number") {
5331
- if (typeof value == "string" && value != "" && value != null && value != undefined) {
5332
- value = Number(value);
5345
+ else if (type == "string") {
5346
+ if (typeof value == "number") {
5347
+ value = String(value);
5348
+ }
5349
+ else if (typeof value == "object") {
5350
+ if (isColor(value)) {
5351
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5352
+ }
5353
+ else {
5354
+ value = null;
5355
+ }
5356
+ }
5333
5357
  }
5334
- else if (typeof value != "number") {
5335
- value = null;
5358
+ else if (type == "color") {
5359
+ value = assertColor(value);
5336
5360
  }
5337
5361
  }
5338
- else if (type == "string") {
5339
- if (typeof value == "number") {
5340
- value = String(value);
5341
- }
5342
- else if (typeof value == "object") {
5343
- if (isColor(value)) {
5344
- value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5362
+ break;
5363
+ // Mapping can be an arbitrary value.
5364
+ // Eg: mapping a value to a Client File ID, or a colour, or a number.
5365
+ // This means we first calculate the value, then validate it in the context of the desired type.
5366
+ case EValueType.Mapping:
5367
+ value = GetMappingValue(field.value, data);
5368
+ if (value != null) {
5369
+ if (type == "number") {
5370
+ if (typeof value == "string" && value != "" && value != null && value != undefined) {
5371
+ value = Number(value);
5345
5372
  }
5346
- else {
5373
+ else if (typeof value != "number") {
5347
5374
  value = null;
5348
5375
  }
5349
5376
  }
5377
+ else if (type == "string") {
5378
+ if (typeof value == "number") {
5379
+ value = String(value);
5380
+ }
5381
+ else if (typeof value == "object") {
5382
+ if (isColor(value)) {
5383
+ value = `rgba(${value.red},${value.green},${value.blue},${value.alpha})`;
5384
+ }
5385
+ else {
5386
+ value = null;
5387
+ }
5388
+ }
5389
+ }
5390
+ else if (type == "color") {
5391
+ value = assertColor(typeof value === "number" ? String(value) : value);
5392
+ }
5350
5393
  }
5351
- else if (type == "color") {
5352
- value = assertColor(typeof value === "number" ? String(value) : value);
5353
- }
5394
+ break;
5395
+ }
5396
+ // Extra layer of validation.
5397
+ // This is a backup in case some branch above failed to convert into the right type.
5398
+ if (type == "number") {
5399
+ if (typeof value !== "number" || isNaN(value)) {
5400
+ value = null;
5354
5401
  }
5355
- break;
5356
- }
5357
- // Extra layer of validation.
5358
- // This is a backup in case some branch above failed to convert into the right type.
5359
- if (type == "number") {
5360
- if (typeof value !== "number" || isNaN(value)) {
5361
- value = null;
5362
5402
  }
5363
- }
5364
- else if (type == "color") {
5365
- if (typeof value !== "object" || !value) {
5366
- value = null;
5403
+ else if (type == "color") {
5404
+ if (typeof value !== "object" || !value) {
5405
+ value = null;
5406
+ }
5367
5407
  }
5368
- }
5369
- else if (type == "string") {
5370
- if (typeof value !== "string" || !value) {
5371
- value = null;
5408
+ else if (type == "string") {
5409
+ if (typeof value !== "string" || !value) {
5410
+ value = null;
5411
+ }
5372
5412
  }
5373
5413
  }
5374
5414
  if (value != null) {
@@ -17451,7 +17491,7 @@ var ChangeSet;
17451
17491
  })(ChangeSet || (ChangeSet = {}));
17452
17492
 
17453
17493
  // This is updated with the package.json version on build.
17454
- const VERSION = "7.1.18";
17494
+ const VERSION = "7.1.20";
17455
17495
 
17456
17496
  export { VERSION, Assembly, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, GeoJson, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityTypeTrigger, EntityType, Entity, EntityCoords, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewBookmarkGroup, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, UserMfaMethod, Account, AccountInvite, AccountFeatures, AccountLimits, AccountTemplate, AccountType, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, DataLabGroup, ImportAssembly, ImportCad, ImportCsv, ImportJson, ImportGeoJson, ImportKml, ImportedFile, ExportBrz, ExportUsd, Markup, Uploader, Plugin, ENVIRONMENT, DataSource, Scenario, Tracking, NavigatorChatClient, NavigatorMcpWebSocketClient, ChangeSet };
17457
17497
  //# sourceMappingURL=bruce-models.es5.js.map