@tomei/sso 0.47.0 → 0.48.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. package/dist/src/components/user-group/user-group.d.ts +5 -0
  2. package/dist/src/components/user-group/user-group.js +73 -0
  3. package/dist/src/components/user-group/user-group.js.map +1 -1
  4. package/dist/src/components/user-privilege/user-privilege.d.ts +42 -0
  5. package/dist/src/components/user-privilege/user-privilege.js +338 -0
  6. package/dist/src/components/user-privilege/user-privilege.js.map +1 -1
  7. package/dist/src/components/user-privilege/user-privilege.repository.d.ts +1 -0
  8. package/dist/src/components/user-privilege/user-privilege.repository.js +25 -0
  9. package/dist/src/components/user-privilege/user-privilege.repository.js.map +1 -1
  10. package/dist/src/components/user-system-access/user-system-access.d.ts +12 -0
  11. package/dist/src/components/user-system-access/user-system-access.js +148 -0
  12. package/dist/src/components/user-system-access/user-system-access.js.map +1 -1
  13. package/dist/src/components/user-system-access/user-system-access.repository.d.ts +1 -0
  14. package/dist/src/components/user-system-access/user-system-access.repository.js +25 -0
  15. package/dist/src/components/user-system-access/user-system-access.repository.js.map +1 -1
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/package.json +1 -1
  18. package/src/components/user-group/user-group.ts +134 -0
  19. package/src/components/user-privilege/user-privilege.repository.ts +14 -0
  20. package/src/components/user-privilege/user-privilege.ts +588 -0
  21. package/src/components/user-system-access/user-system-access.repository.ts +14 -0
  22. package/src/components/user-system-access/user-system-access.ts +298 -0
@@ -2,6 +2,7 @@ import { ObjectBase } from '@tomei/general';
2
2
  import { UserGroupRepository } from './user-group.repository';
3
3
  import { LoginUser, User } from '../../components/login-user';
4
4
  import { Group } from '../../components/group';
5
+ import { Transaction } from 'sequelize';
5
6
  export declare class UserGroup extends ObjectBase {
6
7
  ObjectType: string;
7
8
  TableName: string;
@@ -40,4 +41,8 @@ export declare class UserGroup extends ObjectBase {
40
41
  UpdatedAt: Date;
41
42
  }[];
42
43
  }[]>;
44
+ update(loginUser: LoginUser, dbTransaction: Transaction, UpdatedProperties: {
45
+ InheritGroupPrivilegeYN?: string;
46
+ InheritGroupSystemAccessYN?: string;
47
+ }): Promise<UserGroup>;
43
48
  }
@@ -244,6 +244,79 @@ class UserGroup extends general_1.ObjectBase {
244
244
  }
245
245
  });
246
246
  }
