supa-seed
Version:
A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support
167 lines • 5.01 kB
TypeScript
/**
* Schema-Driven Adapter
* Replaces hardcoded MakerKit workflows with configurable execution patterns
* Integrates all schema-first components to provide a unified interface
*/
import type { createClient } from '@supabase/supabase-js';
import { SchemaIntrospectionResult } from './schema-introspector';
import { UserCreationWorkflow } from '../features/generation/workflow-builder';
import { WorkflowExecutionResult } from '../features/generation/workflow-executor';
import { ValidationResult } from '../features/analysis/constraint-validator';
import { TableColumnMap, MappingConfig } from './dynamic-column-mapper';
type SupabaseClient = ReturnType<typeof createClient>;
export interface SchemaAdapterConfig {
primaryUserTable?: string;
enableConstraintValidation: boolean;
enableRollback: boolean;
enableAutoFixes: boolean;
maxRetries: number;
timeoutMs: number;
continueOnError: boolean;
mappingConfig: MappingConfig;
customColumnMappings?: Record<string, Record<string, string>>;
frameworkOverride?: 'makerkit' | 'nextjs' | 'custom';
versionOverride?: string;
enableSchemaCache: boolean;
cacheTimeout: number;
}
export interface UserCreationRequest {
email: string;
name: string;
username?: string;
bio?: string;
picture_url?: string;
password?: string;
metadata?: Record<string, any>;
customFields?: Record<string, any>;
}
export interface UserCreationResponse {
success: boolean;
userId?: string;
executionId: string;
workflow: UserCreationWorkflow;
executionResult: WorkflowExecutionResult;
validationResult?: ValidationResult;
appliedFixes?: Array<{
field: string;
oldValue: any;
newValue: any;
}>;
schemaInfo: {
framework: string;
version: string;
confidence: number;
primaryUserTable: string;
};
performance: {
introspectionTime: number;
workflowBuildTime: number;
executionTime: number;
totalTime: number;
};
recommendations: string[];
}
export interface SchemaAnalysisResult {
schemaInfo: SchemaIntrospectionResult;
columnMappings: Map<string, TableColumnMap>;
workflow: UserCreationWorkflow;
recommendations: string[];
confidence: number;
}
export declare class SchemaDrivenAdapter {
private client;
private config;
private introspector;
private workflowBuilder;
private executor;
private validator;
private columnMapper;
private cachedSchema;
private cachedMappings;
private cachedWorkflow;
private cacheTimestamp;
constructor(client: SupabaseClient, config?: Partial<SchemaAdapterConfig>);
/**
* Create a user using the schema-driven approach
* This replaces all hardcoded MakerKit workflows
*/
createUser(request: UserCreationRequest): Promise<UserCreationResponse>;
/**
* Analyze schema and build column mappings
*/
analyzeSchema(): Promise<SchemaAnalysisResult>;
/**
* Get the strategy that would be used for user creation
* This replaces the old getUserCreationStrategy method
*/
getUserCreationStrategy(): Promise<{
strategy: string;
primaryTable: string;
workflow: UserCreationWorkflow;
confidence: number;
evidence: string[];
}>;
/**
* Create a user using the legacy interface for backward compatibility
* This replaces createUserForSchema from the old SchemaAdapter
*/
createUserForSchema(userData: {
id?: string;
email: string;
name: string;
username?: string;
bio?: string;
picture_url?: string;
}): Promise<{
id: string;
success: boolean;
error?: string;
}>;
/**
* Validate the current schema and mappings
*/
validateSchema(): Promise<{
valid: boolean;
issues: string[];
recommendations: string[];
schemaHash: string;
}>;
/**
* Get current schema information
*/
getSchemaInfo(): Promise<{
framework: {
type: string;
version: string;
confidence: number;
};
tables: Array<{
name: string;
role: string;
confidence: number;
}>;
relationships: number;
constraints: number;
mappings: Record<string, Record<string, string>>;
}>;
/**
* Clear all caches and force fresh analysis
*/
clearCache(): void;
/**
* Update configuration
*/
updateConfig(newConfig: Partial<SchemaAdapterConfig>): void;
/**
* Private helper methods
*/
private isCacheValid;
private determinePrimaryUserTable;
private normalizeUserData;
private extractCustomFieldMappings;
private generateRecommendations;
private getOrBuildWorkflow;
private getEmptyWorkflow;
}
export {};
//# sourceMappingURL=schema-driven-adapter.d.ts.map