@visulima/pail 4.0.0-alpha.10 → 4.0.0-alpha.12

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 (106) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE.md +143 -931
  3. package/dist/error.d.ts +95 -96
  4. package/dist/index.browser.d.ts +557 -47
  5. package/dist/index.browser.js +2 -2
  6. package/dist/index.server.d.ts +722 -65
  7. package/dist/index.server.js +27 -410
  8. package/dist/middleware/elysia.d.ts +65 -63
  9. package/dist/middleware/elysia.js +2 -2
  10. package/dist/middleware/express.d.ts +73 -71
  11. package/dist/middleware/express.js +1 -1
  12. package/dist/middleware/fastify.d.ts +69 -67
  13. package/dist/middleware/fastify.js +2 -2
  14. package/dist/middleware/hono.d.ts +74 -72
  15. package/dist/middleware/next/handler.d.ts +101 -34
  16. package/dist/middleware/sveltekit.d.ts +100 -98
  17. package/dist/object-tree.d.ts +67 -70
  18. package/dist/packem_shared/{AbstractJsonReporter-DlugSJpY.js → AbstractJsonReporter-BO8Calb4.js} +1 -5
  19. package/dist/packem_shared/{AbstractJsonReporter-CjtVgHbU.js → AbstractJsonReporter-nOj0Ft1F.js} +1 -5
  20. package/dist/packem_shared/{JsonReporter-Dbw82ewj.js → JsonReporter-CCmj7oYL.js} +1 -1
  21. package/dist/packem_shared/{JsonReporter-BgPvIyC2.js → JsonReporter-Ck2PIAEw.js} +2 -2
  22. package/dist/packem_shared/{PrettyReporter-C2dCzIaf.js → PrettyReporter-CIbrmjUV.js} +2 -4
  23. package/dist/packem_shared/{PrettyReporter-gMqa7j_m.js → PrettyReporter-CNJEO9g7.js} +1250 -15
  24. package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
  25. package/dist/packem_shared/{abstract-pretty-reporter-szQO-IgK.js → abstract-pretty-reporter-CkqCt5hg.js} +2300 -2298
  26. package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
  27. package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
  28. package/dist/packem_shared/types.d-BeLumqgD.d.ts +246 -0
  29. package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
  30. package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
  31. package/dist/packem_shared/wide-event.d-B-t8ZnhI.d.ts +704 -0
  32. package/dist/packem_shared/{write-stream-BuFtjATz.js → write-stream-MDqyXmc_.js} +1 -1
  33. package/dist/processor/caller/caller-processor.d.ts +49 -47
  34. package/dist/processor/caller/caller-processor.js +1 -1
  35. package/dist/processor/environment-processor.d.ts +113 -113
  36. package/dist/processor/message-formatter-processor.d.ts +51 -49
  37. package/dist/processor/message-formatter-processor.js +2 -2
  38. package/dist/processor/opentelemetry-processor.d.ts +69 -66
  39. package/dist/processor/redact-processor.d.ts +60 -41
  40. package/dist/processor/sampling-processor.d.ts +102 -101
  41. package/dist/reporter/file/json-file-reporter.d.ts +91 -42
  42. package/dist/reporter/file/json-file-reporter.js +1 -1
  43. package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
  44. package/dist/reporter/http/abstract-http-reporter.js +1 -1
  45. package/dist/reporter/http/http-reporter.d.ts +40 -36
  46. package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
  47. package/dist/reporter/http/http-reporter.edge-light.js +1 -5
  48. package/dist/reporter/json/index.browser.d.ts +99 -3
  49. package/dist/reporter/json/index.browser.js +2 -2
  50. package/dist/reporter/json/index.d.ts +51 -3
  51. package/dist/reporter/json/index.js +2 -2
  52. package/dist/reporter/pretty/index.browser.d.ts +106 -2
  53. package/dist/reporter/pretty/index.browser.js +1 -1
  54. package/dist/reporter/pretty/index.d.ts +219 -2
  55. package/dist/reporter/pretty/index.js +1 -1
  56. package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
  57. package/dist/reporter/simple/simple-reporter.server.js +3 -2
  58. package/dist/wide-event.d.ts +5 -300
  59. package/dist/wide-event.js +3 -2
  60. package/package.json +9 -21
  61. package/dist/constants.d.ts +0 -37
  62. package/dist/interactive/index.d.ts +0 -2
  63. package/dist/interactive/index.js +0 -2
  64. package/dist/interactive/interactive-manager.d.ts +0 -108
  65. package/dist/interactive/interactive-stream-hook.d.ts +0 -68
  66. package/dist/middleware/next/middleware.d.ts +0 -59
  67. package/dist/middleware/next/storage.d.ts +0 -14
  68. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  69. package/dist/middleware/shared/headers.d.ts +0 -14
  70. package/dist/middleware/shared/routes.d.ts +0 -30
  71. package/dist/middleware/shared/storage.d.ts +0 -29
  72. package/dist/packem_shared/InteractiveManager-CowYA3Hx.js +0 -178
  73. package/dist/packem_shared/InteractiveStreamHook-BypRlYTX.js +0 -133
  74. package/dist/packem_shared/Spinner-Cokext9b.js +0 -2183
  75. package/dist/packem_shared/getBarChar-D7JfmdTr.js +0 -459
  76. package/dist/packem_shared/index-BEfVUy9P.js +0 -1256
  77. package/dist/pail.browser.d.ts +0 -412
  78. package/dist/pail.server.d.ts +0 -233
  79. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  80. package/dist/progress-bar.d.ts +0 -145
  81. package/dist/progress-bar.js +0 -459
  82. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  83. package/dist/reporter/http/utils/compression.d.ts +0 -7
  84. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  85. package/dist/reporter/http/utils/retry.d.ts +0 -27
  86. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  87. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  88. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  89. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  90. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  91. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  92. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  93. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  94. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  95. package/dist/reporter/utils/format-label.d.ts +0 -3
  96. package/dist/spinner.d.ts +0 -220
  97. package/dist/spinner.js +0 -2183
  98. package/dist/types.d.ts +0 -241
  99. package/dist/utils/ansi-escapes.d.ts +0 -4
  100. package/dist/utils/arrayify.d.ts +0 -2
  101. package/dist/utils/get-longest-badge.d.ts +0 -4
  102. package/dist/utils/get-longest-label.d.ts +0 -4
  103. package/dist/utils/merge-types.d.ts +0 -4
  104. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  105. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  106. package/dist/utils/write-stream.d.ts +0 -2
