@visulima/pail 4.0.0-alpha.9 → 4.0.1

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 (145) hide show
  1. package/CHANGELOG.md +519 -0
  2. package/LICENSE.md +270 -166
  3. package/README.md +53 -24
  4. package/dist/error.d.ts +95 -96
  5. package/dist/error.js +5 -76
  6. package/dist/index.browser.d.ts +568 -47
  7. package/dist/index.browser.js +19 -1499
  8. package/dist/index.server.d.ts +749 -65
  9. package/dist/index.server.js +32 -3179
  10. package/dist/middleware/elysia.d.ts +66 -63
  11. package/dist/middleware/elysia.js +1 -70
  12. package/dist/middleware/express.d.ts +74 -71
  13. package/dist/middleware/express.js +1 -29
  14. package/dist/middleware/fastify.d.ts +70 -67
  15. package/dist/middleware/fastify.js +1 -46
  16. package/dist/middleware/hono.d.ts +75 -72
  17. package/dist/middleware/hono.js +1 -33
  18. package/dist/middleware/next/handler.d.ts +102 -34
  19. package/dist/middleware/next/handler.js +1 -53
  20. package/dist/middleware/sveltekit.d.ts +101 -98
  21. package/dist/middleware/sveltekit.js +1 -43
  22. package/dist/object-tree.d.ts +67 -70
  23. package/dist/object-tree.js +2 -89
  24. package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
  25. package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +1 -0
  26. package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +2 -0
  27. package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
  28. package/dist/packem_shared/PailError-CbU1Ogfa.js +5 -0
  29. package/dist/packem_shared/PrettyReporter-CcDdPQSt.js +44 -0
  30. package/dist/packem_shared/PrettyReporter-DsHfKOU7.js +5 -0
  31. package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +62 -0
  32. package/dist/packem_shared/abstract-pretty-reporter-DrLBJ6ds.js +57 -0
  33. package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +25 -0
  34. package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
  35. package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
  36. package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +47 -0
  37. package/dist/packem_shared/headers-DH0H2s8W.js +1 -0
  38. package/dist/packem_shared/index-Q1764hvO.js +1 -0
  39. package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
  40. package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +1 -0
  41. package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
  42. package/dist/packem_shared/storage-DaXAlpiO.js +1 -0
  43. package/dist/packem_shared/types.d-Cz9S7jZh.d.ts +201 -0
  44. package/dist/packem_shared/types.d-bWnqHJKL.d.ts +211 -0
  45. package/dist/packem_shared/types.d-xxE3FOD3.d.ts +229 -0
  46. package/dist/packem_shared/useLogger-DB34CuU5.js +1 -0
  47. package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +717 -0
  48. package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +1 -0
  49. package/dist/packem_shared/write-stream-C7jxLxIT.js +1 -0
  50. package/dist/processor/caller/caller-processor.d.ts +50 -47
  51. package/dist/processor/caller/caller-processor.js +1 -59
  52. package/dist/processor/environment-processor.d.ts +114 -113
  53. package/dist/processor/environment-processor.js +1 -78
  54. package/dist/processor/message-formatter-processor.d.ts +59 -49
  55. package/dist/processor/message-formatter-processor.js +1 -713
  56. package/dist/processor/opentelemetry-processor.d.ts +70 -66
  57. package/dist/processor/opentelemetry-processor.js +1 -52
  58. package/dist/processor/redact-processor.d.ts +99 -41
  59. package/dist/processor/redact-processor.js +1 -30
  60. package/dist/processor/sampling-processor.d.ts +103 -101
  61. package/dist/processor/sampling-processor.js +1 -59
  62. package/dist/reporter/file/json-file-reporter.d.ts +109 -42
  63. package/dist/reporter/file/json-file-reporter.js +2 -136
  64. package/dist/reporter/http/abstract-http-reporter.d.ts +256 -211
  65. package/dist/reporter/http/abstract-http-reporter.js +2 -435
  66. package/dist/reporter/http/http-reporter.d.ts +41 -36
  67. package/dist/reporter/http/http-reporter.edge-light.d.ts +487 -39
  68. package/dist/reporter/http/http-reporter.edge-light.js +2 -733
  69. package/dist/reporter/http/http-reporter.js +1 -13
  70. package/dist/reporter/json/index.browser.d.ts +98 -3
  71. package/dist/reporter/json/index.browser.js +1 -2
  72. package/dist/reporter/json/index.d.ts +53 -3
  73. package/dist/reporter/json/index.js +1 -2
  74. package/dist/reporter/pretty/index.browser.d.ts +105 -2
  75. package/dist/reporter/pretty/index.browser.js +1 -1
  76. package/dist/reporter/pretty/index.d.ts +270 -2
  77. package/dist/reporter/pretty/index.js +1 -1
  78. package/dist/reporter/simple/simple-reporter.server.d.ts +215 -18
  79. package/dist/reporter/simple/simple-reporter.server.js +8 -182
  80. package/dist/wide-event.d.ts +6 -300
  81. package/dist/wide-event.js +1 -281
  82. package/package.json +43 -58
  83. package/dist/constants.d.ts +0 -37
  84. package/dist/interactive/index.d.ts +0 -2
  85. package/dist/interactive/index.js +0 -2
  86. package/dist/interactive/interactive-manager.d.ts +0 -108
  87. package/dist/interactive/interactive-stream-hook.d.ts +0 -68
  88. package/dist/middleware/next/middleware.d.ts +0 -59
  89. package/dist/middleware/next/storage.d.ts +0 -14
  90. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  91. package/dist/middleware/shared/headers.d.ts +0 -14
  92. package/dist/middleware/shared/routes.d.ts +0 -30
  93. package/dist/middleware/shared/storage.d.ts +0 -29
  94. package/dist/packem_shared/AbstractJsonReporter-CGKHS8_M.js +0 -286
  95. package/dist/packem_shared/AbstractJsonReporter-DDjDkciI.js +0 -286
  96. package/dist/packem_shared/InteractiveManager-Cd6A14ZK.js +0 -172
  97. package/dist/packem_shared/InteractiveStreamHook-ePIURL_U.js +0 -133
  98. package/dist/packem_shared/JsonReporter-B3XX8GHN.js +0 -58
  99. package/dist/packem_shared/JsonReporter-p_BXg6Sj.js +0 -28
  100. package/dist/packem_shared/PrettyReporter-BYL3NrdA.js +0 -214
  101. package/dist/packem_shared/PrettyReporter-CvBn-hxP.js +0 -1459
  102. package/dist/packem_shared/Spinner-DIdVcfWq.js +0 -2183
  103. package/dist/packem_shared/abstract-pretty-reporter-jU8WL_6c.js +0 -2602
  104. package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
  105. package/dist/packem_shared/constants-omsTHUWB.js +0 -119
  106. package/dist/packem_shared/createPailError-B11aRfrT.js +0 -76
  107. package/dist/packem_shared/getBarChar-BWj1UrH3.js +0 -404
  108. package/dist/packem_shared/headers-Cp4uLtr4.js +0 -123
  109. package/dist/packem_shared/index-DnkF86LQ.js +0 -658
  110. package/dist/packem_shared/index-frijFf5m.js +0 -1252
  111. package/dist/packem_shared/pailMiddleware-Ci88geIF.js +0 -24
  112. package/dist/packem_shared/storage-D0vqz8OX.js +0 -36
  113. package/dist/packem_shared/useLogger-D0rU3lcX.js +0 -33
  114. package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +0 -14
  115. package/dist/packem_shared/write-stream-BG8fhcs3.js +0 -6
  116. package/dist/pail.browser.d.ts +0 -412
  117. package/dist/pail.server.d.ts +0 -233
  118. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  119. package/dist/progress-bar.d.ts +0 -136
  120. package/dist/progress-bar.js +0 -404
  121. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  122. package/dist/reporter/http/utils/compression.d.ts +0 -7
  123. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  124. package/dist/reporter/http/utils/retry.d.ts +0 -27
  125. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  126. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  127. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  128. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  129. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  130. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  131. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  132. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  133. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  134. package/dist/reporter/utils/format-label.d.ts +0 -3
  135. package/dist/spinner.d.ts +0 -220
  136. package/dist/spinner.js +0 -2183
  137. package/dist/types.d.ts +0 -241
  138. package/dist/utils/ansi-escapes.d.ts +0 -4
  139. package/dist/utils/arrayify.d.ts +0 -2
  140. package/dist/utils/get-longest-badge.d.ts +0 -4
  141. package/dist/utils/get-longest-label.d.ts +0 -4
  142. package/dist/utils/merge-types.d.ts +0 -4
  143. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  144. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  145. package/dist/utils/write-stream.d.ts +0 -2
