bruce-models 6.4.7 → 6.4.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.
@@ -11916,7 +11916,8 @@ var Account;
11916
11916
  if (!api) {
11917
11917
  api = ENVIRONMENT.Api().GetGuardianApi();
11918
11918
  }
11919
- const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
11919
+ const cacheKey = GetCacheKey(api.GetSessionId(), id);
11920
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11920
11921
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11921
11922
  return cache.data;
11922
11923
  }
@@ -11940,7 +11941,7 @@ var Account;
11940
11941
  }
11941
11942
  }));
11942
11943
  api.SetCacheItem({
11943
- key: GetCacheKey(id),
11944
+ key: cacheKey,
11944
11945
  value: prom,
11945
11946
  req: reqParams
11946
11947
  });
@@ -11959,7 +11960,8 @@ var Account;
11959
11960
  if (!api) {
11960
11961
  api = ENVIRONMENT.Api().GetGuardianApi();
11961
11962
  }
11962
- const cache = api.GetCacheItem(GetCacheKey(subdomain), reqParams);
11963
+ const cacheKey = GetCacheKey(api.GetSessionId(), subdomain);
11964
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11963
11965
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11964
11966
  return cache.data;
11965
11967
  }
@@ -11983,7 +11985,7 @@ var Account;
11983
11985
  }
11984
11986
  }));
11985
11987
  api.SetCacheItem({
11986
- key: GetCacheKey(subdomain),
11988
+ key: cacheKey,
11987
11989
  value: prom,
11988
11990
  req: reqParams
11989
11991
  });
@@ -12002,7 +12004,8 @@ var Account;
12002
12004
  if (!api) {
12003
12005
  api = ENVIRONMENT.Api().GetGuardianApi();
12004
12006
  }
12005
- const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId(), owned), reqParams);
12007
+ const cacheKey = GetListCacheKey(api.GetSessionId(), userId, owned);
12008
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12006
12009
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12007
12010
  return cache.data;
12008
12011
  }
@@ -12028,7 +12031,7 @@ var Account;
12028
12031
  }
12029
12032
  }));
12030
12033
  api.SetCacheItem({
12031
- key: GetListCacheKey(api.GetSessionId(), owned),
12034
+ key: cacheKey,
12032
12035
  value: prom,
12033
12036
  req: reqParams
12034
12037
  });
@@ -12047,7 +12050,8 @@ var Account;
12047
12050
  if (!api) {
12048
12051
  api = ENVIRONMENT.Api().GetGuardianApi();
12049
12052
  }
12050
- const cache = api.GetCacheItem(GetCacheKey(id, appId), reqParams);
12053
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId);
12054
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12051
12055
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12052
12056
  return cache.data;
12053
12057
  }
@@ -12066,7 +12070,7 @@ var Account;
12066
12070
  }
12067
12071
  }));
12068
12072
  api.SetCacheItem({
12069
- key: GetCacheKey(id, appId),
12073
+ key: cacheKey,
12070
12074
  value: prom,
12071
12075
  req: reqParams
12072
12076
  });
@@ -12087,7 +12091,7 @@ var Account;
12087
12091
  api = ENVIRONMENT.Api().GetGuardianApi();
12088
12092
  }
12089
12093
  const res = yield api.POST(`account/${id}/applicationSettings/${appId}?Override=${override ? "true" : "false"}`, data, reqParams);
12090
- api.Cache.RemoveByStartsWith(Api.ECacheKey.Account + Api.ECacheKey.Id + id);
12094
+ api.Cache.RemoveByContains(Api.ECacheKey.Account + Api.ECacheKey.Id + id);
12091
12095
  return {
12092
12096
  settings: res
12093
12097
  };
@@ -12120,7 +12124,7 @@ var Account;
12120
12124
  const resData = {
12121
12125
  account: res
12122
12126
  };
12123
- api.Cache.RemoveByStartsWith(GetListCacheKey(api.GetSessionId()));
12127
+ api.Cache.RemoveByContains(GetListCacheKey(api.GetSessionId()));
12124
12128
  return resData;
12125
12129
  });
12126
12130
  }
@@ -12153,15 +12157,19 @@ var Account;
12153
12157
  * const key = GetCacheKey(1);
12154
12158
  * api.Cache.Remove(key);
12155
12159
  * }
12160
+ * @param sessionId
12156
12161
  * @param accountId
12157
12162
  * @param appSettingsId
12158
12163
  * @returns
12159
12164
  */
