@flusys/nestjs-iam 7.0.2 → 8.0.0-beta.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 (173) hide show
  1. package/config/index.d.ts +3 -3
  2. package/controllers/action.controller.d.ts +4 -4
  3. package/controllers/company-action-permission.controller.d.ts +2 -2
  4. package/controllers/index.d.ts +6 -6
  5. package/controllers/my-permission.controller.d.ts +3 -3
  6. package/controllers/role-permission.controller.d.ts +4 -4
  7. package/controllers/role.controller.d.ts +2 -2
  8. package/controllers/user-action-permission.controller.d.ts +4 -4
  9. package/docs/iam-swagger.config.d.ts +2 -2
  10. package/docs/index.d.ts +1 -1
  11. package/dtos/action.dto.d.ts +2 -2
  12. package/dtos/index.d.ts +3 -3
  13. package/entities/action.entity.d.ts +2 -2
  14. package/entities/index.d.ts +11 -11
  15. package/entities/permission-with-company.entity.d.ts +1 -1
  16. package/entities/role-with-company.entity.d.ts +1 -1
  17. package/entities/role.entity.d.ts +1 -1
  18. package/entities/user-iam-permission.entity.d.ts +1 -1
  19. package/enums/index.d.ts +4 -4
  20. package/fesm/284.js +1262 -0
  21. package/fesm/867.js +3699 -0
  22. package/fesm/chunks/364.js +86 -0
  23. package/fesm/config/index.js +133 -3
  24. package/fesm/controllers/index.js +18 -7
  25. package/fesm/docs/index.js +240 -1
  26. package/fesm/dtos/index.js +1090 -3
  27. package/fesm/entities/index.js +670 -31
  28. package/fesm/enums/index.js +97 -4
  29. package/fesm/helpers/index.js +125 -2
  30. package/fesm/index.js +806 -11
  31. package/fesm/interfaces/index.js +17 -3
  32. package/fesm/modules/index.js +259 -1
  33. package/fesm/runtime.js +134 -0
  34. package/fesm/services/index.js +43 -6
  35. package/fesm/types/index.js +15 -1
  36. package/helpers/company-access.helper.d.ts +2 -2
  37. package/helpers/index.d.ts +2 -2
  38. package/helpers/permission-mode.helper.d.ts +1 -1
  39. package/index.d.ts +11 -11
  40. package/interfaces/action.interface.d.ts +2 -2
  41. package/interfaces/iam-module-options.interface.d.ts +3 -3
  42. package/interfaces/index.d.ts +3 -3
  43. package/modules/iam.module.d.ts +2 -2
  44. package/modules/index.d.ts +1 -1
  45. package/package.json +30 -37
  46. package/services/action.service.d.ts +9 -9
  47. package/services/iam-config.service.d.ts +4 -4
  48. package/services/iam-datasource.service.d.ts +3 -3
  49. package/services/index.d.ts +6 -6
  50. package/services/permission-cache.service.d.ts +5 -5
  51. package/services/permission.service.d.ts +4 -4
  52. package/services/role.service.d.ts +8 -8
  53. package/types/index.d.ts +1 -1
  54. package/cjs/config/event-actions.js +0 -36
  55. package/cjs/config/iam.constants.js +0 -11
  56. package/cjs/config/index.js +0 -20
  57. package/cjs/config/message-keys.js +0 -71
  58. package/cjs/controllers/action.controller.js +0 -174
  59. package/cjs/controllers/action.controller.spec.js +0 -79
  60. package/cjs/controllers/company-action-permission.controller.js +0 -119
  61. package/cjs/controllers/company-action-permission.controller.spec.js +0 -65
  62. package/cjs/controllers/index.js +0 -23
  63. package/cjs/controllers/my-permission.controller.js +0 -147
  64. package/cjs/controllers/my-permission.controller.spec.js +0 -128
  65. package/cjs/controllers/role-permission.controller.js +0 -191
  66. package/cjs/controllers/role-permission.controller.spec.js +0 -140
  67. package/cjs/controllers/role.controller.js +0 -102
  68. package/cjs/controllers/role.controller.spec.js +0 -86
  69. package/cjs/controllers/user-action-permission.controller.js +0 -129
  70. package/cjs/controllers/user-action-permission.controller.spec.js +0 -68
  71. package/cjs/docs/iam-swagger.config.js +0 -209
  72. package/cjs/docs/iam-swagger.config.spec.js +0 -99
  73. package/cjs/docs/index.js +0 -18
  74. package/cjs/dtos/action.dto.js +0 -282
  75. package/cjs/dtos/index.js +0 -21
  76. package/cjs/dtos/permission.dto.js +0 -637
  77. package/cjs/dtos/role.dto.js +0 -155
  78. package/cjs/entities/action.entity.js +0 -138
  79. package/cjs/entities/index.js +0 -80
  80. package/cjs/entities/index.spec.js +0 -56
  81. package/cjs/entities/permission-base.entity.js +0 -107
  82. package/cjs/entities/permission-with-company.entity.js +0 -100
  83. package/cjs/entities/role-base.entity.js +0 -80
  84. package/cjs/entities/role-with-company.entity.js +0 -55
  85. package/cjs/entities/role.entity.js +0 -25
  86. package/cjs/entities/user-iam-permission.entity.js +0 -43
  87. package/cjs/enums/action-type.enum.js +0 -22
  88. package/cjs/enums/iam-entity-type.enum.js +0 -17
  89. package/cjs/enums/iam-permission-type.enum.js +0 -17
  90. package/cjs/enums/index.js +0 -21
  91. package/cjs/enums/permission-type.enum.js +0 -16
  92. package/cjs/helpers/company-access.helper.js +0 -23
  93. package/cjs/helpers/company-access.helper.spec.js +0 -68
  94. package/cjs/helpers/index.js +0 -19
  95. package/cjs/helpers/permission-mode.helper.js +0 -49
  96. package/cjs/helpers/permission-mode.helper.spec.js +0 -54
  97. package/cjs/index.js +0 -28
  98. package/cjs/interfaces/action.interface.js +0 -4
  99. package/cjs/interfaces/iam-module-options.interface.js +0 -4
  100. package/cjs/interfaces/index.js +0 -20
  101. package/cjs/interfaces/role.interface.js +0 -7
  102. package/cjs/modules/iam.module.js +0 -186
  103. package/cjs/modules/iam.module.spec.js +0 -282
  104. package/cjs/modules/index.js +0 -18
  105. package/cjs/services/action.service.js +0 -337
  106. package/cjs/services/action.service.spec.js +0 -351
  107. package/cjs/services/iam-config.service.js +0 -87
  108. package/cjs/services/iam-config.service.spec.js +0 -110
  109. package/cjs/services/iam-datasource.service.js +0 -129
  110. package/cjs/services/iam-datasource.service.spec.js +0 -110
  111. package/cjs/services/index.js +0 -23
  112. package/cjs/services/permission-cache.service.js +0 -544
  113. package/cjs/services/permission-cache.service.spec.js +0 -718
  114. package/cjs/services/permission.service.js +0 -914
  115. package/cjs/services/permission.service.spec.js +0 -918
  116. package/cjs/services/role.service.js +0 -224
  117. package/cjs/services/role.service.spec.js +0 -347
  118. package/cjs/types/index.js +0 -18
  119. package/cjs/types/logic-node.type.js +0 -30
  120. package/fesm/config/event-actions.js +0 -15
  121. package/fesm/config/iam.constants.js +0 -1
  122. package/fesm/config/message-keys.js +0 -35
  123. package/fesm/controllers/action.controller.js +0 -164
  124. package/fesm/controllers/action.controller.spec.js +0 -75
  125. package/fesm/controllers/company-action-permission.controller.js +0 -109
  126. package/fesm/controllers/company-action-permission.controller.spec.js +0 -61
  127. package/fesm/controllers/my-permission.controller.js +0 -137
  128. package/fesm/controllers/my-permission.controller.spec.js +0 -124
  129. package/fesm/controllers/role-permission.controller.js +0 -181
  130. package/fesm/controllers/role-permission.controller.spec.js +0 -136
  131. package/fesm/controllers/role.controller.js +0 -92
  132. package/fesm/controllers/role.controller.spec.js +0 -82
  133. package/fesm/controllers/user-action-permission.controller.js +0 -119
  134. package/fesm/controllers/user-action-permission.controller.spec.js +0 -64
  135. package/fesm/docs/iam-swagger.config.js +0 -199
  136. package/fesm/docs/iam-swagger.config.spec.js +0 -95
  137. package/fesm/dtos/action.dto.js +0 -252
  138. package/fesm/dtos/permission.dto.js +0 -571
  139. package/fesm/dtos/role.dto.js +0 -134
  140. package/fesm/entities/action.entity.js +0 -128
  141. package/fesm/entities/index.spec.js +0 -52
  142. package/fesm/entities/permission-base.entity.js +0 -100
  143. package/fesm/entities/permission-with-company.entity.js +0 -90
  144. package/fesm/entities/role-base.entity.js +0 -70
  145. package/fesm/entities/role-with-company.entity.js +0 -45
  146. package/fesm/entities/role.entity.js +0 -15
  147. package/fesm/entities/user-iam-permission.entity.js +0 -33
  148. package/fesm/enums/action-type.enum.js +0 -12
  149. package/fesm/enums/iam-entity-type.enum.js +0 -7
  150. package/fesm/enums/iam-permission-type.enum.js +0 -7
  151. package/fesm/enums/permission-type.enum.js +0 -6
  152. package/fesm/helpers/company-access.helper.js +0 -18
  153. package/fesm/helpers/company-access.helper.spec.js +0 -64
  154. package/fesm/helpers/permission-mode.helper.js +0 -49
  155. package/fesm/helpers/permission-mode.helper.spec.js +0 -50
  156. package/fesm/interfaces/action.interface.js +0 -3
  157. package/fesm/interfaces/iam-module-options.interface.js +0 -3
  158. package/fesm/interfaces/role.interface.js +0 -4
  159. package/fesm/modules/iam.module.js +0 -176
  160. package/fesm/modules/iam.module.spec.js +0 -278
  161. package/fesm/services/action.service.js +0 -327
  162. package/fesm/services/action.service.spec.js +0 -347
  163. package/fesm/services/iam-config.service.js +0 -77
  164. package/fesm/services/iam-config.service.spec.js +0 -106
  165. package/fesm/services/iam-datasource.service.js +0 -78
  166. package/fesm/services/iam-datasource.service.spec.js +0 -106
  167. package/fesm/services/permission-cache.service.js +0 -527
  168. package/fesm/services/permission-cache.service.spec.js +0 -714
  169. package/fesm/services/permission.service.js +0 -904
  170. package/fesm/services/permission.service.spec.js +0 -914
  171. package/fesm/services/role.service.js +0 -214
  172. package/fesm/services/role.service.spec.js +0 -343
  173. package/fesm/types/logic-node.type.js +0 -27
