Rend les liens entre notes visibles et persistants (sync NoteLink au save, auto-save, graphe réseau rafraîchi), ajoute living blocks, Memory Echo, recherche globale, consentement IA explicite et consolide les prototypes design en architectural-grid. Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
945 B
TypeScript
31 lines
945 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import prisma from '@/lib/prisma'
|
|
import { auth } from '@/auth'
|
|
import { syncNoteLinksForNote } from '@/lib/notes/sync-note-links'
|
|
|
|
// POST /api/notes/[id]/sync-links — resynchronise les liens internes depuis le contenu
|
|
export async function POST(
|
|
_request: NextRequest,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const session = await auth()
|
|
if (!session?.user?.id) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
}
|
|
|
|
const { id } = await params
|
|
const userId = session.user.id
|
|
|
|
const note = await prisma.note.findUnique({
|
|
where: { id },
|
|
select: { id: true, userId: true, content: true },
|
|
})
|
|
|
|
if (!note || note.userId !== userId) {
|
|
return NextResponse.json({ error: 'Not found' }, { status: 404 })
|
|
}
|
|
|
|
const synced = await syncNoteLinksForNote(id, userId, note.content || '')
|
|
return NextResponse.json({ synced })
|
|
}
|