247
+ update(loginUser, dbTransaction, UpdatedProperties) {
248
+ return __awaiter(this, void 0, void 0, function* () {
249
+ try {
250
+ const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
251
+ const isPrivileged = yield loginUser.checkPrivileges(systemCode, 'USER_GROUP_UPDATE');
252
+ if (!isPrivileged) {
253
+ throw new general_1.ClassError('UserGroup', 'UserGroupErrMsg0X', 'User does not have privilege to update user group.', 'update', 403);
254
+ }
255
+ if (!UpdatedProperties.InheritGroupPrivilegeYN &&
256
+ !UpdatedProperties.InheritGroupSystemAccessYN) {
257
+ throw new general_1.ClassError('UserGroup', 'UserGroupErrMsg04', 'At least one of the properties to update is required.', 'update', 400);
258
+ }
259
+ const entityValueBefore = {
260
+ UserGroupId: this.UserGroupId,
261
+ UserId: this.UserId,
262
+ GroupCode: this.GroupCode,
263
+ Status: this.Status,
264
+ CreatedById: this._CreatedById,
265
+ CreatedAt: this._CreatedAt,
266
+ UpdatedById: this._UpdatedById,
267
+ UpdatedAt: this._UpdatedAt,
268
+ InheritGroupPrivilegeYN: this.InheritGroupPrivilegeYN,
269
+ InheritGroupSystemAccessYN: this.InheritGroupSystemAccessYN,
270
+ };
271
+ this._UpdatedById = loginUser.UserId;
272
+ this._UpdatedAt = new Date();
273
+ if (UpdatedProperties.InheritGroupPrivilegeYN) {
274
+ this.InheritGroupPrivilegeYN =
275
+ UpdatedProperties.InheritGroupPrivilegeYN;
276
+ }
277
+ if (UpdatedProperties.InheritGroupSystemAccessYN) {
278
+ this.InheritGroupSystemAccessYN =
279
+ UpdatedProperties.InheritGroupSystemAccessYN;
280
+ }
281
+ yield UserGroup._Repository.update({
282
+ InheritGroupPrivilegeYN: this.InheritGroupPrivilegeYN,
283
+ InheritGroupSystemAccessYN: this.InheritGroupSystemAccessYN,
284
+ UpdatedById: this._UpdatedById,
285
+ UpdatedAt: this._UpdatedAt,
286
+ }, {
287
+ where: {
288
+ UserGroupId: this.UserGroupId,
289
+ },
290
+ transaction: dbTransaction,
291
+ });
292
+ const entityValueAfter = {
293
+ UserGroupId: this.UserGroupId,
294
+ UserId: this.UserId,
295
+ GroupCode: this.GroupCode,
296
+ Status: this.Status,
297
+ CreatedById: this._CreatedById,
298
+ CreatedAt: this._CreatedAt,
299
+ UpdatedById: this._UpdatedById,
300
+ UpdatedAt: this._UpdatedAt,
301
+ InheritGroupPrivilegeYN: this.InheritGroupPrivilegeYN,
302
+ InheritGroupSystemAccessYN: this.InheritGroupSystemAccessYN,
303
+ };
304
+ const activity = new activity_history_1.Activity();
305
+ activity.ActivityId = activity.createId();
306
+ activity.Action = activity_history_1.ActionEnum.UPDATE;
307
+ activity.Description = 'Update User Group';
308
+ activity.EntityType = 'UserGroup';
309
+ activity.EntityId = this.UserGroupId.toString();
310
+ activity.EntityValueBefore = JSON.stringify(entityValueBefore);
311
+ activity.EntityValueAfter = JSON.stringify(entityValueAfter);
312
+ yield activity.create(loginUser.ObjectId, dbTransaction);
313
+ return this;
314
+ }
315
+ catch (error) {
316
+ throw error;
317
+ }
318
+ });
319
+ }
247
320
  }
248
321
  exports.UserGroup = UserGroup;
249
322
  UserGroup._Repository = new user_group_repository_1.UserGroupRepository();
