@uniorganization/uni-lib 1.0.28 → 1.0.31
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/audit.entity.d.ts +19 -0
- package/dist/entities/audit.entity.js +61 -0
- package/dist/entities/{evaluation-form.entity.d.ts → evaluation-forms.entity.d.ts} +6 -2
- package/dist/entities/{evaluation-form.entity.js → evaluation-forms.entity.js} +17 -15
- package/dist/entities/index.d.ts +2 -0
- package/dist/entities/index.js +2 -0
- package/dist/entities/question-group.entity.d.ts +2 -0
- package/dist/entities/question-group.entity.js +6 -0
- package/dist/interceptors/audit-user-activity.interceptor.d.ts +12 -0
- package/dist/interceptors/audit-user-activity.interceptor.js +57 -0
- package/dist/interceptors/index.d.ts +1 -0
- package/dist/{modules/config → interceptors}/index.js +1 -2
- package/dist/services/audit.service.d.ts +8 -0
- package/dist/services/audit.service.js +49 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +13 -0
- package/package.json +3 -2
- package/dist/modules/auth.module.d.ts +0 -0
- package/dist/modules/auth.module.js +0 -0
- package/dist/modules/config/config.module.d.ts +0 -2
- package/dist/modules/config/config.module.js +0 -32
- package/dist/modules/config/config.service.d.ts +0 -18
- package/dist/modules/config/config.service.js +0 -173
- package/dist/modules/config/index.d.ts +0 -2
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -7
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Timestamp } from 'typeorm';
|
|
2
|
+
import { Users } from './usr.entity';
|
|
3
|
+
export declare enum RequestType {
|
|
4
|
+
GET = "GET",
|
|
5
|
+
POST = "POST",
|
|
6
|
+
DELETE = "DELETE",
|
|
7
|
+
PUT = "PUT",
|
|
8
|
+
PATCH = "PATCH"
|
|
9
|
+
}
|
|
10
|
+
export declare class Audit {
|
|
11
|
+
id: number;
|
|
12
|
+
dateTime: Timestamp;
|
|
13
|
+
beforeValue: JSON;
|
|
14
|
+
afterValue: JSON;
|
|
15
|
+
requestType: RequestType;
|
|
16
|
+
objectId: number;
|
|
17
|
+
objectType: string;
|
|
18
|
+
user: Users;
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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.Audit = exports.RequestType = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const usr_entity_1 = require("./usr.entity");
|
|
15
|
+
var RequestType;
|
|
16
|
+
(function (RequestType) {
|
|
17
|
+
RequestType["GET"] = "GET";
|
|
18
|
+
RequestType["POST"] = "POST";
|
|
19
|
+
RequestType["DELETE"] = "DELETE";
|
|
20
|
+
RequestType["PUT"] = "PUT";
|
|
21
|
+
RequestType["PATCH"] = "PATCH";
|
|
22
|
+
})(RequestType = exports.RequestType || (exports.RequestType = {}));
|
|
23
|
+
let Audit = class Audit {
|
|
24
|
+
};
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
27
|
+
__metadata("design:type", Number)
|
|
28
|
+
], Audit.prototype, "id", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)('timestamp', { name: 'datetime' }),
|
|
31
|
+
__metadata("design:type", typeorm_1.Timestamp)
|
|
32
|
+
], Audit.prototype, "dateTime", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)('json', { name: 'before_value' }),
|
|
35
|
+
__metadata("design:type", Object)
|
|
36
|
+
], Audit.prototype, "beforeValue", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)('json', { name: 'after_value' }),
|
|
39
|
+
__metadata("design:type", Object)
|
|
40
|
+
], Audit.prototype, "afterValue", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ name: 'request_type' }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], Audit.prototype, "requestType", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ name: 'object_id' }),
|
|
47
|
+
__metadata("design:type", Number)
|
|
48
|
+
], Audit.prototype, "objectId", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ name: 'object_type' }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], Audit.prototype, "objectType", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.JoinColumn)({ name: 'user_id' }),
|
|
55
|
+
(0, typeorm_1.ManyToOne)(() => usr_entity_1.Users),
|
|
56
|
+
__metadata("design:type", usr_entity_1.Users)
|
|
57
|
+
], Audit.prototype, "user", void 0);
|
|
58
|
+
Audit = __decorate([
|
|
59
|
+
(0, typeorm_1.Entity)('audit', { schema: 'stm' })
|
|
60
|
+
], Audit);
|
|
61
|
+
exports.Audit = Audit;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Timestamp } from 'typeorm';
|
|
2
2
|
import { QuestionGroup } from './question-group.entity';
|
|
3
|
-
export
|
|
3
|
+
export interface DivisionLob {
|
|
4
|
+
division: string;
|
|
5
|
+
lob: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class EvaluationForms {
|
|
4
8
|
id: number;
|
|
5
9
|
name: string;
|
|
6
10
|
isActive: boolean;
|
|
7
11
|
dateCreated: Timestamp;
|
|
8
12
|
scoreType: string;
|
|
9
|
-
divisionLob:
|
|
13
|
+
divisionLob: DivisionLob[];
|
|
10
14
|
isDefault: boolean;
|
|
11
15
|
questionGroups: QuestionGroup[];
|
|
12
16
|
}
|
|
@@ -9,44 +9,46 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.EvaluationForms = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const question_group_entity_1 = require("./question-group.entity");
|
|
15
|
-
let
|
|
15
|
+
let EvaluationForms = class EvaluationForms {
|
|
16
16
|
};
|
|
17
17
|
__decorate([
|
|
18
18
|
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
19
19
|
__metadata("design:type", Number)
|
|
20
|
-
],
|
|
20
|
+
], EvaluationForms.prototype, "id", void 0);
|
|
21
21
|
__decorate([
|
|
22
22
|
(0, typeorm_1.Column)(),
|
|
23
23
|
__metadata("design:type", String)
|
|
24
|
-
],
|
|
24
|
+
], EvaluationForms.prototype, "name", void 0);
|
|
25
25
|
__decorate([
|
|
26
26
|
(0, typeorm_1.Column)({ name: 'is_active' }),
|
|
27
27
|
__metadata("design:type", Boolean)
|
|
28
|
-
],
|
|
28
|
+
], EvaluationForms.prototype, "isActive", void 0);
|
|
29
29
|
__decorate([
|
|
30
30
|
(0, typeorm_1.Column)('timestamp', { name: 'date_created', default: new Date() }),
|
|
31
31
|
__metadata("design:type", typeorm_1.Timestamp)
|
|
32
|
-
],
|
|
32
|
+
], EvaluationForms.prototype, "dateCreated", void 0);
|
|
33
33
|
__decorate([
|
|
34
34
|
(0, typeorm_1.Column)({ name: 'score_type' }),
|
|
35
35
|
__metadata("design:type", String)
|
|
36
|
-
],
|
|
36
|
+
], EvaluationForms.prototype, "scoreType", void 0);
|
|
37
37
|
__decorate([
|
|
38
38
|
(0, typeorm_1.Column)('jsonb', { name: 'division_lob' }),
|
|
39
|
-
__metadata("design:type",
|
|
40
|
-
],
|
|
39
|
+
__metadata("design:type", Array)
|
|
40
|
+
], EvaluationForms.prototype, "divisionLob", void 0);
|
|
41
41
|
__decorate([
|
|
42
42
|
(0, typeorm_1.Column)({ name: 'is_default' }),
|
|
43
43
|
__metadata("design:type", Boolean)
|
|
44
|
-
],
|
|
44
|
+
], EvaluationForms.prototype, "isDefault", void 0);
|
|
45
45
|
__decorate([
|
|
46
|
-
(0, typeorm_1.OneToMany)(() => question_group_entity_1.QuestionGroup, (questionGroup) => questionGroup.
|
|
46
|
+
(0, typeorm_1.OneToMany)(() => question_group_entity_1.QuestionGroup, (questionGroup) => questionGroup.form, {
|
|
47
|
+
eager: true,
|
|
48
|
+
}),
|
|
47
49
|
__metadata("design:type", Array)
|
|
48
|
-
],
|
|
49
|
-
|
|
50
|
+
], EvaluationForms.prototype, "questionGroups", void 0);
|
|
51
|
+
EvaluationForms = __decorate([
|
|
50
52
|
(0, typeorm_1.Entity)('evaluation_form', { schema: 'tracking' })
|
|
51
|
-
],
|
|
52
|
-
exports.
|
|
53
|
+
], EvaluationForms);
|
|
54
|
+
exports.EvaluationForms = EvaluationForms;
|
package/dist/entities/index.d.ts
CHANGED
package/dist/entities/index.js
CHANGED
|
@@ -70,3 +70,5 @@ __exportStar(require("./user-roles.entity"), exports);
|
|
|
70
70
|
__exportStar(require("./usr.entity"), exports);
|
|
71
71
|
__exportStar(require("./vw-escalation-age"), exports);
|
|
72
72
|
__exportStar(require("./warranty-category.entity"), exports);
|
|
73
|
+
__exportStar(require("./audit.entity"), exports);
|
|
74
|
+
__exportStar(require("./evaluation-forms.entity"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EvaluationForms } from './evaluation-forms.entity';
|
|
1
2
|
import { Questions } from './questions.entity';
|
|
2
3
|
export declare class QuestionGroup {
|
|
3
4
|
id: number;
|
|
@@ -6,4 +7,5 @@ export declare class QuestionGroup {
|
|
|
6
7
|
sequence: number;
|
|
7
8
|
hideScore: boolean;
|
|
8
9
|
questions: Questions[];
|
|
10
|
+
form: EvaluationForms;
|
|
9
11
|
}
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.QuestionGroup = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
|
+
const evaluation_forms_entity_1 = require("./evaluation-forms.entity");
|
|
14
15
|
const questions_entity_1 = require("./questions.entity");
|
|
15
16
|
let QuestionGroup = class QuestionGroup {
|
|
16
17
|
};
|
|
@@ -38,6 +39,11 @@ __decorate([
|
|
|
38
39
|
(0, typeorm_1.OneToMany)(() => questions_entity_1.Questions, (question) => question.group),
|
|
39
40
|
__metadata("design:type", Array)
|
|
40
41
|
], QuestionGroup.prototype, "questions", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.ManyToOne)(() => evaluation_forms_entity_1.EvaluationForms, (form) => form.id),
|
|
44
|
+
(0, typeorm_1.JoinColumn)({ name: 'form_id' }),
|
|
45
|
+
__metadata("design:type", evaluation_forms_entity_1.EvaluationForms)
|
|
46
|
+
], QuestionGroup.prototype, "form", void 0);
|
|
41
47
|
QuestionGroup = __decorate([
|
|
42
48
|
(0, typeorm_1.Entity)('question_group', { schema: 'tracking' })
|
|
43
49
|
], QuestionGroup);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { EntityManager } from 'typeorm';
|
|
5
|
+
import { AuditService } from '../services/audit.service';
|
|
6
|
+
export declare class AuditUserActivityInterceptor implements NestInterceptor {
|
|
7
|
+
private readonly auditService;
|
|
8
|
+
private readonly entityManager;
|
|
9
|
+
private reflector;
|
|
10
|
+
constructor(auditService: AuditService, entityManager: EntityManager, reflector: Reflector);
|
|
11
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
12
|
+
}
|
|
@@ -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.AuditUserActivityInterceptor = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const entities_1 = require("../entities");
|
|
16
|
+
const rxjs_1 = require("rxjs");
|
|
17
|
+
const typeorm_1 = require("typeorm");
|
|
18
|
+
const audit_service_1 = require("../services/audit.service");
|
|
19
|
+
let AuditUserActivityInterceptor = class AuditUserActivityInterceptor {
|
|
20
|
+
constructor(auditService, entityManager, reflector) {
|
|
21
|
+
this.auditService = auditService;
|
|
22
|
+
this.entityManager = entityManager;
|
|
23
|
+
this.reflector = reflector;
|
|
24
|
+
}
|
|
25
|
+
intercept(context, next) {
|
|
26
|
+
var _a;
|
|
27
|
+
const request = context.switchToHttp().getRequest();
|
|
28
|
+
const { body, params, user: { payload: { user: loggedUser }, }, } = request;
|
|
29
|
+
const operation = context.getHandler().name;
|
|
30
|
+
if (!/create?\w+|update?\w+/.test(operation))
|
|
31
|
+
return next.handle();
|
|
32
|
+
const objectId = (_a = body.id) !== null && _a !== void 0 ? _a : params.id;
|
|
33
|
+
const objectType = this.reflector.get('type', context.getClass());
|
|
34
|
+
const audit = new entities_1.Audit();
|
|
35
|
+
audit.objectId = objectId;
|
|
36
|
+
this.entityManager
|
|
37
|
+
.getRepository(objectType)
|
|
38
|
+
.findOne(objectId)
|
|
39
|
+
.then((data) => {
|
|
40
|
+
audit.beforeValue = data;
|
|
41
|
+
});
|
|
42
|
+
audit.requestType = entities_1.RequestType[request.method];
|
|
43
|
+
audit.objectType = objectType;
|
|
44
|
+
audit.user = loggedUser;
|
|
45
|
+
return next.handle().pipe((0, rxjs_1.tap)((data) => {
|
|
46
|
+
audit.afterValue = data;
|
|
47
|
+
this.auditService.recordOperation(audit);
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
AuditUserActivityInterceptor = __decorate([
|
|
52
|
+
(0, common_1.Injectable)(),
|
|
53
|
+
__metadata("design:paramtypes", [audit_service_1.AuditService,
|
|
54
|
+
typeorm_1.EntityManager,
|
|
55
|
+
core_1.Reflector])
|
|
56
|
+
], AuditUserActivityInterceptor);
|
|
57
|
+
exports.AuditUserActivityInterceptor = AuditUserActivityInterceptor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './audit-user-activity.interceptor';
|
|
@@ -10,5 +10,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
14
|
-
__exportStar(require("./config.service"), exports);
|
|
13
|
+
__exportStar(require("./audit-user-activity.interceptor"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Audit } from '../entities';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
export declare class AuditService {
|
|
4
|
+
private readonly auditRepository;
|
|
5
|
+
constructor(auditRepository: Repository<Audit>);
|
|
6
|
+
recordOperation(payload: Audit): Promise<void>;
|
|
7
|
+
findAll(options: Audit): Promise<Audit[]>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.AuditService = void 0;
|
|
25
|
+
const common_1 = require("@nestjs/common");
|
|
26
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
27
|
+
const entities_1 = require("../entities");
|
|
28
|
+
const typeorm_2 = require("typeorm");
|
|
29
|
+
let AuditService = class AuditService {
|
|
30
|
+
constructor(auditRepository) {
|
|
31
|
+
this.auditRepository = auditRepository;
|
|
32
|
+
}
|
|
33
|
+
recordOperation(payload) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
this.auditRepository.save(payload);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
findAll(options) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return yield this.auditRepository.find(options);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
AuditService = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__param(0, (0, typeorm_1.InjectRepository)(entities_1.Audit)),
|
|
47
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
48
|
+
], AuditService);
|
|
49
|
+
exports.AuditService = AuditService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './audit.service';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./audit.service"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniorganization/uni-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "UNI Library",
|
|
5
5
|
"author": "Jhomiguel",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"passport": "^0.5.0",
|
|
33
33
|
"passport-jwt": "^4.0.0",
|
|
34
34
|
"swagger-ui-express": "^4.1.6",
|
|
35
|
-
"typeorm": "^0.2.41"
|
|
35
|
+
"typeorm": "^0.2.41",
|
|
36
|
+
"rxjs": "^7.4.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@nestjs/cli": "^7.6.0",
|
|
File without changes
|
|
File without changes
|
|
@@ -1,32 +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.ConfigurationModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const typeorm_1 = require("@nestjs/typeorm");
|
|
12
|
-
const config_service_1 = require("./config.service");
|
|
13
|
-
const axios_1 = require("@nestjs/axios");
|
|
14
|
-
const aes_gcm_1 = require("@nestrx/aes-gcm");
|
|
15
|
-
const config_entity_1 = require("../../entities/config.entity");
|
|
16
|
-
let ConfigurationModule = class ConfigurationModule {
|
|
17
|
-
};
|
|
18
|
-
ConfigurationModule = __decorate([
|
|
19
|
-
(0, common_1.Module)({
|
|
20
|
-
imports: [
|
|
21
|
-
aes_gcm_1.AesGcmModule.forRoot(process.env.JWT_KEY),
|
|
22
|
-
typeorm_1.TypeOrmModule.forFeature([config_entity_1.Config]),
|
|
23
|
-
axios_1.HttpModule.register({
|
|
24
|
-
timeout: Number(process.env.REQUEST_TIMEOUT) || 5000,
|
|
25
|
-
maxRedirects: Number(process.env.MAX_REDIRECTS) || 5,
|
|
26
|
-
}),
|
|
27
|
-
],
|
|
28
|
-
providers: [config_service_1.ConfigService],
|
|
29
|
-
exports: [typeorm_1.TypeOrmModule, config_service_1.ConfigService],
|
|
30
|
-
})
|
|
31
|
-
], ConfigurationModule);
|
|
32
|
-
exports.ConfigurationModule = ConfigurationModule;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Repository } from 'typeorm';
|
|
2
|
-
import { AesGcmService } from '@nestrx/aes-gcm';
|
|
3
|
-
import { HttpService } from '@nestjs/axios';
|
|
4
|
-
import { Config } from '../../entities/config.entity';
|
|
5
|
-
export declare class ConfigService {
|
|
6
|
-
private readonly configRepository;
|
|
7
|
-
private readonly httpService;
|
|
8
|
-
private readonly aes;
|
|
9
|
-
constructor(configRepository: Repository<Config>, httpService: HttpService, aes: AesGcmService);
|
|
10
|
-
findAll(options?: Config): Promise<Config[]>;
|
|
11
|
-
findOne(param: any): Promise<Config>;
|
|
12
|
-
findByKey(key: string): Promise<Config>;
|
|
13
|
-
save(config: Config): Promise<any>;
|
|
14
|
-
getP1Details(): Promise<any>;
|
|
15
|
-
private findProperty;
|
|
16
|
-
p1Login(): Promise<void>;
|
|
17
|
-
getTicketDetailsFromP1(transaction_id: string): Promise<any>;
|
|
18
|
-
}
|
|
@@ -1,173 +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
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.ConfigService = void 0;
|
|
25
|
-
const common_1 = require("@nestjs/common");
|
|
26
|
-
const typeorm_1 = require("@nestjs/typeorm");
|
|
27
|
-
const typeorm_2 = require("typeorm");
|
|
28
|
-
const aes_gcm_1 = require("@nestrx/aes-gcm");
|
|
29
|
-
const axios_1 = require("@nestjs/axios");
|
|
30
|
-
const config_entity_1 = require("../../entities/config.entity");
|
|
31
|
-
let ConfigService = class ConfigService {
|
|
32
|
-
constructor(configRepository, httpService, aes) {
|
|
33
|
-
this.configRepository = configRepository;
|
|
34
|
-
this.httpService = httpService;
|
|
35
|
-
this.aes = aes;
|
|
36
|
-
}
|
|
37
|
-
findAll(options) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
try {
|
|
40
|
-
return yield this.configRepository.find({ where: options });
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
throw new common_1.BadRequestException(error.message);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
findOne(param) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
try {
|
|
50
|
-
return yield this.configRepository.findOne(param);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw new common_1.BadRequestException(error.message);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
findByKey(key) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
try {
|
|
60
|
-
return yield this.configRepository.findOne({ where: { key: key } });
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
throw new common_1.BadRequestException(error.message);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
save(config) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
try {
|
|
70
|
-
return yield this.configRepository.save(config);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
throw new common_1.BadRequestException(error.message);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
getP1Details() {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
try {
|
|
80
|
-
let p1TokenExpirationDate = new Date((yield this.findByKey('p1.token.expiration')).value);
|
|
81
|
-
let currentDate = new Date();
|
|
82
|
-
if (currentDate > p1TokenExpirationDate) {
|
|
83
|
-
yield this.p1Login();
|
|
84
|
-
}
|
|
85
|
-
return yield this.configRepository.find({
|
|
86
|
-
where: {
|
|
87
|
-
key: (0, typeorm_2.In)([
|
|
88
|
-
'p1.token',
|
|
89
|
-
'p1.ticket.detail.url',
|
|
90
|
-
'p1.company',
|
|
91
|
-
'p1.company.370',
|
|
92
|
-
]),
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
throw new common_1.BadRequestException(error.message);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
findProperty(list, key) {
|
|
102
|
-
try {
|
|
103
|
-
let { value } = list.filter((o) => o.key === key)[0];
|
|
104
|
-
return value;
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
throw new common_1.BadRequestException(error.message);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
p1Login() {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
let p1LoginUrl = yield this.findByKey('p1.login.url');
|
|
113
|
-
let userConfig = yield this.findByKey('p1.login.username');
|
|
114
|
-
let pwdConfig = yield this.findByKey('p1.login.password');
|
|
115
|
-
let p1Token = yield this.findByKey('p1.token');
|
|
116
|
-
let p1TokenExpiration = yield this.findByKey('p1.token.expiration');
|
|
117
|
-
let response = (yield this.httpService
|
|
118
|
-
.post(p1LoginUrl.value, {
|
|
119
|
-
username: userConfig.value,
|
|
120
|
-
password: this.aes.decrypt(pwdConfig.value),
|
|
121
|
-
})
|
|
122
|
-
.toPromise()).data;
|
|
123
|
-
p1Token.value = response.accessToken;
|
|
124
|
-
p1TokenExpiration.value = response.accessTokenExpiresAt;
|
|
125
|
-
yield this.configRepository.save([p1Token, p1TokenExpiration]);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
getTicketDetailsFromP1(transaction_id) {
|
|
129
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
let connDetails = yield this.getP1Details();
|
|
131
|
-
try {
|
|
132
|
-
let response = (yield this.httpService
|
|
133
|
-
.get(this.findProperty(connDetails, 'p1.ticket.detail.url') +
|
|
134
|
-
transaction_id, {
|
|
135
|
-
headers: {
|
|
136
|
-
Authorization: 'Bearer ' + this.findProperty(connDetails, 'p1.token'),
|
|
137
|
-
company: this.findProperty(connDetails, 'p1.company'),
|
|
138
|
-
},
|
|
139
|
-
})
|
|
140
|
-
.toPromise()).data;
|
|
141
|
-
return response;
|
|
142
|
-
}
|
|
143
|
-
catch (error) {
|
|
144
|
-
try {
|
|
145
|
-
let response = (yield this.httpService
|
|
146
|
-
.get(this.findProperty(connDetails, 'p1.ticket.detail.url') +
|
|
147
|
-
transaction_id, {
|
|
148
|
-
headers: {
|
|
149
|
-
Authorization: 'Bearer ' + this.findProperty(connDetails, 'p1.token'),
|
|
150
|
-
company: this.findProperty(connDetails, 'p1.company.370'),
|
|
151
|
-
},
|
|
152
|
-
})
|
|
153
|
-
.toPromise()).data;
|
|
154
|
-
return response;
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
throw new common_1.HttpException({
|
|
158
|
-
status: common_1.HttpStatus.BAD_REQUEST,
|
|
159
|
-
error: error.message,
|
|
160
|
-
}, 400);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
ConfigService = __decorate([
|
|
167
|
-
(0, common_1.Injectable)(),
|
|
168
|
-
__param(0, (0, typeorm_1.InjectRepository)(config_entity_1.Config)),
|
|
169
|
-
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
170
|
-
axios_1.HttpService,
|
|
171
|
-
aes_gcm_1.AesGcmService])
|
|
172
|
-
], ConfigService);
|
|
173
|
-
exports.ConfigService = ConfigService;
|
package/dist/test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getHello(): string;
|