import { ILogger } from '../utils/Logger.js'; import { AttachmentService } from './AttachmentService.js'; import { LocalStorageAdapter } from './LocalStorageAdapter.js'; import { RemoteStorageAdapter } from './RemoteStorageAdapter.js'; import { AttachmentRecord } from './Schema.js'; import { AttachmentErrorHandler } from './AttachmentErrorHandler.js'; import { AttachmentContext } from './AttachmentContext.js'; /** * Orchestrates attachment synchronization between local and remote storage. * Handles uploads, downloads, deletions, and state transitions. * * @internal */ export declare class SyncingService { private attachmentService; private localStorage; private remoteStorage; private logger; private errorHandler?; constructor(attachmentService: AttachmentService, localStorage: LocalStorageAdapter, remoteStorage: RemoteStorageAdapter, logger: ILogger, errorHandler?: AttachmentErrorHandler); /** * Processes attachments based on their state (upload, download, or delete). * All updates are saved in a single batch after processing. * * @param attachments - Array of attachment records to process * @param context - Attachment context for database operations * @returns Promise that resolves when all attachments have been processed and saved */ processAttachments(attachments: AttachmentRecord[], context: AttachmentContext): Promise; /** * Uploads an attachment from local storage to remote storage. * On success, marks as SYNCED. On failure, defers to error handler or archives. * * @param attachment - The attachment record to upload * @returns Updated attachment record with new state * @throws Error if the attachment has no localUri */ uploadAttachment(attachment: AttachmentRecord): Promise; /** * Downloads an attachment from remote storage to local storage. * Retrieves the file, converts to base64, and saves locally. * On success, marks as SYNCED. On failure, defers to error handler or archives. * * @param attachment - The attachment record to download * @returns Updated attachment record with local URI and new state */ downloadAttachment(attachment: AttachmentRecord): Promise; /** * Deletes an attachment from both remote and local storage. * Removes the remote file, local file (if exists), and the attachment record. * On failure, defers to error handler or archives. * * @param attachment - The attachment record to delete * @param context - Attachment context for database operations * @returns Updated attachment record */ deleteAttachment(attachment: AttachmentRecord, context: AttachmentContext): Promise; /** * Performs cleanup of archived attachments by removing their local files and records. * Errors during local file deletion are logged but do not prevent record deletion. */ deleteArchivedAttachments(context: AttachmentContext): Promise; }