@@ -1 +1 @@
1
- {"version":3,"file":"user-group.js","sourceRoot":"","sources":["../../../../src/components/user-group/user-group.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwD;AACxD,mEAA8D;AAI9D,0CAAkD;AAClD,8DAA+D;AAC/D,wFAA6E;AAC7E,4DAAmD;AACnD,8DAAqD;AAErD,MAAa,SAAU,SAAQ,oBAAU;IAkBvC,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UA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d,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;;AA9bH,8BA+bC;AA/akB,qBAAW,GAAG,IAAI,2CAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"user-group.js","sourceRoot":"","sources":["../../../../src/components/user-group/user-group.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwD;AACxD,mEAA8D;AAI9D,0CAAkD;AAClD,8DAA+D;AAC/D,wFAA6E;AAC7E,4DAAmD;AACnD,8DAAqD;AAGrD,MAAa,SAAU,SAAQ,oBAAU;IAkBvC,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,YAAoB,aAA8B;QAChD,KAAK,EAAE,CAAC;QAlCV,eAAU,GAAG,WAAW,CAAC;QACzB,cAAS,GAAG,eAAe,CAAC;QAM5B,4BAAuB,GAAG,GAAG,CAAC;QAC9B,+BAA0B,GAAG,GAAG,CAAC;QA2B/B,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;YAC7C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC;YACzC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,uBAAuB,GAAG,aAAa,CAAC,uBAAuB,CAAC;YACrE,IAAI,CAAC,0BAA0B;gBAC7B,aAAa,CAAC,0BAA0B,CAAC;YAC3C,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC;YAC9C,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC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AAC,UAAU;oBAC1B,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;oBACrD,0BAA0B,EAAE,IAAI,CAAC,0BAA0B;iBAC5D,CAAC;gBASF,MAAM,QAAQ,GAAG,IAAI,2BAAQ,EAAE,CAAC;gBAChC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBAC1C,QAAQ,CAAC,MAAM,GAAG,6BAAU,CAAC,MAAM,CAAC;gBACpC,QAAQ,CAAC,WAAW,GAAG,mBAAmB,CAAC;gBAC3C,QAAQ,CAAC,UAAU,GAAG,WAAW,CAAC;gBAClC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;gBAChD,QAAQ,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;gBAC/D,QAAQ,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;gBAO7D,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;gBAEzD,OAAO,IAAI,CAAC;aACb;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;;AAnkBH,8BAokBC;AApjBkB,qBAAW,GAAG,IAAI,2CAAmB,EAAE,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { ObjectBase } from '@tomei/general';
2
+ import { User as UserClass } from '../login-user/user';
3
+ import { User as UserLogin } from '../login-user/user';
2
4
  export declare class UserPrivilege extends ObjectBase {
3
5
  TableName: string;
4
6
  ObjectType: string;
@@ -17,6 +19,46 @@ export declare class UserPrivilege extends ObjectBase {
17
19
  get CreatedAt(): Date;
18
20
  get UpdatedAt(): Date;
19
21
  private static _Repository;
22
+ private static _UserGroupRepository;
23
+ private static _GroupPrivilegeRepository;
24
+ private static _SystemPrivilegeRepository;
20
25
  private constructor();
21
26
  static init(dbTransaction?: any, UserPrivilegeId?: number): Promise<UserPrivilege>;
27
+ static findAll(loginUser: UserClass, dbTransaction: any, whereOption: {
28
+ UserId: number;
29
+ SystemCode?: string;
30
+ }, pagination: {
31
+ page: number;
32
+ limit: number;
33
+ }): Promise<{
34
+ records: {
35
+ UserPrivilegeId: number;
36
+ SystemPrivilegeId: string;
37
+ PrivilegeCode: string;
38
+ SystemName: string;
39
+ Status: string;
40
+ CreatedBy: string;
41
+ CreatedAt: Date;
42
+ UpdatedBy: string;
43
+ UpdatedAt: Date;
44
+ }[];
45
+ pagination: {
46
+ currentPage: number;
47
+ pageSize: number;
48
+ totalRecords: number;
49
+ };
50
+ }>;
51
+ static findAllInheritedPrivileges(UserId: number, loginUser: UserClass, dbTransaction: any): Promise<any[]>;
52
+ static assignPrivileges(loginUser: UserLogin, dbTransaction: any, UserId: string, SystemPrivilegeId: string, Status: string): Promise<UserPrivilege>;
53
+ update(loginUser: UserLogin, dbTransaction: any, Status: string): Promise<{
54
+ UserPrivilegeId: number;
55
+ UserId: number;
56
+ SystemPrivilegeId: string;
57
+ Status: string;
58
+ CreatedById: number;
59
+ CreatedAt: Date;
60
+ UpdatedById: number;
61
+ UpdatedAt: Date;
62
+ }>;
63
+ static remove(loginUser: UserLogin, dbTransaction: any, UserPrivilegeId: number): Promise<void>;
22
64
  }
@@ -12,6 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UserPrivilege = void 0;
13
13
  const general_1 = require("@tomei/general");
14
14
  const user_privilege_repository_1 = require("./user-privilege.repository");
15
+ const config_1 = require("@tomei/config");
16
+ const system_privilege_entity_1 = require("../../models/system-privilege.entity");
17
+ const system_entity_1 = require("../../models/system.entity");
18
+ const user_group_repository_1 = require("../user-group/user-group.repository");
19
+ const group_entity_1 = require("../../models/group.entity");
20
+ const user_entity_1 = require("../../models/user.entity");
21
+ const group_privilege_repository_1 = require("../group-privilege/group-privilege.repository");
22
+ const system_privilege_repository_1 = require("../system-privilege/system-privilege.repository");
23
+ const sequelize_1 = require("sequelize");
24
+ const activity_history_1 = require("@tomei/activity-history");
15
25
  class UserPrivilege extends general_1.ObjectBase {
16
26
  get CreatedById() {
17
27
  return this._CreatedById;
@@ -63,7 +73,335 @@ class UserPrivilege extends general_1.ObjectBase {
63
73
  }
64
74
  });
65
75
  }
76
+ static findAll(loginUser, dbTransaction, whereOption, pagination) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ try {
79
+ const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
80
+ const privilegeCode = 'USER_PRIVILEGE_LIST';
81
+ const isPrivileged = yield loginUser.checkPrivileges(systemCode, privilegeCode);
82
+ if (!isPrivileged) {
83
+ throw new general_1.ClassError('UserPrivilege', 'UserPrivilegeErrMsg01', 'You do not have permission to access this resource.');
84
+ }
85
+ const options = {
86
+ where: {
87
+ UserId: whereOption.UserId,
88
+ },
89
+ offset: (pagination.page - 1) * pagination.limit,
90
+ limit: pagination.limit,
91
+ transaction: dbTransaction,
92
+ include: [
93
+ {
94
+ model: system_privilege_entity_1.default,
95
+ attributes: ['PrivilegeCode'],
96
+ include: [
97
+ {
98
+ model: system_entity_1.default,
99
+ attributes: ['Name'],
100
+ },
101
+ ],
102
+ },
103
+ {
104
+ model: user_entity_1.default,
105
+ as: 'CreatedByUser',
106
+ attributes: ['FullName'],
107
+ },
108
+ {
109
+ model: user_entity_1.default,
110
+ as: 'UpdatedByUser',
111
+ attributes: ['FullName'],
112
+ },
113
+ ],
114
+ };
115
+ const { count, rows } = yield this._Repository.findAllWithPagination(options);
116
+ return {
117
+ records: rows.map((record) => {
118
+ return {
119
+ UserPrivilegeId: record.UserPrivilegeId,
120
+ SystemPrivilegeId: record.SystemPrivilegeId,
121
+ PrivilegeCode: record.Privilege.PrivilegeCode,
122
+ SystemName: record.Privilege.System.Name,
123
+ Status: record.Status,
124
+ CreatedBy: record.CreatedByUser.FullName,
125
+ CreatedAt: record.CreatedAt,
126
+ UpdatedBy: record.UpdatedByUser.FullName,
127
+ UpdatedAt: record.UpdatedAt,
128
+ };
129
+ }),
130
+ pagination: {
131
+ currentPage: pagination.page,
132
+ pageSize: pagination.limit,
133
+ totalRecords: count,
134
+ },
135
+ };
136
+ }
137
+ catch (error) {
138
+ throw error;
139
+ }
140
+ });
141
+ }
142
+ static findAllInheritedPrivileges(UserId, loginUser, dbTransaction) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ try {
145
+ const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
146
+ const privilegeCode = 'USER_PRIVILEGE_LIST';
147
+ const isPrivileged = yield loginUser.checkPrivileges(systemCode, privilegeCode);
148
+ if (!isPrivileged) {
149
+ throw new general_1.ClassError('UserPrivilege', 'UserPrivilegeErrMsg01', 'You do not have permission to access this resource.');
150
+ }
151
+ const userGroups = yield UserPrivilege._UserGroupRepository.findAll({
152
+ where: {
153
+ UserId,
154
+ },
155
+ include: [
156
+ {
157
+ model: group_entity_1.default,
158
+ attributes: ['GroupCode', 'Name', 'InheritParentPrivilegeYN'],
159
+ },
160
+ ],
161
+ transaction: dbTransaction,
162
+ });
163
+ const listOfGroups = userGroups.map((groups) => {
164
+ let inheritPrivilegeYN = groups.InheritGroupPrivilegeYN;
165
+ if (inheritPrivilegeYN !== 'Y') {
166
+ inheritPrivilegeYN = 'N';
167
+ }
168
+ return {
169
+ UserGroupId: groups.UserGroupId,
170
+ GroupCode: groups.GroupCode,
171
+ GroupName: groups.Group.Name,
172
+ InheritPrivilegeYN: inheritPrivilegeYN,
173
+ Status: groups.Status,
174
+ };
175
+ });
176
+ const userGroupPrivilege = [];
177
+ for (let i = 0; i < listOfGroups.length; i++) {
178
+ const group = yield listOfGroups[i];
179
+ const data = {
180
+ UserGroupId: group.UserGroupId,
181
+ GroupCode: group.GroupCode,
182
+ GroupName: group.GroupName,
183
+ InheritPrivilegeYN: group.InheritPrivilegeYN,
184
+ systems: [],
185
+ };
186
+ if (group.InheritPrivilegeYN === 'Y') {
187
+ if (group.Status === 'Active') {
188
+ const options = {
189
+ where: {
190
+ GroupCode: group.GroupCode,
191
+ Status: 'Active',
192
+ },
193
+ transaction: dbTransaction,
194
+ include: [
195
+ {
196
+ model: system_privilege_entity_1.default,
197
+ attributes: ['PrivilegeCode'],
198
+ include: [
199
+ {
200
+ model: system_entity_1.default,
201
+ attributes: ['Name'],
202
+ },
203
+ ],
204
+ },
205
+ {
206
+ model: user_entity_1.default,
207
+ as: 'CreatedByUser',
208
+ attributes: ['FullName'],
209
+ },
210
+ {
211
+ model: user_entity_1.default,
212
+ as: 'UpdatedByUser',
213
+ attributes: ['FullName'],
214
+ },
215
+ ],
216
+ };
217
+ const systemPrivilege = yield this._GroupPrivilegeRepository.findAll(options);
218
+ const privilegeDetails = systemPrivilege.map((record) => {
219
+ return {
220
+ GroupPrivilegeId: record.GroupPrivilegeId,
221
+ SystemPrivilegeId: record.SystemPrivilegeId,
222
+ PrivilegeCode: record.Privilege.PrivilegeCode,
223
+ Status: record.Status,
224
+ CreatedBy: record.CreatedByUser.FullName,
225
+ CreatedAt: record.CreatedAt,
226
+ UpdatedBy: record.UpdatedByUser.FullName,
227
+ UpdatedAt: record.UpdatedAt,
228
+ };
229
+ });
230
+ data.systems = privilegeDetails;
231
+ }
232
+ }
233
+ userGroupPrivilege.push(data);
234
+ }
235
+ return userGroupPrivilege;
236
+ }
237
+ catch (error) {
238
+ throw error;
239
+ }
240
+ });
241
+ }
242
+ static assignPrivileges(loginUser, dbTransaction, UserId, SystemPrivilegeId, Status) {
243
+ var _a;
244
+ return __awaiter(this, void 0, void 0, function* () {
245
+ try {
246
+ const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
247
+ const privilegeCode = 'USER_PRIVILEGE_CREATE';
248
+ const isPrivileged = yield loginUser.checkPrivileges(systemCode, privilegeCode);
249
+ if (!isPrivileged) {
250
+ throw new general_1.ClassError('UserSystemPrivilege', 'UserSystemPrivilegeErrMsg01', 'You do not have permission to access this resource.');
251
+ }
252
+ const isExist = yield UserPrivilege._SystemPrivilegeRepository.findAll({
253
+ where: { SystemPrivilegeId: SystemPrivilegeId },
254
+ transaction: dbTransaction,
255
+ });
256
+ if ((isExist === null || isExist === void 0 ? void 0 : isExist.length) < 1) {
257
+ throw new general_1.ClassError('UserSystemPrivilege', 'UserSystemPrivilegeErrMsg02', "system privileges don't exist");
258
+ }
259
+ const isUserAlreadyAssign = yield UserPrivilege._Repository.findAll({
260
+ where: {
261
+ [sequelize_1.Op.and]: [
262
+ { UserId: UserId },
263
+ { SystemPrivilegeId: SystemPrivilegeId },
264
+ ],
265
+ },
266
+ transaction: dbTransaction,
267
+ });
268
+ if ((isUserAlreadyAssign === null || isUserAlreadyAssign === void 0 ? void 0 : isUserAlreadyAssign.length) > 0) {
269
+ throw new general_1.ClassError('UserSystemPrivilege', 'UserSystemPrivilegeErrMsg03', 'User already have access to this privilege');
270
+ }
271
+ const newUserPrivilege = new UserPrivilege();
272
+ newUserPrivilege.UserId = parseInt(UserId);
273
+ newUserPrivilege.SystemPrivilegeId = SystemPrivilegeId;
274
+ newUserPrivilege.Status = Status;
275
+ newUserPrivilege._CreatedById = loginUser.UserId;
276
+ newUserPrivilege._CreatedAt = new Date();
277
+ newUserPrivilege._UpdatedById = loginUser.UserId;
278
+ newUserPrivilege._UpdatedAt = new Date();
279
+ const payload = {
280
+ UserId: newUserPrivilege.UserId,
281
+ SystemPrivilegeId: newUserPrivilege.SystemPrivilegeId,
282
+ Status: newUserPrivilege.Status,
283
+ CreatedById: newUserPrivilege.CreatedById,
284
+ CreatedAt: newUserPrivilege.CreatedAt,
285
+ UpdatedById: newUserPrivilege.UpdatedById,
286
+ UpdatedAt: newUserPrivilege.UpdatedAt,
287
+ };
288
+ const userPrivilege = yield UserPrivilege._Repository.create(payload, {
289
+ transaction: dbTransaction,
290
+ });
291
+ const entityValueBefore = {};
292
+ const activity = new activity_history_1.Activity();
293
+ activity.ActivityId = activity.createId();
294
+ activity.Action = activity_history_1.ActionEnum.CREATE;
295
+ activity.Description = 'Create User Privilege';
296
+ activity.EntityType = 'UserPrivilege';
297
+ activity.EntityId = (_a = userPrivilege.UserPrivilegeId) === null || _a === void 0 ? void 0 : _a.toString();
298
+ activity.EntityValueBefore = JSON.stringify(entityValueBefore);
299
+ activity.EntityValueAfter = JSON.stringify(payload);
300
+ yield activity.create(loginUser.ObjectId, dbTransaction);
301
+ newUserPrivilege.UserPrivilegeId = userPrivilege.UserPrivilegeId;
302
+ return newUserPrivilege;
303
+ }
304
+ catch (error) {
305
+ throw error;
306
+ }
307
+ });
308
+ }
309
+ update(loginUser, dbTransaction, Status) {
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ try {
312
+ const entityValueBefore = {
313
+ UserPrivilegeId: this.UserPrivilegeId,
314
+ UserId: this.UserId,
315
+ SystemPrivilegeId: this.SystemPrivilegeId,
316
+ Status: this.Status,
317
+ CreatedById: this.CreatedById,
318
+ CreatedAt: this.CreatedAt,
319
+ UpdatedById: this.UpdatedById,
320
+ UpdatedAt: this.UpdatedAt,
321
+ };
322
+ yield UserPrivilege._Repository.update({
323
+ Status: Status,
324
+ UpdatedById: loginUser.UserId,
325
+ UpdatedAt: new Date(),
326
+ }, {
327
+ where: {
328
+ UserPrivilegeId: this.UserPrivilegeId,
329
+ },
330
+ transaction: dbTransaction,
331
+ });
332
+ const entityValueAfter = {
333
+ UserPrivilegeId: this.UserPrivilegeId,
334
+ UserId: this.UserId,
335
+ SystemPrivilegeId: this.SystemPrivilegeId,
336
+ Status: Status,
337
+ CreatedById: this.CreatedById,
338
+ CreatedAt: this.CreatedAt,
339
+ UpdatedById: loginUser.UserId,
340
+ UpdatedAt: new Date(),
341
+ };
342
+ const activity = new activity_history_1.Activity();
343
+ activity.ActivityId = activity.createId();
344
+ activity.Action = activity_history_1.ActionEnum.UPDATE;
345
+ activity.Description = 'Update User Privilege';
346
+ activity.EntityType = 'UserPrivilege';
347
+ activity.EntityId = this.SystemPrivilegeId + '';
348
+ activity.EntityValueBefore = JSON.stringify(entityValueBefore);
349
+ activity.EntityValueAfter = JSON.stringify(entityValueAfter);
350
+ yield activity.create(loginUser.ObjectId, dbTransaction);
351
+ return entityValueAfter;
352
+ }
353
+ catch (error) {
354
+ throw error;
355
+ }
356
+ });
357
+ }
358
+ static remove(loginUser, dbTransaction, UserPrivilegeId) {
359
+ return __awaiter(this, void 0, void 0, function* () {
360
+ try {
361
+ const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
362
+ const privilegeCode = 'USER_PRIVILEGE_REMOVE';
363
+ const isPrivileged = yield loginUser.checkPrivileges(systemCode, privilegeCode);
364
+ if (!isPrivileged) {
365
+ throw new general_1.ClassError('UserSystemPrivilege', 'UserSystemPrivilegeErrMsg01', 'You do not have permission to access this resource.');
366
+ }
367
+ const userPrivilege = yield UserPrivilege._Repository.findOne({
368
+ where: {
369
+ UserPrivilegeId: UserPrivilegeId,
370
+ },
371
+ transaction: dbTransaction,
372
+ });
373
+ if (!userPrivilege) {
374
+ throw new general_1.ClassError('UserSystemPrivilege', 'UserSystemPrivilegeErrMsg01', 'User Privilege not Found');
375
+ }
376
+ yield UserPrivilege._Repository.delete(UserPrivilegeId, dbTransaction);
377
+ const entityValueBefore = {
378
+ UserId: userPrivilege.UserId,
379
+ SystemPrivilegeId: userPrivilege.SystemPrivilegeId,
380
+ Status: userPrivilege.Status,
381
+ CreatedById: userPrivilege.CreatedById,
382
+ CreatedAt: userPrivilege.CreatedAt,
383
+ UpdatedById: userPrivilege.UpdatedById,
384
+ UpdatedAt: userPrivilege.UpdatedAt,
385
+ };
386
+ const activity = new activity_history_1.Activity();
387
+ activity.ActivityId = activity.createId();
388
+ activity.Action = activity_history_1.ActionEnum.DELETE;
389
+ activity.Description = 'Delete User Privilege';
390
+ activity.EntityType = 'UserPrivilege';
391
+ activity.EntityId = UserPrivilegeId === null || UserPrivilegeId === void 0 ? void 0 : UserPrivilegeId.toString();
392
+ activity.EntityValueBefore = JSON.stringify(entityValueBefore);
393
+ activity.EntityValueAfter = JSON.stringify({});
394
+ yield activity.create(loginUser.ObjectId, dbTransaction);
395
+ }
396
+ catch (error) {
397
+ throw error;
398
+ }
399
+ });
400
+ }
66
401
  }
