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.
@@ -5052,7 +5052,45 @@ var Calculator;
5052
5052
  }
5053
5053
  for (let i = 0; i < value.values.length; i++) {
5054
5054
  const option = value.values[i];
5055
- const mapValue = option.fieldValue;
5055
+ let mapValue = option.fieldValue;
5056
+ // If mapValue is prefixed with "JS:", we evaluate it as JavaScript.
5057
+ // This lets us do things like JS:Boolean("${}") as a quick way to map 'existence' to a target value.
5058
+ if (typeof mapValue === "string" && mapValue.startsWith("JS:")) {
5059
+ try {
5060
+ let jsEval = mapValue.replace("JS:", "").trim();
5061
+ const attrPathStr = PathUtils.Wrap(attrPath);
5062
+ jsEval = jsEval.replace("${}", "${" + attrPathStr + "}");
5063
+ jsEval = BruceVariable.SwapValues({
5064
+ str: jsEval,
5065
+ entity: entity
5066
+ });
5067
+ // https://rollupjs.org/guide/en/#avoiding-eval
5068
+ // This stops eval warning.
5069
+ const eval2 = eval;
5070
+ mapValue = eval2(jsEval);
5071
+ // We currently expect eval to return a validity bool.
5072
+ // So it either matches and we return it, or it doesn't and we continue.
5073
+ if (mapValue) {
5074
+ return option.appliedValue;
5075
+ }
5076
+ else {
5077
+ continue;
5078
+ }
5079
+ }
5080
+ catch (exception) {
5081
+ const e = exception;
5082
+ let suppress = false;
5083
+ if (e && typeof e == "object") {
5084
+ const msg = e.message;
5085
+ suppress = !!msg && (msg.includes("Unexpected end") || msg.includes("got end of script"));
5086
+ }
5087
+ if (!suppress) {
5088
+ console.error(e);
5089
+ }
5090
+ // Eval failed, therefor not a valid mapping-row.
5091
+ continue;
5092
+ }
5093
+ }
5056
5094
  let isMapValueNum = !isNaN(+mapValue);
5057
5095
  if (isMapValueNum == null) {
5058
5096
  isMapValueNum = false;
@@ -5089,7 +5127,7 @@ var Calculator;
5089
5127
  // Common as mapping value is typically a user-entered string.
5090
5128
  else if (typeof eValue === "boolean" && typeof mapValue === "string") {
5091
5129
  const eValueStr = eValue ? "true" : "false";
5092
- if (mapValue == eValueStr) {
5130
+ if (mapValue.toLowerCase() == eValueStr) {
5093
5131
  return option.appliedValue;
5094
5132
  }
5095
5133
  }
@@ -5097,7 +5135,7 @@ var Calculator;
5097
5135
  // Have not seen this happen yet, but preparing for any future cases.
5098
5136
  else if (typeof mapValue === "boolean" && typeof eValue === "string") {
5099
5137
  const mapValueStr = mapValue ? "true" : "false";
5100
- if (mapValueStr == eValue) {
5138
+ if (mapValueStr == eValue.toLowerCase()) {
5101
5139
  return option.appliedValue;
5102
5140
  }
5103
5141
  }
@@ -11916,7 +11954,8 @@ var Account;
11916
11954
  if (!api) {
11917
11955
  api = ENVIRONMENT.Api().GetGuardianApi();
11918
11956
  }
11919
- const cache = api.GetCacheItem(GetCacheKey(id), reqParams);
11957
+ const cacheKey = GetCacheKey(api.GetSessionId(), id);
11958
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11920
11959
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11921
11960
  return cache.data;
11922
11961
  }
@@ -11940,7 +11979,7 @@ var Account;
11940
11979
  }
11941
11980
  }));
11942
11981
  api.SetCacheItem({
11943
- key: GetCacheKey(id),
11982
+ key: cacheKey,
11944
11983
  value: prom,
11945
11984
  req: reqParams
11946
11985
  });
@@ -11959,7 +11998,8 @@ var Account;
11959
11998
  if (!api) {
11960
11999
  api = ENVIRONMENT.Api().GetGuardianApi();
11961
12000
  }
