feat(flows): add flow filters

This commit is contained in:
Ali BARIN
2025-03-19 16:13:36 +00:00
parent d00c5e166f
commit 3d060df5bd
10 changed files with 275 additions and 34 deletions

View File

@@ -0,0 +1,5 @@
export default function objectifyUrlSearchParams(searchParams) {
return Array.from(searchParams.entries()).reduce((acc, [key, value]) => {
return { ...acc, [key]: value };
}, {});
}

View File

@@ -3,17 +3,21 @@ import {
fieldPatternMatcher,
mongoQueryMatcher,
} from '@casl/ability';
// Must be kept in sync with `packages/backend/src/helpers/user-ability.ts`!
// Must be kept in sync with `packages/backend/src/helpers/user-ability.js`!
export default function userAbility(user) {
const permissions = user?.permissions;
const role = user?.role;
// We're not using mongo, but our fields, conditions match
const options = {
conditionsMatcher: mongoQueryMatcher,
fieldMatcher: fieldPatternMatcher,
};
if (!role || !permissions) {
return new PureAbility([], options);
}
return new PureAbility(permissions, options);
}