UNPKG

supa-seed

Version:

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

97 lines 3.35 kB
/** * Framework-Agnostic User Creation Logic * Adapts user creation to any schema structure and constraints * Replaces framework-specific assumptions with dynamic adaptation */ import type { createClient } from '@supabase/supabase-js'; import { UserCreationRequest, UserCreationResponse } from './schema-driven-adapter'; type SupabaseClient = ReturnType<typeof createClient>; export interface AdaptiveUserCreationConfig { fallbackToSimpleCreation: boolean; enableProgressiveEnhancement: boolean; enableGracefulDegradation: boolean; autoDetectFramework: boolean; frameworkHints?: string[]; skipOptionalConstraints: boolean; generateMissingRelationships: boolean; createDependenciesOnDemand: boolean; enableMultipleAttempts: boolean; fallbackStrategies: Array<'simple_profiles' | 'accounts_only' | 'auth_only'>; beforeUserCreation?: (request: UserCreationRequest) => Promise<UserCreationRequest>; afterUserCreation?: (response: UserCreationResponse) => Promise<UserCreationResponse>; onError?: (error: any, attempt: number) => Promise<boolean>; } export interface AdaptiveCreationResult extends UserCreationResponse { adaptationInfo: { frameworkDetected: string; strategiesUsed: string[]; fallbacksTriggered: string[]; constraintsHandled: number; adaptationConfidence: number; }; compatibilityReport: { fullCompatibility: boolean; partialCompatibility: boolean; limitationsFound: string[]; enhancementsApplied: string[]; }; } export declare class FrameworkAgnosticUserCreator { private client; private adapter; private config; constructor(client: SupabaseClient, config?: Partial<AdaptiveUserCreationConfig>); /** * Create a user with adaptive framework detection and constraint handling */ createUser(request: UserCreationRequest): Promise<AdaptiveCreationResult>; /** * Attempt primary creation using schema-driven approach */ private attemptPrimaryCreation; /** * Apply progressive enhancement based on detected framework */ private applyProgressiveEnhancement; /** * Attempt fallback strategies when primary creation fails */ private attemptFallbackStrategies; /** * Execute a specific fallback strategy */ private executeFallbackStrategy; /** * Simple profiles-based user creation (most basic approach) */ private createSimpleProfileUser; /** * Account-only user creation (for account-based systems) */ private createAccountOnlyUser; /** * Auth-only user creation (most basic fallback) */ private createAuthOnlyUser; /** * Utility methods */ private generateUsernameFromEmail; private generateDefaultAvatar; private createSuccessResponse; private createErrorResponse; private logCreationResult; /** * Public configuration methods */ updateConfig(newConfig: Partial<AdaptiveUserCreationConfig>): void; getCompatibilityReport(): Promise<{ detectedFramework: string; confidence: number; supportedFeatures: string[]; limitations: string[]; recommendations: string[]; }>; } export {}; //# sourceMappingURL=framework-agnostic-user-creator.d.ts.map