@visulima/pail 4.0.0-alpha.11 → 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 (78) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE.md +152 -894
  3. package/dist/error.d.ts +95 -96
  4. package/dist/index.browser.d.ts +557 -47
  5. package/dist/index.browser.js +1 -1
  6. package/dist/index.server.d.ts +722 -61
  7. package/dist/index.server.js +5 -4
  8. package/dist/middleware/elysia.d.ts +65 -63
  9. package/dist/middleware/express.d.ts +73 -71
  10. package/dist/middleware/fastify.d.ts +69 -67
  11. package/dist/middleware/hono.d.ts +74 -72
  12. package/dist/middleware/next/handler.d.ts +101 -34
  13. package/dist/middleware/sveltekit.d.ts +100 -98
  14. package/dist/object-tree.d.ts +67 -70
  15. package/dist/packem_shared/{PrettyReporter-BtTr13Ha.js → PrettyReporter-CIbrmjUV.js} +1 -1
  16. package/dist/packem_shared/{PrettyReporter-BCvyNzXO.js → PrettyReporter-CNJEO9g7.js} +11 -8
  17. package/dist/packem_shared/abstract-json-reporter.d-BAgznjyU.d.ts +61 -0
  18. package/dist/packem_shared/{abstract-pretty-reporter-CXAKYCb8.js → abstract-pretty-reporter-CkqCt5hg.js} +4 -2
  19. package/dist/packem_shared/create-middleware-logger.d-DheMh8q4.d.ts +47 -0
  20. package/dist/packem_shared/{index-Bx3-C0j9.js → index-6cG1Kp0t.js} +2 -2
  21. package/dist/packem_shared/types.d-BeLumqgD.d.ts +246 -0
  22. package/dist/packem_shared/types.d-C51XNfQz.d.ts +194 -0
  23. package/dist/packem_shared/types.d-CM5ie2qm.d.ts +236 -0
  24. package/dist/packem_shared/wide-event.d-B-t8ZnhI.d.ts +704 -0
  25. package/dist/processor/caller/caller-processor.d.ts +49 -47
  26. package/dist/processor/environment-processor.d.ts +113 -113
  27. package/dist/processor/environment-processor.js +3 -10
  28. package/dist/processor/message-formatter-processor.d.ts +51 -49
  29. package/dist/processor/message-formatter-processor.js +2 -2
  30. package/dist/processor/opentelemetry-processor.d.ts +69 -66
  31. package/dist/processor/redact-processor.d.ts +60 -41
  32. package/dist/processor/sampling-processor.d.ts +102 -101
  33. package/dist/reporter/file/json-file-reporter.d.ts +91 -42
  34. package/dist/reporter/http/abstract-http-reporter.d.ts +213 -211
  35. package/dist/reporter/http/http-reporter.d.ts +40 -36
  36. package/dist/reporter/http/http-reporter.edge-light.d.ts +430 -38
  37. package/dist/reporter/json/index.browser.d.ts +99 -3
  38. package/dist/reporter/json/index.d.ts +51 -3
  39. package/dist/reporter/pretty/index.browser.d.ts +106 -2
  40. package/dist/reporter/pretty/index.browser.js +1 -1
  41. package/dist/reporter/pretty/index.d.ts +219 -2
  42. package/dist/reporter/pretty/index.js +1 -1
  43. package/dist/reporter/simple/simple-reporter.server.d.ts +168 -18
  44. package/dist/reporter/simple/simple-reporter.server.js +3 -2
  45. package/dist/wide-event.d.ts +5 -300
  46. package/package.json +6 -7
  47. package/dist/constants.d.ts +0 -37
  48. package/dist/middleware/next/middleware.d.ts +0 -59
  49. package/dist/middleware/next/storage.d.ts +0 -14
  50. package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
  51. package/dist/middleware/shared/headers.d.ts +0 -14
  52. package/dist/middleware/shared/routes.d.ts +0 -30
  53. package/dist/middleware/shared/storage.d.ts +0 -29
  54. package/dist/pail.browser.d.ts +0 -412
  55. package/dist/pail.server.d.ts +0 -158
  56. package/dist/processor/caller/get-caller-filename.d.ts +0 -23
  57. package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
  58. package/dist/reporter/http/utils/compression.d.ts +0 -7
  59. package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
  60. package/dist/reporter/http/utils/retry.d.ts +0 -27
  61. package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
  62. package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
  63. package/dist/reporter/json/json-reporter.server.d.ts +0 -50
  64. package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
  65. package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
  66. package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
  67. package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
  68. package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
  69. package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
  70. package/dist/reporter/utils/format-label.d.ts +0 -3
  71. package/dist/types.d.ts +0 -241
  72. package/dist/utils/arrayify.d.ts +0 -2
  73. package/dist/utils/get-longest-badge.d.ts +0 -4
  74. package/dist/utils/get-longest-label.d.ts +0 -4
  75. package/dist/utils/merge-types.d.ts +0 -4
  76. package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
  77. package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
  78. 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 };