bruce-models 6.4.8 → 6.5.0

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.
@@ -4991,7 +4991,45 @@
4991
4991
  }
4992
4992
  for (let i = 0; i < value.values.length; i++) {
4993
4993
  const option = value.values[i];
4994
- const mapValue = option.fieldValue;
4994
+ let mapValue = option.fieldValue;
4995
+ // If mapValue is prefixed with "JS:", we evaluate it as JavaScript.
4996
+ // This lets us do things like JS:Boolean("${}") as a quick way to map 'existence' to a target value.
4997
+ if (typeof mapValue === "string" && mapValue.startsWith("JS:")) {
4998
+ try {
4999
+ let jsEval = mapValue.replace("JS:", "").trim();
5000
+ const attrPathStr = exports.PathUtils.Wrap(attrPath);
5001
+ jsEval = jsEval.replace("${}", "${" + attrPathStr + "}");
5002
+ jsEval = exports.BruceVariable.SwapValues({
5003
+ str: jsEval,
5004
+ entity: entity
5005
+ });
5006
+ // https://rollupjs.org/guide/en/#avoiding-eval
5007
+ // This stops eval warning.
5008
+ const eval2 = eval;
5009
+ mapValue = eval2(jsEval);
5010
+ // We currently expect eval to return a validity bool.
5011
+ // So it either matches and we return it, or it doesn't and we continue.
5012
+ if (mapValue) {
5013
+ return option.appliedValue;
5014
+ }
5015
+ else {
5016
+ continue;
5017
+ }
5018
+ }
5019
+ catch (exception) {
5020
+ const e = exception;
5021
+ let suppress = false;
5022
+ if (e && typeof e == "object") {
5023
+ const msg = e.message;
5024
+ suppress = !!msg && (msg.includes("Unexpected end") || msg.includes("got end of script"));
5025
+ }
5026
+ if (!suppress) {
5027
+ console.error(e);
5028
+ }
5029
+ // Eval failed, therefor not a valid mapping-row.
5030
+ continue;
5031
+ }
5032
+ }
4995
5033
  let isMapValueNum = !isNaN(+mapValue);
4996
5034
  if (isMapValueNum == null) {
4997
5035
  isMapValueNum = false;
@@ -5028,7 +5066,7 @@
5028
5066
  // Common as mapping value is typically a user-entered string.
5029
5067
  else if (typeof eValue === "boolean" && typeof mapValue === "string") {
5030
5068
  const eValueStr = eValue ? "true" : "false";
5031
- if (mapValue == eValueStr) {
5069
+ if (mapValue.toLowerCase() == eValueStr) {
5032
5070
  return option.appliedValue;
5033
5071
  }
5034
5072
  }
@@ -5036,7 +5074,7 @@
5036
5074
  // Have not seen this happen yet, but preparing for any future cases.
5037
5075
  else if (typeof mapValue === "boolean" && typeof eValue === "string") {
5038
5076
  const mapValueStr = mapValue ? "true" : "false";
5039
- if (mapValueStr == eValue) {
5077
+ if (mapValueStr == eValue.toLowerCase()) {
5040
5078
  return option.appliedValue;
5041
5079
  }
5042
5080
  }
@@ -11690,7 +11728,8 @@
11690
11728
  if (!api) {
11691
11729
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11692
11730
  }
11693
- const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
11731
+ const cacheKey = GetCacheKey(api.GetSessionId(), id);
11732
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11694
11733
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11695
11734
  return cache.data;
11696
11735
  }
@@ -11714,7 +11753,7 @@
11714
11753
  }
11715
11754
  }));
11716
11755
  api.SetCacheItem({
11717
- key: GetCacheKey(id),
11756
+ key: cacheKey,
11718
11757
  value: prom,
11719
11758
  req: reqParams
11720
11759
  });
@@ -11733,7 +11772,8 @@
11733
11772
  if (!api) {
11734
11773
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11735
11774
  }
11736
- const cache = api.GetCacheItem(GetCacheKey(subdomain), reqParams);
11775
+ const cacheKey = GetCacheKey(api.GetSessionId(), subdomain);
11776
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11737
11777
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11738
11778
  return cache.data;
11739
11779
  }
@@ -11757,7 +11797,7 @@
11757
11797
  }
11758
11798
  }));
11759
11799
  api.SetCacheItem({
11760
- key: GetCacheKey(subdomain),
11800
+ key: cacheKey,
11761
11801
  value: prom,
11762
11802
  req: reqParams
11763
11803
  });
@@ -11776,7 +11816,8 @@
11776
11816
  if (!api) {
11777
11817
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11778
11818
  }
