bruce-models 4.5.1 → 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.
@@ -10777,14 +10777,37 @@
10777
10777
  * @returns
10778
10778
  */
10779
10779
  function IsSuperPermEnabled(params) {
10780
- var _a, _b;
10780
+ var _a, _b, _c, _d;
10781
10781
  let { session, perm } = params;
10782
10782
  if (!perm) {
10783
10783
  throw ("Perm is required.");
10784
10784
  }
10785
+ if (!session) {
10786
+ return false;
10787
+ }
10785
10788
  perm = perm.toLocaleUpperCase();
10786
- 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 : [];
10787
- return accessPerms.findIndex(x => x.toLocaleUpperCase() == perm) > -1;
10789
+ // We'll look for 'HypeportalAccessPermisssions' first.
10790
+ if ((_a = session.HypeportalAccessPermisssions) === null || _a === void 0 ? void 0 : _a.EnabledFeatures) {
10791
+ const perms = session.HypeportalAccessPermisssions.EnabledFeatures;
10792
+ return perms.findIndex(x => x.toLocaleUpperCase() == perm) > -1;
10793
+ }
10794
+ // Fallback to looking through groups.
10795
+ // This is important if the user directly logged into "hypeportal" as the response differs.
10796
+ else if ((_c = (_b = session.User) === null || _b === void 0 ? void 0 : _b.AccessPermissions) === null || _c === void 0 ? void 0 : _c.length) {
10797
+ const perms = session.User.AccessPermissions.find(x => String(x["ClientAccount.ID"]).toLowerCase() == "hypeportal");
10798
+ if ((_d = perms === null || perms === void 0 ? void 0 : perms.UserGroups) === null || _d === void 0 ? void 0 : _d.length) {
10799
+ for (let j = 0; j < perms.UserGroups.length; j++) {
10800
+ const group = perms.UserGroups[j];
10801
+ if (typeof group != "string") {
10802
+ const features = group.Features;
10803
+ if (features && features.findIndex(x => x.toLocaleUpperCase() == perm) > -1) {
10804
+ return true;
10805
+ }
10806
+ }
10807
+ }
10808
+ }
10809
+ }
10810
+ return false;
10788
10811
  }
10789
10812
  Session.IsSuperPermEnabled = IsSuperPermEnabled;
10790
10813
  /**
@@ -13387,7 +13410,7 @@
13387
13410
  })(exports.DataSource || (exports.DataSource = {}));
13388
13411
 
13389
13412
  // This is updated with the package.json version on build.
13390
- const VERSION = "4.5.1";
13413
+ const VERSION = "4.5.2";
13391
13414
 
13392
13415
  exports.VERSION = VERSION;
13393
13416
  exports.AbstractApi = AbstractApi;