@@ -1,75 +1,72 @@
1
1
  /**
2
- * Function to render a node value for display
3
- * @param node The node to render
4
- * @returns A string representation or undefined if should not render
5
- */
6
- export type TreeRenderFunction = (node: unknown) => string | undefined;
2
+ * Function to render a node value for display
3
+ * @param node The node to render
4
+ * @returns A string representation or undefined if should not render
5
+ */
6
+ type TreeRenderFunction = (node: unknown) => string | undefined;
7
7
  /**
8
- * Function to sort keys during tree traversal
9
- * @param a First key for comparison
10
- * @param b Second key for comparison
11
- * @returns Negative if a < b, positive if a > b, 0 if equal
12
- */
13
- export type TreeSortFunction = (a: string, b: string) => number;
8
+ * Function to sort keys during tree traversal
9
+ * @param a First key for comparison
10
+ * @param b Second key for comparison
11
+ * @returns Negative if a < b, positive if a > b, 0 if equal
12
+ */
13
+ type TreeSortFunction = (a: string, b: string) => number;
14
14
  /**
15
- * Configuration options for object tree rendering
16
- */
17
- export interface ObjectTreeOptions {
18
- /** Text to display for circular references (default: " (circular ref.)") */
19
- breakCircularWith?: string | null | undefined;
20
- /** Whether to return as single string or array of lines (default: true) */
21
- joined?: boolean;
22
- /** Connector for neighbor keys (default: "├─ ") */
23
- keyNeighbour?: string;
24
- /** Connector for non-neighbor keys (default: "└─ ") */
25
- keyNoNeighbour?: string;
26
- /** Function to render node values (default: renders primitives) */
27
- renderFn?: TreeRenderFunction;
28
- /** Separator between key and value (default: ": ") */
29
- separator?: string;
30
- /** Function to sort object keys (default: natural order) */
31
- sortFn?: TreeSortFunction | undefined;
32
- /** Spacer for neighbor branches (default: "│ ") */
33
- spacerNeighbour?: string;
34
- /** Spacer for non-neighbor branches (default: " ") */
35
- spacerNoNeighbour?: string;
15
+ * Configuration options for object tree rendering
16
+ */
17
+ interface ObjectTreeOptions {
18
+ /** Text to display for circular references (default: " (circular ref.)") */
19
+ breakCircularWith?: string | null;
20
+ /** Whether to return as single string or array of lines (default: true) */
21
+ joined?: boolean;
22
+ /** Connector for neighbor keys (default: "├─ ") */
23
+ keyNeighbour?: string;
24
+ /** Connector for non-neighbor keys (default: "└─ ") */
25
+ keyNoNeighbour?: string;
26
+ /** Function to render node values (default: renders primitives) */
27
+ renderFn?: TreeRenderFunction;
28
+ /** Separator between key and value (default: ": ") */
29
+ separator?: string;
30
+ /** Function to sort object keys (default: natural order) */
31
+ sortFn?: TreeSortFunction;
32
+ /** Spacer for neighbor branches (default: "│ ") */
33
+ spacerNeighbour?: string;
34
+ /** Spacer for non-neighbor branches (default: " ") */
35
+ spacerNoNeighbour?: string;
36
36
  }
37
37
  /**
38
- * Renders an object as an ASCII tree structure.
39
- * @param tree The object to render as a tree
40
- * @param options Configuration options for tree rendering
41
- * @returns Formatted tree as string or array of lines
42
- * @example
43
- * ```typescript
44
- * const obj = {
45
- * name: "John",
46
- * age: 30,
47
- * address: {
48
- * street: "Main St",
49
- * city: "New York"
50
- * }
51
- * };
52
- *
53
- * // Default output as string
54
- * console.log(renderObjectTree(obj));
55
- *
56
- * // Custom rendering
57
- * console.log(renderObjectTree(obj, {
58
- * sortFn: (a, b) => a.localeCompare(b),
59
- * renderFn: (node) => {
60
- * if (typeof node === 'string') return node.toUpperCase();
61
- * return ['boolean', 'string', 'number'].includes(typeof node)
62
- * ? String(node)
63
- * : undefined;
64
- * }
65
- * }));
66
- *
67
- * // Get as array of lines
68
- * const lines = renderObjectTree(obj, { joined: false });
69
- * ```
70
- */
71
- export declare const renderObjectTree: (tree: Record<string, unknown> | unknown[], options?: ObjectTreeOptions) => string | string[];
72
- /**
73
- * Default export for CommonJS compatibility
74
- */
75
- export default renderObjectTree;
38
+ * Renders an object as an ASCII tree structure.
39
+ * @param tree The object to render as a tree
40
+ * @param options Configuration options for tree rendering
41
+ * @returns Formatted tree as string or array of lines
42
+ * @example
43
+ * ```typescript
44
+ * const obj = {
45
+ * name: "John",
46
+ * age: 30,
47
+ * address: {
48
+ * street: "Main St",
49
+ * city: "New York"
50
+ * }
51
+ * };
52
+ *
53
+ * // Default output as string
54
+ * console.log(renderObjectTree(obj));
55
+ *
56
+ * // Custom rendering
57
+ * console.log(renderObjectTree(obj, {
58
+ * sortFn: (a, b) => a.localeCompare(b),
59
+ * renderFn: (node) => {
60
+ * if (typeof node === 'string') return node.toUpperCase();
61
+ * return ['boolean', 'string', 'number'].includes(typeof node)
62
+ * ? String(node)
63
+ * : undefined;
64
+ * }
65
+ * }));
66
+ *
67
+ * // Get as array of lines
68
+ * const lines = renderObjectTree(obj, { joined: false });
69
+ * ```
70
+ */
71
+ declare const renderObjectTree: (tree: Record<string, unknown> | unknown[], options?: ObjectTreeOptions) => string | string[];
72
+ export { ObjectTreeOptions, TreeRenderFunction, TreeSortFunction, renderObjectTree as default, renderObjectTree };
@@ -1,89 +1,2 @@
1
- const buildContext = (options) => {
2
- const context = {
3
- breakCircularWith: " (circular ref.)",
4
- joined: true,
5
- keyNeighbour: "├─ ",
6
- keyNoNeighbour: "└─ ",
7
- renderFn: (node) => {
8
- if (["boolean", "number", "string"].includes(typeof node)) {
9
- return String(node);
10
- }
11
- return void 0;
12
- },
13
- separator: ": ",
14
- sortFn: void 0,
15
- spacerNeighbour: "│ ",
16
- spacerNoNeighbour: " ",
17
- ...options
18
- };
19
- if (typeof context.joined !== "boolean") {
20
- throw new TypeError('Option "joined" must be a boolean');
21
- }
22
- if (typeof context.spacerNoNeighbour !== "string") {
23
- throw new TypeError('Option "spacerNoNeighbour" must be a string');
24
- }
25
- if (typeof context.spacerNeighbour !== "string") {
26
- throw new TypeError('Option "spacerNeighbour" must be a string');
27
- }
28
- if (typeof context.keyNoNeighbour !== "string") {
29
- throw new TypeError('Option "keyNoNeighbour" must be a string');
30
- }
31
- if (typeof context.keyNeighbour !== "string") {
32
- throw new TypeError('Option "keyNeighbour" must be a string');
33
- }
34
- if (typeof context.separator !== "string") {
35
- throw new TypeError('Option "separator" must be a string');
36
- }
37
- if (typeof context.renderFn !== "function") {
38
- throw new TypeError('Option "renderFn" must be a function');
39
- }
40
- if (context.sortFn !== void 0 && typeof context.sortFn !== "function") {
41
- throw new TypeError('Option "sortFn" must be a function or undefined');
42
- }
43
- if (context.breakCircularWith !== null && typeof context.breakCircularWith !== "string") {
44
- throw new TypeError('Option "breakCircularWith" must be a string or null');
45
- }
46
- return context;
47
- };
48
- const renderObjectTree = (tree, options) => {
49
- const context = buildContext(options);
50
- const result = [];
51
- const rootRendered = context.renderFn(tree);
52
- if (rootRendered !== void 0) {
53
- result.push(String(rootRendered));
54
- }
55
- const sort = (input) => {
56
- if (context.sortFn === void 0) {
57
- return input;
58
- }
59
- return input.toSorted((a, b) => context?.sortFn?.(b, a) ?? 0);
60
- };
61
- const neighbours = [];
62
- const keys = sort(Object.keys(tree)).map((k) => [k]);
63
- const lookup = [tree];
64
- while (keys.length > 0) {
65
- const key = keys.pop() ?? [];
66
- const node = lookup[key.length - 1][key[key.length - 1] ?? ""];
67
- const isCircular = context.breakCircularWith !== null && lookup.slice(0, key.length).includes(node);
68
- neighbours[key.length - 1] = keys.length > 0 && (keys[keys.length - 1]?.length ?? 0) === key.length;
69
- const indent = neighbours.slice(0, key.length - 1).map((n) => {
70
- if (n) {
71
- return context.spacerNeighbour;
72
- }
73
- return context.spacerNoNeighbour;
74
- }).join("");
75
- const connector = neighbours[key.length - 1] ? context.keyNeighbour : context.keyNoNeighbour;
76
- const keyName = key[key.length - 1];
77
- const nodeRendered = context.renderFn(node);
78
- const value = nodeRendered === void 0 ? "" : `${context.separator}${nodeRendered}`;
79
- const circular = isCircular ? context.breakCircularWith : "";
80
- result.push(`${indent}${connector}${keyName}${value}${circular}`);
81
- if (node !== null && typeof node === "object" && !Array.isArray(node) && !isCircular) {
82
- keys.push(...sort(Object.keys(node)).map((k) => [...key, k]));
83
- lookup[key.length] = node;
84
- }
85
- }
86
- return context.joined === true ? result.join("\n") : result;
87
- };
88
-
89
- export { renderObjectTree as default, renderObjectTree };
1
+ const w=n=>{const o={breakCircularWith:" (circular ref.)",joined:!0,keyNeighbour:"├─ ",keyNoNeighbour:"└─ ",renderFn:r=>{if(["boolean","number","string"].includes(typeof r))return String(r)},separator:": ",sortFn:void 0,spacerNeighbour:"│ ",spacerNoNeighbour:" ",...n};if(typeof o.joined!="boolean")throw new TypeError('Option "joined" must be a boolean');if(typeof o.spacerNoNeighbour!="string")throw new TypeError('Option "spacerNoNeighbour" must be a string');if(typeof o.spacerNeighbour!="string")throw new TypeError('Option "spacerNeighbour" must be a string');if(typeof o.keyNoNeighbour!="string")throw new TypeError('Option "keyNoNeighbour" must be a string');if(typeof o.keyNeighbour!="string")throw new TypeError('Option "keyNeighbour" must be a string');if(typeof o.separator!="string")throw new TypeError('Option "separator" must be a string');if(typeof o.renderFn!="function")throw new TypeError('Option "renderFn" must be a function');if(o.sortFn!==void 0&&typeof o.sortFn!="function")throw new TypeError('Option "sortFn" must be a function or undefined');if(o.breakCircularWith!==null&&typeof o.breakCircularWith!="string")throw new TypeError('Option "breakCircularWith" must be a string or null');return o},k=(n,o)=>{const r=w(o),s=[],b=r.renderFn(n);b!==void 0&&s.push(b);const g=e=>r.sortFn===void 0?e:e.toSorted((t,u)=>r.sortFn?.(u,t)??0),a=[],i=g(Object.keys(n)).map(e=>[e]),p=[n];for(;i.length>0;){const e=i.pop()??[],t=p[e.length-1][e.at(-1)??""],u=r.breakCircularWith!==null&&p.slice(0,e.length).includes(t);a[e.length-1]=i.length>0&&(i.at(-1)?.length??0)===e.length;const l=a.slice(0,e.length-1).map(h=>h?r.spacerNeighbour:r.spacerNoNeighbour).join(""),y=a[e.length-1]?r.keyNeighbour:r.keyNoNeighbour,f=e.at(-1)??"",c=r.renderFn(t),N=c===void 0?"":`${r.separator}${c}`,d=u?r.breakCircularWith??"":"";s.push(`${l}${y}${f}${N}${d}`),t!==null&&typeof t=="object"&&!Array.isArray(t)&&!u&&(i.push(...g(Object.keys(t)).map(h=>[...e,h])),p[e.length]=t)}return r.joined?s.join(`
2
+ `):s};export{k as default,k as renderObjectTree};
@@ -0,0 +1 @@
1
+ import{createRequire as E}from"node:module";import{E as O}from"./constants-DKfCaSUR.js";const S=E(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[r,t]=c.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return c.getBuiltinModule(e)}return S(e)},{createRequire:h}=w("node:module"),T=h(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,N=e=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[r,t]=f.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return f.getBuiltinModule(e)}return T(e)};N("node:util");const P=h(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=e=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[r,t]=p.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return p.getBuiltinModule(e)}return P(e)};d("node:fs");d("node:path");d("node:url");const _=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&_.set("AggregateError",AggregateError);const x=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),A=e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},y=new WeakSet,j=e=>{const r=Object.getOwnPropertyNames(e);for(const t of r){const o=Object.getOwnPropertyDescriptor(e,t);o&&(o.enumerable||Object.defineProperty(e,t,{...o,enumerable:!0}),o.value&&typeof o.value=="object"&&!Array.isArray(o.value)&&(Object.getPrototypeOf(o.value)===Object.prototype||Object.getPrototypeOf(o.value)===null)&&j(o.value))}},I=e=>{y.add(e);const r=e.toJSON();return y.delete(e),Object.isExtensible(r)&&j(r),r},a=(e,r,t,o,n=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(t+=1,m(e,o,r,t));if(o.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const s=[];for(const[u,i]of e.entries())s.push([a(u,r,t,o,n),a(i,r,t,o,n)]);return{__dataType:"Map",value:s}}if(e instanceof Set){const s=[];for(const u of e.values())s.push(a(u,r,t,o,n));return{__dataType:"Set",value:s}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(A(e)){if(n.has(e))return"[Circular]";if(o.maxDepth!==void 0&&o.maxDepth!==Number.POSITIVE_INFINITY&&t+1>=o.maxDepth)return{};t+=1,n.add(e);const s={};for(const u in e)s[u]=a(e[u],r,t,o,n);return n.delete(e),s}try{return e}catch{return"[Not Available]"}},m=(e,r,t,o)=>{if(t.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!y.has(e))return I(e);const n=Object.create(x);if(Object.defineProperty(n,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(n,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(n,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const u=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(t.has(i))return Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),n;u.push(m(i,r,t,o))}Object.defineProperty(n,"errors",{configurable:!0,enumerable:!0,value:u,writable:!0})}const s=e.cause;if(s!=null)if(s instanceof Error)t.has(s)?Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:m(s,r,t,o),writable:!0});else{const u=a(s,t,o,r);Object.defineProperty(n,"cause",{configurable:!0,enumerable:!0,value:u,writable:!0})}for(const u in e){if(u==="name"||u==="message"||u==="stack"||u==="cause"||u==="errors")continue;const i=e[u],l=a(i,t,o,r);Object.defineProperty(n,u,{configurable:!0,enumerable:!0,value:l,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const u of r.exclude)try{delete n[u]}catch{}return n},v=(e,r={})=>m(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0);class M{stringify;errorOptions;constructor(r={}){this.errorOptions=r.error??{}}setStringify(r){this.stringify=r}log(r){const{context:t,error:o,file:n,message:s,type:u,...i}=r;if(i.label&&(i.label=i.label.trim()),n&&(i.file=`${n.name??""}:${String(n.line)}${n.column?`:${String(n.column)}`:""}`),i.message=s===O?void 0:s,o&&(i.error=v(o,this.errorOptions)),t){const l=[];for(let g=0;g<t.length;g+=1){const b=t[g];b!==O&&(b instanceof Error?l.push(v(b,this.errorOptions)):l.push(b))}i.context=l}this._log(this.stringify(i),u.level)}}export{M as AbstractJsonReporter};
@@ -0,0 +1 @@
1
+ import"./addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js";import{O as g}from"./serializeError-C-NFvZ8_-D0CA_Qlx.js";import{E as p}from"./constants-ep2nsfdy.js";class u{stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:i,error:l,file:o,message:c,type:a,...r}=t;if(r.label&&(r.label=r.label.trim()),o&&(r.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),r.message=c===p?void 0:c,l&&(r.error=g(l,this.errorOptions)),i){const s=[];for(let n=0;n<i.length;n+=1){const e=i[n];e!==p&&(e instanceof Error?s.push(g(e,this.errorOptions)):s.push(e))}r.context=s}this._log(this.stringify(r),a.level)}}export{u as AbstractJsonReporter};
@@ -0,0 +1,2 @@
1
+ import{createRequire as r}from"node:module";import{r as a,a as p}from"./write-stream-C7jxLxIT.js";import{AbstractJsonReporter as d}from"./AbstractJsonReporter-w_bGGiD-.js";const l=r(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:i,stderr:c}=o;class f extends d{#s;#t;constructor(s={}){super(s),this.#s=i,this.#t=c}setStdout(s){this.#s=s}setStderr(s){this.#t=s}_log(s,t){const e=a(t)?this.#t:this.#s;p(`${s}
2
+ `,e)}}export{f as default};
@@ -0,0 +1 @@
1
+ import{t as o}from"./write-console-log-based-on-level-BqjxV016.js";import{AbstractJsonReporter as s}from"./AbstractJsonReporter-Bp_JCrMQ.js";class c extends s{constructor(r={}){super(r)}_log(r,t){o(t)(r)}}export{c as default};
@@ -0,0 +1,5 @@
1
+ class e extends Error{status;why;fix;link;constructor(s){const t=typeof s=="string"?{message:s}:s;super(t.message,t.cause===void 0?void 0:{cause:t.cause}),this.name="PailError",this.status=t.status??500,this.why=t.why,this.fix=t.fix,this.link=t.link}toJSON(){const s={message:this.message,name:this.name,status:this.status};return this.why&&(s.why=this.why),this.fix&&(s.fix=this.fix),this.link&&(s.link=this.link),this.stack&&(s.stack=this.stack),this.cause!==void 0&&(s.cause=this.cause instanceof Error?{message:this.cause.message,name:this.cause.name,stack:this.cause.stack}:this.cause),s}toString(){let s=`${this.name} [${String(this.status)}]: ${this.message}`;if(this.why&&(s+=`
2
+ Why: ${this.why}`),this.fix&&(s+=`
3
+ Fix: ${this.fix}`),this.link&&(s+=`
4
+ Link: ${this.link}`),this.cause!==void 0){const t=this.cause instanceof Error?this.cause.message:String(this.cause);s+=`
5
+ Cause: ${t}`}return s}}const a=i=>new e(i);export{e as PailError,a as createPailError};