@flusys/nestjs-iam 4.1.1 → 5.0.1

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.
Files changed (45) hide show
  1. package/README.md +87 -369
  2. package/cjs/config/message-keys.js +7 -49
  3. package/cjs/controllers/company-action-permission.controller.js +19 -18
  4. package/cjs/controllers/my-permission.controller.js +1 -4
  5. package/cjs/controllers/role-permission.controller.js +30 -20
  6. package/cjs/controllers/user-action-permission.controller.js +16 -11
  7. package/cjs/docs/iam-swagger.config.js +3 -2
  8. package/cjs/dtos/action.dto.js +0 -16
  9. package/cjs/dtos/permission.dto.js +4 -19
  10. package/cjs/dtos/role.dto.js +0 -16
  11. package/cjs/entities/action-base.entity.js +3 -8
  12. package/cjs/entities/permission-base.entity.js +1 -7
  13. package/cjs/entities/role-base.entity.js +1 -7
  14. package/cjs/services/action.service.js +1 -2
  15. package/cjs/services/permission.service.js +7 -14
  16. package/cjs/services/role.service.js +0 -1
  17. package/config/message-keys.d.ts +4 -84
  18. package/controllers/company-action-permission.controller.d.ts +3 -3
  19. package/controllers/role-permission.controller.d.ts +4 -4
  20. package/controllers/user-action-permission.controller.d.ts +3 -3
  21. package/docs/iam-swagger.config.d.ts +1 -1
  22. package/dtos/action.dto.d.ts +0 -2
  23. package/dtos/permission.dto.d.ts +1 -3
  24. package/dtos/role.dto.d.ts +0 -2
  25. package/entities/action-base.entity.d.ts +0 -1
  26. package/entities/permission-base.entity.d.ts +0 -1
  27. package/entities/role-base.entity.d.ts +0 -1
  28. package/fesm/config/message-keys.js +7 -44
  29. package/fesm/controllers/company-action-permission.controller.js +22 -21
  30. package/fesm/controllers/my-permission.controller.js +2 -5
  31. package/fesm/controllers/role-permission.controller.js +33 -23
  32. package/fesm/controllers/user-action-permission.controller.js +19 -14
  33. package/fesm/docs/iam-swagger.config.js +3 -2
  34. package/fesm/dtos/action.dto.js +0 -16
  35. package/fesm/dtos/permission.dto.js +4 -19
  36. package/fesm/dtos/role.dto.js +0 -16
  37. package/fesm/entities/action-base.entity.js +4 -9
  38. package/fesm/entities/permission-base.entity.js +1 -7
  39. package/fesm/entities/role-base.entity.js +1 -7
  40. package/fesm/services/action.service.js +1 -2
  41. package/fesm/services/permission.service.js +7 -14
  42. package/fesm/services/role.service.js +0 -1
  43. package/interfaces/action.interface.d.ts +0 -1
  44. package/interfaces/role.interface.d.ts +0 -1
  45. package/package.json +3 -3
@@ -1,41 +1,20 @@
1
1
  export declare const ACTION_MESSAGES: {
2
- readonly CREATE_SUCCESS: "action.create.success";
3
- readonly CREATE_MANY_SUCCESS: "action.create.many.success";
4
- readonly GET_SUCCESS: "action.get.success";
5
2
  readonly GET_ALL_SUCCESS: "action.get.all.success";
6
- readonly UPDATE_SUCCESS: "action.update.success";
7
- readonly UPDATE_MANY_SUCCESS: "action.update.many.success";
8
- readonly DELETE_SUCCESS: "action.delete.success";
9
- readonly RESTORE_SUCCESS: "action.restore.success";
10
- readonly NOT_FOUND: "action.not.found";
11
3
  };
