@devrev/ts-adaas 1.11.1-beta.4 → 1.11.1-beta.6
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/logger/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,UAAU,EAAyC,MAAM,OAAO,CAAC;AAG1E,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,UAAU,EAAyC,MAAM,OAAO,CAAC;AAG1E,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,MAAO,SAAQ,OAAO;IACjC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAqC;gBAErC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sBAAsB;IAUtD,OAAO,CAAC,aAAa;IAerB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAepC,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI7B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGzC;AAID,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CAyB5E;AACD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE1D;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,YAK5C,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAwBzE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RawAxiosResponseHeaders } from 'axios';
|
|
2
|
-
import { AirdropEvent
|
|
2
|
+
import { AirdropEvent } from '../types/extraction';
|
|
3
3
|
import { WorkerAdapterOptions } from '../types/workers';
|
|
4
4
|
export interface LoggerFactoryInterface {
|
|
5
5
|
event: AirdropEvent;
|
|
@@ -36,7 +36,4 @@ export interface AxiosErrorResponse {
|
|
|
36
36
|
code?: string;
|
|
37
37
|
message?: string;
|
|
38
38
|
}
|
|
39
|
-
export interface LogTags extends EventContext {
|
|
40
|
-
sdk_version: string;
|
|
41
|
-
}
|
|
42
39
|
//# sourceMappingURL=logger.interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.interfaces.d.ts","sourceRoot":"","sources":["../../src/logger/logger.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.interfaces.d.ts","sourceRoot":"","sources":["../../src/logger/logger.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,GAAG,CAAC;IAEhB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAE7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,cAAc,GAAG,cAAc,CAAC;CACtD;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAE3B,MAAM,EAAE,GAAG,CAAC;QACZ,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;KACzB,CAAC;IACF,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,uBAAuB,CAAC;QACjC,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/logger/logger.js
CHANGED
|
@@ -7,15 +7,13 @@ exports.serializeAxiosError = serializeAxiosError;
|
|
|
7
7
|
const node_console_1 = require("node:console");
|
|
8
8
|
const node_util_1 = require("node:util");
|
|
9
9
|
const axios_1 = require("axios");
|
|
10
|
-
const helpers_1 = require("../common/helpers");
|
|
11
10
|
const logger_interfaces_1 = require("./logger.interfaces");
|
|
12
11
|
class Logger extends node_console_1.Console {
|
|
13
12
|
constructor({ event, options }) {
|
|
14
13
|
super(process.stdout, process.stderr);
|
|
15
14
|
this.originalConsole = console;
|
|
16
15
|
this.options = options;
|
|
17
|
-
this.
|
|
18
|
-
this.tags = Object.assign(Object.assign({}, event.payload.event_context), { sdk_version: this.sdkVersion });
|
|
16
|
+
this.tags = Object.assign(Object.assign({}, event.payload.event_context), { dev_oid: event.payload.event_context.dev_oid });
|
|
19
17
|
}
|
|
20
18
|
valueToString(value) {
|
|
21
19
|
if (typeof value === 'string') {
|
|
@@ -23,8 +21,11 @@ class Logger extends node_console_1.Console {
|
|
|
23
21
|
}
|
|
24
22
|
// Use Node.js built-in inspect for everything including errors
|
|
25
23
|
return (0, node_util_1.inspect)(value, {
|
|
26
|
-
compact:
|
|
24
|
+
compact: true,
|
|
27
25
|
depth: Infinity,
|
|
26
|
+
maxArrayLength: Infinity,
|
|
27
|
+
maxStringLength: Infinity,
|
|
28
|
+
breakLength: Infinity,
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
31
|
logFn(args, level) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const node_util_1 = require("node:util");
|
|
4
|
-
const helpers_1 = require("../common/helpers");
|
|
5
4
|
const test_helpers_1 = require("../tests/test-helpers");
|
|
6
5
|
const extraction_1 = require("../types/extraction");
|
|
7
6
|
const logger_1 = require("./logger");
|
|
@@ -47,12 +46,12 @@ describe(logger_1.Logger.name, () => {
|
|
|
47
46
|
jest.restoreAllMocks();
|
|
48
47
|
});
|
|
49
48
|
describe('constructor', () => {
|
|
50
|
-
it('should initialize logger with event context and
|
|
49
|
+
it('should initialize logger with event context and dev_oid', () => {
|
|
51
50
|
const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
|
|
52
51
|
// Access private property for testing
|
|
53
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
53
|
const tags = logger.tags;
|
|
55
|
-
expect(tags).toEqual(Object.assign(Object.assign({}, mockEvent.payload.event_context), {
|
|
54
|
+
expect(tags).toEqual(Object.assign(Object.assign({}, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid }));
|
|
56
55
|
});
|
|
57
56
|
});
|
|
58
57
|
describe('production logging', () => {
|
|
@@ -64,32 +63,26 @@ describe(logger_1.Logger.name, () => {
|
|
|
64
63
|
it('should log single string message without backslashes', () => {
|
|
65
64
|
const message = 'Worker is online. Started processing the task.';
|
|
66
65
|
logger.info(message);
|
|
67
|
-
|
|
68
|
-
const logObject = typeof callArgs === 'string' ? JSON.parse(callArgs) : callArgs;
|
|
69
|
-
expect(logObject).toEqual(Object.assign(Object.assign({ message }, mockEvent.payload.event_context), { sdk_version: (0, helpers_1.getLibraryVersion)() }));
|
|
66
|
+
expect(mockConsoleInfo).toHaveBeenCalledWith(Object.assign(Object.assign({ message }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid }));
|
|
70
67
|
});
|
|
71
68
|
it('should log single object message with JSON stringify', () => {
|
|
72
69
|
const data = { id: 123, name: 'test' };
|
|
73
70
|
logger.info(data);
|
|
74
71
|
const expectedMessage = (0, node_util_1.inspect)(data, {
|
|
75
|
-
compact:
|
|
72
|
+
compact: true,
|
|
76
73
|
depth: Infinity,
|
|
77
74
|
});
|
|
78
|
-
|
|
79
|
-
const logObject = typeof callArgs === 'string' ? JSON.parse(callArgs) : callArgs;
|
|
80
|
-
expect(logObject).toEqual(Object.assign(Object.assign({ message: expectedMessage }, mockEvent.payload.event_context), { sdk_version: (0, helpers_1.getLibraryVersion)() }));
|
|
75
|
+
expect(mockConsoleInfo).toHaveBeenCalledWith(Object.assign(Object.assign({ message: expectedMessage }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid }));
|
|
81
76
|
});
|
|
82
77
|
it('should log multiple arguments joined with space', () => {
|
|
83
78
|
const text = 'Successfully fetched';
|
|
84
79
|
const data = { count: 42 };
|
|
85
80
|
logger.info(text, data);
|
|
86
81
|
const expectedDataMessage = (0, node_util_1.inspect)(data, {
|
|
87
|
-
compact:
|
|
82
|
+
compact: true,
|
|
88
83
|
depth: Infinity,
|
|
89
84
|
});
|
|
90
|
-
|
|
91
|
-
const logObject = typeof callArgs === 'string' ? JSON.parse(callArgs) : callArgs;
|
|
92
|
-
expect(logObject).toEqual(Object.assign(Object.assign({ message: `${text} ${expectedDataMessage}` }, mockEvent.payload.event_context), { sdk_version: (0, helpers_1.getLibraryVersion)() }));
|
|
85
|
+
expect(mockConsoleInfo).toHaveBeenCalledWith(Object.assign(Object.assign({ message: `${text} ${expectedDataMessage}` }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid }));
|
|
93
86
|
});
|
|
94
87
|
it('should handle mixed string and object arguments', () => {
|
|
95
88
|
const text1 = 'Processing';
|
|
@@ -97,12 +90,10 @@ describe(logger_1.Logger.name, () => {
|
|
|
97
90
|
const text2 = 'completed';
|
|
98
91
|
logger.info(text1, data, text2);
|
|
99
92
|
const expectedDataMessage = (0, node_util_1.inspect)(data, {
|
|
100
|
-
compact:
|
|
93
|
+
compact: true,
|
|
101
94
|
depth: Infinity,
|
|
102
95
|
});
|
|
103
|
-
|
|
104
|
-
const logObject = typeof callArgs === 'string' ? JSON.parse(callArgs) : callArgs;
|
|
105
|
-
expect(logObject).toEqual(Object.assign(Object.assign({ message: `${text1} ${expectedDataMessage} ${text2}` }, mockEvent.payload.event_context), { sdk_version: (0, helpers_1.getLibraryVersion)() }));
|
|
96
|
+
expect(mockConsoleInfo).toHaveBeenCalledWith(Object.assign(Object.assign({ message: `${text1} ${expectedDataMessage} ${text2}` }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid }));
|
|
106
97
|
});
|
|
107
98
|
});
|
|
108
99
|
describe('local development logging', () => {
|
|
@@ -150,22 +141,18 @@ describe(logger_1.Logger.name, () => {
|
|
|
150
141
|
it('[edge] should handle empty string message', () => {
|
|
151
142
|
logger.info('');
|
|
152
143
|
expect(mockConsoleInfo).toHaveBeenCalledTimes(1);
|
|
153
|
-
const
|
|
154
|
-
const logObject = typeof callArgs === 'string' ? JSON.parse(callArgs) : callArgs;
|
|
144
|
+
const logObject = mockConsoleInfo.mock.calls[0][0];
|
|
155
145
|
expect(logObject.message).toBe('');
|
|
156
146
|
expect(logObject.dev_oid).toBe(mockEvent.payload.event_context.dev_oid);
|
|
157
147
|
expect(logObject.request_id).toBe(mockEvent.payload.event_context.request_id);
|
|
158
|
-
expect(logObject.sdk_version).toBe((0, helpers_1.getLibraryVersion)());
|
|
159
148
|
});
|
|
160
149
|
it('[edge] should handle null and undefined values', () => {
|
|
161
150
|
logger.info('test', null, undefined);
|
|
162
151
|
expect(mockConsoleInfo).toHaveBeenCalledTimes(1);
|
|
163
|
-
const
|
|
164
|
-
const logObject = typeof callArgs === 'string' ? JSON.parse(callArgs) : callArgs;
|
|
152
|
+
const logObject = mockConsoleInfo.mock.calls[0][0];
|
|
165
153
|
// inspect shows 'null' and 'undefined' as strings
|
|
166
154
|
expect(logObject.message).toBe('test null undefined');
|
|
167
155
|
expect(logObject.dev_oid).toBe(mockEvent.payload.event_context.dev_oid);
|
|
168
|
-
expect(logObject.sdk_version).toBe((0, helpers_1.getLibraryVersion)());
|
|
169
156
|
});
|
|
170
157
|
it('[edge] should handle complex nested objects', () => {
|
|
171
158
|
const complexObject = {
|
|
@@ -178,17 +165,15 @@ describe(logger_1.Logger.name, () => {
|
|
|
178
165
|
};
|
|
179
166
|
logger.info(complexObject);
|
|
180
167
|
expect(mockConsoleInfo).toHaveBeenCalledTimes(1);
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
// The logger uses inspect() with formatting, not JSON.stringify()
|
|
168
|
+
const logObject = mockConsoleInfo.mock.calls[0][0];
|
|
169
|
+
// The logger uses inspect() with compact formatting
|
|
184
170
|
const expectedMessage = require('util').inspect(complexObject, {
|
|
185
|
-
compact:
|
|
171
|
+
compact: true,
|
|
186
172
|
depth: Infinity,
|
|
187
173
|
});
|
|
188
174
|
expect(logObject.message).toBe(expectedMessage);
|
|
189
175
|
expect(logObject.dev_oid).toBe(mockEvent.payload.event_context.dev_oid);
|
|
190
176
|
expect(typeof logObject.callback_url).toBe('string');
|
|
191
|
-
expect(logObject.sdk_version).toBe((0, helpers_1.getLibraryVersion)());
|
|
192
177
|
});
|
|
193
178
|
});
|
|
194
179
|
});
|
package/package.json
CHANGED