import { Injectable } from '@angular/core';
import { IPermissionsMapping, PermissionsMapping } from '@red/domain';
import { EntitiesMapService } from '@iqser/common-ui';

@Injectable({ providedIn: 'root' })
export class PermissionsConfigurationMapService extends EntitiesMapService<IPermissionsMapping, PermissionsMapping> {
    getMappedPermissions(targetObject: string): string[] {
        const mappedPermissions = this.get(targetObject).flatMap(p => p.mappedPermissions);
        return Array.from(new Set(mappedPermissions.map(p => p.name)));
    }
}
