@uniorganization/uni-lib 4.3.1 → 4.3.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/dist/entities/bp-alerts.entity.d.ts +2 -2
- package/dist/entities/bp-alerts.entity.js +4 -4
- package/dist/entities/business-schedule.entity.d.ts +2 -2
- package/dist/entities/business-schedule.entity.js +4 -4
- package/dist/entities/call-driver-data.entity.d.ts +2 -2
- package/dist/entities/call-driver-data.entity.js +4 -4
- package/dist/entities/call-drivers.entity.d.ts +1 -1
- package/dist/entities/call-drivers.entity.js +2 -2
- package/dist/entities/cb-completed-reasons.entity.d.ts +1 -1
- package/dist/entities/cb-completed-reasons.entity.js +2 -2
- package/dist/entities/claim-report.entity.d.ts +2 -2
- package/dist/entities/claim-report.entity.js +4 -4
- package/dist/entities/daily-payment.entity.d.ts +58 -0
- package/dist/entities/daily-payment.entity.js +248 -0
- package/dist/entities/dispute-request.entity.d.ts +2 -2
- package/dist/entities/dispute-request.entity.js +4 -4
- package/dist/entities/division.entity.d.ts +11 -0
- package/dist/entities/division.entity.js +52 -0
- package/dist/entities/enr-inventory.entity.d.ts +2 -2
- package/dist/entities/enr-inventory.entity.js +4 -4
- package/dist/entities/enr-results.entity.d.ts +1 -1
- package/dist/entities/enr-results.entity.js +2 -2
- package/dist/entities/escalations.entity.d.ts +2 -2
- package/dist/entities/escalations.entity.js +4 -4
- package/dist/entities/evaluation-forms.entity.d.ts +4 -4
- package/dist/entities/evaluations.entity.d.ts +2 -2
- package/dist/entities/evaluations.entity.js +4 -4
- package/dist/entities/form-fields.entity.d.ts +2 -2
- package/dist/entities/form-fields.entity.js +4 -4
- package/dist/entities/form.entity.d.ts +2 -2
- package/dist/entities/form.entity.js +4 -4
- package/dist/entities/inbox/message-case.entity.d.ts +2 -2
- package/dist/entities/inbox/message-case.entity.js +6 -8
- package/dist/entities/inbox/sla-policy.entity.d.ts +2 -2
- package/dist/entities/inbox/sla-policy.entity.js +4 -4
- package/dist/entities/index.d.ts +3 -0
- package/dist/entities/index.js +3 -0
- package/dist/entities/inventory.entity.d.ts +1 -1
- package/dist/entities/inventory.entity.js +2 -2
- package/dist/entities/lob-assignment.entity.d.ts +1 -1
- package/dist/entities/lob-assignment.entity.js +2 -2
- package/dist/entities/lob-call-drivers.entity.d.ts +1 -1
- package/dist/entities/lob-call-drivers.entity.js +2 -2
- package/dist/entities/lob.entity.d.ts +14 -0
- package/dist/entities/lob.entity.js +65 -0
- package/dist/entities/offphone-activities.entity.d.ts +1 -1
- package/dist/entities/offphone-activities.entity.js +2 -2
- package/dist/entities/otwe-offers.entity.d.ts +1 -1
- package/dist/entities/otwe-offers.entity.js +2 -2
- package/dist/entities/outbound-ticket-history.entity.d.ts +2 -2
- package/dist/entities/outbound-ticket-history.entity.js +4 -4
- package/dist/entities/pending-ticket-history.entity.d.ts +2 -2
- package/dist/entities/pending-ticket-history.entity.js +4 -4
- package/dist/entities/raw_roster.entity.d.ts +2 -2
- package/dist/entities/raw_roster.entity.js +4 -4
- package/dist/entities/roster.entity.d.ts +2 -2
- package/dist/entities/roster.entity.js +4 -4
- package/dist/entities/skipped-ticket.entity.d.ts +2 -2
- package/dist/entities/skipped-ticket.entity.js +4 -4
- package/dist/entities/template.entity.d.ts +2 -2
- package/dist/entities/template.entity.js +4 -4
- package/dist/entities/ticket-queue.entity.d.ts +2 -2
- package/dist/entities/ticket-queue.entity.js +4 -4
- package/dist/entities/user-roster.view.d.ts +2 -2
- package/dist/entities/user-roster.view.js +4 -4
- package/dist/entities/users-lobs.entity.d.ts +11 -0
- package/dist/entities/users-lobs.entity.js +57 -0
- package/dist/entities/usr.entity.d.ts +4 -1
- package/dist/entities/usr.entity.js +22 -10
- package/dist/entities/vw-escalation-age.d.ts +2 -0
- package/dist/entities/vw-escalation-age.js +8 -0
- package/dist/middlewares/index.d.ts +1 -0
- package/dist/middlewares/index.js +17 -0
- package/dist/middlewares/version-checker.middleware.d.ts +2 -0
- package/dist/middlewares/version-checker.middleware.js +27 -0
- package/dist/modules/tenant/tenant-authorization.service.js +4 -1
- package/package.json +13 -12
- package/dist/entities/user-client-context.entity.d.ts +0 -10
- package/dist/entities/user-client-context.entity.js +0 -59
- package/dist/modules/tenant/master-users.guard.d.ts +0 -4
- package/dist/modules/tenant/master-users.guard.js +0 -35
|
@@ -62,9 +62,9 @@ export declare class VwUserRoster {
|
|
|
62
62
|
phoenixId: string;
|
|
63
63
|
five9Id: string;
|
|
64
64
|
communityWfmId: string;
|
|
65
|
-
|
|
65
|
+
divisionId: string | null;
|
|
66
66
|
mainLine: string;
|
|
67
|
-
|
|
67
|
+
lobId: string | null;
|
|
68
68
|
employeeRole: string;
|
|
69
69
|
sector: string;
|
|
70
70
|
sprinklrId: string;
|
|
@@ -267,17 +267,17 @@ __decorate([
|
|
|
267
267
|
__metadata("design:type", String)
|
|
268
268
|
], VwUserRoster.prototype, "communityWfmId", void 0);
|
|
269
269
|
__decorate([
|
|
270
|
-
(0, typeorm_1.Column)({ name: '
|
|
270
|
+
(0, typeorm_1.Column)({ name: 'division_id', type: 'bigint', nullable: true }),
|
|
271
271
|
__metadata("design:type", String)
|
|
272
|
-
], VwUserRoster.prototype, "
|
|
272
|
+
], VwUserRoster.prototype, "divisionId", void 0);
|
|
273
273
|
__decorate([
|
|
274
274
|
(0, typeorm_1.Column)({ name: 'main_line', type: 'text' }),
|
|
275
275
|
__metadata("design:type", String)
|
|
276
276
|
], VwUserRoster.prototype, "mainLine", void 0);
|
|
277
277
|
__decorate([
|
|
278
|
-
(0, typeorm_1.Column)({ name: '
|
|
278
|
+
(0, typeorm_1.Column)({ name: 'lob_id', type: 'bigint', nullable: true }),
|
|
279
279
|
__metadata("design:type", String)
|
|
280
|
-
], VwUserRoster.prototype, "
|
|
280
|
+
], VwUserRoster.prototype, "lobId", void 0);
|
|
281
281
|
__decorate([
|
|
282
282
|
(0, typeorm_1.Column)({ name: 'employee_role', type: 'text' }),
|
|
283
283
|
__metadata("design:type", String)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UsersLobs = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const lob_entity_1 = require("./lob.entity");
|
|
15
|
+
const usr_entity_1 = require("./usr.entity");
|
|
16
|
+
let UsersLobs = class UsersLobs {
|
|
17
|
+
};
|
|
18
|
+
exports.UsersLobs = UsersLobs;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, typeorm_1.PrimaryColumn)({ name: 'client_id', type: 'integer' }),
|
|
21
|
+
__metadata("design:type", Number)
|
|
22
|
+
], UsersLobs.prototype, "clientId", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typeorm_1.PrimaryColumn)({ name: 'user_id', type: 'numeric' }),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], UsersLobs.prototype, "userId", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typeorm_1.PrimaryColumn)({ name: 'lob_id', type: 'bigint' }),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], UsersLobs.prototype, "lobId", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at', type: 'timestamptz' }),
|
|
33
|
+
__metadata("design:type", Date)
|
|
34
|
+
], UsersLobs.prototype, "createdAt", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.UpdateDateColumn)({ name: 'updated_at', type: 'timestamptz' }),
|
|
37
|
+
__metadata("design:type", Date)
|
|
38
|
+
], UsersLobs.prototype, "updatedAt", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.ManyToOne)(() => usr_entity_1.Users, (user) => user.usersLobs, { onDelete: 'CASCADE' }),
|
|
41
|
+
(0, typeorm_1.JoinColumn)([
|
|
42
|
+
{ name: 'user_id', referencedColumnName: 'id' },
|
|
43
|
+
{ name: 'client_id', referencedColumnName: 'clientId' },
|
|
44
|
+
]),
|
|
45
|
+
__metadata("design:type", usr_entity_1.Users)
|
|
46
|
+
], UsersLobs.prototype, "user", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.ManyToOne)(() => lob_entity_1.Lob, (lob) => lob.userLobs),
|
|
49
|
+
(0, typeorm_1.JoinColumn)([
|
|
50
|
+
{ name: 'lob_id', referencedColumnName: 'id' },
|
|
51
|
+
{ name: 'client_id', referencedColumnName: 'clientId' },
|
|
52
|
+
]),
|
|
53
|
+
__metadata("design:type", lob_entity_1.Lob)
|
|
54
|
+
], UsersLobs.prototype, "lob", void 0);
|
|
55
|
+
exports.UsersLobs = UsersLobs = __decorate([
|
|
56
|
+
(0, typeorm_1.Entity)('users_lobs', { schema: 'stm' })
|
|
57
|
+
], UsersLobs);
|
|
@@ -2,6 +2,7 @@ import { Timestamp } from 'typeorm';
|
|
|
2
2
|
import { UserCampaign } from './user-campaign.entity';
|
|
3
3
|
import { UserRoles } from './user-roles.entity';
|
|
4
4
|
import { RawRoster } from './raw_roster.entity';
|
|
5
|
+
import { UsersLobs } from './users-lobs.entity';
|
|
5
6
|
export declare class Users {
|
|
6
7
|
id: number;
|
|
7
8
|
username: string;
|
|
@@ -24,6 +25,8 @@ export declare class Users {
|
|
|
24
25
|
reportsTo: Users;
|
|
25
26
|
userCampaigns: UserCampaign[];
|
|
26
27
|
rawRoster: RawRoster;
|
|
28
|
+
usersLobs: UsersLobs[];
|
|
27
29
|
fullName: string;
|
|
28
|
-
|
|
30
|
+
applyDerivedScope(): void;
|
|
31
|
+
private firstLobDivision;
|
|
29
32
|
}
|
|
@@ -14,9 +14,25 @@ const typeorm_1 = require("typeorm");
|
|
|
14
14
|
const user_campaign_entity_1 = require("./user-campaign.entity");
|
|
15
15
|
const user_roles_entity_1 = require("./user-roles.entity");
|
|
16
16
|
const raw_roster_entity_1 = require("./raw_roster.entity");
|
|
17
|
+
const users_lobs_entity_1 = require("./users-lobs.entity");
|
|
17
18
|
let Users = class Users {
|
|
18
|
-
|
|
19
|
+
applyDerivedScope() {
|
|
20
|
+
var _a;
|
|
19
21
|
this.fullName = `${this.first_name} ${this.last_name}`;
|
|
22
|
+
const lobNames = ((_a = this.usersLobs) !== null && _a !== void 0 ? _a : [])
|
|
23
|
+
.map((assignment) => { var _a; return (_a = assignment.lob) === null || _a === void 0 ? void 0 : _a.name; })
|
|
24
|
+
.filter((name) => Boolean(name))
|
|
25
|
+
.sort((a, b) => a.localeCompare(b));
|
|
26
|
+
this.lob = lobNames.join(',');
|
|
27
|
+
this.division = lobNames.length > 0 ? this.firstLobDivision() : '';
|
|
28
|
+
}
|
|
29
|
+
firstLobDivision() {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const divisions = ((_a = this.usersLobs) !== null && _a !== void 0 ? _a : [])
|
|
32
|
+
.map((assignment) => { var _a, _b; return (_b = (_a = assignment.lob) === null || _a === void 0 ? void 0 : _a.division) === null || _b === void 0 ? void 0 : _b.name; })
|
|
33
|
+
.filter((name) => Boolean(name))
|
|
34
|
+
.sort((a, b) => a.localeCompare(b));
|
|
35
|
+
return (_b = divisions[0]) !== null && _b !== void 0 ? _b : '';
|
|
20
36
|
}
|
|
21
37
|
};
|
|
22
38
|
exports.Users = Users;
|
|
@@ -68,14 +84,6 @@ __decorate([
|
|
|
68
84
|
(0, typeorm_1.Column)({ length: 250, name: 'ntgid' }),
|
|
69
85
|
__metadata("design:type", String)
|
|
70
86
|
], Users.prototype, "ntgid", void 0);
|
|
71
|
-
__decorate([
|
|
72
|
-
(0, typeorm_1.Column)({ length: 250, name: 'lob' }),
|
|
73
|
-
__metadata("design:type", String)
|
|
74
|
-
], Users.prototype, "lob", void 0);
|
|
75
|
-
__decorate([
|
|
76
|
-
(0, typeorm_1.Column)({ length: 250, name: 'division' }),
|
|
77
|
-
__metadata("design:type", String)
|
|
78
|
-
], Users.prototype, "division", void 0);
|
|
79
87
|
__decorate([
|
|
80
88
|
(0, typeorm_1.Column)({ length: 250, name: 'profile' }),
|
|
81
89
|
__metadata("design:type", String)
|
|
@@ -110,12 +118,16 @@ __decorate([
|
|
|
110
118
|
(0, typeorm_1.OneToOne)(() => raw_roster_entity_1.RawRoster, (rawRoster) => rawRoster.user),
|
|
111
119
|
__metadata("design:type", raw_roster_entity_1.RawRoster)
|
|
112
120
|
], Users.prototype, "rawRoster", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
(0, typeorm_1.OneToMany)(() => users_lobs_entity_1.UsersLobs, (usersLobs) => usersLobs.user),
|
|
123
|
+
__metadata("design:type", Array)
|
|
124
|
+
], Users.prototype, "usersLobs", void 0);
|
|
113
125
|
__decorate([
|
|
114
126
|
(0, typeorm_1.AfterLoad)(),
|
|
115
127
|
__metadata("design:type", Function),
|
|
116
128
|
__metadata("design:paramtypes", []),
|
|
117
129
|
__metadata("design:returntype", void 0)
|
|
118
|
-
], Users.prototype, "
|
|
130
|
+
], Users.prototype, "applyDerivedScope", null);
|
|
119
131
|
exports.Users = Users = __decorate([
|
|
120
132
|
(0, typeorm_1.Entity)('USERS')
|
|
121
133
|
], Users);
|
|
@@ -34,6 +34,14 @@ __decorate([
|
|
|
34
34
|
(0, typeorm_1.ViewColumn)(),
|
|
35
35
|
__metadata("design:type", String)
|
|
36
36
|
], VwEscalationAge.prototype, "lob", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.ViewColumn)({ name: 'division_id' }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], VwEscalationAge.prototype, "divisionId", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.ViewColumn)({ name: 'lob_id' }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], VwEscalationAge.prototype, "lobId", void 0);
|
|
37
45
|
__decorate([
|
|
38
46
|
(0, typeorm_1.ViewColumn)(),
|
|
39
47
|
__metadata("design:type", String)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './version-checker.middleware';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./version-checker.middleware"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.versionChecker = versionChecker;
|
|
13
|
+
const fs = require("fs/promises");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
function versionChecker(req, res, next) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const version = (yield fs.readFile(path.join(process.cwd(), 'app-version.txt')))
|
|
18
|
+
.toString()
|
|
19
|
+
.trim();
|
|
20
|
+
if (req.headers['app-version'] !== version)
|
|
21
|
+
return res.status(409).json({
|
|
22
|
+
message: `You need to update the application version to ${version}`,
|
|
23
|
+
status: 409,
|
|
24
|
+
});
|
|
25
|
+
next();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -126,7 +126,10 @@ let TenantAuthorizationService = TenantAuthorizationService_1 = class TenantAuth
|
|
|
126
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
127
|
var _a, _b;
|
|
128
128
|
const [user, client, assignments, accessRows] = yield Promise.all([
|
|
129
|
-
this.userRepository.findOne({
|
|
129
|
+
this.userRepository.findOne({
|
|
130
|
+
where: { id: userId },
|
|
131
|
+
relations: ['usersLobs', 'usersLobs.lob', 'usersLobs.lob.division'],
|
|
132
|
+
}),
|
|
130
133
|
this.clientRepository.findOne({
|
|
131
134
|
where: { id: clientId, deletedAt: (0, typeorm_2.IsNull)() },
|
|
132
135
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniorganization/uni-lib",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"description": "UNI Library",
|
|
5
5
|
"author": "Jhomiguel",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
"dist/**/*",
|
|
10
10
|
"*.md"
|
|
11
11
|
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"start:dev": "tsc -w",
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"prepublishOnly": "pnpm run build",
|
|
16
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
17
|
+
"lint": "tslint -p tsconfig.json -c tslint.json",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:watch": "jest --watch",
|
|
20
|
+
"test:cov": "jest --coverage",
|
|
21
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
22
|
+
},
|
|
12
23
|
"dependencies": {
|
|
13
24
|
"@googlemaps/google-maps-services-js": "^3.4.2",
|
|
14
25
|
"@aws-sdk/client-s3": "^3.833.0",
|
|
@@ -71,15 +82,5 @@
|
|
|
71
82
|
},
|
|
72
83
|
"coverageDirectory": "../coverage",
|
|
73
84
|
"testEnvironment": "node"
|
|
74
|
-
},
|
|
75
|
-
"scripts": {
|
|
76
|
-
"start:dev": "tsc -w",
|
|
77
|
-
"build": "tsc",
|
|
78
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
79
|
-
"lint": "tslint -p tsconfig.json -c tslint.json",
|
|
80
|
-
"test": "jest",
|
|
81
|
-
"test:watch": "jest --watch",
|
|
82
|
-
"test:cov": "jest --coverage",
|
|
83
|
-
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
84
85
|
}
|
|
85
|
-
}
|
|
86
|
+
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.UserClientContext = void 0;
|
|
13
|
-
const typeorm_1 = require("typeorm");
|
|
14
|
-
let UserClientContext = class UserClientContext {
|
|
15
|
-
};
|
|
16
|
-
exports.UserClientContext = UserClientContext;
|
|
17
|
-
__decorate([
|
|
18
|
-
(0, typeorm_1.PrimaryColumn)({ name: 'USER_ID', type: 'numeric' }),
|
|
19
|
-
__metadata("design:type", Number)
|
|
20
|
-
], UserClientContext.prototype, "userId", void 0);
|
|
21
|
-
__decorate([
|
|
22
|
-
(0, typeorm_1.PrimaryColumn)({ name: 'client_id', type: 'integer' }),
|
|
23
|
-
__metadata("design:type", Number)
|
|
24
|
-
], UserClientContext.prototype, "clientId", void 0);
|
|
25
|
-
__decorate([
|
|
26
|
-
(0, typeorm_1.Column)({ type: 'varchar', length: 250, default: '' }),
|
|
27
|
-
__metadata("design:type", String)
|
|
28
|
-
], UserClientContext.prototype, "profile", void 0);
|
|
29
|
-
__decorate([
|
|
30
|
-
(0, typeorm_1.Column)({ type: 'varchar', length: 250, default: '' }),
|
|
31
|
-
__metadata("design:type", String)
|
|
32
|
-
], UserClientContext.prototype, "division", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, typeorm_1.Column)({ type: 'varchar', length: 250, default: '' }),
|
|
35
|
-
__metadata("design:type", String)
|
|
36
|
-
], UserClientContext.prototype, "lob", void 0);
|
|
37
|
-
__decorate([
|
|
38
|
-
(0, typeorm_1.Column)({ name: 'REPORTS_TO', type: 'numeric', nullable: true }),
|
|
39
|
-
__metadata("design:type", Number)
|
|
40
|
-
], UserClientContext.prototype, "reportsToId", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
(0, typeorm_1.CreateDateColumn)({
|
|
43
|
-
name: 'created_at',
|
|
44
|
-
type: 'timestamptz',
|
|
45
|
-
default: () => 'CURRENT_TIMESTAMP',
|
|
46
|
-
}),
|
|
47
|
-
__metadata("design:type", Date)
|
|
48
|
-
], UserClientContext.prototype, "createdAt", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, typeorm_1.UpdateDateColumn)({
|
|
51
|
-
name: 'updated_at',
|
|
52
|
-
type: 'timestamptz',
|
|
53
|
-
default: () => 'CURRENT_TIMESTAMP',
|
|
54
|
-
}),
|
|
55
|
-
__metadata("design:type", Date)
|
|
56
|
-
], UserClientContext.prototype, "updatedAt", void 0);
|
|
57
|
-
exports.UserClientContext = UserClientContext = __decorate([
|
|
58
|
-
(0, typeorm_1.Entity)('USER_CLIENT_CONTEXT', { schema: 'stm' })
|
|
59
|
-
], UserClientContext);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.MasterUsersGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const tenant_constants_1 = require("./tenant.constants");
|
|
12
|
-
let MasterUsersGuard = class MasterUsersGuard {
|
|
13
|
-
canActivate(context) {
|
|
14
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
-
const request = context.switchToHttp().getRequest();
|
|
16
|
-
const user = request.user;
|
|
17
|
-
if (!user || user === true) {
|
|
18
|
-
throw new common_1.UnauthorizedException();
|
|
19
|
-
}
|
|
20
|
-
const effectiveClientId = (_b = (_a = request.tenantContext) === null || _a === void 0 ? void 0 : _a.clientId) !== null && _b !== void 0 ? _b : user.clientId;
|
|
21
|
-
const originalClientId = (_e = (_d = (_c = request.tenantContext) === null || _c === void 0 ? void 0 : _c.originalClientId) !== null && _d !== void 0 ? _d : user.originalClientId) !== null && _e !== void 0 ? _e : null;
|
|
22
|
-
const hasCapability = (user.privileges || []).some((privilege) => privilege.trim().toUpperCase() === tenant_constants_1.MASTER_USERS_ADMIN_PRIVILEGE);
|
|
23
|
-
if (effectiveClientId !== tenant_constants_1.NEWTECH_CLIENT_ID ||
|
|
24
|
-
originalClientId !== null ||
|
|
25
|
-
!user.isMasterTenantAdmin ||
|
|
26
|
-
!hasCapability) {
|
|
27
|
-
throw new common_1.ForbiddenException();
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
exports.MasterUsersGuard = MasterUsersGuard;
|
|
33
|
-
exports.MasterUsersGuard = MasterUsersGuard = __decorate([
|
|
34
|
-
(0, common_1.Injectable)()
|
|
35
|
-
], MasterUsersGuard);
|