@flusys/nestjs-iam 0.1.0-beta.1 → 0.1.0-beta.2
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/README.md +665 -0
- package/cjs/config/iam.constants.js +11 -0
- package/cjs/config/index.js +18 -0
- package/cjs/controllers/action.controller.js +117 -0
- package/cjs/controllers/company-action-permission.controller.js +110 -0
- package/cjs/controllers/index.js +23 -0
- package/cjs/controllers/my-permission.controller.js +90 -0
- package/cjs/controllers/role-permission.controller.js +160 -0
- package/cjs/controllers/role.controller.js +58 -0
- package/cjs/controllers/user-action-permission.controller.js +110 -0
- package/cjs/docs/iam-swagger.config.js +202 -0
- package/cjs/docs/index.js +18 -0
- package/cjs/dtos/action.dto.js +347 -0
- package/cjs/dtos/index.js +21 -0
- package/cjs/dtos/permission.dto.js +554 -0
- package/cjs/dtos/role.dto.js +238 -0
- package/cjs/entities/action-base.entity.js +135 -0
- package/cjs/entities/action.entity.js +28 -0
- package/cjs/entities/index.js +81 -0
- package/cjs/entities/permission-base.entity.js +156 -0
- package/cjs/entities/permission-with-company.entity.js +99 -0
- package/cjs/entities/role-base.entity.js +86 -0
- package/cjs/entities/role-with-company.entity.js +55 -0
- package/cjs/entities/role.entity.js +25 -0
- package/cjs/entities/user-iam-permission.entity.js +57 -0
- package/cjs/enums/action-type.enum.js +22 -0
- package/cjs/enums/index.js +19 -0
- package/cjs/enums/permission-type.enum.js +16 -0
- package/cjs/helpers/index.js +19 -0
- package/cjs/helpers/permission-evaluator.helper.js +175 -0
- package/cjs/helpers/permission-mode.helper.js +49 -0
- package/cjs/index.js +28 -79
- package/cjs/interfaces/action.interface.js +4 -0
- package/cjs/interfaces/iam-module-async-options.interface.js +4 -0
- package/cjs/interfaces/iam-module-options.interface.js +18 -0
- package/cjs/interfaces/index.js +21 -0
- package/cjs/interfaces/role.interface.js +7 -0
- package/cjs/modules/iam.module.js +237 -0
- package/cjs/modules/index.js +18 -0
- package/cjs/services/action.service.js +253 -0
- package/cjs/services/iam-config.service.js +107 -0
- package/cjs/services/iam-datasource.provider.js +205 -0
- package/cjs/services/index.js +23 -0
- package/cjs/services/permission-cache.service.js +308 -0
- package/cjs/services/permission.service.js +1020 -0
- package/cjs/services/role.service.js +181 -0
- package/cjs/types/index.js +18 -0
- package/cjs/types/logic-node.type.js +54 -0
- package/fesm/config/iam.constants.js +1 -0
- package/fesm/config/index.js +1 -0
- package/fesm/controllers/action.controller.js +107 -0
- package/fesm/controllers/company-action-permission.controller.js +100 -0
- package/fesm/controllers/index.js +7 -0
- package/fesm/controllers/my-permission.controller.js +80 -0
- package/fesm/controllers/role-permission.controller.js +150 -0
- package/fesm/controllers/role.controller.js +48 -0
- package/fesm/controllers/user-action-permission.controller.js +100 -0
- package/fesm/docs/iam-swagger.config.js +192 -0
- package/fesm/docs/index.js +1 -0
- package/fesm/dtos/action.dto.js +317 -0
- package/fesm/dtos/index.js +4 -0
- package/fesm/dtos/permission.dto.js +490 -0
- package/fesm/dtos/role.dto.js +214 -0
- package/fesm/entities/action-base.entity.js +128 -0
- package/fesm/entities/action.entity.js +18 -0
- package/fesm/entities/index.js +56 -0
- package/fesm/entities/permission-base.entity.js +138 -0
- package/fesm/entities/permission-with-company.entity.js +89 -0
- package/fesm/entities/role-base.entity.js +79 -0
- package/fesm/entities/role-with-company.entity.js +45 -0
- package/fesm/entities/role.entity.js +15 -0
- package/fesm/entities/user-iam-permission.entity.js +38 -0
- package/fesm/enums/action-type.enum.js +12 -0
- package/fesm/enums/index.js +2 -0
- package/fesm/enums/permission-type.enum.js +6 -0
- package/fesm/helpers/index.js +2 -0
- package/fesm/helpers/permission-evaluator.helper.js +165 -0
- package/fesm/helpers/permission-mode.helper.js +49 -0
- package/fesm/index.js +11 -79
- package/fesm/interfaces/action.interface.js +3 -0
- package/fesm/interfaces/iam-module-async-options.interface.js +3 -0
- package/fesm/interfaces/iam-module-options.interface.js +1 -0
- package/fesm/interfaces/index.js +4 -0
- package/fesm/interfaces/role.interface.js +4 -0
- package/fesm/modules/iam.module.js +227 -0
- package/fesm/modules/index.js +1 -0
- package/fesm/services/action.service.js +243 -0
- package/fesm/services/iam-config.service.js +97 -0
- package/fesm/services/iam-datasource.provider.js +154 -0
- package/fesm/services/index.js +6 -0
- package/fesm/services/permission-cache.service.js +298 -0
- package/fesm/services/permission.service.js +1010 -0
- package/fesm/services/role.service.js +171 -0
- package/fesm/types/index.js +1 -0
- package/fesm/types/logic-node.type.js +36 -0
- package/package.json +25 -25
- package/cjs/config-index.js +0 -1
- package/cjs/controllers-index.js +0 -1
- package/cjs/docs-index.js +0 -79
- package/cjs/dtos-index.js +0 -1
- package/cjs/entities-index.js +0 -1
- package/cjs/enums-index.js +0 -1
- package/cjs/helpers-index.js +0 -1
- package/cjs/interfaces-index.js +0 -1
- package/cjs/modules-index.js +0 -1
- package/cjs/services-index.js +0 -1
- package/cjs/types-index.js +0 -1
- package/fesm/config-index.js +0 -1
- package/fesm/controllers-index.js +0 -1
- package/fesm/docs-index.js +0 -79
- package/fesm/dtos-index.js +0 -1
- package/fesm/entities-index.js +0 -1
- package/fesm/enums-index.js +0 -1
- package/fesm/helpers-index.js +0 -1
- package/fesm/interfaces-index.js +0 -0
- package/fesm/modules-index.js +0 -1
- package/fesm/services-index.js +0 -1
- package/fesm/types-index.js +0 -1
|
@@ -0,0 +1,202 @@
|
|
|
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) {
|
|
21
|
+
const excludeSchemaProperties = enableCompanyFeature ? [] : [
|
|
22
|
+
// DTOs with companyId and branchId
|
|
23
|
+
{
|
|
24
|
+
schemaName: 'AssignUserActionsDto',
|
|
25
|
+
properties: [
|
|
26
|
+
'companyId',
|
|
27
|
+
'branchId'
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
schemaName: 'AssignUserRolesDto',
|
|
32
|
+
properties: [
|
|
33
|
+
'companyId',
|
|
34
|
+
'branchId'
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
schemaName: 'GetUserActionsDto',
|
|
39
|
+
properties: [
|
|
40
|
+
'companyId',
|
|
41
|
+
'branchId'
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
schemaName: 'GetUserRolesDto',
|
|
46
|
+
properties: [
|
|
47
|
+
'companyId',
|
|
48
|
+
'branchId'
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
// Response DTOs with branchId
|
|
52
|
+
{
|
|
53
|
+
schemaName: 'UserActionResponseDto',
|
|
54
|
+
properties: [
|
|
55
|
+
'branchId'
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
schemaName: 'UserRoleResponseDto',
|
|
60
|
+
properties: [
|
|
61
|
+
'branchId'
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
// Company-related DTOs (entire schemas hidden via tag exclusion, but just in case)
|
|
65
|
+
{
|
|
66
|
+
schemaName: 'AssignCompanyActionsDto',
|
|
67
|
+
properties: [
|
|
68
|
+
'companyId'
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
schemaName: 'CompanyActionResponseDto',
|
|
73
|
+
properties: [
|
|
74
|
+
'companyId'
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
// Hide query parameters for GET endpoints when company feature is disabled
|
|
79
|
+
const excludeQueryParameters = enableCompanyFeature ? [] : [
|
|
80
|
+
{
|
|
81
|
+
pathPattern: '/iam/permissions/user-actions/*',
|
|
82
|
+
method: 'get',
|
|
83
|
+
parameters: [
|
|
84
|
+
'companyId',
|
|
85
|
+
'branchId'
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
pathPattern: '/iam/permissions/user-roles/*',
|
|
90
|
+
method: 'get',
|
|
91
|
+
parameters: [
|
|
92
|
+
'companyId',
|
|
93
|
+
'branchId'
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
// Build exclude tags list: always exclude Auth tags + conditionally exclude based on permission mode
|
|
98
|
+
const excludeTags = [
|
|
99
|
+
...AUTH_RELATED_TAGS
|
|
100
|
+
];
|
|
101
|
+
// Hide company-related IAM endpoints when company feature is disabled
|
|
102
|
+
if (!enableCompanyFeature) {
|
|
103
|
+
excludeTags.push('IAM - Company Action Permissions');
|
|
104
|
+
}
|
|
105
|
+
// Conditionally exclude endpoints based on permission mode
|
|
106
|
+
if (permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC) {
|
|
107
|
+
// RBAC only - hide direct user action endpoints
|
|
108
|
+
excludeTags.push('IAM - Permissions (Direct)');
|
|
109
|
+
} else if (permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT) {
|
|
110
|
+
// Direct only - hide RBAC endpoints
|
|
111
|
+
excludeTags.push('IAM - Permissions (RBAC)');
|
|
112
|
+
excludeTags.push('IAM - Roles'); // Roles are only used in RBAC
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
title: 'IAM API',
|
|
116
|
+
description: `
|
|
117
|
+
## Identity & Access Management API
|
|
118
|
+
|
|
119
|
+
Advanced permission system with flexible modes: RBAC, Direct Permissions, or both.
|
|
120
|
+
|
|
121
|
+
### Current Configuration
|
|
122
|
+
- **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'}
|
|
123
|
+
|
|
124
|
+
### Features Based on Mode
|
|
125
|
+
|
|
126
|
+
${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `#### RBAC Features (Active)
|
|
127
|
+
- **Roles**: Create company-scoped roles${enableCompanyFeature ? ' (auto-filtered by user company)' : ''}
|
|
128
|
+
- **Role-Actions**: Assign actions to roles
|
|
129
|
+
- **User-Roles**: Assign roles to users${enableCompanyFeature ? ' at branch level' : ''}
|
|
130
|
+
` : ''}${permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `#### Direct Permission Features (Active)
|
|
131
|
+
- **User-Actions**: Direct action assignment to users${enableCompanyFeature ? ' at branch level' : ''}
|
|
132
|
+
` : ''}${enableCompanyFeature ? `#### Company Features (Active)
|
|
133
|
+
- **Company-Action Whitelist**: Control which actions are available per company
|
|
134
|
+
- **Branch-Based Scoping**: Permissions scoped to specific branches
|
|
135
|
+
- **Auto-Filtering**: Roles automatically filtered by user's company
|
|
136
|
+
- **Action Tree Filtering**: Available actions filtered by company whitelist
|
|
137
|
+
` : ''}
|
|
138
|
+
### Core Concepts
|
|
139
|
+
|
|
140
|
+
#### Actions
|
|
141
|
+
Represent permissions in the system. Can be hierarchical.
|
|
142
|
+
|
|
143
|
+
**Action Types:**
|
|
144
|
+
- \`menu\` - Menu visibility (actions with type='menu' are used as menus)
|
|
145
|
+
- \`endpoint\` - API endpoint access
|
|
146
|
+
- \`frontend\` - Frontend feature toggles
|
|
147
|
+
${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
|
|
148
|
+
#### Roles
|
|
149
|
+
Collections of actions that can be assigned to users.${enableCompanyFeature ? ' Scoped to companies.' : ' Global across the system.'}
|
|
150
|
+
` : ''}${enableCompanyFeature ? `
|
|
151
|
+
#### Company-Action Whitelist
|
|
152
|
+
Controls which actions are available to a company. Users/roles can only use whitelisted actions.
|
|
153
|
+
|
|
154
|
+
**Flow:**
|
|
155
|
+
1. Admin assigns actions to company (whitelist)
|
|
156
|
+
2. Only whitelisted actions appear in permission assignment UIs
|
|
157
|
+
3. Users/roles cannot be assigned non-whitelisted actions
|
|
158
|
+
` : ''}
|
|
159
|
+
### Permission Resolution
|
|
160
|
+
|
|
161
|
+
${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `1. **Company-Action Whitelist** - Filter by company (if enabled)
|
|
162
|
+
2. **UserAction (DENY)** - Explicit denials take precedence
|
|
163
|
+
3. **UserAction (GRANT)** - Direct user grants
|
|
164
|
+
4. **UserRole → RoleAction** - Inherited from assigned roles
|
|
165
|
+
5. **Action Permission Logic** - Complex AND/OR rules` : permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC ? `1. **Company-Action Whitelist** - Filter by company (if enabled)
|
|
166
|
+
2. **UserRole → RoleAction** - Actions inherited from roles
|
|
167
|
+
3. **Action Permission Logic** - Complex AND/OR rules` : `1. **Company-Action Whitelist** - Filter by company (if enabled)
|
|
168
|
+
2. **UserAction (DENY)** - Explicit denials take precedence
|
|
169
|
+
3. **UserAction (GRANT)** - Direct user grants
|
|
170
|
+
4. **Action Permission Logic** - Complex AND/OR rules`}
|
|
171
|
+
|
|
172
|
+
### API Endpoints Summary
|
|
173
|
+
|
|
174
|
+
#### Available Endpoints
|
|
175
|
+
- ✅ **Actions**: CRUD operations, tree view${enableCompanyFeature ? ', filtered tree for permissions' : ''}${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
|
|
176
|
+
- ✅ **Roles**: CRUD operations${enableCompanyFeature ? ' (auto-filtered by company)' : ''}
|
|
177
|
+
- ✅ **Role-Actions**: Assign actions to roles, get role actions
|
|
178
|
+
- ✅ **User-Roles**: Assign roles to users, get user roles` : `
|
|
179
|
+
- ❌ **Roles**: Disabled (RBAC mode not active)`}${permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
|
|
180
|
+
- ✅ **User-Actions**: Direct action assignment to users` : `
|
|
181
|
+
- ❌ **User-Actions**: Disabled (DIRECT mode not active)`}${enableCompanyFeature ? `
|
|
182
|
+
- ✅ **Company-Actions**: Whitelist actions for companies` : `
|
|
183
|
+
- ❌ **Company-Actions**: Disabled (company feature not enabled)`}
|
|
184
|
+
- ✅ **My Permissions**: Get current user's complete permissions (includes menu-type actions)
|
|
185
|
+
|
|
186
|
+
### Best Practices
|
|
187
|
+
|
|
188
|
+
1. **Action Codes**: Use meaningful codes like \`user.create\`, \`order.view\`
|
|
189
|
+
2. **Hierarchical Actions**: Group related actions (use parentId for hierarchy)${permissionMode === _permissiontypeenum.IAMPermissionMode.RBAC || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
|
|
190
|
+
3. **Role Design**: Create roles for common permission patterns` : ''}${permissionMode === _permissiontypeenum.IAMPermissionMode.DIRECT || permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? `
|
|
191
|
+
${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? '4' : '3'}. **Direct Actions**: Use sparingly for exceptions` : ''}${enableCompanyFeature ? `
|
|
192
|
+
${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? '5' : '4'}. **Company Whitelisting**: Set up action whitelist before assigning permissions
|
|
193
|
+
${permissionMode === _permissiontypeenum.IAMPermissionMode.FULL ? '6' : '5'}. **Branch Scoping**: Use branches for location-based access control` : ''}
|
|
194
|
+
`,
|
|
195
|
+
version: '1.0',
|
|
196
|
+
path: 'api/docs/iam',
|
|
197
|
+
bearerAuth: true,
|
|
198
|
+
excludeSchemaProperties,
|
|
199
|
+
excludeTags,
|
|
200
|
+
excludeQueryParameters
|
|
201
|
+
};
|
|
202
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
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 ActionQueryDto () {
|
|
13
|
+
return ActionQueryDto;
|
|
14
|
+
},
|
|
15
|
+
get ActionResponseDto () {
|
|
16
|
+
return ActionResponseDto;
|
|
17
|
+
},
|
|
18
|
+
get ActionTreeDto () {
|
|
19
|
+
return ActionTreeDto;
|
|
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 _swagger = require("@nestjs/swagger");
|
|
32
|
+
const _classvalidator = require("class-validator");
|
|
33
|
+
const _enums = require("../enums");
|
|
34
|
+
const _types = require("../types");
|
|
35
|
+
function _define_property(obj, key, value) {
|
|
36
|
+
if (key in obj) {
|
|
37
|
+
Object.defineProperty(obj, key, {
|
|
38
|
+
value: value,
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
obj[key] = value;
|
|
45
|
+
}
|
|
46
|
+
return obj;
|
|
47
|
+
}
|
|
48
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
49
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
50
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
51
|
+
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;
|
|
52
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
53
|
+
}
|
|
54
|
+
function _ts_metadata(k, v) {
|
|
55
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
56
|
+
}
|
|
57
|
+
let CreateActionDto = class CreateActionDto {
|
|
58
|
+
constructor(){
|
|
59
|
+
_define_property(this, "name", void 0);
|
|
60
|
+
_define_property(this, "description", void 0);
|
|
61
|
+
_define_property(this, "code", void 0);
|
|
62
|
+
_define_property(this, "actionType", void 0);
|
|
63
|
+
_define_property(this, "permissionLogic", void 0);
|
|
64
|
+
_define_property(this, "parentId", void 0);
|
|
65
|
+
_define_property(this, "serial", void 0);
|
|
66
|
+
_define_property(this, "isActive", void 0);
|
|
67
|
+
_define_property(this, "metadata", void 0);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
_ts_decorate([
|
|
71
|
+
(0, _swagger.ApiProperty)({
|
|
72
|
+
description: 'Action name',
|
|
73
|
+
example: 'View Users'
|
|
74
|
+
}),
|
|
75
|
+
(0, _classvalidator.IsString)(),
|
|
76
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
77
|
+
(0, _classvalidator.MaxLength)(255),
|
|
78
|
+
_ts_metadata("design:type", String)
|
|
79
|
+
], CreateActionDto.prototype, "name", void 0);
|
|
80
|
+
_ts_decorate([
|
|
81
|
+
(0, _swagger.ApiProperty)({
|
|
82
|
+
description: 'Action description',
|
|
83
|
+
example: 'Permission to view user list',
|
|
84
|
+
required: false
|
|
85
|
+
}),
|
|
86
|
+
(0, _classvalidator.IsString)(),
|
|
87
|
+
(0, _classvalidator.IsOptional)(),
|
|
88
|
+
(0, _classvalidator.MaxLength)(500),
|
|
89
|
+
_ts_metadata("design:type", String)
|
|
90
|
+
], CreateActionDto.prototype, "description", void 0);
|
|
91
|
+
_ts_decorate([
|
|
92
|
+
(0, _swagger.ApiProperty)({
|
|
93
|
+
description: 'Unique code for programmatic reference',
|
|
94
|
+
example: 'user.view',
|
|
95
|
+
required: false
|
|
96
|
+
}),
|
|
97
|
+
(0, _classvalidator.IsString)(),
|
|
98
|
+
(0, _classvalidator.IsOptional)(),
|
|
99
|
+
(0, _classvalidator.MaxLength)(255),
|
|
100
|
+
_ts_metadata("design:type", String)
|
|
101
|
+
], CreateActionDto.prototype, "code", void 0);
|
|
102
|
+
_ts_decorate([
|
|
103
|
+
(0, _swagger.ApiProperty)({
|
|
104
|
+
description: 'Action type (backend for API endpoints, frontend for UI features)',
|
|
105
|
+
enum: _enums.ActionType,
|
|
106
|
+
example: _enums.ActionType.BACKEND,
|
|
107
|
+
default: _enums.ActionType.BACKEND,
|
|
108
|
+
required: false
|
|
109
|
+
}),
|
|
110
|
+
(0, _classvalidator.IsEnum)(_enums.ActionType),
|
|
111
|
+
(0, _classvalidator.IsOptional)(),
|
|
112
|
+
_ts_metadata("design:type", typeof _enums.ActionType === "undefined" ? Object : _enums.ActionType)
|
|
113
|
+
], CreateActionDto.prototype, "actionType", void 0);
|
|
114
|
+
_ts_decorate([
|
|
115
|
+
(0, _swagger.ApiProperty)({
|
|
116
|
+
description: 'Permission logic (AND/OR rules)',
|
|
117
|
+
required: false
|
|
118
|
+
}),
|
|
119
|
+
(0, _classvalidator.IsOptional)(),
|
|
120
|
+
_ts_metadata("design:type", typeof _types.LogicNode === "undefined" ? Object : _types.LogicNode)
|
|
121
|
+
], CreateActionDto.prototype, "permissionLogic", void 0);
|
|
122
|
+
_ts_decorate([
|
|
123
|
+
(0, _swagger.ApiProperty)({
|
|
124
|
+
description: 'Parent action ID for hierarchy',
|
|
125
|
+
example: '123e4567-e89b-12d3-a456-426614174000',
|
|
126
|
+
required: false
|
|
127
|
+
}),
|
|
128
|
+
(0, _classvalidator.IsUUID)(),
|
|
129
|
+
(0, _classvalidator.IsOptional)(),
|
|
130
|
+
_ts_metadata("design:type", String)
|
|
131
|
+
], CreateActionDto.prototype, "parentId", void 0);
|
|
132
|
+
_ts_decorate([
|
|
133
|
+
(0, _swagger.ApiProperty)({
|
|
134
|
+
description: 'Display order',
|
|
135
|
+
required: false
|
|
136
|
+
}),
|
|
137
|
+
(0, _classvalidator.IsInt)(),
|
|
138
|
+
(0, _classvalidator.IsOptional)(),
|
|
139
|
+
_ts_metadata("design:type", Number)
|
|
140
|
+
], CreateActionDto.prototype, "serial", void 0);
|
|
141
|
+
_ts_decorate([
|
|
142
|
+
(0, _swagger.ApiProperty)({
|
|
143
|
+
description: 'Active status',
|
|
144
|
+
default: true,
|
|
145
|
+
required: false
|
|
146
|
+
}),
|
|
147
|
+
(0, _classvalidator.IsBoolean)(),
|
|
148
|
+
(0, _classvalidator.IsOptional)(),
|
|
149
|
+
_ts_metadata("design:type", Boolean)
|
|
150
|
+
], CreateActionDto.prototype, "isActive", void 0);
|
|
151
|
+
_ts_decorate([
|
|
152
|
+
(0, _swagger.ApiProperty)({
|
|
153
|
+
description: 'Additional metadata',
|
|
154
|
+
required: false
|
|
155
|
+
}),
|
|
156
|
+
(0, _classvalidator.IsOptional)(),
|
|
157
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
158
|
+
], CreateActionDto.prototype, "metadata", void 0);
|
|
159
|
+
let UpdateActionDto = class UpdateActionDto extends (0, _swagger.PartialType)(CreateActionDto) {
|
|
160
|
+
constructor(...args){
|
|
161
|
+
super(...args), _define_property(this, "id", void 0);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
_ts_decorate([
|
|
165
|
+
(0, _swagger.ApiProperty)({
|
|
166
|
+
description: 'Action ID',
|
|
167
|
+
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
168
|
+
}),
|
|
169
|
+
(0, _classvalidator.IsUUID)(),
|
|
170
|
+
(0, _classvalidator.IsNotEmpty)(),
|
|
171
|
+
_ts_metadata("design:type", String)
|
|
172
|
+
], UpdateActionDto.prototype, "id", void 0);
|
|
173
|
+
let ActionResponseDto = class ActionResponseDto {
|
|
174
|
+
constructor(){
|
|
175
|
+
_define_property(this, "id", void 0);
|
|
176
|
+
_define_property(this, "readOnly", void 0);
|
|
177
|
+
_define_property(this, "name", void 0);
|
|
178
|
+
_define_property(this, "description", void 0);
|
|
179
|
+
_define_property(this, "code", void 0);
|
|
180
|
+
_define_property(this, "actionType", void 0);
|
|
181
|
+
_define_property(this, "permissionLogic", void 0);
|
|
182
|
+
_define_property(this, "parentId", void 0);
|
|
183
|
+
_define_property(this, "serial", void 0);
|
|
184
|
+
_define_property(this, "isActive", void 0);
|
|
185
|
+
_define_property(this, "metadata", void 0);
|
|
186
|
+
_define_property(this, "createdAt", void 0);
|
|
187
|
+
_define_property(this, "updatedAt", void 0);
|
|
188
|
+
_define_property(this, "deletedAt", void 0);
|
|
189
|
+
_define_property(this, "createdById", void 0);
|
|
190
|
+
_define_property(this, "updatedById", void 0);
|
|
191
|
+
_define_property(this, "deletedById", void 0);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
_ts_decorate([
|
|
195
|
+
(0, _swagger.ApiProperty)(),
|
|
196
|
+
_ts_metadata("design:type", String)
|
|
197
|
+
], ActionResponseDto.prototype, "id", void 0);
|
|
198
|
+
_ts_decorate([
|
|
199
|
+
(0, _swagger.ApiProperty)(),
|
|
200
|
+
_ts_metadata("design:type", Boolean)
|
|
201
|
+
], ActionResponseDto.prototype, "readOnly", void 0);
|
|
202
|
+
_ts_decorate([
|
|
203
|
+
(0, _swagger.ApiProperty)(),
|
|
204
|
+
_ts_metadata("design:type", String)
|
|
205
|
+
], ActionResponseDto.prototype, "name", void 0);
|
|
206
|
+
_ts_decorate([
|
|
207
|
+
(0, _swagger.ApiProperty)(),
|
|
208
|
+
_ts_metadata("design:type", Object)
|
|
209
|
+
], ActionResponseDto.prototype, "description", void 0);
|
|
210
|
+
_ts_decorate([
|
|
211
|
+
(0, _swagger.ApiProperty)(),
|
|
212
|
+
_ts_metadata("design:type", Object)
|
|
213
|
+
], ActionResponseDto.prototype, "code", void 0);
|
|
214
|
+
_ts_decorate([
|
|
215
|
+
(0, _swagger.ApiProperty)({
|
|
216
|
+
enum: _enums.ActionType
|
|
217
|
+
}),
|
|
218
|
+
_ts_metadata("design:type", typeof _enums.ActionType === "undefined" ? Object : _enums.ActionType)
|
|
219
|
+
], ActionResponseDto.prototype, "actionType", void 0);
|
|
220
|
+
_ts_decorate([
|
|
221
|
+
(0, _swagger.ApiProperty)(),
|
|
222
|
+
_ts_metadata("design:type", Object)
|
|
223
|
+
], ActionResponseDto.prototype, "permissionLogic", void 0);
|
|
224
|
+
_ts_decorate([
|
|
225
|
+
(0, _swagger.ApiProperty)(),
|
|
226
|
+
_ts_metadata("design:type", Object)
|
|
227
|
+
], ActionResponseDto.prototype, "parentId", void 0);
|
|
228
|
+
_ts_decorate([
|
|
229
|
+
(0, _swagger.ApiProperty)(),
|
|
230
|
+
_ts_metadata("design:type", Object)
|
|
231
|
+
], ActionResponseDto.prototype, "serial", void 0);
|
|
232
|
+
_ts_decorate([
|
|
233
|
+
(0, _swagger.ApiProperty)(),
|
|
234
|
+
_ts_metadata("design:type", Boolean)
|
|
235
|
+
], ActionResponseDto.prototype, "isActive", void 0);
|
|
236
|
+
_ts_decorate([
|
|
237
|
+
(0, _swagger.ApiProperty)({
|
|
238
|
+
required: false
|
|
239
|
+
}),
|
|
240
|
+
_ts_metadata("design:type", Object)
|
|
241
|
+
], ActionResponseDto.prototype, "metadata", void 0);
|
|
242
|
+
_ts_decorate([
|
|
243
|
+
(0, _swagger.ApiProperty)(),
|
|
244
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
245
|
+
], ActionResponseDto.prototype, "createdAt", void 0);
|
|
246
|
+
_ts_decorate([
|
|
247
|
+
(0, _swagger.ApiProperty)(),
|
|
248
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
249
|
+
], ActionResponseDto.prototype, "updatedAt", void 0);
|
|
250
|
+
_ts_decorate([
|
|
251
|
+
(0, _swagger.ApiProperty)({
|
|
252
|
+
required: false
|
|
253
|
+
}),
|
|
254
|
+
_ts_metadata("design:type", Object)
|
|
255
|
+
], ActionResponseDto.prototype, "deletedAt", void 0);
|
|
256
|
+
_ts_decorate([
|
|
257
|
+
(0, _swagger.ApiProperty)({
|
|
258
|
+
required: false
|
|
259
|
+
}),
|
|
260
|
+
_ts_metadata("design:type", Object)
|
|
261
|
+
], ActionResponseDto.prototype, "createdById", void 0);
|
|
262
|
+
_ts_decorate([
|
|
263
|
+
(0, _swagger.ApiProperty)({
|
|
264
|
+
required: false
|
|
265
|
+
}),
|
|
266
|
+
_ts_metadata("design:type", Object)
|
|
267
|
+
], ActionResponseDto.prototype, "updatedById", void 0);
|
|
268
|
+
_ts_decorate([
|
|
269
|
+
(0, _swagger.ApiProperty)({
|
|
270
|
+
required: false
|
|
271
|
+
}),
|
|
272
|
+
_ts_metadata("design:type", Object)
|
|
273
|
+
], ActionResponseDto.prototype, "deletedById", void 0);
|
|
274
|
+
let ActionTreeDto = class ActionTreeDto extends ActionResponseDto {
|
|
275
|
+
constructor(...args){
|
|
276
|
+
super(...args), _define_property(this, "children", void 0);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
_ts_decorate([
|
|
280
|
+
(0, _swagger.ApiProperty)({
|
|
281
|
+
type: ()=>[
|
|
282
|
+
ActionTreeDto
|
|
283
|
+
]
|
|
284
|
+
}),
|
|
285
|
+
_ts_metadata("design:type", Array)
|
|
286
|
+
], ActionTreeDto.prototype, "children", void 0);
|
|
287
|
+
let ActionQueryDto = class ActionQueryDto {
|
|
288
|
+
constructor(){
|
|
289
|
+
_define_property(this, "isActive", void 0);
|
|
290
|
+
_define_property(this, "parentId", void 0);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
_ts_decorate([
|
|
294
|
+
(0, _swagger.ApiProperty)({
|
|
295
|
+
description: 'Filter by active status',
|
|
296
|
+
required: false
|
|
297
|
+
}),
|
|
298
|
+
(0, _classvalidator.IsBoolean)(),
|
|
299
|
+
(0, _classvalidator.IsOptional)(),
|
|
300
|
+
_ts_metadata("design:type", Boolean)
|
|
301
|
+
], ActionQueryDto.prototype, "isActive", void 0);
|
|
302
|
+
_ts_decorate([
|
|
303
|
+
(0, _swagger.ApiProperty)({
|
|
304
|
+
description: 'Filter by parent ID',
|
|
305
|
+
required: false
|
|
306
|
+
}),
|
|
307
|
+
(0, _classvalidator.IsUUID)(),
|
|
308
|
+
(0, _classvalidator.IsOptional)(),
|
|
309
|
+
_ts_metadata("design:type", String)
|
|
310
|
+
], ActionQueryDto.prototype, "parentId", void 0);
|
|
311
|
+
let ActionTreeQueryDto = class ActionTreeQueryDto {
|
|
312
|
+
constructor(){
|
|
313
|
+
_define_property(this, "search", void 0);
|
|
314
|
+
_define_property(this, "isActive", void 0);
|
|
315
|
+
_define_property(this, "withDeleted", void 0);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
_ts_decorate([
|
|
319
|
+
(0, _swagger.ApiProperty)({
|
|
320
|
+
description: 'Search by name or code',
|
|
321
|
+
example: 'user',
|
|
322
|
+
required: false
|
|
323
|
+
}),
|
|
324
|
+
(0, _classvalidator.IsString)(),
|
|
325
|
+
(0, _classvalidator.IsOptional)(),
|
|
326
|
+
_ts_metadata("design:type", String)
|
|
327
|
+
], ActionTreeQueryDto.prototype, "search", void 0);
|
|
328
|
+
_ts_decorate([
|
|
329
|
+
(0, _swagger.ApiProperty)({
|
|
330
|
+
description: 'Filter by active status',
|
|
331
|
+
example: true,
|
|
332
|
+
required: false
|
|
333
|
+
}),
|
|
334
|
+
(0, _classvalidator.IsBoolean)(),
|
|
335
|
+
(0, _classvalidator.IsOptional)(),
|
|
336
|
+
_ts_metadata("design:type", Boolean)
|
|
337
|
+
], ActionTreeQueryDto.prototype, "isActive", void 0);
|
|
338
|
+
_ts_decorate([
|
|
339
|
+
(0, _swagger.ApiProperty)({
|
|
340
|
+
description: 'Include deleted actions',
|
|
341
|
+
default: false,
|
|
342
|
+
required: false
|
|
343
|
+
}),
|
|
344
|
+
(0, _classvalidator.IsBoolean)(),
|
|
345
|
+
(0, _classvalidator.IsOptional)(),
|
|
346
|
+
_ts_metadata("design:type", Boolean)
|
|
347
|
+
], ActionTreeQueryDto.prototype, "withDeleted", void 0);
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|