UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

123 lines 3.31 kB
/** * Path Index Generator * @description Generates comprehensive queryable path indices for all entity types * * Purpose: Combine schema-based and data-based path discovery to create * the most comprehensive index of queryable fields for the Dynamic JSON Query Engine. * * Key Features: * - Combines FieldsSchemaResolver and RecursivePathBuilder * - Generates indices for all entity types * - Provides path validation and verification * - Caches generated indices for performance * - Exports indices for use by query engine * * @author Optimizely MCP Server * @version 1.0.0 */ import { IDatabase } from './types/Database.js'; interface QueryablePath { fullPath: string; sqlPath: string; jsonataPath: string; type: string; nullable: boolean; description?: string; enum?: string[]; example?: any; entityType: string; fieldName: string; depth: number; source: 'schema' | 'database' | 'both'; inDatabase: boolean; occurrences?: number; isArray?: boolean; parentPath?: string; childPaths?: string[]; } interface EntityPathIndex { entityType: string; lastUpdated: string; totalPaths: number; schemaPaths: number; databasePaths: number; paths: QueryablePath[]; statistics: { maxDepth: number; arrayPaths: number; nullablePaths: number; enumPaths: number; coverage: number; }; } interface PathIndexCollection { version: string; generated: string; entities: Record<string, EntityPathIndex>; } export declare class PathIndexGenerator { private logger; private database; private indexPath; private cacheDir; constructor(database: IDatabase, cacheDir?: string); /** * Generate path indices for all entity types */ generateAllIndices(forceRegenerate?: boolean): Promise<PathIndexCollection>; /** * Generate index for a single entity type */ generateEntityIndex(entityType: string, pathBuilder?: any): Promise<EntityPathIndex>; /** * Merge schema and database paths */ private mergePaths; /** * Calculate statistics for paths */ private calculateStatistics; /** * Build SQL path for JSON_EXTRACT */ private buildSqlPath; /** * Build JSONata path */ private buildJsonataPath; /** * Ensure cache directory exists */ private ensureCacheDir; /** * Check if cached index is valid (less than 24 hours old) */ private isCacheValid; /** * Load cached index */ private loadCachedIndex; /** * Save complete index to cache */ private saveCompleteIndex; /** * Save individual entity index */ private saveEntityIndex; /** * Get paths for a specific entity type */ getEntityPaths(entityType: string): Promise<QueryablePath[]>; /** * Search for paths matching a pattern */ searchPaths(pattern: string, entityType?: string): Promise<QueryablePath[]>; /** * Get path statistics summary */ getStatisticsSummary(): Promise<any>; } export declare const createPathIndexGenerator: (database: IDatabase, cacheDir?: string) => PathIndexGenerator; export {}; //# sourceMappingURL=PathIndexGenerator.d.ts.map