@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,490 @@
|
|
|
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, ApiPropertyOptional } from '@nestjs/swagger';
|
|
24
|
+
import { Type } from 'class-transformer';
|
|
25
|
+
import { IsArray, IsEnum, IsOptional, IsString, IsUUID, ValidateNested } from 'class-validator';
|
|
26
|
+
export var PermissionAction = /*#__PURE__*/ function(PermissionAction) {
|
|
27
|
+
PermissionAction["ADD"] = "add";
|
|
28
|
+
PermissionAction["REMOVE"] = "remove";
|
|
29
|
+
return PermissionAction;
|
|
30
|
+
}({});
|
|
31
|
+
export class PermissionItemDto {
|
|
32
|
+
constructor(){
|
|
33
|
+
_define_property(this, "id", void 0);
|
|
34
|
+
_define_property(this, "action", void 0);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
_ts_decorate([
|
|
38
|
+
ApiProperty({
|
|
39
|
+
description: 'ID of the target (action or role)'
|
|
40
|
+
}),
|
|
41
|
+
IsUUID(),
|
|
42
|
+
_ts_metadata("design:type", String)
|
|
43
|
+
], PermissionItemDto.prototype, "id", void 0);
|
|
44
|
+
_ts_decorate([
|
|
45
|
+
ApiProperty({
|
|
46
|
+
description: 'Action to perform',
|
|
47
|
+
enum: PermissionAction,
|
|
48
|
+
example: "add"
|
|
49
|
+
}),
|
|
50
|
+
IsEnum(PermissionAction),
|
|
51
|
+
_ts_metadata("design:type", String)
|
|
52
|
+
], PermissionItemDto.prototype, "action", void 0);
|
|
53
|
+
export class AssignUserActionsDto {
|
|
54
|
+
constructor(){
|
|
55
|
+
_define_property(this, "userId", void 0);
|
|
56
|
+
_define_property(this, "companyId", void 0);
|
|
57
|
+
_define_property(this, "branchId", void 0);
|
|
58
|
+
_define_property(this, "items", void 0);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
_ts_decorate([
|
|
62
|
+
ApiProperty({
|
|
63
|
+
description: 'User ID'
|
|
64
|
+
}),
|
|
65
|
+
IsUUID(),
|
|
66
|
+
_ts_metadata("design:type", String)
|
|
67
|
+
], AssignUserActionsDto.prototype, "userId", void 0);
|
|
68
|
+
_ts_decorate([
|
|
69
|
+
ApiPropertyOptional({
|
|
70
|
+
description: 'Company ID (for company-wide or branch-specific assignments)'
|
|
71
|
+
}),
|
|
72
|
+
IsUUID(),
|
|
73
|
+
IsOptional(),
|
|
74
|
+
_ts_metadata("design:type", String)
|
|
75
|
+
], AssignUserActionsDto.prototype, "companyId", void 0);
|
|
76
|
+
_ts_decorate([
|
|
77
|
+
ApiPropertyOptional({
|
|
78
|
+
description: 'Branch ID (null = company-wide, set = branch-specific)'
|
|
79
|
+
}),
|
|
80
|
+
IsUUID(),
|
|
81
|
+
IsOptional(),
|
|
82
|
+
_ts_metadata("design:type", String)
|
|
83
|
+
], AssignUserActionsDto.prototype, "branchId", void 0);
|
|
84
|
+
_ts_decorate([
|
|
85
|
+
ApiProperty({
|
|
86
|
+
description: 'Array of actions to assign/remove',
|
|
87
|
+
type: [
|
|
88
|
+
PermissionItemDto
|
|
89
|
+
]
|
|
90
|
+
}),
|
|
91
|
+
IsArray(),
|
|
92
|
+
ValidateNested({
|
|
93
|
+
each: true
|
|
94
|
+
}),
|
|
95
|
+
Type(()=>PermissionItemDto),
|
|
96
|
+
_ts_metadata("design:type", Array)
|
|
97
|
+
], AssignUserActionsDto.prototype, "items", void 0);
|
|
98
|
+
export class AssignCompanyActionsDto {
|
|
99
|
+
constructor(){
|
|
100
|
+
_define_property(this, "companyId", void 0);
|
|
101
|
+
_define_property(this, "items", void 0);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
_ts_decorate([
|
|
105
|
+
ApiProperty({
|
|
106
|
+
description: 'Company ID'
|
|
107
|
+
}),
|
|
108
|
+
IsUUID(),
|
|
109
|
+
_ts_metadata("design:type", String)
|
|
110
|
+
], AssignCompanyActionsDto.prototype, "companyId", void 0);
|
|
111
|
+
_ts_decorate([
|
|
112
|
+
ApiProperty({
|
|
113
|
+
description: 'Array of actions to assign/remove to company (whitelist)',
|
|
114
|
+
type: [
|
|
115
|
+
PermissionItemDto
|
|
116
|
+
]
|
|
117
|
+
}),
|
|
118
|
+
IsArray(),
|
|
119
|
+
ValidateNested({
|
|
120
|
+
each: true
|
|
121
|
+
}),
|
|
122
|
+
Type(()=>PermissionItemDto),
|
|
123
|
+
_ts_metadata("design:type", Array)
|
|
124
|
+
], AssignCompanyActionsDto.prototype, "items", void 0);
|
|
125
|
+
export class AssignRoleActionsDto {
|
|
126
|
+
constructor(){
|
|
127
|
+
_define_property(this, "roleId", void 0);
|
|
128
|
+
_define_property(this, "items", void 0);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
_ts_decorate([
|
|
132
|
+
ApiProperty({
|
|
133
|
+
description: 'Role ID'
|
|
134
|
+
}),
|
|
135
|
+
IsUUID(),
|
|
136
|
+
_ts_metadata("design:type", String)
|
|
137
|
+
], AssignRoleActionsDto.prototype, "roleId", void 0);
|
|
138
|
+
_ts_decorate([
|
|
139
|
+
ApiProperty({
|
|
140
|
+
description: 'Array of actions to assign/remove',
|
|
141
|
+
type: [
|
|
142
|
+
PermissionItemDto
|
|
143
|
+
]
|
|
144
|
+
}),
|
|
145
|
+
IsArray(),
|
|
146
|
+
ValidateNested({
|
|
147
|
+
each: true
|
|
148
|
+
}),
|
|
149
|
+
Type(()=>PermissionItemDto),
|
|
150
|
+
_ts_metadata("design:type", Array)
|
|
151
|
+
], AssignRoleActionsDto.prototype, "items", void 0);
|
|
152
|
+
export class AssignUserRolesDto {
|
|
153
|
+
constructor(){
|
|
154
|
+
_define_property(this, "userId", void 0);
|
|
155
|
+
_define_property(this, "companyId", void 0);
|
|
156
|
+
_define_property(this, "branchId", void 0);
|
|
157
|
+
_define_property(this, "items", void 0);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
_ts_decorate([
|
|
161
|
+
ApiProperty({
|
|
162
|
+
description: 'User ID'
|
|
163
|
+
}),
|
|
164
|
+
IsUUID(),
|
|
165
|
+
_ts_metadata("design:type", String)
|
|
166
|
+
], AssignUserRolesDto.prototype, "userId", void 0);
|
|
167
|
+
_ts_decorate([
|
|
168
|
+
ApiPropertyOptional({
|
|
169
|
+
description: 'Company ID (for company-wide or branch-specific assignments)'
|
|
170
|
+
}),
|
|
171
|
+
IsUUID(),
|
|
172
|
+
IsOptional(),
|
|
173
|
+
_ts_metadata("design:type", String)
|
|
174
|
+
], AssignUserRolesDto.prototype, "companyId", void 0);
|
|
175
|
+
_ts_decorate([
|
|
176
|
+
ApiPropertyOptional({
|
|
177
|
+
description: 'Branch ID (null = company-wide, set = branch-specific)'
|
|
178
|
+
}),
|
|
179
|
+
IsUUID(),
|
|
180
|
+
IsOptional(),
|
|
181
|
+
_ts_metadata("design:type", String)
|
|
182
|
+
], AssignUserRolesDto.prototype, "branchId", void 0);
|
|
183
|
+
_ts_decorate([
|
|
184
|
+
ApiProperty({
|
|
185
|
+
description: 'Array of roles to assign/remove',
|
|
186
|
+
type: [
|
|
187
|
+
PermissionItemDto
|
|
188
|
+
]
|
|
189
|
+
}),
|
|
190
|
+
IsArray(),
|
|
191
|
+
ValidateNested({
|
|
192
|
+
each: true
|
|
193
|
+
}),
|
|
194
|
+
Type(()=>PermissionItemDto),
|
|
195
|
+
_ts_metadata("design:type", Array)
|
|
196
|
+
], AssignUserRolesDto.prototype, "items", void 0);
|
|
197
|
+
export class GetUserActionsDto {
|
|
198
|
+
constructor(){
|
|
199
|
+
_define_property(this, "companyId", void 0);
|
|
200
|
+
_define_property(this, "branchId", void 0);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
_ts_decorate([
|
|
204
|
+
ApiPropertyOptional({
|
|
205
|
+
description: 'Company ID (ignored when enableCompanyFeature is false)'
|
|
206
|
+
}),
|
|
207
|
+
IsUUID(),
|
|
208
|
+
IsOptional(),
|
|
209
|
+
_ts_metadata("design:type", String)
|
|
210
|
+
], GetUserActionsDto.prototype, "companyId", void 0);
|
|
211
|
+
_ts_decorate([
|
|
212
|
+
ApiPropertyOptional({
|
|
213
|
+
description: 'Branch ID to filter by branch (ignored when enableCompanyFeature is false)'
|
|
214
|
+
}),
|
|
215
|
+
IsUUID(),
|
|
216
|
+
IsOptional(),
|
|
217
|
+
_ts_metadata("design:type", String)
|
|
218
|
+
], GetUserActionsDto.prototype, "branchId", void 0);
|
|
219
|
+
// No query parameters needed for GetRoleActions
|
|
220
|
+
export class GetRoleActionsDto {
|
|
221
|
+
}
|
|
222
|
+
// No query parameters needed for GetCompanyActions
|
|
223
|
+
export class GetCompanyActionsDto {
|
|
224
|
+
}
|
|
225
|
+
export class GetUserRolesDto {
|
|
226
|
+
constructor(){
|
|
227
|
+
_define_property(this, "companyId", void 0);
|
|
228
|
+
_define_property(this, "branchId", void 0);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
_ts_decorate([
|
|
232
|
+
ApiPropertyOptional({
|
|
233
|
+
description: 'Company ID (ignored when enableCompanyFeature is false)'
|
|
234
|
+
}),
|
|
235
|
+
IsUUID(),
|
|
236
|
+
IsOptional(),
|
|
237
|
+
_ts_metadata("design:type", String)
|
|
238
|
+
], GetUserRolesDto.prototype, "companyId", void 0);
|
|
239
|
+
_ts_decorate([
|
|
240
|
+
ApiPropertyOptional({
|
|
241
|
+
description: 'Branch ID to filter by branch (ignored when enableCompanyFeature is false)'
|
|
242
|
+
}),
|
|
243
|
+
IsUUID(),
|
|
244
|
+
IsOptional(),
|
|
245
|
+
_ts_metadata("design:type", String)
|
|
246
|
+
], GetUserRolesDto.prototype, "branchId", void 0);
|
|
247
|
+
export class UserActionResponseDto {
|
|
248
|
+
constructor(){
|
|
249
|
+
_define_property(this, "id", void 0);
|
|
250
|
+
_define_property(this, "userId", void 0);
|
|
251
|
+
_define_property(this, "actionId", void 0);
|
|
252
|
+
_define_property(this, "actionCode", void 0);
|
|
253
|
+
_define_property(this, "actionName", void 0);
|
|
254
|
+
_define_property(this, "branchId", void 0);
|
|
255
|
+
_define_property(this, "createdAt", void 0);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
_ts_decorate([
|
|
259
|
+
ApiProperty(),
|
|
260
|
+
_ts_metadata("design:type", String)
|
|
261
|
+
], UserActionResponseDto.prototype, "id", void 0);
|
|
262
|
+
_ts_decorate([
|
|
263
|
+
ApiProperty(),
|
|
264
|
+
_ts_metadata("design:type", String)
|
|
265
|
+
], UserActionResponseDto.prototype, "userId", void 0);
|
|
266
|
+
_ts_decorate([
|
|
267
|
+
ApiProperty(),
|
|
268
|
+
_ts_metadata("design:type", String)
|
|
269
|
+
], UserActionResponseDto.prototype, "actionId", void 0);
|
|
270
|
+
_ts_decorate([
|
|
271
|
+
ApiProperty(),
|
|
272
|
+
_ts_metadata("design:type", String)
|
|
273
|
+
], UserActionResponseDto.prototype, "actionCode", void 0);
|
|
274
|
+
_ts_decorate([
|
|
275
|
+
ApiProperty(),
|
|
276
|
+
_ts_metadata("design:type", String)
|
|
277
|
+
], UserActionResponseDto.prototype, "actionName", void 0);
|
|
278
|
+
_ts_decorate([
|
|
279
|
+
ApiPropertyOptional(),
|
|
280
|
+
_ts_metadata("design:type", Object)
|
|
281
|
+
], UserActionResponseDto.prototype, "branchId", void 0);
|
|
282
|
+
_ts_decorate([
|
|
283
|
+
ApiProperty(),
|
|
284
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
285
|
+
], UserActionResponseDto.prototype, "createdAt", void 0);
|
|
286
|
+
export class RoleActionResponseDto {
|
|
287
|
+
constructor(){
|
|
288
|
+
_define_property(this, "id", void 0);
|
|
289
|
+
_define_property(this, "roleId", void 0);
|
|
290
|
+
_define_property(this, "actionId", void 0);
|
|
291
|
+
_define_property(this, "actionCode", void 0);
|
|
292
|
+
_define_property(this, "actionName", void 0);
|
|
293
|
+
_define_property(this, "createdAt", void 0);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
_ts_decorate([
|
|
297
|
+
ApiProperty(),
|
|
298
|
+
_ts_metadata("design:type", String)
|
|
299
|
+
], RoleActionResponseDto.prototype, "id", void 0);
|
|
300
|
+
_ts_decorate([
|
|
301
|
+
ApiProperty(),
|
|
302
|
+
_ts_metadata("design:type", String)
|
|
303
|
+
], RoleActionResponseDto.prototype, "roleId", void 0);
|
|
304
|
+
_ts_decorate([
|
|
305
|
+
ApiProperty(),
|
|
306
|
+
_ts_metadata("design:type", String)
|
|
307
|
+
], RoleActionResponseDto.prototype, "actionId", void 0);
|
|
308
|
+
_ts_decorate([
|
|
309
|
+
ApiProperty(),
|
|
310
|
+
_ts_metadata("design:type", String)
|
|
311
|
+
], RoleActionResponseDto.prototype, "actionCode", void 0);
|
|
312
|
+
_ts_decorate([
|
|
313
|
+
ApiProperty(),
|
|
314
|
+
_ts_metadata("design:type", String)
|
|
315
|
+
], RoleActionResponseDto.prototype, "actionName", void 0);
|
|
316
|
+
_ts_decorate([
|
|
317
|
+
ApiProperty(),
|
|
318
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
319
|
+
], RoleActionResponseDto.prototype, "createdAt", void 0);
|
|
320
|
+
export class CompanyActionResponseDto {
|
|
321
|
+
constructor(){
|
|
322
|
+
_define_property(this, "id", void 0);
|
|
323
|
+
_define_property(this, "companyId", void 0);
|
|
324
|
+
_define_property(this, "actionId", void 0);
|
|
325
|
+
_define_property(this, "actionCode", void 0);
|
|
326
|
+
_define_property(this, "actionName", void 0);
|
|
327
|
+
_define_property(this, "createdAt", void 0);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
_ts_decorate([
|
|
331
|
+
ApiProperty({
|
|
332
|
+
description: 'Permission ID'
|
|
333
|
+
}),
|
|
334
|
+
_ts_metadata("design:type", String)
|
|
335
|
+
], CompanyActionResponseDto.prototype, "id", void 0);
|
|
336
|
+
_ts_decorate([
|
|
337
|
+
ApiProperty({
|
|
338
|
+
description: 'Company ID'
|
|
339
|
+
}),
|
|
340
|
+
_ts_metadata("design:type", String)
|
|
341
|
+
], CompanyActionResponseDto.prototype, "companyId", void 0);
|
|
342
|
+
_ts_decorate([
|
|
343
|
+
ApiProperty({
|
|
344
|
+
description: 'Action ID'
|
|
345
|
+
}),
|
|
346
|
+
_ts_metadata("design:type", String)
|
|
347
|
+
], CompanyActionResponseDto.prototype, "actionId", void 0);
|
|
348
|
+
_ts_decorate([
|
|
349
|
+
ApiProperty({
|
|
350
|
+
description: 'Action Code'
|
|
351
|
+
}),
|
|
352
|
+
_ts_metadata("design:type", String)
|
|
353
|
+
], CompanyActionResponseDto.prototype, "actionCode", void 0);
|
|
354
|
+
_ts_decorate([
|
|
355
|
+
ApiProperty({
|
|
356
|
+
description: 'Action Name'
|
|
357
|
+
}),
|
|
358
|
+
_ts_metadata("design:type", String)
|
|
359
|
+
], CompanyActionResponseDto.prototype, "actionName", void 0);
|
|
360
|
+
_ts_decorate([
|
|
361
|
+
ApiProperty({
|
|
362
|
+
description: 'When this permission was created'
|
|
363
|
+
}),
|
|
364
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
365
|
+
], CompanyActionResponseDto.prototype, "createdAt", void 0);
|
|
366
|
+
export class UserRoleResponseDto {
|
|
367
|
+
constructor(){
|
|
368
|
+
_define_property(this, "id", void 0);
|
|
369
|
+
_define_property(this, "userId", void 0);
|
|
370
|
+
_define_property(this, "roleId", void 0);
|
|
371
|
+
_define_property(this, "roleName", void 0);
|
|
372
|
+
_define_property(this, "branchId", void 0);
|
|
373
|
+
_define_property(this, "createdAt", void 0);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
_ts_decorate([
|
|
377
|
+
ApiProperty(),
|
|
378
|
+
_ts_metadata("design:type", String)
|
|
379
|
+
], UserRoleResponseDto.prototype, "id", void 0);
|
|
380
|
+
_ts_decorate([
|
|
381
|
+
ApiProperty(),
|
|
382
|
+
_ts_metadata("design:type", String)
|
|
383
|
+
], UserRoleResponseDto.prototype, "userId", void 0);
|
|
384
|
+
_ts_decorate([
|
|
385
|
+
ApiProperty(),
|
|
386
|
+
_ts_metadata("design:type", String)
|
|
387
|
+
], UserRoleResponseDto.prototype, "roleId", void 0);
|
|
388
|
+
_ts_decorate([
|
|
389
|
+
ApiProperty(),
|
|
390
|
+
_ts_metadata("design:type", String)
|
|
391
|
+
], UserRoleResponseDto.prototype, "roleName", void 0);
|
|
392
|
+
_ts_decorate([
|
|
393
|
+
ApiPropertyOptional(),
|
|
394
|
+
_ts_metadata("design:type", Object)
|
|
395
|
+
], UserRoleResponseDto.prototype, "branchId", void 0);
|
|
396
|
+
_ts_decorate([
|
|
397
|
+
ApiProperty(),
|
|
398
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
399
|
+
], UserRoleResponseDto.prototype, "createdAt", void 0);
|
|
400
|
+
export class FrontendActionDto {
|
|
401
|
+
constructor(){
|
|
402
|
+
_define_property(this, "id", void 0);
|
|
403
|
+
_define_property(this, "code", void 0);
|
|
404
|
+
_define_property(this, "name", void 0);
|
|
405
|
+
_define_property(this, "description", void 0);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
_ts_decorate([
|
|
409
|
+
ApiProperty(),
|
|
410
|
+
_ts_metadata("design:type", String)
|
|
411
|
+
], FrontendActionDto.prototype, "id", void 0);
|
|
412
|
+
_ts_decorate([
|
|
413
|
+
ApiProperty(),
|
|
414
|
+
_ts_metadata("design:type", String)
|
|
415
|
+
], FrontendActionDto.prototype, "code", void 0);
|
|
416
|
+
_ts_decorate([
|
|
417
|
+
ApiProperty(),
|
|
418
|
+
_ts_metadata("design:type", String)
|
|
419
|
+
], FrontendActionDto.prototype, "name", void 0);
|
|
420
|
+
_ts_decorate([
|
|
421
|
+
ApiPropertyOptional(),
|
|
422
|
+
_ts_metadata("design:type", Object)
|
|
423
|
+
], FrontendActionDto.prototype, "description", void 0);
|
|
424
|
+
export class MyPermissionsQueryDto {
|
|
425
|
+
constructor(){
|
|
426
|
+
_define_property(this, "parentCodes", void 0);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
_ts_decorate([
|
|
430
|
+
ApiPropertyOptional({
|
|
431
|
+
description: 'Filter by parent action codes',
|
|
432
|
+
example: [
|
|
433
|
+
'user',
|
|
434
|
+
'role'
|
|
435
|
+
],
|
|
436
|
+
type: [
|
|
437
|
+
String
|
|
438
|
+
]
|
|
439
|
+
}),
|
|
440
|
+
IsArray(),
|
|
441
|
+
IsString({
|
|
442
|
+
each: true
|
|
443
|
+
}),
|
|
444
|
+
IsOptional(),
|
|
445
|
+
_ts_metadata("design:type", Array)
|
|
446
|
+
], MyPermissionsQueryDto.prototype, "parentCodes", void 0);
|
|
447
|
+
export class MyPermissionsResponseDto {
|
|
448
|
+
constructor(){
|
|
449
|
+
_define_property(this, "frontendActions", void 0);
|
|
450
|
+
_define_property(this, "cachedEndpoints", void 0);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
_ts_decorate([
|
|
454
|
+
ApiProperty({
|
|
455
|
+
type: [
|
|
456
|
+
FrontendActionDto
|
|
457
|
+
]
|
|
458
|
+
}),
|
|
459
|
+
_ts_metadata("design:type", Array)
|
|
460
|
+
], MyPermissionsResponseDto.prototype, "frontendActions", void 0);
|
|
461
|
+
_ts_decorate([
|
|
462
|
+
ApiProperty({
|
|
463
|
+
description: 'Number of endpoint actions cached for PermissionGuard'
|
|
464
|
+
}),
|
|
465
|
+
_ts_metadata("design:type", Number)
|
|
466
|
+
], MyPermissionsResponseDto.prototype, "cachedEndpoints", void 0);
|
|
467
|
+
export class PermissionOperationResultDto {
|
|
468
|
+
constructor(){
|
|
469
|
+
_define_property(this, "success", void 0);
|
|
470
|
+
_define_property(this, "added", void 0);
|
|
471
|
+
_define_property(this, "removed", void 0);
|
|
472
|
+
_define_property(this, "message", void 0);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
_ts_decorate([
|
|
476
|
+
ApiProperty(),
|
|
477
|
+
_ts_metadata("design:type", Boolean)
|
|
478
|
+
], PermissionOperationResultDto.prototype, "success", void 0);
|
|
479
|
+
_ts_decorate([
|
|
480
|
+
ApiProperty(),
|
|
481
|
+
_ts_metadata("design:type", Number)
|
|
482
|
+
], PermissionOperationResultDto.prototype, "added", void 0);
|
|
483
|
+
_ts_decorate([
|
|
484
|
+
ApiProperty(),
|
|
485
|
+
_ts_metadata("design:type", Number)
|
|
486
|
+
], PermissionOperationResultDto.prototype, "removed", void 0);
|
|
487
|
+
_ts_decorate([
|
|
488
|
+
ApiProperty(),
|
|
489
|
+
_ts_metadata("design:type", String)
|
|
490
|
+
], PermissionOperationResultDto.prototype, "message", void 0);
|
|
@@ -0,0 +1,214 @@
|
|
|
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, IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
|
|
25
|
+
export class CreateRoleDto {
|
|
26
|
+
constructor(){
|
|
27
|
+
_define_property(this, "name", void 0);
|
|
28
|
+
_define_property(this, "description", void 0);
|
|
29
|
+
_define_property(this, "companyId", void 0);
|
|
30
|
+
_define_property(this, "isActive", void 0);
|
|
31
|
+
_define_property(this, "serial", void 0);
|
|
32
|
+
_define_property(this, "metadata", void 0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
_ts_decorate([
|
|
36
|
+
ApiProperty({
|
|
37
|
+
description: 'Role name',
|
|
38
|
+
example: 'Manager'
|
|
39
|
+
}),
|
|
40
|
+
IsString(),
|
|
41
|
+
IsNotEmpty(),
|
|
42
|
+
MaxLength(255),
|
|
43
|
+
_ts_metadata("design:type", String)
|
|
44
|
+
], CreateRoleDto.prototype, "name", void 0);
|
|
45
|
+
_ts_decorate([
|
|
46
|
+
ApiProperty({
|
|
47
|
+
description: 'Role description',
|
|
48
|
+
example: 'Management level access',
|
|
49
|
+
required: false
|
|
50
|
+
}),
|
|
51
|
+
IsString(),
|
|
52
|
+
IsOptional(),
|
|
53
|
+
MaxLength(500),
|
|
54
|
+
_ts_metadata("design:type", String)
|
|
55
|
+
], CreateRoleDto.prototype, "description", void 0);
|
|
56
|
+
_ts_decorate([
|
|
57
|
+
ApiProperty({
|
|
58
|
+
description: 'Company ID (scope role to specific company) - Only available when company feature is enabled',
|
|
59
|
+
example: '123e4567-e89b-12d3-a456-426614174000',
|
|
60
|
+
required: false
|
|
61
|
+
}),
|
|
62
|
+
IsUUID(),
|
|
63
|
+
IsOptional(),
|
|
64
|
+
_ts_metadata("design:type", String)
|
|
65
|
+
], CreateRoleDto.prototype, "companyId", void 0);
|
|
66
|
+
_ts_decorate([
|
|
67
|
+
ApiProperty({
|
|
68
|
+
description: 'Active status',
|
|
69
|
+
default: true,
|
|
70
|
+
required: false
|
|
71
|
+
}),
|
|
72
|
+
IsBoolean(),
|
|
73
|
+
IsOptional(),
|
|
74
|
+
_ts_metadata("design:type", Boolean)
|
|
75
|
+
], CreateRoleDto.prototype, "isActive", void 0);
|
|
76
|
+
_ts_decorate([
|
|
77
|
+
ApiProperty({
|
|
78
|
+
description: 'Display order',
|
|
79
|
+
required: false
|
|
80
|
+
}),
|
|
81
|
+
IsInt(),
|
|
82
|
+
IsOptional(),
|
|
83
|
+
_ts_metadata("design:type", Number)
|
|
84
|
+
], CreateRoleDto.prototype, "serial", void 0);
|
|
85
|
+
_ts_decorate([
|
|
86
|
+
ApiProperty({
|
|
87
|
+
description: 'Additional metadata',
|
|
88
|
+
required: false
|
|
89
|
+
}),
|
|
90
|
+
IsOptional(),
|
|
91
|
+
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
92
|
+
], CreateRoleDto.prototype, "metadata", void 0);
|
|
93
|
+
export class UpdateRoleDto extends PartialType(CreateRoleDto) {
|
|
94
|
+
constructor(...args){
|
|
95
|
+
super(...args), _define_property(this, "id", void 0);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
_ts_decorate([
|
|
99
|
+
ApiProperty({
|
|
100
|
+
description: 'Role ID',
|
|
101
|
+
example: '123e4567-e89b-12d3-a456-426614174000'
|
|
102
|
+
}),
|
|
103
|
+
IsUUID(),
|
|
104
|
+
IsNotEmpty(),
|
|
105
|
+
_ts_metadata("design:type", String)
|
|
106
|
+
], UpdateRoleDto.prototype, "id", void 0);
|
|
107
|
+
export class RoleQueryDto {
|
|
108
|
+
constructor(){
|
|
109
|
+
_define_property(this, "companyId", void 0);
|
|
110
|
+
_define_property(this, "isActive", void 0);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
_ts_decorate([
|
|
114
|
+
ApiProperty({
|
|
115
|
+
description: 'Filter by company ID - Only available when company feature is enabled',
|
|
116
|
+
required: false
|
|
117
|
+
}),
|
|
118
|
+
IsUUID(),
|
|
119
|
+
IsOptional(),
|
|
120
|
+
_ts_metadata("design:type", String)
|
|
121
|
+
], RoleQueryDto.prototype, "companyId", void 0);
|
|
122
|
+
_ts_decorate([
|
|
123
|
+
ApiProperty({
|
|
124
|
+
description: 'Filter by active status',
|
|
125
|
+
required: false
|
|
126
|
+
}),
|
|
127
|
+
IsBoolean(),
|
|
128
|
+
IsOptional(),
|
|
129
|
+
_ts_metadata("design:type", Boolean)
|
|
130
|
+
], RoleQueryDto.prototype, "isActive", void 0);
|
|
131
|
+
export class RoleResponseDto {
|
|
132
|
+
constructor(){
|
|
133
|
+
_define_property(this, "id", void 0);
|
|
134
|
+
_define_property(this, "readOnly", void 0);
|
|
135
|
+
_define_property(this, "name", void 0);
|
|
136
|
+
_define_property(this, "description", void 0);
|
|
137
|
+
_define_property(this, "companyId", void 0);
|
|
138
|
+
_define_property(this, "isActive", void 0);
|
|
139
|
+
_define_property(this, "serial", void 0);
|
|
140
|
+
_define_property(this, "metadata", void 0);
|
|
141
|
+
_define_property(this, "createdAt", void 0);
|
|
142
|
+
_define_property(this, "updatedAt", void 0);
|
|
143
|
+
_define_property(this, "deletedAt", void 0);
|
|
144
|
+
_define_property(this, "createdById", void 0);
|
|
145
|
+
_define_property(this, "updatedById", void 0);
|
|
146
|
+
_define_property(this, "deletedById", void 0);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
_ts_decorate([
|
|
150
|
+
ApiProperty(),
|
|
151
|
+
_ts_metadata("design:type", String)
|
|
152
|
+
], RoleResponseDto.prototype, "id", void 0);
|
|
153
|
+
_ts_decorate([
|
|
154
|
+
ApiProperty(),
|
|
155
|
+
_ts_metadata("design:type", Boolean)
|
|
156
|
+
], RoleResponseDto.prototype, "readOnly", void 0);
|
|
157
|
+
_ts_decorate([
|
|
158
|
+
ApiProperty(),
|
|
159
|
+
_ts_metadata("design:type", String)
|
|
160
|
+
], RoleResponseDto.prototype, "name", void 0);
|
|
161
|
+
_ts_decorate([
|
|
162
|
+
ApiProperty(),
|
|
163
|
+
_ts_metadata("design:type", Object)
|
|
164
|
+
], RoleResponseDto.prototype, "description", void 0);
|
|
165
|
+
_ts_decorate([
|
|
166
|
+
ApiProperty(),
|
|
167
|
+
_ts_metadata("design:type", Object)
|
|
168
|
+
], RoleResponseDto.prototype, "companyId", void 0);
|
|
169
|
+
_ts_decorate([
|
|
170
|
+
ApiProperty(),
|
|
171
|
+
_ts_metadata("design:type", Boolean)
|
|
172
|
+
], RoleResponseDto.prototype, "isActive", void 0);
|
|
173
|
+
_ts_decorate([
|
|
174
|
+
ApiProperty(),
|
|
175
|
+
_ts_metadata("design:type", Object)
|
|
176
|
+
], RoleResponseDto.prototype, "serial", void 0);
|
|
177
|
+
_ts_decorate([
|
|
178
|
+
ApiProperty({
|
|
179
|
+
required: false
|
|
180
|
+
}),
|
|
181
|
+
_ts_metadata("design:type", Object)
|
|
182
|
+
], RoleResponseDto.prototype, "metadata", void 0);
|
|
183
|
+
_ts_decorate([
|
|
184
|
+
ApiProperty(),
|
|
185
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
186
|
+
], RoleResponseDto.prototype, "createdAt", void 0);
|
|
187
|
+
_ts_decorate([
|
|
188
|
+
ApiProperty(),
|
|
189
|
+
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
190
|
+
], RoleResponseDto.prototype, "updatedAt", void 0);
|
|
191
|
+
_ts_decorate([
|
|
192
|
+
ApiProperty({
|
|
193
|
+
required: false
|
|
194
|
+
}),
|
|
195
|
+
_ts_metadata("design:type", Object)
|
|
196
|
+
], RoleResponseDto.prototype, "deletedAt", void 0);
|
|
197
|
+
_ts_decorate([
|
|
198
|
+
ApiProperty({
|
|
199
|
+
required: false
|
|
200
|
+
}),
|
|
201
|
+
_ts_metadata("design:type", Object)
|
|
202
|
+
], RoleResponseDto.prototype, "createdById", void 0);
|
|
203
|
+
_ts_decorate([
|
|
204
|
+
ApiProperty({
|
|
205
|
+
required: false
|
|
206
|
+
}),
|
|
207
|
+
_ts_metadata("design:type", Object)
|
|
208
|
+
], RoleResponseDto.prototype, "updatedById", void 0);
|
|
209
|
+
_ts_decorate([
|
|
210
|
+
ApiProperty({
|
|
211
|
+
required: false
|
|
212
|
+
}),
|
|
213
|
+
_ts_metadata("design:type", Object)
|
|
214
|
+
], RoleResponseDto.prototype, "deletedById", void 0);
|