@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
75 lines • 2.19 kB
TypeScript
/**
* JSONata-based Field Extractor
*
* Uses JSONata expressions to dynamically search for and extract required fields
* from payloads regardless of nesting depth or field naming variations.
*
* This addresses the core problem of AI agents sending data in unpredictable
* structures with varying field names and nesting levels.
*/
export interface FieldExtractionResult {
success: boolean;
extractedFields: Record<string, any>;
missingRequired: string[];
transformations: Array<{
field: string;
sourcePath: string;
targetPath: string;
value: any;
}>;
confidence: number;
}
export declare class JSONataFieldExtractor {
private logger;
private readonly FIELD_SYNONYMS;
private expressions;
constructor();
/**
* Initialize commonly used JSONata expressions
*/
private initializeExpressions;
/**
* Extract required fields for an entity type from a payload
*/
extractFields(entityType: string, payload: any, options?: {
platform?: 'feature' | 'web';
strictMode?: boolean;
}): Promise<FieldExtractionResult>;
/**
* Find a field in the payload using JSONata
*/
private findField;
/**
* Manual nested object search as fallback when JSONata fails
*/
private searchNestedObject;
/**
* Find the source path that was used to extract a value
*/
private findSourcePath;
/**
* Handle special nested structures (like ab_test containing variations)
*/
private handleNestedStructures;
/**
* Preserve complete array structures without field-by-field extraction
*/
private preserveCompleteArrays;
/**
* Deep clone array preserving all nested structure
*/
private deepCloneArray;
/**
* Apply platform-specific logic
*/
private applyPlatformSpecificLogic;
/**
* Calculate confidence score for the extraction
*/
private calculateConfidence;
/**
* Add custom field synonyms for a specific entity type
*/
addFieldSynonyms(field: string, synonyms: string[]): void;
}
//# sourceMappingURL=JSONataFieldExtractor.d.ts.map