@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
81 lines • 2.2 kB
TypeScript
/**
* Comprehensive Schema Validator
*
* This validator uses fields.generated.ts to validate entity data against
* actual API schemas, catching issues before they reach the API.
*/
import { EntityName } from '../generated/fields.generated.js';
import { SchemaCache } from './SchemaCache.js';
export interface ValidationResult {
valid: boolean;
errors: string[];
warnings: string[];
autoFixed?: Record<string, any>;
}
export interface ValidationError {
field: string;
value: any;
reason: string;
allowedValues?: any[];
suggestion?: string;
}
export declare class ComprehensiveSchemaValidator {
private logger;
private schemaCache;
constructor(schemaCache?: SchemaCache);
/**
* Validate entity data against API schema from fields.generated.ts
*/
validateEntity(entityType: EntityName, data: any, options?: {
platform?: 'web' | 'feature';
autoFix?: boolean;
operation?: 'create' | 'update' | 'get';
}): ValidationResult;
/**
* Get suggestion for common enum mistakes
*/
private getSuggestionForInvalidEnum;
/**
* Check if types are compatible (allowing some flexibility)
*/
private checkTypeCompatibility;
/**
* Platform-specific validation rules
*/
private validatePlatformSpecific;
/**
* Batch validate multiple entities
*/
validateEntities(entities: Array<{
entityType: EntityName;
data: any;
id?: string;
}>, options?: {
platform?: 'web' | 'feature';
autoFix?: boolean;
}): {
allValid: boolean;
results: Map<string, ValidationResult>;
};
/**
* Get cache statistics
*/
getCacheStats(): import("./SchemaCache.js").SchemaCacheStats;
/**
* Clear schema cache
*/
clearCache(entityType?: EntityName): void;
/**
* Refresh schema in cache
*/
refreshSchema(entityType: EntityName): void;
/**
* Get cached entity types
*/
getCachedTypes(): EntityName[];
/**
* Clean up expired cache entries
*/
cleanupCache(): number;
}
//# sourceMappingURL=ComprehensiveSchemaValidator.d.ts.map