@devrev/ts-adaas 1.11.1-beta.9 → 1.12.1-beta.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.
- package/dist/common/install-initial-domain-mapping.d.ts.map +1 -1
- package/dist/common/install-initial-domain-mapping.js +1 -1
- package/dist/logger/logger.constants.d.ts +6 -0
- package/dist/logger/logger.constants.d.ts.map +1 -0
- package/dist/logger/logger.constants.js +13 -0
- package/dist/logger/logger.d.ts +70 -6
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +4 -1
- package/dist/logger/logger.interfaces.d.ts.map +1 -1
- package/dist/logger/logger.js +102 -46
- package/dist/logger/logger.test.js +427 -192
- package/dist/types/workers.d.ts +1 -0
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/workers/create-worker.d.ts.map +1 -1
- package/dist/workers/create-worker.js +2 -7
- package/dist/workers/spawn.d.ts +2 -2
- package/dist/workers/spawn.d.ts.map +1 -1
- package/dist/workers/spawn.js +31 -20
- package/dist/workers/worker-adapter.d.ts.map +1 -1
- package/dist/workers/worker-adapter.js +34 -37
- package/dist/workers/worker.js +3 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install-initial-domain-mapping.d.ts","sourceRoot":"","sources":["../../src/common/install-initial-domain-mapping.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,YAAY,EACnB,wBAAwB,EAAE,oBAAoB,GAC7C,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"install-initial-domain-mapping.d.ts","sourceRoot":"","sources":["../../src/common/install-initial-domain-mapping.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,YAAY,EACnB,wBAAwB,EAAE,oBAAoB,GAC7C,OAAO,CAAC,IAAI,CAAC,CA0Ff"}
|
|
@@ -54,5 +54,5 @@ async function installInitialDomainMapping(event, initialDomainMappingJson) {
|
|
|
54
54
|
Authorization: devrevToken,
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
|
-
console.log(
|
|
57
|
+
console.log('Successfully installed initial domain mapping', initialDomainMappingInstallResponse.data);
|
|
58
58
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InspectOptions } from 'node:util';
|
|
2
|
+
export declare const MAX_LOG_STRING_LENGTH = 10000;
|
|
3
|
+
export declare const MAX_LOG_DEPTH = 10;
|
|
4
|
+
export declare const MAX_LOG_ARRAY_LENGTH = 100;
|
|
5
|
+
export declare const INSPECT_OPTIONS: InspectOptions;
|
|
6
|
+
//# sourceMappingURL=logger.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.constants.d.ts","sourceRoot":"","sources":["../../src/logger/logger.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,eAAO,MAAM,eAAe,EAAE,cAM7B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INSPECT_OPTIONS = exports.MAX_LOG_ARRAY_LENGTH = exports.MAX_LOG_DEPTH = exports.MAX_LOG_STRING_LENGTH = void 0;
|
|
4
|
+
exports.MAX_LOG_STRING_LENGTH = 10000;
|
|
5
|
+
exports.MAX_LOG_DEPTH = 10;
|
|
6
|
+
exports.MAX_LOG_ARRAY_LENGTH = 100;
|
|
7
|
+
exports.INSPECT_OPTIONS = {
|
|
8
|
+
compact: false,
|
|
9
|
+
breakLength: Infinity,
|
|
10
|
+
depth: exports.MAX_LOG_DEPTH,
|
|
11
|
+
maxArrayLength: exports.MAX_LOG_ARRAY_LENGTH,
|
|
12
|
+
maxStringLength: exports.MAX_LOG_STRING_LENGTH,
|
|
13
|
+
};
|
package/dist/logger/logger.d.ts
CHANGED
|
@@ -1,24 +1,88 @@
|
|
|
1
|
-
import { Console } from 'node:console';
|
|
2
1
|
import { AxiosError } from 'axios';
|
|
2
|
+
import { Console } from 'node:console';
|
|
3
3
|
import { AxiosErrorResponse, LoggerFactoryInterface, LogLevel, PrintableState } from './logger.interfaces';
|
|
4
|
+
/**
|
|
5
|
+
* Custom logger that extends Node.js Console with context-aware logging.
|
|
6
|
+
* Handles local development, main thread, and worker thread logging differently.
|
|
7
|
+
*/
|
|
4
8
|
export declare class Logger extends Console {
|
|
5
9
|
private originalConsole;
|
|
6
10
|
private options?;
|
|
7
11
|
private tags;
|
|
8
12
|
constructor({ event, options }: LoggerFactoryInterface);
|
|
13
|
+
/**
|
|
14
|
+
* Converts any value to a string using `util.inspect()` for complex types.
|
|
15
|
+
*
|
|
16
|
+
* @param value - The value to convert
|
|
17
|
+
* @returns String representation of the value
|
|
18
|
+
*/
|
|
9
19
|
private valueToString;
|
|
10
|
-
|
|
11
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Truncates a message if it exceeds the maximum allowed length.
|
|
22
|
+
* Adds a suffix indicating how many characters were omitted.
|
|
23
|
+
*
|
|
24
|
+
* @param message - The message to truncate
|
|
25
|
+
* @returns Truncated message or original if within limits
|
|
26
|
+
*/
|
|
27
|
+
private truncateMessage;
|
|
28
|
+
/**
|
|
29
|
+
* Logs a pre-formatted message string to the console.
|
|
30
|
+
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
31
|
+
* In local development mode, logs the message directly without JSON wrapping.
|
|
32
|
+
* This is useful when you need to log already-stringified content.
|
|
33
|
+
*
|
|
34
|
+
* @param message - The pre-formatted message string to log
|
|
35
|
+
* @param level - Log level (info, warn, error)
|
|
36
|
+
*/
|
|
37
|
+
logFn(message: string, level: LogLevel): void;
|
|
38
|
+
/**
|
|
39
|
+
* Stringifies and logs arguments to the appropriate destination.
|
|
40
|
+
* On main thread, converts arguments to strings and calls logFn.
|
|
41
|
+
* In worker threads, forwards stringified arguments to the main thread for processing.
|
|
42
|
+
* All arguments are converted to strings using util.inspect and joined with spaces.
|
|
43
|
+
*
|
|
44
|
+
* @param args - Values to log (will be stringified and truncated if needed)
|
|
45
|
+
* @param level - Log level (info, warn, error)
|
|
46
|
+
*/
|
|
47
|
+
private stringifyAndLog;
|
|
12
48
|
log(...args: unknown[]): void;
|
|
13
49
|
info(...args: unknown[]): void;
|
|
14
50
|
warn(...args: unknown[]): void;
|
|
15
51
|
error(...args: unknown[]): void;
|
|
16
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Converts a state object into a printable format where arrays are summarized.
|
|
55
|
+
* Arrays show their length, first item, and last item instead of all elements.
|
|
56
|
+
* Objects are recursively processed and primitives are returned as-is.
|
|
57
|
+
*
|
|
58
|
+
* @param state - State object to convert
|
|
59
|
+
* @returns Printable representation with summarized arrays
|
|
60
|
+
*/
|
|
17
61
|
export declare function getPrintableState(state: Record<string, any>): PrintableState;
|
|
18
62
|
/**
|
|
19
|
-
*
|
|
63
|
+
* Serializes an error into a structured format.
|
|
64
|
+
* Automatically detects and formats Axios errors with HTTP details.
|
|
65
|
+
* Returns other error types as-is.
|
|
66
|
+
*
|
|
67
|
+
* @param error - Error to serialize
|
|
68
|
+
* @returns Serialized error or original if not an Axios error
|
|
69
|
+
*/
|
|
70
|
+
export declare function serializeError(error: unknown): unknown;
|
|
71
|
+
/**
|
|
72
|
+
* Serializes an Axios error into a structured format with HTTP request/response details.
|
|
73
|
+
* Extracts method, URL, parameters, status code, headers, and data.
|
|
74
|
+
* Includes CORS/network failure indicator when no response is available.
|
|
75
|
+
*
|
|
76
|
+
* @param error - Axios error to serialize
|
|
77
|
+
* @returns Structured object with error details
|
|
20
78
|
*/
|
|
21
|
-
export declare function formatAxiosError(error: AxiosError): object;
|
|
22
|
-
export declare const serializeError: (error: unknown) => unknown;
|
|
23
79
|
export declare function serializeAxiosError(error: AxiosError): AxiosErrorResponse;
|
|
80
|
+
/**
|
|
81
|
+
* Formats an Axios error to a printable format.
|
|
82
|
+
*
|
|
83
|
+
* @param error - Axios error to format
|
|
84
|
+
* @returns Formatted error object
|
|
85
|
+
* @deprecated Use {@link serializeAxiosError} instead
|
|
86
|
+
*/
|
|
87
|
+
export declare function formatAxiosError(error: AxiosError): object;
|
|
24
88
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyC,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,qBAAa,MAAO,SAAQ,OAAO;IACjC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAa;gBAEb,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sBAAsB;IAUtD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAOrB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAa7C;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAcd,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;AAED;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CAqB5E;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKtD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAwBzE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE1D"}
|
|
@@ -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,7 @@ export interface AxiosErrorResponse {
|
|
|
36
36
|
code?: string;
|
|
37
37
|
message?: string;
|
|
38
38
|
}
|
|
39
|
+
export interface LoggerTags extends EventContext {
|
|
40
|
+
sdk_version: string;
|
|
41
|
+
}
|
|
39
42
|
//# 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;
|
|
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,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjE,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;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/logger/logger.js
CHANGED
|
@@ -1,81 +1,121 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Logger = void 0;
|
|
4
4
|
exports.getPrintableState = getPrintableState;
|
|
5
|
-
exports.
|
|
5
|
+
exports.serializeError = serializeError;
|
|
6
6
|
exports.serializeAxiosError = serializeAxiosError;
|
|
7
|
+
exports.formatAxiosError = formatAxiosError;
|
|
8
|
+
const axios_1 = require("axios");
|
|
7
9
|
const node_console_1 = require("node:console");
|
|
8
10
|
const node_util_1 = require("node:util");
|
|
9
11
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
10
|
-
const
|
|
12
|
+
const constants_1 = require("../common/constants");
|
|
11
13
|
const workers_1 = require("../types/workers");
|
|
14
|
+
const logger_constants_1 = require("./logger.constants");
|
|
12
15
|
const logger_interfaces_1 = require("./logger.interfaces");
|
|
16
|
+
/**
|
|
17
|
+
* Custom logger that extends Node.js Console with context-aware logging.
|
|
18
|
+
* Handles local development, main thread, and worker thread logging differently.
|
|
19
|
+
*/
|
|
13
20
|
class Logger extends node_console_1.Console {
|
|
14
21
|
constructor({ event, options }) {
|
|
15
22
|
super(process.stdout, process.stderr);
|
|
16
23
|
this.originalConsole = console;
|
|
17
24
|
this.options = options;
|
|
18
|
-
this.tags = Object.assign(Object.assign({}, event.payload.event_context), {
|
|
25
|
+
this.tags = Object.assign(Object.assign({}, event.payload.event_context), { sdk_version: constants_1.LIBRARY_VERSION });
|
|
19
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Converts any value to a string using `util.inspect()` for complex types.
|
|
29
|
+
*
|
|
30
|
+
* @param value - The value to convert
|
|
31
|
+
* @returns String representation of the value
|
|
32
|
+
*/
|
|
20
33
|
valueToString(value) {
|
|
21
34
|
if (typeof value === 'string') {
|
|
22
35
|
return value;
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
return (0, node_util_1.inspect)(value, {
|
|
26
|
-
compact: true,
|
|
27
|
-
depth: Infinity,
|
|
28
|
-
maxArrayLength: Infinity,
|
|
29
|
-
maxStringLength: Infinity,
|
|
30
|
-
breakLength: Infinity,
|
|
31
|
-
});
|
|
37
|
+
return (0, node_util_1.inspect)(value, logger_constants_1.INSPECT_OPTIONS);
|
|
32
38
|
}
|
|
33
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Truncates a message if it exceeds the maximum allowed length.
|
|
41
|
+
* Adds a suffix indicating how many characters were omitted.
|
|
42
|
+
*
|
|
43
|
+
* @param message - The message to truncate
|
|
44
|
+
* @returns Truncated message or original if within limits
|
|
45
|
+
*/
|
|
46
|
+
truncateMessage(message) {
|
|
47
|
+
if (message.length > logger_constants_1.MAX_LOG_STRING_LENGTH) {
|
|
48
|
+
return `${message.substring(0, logger_constants_1.MAX_LOG_STRING_LENGTH)}... ${message.length - logger_constants_1.MAX_LOG_STRING_LENGTH} more characters`;
|
|
49
|
+
}
|
|
50
|
+
return message;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Logs a pre-formatted message string to the console.
|
|
54
|
+
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
55
|
+
* In local development mode, logs the message directly without JSON wrapping.
|
|
56
|
+
* This is useful when you need to log already-stringified content.
|
|
57
|
+
*
|
|
58
|
+
* @param message - The pre-formatted message string to log
|
|
59
|
+
* @param level - Log level (info, warn, error)
|
|
60
|
+
*/
|
|
61
|
+
logFn(message, level) {
|
|
62
|
+
var _a;
|
|
63
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isLocalDevelopment) {
|
|
64
|
+
this.originalConsole[level](message);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
34
67
|
const logObject = Object.assign({ message }, this.tags);
|
|
35
68
|
this.originalConsole[level](JSON.stringify(logObject));
|
|
36
69
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Stringifies and logs arguments to the appropriate destination.
|
|
72
|
+
* On main thread, converts arguments to strings and calls logFn.
|
|
73
|
+
* In worker threads, forwards stringified arguments to the main thread for processing.
|
|
74
|
+
* All arguments are converted to strings using util.inspect and joined with spaces.
|
|
75
|
+
*
|
|
76
|
+
* @param args - Values to log (will be stringified and truncated if needed)
|
|
77
|
+
* @param level - Log level (info, warn, error)
|
|
78
|
+
*/
|
|
79
|
+
stringifyAndLog(args, level) {
|
|
80
|
+
let stringifiedArgs = args.map((arg) => this.valueToString(arg)).join(' ');
|
|
81
|
+
stringifiedArgs = this.truncateMessage(stringifiedArgs);
|
|
82
|
+
if (node_worker_threads_1.isMainThread) {
|
|
83
|
+
this.logFn(stringifiedArgs, level);
|
|
41
84
|
}
|
|
42
85
|
else {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
payload: {
|
|
48
|
-
message,
|
|
49
|
-
level,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
this.logWithTags(message, level);
|
|
55
|
-
}
|
|
86
|
+
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage({
|
|
87
|
+
subject: workers_1.WorkerMessageSubject.WorkerMessageLog,
|
|
88
|
+
payload: { stringifiedArgs, level },
|
|
89
|
+
});
|
|
56
90
|
}
|
|
57
91
|
}
|
|
58
92
|
log(...args) {
|
|
59
|
-
this.
|
|
93
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.INFO);
|
|
60
94
|
}
|
|
61
95
|
info(...args) {
|
|
62
|
-
this.
|
|
96
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.INFO);
|
|
63
97
|
}
|
|
64
98
|
warn(...args) {
|
|
65
|
-
this.
|
|
99
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.WARN);
|
|
66
100
|
}
|
|
67
101
|
error(...args) {
|
|
68
|
-
this.
|
|
102
|
+
this.stringifyAndLog(args, logger_interfaces_1.LogLevel.ERROR);
|
|
69
103
|
}
|
|
70
104
|
}
|
|
71
105
|
exports.Logger = Logger;
|
|
72
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Converts a state object into a printable format where arrays are summarized.
|
|
108
|
+
* Arrays show their length, first item, and last item instead of all elements.
|
|
109
|
+
* Objects are recursively processed and primitives are returned as-is.
|
|
110
|
+
*
|
|
111
|
+
* @param state - State object to convert
|
|
112
|
+
* @returns Printable representation with summarized arrays
|
|
113
|
+
*/
|
|
73
114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
115
|
function getPrintableState(state) {
|
|
75
116
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
117
|
function processValue(value) {
|
|
77
118
|
if (Array.isArray(value)) {
|
|
78
|
-
// If the value is an array, summarize it
|
|
79
119
|
return {
|
|
80
120
|
type: 'array',
|
|
81
121
|
length: value.length,
|
|
@@ -84,32 +124,38 @@ function getPrintableState(state) {
|
|
|
84
124
|
};
|
|
85
125
|
}
|
|
86
126
|
else if (typeof value === 'object' && value !== null) {
|
|
87
|
-
// If the value is an object, recursively process its properties
|
|
88
127
|
const processedObject = {};
|
|
89
128
|
for (const key in value) {
|
|
90
129
|
processedObject[key] = processValue(value[key]);
|
|
91
130
|
}
|
|
92
131
|
return processedObject;
|
|
93
132
|
}
|
|
94
|
-
// For primitive types, return the value as is
|
|
95
133
|
return value;
|
|
96
134
|
}
|
|
97
|
-
// Process the state object directly since it's guaranteed to be an object
|
|
98
135
|
return processValue(state);
|
|
99
136
|
}
|
|
100
137
|
/**
|
|
101
|
-
*
|
|
138
|
+
* Serializes an error into a structured format.
|
|
139
|
+
* Automatically detects and formats Axios errors with HTTP details.
|
|
140
|
+
* Returns other error types as-is.
|
|
141
|
+
*
|
|
142
|
+
* @param error - Error to serialize
|
|
143
|
+
* @returns Serialized error or original if not an Axios error
|
|
102
144
|
*/
|
|
103
|
-
function
|
|
104
|
-
return serializeAxiosError(error);
|
|
105
|
-
}
|
|
106
|
-
const serializeError = (error) => {
|
|
145
|
+
function serializeError(error) {
|
|
107
146
|
if ((0, axios_1.isAxiosError)(error)) {
|
|
108
147
|
return serializeAxiosError(error);
|
|
109
148
|
}
|
|
110
149
|
return error;
|
|
111
|
-
}
|
|
112
|
-
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Serializes an Axios error into a structured format with HTTP request/response details.
|
|
153
|
+
* Extracts method, URL, parameters, status code, headers, and data.
|
|
154
|
+
* Includes CORS/network failure indicator when no response is available.
|
|
155
|
+
*
|
|
156
|
+
* @param error - Axios error to serialize
|
|
157
|
+
* @returns Structured object with error details
|
|
158
|
+
*/
|
|
113
159
|
function serializeAxiosError(error) {
|
|
114
160
|
var _a, _b, _c;
|
|
115
161
|
const serializedAxiosError = {
|
|
@@ -135,3 +181,13 @@ function serializeAxiosError(error) {
|
|
|
135
181
|
}
|
|
136
182
|
return serializedAxiosError;
|
|
137
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Formats an Axios error to a printable format.
|
|
186
|
+
*
|
|
187
|
+
* @param error - Axios error to format
|
|
188
|
+
* @returns Formatted error object
|
|
189
|
+
* @deprecated Use {@link serializeAxiosError} instead
|
|
190
|
+
*/
|
|
191
|
+
function formatAxiosError(error) {
|
|
192
|
+
return serializeAxiosError(error);
|
|
193
|
+
}
|