11962
- const cache = api.GetCacheItem(GetCacheKey(subdomain), reqParams);
12001
+ const cacheKey = GetCacheKey(api.GetSessionId(), subdomain);
12002
+ const cache = api.GetCacheItem(cacheKey, reqParams);
11963
12003
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
11964
12004
  return cache.data;
11965
12005
  }
@@ -11983,7 +12023,7 @@ var Account;
11983
12023
  }
11984
12024
  }));
11985
12025
  api.SetCacheItem({
11986
- key: GetCacheKey(subdomain),
12026
+ key: cacheKey,
11987
12027
  value: prom,
11988
12028
  req: reqParams
11989
12029
  });
@@ -12002,7 +12042,8 @@ var Account;
12002
12042
  if (!api) {
12003
12043
  api = ENVIRONMENT.Api().GetGuardianApi();
12004
12044
  }
12005
- const cache = api.GetCacheItem(GetListCacheKey(api.GetSessionId(), owned), reqParams);
12045
+ const cacheKey = GetListCacheKey(api.GetSessionId(), userId, owned);
12046
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12006
12047
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12007
12048
  return cache.data;
12008
12049
  }
@@ -12028,7 +12069,7 @@ var Account;
12028
12069
  }
12029
12070
  }));
12030
12071
  api.SetCacheItem({
12031
- key: GetListCacheKey(api.GetSessionId(), owned),
12072
+ key: cacheKey,
12032
12073
  value: prom,
12033
12074
  req: reqParams
12034
12075
  });
@@ -12047,7 +12088,8 @@ var Account;
12047
12088
  if (!api) {
12048
12089
  api = ENVIRONMENT.Api().GetGuardianApi();
12049
12090
  }
12050
- const cache = api.GetCacheItem(GetCacheKey(id, appId), reqParams);
12091
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, appId);
12092
+ const cache = api.GetCacheItem(cacheKey, reqParams);
12051
12093
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12052
12094
  return cache.data;
12053
12095
  }
@@ -12066,7 +12108,7 @@ var Account;
12066
12108
  }
12067
12109
  }));
12068
12110
  api.SetCacheItem({
12069
- key: GetCacheKey(id, appId),
12111
+ key: cacheKey,
12070
12112
  value: prom,
12071
12113
  req: reqParams
12072
12114
  });
@@ -12087,7 +12129,7 @@ var Account;
12087
12129
  api = ENVIRONMENT.Api().GetGuardianApi();
12088
12130
  }
12089
12131
  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);
12132
+ api.Cache.RemoveByContains(Api.ECacheKey.Account + Api.ECacheKey.Id + id);
12091
12133
  return {
12092
12134
  settings: res
12093
12135
  };
@@ -12120,7 +12162,7 @@ var Account;
12120
12162
  const resData = {
12121
12163
  account: res
12122
12164
  };
12123
- api.Cache.RemoveByStartsWith(GetListCacheKey(api.GetSessionId()));
12165
+ api.Cache.RemoveByContains(GetListCacheKey(api.GetSessionId()));
12124
12166
  return resData;
12125
12167
  });
12126
12168
  }
@@ -12153,15 +12195,19 @@ var Account;
12153
12195
  * const key = GetCacheKey(1);
12154
12196
  * api.Cache.Remove(key);
12155
12197
  * }
12198
+ * @param sessionId
12156
12199
  * @param accountId
12157
12200
  * @param appSettingsId
12158
12201
  * @returns
12159
12202
  */
