@cargolift-cdi/types 0.1.111 → 0.1.112

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.
@@ -1,8 +1,9 @@
1
1
  import { Repository } from 'typeorm';
2
2
  import { LogIntegrationInbound } from '../entities/log-integration-inbound.entity.js';
3
3
  /**
4
- * Repositório de diagnóstico de latência.
4
+ * Repositório de log de integração de entrada (inbound).
5
5
  * Responsável por criar/atualizar registros de latência associados a um id.
6
+ * Possibilidade de reprocessamento e auditoria.
6
7
  */
7
8
  export declare class LogInboundRepositoryService {
8
9
  private readonly repo;
@@ -14,6 +15,6 @@ export declare class LogInboundRepositoryService {
14
15
  * @param timestamp_start
15
16
  * @returns
16
17
  */
17
- register(system: string, event: string, action: string, correlationId: string, data?: Partial<LogIntegrationInbound>): Promise<LogIntegrationInbound | null>;
18
+ register(correlationId: string, data?: Partial<LogIntegrationInbound>): Promise<LogIntegrationInbound | null>;
18
19
  }
19
20
  //# sourceMappingURL=log-integration-inbound.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log-integration-inbound.service.d.ts","sourceRoot":"","sources":["../../src/repository/log-integration-inbound.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAGtF;;;GAGG;AACH,qBACa,2BAA2B;IAGpC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU,CAAC,qBAAqB,CAAC;IAG1D;;;;;;OAMG;IACG,QAAQ,CACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE,OAAO,CAAC,qBAAqB,CAAM,GACxC,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;CAyBzC"}
1
+ {"version":3,"file":"log-integration-inbound.service.d.ts","sourceRoot":"","sources":["../../src/repository/log-integration-inbound.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAGtF;;;;GAIG;AACH,qBACa,2BAA2B;IAGpC,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU,CAAC,qBAAqB,CAAC;IAG1D;;;;;;OAMG;IACG,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,GAAE,OAAO,CAAC,qBAAqB,CAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;CA0BxH"}
@@ -12,8 +12,9 @@ import { InjectRepository } from '@nestjs/typeorm';
12
12
  import { LogIntegrationInbound } from '../entities/log-integration-inbound.entity.js';
13
13
  import { IntegrationStatus } from '../enum/integration.enums.js';
14
14
  /**
15
- * Repositório de diagnóstico de latência.
15
+ * Repositório de log de integração de entrada (inbound).
16
16
  * Responsável por criar/atualizar registros de latência associados a um id.
17
+ * Possibilidade de reprocessamento e auditoria.
17
18
  */
18
19
  let LogInboundRepositoryService = class LogInboundRepositoryService {
19
20
  repo;
@@ -27,25 +28,26 @@ let LogInboundRepositoryService = class LogInboundRepositoryService {
27
28
  * @param timestamp_start
28
29
  * @returns
29
30
  */
30
- async register(system, event, action, correlationId, data = {}) {
31
+ async register(correlationId, data = {}) {
31
32
  const payload = {
32
- system,
33
- event,
34
- action,
35
33
  correlationId,
36
- timestampLast: new Date(),
37
- ...data
34
+ durationProcessMs: data.timestampProcess
35
+ ? Date.now() - new Date(data.timestampProcess || "").getTime()
36
+ : undefined,
37
+ ...data,
38
38
  };
39
- if (data.status === IntegrationStatus.SUCCESS && payload.timestampStart) {
40
- const startTime = new Date(payload.timestampStart).getTime();
39
+ if (data.status === IntegrationStatus.SUCCESS || data.status === IntegrationStatus.FAILED) {
41
40
  const endTime = Date.now();
42
- payload.durationMs = endTime - startTime;
41
+ payload.timestampEnd = new Date();
42
+ if (payload.timestampStart) {
43
+ payload.durationMs = endTime - new Date(payload.timestampStart).getTime();
44
+ }
43
45
  }
44
- await this.repo.upsert(payload, ['correlationId']);
46
+ await this.repo.upsert(payload, ["correlationId"]);
45
47
  return this.repo.findOne({
46
48
  where: {
47
- correlationId
48
- }
49
+ correlationId,
50
+ },
49
51
  });
50
52
  }
51
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cargolift-cdi/types",
3
- "version": "0.1.111",
3
+ "version": "0.1.112",
4
4
  "description": "TypeScript types e interfaces comuns para projetos Cargolift CDI",
5
5
  "keywords": [
6
6
  "typescript",