@rebasepro/common 0.4.0 → 0.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.
package/dist/index.umd.js CHANGED
@@ -907,14 +907,14 @@
907
907
  if (rule.withCheck && !evaluateAST(rule.withCheck, auth, entity)) return false;
908
908
  return true;
909
909
  }
910
- function checkOperation(collection, authController, entity, targetOperation) {
910
+ function checkOperation(collection, authContext, entity, targetOperation) {
911
911
  const securityRules = types.getDataSourceCapabilities(collection.driver).supportsRLS ? collection.securityRules : void 0;
912
912
  if (!securityRules || securityRules.length === 0) {
913
913
  return true;
914
914
  }
915
915
  const applicableRules = securityRules.filter((r) => r.operation === targetOperation || r.operation === "all" || r.operations?.includes(targetOperation) || r.operations?.includes("all"));
916
916
  if (applicableRules.length === 0) return false;
917
- const userRoleIds = authController.user?.roles ?? [];
917
+ const userRoleIds = authContext.user?.roles ?? [];
918
918
  const userRoles = [...userRoleIds, "public"];
919
919
  const roleApplicableRules = applicableRules.filter((rule) => {
920
920
  if (!rule.roles || rule.roles.length === 0) return true;
@@ -925,7 +925,7 @@
925
925
  let deniedByRestrictive = false;
926
926
  for (const rule of roleApplicableRules) {
927
927
  const mode = rule.mode || "permissive";
928
- const passed = evaluateRule(rule, authController, entity);
928
+ const passed = evaluateRule(rule, authContext, entity);
929
929
  if (mode === "restrictive" && !passed) {
930
930
  deniedByRestrictive = true;
931
931
  break;
@@ -942,17 +942,17 @@
942
942
  return false;
943
943
  }
944
944
  }
945
- function canReadCollection(collection, authController) {
946
- return checkOperation(collection, authController, null, "select");
945
+ function canReadCollection(collection, authContext) {
946
+ return checkOperation(collection, authContext, null, "select");
947
947
  }
948
- function canEditEntity(collection, authController, path, entity) {
949
- return checkOperation(collection, authController, entity, "update");
948
+ function canEditEntity(collection, authContext, path, entity) {
949
+ return checkOperation(collection, authContext, entity, "update");
950
950
  }
951
- function canCreateEntity(collection, authController, path, entity) {
952
- return checkOperation(collection, authController, entity, "insert");
951
+ function canCreateEntity(collection, authContext, path, entity) {
952
+ return checkOperation(collection, authContext, entity, "insert");
953
953
  }
954
- function canDeleteEntity(collection, authController, path, entity) {
955
- return checkOperation(collection, authController, entity, "delete");
954
+ function canDeleteEntity(collection, authContext, path, entity) {
955
+ return checkOperation(collection, authContext, entity, "delete");
956
956
  }
957
957
  function getEntityImagePreviewPropertyKey(collection) {
958
958
  for (const key in collection.properties) {