bruce-models 7.1.46 → 7.1.48

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.
@@ -1460,6 +1460,8 @@
1460
1460
  })(exports.GuardianApi || (exports.GuardianApi = {}));
1461
1461
 
1462
1462
  (function (BruceApi) {
1463
+ // Minimum API version that supports server-side token proxies.
1464
+ BruceApi.VERSION_WITH_PROXIES = "1.0.6437";
1463
1465
  /**
1464
1466
  * This is the request handler for Bruce Api,
1465
1467
  * it should be passed to any method that wants to communicate with this particular api.
@@ -1563,6 +1565,16 @@
1563
1565
  this.version = "UNKNOWN";
1564
1566
  }
1565
1567
  }
1568
+ // Same version as the proxy-update we started supporting an accountId/subdomain prefix.
1569
+ // We can upgrade URLs automatically so anything using them for proxies doesn't have to manage query params.
1570
+ // Eg: "/v3/entity/abc?accountId=template" would become "/A:template/v3/entity/abc".
1571
+ if (this.IsVersionAtLeast(BruceApi.VERSION_WITH_PROXIES)) {
1572
+ this.baseUrl = Api$$1.rewriteAccountIdToPath(this.baseUrl);
1573
+ this.cdnBaseUrl = Api$$1.rewriteAccountIdToPath(this.cdnBaseUrl);
1574
+ this.EntityCdnUrl = Api$$1.rewriteAccountIdToPath(this.EntityCdnUrl);
1575
+ this.TilesetCdnUrl = Api$$1.rewriteAccountIdToPath(this.TilesetCdnUrl);
1576
+ this.LegacyTilesetCdnUrl = Api$$1.rewriteAccountIdToPath(this.LegacyTilesetCdnUrl);
1577
+ }
1566
1578
  // Start web socket connection.
1567
1579
  if (loadWebSocket == true) {
1568
1580
  try {
@@ -1576,6 +1588,34 @@
1576
1588
  }
1577
1589
  });
1578
1590
  }
1591
+ /**
1592
+ * Moves query param specified accountId/subdomain to be a prefix segment in the URL path.
1593
+ * Eg: "/v3/entity/abc?accountId=template" would become "/A:template/v3/entity/abc".
1594
+ * If no accountId param is present or the URL is invalid, returns the URL unchanged.
1595
+ */
1596
+ static rewriteAccountIdToPath(url) {
1597
+ if (!url) {
1598
+ return url;
1599
+ }
1600
+ try {
1601
+ const parsed = new URL(url);
1602
+ const accountId = parsed.searchParams.get("accountId");
1603
+ if (!accountId) {
1604
+ return url;
1605
+ }
1606
+ parsed.searchParams.delete("accountId");
1607
+ // Prepend A:<id>/ to the existing pathname.
1608
+ let path = parsed.pathname;
1609
+ if (!path.endsWith("/")) {
1610
+ path += "/";
1611
+ }
1612
+ parsed.pathname = path + `A:${accountId}/`;
1613
+ return parsed.toString();
1614
+ }
1615
+ catch (e) {
1616
+ return url;
1617
+ }
1618
+ }
1579
1619
  getDomain() {
1580
1620
  const env = this.env.toUpperCase();
1581
1621
  let domain = "nextspace.host";
@@ -18608,7 +18648,7 @@
18608
18648
  })(exports.UrlUtils || (exports.UrlUtils = {}));
18609
18649
 
18610
18650
  // This is updated with the package.json version on build.
18611
- const VERSION = "7.1.46";
18651
+ const VERSION = "7.1.48";
18612
18652
 
18613
18653
  exports.VERSION = VERSION;
18614
18654
  exports.AbstractApi = AbstractApi;