@uniorganization/uni-lib 4.3.4 → 5.0.0
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/division-lob.types.d.ts +23 -0
- package/dist/entities/division-lob.types.js +14 -0
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.js +1 -0
- package/dist/entities/usr.entity.d.ts +1 -3
- package/dist/entities/usr.entity.js +2 -11
- package/dist/entities/vw-escalation-age.d.ts +0 -2
- package/dist/entities/vw-escalation-age.js +0 -8
- package/dist/modules/common/jwt.strategy.js +2 -3
- package/dist/modules/tenant/tenant-authorization.keys.js +1 -1
- package/dist/modules/tenant/tenant-authorization.service.js +4 -4
- package/dist/modules/tenant/tenant-authorization.types.d.ts +1 -2
- package/dist/modules/tenant/tenant.types.d.ts +1 -2
- package/dist/utils/division-lob-catalog.d.ts +9 -0
- package/dist/utils/division-lob-catalog.js +60 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface DivisionReference {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
export interface LobReference {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
division: DivisionReference;
|
|
9
|
+
}
|
|
10
|
+
export interface DivisionLobScope {
|
|
11
|
+
division: DivisionReference | null;
|
|
12
|
+
lob: LobReference | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function toLobReference(assignment: {
|
|
15
|
+
lob?: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
division?: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
} | null;
|
|
22
|
+
} | null;
|
|
23
|
+
}): LobReference | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toLobReference = toLobReference;
|
|
4
|
+
function toLobReference(assignment) {
|
|
5
|
+
const lob = assignment.lob;
|
|
6
|
+
const division = lob === null || lob === void 0 ? void 0 : lob.division;
|
|
7
|
+
if (!lob || !division)
|
|
8
|
+
return null;
|
|
9
|
+
return {
|
|
10
|
+
id: String(lob.id),
|
|
11
|
+
name: lob.name,
|
|
12
|
+
division: { id: String(division.id), name: division.name },
|
|
13
|
+
};
|
|
14
|
+
}
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './config.entity';
|
|
|
9
9
|
export * from './depreciation-categories.entity';
|
|
10
10
|
export * from './depreciation-details.entity';
|
|
11
11
|
export * from './division.entity';
|
|
12
|
+
export * from './division-lob.types';
|
|
12
13
|
export * from './detail-type.entity';
|
|
13
14
|
export * from './lob.entity';
|
|
14
15
|
export * from './users-lobs.entity';
|
package/dist/entities/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __exportStar(require("./config.entity"), exports);
|
|
|
25
25
|
__exportStar(require("./depreciation-categories.entity"), exports);
|
|
26
26
|
__exportStar(require("./depreciation-details.entity"), exports);
|
|
27
27
|
__exportStar(require("./division.entity"), exports);
|
|
28
|
+
__exportStar(require("./division-lob.types"), exports);
|
|
28
29
|
__exportStar(require("./detail-type.entity"), exports);
|
|
29
30
|
__exportStar(require("./lob.entity"), exports);
|
|
30
31
|
__exportStar(require("./users-lobs.entity"), exports);
|
|
@@ -16,8 +16,6 @@ export declare class Users {
|
|
|
16
16
|
is_active: number;
|
|
17
17
|
password_expired: number;
|
|
18
18
|
ntgid: string;
|
|
19
|
-
lob: string;
|
|
20
|
-
division: string;
|
|
21
19
|
profile: string;
|
|
22
20
|
viewEvaluations: boolean;
|
|
23
21
|
ern: string;
|
|
@@ -27,5 +25,5 @@ export declare class Users {
|
|
|
27
25
|
rawRoster: RawRoster;
|
|
28
26
|
usersLobs: UsersLobs[];
|
|
29
27
|
fullName: string;
|
|
30
|
-
|
|
28
|
+
applyCalculatedProperties(): void;
|
|
31
29
|
}
|
|
@@ -16,17 +16,8 @@ const user_roles_entity_1 = require("./user-roles.entity");
|
|
|
16
16
|
const raw_roster_entity_1 = require("./raw_roster.entity");
|
|
17
17
|
const users_lobs_entity_1 = require("./users-lobs.entity");
|
|
18
18
|
let Users = class Users {
|
|
19
|
-
|
|
20
|
-
var _a, _b, _c, _d, _e;
|
|
19
|
+
applyCalculatedProperties() {
|
|
21
20
|
this.fullName = `${this.first_name} ${this.last_name}`;
|
|
22
|
-
const assignments = [...((_a = this.usersLobs) !== null && _a !== void 0 ? _a : [])]
|
|
23
|
-
.filter((assignment) => { var _a; return Boolean((_a = assignment.lob) === null || _a === void 0 ? void 0 : _a.name); })
|
|
24
|
-
.sort((left, right) => { var _a, _b, _c, _d; return ((_b = (_a = left.lob) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '').localeCompare((_d = (_c = right.lob) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : ''); });
|
|
25
|
-
this.lob = assignments
|
|
26
|
-
.map((assignment) => { var _a; return (_a = assignment.lob) === null || _a === void 0 ? void 0 : _a.name; })
|
|
27
|
-
.filter((name) => Boolean(name))
|
|
28
|
-
.join(',');
|
|
29
|
-
this.division = (_e = (_d = (_c = (_b = assignments[0]) === null || _b === void 0 ? void 0 : _b.lob) === null || _c === void 0 ? void 0 : _c.division) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : '';
|
|
30
21
|
}
|
|
31
22
|
};
|
|
32
23
|
exports.Users = Users;
|
|
@@ -121,7 +112,7 @@ __decorate([
|
|
|
121
112
|
__metadata("design:type", Function),
|
|
122
113
|
__metadata("design:paramtypes", []),
|
|
123
114
|
__metadata("design:returntype", void 0)
|
|
124
|
-
], Users.prototype, "
|
|
115
|
+
], Users.prototype, "applyCalculatedProperties", null);
|
|
125
116
|
exports.Users = Users = __decorate([
|
|
126
117
|
(0, typeorm_1.Entity)('USERS')
|
|
127
118
|
], Users);
|
|
@@ -26,14 +26,6 @@ __decorate([
|
|
|
26
26
|
(0, typeorm_1.ViewColumn)(),
|
|
27
27
|
__metadata("design:type", String)
|
|
28
28
|
], VwEscalationAge.prototype, "category", void 0);
|
|
29
|
-
__decorate([
|
|
30
|
-
(0, typeorm_1.ViewColumn)(),
|
|
31
|
-
__metadata("design:type", String)
|
|
32
|
-
], VwEscalationAge.prototype, "division", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, typeorm_1.ViewColumn)(),
|
|
35
|
-
__metadata("design:type", String)
|
|
36
|
-
], VwEscalationAge.prototype, "lob", void 0);
|
|
37
29
|
__decorate([
|
|
38
30
|
(0, typeorm_1.ViewColumn)({ name: 'division_id' }),
|
|
39
31
|
__metadata("design:type", String)
|
|
@@ -35,7 +35,7 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
|
|
|
35
35
|
}
|
|
36
36
|
validate(payload) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
39
|
const signedUser = payload === null || payload === void 0 ? void 0 : payload.user;
|
|
40
40
|
const effectiveClientId = Number(signedUser === null || signedUser === void 0 ? void 0 : signedUser.clientId);
|
|
41
41
|
const originalClientId = (_a = signedUser === null || signedUser === void 0 ? void 0 : signedUser.originalClientId) !== null && _a !== void 0 ? _a : null;
|
|
@@ -80,8 +80,7 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
|
|
|
80
80
|
first_name: identity.firstName,
|
|
81
81
|
username: identity.username,
|
|
82
82
|
last_name: identity.lastName,
|
|
83
|
-
|
|
84
|
-
lob: identity.lob,
|
|
83
|
+
lobIds: (_d = identity.lobIds) !== null && _d !== void 0 ? _d : [],
|
|
85
84
|
fullName: identity.fullName,
|
|
86
85
|
ntgid: identity.ntgid,
|
|
87
86
|
profile: identity.profile,
|
|
@@ -18,7 +18,7 @@ function tokenIdentifier(value) {
|
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
20
|
function tenantAuthorizationKey(clientId, userId) {
|
|
21
|
-
return `client:${positiveInteger(clientId, 'clientId')}:authz:user:${positiveInteger(userId, 'userId')}`;
|
|
21
|
+
return `client:${positiveInteger(clientId, 'clientId')}:authz:v2:user:${positiveInteger(userId, 'userId')}`;
|
|
22
22
|
}
|
|
23
23
|
function revokedAccessTokenKey(jti) {
|
|
24
24
|
return `security:access-token:revoked:${tokenIdentifier(jti)}`;
|
|
@@ -124,7 +124,7 @@ let TenantAuthorizationService = TenantAuthorizationService_1 = class TenantAuth
|
|
|
124
124
|
}
|
|
125
125
|
loadFromDatabase(userId, clientId) {
|
|
126
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
var _a, _b, _c;
|
|
127
|
+
var _a, _b, _c, _d;
|
|
128
128
|
const [user, client, assignments, accessRows] = yield Promise.all([
|
|
129
129
|
this.userRepository.findOne({
|
|
130
130
|
where: { id: userId },
|
|
@@ -168,7 +168,6 @@ let TenantAuthorizationService = TenantAuthorizationService_1 = class TenantAuth
|
|
|
168
168
|
]);
|
|
169
169
|
if (user) {
|
|
170
170
|
user.usersLobs = ((_a = user.usersLobs) !== null && _a !== void 0 ? _a : []).filter((assignment) => Number(assignment.clientId) === clientId);
|
|
171
|
-
user.applyDerivedScope();
|
|
172
171
|
}
|
|
173
172
|
if (!user ||
|
|
174
173
|
!Number(user.is_active) ||
|
|
@@ -236,8 +235,9 @@ let TenantAuthorizationService = TenantAuthorizationService_1 = class TenantAuth
|
|
|
236
235
|
firstName: user.first_name,
|
|
237
236
|
username: user.username,
|
|
238
237
|
lastName: user.last_name,
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
lobIds: ((_d = user.usersLobs) !== null && _d !== void 0 ? _d : [])
|
|
239
|
+
.map((assignment) => String(assignment.lobId))
|
|
240
|
+
.sort(),
|
|
241
241
|
fullName: user.fullName,
|
|
242
242
|
ntgid: user.ntgid,
|
|
243
243
|
profile: user.profile,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataSource, EntityManager } from 'typeorm';
|
|
2
|
+
import { DivisionLobScope } from '../entities/division-lob.types';
|
|
3
|
+
type QueryExecutor = Pick<DataSource | EntityManager, 'query'>;
|
|
4
|
+
export declare function validateDivisionLobIds(executor: QueryExecutor, clientId: number, divisionIdValue: unknown, lobIdValue: unknown): Promise<{
|
|
5
|
+
divisionId: string;
|
|
6
|
+
lobId: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function loadDivisionLobScope(executor: QueryExecutor, clientId: number, divisionIdValue: unknown, lobIdValue: unknown): Promise<DivisionLobScope>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
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.validateDivisionLobIds = validateDivisionLobIds;
|
|
13
|
+
exports.loadDivisionLobScope = loadDivisionLobScope;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
function bigintId(value, field) {
|
|
16
|
+
const normalized = String(value !== null && value !== void 0 ? value : '');
|
|
17
|
+
if (!/^[1-9]\d*$/.test(normalized)) {
|
|
18
|
+
throw new common_1.BadRequestException(`${field} must be a positive bigint identifier`);
|
|
19
|
+
}
|
|
20
|
+
return normalized;
|
|
21
|
+
}
|
|
22
|
+
function validateDivisionLobIds(executor, clientId, divisionIdValue, lobIdValue) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const divisionId = bigintId(divisionIdValue, 'divisionId');
|
|
25
|
+
const lobId = bigintId(lobIdValue, 'lobId');
|
|
26
|
+
const rows = yield executor.query(`SELECT lob.id
|
|
27
|
+
FROM stm.lob lob
|
|
28
|
+
JOIN stm.division division
|
|
29
|
+
ON division.id = lob.division_id
|
|
30
|
+
AND division.client_id = lob.client_id
|
|
31
|
+
WHERE lob.id = $1 AND division.id = $2 AND lob.client_id = $3
|
|
32
|
+
AND lob.deleted_at IS NULL AND division.deleted_at IS NULL`, [lobId, divisionId, clientId]);
|
|
33
|
+
if (!rows.length) {
|
|
34
|
+
throw new common_1.BadRequestException('Division and LOB are not active for this client');
|
|
35
|
+
}
|
|
36
|
+
return { divisionId, lobId };
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function loadDivisionLobScope(executor, clientId, divisionIdValue, lobIdValue) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (divisionIdValue == null && lobIdValue == null) {
|
|
42
|
+
return { division: null, lob: null };
|
|
43
|
+
}
|
|
44
|
+
const divisionId = bigintId(divisionIdValue, 'divisionId');
|
|
45
|
+
const lobId = bigintId(lobIdValue, 'lobId');
|
|
46
|
+
const rows = yield executor.query(`SELECT division.id::text AS "divisionId", division.name AS "divisionName",
|
|
47
|
+
lob.id::text AS "lobId", lob.name AS "lobName"
|
|
48
|
+
FROM stm.division division
|
|
49
|
+
JOIN stm.lob lob ON lob.division_id = division.id AND lob.client_id = division.client_id
|
|
50
|
+
WHERE division.id = $1 AND lob.id = $2 AND division.client_id = $3`, [divisionId, lobId, clientId]);
|
|
51
|
+
if (!rows.length)
|
|
52
|
+
return { division: null, lob: null };
|
|
53
|
+
const row = rows[0];
|
|
54
|
+
const division = { id: String(row.divisionId), name: row.divisionName };
|
|
55
|
+
return {
|
|
56
|
+
division,
|
|
57
|
+
lob: { id: String(row.lobId), name: row.lobName, division },
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./object.utils"), exports);
|
|
|
18
18
|
__exportStar(require("./string.utils"), exports);
|
|
19
19
|
__exportStar(require("./parse.util"), exports);
|
|
20
20
|
__exportStar(require("./ticket-service-center-match-progress.util"), exports);
|
|
21
|
+
__exportStar(require("./division-lob-catalog"), exports);
|