supa-seed
Version:
A constraint-aware, framework-agnostic database seeding framework with deep PostgreSQL business logic discovery and MakerKit integration support
80 lines • 3.04 kB
TypeScript
/**
* Dynamic Table Mapping Resolver
* FEAT-003: Memory Management & Schema Mapping Fixes - Phase 2
*
* Resolves table name conflicts between framework expectations and actual schema.
* Handles MakerKit base_templates vs setup_types mapping and other schema variations.
*/
import { SchemaMapping } from '../core/config/schema-mappings';
import { SupabaseClient } from '@supabase/supabase-js';
export interface TableMappingConfig {
/** Framework type detected */
framework: string;
/** Custom schema mappings to override defaults */
customMappings?: Partial<SchemaMapping>;
/** Whether to perform schema introspection for validation */
validateWithDatabase?: boolean;
}
export interface TableMappingResult {
/** The actual table name to use in queries */
actualTableName: string;
/** Whether the table exists in the database */
exists: boolean;
/** The mapping source (config, fallback, or error) */
source: 'config' | 'fallback' | 'introspection' | 'error';
/** Any warnings or recommendations */
warnings: string[];
}
/**
* Resolves table name conflicts dynamically based on configuration and schema introspection
*/
export declare class TableMappingResolver {
private client;
private config;
private cachedMappings;
private schemaValidated;
constructor(client: SupabaseClient, config: TableMappingConfig);
/**
* Resolve a framework-expected table name to the actual table name
*/
resolveTableName(expectedTableName: string, tableType: 'userTable' | 'setupTable' | 'baseTemplateTable' | 'mediaAttachmentsTable'): Promise<TableMappingResult>;
/**
* Internal table name resolution logic
*/
private _resolveTableNameInternal;
/**
* Get the effective schema mapping (defaults + custom overrides)
*/
private getSchemaMapping;
/**
* Validate that a table exists in the database
*/
private validateTableExists;
/**
* Get all table mappings for the current configuration
*/
getAllTableMappings(): Promise<Record<string, TableMappingResult>>;
/**
* Clear cached mappings (useful for testing or configuration changes)
*/
clearCache(): void;
/**
* Get performance and mapping statistics
*/
getStats(): {
cachedMappings: number;
schemaValidated: boolean;
framework: string;
hasCustomMappings: boolean;
};
}
/**
* Factory function to create a table mapping resolver
*/
export declare function createTableMappingResolver(client: SupabaseClient, config: TableMappingConfig): TableMappingResolver;
/**
* Utility function to resolve a single table name quickly
*/
export declare function resolveTableName(client: SupabaseClient, framework: string, expectedTableName: string, tableType: 'userTable' | 'setupTable' | 'baseTemplateTable' | 'mediaAttachmentsTable', customMappings?: Partial<SchemaMapping>): Promise<string>;
export default TableMappingResolver;
//# sourceMappingURL=table-mapping-resolver.d.ts.map