UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

97 lines (96 loc) 3.03 kB
/** * Error Serializer Utility * * Safe error serialization with full context preservation. * Features: * - Handles circular references * - Filters sensitive data (PII, credentials) * - Generates error fingerprints for deduplication * - Preserves custom error properties * - Filters stack traces in production * * @module processors/errors */ import type { SerializeOptions, SerializedError } from "../../types/index.js"; /** * Safely serialize an error with full context preservation. * Handles circular references, redacts sensitive data, and preserves error metadata. * * @param error - Error instance or unknown value to serialize * @param options - Serialization options * @returns Serialized error with full context * * @example * ```typescript * try { * await riskyOperation(); * } catch (error) { * const serialized = serializeError(error); * logger.error("Operation failed", serialized); * } * ``` */ export declare function serializeError(error: unknown, options?: SerializeOptions): SerializedError; /** * Generate a deterministic fingerprint for error aggregation. * Normalizes dynamic values (IDs, timestamps, paths) to group similar errors together. * * @param error - Error to fingerprint * @param context - Optional context with operation name * @returns 16-character hex fingerprint hash * * @example * ```typescript * const fp1 = generateErrorFingerprint(new Error("User 123 not found")); * const fp2 = generateErrorFingerprint(new Error("User 456 not found")); * // fp1 === fp2 (same error pattern, different IDs) * ``` */ export declare function generateErrorFingerprint(error: Error, context?: { operation?: string; }): string; /** * Safely stringify an object with circular reference handling. * * @param obj - Object to stringify * @param maxDepth - Maximum depth for nested objects * @returns JSON string representation */ export declare function safeStringify(obj: unknown, maxDepth?: number): string; /** * Extract safe metadata from an object. * Sanitizes sensitive fields and handles truncation. * * @param obj - Object to extract metadata from * @param options - Extraction options * @returns Sanitized metadata record * * @example * ```typescript * const metadata = extractSafeMetadata({ * userId: "123", * password: "secret", * data: largeObject, * }); * // Result: { userId: "123", password: "[REDACTED]", data: truncated } * ``` */ export declare function extractSafeMetadata(obj: unknown, options?: { /** Maximum size per field */ maxSize?: number; /** Maximum depth for nested objects */ maxDepth?: number; }): Record<string, unknown>; /** * Create a minimal error representation for logging. * Useful when you need just the essentials without full serialization. * * @param error - Error to summarize * @returns Minimal error representation */ export declare function summarizeError(error: unknown): { type: string; message: string; code?: string; fingerprint: string; };