67
402
  exports.UserPrivilege = UserPrivilege;
68
403
  UserPrivilege._Repository = new user_privilege_repository_1.UserPrivilegeRepository();
404
+ UserPrivilege._UserGroupRepository = new user_group_repository_1.UserGroupRepository();
405
+ UserPrivilege._GroupPrivilegeRepository = new group_privilege_repository_1.GroupPrivilegeRepository();
406
+ UserPrivilege._SystemPrivilegeRepository = new system_privilege_repository_1.SystemPrivilegeRepository();
69
407
  //# sourceMappingURL=user-privilege.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-privilege.js","sourceRoot":"","sources":["../../../../src/components/user-privilege/user-privilege.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwD;AAExD,2EAAsE;AAEtE,MAAa,aAAc,SAAQ,oBAAU;IAc3C,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAID,YAAoB,iBAAsC;QACxD,KAAK,EAAE,CAAC;QAhCV,cAAS,GAAG,mBAAmB,CAAC;QAChC,eAAU,GAAG,eAAe,CAAC;QAgC3B,IAAI,iBAAiB,EAAE;YACrB,IAAI,CAAC,eAAe,GAAG,iBAAiB,CAAC,eAAe,CAAC;YACzD,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;YACvC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,iBAAiB,CAAC;YAC7D,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;YACvC,IAAI,CAAC,YAAY,GAAG,iBAAiB,CAAC,WAAW,CAAC;YAClD,IAAI,CAAC,YAAY,GAAG,iBAAiB,CAAC,WAAW,CAAC;YAClD,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC,SAAS,CAAC;YAC9C,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC,SAAS,CAAC;SAC/C;IACH,CAAC;IAEM,MAAM,CAAO,IAAI,CAAC,aAAmB,EAAE,eAAwB;;YACpE,IAAI;gBACF,IAAI,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;gBACxC,IAAI,eAAe,EAAE;oBACnB,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;wBACvD,KAAK,EAAE,EAAE,eAAe,EAAE;wBAC1B,WAAW,EAAE,aAAa;qBAC3B,CAAC,CAAC;oBACH,IAAI,iBAAiB,EAAE;wBACrB,aAAa,GAAG,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;qBACtD;yBAAM;wBACL,MAAM,IAAI,oBAAU,CAClB,eAAe,EACf,uBAAuB,EACvB,yBAAyB,CAC1B,CAAC;qBACH;iBACF;gBACD,OAAO,aAAa,CAAC;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;;AApEH,sCAqEC;AAvCgB,yBAAW,GAAG,IAAI,mDAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"user-privilege.js","sourceRoot":"","sources":["../../../../src/components/user-privilege/user-privilege.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwD;AAExD,2EAAsE;AAEtE,0CAAkD;AAClD,kFAAwE;AACxE,8DAAqD;AACrD,+EAA0E;AAC1E,4DAAmD;AACnD,0DAA4C;AAC5C,8FAAyF;AAEzF,iGAA4F;AAC5F,yCAA+B;AAC/B,8DAA+D;AAG/D,MAAa,aAAc,SAAQ,oBAAU;IAc3C,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3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ChD,QAAQ,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;gBAC/D,QAAQ,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBAG/C,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;aAC1D;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;;AAnoBH,sCAooBC;AAtmBgB,yBAAW,GAAG,IAAI,mDAAuB,EAAE,CAAC;AAC5C,kCAAoB,GAAG,IAAI,2CAAmB,EAAE,CAAC;AACjD,uCAAyB,GAAG,IAAI,qDAAwB,EAAE,CAAC;AAC3D,wCAA0B,GAAG,IAAI,uDAAyB,EAAE,CAAC"}
