UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

113 lines 3.26 kB
/** * Multi-Entity Join Path Planning - Phase 4A Implementation * * Enables complex analytics queries that join across multiple entities * like experiments+pages+events with automatic join path discovery. * * Features: * - Dijkstra-like algorithm for optimal join path discovery * - Cost-based join optimization * - Relationship type validation (one-to-one, one-to-many, many-to-many) * - Automatic join table detection for many-to-many relationships */ export interface JoinPath { from: { entity: string; field: string; table: string; }; to: { entity: string; field: string; table: string; }; joinType: 'INNER' | 'LEFT' | 'RIGHT'; cost: number; required: boolean; relationshipType: 'one-to-one' | 'one-to-many' | 'many-to-many'; joinTable?: string; } export interface EntityRelationship { fromEntity: string; toEntity: string; fromField: string; toField: string; relationshipType: 'one-to-one' | 'one-to-many' | 'many-to-many'; joinTable?: string; cost: number; bidirectional: boolean; } export interface JoinPlanNode { entity: string; table: string; distance: number; previous?: JoinPlanNode; relationship?: EntityRelationship; } export interface JoinPlanOptions { preferLeftJoins: boolean; maxJoinDepth: number; avoidCartesianProducts: boolean; optimizeForPerformance: boolean; } export declare class JoinPathPlanner { private relationships; private entityTableMap; private joinCostCache; constructor(); /** * Initialize known relationships in Optimizely data model */ private initializeOptimizelyRelationships; /** * Find optimal join path between multiple entities * Uses Dijkstra-like algorithm for shortest cost path */ findOptimalJoinPath(entities: string[], options?: Partial<JoinPlanOptions>): Promise<JoinPath[]>; /** * Find shortest path between two entities using Dijkstra's algorithm */ private findShortestPath; /** * Reconstruct join path from Dijkstra result */ private reconstructPath; /** * Optimize join order for better performance */ private optimizeJoinOrder; /** * Calculate total cost of join path */ calculateJoinCost(joinPaths: JoinPath[]): number; /** * Validate that join path is executable */ validateJoinPath(joinPaths: JoinPath[]): boolean; /** * Get all available relationships for an entity */ getEntityRelationships(entity: string): EntityRelationship[]; /** * Check if two entities can be joined directly */ canJoinDirectly(fromEntity: string, toEntity: string): boolean; /** * Get table name for entity */ private getTableName; /** * Add custom relationship (for extensibility) */ addRelationship(relationship: EntityRelationship): void; /** * Get statistics about relationship graph */ getStatistics(): { totalEntities: number; totalRelationships: number; avgRelationshipsPerEntity: number; relationshipTypes: Record<string, number>; }; } //# sourceMappingURL=JoinPathPlanner.d.ts.map