@devrev/ts-adaas 1.11.1-beta.11 → 1.11.1-beta.13

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.
@@ -7,7 +7,7 @@ export declare class Logger extends Console {
7
7
  private tags;
8
8
  constructor({ event, options }: LoggerFactoryInterface);
9
9
  private valueToString;
10
- logWithTags(argsString: string, level: LogLevel): void;
10
+ logWithTags(stringifiedArgs: string, level: LogLevel): void;
11
11
  logFn(args: unknown[], level: LogLevel): void;
12
12
  log(...args: unknown[]): void;
13
13
  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;AAIvC,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;IAcrB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAYtD,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAapC,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,OAA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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 } from '../types/extraction';
2
+ import { AirdropEvent, EventContext } from '../types/extraction';
3
3
  import { WorkerAdapterOptions } from '../types/workers';
4
4
  export interface LoggerFactoryInterface {
5
5
  event: AirdropEvent;
@@ -36,4 +36,8 @@ export interface AxiosErrorResponse {
36
36
  code?: string;
37
37
  message?: string;
38
38
  }
39
+ export interface LoggerTags extends EventContext {
40
+ dev_oid: string;
41
+ sdk_version: string;
42
+ }
39
43
  //# 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,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;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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;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -8,14 +8,16 @@ const node_console_1 = require("node:console");
8
8
  const node_util_1 = require("node:util");
9
9
  const node_worker_threads_1 = require("node:worker_threads");
10
10
  const axios_1 = require("axios");
11
+ const constants_1 = require("../common/constants");
11
12
  const workers_1 = require("../types/workers");
12
13
  const logger_interfaces_1 = require("./logger.interfaces");
14
+ // Save the original console object at module load time
15
+ const originalConsole = console;
13
16
  class Logger extends node_console_1.Console {
14
17
  constructor({ event, options }) {
15
18
  super(process.stdout, process.stderr);
16
- this.originalConsole = console;
17
19
  this.options = options;
18
- this.tags = Object.assign(Object.assign({}, event.payload.event_context), { dev_oid: event.payload.event_context.dev_oid });
20
+ this.tags = Object.assign(Object.assign({}, event.payload.event_context), { dev_oid: event.payload.event_context.dev_oid, sdk_version: constants_1.LIBRARY_VERSION });
19
21
  }
20
22
  valueToString(value) {
21
23
  if (typeof value === 'string') {
@@ -29,26 +31,28 @@ class Logger extends node_console_1.Console {
29
31
  maxStringLength: Infinity,
30
32
  });
31
33
  }
32
- logWithTags(argsString, level) {
34
+ logWithTags(stringifiedArgs, level) {
33
35
  var _a;
34
36
  if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isLocalDevelopment) {
35
- this.originalConsole[level](argsString);
37
+ originalConsole[level](stringifiedArgs);
36
38
  }
37
39
  else {
38
- const logObject = Object.assign({ message: argsString }, this.tags);
39
- this.originalConsole[level](JSON.stringify(logObject));
40
+ const logObject = Object.assign({ message: stringifiedArgs }, this.tags);
41
+ originalConsole[level](JSON.stringify(logObject));
40
42
  }
41
43
  }
42
44
  logFn(args, level) {
43
45
  var _a;
44
- const argsString = args.map((arg) => this.valueToString(arg)).join(' ');
46
+ const stringifiedArgs = args
47
+ .map((arg) => this.valueToString(arg))
48
+ .join(' ');
45
49
  if (node_worker_threads_1.isMainThread) {
46
- this.logWithTags(argsString, level);
50
+ this.logWithTags(stringifiedArgs, level);
47
51
  }
48
52
  else {
49
53
  (_a = node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage) === null || _a === void 0 ? void 0 : _a.call(node_worker_threads_1.parentPort, {
50
54
  subject: workers_1.WorkerMessageSubject.WorkerMessageLog,
51
- payload: { argsString, level },
55
+ payload: { stringifiedArgs, level },
52
56
  });
53
57
  }
54
58
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const node_util_1 = require("node:util");
4
+ const constants_1 = require("../common/constants");
4
5
  const test_helpers_1 = require("../tests/test-helpers");
5
6
  const extraction_1 = require("../types/extraction");
6
7
  const logger_1 = require("./logger");
@@ -46,12 +47,12 @@ describe(logger_1.Logger.name, () => {
46
47
  jest.restoreAllMocks();
47
48
  });
48
49
  describe('constructor', () => {
49
- it('should initialize logger with event context and dev_oid', () => {
50
+ it('should initialize logger with event context, dev_oid, and base tags', () => {
50
51
  const logger = new logger_1.Logger({ event: mockEvent, options: mockOptions });
51
52
  // Access private property for testing
52
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
54
  const tags = logger.tags;
54
- expect(tags).toEqual(Object.assign(Object.assign({}, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid }));
55
+ expect(tags).toEqual(Object.assign(Object.assign({}, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid, sdk_version: constants_1.LIBRARY_VERSION }));
55
56
  });
56
57
  });
57
58
  describe('production logging', () => {
@@ -63,7 +64,7 @@ describe(logger_1.Logger.name, () => {
63
64
  it('should log single string message without backslashes', () => {
64
65
  const message = 'Worker is online. Started processing the task.';
65
66
  logger.info(message);
66
- const expectedLogObject = Object.assign(Object.assign({ message }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid });
67
+ const expectedLogObject = Object.assign(Object.assign({ message }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid, sdk_version: constants_1.LIBRARY_VERSION });
67
68
  const actualCall = mockConsoleInfo.mock.calls[0][0];
68
69
  const actualLogObject = JSON.parse(actualCall);
69
70
  expect(actualLogObject).toEqual(expectedLogObject);
@@ -77,7 +78,7 @@ describe(logger_1.Logger.name, () => {
77
78
  maxArrayLength: Infinity,
78
79
  maxStringLength: Infinity,
79
80
  });
80
- const expectedLogObject = Object.assign(Object.assign({ message: expectedMessage }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid });
81
+ const expectedLogObject = Object.assign(Object.assign({ message: expectedMessage }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid, sdk_version: constants_1.LIBRARY_VERSION });
81
82
  const actualCall = mockConsoleInfo.mock.calls[0][0];
82
83
  const actualLogObject = JSON.parse(actualCall);
83
84
  expect(actualLogObject).toEqual(expectedLogObject);
@@ -92,7 +93,7 @@ describe(logger_1.Logger.name, () => {
92
93
  maxArrayLength: Infinity,
93
94
  maxStringLength: Infinity,
94
95
  });
95
- const expectedLogObject = Object.assign(Object.assign({ message: `${text} ${expectedDataMessage}` }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid });
96
+ const expectedLogObject = Object.assign(Object.assign({ message: `${text} ${expectedDataMessage}` }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid, sdk_version: constants_1.LIBRARY_VERSION });
96
97
  const actualCall = mockConsoleInfo.mock.calls[0][0];
97
98
  const actualLogObject = JSON.parse(actualCall);
98
99
  expect(actualLogObject).toEqual(expectedLogObject);
@@ -108,7 +109,7 @@ describe(logger_1.Logger.name, () => {
108
109
  maxArrayLength: Infinity,
109
110
  maxStringLength: Infinity,
110
111
  });
111
- const expectedLogObject = Object.assign(Object.assign({ message: `${text1} ${expectedDataMessage} ${text2}` }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid });
112
+ const expectedLogObject = Object.assign(Object.assign({ message: `${text1} ${expectedDataMessage} ${text2}` }, mockEvent.payload.event_context), { dev_oid: mockEvent.payload.event_context.dev_oid, sdk_version: constants_1.LIBRARY_VERSION });
112
113
  const actualCall = mockConsoleInfo.mock.calls[0][0];
113
114
  const actualLogObject = JSON.parse(actualCall);
114
115
  expect(actualLogObject).toEqual(expectedLogObject);
@@ -172,9 +172,9 @@ class Spawn {
172
172
  worker.on(workers_1.WorkerEvent.WorkerMessage, (message) => {
173
173
  var _a, _b;
174
174
  if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageLog) {
175
- const argsString = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.argsString;
175
+ const stringifiedArgs = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.stringifiedArgs;
176
176
  const level = (_b = message.payload) === null || _b === void 0 ? void 0 : _b.level;
177
- console.logWithTags(argsString, level);
177
+ console.logWithTags(stringifiedArgs, level);
178
178
  }
179
179
  // If worker sends a message that it has emitted an event, then set alreadyEmitted to true.
180
180
  if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageEmitted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/ts-adaas",
3
- "version": "1.11.1-beta.11",
3
+ "version": "1.11.1-beta.13",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",