bruce-models 6.4.9 → 6.5.1

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
  }
@@ -12623,6 +12661,7 @@ var Session;
12623
12661
  if ((_c = (_b = session === null || session === void 0 ? void 0 : session.User) === null || _b === void 0 ? void 0 : _b.AccessPermissions) === null || _c === void 0 ? void 0 : _c.length) {
12624
12662
  for (let i = 0; i < session.User.AccessPermissions.length; i++) {
12625
12663
  const perms = session.User.AccessPermissions[i];
12664
+ let accIdChecked = false;
12626
12665
  // Newer API versions always specify accountId in the collections.
12627
12666
  // If it's set we can do a super account check early.
12628
12667
  if (perms["ClientAccount.ID"] != null) {
@@ -12630,13 +12669,14 @@ var Session;
12630
12669
  if (pAccountId != Api.SUPER_ACCOUNT_ID) {
12631
12670
  continue;
12632
12671
  }
12672
+ accIdChecked = true;
12633
12673
  }
12634
12674
  if ((_d = perms === null || perms === void 0 ? void 0 : perms.UserGroups) === null || _d === void 0 ? void 0 : _d.length) {
12635
12675
  for (let j = 0; j < perms.UserGroups.length; j++) {
12636
12676
  const group = perms.UserGroups[j];
12637
12677
  if (typeof group != "string") {
12638
12678
  const gAccountId = String(group["ClientAccount.ID"]).toLowerCase();
12639
- if (gAccountId != Api.SUPER_ACCOUNT_ID) {
12679
+ if (gAccountId != Api.SUPER_ACCOUNT_ID && !accIdChecked) {
12640
12680
  continue;
12641
12681
  }
12642
12682
  const features = group.Features;
@@ -16109,7 +16149,7 @@ var Tracking;
16109
16149
  })(Tracking || (Tracking = {}));
16110
16150
 
16111
16151
  // This is updated with the package.json version on build.
16112
- const VERSION = "6.4.9";
16152
+ const VERSION = "6.5.1";
16113
16153
 
16114
16154
  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 };
16115
16155
  //# sourceMappingURL=bruce-models.es5.js.map