package/dist/error.d.ts CHANGED
@@ -1,104 +1,103 @@
1
1
  /**
2
- * Options for creating a PailError.
3
- *
4
- * Extends standard error properties with self-documenting fields
5
- * that provide actionable context for debugging, particularly useful
6
- * for AI-assisted log analysis.
7
- */
2
+ * Options for creating a PailError.
3
+ *
4
+ * Extends standard error properties with self-documenting fields
5
+ * that provide actionable context for debugging, particularly useful
6
+ * for AI-assisted log analysis.
7
+ */
8
8
  interface PailErrorOptions {
9
- /** The root cause of this error */
10
- cause?: unknown;
11
- /** A suggested resolution or steps to fix the issue */
12
- fix?: string;
13
- /** A link to relevant documentation or issue tracker */
14
- link?: string;
15
- /** The error message */
16
- message: string;
17
- /** HTTP status code associated with this error */
18
- status?: number;
19
- /** An explanation of what caused the failure */
20
- why?: string;
9
+ /** The root cause of this error */
10
+ cause?: unknown;
11
+ /** A suggested resolution or steps to fix the issue */
12
+ fix?: string;
13
+ /** A link to relevant documentation or issue tracker */
14
+ link?: string;
15
+ /** The error message */
16
+ message: string;
17
+ /** HTTP status code associated with this error */
18
+ status?: number;
19
+ /** An explanation of what caused the failure */
20
+ why?: string;
21
21
  }
