@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
@@ -10,8 +10,8 @@ const {
10
10
  env
11
11
  } = __cjs_getProcess;
12
12
  import { InteractiveManager, InteractiveStreamHook } from '@visulima/interactive-manager';
13
- import { g as getLongestLabel, E as EXTENDED_RFC_5424_LOG_LEVELS, a as EMPTY_SYMBOL, L as LOG_TYPES, i as inspect, w as writeStream, A as AbstractPrettyReporter, d as defaultInspectorConfig, t as terminalSize, b as getLongestBadge, c as getStringWidth, f as formatLabel, e as wordWrap, r as renderError, W as WrapMode } from './packem_shared/abstract-pretty-reporter-CXAKYCb8.js';
14
- import colorize, { red, greenBright, cyan, green, grey, bgGrey, underline, white } from '@visulima/colorize';
13
+ import { g as getLongestLabel, E as EXTENDED_RFC_5424_LOG_LEVELS, a as EMPTY_SYMBOL, L as LOG_TYPES, i as inspect, w as writeStream, A as AbstractPrettyReporter, d as defaultInspectorConfig, t as terminalSize, b as getLongestBadge, c as getStringWidth, f as formatLabel, e as wordWrap, r as renderError, W as WrapMode } from './packem_shared/abstract-pretty-reporter-CkqCt5hg.js';
14
+ import colorize from '@visulima/colorize';
15
15
  export { PailError, createPailError } from './packem_shared/createPailError-B_sgL0nF.js';
16
16
 
17
17
  const ESC = "\x1B";
@@ -2183,7 +2183,7 @@ const parseCss = (cssString) => {
2183
2183
  }
2184
2184
  return css;
2185
2185
  };
