@servicelabsco/slabs-access-manager 0.0.16 → 0.0.17
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.
- package/dist/access/entities/menu.action.entity.d.ts +3 -1
- package/dist/access/entities/menu.action.entity.js +6 -4
- package/dist/access/entities/menu.action.entity.js.map +1 -1
- package/dist/access/entities/menu.entity.d.ts +2 -1
- package/dist/access/entities/menu.entity.js +3 -2
- package/dist/access/entities/menu.entity.js.map +1 -1
- package/dist/access/entities/module.entity.d.ts +2 -1
- package/dist/access/entities/module.entity.js +3 -2
- package/dist/access/entities/module.entity.js.map +1 -1
- package/dist/access/libraries/process.menu.details.js +8 -5
- package/dist/access/libraries/process.menu.details.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { CommonEntity
|
|
1
|
+
import { CommonEntity } from '@servicelabsco/nestjs-utility-services';
|
|
2
2
|
import { MenuActionAttributesDto } from '../dtos';
|
|
3
|
+
import { MenuEntity } from './menu.entity';
|
|
4
|
+
import { UiActionEntity } from './ui.action.entity';
|
|
3
5
|
export declare class MenuActionEntity extends CommonEntity {
|
|
4
6
|
ui_action_id: number;
|
|
5
7
|
menu_id: number;
|
|
@@ -13,6 +13,8 @@ exports.MenuActionEntity = void 0;
|
|
|
13
13
|
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
14
14
|
const typeorm_1 = require("typeorm");
|
|
15
15
|
const dtos_1 = require("../dtos");
|
|
16
|
+
const menu_entity_1 = require("./menu.entity");
|
|
17
|
+
const ui_action_entity_1 = require("./ui.action.entity");
|
|
16
18
|
let MenuActionEntity = class MenuActionEntity extends nestjs_utility_services_1.CommonEntity {
|
|
17
19
|
};
|
|
18
20
|
__decorate([
|
|
@@ -28,14 +30,14 @@ __decorate([
|
|
|
28
30
|
__metadata("design:type", dtos_1.MenuActionAttributesDto)
|
|
29
31
|
], MenuActionEntity.prototype, "attributes", void 0);
|
|
30
32
|
__decorate([
|
|
31
|
-
(0, typeorm_1.ManyToOne)(() =>
|
|
33
|
+
(0, typeorm_1.ManyToOne)(() => menu_entity_1.MenuEntity),
|
|
32
34
|
(0, typeorm_1.JoinColumn)({ name: 'menu_id' }),
|
|
33
|
-
__metadata("design:type",
|
|
35
|
+
__metadata("design:type", menu_entity_1.MenuEntity)
|
|
34
36
|
], MenuActionEntity.prototype, "menu", void 0);
|
|
35
37
|
__decorate([
|
|
36
|
-
(0, typeorm_1.ManyToOne)(() =>
|
|
38
|
+
(0, typeorm_1.ManyToOne)(() => ui_action_entity_1.UiActionEntity),
|
|
37
39
|
(0, typeorm_1.JoinColumn)({ name: 'ui_action_id' }),
|
|
38
|
-
__metadata("design:type",
|
|
40
|
+
__metadata("design:type", ui_action_entity_1.UiActionEntity)
|
|
39
41
|
], MenuActionEntity.prototype, "ui_action", void 0);
|
|
40
42
|
MenuActionEntity = __decorate([
|
|
41
43
|
(0, typeorm_1.Entity)('utl_menu_actions')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.action.entity.js","sourceRoot":"","sources":["../../../src/access/entities/menu.action.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"menu.action.entity.js","sourceRoot":"","sources":["../../../src/access/entities/menu.action.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oFAAsE;AACtE,qCAAgE;AAChE,kCAAkD;AAClD,+CAA2C;AAC3C,yDAAoD;AAS7C,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,sCAAY;CAajD,CAAA;AAZG;IAAC,IAAA,gBAAM,GAAE;;sDACY;AAErB;IAAC,IAAA,gBAAM,GAAE;;iDACO;AAEhB;IAAC,IAAA,gBAAM,EAAC,MAAM,CAAC;8BACH,8BAAuB;oDAAC;AAGpC;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8BAAO,wBAAU;8CAAC;AAC/E;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iCAAc,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;8BAAY,iCAAc;mDAAC;AAZxF,gBAAgB;IAD5B,IAAA,gBAAM,EAAC,kBAAkB,CAAC;GACd,gBAAgB,CAa5B;AAbY,4CAAgB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CommonEntity
|
|
1
|
+
import { CommonEntity } from '@servicelabsco/nestjs-utility-services';
|
|
2
|
+
import { UiActionEntity } from './ui.action.entity';
|
|
2
3
|
export declare class MenuEntity extends CommonEntity {
|
|
3
4
|
name: string;
|
|
4
5
|
label: string;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.MenuEntity = void 0;
|
|
13
13
|
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
14
14
|
const typeorm_1 = require("typeorm");
|
|
15
|
+
const ui_action_entity_1 = require("./ui.action.entity");
|
|
15
16
|
let MenuEntity = class MenuEntity extends nestjs_utility_services_1.CommonEntity {
|
|
16
17
|
};
|
|
17
18
|
__decorate([
|
|
@@ -55,9 +56,9 @@ __decorate([
|
|
|
55
56
|
__metadata("design:type", Object)
|
|
56
57
|
], MenuEntity.prototype, "attributes", void 0);
|
|
57
58
|
__decorate([
|
|
58
|
-
(0, typeorm_1.ManyToOne)(() =>
|
|
59
|
+
(0, typeorm_1.ManyToOne)(() => ui_action_entity_1.UiActionEntity),
|
|
59
60
|
(0, typeorm_1.JoinColumn)({ name: 'ui_action_id' }),
|
|
60
|
-
__metadata("design:type",
|
|
61
|
+
__metadata("design:type", ui_action_entity_1.UiActionEntity)
|
|
61
62
|
], MenuEntity.prototype, "ui_action", void 0);
|
|
62
63
|
MenuEntity = __decorate([
|
|
63
64
|
(0, typeorm_1.Entity)('utl_menu_details')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.entity.js","sourceRoot":"","sources":["../../../src/access/entities/menu.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"menu.entity.js","sourceRoot":"","sources":["../../../src/access/entities/menu.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oFAAsE;AACtE,qCAAgE;AAChE,yDAAoD;AAS7C,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,sCAAY;CAmC3C,CAAA;AAlCG;IAAC,IAAA,gBAAM,GAAE;;wCACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;yCACK;AAEd;IAAC,IAAA,gBAAM,GAAE;;gDACY;AAErB;IAAC,IAAA,gBAAM,GAAE;;yCACK;AAEd;IAAC,IAAA,gBAAM,GAAE;;+CACW;AAEpB;IAAC,IAAA,gBAAM,GAAE;;gDACY;AAErB;IAAC,IAAA,gBAAM,GAAE;;6CACS;AAElB;IAAC,IAAA,gBAAM,GAAE;;wCACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;8CACW;AAEpB;IAAC,IAAA,gBAAM,EAAC,MAAM,CAAC;;8CACC;AAGhB;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iCAAc,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;8BAAY,iCAAc;6CAAC;AAhCxF,UAAU;IADtB,IAAA,gBAAM,EAAC,kBAAkB,CAAC;GACd,UAAU,CAmCtB;AAnCY,gCAAU"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CommonEntity
|
|
1
|
+
import { CommonEntity } from '@servicelabsco/nestjs-utility-services';
|
|
2
2
|
import { ModuleAttributesDto } from '../dtos/module.attributes.dto';
|
|
3
3
|
import { ProductEntity } from './product.entity';
|
|
4
|
+
import { UiActionEntity } from './ui.action.entity';
|
|
4
5
|
export declare class ModuleEntity extends CommonEntity {
|
|
5
6
|
product_id: number;
|
|
6
7
|
name: string;
|
|
@@ -14,6 +14,7 @@ const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-service
|
|
|
14
14
|
const typeorm_1 = require("typeorm");
|
|
15
15
|
const module_attributes_dto_1 = require("../dtos/module.attributes.dto");
|
|
16
16
|
const product_entity_1 = require("./product.entity");
|
|
17
|
+
const ui_action_entity_1 = require("./ui.action.entity");
|
|
17
18
|
let ModuleEntity = class ModuleEntity extends nestjs_utility_services_1.CommonEntity {
|
|
18
19
|
};
|
|
19
20
|
__decorate([
|
|
@@ -74,9 +75,9 @@ __decorate([
|
|
|
74
75
|
__metadata("design:type", product_entity_1.ProductEntity)
|
|
75
76
|
], ModuleEntity.prototype, "product", void 0);
|
|
76
77
|
__decorate([
|
|
77
|
-
(0, typeorm_1.ManyToOne)(() =>
|
|
78
|
+
(0, typeorm_1.ManyToOne)(() => ui_action_entity_1.UiActionEntity),
|
|
78
79
|
(0, typeorm_1.JoinColumn)({ name: 'ui_action_id' }),
|
|
79
|
-
__metadata("design:type",
|
|
80
|
+
__metadata("design:type", ui_action_entity_1.UiActionEntity)
|
|
80
81
|
], ModuleEntity.prototype, "ui_action", void 0);
|
|
81
82
|
ModuleEntity = __decorate([
|
|
82
83
|
(0, typeorm_1.Entity)('utl_modules')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.entity.js","sourceRoot":"","sources":["../../../src/access/entities/module.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"module.entity.js","sourceRoot":"","sources":["../../../src/access/entities/module.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oFAAsE;AACtE,qCAAgE;AAChE,yEAAoE;AACpE,qDAAiD;AACjD,yDAAoD;AAS7C,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,sCAAY;CA4C7C,CAAA;AA3CG;IAAC,IAAA,gBAAM,GAAE;;gDACU;AAEnB;IAAC,IAAA,gBAAM,GAAE;;0CACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;2CACK;AAEd;IAAC,IAAA,gBAAM,GAAE;;kDACY;AAErB;IAAC,IAAA,gBAAM,GAAE;;2CACK;AAEd;IAAC,IAAA,gBAAM,GAAE;;iDACW;AAEpB;IAAC,IAAA,gBAAM,GAAE;;+CACS;AAElB;IAAC,IAAA,gBAAM,GAAE;;0CACI;AAEb;IAAC,IAAA,gBAAM,GAAE;;kDACY;AAErB;IAAC,IAAA,gBAAM,GAAE;;kDACa;AAEtB;IAAC,IAAA,gBAAM,GAAE;;mDACa;AAEtB;IAAC,IAAA,gBAAM,GAAE;;4CACO;AAEhB;IAAC,IAAA,gBAAM,EAAC,MAAM,CAAC;8BACH,2CAAmB;gDAAC;AAGhC;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,8BAAa,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAAU,8BAAa;6CAAC;AAE3F;IAAC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iCAAc,CAAC;IAAE,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;8BAAY,iCAAc;+CAAC;AA3CxF,YAAY;IADxB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,YAAY,CA4CxB;AA5CY,oCAAY"}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProcessMenuDetails = void 0;
|
|
4
4
|
const nestjs_utility_services_1 = require("@servicelabsco/nestjs-utility-services");
|
|
5
|
-
const
|
|
5
|
+
const child_menu_entity_1 = require("../entities/child.menu.entity");
|
|
6
|
+
const menu_action_entity_1 = require("../entities/menu.action.entity");
|
|
6
7
|
const menu_entity_1 = require("../entities/menu.entity");
|
|
8
|
+
const menu_role_entity_1 = require("../entities/menu.role.entity");
|
|
9
|
+
const ui_action_role_entity_1 = require("../entities/ui.action.role.entity");
|
|
7
10
|
class ProcessMenuDetails {
|
|
8
11
|
constructor(accessManager) {
|
|
9
12
|
this.accessManager = accessManager;
|
|
@@ -28,7 +31,7 @@ class ProcessMenuDetails {
|
|
|
28
31
|
return this.hasChildMenuAccess(menu);
|
|
29
32
|
}
|
|
30
33
|
async hasChildMenuAccess(menu) {
|
|
31
|
-
const parents = await
|
|
34
|
+
const parents = await child_menu_entity_1.ChildMenuEntity.find({ where: { menu_id: menu.id }, relations: ['parent'] });
|
|
32
35
|
for (const parent of parents) {
|
|
33
36
|
const hasAccess = await this.userHasAccess(parent.parent);
|
|
34
37
|
if (hasAccess)
|
|
@@ -37,13 +40,13 @@ class ProcessMenuDetails {
|
|
|
37
40
|
return false;
|
|
38
41
|
}
|
|
39
42
|
async userHasAccess(menu) {
|
|
40
|
-
const roles = await
|
|
43
|
+
const roles = await menu_role_entity_1.MenuRoleEntity.find({ where: { menu_id: menu.id } });
|
|
41
44
|
if (!roles.length)
|
|
42
45
|
return true;
|
|
43
46
|
return this.accessManager.hasRoleAssignments(roles);
|
|
44
47
|
}
|
|
45
48
|
async getUiActions(menu) {
|
|
46
|
-
const uiActions = await
|
|
49
|
+
const uiActions = await menu_action_entity_1.MenuActionEntity.find({ where: { menu_id: menu.id }, relations: ['ui_action'] });
|
|
47
50
|
const promises = [];
|
|
48
51
|
for (const action of uiActions) {
|
|
49
52
|
promises.push(this.uiActionHasRole(action.ui_action));
|
|
@@ -55,7 +58,7 @@ class ProcessMenuDetails {
|
|
|
55
58
|
async uiActionHasRole(uiAction) {
|
|
56
59
|
if (!uiAction?.id)
|
|
57
60
|
return false;
|
|
58
|
-
const roles = await
|
|
61
|
+
const roles = await ui_action_role_entity_1.UiActionRoleEntity.find({ where: { ui_action_id: uiAction.id } });
|
|
59
62
|
if (!roles.length)
|
|
60
63
|
return uiAction;
|
|
61
64
|
const hasAccess = this.accessManager.hasRoleAssignments(roles);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.menu.details.js","sourceRoot":"","sources":["../../../src/access/libraries/process.menu.details.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"process.menu.details.js","sourceRoot":"","sources":["../../../src/access/libraries/process.menu.details.ts"],"names":[],"mappings":";;;AAAA,oFAAwF;AACxF,qEAAgE;AAChE,uEAAkE;AAClE,yDAAqD;AACrD,mEAA8D;AAE9D,6EAAuE;AAEvE,MAAa,kBAAkB;IAC3B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,KAAK,CAAC,OAAO,CAAC,MAAc;QACxB,MAAM,IAAI,GAAG,MAAM,wBAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,yCAAe,EAAE,CAAC;QAEvC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,yCAAe,EAAE,CAAC;QAE5C,MAAM,SAAS,GAAqB,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAElE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACxC,OAAO,IAAI,EAAE,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,IAAgB;QACpC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAEvD,IAAI,eAAe;YAAE,OAAO,IAAI,CAAC;QAEjC,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,IAAgB;QAC7C,MAAM,OAAO,GAAG,MAAM,mCAAe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