@devrev/ts-adaas 1.11.1-beta.5 → 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
|
@@ -5,8 +5,8 @@ export declare class Logger extends Console {
|
|
|
5
5
|
private originalConsole;
|
|
6
6
|
private options?;
|
|
7
7
|
private tags;
|
|
8
|
-
private sdkVersion;
|
|
9
8
|
constructor({ event, options }: LoggerFactoryInterface);
|
|
9
|
+
private valueToString;
|
|
10
10
|
logFn(args: unknown[], level: LogLevel): void;
|
|
11
11
|
log(...args: unknown[]): void;
|
|
12
12
|
info(...args: unknown[]): void;
|
|
@@ -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,26 +7,37 @@ 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
|
-
|
|
16
|
+
this.tags = Object.assign(Object.assign({}, event.payload.event_context), { dev_oid: event.payload.event_context.dev_oid });
|
|
17
|
+
}
|
|
18
|
+
valueToString(value) {
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
// Use Node.js built-in inspect for everything including errors
|
|
23
|
+
return (0, node_util_1.inspect)(value, {
|
|
24
|
+
compact: true,
|
|
25
|
+
depth: Infinity,
|
|
26
|
+
maxArrayLength: Infinity,
|
|
27
|
+
maxStringLength: Infinity,
|
|
28
|
+
breakLength: Infinity,
|
|
29
|
+
});
|
|
19
30
|
}
|
|
20
31
|
logFn(args, level) {
|
|
21
32
|
var _a;
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isLocalDevelopment) {
|
|
34
|
+
this.originalConsole[level](...args);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const message = args.map((arg) => this.valueToString(arg)).join(' ');
|
|
38
|
+
const logObject = Object.assign({ message }, this.tags);
|
|
39
|
+
this.originalConsole[level](logObject);
|
|
40
|
+
}
|
|
30
41
|
}
|
|
31
42
|
log(...args) {
|
|
32
43
|
this.logFn(args, logger_interfaces_1.LogLevel.INFO);
|
|
@@ -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: `'${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', () => {
|
|
@@ -115,14 +106,7 @@ describe(logger_1.Logger.name, () => {
|
|
|
115
106
|
const message = 'Test message';
|
|
116
107
|
const data = { test: true };
|
|
117
108
|
logger.info(message, data);
|
|
118
|
-
|
|
119
|
-
const expectedMessage = `'${message}' ${(0, node_util_1.inspect)(data, {
|
|
120
|
-
compact: false,
|
|
121
|
-
depth: Infinity,
|
|
122
|
-
})}`;
|
|
123
|
-
expect(mockConsoleInfo).toHaveBeenCalledWith({
|
|
124
|
-
message: expectedMessage,
|
|
125
|
-
});
|
|
109
|
+
expect(mockConsoleInfo).toHaveBeenCalledWith(message, data);
|
|
126
110
|
});
|
|
127
111
|
});
|
|
128
112
|
describe('log levels', () => {
|
|
@@ -157,22 +141,18 @@ describe(logger_1.Logger.name, () => {
|
|
|
157
141
|
it('[edge] should handle empty string message', () => {
|
|
158
142
|
logger.info('');
|
|
159
143
|
expect(mockConsoleInfo).toHaveBeenCalledTimes(1);
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
expect(logObject.message).toBe("''"); // inspect wraps empty string in quotes
|
|
144
|
+
const logObject = mockConsoleInfo.mock.calls[0][0];
|
|
145
|
+
expect(logObject.message).toBe('');
|
|
163
146
|
expect(logObject.dev_oid).toBe(mockEvent.payload.event_context.dev_oid);
|
|
164
147
|
expect(logObject.request_id).toBe(mockEvent.payload.event_context.request_id);
|
|
165
|
-
expect(logObject.sdk_version).toBe((0, helpers_1.getLibraryVersion)());
|
|
166
148
|
});
|
|
167
149
|
it('[edge] should handle null and undefined values', () => {
|
|
168
150
|
logger.info('test', null, undefined);
|
|
169
151
|
expect(mockConsoleInfo).toHaveBeenCalledTimes(1);
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
expect(logObject.message).toBe("'test' null undefined");
|
|
152
|
+
const logObject = mockConsoleInfo.mock.calls[0][0];
|
|
153
|
+
// inspect shows 'null' and 'undefined' as strings
|
|
154
|
+
expect(logObject.message).toBe('test null undefined');
|
|
174
155
|
expect(logObject.dev_oid).toBe(mockEvent.payload.event_context.dev_oid);
|
|
175
|
-
expect(logObject.sdk_version).toBe((0, helpers_1.getLibraryVersion)());
|
|
176
156
|
});
|
|
177
157
|
it('[edge] should handle complex nested objects', () => {
|
|
178
158
|
const complexObject = {
|
|
@@ -185,17 +165,15 @@ describe(logger_1.Logger.name, () => {
|
|
|
185
165
|
};
|
|
186
166
|
logger.info(complexObject);
|
|
187
167
|
expect(mockConsoleInfo).toHaveBeenCalledTimes(1);
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
// 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
|
|
191
170
|
const expectedMessage = require('util').inspect(complexObject, {
|
|
192
|
-
compact:
|
|
171
|
+
compact: true,
|
|
193
172
|
depth: Infinity,
|
|
194
173
|
});
|
|
195
174
|
expect(logObject.message).toBe(expectedMessage);
|
|
196
175
|
expect(logObject.dev_oid).toBe(mockEvent.payload.event_context.dev_oid);
|
|
197
176
|
expect(typeof logObject.callback_url).toBe('string');
|
|
198
|
-
expect(logObject.sdk_version).toBe((0, helpers_1.getLibraryVersion)());
|
|
199
177
|
});
|
|
200
178
|
});
|
|
201
179
|
});
|
package/package.json
CHANGED