@@ -2,4 +2,5 @@ import UserPrivilegeModel from '../../models/user-privilege.entity';
2
2
  import { RepositoryBase, IRepositoryBase } from '@tomei/general';
3
3
  export declare class UserPrivilegeRepository extends RepositoryBase<UserPrivilegeModel> implements IRepositoryBase<UserPrivilegeModel> {
4
4
  constructor();
5
+ delete(UserPrivilegeId: number, dbTransaction?: any): Promise<void>;
5
6
  }
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.UserPrivilegeRepository = void 0;
4
13
  const user_privilege_entity_1 = require("../../models/user-privilege.entity");
@@ -7,6 +16,22 @@ class UserPrivilegeRepository extends general_1.RepositoryBase {
7
16
  constructor() {
8
17
  super(user_privilege_entity_1.default);
9
18
  }
19
+ delete(UserPrivilegeId, dbTransaction) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ try {
22
+ const options = {
23
+ where: {
24
+ UserPrivilegeId: UserPrivilegeId,
25
+ },
26
+ transaction: dbTransaction,
27
+ };
28
+ yield user_privilege_entity_1.default.destroy(options);
29
+ }
30
+ catch (error) {
31
+ throw new Error(`An Error occured when delete : ${error.message}`);
32
+ }
33
+ });
34
+ }
10
35
  }
