ogma-necord-platform 2.2.0 → 2.3.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.
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ExecutionContext } from '@nestjs/common';
|
|
2
2
|
import { AbstractInterceptorService, OgmaInterceptorServiceOptions } from '@ogma/nestjs-module';
|
|
3
|
+
import { MetaLogObject } from '@ogma/nestjs-module/src/interceptor/interfaces/log.interface.js';
|
|
3
4
|
export declare class NecordParser extends AbstractInterceptorService {
|
|
4
5
|
private readonly store;
|
|
6
|
+
getSuccessContext(data: unknown, context: ExecutionContext, startTime: number, options: OgmaInterceptorServiceOptions): MetaLogObject;
|
|
5
7
|
private getContext;
|
|
6
8
|
private getEvent;
|
|
7
9
|
getCallerIp(context: ExecutionContext): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"necord-interceptor.service.d.ts","sourceRoot":"","sources":["../../src/necord-interceptor.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EACN,0BAA0B,EAC1B,6BAA6B,EAE7B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"necord-interceptor.service.d.ts","sourceRoot":"","sources":["../../src/necord-interceptor.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EACN,0BAA0B,EAC1B,6BAA6B,EAE7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,iEAAiE,CAAC;AA4BhG,qBACa,YAAa,SAAQ,0BAA0B;IAC3D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAGlB;IAEK,iBAAiB,CACzB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,6BAA6B,GACpC,aAAa;IAOhB,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,QAAQ;IAqCP,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;IAgB9C,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;IAM5C,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM;IAI/C,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;IAY/C,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAQhE,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM;IAS/C,OAAO,CACf,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,6BAA6B,GACpC,OAAO;CAyCV"}
|
|
@@ -10,6 +10,12 @@ import { AsyncCustomListenerContext, NecordExecutionContext, } from 'necord';
|
|
|
10
10
|
import { BodyMap, CallpointMap, OriginMap, } from '@argentina-community/events-descriptions';
|
|
11
11
|
let NecordParser = class NecordParser extends AbstractInterceptorService {
|
|
12
12
|
store = new WeakMap();
|
|
13
|
+
getSuccessContext(data, context, startTime, options) {
|
|
14
|
+
return {
|
|
15
|
+
...super.getSuccessContext(undefined, context, startTime, options),
|
|
16
|
+
meta: this.getMeta(context, data, options),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
13
19
|
getContext(context) {
|
|
14
20
|
const stored = this.store.get(context);
|
|
15
21
|
if (stored)
|
|
@@ -75,7 +81,34 @@ let NecordParser = class NecordParser extends AbstractInterceptorService {
|
|
|
75
81
|
getMeta(context, _data, options) {
|
|
76
82
|
const event = this.getEvent(context);
|
|
77
83
|
const body = BodyMap[event.name](...event.payload);
|
|
78
|
-
|
|
84
|
+
if (options.json)
|
|
85
|
+
return body;
|
|
86
|
+
const quoteIfNeeded = (value) => /[\s="'`\\]/.test(value)
|
|
87
|
+
? `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`
|
|
88
|
+
: value;
|
|
89
|
+
const serializeValue = (value) => {
|
|
90
|
+
if (value === null)
|
|
91
|
+
return 'null';
|
|
92
|
+
if (value === undefined)
|
|
93
|
+
return '';
|
|
94
|
+
if (typeof value === 'string')
|
|
95
|
+
return quoteIfNeeded(value);
|
|
96
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
97
|
+
return String(value);
|
|
98
|
+
return quoteIfNeeded(JSON.stringify(value));
|
|
99
|
+
};
|
|
100
|
+
const toLogFormat = (obj, prefix = '') => Object.entries(obj)
|
|
101
|
+
.flatMap(([key, value]) => {
|
|
102
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
103
|
+
if (value !== null &&
|
|
104
|
+
typeof value === 'object' &&
|
|
105
|
+
!Array.isArray(value)) {
|
|
106
|
+
return toLogFormat(value, fullKey).split(' ');
|
|
107
|
+
}
|
|
108
|
+
return [`${fullKey}=${serializeValue(value)}`];
|
|
109
|
+
})
|
|
110
|
+
.join(' ');
|
|
111
|
+
return toLogFormat(body);
|
|
79
112
|
}
|
|
80
113
|
};
|
|
81
114
|
NecordParser = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"necord-interceptor.service.js","sourceRoot":"","sources":["../../src/necord-interceptor.service.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EACN,0BAA0B,EAE1B,MAAM,GACN,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"necord-interceptor.service.js","sourceRoot":"","sources":["../../src/necord-interceptor.service.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EACN,0BAA0B,EAE1B,MAAM,GACN,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAgB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,EACN,0BAA0B,EAE1B,sBAAsB,GACtB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACN,OAAO,EACP,YAAY,EAEZ,SAAS,GAIT,MAAM,0CAA0C,CAAC;AAY3C,IAAM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