@pod-protocol/sdk
Version:
TypeScript SDK for PoD Protocol - AI agent communication on Solana
149 lines • 4.1 kB
TypeScript
/**
* Debug and Development Utilities for PoD Protocol SDK
*
* Provides enhanced error messages, logging, and debugging tools
* to improve developer experience and troubleshooting
*/
import type { Address } from "@solana/addresses";
export declare enum LogLevel {
DEBUG = 0,
INFO = 1,
WARN = 2,
ERROR = 3,
OFF = 4
}
export interface DebugConfig {
logLevel: LogLevel;
enableColors: boolean;
showTimestamp: boolean;
showStackTrace: boolean;
logToFile: boolean;
fileName?: string;
}
/**
* Enhanced Debug Logger for PoD Protocol SDK
*/
export declare class DebugLogger {
private static instance;
private config;
private logBuffer;
private constructor();
static getInstance(config?: Partial<DebugConfig>): DebugLogger;
private formatMessage;
private getColor;
private shouldLog;
debug(message: string, data?: any): void;
info(message: string, data?: any): void;
warn(message: string, data?: any): void;
error(message: string, error?: Error | any): void;
getLogBuffer(): string[];
clearLogBuffer(): void;
updateConfig(config: Partial<DebugConfig>): void;
}
/**
* Enhanced Error Classes for Better Debugging
*/
export declare class PodProtocolError extends Error {
readonly code: string;
readonly context?: any;
readonly timestamp: Date;
constructor(message: string, code: string, context?: any);
toJSON(): {
name: string;
message: string;
code: string;
context: any;
timestamp: string;
stack: string;
};
}
export declare class ValidationError extends PodProtocolError {
constructor(message: string, context?: any);
}
export declare class NetworkError extends PodProtocolError {
constructor(message: string, context?: any);
}
export declare class ConfigurationError extends PodProtocolError {
constructor(message: string, context?: any);
}
/**
* SDK Information interface
*/
export interface SDKInfo {
timestamp: number;
sdkVersion: string;
}
/**
* Development Utilities
*/
export declare class DevUtils {
private static logger;
/**
* Validate Solana address format
*/
static validateAddress(address: string | Address): boolean;
/**
* Format address for display (truncate middle)
*/
static formatAddress(address: string | Address, length?: number): string;
/**
* Convert lamports to SOL with formatting
*/
static formatSOL(lamports: number | bigint): string;
/**
* Performance timer utility
*/
static timer(name: string): {
end: () => number;
};
/**
* Retry utility with exponential backoff
*/
static retry<T>(fn: () => Promise<T>, maxRetries?: number, baseDelay?: number): Promise<T>;
/**
* Environment detection
*/
static getEnvironment(): 'browser' | 'node' | 'unknown';
/**
* Memory usage (Node.js only)
*/
static getMemoryUsage(): any;
/**
* Generate development report
*/
static generateReport(): string;
/**
* Get SDK version from package.json
*/
private static getSDKVersion;
getSDKInfo(): Promise<SDKInfo>;
}
/**
* Performance Monitoring
*/
export declare class PerformanceMonitor {
private static measurements;
private static logger;
static start(name: string): string;
static end(id: string): number;
static getStats(name: string): {
avg: number;
min: number;
max: number;
count: number;
} | null;
static getAllStats(): Record<string, ReturnType<typeof PerformanceMonitor.getStats>>;
static reset(name?: string): void;
}
export declare const logger: DebugLogger;
export declare const debug: {
logger: DebugLogger;
DevUtils: typeof DevUtils;
PerformanceMonitor: typeof PerformanceMonitor;
PodProtocolError: typeof PodProtocolError;
ValidationError: typeof ValidationError;
NetworkError: typeof NetworkError;
ConfigurationError: typeof ConfigurationError;
};
export default debug;
//# sourceMappingURL=debug.d.ts.map