- Add slides.tool.ts with support for title, bullets, chart, stats, table, cards, timeline, quote, comparison, equation, image, summary slide types - Chart types: bar, horizontal-bar, line, donut, radar - Integrate with agent executor and canvas system - Add multilingual support (en/fr) - Various UI improvements and bug fixes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
import prisma from '@/lib/prisma'
|
|
import { auth } from '@/auth'
|
|
|
|
// GET /api/notes/[id]/backlinks
|
|
// Returns all notes that link TO this note via [[wikilinks]]
|
|
export async function GET(
|
|
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
|
|
|
|
// Verify the note belongs to the user
|
|
const note = await prisma.note.findUnique({ where: { id }, select: { userId: true } })
|
|
if (!note || note.userId !== session.user.id) {
|
|
return NextResponse.json({ error: 'Not found' }, { status: 404 })
|
|
}
|
|
|
|
const backlinks = await (prisma as any).noteLink.findMany({
|
|
where: { targetNoteId: id },
|
|
include: {
|
|
sourceNote: {
|
|
select: { id: true, title: true, updatedAt: true, notebookId: true },
|
|
},
|
|
},
|
|
orderBy: { createdAt: 'desc' },
|
|
})
|
|
|
|
return NextResponse.json({
|
|
backlinks: backlinks.map((bl: any) => ({
|
|
id: bl.id,
|
|
sourceNote: bl.sourceNote,
|
|
contextSnippet: bl.contextSnippet,
|
|
createdAt: bl.createdAt,
|
|
})),
|
|
})
|
|
}
|