12160
- function GetCacheKey(accountId, appSettingsId) {
12203
+ function GetCacheKey(sessionId, accountId, appSettingsId) {
12204
+ if (!sessionId) {
12205
+ sessionId = "anonymous";
12206
+ }
12161
12207
  if (appSettingsId) {
12162
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId;
12208
+ return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey + appSettingsId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12163
12209
  }
12164
- return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
12210
+ return Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
12165
12211
  }
12166
12212
  Account.GetCacheKey = GetCacheKey;
12167
12213
  /**
@@ -12174,11 +12220,17 @@ var Account;
12174
12220
  * @param ssid
12175
12221
  * @returns
12176
12222
  */
12177
- function GetListCacheKey(ssid, owned) {
12223
+ function GetListCacheKey(ssid, userId, owned) {
12178
12224
  if (!owned) {
12179
12225
  owned = false;
12180
12226
  }
12181
- return Api.ECacheKey.Account + Api.ECacheKey.Session + Api.ECacheKey.Id + ssid + Api.ECacheKey.Id + (owned ? "owned" : "related");
12227
+ if (!ssid) {
12228
+ ssid = "anonymous";
12229
+ }
12230
+ if (!userId) {
12231
+ userId = "anonymous";
12232
+ }
12233
+ 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
12234
  }
12183
12235
  Account.GetListCacheKey = GetListCacheKey;
12184
12236
  /**
@@ -12761,7 +12813,7 @@ var User;
12761
12813
  if (!api) {
12762
12814
  api = ENVIRONMENT.Api().GetGuardianApi();
12763
12815
  }
12764
- const cacheKey = GetCacheKey(id, accountId);
12816
+ const cacheKey = GetCacheKey(api.GetSessionId(), id, accountId);
12765
12817
  const cache = api.GetCacheItem(cacheKey, reqParams);
12766
12818
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12767
12819
  return cache.data;
@@ -12825,10 +12877,10 @@ var User;
12825
12877
  const res = yield api.POST(`user/${data.ID}`, data, reqParams);
12826
12878
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + data.ID);
12827
12879
  if (data.Type == EType.AccessToken) {
12828
- api.Cache.RemoveByStartsWith(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
12880
+ api.Cache.RemoveByContains(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
12829
12881
  }
12830
12882
  else if (data.Type == EType.User) {
12831
- api.Cache.RemoveByStartsWith(Api.ECacheKey.User + Api.ECacheKey.Account);
12883
+ api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Account);
12832
12884
  }
12833
12885
  return {
12834
12886
  user: res
@@ -12859,7 +12911,7 @@ var User;
12859
12911
  }
12860
12912
  const res = yield api.POST("user", data, reqParams);
12861
12913
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + data.ID);
12862
- api.Cache.RemoveByStartsWith(Api.ECacheKey.User + Api.ECacheKey.Account);
12914
+ api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Account);
12863
12915
  return {
12864
12916
  user: res
12865
12917
  };
@@ -12880,7 +12932,8 @@ var User;
12880
12932
  if (!api) {
12881
12933
  api = ENVIRONMENT.Api().GetGuardianApi();
12882
12934
  }
12883
- const cache = api.GetCacheItem(GetSettingsCacheKey(userId, appId), req);
12935
+ const cacheKey = GetSettingsCacheKey(api.GetSessionId(), userId, appId);
12936
+ const cache = api.GetCacheItem(cacheKey, req);
12884
12937
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
12885
12938
  return cache.data;
12886
12939
  }
@@ -12907,7 +12960,7 @@ var User;
12907
12960
  }
12908
12961
  }));
12909
12962
  api.SetCacheItem({
12910
- key: GetSettingsCacheKey(userId, appId),
12963
+ key: cacheKey,
12911
12964
  value: prom,
12912
12965
  req: req
12913
12966
  });
@@ -12937,7 +12990,7 @@ var User;
12937
12990
  UserID: userId
12938
12991
  };
12939
12992
  const prom = api.POST(`user/${userId}/application/${appId}/settings?Override=${override ? "true" : "false"}`, postBody, req);
12940
- api.Cache.Remove(GetSettingsCacheKey(userId, appId));
12993
+ api.Cache.Remove(GetSettingsCacheKey(api.GetSessionId(), userId, appId));
12941
12994
  return prom;
12942
12995
  });
12943
12996
  }
@@ -12986,14 +13039,20 @@ var User;
12986
13039
  * @param search
12987
13040
  * @returns
12988
13041
  */
12989
- function GetListCacheKey(accountId, exclusive, search) {
13042
+ function GetListCacheKey(sessionId, accountId, exclusive, search) {
12990
13043
  if (!exclusive) {
12991
13044
  exclusive = false;
12992
13045
  }
12993
13046
  if (!search) {
12994
13047
  search = "";
12995
13048
  }
12996
- return Api.ECacheKey.User + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Id + exclusive + Api.ECacheKey.Id + search;
13049
+ if (!sessionId) {
13050
+ sessionId = "anonymous";
13051
+ }
13052
+ if (!accountId) {
13053
+ accountId = "";
13054
+ }
13055
+ 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;
12997
13056
  }
12998
13057
  LoginUser.GetListCacheKey = GetListCacheKey;
12999
13058
  /**
@@ -13010,7 +13069,8 @@ var User;
13010
13069
  if (!api) {
13011
13070
  api = ENVIRONMENT.Api().GetGuardianApi();
13012
13071
  }
13013
- const cache = api.GetCacheItem(GetEmailCacheKey(email, accountId), reqParams);
13072
+ const cacheKey = GetEmailCacheKey(api.GetSessionId(), email, accountId);
13073
+ const cache = api.GetCacheItem(cacheKey, reqParams);
13014
13074
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13015
13075
  return cache.data;
13016
13076
  }
@@ -13026,7 +13086,7 @@ var User;
13026
13086
  }
13027
13087
  }));
13028
13088
  api.SetCacheItem({
13029
- key: GetEmailCacheKey(email, accountId),
13089
+ key: cacheKey,
13030
13090
  value: prom,
13031
13091
  req: reqParams
13032
13092
  });
@@ -13048,7 +13108,8 @@ var User;
13048
13108
  if (!exclusive) {
13049
13109
  exclusive = false;
13050
13110
  }
13051
- const cacheKey = GetListCacheKey(accountId, exclusive, search);
13111
+ const sessionId = api.GetSessionId();
13112
+ const cacheKey = GetListCacheKey(sessionId, accountId, exclusive, search);
13052
13113
  const cache = exclusive ? null : api.GetCacheItem(cacheKey, reqParams);
13053
13114
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13054
13115
  return cache.data;
@@ -13078,7 +13139,7 @@ var User;
13078
13139
  const users = data.users;
13079
13140
  for (let i = 0; i < users.length; i++) {
13080
13141
  api.SetCacheItem({
13081
- key: GetCacheKey(users[i].ID, accountId),
13142
+ key: GetCacheKey(sessionId, users[i].ID, accountId),
13082
13143
  value: {
13083
13144
  user: users[i]
13084
13145
  },
@@ -13236,11 +13297,18 @@ var User;
13236
13297
  * const key = GetListCacheKey("abc");
13237
13298
  * api.Cache.Remove(key);
13238
13299
  * }
13300
+ * @param sessionId
13239
13301
  * @param accountId
13240
13302
  * @returns
13241
13303
  */
13242
- function GetListCacheKey(accountId) {
13243
- return Api.ECacheKey.AccessToken + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId;
13304
+ function GetListCacheKey(sessionId, accountId) {
13305
+ if (!sessionId) {
13306
+ sessionId = "anonymous";
13307
+ }
13308
+ if (!accountId) {
13309
+ accountId = "";
13310
+ }
13311
+ return Api.ECacheKey.AccessToken + Api.ECacheKey.Account + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
13244
13312
  }
13245
13313
  AccessToken.GetListCacheKey = GetListCacheKey;
13246
13314
  /**
@@ -13254,7 +13322,8 @@ var User;
13254
13322
  if (!api) {
13255
13323
  api = ENVIRONMENT.Api().GetGuardianApi();
13256
13324
  }
13257
- const cache = api.GetCacheItem(GetListCacheKey(accountId), reqParams);
13325
+ const cacheKey = GetListCacheKey(api.GetSessionId(), accountId);
13326
+ const cache = api.GetCacheItem(cacheKey, reqParams);
13258
13327
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
13259
13328
  return cache.data;
13260
13329
  }
@@ -13270,7 +13339,7 @@ var User;
13270
13339
  }
13271
13340
  }));
13272
13341
  api.SetCacheItem({
13273
- key: GetListCacheKey(accountId),
13342
+ key: cacheKey,
13274
13343
  value: req,
13275
13344
  req: reqParams
13276
13345
  });
@@ -13290,7 +13359,7 @@ var User;
13290
13359
  }
13291
13360
  yield api.DELETE(`accessToken/${id}`, reqParams);
13292
13361
  api.Cache.RemoveByContains(Api.ECacheKey.User + Api.ECacheKey.Id + id);
13293
- api.Cache.RemoveByStartsWith(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13362
+ api.Cache.RemoveByContains(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13294
13363
  });
13295
13364
  }
13296
13365
  AccessToken.Delete = Delete;
@@ -13315,7 +13384,7 @@ var User;
13315
13384
  data.Type = EType.AccessToken;
13316
13385
  }
13317
13386
  data = yield api.POST("accessToken", data, reqParams);
13318
- api.Cache.RemoveByStartsWith(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13387
+ api.Cache.RemoveByContains(Api.ECacheKey.AccessToken + Api.ECacheKey.Account);
13319
13388
  return {
13320
13389
  user: data
13321
13390
  };
@@ -13350,15 +13419,19 @@ var User;
13350
13419
  * const key = GetCacheKey("abc", "def");
13351
13420
  * api.Cache.Remove(key);
13352
13421
  * }
13422
+ * @param sessionId
13353
13423
  * @param userId
13354
13424
  * @param accountId
13355
13425
  * @returns
13356
13426
  */
13357
- function GetCacheKey(userId, accountId) {
13427
+ function GetCacheKey(sessionId, userId, accountId) {
13358
13428
  if (!accountId) {
13359
13429
  accountId = "";
13360
13430
  }
13361
- return Api.ECacheKey.User + Api.ECacheKey.Id + userId + Api.ECacheKey.Id + accountId;
13431
+ if (!sessionId) {
13432
+ sessionId = "anonymous";
13433
+ }
13434
+ return Api.ECacheKey.User + Api.ECacheKey.Id + userId + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
13362
13435
  }
13363
13436
  User$$1.GetCacheKey = GetCacheKey;
13364
13437
  /**
@@ -13372,11 +13445,17 @@ var User;
13372
13445
  * @param accountId
13373
13446
  * @returns
13374
13447
  */
13375
- function GetEmailCacheKey(email, accountId) {
13448
+ function GetEmailCacheKey(sessionId, email, accountId) {
13376
13449
  if (!accountId) {
13377
13450
  accountId = "";
13378
13451
  }
13379
- return Api.ECacheKey.User + Api.ECacheKey.UserEmail + email + Api.ECacheKey.Id + accountId;
13452
+ if (!sessionId) {
13453
+ sessionId = "anonymous";
13454
+ }
13455
+ if (!email) {
13456
+ email = "";
13457
+ }
13458
+ return Api.ECacheKey.User + Api.ECacheKey.UserEmail + email + Api.ECacheKey.Id + accountId + Api.ECacheKey.Session + Api.ECacheKey.Id + sessionId;
13380
13459
  }
13381
13460
  User$$1.GetEmailCacheKey = GetEmailCacheKey;
13382
13461
  /**
@@ -13386,11 +13465,15 @@ var User;
13386
13465
  * const key = GetCacheKey("abc", "def");
13387
13466
  * api.Cache.Remove(key);
13388
13467
  * }
13468
+ * @param sessionId
13389
13469
  * @param userId
13390
13470
  * @param appId
13391
13471
  * @returns
13392
13472
  */
13393
- function GetSettingsCacheKey(userId, appId) {
13473
+ function GetSettingsCacheKey(sessionId, userId, appId) {
13474
+ if (!sessionId) {
13475
+ sessionId = "anonymous";
13476
+ }
13394
13477
  return Api.ECacheKey.User + Api.ECacheKey.UserSettings + userId + Api.ECacheKey.Id + appId;
13395
13478
  }
13396
13479
  User$$1.GetSettingsCacheKey = GetSettingsCacheKey;
@@ -16064,7 +16147,7 @@ var Tracking;
16064
16147
  })(Tracking || (Tracking = {}));
16065
16148
 
16066
16149
  // This is updated with the package.json version on build.
16067
- const VERSION = "6.4.8";
16150
+ const VERSION = "6.5.0";
16068
16151
 
16069
16152
  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 };
16070
16153
  //# sourceMappingURL=bruce-models.es5.js.map