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.
@@ -11690,7 +11690,8 @@
11690
11690
  if (!api) {
11691
11691
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11692
11692
  }
11693
- const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
11693
+ const cacheKey = GetCacheKey(api.GetSessionId(), id);
11694
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11694
11695
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11695
11696
  return cache.data;
11696
11697
  }
@@ -11714,7 +11715,7 @@
11714
11715
  }
11715
11716
  }));
11716
11717
  api.SetCacheItem({
11717
- key: GetCacheKey(id),
11718
+ key: cacheKey,
11718
11719
  value: prom,
11719
11720
  req: reqParams
11720
11721
  });
@@ -11733,7 +11734,8 @@
11733
11734
  if (!api) {
11734
11735
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11735
11736
  }
11736
- const cache = api.GetCacheItem(GetCacheKey(subdomain), reqParams);
11737
+ const cacheKey = GetCacheKey(api.GetSessionId(), subdomain);
11738
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11737
11739
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11738
11740
  return cache.data;
11739
11741
  }
@@ -11757,7 +11759,7 @@
11757
11759
  }
11758
11760
  }));
11759
11761
  api.SetCacheItem({
11760
- key: GetCacheKey(subdomain),
11762
+ key: cacheKey,
11761
11763
  value: prom,
11762
11764
  req: reqParams
11763
11765
  });
@@ -11776,7 +11778,8 @@
11776
11778
  if (!api) {
11777
11779
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11778
11780
  }
11779
- const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId(), owned), reqParams);
11781
+ const cacheKey = GetListCacheKey(api.GetSessionId(), userId, owned);
11782
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11780
11783
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11781
11784
  return cache.data;
11782
11785
  }
@@ -11802,7 +11805,7 @@
11802
11805
  }
11803
11806
  }));
11804
11807
  api.SetCacheItem({
11805
- key: GetListCacheKey(api.GetSessionId(), owned),
11808
+ key: cacheKey,
11806
11809
  value: prom,
11807
11810
  req: reqParams
11808
11811
  });
@@ -11821,7 +11824,8 @@
11821
11824
  if (!api) {
11822
11825
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11823
11826
  }
11824
- const cache = api.GetCacheItem(GetCacheKey(id, appId), reqParams);
11827
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId);
11828
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11825
11829
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11826
11830
  return cache.data;
11827
11831
  }
@@ -11840,7 +11844,7 @@
11840
11844
  }
11841
11845
  }));
11842
11846
  api.SetCacheItem({
11843
- key: GetCacheKey(id, appId),
11847
+ key: cacheKey,
11844
11848
  value: prom,
11845
11849
  req: reqParams
11846
11850
  });
@@ -11861,7 +11865,7 @@
11861
11865
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11862
11866
  }
11863
11867
  const res = yield api.POST(`account/${id}/applicationSettings/${appId}?Override=${override ? "true" : "false"}`, data, reqParams);
11864
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
11868
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
11865
11869
  return {
11866
11870
  settings: res
11867
11871
  };
@@ -11894,7 +11898,7 @@
11894
11898
  const resData = {
11895
11899
  account: res
11896
11900
  };
11897
- api.Cache.RemoveByStartsWith(GetListCacheKey(api.GetSessionId()));
11901
+ api.Cache.RemoveByContains(GetListCacheKey(api.GetSessionId()));
11898
11902
  return resData;
11899
11903
  });
11900
11904
  }
@@ -11927,15 +11931,19 @@
11927
11931
  * const key = GetCacheKey(1);
11928
11932
  * api.Cache.Remove(key);
11929
11933
  * }
11934
+ * @param sessionId
11930
11935
  * @param accountId
11931
11936
  * @param appSettingsId
11932
11937
  * @returns
11933
11938
  */
