@loglayer/transport-pretty-terminal 4.0.5 → 4.1.0

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.
package/dist/index.d.cts CHANGED
@@ -1,138 +1,124 @@
1
- import { LoggerlessTransportConfig, LoggerlessTransport, LogLayerTransportParams } from '@loglayer/transport';
2
- import { ChalkInstance } from 'chalk';
3
- import * as chalk from 'chalk';
4
- export { chalk };
1
+ import { LogLayerTransportParams, LoggerlessTransport, LoggerlessTransportConfig } from "@loglayer/transport";
2
+ import * as chalk from "chalk";
3
+ import { ChalkInstance } from "chalk";
4
+
5
+ //#region src/types.d.ts
5
6
 
6
7
  /**
7
8
  * Represents a single log entry in the storage system.
8
9
  * Each entry contains metadata and the actual log content.
9
10
  */
10
11
  interface LogEntry {
11
- /** Unique identifier for the log entry */
12
- id: string;
13
- /** Unix timestamp in milliseconds when the log was created */
14
- timestamp: number;
15
- /** Log level (trace, debug, info, warn, error, fatal) */
16
- level: string;
17
- /** Main log message content */
18
- message: string;
19
- /** Optional structured data associated with the log, stored as JSON string */
20
- data: string | null;
12
+ /** Unique identifier for the log entry */
13
+ id: string;
14
+ /** Unix timestamp in milliseconds when the log was created */
15
+ timestamp: number;
16
+ /** Log level (trace, debug, info, warn, error, fatal) */
17
+ level: string;
18
+ /** Main log message content */
19
+ message: string;
20
+ /** Optional structured data associated with the log, stored as JSON string */
21
+ data: string | null;
21
22
  }
22
23
  /**
23
24
  * Configuration for log level colors.
24
25
  * Each log level can have its own chalk styling.
25
26
  */
26
27
  interface ColorConfig {
27
- /** Style for trace level logs - lowest severity */
28
- trace?: ChalkInstance;
29
- /** Style for debug level logs */
30
- debug?: ChalkInstance;
31
- /** Style for info level logs - normal operation */
32
- info?: ChalkInstance;
33
- /** Style for warning level logs */
34
- warn?: ChalkInstance;
35
- /** Style for error level logs */
36
- error?: ChalkInstance;
37
- /** Style for fatal level logs - highest severity */
38
- fatal?: ChalkInstance;
28
+ /** Style for trace level logs - lowest severity */
29
+ trace?: ChalkInstance;
30
+ /** Style for debug level logs */
31
+ debug?: ChalkInstance;
32
+ /** Style for info level logs - normal operation */
33
+ info?: ChalkInstance;
34
+ /** Style for warning level logs */
35
+ warn?: ChalkInstance;
36
+ /** Style for error level logs */
37
+ error?: ChalkInstance;
38
+ /** Style for fatal level logs - highest severity */
39
+ fatal?: ChalkInstance;
39
40
  }
40
41
  /**
41
42
  * Base configuration for log view styling.
42
43
  * Defines colors and styles for different log elements.
43
44
  */
44
45
  interface ViewConfig {
45
- /** Color configuration for different log levels */
46
- colors?: ColorConfig;
47
- /** Style for log entry IDs */
48
- logIdColor?: ChalkInstance;
49
- /** Style for data values in structured data */
50
- dataValueColor?: ChalkInstance;
51
- /** Style for data keys in structured data */
52
- dataKeyColor?: ChalkInstance;
53
- /** Style for selection indicators in interactive mode */
54
- selectorColor?: ChalkInstance;
46
+ /** Color configuration for different log levels */
47
+ colors?: ColorConfig;
48
+ /** Style for log entry IDs */
49
+ logIdColor?: ChalkInstance;
50
+ /** Style for data values in structured data */
51
+ dataValueColor?: ChalkInstance;
52
+ /** Style for data keys in structured data */
53
+ dataKeyColor?: ChalkInstance;
54
+ /** Style for selection indicators in interactive mode */
55
+ selectorColor?: ChalkInstance;
55
56
  }
