bruce-models 3.7.1 → 3.7.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.
@@ -1382,69 +1382,96 @@
1382
1382
  env: this.env
1383
1383
  });
1384
1384
  }
1385
- const env = this.env.toUpperCase();
1386
- const domain = this.getDomain();
1387
- const host = yield exports.HostingLocation.GetByAccountId({
1385
+ const { account } = yield exports.Account.Get({
1388
1386
  accountId: this.accountId,
1389
1387
  api: guardian
1390
1388
  });
1391
- if (host === null || host === void 0 ? void 0 : host.location) {
1392
- const settings = host.location.Settings;
1393
- if (!this.loadCancelled) {
1394
- // Attempt to load regional base url.
1395
- // First try go through settings.
1396
- let urlSet = false;
1397
- if (settings === null || settings === void 0 ? void 0 : settings.BruceAPIURL) {
1398
- let envUrl = settings.BruceAPIURL[env];
1399
- if (envUrl) {
1400
- envUrl = envUrl
1389
+ // Precalculated URLs exist.
1390
+ // Soon this will be a stable requirement for any account record.
1391
+ if (account.URL) {
1392
+ const urls = account.URL;
1393
+ if (urls === null || urls === void 0 ? void 0 : urls.Base) {
1394
+ this.baseUrl = urls.Base;
1395
+ }
1396
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNEntities) {
1397
+ this.EntityCdnUrl = urls.CDNEntities;
1398
+ }
1399
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNTileset) {
1400
+ this.TilesetCdnUrl = urls.CDNTileset;
1401
+ }
1402
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNLegacyTileset) {
1403
+ this.LegacyTilesetCdnUrl = urls.CDNLegacyTileset;
1404
+ }
1405
+ if (urls === null || urls === void 0 ? void 0 : urls.CDNBase) {
1406
+ this.cdnBaseUrl = urls.CDNBase;
1407
+ }
1408
+ }
1409
+ // Deprecated and will eventually stop working at all.
1410
+ else {
1411
+ const env = this.env.toUpperCase();
1412
+ const domain = this.getDomain();
1413
+ const host = yield exports.HostingLocation.GetByAccountId({
1414
+ accountId: this.accountId,
1415
+ api: guardian
1416
+ });
1417
+ if (host === null || host === void 0 ? void 0 : host.location) {
1418
+ const settings = host.location.Settings;
1419
+ if (!this.loadCancelled) {
1420
+ // Attempt to load regional base url.
1421
+ // First try go through settings.
1422
+ let urlSet = false;
1423
+ if (settings === null || settings === void 0 ? void 0 : settings.BruceAPIURL) {
1424
+ let envUrl = settings.BruceAPIURL[env];
1425
+ if (envUrl) {
1426
+ envUrl = envUrl
1427
+ .replace("<ACCOUNTID>", this.accountId)
1428
+ .replace("<ACCOUNT>", this.accountId);
1429
+ if (envUrl && envUrl.length > 1) {
1430
+ this.baseUrl = envUrl;
1431
+ urlSet = true;
1432
+ }
1433
+ }
1434
+ }
1435
+ // Try go through host location's base url.
1436
+ // This may be wrong env which is why it's used as fallback right now.
1437
+ if (!urlSet && host.location.BruceAPIURL) {
1438
+ const regionalUrl = host.location.BruceAPIURL
1401
1439
  .replace("<ACCOUNTID>", this.accountId)
1402
- .replace("<ACCOUNT>", this.accountId);
1403
- if (envUrl && envUrl.length > 1) {
1404
- this.baseUrl = envUrl;
1440
+ .replace("<ACCOUNT>", this.accountId)
1441
+ .replace("<DOMAIN>", domain);
1442
+ if (regionalUrl && regionalUrl.length > 1) {
1443
+ this.baseUrl = regionalUrl;
1405
1444
  urlSet = true;
1406
1445
  }
1407
1446
  }
1408
1447
  }
1409
- // Try go through host location's base url.
1410
- // This may be wrong env which is why it's used as fallback right now.
1411
- if (!urlSet && host.location.BruceAPIURL) {
1412
- const regionalUrl = host.location.BruceAPIURL
1413
- .replace("<ACCOUNTID>", this.accountId)
1414
- .replace("<ACCOUNT>", this.accountId)
1415
- .replace("<DOMAIN>", domain);
1416
- if (regionalUrl && regionalUrl.length > 1) {
1417
- this.baseUrl = regionalUrl;
1418
- urlSet = true;
1419
- }
1420
- }
1421
- }
1422
- // Attempt to load CDN settings.
1423
- if (settings === null || settings === void 0 ? void 0 : settings.CDN) {
1424
- this.EntityCdnUrl = (_a = settings.CDN.entityURL) === null || _a === void 0 ? void 0 : _a[env];
1425
- // We need to fix our configs.
1426
- if (this.EntityCdnUrl) {
1427
- if (this.EntityCdnUrl.includes("entitiesListForCDN")) {
1428
- this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", this.accountId);
1448
+ // Attempt to load CDN settings.
1449
+ if (settings === null || settings === void 0 ? void 0 : settings.CDN) {
1450
+ this.EntityCdnUrl = (_a = settings.CDN.entityURL) === null || _a === void 0 ? void 0 : _a[env];
1451
+ // We need to fix our configs.
1452
+ if (this.EntityCdnUrl) {
1453
+ if (this.EntityCdnUrl.includes("entitiesListForCDN")) {
1454
+ this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", this.accountId);
1455
+ }
1456
+ else {
1457
+ this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", "entitiesListForCDN/" + this.accountId);
1458
+ }
1429
1459
  }
1430
- else {
1431
- this.EntityCdnUrl = this.EntityCdnUrl.replace("<ACCOUNT>", "entitiesListForCDN/" + this.accountId);
1460
+ this.LegacyTilesetCdnUrl = (_b = settings.CDN.legacyTilesetURL) === null || _b === void 0 ? void 0 : _b[env];
1461
+ this.TilesetCdnUrl = (_c = settings.CDN.tilesetURL) === null || _c === void 0 ? void 0 : _c[env];
1462
+ if (this.TilesetCdnUrl) {
1463
+ this.TilesetCdnUrl = this.TilesetCdnUrl.replace("<ACCOUNT>", this.accountId);
1432
1464
  }
1433
- }
1434
- this.LegacyTilesetCdnUrl = (_b = settings.CDN.legacyTilesetURL) === null || _b === void 0 ? void 0 : _b[env];
1435
- this.TilesetCdnUrl = (_c = settings.CDN.tilesetURL) === null || _c === void 0 ? void 0 : _c[env];
1436
- if (this.TilesetCdnUrl) {
1437
- this.TilesetCdnUrl = this.TilesetCdnUrl.replace("<ACCOUNT>", this.accountId);
1438
- }
1439
- // TilesetCdnUrl example: "https://blah.cloudfront.net/tilesets/<TILESETID>/files/<FILEPATH>?accountId=<ACCOUNT>".
1440
- // Lazy at the moment to go around updating every region we have, I'll interpret the url from tilesetCdnUrl.
1441
- if (this.TilesetCdnUrl) {
1442
- try {
1443
- const url = new URL(this.TilesetCdnUrl);
1444
- this.cdnBaseUrl = `${url.protocol}//${url.hostname}/`;
1445
- }
1446
- catch (e) {
1447
- console.error(e);
1465
+ // TilesetCdnUrl example: "https://blah.cloudfront.net/tilesets/<TILESETID>/files/<FILEPATH>?accountId=<ACCOUNT>".
1466
+ // Lazy at the moment to go around updating every region we have, I'll interpret the url from tilesetCdnUrl.
1467
+ if (this.TilesetCdnUrl) {
1468
+ try {
1469
+ const url = new URL(this.TilesetCdnUrl);
1470
+ this.cdnBaseUrl = `${url.protocol}//${url.hostname}/`;
1471
+ }
1472
+ catch (e) {
1473
+ console.error(e);
1474
+ }
1448
1475
  }
1449
1476
  }
1450
1477
  }
@@ -10834,7 +10861,7 @@
10834
10861
  })(exports.DataSource || (exports.DataSource = {}));
10835
10862
 
10836
10863
  // This is updated with the package.json version on build.
10837
- const VERSION = "3.7.1";
10864
+ const VERSION = "3.7.3";
10838
10865
 
10839
10866
  exports.VERSION = VERSION;
10840
10867
  exports.AbstractApi = AbstractApi;