bruce-models 3.2.4 → 3.2.6

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.
@@ -1142,13 +1142,28 @@ var HostingLocation;
1142
1142
  */
1143
1143
  function GetKeyByAccountId(params) {
1144
1144
  return __awaiter(this, void 0, void 0, function* () {
1145
- let { accountId, apiSettings, api, req } = params;
1145
+ let { accountId, apiSettings, api, account, req } = params;
1146
1146
  if (!accountId && !apiSettings) {
1147
1147
  throw ("Invalid accountId or apiSettings");
1148
1148
  }
1149
1149
  if (!api) {
1150
1150
  api = ENVIRONMENT.Api().GetGuardianApi();
1151
1151
  }
1152
+ // We'll prioritize account record if provided.
1153
+ if (accountId && !account) {
1154
+ account = (yield Account.Get({
1155
+ accountId,
1156
+ api,
1157
+ req
1158
+ })).account;
1159
+ }
1160
+ if (account === null || account === void 0 ? void 0 : account["HostingLocation.Key"]) {
1161
+ return {
1162
+ key: account["HostingLocation.Key"],
1163
+ isLegacy: false
1164
+ };
1165
+ }
1166
+ // Fallback to settings JSON for older records.
1152
1167
  const settings = apiSettings ? apiSettings : (yield Account.GetAppSettings({
1153
1168
  api,
1154
1169
  accountId,
@@ -1180,12 +1195,13 @@ var HostingLocation;
1180
1195
  */
1181
1196
  function GetByAccountId(params) {
1182
1197
  return __awaiter(this, void 0, void 0, function* () {
1183
- let { accountId, apiSettings, api, req } = params;
1198
+ let { accountId, apiSettings, api, req, account } = params;
1184
1199
  if (!api) {
1185
1200
  api = ENVIRONMENT.Api().GetGuardianApi();
1186
1201
  }
1187
1202
  const data = yield GetKeyByAccountId({
1188
1203
  accountId,
1204
+ account,
1189
1205
  apiSettings,
1190
1206
  api,
1191
1207
  req
@@ -1376,6 +1392,25 @@ var BruceApi;
1376
1392
  GetCdnBaseUrl() {
1377
1393
  return this.cdnBaseUrl;
1378
1394
  }
1395
+ /**
1396
+ * Returns a url routed through the API's CDN.
1397
+ * If the CDN is not enabled for the account, this will return null.
1398
+ * @param url suffix to append to the base url.
1399
+ * @param urlParams
1400
+ * @returns
1401
+ */
1402
+ ConstructCdnUrl(url, urlParams) {
1403
+ if (!this.cdnBaseUrl) {
1404
+ return null;
1405
+ }
1406
+ let cdnUrl = this.cdnBaseUrl + url;
1407
+ if (!urlParams) {
1408
+ urlParams = new URLSearchParams();
1409
+ }
1410
+ urlParams.set("accountId", this.accountId);
1411
+ cdnUrl += "?" + urlParams.toString();
1412
+ return cdnUrl;
1413
+ }
1379
1414
  /**
1380
1415
  * Warning: This will cancel the init process.
1381
1416
  * The init process loads a region specific endpoint.
@@ -1689,7 +1724,7 @@ class ApiGetters {
1689
1724
  if (!params) {
1690
1725
  params = {};
1691
1726
  }
1692
- let { accountId, env } = params;
1727
+ let { accountId, env, loadConfig, loadWebSocket } = params;
1693
1728
  accountId = accountId ? accountId : this.accountId;
1694
1729
  env = env ? env : this.env;
1695
1730
  const key = `${accountId}-${env}`;
@@ -1697,7 +1732,11 @@ class ApiGetters {
1697
1732
  this.bruce[key] = new BruceApi.Api({
1698
1733
  accountId,
1699
1734
  env,
1700
- loadRegionalBaseUrl: true
1735
+ loadConfig: loadConfig,
1736
+ loadWebSocket: loadWebSocket,
1737
+ guardian: this.GetGuardianApi({
1738
+ env
1739
+ }),
1701
1740
  });
1702
1741
  this.bruce[key].SetSessionId(this.sessionId);
1703
1742
  }
@@ -1714,7 +1753,12 @@ class ApiGetters {
1714
1753
  accountId: this.accountId,
1715
1754
  env: this.env,
1716
1755
  getApi: (accountId, env) => {
1717
- return this.GetBruceApi({ accountId, env });
1756
+ return this.GetBruceApi({
1757
+ accountId,
1758
+ env,
1759
+ loadWebSocket: this.accountId == accountId,
1760
+ loadConfig: this.accountId == accountId
1761
+ });
1718
1762
  }
1719
1763
  };
1720
1764
  }
@@ -6296,11 +6340,16 @@ var ClientFile;
6296
6340
  * @returns
6297
6341
  */
6298
6342
  function GetUrl(params) {
6299
- let { api, fileId } = params;
6343
+ let { api, fileId, viaCdn } = params;
6300
6344
  if (!api) {
6301
6345
  api = ENVIRONMENT.Api().GetBruceApi();
6302
6346
  }
6303
- return `${api.GetBaseUrl()}file/${fileId}`;
6347
+ const urlSuffix = `file/${fileId}`;
6348
+ const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
6349
+ if (cdnUrl) {
6350
+ return cdnUrl;
6351
+ }
6352
+ return `${api.GetBaseUrl()}${urlSuffix}`;
6304
6353
  }
6305
6354
  ClientFile.GetUrl = GetUrl;
6306
6355
  /**
@@ -6309,11 +6358,16 @@ var ClientFile;
6309
6358
  * @returns
6310
6359
  */
6311
6360
  function GetUrlWithExt(params) {
6312
- let { api, file } = params;
6361
+ let { api, file, viaCdn } = params;
6313
6362
  if (!api) {
6314
6363
  api = ENVIRONMENT.Api().GetBruceApi();
6315
6364
  }
6316
- return `${api.GetBaseUrl()}file/${file.ID}${file.FileExt ? file.FileExt : ""}`;
6365
+ const urlSuffix = file.FileExt ? `file/${file.ID}${file.FileExt}` : `file/${file.ID}`;
6366
+ const cdnUrl = viaCdn ? api.ConstructCdnUrl(urlSuffix) : null;
6367
+ if (cdnUrl) {
6368
+ return cdnUrl;
6369
+ }
6370
+ return `${api.GetBaseUrl()}${urlSuffix}`;
6317
6371
  }
6318
6372
  ClientFile.GetUrlWithExt = GetUrlWithExt;
6319
6373
  /**
@@ -10482,7 +10536,7 @@ var DataSource;
10482
10536
  DataSource.GetList = GetList;
10483
10537
  })(DataSource || (DataSource = {}));
10484
10538
 
10485
- const VERSION = "3.2.4";
10539
+ const VERSION = "3.2.6";
10486
10540
 
10487
10541
  export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
10488
10542
  //# sourceMappingURL=bruce-models.es5.js.map