@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
97 lines • 3.01 kB
TypeScript
/**
* UpdateAutoCorrector - Safe auto-corrections for UPDATE operations
*
* This class provides a subset of ComprehensiveAutoCorrector's capabilities
* that are safe for UPDATE operations. It focuses on fixing AI agent mistakes
* without applying defaults or making assumptions about missing fields.
*
* SAFE FOR UPDATES:
* - Field name corrections (flag_key → key)
* - Enum fuzzy matching (SUM → sum)
* - URL protocol fixes
* - Format validations
* - Typo corrections
*
* NOT SAFE FOR UPDATES:
* - Swagger defaults (could overwrite existing values)
* - Safety fallbacks (could change intended nulls)
* - Missing field additions (partial updates are valid)
*/
import { CorrectionResult } from './ComprehensiveAutoCorrector.js';
export declare class UpdateAutoCorrector {
private static corrections;
private static entity;
/**
* Main entry point for UPDATE operation auto-correction
*/
static autoCorrectForUpdate(entityType: string, userInput: any, context?: {
platform?: string;
projectId?: string;
}): CorrectionResult;
/**
* Correct common field name mistakes
*/
private static correctFieldNames;
/**
* Fix URL protocols (add https:// if missing)
*/
private static fixUrlProtocols;
/**
* Correct enum values using fuzzy matching
*/
private static correctEnumValues;
/**
* Validate and fix common format issues
*/
private static validateAndFixFormats;
/**
* Generate user-friendly message
*/
private static generateUserMessage;
/**
* Apply Status semantic expansion for entity-specific meanings
* Phase 1: Status semantic expansion (flags only)
*/
private static applyStatusSemanticExpansion;
/**
* Remove fields that don't exist in the entity schema
* Phase 2: Schema-based field cleanup
*/
private static removeInvalidFields;
/**
* Add a correction to the list
*/
private static addCorrection;
}
/**
* Integration point for EntityRouter
*
* Add this to EntityRouter.handleUpdateOperation before line 2283:
*
* ```typescript
* // Apply UPDATE-safe auto-corrections
* if (data && !Array.isArray(data)) {
* const { UpdateAutoCorrector } = await import('../validation/UpdateAutoCorrector.js');
*
* const correctionResult = UpdateAutoCorrector.autoCorrectForUpdate(
* entityType,
* data,
* {
* platform: projectId ? await this.getProjectPlatformType(projectId) : undefined,
* projectId
* }
* );
*
* if (correctionResult.corrections.length > 0) {
* data = correctionResult.correctedData;
* getLogger().info({
* entityType,
* operation: 'update',
* corrections: correctionResult.corrections.length,
* details: correctionResult.corrections.map(c => `${c.field}: ${c.reason}`)
* }, 'Applied UPDATE auto-corrections');
* }
* }
* ```
*/
//# sourceMappingURL=UpdateAutoCorrector.d.ts.map