/** * Debug Utility Functions * * This file provides utility functions for the RouteCodex debugging system, * including data sanitization, formatting, performance measurement, and other helpers. */ import type { DebugUtils, SanitizeOptions, FormatOptions, PerformanceMarker } from '../types/debug-types.js'; /** * Debug utility implementation */ export declare class DebugUtilsImpl implements DebugUtils { private readonly defaultSensitiveFields; /** * Sanitize data for logging (remove sensitive information) */ sanitizeData(data: unknown, options?: SanitizeOptions): unknown; /** * Format data for display */ formatData(data: unknown, options?: FormatOptions): string; /** * Calculate data size */ calculateDataSize(data: unknown): number; /** * Deep clone data */ deepClone(data: T): T; /** * Generate unique identifier */ generateId(prefix?: string): string; /** * Measure execution time */ measureTime(fn: () => T): { result: T; time: number; }; /** * Measure async execution time */ measureTimeAsync(fn: () => Promise): Promise<{ result: T; time: number; }>; /** * Create performance marker */ createPerformanceMarker(name: string): PerformanceMarker; /** * Internal method to sanitize data recursively */ private doSanitizeData; /** * Check if a field is sensitive */ private isSensitiveField; /** * Format data in pretty print style */ private formatPretty; } /** * Utility functions for common debug operations */ export declare class DebugUtilsStatic { private static instance; /** * Get singleton instance */ static getInstance(): DebugUtilsImpl; /** * Sanitize data for logging */ static sanitizeData(data: unknown, options?: SanitizeOptions): unknown; /** * Format data for display */ static formatData(data: unknown, options?: FormatOptions): string; /** * Calculate data size */ static calculateDataSize(data: unknown): number; /** * Deep clone data */ static deepClone(data: T): T; /** * Generate unique identifier */ static generateId(prefix?: string): string; /** * Measure execution time */ static measureTime(fn: () => T): { result: T; time: number; }; /** * Measure async execution time */ static measureTimeAsync(fn: () => Promise): Promise<{ result: T; time: number; }>; /** * Create performance marker */ static createPerformanceMarker(name: string): PerformanceMarker; /** * Extract error information safely */ static extractErrorInfo(error: unknown): { message: string; stack?: string; name?: string; code?: string; }; /** * Truncate string if too long */ static truncateString(str: string, maxLength: number): string; /** * Format bytes to human readable format */ static formatBytes(bytes: number, decimals?: number): string; /** * Format duration to human readable format */ static formatDuration(milliseconds: number): string; /** * Get current memory usage */ static getMemoryUsage(): { used: number; total: number; percentage: number; }; /** * Safe JSON parsing */ static safeJsonParse(jsonString: string, defaultValue: T): T; /** * Safe JSON stringifying */ static safeJsonStringify(data: unknown, indent?: number): string; /** * Create debounced function */ static debounce unknown>(func: T, wait: number): (...args: Parameters) => void; /** * Create throttled function */ static throttle unknown>(func: T, limit: number): (...args: Parameters) => void; /** * Create retry function */ static retry(fn: () => Promise, maxRetries?: number, delay?: number): Promise; /** * Validate and normalize port number */ static normalizePort(port: string | number): number; /** * Validate URL */ static isValidUrl(url: string): boolean; /** * Get nested value from object using dot notation */ static getNestedValue(obj: unknown, path: string, defaultValue?: unknown): unknown; /** * Set nested value in object using dot notation */ static setNestedValue(obj: Record, path: string, value: unknown): void; }