11934
- function GetCacheKey(accountId, appSettingsId) {
11939
+ function GetCacheKey(sessionId, accountId, appSettingsId) {
11940
+ if (!sessionId) {
11941
+ sessionId = "anonymous";
11942
+ }
11935
11943
  if (appSettingsId) {
11936
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId;
11944
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
11937
11945
  }
11938
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
11946
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
11939
11947
  }
11940
11948
  Account.GetCacheKey = GetCacheKey;
11941
11949
  /**
@@ -11948,11 +11956,17 @@
11948
11956
  * @param ssid
11949
11957
  * @returns
11950
11958
  */
11951
- function GetListCacheKey(ssid, owned) {
11959
+ function GetListCacheKey(ssid, userId, owned) {
11952
11960
  if (!owned) {
11953
11961
  owned = false;
11954
11962
  }
11955
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid + exports.Api.ECacheKey.Id + (owned ? "owned" : "related");
11963
+ if (!ssid) {
11964
+ ssid = "anonymous";
11965
+ }
11966
+ if (!userId) {
11967
+ userId = "anonymous";
11968
+ }
11969
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid + exports.Api.ECacheKey.Id + (owned ? "owned" : "related") + exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + userId;
11956
11970
  }
11957
11971
  Account.GetListCacheKey = GetListCacheKey;
11958
11972
  /**
@@ -12466,6 +12480,41 @@
12466
12480
  // Access token. Used to gain access to related permissions.
12467
12481
  EType["AccessToken"] = "ACCESS_TOKEN";
12468
12482
  })(EType = User.EType || (User.EType = {}));
12483
+ /**
12484
+ * Returns an array of User Group IDs for the User that have been loaded.
12485
+ * Note, this does not perform an API lookup if the User instance hasn't loaded the specific account's details.
12486
+ * @param params
12487
+ * @returns
12488
+ */
12489
+ function UnpackRelatedUserGroupIDs(params) {
12490
+ var _a, _b;
12491
+ const { user, accountId } = params;
12492
+ if (!user || !accountId) {
12493
+ throw ("User and accountId are required.");
12494
+ }
12495
+ let accessPerms = user.AccessPermissions;
12496
+ if (!accessPerms || !Array.isArray(accessPerms) || accessPerms.length === 0) {
12497
+ return [];
12498
+ }
12499
+ for (const perm of accessPerms) {
12500
+ if (!perm || perm["ClientAccount.ID"] !== accountId) {
12501
+ continue;
12502
+ }
12503
+ else if ((_a = perm["UserGroup.ID"]) === null || _a === void 0 ? void 0 : _a.length) {
12504
+ return perm["UserGroup.ID"];
12505
+ }
12506
+ else if ((_b = perm.UserGroups) === null || _b === void 0 ? void 0 : _b.length) {
12507
+ if (typeof perm.UserGroups[0] === "string") {
12508
+ return perm.UserGroups;
12509
+ }
12510
+ else if (typeof perm.UserGroups[0] === "object") {
12511
+ return perm.UserGroups.map(group => group.ID);
12512
+ }
12513
+ }
12514
+ }
12515
+ return [];
12516
+ }
12517
+ User.UnpackRelatedUserGroupIDs = UnpackRelatedUserGroupIDs;
12469
12518
  /**
12470
12519
  * Gets a user record.
12471
12520
  * @param params
@@ -12480,7 +12529,7 @@
12480
12529
  if (!api) {
12481
12530
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12482
12531
  }
12483
- const cacheKey = GetCacheKey(id, accountId);
12532
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, accountId);
12484
12533
  const cache = api.GetCacheItem(cacheKey, reqParams);
12485
12534
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12486
12535
  return cache.data;
@@ -12544,10 +12593,10 @@
12544
12593
  const res = yield api.POST(`user/${data.ID}`, data, reqParams);
12545
12594
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + data.ID);
12546
12595
  if (data.Type == EType.AccessToken) {
12547
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12596
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12548
12597
  }
12549
12598
  else if (data.Type == EType.User) {
12550
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12599
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12551
12600
  }
12552
12601
  return {
12553
12602
  user: res
@@ -12578,7 +12627,7 @@
12578
12627
  }
12579
12628
  const res = yield api.POST("user", data, reqParams);
12580
12629
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + data.ID);
12581
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12630
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12582
12631
  return {
12583
12632
  user: res
12584
12633
  };
@@ -12599,7 +12648,8 @@
12599
12648
  if (!api) {
12600
12649
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12601
12650
  }
12602
- const cache = api.GetCacheItem(GetSettingsCacheKey(userId, appId), req);
12651
+ const cacheKey = GetSettingsCacheKey(api.GetSessionId(), userId, appId);
12652
+ const cache = api.GetCacheItem(cacheKey, req);
12603
12653
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12604
12654
  return cache.data;
12605
12655
  }
@@ -12626,7 +12676,7 @@
12626
12676
  }
12627
12677
  }));
12628
12678
  api.SetCacheItem({
12629
- key: GetSettingsCacheKey(userId, appId),
12679
+ key: cacheKey,
12630
12680
  value: prom,
12631
12681
  req: req
12632
12682
  });
@@ -12656,7 +12706,7 @@
12656
12706
  UserID: userId
12657
12707
  };
12658
12708
  const prom = api.POST(`user/${userId}/application/${appId}/settings?Override=${override ? "true" : "false"}`, postBody, req);
12659
- api.Cache.Remove(GetSettingsCacheKey(userId, appId));
12709
+ api.Cache.Remove(GetSettingsCacheKey(api.GetSessionId(), userId, appId));
12660
12710
  return prom;
12661
12711
  });
12662
12712
  }
@@ -12705,14 +12755,20 @@
12705
12755
  * @param search
12706
12756
  * @returns
12707
12757
  */
12708
- function GetListCacheKey(accountId, exclusive, search) {
12758
+ function GetListCacheKey(sessionId, accountId, exclusive, search) {
12709
12759
  if (!exclusive) {
12710
12760
  exclusive = false;
12711
12761
  }
12712
12762
  if (!search) {
12713
12763
  search = "";
12714
12764
  }
12715
- return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Id + exclusive + exports.Api.ECacheKey.Id + search;
12765
+ if (!sessionId) {
12766
+ sessionId = "anonymous";
12767
+ }
12768
+ if (!accountId) {
12769
+ accountId = "";
12770
+ }
12771
+ return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Id + exclusive + exports.Api.ECacheKey.Id + search + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
12716
12772
  }
12717
12773
  LoginUser.GetListCacheKey = GetListCacheKey;
12718
12774
  /**
@@ -12729,7 +12785,8 @@
12729
12785
  if (!api) {
12730
12786
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12731
12787
  }
12732
- const cache = api.GetCacheItem(GetEmailCacheKey(email, accountId), reqParams);
12788
+ const cacheKey = GetEmailCacheKey(api.GetSessionId(), email, accountId);
12789
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12733
12790
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12734
12791
  return cache.data;
12735
12792
  }
@@ -12745,7 +12802,7 @@
12745
12802
  }
12746
12803
  }));
12747
12804
  api.SetCacheItem({
12748
- key: GetEmailCacheKey(email, accountId),
12805
+ key: cacheKey,
12749
12806
  value: prom,
12750
12807
  req: reqParams
12751
12808
  });
@@ -12767,7 +12824,8 @@
12767
12824
  if (!exclusive) {
12768
12825
  exclusive = false;
12769
12826
  }
12770
- const cacheKey = GetListCacheKey(accountId, exclusive, search);
12827
+ const sessionId = api.GetSessionId();
12828
+ const cacheKey = GetListCacheKey(sessionId, accountId, exclusive, search);
12771
12829
  const cache = exclusive ? null : api.GetCacheItem(cacheKey, reqParams);
12772
12830
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12773
12831
  return cache.data;
@@ -12797,7 +12855,7 @@
12797
12855
  const users = data.users;
12798
12856
  for (let i = 0; i < users.length; i++) {
12799
12857
  api.SetCacheItem({
12800
- key: GetCacheKey(users[i].ID, accountId),
12858
+ key: GetCacheKey(sessionId, users[i].ID, accountId),
12801
12859
  value: {
12802
12860
  user: users[i]
12803
12861
  },
@@ -12955,11 +13013,18 @@
12955
13013
  * const key = GetListCacheKey("abc");
12956
13014
  * api.Cache.Remove(key);
12957
13015
  * }
13016
+ * @param sessionId
12958
13017
  * @param accountId
12959
13018
  * @returns
12960
13019
  */
12961
- function GetListCacheKey(accountId) {
12962
- return exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
13020
+ function GetListCacheKey(sessionId, accountId) {
13021
+ if (!sessionId) {
13022
+ sessionId = "anonymous";
13023
+ }
13024
+ if (!accountId) {
13025
+ accountId = "";
13026
+ }
13027
+ return exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
12963
13028
  }
12964
13029
  AccessToken.GetListCacheKey = GetListCacheKey;
12965
13030
  /**
@@ -12973,7 +13038,8 @@
12973
13038
  if (!api) {
12974
13039
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12975
13040
  }
12976
- const cache = api.GetCacheItem(GetListCacheKey(accountId), reqParams);
13041
+ const cacheKey = GetListCacheKey(api.GetSessionId(), accountId);
13042
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12977
13043
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12978
13044
  return cache.data;
12979
13045
  }
@@ -12989,7 +13055,7 @@
12989
13055
  }
12990
13056
  }));
12991
13057
  api.SetCacheItem({
12992
- key: GetListCacheKey(accountId),
13058
+ key: cacheKey,
12993
13059
  value: req,
12994
13060
  req: reqParams
12995
13061
  });
@@ -13009,7 +13075,7 @@
13009
13075
  }
13010
13076
  yield api.DELETE(`accessToken/${id}`, reqParams);
13011
13077
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + id);
13012
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13078
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13013
13079
  });
13014
13080
  }
13015
13081
  AccessToken.Delete = Delete;
@@ -13034,7 +13100,7 @@
13034
13100
  data.Type = EType.AccessToken;
13035
13101
  }
13036
13102
  data = yield api.POST("accessToken", data, reqParams);
13037
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13103
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13038
13104
  return {
13039
13105
  user: data
13040
13106
  };
@@ -13069,15 +13135,19 @@
13069
13135
  * const key = GetCacheKey("abc", "def");
13070
13136
  * api.Cache.Remove(key);
13071
13137
  * }
13138
+ * @param sessionId
13072
13139
  * @param userId
13073
13140
  * @param accountId
13074
13141
  * @returns
13075
13142
  */
13076
- function GetCacheKey(userId, accountId) {
13143
+ function GetCacheKey(sessionId, userId, accountId) {
13077
13144
  if (!accountId) {
13078
13145
  accountId = "";
13079
13146
  }
13080
- return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + userId + exports.Api.ECacheKey.Id + accountId;
13147
+ if (!sessionId) {
13148
+ sessionId = "anonymous";
13149
+ }
13150
+ return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + userId + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
13081
13151
  }
13082
13152
  User.GetCacheKey = GetCacheKey;
13083
13153
  /**
@@ -13091,11 +13161,17 @@
13091
13161
  * @param accountId
13092
13162
  * @returns
13093
13163
  */
13094
- function GetEmailCacheKey(email, accountId) {
13164
+ function GetEmailCacheKey(sessionId, email, accountId) {
13095
13165
  if (!accountId) {
13096
13166
  accountId = "";
13097
13167
  }
13098
- return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserEmail + email + exports.Api.ECacheKey.Id + accountId;
13168
+ if (!sessionId) {
13169
+ sessionId = "anonymous";
13170
+ }
13171
+ if (!email) {
13172
+ email = "";
13173
+ }
13174
+ return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserEmail + email + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
13099
13175
  }
13100
13176
  User.GetEmailCacheKey = GetEmailCacheKey;
13101
13177
  /**
@@ -13105,11 +13181,15 @@
13105
13181
  * const key = GetCacheKey("abc", "def");
13106
13182
  * api.Cache.Remove(key);
13107
13183
  * }
13184
+ * @param sessionId
13108
13185
  * @param userId
13109
13186
  * @param appId
13110
13187
  * @returns
13111
13188
  */
13112
- function GetSettingsCacheKey(userId, appId) {
13189
+ function GetSettingsCacheKey(sessionId, userId, appId) {
13190
+ if (!sessionId) {
13191
+ sessionId = "anonymous";
13192
+ }
13113
13193
  return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserSettings + userId + exports.Api.ECacheKey.Id + appId;
13114
13194
  }
13115
13195
  User.GetSettingsCacheKey = GetSettingsCacheKey;
@@ -15715,7 +15795,7 @@
15715
15795
  })(exports.Tracking || (exports.Tracking = {}));
15716
15796
 
15717
15797
  // This is updated with the package.json version on build.
15718
- const VERSION = "6.4.7";
15798
+ const VERSION = "6.4.9";
15719
15799
 
15720
15800
  exports.VERSION = VERSION;
15721
15801
  exports.AbstractApi = AbstractApi;