22
22
  /**
23
- * Self-documenting error class for structured logging.
24
- *
25
- * Inspired by evlog's structured error approach, PailError extends the native
26
- * Error class with additional fields that make log entries immediately actionable:
27
- * - `why`: Explains what caused the failure
28
- * - `fix`: Suggests how to resolve the issue
29
- * - `link`: Points to relevant documentation
30
- * - `status`: HTTP status code for request-related errors
31
- *
32
- * These fields are preserved through the logging pipeline and displayed by reporters,
33
- * making it easier for both humans and AI agents to understand and resolve issues.
34
- * @example
35
- * ```typescript
36
- * import { PailError, createPailError } from "@visulima/pail/error";
37
- *
38
- * // Using the class directly
39
- * throw new PailError({
40
- * message: "Payment processing failed",
41
- * status: 402,
42
- * why: "The customer's card was declined by the payment provider",
43
- * fix: "Retry with a different payment method or contact the card issuer",
44
- * link: "https://docs.example.com/payments/declined",
45
- * });
46
- *
47
- * // Using the factory function
48
- * throw createPailError("Connection timeout");
49
- *
50
- * // With full options
51
- * throw createPailError({
52
- * message: "Database connection failed",
53
- * why: "Connection pool exhausted after 30s timeout",
54
- * fix: "Increase pool size or check for connection leaks",
55
- * });
56
- * ```
57
- */
23
+ * Self-documenting error class for structured logging.
24
+ *
25
+ * Inspired by evlog's structured error approach, PailError extends the native
26
+ * Error class with additional fields that make log entries immediately actionable:
27
+ * - `why`: Explains what caused the failure
28
+ * - `fix`: Suggests how to resolve the issue
29
+ * - `link`: Points to relevant documentation
30
+ * - `status`: HTTP status code for request-related errors
31
+ *
32
+ * These fields are preserved through the logging pipeline and displayed by reporters,
33
+ * making it easier for both humans and AI agents to understand and resolve issues.
34
+ * @example
35
+ * ```typescript
36
+ * import { PailError, createPailError } from "@visulima/pail/error";
37
+ *
38
+ * // Using the class directly
39
+ * throw new PailError({
40
+ * message: "Payment processing failed",
41
+ * status: 402,
42
+ * why: "The customer's card was declined by the payment provider",
43
+ * fix: "Retry with a different payment method or contact the card issuer",
44
+ * link: "https://docs.example.com/payments/declined",
45
+ * });
46
+ *
47
+ * // Using the factory function
48
+ * throw createPailError("Connection timeout");
49
+ *
50
+ * // With full options
51
+ * throw createPailError({
52
+ * message: "Database connection failed",
53
+ * why: "Connection pool exhausted after 30s timeout",
54
+ * fix: "Increase pool size or check for connection leaks",
55
+ * });
56
+ * ```
57
+ */
58
58
  declare class PailError extends Error {
59
- /** HTTP status code (defaults to 500) */
60
- readonly status: number;
61
- /** Explanation of what caused the failure */
62
- readonly why: string | undefined;
63
- /** Suggested resolution steps */
64
- readonly fix: string | undefined;
65
- /** Link to relevant documentation */
66
- readonly link: string | undefined;
67
- constructor(options: PailErrorOptions | string);
68
- /**
69
- * Converts the error to a JSON-serializable object.
70
- *
71
- * Includes all self-documenting fields in the output for structured logging.
72
- * @returns A plain object representation of the error
73
- */
74
- toJSON(): Record<string, unknown>;
75
- /**
76
- * Returns a formatted string representation including self-documenting fields.
77
- * @returns Formatted error string with why/fix/link context
78
- */
79
- toString(): string;
59
+ /** HTTP status code (defaults to 500) */
60
+ readonly status: number;
61
+ /** Explanation of what caused the failure */
62
+ readonly why: string | undefined;
63
+ /** Suggested resolution steps */
64
+ readonly fix: string | undefined;
65
+ /** Link to relevant documentation */
66
+ readonly link: string | undefined;
67
+ constructor(options: PailErrorOptions | string);
68
+ /**
69
+ * Converts the error to a JSON-serializable object.
70
+ *
71
+ * Includes all self-documenting fields in the output for structured logging.
72
+ * @returns A plain object representation of the error
73
+ */
74
+ toJSON(): Record<string, unknown>;
75
+ /**
76
+ * Returns a formatted string representation including self-documenting fields.
77
+ * @returns Formatted error string with why/fix/link context
78
+ */
79
+ override toString(): string;
80
80
  }
81
81
  /**
82
- * Factory function for creating PailError instances.
83
- *
84
- * A convenient shorthand for creating PailError objects. Accepts either
85
- * a string message or a full PailErrorOptions object.
86
- * @param options Error message string or PailErrorOptions object
87
- * @returns A new PailError instance
88
- * @example
89
- * ```typescript
90
- * import { createPailError } from "@visulima/pail/error";
91
- *
92
- * throw createPailError("Something went wrong");
93
- *
94
- * throw createPailError({
95
- * message: "Auth failed",
96
- * status: 401,
97
- * why: "Token expired",
98
- * fix: "Refresh the authentication token",
99
- * });
100
- * ```
101
- */
82
+ * Factory function for creating PailError instances.
83
+ *
84
+ * A convenient shorthand for creating PailError objects. Accepts either
85
+ * a string message or a full PailErrorOptions object.
86
+ * @param options Error message string or PailErrorOptions object
87
+ * @returns A new PailError instance
88
+ * @example
89
+ * ```typescript
90
+ * import { createPailError } from "@visulima/pail/error";
91
+ *
92
+ * throw createPailError("Something went wrong");
93
+ *
94
+ * throw createPailError({
95
+ * message: "Auth failed",
96
+ * status: 401,
97
+ * why: "Token expired",
98
+ * fix: "Refresh the authentication token",
99
+ * });
100
+ * ```
101
+ */
102
102
  declare const createPailError: (options: PailErrorOptions | string) => PailError;
103
- export { createPailError, PailError };
104
- export type { PailErrorOptions };
103
+ export { PailError, type PailErrorOptions, createPailError };