@budibase/backend-core 2.33.10 → 2.33.11

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.
package/dist/index.js CHANGED
@@ -69702,7 +69702,7 @@ function getBuiltinRole(roleId) {
69702
69702
  function builtinRoleToNumber(id) {
69703
69703
  const builtins = getBuiltinRoles();
69704
69704
  const MAX = Object.values(builtins).length + 1;
69705
- if (compareRoleIds(id, BUILTIN_IDS.ADMIN) || compareRoleIds(id, BUILTIN_IDS.BUILDER)) {
69705
+ if (id === BUILTIN_IDS.ADMIN || id === BUILTIN_IDS.BUILDER) {
69706
69706
  return MAX;
69707
69707
  }
69708
69708
  let role = builtins[id], count = 0;
@@ -69732,9 +69732,7 @@ async function roleToNumber(id) {
69732
69732
  }
69733
69733
  if (Array.isArray(role.inherits)) {
69734
69734
  const highestBuiltin = role.inherits.map((roleId) => {
69735
- const foundRole = hierarchy.find(
69736
- (role2) => compareRoleIds(role2._id, roleId)
69737
- );
69735
+ const foundRole = hierarchy.find((role2) => role2._id === roleId);
69738
69736
  if (foundRole) {
69739
69737
  return findNumber(foundRole) + 1;
69740
69738
  }
@@ -69811,7 +69809,7 @@ async function saveRoles(roles) {
69811
69809
  }
69812
69810
  async function getAllUserRoles(userRoleId, opts) {
69813
69811
  const allRoles = await getAllRoles();
69814
- if (compareRoleIds(userRoleId, BUILTIN_IDS.ADMIN)) {
69812
+ if (userRoleId === BUILTIN_IDS.ADMIN) {
69815
69813
  return allRoles;
69816
69814
  }
69817
69815
  const foundRole = findRole(userRoleId, allRoles, opts);
@@ -69886,19 +69884,14 @@ async function getAllRoles(appId) {
69886
69884
  for (let builtinRoleId of externalBuiltinRoles) {
69887
69885
  const builtinRole = builtinRoles[builtinRoleId];
69888
69886
  const dbBuiltin = roles.filter(
69889
- (dbRole) => compareRoleIds(dbRole._id, builtinRoleId)
69887
+ (dbRole) => getExternalRoleID(dbRole._id, dbRole.version) === builtinRoleId
69890
69888
  )[0];
69891
69889
  if (dbBuiltin == null) {
69892
69890
  roles.push(builtinRole || builtinRoles.BASIC);
69893
69891
  } else {
69894
69892
  roles = roles.filter((role) => role._id !== dbBuiltin._id);
69895
- dbBuiltin._id = getExternalRoleID(builtinRole._id, dbBuiltin.version);
69896
- roles.push({
69897
- ...builtinRole,
69898
- ...dbBuiltin,
69899
- name: builtinRole.name,
69900
- _id: getExternalRoleID(builtinRole._id, builtinRole.version)
69901
- });
69893
+ dbBuiltin._id = getExternalRoleID(dbBuiltin._id, dbBuiltin.version);
69894
+ roles.push(Object.assign(builtinRole, dbBuiltin));
69902
69895
  }
69903
69896
  }
69904
69897
  for (let role of roles) {
@@ -69929,7 +69922,7 @@ var AccessController = class {
69929
69922
  this.userHierarchies = {};
69930
69923
  }
69931
69924
  async hasAccess(tryingRoleId, userRoleId) {
69932
- if (tryingRoleId == null || tryingRoleId === "" || compareRoleIds(tryingRoleId, BUILTIN_IDS.BUILDER) || compareRoleIds(userRoleId, tryingRoleId) || compareRoleIds(userRoleId, BUILTIN_IDS.BUILDER)) {
69925
+ if (tryingRoleId == null || tryingRoleId === "" || tryingRoleId === userRoleId || tryingRoleId === BUILTIN_IDS.BUILDER || userRoleId === BUILTIN_IDS.BUILDER) {
69933
69926
  return true;
69934
69927
  }
69935
69928
  let roleIds = userRoleId ? this.userHierarchies[userRoleId] : null;