12
- export declare const ROLE_MESSAGES: {
13
- readonly CREATE_SUCCESS: "role.create.success";
14
- readonly CREATE_MANY_SUCCESS: "role.create.many.success";
15
- readonly GET_SUCCESS: "role.get.success";
16
- readonly GET_ALL_SUCCESS: "role.get.all.success";
17
- readonly UPDATE_SUCCESS: "role.update.success";
18
- readonly UPDATE_MANY_SUCCESS: "role.update.many.success";
19
- readonly DELETE_SUCCESS: "role.delete.success";
20
- readonly RESTORE_SUCCESS: "role.restore.success";
21
- readonly NOT_FOUND: "role.not.found";
4
+ export declare const PERMISSION_OPERATION_MESSAGES: {
5
+ readonly PROCESS_SUCCESS: "permission.process.success";
6
+ readonly ALREADY_EXISTS: "permission.already.exists";
7
+ readonly USER_REQUIRED: "permission.user.required";
22
8
  };
23
9
  export declare const ROLE_PERMISSION_MESSAGES: {
24
- readonly GET_SUCCESS: "role.permission.get.success";
25
- readonly ASSIGN_SUCCESS: "role.permission.assign.success";
26
10
  readonly ACTIONS_SUCCESS: "role.permission.actions.success";
27
- readonly USERS_SUCCESS: "role.permission.users.success";
28
11
  readonly USER_ROLES_SUCCESS: "role.permission.user.roles.success";
29
12
  };
30
13
  export declare const USER_ACTION_PERMISSION_MESSAGES: {
31
14
  readonly GET_SUCCESS: "user.action.permission.get.success";
32
- readonly ASSIGN_SUCCESS: "user.action.permission.assign.success";
33
- readonly REVOKE_SUCCESS: "user.action.permission.revoke.success";
34
15
  };
35
16
  export declare const COMPANY_ACTION_PERMISSION_MESSAGES: {
36
17
  readonly GET_SUCCESS: "company.action.permission.get.success";
37
- readonly ASSIGN_SUCCESS: "company.action.permission.assign.success";
38
- readonly REVOKE_SUCCESS: "company.action.permission.revoke.success";
39
18
  };
40
19
  export declare const MY_PERMISSION_MESSAGES: {
41
20
  readonly GET_SUCCESS: "my.permission.get.success";
@@ -45,62 +24,3 @@ export declare const IAM_MODE_MESSAGES: {
45
24
  readonly RBAC_MODE_UNAVAILABLE: "iam.rbac.mode.unavailable";
46
25
  readonly ROLE_ASSIGNMENT_UNAVAILABLE: "iam.role.assignment.unavailable";
47
26
  };
48
- export declare const PERMISSION_OPERATION_MESSAGES: {
49
- readonly PROCESS_SUCCESS: "permission.process.success";
50
- readonly ALREADY_EXISTS: "permission.already.exists";
51
- readonly USER_REQUIRED: "permission.user.required";
52
- };
53
- export declare const IAM_MODULE_MESSAGES: {
54
- readonly ACTION: {
55
- readonly CREATE_SUCCESS: "action.create.success";
56
- readonly CREATE_MANY_SUCCESS: "action.create.many.success";
57
- readonly GET_SUCCESS: "action.get.success";
58
- readonly GET_ALL_SUCCESS: "action.get.all.success";
59
- readonly UPDATE_SUCCESS: "action.update.success";
60
- readonly UPDATE_MANY_SUCCESS: "action.update.many.success";
61
- readonly DELETE_SUCCESS: "action.delete.success";
62
- readonly RESTORE_SUCCESS: "action.restore.success";
63
- readonly NOT_FOUND: "action.not.found";
64
- };
65
- readonly ROLE: {
66
- readonly CREATE_SUCCESS: "role.create.success";
67
- readonly CREATE_MANY_SUCCESS: "role.create.many.success";
68
- readonly GET_SUCCESS: "role.get.success";
69
- readonly GET_ALL_SUCCESS: "role.get.all.success";
70
- readonly UPDATE_SUCCESS: "role.update.success";
71
- readonly UPDATE_MANY_SUCCESS: "role.update.many.success";
72
- readonly DELETE_SUCCESS: "role.delete.success";
73
- readonly RESTORE_SUCCESS: "role.restore.success";
74
- readonly NOT_FOUND: "role.not.found";
75
- };
76
- readonly ROLE_PERMISSION: {
77
- readonly GET_SUCCESS: "role.permission.get.success";
78
- readonly ASSIGN_SUCCESS: "role.permission.assign.success";
79
- readonly ACTIONS_SUCCESS: "role.permission.actions.success";
80
- readonly USERS_SUCCESS: "role.permission.users.success";
81
- readonly USER_ROLES_SUCCESS: "role.permission.user.roles.success";
82
- };
83
- readonly USER_ACTION_PERMISSION: {
84
- readonly GET_SUCCESS: "user.action.permission.get.success";
85
- readonly ASSIGN_SUCCESS: "user.action.permission.assign.success";
86
- readonly REVOKE_SUCCESS: "user.action.permission.revoke.success";
87
- };
88
- readonly COMPANY_ACTION_PERMISSION: {
89
- readonly GET_SUCCESS: "company.action.permission.get.success";
90
- readonly ASSIGN_SUCCESS: "company.action.permission.assign.success";
91
- readonly REVOKE_SUCCESS: "company.action.permission.revoke.success";
92
- };
93
- readonly MY_PERMISSION: {
94
- readonly GET_SUCCESS: "my.permission.get.success";
95
- };
96
- readonly IAM_MODE: {
97
- readonly DIRECT_MODE_UNAVAILABLE: "iam.direct.mode.unavailable";
98
- readonly RBAC_MODE_UNAVAILABLE: "iam.rbac.mode.unavailable";
99
- readonly ROLE_ASSIGNMENT_UNAVAILABLE: "iam.role.assignment.unavailable";
100
- };
101
- readonly PERMISSION_OPERATION: {
102
- readonly PROCESS_SUCCESS: "permission.process.success";
103
- readonly ALREADY_EXISTS: "permission.already.exists";
104
- readonly USER_REQUIRED: "permission.user.required";
105
- };
106
- };
@@ -1,9 +1,9 @@
1
- import { ILoggedUserInfo, SingleResponseDto } from '@flusys/nestjs-shared';
1
+ import { SingleResponseDto } from '@flusys/nestjs-shared';
2
2
  import { AssignCompanyActionsDto, CompanyActionResponseDto, GetCompanyActionsDto, PermissionOperationResultDto } from '../dtos/permission.dto';
3
3
  import { PermissionService } from '../services/permission.service';
4
4
  export declare class CompanyActionPermissionController {
5
5
  private readonly permissionService;
6
6
  constructor(permissionService: PermissionService);
7
- assignCompanyActions(dto: AssignCompanyActionsDto, user: ILoggedUserInfo): Promise<PermissionOperationResultDto>;
8
- getCompanyActions(dto: GetCompanyActionsDto, user: ILoggedUserInfo): Promise<SingleResponseDto<CompanyActionResponseDto[]>>;
7
+ assignCompanyActions(dto: AssignCompanyActionsDto): Promise<SingleResponseDto<PermissionOperationResultDto>>;
8
+ getCompanyActions(dto: GetCompanyActionsDto): Promise<SingleResponseDto<CompanyActionResponseDto[]>>;
9
9
  }
@@ -1,13 +1,13 @@
1
- import { SingleResponseDto, ILoggedUserInfo } from '@flusys/nestjs-shared';
1
+ import { ILoggedUserInfo, SingleResponseDto } from '@flusys/nestjs-shared';
2
2
  import { AssignRoleActionsDto, AssignUserRolesDto, GetRoleActionsDto, GetUserRolesDto, PermissionOperationResultDto, RoleActionResponseDto, UserRoleResponseDto } from '../dtos/permission.dto';
3
- import { PermissionService } from '../services/permission.service';
4
3
  import { IAMConfigService } from '../services/iam-config.service';
4
+ import { PermissionService } from '../services/permission.service';
5
5
  export declare class RolePermissionController {
6
6
  private readonly permissionService;
7
7
  private readonly config;
8
8
  constructor(permissionService: PermissionService, config: IAMConfigService);
9
- assignRoleActions(dto: AssignRoleActionsDto): Promise<PermissionOperationResultDto>;
9
+ assignRoleActions(dto: AssignRoleActionsDto): Promise<SingleResponseDto<PermissionOperationResultDto>>;
10
10
  getRoleActions(dto: GetRoleActionsDto): Promise<SingleResponseDto<RoleActionResponseDto[]>>;
11
- assignUserRoles(dto: AssignUserRolesDto, user: ILoggedUserInfo): Promise<PermissionOperationResultDto>;
11
+ assignUserRoles(dto: AssignUserRolesDto, user: ILoggedUserInfo): Promise<SingleResponseDto<PermissionOperationResultDto>>;
12
12
  getUserRoles(dto: GetUserRolesDto, user: ILoggedUserInfo): Promise<SingleResponseDto<UserRoleResponseDto[]>>;
13
13
  }
@@ -1,11 +1,11 @@
1
- import { SingleResponseDto, ILoggedUserInfo } from '@flusys/nestjs-shared';
1
+ import { ILoggedUserInfo, SingleResponseDto } from '@flusys/nestjs-shared';
2
2
  import { AssignUserActionsDto, GetUserActionsDto, PermissionOperationResultDto, UserActionResponseDto } from '../dtos/permission.dto';
3
- import { PermissionService } from '../services/permission.service';
4
3
  import { IAMConfigService } from '../services/iam-config.service';
4
+ import { PermissionService } from '../services/permission.service';
5
5
  export declare class UserActionPermissionController {
6
6
  private readonly permissionService;
7
7
  private readonly config;
8
8
  constructor(permissionService: PermissionService, config: IAMConfigService);
9
- assignUserActions(dto: AssignUserActionsDto, user: ILoggedUserInfo): Promise<PermissionOperationResultDto>;
9
+ assignUserActions(dto: AssignUserActionsDto, user: ILoggedUserInfo): Promise<SingleResponseDto<PermissionOperationResultDto>>;
10
10
  getUserActions(dto: GetUserActionsDto, user: ILoggedUserInfo): Promise<SingleResponseDto<UserActionResponseDto[]>>;
11
11
  }
@@ -1,3 +1,3 @@
1
1
  import { IModuleSwaggerOptions } from '@flusys/nestjs-core/docs';
2
2
  import { IAMPermissionMode } from '../enums/permission-type.enum';
3
- export declare function iamSwaggerConfig(enableCompanyFeature?: boolean, permissionMode?: IAMPermissionMode): IModuleSwaggerOptions;
3
+ export declare function iamSwaggerConfig(enableCompanyFeature?: boolean, permissionMode?: IAMPermissionMode, databaseMode?: 'single' | 'multi-tenant'): IModuleSwaggerOptions;
@@ -9,7 +9,6 @@ export declare class CreateActionDto {
9
9
  parentId?: string;
10
10
  serial?: number;
11
11
  isActive?: boolean;
12
- metadata?: Record<string, any>;
13
12
  }
14
13
  declare const UpdateActionDto_base: import("@nestjs/common").Type<Partial<CreateActionDto>>;
15
14
  export declare class UpdateActionDto extends UpdateActionDto_base {
@@ -26,7 +25,6 @@ export declare class ActionResponseDto {
26
25
  parentId: string | null;
27
26
  serial: number | null;
28
27
  isActive: boolean;
29
- metadata: Record<string, any> | null;
30
28
  createdAt: Date;
31
29
  updatedAt: Date;
32
30
  deletedAt: Date | null;
@@ -89,9 +89,7 @@ export declare class MyPermissionsResponseDto {
89
89
  cachedEndpoints: number;
90
90
  }
91
91
  export declare class PermissionOperationResultDto {
92
- success: boolean;
93
92
  added: number;
94
93
  removed: number;
95
- message: string;
96
- messageKey?: string;
94
+ total: number;
97
95
  }
@@ -4,7 +4,6 @@ export declare class CreateRoleDto {
4
4
  companyId?: string;
5
5
  isActive?: boolean;
6
6
  serial?: number;
7
- metadata?: Record<string, any>;
8
7
  }
9
8
  declare const UpdateRoleDto_base: import("@nestjs/common").Type<Partial<CreateRoleDto>>;
10
9
  export declare class UpdateRoleDto extends UpdateRoleDto_base {
@@ -18,7 +17,6 @@ export declare class RoleResponseDto {
18
17
  companyId: string | null;
19
18
  isActive: boolean;
20
19
  serial: number | null;
21
- metadata: Record<string, any> | null;
22
20
  createdAt: Date;
23
21
  updatedAt: Date;
24
22
  deletedAt: Date | null;
@@ -13,5 +13,4 @@ export declare abstract class ActionBase extends Identity {
13
13
  parent: ActionBase | null;
14
14
  parentId: string | null;
15
15
  children: ActionBase[];
16
- metadata: Record<string, any> | null;
17
16
  }
@@ -21,6 +21,5 @@ export declare abstract class PermissionBase extends Identity {
21
21
  validFrom: Date | null;
22
22
  validUntil: Date | null;
23
23
  reason: string | null;
24
- metadata: Record<string, any> | null;
25
24
  isValid(now?: Date): boolean;
26
25
  }
@@ -5,5 +5,4 @@ export declare abstract class RoleBase extends Identity {
5
5
  description: string | null;
6
6
  isActive: boolean;
7
7
  serial: number | null;
8
- metadata: Record<string, any> | null;
9
8
  }
@@ -1,42 +1,21 @@
1
1
  // ==================== IAM MODULE MESSAGE KEYS ====================
2
2
  export const ACTION_MESSAGES = {
3
- CREATE_SUCCESS: 'action.create.success',
4
- CREATE_MANY_SUCCESS: 'action.create.many.success',
5
- GET_SUCCESS: 'action.get.success',
6
- GET_ALL_SUCCESS: 'action.get.all.success',
7
- UPDATE_SUCCESS: 'action.update.success',
8
- UPDATE_MANY_SUCCESS: 'action.update.many.success',
9
- DELETE_SUCCESS: 'action.delete.success',
10
- RESTORE_SUCCESS: 'action.restore.success',
11
- NOT_FOUND: 'action.not.found'
3
+ GET_ALL_SUCCESS: 'action.get.all.success'
12
4
  };
13
- export const ROLE_MESSAGES = {
14
- CREATE_SUCCESS: 'role.create.success',
15
- CREATE_MANY_SUCCESS: 'role.create.many.success',
16
- GET_SUCCESS: 'role.get.success',
17
- GET_ALL_SUCCESS: 'role.get.all.success',
18
- UPDATE_SUCCESS: 'role.update.success',
19
- UPDATE_MANY_SUCCESS: 'role.update.many.success',
20
- DELETE_SUCCESS: 'role.delete.success',
21
- RESTORE_SUCCESS: 'role.restore.success',
22
- NOT_FOUND: 'role.not.found'
5
+ export const PERMISSION_OPERATION_MESSAGES = {
6
+ PROCESS_SUCCESS: 'permission.process.success',
7
+ ALREADY_EXISTS: 'permission.already.exists',
8
+ USER_REQUIRED: 'permission.user.required'
23
9
  };
24
10
  export const ROLE_PERMISSION_MESSAGES = {
25
- GET_SUCCESS: 'role.permission.get.success',
26
- ASSIGN_SUCCESS: 'role.permission.assign.success',
27
11
  ACTIONS_SUCCESS: 'role.permission.actions.success',
28
- USERS_SUCCESS: 'role.permission.users.success',
29
12
  USER_ROLES_SUCCESS: 'role.permission.user.roles.success'
30
13
  };
31
14
  export const USER_ACTION_PERMISSION_MESSAGES = {
32
- GET_SUCCESS: 'user.action.permission.get.success',
33
- ASSIGN_SUCCESS: 'user.action.permission.assign.success',
34
- REVOKE_SUCCESS: 'user.action.permission.revoke.success'
15
+ GET_SUCCESS: 'user.action.permission.get.success'
35
16
  };
36
17
  export const COMPANY_ACTION_PERMISSION_MESSAGES = {
37
- GET_SUCCESS: 'company.action.permission.get.success',
38
- ASSIGN_SUCCESS: 'company.action.permission.assign.success',
39
- REVOKE_SUCCESS: 'company.action.permission.revoke.success'
18
+ GET_SUCCESS: 'company.action.permission.get.success'
40
19
  };
41
20
  export const MY_PERMISSION_MESSAGES = {
42
21
  GET_SUCCESS: 'my.permission.get.success'
@@ -46,19 +25,3 @@ export const IAM_MODE_MESSAGES = {
46
25
  RBAC_MODE_UNAVAILABLE: 'iam.rbac.mode.unavailable',
47
26
  ROLE_ASSIGNMENT_UNAVAILABLE: 'iam.role.assignment.unavailable'
48
27
  };
49
- export const PERMISSION_OPERATION_MESSAGES = {
50
- PROCESS_SUCCESS: 'permission.process.success',
51
- ALREADY_EXISTS: 'permission.already.exists',
52
- USER_REQUIRED: 'permission.user.required'
53
- };
54
- // Aggregated export for backward compatibility
55
- export const IAM_MODULE_MESSAGES = {
56
- ACTION: ACTION_MESSAGES,
57
- ROLE: ROLE_MESSAGES,
58
- ROLE_PERMISSION: ROLE_PERMISSION_MESSAGES,
59
- USER_ACTION_PERMISSION: USER_ACTION_PERMISSION_MESSAGES,
60
- COMPANY_ACTION_PERMISSION: COMPANY_ACTION_PERMISSION_MESSAGES,
61
- MY_PERMISSION: MY_PERMISSION_MESSAGES,
62
- IAM_MODE: IAM_MODE_MESSAGES,
63
- PERMISSION_OPERATION: PERMISSION_OPERATION_MESSAGES
64
- };
@@ -25,17 +25,28 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
- import { COMPANY_ACTION_PERMISSIONS, CurrentUser, ILoggedUserInfo, JwtAuthGuard, RequirePermission, SingleResponseDto } from '@flusys/nestjs-shared';
29
- import { COMPANY_ACTION_PERMISSION_MESSAGES } from '../config';
28
+ import { ApiResponseDto, COMPANY_ACTION_PERMISSIONS, JwtAuthGuard, RequirePermission } from '@flusys/nestjs-shared';
30
29
  import { Body, Controller, Inject, Post, UseGuards } from '@nestjs/common';
31
- import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
32
- import { AssignCompanyActionsDto, GetCompanyActionsDto, PermissionOperationResultDto } from '../dtos/permission.dto';
30
+ import { ApiBearerAuth, ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
31
+ import { COMPANY_ACTION_PERMISSION_MESSAGES, PERMISSION_OPERATION_MESSAGES } from '../config';
32
+ import { AssignCompanyActionsDto, CompanyActionResponseDto, GetCompanyActionsDto, PermissionOperationResultDto } from '../dtos/permission.dto';
33
33
  import { PermissionService } from '../services/permission.service';
34
34
  export class CompanyActionPermissionController {
35
- async assignCompanyActions(dto, user) {
36
- return this.permissionService.assignCompanyActions(dto);
35
+ async assignCompanyActions(dto) {
36
+ const result = await this.permissionService.assignCompanyActions(dto);
37
+ return {
38
+ success: true,
39
+ message: 'Company actions updated successfully',
40
+ messageKey: PERMISSION_OPERATION_MESSAGES.PROCESS_SUCCESS,
41
+ messageVariables: {
42
+ added: result.added,
43
+ removed: result.removed,
44
+ total: result.total
45
+ },
46
+ data: result
47
+ };
37
48
  }
38
- async getCompanyActions(dto, user) {
49
+ async getCompanyActions(dto) {
39
50
  const actions = await this.permissionService.getCompanyActions(dto.companyId);
40
51
  return {
41
52
  success: true,
@@ -56,19 +67,14 @@ _ts_decorate([
56
67
  summary: 'Whitelist actions for company',
57
68
  description: 'Controls which actions are available to company users/roles.'
58
69
  }),
59
- ApiResponse({
60
- status: 200,
61
- type: PermissionOperationResultDto
62
- }),
70
+ ApiResponseDto(PermissionOperationResultDto),
63
71
  ApiBody({
64
72
  type: AssignCompanyActionsDto
65
73
  }),
66
74
  _ts_param(0, Body()),
67
- _ts_param(1, CurrentUser()),
68
75
  _ts_metadata("design:type", Function),
69
76
  _ts_metadata("design:paramtypes", [
70
- typeof AssignCompanyActionsDto === "undefined" ? Object : AssignCompanyActionsDto,
71
- typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
77
+ typeof AssignCompanyActionsDto === "undefined" ? Object : AssignCompanyActionsDto
72
78
  ]),
73
79
  _ts_metadata("design:returntype", Promise)
74
80
  ], CompanyActionPermissionController.prototype, "assignCompanyActions", null);
@@ -79,19 +85,14 @@ _ts_decorate([
79
85
  summary: 'Get company whitelisted actions',
80
86
  description: 'Returns actions available to company.'
81
87
  }),
82
- ApiResponse({
83
- status: 200,
84
- type: SingleResponseDto
85
- }),
88
+ ApiResponseDto(CompanyActionResponseDto, true, 'single'),
86
89
  ApiBody({
87
90
  type: GetCompanyActionsDto
88
91
  }),
89
92
  _ts_param(0, Body()),
90
- _ts_param(1, CurrentUser()),
91
93
  _ts_metadata("design:type", Function),
92
94
  _ts_metadata("design:paramtypes", [
93
- typeof GetCompanyActionsDto === "undefined" ? Object : GetCompanyActionsDto,
94
- typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
95
+ typeof GetCompanyActionsDto === "undefined" ? Object : GetCompanyActionsDto
95
96
  ]),
96
97
  _ts_metadata("design:returntype", Promise)
97
98
  ], CompanyActionPermissionController.prototype, "getCompanyActions", null);
@@ -25,7 +25,7 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
- import { CurrentUser, ILoggedUserInfo, JwtAuthGuard } from '@flusys/nestjs-shared';
28
+ import { ApiResponseDto, CurrentUser, ILoggedUserInfo, JwtAuthGuard } from '@flusys/nestjs-shared';
29
29
  import { MY_PERMISSION_MESSAGES } from '../config';
30
30
  import { Body, Controller, Inject, Post, UseGuards } from '@nestjs/common';
31
31
  import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
@@ -53,10 +53,7 @@ _ts_decorate([
53
53
  summary: 'Get current user permissions',
54
54
  description: 'Returns complete permissions for authenticated user. Includes menus, frontend actions, and caches endpoint permissions. Optionally filter by parent codes.'
55
55
  }),
56
- ApiResponse({
57
- status: 200,
58
- type: MyPermissionsResponseDto
59
- }),
56
+ ApiResponseDto(MyPermissionsResponseDto),
60
57
  ApiResponse({
61
58
  status: 401,
62
59
  description: 'Unauthorized'
@@ -25,17 +25,28 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
- import { JwtAuthGuard, SingleResponseDto, RequirePermission, ROLE_ACTION_PERMISSIONS, USER_ROLE_PERMISSIONS, CurrentUser, ILoggedUserInfo } from '@flusys/nestjs-shared';
29
- import { ROLE_PERMISSION_MESSAGES } from '../config';
28
+ import { ApiResponseDto, CurrentUser, ILoggedUserInfo, JwtAuthGuard, RequirePermission, ROLE_ACTION_PERMISSIONS, USER_ROLE_PERMISSIONS } from '@flusys/nestjs-shared';
30
29
  import { Body, Controller, Inject, Post, UseGuards } from '@nestjs/common';
31
- import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
32
- import { AssignRoleActionsDto, AssignUserRolesDto, GetRoleActionsDto, GetUserRolesDto, PermissionOperationResultDto } from '../dtos/permission.dto';
30
+ import { ApiBearerAuth, ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
31
+ import { PERMISSION_OPERATION_MESSAGES, ROLE_PERMISSION_MESSAGES } from '../config';
32
+ import { AssignRoleActionsDto, AssignUserRolesDto, GetRoleActionsDto, GetUserRolesDto, PermissionOperationResultDto, RoleActionResponseDto, UserRoleResponseDto } from '../dtos/permission.dto';
33
33
  import { validateCompanyAccess } from '../helpers';
34
- import { PermissionService } from '../services/permission.service';
35
34
  import { IAMConfigService } from '../services/iam-config.service';
35
+ import { PermissionService } from '../services/permission.service';
36
36
  export class RolePermissionController {
37
37
  async assignRoleActions(dto) {
38
- return this.permissionService.assignRoleActions(dto);
38
+ const result = await this.permissionService.assignRoleActions(dto);
39
+ return {
40
+ success: true,
41
+ message: 'Role actions updated successfully',
42
+ messageKey: PERMISSION_OPERATION_MESSAGES.PROCESS_SUCCESS,
43
+ messageVariables: {
44
+ added: result.added,
45
+ removed: result.removed,
46
+ total: result.total
47
+ },
48
+ data: result
49
+ };
39
50
  }
40
51
  async getRoleActions(dto) {
41
52
  const actions = await this.permissionService.getRoleActions(dto.roleId);
@@ -48,7 +59,18 @@ export class RolePermissionController {
48
59
  }
49
60
  async assignUserRoles(dto, user) {
50
61
  validateCompanyAccess(this.config, dto.companyId, user);
51
- return this.permissionService.assignUserRoles(dto);
62
+ const result = await this.permissionService.assignUserRoles(dto);
63
+ return {
64
+ success: true,
65
+ message: 'User roles updated successfully',
66
+ messageKey: PERMISSION_OPERATION_MESSAGES.PROCESS_SUCCESS,
67
+ messageVariables: {
68
+ added: result.added,
69
+ removed: result.removed,
70
+ total: result.total
71
+ },
72
+ data: result
73
+ };
52
74
  }
53
75
  async getUserRoles(dto, user) {
54
76
  validateCompanyAccess(this.config, dto.companyId, user);
@@ -75,10 +97,7 @@ _ts_decorate([
75
97
  summary: 'Assign/remove actions to/from role',
76
98
  description: 'RBAC mode. No branch scoping.'
77
99
  }),
78
- ApiResponse({
79
- status: 200,
80
- type: PermissionOperationResultDto
81
- }),
100
+ ApiResponseDto(PermissionOperationResultDto),
82
101
  ApiBody({
83
102
  type: AssignRoleActionsDto
84
103
  }),
@@ -96,10 +115,7 @@ _ts_decorate([
96
115
  summary: 'Get role actions',
97
116
  description: 'Returns actions assigned to role.'
98
117
  }),
99
- ApiResponse({
100
- status: 200,
101
- type: SingleResponseDto
102
- }),
118
+ ApiResponseDto(RoleActionResponseDto, true, 'single'),
103
119
  ApiBody({
104
120
  type: GetRoleActionsDto
105
121
  }),
@@ -117,10 +133,7 @@ _ts_decorate([
117
133
  summary: 'Assign/remove roles to/from user',
118
134
  description: 'RBAC mode. If company feature enabled, branchId is required.'
119
135
  }),
120
- ApiResponse({
121
- status: 200,
122
- type: PermissionOperationResultDto
123
- }),
136
+ ApiResponseDto(PermissionOperationResultDto),
124
137
  ApiBody({
125
138
  type: AssignUserRolesDto
126
139
  }),
@@ -140,10 +153,7 @@ _ts_decorate([
140
153
  summary: 'Get user roles',
141
154
  description: 'Returns roles assigned to user. Filter by companyId and branchId.'
142
155
  }),
143
- ApiResponse({
144
- status: 200,
145
- type: SingleResponseDto
146
- }),
156
+ ApiResponseDto(UserRoleResponseDto, true, 'single'),
147
157
  ApiBody({
148
158
  type: GetUserRolesDto
149
159
  }),
@@ -25,18 +25,29 @@ function _ts_param(paramIndex, decorator) {
25
25
  decorator(target, key, paramIndex);
26
26
  };
27
27
  }
28
- import { JwtAuthGuard, SingleResponseDto, RequirePermission, USER_ACTION_PERMISSIONS, CurrentUser, ILoggedUserInfo } from '@flusys/nestjs-shared';
29
- import { USER_ACTION_PERMISSION_MESSAGES } from '../config';
28
+ import { ApiResponseDto, CurrentUser, ILoggedUserInfo, JwtAuthGuard, RequirePermission, USER_ACTION_PERMISSIONS } from '@flusys/nestjs-shared';
30
29
  import { Body, Controller, Inject, Post, UseGuards } from '@nestjs/common';
31
- import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
32
- import { AssignUserActionsDto, GetUserActionsDto, PermissionOperationResultDto } from '../dtos/permission.dto';
30
+ import { ApiBearerAuth, ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
31
+ import { PERMISSION_OPERATION_MESSAGES, USER_ACTION_PERMISSION_MESSAGES } from '../config';
32
+ import { AssignUserActionsDto, GetUserActionsDto, PermissionOperationResultDto, UserActionResponseDto } from '../dtos/permission.dto';
33
33
  import { validateCompanyAccess } from '../helpers';
34
- import { PermissionService } from '../services/permission.service';
35
34
  import { IAMConfigService } from '../services/iam-config.service';
35
+ import { PermissionService } from '../services/permission.service';
36
36
  export class UserActionPermissionController {
37
37
  async assignUserActions(dto, user) {
38
38
  validateCompanyAccess(this.config, dto.companyId, user);
39
- return this.permissionService.assignUserActions(dto);
39
+ const result = await this.permissionService.assignUserActions(dto);
40
+ return {
41
+ success: true,
42
+ message: 'User actions updated successfully',
43
+ messageKey: PERMISSION_OPERATION_MESSAGES.PROCESS_SUCCESS,
44
+ messageVariables: {
45
+ added: result.added,
46
+ removed: result.removed,
47
+ total: result.total
48
+ },
49
+ data: result
50
+ };
40
51
  }
41
52
  async getUserActions(dto, user) {
42
53
  validateCompanyAccess(this.config, dto.companyId, user);
@@ -63,10 +74,7 @@ _ts_decorate([
63
74
  summary: 'Assign/remove actions to/from user',
64
75
  description: 'Direct permissions. If company feature enabled, branchId is required.'
65
76
  }),
66
- ApiResponse({
67
- status: 200,
68
- type: PermissionOperationResultDto
69
- }),
77
+ ApiResponseDto(PermissionOperationResultDto),
70
78
  ApiBody({
71
79
  type: AssignUserActionsDto
72
80
  }),
@@ -86,10 +94,7 @@ _ts_decorate([
86
94
  summary: 'Get user direct actions',
87
95
  description: 'Returns direct action permissions for user. Filter by companyId and branchId.'
88
96
  }),
89
- ApiResponse({
90
- status: 200,
91
- type: SingleResponseDto
92
- }),
97
+ ApiResponseDto(UserActionResponseDto, true, 'single'),
93
98
  ApiBody({
94
99
  type: GetUserActionsDto
95
100
  }),
@@ -7,7 +7,8 @@ import { IAMPermissionMode } from '../enums/permission-type.enum';
7
7
  'User Permissions',
8
8
  'Company Selection'
9
9
  ];
10
- export function iamSwaggerConfig(enableCompanyFeature = false, permissionMode = IAMPermissionMode.FULL) {
10
+ export function iamSwaggerConfig(enableCompanyFeature = false, permissionMode = IAMPermissionMode.FULL, databaseMode = 'single') {
11
+ const multiTenantNote = databaseMode === 'multi-tenant' ? `\n> **Multi-Tenant Mode**: Include \`x-tenant-id\` header to target a specific tenant database.\n` : '';
11
12
  const excludeSchemaProperties = enableCompanyFeature ? [] : [
12
13
  // DTOs with companyId and branchId
13
14
  {
@@ -105,7 +106,7 @@ export function iamSwaggerConfig(enableCompanyFeature = false, permissionMode =
105
106
  title: 'IAM API',
106
107
  description: `
107
108
  ## Identity & Access Management API
108
-
109
+ ${multiTenantNote}
109
110
  Advanced permission system with flexible modes: RBAC, Direct Permissions, or both.
110
111
 
111
112
  ### Current Configuration
@@ -34,7 +34,6 @@ export class CreateActionDto {
34
34
  _define_property(this, "parentId", void 0);
35
35
  _define_property(this, "serial", void 0);
36
36
  _define_property(this, "isActive", void 0);
37
- _define_property(this, "metadata", void 0);
38
37
  }
39
38
  }
40
39
  _ts_decorate([
@@ -118,14 +117,6 @@ _ts_decorate([
118
117
  IsOptional(),
119
118
  _ts_metadata("design:type", Boolean)
120
119
  ], CreateActionDto.prototype, "isActive", void 0);
121
- _ts_decorate([
122
- ApiProperty({
123
- description: 'Additional metadata',
124
- required: false
125
- }),
126
- IsOptional(),
127
- _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
128
- ], CreateActionDto.prototype, "metadata", void 0);
129
120
  export class UpdateActionDto extends PartialType(CreateActionDto) {
130
121
  constructor(...args){
131
122
  super(...args), _define_property(this, "id", void 0);
@@ -152,7 +143,6 @@ export class ActionResponseDto {
152
143
  _define_property(this, "parentId", void 0);
153
144
  _define_property(this, "serial", void 0);
154
145
  _define_property(this, "isActive", void 0);
155
- _define_property(this, "metadata", void 0);
156
146
  _define_property(this, "createdAt", void 0);
157
147
  _define_property(this, "updatedAt", void 0);
158
148
  _define_property(this, "deletedAt", void 0);
@@ -203,12 +193,6 @@ _ts_decorate([
203
193
  ApiProperty(),
204
194
  _ts_metadata("design:type", Boolean)
205
195
  ], ActionResponseDto.prototype, "isActive", void 0);
206
- _ts_decorate([
207
- ApiProperty({
208
- required: false
209
- }),
210
- _ts_metadata("design:type", Object)
211
- ], ActionResponseDto.prototype, "metadata", void 0);
212
196
  _ts_decorate([
213
197
  ApiProperty(),
214
198
  _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)