2186
- const cssToAnsi = (css, previousCss = null) => {
2186
+ const cssToAnsi = (css, previousCss) => {
2187
2187
  previousCss = previousCss ?? getDefaultCss();
2188
2188
  let ansi = "";
2189
2189
  if (!colorEquals(css.backgroundColor, previousCss.backgroundColor)) {
@@ -2360,7 +2360,7 @@ const format = (fmt, arguments_ = [], options = {}) => {
2360
2360
  let a = 1 - offset;
2361
2361
  let lastPosition = -1;
2362
2362
  let usedStyle = false;
2363
- let previousCss = null;
2363
+ let previousCss;
2364
2364
  for (let index = 0; index < fmt.length; ) {
2365
2365
  if (fmt.codePointAt(index) === CHAR_PERCENT && index + 1 < fmt.length) {
2366
2366
  lastPosition = lastPosition > -1 ? lastPosition : 0;
@@ -2573,6 +2573,7 @@ class MessageFormatterProcessor {
2573
2573
  }
2574
2574
  }
2575
2575
 
2576
+ const { bgGrey, cyan, green, greenBright, grey, red, underline, white } = colorize;
2576
2577
  const PAIL_DIST_REGEX = /[\\/]pail[\\/]dist/;
2577
2578
  const pailFileFilter = (line) => !PAIL_DIST_REGEX.test(line);
2578
2579
  class PrettyReporter extends AbstractPrettyReporter {
@@ -1,71 +1,73 @@
1
- import type { WideEvent } from "../wide-event.d.ts";
2
- import type { PailMiddlewareOptions } from "./shared/create-middleware-logger.d.ts";
1
+ import { W as WideEvent } from "../packem_shared/wide-event.d-B-t8ZnhI.js";
2
+ import { P as PailMiddlewareOptions } from "../packem_shared/create-middleware-logger.d-DheMh8q4.js";
3
+ import 'safe-stable-stringify';
4
+ import "../packem_shared/types.d-BeLumqgD.js";
5
+ import '@visulima/colorize';
6
+ import '@visulima/interactive-manager';
3
7
  /**
4
- * An Elysia-like instance that supports the derive/hook registration API.
5
- * Compatible with Elysia v1+.
6
- */
8
+ * An Elysia-like instance that supports the derive/hook registration API.
9
+ * Compatible with Elysia v1+.
10
+ */
7
11
  interface PailElysiaInstance {
8
- derive: (options: {
9
- as: string;
10
- }, handler: (context: {
11
- request: Request;
12
- }) => Record<string, unknown>) => PailElysiaInstance;
13
- onAfterHandle: (options: {
14
- as: string;
15
- }, handler: (context: {
16
- request: Request;
17
- set: {
18
- status?: number;
19
- };
20
- }) => Promise<void>) => PailElysiaInstance;
21
- onError: (options: {
22
- as: string;
23
- }, handler: (context: {
24
- error: Error;
25
- request: Request;
26
- }) => Promise<void>) => PailElysiaInstance;
12
+ derive: (options: {
13
+ as: string;
14
+ }, handler: (context: {
15
+ request: Request;
16
+ }) => Record<string, unknown>) => PailElysiaInstance;
17
+ onAfterHandle: (options: {
18
+ as: string;
19
+ }, handler: (context: {
20
+ request: Request;
21
+ set: {
22
+ status?: number;
23
+ };
24
+ }) => Promise<void>) => PailElysiaInstance;
25
+ onError: (options: {
26
+ as: string;
27
+ }, handler: (context: {
28
+ error: Error;
29
+ request: Request;
30
+ }) => Promise<void>) => PailElysiaInstance;
27
31
  }
28
32
  /**
29
- * Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
30
- * Must be called within a request handler where pail middleware is active.
31
- * @returns The request-scoped WideEvent logger
32
- * @throws Error if called outside of the middleware context
33
- */
33
+ * Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
34
+ * Must be called within a request handler where pail middleware is active.
35
+ * @returns The request-scoped WideEvent logger
36
+ * @throws Error if called outside of the middleware context
37
+ */
34
38
  declare const useLogger: () => WideEvent;
35
39
  /**
36
- * Configuration options for the Elysia pail plugin.
37
- * @template T - Custom logger type names from the pail instance
38
- */
40
+ * Configuration options for the Elysia pail plugin.
41
+ * @template T - Custom logger type names from the pail instance
42
+ */
39
43
  type ElysiaPluginOptions<T extends string = string> = PailMiddlewareOptions<T>;
40
44
  /**
41
- * Register pail wide event logging as an Elysia plugin.
42
- *
43
- * Injects a `log` property into handler context via `derive`, accessible via:
44
- * - `context.log` in route handlers (auto-injected)
45
- * - `useLogger()` from anywhere in the async call stack
46
- *
47
- * The wide event is automatically emitted on response or error.
48
- * @param app The Elysia instance
49
- * @param options Plugin configuration
50
- * @returns The Elysia instance (for chaining)
51
- * @example
52
- * ```typescript
53
- * import { Elysia } from "elysia";
54
- * import { createPail } from "@visulima/pail";
55
- * import { pailPlugin, useLogger } from "@visulima/pail/middleware/elysia";
56
- *
57
- * const logger = createPail();
58
- * const app = new Elysia();
59
- *
60
- * pailPlugin(app, { pail: logger });
61
- *
62
- * app.get("/api/users", ({ log }) => {
63
- * log.set({ user: { id: 1 } });
64
- * return { ok: true };
65
- * });
66
- * ```
67
- */
68
- export declare const pailPlugin: <T extends string = string>(app: PailElysiaInstance, options: ElysiaPluginOptions<T>) => PailElysiaInstance;
69
- export { useLogger };
70
- export type { ElysiaPluginOptions, PailElysiaInstance };
71
- export type { WideEvent } from "../wide-event.d.ts";
45
+ * Register pail wide event logging as an Elysia plugin.
46
+ *
47
+ * Injects a `log` property into handler context via `derive`, accessible via:
48
+ * - `context.log` in route handlers (auto-injected)
49
+ * - `useLogger()` from anywhere in the async call stack
50
+ *
51
+ * The wide event is automatically emitted on response or error.
52
+ * @param app The Elysia instance
53
+ * @param options Plugin configuration
54
+ * @returns The Elysia instance (for chaining)
55
+ * @example
56
+ * ```typescript
57
+ * import { Elysia } from "elysia";
58
+ * import { createPail } from "@visulima/pail";
59
+ * import { pailPlugin, useLogger } from "@visulima/pail/middleware/elysia";
60
+ *
61
+ * const logger = createPail();
62
+ * const app = new Elysia();
63
+ *
64
+ * pailPlugin(app, { pail: logger });
65
+ *
66
+ * app.get("/api/users", ({ log }) => {
67
+ * log.set({ user: { id: 1 } });
68
+ * return { ok: true };
69
+ * });
70
+ * ```
71
+ */
72
+ declare const pailPlugin: <T extends string = string>(app: PailElysiaInstance, options: ElysiaPluginOptions<T>) => PailElysiaInstance;
73
+ export { type ElysiaPluginOptions, type PailElysiaInstance, type WideEvent, pailPlugin, useLogger };
@@ -1,86 +1,88 @@
1
- import type { WideEvent } from "../wide-event.d.ts";
2
- import type { PailMiddlewareOptions } from "./shared/create-middleware-logger.d.ts";
1
+ import { W as WideEvent } from "../packem_shared/wide-event.d-B-t8ZnhI.js";
2
+ import { P as PailMiddlewareOptions } from "../packem_shared/create-middleware-logger.d-DheMh8q4.js";
3
+ import 'safe-stable-stringify';
4
+ import "../packem_shared/types.d-BeLumqgD.js";
5
+ import '@visulima/colorize';
6
+ import '@visulima/interactive-manager';
3
7
  /**
4
- * An Express-like request object with the pail logger attached.
5
- * Use this to type your route handlers when accessing `req.log`.
6
- * @example
7
- * ```typescript
8
- * import type { PailRequest } from "@visulima/pail/middleware/express";
9
- *
10
- * app.get("/api/users", (req: PailRequest, res) => {
11
- * req.log?.set({ user: { id: 1 } });
12
- * });
13
- * ```
14
- */
8
+ * An Express-like request object with the pail logger attached.
9
+ * Use this to type your route handlers when accessing `req.log`.
10
+ * @example
11
+ * ```typescript
12
+ * import type { PailRequest } from "@visulima/pail/middleware/express";
13
+ *
14
+ * app.get("/api/users", (req: PailRequest, res) => {
15
+ * req.log?.set({ user: { id: 1 } });
16
+ * });
17
+ * ```
18
+ */
15
19
  interface PailRequest {
16
- [key: string]: unknown;
17
- headers: Record<string, string | string[] | undefined>;
18
- /**
19
- * The request-scoped WideEvent logger, attached by pail middleware.
20
- * Only present for non-excluded routes.
21
- */
22
- log?: WideEvent;
23
- method: string;
24
- originalUrl?: string;
25
- path: string;
20
+ [key: string]: unknown;
21
+ headers: Record<string, string | string[] | undefined>;
22
+ /**
23
+ * The request-scoped WideEvent logger, attached by pail middleware.
24
+ * Only present for non-excluded routes.
25
+ */
26
+ log?: WideEvent;
27
+ method: string;
28
+ originalUrl?: string;
29
+ path: string;
26
30
  }
27
31
  /**
28
- * An Express-like response object.
29
- */
32
+ * An Express-like response object.
33
+ */
30
34
  interface PailResponse {
31
- [key: string]: unknown;
32
- on: (event: string, listener: () => void) => void;
33
- statusCode: number;
35
+ [key: string]: unknown;
36
+ on: (event: string, listener: () => void) => void;
37
+ statusCode: number;
34
38
  }
35
39
  /**
36
- * Express-compatible next function.
37
- */
40
+ * Express-compatible next function.
41
+ */
38
42
  type PailNextFunction = (error?: unknown) => void;
39
43
  /**
40
- * The Express middleware function signature returned by `pailMiddleware()`.
41
- */
44
+ * The Express middleware function signature returned by `pailMiddleware()`.
45
+ */
42
46
  type PailExpressMiddleware = (request: PailRequest, response: PailResponse, next: PailNextFunction) => void;
43
47
  /**
44
- * Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
45
- * Must be called within a request handled by the pail Express middleware.
46
- * @returns The request-scoped WideEvent logger
47
- * @throws Error if called outside of the middleware context
48
- */
48
+ * Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
49
+ * Must be called within a request handled by the pail Express middleware.
50
+ * @returns The request-scoped WideEvent logger
51
+ * @throws Error if called outside of the middleware context
52
+ */
49
53
  declare const useLogger: () => WideEvent;
50
54
  /**
51
- * Configuration options for the Express pail middleware.
52
- * @template T - Custom logger type names from the pail instance
53
- */
55
+ * Configuration options for the Express pail middleware.
56
+ * @template T - Custom logger type names from the pail instance
57
+ */
54
58
  type ExpressMiddlewareOptions<T extends string = string> = PailMiddlewareOptions<T>;
55
59
  /**
56
- * Create Express middleware that attaches a WideEvent logger to each request.
57
- *
58
- * The logger is available via:
59
- * - `req.log` on the request object
60
- * - `useLogger()` from anywhere in the async call stack
61
- *
62
- * The wide event is automatically emitted when the response finishes.
63
- * @param options Middleware configuration
64
- * @returns Express middleware function
65
- * @example
66
- * ```typescript
67
- * import express from "express";
68
- * import { createPail } from "@visulima/pail";
69
- * import { pailMiddleware, useLogger } from "@visulima/pail/middleware/express";
70
- *
71
- * const app = express();
72
- * const logger = createPail();
73
- *
74
- * app.use(pailMiddleware({ pail: logger }));
75
- *
76
- * app.get("/api/users", (req, res) => {
77
- * req.log.set({ user: { id: 1 } });
78
- * // or: useLogger().set({ user: { id: 1 } });
79
- * res.json({ ok: true });
80
- * });
81
- * ```
82
- */
83
- export declare const pailMiddleware: <T extends string = string>(options: ExpressMiddlewareOptions<T>) => PailExpressMiddleware;
84
- export { useLogger };
85
- export type { ExpressMiddlewareOptions, PailExpressMiddleware, PailNextFunction, PailRequest, PailResponse };
86
- export type { WideEvent } from "../wide-event.d.ts";
60
+ * Create Express middleware that attaches a WideEvent logger to each request.
61
+ *
62
+ * The logger is available via:
63
+ * - `req.log` on the request object
64
+ * - `useLogger()` from anywhere in the async call stack
65
+ *
66
+ * The wide event is automatically emitted when the response finishes.
67
+ * @param options Middleware configuration
68
+ * @returns Express middleware function
69
+ * @example
70
+ * ```typescript
71
+ * import express from "express";
72
+ * import { createPail } from "@visulima/pail";
73
+ * import { pailMiddleware, useLogger } from "@visulima/pail/middleware/express";
74
+ *
75
+ * const app = express();
76
+ * const logger = createPail();
77
+ *
78
+ * app.use(pailMiddleware({ pail: logger }));
79
+ *
80
+ * app.get("/api/users", (req, res) => {
81
+ * req.log.set({ user: { id: 1 } });
82
+ * // or: useLogger().set({ user: { id: 1 } });
83
+ * res.json({ ok: true });
84
+ * });
85
+ * ```
86
+ */
87
+ declare const pailMiddleware: <T extends string = string>(options: ExpressMiddlewareOptions<T>) => PailExpressMiddleware;
88
+ export { type ExpressMiddlewareOptions, type PailExpressMiddleware, type PailNextFunction, type PailRequest, type PailResponse, type WideEvent, pailMiddleware, useLogger };
@@ -1,81 +1,83 @@
1
- import type { WideEvent } from "../wide-event.d.ts";
2
- import type { PailMiddlewareOptions } from "./shared/create-middleware-logger.d.ts";
1
+ import { W as WideEvent } from "../packem_shared/wide-event.d-B-t8ZnhI.js";
2
+ import { P as PailMiddlewareOptions } from "../packem_shared/create-middleware-logger.d-DheMh8q4.js";
3
+ import 'safe-stable-stringify';
4
+ import "../packem_shared/types.d-BeLumqgD.js";
5
+ import '@visulima/colorize';
6
+ import '@visulima/interactive-manager';
3
7
  /**
4
- * A Fastify-like request object with the pail logger attached.
5
- * Use this to type your route handlers when accessing `request.log`.
6
- * @example
7
- * ```typescript
8
- * import type { PailFastifyRequest } from "@visulima/pail/middleware/fastify";
9
- *
10
- * app.get("/api/users", async (request: PailFastifyRequest, reply) => {
11
- * request.log?.set({ user: { id: 1 } });
12
- * });
13
- * ```
14
- */
8
+ * A Fastify-like request object with the pail logger attached.
9
+ * Use this to type your route handlers when accessing `request.log`.
10
+ * @example
11
+ * ```typescript
12
+ * import type { PailFastifyRequest } from "@visulima/pail/middleware/fastify";
13
+ *
14
+ * app.get("/api/users", async (request: PailFastifyRequest, reply) => {
15
+ * request.log?.set({ user: { id: 1 } });
16
+ * });
17
+ * ```
18
+ */
15
19
  interface PailFastifyRequest {
16
- [key: string]: unknown;
17
- headers: Record<string, string | string[] | undefined>;
18
- /**
19
- * The request-scoped WideEvent logger, attached by pail plugin.
20
- * Only present for non-excluded routes.
21
- */
22
- log?: WideEvent;
23
- method: string;
24
- url: string;
20
+ [key: string]: unknown;
21
+ headers: Record<string, string | string[] | undefined>;
22
+ /**
23
+ * The request-scoped WideEvent logger, attached by pail plugin.
24
+ * Only present for non-excluded routes.
25
+ */
26
+ log?: WideEvent;
27
+ method: string;
28
+ url: string;
25
29
  }
26
30
  /**
27
- * A Fastify-like reply object.
28
- */
31
+ * A Fastify-like reply object.
32
+ */
29
33
  interface PailFastifyReply {
30
- [key: string]: unknown;
31
- statusCode: number;
34
+ [key: string]: unknown;
35
+ statusCode: number;
32
36
  }
33
37
  /**
34
- * A Fastify-like instance that supports the hook registration API.
35
- */
38
+ * A Fastify-like instance that supports the hook registration API.
39
+ */
36
40
  interface PailFastifyInstance {
37
- addHook: ((name: "onError", hook: (request: PailFastifyRequest, reply: PailFastifyReply, error: Error) => Promise<void>) => void) & ((name: "onRequest", hook: (request: PailFastifyRequest, reply: PailFastifyReply, done: () => void) => void) => void) & ((name: "onResponse", hook: (request: PailFastifyRequest, reply: PailFastifyReply) => Promise<void>) => void);
41
+ addHook: ((name: "onError", hook: (request: PailFastifyRequest, reply: PailFastifyReply, error: Error) => Promise<void>) => void) & ((name: "onRequest", hook: (request: PailFastifyRequest, reply: PailFastifyReply, done: () => void) => void) => void) & ((name: "onResponse", hook: (request: PailFastifyRequest, reply: PailFastifyReply) => Promise<void>) => void);
38
42
  }
39
43
  /**
40
- * Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
41
- * Must be called within a request handled by the pail Fastify plugin.
42
- * @returns The request-scoped WideEvent logger
43
- * @throws Error if called outside of the plugin context
44
- */
44
+ * Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
45
+ * Must be called within a request handled by the pail Fastify plugin.
46
+ * @returns The request-scoped WideEvent logger
47
+ * @throws Error if called outside of the plugin context
48
+ */
45
49
  declare const useLogger: () => WideEvent;
46
50
  /**
47
- * Configuration options for the Fastify pail plugin.
48
- * @template T - Custom logger type names from the pail instance
49
- */
51
+ * Configuration options for the Fastify pail plugin.
52
+ * @template T - Custom logger type names from the pail instance
53
+ */
50
54
  type FastifyPluginOptions<T extends string = string> = PailMiddlewareOptions<T>;
51
55
  /**
52
- * Register pail wide event logging as a Fastify plugin.
53
- *
54
- * Attaches a WideEvent logger to each request, accessible via:
55
- * - `request.log` on the Fastify request object
56
- * - `useLogger()` from anywhere in the async call stack
57
- *
58
- * The wide event is automatically emitted on response or error.
59
- * @param fastify The Fastify instance
60
- * @param options Plugin configuration
61
- * @example
62
- * ```typescript
63
- * import Fastify from "fastify";
64
- * import { createPail } from "@visulima/pail";
65
- * import { pailPlugin, useLogger } from "@visulima/pail/middleware/fastify";
66
- *
67
- * const app = Fastify();
68
- * const logger = createPail();
69
- *
70
- * pailPlugin(app, { pail: logger });
71
- *
72
- * app.get("/api/users", async (request, reply) => {
73
- * request.log.set({ user: { id: 1 } });
74
- * return { ok: true };
75
- * });
76
- * ```
77
- */
78
- export declare const pailPlugin: <T extends string = string>(fastify: PailFastifyInstance, options: FastifyPluginOptions<T>) => void;
79
- export { useLogger };
80
- export type { FastifyPluginOptions, PailFastifyInstance, PailFastifyReply, PailFastifyRequest };
81
- export type { WideEvent } from "../wide-event.d.ts";
56
+ * Register pail wide event logging as a Fastify plugin.
57
+ *
58
+ * Attaches a WideEvent logger to each request, accessible via:
59
+ * - `request.log` on the Fastify request object
60
+ * - `useLogger()` from anywhere in the async call stack
61
+ *
62
+ * The wide event is automatically emitted on response or error.
63
+ * @param fastify The Fastify instance
64
+ * @param options Plugin configuration
65
+ * @example
66
+ * ```typescript
67
+ * import Fastify from "fastify";
68
+ * import { createPail } from "@visulima/pail";
69
+ * import { pailPlugin, useLogger } from "@visulima/pail/middleware/fastify";
70
+ *
71
+ * const app = Fastify();
72
+ * const logger = createPail();
73
+ *
74
+ * pailPlugin(app, { pail: logger });
75
+ *
76
+ * app.get("/api/users", async (request, reply) => {
77
+ * request.log.set({ user: { id: 1 } });
78
+ * return { ok: true };
79
+ * });
80
+ * ```
81
+ */
82
+ declare const pailPlugin: <T extends string = string>(fastify: PailFastifyInstance, options: FastifyPluginOptions<T>) => void;
83
+ export { type FastifyPluginOptions, type PailFastifyInstance, type PailFastifyReply, type PailFastifyRequest, type WideEvent, pailPlugin, useLogger };
@@ -1,85 +1,87 @@
1
- import type { WideEvent } from "../wide-event.d.ts";
2
- import type { PailMiddlewareOptions } from "./shared/create-middleware-logger.d.ts";
1
+ import { W as WideEvent } from "../packem_shared/wide-event.d-B-t8ZnhI.js";
2
+ import { P as PailMiddlewareOptions } from "../packem_shared/create-middleware-logger.d-DheMh8q4.js";
3
+ import 'safe-stable-stringify';
4
+ import "../packem_shared/types.d-BeLumqgD.js";
5
+ import '@visulima/colorize';
6
+ import '@visulima/interactive-manager';
3
7
  /**
4
- * A Hono-like context object with access to the pail logger.
5
- *
6
- * Use `c.get("log")` or `useLogger(c)` to access the WideEvent logger.
7
- * @example
8
- * ```typescript
9
- * import type { PailHonoContext } from "@visulima/pail/middleware/hono";
10
- *
11
- * app.get("/api/users", (c: PailHonoContext) => {
12
- * const log = c.get("log");
13
- * log.set({ user: { id: 1 } });
14
- * });
15
- * ```
16
- */
8
+ * A Hono-like context object with access to the pail logger.
9
+ *
10
+ * Use `c.get("log")` or `useLogger(c)` to access the WideEvent logger.
11
+ * @example
12
+ * ```typescript
13
+ * import type { PailHonoContext } from "@visulima/pail/middleware/hono";
14
+ *
15
+ * app.get("/api/users", (c: PailHonoContext) => {
16
+ * const log = c.get("log");
17
+ * log.set({ user: { id: 1 } });
18
+ * });
19
+ * ```
20
+ */
17
21
  interface PailHonoContext {
18
- [key: string]: unknown;
19
- get: (key: string) => unknown;
20
- req: {
21
- header: (name: string) => string | undefined;
22
- method: string;
23
- path: string;
24
- raw: {
25
- headers: Headers;
26
- };
22
+ [key: string]: unknown;
23
+ get: (key: string) => unknown;
24
+ req: {
25
+ header: (name: string) => string | undefined;
26
+ method: string;
27
+ path: string;
28
+ raw: {
29
+ headers: Headers;
27
30
  };
28
- res: {
29
- status: number;
30
- };
31
- set: (key: string, value: unknown) => void;
31
+ };
32
+ res: {
33
+ status: number;
34
+ };
35
+ set: (key: string, value: unknown) => void;
32
36
  }
33
37
  /**
34
- * Hono-compatible next function.
35
- */
38
+ * Hono-compatible next function.
39
+ */
36
40
  type PailHonoNext = () => Promise<void>;
37
41
  /**
38
- * The Hono middleware function signature returned by `pailMiddleware()`.
39
- */
42
+ * The Hono middleware function signature returned by `pailMiddleware()`.
43
+ */
40
44
  type PailHonoMiddleware = (c: PailHonoContext, next: PailHonoNext) => Promise<void>;
41
45
  /**
42
- * Configuration options for the Hono pail middleware.
43
- * @template T - Custom logger type names from the pail instance
44
- */
46
+ * Configuration options for the Hono pail middleware.
47
+ * @template T - Custom logger type names from the pail instance
48
+ */
45
49
  type HonoMiddlewareOptions<T extends string = string> = PailMiddlewareOptions<T>;
46
50
  /**
47
- * Retrieve the WideEvent logger from Hono context.
48
- * Must be called within a request handler where pail middleware is active.
49
- * @param c The Hono context object
50
- * @returns The request-scoped WideEvent logger
51
- * @throws Error if the middleware is not registered
52
- */
51
+ * Retrieve the WideEvent logger from Hono context.
52
+ * Must be called within a request handler where pail middleware is active.
53
+ * @param c The Hono context object
54
+ * @returns The request-scoped WideEvent logger
55
+ * @throws Error if the middleware is not registered
56
+ */
53
57
  declare const useLogger: (c: PailHonoContext) => WideEvent;
54
58
  /**
55
- * Create Hono middleware that attaches a WideEvent logger to each request.
56
- *
57
- * The logger is available via:
58
- * - `c.get("log")` on the Hono context
59
- * - `useLogger(c)` helper function
60
- *
61
- * The wide event is automatically emitted when the handler completes or throws.
62
- * @param options Middleware configuration
63
- * @returns Hono middleware function
64
- * @example
65
- * ```typescript
66
- * import { Hono } from "hono";
67
- * import { createPail } from "@visulima/pail";
68
- * import { pailMiddleware, useLogger } from "@visulima/pail/middleware/hono";
69
- *
70
- * const app = new Hono();
71
- * const logger = createPail();
72
- *
73
- * app.use("*", pailMiddleware({ pail: logger }));
74
- *
75
- * app.get("/api/users", (c) => {
76
- * const log = useLogger(c);
77
- * log.set({ user: { id: 1 } });
78
- * return c.json({ ok: true });
79
- * });
80
- * ```
81
- */
82
- export declare const pailMiddleware: <T extends string = string>(options: HonoMiddlewareOptions<T>) => PailHonoMiddleware;
83
- export { useLogger };
84
- export type { HonoMiddlewareOptions, PailHonoContext, PailHonoMiddleware, PailHonoNext };
85
- export type { WideEvent } from "../wide-event.d.ts";
59
+ * Create Hono middleware that attaches a WideEvent logger to each request.
60
+ *
61
+ * The logger is available via:
62
+ * - `c.get("log")` on the Hono context
63
+ * - `useLogger(c)` helper function
64
+ *
65
+ * The wide event is automatically emitted when the handler completes or throws.
66
+ * @param options Middleware configuration
67
+ * @returns Hono middleware function
68
+ * @example
69
+ * ```typescript
70
+ * import { Hono } from "hono";
71
+ * import { createPail } from "@visulima/pail";
72
+ * import { pailMiddleware, useLogger } from "@visulima/pail/middleware/hono";
73
+ *
74
+ * const app = new Hono();
75
+ * const logger = createPail();
76
+ *
77
+ * app.use("*", pailMiddleware({ pail: logger }));
78
+ *
79
+ * app.get("/api/users", (c) => {
80
+ * const log = useLogger(c);
81
+ * log.set({ user: { id: 1 } });
82
+ * return c.json({ ok: true });
83
+ * });
84
+ * ```
85
+ */
86
+ declare const pailMiddleware: <T extends string = string>(options: HonoMiddlewareOptions<T>) => PailHonoMiddleware;
87
+ export { type HonoMiddlewareOptions, type PailHonoContext, type PailHonoMiddleware, type PailHonoNext, type WideEvent, pailMiddleware, useLogger };