56
57
  /**
57
58
  * Extended view configuration for detailed/interactive mode.
58
59
  * Includes additional styling options for the detailed view UI.
59
60
  */
60
61
  interface DetailedViewConfig extends ViewConfig {
61
- /** Style for section headers in detailed view */
62
- headerColor?: ChalkInstance;
63
- /** Style for field labels in detailed view */
64
- labelColor?: ChalkInstance;
65
- /** Style for visual separators between sections */
66
- separatorColor?: ChalkInstance;
67
- /** Configuration for JSON data formatting colors */
68
- jsonColors?: {
69
- /** Style for object property names */
70
- keysColor?: ChalkInstance;
71
- /** Style for array bullets */
72
- dashColor?: ChalkInstance;
73
- /** Default style for numbers */
74
- numberColor?: ChalkInstance;
75
- /** Style for single-line strings */
76
- stringColor?: ChalkInstance;
77
- /** Style for multi-line strings */
78
- multilineStringColor?: ChalkInstance;
79
- /** Style for positive numbers */
80
- positiveNumberColor?: ChalkInstance;
81
- /** Style for negative numbers */
82
- negativeNumberColor?: ChalkInstance;
83
- /** Style for boolean values */
84
- booleanColor?: ChalkInstance;
85
- /** Style for null and undefined values */
86
- nullUndefinedColor?: ChalkInstance;
87
- /** Style for date objects */
88
- dateColor?: ChalkInstance;
89
- };
62
+ /** Style for section headers in detailed view */
63
+ headerColor?: ChalkInstance;
64
+ /** Style for field labels in detailed view */
65
+ labelColor?: ChalkInstance;
66
+ /** Style for visual separators between sections */
67
+ separatorColor?: ChalkInstance;
68
+ /** Configuration for JSON data formatting colors */
69
+ jsonColors?: {
70
+ /** Style for object property names */
71
+ keysColor?: ChalkInstance;
72
+ /** Style for array bullets */
73
+ dashColor?: ChalkInstance;
74
+ /** Default style for numbers */
75
+ numberColor?: ChalkInstance;
76
+ /** Style for single-line strings */
77
+ stringColor?: ChalkInstance;
78
+ /** Style for multi-line strings */
79
+ multilineStringColor?: ChalkInstance;
80
+ /** Style for positive numbers */
81
+ positiveNumberColor?: ChalkInstance;
82
+ /** Style for negative numbers */
83
+ negativeNumberColor?: ChalkInstance;
84
+ /** Style for boolean values */
85
+ booleanColor?: ChalkInstance;
86
+ /** Style for null and undefined values */
87
+ nullUndefinedColor?: ChalkInstance;
88
+ /** Style for date objects */
89
+ dateColor?: ChalkInstance;
90
+ };
90
91
  }
91
92
  /**
92
93
  * Theme configuration for the pretty terminal transport.
93
94
  * Defines styling for both simple and detailed view modes.
94
95
  */
95
96
  interface PrettyTerminalTheme {
96
- /** Styling configuration for real-time log output mode */
97
- simpleView: ViewConfig;
98
- /** Styling configuration for interactive/detailed view mode */
99
- detailedView: DetailedViewConfig;
97
+ /** Styling configuration for real-time log output mode */
98
+ simpleView: ViewConfig;
99
+ /** Styling configuration for interactive/detailed view mode */
100
+ detailedView: DetailedViewConfig;
100
101
  }
101
102
  /**
102
103
  * Main configuration interface for PrettyTerminalTransport.
103
104
  * Extends the base transport configuration with pretty terminal specific options.
104
105
  */
