@cargolift-cdi/types 0.1.20 → 0.1.22
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/diagnostic-latency.entity.d.ts +16 -0
- package/dist/entities/diagnostic-latency.entity.d.ts.map +1 -0
- package/dist/entities/diagnostic-latency.entity.js +41 -0
- package/dist/entities/repository/diagnostic-latency-repository.service.d.ts +22 -0
- package/dist/entities/repository/diagnostic-latency-repository.service.d.ts.map +1 -0
- package/dist/entities/repository/diagnostic-latency-repository.service.js +75 -0
- package/dist/entities/repository/integration-inbound-repository.entity.d.ts +2 -0
- package/dist/entities/repository/integration-inbound-repository.entity.d.ts.map +1 -0
- package/dist/entities/repository/integration-inbound-repository.entity.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entidade de diagnóstico de latência.
|
|
3
|
+
* Armazena o número de hits (requisições / eventos), histórico de log em JSON
|
|
4
|
+
* e timestamps de início e último registro.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DiagnosticLatency {
|
|
7
|
+
id: string;
|
|
8
|
+
hit: number;
|
|
9
|
+
/**
|
|
10
|
+
* Histórico de ocorrências. Mantido como array JSON (jsonb) para facilitar append.
|
|
11
|
+
*/
|
|
12
|
+
log: any[];
|
|
13
|
+
timestamp_start: Date;
|
|
14
|
+
timestamp_last: Date;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=diagnostic-latency.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-latency.entity.d.ts","sourceRoot":"","sources":["../../src/entities/diagnostic-latency.entity.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBACa,iBAAiB;IAE5B,EAAE,EAAG,MAAM,CAAC;IAGZ,GAAG,EAAG,MAAM,CAAC;IAEb;;OAEG;IAEH,GAAG,EAAG,GAAG,EAAE,CAAC;IAGZ,eAAe,EAAG,IAAI,CAAC;IAGvB,cAAc,EAAG,IAAI,CAAC;CACvB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Column, Entity, PrimaryColumn } from 'typeorm';
|
|
8
|
+
/**
|
|
9
|
+
* Entidade de diagnóstico de latência.
|
|
10
|
+
* Armazena o número de hits (requisições / eventos), histórico de log em JSON
|
|
11
|
+
* e timestamps de início e último registro.
|
|
12
|
+
*/
|
|
13
|
+
let DiagnosticLatency = class DiagnosticLatency {
|
|
14
|
+
id;
|
|
15
|
+
hit;
|
|
16
|
+
/**
|
|
17
|
+
* Histórico de ocorrências. Mantido como array JSON (jsonb) para facilitar append.
|
|
18
|
+
*/
|
|
19
|
+
log;
|
|
20
|
+
timestamp_start;
|
|
21
|
+
timestamp_last;
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
PrimaryColumn({ type: 'varchar', length: 80 })
|
|
25
|
+
], DiagnosticLatency.prototype, "id", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
Column({ type: 'int', default: 1 })
|
|
28
|
+
], DiagnosticLatency.prototype, "hit", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
Column({ type: 'jsonb', nullable: true, default: () => "'[]'::jsonb" })
|
|
31
|
+
], DiagnosticLatency.prototype, "log", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
Column({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
|
34
|
+
], DiagnosticLatency.prototype, "timestamp_start", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
Column({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
|
37
|
+
], DiagnosticLatency.prototype, "timestamp_last", void 0);
|
|
38
|
+
DiagnosticLatency = __decorate([
|
|
39
|
+
Entity({ name: 'diagnostic_latency' })
|
|
40
|
+
], DiagnosticLatency);
|
|
41
|
+
export { DiagnosticLatency };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { DiagnosticLatency } from '../diagnostic-latency.entity.js';
|
|
3
|
+
/**
|
|
4
|
+
* Repositório de diagnóstico de latência.
|
|
5
|
+
* Responsável por criar/atualizar registros de latência associados a um id.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DiagnosticLatencyRepositoryService {
|
|
8
|
+
private readonly repo;
|
|
9
|
+
constructor(repo: Repository<DiagnosticLatency>);
|
|
10
|
+
/**
|
|
11
|
+
* Upsert de latência: cria se não existir, senão incrementa hit e atualiza timestamp_last.
|
|
12
|
+
* Opcionalmente adiciona entrada no histórico (log).
|
|
13
|
+
* @param id Identificador único do fluxo / teste.
|
|
14
|
+
* @param logEntry Objeto livre para compor histórico.
|
|
15
|
+
*/
|
|
16
|
+
upsert(id: string, logEntry?: Record<string, any>): Promise<DiagnosticLatency>;
|
|
17
|
+
/** Recupera registro pelo id. */
|
|
18
|
+
get(id: string): Promise<DiagnosticLatency | null>;
|
|
19
|
+
/** Reinicia os contadores e histórico para o id informado. */
|
|
20
|
+
reset(id: string): Promise<DiagnosticLatency>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=diagnostic-latency-repository.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-latency-repository.service.d.ts","sourceRoot":"","sources":["../../../src/entities/repository/diagnostic-latency-repository.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE;;;GAGG;AACH,qBACa,kCAAkC;IAG3C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU,CAAC,iBAAiB,CAAC;IAGtD;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwBpF,iCAAiC;IAC3B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAIxD,8DAA8D;IACxD,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAapD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Injectable } from '@nestjs/common';
|
|
11
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
12
|
+
import { DiagnosticLatency } from '../diagnostic-latency.entity.js';
|
|
13
|
+
/**
|
|
14
|
+
* Repositório de diagnóstico de latência.
|
|
15
|
+
* Responsável por criar/atualizar registros de latência associados a um id.
|
|
16
|
+
*/
|
|
17
|
+
let DiagnosticLatencyRepositoryService = class DiagnosticLatencyRepositoryService {
|
|
18
|
+
repo;
|
|
19
|
+
constructor(repo) {
|
|
20
|
+
this.repo = repo;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Upsert de latência: cria se não existir, senão incrementa hit e atualiza timestamp_last.
|
|
24
|
+
* Opcionalmente adiciona entrada no histórico (log).
|
|
25
|
+
* @param id Identificador único do fluxo / teste.
|
|
26
|
+
* @param logEntry Objeto livre para compor histórico.
|
|
27
|
+
*/
|
|
28
|
+
async upsert(id, logEntry) {
|
|
29
|
+
let entity = await this.repo.findOne({ where: { id } });
|
|
30
|
+
const now = new Date();
|
|
31
|
+
if (entity) {
|
|
32
|
+
entity.hit = (entity.hit || 0) + 1;
|
|
33
|
+
entity.timestamp_last = now;
|
|
34
|
+
if (logEntry) {
|
|
35
|
+
if (!Array.isArray(entity.log))
|
|
36
|
+
entity.log = [];
|
|
37
|
+
entity.log.push(logEntry);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
entity = this.repo.create({
|
|
42
|
+
id,
|
|
43
|
+
hit: 1,
|
|
44
|
+
log: logEntry ? [logEntry] : [],
|
|
45
|
+
timestamp_start: now,
|
|
46
|
+
timestamp_last: now,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return this.repo.save(entity);
|
|
50
|
+
}
|
|
51
|
+
/** Recupera registro pelo id. */
|
|
52
|
+
async get(id) {
|
|
53
|
+
return this.repo.findOne({ where: { id } });
|
|
54
|
+
}
|
|
55
|
+
/** Reinicia os contadores e histórico para o id informado. */
|
|
56
|
+
async reset(id) {
|
|
57
|
+
let entity = await this.repo.findOne({ where: { id } });
|
|
58
|
+
const now = new Date();
|
|
59
|
+
if (entity) {
|
|
60
|
+
entity.hit = 0;
|
|
61
|
+
entity.log = [];
|
|
62
|
+
entity.timestamp_start = now;
|
|
63
|
+
entity.timestamp_last = now;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
entity = this.repo.create({ id, hit: 0, log: [], timestamp_start: now, timestamp_last: now });
|
|
67
|
+
}
|
|
68
|
+
return this.repo.save(entity);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
DiagnosticLatencyRepositoryService = __decorate([
|
|
72
|
+
Injectable(),
|
|
73
|
+
__param(0, InjectRepository(DiagnosticLatency))
|
|
74
|
+
], DiagnosticLatencyRepositoryService);
|
|
75
|
+
export { DiagnosticLatencyRepositoryService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-inbound-repository.entity.d.ts","sourceRoot":"","sources":["../../../src/entities/repository/integration-inbound-repository.entity.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,6 @@ export * from './entities/integration-inbound.entity.js';
|
|
|
11
11
|
export * from './entities/integration-outbound.entity.js';
|
|
12
12
|
export * from './entities/repository/integration-inbound-repository.service.js';
|
|
13
13
|
export * from './entities/repository/integration-outbound-repository.service.js';
|
|
14
|
+
export * from './entities/diagnostic-latency.entity.js';
|
|
15
|
+
export * from './entities/repository/diagnostic-latency-repository.service.js';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iEAAiE,CAAC;AAChF,cAAc,kEAAkE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iEAAiE,CAAC;AAChF,cAAc,kEAAkE,CAAC;AACjF,cAAc,yCAAyC,CAAC;AACxD,cAAc,gEAAgE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,3 +11,5 @@ export * from './entities/integration-inbound.entity.js';
|
|
|
11
11
|
export * from './entities/integration-outbound.entity.js';
|
|
12
12
|
export * from './entities/repository/integration-inbound-repository.service.js';
|
|
13
13
|
export * from './entities/repository/integration-outbound-repository.service.js';
|
|
14
|
+
export * from './entities/diagnostic-latency.entity.js';
|
|
15
|
+
export * from './entities/repository/diagnostic-latency-repository.service.js';
|