UNPKG

supa-seed

Version:

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

168 lines 4.78 kB
/** * Constraint Discovery Types * Type definitions for PostgreSQL constraint discovery and handling */ export interface TableConstraints { table: string; schema: string; checkConstraints: CheckConstraint[]; foreignKeyConstraints: ForeignKeyConstraint[]; uniqueConstraints: UniqueConstraint[]; primaryKeyConstraints: PrimaryKeyConstraint[]; notNullConstraints: NotNullConstraint[]; confidence: number; discoveryTimestamp: string; schemaVersion?: string; } export interface CheckConstraint { constraintName: string; table: string; schema: string; checkClause: string; isEnforced: boolean; description?: string; handler?: ConstraintHandler; } export interface ForeignKeyConstraint { constraintName: string; table: string; schema: string; columnName: string; referencedTable: string; referencedSchema: string; referencedColumn: string; onDelete: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION' | 'SET DEFAULT'; onUpdate: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION' | 'SET DEFAULT'; isEnforced: boolean; handler?: ConstraintHandler; } export interface UniqueConstraint { constraintName: string; table: string; schema: string; columns: string[]; isEnforced: boolean; isPrimaryKey: boolean; handler?: ConstraintHandler; } export interface PrimaryKeyConstraint { constraintName: string; table: string; schema: string; columns: string[]; handler?: ConstraintHandler; } export interface NotNullConstraint { columnName: string; table: string; schema: string; isEnforced: boolean; handler?: ConstraintHandler; } export interface ConstraintHandler { id: string; type: ConstraintType; priority: number; description: string; canHandle: (constraint: any, data: any) => boolean; handle: (constraint: any, data: any) => ConstraintHandlingResult; generateFix?: (constraint: any, data: any) => ConstraintFix; } export interface ConstraintHandlingResult { success: boolean; originalData: any; modifiedData: any; appliedFixes: ConstraintFix[]; warnings: string[]; errors: string[]; bypassRequired: boolean; } export interface ConstraintFix { type: 'set_field' | 'remove_field' | 'transform_value' | 'add_dependency' | 'bypass_constraint'; field?: string; oldValue?: any; newValue?: any; reason: string; confidence: number; requiresManualReview?: boolean; } export type ConstraintType = 'check' | 'foreign_key' | 'unique' | 'primary_key' | 'not_null'; export interface ConstraintDiscoveryOptions { enableCaching: boolean; cacheTimeout: number; enableSchemaVersioning: boolean; includeSystemTables: boolean; includeViews: boolean; schemas: string[]; enableConfidenceScoring: boolean; minimumConfidence: number; enableConstraintParsing: boolean; enableHandlerGeneration: boolean; maxConcurrentQueries: number; queryTimeout: number; batchSize: number; } export interface ConstraintDiscoveryResult { success: boolean; tablesAnalyzed: number; constraintsDiscovered: number; constraintsByType: Record<ConstraintType, number>; confidence: number; errors: string[]; warnings: string[]; executionTime: number; cacheHit: boolean; schemaVersion?: string; tables: TableConstraints[]; } export interface ConstraintCache { key: string; schemaVersion: string; timestamp: string; expiresAt: string; data: TableConstraints[]; confidence: number; } export interface SchemaVersionInfo { hash: string; timestamp: string; tableCount: number; constraintCount: number; lastModified?: string; } export interface ConstraintPattern { name: string; pattern: RegExp; type: ConstraintType; description: string; handler: string; confidence: number; examples: string[]; } export declare const MAKERKIT_CONSTRAINT_PATTERNS: ConstraintPattern[]; export interface ConstraintAnalysisReport { summary: { totalTables: number; totalConstraints: number; constraintsByType: Record<ConstraintType, number>; averageConfidence: number; frameworkPatterns: string[]; }; tables: Array<{ name: string; constraintCount: number; confidence: number; issues: string[]; recommendations: string[]; }>; potentialIssues: Array<{ table: string; constraint: string; issue: string; severity: 'low' | 'medium' | 'high' | 'critical'; recommendation: string; }>; frameworkRecommendations: string[]; nextSteps: string[]; } //# sourceMappingURL=constraint-types.d.ts.map