11779
- const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId(), owned), reqParams);
11819
+ const cacheKey = GetListCacheKey(api.GetSessionId(), userId, owned);
11820
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11780
11821
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11781
11822
  return cache.data;
11782
11823
  }
@@ -11802,7 +11843,7 @@
11802
11843
  }
11803
11844
  }));
11804
11845
  api.SetCacheItem({
11805
- key: GetListCacheKey(api.GetSessionId(), owned),
11846
+ key: cacheKey,
11806
11847
  value: prom,
11807
11848
  req: reqParams
11808
11849
  });
@@ -11821,7 +11862,8 @@
11821
11862
  if (!api) {
11822
11863
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11823
11864
  }
11824
- const cache = api.GetCacheItem(GetCacheKey(id, appId), reqParams);
11865
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId);
11866
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11825
11867
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11826
11868
  return cache.data;
11827
11869
  }
@@ -11840,7 +11882,7 @@
11840
11882
  }
11841
11883
  }));
11842
11884
  api.SetCacheItem({
11843
- key: GetCacheKey(id, appId),
11885
+ key: cacheKey,
11844
11886
  value: prom,
11845
11887
  req: reqParams
11846
11888
  });
@@ -11861,7 +11903,7 @@
11861
11903
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
11862
11904
  }
11863
11905
  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);
11906
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + id);
11865
11907
  return {
11866
11908
  settings: res
11867
11909
  };
@@ -11894,7 +11936,7 @@
11894
11936
  const resData = {
11895
11937
  account: res
11896
11938
  };
11897
- api.Cache.RemoveByStartsWith(GetListCacheKey(api.GetSessionId()));
11939
+ api.Cache.RemoveByContains(GetListCacheKey(api.GetSessionId()));
11898
11940
  return resData;
11899
11941
  });
11900
11942
  }
@@ -11927,15 +11969,19 @@
11927
11969
  * const key = GetCacheKey(1);
11928
11970
  * api.Cache.Remove(key);
11929
11971
  * }
11972
+ * @param sessionId
11930
11973
  * @param accountId
11931
11974
  * @param appSettingsId
11932
11975
  * @returns
11933
11976
  */
