UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

88 lines 2.52 kB
/** * Field Disambiguator - Phase 4C Implementation * * Handles ambiguous field names across tables by: * 1. Detecting ambiguous field references * 2. Applying context-based resolution rules * 3. Supporting explicit table prefixes * 4. Managing field aliases * * Key features: * - Automatic disambiguation based on query context * - Support for table.field notation * - Field aliasing with AS clause * - Smart error messages for truly ambiguous cases */ import type { FieldCatalog } from './FieldCatalog.js'; import type { UniversalQuery } from './types.js'; export interface DisambiguationContext { primaryEntity: string; joinedEntities: string[]; fieldAliases: Map<string, string>; } export interface DisambiguatedField { originalField: string; resolvedField: string; tableName: string; fieldName: string; alias?: string; isAmbiguous: boolean; possibleMatches?: string[]; isJsonPath?: boolean; } export interface DisambiguationResult { fields: Map<string, DisambiguatedField>; errors: string[]; warnings: string[]; } export declare class FieldDisambiguator { private fieldCatalog; private jsonHandler; private readonly COMMON_AMBIGUOUS_FIELDS; constructor(fieldCatalog: FieldCatalog); /** * Disambiguate all fields in a query */ disambiguateQuery(query: UniversalQuery): DisambiguationResult; /** * Build disambiguation context from query */ private buildContext; /** * Disambiguate a single field */ private disambiguateField; /** * Check if a field exists in the catalog */ private fieldExists; /** * Convert table name to entity name (reverse of EntityTableMapper) */ private getEntityNameFromTable; /** * Check if this is a known A/B test field that bypasses catalog validation */ private isKnownABTestField; /** * Check if this is a join table field that might not be in the field catalog */ private isJoinTableField; /** * Validate disambiguation results */ private validateDisambiguation; /** * Get plural form of entity name for SQL table names */ private getPluralEntityName; /** * Check if a field is a computed field */ private isComputedField; /** * Apply disambiguation to a query */ applyDisambiguation(query: UniversalQuery, result: DisambiguationResult): UniversalQuery; } //# sourceMappingURL=FieldDisambiguator.d.ts.map