@visulima/pail 4.0.0-alpha.11 → 4.0.0-alpha.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.
- package/CHANGELOG.md +33 -0
- package/LICENSE.md +131 -900
- package/dist/error.d.ts +95 -96
- package/dist/error.js +5 -76
- package/dist/index.browser.d.ts +557 -47
- package/dist/index.browser.js +19 -1499
- package/dist/index.server.d.ts +722 -61
- package/dist/index.server.js +31 -2803
- package/dist/middleware/elysia.d.ts +65 -63
- package/dist/middleware/elysia.js +1 -70
- package/dist/middleware/express.d.ts +73 -71
- package/dist/middleware/express.js +1 -29
- package/dist/middleware/fastify.d.ts +69 -67
- package/dist/middleware/fastify.js +1 -46
- package/dist/middleware/hono.d.ts +74 -72
- package/dist/middleware/hono.js +1 -33
- package/dist/middleware/next/handler.d.ts +101 -34
- package/dist/middleware/next/handler.js +1 -53
- package/dist/middleware/sveltekit.d.ts +100 -98
- package/dist/middleware/sveltekit.js +1 -43
- package/dist/object-tree.d.ts +67 -70
- package/dist/object-tree.js +2 -89
- package/dist/packem_shared/AbstractJsonReporter-BawNFYxI.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-Dt5-5x2R.js +1 -0
- package/dist/packem_shared/JsonReporter-15ln04rX.js +2 -0
- package/dist/packem_shared/JsonReporter-CerNvhg-.js +1 -0
- package/dist/packem_shared/PrettyReporter-Br5njEEy.js +5 -0
- package/dist/packem_shared/PrettyReporter-CgXnwIip.js +44 -0
- package/dist/packem_shared/abstract-json-reporter.d-Bz3lZEDi.d.ts +61 -0
- package/dist/packem_shared/abstract-pretty-reporter-BiHgKxG_.js +33 -0
- package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
- package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
- package/dist/packem_shared/create-middleware-logger.d-DeNLii5l.d.ts +47 -0
- package/dist/packem_shared/createPailError-53jAfQ-T.js +5 -0
- package/dist/packem_shared/headers-S8WyX-2m.js +1 -0
- package/dist/packem_shared/index-Bzp4LnJ5.js +1 -0
- package/dist/packem_shared/pailMiddleware-CWOJRmJq.js +1 -0
- package/dist/packem_shared/storage-DHM1EP2P.js +1 -0
- package/dist/packem_shared/types.d-ByY2ZuYG.d.ts +246 -0
- package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
- package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
- package/dist/packem_shared/useLogger-qyZrjy4D.js +1 -0
- package/dist/packem_shared/wide-event.d-Ke44zirU.d.ts +704 -0
- package/dist/packem_shared/write-console-log-based-on-level-DfD64owL.js +1 -0
- package/dist/packem_shared/write-stream-Dd4_PTcm.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +49 -47
- package/dist/processor/caller/caller-processor.js +1 -59
- package/dist/processor/environment-processor.d.ts +113 -113
- package/dist/processor/environment-processor.js +1 -89
- package/dist/processor/message-formatter-processor.d.ts +51 -49
- package/dist/processor/message-formatter-processor.js +1 -715
- package/dist/processor/opentelemetry-processor.d.ts +69 -66
- package/dist/processor/opentelemetry-processor.js +1 -52
- package/dist/processor/redact-processor.d.ts +60 -41
- package/dist/processor/redact-processor.js +1 -31
- package/dist/processor/sampling-processor.d.ts +102 -101
- package/dist/processor/sampling-processor.js +1 -59
- package/dist/reporter/file/json-file-reporter.d.ts +91 -42
- package/dist/reporter/file/json-file-reporter.js +2 -136
- package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
- package/dist/reporter/http/abstract-http-reporter.js +2 -432
- package/dist/reporter/http/http-reporter.d.ts +40 -36
- package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
- package/dist/reporter/http/http-reporter.edge-light.js +2 -728
- package/dist/reporter/http/http-reporter.js +1 -13
- package/dist/reporter/json/index.browser.d.ts +99 -3
- package/dist/reporter/json/index.browser.js +1 -2
- package/dist/reporter/json/index.d.ts +51 -3
- package/dist/reporter/json/index.js +1 -2
- package/dist/reporter/pretty/index.browser.d.ts +106 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +186 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
- package/dist/reporter/simple/simple-reporter.server.js +8 -182
- package/dist/wide-event.d.ts +5 -300
- package/dist/wide-event.js +1 -284
- package/package.json +29 -30
- package/dist/constants.d.ts +0 -37
- package/dist/middleware/next/middleware.d.ts +0 -59
- package/dist/middleware/next/storage.d.ts +0 -14
- package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
- package/dist/middleware/shared/headers.d.ts +0 -14
- package/dist/middleware/shared/routes.d.ts +0 -30
- package/dist/middleware/shared/storage.d.ts +0 -29
- package/dist/packem_shared/AbstractJsonReporter-BO8Calb4.js +0 -284
- package/dist/packem_shared/AbstractJsonReporter-nOj0Ft1F.js +0 -284
- package/dist/packem_shared/JsonReporter-CCmj7oYL.js +0 -28
- package/dist/packem_shared/JsonReporter-Ck2PIAEw.js +0 -58
- package/dist/packem_shared/PrettyReporter-BCvyNzXO.js +0 -2720
- package/dist/packem_shared/PrettyReporter-BtTr13Ha.js +0 -213
- package/dist/packem_shared/abstract-pretty-reporter-CXAKYCb8.js +0 -2635
- package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
- package/dist/packem_shared/constants-omsTHUWB.js +0 -119
- package/dist/packem_shared/createPailError-B_sgL0nF.js +0 -76
- package/dist/packem_shared/headers-BxHWM6KI.js +0 -127
- package/dist/packem_shared/index-Bx3-C0j9.js +0 -658
- package/dist/packem_shared/pailMiddleware-Ci88geIF.js +0 -24
- package/dist/packem_shared/storage-D0vqz8OX.js +0 -36
- package/dist/packem_shared/useLogger-D0rU3lcX.js +0 -33
- package/dist/packem_shared/write-console-log-based-on-level-ree2lDPw.js +0 -15
- package/dist/packem_shared/write-stream-MDqyXmc_.js +0 -6
- package/dist/pail.browser.d.ts +0 -412
- package/dist/pail.server.d.ts +0 -158
- package/dist/processor/caller/get-caller-filename.d.ts +0 -23
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
- package/dist/reporter/http/utils/compression.d.ts +0 -7
- package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
- package/dist/reporter/http/utils/retry.d.ts +0 -27
- package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
- package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
- package/dist/reporter/json/json-reporter.server.d.ts +0 -50
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
- package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
- package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
- package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
- package/dist/reporter/utils/format-label.d.ts +0 -3
- package/dist/types.d.ts +0 -241
- package/dist/utils/arrayify.d.ts +0 -2
- package/dist/utils/get-longest-badge.d.ts +0 -4
- package/dist/utils/get-longest-label.d.ts +0 -4
- package/dist/utils/merge-types.d.ts +0 -4
- package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
- package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
- package/dist/utils/write-stream.d.ts +0 -2
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { E as EMPTY_SYMBOL } from './constants-omsTHUWB.js';
|
|
2
|
-
|
|
3
|
-
function isPlainObject(value) {
|
|
4
|
-
if (typeof value !== "object" || value === null) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
const prototype = Object.getPrototypeOf(value);
|
|
8
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const ErrorProto = Object.create(
|
|
12
|
-
{},
|
|
13
|
-
{
|
|
14
|
-
cause: {
|
|
15
|
-
enumerable: false,
|
|
16
|
-
value: void 0,
|
|
17
|
-
writable: true
|
|
18
|
-
},
|
|
19
|
-
code: {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
value: void 0,
|
|
22
|
-
writable: true
|
|
23
|
-
},
|
|
24
|
-
errors: {
|
|
25
|
-
enumerable: false,
|
|
26
|
-
value: void 0,
|
|
27
|
-
writable: true
|
|
28
|
-
},
|
|
29
|
-
message: {
|
|
30
|
-
enumerable: false,
|
|
31
|
-
value: void 0,
|
|
32
|
-
writable: true
|
|
33
|
-
},
|
|
34
|
-
name: {
|
|
35
|
-
enumerable: false,
|
|
36
|
-
value: void 0,
|
|
37
|
-
writable: true
|
|
38
|
-
},
|
|
39
|
-
stack: {
|
|
40
|
-
enumerable: false,
|
|
41
|
-
value: void 0,
|
|
42
|
-
writable: true
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
const toJsonWasCalled = /* @__PURE__ */ new WeakSet();
|
|
47
|
-
const makePropertiesEnumerable = (object) => {
|
|
48
|
-
const props = Object.getOwnPropertyNames(object);
|
|
49
|
-
for (const prop of props) {
|
|
50
|
-
const descriptor = Object.getOwnPropertyDescriptor(object, prop);
|
|
51
|
-
if (descriptor) {
|
|
52
|
-
if (!descriptor.enumerable) {
|
|
53
|
-
Object.defineProperty(object, prop, {
|
|
54
|
-
...descriptor,
|
|
55
|
-
enumerable: true
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
if (descriptor.value && typeof descriptor.value === "object" && !Array.isArray(descriptor.value) && (Object.getPrototypeOf(descriptor.value) === Object.prototype || Object.getPrototypeOf(descriptor.value) === null)) {
|
|
59
|
-
makePropertiesEnumerable(descriptor.value);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const toJSON = (from) => {
|
|
65
|
-
toJsonWasCalled.add(from);
|
|
66
|
-
const json = from.toJSON();
|
|
67
|
-
toJsonWasCalled.delete(from);
|
|
68
|
-
if (
|
|
69
|
-
// Only make properties enumerable if the object is extensible
|
|
70
|
-
// Non-extensible objects (like when toJSON returns 'this') should preserve original enumerability
|
|
71
|
-
Object.isExtensible(json)
|
|
72
|
-
) {
|
|
73
|
-
makePropertiesEnumerable(json);
|
|
74
|
-
}
|
|
75
|
-
return json;
|
|
76
|
-
};
|
|
77
|
-
const serializeValue = (value, seen, depth, options) => {
|
|
78
|
-
if (value && value instanceof Uint8Array && value.constructor.name === "Buffer") {
|
|
79
|
-
return "[object Buffer]";
|
|
80
|
-
}
|
|
81
|
-
if (value !== null && typeof value === "object" && "pipe" in value && typeof value.pipe === "function") {
|
|
82
|
-
return "[object Stream]";
|
|
83
|
-
}
|
|
84
|
-
if (value instanceof Error) {
|
|
85
|
-
if (seen.has(value)) {
|
|
86
|
-
return "[Circular]";
|
|
87
|
-
}
|
|
88
|
-
depth += 1;
|
|
89
|
-
return _serialize(value, options, seen, depth);
|
|
90
|
-
}
|
|
91
|
-
if (options.useToJSON && value !== null && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
|
|
92
|
-
return value.toJSON();
|
|
93
|
-
}
|
|
94
|
-
if (value instanceof Date) {
|
|
95
|
-
return value.toISOString();
|
|
96
|
-
}
|
|
97
|
-
if (typeof value === "function") {
|
|
98
|
-
return `[Function: ${value.name || "anonymous"}]`;
|
|
99
|
-
}
|
|
100
|
-
if (typeof value === "bigint") {
|
|
101
|
-
return `${String(value)}n`;
|
|
102
|
-
}
|
|
103
|
-
if (isPlainObject(value)) {
|
|
104
|
-
if (options.maxDepth !== void 0 && options.maxDepth !== Number.POSITIVE_INFINITY && depth + 1 >= options.maxDepth) {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
depth += 1;
|
|
108
|
-
const plainObject = {};
|
|
109
|
-
for (const key in value) {
|
|
110
|
-
plainObject[key] = serializeValue(value[key], seen, depth, options);
|
|
111
|
-
}
|
|
112
|
-
return plainObject;
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
return value;
|
|
116
|
-
} catch {
|
|
117
|
-
return "[Not Available]";
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const _serialize = (error, options, seen, depth) => {
|
|
121
|
-
seen.add(error);
|
|
122
|
-
if (options.maxDepth === 0) {
|
|
123
|
-
return {};
|
|
124
|
-
}
|
|
125
|
-
if (options.useToJSON && typeof error.toJSON === "function" && !toJsonWasCalled.has(error)) {
|
|
126
|
-
return toJSON(error);
|
|
127
|
-
}
|
|
128
|
-
const protoError = Object.create(ErrorProto);
|
|
129
|
-
Object.defineProperty(protoError, "name", {
|
|
130
|
-
configurable: true,
|
|
131
|
-
enumerable: true,
|
|
132
|
-
value: Object.prototype.toString.call(error.constructor) === "[object Function]" ? error.constructor.name : error.name,
|
|
133
|
-
writable: true
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(protoError, "message", {
|
|
136
|
-
configurable: true,
|
|
137
|
-
enumerable: true,
|
|
138
|
-
value: error.message,
|
|
139
|
-
writable: true
|
|
140
|
-
});
|
|
141
|
-
Object.defineProperty(protoError, "stack", {
|
|
142
|
-
configurable: true,
|
|
143
|
-
enumerable: true,
|
|
144
|
-
value: error.stack,
|
|
145
|
-
writable: true
|
|
146
|
-
});
|
|
147
|
-
if (Array.isArray(error.errors)) {
|
|
148
|
-
const aggregateErrors = [];
|
|
149
|
-
for (const aggregateError of error.errors) {
|
|
150
|
-
if (!(aggregateError instanceof Error)) {
|
|
151
|
-
throw new TypeError("All errors in the 'errors' property must be instances of Error");
|
|
152
|
-
}
|
|
153
|
-
if (seen.has(aggregateError)) {
|
|
154
|
-
Object.defineProperty(protoError, "errors", {
|
|
155
|
-
configurable: true,
|
|
156
|
-
enumerable: true,
|
|
157
|
-
value: [],
|
|
158
|
-
writable: true
|
|
159
|
-
});
|
|
160
|
-
return protoError;
|
|
161
|
-
}
|
|
162
|
-
aggregateErrors.push(_serialize(aggregateError, options, seen, depth));
|
|
163
|
-
}
|
|
164
|
-
Object.defineProperty(protoError, "errors", {
|
|
165
|
-
configurable: true,
|
|
166
|
-
enumerable: true,
|
|
167
|
-
value: aggregateErrors,
|
|
168
|
-
writable: true
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
const causeValue = error.cause;
|
|
172
|
-
if (causeValue !== void 0 && causeValue !== null) {
|
|
173
|
-
if (causeValue instanceof Error) {
|
|
174
|
-
if (seen.has(causeValue)) {
|
|
175
|
-
Object.defineProperty(protoError, "cause", {
|
|
176
|
-
configurable: true,
|
|
177
|
-
enumerable: true,
|
|
178
|
-
value: "[Circular]",
|
|
179
|
-
writable: true
|
|
180
|
-
});
|
|
181
|
-
} else {
|
|
182
|
-
Object.defineProperty(protoError, "cause", {
|
|
183
|
-
configurable: true,
|
|
184
|
-
enumerable: true,
|
|
185
|
-
value: _serialize(causeValue, options, seen, depth),
|
|
186
|
-
writable: true
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
} else {
|
|
190
|
-
const serializedCause = serializeValue(causeValue, seen, depth, options);
|
|
191
|
-
Object.defineProperty(protoError, "cause", {
|
|
192
|
-
configurable: true,
|
|
193
|
-
enumerable: true,
|
|
194
|
-
value: serializedCause,
|
|
195
|
-
writable: true
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
for (const key in error) {
|
|
200
|
-
if (key === "name" || key === "message" || key === "stack" || key === "cause" || key === "errors") {
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
const value = error[key];
|
|
204
|
-
const serializedValue = serializeValue(value, seen, depth, options);
|
|
205
|
-
Object.defineProperty(protoError, key, {
|
|
206
|
-
configurable: true,
|
|
207
|
-
enumerable: true,
|
|
208
|
-
value: serializedValue,
|
|
209
|
-
writable: true
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (Array.isArray(options.exclude) && options.exclude.length > 0) {
|
|
213
|
-
for (const key of options.exclude) {
|
|
214
|
-
try {
|
|
215
|
-
delete protoError[key];
|
|
216
|
-
} catch {
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return protoError;
|
|
221
|
-
};
|
|
222
|
-
const serialize = (error, options = {}) => _serialize(
|
|
223
|
-
error,
|
|
224
|
-
{
|
|
225
|
-
exclude: options.exclude ?? [],
|
|
226
|
-
maxDepth: options.maxDepth ?? Number.POSITIVE_INFINITY,
|
|
227
|
-
useToJSON: options.useToJSON ?? false
|
|
228
|
-
},
|
|
229
|
-
/* @__PURE__ */ new Set(),
|
|
230
|
-
0
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
class AbstractJsonReporter {
|
|
234
|
-
/** Custom stringify function for object serialization */
|
|
235
|
-
stringify;
|
|
236
|
-
/** Error serialization options */
|
|
237
|
-
errorOptions;
|
|
238
|
-
/**
|
|
239
|
-
* Creates a new AbstractJsonReporter instance.
|
|
240
|
-
* @param options Configuration options for JSON formatting and error handling
|
|
241
|
-
*/
|
|
242
|
-
constructor(options = {}) {
|
|
243
|
-
this.errorOptions = options.error ?? {};
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Sets a custom stringify function for object serialization.
|
|
247
|
-
* @param function_ The stringify function to use for serialization
|
|
248
|
-
*/
|
|
249
|
-
setStringify(function_) {
|
|
250
|
-
this.stringify = function_;
|
|
251
|
-
}
|
|
252
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
253
|
-
log(meta) {
|
|
254
|
-
const { context, error, file, message, type, ...rest } = meta;
|
|
255
|
-
if (rest.label) {
|
|
256
|
-
rest.label = rest.label.trim();
|
|
257
|
-
}
|
|
258
|
-
if (file) {
|
|
259
|
-
rest.file = `${file.name ?? ""}:${String(file.line)}${file.column ? `:${String(file.column)}` : ""}`;
|
|
260
|
-
}
|
|
261
|
-
rest.message = message === EMPTY_SYMBOL ? void 0 : message;
|
|
262
|
-
if (error) {
|
|
263
|
-
rest.error = serialize(error, this.errorOptions);
|
|
264
|
-
}
|
|
265
|
-
if (context) {
|
|
266
|
-
const newContext = [];
|
|
267
|
-
for (let i = 0; i < context.length; i += 1) {
|
|
268
|
-
const item = context[i];
|
|
269
|
-
if (item === EMPTY_SYMBOL) {
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
if (item instanceof Error) {
|
|
273
|
-
newContext.push(serialize(item, this.errorOptions));
|
|
274
|
-
} else {
|
|
275
|
-
newContext.push(item);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
rest.context = newContext;
|
|
279
|
-
}
|
|
280
|
-
this._log(this.stringify(rest), type.level);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export { AbstractJsonReporter };
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { E as EMPTY_SYMBOL } from './constants-B1RjD_ps.js';
|
|
2
|
-
|
|
3
|
-
function isPlainObject(value) {
|
|
4
|
-
if (typeof value !== "object" || value === null) {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
const prototype = Object.getPrototypeOf(value);
|
|
8
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const ErrorProto = Object.create(
|
|
12
|
-
{},
|
|
13
|
-
{
|
|
14
|
-
cause: {
|
|
15
|
-
enumerable: false,
|
|
16
|
-
value: void 0,
|
|
17
|
-
writable: true
|
|
18
|
-
},
|
|
19
|
-
code: {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
value: void 0,
|
|
22
|
-
writable: true
|
|
23
|
-
},
|
|
24
|
-
errors: {
|
|
25
|
-
enumerable: false,
|
|
26
|
-
value: void 0,
|
|
27
|
-
writable: true
|
|
28
|
-
},
|
|
29
|
-
message: {
|
|
30
|
-
enumerable: false,
|
|
31
|
-
value: void 0,
|
|
32
|
-
writable: true
|
|
33
|
-
},
|
|
34
|
-
name: {
|
|
35
|
-
enumerable: false,
|
|
36
|
-
value: void 0,
|
|
37
|
-
writable: true
|
|
38
|
-
},
|
|
39
|
-
stack: {
|
|
40
|
-
enumerable: false,
|
|
41
|
-
value: void 0,
|
|
42
|
-
writable: true
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
const toJsonWasCalled = /* @__PURE__ */ new WeakSet();
|
|
47
|
-
const makePropertiesEnumerable = (object) => {
|
|
48
|
-
const props = Object.getOwnPropertyNames(object);
|
|
49
|
-
for (const prop of props) {
|
|
50
|
-
const descriptor = Object.getOwnPropertyDescriptor(object, prop);
|
|
51
|
-
if (descriptor) {
|
|
52
|
-
if (!descriptor.enumerable) {
|
|
53
|
-
Object.defineProperty(object, prop, {
|
|
54
|
-
...descriptor,
|
|
55
|
-
enumerable: true
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
if (descriptor.value && typeof descriptor.value === "object" && !Array.isArray(descriptor.value) && (Object.getPrototypeOf(descriptor.value) === Object.prototype || Object.getPrototypeOf(descriptor.value) === null)) {
|
|
59
|
-
makePropertiesEnumerable(descriptor.value);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const toJSON = (from) => {
|
|
65
|
-
toJsonWasCalled.add(from);
|
|
66
|
-
const json = from.toJSON();
|
|
67
|
-
toJsonWasCalled.delete(from);
|
|
68
|
-
if (
|
|
69
|
-
// Only make properties enumerable if the object is extensible
|
|
70
|
-
// Non-extensible objects (like when toJSON returns 'this') should preserve original enumerability
|
|
71
|
-
Object.isExtensible(json)
|
|
72
|
-
) {
|
|
73
|
-
makePropertiesEnumerable(json);
|
|
74
|
-
}
|
|
75
|
-
return json;
|
|
76
|
-
};
|
|
77
|
-
const serializeValue = (value, seen, depth, options) => {
|
|
78
|
-
if (value && value instanceof Uint8Array && value.constructor.name === "Buffer") {
|
|
79
|
-
return "[object Buffer]";
|
|
80
|
-
}
|
|
81
|
-
if (value !== null && typeof value === "object" && "pipe" in value && typeof value.pipe === "function") {
|
|
82
|
-
return "[object Stream]";
|
|
83
|
-
}
|
|
84
|
-
if (value instanceof Error) {
|
|
85
|
-
if (seen.has(value)) {
|
|
86
|
-
return "[Circular]";
|
|
87
|
-
}
|
|
88
|
-
depth += 1;
|
|
89
|
-
return _serialize(value, options, seen, depth);
|
|
90
|
-
}
|
|
91
|
-
if (options.useToJSON && value !== null && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
|
|
92
|
-
return value.toJSON();
|
|
93
|
-
}
|
|
94
|
-
if (value instanceof Date) {
|
|
95
|
-
return value.toISOString();
|
|
96
|
-
}
|
|
97
|
-
if (typeof value === "function") {
|
|
98
|
-
return `[Function: ${value.name || "anonymous"}]`;
|
|
99
|
-
}
|
|
100
|
-
if (typeof value === "bigint") {
|
|
101
|
-
return `${String(value)}n`;
|
|
102
|
-
}
|
|
103
|
-
if (isPlainObject(value)) {
|
|
104
|
-
if (options.maxDepth !== void 0 && options.maxDepth !== Number.POSITIVE_INFINITY && depth + 1 >= options.maxDepth) {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
depth += 1;
|
|
108
|
-
const plainObject = {};
|
|
109
|
-
for (const key in value) {
|
|
110
|
-
plainObject[key] = serializeValue(value[key], seen, depth, options);
|
|
111
|
-
}
|
|
112
|
-
return plainObject;
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
return value;
|
|
116
|
-
} catch {
|
|
117
|
-
return "[Not Available]";
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const _serialize = (error, options, seen, depth) => {
|
|
121
|
-
seen.add(error);
|
|
122
|
-
if (options.maxDepth === 0) {
|
|
123
|
-
return {};
|
|
124
|
-
}
|
|
125
|
-
if (options.useToJSON && typeof error.toJSON === "function" && !toJsonWasCalled.has(error)) {
|
|
126
|
-
return toJSON(error);
|
|
127
|
-
}
|
|
128
|
-
const protoError = Object.create(ErrorProto);
|
|
129
|
-
Object.defineProperty(protoError, "name", {
|
|
130
|
-
configurable: true,
|
|
131
|
-
enumerable: true,
|
|
132
|
-
value: Object.prototype.toString.call(error.constructor) === "[object Function]" ? error.constructor.name : error.name,
|
|
133
|
-
writable: true
|
|
134
|
-
});
|
|
135
|
-
Object.defineProperty(protoError, "message", {
|
|
136
|
-
configurable: true,
|
|
137
|
-
enumerable: true,
|
|
138
|
-
value: error.message,
|
|
139
|
-
writable: true
|
|
140
|
-
});
|
|
141
|
-
Object.defineProperty(protoError, "stack", {
|
|
142
|
-
configurable: true,
|
|
143
|
-
enumerable: true,
|
|
144
|
-
value: error.stack,
|
|
145
|
-
writable: true
|
|
146
|
-
});
|
|
147
|
-
if (Array.isArray(error.errors)) {
|
|
148
|
-
const aggregateErrors = [];
|
|
149
|
-
for (const aggregateError of error.errors) {
|
|
150
|
-
if (!(aggregateError instanceof Error)) {
|
|
151
|
-
throw new TypeError("All errors in the 'errors' property must be instances of Error");
|
|
152
|
-
}
|
|
153
|
-
if (seen.has(aggregateError)) {
|
|
154
|
-
Object.defineProperty(protoError, "errors", {
|
|
155
|
-
configurable: true,
|
|
156
|
-
enumerable: true,
|
|
157
|
-
value: [],
|
|
158
|
-
writable: true
|
|
159
|
-
});
|
|
160
|
-
return protoError;
|
|
161
|
-
}
|
|
162
|
-
aggregateErrors.push(_serialize(aggregateError, options, seen, depth));
|
|
163
|
-
}
|
|
164
|
-
Object.defineProperty(protoError, "errors", {
|
|
165
|
-
configurable: true,
|
|
166
|
-
enumerable: true,
|
|
167
|
-
value: aggregateErrors,
|
|
168
|
-
writable: true
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
const causeValue = error.cause;
|
|
172
|
-
if (causeValue !== void 0 && causeValue !== null) {
|
|
173
|
-
if (causeValue instanceof Error) {
|
|
174
|
-
if (seen.has(causeValue)) {
|
|
175
|
-
Object.defineProperty(protoError, "cause", {
|
|
176
|
-
configurable: true,
|
|
177
|
-
enumerable: true,
|
|
178
|
-
value: "[Circular]",
|
|
179
|
-
writable: true
|
|
180
|
-
});
|
|
181
|
-
} else {
|
|
182
|
-
Object.defineProperty(protoError, "cause", {
|
|
183
|
-
configurable: true,
|
|
184
|
-
enumerable: true,
|
|
185
|
-
value: _serialize(causeValue, options, seen, depth),
|
|
186
|
-
writable: true
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
} else {
|
|
190
|
-
const serializedCause = serializeValue(causeValue, seen, depth, options);
|
|
191
|
-
Object.defineProperty(protoError, "cause", {
|
|
192
|
-
configurable: true,
|
|
193
|
-
enumerable: true,
|
|
194
|
-
value: serializedCause,
|
|
195
|
-
writable: true
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
for (const key in error) {
|
|
200
|
-
if (key === "name" || key === "message" || key === "stack" || key === "cause" || key === "errors") {
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
const value = error[key];
|
|
204
|
-
const serializedValue = serializeValue(value, seen, depth, options);
|
|
205
|
-
Object.defineProperty(protoError, key, {
|
|
206
|
-
configurable: true,
|
|
207
|
-
enumerable: true,
|
|
208
|
-
value: serializedValue,
|
|
209
|
-
writable: true
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (Array.isArray(options.exclude) && options.exclude.length > 0) {
|
|
213
|
-
for (const key of options.exclude) {
|
|
214
|
-
try {
|
|
215
|
-
delete protoError[key];
|
|
216
|
-
} catch {
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return protoError;
|
|
221
|
-
};
|
|
222
|
-
const serialize = (error, options = {}) => _serialize(
|
|
223
|
-
error,
|
|
224
|
-
{
|
|
225
|
-
exclude: options.exclude ?? [],
|
|
226
|
-
maxDepth: options.maxDepth ?? Number.POSITIVE_INFINITY,
|
|
227
|
-
useToJSON: options.useToJSON ?? false
|
|
228
|
-
},
|
|
229
|
-
/* @__PURE__ */ new Set(),
|
|
230
|
-
0
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
class AbstractJsonReporter {
|
|
234
|
-
/** Custom stringify function for object serialization */
|
|
235
|
-
stringify;
|
|
236
|
-
/** Error serialization options */
|
|
237
|
-
errorOptions;
|
|
238
|
-
/**
|
|
239
|
-
* Creates a new AbstractJsonReporter instance.
|
|
240
|
-
* @param options Configuration options for JSON formatting and error handling
|
|
241
|
-
*/
|
|
242
|
-
constructor(options = {}) {
|
|
243
|
-
this.errorOptions = options.error ?? {};
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Sets a custom stringify function for object serialization.
|
|
247
|
-
* @param function_ The stringify function to use for serialization
|
|
248
|
-
*/
|
|
249
|
-
setStringify(function_) {
|
|
250
|
-
this.stringify = function_;
|
|
251
|
-
}
|
|
252
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
253
|
-
log(meta) {
|
|
254
|
-
const { context, error, file, message, type, ...rest } = meta;
|
|
255
|
-
if (rest.label) {
|
|
256
|
-
rest.label = rest.label.trim();
|
|
257
|
-
}
|
|
258
|
-
if (file) {
|
|
259
|
-
rest.file = `${file.name ?? ""}:${String(file.line)}${file.column ? `:${String(file.column)}` : ""}`;
|
|
260
|
-
}
|
|
261
|
-
rest.message = message === EMPTY_SYMBOL ? void 0 : message;
|
|
262
|
-
if (error) {
|
|
263
|
-
rest.error = serialize(error, this.errorOptions);
|
|
264
|
-
}
|
|
265
|
-
if (context) {
|
|
266
|
-
const newContext = [];
|
|
267
|
-
for (let i = 0; i < context.length; i += 1) {
|
|
268
|
-
const item = context[i];
|
|
269
|
-
if (item === EMPTY_SYMBOL) {
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
if (item instanceof Error) {
|
|
273
|
-
newContext.push(serialize(item, this.errorOptions));
|
|
274
|
-
} else {
|
|
275
|
-
newContext.push(item);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
rest.context = newContext;
|
|
279
|
-
}
|
|
280
|
-
this._log(this.stringify(rest), type.level);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export { AbstractJsonReporter };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AbstractJsonReporter } from './AbstractJsonReporter-BO8Calb4.js';
|
|
2
|
-
import { w as writeConsoleLogBasedOnLevel } from './write-console-log-based-on-level-ree2lDPw.js';
|
|
3
|
-
|
|
4
|
-
class JsonReporter extends AbstractJsonReporter {
|
|
5
|
-
/**
|
|
6
|
-
* Creates a new Browser JSON Reporter instance.
|
|
7
|
-
* @param options Configuration options for JSON formatting
|
|
8
|
-
*/
|
|
9
|
-
constructor(options = {}) {
|
|
10
|
-
super(options);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Outputs the JSON message to the browser console.
|
|
14
|
-
*
|
|
15
|
-
* Uses the appropriate console method based on the log level
|
|
16
|
-
* (console.log, console.error, console.warn, etc.).
|
|
17
|
-
* @param message The JSON-formatted log message
|
|
18
|
-
* @param logLevel The log level determining which console method to use
|
|
19
|
-
* @protected
|
|
20
|
-
*/
|
|
21
|
-
// eslint-disable-next-line class-methods-use-this, no-underscore-dangle
|
|
22
|
-
_log(message, logLevel) {
|
|
23
|
-
const consoleLogFunction = writeConsoleLogBasedOnLevel(logLevel);
|
|
24
|
-
consoleLogFunction(message);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { JsonReporter as default };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cjs_createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
const __cjs_require = __cjs_createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
stdout,
|
|
9
|
-
stderr
|
|
10
|
-
} = __cjs_getProcess;
|
|
11
|
-
import { w as writeStream } from './write-stream-MDqyXmc_.js';
|
|
12
|
-
import { AbstractJsonReporter } from './AbstractJsonReporter-nOj0Ft1F.js';
|
|
13
|
-
|
|
14
|
-
class JsonReporter extends AbstractJsonReporter {
|
|
15
|
-
/** Standard output stream */
|
|
16
|
-
#stdout;
|
|
17
|
-
/** Standard error stream */
|
|
18
|
-
#stderr;
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new Server JSON Reporter instance.
|
|
21
|
-
* @param options Configuration options for JSON formatting
|
|
22
|
-
*/
|
|
23
|
-
constructor(options = {}) {
|
|
24
|
-
super(options);
|
|
25
|
-
this.#stdout = stdout;
|
|
26
|
-
this.#stderr = stderr;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Sets the stdout stream for the reporter.
|
|
30
|
-
* @param stdout_ The writable stream to use for stdout output
|
|
31
|
-
*/
|
|
32
|
-
setStdout(stdout_) {
|
|
33
|
-
this.#stdout = stdout_;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Sets the stderr stream for the reporter.
|
|
37
|
-
* @param stderr_ The writable stream to use for stderr output
|
|
38
|
-
*/
|
|
39
|
-
setStderr(stderr_) {
|
|
40
|
-
this.#stderr = stderr_;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Outputs the JSON message to the appropriate stream.
|
|
44
|
-
*
|
|
45
|
-
* Routes error and warning level messages to stderr, others to stdout.
|
|
46
|
-
* @param message The JSON-formatted log message
|
|
47
|
-
* @param logLevel The log level determining which stream to use
|
|
48
|
-
* @protected
|
|
49
|
-
*/
|
|
50
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
51
|
-
_log(message, logLevel) {
|
|
52
|
-
const stream = ["error", "warn"].includes(logLevel) ? this.#stderr : this.#stdout;
|
|
53
|
-
writeStream(`${message}
|
|
54
|
-
`, stream);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { JsonReporter as default };
|