import { AbstractPowerSyncDatabase } from '../client/AbstractPowerSyncDatabase.js'; import { ILogger } from '../utils/Logger.js'; import { Transaction } from '../db/DBAdapter.js'; import { AttachmentRecord } from './Schema.js'; /** * AttachmentContext provides database operations for managing attachment records. * * Provides methods to query, insert, update, and delete attachment records with * proper transaction management through PowerSync. * * @internal */ export declare class AttachmentContext { /** PowerSync database instance for executing queries */ db: AbstractPowerSyncDatabase; /** Name of the database table storing attachment records */ tableName: string; /** Logger instance for diagnostic information */ logger: ILogger; /** Maximum number of archived attachments to keep before cleanup */ archivedCacheLimit: number; /** * Creates a new AttachmentContext instance. * * @param db - PowerSync database instance * @param tableName - Name of the table storing attachment records. Default: 'attachments' * @param logger - Logger instance for diagnostic output */ constructor(db: AbstractPowerSyncDatabase, tableName: string | undefined, logger: ILogger, archivedCacheLimit: number); /** * Retrieves all active attachments that require synchronization. * Active attachments include those queued for upload, download, or delete. * Results are ordered by timestamp in ascending order. * * @returns Promise resolving to an array of active attachment records */ getActiveAttachments(): Promise; /** * Retrieves all archived attachments. * * Archived attachments are no longer referenced but haven't been permanently deleted. * These are candidates for cleanup operations to free up storage space. * * @returns Promise resolving to an array of archived attachment records */ getArchivedAttachments(): Promise; /** * Retrieves all attachment records regardless of state. * Results are ordered by timestamp in ascending order. * * @returns Promise resolving to an array of all attachment records */ getAttachments(): Promise; /** * Inserts or updates an attachment record within an existing transaction. * * Performs an upsert operation (INSERT OR REPLACE). Must be called within * an active database transaction context. * * @param attachment - The attachment record to upsert * @param context - Active database transaction context */ upsertAttachment(attachment: AttachmentRecord, context: Transaction): Promise; getAttachment(id: string): Promise; /** * Permanently deletes an attachment record from the database. * * This operation removes the attachment record but does not delete * the associated local or remote files. File deletion should be handled * separately through the appropriate storage adapters. * * @param attachmentId - Unique identifier of the attachment to delete */ deleteAttachment(attachmentId: string): Promise; clearQueue(): Promise; deleteArchivedAttachments(callback?: (attachments: AttachmentRecord[]) => Promise): Promise; /** * Saves multiple attachment records in a single transaction. * * All updates are saved in a single batch after processing. * If the attachments array is empty, no database operations are performed. * * @param attachments - Array of attachment records to save */ saveAttachments(attachments: AttachmentRecord[]): Promise; }