supa-seed
Version:
A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support
312 lines • 15.9 kB
JavaScript
;
/**
* Schema-First Architecture - Main Integration Module
* Exports all components of the new schema-driven approach
* v2.1.0 - Complete architectural overhaul addressing beta tester feedback
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_SCHEMA_FIRST_CONFIG = exports.DEFAULT_CONSTRAINT_AWARE_CONFIG = exports.MIGRATION_NOTES = exports.V2_2_0_MIGRATION_NOTES = exports.SCHEMA_FIRST_VERSION = exports.CONSTRAINT_AWARE_VERSION = exports.CURRENT_VERSION = exports.ConstraintAwareTestSuite = exports.V2_2_0_Migrator = exports.WorkflowGenerator = exports.ConstraintAwareExecutor = exports.ConstraintDiscoveryEngine = exports.ArchitectureTestSuite = exports.ConfigMigrator = exports.FrameworkAgnosticUserCreator = exports.SchemaDrivenAdapter = exports.RelationshipDiscoverer = exports.DynamicColumnMapper = exports.ConstraintValidator = exports.WorkflowExecutor = exports.WorkflowBuilder = exports.SchemaIntrospector = void 0;
exports.createSchemaDrivenSeeder = createSchemaDrivenSeeder;
exports.createFrameworkAgnosticCreator = createFrameworkAgnosticCreator;
exports.createConstraintDiscoveryEngine = createConstraintDiscoveryEngine;
exports.createConstraintAwareExecutor = createConstraintAwareExecutor;
exports.createWorkflowGenerator = createWorkflowGenerator;
exports.createV2_2_0_Migrator = createV2_2_0_Migrator;
exports.createConstraintAwareTestSuite = createConstraintAwareTestSuite;
exports.createConstraintAwareSeeder = createConstraintAwareSeeder;
exports.quickStart = quickStart;
// Core schema introspection and analysis
var schema_introspector_1 = require("./schema-introspector");
Object.defineProperty(exports, "SchemaIntrospector", { enumerable: true, get: function () { return schema_introspector_1.SchemaIntrospector; } });
// Workflow building and execution
var workflow_builder_1 = require("../features/generation/workflow-builder");
Object.defineProperty(exports, "WorkflowBuilder", { enumerable: true, get: function () { return workflow_builder_1.WorkflowBuilder; } });
var workflow_executor_1 = require("../features/generation/workflow-executor");
Object.defineProperty(exports, "WorkflowExecutor", { enumerable: true, get: function () { return workflow_executor_1.WorkflowExecutor; } });
// Constraint validation
var constraint_validator_1 = require("../features/analysis/constraint-validator");
Object.defineProperty(exports, "ConstraintValidator", { enumerable: true, get: function () { return constraint_validator_1.ConstraintValidator; } });
// Dynamic column mapping
var dynamic_column_mapper_1 = require("./dynamic-column-mapper");
Object.defineProperty(exports, "DynamicColumnMapper", { enumerable: true, get: function () { return dynamic_column_mapper_1.DynamicColumnMapper; } });
// Relationship discovery
var relationship_discoverer_1 = require("./relationship-discoverer");
Object.defineProperty(exports, "RelationshipDiscoverer", { enumerable: true, get: function () { return relationship_discoverer_1.RelationshipDiscoverer; } });
// Main adapters and creators
var schema_driven_adapter_1 = require("./schema-driven-adapter");
Object.defineProperty(exports, "SchemaDrivenAdapter", { enumerable: true, get: function () { return schema_driven_adapter_1.SchemaDrivenAdapter; } });
var framework_agnostic_user_creator_1 = require("./framework-agnostic-user-creator");
Object.defineProperty(exports, "FrameworkAgnosticUserCreator", { enumerable: true, get: function () { return framework_agnostic_user_creator_1.FrameworkAgnosticUserCreator; } });
// Migration and testing
var config_migrator_1 = require("./config-migrator");
Object.defineProperty(exports, "ConfigMigrator", { enumerable: true, get: function () { return config_migrator_1.ConfigMigrator; } });
var architecture_test_suite_1 = require("./architecture-test-suite");
Object.defineProperty(exports, "ArchitectureTestSuite", { enumerable: true, get: function () { return architecture_test_suite_1.ArchitectureTestSuite; } });
// v2.2.0: Constraint-aware architecture components
var constraint_discovery_engine_1 = require("../features/analysis/constraint-discovery-engine");
Object.defineProperty(exports, "ConstraintDiscoveryEngine", { enumerable: true, get: function () { return constraint_discovery_engine_1.ConstraintDiscoveryEngine; } });
var constraint_aware_executor_1 = require("../features/analysis/constraint-aware-executor");
Object.defineProperty(exports, "ConstraintAwareExecutor", { enumerable: true, get: function () { return constraint_aware_executor_1.ConstraintAwareExecutor; } });
var workflow_generator_1 = require("../features/generation/workflow-generator");
Object.defineProperty(exports, "WorkflowGenerator", { enumerable: true, get: function () { return workflow_generator_1.WorkflowGenerator; } });
var v2_2_0_migrator_1 = require("./v2-2-0-migrator");
Object.defineProperty(exports, "V2_2_0_Migrator", { enumerable: true, get: function () { return v2_2_0_migrator_1.V2_2_0_Migrator; } });
var constraint_aware_test_suite_1 = require("../features/analysis/constraint-aware-test-suite");
Object.defineProperty(exports, "ConstraintAwareTestSuite", { enumerable: true, get: function () { return constraint_aware_test_suite_1.ConstraintAwareTestSuite; } });
// Import the actual classes to use in factory functions
const schema_driven_adapter_2 = require("./schema-driven-adapter");
const framework_agnostic_user_creator_2 = require("./framework-agnostic-user-creator");
const architecture_test_suite_2 = require("./architecture-test-suite");
const constraint_discovery_engine_2 = require("../features/analysis/constraint-discovery-engine");
const constraint_aware_executor_2 = require("../features/analysis/constraint-aware-executor");
const workflow_generator_2 = require("../features/generation/workflow-generator");
const v2_2_0_migrator_2 = require("./v2-2-0-migrator");
const constraint_aware_test_suite_2 = require("../features/analysis/constraint-aware-test-suite");
// Convenience factory function for easy setup
function createSchemaDrivenSeeder(client, config = {}) {
return new schema_driven_adapter_2.SchemaDrivenAdapter(client, config);
}
// Convenience factory function for framework-agnostic creation
function createFrameworkAgnosticCreator(client, config = {}) {
return new framework_agnostic_user_creator_2.FrameworkAgnosticUserCreator(client, config);
}
// v2.2.0: Convenience factory functions for constraint-aware architecture
function createConstraintDiscoveryEngine(client) {
return new constraint_discovery_engine_2.ConstraintDiscoveryEngine(client);
}
function createConstraintAwareExecutor(client) {
return new constraint_aware_executor_2.ConstraintAwareExecutor(client);
}
function createWorkflowGenerator(client) {
return new workflow_generator_2.WorkflowGenerator(client);
}
function createV2_2_0_Migrator(client) {
return new v2_2_0_migrator_2.V2_2_0_Migrator(client);
}
function createConstraintAwareTestSuite(client) {
return new constraint_aware_test_suite_2.ConstraintAwareTestSuite(client);
}
// v2.2.0: All-in-one constraint-aware setup
async function createConstraintAwareSeeder(client, options = {}) {
const generator = new workflow_generator_2.WorkflowGenerator(client);
const executor = new constraint_aware_executor_2.ConstraintAwareExecutor(client);
const tableNames = options.tableNames || ['profiles', 'accounts', 'users'];
const generationOptions = {
userCreationStrategy: 'adaptive',
constraintHandling: 'auto_fix',
generateOptionalSteps: true,
includeDependencyCreation: true,
enableAutoFixes: true,
...options.generationOptions
};
const { configuration, metadata } = await generator.generateWorkflowConfiguration(tableNames, generationOptions);
return {
generator,
executor,
configuration,
metadata,
async createUser(userData) {
return executor.executeWorkflow(configuration.workflows.userCreation, userData);
}
};
}
// Version and metadata
exports.CURRENT_VERSION = '2.4.3';
exports.CONSTRAINT_AWARE_VERSION = '2.2.0';
exports.SCHEMA_FIRST_VERSION = '2.1.0'; // Maintained for compatibility
exports.V2_2_0_MIGRATION_NOTES = {
from: '2.1.0',
to: '2.2.0',
majorFeatures: [
'Deep PostgreSQL constraint discovery and parsing',
'Business logic rule extraction from triggers and functions',
'Constraint-aware workflow execution engine',
'Pre-execution constraint validation system',
'Automatic constraint violation detection and fixing',
'Configurable workflow generation from discovered constraints',
'Dependency graph analysis for proper operation ordering'
],
architecturalChanges: [
'Added ConstraintDiscoveryEngine for PostgreSQL function/trigger parsing',
'Created ConstraintAwareExecutor for validated workflow execution',
'Built WorkflowGenerator for dynamic workflow creation from constraints',
'Enhanced SchemaIntrospector with deep constraint discovery',
'Implemented auto-fix suggestion and application system'
],
coreImprovements: [
'Eliminates constraint violations at runtime through pre-validation',
'Automatically discovers and respects PostgreSQL business logic',
'Generates workflows that adapt to any schema structure',
'Provides actionable auto-fix suggestions for constraint violations',
'Supports configurable constraint handling strategies'
],
betaTesterIssuesResolved: [
'Fixed "Profiles can only be created for personal accounts" MakerKit constraint',
'Eliminated hardcoded business logic assumptions entirely',
'Added comprehensive constraint-aware user creation workflows',
'Implemented automatic dependency creation and validation',
'Built framework-agnostic constraint discovery for any PostgreSQL schema'
]
};
// Legacy v2.1.0 migration notes (maintained for compatibility)
exports.MIGRATION_NOTES = {
from: '2.0.5',
to: '2.1.0',
changes: [
'Replaced hardcoded framework assumptions with dynamic schema introspection',
'Added constraint-aware validation and execution',
'Implemented intelligent column mapping with fuzzy matching',
'Added framework-agnostic user creation with fallback strategies',
'Introduced relationship discovery for proper foreign key handling',
'Created migration system for smooth upgrade from legacy configs',
'Built comprehensive test suite for multiple MakerKit variants'
],
betaTesterIssuesAddressed: [
'Fixed hardcoded business logic assumptions',
'Eliminated "whack-a-mole" pattern of individual column fixes',
'Added constraint validation to prevent "personal account" errors',
'Implemented schema-discovery-based workflow generation',
'Enabled framework-agnostic operation for any MakerKit variant'
]
};
// v2.2.0: Default configuration for constraint-aware architecture
exports.DEFAULT_CONSTRAINT_AWARE_CONFIG = {
version: '2.2.0',
strategy: 'constraint-aware',
seeding: {
enableSchemaIntrospection: true,
enableConstraintValidation: true,
enableAutoFixes: true,
enableProgressiveEnhancement: true,
enableGracefulDegradation: true,
// v2.2.0: New constraint-aware settings
enableDeepConstraintDiscovery: true,
enableBusinessLogicParsing: true,
enableWorkflowGeneration: true
},
schema: {
autoDetectFramework: true,
columnMapping: {
enableDynamicMapping: true,
enableFuzzyMatching: true,
enablePatternMatching: true,
minimumConfidence: 0.3
},
constraints: {
enableValidation: true,
enableAutoFixes: true,
createDependenciesOnDemand: true,
// v2.2.0: Enhanced constraint handling
enableDeepDiscovery: true,
parseTriggerFunctions: true,
buildDependencyGraph: true,
preValidateOperations: true
},
relationships: {
enableDiscovery: true,
respectForeignKeys: true,
handleCircularDependencies: true,
enableParallelSeeding: true
}
},
execution: {
enableRollback: true,
maxRetries: 3,
timeoutMs: 30000,
enableCaching: true,
cacheTimeout: 30,
// v2.2.0: Constraint-aware execution settings
constraintValidationStrategy: 'pre_execution',
errorHandlingStrategy: 'graceful_degradation',
autoFixStrategy: 'aggressive'
},
compatibility: {
enableLegacyMode: false,
legacyFallbacks: ['simple_profiles', 'accounts_only', 'auth_only'],
// v2.2.0: Maintain v2.1.0 compatibility
supportSchemaFirstMode: true,
enableV2_1_0_Fallback: true
}
};
// Legacy v2.1.0 configuration (maintained for compatibility)
exports.DEFAULT_SCHEMA_FIRST_CONFIG = {
version: '2.1.0',
seeding: {
enableSchemaIntrospection: true,
enableConstraintValidation: true,
enableAutoFixes: true,
enableProgressiveEnhancement: true,
enableGracefulDegradation: true
},
schema: {
autoDetectFramework: true,
columnMapping: {
enableDynamicMapping: true,
enableFuzzyMatching: true,
enablePatternMatching: true,
minimumConfidence: 0.3
},
constraints: {
enableValidation: true,
enableAutoFixes: true,
createDependenciesOnDemand: true
},
relationships: {
enableDiscovery: true,
respectForeignKeys: true,
handleCircularDependencies: true,
enableParallelSeeding: true
}
},
execution: {
enableRollback: true,
maxRetries: 3,
timeoutMs: 30000,
enableCaching: true,
cacheTimeout: 30
},
compatibility: {
enableLegacyMode: false,
legacyFallbacks: ['simple_profiles', 'accounts_only', 'auth_only']
}
};
/**
* Quick start function for immediate use
* Automatically configures the best settings based on database analysis
*/
async function quickStart(client, options = {}) {
const adapter = new schema_driven_adapter_2.SchemaDrivenAdapter(client, exports.DEFAULT_SCHEMA_FIRST_CONFIG);
if (options.enableTesting) {
const testSuite = new architecture_test_suite_2.ArchitectureTestSuite();
const testResults = await testSuite.runTestSuite();
console.log('🧪 Architecture test suite completed');
console.log(`Success rate: ${testResults.summary.overallSuccess.toFixed(1)}%`);
}
if (options.email) {
const creator = new framework_agnostic_user_creator_2.FrameworkAgnosticUserCreator(client, {});
const result = await creator.createUser({
email: options.email,
name: 'Test User',
username: 'testuser'
});
return {
adapter,
userCreationResult: result,
recommendations: [
'Schema-first architecture is now active',
'All hardcoded assumptions have been replaced with dynamic discovery',
'Constraint validation is enabled to prevent seeding errors',
'Framework-agnostic operation supports any MakerKit variant'
]
};
}
return {
adapter,
recommendations: [
'Use adapter.createUser() for schema-aware user creation',
'Enable constraint validation to prevent errors',
'Use framework-agnostic creator for maximum compatibility'
]
};
}
//# sourceMappingURL=index.js.map