bruce-models 4.2.1 → 4.2.3

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.
@@ -1318,6 +1318,9 @@
1318
1318
  get ConfigLoadAttempted() {
1319
1319
  return this.configLoadAttempted;
1320
1320
  }
1321
+ get Version() {
1322
+ return this.version;
1323
+ }
1321
1324
  get Loading() {
1322
1325
  return this.loadProm;
1323
1326
  }
@@ -1367,6 +1370,16 @@
1367
1370
  forceLoad: true
1368
1371
  });
1369
1372
  }
1373
+ // Get the version.
1374
+ if (this.baseUrl) {
1375
+ const data = yield this.get(this.baseUrl + "version");
1376
+ if (data === null || data === void 0 ? void 0 : data["Bruce-API"]) {
1377
+ this.version = data["Bruce-API"];
1378
+ }
1379
+ else {
1380
+ this.version = "UNKNOWN";
1381
+ }
1382
+ }
1370
1383
  // Start web socket connection.
1371
1384
  if (loadWebSocket == true) {
1372
1385
  try {
@@ -1424,21 +1437,23 @@
1424
1437
  // Precalculated URLs exist.
1425
1438
  // Soon this will be a stable requirement for any account record.
1426
1439
  if (account.URL) {
1427
- const urls = account.URL;
1428
- if (urls === null || urls === void 0 ? void 0 : urls.Base) {
1429
- this.baseUrl = urls.Base;
1430
- }
1431
- if (urls === null || urls === void 0 ? void 0 : urls.CDNEntities) {
1432
- this.EntityCdnUrl = urls.CDNEntities;
1433
- }
1434
- if (urls === null || urls === void 0 ? void 0 : urls.CDNTileset) {
1435
- this.TilesetCdnUrl = urls.CDNTileset;
1436
- }
1437
- if (urls === null || urls === void 0 ? void 0 : urls.CDNLegacyTileset) {
1438
- this.LegacyTilesetCdnUrl = urls.CDNLegacyTileset;
1439
- }
1440
- if (urls === null || urls === void 0 ? void 0 : urls.CDNBase) {
1441
- this.cdnBaseUrl = urls.CDNBase;
1440
+ if (!this.loadCancelled) {
1441
+ const urls = account.URL;
1442
+ if (urls === null || urls === void 0 ? void 0 : urls.Base) {
1443
+ this.baseUrl = urls.Base;
1444
+ }
1445
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNEntities) {
1446
+ this.EntityCdnUrl = urls.CDNEntities;
1447
+ }
1448
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNTileset) {
1449
+ this.TilesetCdnUrl = urls.CDNTileset;
1450
+ }
1451
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNLegacyTileset) {
1452
+ this.LegacyTilesetCdnUrl = urls.CDNLegacyTileset;
1453
+ }
1454
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNBase) {
1455
+ this.cdnBaseUrl = urls.CDNBase;
1456
+ }
1442
1457
  }
1443
1458
  }
1444
1459
  // Deprecated and will eventually stop working at all.
@@ -3499,6 +3514,7 @@
3499
3514
  Entity.Update = Update;
3500
3515
  /**
3501
3516
  * Util to remove a tag from an entity.
3517
+ * @warning This does not save the entity record.
3502
3518
  * @param params
3503
3519
  */