105
106
  interface PrettyTerminalConfig extends LoggerlessTransportConfig {
106
- /** Maximum depth for inline data display before collapsing */
107
- maxInlineDepth?: number;
108
- /** Maximum length for inline data display before truncating */
109
- maxInlineLength?: number;
110
- /** Custom theme configuration for log display */
111
- theme?: PrettyTerminalTheme;
112
- /** Path to SQLite file for persistent storage. If not provided, uses in-memory database */
113
- logFile?: string;
114
- /** Whether the transport is enabled. If false, all operations will no-op. Defaults to true */
115
- enabled?: boolean;
116
- /** Whether to disable interactive mode (keyboard input and navigation). Useful when multiple applications need to print to the same terminal. Defaults to false */
117
- disableInteractiveMode?: boolean;
107
+ /** Maximum depth for inline data display before collapsing */
108
+ maxInlineDepth?: number;
109
+ /** Maximum length for inline data display before truncating */
110
+ maxInlineLength?: number;
111
+ /** Custom theme configuration for log display */
112
+ theme?: PrettyTerminalTheme;
113
+ /** Path to SQLite file for persistent storage. If not provided, uses in-memory database */
114
+ logFile?: string;
115
+ /** Whether the transport is enabled. If false, all operations will no-op. Defaults to true */
116
+ enabled?: boolean;
117
+ /** Whether to disable interactive mode (keyboard input and navigation). Useful when multiple applications need to print to the same terminal. Defaults to false */
118
+ disableInteractiveMode?: boolean;
118
119
  }
119
-
120
- /**
121
- * A transport for LogLayer that provides a pretty terminal output with interactive features.
122
- * This transport implements an interactive terminal UI for viewing and filtering logs.
123
- *
124
- * Features:
125
- * - Real-time log display with color-coded levels
126
- * - Interactive selection mode for browsing logs
127
- * - Detailed view for inspecting individual log entries
128
- * - Search/filter functionality
129
- * - JSON data pretty printing
130
- * - Configurable themes and colors
131
- *
132
- * The transport uses a singleton pattern to ensure only one instance exists,
133
- * as it manages terminal input and output which cannot be shared.
134
- */
135
-
120
+ //#endregion
121
+ //#region src/PrettyTerminalTransport.d.ts
136
122
  /**
137
123
  * Main transport class that handles pretty terminal output and interactive features.
138
124
  * This class coordinates between different components:
@@ -154,59 +140,65 @@ interface PrettyTerminalConfig extends LoggerlessTransportConfig {
154
140
  * ```
155
141
  */
