{
  "id": "file-attachments",
  "name": "File Attachments",
  "category": "data",
  "description": "File upload with inline previews for images, videos, audio, PDF, code, CSV, DOCX, XLSX",
  "details": "Adds a file attachments collection backed by R2 storage with useR2Files. MIME detection and preview loading live in focused hooks; one preview component owns thumbnail and full rendering for PDF.js, CodeMirror, CSV, DOCX, XLSX, audio, video, and images. Members can upload and manage their own files, admins can manage all.",
  "files": [
    { "src": "src/attachments-schema.ts", "dest": "src/schemas/attachments-schema.ts" },
    { "src": "src/useMimeTypeDetection.ts", "dest": "src/hooks/useMimeTypeDetection.ts" },
    { "src": "src/useFilePreview.ts", "dest": "src/hooks/useFilePreview.ts" },
    { "src": "src/AttachmentPreview.tsx", "dest": "src/components/AttachmentPreview.tsx" },
    { "src": "src/AttachmentsPage.tsx", "dest": "src/pages/attachments.tsx" }
  ],
  "schema": {
    "exportName": "attachmentsSchema",
    "importPath": "./schemas/attachments-schema",
    "spreadOperator": false
  },
  "route": {
    "path": "/attachments",
    "protected": true
  },
  "dependencies": {
    "file-type": "^19.6.0",
    "@uiw/react-codemirror": "^4.23.0",
    "@codemirror/lang-javascript": "^6.2.2",
    "@codemirror/theme-one-dark": "^6.1.2",
    "papaparse": "^5.4.1",
    "docx-preview": "^0.3.5",
    "exceljs": "^4.4.0",
    "pdfjs-dist": "^4.7.76"
  },
  "devDependencies": {
    "@types/papaparse": "^5.3.0"
  },
  "instructions": [],
  "patterns": [
    "useMimeTypeDetection() → { detectMimeType, getFileCategory, getExtension, canPreview }",
    "useFilePreview({ url, fileName, mimeType }) → { category, canPreview, textContent, csvData, codeEditorKit, xlsxData, ... }",
    "useR2Files() → { upload, downloadFile, readFile, deleteFile, list, listPage, getUrl, isUploading }",
    "list() throws on failure (render the error); listPage() returns { files, cursor, truncated } for pagination; entries carry relativeKey",
    "File metadata stored in collection, binary stored in R2",
    "Dynamic imports: PDF.js for PDF, CodeMirror for code, PapaParse for CSV, docx-preview for DOCX, ExcelJS for XLSX"
  ]
}
