logixia 1.0.3 → 1.1.2

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 (37) hide show
  1. package/README.md +523 -2852
  2. package/dist/{build-C67p8wVr.js → build-DIEB3doa.js} +7 -2
  3. package/dist/build-DIEB3doa.js.map +1 -0
  4. package/dist/{build-MpmEusc_.mjs → build-MmD3T4bV.mjs} +8 -3
  5. package/dist/build-MmD3T4bV.mjs.map +1 -0
  6. package/dist/{chunk-C41Io3cc.mjs → chunk-uEZWKkIX.mjs} +1 -1
  7. package/dist/{esm-BYmTa3gi.mjs → esm-BRY8ugtK.mjs} +438 -276
  8. package/dist/esm-BRY8ugtK.mjs.map +1 -0
  9. package/dist/{esm-BTpcNBX_.js → esm-CzjF801-.js} +437 -275
  10. package/dist/esm-CzjF801-.js.map +1 -0
  11. package/dist/index.d.mts +1012 -95
  12. package/dist/index.d.mts.map +1 -1
  13. package/dist/index.d.ts +1012 -95
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3558 -1435
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +3517 -1408
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/{lib-DvMm_tAr.mjs → lib-BNWFXK2z.mjs} +2211 -786
  20. package/dist/lib-BNWFXK2z.mjs.map +1 -0
  21. package/dist/{lib-xHiD5O-N.js → lib-Bb_wxP5g.js} +2210 -785
  22. package/dist/lib-Bb_wxP5g.js.map +1 -0
  23. package/dist/{promise-CnIyndHL.mjs → promise-BAWXE7C8.mjs} +820 -1449
  24. package/dist/promise-BAWXE7C8.mjs.map +1 -0
  25. package/dist/{promise-C7YeyZbJ.js → promise-Tbon3Kaq.js} +819 -1448
  26. package/dist/promise-Tbon3Kaq.js.map +1 -0
  27. package/dist/{sqlite3--ZdiJYT3.mjs → sqlite3-BUpkBlte.mjs} +2 -2
  28. package/dist/{sqlite3--ZdiJYT3.mjs.map → sqlite3-BUpkBlte.mjs.map} +1 -1
  29. package/package.json +124 -53
  30. package/dist/build-C67p8wVr.js.map +0 -1
  31. package/dist/build-MpmEusc_.mjs.map +0 -1
  32. package/dist/esm-BTpcNBX_.js.map +0 -1
  33. package/dist/esm-BYmTa3gi.mjs.map +0 -1
  34. package/dist/lib-DvMm_tAr.mjs.map +0 -1
  35. package/dist/lib-xHiD5O-N.js.map +0 -1
  36. package/dist/promise-C7YeyZbJ.js.map +0 -1
  37. package/dist/promise-CnIyndHL.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AsyncLocalStorage } from "async_hooks";
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import * as _nestjs_common0 from "@nestjs/common";
3
3
  import { CallHandler, ExecutionContext, InjectionToken, LoggerService, MiddlewareConsumer, ModuleMetadata, NestInterceptor, NestModule, OptionalFactoryDependency, Type } from "@nestjs/common";
4
4
  import { Observable } from "rxjs";
