UNPKG

supa-seed

Version:

A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support

154 lines 5.03 kB
/** * User Choice Validator System * Phase 4, Checkpoint D2 - Advanced validation for interactive configuration choices */ import { ConfigurationPrompt, UserChoice } from './interactive-configuration'; import { SchemaChange } from './schema-evolution'; export interface ValidationRule { id: string; name: string; type: 'dependency' | 'constraint' | 'compatibility' | 'safety' | 'business_logic'; priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; description: string; validator: (choice: UserChoice, prompt: ConfigurationPrompt, context: ValidationContext) => ValidationResult; autoFix?: (choice: UserChoice, prompt: ConfigurationPrompt, context: ValidationContext) => UserChoice | null; } export interface ValidationContext { previousChoices: UserChoice[]; availablePrompts: ConfigurationPrompt[]; schemaChanges: SchemaChange[]; systemConstraints: SystemConstraint[]; userPreferences: UserPreferences; environment: { nodeEnv: string; projectPath: string; configFiles: string[]; dependencies: Record<string, string>; }; } export interface ValidationResult { isValid: boolean; errors: ValidationError[]; warnings: ValidationWarning[]; suggestions: ValidationSuggestion[]; metadata: { ruleId: string; executionTime: number; confidence: number; canAutoFix: boolean; }; } export interface ValidationError { code: string; message: string; severity: 'error' | 'critical'; field?: string; expectedValue?: any; actualValue?: any; resolution?: string; } export interface ValidationWarning { code: string; message: string; impact: 'low' | 'medium' | 'high'; recommendation?: string; } export interface ValidationSuggestion { type: 'alternative_option' | 'parameter_adjustment' | 'dependency_resolution' | 'risk_mitigation'; description: string; suggestedChoice?: Partial<UserChoice>; rationale: string; confidence: number; } export interface SystemConstraint { id: string; type: 'file_system' | 'dependency' | 'version' | 'permission' | 'resource'; description: string; validator: (context: ValidationContext) => boolean; errorMessage: string; } export interface UserPreferences { riskTolerance: 'conservative' | 'balanced' | 'aggressive'; autoConfirmLowRisk: boolean; requireExplicitHighRisk: boolean; preferredBackupStrategy: 'always' | 'high_risk_only' | 'never'; maxConfigurationTime: number; notificationLevel: 'minimal' | 'standard' | 'verbose'; } export interface ChoiceValidationSummary { totalChoices: number; validChoices: number; errorsFound: number; warningsFound: number; suggestionsGenerated: number; autoFixesApplied: number; overallRisk: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; estimatedImpact: string; recommendations: string[]; } export declare class UserChoiceValidator { private validationRules; private systemConstraints; private userPreferences; constructor(userPreferences?: Partial<UserPreferences>); /** * Validate a single user choice */ validateChoice(choice: UserChoice, prompt: ConfigurationPrompt, context: ValidationContext): Promise<ValidationResult>; /** * Validate multiple choices for consistency and dependencies */ validateChoiceSequence(choices: UserChoice[], prompts: ConfigurationPrompt[], baseContext: Partial<ValidationContext>): Promise<ChoiceValidationSummary>; /** * Attempt to automatically fix a choice */ autoFixChoice(choice: UserChoice, prompt: ConfigurationPrompt, context: ValidationContext): Promise<UserChoice | null>; /** * Validate choice against system constraints */ validateSystemConstraints(context: ValidationContext): { satisfied: SystemConstraint[]; violated: SystemConstraint[]; }; /** * Add custom validation rule */ addValidationRule(rule: ValidationRule): void; /** * Remove validation rule */ removeValidationRule(ruleId: string): boolean; /** * Get all validation rules */ getValidationRules(): ValidationRule[]; /** * Update user preferences */ updateUserPreferences(preferences: Partial<UserPreferences>): void; /** * Generate validation report */ generateValidationReport(summary: ChoiceValidationSummary): string; /** * Private: Initialize built-in validation rules */ private initializeBuiltInRules; /** * Private: Initialize system constraints */ private initializeSystemConstraints; /** * Private: Get risk level for a specific option */ private getOptionRiskLevel; /** * Private: Check if one risk level is higher than another */ private isHigherRisk; /** * Private: Assess overall impact of choices */ private assessOverallImpact; } //# sourceMappingURL=choice-validator.d.ts.map