bruce-models 4.5.0 → 4.5.2

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.
@@ -11000,14 +11000,37 @@ var Session;
11000
11000
  * @returns
11001
11001
  */
11002
11002
  function IsSuperPermEnabled(params) {
11003
- var _a, _b;
11003
+ var _a, _b, _c, _d;
11004
11004
  let { session, perm } = params;
11005
11005
  if (!perm) {
11006
11006
  throw ("Perm is required.");
11007
11007
  }
11008
+ if (!session) {
11009
+ return false;
11010
+ }
11008
11011
  perm = perm.toLocaleUpperCase();
11009
- const accessPerms = (_b = (_a = session === null || session === void 0 ? void 0 : session.HypeportalAccessPermisssions) === null || _a === void 0 ? void 0 : _a.EnabledFeatures) !== null && _b !== void 0 ? _b : [];
11010
- return accessPerms.findIndex(x => x.toLocaleUpperCase() == perm) > -1;
11012
+ // We'll look for 'HypeportalAccessPermisssions' first.
11013
+ if ((_a = session.HypeportalAccessPermisssions) === null || _a === void 0 ? void 0 : _a.EnabledFeatures) {
11014
+ const perms = session.HypeportalAccessPermisssions.EnabledFeatures;
11015
+ return perms.findIndex(x => x.toLocaleUpperCase() == perm) > -1;
11016
+ }
11017
+ // Fallback to looking through groups.
11018
+ // This is important if the user directly logged into "hypeportal" as the response differs.
11019
+ else if ((_c = (_b = session.User) === null || _b === void 0 ? void 0 : _b.AccessPermissions) === null || _c === void 0 ? void 0 : _c.length) {
11020
+ const perms = session.User.AccessPermissions.find(x => String(x["ClientAccount.ID"]).toLowerCase() == "hypeportal");
11021
+ if ((_d = perms === null || perms === void 0 ? void 0 : perms.UserGroups) === null || _d === void 0 ? void 0 : _d.length) {
11022
+ for (let j = 0; j < perms.UserGroups.length; j++) {
11023
+ const group = perms.UserGroups[j];
11024
+ if (typeof group != "string") {
11025
+ const features = group.Features;
11026
+ if (features && features.findIndex(x => x.toLocaleUpperCase() == perm) > -1) {
11027
+ return true;
11028
+ }
11029
+ }
11030
+ }
11031
+ }
11032
+ }
11033
+ return false;
11011
11034
  }
11012
11035
  Session.IsSuperPermEnabled = IsSuperPermEnabled;
11013
11036
  /**
@@ -13658,7 +13681,7 @@ var DataSource;
13658
13681
  })(DataSource || (DataSource = {}));
13659
13682
 
13660
13683
  // This is updated with the package.json version on build.
13661
- const VERSION = "4.5.0";
13684
+ const VERSION = "4.5.2";
13662
13685
 
13663
13686
  export { VERSION, AnnDocument, CustomForm, AbstractApi, Api, BruceApi, GlobalApi, GuardianApi, ApiGetters, Calculator, Bounds, BruceEvent, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, Geometry, UTC, BruceVariable, LRUCache, EntityAttachmentType, EntityAttachment, EntityComment, EntityLink, EntityLod, EntityLodCategory, EntityRelationType, EntityRelation, EntitySource, EntityTag, EntityType, Entity, EntityCoords, EntityTypeVisualSettings, EntityAttribute, EntityHistoricData, EntityTableView, Comment, ClientFile, ProgramKey, ZoomControl, MenuItem, ProjectViewBookmark, ProjectView, ProjectViewLegacyTile, ProjectViewTile, ProjectViewLegacy, ProjectViewLegacyBookmark, PendingAction, MessageBroker, HostingLocation, Style, Tileset, Permission, Session, UserGroup, User, Account, AccountInvite, AccountFeatures, AccountLimits, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, DataLab, ImportCad, ImportCsv, ImportJson, ImportKml, ImportedFile, Markup, Uploader, Plugin, ENVIRONMENT, DataSource };
13664
13687
  //# sourceMappingURL=bruce-models.es5.js.map