feat: MVP-5 P2 - Export/Import, Settings, Tests y Validaciones

- Ticket 10: Navegación completa de listas por teclado (↑↓ Enter E F P)
- Ticket 13: Historial de navegación contextual con recent-context-list
- Ticket 17: Exportación mejorada a Markdown con frontmatter
- Ticket 18: Exportación HTML simple y legible
- Ticket 19: Importador Markdown mejorado con frontmatter, tags, wiki links
- Ticket 20: Importador Obsidian-compatible (wiki links, #tags inline)
- Ticket 21: Centro de respaldo y portabilidad en Settings
- Ticket 22: Configuración visible de feature flags
- Ticket 24: Tests de command palette y captura externa
- Ticket 25: Harden de validaciones y límites (50MB backup, 10K notas, etc)
This commit is contained in:
2026-03-22 19:39:55 -03:00
parent 8d56f34d68
commit e66a678160
24 changed files with 1286 additions and 42 deletions

View File

@@ -4,6 +4,8 @@ import { noteSchema, NoteInput } from '@/lib/validators'
import { createErrorResponse, createSuccessResponse, ValidationError } from '@/lib/errors'
import { syncBacklinks } from '@/lib/backlinks'
import { createBackupSnapshot } from '@/lib/backup'
import { notesToMarkdownZip, noteToMarkdown } from '@/lib/export-markdown'
import { notesToHtmlZip, noteToHtml } from '@/lib/export-html'
export async function GET(req: NextRequest) {
try {
@@ -26,6 +28,38 @@ export async function GET(req: NextRequest) {
updatedAt: note.updatedAt.toISOString(),
}))
if (format === 'markdown') {
const notesForExport = notes.map(note => ({
...note,
tags: note.tags,
createdAt: note.createdAt.toISOString(),
updatedAt: note.updatedAt.toISOString(),
}))
if (notes.length === 1) {
return createSuccessResponse({
filename: notesToMarkdownZip(notesForExport).files[0].name,
content: noteToMarkdown(notesForExport[0]),
})
}
return createSuccessResponse(notesToMarkdownZip(notesForExport))
}
if (format === 'html') {
const notesForExport = notes.map(note => ({
...note,
tags: note.tags,
createdAt: note.createdAt.toISOString(),
updatedAt: note.updatedAt.toISOString(),
}))
if (notes.length === 1) {
return createSuccessResponse({
filename: notesToHtmlZip(notesForExport).files[0].name,
content: noteToHtml(notesForExport[0]),
})
}
return createSuccessResponse(notesToHtmlZip(notesForExport))
}
return createSuccessResponse(exportData)
} catch (error) {
return createErrorResponse(error)