law-common 14.1.4-beta.7 → 14.1.4-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IBaseEntityApiResponse, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
1
|
+
import { EntityEnum, EntityIndexMap, EntityMap, EnumEntityType, EnumToModel, IBaseEntityApiResponse, ISearchIncludeEntity, VirtualEntityEnum } from "../interface/entity.utils.interface";
|
|
2
|
+
import { PermissionGroupEnum } from "../enums/permission_group_enum";
|
|
3
|
+
import { IUserEntity } from "../interface/user.entity.interface";
|
|
2
4
|
import { BaseEntityModel } from "./base.entity.model";
|
|
3
5
|
export declare function mapToIndex(entityMap: EntityMap): EntityIndexMap;
|
|
4
6
|
export declare function getEntityIndexMap<T extends EntityEnum>(data: IBaseEntityApiResponse<EnumEntityType<T>>, baseEntity: T, reusedConfig?: {
|
|
@@ -51,4 +53,11 @@ export declare class EntityModelRelationHelper {
|
|
|
51
53
|
mergeHelperFrom(other: EntityModelRelationHelper, config?: {
|
|
52
54
|
populateRelations?: boolean;
|
|
53
55
|
}): EntityModelRelationHelper;
|
|
56
|
+
/**
|
|
57
|
+
* Builds the role-scoped permission search entity: ROLE (caller's role) -> ROLE_PERMISSION_MAPPING -> PERMISSION
|
|
58
|
+
* (entity + org + action groups). Append to `filter.entities` so the caller's permissions land in the helper.
|
|
59
|
+
*/
|
|
60
|
+
static getRoleFilterFromDtos<T extends EntityEnum>(currentUser: IUserEntity, entity: T, dtos: {
|
|
61
|
+
getActionPermissionGroup(): PermissionGroupEnum;
|
|
62
|
+
}[]): ISearchIncludeEntity<EntityEnum>;
|
|
54
63
|
}
|
|
@@ -485,5 +485,34 @@ class EntityModelRelationHelper {
|
|
|
485
485
|
}
|
|
486
486
|
return EntityModelRelationHelper.getClone(this);
|
|
487
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* Builds the role-scoped permission search entity: ROLE (caller's role) -> ROLE_PERMISSION_MAPPING -> PERMISSION
|
|
490
|
+
* (entity + org + action groups). Append to `filter.entities` so the caller's permissions land in the helper.
|
|
491
|
+
*/
|
|
492
|
+
static getRoleFilterFromDtos(currentUser, entity, dtos) {
|
|
493
|
+
const permissionSearch = {
|
|
494
|
+
name: entity_utils_interface_1.EntityEnum.PERMISSION,
|
|
495
|
+
include: {
|
|
496
|
+
entity: [entity],
|
|
497
|
+
organizationId: [currentUser.organizationId],
|
|
498
|
+
group: [...new Set(dtos.map((dto) => dto.getActionPermissionGroup()))],
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
const rolePermissionMappingSearch = {
|
|
502
|
+
name: entity_utils_interface_1.EntityEnum.ROLE_PERMISSION_MAPPING,
|
|
503
|
+
columnKeys: ["roleId", "permissionId", "id"],
|
|
504
|
+
relations: [permissionSearch],
|
|
505
|
+
};
|
|
506
|
+
const roleSearch = {
|
|
507
|
+
name: entity_utils_interface_1.EntityEnum.ROLE,
|
|
508
|
+
columnKeys: ["id", "name", "organizationId"],
|
|
509
|
+
include: {
|
|
510
|
+
name: [currentUser.role],
|
|
511
|
+
organizationId: [currentUser.organizationId],
|
|
512
|
+
},
|
|
513
|
+
relations: [rolePermissionMappingSearch],
|
|
514
|
+
};
|
|
515
|
+
return roleSearch;
|
|
516
|
+
}
|
|
488
517
|
}
|
|
489
518
|
exports.EntityModelRelationHelper = EntityModelRelationHelper;
|