@flusys/nestjs-iam 7.1.0 → 8.0.0
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/config/index.d.ts +3 -3
- package/config/message-keys.d.ts +2 -0
- package/controllers/action.controller.d.ts +4 -4
- package/controllers/company-action-permission.controller.d.ts +2 -2
- package/controllers/index.d.ts +6 -6
- package/controllers/my-permission.controller.d.ts +3 -3
- package/controllers/role-permission.controller.d.ts +5 -4
- package/controllers/role.controller.d.ts +2 -2
- package/controllers/user-action-permission.controller.d.ts +5 -4
- package/docs/iam-swagger.config.d.ts +2 -2
- package/docs/index.d.ts +1 -1
- package/dtos/action.dto.d.ts +2 -2
- package/dtos/index.d.ts +3 -3
- package/dtos/permission.dto.d.ts +16 -0
- package/entities/action.entity.d.ts +2 -2
- package/entities/index.d.ts +11 -11
- package/entities/permission-with-company.entity.d.ts +1 -1
- package/entities/role-with-company.entity.d.ts +1 -1
- package/entities/role.entity.d.ts +1 -1
- package/entities/user-iam-permission.entity.d.ts +1 -1
- package/enums/index.d.ts +4 -4
- package/fesm/284.js +1316 -0
- package/fesm/867.js +3801 -0
- package/fesm/chunks/364.js +86 -0
- package/fesm/config/index.js +135 -3
- package/fesm/controllers/index.js +18 -7
- package/fesm/docs/index.js +240 -1
- package/fesm/dtos/index.js +1168 -3
- package/fesm/entities/index.js +670 -31
- package/fesm/enums/index.js +97 -4
- package/fesm/helpers/index.js +125 -2
- package/fesm/index.js +818 -11
- package/fesm/interfaces/index.js +17 -3
- package/fesm/modules/index.js +259 -1
- package/fesm/runtime.js +134 -0
- package/fesm/services/index.js +43 -6
- package/fesm/types/index.js +15 -1
- package/helpers/company-access.helper.d.ts +2 -2
- package/helpers/index.d.ts +2 -2
- package/helpers/permission-mode.helper.d.ts +1 -1
- package/index.d.ts +11 -11
- package/interfaces/action.interface.d.ts +2 -2
- package/interfaces/iam-module-options.interface.d.ts +3 -3
- package/interfaces/index.d.ts +3 -3
- package/modules/iam.module.d.ts +2 -2
- package/modules/index.d.ts +1 -1
- package/package.json +30 -37
- package/services/action.service.d.ts +9 -9
- package/services/iam-config.service.d.ts +4 -4
- package/services/iam-datasource.service.d.ts +3 -3
- package/services/index.d.ts +6 -6
- package/services/permission-cache.service.d.ts +5 -5
- package/services/permission.service.d.ts +6 -4
- package/services/role.service.d.ts +8 -8
- package/types/index.d.ts +1 -1
- package/cjs/config/event-actions.js +0 -36
- package/cjs/config/iam.constants.js +0 -11
- package/cjs/config/index.js +0 -20
- package/cjs/config/message-keys.js +0 -71
- package/cjs/controllers/action.controller.js +0 -174
- package/cjs/controllers/action.controller.spec.js +0 -79
- package/cjs/controllers/company-action-permission.controller.js +0 -119
- package/cjs/controllers/company-action-permission.controller.spec.js +0 -65
- package/cjs/controllers/index.js +0 -23
- package/cjs/controllers/my-permission.controller.js +0 -147
- package/cjs/controllers/my-permission.controller.spec.js +0 -128
- package/cjs/controllers/role-permission.controller.js +0 -191
- package/cjs/controllers/role-permission.controller.spec.js +0 -140
- package/cjs/controllers/role.controller.js +0 -102
- package/cjs/controllers/role.controller.spec.js +0 -86
- package/cjs/controllers/user-action-permission.controller.js +0 -129
- package/cjs/controllers/user-action-permission.controller.spec.js +0 -68
- package/cjs/docs/iam-swagger.config.js +0 -209
- package/cjs/docs/iam-swagger.config.spec.js +0 -99
- package/cjs/docs/index.js +0 -18
- package/cjs/dtos/action.dto.js +0 -282
- package/cjs/dtos/index.js +0 -21
- package/cjs/dtos/permission.dto.js +0 -637
- package/cjs/dtos/role.dto.js +0 -155
- package/cjs/entities/action.entity.js +0 -138
- package/cjs/entities/index.js +0 -80
- package/cjs/entities/index.spec.js +0 -56
- package/cjs/entities/permission-base.entity.js +0 -107
- package/cjs/entities/permission-with-company.entity.js +0 -100
- package/cjs/entities/role-base.entity.js +0 -80
- package/cjs/entities/role-with-company.entity.js +0 -55
- package/cjs/entities/role.entity.js +0 -25
- package/cjs/entities/user-iam-permission.entity.js +0 -43
- package/cjs/enums/action-type.enum.js +0 -22
- package/cjs/enums/iam-entity-type.enum.js +0 -17
- package/cjs/enums/iam-permission-type.enum.js +0 -17
- package/cjs/enums/index.js +0 -21
- package/cjs/enums/permission-type.enum.js +0 -16
- package/cjs/helpers/company-access.helper.js +0 -23
- package/cjs/helpers/company-access.helper.spec.js +0 -68
- package/cjs/helpers/index.js +0 -19
- package/cjs/helpers/permission-mode.helper.js +0 -49
- package/cjs/helpers/permission-mode.helper.spec.js +0 -54
- package/cjs/index.js +0 -28
- package/cjs/interfaces/action.interface.js +0 -4
- package/cjs/interfaces/iam-module-options.interface.js +0 -4
- package/cjs/interfaces/index.js +0 -20
- package/cjs/interfaces/role.interface.js +0 -7
- package/cjs/modules/iam.module.js +0 -186
- package/cjs/modules/iam.module.spec.js +0 -282
- package/cjs/modules/index.js +0 -18
- package/cjs/services/action.service.js +0 -337
- package/cjs/services/action.service.spec.js +0 -351
- package/cjs/services/iam-config.service.js +0 -87
- package/cjs/services/iam-config.service.spec.js +0 -110
- package/cjs/services/iam-datasource.service.js +0 -129
- package/cjs/services/iam-datasource.service.spec.js +0 -110
- package/cjs/services/index.js +0 -23
- package/cjs/services/permission-cache.service.js +0 -544
- package/cjs/services/permission-cache.service.spec.js +0 -718
- package/cjs/services/permission.service.js +0 -914
- package/cjs/services/permission.service.spec.js +0 -918
- package/cjs/services/role.service.js +0 -224
- package/cjs/services/role.service.spec.js +0 -347
- package/cjs/types/index.js +0 -18
- package/cjs/types/logic-node.type.js +0 -30
- package/fesm/config/event-actions.js +0 -15
- package/fesm/config/iam.constants.js +0 -1
- package/fesm/config/message-keys.js +0 -35
- package/fesm/controllers/action.controller.js +0 -164
- package/fesm/controllers/action.controller.spec.js +0 -75
- package/fesm/controllers/company-action-permission.controller.js +0 -109
- package/fesm/controllers/company-action-permission.controller.spec.js +0 -61
- package/fesm/controllers/my-permission.controller.js +0 -137
- package/fesm/controllers/my-permission.controller.spec.js +0 -124
- package/fesm/controllers/role-permission.controller.js +0 -181
- package/fesm/controllers/role-permission.controller.spec.js +0 -136
- package/fesm/controllers/role.controller.js +0 -92
- package/fesm/controllers/role.controller.spec.js +0 -82
- package/fesm/controllers/user-action-permission.controller.js +0 -119
- package/fesm/controllers/user-action-permission.controller.spec.js +0 -64
- package/fesm/docs/iam-swagger.config.js +0 -199
- package/fesm/docs/iam-swagger.config.spec.js +0 -95
- package/fesm/dtos/action.dto.js +0 -252
- package/fesm/dtos/permission.dto.js +0 -571
- package/fesm/dtos/role.dto.js +0 -134
- package/fesm/entities/action.entity.js +0 -128
- package/fesm/entities/index.spec.js +0 -52
- package/fesm/entities/permission-base.entity.js +0 -100
- package/fesm/entities/permission-with-company.entity.js +0 -90
- package/fesm/entities/role-base.entity.js +0 -70
- package/fesm/entities/role-with-company.entity.js +0 -45
- package/fesm/entities/role.entity.js +0 -15
- package/fesm/entities/user-iam-permission.entity.js +0 -33
- package/fesm/enums/action-type.enum.js +0 -12
- package/fesm/enums/iam-entity-type.enum.js +0 -7
- package/fesm/enums/iam-permission-type.enum.js +0 -7
- package/fesm/enums/permission-type.enum.js +0 -6
- package/fesm/helpers/company-access.helper.js +0 -18
- package/fesm/helpers/company-access.helper.spec.js +0 -64
- package/fesm/helpers/permission-mode.helper.js +0 -49
- package/fesm/helpers/permission-mode.helper.spec.js +0 -50
- package/fesm/interfaces/action.interface.js +0 -3
- package/fesm/interfaces/iam-module-options.interface.js +0 -3
- package/fesm/interfaces/role.interface.js +0 -4
- package/fesm/modules/iam.module.js +0 -176
- package/fesm/modules/iam.module.spec.js +0 -278
- package/fesm/services/action.service.js +0 -327
- package/fesm/services/action.service.spec.js +0 -347
- package/fesm/services/iam-config.service.js +0 -77
- package/fesm/services/iam-config.service.spec.js +0 -106
- package/fesm/services/iam-datasource.service.js +0 -78
- package/fesm/services/iam-datasource.service.spec.js +0 -106
- package/fesm/services/permission-cache.service.js +0 -527
- package/fesm/services/permission-cache.service.spec.js +0 -714
- package/fesm/services/permission.service.js +0 -904
- package/fesm/services/permission.service.spec.js +0 -914
- package/fesm/services/role.service.js +0 -214
- package/fesm/services/role.service.spec.js +0 -343
- package/fesm/types/logic-node.type.js +0 -27
package/package.json
CHANGED
|
@@ -1,96 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-iam",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Identity and Access Management (IAM) module for NestJS applications",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./fesm/index.js",
|
|
7
|
+
"module": "./fesm/index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
8
9
|
"sideEffects": false,
|
|
9
10
|
"keywords": [
|
|
10
11
|
"nestjs",
|
|
12
|
+
"@flusys",
|
|
11
13
|
"iam",
|
|
12
14
|
"rbac",
|
|
13
15
|
"permissions",
|
|
14
16
|
"roles",
|
|
15
|
-
"access-control"
|
|
16
|
-
"@flusys"
|
|
17
|
+
"access-control"
|
|
17
18
|
],
|
|
18
19
|
"license": "UNLICENSED",
|
|
19
20
|
"exports": {
|
|
20
21
|
".": {
|
|
21
22
|
"types": "./index.d.ts",
|
|
22
|
-
"import": "./fesm/index.js"
|
|
23
|
-
"require": "./cjs/index.js"
|
|
23
|
+
"import": "./fesm/index.js"
|
|
24
24
|
},
|
|
25
25
|
"./config": {
|
|
26
26
|
"types": "./config/index.d.ts",
|
|
27
|
-
"import": "./fesm/config/index.js"
|
|
28
|
-
"require": "./cjs/config/index.js"
|
|
27
|
+
"import": "./fesm/config/index.js"
|
|
29
28
|
},
|
|
30
29
|
"./controllers": {
|
|
31
30
|
"types": "./controllers/index.d.ts",
|
|
32
|
-
"import": "./fesm/controllers/index.js"
|
|
33
|
-
"require": "./cjs/controllers/index.js"
|
|
31
|
+
"import": "./fesm/controllers/index.js"
|
|
34
32
|
},
|
|
35
33
|
"./docs": {
|
|
36
34
|
"types": "./docs/index.d.ts",
|
|
37
|
-
"import": "./fesm/docs/index.js"
|
|
38
|
-
"require": "./cjs/docs/index.js"
|
|
35
|
+
"import": "./fesm/docs/index.js"
|
|
39
36
|
},
|
|
40
37
|
"./dtos": {
|
|
41
38
|
"types": "./dtos/index.d.ts",
|
|
42
|
-
"import": "./fesm/dtos/index.js"
|
|
43
|
-
"require": "./cjs/dtos/index.js"
|
|
39
|
+
"import": "./fesm/dtos/index.js"
|
|
44
40
|
},
|
|
45
41
|
"./entities": {
|
|
46
42
|
"types": "./entities/index.d.ts",
|
|
47
|
-
"import": "./fesm/entities/index.js"
|
|
48
|
-
"require": "./cjs/entities/index.js"
|
|
43
|
+
"import": "./fesm/entities/index.js"
|
|
49
44
|
},
|
|
50
45
|
"./enums": {
|
|
51
46
|
"types": "./enums/index.d.ts",
|
|
52
|
-
"import": "./fesm/enums/index.js"
|
|
53
|
-
"require": "./cjs/enums/index.js"
|
|
47
|
+
"import": "./fesm/enums/index.js"
|
|
54
48
|
},
|
|
55
49
|
"./helpers": {
|
|
56
50
|
"types": "./helpers/index.d.ts",
|
|
57
|
-
"import": "./fesm/helpers/index.js"
|
|
58
|
-
"require": "./cjs/helpers/index.js"
|
|
51
|
+
"import": "./fesm/helpers/index.js"
|
|
59
52
|
},
|
|
60
53
|
"./interfaces": {
|
|
61
54
|
"types": "./interfaces/index.d.ts",
|
|
62
|
-
"import": "./fesm/interfaces/index.js"
|
|
63
|
-
"require": "./cjs/interfaces/index.js"
|
|
55
|
+
"import": "./fesm/interfaces/index.js"
|
|
64
56
|
},
|
|
65
57
|
"./modules": {
|
|
66
58
|
"types": "./modules/index.d.ts",
|
|
67
|
-
"import": "./fesm/modules/index.js"
|
|
68
|
-
"require": "./cjs/modules/index.js"
|
|
59
|
+
"import": "./fesm/modules/index.js"
|
|
69
60
|
},
|
|
70
61
|
"./services": {
|
|
71
62
|
"types": "./services/index.d.ts",
|
|
72
|
-
"import": "./fesm/services/index.js"
|
|
73
|
-
"require": "./cjs/services/index.js"
|
|
63
|
+
"import": "./fesm/services/index.js"
|
|
74
64
|
},
|
|
75
65
|
"./types": {
|
|
76
66
|
"types": "./types/index.d.ts",
|
|
77
|
-
"import": "./fesm/types/index.js"
|
|
78
|
-
|
|
67
|
+
"import": "./fesm/types/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./*": {
|
|
70
|
+
"types": "./*.d.ts",
|
|
71
|
+
"import": "./fesm/*.js"
|
|
79
72
|
}
|
|
80
73
|
},
|
|
81
74
|
"peerDependencies": {
|
|
82
|
-
"@nestjs/common": "^
|
|
83
|
-
"@nestjs/config": "^
|
|
84
|
-
"@nestjs/core": "^
|
|
85
|
-
"@nestjs/swagger": "^
|
|
86
|
-
"@nestjs/typeorm": "^
|
|
75
|
+
"@nestjs/common": "^12.0.0",
|
|
76
|
+
"@nestjs/config": "^12.0.0",
|
|
77
|
+
"@nestjs/core": "^12.0.0",
|
|
78
|
+
"@nestjs/swagger": "^12.0.0",
|
|
79
|
+
"@nestjs/typeorm": "^12.0.0",
|
|
87
80
|
"class-transformer": "^0.5.1",
|
|
88
81
|
"class-validator": "^0.15.0",
|
|
89
82
|
"typeorm": "^0.3.0",
|
|
90
83
|
"express": "^5.0.0"
|
|
91
84
|
},
|
|
92
85
|
"dependencies": {
|
|
93
|
-
"@flusys/nestjs-core": "
|
|
94
|
-
"@flusys/nestjs-shared": "
|
|
86
|
+
"@flusys/nestjs-core": "8.0.0",
|
|
87
|
+
"@flusys/nestjs-shared": "8.0.0"
|
|
95
88
|
}
|
|
96
89
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { DeleteDto } from '@flusys/nestjs-shared/dtos';
|
|
3
|
-
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
3
|
+
import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
5
|
-
import { QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
6
|
-
import { CreateActionDto, UpdateActionDto } from '../dtos/action.dto';
|
|
7
|
-
import { Action } from '../entities/action.entity';
|
|
8
|
-
import { IAction, IActionTree } from '../interfaces/action.interface';
|
|
9
|
-
import { IAMConfigService } from './iam-config.service';
|
|
10
|
-
import { IAMDataSourceService } from './iam-datasource.service';
|
|
11
|
-
import { PermissionCacheService } from './permission-cache.service';
|
|
12
|
-
import { PermissionService } from './permission.service';
|
|
5
|
+
import { type QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
6
|
+
import { CreateActionDto, UpdateActionDto } from '../dtos/action.dto.js';
|
|
7
|
+
import { Action } from '../entities/action.entity.js';
|
|
8
|
+
import { type IAction, type IActionTree } from '../interfaces/action.interface.js';
|
|
9
|
+
import { IAMConfigService } from './iam-config.service.js';
|
|
10
|
+
import { IAMDataSourceService } from './iam-datasource.service.js';
|
|
11
|
+
import { PermissionCacheService } from './permission-cache.service.js';
|
|
12
|
+
import { PermissionService } from './permission.service.js';
|
|
13
13
|
export declare class ActionService extends ApiService<CreateActionDto, UpdateActionDto, IAction, Action> {
|
|
14
14
|
protected cacheManager: HybridCache;
|
|
15
15
|
protected utilsService: UtilsService;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DatabaseMode } from '@flusys/nestjs-core';
|
|
2
|
-
import { IModuleConfigService } from '@flusys/nestjs-shared/interfaces';
|
|
3
|
-
import { IAMPermissionMode } from '../enums/permission-type.enum';
|
|
4
|
-
import { IAMModuleOptions } from '../interfaces/iam-module-options.interface';
|
|
1
|
+
import { type DatabaseMode } from '@flusys/nestjs-core';
|
|
2
|
+
import { type IModuleConfigService } from '@flusys/nestjs-shared/interfaces';
|
|
3
|
+
import { IAMPermissionMode } from '../enums/permission-type.enum.js';
|
|
4
|
+
import { type IAMModuleOptions } from '../interfaces/iam-module-options.interface.js';
|
|
5
5
|
export declare class IAMConfigService implements IModuleConfigService {
|
|
6
6
|
private readonly options;
|
|
7
7
|
constructor(injectedOptions?: IAMModuleOptions);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MultiTenantDataSourceService } from '@flusys/nestjs-shared/modules';
|
|
2
|
-
import { IDatabaseConfig, ITenantDatabaseConfig } from '@flusys/nestjs-core';
|
|
3
|
-
import { Request } from 'express';
|
|
2
|
+
import { type IDatabaseConfig, type ITenantDatabaseConfig } from '@flusys/nestjs-core';
|
|
3
|
+
import { type Request } from 'express';
|
|
4
4
|
import { DataSource } from 'typeorm';
|
|
5
|
-
import { IAMConfigService } from './iam-config.service';
|
|
5
|
+
import { IAMConfigService } from './iam-config.service.js';
|
|
6
6
|
export declare class IAMDataSourceService extends MultiTenantDataSourceService {
|
|
7
7
|
private readonly configService;
|
|
8
8
|
protected static readonly tenantConnections: Map<string, DataSource>;
|
package/services/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './action.service';
|
|
2
|
-
export * from './iam-config.service';
|
|
3
|
-
export * from './iam-datasource.service';
|
|
4
|
-
export * from './permission-cache.service';
|
|
5
|
-
export * from './permission.service';
|
|
6
|
-
export * from './role.service';
|
|
1
|
+
export * from './action.service.js';
|
|
2
|
+
export * from './iam-config.service.js';
|
|
3
|
+
export * from './iam-datasource.service.js';
|
|
4
|
+
export * from './permission-cache.service.js';
|
|
5
|
+
export * from './permission.service.js';
|
|
6
|
+
export * from './role.service.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { HybridCache, PermissionCacheKeyOptions, PermissionGuardConfig } from '@flusys/nestjs-shared';
|
|
2
|
-
import { MyPermissionsResponseDto } from '../dtos/permission.dto';
|
|
3
|
-
import { IAMConfigService } from './iam-config.service';
|
|
4
|
-
import { IAMDataSourceService } from './iam-datasource.service';
|
|
5
|
-
export { PermissionCacheKeyOptions } from '@flusys/nestjs-shared';
|
|
1
|
+
import { HybridCache, type PermissionCacheKeyOptions, type PermissionGuardConfig } from '@flusys/nestjs-shared';
|
|
2
|
+
import { MyPermissionsResponseDto } from '../dtos/permission.dto.js';
|
|
3
|
+
import { IAMConfigService } from './iam-config.service.js';
|
|
4
|
+
import { IAMDataSourceService } from './iam-datasource.service.js';
|
|
5
|
+
export type { PermissionCacheKeyOptions } from '@flusys/nestjs-shared';
|
|
6
6
|
export interface CachedMyPermissions {
|
|
7
7
|
frontendActions: Array<{
|
|
8
8
|
id: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AssignCompanyActionsDto, AssignRoleActionsDto, AssignUserActionsDto, AssignUserRolesDto, CompanyActionResponseDto, MyPermissionsResponseDto, PermissionOperationResultDto, RoleActionResponseDto, UserActionResponseDto, UserRoleResponseDto } from '../dtos/permission.dto';
|
|
2
|
-
import { IAMConfigService } from './iam-config.service';
|
|
3
|
-
import { IAMDataSourceService } from './iam-datasource.service';
|
|
4
|
-
import { PermissionCacheService } from './permission-cache.service';
|
|
1
|
+
import { ActionUserResponseDto, AssignCompanyActionsDto, AssignRoleActionsDto, AssignUserActionsDto, AssignUserRolesDto, CompanyActionResponseDto, MyPermissionsResponseDto, PermissionOperationResultDto, RoleActionResponseDto, RoleUserResponseDto, UserActionResponseDto, UserRoleResponseDto } from '../dtos/permission.dto.js';
|
|
2
|
+
import { IAMConfigService } from './iam-config.service.js';
|
|
3
|
+
import { IAMDataSourceService } from './iam-datasource.service.js';
|
|
4
|
+
import { PermissionCacheService } from './permission-cache.service.js';
|
|
5
5
|
export declare class PermissionService {
|
|
6
6
|
private readonly permissionCacheService;
|
|
7
7
|
private readonly iamConfigService;
|
|
@@ -13,12 +13,14 @@ export declare class PermissionService {
|
|
|
13
13
|
private getActionsMap;
|
|
14
14
|
assignUserActions(dto: AssignUserActionsDto): Promise<PermissionOperationResultDto>;
|
|
15
15
|
getUserActions(userId: string, companyId: string | undefined, branchId: string | undefined): Promise<UserActionResponseDto[]>;
|
|
16
|
+
getUsersForAction(actionId: string): Promise<ActionUserResponseDto[]>;
|
|
16
17
|
assignRoleActions(dto: AssignRoleActionsDto): Promise<PermissionOperationResultDto>;
|
|
17
18
|
getRoleActions(roleId: string): Promise<RoleActionResponseDto[]>;
|
|
18
19
|
assignCompanyActions(dto: AssignCompanyActionsDto): Promise<PermissionOperationResultDto>;
|
|
19
20
|
getCompanyActions(companyId: string, isOnlyId?: boolean): Promise<CompanyActionResponseDto[] | string[]>;
|
|
20
21
|
assignUserRoles(dto: AssignUserRolesDto): Promise<PermissionOperationResultDto>;
|
|
21
22
|
getUserRoles(userId: string, branchId?: string | undefined, companyId?: string | undefined): Promise<UserRoleResponseDto[]>;
|
|
23
|
+
getUsersForRole(roleId: string): Promise<RoleUserResponseDto[]>;
|
|
22
24
|
getUserEffectiveRoles(userId: string, companyId?: string | null, branchId?: string | null): Promise<UserRoleResponseDto[]>;
|
|
23
25
|
getUserEffectiveActions(userId: string, companyId?: string | null, branchId?: string | null): Promise<UserActionResponseDto[]>;
|
|
24
26
|
getMyPermissions(userId: string, branchId: string | null, companyId?: string | null, parentCodes?: string[]): Promise<MyPermissionsResponseDto>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { DeleteDto } from '@flusys/nestjs-shared/dtos';
|
|
3
|
-
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
3
|
+
import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
5
|
-
import { QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
6
|
-
import { CreateRoleDto, UpdateRoleDto } from '../dtos/role.dto';
|
|
7
|
-
import { RoleBase } from '../entities/role-base.entity';
|
|
8
|
-
import { IRole } from '../interfaces/role.interface';
|
|
9
|
-
import { IAMConfigService } from './iam-config.service';
|
|
10
|
-
import { IAMDataSourceService } from './iam-datasource.service';
|
|
11
|
-
import { PermissionCacheService } from './permission-cache.service';
|
|
5
|
+
import { type QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
6
|
+
import { CreateRoleDto, UpdateRoleDto } from '../dtos/role.dto.js';
|
|
7
|
+
import { RoleBase } from '../entities/role-base.entity.js';
|
|
8
|
+
import { type IRole } from '../interfaces/role.interface.js';
|
|
9
|
+
import { IAMConfigService } from './iam-config.service.js';
|
|
10
|
+
import { IAMDataSourceService } from './iam-datasource.service.js';
|
|
11
|
+
import { PermissionCacheService } from './permission-cache.service.js';
|
|
12
12
|
export declare class RoleService extends ApiService<CreateRoleDto, UpdateRoleDto, IRole, RoleBase> {
|
|
13
13
|
protected cacheManager: HybridCache;
|
|
14
14
|
protected utilsService: UtilsService;
|
package/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './logic-node.type';
|
|
1
|
+
export * from './logic-node.type.js';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain event actions published by the IAM module, alongside the CRUD
|
|
3
|
-
* lifecycle actions every ApiService emits.
|
|
4
|
-
*/ "use strict";
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
function _export(target, all) {
|
|
9
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
_export(exports, {
|
|
15
|
-
get IAM_EVENT_ACTIONS () {
|
|
16
|
-
return IAM_EVENT_ACTIONS;
|
|
17
|
-
},
|
|
18
|
-
get IAM_EVENT_ENTITIES () {
|
|
19
|
-
return IAM_EVENT_ENTITIES;
|
|
20
|
-
},
|
|
21
|
-
get IAM_EVENT_MODULE () {
|
|
22
|
-
return IAM_EVENT_MODULE;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const IAM_EVENT_ACTIONS = {
|
|
26
|
-
PERMISSIONS_ASSIGNED: 'permissions-assigned'
|
|
27
|
-
};
|
|
28
|
-
const IAM_EVENT_ENTITIES = {
|
|
29
|
-
ACTION: 'action',
|
|
30
|
-
ROLE: 'role',
|
|
31
|
-
USER_ACTION: 'user_action',
|
|
32
|
-
ROLE_ACTION: 'role_action',
|
|
33
|
-
COMPANY_ACTION: 'company_action',
|
|
34
|
-
USER_ROLE: 'user_role'
|
|
35
|
-
};
|
|
36
|
-
const IAM_EVENT_MODULE = 'iam';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "IAM_MODULE_OPTIONS", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return IAM_MODULE_OPTIONS;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const IAM_MODULE_OPTIONS = 'IAM_MODULE_OPTIONS';
|
package/cjs/config/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./event-actions"), exports);
|
|
6
|
-
_export_star(require("./iam.constants"), exports);
|
|
7
|
-
_export_star(require("./message-keys"), exports);
|
|
8
|
-
function _export_star(from, to) {
|
|
9
|
-
Object.keys(from).forEach(function(k) {
|
|
10
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
11
|
-
Object.defineProperty(to, k, {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function() {
|
|
14
|
-
return from[k];
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return from;
|
|
20
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// ==================== IAM MODULE MESSAGE KEYS ====================
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
function _export(target, all) {
|
|
7
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
get ACTION_MESSAGES () {
|
|
14
|
-
return ACTION_MESSAGES;
|
|
15
|
-
},
|
|
16
|
-
get COMPANY_ACTION_PERMISSION_MESSAGES () {
|
|
17
|
-
return COMPANY_ACTION_PERMISSION_MESSAGES;
|
|
18
|
-
},
|
|
19
|
-
get IAM_MODE_MESSAGES () {
|
|
20
|
-
return IAM_MODE_MESSAGES;
|
|
21
|
-
},
|
|
22
|
-
get MY_PERMISSION_MESSAGES () {
|
|
23
|
-
return MY_PERMISSION_MESSAGES;
|
|
24
|
-
},
|
|
25
|
-
get PERMISSION_OPERATION_MESSAGES () {
|
|
26
|
-
return PERMISSION_OPERATION_MESSAGES;
|
|
27
|
-
},
|
|
28
|
-
get ROLE_MESSAGES () {
|
|
29
|
-
return ROLE_MESSAGES;
|
|
30
|
-
},
|
|
31
|
-
get ROLE_PERMISSION_MESSAGES () {
|
|
32
|
-
return ROLE_PERMISSION_MESSAGES;
|
|
33
|
-
},
|
|
34
|
-
get USER_ACTION_PERMISSION_MESSAGES () {
|
|
35
|
-
return USER_ACTION_PERMISSION_MESSAGES;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
const ACTION_MESSAGES = {
|
|
39
|
-
GET_ALL_SUCCESS: 'action.get.all.success',
|
|
40
|
-
READONLY_UPDATE_FORBIDDEN: 'action.readonly.update.forbidden',
|
|
41
|
-
READONLY_DELETE_FORBIDDEN: 'action.readonly.delete.forbidden'
|
|
42
|
-
};
|
|
43
|
-
const ROLE_MESSAGES = {
|
|
44
|
-
READONLY_UPDATE_FORBIDDEN: 'role.readonly.update.forbidden',
|
|
45
|
-
READONLY_DELETE_FORBIDDEN: 'role.readonly.delete.forbidden'
|
|
46
|
-
};
|
|
47
|
-
const PERMISSION_OPERATION_MESSAGES = {
|
|
48
|
-
PROCESS_SUCCESS: 'permission.process.success',
|
|
49
|
-
ALREADY_EXISTS: 'permission.already.exists',
|
|
50
|
-
USER_REQUIRED: 'permission.user.required'
|
|
51
|
-
};
|
|
52
|
-
const ROLE_PERMISSION_MESSAGES = {
|
|
53
|
-
ACTIONS_SUCCESS: 'role.permission.actions.success',
|
|
54
|
-
USER_ROLES_SUCCESS: 'role.permission.user.roles.success'
|
|
55
|
-
};
|
|
56
|
-
const USER_ACTION_PERMISSION_MESSAGES = {
|
|
57
|
-
GET_SUCCESS: 'user.action.permission.get.success'
|
|
58
|
-
};
|
|
59
|
-
const COMPANY_ACTION_PERMISSION_MESSAGES = {
|
|
60
|
-
GET_SUCCESS: 'company.action.permission.get.success'
|
|
61
|
-
};
|
|
62
|
-
const MY_PERMISSION_MESSAGES = {
|
|
63
|
-
GET_SUCCESS: 'my.permission.get.success',
|
|
64
|
-
MY_ROLES_SUCCESS: 'my.permission.roles.success',
|
|
65
|
-
MY_ACTIONS_SUCCESS: 'my.permission.actions.success'
|
|
66
|
-
};
|
|
67
|
-
const IAM_MODE_MESSAGES = {
|
|
68
|
-
DIRECT_MODE_UNAVAILABLE: 'iam.direct.mode.unavailable',
|
|
69
|
-
RBAC_MODE_UNAVAILABLE: 'iam.rbac.mode.unavailable',
|
|
70
|
-
ROLE_ASSIGNMENT_UNAVAILABLE: 'iam.role.assignment.unavailable'
|
|
71
|
-
};
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ActionController", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ActionController;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _nestjsshared = require("@flusys/nestjs-shared");
|
|
12
|
-
const _guards = require("@flusys/nestjs-shared/guards");
|
|
13
|
-
const _common = require("@nestjs/common");
|
|
14
|
-
const _swagger = require("@nestjs/swagger");
|
|
15
|
-
const _config = require("../config");
|
|
16
|
-
const _actiondto = require("../dtos/action.dto");
|
|
17
|
-
const _actionservice = require("../services/action.service");
|
|
18
|
-
const _iamconfigservice = require("../services/iam-config.service");
|
|
19
|
-
function _define_property(obj, key, value) {
|
|
20
|
-
if (key in obj) {
|
|
21
|
-
Object.defineProperty(obj, key, {
|
|
22
|
-
value: value,
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
obj[key] = value;
|
|
29
|
-
}
|
|
30
|
-
return obj;
|
|
31
|
-
}
|
|
32
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
33
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
37
|
-
}
|
|
38
|
-
function _ts_metadata(k, v) {
|
|
39
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
40
|
-
}
|
|
41
|
-
function _ts_param(paramIndex, decorator) {
|
|
42
|
-
return function(target, key) {
|
|
43
|
-
decorator(target, key, paramIndex);
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
let ActionController = class ActionController extends (0, _nestjsshared.createApiController)(_actiondto.CreateActionDto, _actiondto.UpdateActionDto, _actiondto.ActionResponseDto, {
|
|
47
|
-
entityName: 'action',
|
|
48
|
-
security: {
|
|
49
|
-
insert: {
|
|
50
|
-
level: 'permission',
|
|
51
|
-
permissions: [
|
|
52
|
-
_nestjsshared.ACTION_PERMISSIONS.CREATE
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
insertMany: {
|
|
56
|
-
level: 'permission',
|
|
57
|
-
permissions: [
|
|
58
|
-
_nestjsshared.ACTION_PERMISSIONS.CREATE
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
|
-
getById: {
|
|
62
|
-
level: 'permission',
|
|
63
|
-
permissions: [
|
|
64
|
-
_nestjsshared.ACTION_PERMISSIONS.READ
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
getAll: {
|
|
68
|
-
level: 'permission',
|
|
69
|
-
permissions: [
|
|
70
|
-
_nestjsshared.ACTION_PERMISSIONS.READ
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
update: {
|
|
74
|
-
level: 'permission',
|
|
75
|
-
permissions: [
|
|
76
|
-
_nestjsshared.ACTION_PERMISSIONS.UPDATE
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
updateMany: {
|
|
80
|
-
level: 'permission',
|
|
81
|
-
permissions: [
|
|
82
|
-
_nestjsshared.ACTION_PERMISSIONS.UPDATE
|
|
83
|
-
]
|
|
84
|
-
},
|
|
85
|
-
delete: {
|
|
86
|
-
level: 'permission',
|
|
87
|
-
permissions: [
|
|
88
|
-
_nestjsshared.ACTION_PERMISSIONS.DELETE
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}) {
|
|
93
|
-
async getActionsForPermission(dto, user) {
|
|
94
|
-
const actions = await this.actionService.getActionsForPermission(user, dto?.companyId);
|
|
95
|
-
return {
|
|
96
|
-
success: true,
|
|
97
|
-
message: 'Actions retrieved successfully',
|
|
98
|
-
messageKey: _config.ACTION_MESSAGES.GET_ALL_SUCCESS,
|
|
99
|
-
data: actions
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
async getActionTree(query, user) {
|
|
103
|
-
const tree = await this.actionService.getActionTree(user, query.search, query.isActive, query.withDeleted);
|
|
104
|
-
return {
|
|
105
|
-
success: true,
|
|
106
|
-
message: 'Action tree retrieved successfully',
|
|
107
|
-
messageKey: _config.ACTION_MESSAGES.GET_ALL_SUCCESS,
|
|
108
|
-
data: tree
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
constructor(actionService, iamConfigService){
|
|
112
|
-
super(actionService), _define_property(this, "actionService", void 0), _define_property(this, "iamConfigService", void 0), this.actionService = actionService, this.iamConfigService = iamConfigService;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
_ts_decorate([
|
|
116
|
-
(0, _common.Post)('tree-for-permission'),
|
|
117
|
-
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
118
|
-
(0, _swagger.ApiBearerAuth)(),
|
|
119
|
-
(0, _swagger.ApiOperation)({
|
|
120
|
-
summary: 'Get actions for permission assignment',
|
|
121
|
-
description: "Returns actions available for permission assignment, filtered by company whitelist when company feature is enabled. Optional companyId scopes the whitelist to a specific company (must match the caller's own company); defaults to the caller's session company when omitted."
|
|
122
|
-
}),
|
|
123
|
-
(0, _swagger.ApiResponse)({
|
|
124
|
-
status: 200,
|
|
125
|
-
type: _nestjsshared.SingleResponseDto
|
|
126
|
-
}),
|
|
127
|
-
(0, _swagger.ApiBody)({
|
|
128
|
-
type: _actiondto.ActionTreeForPermissionDto
|
|
129
|
-
}),
|
|
130
|
-
_ts_param(0, (0, _common.Body)()),
|
|
131
|
-
_ts_param(1, (0, _nestjsshared.CurrentUser)()),
|
|
132
|
-
_ts_metadata("design:type", Function),
|
|
133
|
-
_ts_metadata("design:paramtypes", [
|
|
134
|
-
typeof _actiondto.ActionTreeForPermissionDto === "undefined" ? Object : _actiondto.ActionTreeForPermissionDto,
|
|
135
|
-
typeof _nestjsshared.ILoggedUserInfo === "undefined" ? Object : _nestjsshared.ILoggedUserInfo
|
|
136
|
-
]),
|
|
137
|
-
_ts_metadata("design:returntype", Promise)
|
|
138
|
-
], ActionController.prototype, "getActionsForPermission", null);
|
|
139
|
-
_ts_decorate([
|
|
140
|
-
(0, _common.Post)('tree'),
|
|
141
|
-
(0, _common.UseGuards)(_guards.JwtAuthGuard),
|
|
142
|
-
(0, _swagger.ApiBearerAuth)(),
|
|
143
|
-
(0, _swagger.ApiOperation)({
|
|
144
|
-
summary: 'Get actions in hierarchical tree structure',
|
|
145
|
-
description: 'Returns all actions organized in a parent-child tree structure. Supports optional search and filtering.'
|
|
146
|
-
}),
|
|
147
|
-
(0, _swagger.ApiResponse)({
|
|
148
|
-
status: 200,
|
|
149
|
-
description: 'Actions tree retrieved successfully',
|
|
150
|
-
type: _nestjsshared.SingleResponseDto
|
|
151
|
-
}),
|
|
152
|
-
(0, _swagger.ApiBody)({
|
|
153
|
-
type: _actiondto.ActionTreeQueryDto
|
|
154
|
-
}),
|
|
155
|
-
_ts_param(0, (0, _common.Body)()),
|
|
156
|
-
_ts_param(1, (0, _nestjsshared.CurrentUser)()),
|
|
157
|
-
_ts_metadata("design:type", Function),
|
|
158
|
-
_ts_metadata("design:paramtypes", [
|
|
159
|
-
typeof _actiondto.ActionTreeQueryDto === "undefined" ? Object : _actiondto.ActionTreeQueryDto,
|
|
160
|
-
typeof _nestjsshared.ILoggedUserInfo === "undefined" ? Object : _nestjsshared.ILoggedUserInfo
|
|
161
|
-
]),
|
|
162
|
-
_ts_metadata("design:returntype", Promise)
|
|
163
|
-
], ActionController.prototype, "getActionTree", null);
|
|
164
|
-
ActionController = _ts_decorate([
|
|
165
|
-
(0, _swagger.ApiTags)('IAM - Actions'),
|
|
166
|
-
(0, _common.Controller)('iam/actions'),
|
|
167
|
-
_ts_param(0, (0, _common.Inject)(_actionservice.ActionService)),
|
|
168
|
-
_ts_param(1, (0, _common.Inject)(_iamconfigservice.IAMConfigService)),
|
|
169
|
-
_ts_metadata("design:type", Function),
|
|
170
|
-
_ts_metadata("design:paramtypes", [
|
|
171
|
-
typeof _actionservice.ActionService === "undefined" ? Object : _actionservice.ActionService,
|
|
172
|
-
typeof _iamconfigservice.IAMConfigService === "undefined" ? Object : _iamconfigservice.IAMConfigService
|
|
173
|
-
])
|
|
174
|
-
], ActionController);
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
const _loggedusermock = require("@test-utils/mocks/logged-user.mock");
|
|
6
|
-
const _actioncontroller = require("./action.controller");
|
|
7
|
-
describe('ActionController', ()=>{
|
|
8
|
-
let controller;
|
|
9
|
-
let mockActionService;
|
|
10
|
-
let mockIamConfigService;
|
|
11
|
-
beforeEach(()=>{
|
|
12
|
-
mockActionService = {
|
|
13
|
-
insert: jest.fn(),
|
|
14
|
-
findById: jest.fn(),
|
|
15
|
-
getAll: jest.fn(),
|
|
16
|
-
update: jest.fn(),
|
|
17
|
-
delete: jest.fn(),
|
|
18
|
-
getActionsForPermission: jest.fn(),
|
|
19
|
-
getActionTree: jest.fn()
|
|
20
|
-
};
|
|
21
|
-
mockIamConfigService = {};
|
|
22
|
-
controller = new _actioncontroller.ActionController(mockActionService, mockIamConfigService);
|
|
23
|
-
});
|
|
24
|
-
it('wires the injected service onto the generated controller base', ()=>{
|
|
25
|
-
expect(controller.actionService).toBe(mockActionService);
|
|
26
|
-
expect(controller.service).toBe(mockActionService);
|
|
27
|
-
});
|
|
28
|
-
describe('getActionsForPermission', ()=>{
|
|
29
|
-
it('returns actions scoped to the caller session company when no companyId is given', async ()=>{
|
|
30
|
-
const user = (0, _loggedusermock.buildMockUser)();
|
|
31
|
-
mockActionService.getActionsForPermission.mockResolvedValue([
|
|
32
|
-
{
|
|
33
|
-
id: 'action-1',
|
|
34
|
-
code: 'user.create'
|
|
35
|
-
}
|
|
36
|
-
]);
|
|
37
|
-
const result = await controller.getActionsForPermission({}, user);
|
|
38
|
-
expect(mockActionService.getActionsForPermission).toHaveBeenCalledWith(user, undefined);
|
|
39
|
-
expect(result.success).toBe(true);
|
|
40
|
-
expect(result.data).toEqual([
|
|
41
|
-
{
|
|
42
|
-
id: 'action-1',
|
|
43
|
-
code: 'user.create'
|
|
44
|
-
}
|
|
45
|
-
]);
|
|
46
|
-
});
|
|
47
|
-
it('forwards an explicit companyId override', async ()=>{
|
|
48
|
-
const user = (0, _loggedusermock.buildMockUser)();
|
|
49
|
-
mockActionService.getActionsForPermission.mockResolvedValue([]);
|
|
50
|
-
await controller.getActionsForPermission({
|
|
51
|
-
companyId: 'company-2'
|
|
52
|
-
}, user);
|
|
53
|
-
expect(mockActionService.getActionsForPermission).toHaveBeenCalledWith(user, 'company-2');
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('getActionTree', ()=>{
|
|
57
|
-
it('returns the hierarchical action tree with query filters applied', async ()=>{
|
|
58
|
-
const user = (0, _loggedusermock.buildMockUser)();
|
|
59
|
-
mockActionService.getActionTree.mockResolvedValue([
|
|
60
|
-
{
|
|
61
|
-
id: 'action-1',
|
|
62
|
-
children: []
|
|
63
|
-
}
|
|
64
|
-
]);
|
|
65
|
-
const result = await controller.getActionTree({
|
|
66
|
-
search: 'user',
|
|
67
|
-
isActive: true,
|
|
68
|
-
withDeleted: false
|
|
69
|
-
}, user);
|
|
70
|
-
expect(mockActionService.getActionTree).toHaveBeenCalledWith(user, 'user', true, false);
|
|
71
|
-
expect(result.data).toEqual([
|
|
72
|
-
{
|
|
73
|
-
id: 'action-1',
|
|
74
|
-
children: []
|
|
75
|
-
}
|
|
76
|
-
]);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|