UNPKG

longurl-js

Version:

LongURL - Programmable URL management framework with entity-driven design and production-ready infrastructure

87 lines (86 loc) 2.81 kB
/** * LongURL - Programmable URL Shortener * * Infrastructure-as-code for URLs. Built for developers who need control. * * A developer-friendly URL shortener with entity-based organization, * collision detection, and analytics tracking. */ import { LongURLConfig, GenerationResult, ResolutionResult, AnalyticsData } from '../types'; export declare class LongURL { private config; private adapter; constructor(config?: LongURLConfig); /** * Check if Supabase environment variables are available */ private hasSupabaseEnvVars; /** * Build Supabase configuration with environment variable fallbacks */ private buildSupabaseConfig; /** * Initialize the LongURL instance */ initialize(): Promise<void>; /** * Transform result to include both new and legacy field names for backward compatibility */ private enhanceGenerationResult; /** * Transform resolution result to include both new and legacy field names */ private enhanceResolutionResult; /** * Manage a URL for a specific entity * * Primary method for the LongURL framework. Handles both shortening mode * and framework mode with readable URLs. */ manageUrl(entityType: string, entityId: string, originalUrl: string, metadata?: Record<string, any>, options?: { urlPattern?: string; publicId?: string; endpointId?: string; includeInSlug?: boolean; generate_qr_code?: boolean; }): Promise<GenerationResult>; /** * Shorten a URL for a specific entity (legacy alias) * * @deprecated Use manageUrl() instead for clearer semantics. * This method is maintained for backward compatibility. */ shorten(entityType: string, entityId: string, originalUrl: string, metadata?: Record<string, any>, options?: { urlPattern?: string; publicId?: string; endpointId?: string; includeInSlug?: boolean; generate_qr_code?: boolean; }): Promise<GenerationResult>; /** * Resolve a short URL back to its original URL and entity */ resolve(urlId: string): Promise<ResolutionResult>; /** * Get analytics data for a URL */ analytics(urlId: string): Promise<{ success: boolean; data?: AnalyticsData; error?: string; }>; /** * Close the adapter connection */ close(): Promise<void>; /** * Health check */ healthCheck(): Promise<boolean>; /** * Get legacy database config for backward compatibility */ private getLegacyDbConfig; } export { StorageAdapter, SupabaseAdapter } from './adapters'; export type { LongURLConfig, EntityConfig, GenerationResult, ResolutionResult, AnalyticsData } from '../types';