longurl-js
Version:
LongURL - Programmable URL management framework with entity-driven design and production-ready infrastructure
52 lines (51 loc) • 1.76 kB
TypeScript
/**
* Supabase Storage Adapter
*
* Production-ready adapter for Supabase/PostgreSQL storage.
* Includes intelligent caching and detailed error handling.
* Retry logic is handled by the user's application layer.
*/
import { StorageAdapter } from '../../core/storage/StorageAdapter.js';
import { EntityData, AnalyticsData } from '../../core/storage/types.js';
import { SupabaseConfig } from './types.js';
export declare class SupabaseAdapter extends StorageAdapter {
private client;
private config;
private cache;
private cacheEnabled;
private cacheTimeout;
private maxCacheSize;
private tableName;
private analyticsTable;
private tableSchema;
constructor(config: SupabaseConfig);
/**
* Handle errors with detailed context - no retry logic
*/
private handleError;
/**
* Intelligent cache management with size limits and expiration
*/
private cleanupCache;
private getCached;
private setCache;
/**
* Auto-detect table schema for backwards compatibility
*/
private detectTableSchema;
initialize(): Promise<void>;
save(urlId: string, data: EntityData): Promise<void>;
resolve(urlId: string): Promise<EntityData | null>;
exists(urlId: string): Promise<boolean>;
incrementClicks(urlId: string, metadata?: Record<string, any>): Promise<void>;
getAnalytics(urlId: string): Promise<AnalyticsData | null>;
close(): Promise<void>;
healthCheck(): Promise<boolean>;
subscribeToChanges(callback: (payload: any) => void): Promise<import("@supabase/supabase-js").RealtimeChannel>;
saveBatch(data: EntityData[]): Promise<void>;
getCacheStats(): {
size: number;
maxSize: number;
enabled: boolean;
};
}