feat: add slides generation tool with multiple slide types
- 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>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { Prisma } from '@prisma/client'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { auth } from '@/auth'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { PatchNotebookSchema } from '@/lib/validators'
|
||||
|
||||
async function getDescendantIds(notebookId: string): Promise<string[]> {
|
||||
const ids: string[] = []
|
||||
@@ -28,7 +30,14 @@ export async function PATCH(
|
||||
try {
|
||||
const { id } = await params
|
||||
const body = await request.json()
|
||||
const { name, icon, color, order, trashedAt, parentId } = body
|
||||
const parsed = PatchNotebookSchema.safeParse(body)
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json(
|
||||
{ success: false, error: 'Invalid request body', details: parsed.error.flatten() },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
const { name, icon, color, order, trashedAt, parentId } = parsed.data
|
||||
|
||||
const existing = await prisma.notebook.findUnique({
|
||||
where: { id },
|
||||
@@ -76,12 +85,12 @@ export async function PATCH(
|
||||
}
|
||||
}
|
||||
|
||||
const updateData: any = {}
|
||||
if (name !== undefined) updateData.name = name.trim()
|
||||
const updateData: Prisma.NotebookUpdateInput = {}
|
||||
if (name !== undefined) updateData.name = name
|
||||
if (icon !== undefined) updateData.icon = icon
|
||||
if (color !== undefined) updateData.color = color
|
||||
if (order !== undefined) updateData.order = order
|
||||
if (trashedAt !== undefined) updateData.trashedAt = trashedAt
|
||||
if (trashedAt !== undefined) updateData.trashedAt = trashedAt ? new Date(trashedAt) : null
|
||||
if (parentId !== undefined) updateData.parentId = parentId
|
||||
|
||||
if (trashedAt !== undefined) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { Prisma } from '@prisma/client'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { auth } from '@/auth'
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { CreateNotebookSchema } from '@/lib/validators'
|
||||
|
||||
const DEFAULT_COLORS = ['#3B82F6', '#8B5CF6', '#EC4899', '#F59E0B', '#10B981', '#06B6D4']
|
||||
const DEFAULT_ICONS = ['📁', '📚', '💼', '🎯', '📊', '🎨', '💡', '🔧']
|
||||
@@ -63,11 +65,14 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
try {
|
||||
const body = await request.json()
|
||||
const { name, icon, color, parentId } = body
|
||||
|
||||
if (!name || typeof name !== 'string') {
|
||||
return NextResponse.json({ success: false, error: 'Notebook name is required' }, { status: 400 })
|
||||
const parsed = CreateNotebookSchema.safeParse(body)
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json(
|
||||
{ success: false, error: 'Invalid request body', details: parsed.error.flatten() },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
const { name, icon, color, parentId } = parsed.data
|
||||
|
||||
if (parentId) {
|
||||
const parent = await prisma.notebook.findFirst({
|
||||
@@ -78,9 +83,7 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
const whereClause: any = { userId: session.user.id }
|
||||
if (parentId) whereClause.parentId = parentId
|
||||
else whereClause.parentId = null
|
||||
const whereClause: Prisma.NotebookWhereInput = { userId: session.user.id, parentId: parentId ?? null }
|
||||
|
||||
const highestOrder = await prisma.notebook.findFirst({
|
||||
where: whereClause,
|
||||
|
||||
Reference in New Issue
Block a user