UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

102 lines 2.6 kB
/** * Schema Resolver * @description Resolves field paths from OpenAPI schema definitions * * Purpose: Parse and traverse OpenAPI schemas to build queryable field paths * for the Dynamic JSON Query Engine. This is the foundation that enables * querying ANY field in the Optimizely data model. * * Key Features: * - Loads and parses fields.generated.ts * - Recursively traverses schema definitions * - Handles references ($ref) and allOf/anyOf/oneOf * - Generates dot-notation paths for all queryable fields * - Caches results for performance * * @author Optimizely MCP Server * @version 1.0.0 */ interface SchemaField { path: string; type: string; description?: string; enum?: string[]; format?: string; nullable?: boolean; required?: boolean; example?: any; properties?: Record<string, any>; items?: any; $ref?: string; allOf?: any[]; anyOf?: any[]; oneOf?: any[]; } interface ResolvedPath { fullPath: string; sqlPath: string; jsonataPath: string; type: string; nullable: boolean; description?: string; enum?: string[]; example?: any; entityType: string; fieldName: string; depth: number; } export declare class SchemaResolver { private logger; private schemaCache; private pathCache; private schemas; private fieldsPath; constructor(fieldsPath?: string); /** * Initialize by loading the generated fields file */ initialize(): Promise<void>; /** * Get all queryable paths for an entity type */ getQueryablePaths(entityType: string): Promise<ResolvedPath[]>; /** * Find the schema key for an entity type */ private findSchemaKey; /** * Recursively traverse a schema to build paths */ private traverseSchema; /** * Resolve a $ref to its schema */ private resolveRef; /** * Build SQL path for JSON_EXTRACT */ private buildSqlPath; /** * Build JSONata path */ private buildJsonataPath; /** * Get field type information */ getFieldType(entityType: string, fieldPath: string): Promise<SchemaField | null>; /** * Search for fields matching a pattern */ searchFields(entityType: string, pattern: string): Promise<ResolvedPath[]>; /** * Get all entity types with schemas */ getAvailableEntityTypes(): string[]; /** * Clear all caches */ clearCache(): void; } export declare const schemaResolver: SchemaResolver; export {}; //# sourceMappingURL=SchemaResolver.d.ts.map