@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,317 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
15
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
+
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;
|
|
18
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
+
}
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
21
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
22
|
+
}
|
|
23
|
+
import { ApiProperty, PartialType } from '@nestjs/swagger';
|
|
24
|
+
import { IsBoolean, IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
|
|
25
|
+
import { ActionType } from '../enums';
|
|
26
|
+
import { LogicNode } from '../types';
|
|
27
|
+
export class CreateActionDto {
|
|
28
|
+
constructor(){
|
|
29
|
+
_define_property(this, "name", void 0);
|
|
30
|
+
_define_property(this, "description", void 0);
|
|
31
|
+
_define_property(this, "code", void 0);
|
|
32
|
+
_define_property(this, "actionType", void 0);
|
|
33
|
+
_define_property(this, "permissionLogic", void 0);
|
|
34
|
+
_define_property(this, "parentId", void 0);
|
|
35
|
+
_define_property(this, "serial", void 0);
|
|
36
|
+
_define_property(this, "isActive", void 0);
|
|
37
|
+
_define_property(this, "metadata", void 0);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
_ts_decorate([
|
|
41
|
+
ApiProperty({
|
|
42
|
+
description: 'Action name',
|
|
43
|
+
example: 'View Users'
|
|
44
|
+
}),
|
|
45
|
+
IsString(),
|
|
46
|
+
IsNotEmpty(),
|
|
47
|
+
MaxLength(255),
|
|
48
|
+
_ts_metadata("design:type", String)
|
|
49
|
+
], CreateActionDto.prototype, "name", void 0);
|
|
50
|
+
_ts_decorate([
|
|
51
|
+
ApiProperty({
|
|
52
|
+
description: 'Action description',
|
|
53
|
+
example: 'Permission to view user list',
|
|
54
|
+
required: false
|
|
55
|
+
}),
|
|
56
|
+
IsString(),
|
|
57
|
+
IsOptional(),
|
|
58
|
+
MaxLength(500),
|
|
59
|
+
_ts_metadata("design:type", String)
|
|
60
|
+
], CreateActionDto.prototype, "description", void 0);
|
|
61
|
+
_ts_decorate([
|
|
62
|
+
ApiProperty({
|
|
63
|
+
description: 'Unique code for programmatic reference',
|
|
64
|
+
example: 'user.view',
|
|
65
|
+
required: false
|
|
66
|
+
}),
|
|
67
|
+
IsString(),
|
|
68
|
+
IsOptional(),
|
|
69
|
+
MaxLength(255),
|
|
70
|
+
_ts_metadata("design:type", String)
|
|
71
|
+
], CreateActionDto.prototype, "code", void 0);
|
|
72
|
+
_ts_decorate([
|
|
73
|
+
ApiProperty({
|
|
74
|
+
description: 'Action type (backend for API endpoints, frontend for UI features)',
|
|
75
|
+
enum: ActionType,
|
|
76
|
+
example: ActionType.BACKEND,
|
|
77
|
+
default: ActionType.BACKEND,
|
|
78
|
+
required: false
|
|
79
|
+
}),
|
|
80
|
+
IsEnum(ActionType),
|
|
81
|
+
IsOptional(),
|
|
82
|
+
_ts_metadata("design:type", typeof ActionType === "undefined" ? Object : ActionType)
|
|
83
|
+
], CreateActionDto.prototype, "actionType", void 0);
|
|
84
|
+
_ts_decorate([
|
|
85
|
+
ApiProperty({
|
|
86
|
+
description: 'Permission logic (AND/OR rules)',
|
|
87
|
+
required: false
|
|
88
|
+
}),
|
|
89
|
+
IsOptional(),
|
|
90
|
+
_ts_metadata("design:type", typeof LogicNode === "undefined" ? Object : LogicNode)
|
|
91
|
+
], CreateActionDto.prototype, "permissionLogic", void 0);
|
|
92
|
+
_ts_decorate([
|
|
93
|
+
ApiProperty({
|
|
94
|
+
description: 'Parent action ID for hierarchy',
|
|
95
|
+
example: '123e4567-e89b-12d3-a456-426614174000',
|
|
96
|
+
required: false
|
|
97
|
+
}),
|
|
98
|
+
IsUUID(),
|
|
99
|
+
IsOptional(),
|
|
100
|
+
_ts_metadata("design:type", String)
|
|
101
|
+
], CreateActionDto.prototype, "parentId", void 0);
|
|
102
|
+
_ts_decorate([
|
|
103
|
+
ApiProperty({
|
|
104
|
+
description: 'Display order',
|
|
105
|
+
required: false
|
|
106
|
+
}),
|
|
107
|
+
IsInt(),
|
|
108
|
+
IsOptional(),
|
|
109
|
+
_ts_metadata("design:type", Number)
|
|
110
|
+
], CreateActionDto.prototype, "serial", void 0);
|
|
111
|
+
_ts_decorate([
|
|
112
|
+
ApiProperty({
|
|
113
|
+
description: 'Active status',
|
|
114
|
+
default: true,
|
|
115
|
+
required: false
|
|
116
|
+
}),
|
|
117
|
+
IsBoolean(),
|
|
118
|
+
IsOptional(),
|
|
119
|
+
_ts_metadata("design:type", Boolean)
|
|
120
|
+
], 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
|
+
export class UpdateActionDto extends PartialType(CreateActionDto) {
|
|
130
|
+
constructor(...args){
|
|
131
|
+
super(...args), _define_property(this, "id", void 0);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
_ts_decorate([
|
|
135
|
+
ApiProperty({
|
|
136
|
+
description: 'Action ID',
|
|
137
|
+
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
138
|
+
}),
|
|
139
|
+
IsUUID(),
|
|
140
|
+
IsNotEmpty(),
|
|
141
|
+
_ts_metadata("design:type", String)
|
|
142
|
+
], UpdateActionDto.prototype, "id", void 0);
|
|
143
|
+
export class ActionResponseDto {
|
|
144
|
+
constructor(){
|
|
145
|
+
_define_property(this, "id", void 0);
|
|
146
|
+
_define_property(this, "readOnly", void 0);
|
|
147
|
+
_define_property(this, "name", void 0);
|
|
148
|
+
_define_property(this, "description", void 0);
|
|
149
|
+
_define_property(this, "code", void 0);
|
|
150
|
+
_define_property(this, "actionType", void 0);
|
|
151
|
+
_define_property(this, "permissionLogic", void 0);
|
|
152
|
+
_define_property(this, "parentId", void 0);
|
|
153
|
+
_define_property(this, "serial", void 0);
|
|
154
|
+
_define_property(this, "isActive", void 0);
|
|
155
|
+
_define_property(this, "metadata", void 0);
|
|
156
|
+
_define_property(this, "createdAt", void 0);
|
|
157
|
+
_define_property(this, "updatedAt", void 0);
|
|
158
|
+
_define_property(this, "deletedAt", void 0);
|
|
159
|
+
_define_property(this, "createdById", void 0);
|
|
160
|
+
_define_property(this, "updatedById", void 0);
|
|
161
|
+
_define_property(this, "deletedById", void 0);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
_ts_decorate([
|
|
165
|
+
ApiProperty(),
|
|
166
|
+
_ts_metadata("design:type", String)
|
|
167
|
+
], ActionResponseDto.prototype, "id", void 0);
|
|
168
|
+
_ts_decorate([
|
|
169
|
+
ApiProperty(),
|
|
170
|
+
_ts_metadata("design:type", Boolean)
|
|
171
|
+
], ActionResponseDto.prototype, "readOnly", void 0);
|
|
172
|
+
_ts_decorate([
|
|
173
|
+
ApiProperty(),
|
|
174
|
+
_ts_metadata("design:type", String)
|
|
175
|
+
], ActionResponseDto.prototype, "name", void 0);
|
|
176
|
+
_ts_decorate([
|
|
177
|
+
ApiProperty(),
|
|
178
|
+
_ts_metadata("design:type", Object)
|
|
179
|
+
], ActionResponseDto.prototype, "description", void 0);
|
|
180
|
+
_ts_decorate([
|
|
181
|
+
ApiProperty(),
|
|
182
|
+
_ts_metadata("design:type", Object)
|
|
183
|
+
], ActionResponseDto.prototype, "code", void 0);
|
|
184
|
+
_ts_decorate([
|
|
185
|
+
ApiProperty({
|
|
186
|
+
enum: ActionType
|
|
187
|
+
}),
|
|
188
|
+
_ts_metadata("design:type", typeof ActionType === "undefined" ? Object : ActionType)
|
|
189
|
+
], ActionResponseDto.prototype, "actionType", void 0);
|
|
190
|
+
_ts_decorate([
|
|
191
|
+
ApiProperty(),
|
|
192
|
+
_ts_metadata("design:type", Object)
|
|
193
|
+
], ActionResponseDto.prototype, "permissionLogic", void 0);
|
|
194
|
+
_ts_decorate([
|
|
195
|
+
ApiProperty(),
|
|
196
|
+
_ts_metadata("design:type", Object)
|
|
197
|
+
], ActionResponseDto.prototype, "parentId", void 0);
|
|
198
|
+
_ts_decorate([
|
|
199
|
+
ApiProperty(),
|
|
200
|
+
_ts_metadata("design:type", Object)
|
|
201
|
+
], ActionResponseDto.prototype, "serial", void 0);
|
|
202
|
+
_ts_decorate([
|
|
203
|
+
ApiProperty(),
|
|
204
|
+
_ts_metadata("design:type", Boolean)
|
|
205
|
+
], 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
|
+
_ts_decorate([
|
|
213
|
+
ApiProperty(),
|
|
214
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
215
|
+
], ActionResponseDto.prototype, "createdAt", void 0);
|
|
216
|
+
_ts_decorate([
|
|
217
|
+
ApiProperty(),
|
|
218
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
219
|
+
], ActionResponseDto.prototype, "updatedAt", void 0);
|
|
220
|
+
_ts_decorate([
|
|
221
|
+
ApiProperty({
|
|
222
|
+
required: false
|
|
223
|
+
}),
|
|
224
|
+
_ts_metadata("design:type", Object)
|
|
225
|
+
], ActionResponseDto.prototype, "deletedAt", void 0);
|
|
226
|
+
_ts_decorate([
|
|
227
|
+
ApiProperty({
|
|
228
|
+
required: false
|
|
229
|
+
}),
|
|
230
|
+
_ts_metadata("design:type", Object)
|
|
231
|
+
], ActionResponseDto.prototype, "createdById", void 0);
|
|
232
|
+
_ts_decorate([
|
|
233
|
+
ApiProperty({
|
|
234
|
+
required: false
|
|
235
|
+
}),
|
|
236
|
+
_ts_metadata("design:type", Object)
|
|
237
|
+
], ActionResponseDto.prototype, "updatedById", void 0);
|
|
238
|
+
_ts_decorate([
|
|
239
|
+
ApiProperty({
|
|
240
|
+
required: false
|
|
241
|
+
}),
|
|
242
|
+
_ts_metadata("design:type", Object)
|
|
243
|
+
], ActionResponseDto.prototype, "deletedById", void 0);
|
|
244
|
+
export class ActionTreeDto extends ActionResponseDto {
|
|
245
|
+
constructor(...args){
|
|
246
|
+
super(...args), _define_property(this, "children", void 0);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
_ts_decorate([
|
|
250
|
+
ApiProperty({
|
|
251
|
+
type: ()=>[
|
|
252
|
+
ActionTreeDto
|
|
253
|
+
]
|
|
254
|
+
}),
|
|
255
|
+
_ts_metadata("design:type", Array)
|
|
256
|
+
], ActionTreeDto.prototype, "children", void 0);
|
|
257
|
+
export class ActionQueryDto {
|
|
258
|
+
constructor(){
|
|
259
|
+
_define_property(this, "isActive", void 0);
|
|
260
|
+
_define_property(this, "parentId", void 0);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
_ts_decorate([
|
|
264
|
+
ApiProperty({
|
|
265
|
+
description: 'Filter by active status',
|
|
266
|
+
required: false
|
|
267
|
+
}),
|
|
268
|
+
IsBoolean(),
|
|
269
|
+
IsOptional(),
|
|
270
|
+
_ts_metadata("design:type", Boolean)
|
|
271
|
+
], ActionQueryDto.prototype, "isActive", void 0);
|
|
272
|
+
_ts_decorate([
|
|
273
|
+
ApiProperty({
|
|
274
|
+
description: 'Filter by parent ID',
|
|
275
|
+
required: false
|
|
276
|
+
}),
|
|
277
|
+
IsUUID(),
|
|
278
|
+
IsOptional(),
|
|
279
|
+
_ts_metadata("design:type", String)
|
|
280
|
+
], ActionQueryDto.prototype, "parentId", void 0);
|
|
281
|
+
export class ActionTreeQueryDto {
|
|
282
|
+
constructor(){
|
|
283
|
+
_define_property(this, "search", void 0);
|
|
284
|
+
_define_property(this, "isActive", void 0);
|
|
285
|
+
_define_property(this, "withDeleted", void 0);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
_ts_decorate([
|
|
289
|
+
ApiProperty({
|
|
290
|
+
description: 'Search by name or code',
|
|
291
|
+
example: 'user',
|
|
292
|
+
required: false
|
|
293
|
+
}),
|
|
294
|
+
IsString(),
|
|
295
|
+
IsOptional(),
|
|
296
|
+
_ts_metadata("design:type", String)
|
|
297
|
+
], ActionTreeQueryDto.prototype, "search", void 0);
|
|
298
|
+
_ts_decorate([
|
|
299
|
+
ApiProperty({
|
|
300
|
+
description: 'Filter by active status',
|
|
301
|
+
example: true,
|
|
302
|
+
required: false
|
|
303
|
+
}),
|
|
304
|
+
IsBoolean(),
|
|
305
|
+
IsOptional(),
|
|
306
|
+
_ts_metadata("design:type", Boolean)
|
|
307
|
+
], ActionTreeQueryDto.prototype, "isActive", void 0);
|
|
308
|
+
_ts_decorate([
|
|
309
|
+
ApiProperty({
|
|
310
|
+
description: 'Include deleted actions',
|
|
311
|
+
default: false,
|
|
312
|
+
required: false
|
|
313
|
+
}),
|
|
314
|
+
IsBoolean(),
|
|
315
|
+
IsOptional(),
|
|
316
|
+
_ts_metadata("design:type", Boolean)
|
|
317
|
+
], ActionTreeQueryDto.prototype, "withDeleted", void 0);
|