/** * Storage Types */ import { StorageProviders } from '../../types'; /** * Storage service configuration */ export interface IStorageServiceConfig { workspace_id: string; public_key: string; user_id: string; token: string; env_type: string; redis_client?: any; default_product?: string; default_env?: string; } /** * Storage provider configuration */ export interface IStorageProviderConfig { provider: StorageProviders; awsConfig?: IAWSStorageConfig; gcpConfig?: IGCPStorageConfig; azureConfig?: IAzureStorageConfig; } /** * AWS S3 configuration */ export interface IAWSStorageConfig { bucketName: string; accessKeyId: string; secretAccessKey: string; region: string; sessionToken?: string; } /** * GCP Cloud Storage configuration */ export interface IGCPStorageConfig { bucketName: string; config: { type: string; project_id: string; private_key_id: string; private_key: string; client_email: string; client_id: string; auth_uri: string; token_uri: string; auth_provider_x509_cert_url: string; client_x509_cert_url: string; }; } /** * Azure Blob Storage configuration */ export interface IAzureStorageConfig { containerName: string; connectionString: string; } /** * Upload request options */ export interface IUploadOptions { product: string; env: string; storage: string; fileName: string; /** File content as Buffer or base64 string (preferred when calling from SDK) */ buffer?: string | Buffer; /** File content as base64 string (used by client/proxy when sending over JSON) */ data?: string; mimeType?: string; cache?: string; session?: string; } /** * Download request options */ export interface IDownloadOptions { product: string; env: string; storage: string; fileName: string; cache?: string; session?: string; } /** * Delete request options */ export interface IDeleteOptions { product: string; env: string; storage: string; fileName: string; session?: string; } /** * File type filter for list operations */ export type StorageFileType = 'image' | 'video' | 'audio' | 'document' | 'archive' | 'other'; /** * List files request options with pagination */ export interface IListFilesOptions { product: string; env: string; storage: string; prefix?: string; /** Filter by file type (image, video, audio, document, archive, other) */ fileType?: StorageFileType; /** Maximum results per page (default: 100, max: 1000) */ limit?: number; /** Page number for offset-based pagination (1-indexed) */ page?: number; /** Continuation token for cursor-based pagination (preferred for large datasets) */ continuationToken?: string; session?: string; /** Optional cache tag for caching the result */ cache?: string; } /** * Storage operation result */ export interface IStorageResult { success: boolean; url?: string; fileName?: string; size?: number; mimeType?: string; metadata?: Record; } /** * Download result */ export interface IDownloadResult { success: boolean; data?: Buffer | string; fileName?: string; size?: number; mimeType?: string; metadata?: Record; } /** * Delete result */ export interface IDeleteResult { success: boolean; fileName?: string; } /** * List files result with pagination info */ export interface IListFilesResult { success: boolean; files: IStorageFileInfo[]; /** Total count of files (when available) */ total?: number; /** Current page number */ page?: number; /** Items per page */ limit?: number; /** Next continuation token for cursor-based pagination */ nextToken?: string; /** Whether there are more results */ hasMore: boolean; } /** * Storage file info */ export interface IStorageFileInfo { name: string; size: number; lastModified: Date; url?: string; mimeType?: string; metadata?: Record; } /** * Signed URL options */ export interface ISignedUrlOptions { product: string; env: string; storage: string; fileName: string; expiresIn?: number; action?: 'read' | 'write'; session?: string; /** Optional cache tag for caching the result */ cache?: string; } /** * Signed URL result */ export interface ISignedUrlResult { success: boolean; url: string; expiresAt: Date; } /** * Storage dispatch options for background jobs */ export interface IStorageDispatchOptions { product: string; env: string; storage: string; fileName: string; buffer?: string | Buffer; mimeType?: string; operation: 'upload' | 'delete'; startAt?: number; /** Session token in format: session_tag:jwt_token */ session?: string; } /** * Storage dispatch result */ export interface IStorageDispatchResult { jobId: string; status: 'queued' | 'processing' | 'completed' | 'failed'; } /** * Storage stats options */ export interface IStorageStatsOptions { product: string; env: string; storage: string; /** Optional prefix to filter files */ prefix?: string; session?: string; /** Optional cache tag for caching the result */ cache?: string; } /** * Storage stats result with file counts by type */ export interface IStorageStatsResult { success: boolean; /** Total number of files */ totalFiles: number; /** Total size in bytes */ totalSize: number; /** Breakdown by file type */ byType: { image: { count: number; size: number; }; video: { count: number; size: number; }; audio: { count: number; size: number; }; document: { count: number; size: number; }; archive: { count: number; size: number; }; other: { count: number; size: number; }; }; }