11
36
  exports.UserPrivilegeRepository = UserPrivilegeRepository;
12
37
  //# sourceMappingURL=user-privilege.repository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-privilege.repository.js","sourceRoot":"","sources":["../../../../src/components/user-privilege/user-privilege.repository.ts"],"names":[],"mappings":";;;AAAA,8EAAoE;AACpE,4CAAiE;AAEjE,MAAa,uBACX,SAAQ,wBAAkC;IAG1C;QACE,KAAK,CAAC,+BAAkB,CAAC,CAAC;IAC5B,CAAC;CACF;AAPD,0DAOC"}
1
+ {"version":3,"file":"user-privilege.repository.js","sourceRoot":"","sources":["../../../../src/components/user-privilege/user-privilege.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8EAAoE;AACpE,4CAAiE;AAEjE,MAAa,uBACX,SAAQ,wBAAkC;IAG1C;QACE,KAAK,CAAC,+BAAkB,CAAC,CAAC;IAC5B,CAAC;IAEK,MAAM,CAAC,eAAuB,EAAE,aAAmB;;YACvD,IAAI;gBACF,MAAM,OAAO,GAAG;oBACd,KAAK,EAAE;wBACL,eAAe,EAAE,eAAe;qBACjC;oBACD,WAAW,EAAE,aAAa;iBAC3B,CAAC;gBACF,MAAM,+BAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAC3C;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;aACpE;QACH,CAAC;KAAA;CACF;AArBD,0DAqBC"}
@@ -22,6 +22,7 @@ export declare class UserSystemAccess extends ObjectBase {
22
22
  static init(dbTransaction: any, UserSystemAccessId?: number): Promise<UserSystemAccess>;
23
23
  static findAll(loginUser: User, dbTransaction: any, whereOption: {
24
24
  UserId: number;
25
+ SystemCode?: string;
25
26
  }, pagination: {
26
27
  page: number;
27
28
  limit: number;
@@ -41,4 +42,15 @@ export declare class UserSystemAccess extends ObjectBase {
41
42
  totalRecords: number;
42
43
  };
43
44
  }>;
45
+ static createAccess(loginUser: User, dbTransaction: any, UserId: string, SystemCode: string, Status: string): Promise<UserSystemAccess>;
46
+ update(loginUser: User, dbTransaction: any, Status: string): Promise<{
47
+ UserId: number;
48
+ SystemCode: string;
49
+ Status: string;
50
+ CreatedById: number;
51
+ CreatedAt: Date;
52
+ UpdatedById: number;
53
+ UpdatedAt: Date;
54
+ }>;
55
+ static remove(loginUser: User, dbTransaction: any, UserSystemAccessId: number): Promise<void>;
44
56
  }