UNPKG

supa-seed

Version:

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

201 lines 6.04 kB
/** * Interactive Configuration Updates System * Phase 4, Checkpoint D2 - Interactive configuration prompt engine and user choice handling */ import { SchemaChange, ConfigurationImpact, MigrationSuggestion } from './schema-evolution'; export interface ConfigurationPrompt { id: string; type: 'schema_change' | 'migration_suggestion' | 'impact_resolution' | 'conflict_resolution'; title: string; description: string; context: { affectedFiles: string[]; schemaChanges: SchemaChange[]; migrationSuggestions: MigrationSuggestion[]; impactAnalysis: ConfigurationImpact[]; estimatedEffort: 'LOW' | 'MEDIUM' | 'HIGH' | 'EXTENSIVE'; }; options: ConfigurationOption[]; defaultOption?: string; required: boolean; dependencies: string[]; metadata: { priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; riskLevel: 'LOW' | 'MEDIUM' | 'HIGH'; reversible: boolean; estimatedTime: number; }; } export interface ConfigurationOption { id: string; label: string; description: string; type: 'accept' | 'reject' | 'customize' | 'defer' | 'skip'; consequences: string[]; prerequisites: string[]; actions: ConfigurationAction[]; reversible: boolean; riskLevel: 'LOW' | 'MEDIUM' | 'HIGH'; } export interface ConfigurationAction { type: 'file_update' | 'file_create' | 'file_backup' | 'schema_migration' | 'validation' | 'user_input'; description: string; targetPath: string; parameters: Record<string, any>; rollbackAction?: ConfigurationAction; validation?: { type: 'syntax' | 'semantic' | 'compatibility'; command?: string; expectedOutcome: string; }; } export interface UserChoice { promptId: string; optionId: string; customParameters?: Record<string, any>; userNotes?: string; timestamp: Date; confidence: number; } export interface ConfigurationSession { id: string; startTime: Date; endTime?: Date; prompts: ConfigurationPrompt[]; choices: UserChoice[]; status: 'in_progress' | 'completed' | 'aborted' | 'deferred'; metadata: { triggeredByChangeId: string; affectedFiles: string[]; totalPrompts: number; completedPrompts: number; estimatedTotalTime: number; actualTime?: number; }; } export interface PromptGenerationOptions { interactiveMode: boolean; autoAcceptLowRisk: boolean; requireConfirmationForHighRisk: boolean; includePreview: boolean; batchSimilarChanges: boolean; minimumRiskThreshold: 'LOW' | 'MEDIUM' | 'HIGH'; timeoutSeconds: number; saveChoices: boolean; } export declare class ConfigurationPromptEngine { private sessions; private readline?; private options; constructor(options?: Partial<PromptGenerationOptions>); /** * Generate configuration prompts from schema changes and migration suggestions */ generatePrompts(changes: SchemaChange[], impacts: ConfigurationImpact[], suggestions: MigrationSuggestion[]): Promise<ConfigurationPrompt[]>; /** * Start an interactive configuration session */ startConfigurationSession(changes: SchemaChange[], impacts: ConfigurationImpact[], suggestions: MigrationSuggestion[]): Promise<ConfigurationSession>; /** * Present a single prompt to the user and collect their choice */ presentPrompt(prompt: ConfigurationPrompt): Promise<UserChoice>; /** * Validate a user choice against prompt constraints */ validateChoice(prompt: ConfigurationPrompt, choice: UserChoice): { isValid: boolean; errors: string[]; warnings: string[]; }; /** * Execute the actions associated with a user choice */ executeChoice(prompt: ConfigurationPrompt, choice: UserChoice, dryRun?: boolean): Promise<{ success: boolean; executedActions: ConfigurationAction[]; errors: string[]; rollbackActions: ConfigurationAction[]; }>; /** * Get the current session status */ getSessionStatus(sessionId: string): ConfigurationSession | undefined; /** * Get all active sessions */ getActiveSessions(): ConfigurationSession[]; /** * Cleanup completed sessions */ cleanupSessions(): void; /** * Private: Initialize readline interface */ private initializeReadline; /** * Private: Group related schema changes for batch processing */ private groupRelatedChanges; /** * Private: Generate prompt for schema changes */ private generateSchemaChangePrompt; /** * Private: Generate prompt for migration suggestions */ private generateMigrationPrompt; /** * Private: Generate prompt for impact resolution */ private generateImpactResolutionPrompt; /** * Private: Sort prompts by priority and dependencies */ private sortPromptsByPriority; /** * Private: Extract affected files from impacts */ private extractAffectedFiles; /** * Private: Run interactive session */ private runInteractiveSession; /** * Private: Get user choice through readline */ private getUserChoice; /** * Private: Validate custom parameters */ private validateCustomParameters; /** * Private: Execute a single configuration action */ private executeAction; /** * Private: Execute file update action */ private executeFileUpdate; /** * Private: Execute file create action */ private executeFileCreate; /** * Private: Execute file backup action */ private executeFileBackup; /** * Private: Execute validation action */ private executeValidation; /** * Private: Save session to disk */ private saveSession; /** * Cleanup resources */ dispose(): void; } //# sourceMappingURL=interactive-configuration.d.ts.map