@@ -11,9 +11,9 @@ interface HttpRequest {
11
11
  method: string;
12
12
  url: string;
13
13
  headers: Record<string, string | string[]>;
14
- query?: Record<string, any>;
15
- params?: Record<string, any>;
16
- body?: any;
14
+ query?: Record<string, unknown>;
15
+ params?: Record<string, unknown>;
16
+ body?: unknown;
17
17
  ip?: string;
18
18
  userAgent?: string;
19
19
  timestamp: number;
@@ -21,14 +21,14 @@ interface HttpRequest {
21
21
  interface HttpResponse {
22
22
  statusCode: number;
23
23
  headers: Record<string, string | string[]>;
24
- body?: any;
24
+ body?: unknown;
25
25
  timestamp: number;
26
26
  contentLength?: number;
27
27
  }
28
28
  interface HttpError extends Error {
29
29
  statusCode?: number;
30
30
  code?: string;
31
- details?: Record<string, any>;
31
+ details?: Record<string, unknown>;
32
32
  }
33
33
  interface RequestTiming {
34
34
  start: number;
@@ -63,7 +63,7 @@ declare const LogLevel: {
63
63
  readonly TRACE: "trace";
64
64
  readonly VERBOSE: "verbose";
65
65
  };
66
- type LogLevel = typeof LogLevel[keyof typeof LogLevel];
66
+ type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
67
67
  type LogLevelString = LogLevel | (string & {});
68
68
  type LogColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | 'grey' | 'brightRed' | 'brightGreen' | 'brightYellow' | 'brightBlue' | 'brightMagenta' | 'brightCyan' | 'brightWhite';
69
69
  type LogFieldKey = 'timestamp' | 'level' | 'appName' | 'service' | 'traceId' | 'message' | 'payload' | 'timeTaken' | 'context' | 'requestId' | 'userId' | 'sessionId' | 'environment';
@@ -80,6 +80,43 @@ interface TraceIdConfig {
80
80
  contextKey?: string;
81
81
  extractor?: TraceIdExtractorConfig;
82
82
  }
83
+ interface RedactConfig {
84
+ /**
85
+ * Dot-notation field paths to redact. Supports `*` (one segment) and `**` (any depth).
86
+ * @example `['req.headers.authorization', '*.password', 'user.creditCard']`
87
+ */
88
+ paths?: string[];
89
+ /**
90
+ * Regex patterns applied to string values — replaces matches with the censor string.
91
+ * @example `[/Bearer\s+\S+/gi, /sk-[a-z0-9]{32,}/gi]`
92
+ */
93
+ patterns?: RegExp[];
94
+ /** Replacement value for redacted content. Default: `"[REDACTED]"` */
95
+ censor?: string;
96
+ }
97
+ /**
98
+ * Per-namespace log level overrides.
99
+ * Keys are namespace patterns (dot-separated, `*` wildcard); values are log levels.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * namespaceLevels: {
104
+ * 'db.*': 'debug', // all db.* namespaces → DEBUG
105
+ * 'http.*': 'warn', // all http.* → WARN only
106
+ * 'payment': 'trace', // payment namespace → TRACE
107
+ * }
108
+ * ```
109
+ * ENV overrides: `LOGIXIA_LEVEL_DB=debug` maps to namespace `db`.
110
+ */
111
+ type NamespaceLevels = Record<string, LogLevelString>;
112
+ interface GracefulShutdownConfig {
113
+ /** Auto-register SIGTERM/SIGINT handlers to flush this logger on exit. Default: false */
114
+ enabled: boolean;
115
+ /** Max ms to wait for transports to flush. Default: 5000 */
116
+ timeout?: number;
117
+ /** Signals to listen on. Default: ['SIGTERM', 'SIGINT'] */
118
+ signals?: NodeJS.Signals[];
119
+ }
83
120
  interface LoggerConfig<TLevels extends Record<string, number> = Record<string, number>> {
84
121
  appName?: string;
85
122
  environment?: Environment;
@@ -96,17 +133,34 @@ interface LoggerConfig<TLevels extends Record<string, number> = Record<string, n
96
133
  colors?: Record<string, LogColor>;
97
134
  } | undefined;
98
135
  fields?: Partial<Record<LogFieldKey, string | boolean>>;
99
- [key: string]: any;
136
+ /**
137
+ * Built-in log redaction — masks sensitive fields before they reach any transport.
138
+ * @see RedactConfig
139
+ */
140
+ redact?: RedactConfig;
141
+ /**
142
+ * Per-namespace log level overrides.
143
+ * A child logger's context is used as its namespace for matching.
144
+ * ENV vars `LOGIXIA_LEVEL_<NS>=<level>` also apply.
145
+ */
146
+ namespaceLevels?: NamespaceLevels;
147
+ /**
148
+ * Automatically register SIGTERM/SIGINT handlers that flush all transports
149
+ * before the process exits — prevents losing the last N seconds of logs on
150
+ * deployments / restarts.
151
+ */
152
+ gracefulShutdown?: boolean | GracefulShutdownConfig;
153
+ [key: string]: unknown;
100
154
  }
101
155
  interface IBaseLogger {
102
- error(message: string, data?: Record<string, any>): Promise<void>;
103
- error(error: Error, data?: Record<string, any>): Promise<void>;
104
- warn(message: string, data?: Record<string, any>): Promise<void>;
105
- info(message: string, data?: Record<string, any>): Promise<void>;
106
- debug(message: string, data?: Record<string, any>): Promise<void>;
107
- trace(message: string, data?: Record<string, any>): Promise<void>;
108
- verbose(message: string, data?: Record<string, any>): Promise<void>;
109
- logLevel(level: string, message: string, data?: Record<string, any>): Promise<void>;
156
+ error(message: string, data?: Record<string, unknown>): Promise<void>;
157
+ error(error: Error, data?: Record<string, unknown>): Promise<void>;
158
+ warn(message: string, data?: Record<string, unknown>): Promise<void>;
159
+ info(message: string, data?: Record<string, unknown>): Promise<void>;
160
+ debug(message: string, data?: Record<string, unknown>): Promise<void>;
161
+ trace(message: string, data?: Record<string, unknown>): Promise<void>;
162
+ verbose(message: string, data?: Record<string, unknown>): Promise<void>;
163
+ logLevel(level: string, message: string, data?: Record<string, unknown>): Promise<void>;
110
164
  time(label: string): void;
111
165
  timeEnd(label: string): Promise<number | undefined>;
112
166
  timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
@@ -125,10 +179,10 @@ interface IBaseLogger {
125
179
  getTransportLevels(transportId: string): string[] | undefined;
126
180
  clearTransportLevelPreferences(): void;
127
181
  getAvailableTransports(): string[];
128
- child(context: string, data?: Record<string, any>): ILogger;
182
+ child(context: string, data?: Record<string, unknown>): ILogger;
129
183
  close(): Promise<void>;
130
184
  }
131
- type CustomLevelMethods<T extends Record<string, number>> = { [K in keyof T]: (message: string, data?: Record<string, any>) => Promise<void> };
185
+ type CustomLevelMethods<T extends Record<string, number>> = { [K in keyof T]: (message: string, data?: Record<string, unknown>) => Promise<void> };
132
186
  type ILogger<TLevels extends Record<string, number> = {}> = IBaseLogger & CustomLevelMethods<TLevels>;
133
187
  interface ILoggerDefault extends IBaseLogger {}
134
188
  type LoggerWithLevels<T extends LoggerConfig<any>> = T['levelOptions'] extends {
@@ -142,7 +196,7 @@ interface LogEntry {
142
196
  environment?: string;
143
197
  traceId?: string;
144
198
  message: string;
145
- payload?: Record<string, any>;
199
+ payload?: Record<string, unknown>;
146
200
  context?: string;
147
201
  error?: Error;
148
202
  }
@@ -158,7 +212,7 @@ interface TimingEntry {
158
212
  duration?: number;
159
213
  }
160
214
  interface ContextData {
161
- [key: string]: any;
215
+ [key: string]: unknown;
162
216
  }
163
217
  interface ILogFormatter {
164
218
  format(entry: LogEntry): string;
@@ -203,33 +257,45 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<any> = LoggerConfig> im
203
257
  private contextData;
204
258
  private transportManager?;
205
259
  private fieldState;
206
- constructor(config: TConfig, context?: string);
260
+ /** Stable fallback trace ID generated ONCE per logger instance. */
261
+ private readonly fallbackTraceId;
262
+ /** Numeric value for each known log level — built once, read on every log call. */
263
+ private _levelValues;
264
+ /** Numeric threshold for the currently active log level. */
265
+ private _minLevelValue;
266
+ /** Pre-built ANSI color codes to avoid recreating the object in colorize(). */
267
+ private _colorMap;
268
+ /** Pre-computed field-enabled booleans so isFieldEnabled() isn't called per log. */
269
+ private _fieldCache;
270
+ /** True when contextData is non-empty — avoids Object.keys() check on hot path. */
271
+ private _hasContextData;
207
272
  /**
208
- * Create dynamic methods for custom levels
273
+ * Pre-computed `[INFO] `, `[WARN] ` etc. strings — avoids a colorize() call per log.
274
+ * Key: lowercase level name. Value: formatted bracket string ready to concatenate.
209
275
  */
276
+ private _formattedLevels;
277
+ /** Pre-computed `[appName] ` string — avoids template literal allocation per log. */
278
+ private _formattedAppName;
279
+ /** True when a redact config is present — short-circuits applyRedaction when false. */
280
+ private _hasRedact;
281
+ constructor(config: TConfig, context?: string);
282
+ private setupGracefulShutdown;
210
283
  private createCustomLevelMethods;
211
284
  /**
212
- * Error logging with overloads
213
- */
214
- error(messageOrError: string | Error, data?: Record<string, any>): Promise<void>;
215
- warn(message: string, data?: Record<string, any>): Promise<void>;
216
- info(message: string, data?: Record<string, any>): Promise<void>;
217
- debug(message: string, data?: Record<string, any>): Promise<void>;
218
- trace(message: string, data?: Record<string, any>): Promise<void>;
219
- verbose(message: string, data?: Record<string, any>): Promise<void>;
220
- /**
221
- * Log with custom level
222
- */
223
- logLevel(level: string, message: string, data?: Record<string, any>): Promise<void>;
224
- /**
225
- * Timing methods
285
+ * Rebuild all hot-path caches after any config mutation or level change.
286
+ * Keeps the actual log() call free of allocations in the common case.
226
287
  */
288
+ private _buildPerfCaches;
289
+ error(messageOrError: string | Error, data?: Record<string, unknown>): Promise<void>;
290
+ warn(message: string, data?: Record<string, unknown>): Promise<void>;
291
+ info(message: string, data?: Record<string, unknown>): Promise<void>;
292
+ debug(message: string, data?: Record<string, unknown>): Promise<void>;
293
+ trace(message: string, data?: Record<string, unknown>): Promise<void>;
294
+ verbose(message: string, data?: Record<string, unknown>): Promise<void>;
295
+ logLevel(level: string, message: string, data?: Record<string, unknown>): Promise<void>;
227
296
  time(label: string): void;
228
297
  timeEnd(label: string): Promise<number | undefined>;
229
298
  timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;
230
- /**
231
- * Level and context management
232
- */
233
299
  setLevel(level: LogLevelString): void;
234
300
  getLevel(): LogLevelString;
235
301
  setContext(context: string): void;
@@ -245,46 +311,33 @@ declare class LogixiaLogger<TConfig extends LoggerConfig<any> = LoggerConfig> im
245
311
  getTransportLevels(transportId: string): string[] | undefined;
246
312
  clearTransportLevelPreferences(): void;
247
313
  getAvailableTransports(): string[];
248
- /**
249
- * Create child logger
250
- */
251
- child(context: string, data?: Record<string, any>): ILogger;
252
- /**
253
- * Flush all transports
254
- */
314
+ child(context: string, data?: Record<string, unknown>): ILogger;
255
315
  flush(): Promise<void>;
256
- /**
257
- * Check health of all transports
258
- */
259
316
  healthCheck(): Promise<{
260
317
  healthy: boolean;
261
- details: Record<string, any>;
318
+ details: Record<string, unknown>;
262
319
  }>;
263
- /**
264
- * Close logger and cleanup resources
265
- */
266
320
  close(): Promise<void>;
267
- /**
268
- * Core logging method
269
- */
270
321
  private log;
271
322
  /**
272
- * Format log entry according to configuration
273
- */
274
- private formatLog;
275
- /**
276
- * Colorize text based on color name
323
+ * Hot-path level check: a single Map lookup + integer compare.
324
+ * The level map and threshold are pre-built in _buildPerfCaches().
277
325
  */
278
- private colorize;
279
326
  private shouldLog;
280
327
  /**
281
- * Output log to console or other destinations
328
+ * Feature 3: Resolve the effective log level for this logger instance.
329
+ *
330
+ * Priority:
331
+ * 1. ENV `LOGIXIA_LEVEL_<NS_UPPER>` (e.g. LOGIXIA_LEVEL_DB for ns "db" or "db.queries")
332
+ * 2. Matching `namespaceLevels` config entry (longer pattern = more specific, wins)
333
+ * 3. Global `LOGIXIA_LEVEL` ENV override
334
+ * 4. `levelOptions.level` (resolved via Feature 5 in constructor)
282
335
  */
336
+ private resolveEffectiveLevel;
337
+ private formatLog;
338
+ private colorize;
283
339
  private output;
284
340
  }
285
- /**
286
- * Factory function to create a typed logger with custom levels
287
- */
288
341
  declare function createLogger$1<T extends LoggerConfig<any>>(config: T, context?: string): LoggerWithLevels<T>;
289
342
  //#endregion
290
343
  //#region src/core/logitron-nestjs.service.d.ts
@@ -295,17 +348,17 @@ declare class LogixiaLoggerService implements LoggerService {
295
348
  /**
296
349
  * NestJS LoggerService interface implementation
297
350
  */
298
- log(message: any, context?: string): void;
299
- error(message: any, trace?: string, context?: string): void;
300
- warn(message: any, context?: string): void;
301
- debug(message: any, context?: string): void;
302
- verbose(message: any, context?: string): void;
351
+ log(message: unknown, context?: string): void;
352
+ error(message: unknown, trace?: string, context?: string): void;
353
+ warn(message: unknown, context?: string): void;
354
+ debug(message: unknown, context?: string): void;
355
+ verbose(message: unknown, context?: string): void;
303
356
  /**
304
357
  * Extended Logitron methods
305
358
  */
306
- info(message: string, data?: Record<string, any>): Promise<void>;
307
- trace(message: string, data?: Record<string, any>): Promise<void>;
308
- logLevel(level: string, message: string, data?: Record<string, any>): Promise<void>;
359
+ info(message: string, data?: Record<string, unknown>): Promise<void>;
360
+ trace(message: string, data?: Record<string, unknown>): Promise<void>;
361
+ logLevel(level: string, message: string, data?: Record<string, unknown>): Promise<void>;
309
362
  /**
310
363
  * Timing methods
311
364
  */
@@ -322,7 +375,7 @@ declare class LogixiaLoggerService implements LoggerService {
322
375
  /**
323
376
  * Create child logger
324
377
  */
325
- child(context: string, data?: Record<string, any>): LogixiaLoggerService;
378
+ child(context: string, data?: Record<string, unknown>): LogixiaLoggerService;
326
379
  /**
327
380
  * Get current trace ID
328
381
  */
@@ -366,7 +419,7 @@ declare const LOGIXIA_LOGGER_PREFIX = "LOGIXIA_LOGGER_";
366
419
  interface LogixiaAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
367
420
  useExisting?: Type<LogixiaOptionsFactory>;
368
421
  useClass?: Type<LogixiaOptionsFactory>;
369
- useFactory?: (...args: any[]) => Promise<Partial<LoggerConfig>> | Partial<LoggerConfig>;
422
+ useFactory?: (...args: unknown[]) => Promise<Partial<LoggerConfig>> | Partial<LoggerConfig>;
370
423
  inject?: Array<InjectionToken | OptionalFactoryDependency>;
371
424
  }
372
425
  interface LogixiaOptionsFactory {
@@ -421,7 +474,7 @@ declare class LogixiaLoggerModule implements NestModule {
421
474
  imports: (Type<any> | _nestjs_common0.DynamicModule | Promise<_nestjs_common0.DynamicModule> | _nestjs_common0.ForwardReference<any>)[];
422
475
  providers: ({
423
476
  provide: string;
424
- useFactory: (...args: any[]) => Promise<Partial<LoggerConfig>> | Partial<LoggerConfig>;
477
+ useFactory: (...args: unknown[]) => Promise<Partial<LoggerConfig>> | Partial<LoggerConfig>;
425
478
  inject: (InjectionToken | OptionalFactoryDependency)[];
426
479
  } | {
427
480
  provide: string;
@@ -515,9 +568,89 @@ declare class TextFormatter implements ILogFormatter {
515
568
  static createMinimal(): TextFormatter;
516
569
  }
517
570
  //#endregion
571
+ //#region src/utils/error.utils.d.ts
572
+ /**
573
+ * Serialize an Error into a plain JSON-safe object, including:
574
+ * - `name`, `message`, `stack`
575
+ * - `cause` (recursively serialized, full ES2022 chain)
576
+ * - `errors` (for AggregateError)
577
+ * - standard Node.js error fields (`code`, `statusCode`, `errno`, …)
578
+ * - any other enumerable own properties
579
+ */
580
+ declare function serializeError(error: Error, options?: ErrorSerializationOptions): Record<string, unknown>;
581
+ /**
582
+ * Type guard: returns true if the value looks like an Error object.
583
+ */
584
+ declare function isError(value: unknown): value is Error;
585
+ /**
586
+ * Coerce any thrown value into a proper Error instance.
587
+ */
588
+ declare function normalizeError(error: unknown): Error;
589
+ //#endregion
590
+ //#region src/utils/redact.utils.d.ts
591
+ /**
592
+ * Deep-clone and redact an object according to the given RedactConfig.
593
+ * Non-objects are returned as-is (with pattern replacement on strings).
594
+ *
595
+ * The function is intentionally non-mutating — it returns a new object.
596
+ */
597
+ declare function redactObject(obj: Record<string, unknown>, config: RedactConfig, _currentPath?: string): Record<string, unknown>;
598
+ /**
599
+ * Apply redaction to a log payload (top-level call convenience wrapper).
600
+ * Returns a new object — never mutates the input.
601
+ */
602
+ declare function applyRedaction(payload: Record<string, unknown> | undefined, config: RedactConfig | undefined): Record<string, unknown> | undefined;
603
+ //#endregion
604
+ //#region src/utils/shutdown.utils.d.ts
605
+ /**
606
+ * Graceful shutdown utilities for Logixia
607
+ *
608
+ * Ensures all in-flight logs are flushed to every transport before the process
609
+ * exits on SIGTERM / SIGINT — solving the "last N seconds of logs are lost on
610
+ * deployment" problem reported in Pino issue #2002 and LogDNA issue #15.
611
+ */
612
+ interface FlushOnExitOptions {
613
+ /** How long (ms) to wait for transports to flush before force-exiting. Default: 5000 */
614
+ timeout?: number;
615
+ /** OS signals that trigger a graceful flush. Default: ['SIGTERM', 'SIGINT'] */
616
+ signals?: NodeJS.Signals[];
617
+ /** Called just before flushing starts — useful for stopping traffic intake */
618
+ beforeFlush?: () => void | Promise<void>;
619
+ /** Called after all loggers have flushed successfully */
620
+ afterFlush?: () => void | Promise<void>;
621
+ }
622
+ type Closeable = {
623
+ close(): Promise<void>;
624
+ };
625
+ /**
626
+ * Register a logger instance so it is included in the graceful shutdown flush.
627
+ * Called automatically when `gracefulShutdown: true` is set in logger config.
628
+ */
629
+ declare function registerForShutdown(logger: Closeable): void;
630
+ /**
631
+ * Deregister a logger (e.g. after `logger.close()` is called manually).
632
+ */
633
+ declare function deregisterFromShutdown(logger: Closeable): void;
634
+ /**
635
+ * Register SIGTERM / SIGINT handlers that flush all registered loggers before
636
+ * the process exits. Idempotent — calling multiple times is safe.
637
+ *
638
+ * @example
639
+ * ```ts
640
+ * import { flushOnExit } from 'logixia';
641
+ * flushOnExit({ timeout: 5000 });
642
+ * ```
643
+ */
644
+ declare function flushOnExit(options?: FlushOnExitOptions): void;
645
+ /**
646
+ * Remove all graceful shutdown handlers and clear the registry.
647
+ * Primarily useful in tests.
648
+ */
649
+ declare function resetShutdownHandlers(): void;
650
+ //#endregion
518
651
  //#region src/utils/trace.utils.d.ts
519
652
  declare const traceStorage: AsyncLocalStorage<{
520
- [key: string]: any;
653
+ [key: string]: unknown;
521
654
  traceId: string;
522
655
  }>;
523
656
  /**
@@ -529,35 +662,823 @@ declare function generateTraceId(): string;
529
662
  */
530
663
  declare function getCurrentTraceId(): string | undefined;
531
664
  /**
532
- * Set trace ID in async context
665
+ * Set trace ID in the CURRENT async context without starting a new one.
666
+ *
667
+ * ⚠️ Uses `enterWith()` which mutates the context for the current async
668
+ * execution and ALL futures spawned from it. Prefer `runWithTraceId()` when
669
+ * you can wrap the operation in a callback, as it creates a properly-scoped
670
+ * child context. Use `setTraceId()` only when you cannot use `runWithTraceId()`
671
+ * (e.g., inside a class constructor or a non-callback async entry point).
533
672
  */
534
- declare function setTraceId(traceId: string, data?: Record<string, any>): void;
673
+ declare function setTraceId(traceId: string, data?: Record<string, unknown>): void;
535
674
  /**
536
675
  * Run function with trace ID context
537
676
  */
538
- declare function runWithTraceId<T>(traceId: string, fn: () => T, data?: Record<string, any>): T;
677
+ declare function runWithTraceId<T>(traceId: string, fn: () => T, data?: Record<string, unknown>): T;
539
678
  /**
540
679
  * Extract trace ID from request using configuration
541
680
  */
542
- declare function extractTraceId(request: any, config: TraceIdExtractorConfig): string | undefined;
681
+ declare function extractTraceId(request: unknown, config: TraceIdExtractorConfig): string | undefined;
682
+ /**
683
+ * Default headers checked for incoming trace ID propagation, in priority order:
684
+ * traceparent (W3C/OTel) → x-trace-id → x-request-id → x-correlation-id → trace-id
685
+ */
686
+ declare const DEFAULT_TRACE_HEADERS: string[];
543
687
  /**
544
688
  * Create trace ID middleware for Express/NestJS
545
689
  */
546
- declare function createTraceMiddleware(config: TraceIdConfig): (req: any, res: any, next: any) => void;
690
+ declare function createTraceMiddleware(config: TraceIdConfig): (req: unknown, res: unknown, next: () => void) => void;
547
691
  //#endregion
548
- //#region src/utils/error.utils.d.ts
692
+ //#region src/search/types/search.types.d.ts
693
+ /**
694
+ * Search filter options
695
+ */
696
+ interface SearchFilters {
697
+ levels?: string[];
698
+ services?: string[];
699
+ traceIds?: string[];
700
+ timeRange?: TimeRange;
701
+ userIds?: string[];
702
+ sessionIds?: string[];
703
+ contexts?: string[];
704
+ excludePatterns?: string[];
705
+ minSeverity?: number;
706
+ hasError?: boolean;
707
+ customFields?: Record<string, unknown>;
708
+ }
709
+ /**
710
+ * Time range for filtering logs
711
+ */
712
+ interface TimeRange {
713
+ start: Date | number;
714
+ end?: Date | number;
715
+ relative?: RelativeTime;
716
+ }
549
717
  /**
550
- * Serialize error object to JSON-safe format
718
+ * Relative time specification
551
719
  */
552
- declare function serializeError(error: Error, options?: ErrorSerializationOptions): Record<string, any>;
720
+ interface RelativeTime {
721
+ value: number;
722
+ unit: 'seconds' | 'minutes' | 'hours' | 'days';
723
+ }
553
724
  /**
554
- * Check if value is an Error instance
725
+ * Search result with metadata
555
726
  */
556
- declare function isError(value: any): value is Error;
727
+ interface SearchResult {
728
+ log: LogEntry;
729
+ score: number;
730
+ highlights?: SearchHighlight[];
731
+ matches?: SearchMatch[];
732
+ context?: LogEntry[];
733
+ relatedLogs?: RelatedLog[];
734
+ }
557
735
  /**
558
- * Create error from various input types
736
+ * Search highlight information
559
737
  */
560
- declare function normalizeError(error: any): Error;
738
+ interface SearchHighlight {
739
+ field: string;
740
+ fragments: string[];
741
+ matchedTerms: string[];
742
+ }
743
+ /**
744
+ * Search match details
745
+ */
746
+ interface SearchMatch {
747
+ field: string;
748
+ value: string;
749
+ position: number;
750
+ length: number;
751
+ }
752
+ /**
753
+ * Related log entry
754
+ */
755
+ interface RelatedLog {
756
+ log: LogEntry;
757
+ relationship: RelationshipType;
758
+ score: number;
759
+ }
760
+ /**
761
+ * Type of relationship between logs
762
+ */
763
+ type RelationshipType = 'same_trace' | 'same_user' | 'same_session' | 'temporal_proximity' | 'error_cascade' | 'similar_pattern';
764
+ /**
765
+ * Correlated logs grouped by trace ID or other criteria
766
+ */
767
+ interface CorrelatedLogs {
768
+ traceId?: string;
769
+ correlationKey: string;
770
+ logs: LogEntry[];
771
+ timeline: TimelineEvent[];
772
+ summary?: LogCorrelationSummary;
773
+ }
774
+ /**
775
+ * Timeline event for correlated logs
776
+ */
777
+ interface TimelineEvent {
778
+ timestamp: Date;
779
+ log: LogEntry;
780
+ eventType: 'start' | 'end' | 'error' | 'milestone' | 'info';
781
+ duration?: number;
782
+ }
783
+ /**
784
+ * Summary of correlated logs
785
+ */
786
+ interface LogCorrelationSummary {
787
+ totalLogs: number;
788
+ errorCount: number;
789
+ warningCount: number;
790
+ duration?: number;
791
+ services: string[];
792
+ criticalPath?: LogEntry[];
793
+ }
794
+ /**
795
+ * Similar log entry
796
+ */
797
+ interface SimilarLog {
798
+ log: LogEntry;
799
+ similarity: number;
800
+ matchedPatterns: string[];
801
+ reason: string;
802
+ }
803
+ /**
804
+ * Search query with metadata
805
+ */
806
+ interface SearchQuery {
807
+ query: string;
808
+ filters?: SearchFilters;
809
+ options?: SearchOptions;
810
+ timestamp: Date;
811
+ userId?: string;
812
+ }
813
+ /**
814
+ * Search options
815
+ */
816
+ interface SearchOptions {
817
+ limit?: number;
818
+ offset?: number;
819
+ sortBy?: SortField;
820
+ sortOrder?: 'asc' | 'desc';
821
+ includeContext?: boolean;
822
+ contextSize?: number;
823
+ highlightMatches?: boolean;
824
+ findSimilar?: boolean;
825
+ correlate?: boolean;
826
+ semanticSearch?: boolean;
827
+ }
828
+ /**
829
+ * Sort field options
830
+ */
831
+ type SortField = 'timestamp' | 'level' | 'score' | 'relevance';
832
+ /**
833
+ * Search suggestion
834
+ */
835
+ interface SearchSuggestion {
836
+ text: string;
837
+ type: SuggestionType;
838
+ category?: string;
839
+ frequency?: number;
840
+ lastUsed?: Date;
841
+ }
842
+ /**
843
+ * Suggestion type
844
+ */
845
+ type SuggestionType = 'field' | 'value' | 'operator' | 'query_history' | 'pattern' | 'filter';
846
+ /**
847
+ * Search statistics
848
+ */
849
+ interface SearchStats {
850
+ totalResults: number;
851
+ executionTime: number;
852
+ indexSize: number;
853
+ cacheHitRate?: number;
854
+ topTerms?: string[];
855
+ }
856
+ /**
857
+ * Semantic index for intelligent search
858
+ */
859
+ interface SemanticIndex {
860
+ version: string;
861
+ indexedCount: number;
862
+ lastUpdated: Date;
863
+ embeddings?: Map<string, number[]>;
864
+ clusters?: LogCluster[];
865
+ }
866
+ /**
867
+ * Log cluster for grouping similar logs
868
+ */
869
+ interface LogCluster {
870
+ id: string;
871
+ centroid: number[];
872
+ logs: LogEntry[];
873
+ pattern: string;
874
+ frequency: number;
875
+ labels?: string[];
876
+ }
877
+ /**
878
+ * Log pattern for pattern recognition
879
+ */
880
+ interface LogPattern {
881
+ id: string;
882
+ pattern: string;
883
+ regex?: RegExp;
884
+ examples: LogEntry[];
885
+ frequency: number;
886
+ lastSeen: Date;
887
+ category?: string;
888
+ severity?: string;
889
+ }
890
+ /**
891
+ * Anomaly detection result
892
+ */
893
+ interface AnomalyDetection {
894
+ log: LogEntry;
895
+ anomalyScore: number;
896
+ reason: string;
897
+ expectedPattern?: string;
898
+ deviations: string[];
899
+ }
900
+ /**
901
+ * Natural language query parsed result
902
+ */
903
+ interface ParsedNLQuery {
904
+ originalQuery: string;
905
+ intent: QueryIntent;
906
+ entities: QueryEntity[];
907
+ filters: SearchFilters;
908
+ timeRange?: TimeRange;
909
+ confidence: number;
910
+ }
911
+ /**
912
+ * Query intent
913
+ */
914
+ type QueryIntent = 'find_errors' | 'trace_request' | 'find_user_activity' | 'performance_analysis' | 'find_similar' | 'time_range_query' | 'correlation' | 'general_search';
915
+ /**
916
+ * Query entity extracted from natural language
917
+ */
918
+ interface QueryEntity {
919
+ type: EntityType;
920
+ value: string;
921
+ field?: string;
922
+ confidence: number;
923
+ }
924
+ /**
925
+ * Entity type
926
+ */
927
+ type EntityType = 'level' | 'service' | 'user_id' | 'trace_id' | 'time' | 'error_type' | 'field_value';
928
+ /**
929
+ * Search preset for saving common searches
930
+ */
931
+ interface SearchPreset {
932
+ id: string;
933
+ name: string;
934
+ description?: string;
935
+ query: string;
936
+ filters: SearchFilters;
937
+ options: SearchOptions;
938
+ createdAt: Date;
939
+ updatedAt: Date;
940
+ userId?: string;
941
+ shared?: boolean;
942
+ }
943
+ /**
944
+ * Export options for search results
945
+ */
946
+ interface ExportOptions {
947
+ format: 'json' | 'csv' | 'text';
948
+ includeMetadata?: boolean;
949
+ filename?: string;
950
+ fields?: string[];
951
+ }
952
+ //#endregion
953
+ //#region src/search/search-manager.d.ts
954
+ /**
955
+ * Configuration for search manager
956
+ */
957
+ interface SearchManagerConfig {
958
+ enableNLP?: boolean;
959
+ enablePatternRecognition?: boolean;
960
+ enableCorrelation?: boolean;
961
+ maxIndexSize?: number;
962
+ autoOptimize?: boolean;
963
+ }
964
+ /**
965
+ * Main search manager class
966
+ */
967
+ declare class SearchManager {
968
+ private searchEngine;
969
+ private indexer;
970
+ private patternEngine?;
971
+ private correlationEngine?;
972
+ private config;
973
+ constructor(config?: SearchManagerConfig);
974
+ /**
975
+ * Index new logs
976
+ */
977
+ indexLogs(logs: LogEntry[]): Promise<void>;
978
+ /**
979
+ * Add a single log to the index
980
+ */
981
+ indexLog(log: LogEntry): Promise<void>;
982
+ /**
983
+ * Perform a search
984
+ */
985
+ search(query: string, filters?: SearchFilters, options?: SearchOptions): Promise<SearchResult[]>;
986
+ /**
987
+ * Perform a natural language search
988
+ */
989
+ naturalLanguageSearch(query: string): Promise<SearchResult[]>;
990
+ /**
991
+ * Find logs correlated by trace ID
992
+ */
993
+ correlateByTraceId(traceId: string): Promise<CorrelatedLogs>;
994
+ /**
995
+ * Find similar logs
996
+ */
997
+ findSimilarLogs(logEntry: LogEntry, limit?: number): Promise<SimilarLog[]>;
998
+ /**
999
+ * Find logs related to a given log
1000
+ */
1001
+ findRelatedLogs(log: LogEntry, limit?: number): Promise<RelatedLog[]>;
1002
+ /**
1003
+ * Get search suggestions
1004
+ */
1005
+ getSuggestions(partialQuery: string, limit?: number): Promise<SearchSuggestion[]>;
1006
+ /**
1007
+ * Get search statistics
1008
+ */
1009
+ getStats(): Promise<SearchStats>;
1010
+ /**
1011
+ * Parse natural language query
1012
+ */
1013
+ parseNaturalLanguageQuery(query: string): Promise<ParsedNLQuery>;
1014
+ /**
1015
+ * Save a search preset
1016
+ */
1017
+ savePreset(preset: Omit<SearchPreset, 'id' | 'createdAt' | 'updatedAt'>): Promise<SearchPreset>;
1018
+ /**
1019
+ * Get saved presets
1020
+ */
1021
+ getPresets(userId?: string): Promise<SearchPreset[]>;
1022
+ /**
1023
+ * Delete a preset
1024
+ */
1025
+ deletePreset(presetId: string): Promise<void>;
1026
+ /**
1027
+ * Detect log patterns
1028
+ */
1029
+ detectPatterns(): Promise<LogPattern[]>;
1030
+ /**
1031
+ * Get detected patterns
1032
+ */
1033
+ getPatterns(): LogPattern[];
1034
+ /**
1035
+ * Detect anomalies in logs
1036
+ */
1037
+ detectAnomalies(): Promise<AnomalyDetection[]>;
1038
+ /**
1039
+ * Correlate logs by multiple criteria
1040
+ */
1041
+ correlateByMultipleCriteria(criteria: {
1042
+ traceId?: boolean;
1043
+ userId?: boolean;
1044
+ sessionId?: boolean;
1045
+ temporal?: boolean;
1046
+ errorCascade?: boolean;
1047
+ }): Promise<Map<string, CorrelatedLogs>>;
1048
+ /**
1049
+ * Analyze error cascades
1050
+ */
1051
+ analyzeErrorCascade(traceId: string): Promise<{
1052
+ rootCause?: LogEntry;
1053
+ cascade: LogEntry[];
1054
+ impactedServices: string[];
1055
+ }>;
1056
+ /**
1057
+ * Export search results
1058
+ */
1059
+ exportResults(results: SearchResult[], options: ExportOptions): Promise<string>;
1060
+ /**
1061
+ * Clear all indexed data
1062
+ */
1063
+ clearIndex(): Promise<void>;
1064
+ /**
1065
+ * Optimize the index
1066
+ */
1067
+ optimizeIndex(): Promise<void>;
1068
+ /**
1069
+ * Get index statistics
1070
+ */
1071
+ getIndexStats(): Promise<{
1072
+ totalDocuments: number;
1073
+ indexSize: number;
1074
+ lastOptimized?: Date;
1075
+ }>;
1076
+ /**
1077
+ * Remove old logs
1078
+ */
1079
+ removeOldLogs(olderThan: Date): Promise<number>;
1080
+ private exportAsJSON;
1081
+ private exportAsCSV;
1082
+ private exportAsText;
1083
+ private filterFields;
1084
+ private getNestedValue;
1085
+ private escapeCSVValue;
1086
+ }
1087
+ //#endregion
1088
+ //#region src/search/core/log-indexer.interface.d.ts
1089
+ /**
1090
+ * Log indexer interface
1091
+ */
1092
+ interface ILogIndexer {
1093
+ /**
1094
+ * Index a single log entry
1095
+ * @param log - Log entry to index
1096
+ */
1097
+ indexLog(log: LogEntry): Promise<void>;
1098
+ /**
1099
+ * Index multiple log entries in batch
1100
+ * @param logs - Array of log entries to index
1101
+ */
1102
+ indexBatch(logs: LogEntry[]): Promise<void>;
1103
+ /**
1104
+ * Build semantic index for intelligent search
1105
+ * @param logs - Array of log entries to build index from
1106
+ * @returns Semantic index
1107
+ */
1108
+ buildSemanticIndex(logs: LogEntry[]): Promise<SemanticIndex>;
1109
+ /**
1110
+ * Update search suggestions based on search history
1111
+ * @param searchHistory - Array of past search queries
1112
+ */
1113
+ updateSearchSuggestions(searchHistory: SearchQuery[]): Promise<void>;
1114
+ /**
1115
+ * Optimize the index for better performance
1116
+ */
1117
+ optimizeIndex(): Promise<void>;
1118
+ /**
1119
+ * Clear the index
1120
+ */
1121
+ clearIndex(): Promise<void>;
1122
+ /**
1123
+ * Get index statistics
1124
+ * @returns Index statistics
1125
+ */
1126
+ getIndexStats(): Promise<{
1127
+ totalDocuments: number;
1128
+ indexSize: number;
1129
+ lastOptimized?: Date;
1130
+ }>;
1131
+ /**
1132
+ * Remove logs older than specified time
1133
+ * @param olderThan - Remove logs older than this date
1134
+ * @returns Number of logs removed
1135
+ */
1136
+ removeOldLogs(olderThan: Date): Promise<number>;
1137
+ }
1138
+ //#endregion
1139
+ //#region src/search/core/basic-log-indexer.d.ts
1140
+ /**
1141
+ * Basic log indexer implementation
1142
+ */
1143
+ declare class BasicLogIndexer implements ILogIndexer {
1144
+ private options?;
1145
+ private index;
1146
+ private fieldIndices;
1147
+ private semanticIndex;
1148
+ private lastOptimized?;
1149
+ constructor(options?: {
1150
+ maxIndexSize?: number;
1151
+ autoOptimize?: boolean;
1152
+ optimizeThreshold?: number;
1153
+ } | undefined);
1154
+ /**
1155
+ * Index a single log entry
1156
+ */
1157
+ indexLog(log: LogEntry): Promise<void>;
1158
+ /**
1159
+ * Index multiple log entries in batch
1160
+ */
1161
+ indexBatch(logs: LogEntry[]): Promise<void>;
1162
+ /**
1163
+ * Build semantic index for intelligent search
1164
+ */
1165
+ buildSemanticIndex(logs: LogEntry[]): Promise<SemanticIndex>;
1166
+ /**
1167
+ * Update search suggestions based on search history
1168
+ */
1169
+ updateSearchSuggestions(searchHistory: SearchQuery[]): Promise<void>;
1170
+ /**
1171
+ * Optimize the index for better performance
1172
+ */
1173
+ optimizeIndex(): Promise<void>;
1174
+ /**
1175
+ * Clear the index
1176
+ */
1177
+ clearIndex(): Promise<void>;
1178
+ /**
1179
+ * Get index statistics
1180
+ */
1181
+ getIndexStats(): Promise<{
1182
+ totalDocuments: number;
1183
+ indexSize: number;
1184
+ lastOptimized?: Date;
1185
+ }>;
1186
+ /**
1187
+ * Remove logs older than specified time
1188
+ */
1189
+ removeOldLogs(olderThan: Date): Promise<number>;
1190
+ /**
1191
+ * Search logs by field
1192
+ */
1193
+ searchByField(field: string, value: string): LogEntry[];
1194
+ /**
1195
+ * Get all indexed logs
1196
+ */
1197
+ getAllLogs(): LogEntry[];
1198
+ private initializeFieldIndices;
1199
+ private updateFieldIndices;
1200
+ private addToFieldIndex;
1201
+ private removeFromFieldIndices;
1202
+ private generateLogId;
1203
+ private calculateIndexSize;
1204
+ private removeOldestLogs;
1205
+ private clusterLogs;
1206
+ }
1207
+ //#endregion
1208
+ //#region src/search/core/search-engine.interface.d.ts
1209
+ /**
1210
+ * Main search engine interface
1211
+ */
1212
+ interface ILogSearchEngine {
1213
+ /**
1214
+ * Perform a full-text search across logs
1215
+ * @param query - Search query string
1216
+ * @param filters - Optional filters to narrow down results
1217
+ * @param options - Search options
1218
+ * @returns Array of search results
1219
+ */
1220
+ search(query: string, filters?: SearchFilters, options?: SearchOptions): Promise<SearchResult[]>;
1221
+ /**
1222
+ * Perform a natural language search
1223
+ * @param query - Natural language query
1224
+ * @returns Array of search results
1225
+ */
1226
+ naturalLanguageSearch(query: string): Promise<SearchResult[]>;
1227
+ /**
1228
+ * Find logs correlated by trace ID
1229
+ * @param traceId - Trace ID to correlate logs
1230
+ * @returns Correlated logs
1231
+ */
1232
+ correlateByTraceId(traceId: string): Promise<CorrelatedLogs>;
1233
+ /**
1234
+ * Find logs similar to a given log entry
1235
+ * @param logEntry - Log entry to find similar logs for
1236
+ * @param limit - Maximum number of similar logs to return
1237
+ * @returns Array of similar logs
1238
+ */
1239
+ findSimilarLogs(logEntry: LogEntry, limit?: number): Promise<SimilarLog[]>;
1240
+ /**
1241
+ * Get search suggestions based on partial query
1242
+ * @param partialQuery - Partial query string
1243
+ * @param limit - Maximum number of suggestions
1244
+ * @returns Array of suggestions
1245
+ */
1246
+ getSuggestions(partialQuery: string, limit?: number): Promise<SearchSuggestion[]>;
1247
+ /**
1248
+ * Get search statistics
1249
+ * @returns Search statistics
1250
+ */
1251
+ getStats(): Promise<SearchStats>;
1252
+ /**
1253
+ * Parse natural language query
1254
+ * @param query - Natural language query
1255
+ * @returns Parsed query with intent and entities
1256
+ */
1257
+ parseNaturalLanguageQuery(query: string): Promise<ParsedNLQuery>;
1258
+ /**
1259
+ * Save a search preset
1260
+ * @param preset - Search preset to save
1261
+ * @returns Saved preset with ID
1262
+ */
1263
+ savePreset(preset: Omit<SearchPreset, 'id' | 'createdAt' | 'updatedAt'>): Promise<SearchPreset>;
1264
+ /**
1265
+ * Get saved presets
1266
+ * @param userId - Optional user ID to filter presets
1267
+ * @returns Array of presets
1268
+ */
1269
+ getPresets(userId?: string): Promise<SearchPreset[]>;
1270
+ /**
1271
+ * Delete a preset
1272
+ * @param presetId - ID of preset to delete
1273
+ */
1274
+ deletePreset(presetId: string): Promise<void>;
1275
+ }
1276
+ //#endregion
1277
+ //#region src/search/core/basic-search-engine.d.ts
1278
+ /**
1279
+ * Basic search engine implementation
1280
+ */
1281
+ declare class BasicSearchEngine implements ILogSearchEngine {
1282
+ private options?;
1283
+ private logs;
1284
+ private presets;
1285
+ private searchHistory;
1286
+ private suggestionCache;
1287
+ constructor(options?: {
1288
+ maxHistorySize?: number;
1289
+ cacheSize?: number;
1290
+ } | undefined);
1291
+ /**
1292
+ * Add logs to the search index
1293
+ */
1294
+ addLogs(logs: LogEntry[]): void;
1295
+ /**
1296
+ * Clear all logs from the index
1297
+ */
1298
+ clearLogs(): void;
1299
+ /**
1300
+ * Get all indexed logs
1301
+ */
1302
+ getLogs(): LogEntry[];
1303
+ /**
1304
+ * Perform a full-text search across logs
1305
+ */
1306
+ search(query: string, filters?: SearchFilters, options?: SearchOptions): Promise<SearchResult[]>;
1307
+ /**
1308
+ * Natural language search (basic implementation)
1309
+ */
1310
+ naturalLanguageSearch(query: string): Promise<SearchResult[]>;
1311
+ /**
1312
+ * Find logs correlated by trace ID
1313
+ */
1314
+ correlateByTraceId(traceId: string): Promise<CorrelatedLogs>;
1315
+ /**
1316
+ * Find similar logs based on content similarity
1317
+ */
1318
+ findSimilarLogs(logEntry: LogEntry, limit?: number): Promise<SimilarLog[]>;
1319
+ /**
1320
+ * Get search suggestions
1321
+ */
1322
+ getSuggestions(partialQuery: string, limit?: number): Promise<SearchSuggestion[]>;
1323
+ /**
1324
+ * Get search statistics
1325
+ */
1326
+ getStats(): Promise<SearchStats>;
1327
+ /**
1328
+ * Parse natural language query
1329
+ */
1330
+ parseNaturalLanguageQuery(query: string): Promise<ParsedNLQuery>;
1331
+ /**
1332
+ * Save a search preset
1333
+ */
1334
+ savePreset(preset: Omit<SearchPreset, 'id' | 'createdAt' | 'updatedAt'>): Promise<SearchPreset>;
1335
+ /**
1336
+ * Get saved presets
1337
+ */
1338
+ getPresets(userId?: string): Promise<SearchPreset[]>;
1339
+ /**
1340
+ * Delete a preset
1341
+ */
1342
+ deletePreset(presetId: string): Promise<void>;
1343
+ private applyFilters;
1344
+ private performTextSearch;
1345
+ private getSearchableText;
1346
+ private getHighlightFragments;
1347
+ private applySorting;
1348
+ private applyPagination;
1349
+ private enrichWithContext;
1350
+ private calculateSimilarity;
1351
+ private calculateTextSimilarity;
1352
+ private findMatchedPatterns;
1353
+ private generateSimilarityReason;
1354
+ private extractTimeRange;
1355
+ private addToSearchHistory;
1356
+ private getTopTerms;
1357
+ private generateId;
1358
+ }
1359
+ //#endregion
1360
+ //#region src/search/engines/correlation-engine.d.ts
1361
+ /**
1362
+ * Correlation engine for log analysis
1363
+ */
1364
+ declare class CorrelationEngine {
1365
+ private options?;
1366
+ constructor(options?: {
1367
+ maxCorrelationDistance?: number;
1368
+ temporalWindowMs?: number;
1369
+ minSimilarityScore?: number;
1370
+ } | undefined);
1371
+ /**
1372
+ * Find logs related to a given log entry
1373
+ */
1374
+ findRelatedLogs(log: LogEntry, allLogs: LogEntry[], limit?: number): Promise<RelatedLog[]>;
1375
+ /**
1376
+ * Correlate logs by multiple criteria
1377
+ */
1378
+ correlateByMultipleCriteria(logs: LogEntry[], criteria: {
1379
+ traceId?: boolean;
1380
+ userId?: boolean;
1381
+ sessionId?: boolean;
1382
+ temporal?: boolean;
1383
+ errorCascade?: boolean;
1384
+ }): Promise<Map<string, CorrelatedLogs>>;
1385
+ /**
1386
+ * Build a timeline from correlated logs
1387
+ */
1388
+ buildTimeline(logs: LogEntry[]): TimelineEvent[];
1389
+ /**
1390
+ * Analyze error cascades
1391
+ */
1392
+ analyzeErrorCascade(logs: LogEntry[]): Promise<{
1393
+ rootCause?: LogEntry;
1394
+ cascade: LogEntry[];
1395
+ impactedServices: string[];
1396
+ }>;
1397
+ private correlateByTraceId;
1398
+ private correlateByUserId;
1399
+ private correlateBySessionId;
1400
+ private correlateByTemporalProximity;
1401
+ private correlateErrorCascades;
1402
+ private buildErrorCascade;
1403
+ private findRelationships;
1404
+ private calculateRelationshipScore;
1405
+ private haveSimilarPattern;
1406
+ private normalizeMessage;
1407
+ private determineEventType;
1408
+ private deduplicateRelatedLogs;
1409
+ private convertToCorrelatedLogs;
1410
+ private generateSummary;
1411
+ }
1412
+ //#endregion
1413
+ //#region src/search/engines/nlp-search-engine.d.ts
1414
+ /**
1415
+ * NLP-enhanced search engine
1416
+ */
1417
+ declare class NLPSearchEngine extends BasicSearchEngine {
1418
+ private intentPatterns;
1419
+ private entityPatterns;
1420
+ constructor(options?: Record<string, unknown>);
1421
+ /**
1422
+ * Enhanced natural language query parsing
1423
+ */
1424
+ parseNaturalLanguageQuery(query: string): Promise<ParsedNLQuery>;
1425
+ /**
1426
+ * Enhanced natural language search
1427
+ */
1428
+ naturalLanguageSearch(query: string): Promise<SearchResult[]>;
1429
+ private initializePatterns;
1430
+ private detectIntent;
1431
+ private extractEntities;
1432
+ private applyEntityToFilter;
1433
+ private extractAdvancedTimeRange;
1434
+ private calculateConfidence;
1435
+ private getOptionsForIntent;
1436
+ private extractCleanQuery;
1437
+ }
1438
+ //#endregion
1439
+ //#region src/search/engines/pattern-recognition-engine.d.ts
1440
+ /**
1441
+ * Pattern recognition engine for log analysis
1442
+ */
1443
+ declare class PatternRecognitionEngine {
1444
+ private options?;
1445
+ private patterns;
1446
+ private patternFrequencies;
1447
+ constructor(options?: {
1448
+ minFrequency?: number;
1449
+ maxPatterns?: number;
1450
+ anomalyThreshold?: number;
1451
+ } | undefined);
1452
+ /**
1453
+ * Analyze logs and detect patterns
1454
+ */
1455
+ analyzePatterns(logs: LogEntry[]): Promise<LogPattern[]>;
1456
+ /**
1457
+ * Detect anomalies in logs
1458
+ */
1459
+ detectAnomalies(logs: LogEntry[]): Promise<AnomalyDetection[]>;
1460
+ /**
1461
+ * Find patterns matching a log entry
1462
+ */
1463
+ findMatchingPatterns(log: LogEntry): LogPattern[];
1464
+ /**
1465
+ * Get all detected patterns
1466
+ */
1467
+ getPatterns(): LogPattern[];
1468
+ /**
1469
+ * Get pattern by ID
1470
+ */
1471
+ getPattern(patternId: string): LogPattern | undefined;
1472
+ private extractMessagePatterns;
1473
+ private extractErrorPatterns;
1474
+ private extractTimingPatterns;
1475
+ private normalizeMessage;
1476
+ private extractErrorPattern;
1477
+ private calculateAnomalyScore;
1478
+ private generateAnomalyReason;
1479
+ private findDeviations;
1480
+ private doesLogMatchPattern;
1481
+ }
561
1482
  //#endregion
562
1483
  //#region src/index.d.ts
563
1484
  /**
@@ -644,10 +1565,6 @@ declare const logger: LogixiaLogger<{
644
1565
  };
645
1566
  outputs: string[];
646
1567
  }>;
647
- /**
648
- * Export default configuration for reference
649
- */
650
-
651
1568
  //#endregion
652
- export { ContextData, CustomLevelMethods, DEFAULT_CONFIG, DEFAULT_LOG_COLORS, DEFAULT_LOG_LEVELS, Environment, ErrorSerializationOptions, ExtractLevels, HttpError, HttpRequest, HttpResponse, IBaseLogger, ILogFormatter, ILogger, ILoggerDefault, JsonFormatter, KafkaTraceInterceptor, LOGIXIA_LOGGER_CONFIG, LOGIXIA_LOGGER_PREFIX, LogColor, LogEntry, LogFieldKey, LogLevel, LogLevelString, LoggerConfig, type LoggerConfig as LoggerConfigInterface, LoggerWithLevels, LogixiaAsyncOptions, LogixiaLogger, LogixiaLoggerModule, LogixiaLoggerService, LogixiaOptionsFactory, RequestContext, RequestMetrics, RequestTiming, TextFormatter, TimingEntry, TraceIdConfig, TraceIdExtractorConfig, WebSocketTraceInterceptor, createLogger, createLoggerService, createTraceMiddleware, extractTraceId, generateTraceId, getCurrentTraceId, isError, logger, normalizeError, runWithTraceId, serializeError, setTraceId, traceStorage };
1569
+ export { AnomalyDetection, BasicLogIndexer, BasicSearchEngine, ContextData, CorrelatedLogs, CorrelationEngine, CustomLevelMethods, DEFAULT_CONFIG, DEFAULT_LOG_COLORS, DEFAULT_LOG_LEVELS, DEFAULT_TRACE_HEADERS, EntityType, Environment, ErrorSerializationOptions, ExportOptions, ExtractLevels, FlushOnExitOptions, GracefulShutdownConfig, HttpError, HttpRequest, HttpResponse, IBaseLogger, ILogFormatter, ILogIndexer, ILogSearchEngine, ILogger, ILoggerDefault, JsonFormatter, KafkaTraceInterceptor, LOGIXIA_LOGGER_CONFIG, LOGIXIA_LOGGER_PREFIX, LogCluster, LogColor, LogCorrelationSummary, LogEntry, LogFieldKey, LogLevel, LogLevelString, LogPattern, LoggerConfig, type LoggerConfig as LoggerConfigInterface, LoggerWithLevels, LogixiaAsyncOptions, LogixiaLogger, LogixiaLoggerModule, LogixiaLoggerService, LogixiaOptionsFactory, NLPSearchEngine, NamespaceLevels, ParsedNLQuery, PatternRecognitionEngine, QueryEntity, QueryIntent, type RedactConfig, RelatedLog, RelationshipType, RelativeTime, RequestContext, RequestMetrics, RequestTiming, SearchFilters, SearchHighlight, SearchManager, SearchManagerConfig, SearchMatch, SearchOptions, SearchPreset, SearchQuery, SearchResult, SearchStats, SearchSuggestion, SemanticIndex, SimilarLog, SortField, SuggestionType, TextFormatter, TimeRange, TimelineEvent, TimingEntry, TraceIdConfig, TraceIdExtractorConfig, WebSocketTraceInterceptor, applyRedaction, createLogger, createLoggerService, createTraceMiddleware, deregisterFromShutdown, extractTraceId, flushOnExit, generateTraceId, getCurrentTraceId, isError, logger, normalizeError, redactObject, registerForShutdown, resetShutdownHandlers, runWithTraceId, serializeError, setTraceId, traceStorage };
653
1570
  //# sourceMappingURL=index.d.mts.map