@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
91 lines • 2.62 kB
TypeScript
/**
* Field Mapper
* @description Maps AI-generated field names to template field names using fuzzy matching
*
* Purpose: Bridge the gap between creative AI field naming and standardized template fields
* using intelligent fuzzy matching with Fuse.js.
*
* Key Features:
* - Fuzzy matching with configurable thresholds
* - Entity-specific field mappings
* - Confidence scoring for mappings
* - Common transformation patterns
*
* @author Optimizely MCP Server
* @version 1.0.0
*/
export interface FieldMapping {
aiFieldName: string;
templateFieldName: string;
confidence: number;
transformationType?: 'direct' | 'camelCase' | 'snake_case' | 'custom';
transformer?: (value: any) => any;
}
export interface FieldMappingOptions {
entityType: string;
threshold?: number;
enableTransformations?: boolean;
strictMode?: boolean;
}
/**
* Field Mapper for intelligent field name matching
*/
export declare class FieldMapper {
protected readonly logger: import("../logging/Logger.js").OptimizelyMCPLogger;
private templateFieldCache;
private commonTransformations;
constructor();
private generateCasePermutations;
private buildComprehensivePattern;
private initializeTransformations;
private readonly entityTemplateFields;
/**
* Map AI field names to template field names
*/
mapFields(payload: any, options: FieldMappingOptions): Promise<FieldMapping[]>;
/**
* Extract field names from payload
*/
private extractFieldNames;
/**
* Get template fields for entity type
*/
private getTemplateFields;
/**
* Apply common transformation patterns
*/
private applyCommonTransformations;
/**
* Apply fuzzy matching using Fuse.js
*/
private applyFuzzyMatching;
/**
* Clean field name for better matching
*/
private cleanFieldName;
/**
* Detect transformation type needed between fields
*/
private detectTransformationType;
/**
* Apply field mappings to transform a payload
*/
applyMappings(payload: any, mappings: FieldMapping[]): Promise<any>;
/**
* Deep clone array preserving all nested structure
*/
private deepCloneArray;
/**
* Get mapping suggestions for debugging
*/
getMappingSuggestions(aiFields: string[], entityType: string): Promise<{
field: string;
suggestions: string[];
confidence: number[];
}[]>;
}
/**
* Singleton instance for global use
*/
export declare const fieldMapper: FieldMapper;
//# sourceMappingURL=FieldMapper.d.ts.map