supa-seed
Version:
A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support
297 lines • 8.89 kB
TypeScript
/**
* Configuration Validation and Migration System for SupaSeed v2.5.0
* Implements Task 5.3.2: Validation and migration utilities for configuration upgrades
* Enhanced from Epic 7 system with advanced layered configuration support
*/
import type { createClient } from '@supabase/supabase-js';
import { ExtendedSeedConfig } from '../types/config-types';
import type { LayeredConfiguration } from './config-layers';
type SupabaseClient = ReturnType<typeof createClient>;
export interface ValidationResult {
valid: boolean;
errors: string[];
warnings: string[];
recommendations: string[];
score: number;
}
export interface ConfigurationRecommendation {
type: 'framework' | 'constraint' | 'relationship' | 'data_volume' | 'general';
priority: 'critical' | 'high' | 'medium' | 'low';
message: string;
suggestedFix?: string;
autoFixable: boolean;
}
/**
* Advanced validation options for Task 5.3.2
*/
export interface AdvancedValidationOptions {
strictMode?: boolean;
checkCompatibility?: boolean;
validatePerformance?: boolean;
includeWarnings?: boolean;
autoFix?: boolean;
migrationSupport?: boolean;
layeredConfigMode?: boolean;
}
/**
* Layered configuration validation result
*/
export interface LayeredConfigValidationResult {
valid: boolean;
score: number;
validationTime: number;
layers: {
universal: LayerValidationResult;
detection: LayerValidationResult;
extensions: LayerValidationResult;
};
errors: LayeredValidationError[];
warnings: LayeredValidationWarning[];
suggestions: LayeredValidationSuggestion[];
autoFixSuggestions: LayeredAutoFixSuggestion[];
migrationInfo?: LayeredMigrationInfo;
performanceImpact?: LayeredPerformanceValidation;
}
/**
* Individual layer validation result
*/
export interface LayerValidationResult {
valid: boolean;
score: number;
errors: LayeredValidationError[];
warnings: LayeredValidationWarning[];
coverage: {
totalFields: number;
validatedFields: number;
percentage: number;
};
constraints: {
checked: number;
passed: number;
failed: number;
};
}
/**
* Layered configuration validation error
*/
export interface LayeredValidationError {
code: string;
path: string;
message: string;
severity: 'critical' | 'high' | 'medium' | 'low';
category: 'structure' | 'type' | 'constraint' | 'compatibility' | 'performance';
layer: 'universal' | 'detection' | 'extensions' | 'cross-layer';
autoFixable: boolean;
migrationRequired?: boolean;
relatedErrors?: string[];
}
/**
* Layered configuration validation warning
*/
export interface LayeredValidationWarning {
code: string;
path: string;
message: string;
impact: 'high' | 'medium' | 'low';
category: 'performance' | 'compatibility' | 'best-practice' | 'security';
layer: 'universal' | 'detection' | 'extensions' | 'cross-layer';
recommendation: string;
autoFixable: boolean;
}
/**
* Layered configuration validation suggestion
*/
export interface LayeredValidationSuggestion {
type: 'optimization' | 'enhancement' | 'alternative' | 'migration';
priority: 'high' | 'medium' | 'low';
description: string;
impact: string;
implementation: string[];
estimatedBenefit: string;
affectedLayers: ('universal' | 'detection' | 'extensions')[];
}
/**
* Layered auto-fix suggestion
*/
export interface LayeredAutoFixSuggestion {
errorCode: string;
path: string;
description: string;
action: 'add' | 'modify' | 'remove' | 'restructure';
currentValue?: any;
suggestedValue: any;
riskLevel: 'safe' | 'moderate' | 'risky';
backupRequired: boolean;
affectedLayers: ('universal' | 'detection' | 'extensions')[];
}
/**
* Layered migration information
*/
export interface LayeredMigrationInfo {
required: boolean;
fromVersion: string;
toVersion: string;
migrationSteps: LayeredMigrationStep[];
estimatedDuration: number;
riskAssessment: 'low' | 'medium' | 'high';
backupRecommended: boolean;
rollbackSupported: boolean;
layerMigrations: {
universal: LayeredMigrationStep[];
detection: LayeredMigrationStep[];
extensions: LayeredMigrationStep[];
};
}
/**
* Individual layered migration step
*/
export interface LayeredMigrationStep {
id: string;
order: number;
description: string;
type: 'schema' | 'config' | 'data' | 'validation';
layer: 'universal' | 'detection' | 'extensions' | 'cross-layer';
action: string;
reversible: boolean;
estimatedTime: number;
riskLevel: 'low' | 'medium' | 'high';
dependencies: string[];
}
/**
* Layered performance validation
*/
export interface LayeredPerformanceValidation {
score: number;
estimatedSlowdown: number;
memoryImpact: number;
complexityAnalysis: {
universalComplexity: number;
detectionComplexity: number;
extensionComplexity: number;
crossLayerComplexity: number;
};
recommendations: string[];
optimizations: string[];
layerImpact: {
universal: number;
detection: number;
extensions: number;
};
}
export declare class ConfigValidator {
private client;
private schemaAdapter;
private frameworkAdapter;
constructor(client: SupabaseClient);
/**
* Comprehensive configuration validation
*/
validateConfiguration(config: ExtendedSeedConfig): Promise<ValidationResult>;
/**
* Validate basic configuration structure and required fields
*/
private validateBasicConfiguration;
/**
* Validate framework strategy configuration
*/
private validateFrameworkStrategy;
/**
* Validate constraint handlers configuration
*/
private validateConstraintHandlers;
/**
* Validate schema evolution configuration
*/
private validateSchemaEvolution;
/**
* Validate data volume configuration
*/
private validateDataVolumes;
/**
* Validate custom relationships configuration
*/
private validateCustomRelationships;
/**
* Generate configuration recommendations based on validation results
*/
private generateRecommendations;
/**
* Check if a table exists in the database
*/
private tableExists;
/**
* Validate configuration against actual database schema
*/
validateAgainstSchema(config: ExtendedSeedConfig): Promise<ValidationResult>;
/**
* Get configuration recommendations for a specific framework
*/
getFrameworkRecommendations(frameworkType: string): Promise<ConfigurationRecommendation[]>;
/**
* Validate layered configuration with comprehensive analysis
* Task 5.3.2: Advanced validation for layered configuration system
*/
validateLayeredConfiguration(config: LayeredConfiguration, options?: AdvancedValidationOptions): Promise<LayeredConfigValidationResult>;
/**
* Validate individual configuration layer
*/
private validateConfigurationLayer;
/**
* Validate universal layer
*/
private validateUniversalLayer;
/**
* Validate detection layer
*/
private validateDetectionLayer;
/**
* Validate extensions layer
*/
private validateExtensionsLayer;
/**
* Validate cross-layer constraints
*/
private validateCrossLayerConstraints;
/**
* Validate layered configuration compatibility
*/
private validateLayeredCompatibility;
/**
* Validate layered configuration performance
*/
private validateLayeredPerformance;
/**
* Analyze migration requirements for layered configuration
*/
private analyzeLayeredMigrationRequirements;
/**
* Generate improvement suggestions for layered configuration
*/
private generateLayeredSuggestions;
/**
* Generate auto-fix suggestions for layered configuration
*/
private generateLayeredAutoFixSuggestions;
/**
* Utility methods for layered validation
*/
private calculateLayerCoverage;
private getExpectedFieldsForLayer;
private calculateLayerConstraintStats;
private calculateLayerScore;
private calculateLayeredOverallScore;
private analyzeLayerComplexity;
private analyzeCrossLayerComplexity;
private generateLayeredPerformanceRecommendations;
private generateLayeredOptimizationSuggestions;
/**
* Apply auto-fixes to layered configuration
*/
applyLayeredAutoFixes(config: LayeredConfiguration, autoFixSuggestions: LayeredAutoFixSuggestion[]): Promise<{
fixedConfig: LayeredConfiguration;
appliedFixes: string[];
}>;
private applyLayeredFix;
}
export {};
//# sourceMappingURL=config-validator.d.ts.map