mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-19 07:20:00 +00:00
16 lines
471 B
TypeScript
16 lines
471 B
TypeScript
![]() |
import { TSelfGrantableRoleEntry } from "../types";
|
||
|
|
||
|
export function findMatchingRoles(roleNames, entries: TSelfGrantableRoleEntry[]): string[] {
|
||
|
const aliasToRoleId = entries.reduce((map, entry) => {
|
||
|
for (const [roleId, aliases] of Object.entries(entry.roles)) {
|
||
|
for (const alias of aliases) {
|
||
|
map.set(alias, roleId);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return map;
|
||
|
}, new Map());
|
||
|
|
||
|
return roleNames.map(roleName => aliasToRoleId.get(roleName)).filter(Boolean);
|
||
|
}
|