12160
- function GetCacheKey(accountId, appSettingsId) {
12165
+ function GetCacheKey(sessionId, accountId, appSettingsId) {
12166
+ if (!sessionId) {
12167
+ sessionId = "anonymous";
12168
+ }
12161
12169
  if (appSettingsId) {
12162
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId;
12170
+ return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12163
12171
  }
12164
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
12172
+ return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12165
12173
  }
12166
12174
  Account.GetCacheKey = GetCacheKey;
12167
12175
  /**
@@ -12174,11 +12182,17 @@ var Account;
12174
12182
  * @param ssid
12175
12183
  * @returns
12176
12184
  */
12177
- function GetListCacheKey(ssid, owned) {
12185
+ function GetListCacheKey(ssid, userId, owned) {
12178
12186
  if (!owned) {
12179
12187
  owned = false;
12180
12188
  }
12181
- return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid + Api.ECacheKey.Id + (owned ? "owned" : "related");
12189
+ if (!ssid) {
12190
+ ssid = "anonymous";
12191
+ }
12192
+ if (!userId) {
12193
+ userId = "anonymous";
12194
+ }
12195
+ return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid + Api.ECacheKey.Id + (owned ? "owned" : "related") + Api.ECacheKey.User + Api.ECacheKey.Id + userId;
12182
12196
  }
12183
12197
  Account.GetListCacheKey = GetListCacheKey;
12184
12198
  /**
@@ -12712,6 +12726,41 @@ var User;
12712
12726
  // Access token. Used to gain access to related permissions.
12713
12727
  EType["AccessToken"] = "ACCESS_TOKEN";
12714
12728
  })(EType = User$$1.EType || (User$$1.EType = {}));
12729
+ /**
12730
+ * Returns an array of User Group IDs for the User that have been loaded.
12731
+ * Note, this does not perform an API lookup if the User instance hasn't loaded the specific account's details.
12732
+ * @param params
12733
+ * @returns
12734
+ */
12735
+ function UnpackRelatedUserGroupIDs(params) {
12736
+ var _a, _b;
12737
+ const { user, accountId } = params;
12738
+ if (!user || !accountId) {
12739
+ throw ("User and accountId are required.");
12740
+ }
12741
+ let accessPerms = user.AccessPermissions;
12742
+ if (!accessPerms || !Array.isArray(accessPerms) || accessPerms.length === 0) {
12743
+ return [];
12744
+ }
12745
+ for (const perm of accessPerms) {
12746
+ if (!perm || perm["ClientAccount.ID"] !== accountId) {
12747
+ continue;
12748
+ }
12749
+ else if ((_a = perm["UserGroup.ID"]) === null || _a === void 0 ? void 0 : _a.length) {
12750
+ return perm["UserGroup.ID"];
12751
+ }
12752
+ else if ((_b = perm.UserGroups) === null || _b === void 0 ? void 0 : _b.length) {
12753
+ if (typeof perm.UserGroups[0] === "string") {
12754
+ return perm.UserGroups;
12755
+ }
12756
+ else if (typeof perm.UserGroups[0] === "object") {
12757
+ return perm.UserGroups.map(group => group.ID);
12758
+ }
12759
+ }
12760
+ }
12761
+ return [];
12762
+ }
12763
+ User$$1.UnpackRelatedUserGroupIDs = UnpackRelatedUserGroupIDs;
12715
12764
  /**
12716
12765
  * Gets a user record.
12717
12766
  * @param params
@@ -12726,7 +12775,7 @@ var User;
12726
12775
  if (!api) {
12727
12776
  api = ENVIRONMENT.Api().GetGuardianApi();
12728
12777
  }
12729
- const cacheKey = GetCacheKey(id, accountId);
12778
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, accountId);
12730
12779
  const cache = api.GetCacheItem(cacheKey, reqParams);
12731
12780
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12732
12781
  return cache.data;
@@ -12790,10 +12839,10 @@ var User;
12790
12839
  const res = yield api.POST(`user/${data.ID}`, data, reqParams);
12791
12840
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + data.ID);
12792
12841
  if (data.Type == EType.AccessToken) {
12793
- api.Cache.RemoveByStartsWith(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
12842
+ api.Cache.RemoveByContains(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
12794
12843
  }
12795
12844
  else if (data.Type == EType.User) {
12796
- api.Cache.RemoveByStartsWith(Api.ECacheKey.User + Api.ECacheKey.Account);
12845
+ api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Account);
12797
12846
  }
12798
12847
  return {
12799
12848
  user: res
@@ -12824,7 +12873,7 @@ var User;
12824
12873
  }
12825
12874
  const res = yield api.POST("user", data, reqParams);
12826
12875
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + data.ID);
12827
- api.Cache.RemoveByStartsWith(Api.ECacheKey.User + Api.ECacheKey.Account);
12876
+ api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Account);
12828
12877
  return {
12829
12878
  user: res
12830
12879
  };
@@ -12845,7 +12894,8 @@ var User;
12845
12894
  if (!api) {
12846
12895
  api = ENVIRONMENT.Api().GetGuardianApi();
12847
12896
  }
12848
- const cache = api.GetCacheItem(GetSettingsCacheKey(userId, appId), req);
12897
+ const cacheKey = GetSettingsCacheKey(api.GetSessionId(), userId, appId);
12898
+ const cache = api.GetCacheItem(cacheKey, req);
12849
12899
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12850
12900
  return cache.data;
12851
12901
  }
@@ -12872,7 +12922,7 @@ var User;
12872
12922
  }
12873
12923
  }));
12874
12924
  api.SetCacheItem({
12875
- key: GetSettingsCacheKey(userId, appId),
12925
+ key: cacheKey,
12876
12926
  value: prom,
12877
12927
  req: req
12878
12928
  });
@@ -12902,7 +12952,7 @@ var User;
12902
12952
  UserID: userId
12903
12953
  };
12904
12954
  const prom = api.POST(`user/${userId}/application/${appId}/settings?Override=${override ? "true" : "false"}`, postBody, req);
12905
- api.Cache.Remove(GetSettingsCacheKey(userId, appId));
12955
+ api.Cache.Remove(GetSettingsCacheKey(api.GetSessionId(), userId, appId));
12906
12956
  return prom;
12907
12957
  });
12908
12958
  }
@@ -12951,14 +13001,20 @@ var User;
12951
13001
  * @param search
12952
13002
  * @returns
12953
13003
  */
12954
- function GetListCacheKey(accountId, exclusive, search) {
13004
+ function GetListCacheKey(sessionId, accountId, exclusive, search) {
12955
13005
  if (!exclusive) {
12956
13006
  exclusive = false;
12957
13007
  }
12958
13008
  if (!search) {
12959
13009
  search = "";
12960
13010
  }
12961
- return Api.ECacheKey.User + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Id + exclusive + Api.ECacheKey.Id + search;
13011
+ if (!sessionId) {
13012
+ sessionId = "anonymous";
13013
+ }
13014
+ if (!accountId) {
13015
+ accountId = "";
13016
+ }
13017
+ return Api.ECacheKey.User + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Id + exclusive + Api.ECacheKey.Id + search + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12962
13018
  }
12963
13019
  LoginUser.GetListCacheKey = GetListCacheKey;
12964
13020
  /**
@@ -12975,7 +13031,8 @@ var User;
12975
13031
  if (!api) {
12976
13032
  api = ENVIRONMENT.Api().GetGuardianApi();
12977
13033
  }
12978
- const cache = api.GetCacheItem(GetEmailCacheKey(email, accountId), reqParams);
13034
+ const cacheKey = GetEmailCacheKey(api.GetSessionId(), email, accountId);
13035
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12979
13036
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12980
13037
  return cache.data;
12981
13038
  }
@@ -12991,7 +13048,7 @@ var User;
12991
13048
  }
12992
13049
  }));
12993
13050
  api.SetCacheItem({
12994
- key: GetEmailCacheKey(email, accountId),
13051
+ key: cacheKey,
12995
13052
  value: prom,
12996
13053
  req: reqParams
12997
13054
  });
@@ -13013,7 +13070,8 @@ var User;
13013
13070
  if (!exclusive) {
13014
13071
  exclusive = false;
13015
13072
  }
13016
- const cacheKey = GetListCacheKey(accountId, exclusive, search);
13073
+ const sessionId = api.GetSessionId();
13074
+ const cacheKey = GetListCacheKey(sessionId, accountId, exclusive, search);
13017
13075
  const cache = exclusive ? null : api.GetCacheItem(cacheKey, reqParams);
13018
13076
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13019
13077
  return cache.data;
@@ -13043,7 +13101,7 @@ var User;
13043
13101
  const users = data.users;
13044
13102
  for (let i = 0; i < users.length; i++) {
13045
13103
  api.SetCacheItem({
13046
- key: GetCacheKey(users[i].ID, accountId),
13104
+ key: GetCacheKey(sessionId, users[i].ID, accountId),
13047
13105
  value: {
13048
13106
  user: users[i]
13049
13107
  },
@@ -13201,11 +13259,18 @@ var User;
13201
13259
  * const key = GetListCacheKey("abc");
13202
13260
  * api.Cache.Remove(key);
13203
13261
  * }
13262
+ * @param sessionId
13204
13263
  * @param accountId
13205
13264
  * @returns
13206
13265
  */
13207
- function GetListCacheKey(accountId) {
13208
- return Api.ECacheKey.AccessToken + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
13266
+ function GetListCacheKey(sessionId, accountId) {
13267
+ if (!sessionId) {
13268
+ sessionId = "anonymous";
13269
+ }
13270
+ if (!accountId) {
13271
+ accountId = "";
13272
+ }
13273
+ return Api.ECacheKey.AccessToken + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
13209
13274
  }
13210
13275
  AccessToken.GetListCacheKey = GetListCacheKey;
13211
13276
  /**
@@ -13219,7 +13284,8 @@ var User;
13219
13284
  if (!api) {
13220
13285
  api = ENVIRONMENT.Api().GetGuardianApi();
13221
13286
  }
13222
- const cache = api.GetCacheItem(GetListCacheKey(accountId), reqParams);
13287
+ const cacheKey = GetListCacheKey(api.GetSessionId(), accountId);
13288
+ const cache = api.GetCacheItem(cacheKey, reqParams);
13223
13289
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13224
13290
  return cache.data;
13225
13291
  }
@@ -13235,7 +13301,7 @@ var User;
13235
13301
  }
13236
13302
  }));
13237
13303
  api.SetCacheItem({
13238
- key: GetListCacheKey(accountId),
13304
+ key: cacheKey,
13239
13305
  value: req,
13240
13306
  req: reqParams
13241
13307
  });
@@ -13255,7 +13321,7 @@ var User;
13255
13321
  }
13256
13322
  yield api.DELETE(`accessToken/${id}`, reqParams);
13257
13323
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + id);
13258
- api.Cache.RemoveByStartsWith(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13324
+ api.Cache.RemoveByContains(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13259
13325
  });
13260
13326
  }
13261
13327
  AccessToken.Delete = Delete;
@@ -13280,7 +13346,7 @@ var User;
13280
13346
  data.Type = EType.AccessToken;
13281
13347
  }
13282
13348
  data = yield api.POST("accessToken", data, reqParams);
13283
- api.Cache.RemoveByStartsWith(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13349
+ api.Cache.RemoveByContains(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13284
13350
  return {
13285
13351
  user: data
13286
13352
  };
@@ -13315,15 +13381,19 @@ var User;
13315
13381
  * const key = GetCacheKey("abc", "def");
13316
13382
  * api.Cache.Remove(key);
13317
13383
  * }
13384
+ * @param sessionId
13318
13385
  * @param userId
13319
13386
  * @param accountId
13320
13387
  * @returns
13321
13388
  */
13322
- function GetCacheKey(userId, accountId) {
13389
+ function GetCacheKey(sessionId, userId, accountId) {
13323
13390
  if (!accountId) {
13324
13391
  accountId = "";
13325
13392
  }
13326
- return Api.ECacheKey.User + Api.ECacheKey.Id + userId + Api.ECacheKey.Id + accountId;
13393
+ if (!sessionId) {
13394
+ sessionId = "anonymous";
13395
+ }
13396
+ return Api.ECacheKey.User + Api.ECacheKey.Id + userId + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
13327
13397
  }
13328
13398
  User$$1.GetCacheKey = GetCacheKey;
13329
13399
  /**
@@ -13337,11 +13407,17 @@ var User;
13337
13407
  * @param accountId
13338
13408
  * @returns
13339
13409
  */
13340
- function GetEmailCacheKey(email, accountId) {
13410
+ function GetEmailCacheKey(sessionId, email, accountId) {
13341
13411
  if (!accountId) {
13342
13412
  accountId = "";
13343
13413
  }
13344
- return Api.ECacheKey.User + Api.ECacheKey.UserEmail + email + Api.ECacheKey.Id + accountId;
13414
+ if (!sessionId) {
13415
+ sessionId = "anonymous";
13416
+ }
13417
+ if (!email) {
13418
+ email = "";
13419
+ }
13420
+ return Api.ECacheKey.User + Api.ECacheKey.UserEmail + email + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
13345
13421
  }
13346
13422
  User$$1.GetEmailCacheKey = GetEmailCacheKey;
13347
13423
  /**
@@ -13351,11 +13427,15 @@ var User;
13351
13427
  * const key = GetCacheKey("abc", "def");
13352
13428
  * api.Cache.Remove(key);
13353
13429
  * }
13430
+ * @param sessionId
13354
13431
  * @param userId
13355
13432
  * @param appId
13356
13433
  * @returns
13357
13434
  */
13358
- function GetSettingsCacheKey(userId, appId) {
13435
+ function GetSettingsCacheKey(sessionId, userId, appId) {
13436
+ if (!sessionId) {
13437
+ sessionId = "anonymous";
13438
+ }
13359
13439
  return Api.ECacheKey.User + Api.ECacheKey.UserSettings + userId + Api.ECacheKey.Id + appId;
13360
13440
  }
13361
13441
  User$$1.GetSettingsCacheKey = GetSettingsCacheKey;
@@ -16029,7 +16109,7 @@ var Tracking;
16029
16109
  })(Tracking || (Tracking = {}));
16030
16110
 
16031
16111
  // This is updated with the package.json version on build.
16032
- const VERSION = "6.4.7";
16112
+ const VERSION = "6.4.9";
16033
16113
 
16034
16114
  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, 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 };
16035
16115
  //# sourceMappingURL=bruce-models.es5.js.map