UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

88 lines 2.45 kB
/** * Recursive Path Builder * @description Builds comprehensive field paths by recursively analyzing database content * * Purpose: Discover nested JSON structures by analyzing actual data in the database * to find all queryable paths, including deeply nested and dynamic structures. * * Key Features: * - Analyzes actual JSON data from database * - Discovers dynamic field names and array structures * - Builds comprehensive path index * - Handles complex nested objects * - Merges paths from multiple records * - Provides path statistics and usage * * @author Optimizely MCP Server * @version 1.0.0 */ import { IDatabase } from './types/Database.js'; interface PathInfo { path: string; type: string; occurrences: number; examples: any[]; isArray: boolean; isNullable: boolean; depth: number; entityType: string; parentPath?: string; childPaths?: string[]; } interface PathAnalysisResult { entityType: string; totalRecords: number; discoveredPaths: PathInfo[]; complexityScore: number; recommendations: string[]; } export declare class RecursivePathBuilder { private logger; private database; private maxDepth; private maxExamples; constructor(database: IDatabase); /** * Analyze all records of an entity type to discover paths */ analyzeEntity(entityType: string, limit?: number): Promise<PathAnalysisResult>; /** * Get sample records from database */ private getSampleRecords; /** * Recursively build paths from an object */ private buildPathsFromObject; /** * Calculate complexity score for discovered paths */ private calculateComplexityScore; /** * Generate recommendations based on discovered paths */ private generateRecommendations; /** * Find common patterns in paths */ private findCommonPatterns; /** * Get table name for entity type */ private getTableName; /** * Merge paths from schema and database analysis */ mergePaths(schemaPaths: any[], databasePaths: PathInfo[]): Promise<any[]>; /** * Build SQL path for JSON_EXTRACT */ private buildSqlPath; /** * Build JSONata path */ private buildJsonataPath; } export declare const recursivePathBuilder: (database: IDatabase) => RecursivePathBuilder; export {}; //# sourceMappingURL=RecursivePathBuilder.d.ts.map