@health-ecosystem/file-upload
Version:
File upload library for Health Ecosystem applications with improved Next.js 15+ compatibility
148 lines • 4.55 kB
TypeScript
/**
* File Upload Library Types
* Production-ready types for Health Ecosystem file uploads
*/
export interface FileUploadConfig {
/** Base URL of the file upload service */
baseUrl: string;
/** Authentication token */
authToken: string;
/** Maximum file size in bytes (default: 50MB) */
maxFileSize?: number;
/** Allowed file types */
allowedTypes?: string[];
/** Request timeout in milliseconds (default: 30000) */
timeout?: number;
/** Enable retry on failure (default: true) */
enableRetry?: boolean;
/** Number of retry attempts (default: 3) */
maxRetries?: number;
}
export interface UploadOptions {
/** File category (medical_image, document, report, etc.) */
category?: string;
/** Associated entity type (patient, doctor, appointment, etc.) */
entityType?: string;
/** Associated entity ID */
entityId?: string;
/** Whether the file should be public (default: false) */
isPublic?: boolean;
/** Additional metadata as JSON string */
metadata?: string;
/** Progress callback function */
onProgress?: (progress: number) => void;
/** Upload start callback */
onStart?: () => void;
/** Upload success callback */
onSuccess?: (result: UploadResult) => void;
/** Upload error callback */
onError?: (error: UploadError) => void;
}
export interface UploadResult {
/** Unique file ID */
id: string;
/** Legacy file ID (for backward compatibility) */
fileId: string;
/** Original filename */
originalFilename: string;
/** Stored filename on server */
storedFilename: string;
/** File size in bytes */
fileSize: number;
/** MIME type */
mimeType: string;
/** File category */
category: string;
/** Download URL */
downloadUrl: string;
/** Thumbnail URL (for images) */
thumbnailUrl?: string;
/** Preview URL with transformation options */
previewUrl?: string;
/** Upload timestamp */
uploadedAt: string;
/** Legacy stored filename (for backward compatibility) */
filename?: string;
/** Whether the file is public */
isPublic?: boolean;
}
export interface UploadError {
/** Error code */
code: string;
/** Error message */
message: string;
/** HTTP status code */
status?: number;
/** Additional error details */
details?: any;
}
export interface FileMetadata {
/** File ID */
id: string;
/** Original filename */
originalFilename: string;
/** File size in bytes */
fileSize: number;
/** MIME type */
mimeType: string;
/** File category */
category: string;
/** Uploader user ID */
uploadedBy: string;
/** Associated entity type */
entityType?: string;
/** Associated entity ID */
entityId?: string;
/** Whether file is public */
isPublic: boolean;
/** Creation timestamp */
createdAt: string;
/** Download URL */
downloadUrl: string;
/** Thumbnail URL */
thumbnailUrl?: string;
/** Preview URL with transformation options */
previewUrl?: string;
}
export interface UploadProgress {
/** Upload progress percentage (0-100) */
progress: number;
/** Bytes uploaded */
loaded: number;
/** Total bytes */
total: number;
/** Upload speed in bytes/second */
speed?: number;
/** Estimated time remaining in seconds */
timeRemaining?: number;
}
export interface FileUploadState {
/** Whether upload is in progress */
isUploading: boolean;
/** Upload progress */
progress: UploadProgress;
/** Upload result (when successful) */
result?: UploadResult;
/** Upload error (when failed) */
error?: UploadError;
/** Whether upload was cancelled */
isCancelled: boolean;
}
export type FileCategory = 'medical_image' | 'document' | 'report' | 'prescription' | 'lab_result' | 'profile_picture' | 'identification' | 'insurance' | 'other';
export type EntityType = 'patient' | 'doctor' | 'appointment' | 'consultation' | 'prescription' | 'business' | 'user' | 'other';
/**
* Preview transformation options
*/
export interface PreviewOptions {
/** Return thumbnail instead of original file */
thumbnail?: boolean;
/** Resize image to specified width */
width?: number;
/** Resize image to specified height */
height?: number;
/** Image quality (1-100) */
quality?: number;
/** Convert image to specified format */
format?: 'jpg' | 'png' | 'webp';
}
//# sourceMappingURL=types.d.ts.map