/** * File Path Generator Utility * * Provides multiple strategies for generating storage paths: * - Hash-based: Deterministic paths based on file content (enables deduplication) * - Entity-based: Organized by entity type and ID * - Date-based: Organized by upload date (year/month/day) * - Category-based: Organized by file category * - Flat: All files in a single directory (with unique IDs) */ import { PATH_GENERATION_STRATEGY } from '@plyaz/types/storage'; import type { PathGenerationConfig, FileMetadata, StorageHashPathOptions, StorageEntityPathOptions, StorageDatePathOptions, StorageCategoryPathOptions, StorageFlatPathOptions, StorageTemplateVariables } from '@plyaz/types/storage'; /** * File Path Generator Class * Provides static methods for generating storage paths using various strategies */ export declare class FilePathGenerator { /** * Generate path using specified strategy * * @param config - Path generation configuration * @param metadata - File metadata * @param fileBuffer - File buffer (required for hash-based strategy) * @returns Generated path */ static generate(config: PathGenerationConfig, metadata: Partial, fileBuffer?: Buffer): string; /** * Generate hash-based path (deterministic) * Same file content always generates same path (enables deduplication) * * Example: files/ab/c1/23/abc123456789.jpg * * @param fileBuffer - File buffer to hash * @param options - Hash path options * @returns Generated hash-based path */ static generateHashPath(fileBuffer: Buffer, options?: StorageHashPathOptions): string; /** * Generate entity-based path (organized by entity) * * Example: athletes/abc123/videos/1706745600000-workout-video.mp4 * * @param options - Entity path options * @returns Generated entity-based path */ static generateEntityPath(options: StorageEntityPathOptions): string; /** * Generate raw adapter path (NO pluralization, NO transformations) * Uses exact values as provided - matches what storage adapters actually use * * Example: organization/abc123/financial_document/report.pdf * * @param options - Entity path options * @returns Generated raw adapter path (no pluralization) */ static generateAdapterPath(options: StorageEntityPathOptions): string; /** * Generate date-based path (organized by upload date) * * Example: uploads/2025/01/31/abc123-video.mp4 * * @param options - Date path options * @returns Generated date-based path */ static generateDatePath(options: StorageDatePathOptions): string; /** * Generate category-based path (organized by file category) * * Example: documents/user-abc123/report.pdf * * @param options - Category path options * @returns Generated category-based path */ static generateCategoryPath(options: StorageCategoryPathOptions): string; /** * Generate flat path (all files in same directory with unique IDs) * * Example: files/abc123-document.pdf * * @param options - Flat path options * @returns Generated flat path */ static generateFlatPath(options: StorageFlatPathOptions): string; /** * Generate path from template * Supports variables: {entityType}, {entityId}, {category}, {year}, {month}, {day}, {uuid}, {filename}, {hash}, {timestamp} * * Example template: "{entityType}/{entityId}/{category}/{year}/{month}/{uuid}-{filename}" * * @param template - Path template with variables * @param variables - Template variables * @returns Generated path */ static generateFromTemplate(template: string, variables: StorageTemplateVariables): string; /** * Sanitize filename (remove special characters, make filesystem-safe) * * @param filename - Original filename * @returns Sanitized filename */ static sanitizeFilename(filename: string): string; /** * Extract file extension from filename * * @param filename - Filename * @returns Extension with dot (e.g., ".jpg") or empty string */ static getExtension(filename: string): string; /** * Generate unique filename with timestamp and UUID * * @param originalFilename - Original filename * @returns Unique filename */ static generateUniqueFilename(originalFilename: string): string; /** * Pluralize entity type (simple implementation) * * @param entityType - Entity type * @returns Pluralized entity type */ private static pluralize; } /** * Helper function to generate storage path with specified strategy * Convenience wrapper around FilePathGenerator.generate * * @param strategy - Path generation strategy * @param metadata - File metadata * @param fileBuffer - File buffer (required for hash-based strategy) * @returns Generated path */ export declare function generateStoragePath(strategy: PATH_GENERATION_STRATEGY, metadata: Partial, fileBuffer?: Buffer): string;