@@ -1,209 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "iamSwaggerConfig", {
6
- enumerable: true,
7
- get: function() {
8
- return iamSwaggerConfig;
9
- }
10
- });
11
- const _permissiontypeenum = require("../enums/permission-type.enum");
12
- /** Auth-related tags that should always be excluded from IAM API docs */ const AUTH_RELATED_TAGS = [
13
- 'Authentication',
14
- 'Users',
15
- 'Companies',
16
- 'Branches',
17
- 'User Permissions',
18
- 'Company Selection'
19
- ];
20
- function iamSwaggerConfig(enableCompanyFeature = false, permissionMode = _permissiontypeenum.IAMPermissionMode.FULL, databaseMode = 'single') {
21
- const multiTenantNote = databaseMode === 'multi-tenant' ? `\n> **Multi-Tenant Mode**: Include \`x-tenant-id\` header to target a specific tenant database.\n` : '';
22
- const excludeSchemaProperties = enableCompanyFeature ? [] : [
23
- // DTOs with companyId and branchId
24
- {
25
- schemaName: 'AssignUserActionsDto',
26
- properties: [
27
- 'companyId',
28
- 'branchId'
29
- ]
30
- },
31
- {
32
- schemaName: 'AssignUserRolesDto',
33
- properties: [
34
- 'companyId',
35
- 'branchId'
36
- ]
37
- },
38
- {
39
- schemaName: 'GetUserActionsDto',
40
- properties: [
41
- 'companyId',
42
- 'branchId'
43
- ]
44
- },
45
- {
46
- schemaName: 'GetUserRolesDto',
47
- properties: [
48
- 'companyId',
49
- 'branchId'
50
- ]
51
- },
52
- {
53
- schemaName: 'ActionTreeForPermissionDto',
54
- properties: [
55
- 'companyId'
56
- ]
57
- },
58
- // Response DTOs with branchId
59
- {
60
- schemaName: 'UserActionResponseDto',
61
- properties: [
62
- 'branchId'
63
- ]
64
- },
65
- {
66
- schemaName: 'UserRoleResponseDto',
67
- properties: [
68
- 'branchId'
69
- ]
70
- },
71
- // Company-related DTOs (entire schemas hidden via tag exclusion, but just in case)
72
- {
73
- schemaName: 'AssignCompanyActionsDto',
74
- properties: [
75
- 'companyId'
76
- ]
77
- },
78
- {
79
- schemaName: 'CompanyActionResponseDto',
80
- properties: [
81
- 'companyId'
82
- ]
83
- }
84
- ];
85
- // Hide query parameters for GET endpoints when company feature is disabled
86
- const excludeQueryParameters = enableCompanyFeature ? [] : [
87
- {
88
- pathPattern: '/iam/permissions/user-actions/*',
89
- method: 'get',
90
- parameters: [
91
- 'companyId',
92
- 'branchId'
93
- ]
94
- },
95
- {
96
- pathPattern: '/iam/permissions/user-roles/*',
97
- method: 'get',
98
- parameters: [
99
- 'companyId',
100
- 'branchId'
101
- ]
102
- }
103
- ];
104
- // Build exclude tags list: always exclude Auth tags + conditionally exclude based on permission mode
105
- const excludeTags = [
106
- ...AUTH_RELATED_TAGS
107
- ];
108
- // Hide company-related IAM endpoints when company feature is disabled
109
- if (!enableCompanyFeature) {
110
- excludeTags.push('IAM - Company Action Permissions');
111
- }
112
- // Conditionally exclude endpoints based on permission mode
113
- if (permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC) {
114
- // RBAC only - hide direct user action endpoints
115
- excludeTags.push('IAM - Permissions (Direct)');
116
- } else if (permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT) {
117
- // Direct only - hide RBAC endpoints
118
- excludeTags.push('IAM - Permissions (RBAC)');
119
- excludeTags.push('IAM - Roles'); // Roles are only used in RBAC
120
- }
121
- return {
122
- title: 'IAM API',
123
- description: `
124
- ## Identity & Access Management API
125
- ${multiTenantNote}
126
- Advanced permission system with flexible modes: RBAC, Direct Permissions, or both.
127
-
128
- ### Current Configuration
129
- - **Permission Mode**: ${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC ? '**RBAC** (Role-Based Access Control)' : permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT ? '**DIRECT** (Direct User Permissions)' : '**FULL** (RBAC + Direct)'}${enableCompanyFeature ? '\n- **Company Feature**: Enabled (Multi-tenant with company/branch scoping)' : '\n- **Company Feature**: Disabled'}
130
-
131
- ### Features Based on Mode
132
-
133
- ${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `#### RBAC Features (Active)
134
- - **Roles**: Create company-scoped roles${enableCompanyFeature ? ' (auto-filtered by user company)' : ''}
135
- - **Role-Actions**: Assign actions to roles
136
- - **User-Roles**: Assign roles to users${enableCompanyFeature ? ' at branch level' : ''}
137
- ` : ''}${permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `#### Direct Permission Features (Active)
138
- - **User-Actions**: Direct action assignment to users${enableCompanyFeature ? ' at branch level' : ''}
139
- ` : ''}${enableCompanyFeature ? `#### Company Features (Active)
140
- - **Company-Action Whitelist**: Control which actions are available per company
141
- - **Branch-Based Scoping**: Permissions scoped to specific branches
142
- - **Auto-Filtering**: Roles automatically filtered by user's company
143
- - **Action Tree Filtering**: Available actions filtered by company whitelist
144
- ` : ''}
145
- ### Core Concepts
146
-
147
- #### Actions
148
- Represent permissions in the system. Can be hierarchical.
149
-
150
- **Action Types:**
151
- - \`menu\` - Menu visibility (actions with type='menu' are used as menus)
152
- - \`endpoint\` - API endpoint access
153
- - \`frontend\` - Frontend feature toggles
154
- ${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
155
- #### Roles
156
- Collections of actions that can be assigned to users.${enableCompanyFeature ? ' Scoped to companies.' : ' Global across the system.'}
157
- ` : ''}${enableCompanyFeature ? `
158
- #### Company-Action Whitelist
159
- Controls which actions are available to a company. Users/roles can only use whitelisted actions.
160
-
161
- **Flow:**
162
- 1. Admin assigns actions to company (whitelist)
163
- 2. Only whitelisted actions appear in permission assignment UIs
164
- 3. Users/roles cannot be assigned non-whitelisted actions
165
- ` : ''}
166
- ### Permission Resolution
167
-
168
- ${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `1. **Company-Action Whitelist** - Filter by company (if enabled)
169
- 2. **UserAction (DENY)** - Explicit denials take precedence
170
- 3. **UserAction (GRANT)** - Direct user grants
171
- 4. **UserRole → RoleAction** - Inherited from assigned roles
172
- 5. **Action Permission Logic** - Complex AND/OR rules` : permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC ? `1. **Company-Action Whitelist** - Filter by company (if enabled)
173
- 2. **UserRole → RoleAction** - Actions inherited from roles
174
- 3. **Action Permission Logic** - Complex AND/OR rules` : `1. **Company-Action Whitelist** - Filter by company (if enabled)
175
- 2. **UserAction (DENY)** - Explicit denials take precedence
176
- 3. **UserAction (GRANT)** - Direct user grants
177
- 4. **Action Permission Logic** - Complex AND/OR rules`}
178
-
179
- ### API Endpoints Summary
180
-
181
- #### Available Endpoints
182
- - ✅ **Actions**: CRUD operations, tree view${enableCompanyFeature ? ', filtered tree for permissions' : ''}${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
183
- - ✅ **Roles**: CRUD operations${enableCompanyFeature ? ' (auto-filtered by company)' : ''}
184
- - ✅ **Role-Actions**: Assign actions to roles, get role actions
185
- - ✅ **User-Roles**: Assign roles to users, get user roles` : `
186
- - ❌ **Roles**: Disabled (RBAC mode not active)`}${permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
187
- - ✅ **User-Actions**: Direct action assignment to users` : `
188
- - ❌ **User-Actions**: Disabled (DIRECT mode not active)`}${enableCompanyFeature ? `
189
- - ✅ **Company-Actions**: Whitelist actions for companies` : `
190
- - ❌ **Company-Actions**: Disabled (company feature not enabled)`}
191
- - ✅ **My Permissions**: Get current user's complete permissions (includes menu-type actions)
192
-
193
- ### Best Practices
194
-
195
- 1. **Action Codes**: Use meaningful codes like \`user.create\`, \`order.view\`
196
- 2. **Hierarchical Actions**: Group related actions (use parentId for hierarchy)${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
197
- 3. **Role Design**: Create roles for common permission patterns` : ''}${permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
198
- ${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? '4' : '3'}. **Direct Actions**: Use sparingly for exceptions` : ''}${enableCompanyFeature ? `
199
- ${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? '5' : '4'}. **Company Whitelisting**: Set up action whitelist before assigning permissions
200
- ${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? '6' : '5'}. **Branch Scoping**: Use branches for location-based access control` : ''}
201
- `,
202
- version: '1.0',
203
- path: 'api/docs/iam',
204
- bearerAuth: true,
205
- excludeSchemaProperties,
206
- excludeTags,
207
- excludeQueryParameters
208
- };
209
- }
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- const _iamswaggerconfig = require("./iam-swagger.config");
6
- const _permissiontypeenum = require("../enums/permission-type.enum");
7
- describe('iamSwaggerConfig', ()=>{
8
- it('should default to company disabled, FULL mode, single database', ()=>{
9
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)();
10
- expect(config.title).toBe('IAM API');
11
- expect(config.path).toBe('api/docs/iam');
12
- expect(config.bearerAuth).toBe(true);
13
- // enableCompanyFeature defaults to false, so company-scoped exclusions apply
14
- expect(config.excludeSchemaProperties?.length).toBeGreaterThan(0);
15
- expect(config.excludeQueryParameters?.length).toBeGreaterThan(0);
16
- expect(config.description).not.toContain('Multi-Tenant Mode');
17
- });
18
- it('should always exclude auth-related tags regardless of configuration', ()=>{
19
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(true, _permissiontypeenum.IAMPermissionMode.FULL);
20
- expect(config.excludeTags).toEqual(expect.arrayContaining([
21
- 'Authentication',
22
- 'Users',
23
- 'Companies',
24
- 'Branches'
25
- ]));
26
- });
27
- it('should exclude company-scoped schema properties and query params when company feature is off', ()=>{
28
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(false);
29
- expect(config.excludeSchemaProperties).toEqual(expect.arrayContaining([
30
- expect.objectContaining({
31
- schemaName: 'AssignUserActionsDto',
32
- properties: [
33
- 'companyId',
34
- 'branchId'
35
- ]
36
- })
37
- ]));
38
- expect(config.excludeQueryParameters).toEqual(expect.arrayContaining([
39
- expect.objectContaining({
40
- pathPattern: '/iam/permissions/user-actions/*',
41
- method: 'get'
42
- })
43
- ]));
44
- expect(config.excludeTags).toContain('IAM - Company Action Permissions');
45
- });
46
- it('should not exclude company-scoped schema properties, query params, or tags when company feature is on', ()=>{
47
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(true);
48
- expect(config.excludeSchemaProperties).toEqual([]);
49
- expect(config.excludeQueryParameters).toEqual([]);
50
- expect(config.excludeTags).not.toContain('IAM - Company Action Permissions');
51
- });
52
- it('should hide DIRECT-mode tags in RBAC mode', ()=>{
53
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.RBAC);
54
- expect(config.excludeTags).toContain('IAM - Permissions (Direct)');
55
- expect(config.excludeTags).not.toContain('IAM - Permissions (RBAC)');
56
- expect(config.excludeTags).not.toContain('IAM - Roles');
57
- });
58
- it('should hide RBAC-mode tags (including Roles) in DIRECT mode', ()=>{
59
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.DIRECT);
60
- expect(config.excludeTags).toContain('IAM - Permissions (RBAC)');
61
- expect(config.excludeTags).toContain('IAM - Roles');
62
- expect(config.excludeTags).not.toContain('IAM - Permissions (Direct)');
63
- });
64
- it('should hide neither RBAC nor DIRECT tags in FULL mode', ()=>{
65
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.FULL);
66
- expect(config.excludeTags).not.toContain('IAM - Permissions (RBAC)');
67
- expect(config.excludeTags).not.toContain('IAM - Permissions (Direct)');
68
- expect(config.excludeTags).not.toContain('IAM - Roles');
69
- });
70
- it('should mention multi-tenant mode in the description only for multi-tenant database mode', ()=>{
71
- const multiTenant = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.FULL, 'multi-tenant');
72
- const single = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.FULL, 'single');
73
- expect(multiTenant.description).toContain('Multi-Tenant Mode');
74
- expect(single.description).not.toContain('Multi-Tenant Mode');
75
- });
76
- it('should describe RBAC as active and DIRECT as disabled in the endpoints summary for RBAC mode', ()=>{
77
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.RBAC);
78
- expect(config.description).toContain('**Roles**: CRUD operations');
79
- expect(config.description).toContain('❌ **User-Actions**: Disabled (DIRECT mode not active)');
80
- });
81
- it('should describe DIRECT as active and Roles as disabled in the endpoints summary for DIRECT mode', ()=>{
82
- const config = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.DIRECT);
83
- expect(config.description).toContain('✅ **User-Actions**: Direct action assignment to users');
84
- expect(config.description).toContain('❌ **Roles**: Disabled (RBAC mode not active)');
85
- });
86
- it('should describe company features as active only when company feature is enabled', ()=>{
87
- const withCompany = (0, _iamswaggerconfig.iamSwaggerConfig)(true, _permissiontypeenum.IAMPermissionMode.FULL);
88
- const withoutCompany = (0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.FULL);
89
- expect(withCompany.description).toContain('Company Features (Active)');
90
- expect(withCompany.description).toContain('✅ **Company-Actions**: Whitelist actions for companies');
91
- expect(withoutCompany.description).not.toContain('Company Features (Active)');
92
- expect(withoutCompany.description).toContain('❌ **Company-Actions**: Disabled (company feature not enabled)');
93
- });
94
- it('should describe the current permission mode label correctly for each mode', ()=>{
95
- expect((0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.RBAC).description).toContain('**RBAC** (Role-Based Access Control)');
96
- expect((0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.DIRECT).description).toContain('**DIRECT** (Direct User Permissions)');
97
- expect((0, _iamswaggerconfig.iamSwaggerConfig)(false, _permissiontypeenum.IAMPermissionMode.FULL).description).toContain('**FULL** (RBAC + Direct)');
98
- });
99
- });
package/cjs/docs/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- _export_star(require("./iam-swagger.config"), exports);
6
- function _export_star(from, to) {
7
- Object.keys(from).forEach(function(k) {
8
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
- Object.defineProperty(to, k, {
10
- enumerable: true,
11
- get: function() {
12
- return from[k];
13
- }
14
- });
15
- }
16
- });
17
- return from;
18
- }
@@ -1,282 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get ActionResponseDto () {
13
- return ActionResponseDto;
14
- },
15
- get ActionTreeDto () {
16
- return ActionTreeDto;
17
- },
18
- get ActionTreeForPermissionDto () {
19
- return ActionTreeForPermissionDto;
20
- },
21
- get ActionTreeQueryDto () {
22
- return ActionTreeQueryDto;
23
- },
24
- get CreateActionDto () {
25
- return CreateActionDto;
26
- },
27
- get UpdateActionDto () {
28
- return UpdateActionDto;
29
- }
30
- });
31
- const _dtos = require("@flusys/nestjs-shared/dtos");
32
- const _swagger = require("@nestjs/swagger");
33
- const _classtransformer = require("class-transformer");
34
- const _classvalidator = require("class-validator");
35
- const _enums = require("../enums");
36
- const _types = require("../types");
37
- function _define_property(obj, key, value) {
38
- if (key in obj) {
39
- Object.defineProperty(obj, key, {
40
- value: value,
41
- enumerable: true,
42
- configurable: true,
43
- writable: true
44
- });
45
- } else {
46
- obj[key] = value;
47
- }
48
- return obj;
49
- }
50
- function _ts_decorate(decorators, target, key, desc) {
51
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
52
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
53
- 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;
54
- return c > 3 && r && Object.defineProperty(target, key, r), r;
55
- }
56
- function _ts_metadata(k, v) {
57
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
58
- }
59
- let CreateActionDto = class CreateActionDto {
60
- constructor(){
61
- _define_property(this, "name", void 0);
62
- _define_property(this, "description", void 0);
63
- _define_property(this, "code", void 0);
64
- _define_property(this, "actionType", void 0);
65
- _define_property(this, "permissionLogic", void 0);
66
- _define_property(this, "parentId", void 0);
67
- _define_property(this, "serial", void 0);
68
- _define_property(this, "isActive", void 0);
69
- }
70
- };
71
- _ts_decorate([
72
- (0, _swagger.ApiProperty)({
73
- description: 'Action name',
74
- example: 'View Users'
75
- }),
76
- (0, _classvalidator.IsString)(),
77
- (0, _classvalidator.IsNotEmpty)(),
78
- (0, _classvalidator.MaxLength)(255),
79
- _ts_metadata("design:type", String)
80
- ], CreateActionDto.prototype, "name", void 0);
81
- _ts_decorate([
82
- (0, _swagger.ApiProperty)({
83
- description: 'Action description',
84
- example: 'Permission to view user list',
85
- required: false
86
- }),
87
- (0, _classvalidator.IsString)(),
88
- (0, _classvalidator.IsOptional)(),
89
- (0, _classvalidator.MaxLength)(500),
90
- _ts_metadata("design:type", String)
91
- ], CreateActionDto.prototype, "description", void 0);
92
- _ts_decorate([
93
- (0, _swagger.ApiProperty)({
94
- description: 'Unique code for programmatic reference',
95
- example: 'user.view',
96
- required: false
97
- }),
98
- (0, _classvalidator.IsString)(),
99
- (0, _classvalidator.IsOptional)(),
100
- (0, _classvalidator.MaxLength)(255),
101
- _ts_metadata("design:type", String)
102
- ], CreateActionDto.prototype, "code", void 0);
103
- _ts_decorate([
104
- (0, _swagger.ApiProperty)({
105
- description: 'Action type (backend for API endpoints, frontend for UI features)',
106
- enum: _enums.ActionType,
107
- example: _enums.ActionType.BACKEND,
108
- default: _enums.ActionType.BACKEND,
109
- required: false
110
- }),
111
- (0, _classvalidator.IsEnum)(_enums.ActionType),
112
- (0, _classvalidator.IsOptional)(),
113
- _ts_metadata("design:type", typeof _enums.ActionType === "undefined" ? Object : _enums.ActionType)
114
- ], CreateActionDto.prototype, "actionType", void 0);
115
- _ts_decorate([
116
- (0, _swagger.ApiProperty)({
117
- description: 'Permission logic (AND/OR rules)',
118
- required: false
119
- }),
120
- (0, _classvalidator.IsOptional)(),
121
- _ts_metadata("design:type", typeof _types.LogicNode === "undefined" ? Object : _types.LogicNode)
122
- ], CreateActionDto.prototype, "permissionLogic", void 0);
123
- _ts_decorate([
124
- (0, _swagger.ApiProperty)({
125
- description: 'Parent action ID for hierarchy',
126
- example: '123e4567-e89b-12d3-a456-426614174000',
127
- required: false
128
- }),
129
- (0, _classvalidator.IsUUID)(),
130
- (0, _classvalidator.IsOptional)(),
131
- _ts_metadata("design:type", String)
132
- ], CreateActionDto.prototype, "parentId", void 0);
133
- _ts_decorate([
134
- (0, _swagger.ApiProperty)({
135
- description: 'Display order',
136
- required: false
137
- }),
138
- (0, _classvalidator.IsInt)(),
139
- (0, _classvalidator.IsOptional)(),
140
- _ts_metadata("design:type", Number)
141
- ], CreateActionDto.prototype, "serial", void 0);
142
- _ts_decorate([
143
- (0, _swagger.ApiProperty)({
144
- description: 'Active status',
145
- default: true,
146
- required: false
147
- }),
148
- (0, _classvalidator.IsBoolean)(),
149
- (0, _classvalidator.IsOptional)(),
150
- _ts_metadata("design:type", Boolean)
151
- ], CreateActionDto.prototype, "isActive", void 0);
152
- let UpdateActionDto = class UpdateActionDto extends (0, _swagger.PartialType)(CreateActionDto) {
153
- constructor(...args){
154
- super(...args), _define_property(this, "id", void 0);
155
- }
156
- };
157
- _ts_decorate([
158
- (0, _swagger.ApiProperty)({
159
- description: 'Action ID',
160
- example: '123e4567-e89b-12d3-a456-426614174000'
161
- }),
162
- (0, _classvalidator.IsUUID)(),
163
- (0, _classvalidator.IsNotEmpty)(),
164
- _ts_metadata("design:type", String)
165
- ], UpdateActionDto.prototype, "id", void 0);
166
- let ActionResponseDto = class ActionResponseDto extends _dtos.IdentityResponseDto {
167
- constructor(...args){
168
- super(...args), _define_property(this, "readOnly", void 0), _define_property(this, "name", void 0), _define_property(this, "description", void 0), _define_property(this, "code", void 0), _define_property(this, "actionType", void 0), _define_property(this, "permissionLogic", void 0), _define_property(this, "parentId", void 0), _define_property(this, "serial", void 0), _define_property(this, "isActive", void 0);
169
- }
170
- };
171
- _ts_decorate([
172
- (0, _classtransformer.Expose)(),
173
- (0, _swagger.ApiProperty)(),
174
- _ts_metadata("design:type", Boolean)
175
- ], ActionResponseDto.prototype, "readOnly", void 0);
176
- _ts_decorate([
177
- (0, _classtransformer.Expose)(),
178
- (0, _swagger.ApiProperty)(),
179
- _ts_metadata("design:type", String)
180
- ], ActionResponseDto.prototype, "name", void 0);
181
- _ts_decorate([
182
- (0, _classtransformer.Expose)(),
183
- (0, _swagger.ApiProperty)(),
184
- _ts_metadata("design:type", Object)
185
- ], ActionResponseDto.prototype, "description", void 0);
186
- _ts_decorate([
187
- (0, _classtransformer.Expose)(),
188
- (0, _swagger.ApiProperty)(),
189
- _ts_metadata("design:type", Object)
190
- ], ActionResponseDto.prototype, "code", void 0);
191
- _ts_decorate([
192
- (0, _classtransformer.Expose)(),
193
- (0, _swagger.ApiProperty)({
194
- enum: _enums.ActionType
195
- }),
196
- _ts_metadata("design:type", typeof _enums.ActionType === "undefined" ? Object : _enums.ActionType)
197
- ], ActionResponseDto.prototype, "actionType", void 0);
198
- _ts_decorate([
199
- (0, _classtransformer.Expose)(),
200
- (0, _swagger.ApiProperty)(),
201
- _ts_metadata("design:type", Object)
202
- ], ActionResponseDto.prototype, "permissionLogic", void 0);
203
- _ts_decorate([
204
- (0, _classtransformer.Expose)(),
205
- (0, _swagger.ApiProperty)(),
206
- _ts_metadata("design:type", Object)
207
- ], ActionResponseDto.prototype, "parentId", void 0);
208
- _ts_decorate([
209
- (0, _classtransformer.Expose)(),
210
- (0, _swagger.ApiProperty)(),
211
- _ts_metadata("design:type", Object)
212
- ], ActionResponseDto.prototype, "serial", void 0);
213
- _ts_decorate([
214
- (0, _classtransformer.Expose)(),
215
- (0, _swagger.ApiProperty)(),
216
- _ts_metadata("design:type", Boolean)
217
- ], ActionResponseDto.prototype, "isActive", void 0);
218
- let ActionTreeDto = class ActionTreeDto extends ActionResponseDto {
219
- constructor(...args){
220
- super(...args), _define_property(this, "children", void 0);
221
- }
222
- };
223
- _ts_decorate([
224
- (0, _classtransformer.Expose)(),
225
- (0, _swagger.ApiProperty)({
226
- type: ()=>[
227
- ActionTreeDto
228
- ]
229
- }),
230
- _ts_metadata("design:type", Array)
231
- ], ActionTreeDto.prototype, "children", void 0);
232
- let ActionTreeForPermissionDto = class ActionTreeForPermissionDto {
233
- constructor(){
234
- _define_property(this, "companyId", void 0);
235
- }
236
- };
237
- _ts_decorate([
238
- (0, _swagger.ApiProperty)({
239
- description: 'Company to scope the action whitelist to. Defaults to the current user session company when omitted.',
240
- required: false
241
- }),
242
- (0, _classvalidator.IsUUID)(),
243
- (0, _classvalidator.IsOptional)(),
244
- _ts_metadata("design:type", String)
245
- ], ActionTreeForPermissionDto.prototype, "companyId", void 0);
246
- let ActionTreeQueryDto = class ActionTreeQueryDto {
247
- constructor(){
248
- _define_property(this, "search", void 0);
249
- _define_property(this, "isActive", void 0);
250
- _define_property(this, "withDeleted", void 0);
251
- }
252
- };
253
- _ts_decorate([
254
- (0, _swagger.ApiProperty)({
255
- description: 'Search by name or code',
256
- example: 'user',
257
- required: false
258
- }),
259
- (0, _classvalidator.IsString)(),
260
- (0, _classvalidator.IsOptional)(),
261
- _ts_metadata("design:type", String)
262
- ], ActionTreeQueryDto.prototype, "search", void 0);
263
- _ts_decorate([
264
- (0, _swagger.ApiProperty)({
265
- description: 'Filter by active status',
266
- example: true,
267
- required: false
268
- }),
269
- (0, _classvalidator.IsBoolean)(),
270
- (0, _classvalidator.IsOptional)(),
271
- _ts_metadata("design:type", Boolean)
272
- ], ActionTreeQueryDto.prototype, "isActive", void 0);
273
- _ts_decorate([
274
- (0, _swagger.ApiProperty)({
275
- description: 'Include deleted actions',
276
- default: false,
277
- required: false
278
- }),
279
- (0, _classvalidator.IsBoolean)(),
280
- (0, _classvalidator.IsOptional)(),
281
- _ts_metadata("design:type", Boolean)
282
- ], ActionTreeQueryDto.prototype, "withDeleted", void 0);
package/cjs/dtos/index.js DELETED
@@ -1,21 +0,0 @@
1
- // Core DTOs
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- _export_star(require("./action.dto"), exports);
7
- _export_star(require("./role.dto"), exports);
8
- _export_star(require("./permission.dto"), exports);
9
- function _export_star(from, to) {
10
- Object.keys(from).forEach(function(k) {
11
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
12
- Object.defineProperty(to, k, {
13
- enumerable: true,
14
- get: function() {
15
- return from[k];
16
- }
17
- });
18
- }
19
- });
20
- return from;
21
- }