bruce-models 6.7.7 → 6.7.9

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.
@@ -1092,9 +1092,11 @@ var BruceApi;
1092
1092
  });
1093
1093
  }
1094
1094
  if (!account) {
1095
- account = (yield Account.GetBySubdomain({
1096
- subdomain: this.accountId,
1097
- api: guardian
1095
+ account = (yield Account.Get({
1096
+ accountId: this.accountId,
1097
+ api: guardian,
1098
+ appId: ENVIRONMENT.PARAMS.appId,
1099
+ expand: ["limit"]
1098
1100
  })).account;
1099
1101
  }
1100
1102
  if (!this.loadCancelled) {
@@ -1794,7 +1796,9 @@ var ENVIRONMENT;
1794
1796
  // Default environment.
1795
1797
  env: Api.EEnv.PROD,
1796
1798
  // Default session ID.
1797
- sessionId: ENVIRONMENT.GetPageLoadSessionId()
1799
+ sessionId: ENVIRONMENT.GetPageLoadSessionId(),
1800
+ // Default app ID to use when loading account data.
1801
+ appId: null
1798
1802
  };
1799
1803
  // Subscribe to get notified when someone calls Reset.
1800
1804
  // If you are manually updating params, call OnParamsChange.Trigger() to notify others.
@@ -1827,6 +1831,12 @@ var ENVIRONMENT;
1827
1831
  if (ENVIRONMENT.IS_SELF_MANAGED) {
1828
1832
  throw ("Self managed mode ON. You are getting this error because you didn't pass an Api instance to a function.");
1829
1833
  }
1834
+ if (params.appId) {
1835
+ ENVIRONMENT.PARAMS.appId = params.appId;
1836
+ }
1837
+ if (params.env) {
1838
+ ENVIRONMENT.PARAMS.env = params.env;
1839
+ }
1830
1840
  if (_getters) {
1831
1841
  _getters.ClearCache();
1832
1842
  if (params.accountId) {
@@ -12056,18 +12066,29 @@ var Account;
12056
12066
  */
12057
12067
  function Get(params) {
12058
12068
  return __awaiter(this, void 0, void 0, function* () {
12059
- let { api, accountId: id, req: reqParams } = params;
12069
+ let { api, accountId: id, req: reqParams, expand, appId } = params;
12060
12070
  if (!api) {
12061
12071
  api = ENVIRONMENT.Api().GetGuardianApi();
12062
12072
  }
12063
- const cacheKey = GetCacheKey(api.GetSessionId(), id);
12073
+ const expandParam = (expand === null || expand === void 0 ? void 0 : expand.length) ? expand.join(",") : undefined;
12074
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId, expandParam);
12064
12075
  const cache = api.GetCacheItem(cacheKey, reqParams);
12065
12076
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12066
12077
  return cache.data;
12067
12078
  }
12068
12079
  const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
12069
12080
  try {
12070
- const data = yield api.GET(`accountbyid/${id}`, reqParams);
12081
+ let url = `accountbyid/${id}`;
12082
+ let added = false;
12083
+ if (expandParam) {
12084
+ url += (added ? "&" : "?") + `Expand=${expandParam}`;
12085
+ added = true;
12086
+ }
12087
+ if (appId) {
12088
+ url += (added ? "&" : "?") + `App=${encodeURIComponent(appId)}`;
12089
+ added = true;
12090
+ }
12091
+ const data = yield api.GET(url, reqParams);
12071
12092
  // Update the cache by subdomain as well in case it's different to the ID.
12072
12093
  if ((data === null || data === void 0 ? void 0 : data.ID) && (reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache) != false) {
12073
12094
  api.SetCacheItem({
@@ -12095,6 +12116,7 @@ var Account;
12095
12116
  Account.Get = Get;
12096
12117
  /**
12097
12118
  * Returns a client account record by subdomain or ID.
12119
+ * @deprecated use Get() as both will check against ID and subdomain.
12098
12120
  * @param params
12099
12121
  * @returns
12100
12122
  */
@@ -12304,16 +12326,22 @@ var Account;
12304
12326
  * @param sessionId
12305
12327
  * @param accountId
12306
12328
  * @param appSettingsId
12329
+ * @param expandParam Comma delimited list of expand params.
12307
12330
  * @returns
12308
12331
  */
12309
- function GetCacheKey(sessionId, accountId, appSettingsId) {
12332
+ function GetCacheKey(sessionId, accountId, appSettingsId, expandParam) {
12310
12333
  if (!sessionId) {
12311
12334
  sessionId = "anonymous";
12312
12335
  }
12336
+ let cacheKey = [Api.ECacheKey.Account + Api.ECacheKey.Id + accountId];
12337
+ if (expandParam) {
12338
+ cacheKey.push(Api.ECacheKey.Id + expandParam);
12339
+ }
12313
12340
  if (appSettingsId) {
12314
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12341
+ cacheKey.push(Api.ECacheKey + appSettingsId);
12315
12342
  }
12316
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12343
+ cacheKey.push(Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId);
12344
+ return cacheKey.join("");
12317
12345
  }
12318
12346
  Account.GetCacheKey = GetCacheKey;
12319
12347
  /**
@@ -14220,28 +14248,16 @@ var AccountLimits;
14220
14248
  api = ENVIRONMENT.Api().GetGuardianApi();
14221
14249
  }
14222
14250
  req = Api.PrepReqParams(req);
14223
- const cacheData = api.GetCacheItem(GetLimitsCacheKey(accountId));
14224
- if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
14225
- return cacheData.data;
14226
- }
14227
- const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
14228
- try {
14229
- const data = yield api.GET(`account/${accountId}?WithLimits=true`);
14230
- const limits = data.Limits ? data.Limits : {};
14231
- res({
14232
- limits: limits
14233
- });
14234
- }
14235
- catch (e) {
14236
- rej(e);
14237
- }
14238
- }));
14239
- api.SetCacheItem({
14240
- key: GetLimitsCacheKey(accountId),
14241
- value: prom,
14242
- req: req
14251
+ const { account } = yield Account.Get({
14252
+ accountId: accountId,
14253
+ api: api,
14254
+ expand: ["limit"],
14255
+ appId: ENVIRONMENT.PARAMS.appId
14243
14256
  });
14244
- return prom;
14257
+ const limits = account["Limits"] || {};
14258
+ return {
14259
+ limits: limits
14260
+ };
14245
14261
  });
14246
14262
  }
14247
14263
  AccountLimits$$1.GetLimits = GetLimits;
@@ -14831,14 +14847,6 @@ var AccountLimits;
14831
14847
  }
14832
14848
  Assert.GetDenyPublicAccess = GetDenyPublicAccess;
14833
14849
  })(Assert = AccountLimits$$1.Assert || (AccountLimits$$1.Assert = {}));
14834
- /**
14835
- * Cache key for requesting account limits for a specific account.
14836
- * @param accountId
14837
- */
14838
- function GetLimitsCacheKey(accountId) {
14839
- return Api.ECacheKey.AccountLimits + Api.ECacheKey.Id + accountId;
14840
- }
14841
- AccountLimits$$1.GetLimitsCacheKey = GetLimitsCacheKey;
14842
14850
  })(AccountLimits || (AccountLimits = {}));
14843
14851
 
14844
14852
  /**
@@ -16459,7 +16467,7 @@ var Tracking;
16459
16467
  })(Tracking || (Tracking = {}));
16460
16468
 
16461
16469
  // This is updated with the package.json version on build.
16462
- const VERSION = "6.7.7";
16470
+ const VERSION = "6.7.9";
16463
16471
 
16464
16472
  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 };
16465
16473
  //# sourceMappingURL=bruce-models.es5.js.map