/** * Response transformation utilities for handling large API responses * * This module implements schema-driven smart response transformation to: * - Preserve critical pagination metadata * - Provide statistical summaries (min/max/sum/avg/median/percentiles) * - Include categorical distributions * - Sample representative items * - Dramatically reduce token usage (80-95% for large responses) */ export interface TransformOptions { /** Maximum response size before transformation (default: 20000) */ maxResponseSize?: number; /** Number of sample items to include (default: 5) */ sampleSize?: number; /** Whether to compute statistics (default: true) */ computeStats?: boolean; /** Whether to include distribution analysis (default: true) */ includeDistribution?: boolean; /** Enable transformation (can be disabled for backward compatibility) */ enabled?: boolean; } export interface TransformedResponse { /** Original HTTP status */ status: number; /** Preserved metadata (pagination, totals, etc.) */ metadata: Record; /** Transformed data with statistics and samples */ data: { /** Summary of transformation */ _transformation: { applied: boolean; reason: string; originalSize: number; transformedSize: number; timestamp: string; }; /** Sample items from arrays */ sample?: any[]; /** Statistical aggregations */ statistics?: { count: number; numericFields?: Record; categoricalFields?: Record>; }; /** Original array name (for context) */ arrayName?: string; /** Full data for small responses */ full?: any; }; /** Original response shape for reference */ _originalShape?: { topLevelKeys: string[]; arrayFields: Array<{ name: string; length: number; }>; scalarFields: string[]; }; } /** * Detect if response needs transformation */ export declare function shouldTransform(response: any, options: TransformOptions): boolean; /** * Main transformation function */ export declare function transformResponse(response: any, options?: TransformOptions, responseSchema?: any): TransformedResponse; //# sourceMappingURL=response-transformer.d.ts.map