|
@@ -97,21 +97,17 @@ class RoleUtils {
|
|
|
static parseRole(role: string): Role {
|
|
static parseRole(role: string): Role {
|
|
|
const parts = role.split('_')
|
|
const parts = role.split('_')
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
- parts.shift()
|
|
|
|
|
|
|
+ parts.shift()
|
|
|
|
|
|
|
|
- let action: 'VIEW' | 'CORE' | 'REFERENCE' | '' = ''
|
|
|
|
|
- if (actions.includes(parts.at(-1) ?? '')) {
|
|
|
|
|
- // @ts-ignore
|
|
|
|
|
- action = parts.pop() ?? ''
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let action: 'VIEW' | 'CORE' | 'REFERENCE' | '' = ''
|
|
|
|
|
+ if (actions.includes(parts.at(-1) ?? '')) {
|
|
|
|
|
+ // @ts-ignore
|
|
|
|
|
+ action = parts.pop() ?? ''
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const subject = parts.join('-')
|
|
|
|
|
|
|
+ const subject = parts.join('-')
|
|
|
|
|
|
|
|
- return { subject, action }
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- throw new Error('can not parse role: ' + role, { cause: error })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return { subject, action }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static roleToString(role: Role) {
|
|
static roleToString(role: Role) {
|