supa-seed
Version:
A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support
211 lines • 7.59 kB
TypeScript
/**
* Detection System Integration Layer for Epic 2: Smart Platform Detection Engine
* Integrates new Architecture Detection Engine with existing schema introspection and framework detection
* Part of Task 2.1.5: Integrate with existing schema introspection and framework detection
*/
import type { createClient } from '@supabase/supabase-js';
import { type AutoConfigurationResult, type AutoConfigurationOptions } from './auto-configurator';
import { type SchemaIntrospectionResult } from '../../schema/schema-introspector';
import { type MakerKitDetectionResult } from '../../features/integration/strategies/makerkit-detector';
import { PlatformArchitectureDetectionResult, DomainDetectionResult, ArchitectureDetectionConfig, DomainDetectionConfig, PlatformArchitectureType } from './detection-types';
type SupabaseClient = ReturnType<typeof createClient>;
/**
* Unified detection result combining all detection systems
*/
export interface UnifiedDetectionResult {
/** Architecture detection results (new system) */
architecture: PlatformArchitectureDetectionResult;
/** Domain detection results (new system) */
domain: DomainDetectionResult;
/** Schema introspection results (existing system) */
schema: SchemaIntrospectionResult;
/** Framework detection results (existing system) */
framework: MakerKitDetectionResult;
/** Integration metadata */
integration: {
/** Overall confidence in unified detection */
overallConfidence: number;
/** Cross-validation results */
crossValidation: CrossValidationResult;
/** Consolidated recommendations */
recommendations: string[];
/** Detection conflicts and resolutions */
conflicts: DetectionConflict[];
/** Integration warnings */
warnings: string[];
/** Performance metrics */
performance: {
totalExecutionTime: number;
schemaIntrospectionTime: number;
frameworkDetectionTime: number;
architectureDetectionTime: number;
domainDetectionTime: number;
};
};
}
/**
* Cross-validation between different detection systems
*/
export interface CrossValidationResult {
/** Whether architecture and framework detection agree */
architectureFrameworkAgreement: number;
/** Whether schema patterns match architecture detection */
schemaArchitectureAgreement: number;
/** Whether domain and architecture detection align */
domainArchitectureAgreement: number;
/** Overall cross-validation score */
overallAgreement: number;
/** Individual engine agreement scores */
engineAgreement: Record<string, number>;
/** Specific agreements and disagreements */
agreements: string[];
disagreements: string[];
}
/**
* Detection conflicts between systems
*/
export interface DetectionConflict {
/** Type of conflict */
type: 'architecture_mismatch' | 'framework_mismatch' | 'schema_inconsistency';
/** Description of the conflict */
description: string;
/** Severity of the conflict */
severity: 'low' | 'medium' | 'high';
/** Suggested resolution */
suggestedResolution: string;
/** Systems involved in the conflict */
involvedSystems: ('architecture' | 'schema' | 'framework' | 'domain')[];
}
/**
* Configuration for unified detection
*/
export interface UnifiedDetectionConfig {
/** Architecture detection configuration */
architecture?: Partial<ArchitectureDetectionConfig>;
/** Domain detection configuration */
domain?: Partial<DomainDetectionConfig>;
/** Whether to perform cross-validation */
enableCrossValidation: boolean;
/** Whether to attempt conflict resolution */
enableConflictResolution: boolean;
/** Maximum execution time for unified detection (ms) */
maxExecutionTime: number;
/** Whether to cache detection results */
enableCaching: boolean;
/** Confidence threshold for accepting results */
confidenceThreshold: number;
}
/**
* Main integration orchestrator for all detection systems
*/
export declare class DetectionIntegrationEngine {
private client;
private schemaIntrospector;
private makerKitDetector;
private architectureDetector;
private domainDetector;
private evidenceCollector;
private cacheManager;
private autoConfigurator;
private databaseUrl;
private schemaHash?;
constructor(client: SupabaseClient, databaseUrl?: string);
/**
* Perform unified detection with auto-configuration
*/
performUnifiedDetectionWithAutoConfig(autoConfigOptions?: Partial<AutoConfigurationOptions>, detectionConfig?: Partial<UnifiedDetectionConfig>): Promise<{
detection: UnifiedDetectionResult;
autoConfiguration: AutoConfigurationResult;
}>;
/**
* Perform unified detection across all systems
*/
performUnifiedDetection(config?: Partial<UnifiedDetectionConfig>): Promise<UnifiedDetectionResult>;
/**
* Build detection context from existing introspection results
*/
private buildDetectionContext;
/**
* Build domain analysis context from existing results
*/
private buildDomainContext;
/**
* Suggest likely domains based on architecture type
*/
private suggestDomainsFromArchitecture;
/**
* Perform cross-validation between different detection systems
*/
private performCrossValidation;
/**
* Validate agreement between architecture and framework detection
*/
private validateArchitectureFrameworkAgreement;
/**
* Validate agreement between schema patterns and architecture detection
*/
private validateSchemaArchitectureAgreement;
/**
* Validate agreement between domain and architecture detection
*/
private validateDomainArchitectureAgreement;
/**
* Get alignment score between domain and architecture types
*/
private getDomainArchitectureAlignment;
/**
* Detect and resolve conflicts between detection systems
*/
private detectAndResolveConflicts;
/**
* Generate consolidated recommendations from all systems
*/
private generateConsolidatedRecommendations;
/**
* Calculate overall confidence across all detection systems
*/
private calculateOverallConfidence;
/**
* Helper methods
*/
private createEmptyCrossValidation;
private mapConstraintType;
private mapConstraintTypeToFramework;
private getExpectedRelationshipComplexity;
/**
* Extract database URL from Supabase client
*/
private extractUrlFromClient;
/**
* Clear detection cache
*/
clearCache(): Promise<void>;
/**
* Get cache statistics
*/
getCacheStatistics(): Promise<import("./detection-cache").CacheStatistics>;
private generateCacheKey;
/**
* Clear all detection caches
*/
clearCaches(): Promise<void>;
/**
* Get quick detection summary for performance-critical scenarios
*/
getQuickDetectionSummary(): Promise<{
architectureType: PlatformArchitectureType;
confidence: number;
isFrameworkDetected: boolean;
executionTime: number;
}>;
/**
* Generate integration warnings based on detection results
*/
private generateIntegrationWarnings;
}
/**
* Default configuration for unified detection
*/
export declare const DEFAULT_UNIFIED_DETECTION_CONFIG: UnifiedDetectionConfig;
export {};
//# sourceMappingURL=detection-integration.d.ts.map