3504
3520
  function RemoveTag(params) {
@@ -3514,6 +3530,7 @@
3514
3530
  Entity.RemoveTag = RemoveTag;
3515
3531
  /**
3516
3532
  * Util to add a tag to an entity.
3533
+ * @warning This does not save the entity record.
3517
3534
  * @param params
3518
3535
  */
3519
3536
  function AddTag(params) {
@@ -3528,6 +3545,7 @@
3528
3545
  Entity.AddTag = AddTag;
3529
3546
  /**
3530
3547
  * Util to set a value on an entity.
3548
+ * @warning This does not save the entity record.
3531
3549
  * @param params
3532
3550
  */
3533
3551
  function SetValue(params) {
@@ -3553,28 +3571,71 @@
3553
3571
  */
3554
3572
  function GetValue(params) {
3555
3573
  var _a;
3556
- const { entity: data, path } = params;
3557
- // Backwards compatibility.
3558
- if (path.length == 1 && path[0] == "ID") {
3574
+ let { entity: data, path, handleLegacy: checkAgainstLegacy } = params;
3575
+ if (checkAgainstLegacy == null) {
3576
+ checkAgainstLegacy = true;
3577
+ }
3578
+ // Backwards compatibility for incredibly old data.
3579
+ if (checkAgainstLegacy && path.length == 1 && path[0] == "ID") {
3559
3580
  return (_a = data.Bruce) === null || _a === void 0 ? void 0 : _a.ID;
3560
3581
  }
3561
- let curData = data;
3562
- for (let i = 0; i < path.length; i++) {
3563
- const step = path[i];
3564
- if (!curData[step]) {
3565
- return null;
3582
+ const checkForValue = (path) => {
3583
+ let curData = data;
3584
+ for (let i = 0; i < path.length; i++) {
3585
+ const step = path[i];
3586
+ if (!curData[step]) {
3587
+ return null;
3588
+ }
3589
+ if (i >= path.length - 1) {
3590
+ return curData[step];
3591
+ }
3592
+ curData = curData[step];
3566
3593
  }
3567
- if (i >= path.length - 1) {
3568
- return curData[step];
3594
+ return null;
3595
+ };
3596
+ // Check using the path provided.
3597
+ let value = checkForValue(path);
3598
+ // Check for the same path but in both top-level and internal data.
3599
+ // This is done for specific paths we're migrating.
3600
+ if (value == null && checkAgainstLegacy) {
3601
+ // We're migrating 2D vector data into the internal data.
3602
+ // So we'll check against both locations until migration is complete.
3603
+ // First we'll check against properties that could be found inside the internal section.
3604
+ if (path[0] == "location") {
3605
+ value = checkForValue(["Bruce"].concat(path));
3606
+ }
3607
+ else if (path[0] == "transform") {
3608
+ value = checkForValue(["Bruce"].concat(path));
3609
+ }
3610
+ else if (path[0] == "geometry") {
3611
+ value = checkForValue(["Bruce"].concat(path));
3612
+ }
3613
+ else if (path[0] == "boundaries") {
3614
+ value = checkForValue(["Bruce"].concat(path));
3615
+ }
3616
+ // Now we'll check against properties that could still be in the top-level and haven't been migrated yet.
3617
+ if (path[0] == "Bruce" && path.length > 1) {
3618
+ if (path[1] == "location") {
3619
+ value = checkForValue(path.slice(1));
3620
+ }
3621
+ else if (path[1] == "transform") {
3622
+ value = checkForValue(path.slice(1));
3623
+ }
3624
+ else if (path[1] == "geometry") {
3625
+ value = checkForValue(path.slice(1));
3626
+ }
3627
+ else if (path[1] == "boundaries") {
3628
+ value = checkForValue(path.slice(1));
3629
+ }
3569
3630
  }
3570
- curData = curData[step];
3571
3631
  }
3572
- return null;
3632
+ return value;
3573
3633
  }
3574
3634
  Entity.GetValue = GetValue;
3575
3635
  /**
3576
3636
  * Removes a value from an entity.
3577
3637
  * This will mutate the entity record and run "delete" on the object property.
3638
+ * @warning This does not save the entity record.
3578
3639
  * @param params
3579
3640
  */
3580
3641
  function RemoveValue(params) {
@@ -12898,7 +12959,7 @@
12898
12959
  })(exports.DataSource || (exports.DataSource = {}));
12899
12960
 
12900
12961
  // This is updated with the package.json version on build.
12901
- const VERSION = "4.2.1";
12962
+ const VERSION = "4.2.3";
12902
12963
 
12903
12964
  exports.VERSION = VERSION;
12904
12965
  exports.AbstractApi = AbstractApi;