mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor(core): Mark all backend Enterprise Edition files and dirs (#12350)
This commit is contained in:
23
packages/@n8n/permissions/src/combineScopes.ee.ts
Normal file
23
packages/@n8n/permissions/src/combineScopes.ee.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Scope, ScopeLevels, GlobalScopes, MaskLevels } from './types.ee';
|
||||
|
||||
export function combineScopes(userScopes: GlobalScopes, masks?: MaskLevels): Set<Scope>;
|
||||
export function combineScopes(userScopes: ScopeLevels, masks?: MaskLevels): Set<Scope>;
|
||||
export function combineScopes(
|
||||
userScopes: GlobalScopes | ScopeLevels,
|
||||
masks?: MaskLevels,
|
||||
): Set<Scope> {
|
||||
const maskedScopes: GlobalScopes | ScopeLevels = Object.fromEntries(
|
||||
Object.entries(userScopes).map((e) => [e[0], [...e[1]]]),
|
||||
) as GlobalScopes | ScopeLevels;
|
||||
|
||||
if (masks?.sharing) {
|
||||
if ('project' in maskedScopes) {
|
||||
maskedScopes.project = maskedScopes.project.filter((v) => masks.sharing.includes(v));
|
||||
}
|
||||
if ('resource' in maskedScopes) {
|
||||
maskedScopes.resource = maskedScopes.resource.filter((v) => masks.sharing.includes(v));
|
||||
}
|
||||
}
|
||||
|
||||
return new Set(Object.values(maskedScopes).flat());
|
||||
}
|
||||
Reference in New Issue
Block a user