bruce-models 6.7.6 → 6.7.8

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.
@@ -985,7 +985,7 @@ var BruceApi;
985
985
  // Indicates if the init process has finished loading.
986
986
  // While this is not resolved requests will be in a pending state.
987
987
  this.loadProm = Promise.resolve();
988
- let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy } = params;
988
+ let { accountId, env, guardian, loadRegionalBaseUrl, loadConfig, loadWebSocket, dummy, account } = params;
989
989
  this.accountId = accountId;
990
990
  this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
991
991
  if (!dummy) {
@@ -997,16 +997,20 @@ var BruceApi;
997
997
  // Mark it as attempted right away because we don't want any external calls while it gets to that async point.
998
998
  this.configLoadAttempted = true;
999
999
  }
1000
- this.loadProm = this.init(guardian, loadConfig, loadWebSocket);
1000
+ this.loadProm = this.init(guardian, loadConfig, loadWebSocket, account);
1001
1001
  }
1002
1002
  }
1003
1003
  /**
1004
1004
  * Loads regional base url and sets up message broker.
1005
1005
  * @param guardian Required for loading regional base url.
1006
1006
  * @param loadConfig
1007
+ * @param loadWebSocket
1008
+ * @param account
1007
1009
  * @returns
1008
1010
  */
1009
- init(guardian, loadConfig, loadWebSocket) {
1011
+ init(guardian, loadConfig, loadWebSocket,
1012
+ // Preloaded account to save doing an API call.
1013
+ account) {
1010
1014
  return __awaiter(this, void 0, void 0, function* () {
1011
1015
  if (!this.accountId) {
1012
1016
  throw ("accountId is required.");
@@ -1020,7 +1024,8 @@ var BruceApi;
1020
1024
  guardian: guardian,
1021
1025
  // We marked it as attempted to load outside this method to fight any external calls.
1022
1026
  // So we'll force load it now.
1023
- forceLoad: true
1027
+ forceLoad: true,
1028
+ account: account
1024
1029
  });
1025
1030
  }
1026
1031
  // Get the version.
@@ -1075,7 +1080,7 @@ var BruceApi;
1075
1080
  */
1076
1081
  LoadConfig(params) {
1077
1082
  return __awaiter(this, void 0, void 0, function* () {
1078
- let { guardian, forceLoad } = (params !== null && params !== void 0 ? params : {});
1083
+ let { guardian, forceLoad, account } = (params !== null && params !== void 0 ? params : {});
1079
1084
  if (this.configLoadAttempted && forceLoad != true) {
1080
1085
  return;
1081
1086
  }
@@ -1086,10 +1091,12 @@ var BruceApi;
1086
1091
  env: this.env
1087
1092
  });
1088
1093
  }
1089
- const { account } = yield Account.GetBySubdomain({
1090
- subdomain: this.accountId,
1091
- api: guardian
1092
- });
1094
+ if (!account) {
1095
+ account = (yield Account.GetBySubdomain({
1096
+ subdomain: this.accountId,
1097
+ api: guardian
1098
+ })).account;
1099
+ }
1093
1100
  if (!this.loadCancelled) {
1094
1101
  // Set the calculated base url.
1095
1102
  // If this is not available then this is considered a critical failure.
@@ -12049,18 +12056,29 @@ var Account;
12049
12056
  */
12050
12057
  function Get(params) {
12051
12058
  return __awaiter(this, void 0, void 0, function* () {
12052
- let { api, accountId: id, req: reqParams } = params;
12059
+ let { api, accountId: id, req: reqParams, expand, appId } = params;
12053
12060
  if (!api) {
12054
12061
  api = ENVIRONMENT.Api().GetGuardianApi();
12055
12062
  }
12056
- const cacheKey = GetCacheKey(api.GetSessionId(), id);
12063
+ const expandParam = (expand === null || expand === void 0 ? void 0 : expand.length) ? expand.join(",") : undefined;
12064
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId, expandParam);
12057
12065
  const cache = api.GetCacheItem(cacheKey, reqParams);
12058
12066
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12059
12067
  return cache.data;
12060
12068
  }
12061
12069
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
12062
12070
  try {
12063
- const data = yield api.GET(`accountbyid/${id}`, reqParams);
12071
+ let url = `accountbyid/${id}`;
12072
+ let added = false;
12073
+ if (expandParam) {
12074
+ url += (added ? "&" : "?") + `Expand=${expandParam}`;
12075
+ added = true;
12076
+ }
12077
+ if (appId) {
12078
+ url += (added ? "&" : "?") + `App=${encodeURIComponent(appId)}`;
12079
+ added = true;
12080
+ }
12081
+ const data = yield api.GET(url, reqParams);
12064
12082
  // Update the cache by subdomain as well in case it's different to the ID.
12065
12083
  if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
12066
12084
  api.SetCacheItem({
@@ -12088,6 +12106,7 @@ var Account;
12088
12106
  Account.Get = Get;
12089
12107
  /**
12090
12108
  * Returns a client account record by subdomain or ID.
12109
+ * @deprecated use Get() as both will check against ID and subdomain.
12091
12110
  * @param params
12092
12111
  * @returns
12093
12112
  */
@@ -12297,16 +12316,22 @@ var Account;
12297
12316
  * @param sessionId
12298
12317
  * @param accountId
12299
12318
  * @param appSettingsId
12319
+ * @param expandParam Comma delimited list of expand params.
12300
12320
  * @returns
12301
12321
  */
12302
- function GetCacheKey(sessionId, accountId, appSettingsId) {
12322
+ function GetCacheKey(sessionId, accountId, appSettingsId, expandParam) {
12303
12323
  if (!sessionId) {
12304
12324
  sessionId = "anonymous";
12305
12325
  }
12326
+ let cacheKey = [Api.ECacheKey.Account + Api.ECacheKey.Id + accountId];
12327
+ if (expandParam) {
12328
+ cacheKey.push(Api.ECacheKey.Id + expandParam);
12329
+ }
12306
12330
  if (appSettingsId) {
12307
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12331
+ cacheKey.push(Api.ECacheKey + appSettingsId);
12308
12332
  }
12309
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12333
+ cacheKey.push(Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId);
12334
+ return cacheKey.join("");
12310
12335
  }
12311
12336
  Account.GetCacheKey = GetCacheKey;
12312
12337
  /**
@@ -16452,7 +16477,7 @@ var Tracking;
16452
16477
  })(Tracking || (Tracking = {}));
16453
16478
 
16454
16479
  // This is updated with the package.json version on build.
16455
- const VERSION = "6.7.6";
16480
+ const VERSION = "6.7.8";
16456
16481
 
16457
16482
  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, 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 };
16458
16483
  //# sourceMappingURL=bruce-models.es5.js.map