11934
- function GetCacheKey(accountId, appSettingsId) {
11977
+ function GetCacheKey(sessionId, accountId, appSettingsId) {
11978
+ if (!sessionId) {
11979
+ sessionId = "anonymous";
11980
+ }
11935
11981
  if (appSettingsId) {
11936
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId;
11982
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey + appSettingsId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
11937
11983
  }
11938
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
11984
+ return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
11939
11985
  }
11940
11986
  Account.GetCacheKey = GetCacheKey;
11941
11987
  /**
@@ -11948,11 +11994,17 @@
11948
11994
  * @param ssid
11949
11995
  * @returns
11950
11996
  */
11951
- function GetListCacheKey(ssid, owned) {
11997
+ function GetListCacheKey(ssid, userId, owned) {
11952
11998
  if (!owned) {
11953
11999
  owned = false;
11954
12000
  }
11955
- return exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + ssid + exports.Api.ECacheKey.Id + (owned ? "owned" : "related");
12001
+ if (!ssid) {
12002
+ ssid = "anonymous";
12003
+ }
12004
+ if (!userId) {
12005
+ userId = "anonymous";
12006
+ }
12007
+ 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
12008
  }
11957
12009
  Account.GetListCacheKey = GetListCacheKey;
11958
12010
  /**
@@ -12515,7 +12567,7 @@
12515
12567
  if (!api) {
12516
12568
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12517
12569
  }
12518
- const cacheKey = GetCacheKey(id, accountId);
12570
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, accountId);
12519
12571
  const cache = api.GetCacheItem(cacheKey, reqParams);
12520
12572
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12521
12573
  return cache.data;
@@ -12579,10 +12631,10 @@
12579
12631
  const res = yield api.POST(`user/${data.ID}`, data, reqParams);
12580
12632
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + data.ID);
12581
12633
  if (data.Type == EType.AccessToken) {
12582
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12634
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
12583
12635
  }
12584
12636
  else if (data.Type == EType.User) {
12585
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12637
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12586
12638
  }
12587
12639
  return {
12588
12640
  user: res
@@ -12613,7 +12665,7 @@
12613
12665
  }
12614
12666
  const res = yield api.POST("user", data, reqParams);
12615
12667
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + data.ID);
12616
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12668
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account);
12617
12669
  return {
12618
12670
  user: res
12619
12671
  };
@@ -12634,7 +12686,8 @@
12634
12686
  if (!api) {
12635
12687
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12636
12688
  }
12637
- const cache = api.GetCacheItem(GetSettingsCacheKey(userId, appId), req);
12689
+ const cacheKey = GetSettingsCacheKey(api.GetSessionId(), userId, appId);
12690
+ const cache = api.GetCacheItem(cacheKey, req);
12638
12691
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12639
12692
  return cache.data;
12640
12693
  }
@@ -12661,7 +12714,7 @@
12661
12714
  }
12662
12715
  }));
12663
12716
  api.SetCacheItem({
12664
- key: GetSettingsCacheKey(userId, appId),
12717
+ key: cacheKey,
12665
12718
  value: prom,
12666
12719
  req: req
12667
12720
  });
@@ -12691,7 +12744,7 @@
12691
12744
  UserID: userId
12692
12745
  };
12693
12746
  const prom = api.POST(`user/${userId}/application/${appId}/settings?Override=${override ? "true" : "false"}`, postBody, req);
12694
- api.Cache.Remove(GetSettingsCacheKey(userId, appId));
12747
+ api.Cache.Remove(GetSettingsCacheKey(api.GetSessionId(), userId, appId));
12695
12748
  return prom;
12696
12749
  });
12697
12750
  }
@@ -12740,14 +12793,20 @@
12740
12793
  * @param search
12741
12794
  * @returns
12742
12795
  */
12743
- function GetListCacheKey(accountId, exclusive, search) {
12796
+ function GetListCacheKey(sessionId, accountId, exclusive, search) {
12744
12797
  if (!exclusive) {
12745
12798
  exclusive = false;
12746
12799
  }
12747
12800
  if (!search) {
12748
12801
  search = "";
12749
12802
  }
12750
- return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Id + exclusive + exports.Api.ECacheKey.Id + search;
12803
+ if (!sessionId) {
12804
+ sessionId = "anonymous";
12805
+ }
12806
+ if (!accountId) {
12807
+ accountId = "";
12808
+ }
12809
+ 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;
12751
12810
  }
12752
12811
  LoginUser.GetListCacheKey = GetListCacheKey;
12753
12812
  /**
@@ -12764,7 +12823,8 @@
12764
12823
  if (!api) {
12765
12824
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
12766
12825
  }
12767
- const cache = api.GetCacheItem(GetEmailCacheKey(email, accountId), reqParams);
12826
+ const cacheKey = GetEmailCacheKey(api.GetSessionId(), email, accountId);
12827
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12768
12828
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12769
12829
  return cache.data;
12770
12830
  }
@@ -12780,7 +12840,7 @@
12780
12840
  }
12781
12841
  }));
12782
12842
  api.SetCacheItem({
12783
- key: GetEmailCacheKey(email, accountId),
12843
+ key: cacheKey,
12784
12844
  value: prom,
12785
12845
  req: reqParams
12786
12846
  });
@@ -12802,7 +12862,8 @@
12802
12862
  if (!exclusive) {
12803
12863
  exclusive = false;
12804
12864
  }
12805
- const cacheKey = GetListCacheKey(accountId, exclusive, search);
12865
+ const sessionId = api.GetSessionId();
12866
+ const cacheKey = GetListCacheKey(sessionId, accountId, exclusive, search);
12806
12867
  const cache = exclusive ? null : api.GetCacheItem(cacheKey, reqParams);
12807
12868
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12808
12869
  return cache.data;
@@ -12832,7 +12893,7 @@
12832
12893
  const users = data.users;
12833
12894
  for (let i = 0; i < users.length; i++) {
12834
12895
  api.SetCacheItem({
12835
- key: GetCacheKey(users[i].ID, accountId),
12896
+ key: GetCacheKey(sessionId, users[i].ID, accountId),
12836
12897
  value: {
12837
12898
  user: users[i]
12838
12899
  },
@@ -12990,11 +13051,18 @@
12990
13051
  * const key = GetListCacheKey("abc");
12991
13052
  * api.Cache.Remove(key);
12992
13053
  * }
13054
+ * @param sessionId
12993
13055
  * @param accountId
12994
13056
  * @returns
12995
13057
  */
12996
- function GetListCacheKey(accountId) {
12997
- return exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId;
13058
+ function GetListCacheKey(sessionId, accountId) {
13059
+ if (!sessionId) {
13060
+ sessionId = "anonymous";
13061
+ }
13062
+ if (!accountId) {
13063
+ accountId = "";
13064
+ }
13065
+ return exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
12998
13066
  }
12999
13067
  AccessToken.GetListCacheKey = GetListCacheKey;
13000
13068
  /**
@@ -13008,7 +13076,8 @@
13008
13076
  if (!api) {
13009
13077
  api = exports.ENVIRONMENT.Api().GetGuardianApi();
13010
13078
  }
13011
- const cache = api.GetCacheItem(GetListCacheKey(accountId), reqParams);
13079
+ const cacheKey = GetListCacheKey(api.GetSessionId(), accountId);
13080
+ const cache = api.GetCacheItem(cacheKey, reqParams);
13012
13081
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13013
13082
  return cache.data;
13014
13083
  }
@@ -13024,7 +13093,7 @@
13024
13093
  }
13025
13094
  }));
13026
13095
  api.SetCacheItem({
13027
- key: GetListCacheKey(accountId),
13096
+ key: cacheKey,
13028
13097
  value: req,
13029
13098
  req: reqParams
13030
13099
  });
@@ -13044,7 +13113,7 @@
13044
13113
  }
13045
13114
  yield api.DELETE(`accessToken/${id}`, reqParams);
13046
13115
  api.Cache.RemoveByContains(exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + id);
13047
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13116
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13048
13117
  });
13049
13118
  }
13050
13119
  AccessToken.Delete = Delete;
@@ -13069,7 +13138,7 @@
13069
13138
  data.Type = EType.AccessToken;
13070
13139
  }
13071
13140
  data = yield api.POST("accessToken", data, reqParams);
13072
- api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13141
+ api.Cache.RemoveByContains(exports.Api.ECacheKey.AccessToken + exports.Api.ECacheKey.Account);
13073
13142
  return {
13074
13143
  user: data
13075
13144
  };
@@ -13104,15 +13173,19 @@
13104
13173
  * const key = GetCacheKey("abc", "def");
13105
13174
  * api.Cache.Remove(key);
13106
13175
  * }
13176
+ * @param sessionId
13107
13177
  * @param userId
13108
13178
  * @param accountId
13109
13179
  * @returns
13110
13180
  */
13111
- function GetCacheKey(userId, accountId) {
13181
+ function GetCacheKey(sessionId, userId, accountId) {
13112
13182
  if (!accountId) {
13113
13183
  accountId = "";
13114
13184
  }
13115
- return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + userId + exports.Api.ECacheKey.Id + accountId;
13185
+ if (!sessionId) {
13186
+ sessionId = "anonymous";
13187
+ }
13188
+ return exports.Api.ECacheKey.User + exports.Api.ECacheKey.Id + userId + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
13116
13189
  }
13117
13190
  User.GetCacheKey = GetCacheKey;
13118
13191
  /**
@@ -13126,11 +13199,17 @@
13126
13199
  * @param accountId
13127
13200
  * @returns
13128
13201
  */
13129
- function GetEmailCacheKey(email, accountId) {
13202
+ function GetEmailCacheKey(sessionId, email, accountId) {
13130
13203
  if (!accountId) {
13131
13204
  accountId = "";
13132
13205
  }
13133
- return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserEmail + email + exports.Api.ECacheKey.Id + accountId;
13206
+ if (!sessionId) {
13207
+ sessionId = "anonymous";
13208
+ }
13209
+ if (!email) {
13210
+ email = "";
13211
+ }
13212
+ return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserEmail + email + exports.Api.ECacheKey.Id + accountId + exports.Api.ECacheKey.Session + exports.Api.ECacheKey.Id + sessionId;
13134
13213
  }
13135
13214
  User.GetEmailCacheKey = GetEmailCacheKey;
13136
13215
  /**
@@ -13140,11 +13219,15 @@
13140
13219
  * const key = GetCacheKey("abc", "def");
13141
13220
  * api.Cache.Remove(key);
13142
13221
  * }
13222
+ * @param sessionId
13143
13223
  * @param userId
13144
13224
  * @param appId
13145
13225
  * @returns
13146
13226
  */
13147
- function GetSettingsCacheKey(userId, appId) {
13227
+ function GetSettingsCacheKey(sessionId, userId, appId) {
13228
+ if (!sessionId) {
13229
+ sessionId = "anonymous";
13230
+ }
13148
13231
  return exports.Api.ECacheKey.User + exports.Api.ECacheKey.UserSettings + userId + exports.Api.ECacheKey.Id + appId;
13149
13232
  }
13150
13233
  User.GetSettingsCacheKey = GetSettingsCacheKey;
@@ -15750,7 +15833,7 @@
15750
15833
  })(exports.Tracking || (exports.Tracking = {}));
15751
15834
 
15752
15835
  // This is updated with the package.json version on build.
15753
- const VERSION = "6.4.8";
15836
+ const VERSION = "6.5.0";
15754
15837
 
15755
15838
  exports.VERSION = VERSION;
15756
15839
  exports.AbstractApi = AbstractApi;