@visulima/pail 4.0.0-alpha.1 → 4.0.0-alpha.11

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/LICENSE.md +434 -52
  3. package/README.md +323 -0
  4. package/dist/error.d.ts +104 -0
  5. package/dist/error.js +76 -0
  6. package/dist/index.browser.d.ts +3 -1
  7. package/dist/index.browser.js +1490 -3
  8. package/dist/index.server.d.ts +3 -5
  9. package/dist/index.server.js +2380 -110
  10. package/dist/middleware/elysia.d.ts +71 -0
  11. package/dist/middleware/elysia.js +70 -0
  12. package/dist/middleware/express.d.ts +86 -0
  13. package/dist/middleware/express.js +29 -0
  14. package/dist/middleware/fastify.d.ts +81 -0
  15. package/dist/middleware/fastify.js +46 -0
  16. package/dist/middleware/hono.d.ts +85 -0
  17. package/dist/middleware/hono.js +33 -0
  18. package/dist/middleware/next/handler.d.ts +36 -0
  19. package/dist/middleware/next/handler.js +53 -0
  20. package/dist/middleware/next/middleware.d.ts +59 -0
  21. package/dist/middleware/next/storage.d.ts +14 -0
  22. package/dist/middleware/shared/create-middleware-logger.d.ts +82 -0
  23. package/dist/middleware/shared/headers.d.ts +14 -0
  24. package/dist/middleware/shared/routes.d.ts +30 -0
  25. package/dist/middleware/shared/storage.d.ts +29 -0
  26. package/dist/middleware/sveltekit.d.ts +123 -0
  27. package/dist/middleware/sveltekit.js +43 -0
  28. package/dist/object-tree.d.ts +2 -2
  29. package/dist/object-tree.js +7 -7
  30. package/dist/packem_shared/{AbstractJsonReporter-BaZ33PlE.js → AbstractJsonReporter-BO8Calb4.js} +112 -32
  31. package/dist/packem_shared/AbstractJsonReporter-nOj0Ft1F.js +284 -0
  32. package/dist/packem_shared/{JsonReporter-BRw4skd5.js → JsonReporter-CCmj7oYL.js} +2 -2
  33. package/dist/packem_shared/{JsonReporter-VzgyLEYz.js → JsonReporter-Ck2PIAEw.js} +2 -2
  34. package/dist/packem_shared/PrettyReporter-BCvyNzXO.js +2720 -0
  35. package/dist/packem_shared/{PrettyReporter-DySIXBjQ.js → PrettyReporter-BtTr13Ha.js} +55 -11
  36. package/dist/packem_shared/abstract-pretty-reporter-CXAKYCb8.js +2635 -0
  37. package/dist/packem_shared/constants-B1RjD_ps.js +99 -0
  38. package/dist/packem_shared/createPailError-B_sgL0nF.js +76 -0
  39. package/dist/packem_shared/headers-BxHWM6KI.js +127 -0
  40. package/dist/packem_shared/{index-BomQ3E6J.js → index-Bx3-C0j9.js} +29 -21
  41. package/dist/packem_shared/pailMiddleware-Ci88geIF.js +24 -0
  42. package/dist/packem_shared/storage-D0vqz8OX.js +36 -0
  43. package/dist/packem_shared/{InteractiveStreamHook-DiSubbJ1.js → useLogger-D0rU3lcX.js} +13 -1
  44. package/dist/packem_shared/{write-console-log-based-on-level-DBmRYXpj.js → write-console-log-based-on-level-ree2lDPw.js} +5 -4
  45. package/dist/packem_shared/{write-stream-BG8fhcs3.js → write-stream-MDqyXmc_.js} +1 -1
  46. package/dist/pail.browser.d.ts +1 -1
  47. package/dist/pail.server.d.ts +1 -76
  48. package/dist/processor/caller/caller-processor.js +1 -1
  49. package/dist/processor/environment-processor.d.ts +124 -0
  50. package/dist/processor/environment-processor.js +89 -0
  51. package/dist/processor/message-formatter-processor.d.ts +2 -3
  52. package/dist/processor/message-formatter-processor.js +654 -5
  53. package/dist/processor/opentelemetry-processor.js +4 -4
  54. package/dist/processor/redact-processor.d.ts +1 -1
  55. package/dist/processor/redact-processor.js +2 -1
  56. package/dist/processor/sampling-processor.d.ts +111 -0
  57. package/dist/processor/sampling-processor.js +59 -0
  58. package/dist/reporter/file/json-file-reporter.js +1 -1
  59. package/dist/reporter/http/abstract-http-reporter.js +23 -26
  60. package/dist/reporter/http/http-reporter.edge-light.js +134 -57
  61. package/dist/reporter/json/abstract-json-reporter.d.ts +1 -1
  62. package/dist/reporter/json/index.browser.js +2 -2
  63. package/dist/reporter/json/index.js +2 -2
  64. package/dist/reporter/pretty/index.browser.js +1 -1
  65. package/dist/reporter/pretty/index.js +1 -1
  66. package/dist/reporter/pretty/pretty-reporter.server.d.ts +1 -1
  67. package/dist/reporter/raw/raw-reporter.server.d.ts +1 -1
  68. package/dist/reporter/simple/simple-reporter.server.d.ts +1 -1
  69. package/dist/reporter/simple/simple-reporter.server.js +8 -12
  70. package/dist/types.d.ts +4 -4
  71. package/dist/utils/write-console-log-based-on-level.d.ts +1 -1
  72. package/dist/wide-event.d.ts +300 -0
  73. package/dist/wide-event.js +284 -0
  74. package/package.json +73 -20
  75. package/dist/interactive/index.d.ts +0 -2
  76. package/dist/interactive/index.js +0 -2
  77. package/dist/interactive/interactive-manager.d.ts +0 -108
  78. package/dist/interactive/interactive-stream-hook.d.ts +0 -68
  79. package/dist/packem_shared/InteractiveManager-CZ85hGNW.js +0 -172
  80. package/dist/packem_shared/PrettyReporter-DgZB2eBG.js +0 -222
  81. package/dist/packem_shared/abstract-pretty-reporter-Di_sdm2r.js +0 -50
  82. package/dist/packem_shared/format-label-De49vNPd.js +0 -1193
  83. package/dist/packem_shared/get-longest-label-C9PWeyKq.js +0 -9
  84. package/dist/packem_shared/index-DqKWykfa.js +0 -1146
  85. package/dist/packem_shared/interactive-stream-hook-DG4BtN12.js +0 -141
  86. package/dist/packem_shared/pail.browser-u2CSR_af.js +0 -1427
  87. package/dist/progress-bar.d.ts +0 -136
  88. package/dist/progress-bar.js +0 -404
  89. package/dist/spinner.d.ts +0 -220
  90. package/dist/spinner.js +0 -2150
  91. package/dist/utils/ansi-escapes.d.ts +0 -4
@@ -0,0 +1,284 @@
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,5 +1,5 @@
1
- import { AbstractJsonReporter } from './AbstractJsonReporter-BaZ33PlE.js';
2
- import { w as writeConsoleLogBasedOnLevel } from './write-console-log-based-on-level-DBmRYXpj.js';
1
+ import { AbstractJsonReporter } from './AbstractJsonReporter-BO8Calb4.js';
2
+ import { w as writeConsoleLogBasedOnLevel } from './write-console-log-based-on-level-ree2lDPw.js';
3
3
 
4
4
  class JsonReporter extends AbstractJsonReporter {
5
5
  /**
@@ -8,8 +8,8 @@ const {
8
8
  stdout,
9
9
  stderr
10
10
  } = __cjs_getProcess;
11
- import { w as writeStream } from './write-stream-BG8fhcs3.js';
12
- import { AbstractJsonReporter } from './AbstractJsonReporter-BaZ33PlE.js';
11
+ import { w as writeStream } from './write-stream-MDqyXmc_.js';
12
+ import { AbstractJsonReporter } from './AbstractJsonReporter-nOj0Ft1F.js';
13
13
 
14
14
  class JsonReporter extends AbstractJsonReporter {
15
15
  /** Standard output stream */