Data Layer medium complexity mobile
0
Dependencies
0
Dependents
0
Entities
0
Integrations

Description

Manages local and remote persistence of attachment metadata records linked to activity entries. It reads and writes attachment records including file URLs, MIME types, sizes, and upload status to the local SQLite database. The repository serves as the source of truth for attachment state and supports offline-first operation through a pending-upload status flag.

Feature: Document Attachments

attachment-repository

Sources & reasoning

Lines 107-108 give the exact use-case (invitations, screenshots for Bufdir auditing). Line 348 places it in Fase 2 (v1.0). The needs matrix marks it NICE TO HAVE / Fase 2, consistent with should_have at v1.0.

Responsibilities

  • Insert new attachment metadata records with upload status and activity association
  • Query all attachments for a given activity ID
  • Update upload status and remote URL after successful cloud upload
  • Delete attachment records when an attachment is removed by the user
  • Return all records with pending-upload status for the offline sync queue

Interfaces

save(attachment: AttachmentRecord): Promise<void>
findByActivityId(activityId: string): Promise<AttachmentRecord[]>
updateUploadStatus(attachmentId: string, status: UploadStatus, url?: string): Promise<void>
delete(attachmentId: string): Promise<void>
getPendingUploads(): Promise<AttachmentRecord[]>