UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

114 lines 3.33 kB
/** * Analytics Transformer * @description JSONata-based transformation pipeline for converting complex database results * into simplified, paginated analytics responses that are client-friendly. * * Key Features: * - Extracts Feature Experimentation A/B tests from nested rulesets * - Unified response format across Web and Feature Experimentation * - Cursor-based pagination for large datasets * - Environment variable controlled complexity * * @author Optimizely MCP Server * @version 1.0.0 */ export interface PaginationOptions { page_size?: number; cursor?: string; max_page_size?: number; } export interface SimplifiedEntityResponse { entity_type: string; platform: 'web' | 'feature' | 'auto'; key: string; name: string; description?: string; status: { state: string; enabled_environments?: number; traffic_allocation?: number; has_targeting: boolean; }; details: { variables?: { count: number; names: string[]; }; environments?: Record<string, RulesetSummary>; variations_count?: number; parent_flag?: string; experiments_count?: number; conditions_count?: number; }; timestamps: { created?: string; last_modified?: string; }; } export interface RulesetSummary { enabled: boolean; rules_count: number; variations_count: number; has_targeting: boolean; last_modified?: string; } export interface PaginatedAnalyticsResponse { entities: SimplifiedEntityResponse[]; entity_type: string; platform: string; pagination: { total_count: number; returned_count: number; has_more: boolean; next_cursor?: string; page_size: number; current_page?: number; }; summary: { total_entities: number; environment_filter?: string; project_id?: string; project_name?: string; query_executed_at: string; usage_hint?: string; }; } export declare class AnalyticsTransformer { private readonly logger; private readonly defaultPageSize; private readonly maxPageSize; private readonly responseMode; private readonly transformations; constructor(); /** * Transform database results into simplified analytics response */ transformAnalyticsResults(dbResults: any[], entityType: string, platform: 'web' | 'feature' | 'auto', options?: { pagination?: PaginationOptions; environment_filter?: string; project_id?: string; project_name?: string; keysOnly?: boolean; }): Promise<PaginatedAnalyticsResponse | string[]>; /** * Apply JSONata transformation based on entity type and platform */ private applyTransformation; /** * Manual simplification fallback when JSONata fails */ private manualSimplification; /** * Apply cursor-based pagination to transformed entities */ private applyPagination; /** * Generate helpful usage hints for agents */ private generateUsageHint; /** * Get optimal page size based on response mode and entity type */ getOptimalPageSize(entityType: string): number; } //# sourceMappingURL=AnalyticsTransformer.d.ts.map