156
142
  declare class PrettyTerminalTransport extends LoggerlessTransport {
157
- /** Singleton instance of the transport */
158
- private static instance;
159
- /** Handles all rendering and formatting of logs */
160
- private renderer;
161
- /** Manages log persistence in SQLite database */
162
- private storage;
163
- /** Manages user interaction and view state */
164
- private uiManager;
165
- /** Configuration options */
166
- private config;
167
- /**
168
- * Creates a new PrettyTerminalTransport instance.
169
- * This is a singleton class - only one instance can exist at a time.
170
- * Use getInstance() instead of constructor directly.
171
- *
172
- * @param config - Configuration options for the transport
173
- * @throws Error if attempting to create multiple instances
174
- */
175
- constructor(config?: PrettyTerminalConfig);
176
- /**
177
- * Gets or creates the singleton instance of PrettyTerminalTransport.
178
- * This is the recommended way to obtain a transport instance.
179
- *
180
- * @param config - Configuration options for the transport
181
- * @returns The singleton instance of PrettyTerminalTransport
182
- */
183
- static getInstance(config?: PrettyTerminalConfig): PrettyTerminalTransport;
184
- /**
185
- * Generates a random ID for each log entry.
186
- * Uses base36 encoding for compact, readable IDs.
187
- *
188
- * @returns A 6-character string ID
189
- * @example
190
- * "a1b2c3" // Example generated ID
191
- */
192
- private generateId;
193
- /**
194
- * Main transport method that receives logs from LogLayer.
195
- * This method is called for each log event and handles:
196
- * - Generating a unique ID for the log
197
- * - Converting the log data to a storable format
198
- * - Storing the log in the database
199
- * - Rendering the log if not in selection mode
200
- *
201
- * @param logLevel - The severity level of the log
202
- * @param messages - Array of message strings to be joined
203
- * @param data - Additional structured data to be logged
204
- * @param hasData - Whether the log includes additional data
205
- * @returns The original messages array
206
- */
207
- shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
143
+ /** Singleton instance of the transport */
144
+ private static instance;
145
+ /** Handles all rendering and formatting of logs */
146
+ private renderer;
147
+ /** Manages log persistence in SQLite database */
148
+ private storage;
149
+ /** Manages user interaction and view state */
150
+ private uiManager;
151
+ /** Configuration options */
152
+ private config;
153
+ /**
154
+ * Creates a new PrettyTerminalTransport instance.
155
+ * This is a singleton class - only one instance can exist at a time.
156
+ * Use getInstance() instead of constructor directly.
157
+ *
158
+ * @param config - Configuration options for the transport
159
+ * @throws Error if attempting to create multiple instances
160
+ */
161
+ constructor(config?: PrettyTerminalConfig);
162
+ /**
163
+ * Gets or creates the singleton instance of PrettyTerminalTransport.
164
+ * This is the recommended way to obtain a transport instance.
165
+ *
166
+ * @param config - Configuration options for the transport
167
+ * @returns The singleton instance of PrettyTerminalTransport
168
+ */
169
+ static getInstance(config?: PrettyTerminalConfig): PrettyTerminalTransport;
170
+ /**
171
+ * Generates a random ID for each log entry.
172
+ * Uses base36 encoding for compact, readable IDs.
173
+ *
174
+ * @returns A 6-character string ID
175
+ * @example
176
+ * "a1b2c3" // Example generated ID
177
+ */
178
+ private generateId;
179
+ /**
180
+ * Main transport method that receives logs from LogLayer.
181
+ * This method is called for each log event and handles:
182
+ * - Generating a unique ID for the log
183
+ * - Converting the log data to a storable format
184
+ * - Storing the log in the database
185
+ * - Rendering the log if not in selection mode
186
+ *
187
+ * @param logLevel - The severity level of the log
188
+ * @param messages - Array of message strings to be joined
189
+ * @param data - Additional structured data to be logged
190
+ * @param hasData - Whether the log includes additional data
191
+ * @returns The original messages array
192
+ */
193
+ shipToLogger({
194
+ logLevel,
195
+ messages,
196
+ data,
197
+ hasData
198
+ }: LogLayerTransportParams): any[];
208
199
  }
209
-
200
+ //#endregion
201
+ //#region src/themes.d.ts
210
202
  /**
211
203
  * Moonlight - A dark theme with cool blue tones
212
204
  * Inspired by moonlit nights and modern IDEs
@@ -284,7 +276,9 @@ declare const nature: PrettyTerminalTheme;
284
276
  * - Applications focusing on reduced visual stress
285
277
  */
286
278
  declare const pastel: PrettyTerminalTheme;
287
-
279
+ //#endregion
280
+ //#region src/index.d.ts
288
281
  declare function getPrettyTerminal(config?: PrettyTerminalConfig): PrettyTerminalTransport;
289
-
290
- export { type ColorConfig, type DetailedViewConfig, type LogEntry, type PrettyTerminalConfig, type PrettyTerminalTheme, PrettyTerminalTransport, type ViewConfig, getPrettyTerminal, moonlight, nature, neon, pastel, sunlight };
282
+ //#endregion
283
+ export { ColorConfig, DetailedViewConfig, LogEntry, PrettyTerminalConfig, PrettyTerminalTheme, PrettyTerminalTransport, ViewConfig, chalk, getPrettyTerminal, moonlight, nature, neon, pastel, sunlight };
284
+ //# sourceMappingURL=index.d.cts.map