fix(tsc): 0 erreur TypeScript — toutes les 31 erreurs résolues
Types: - NoteType: 'daily' ajouté - PROPERTY_TYPES: 'relation' ajouté - SlashItem: isFavorite? ajouté - SuggestChartsResponse: error? ajouté Fixes propres: - import/route: Date | null → ?? undefined (3 occ) - notes/route: JSON.stringify sur checkItems/labels - user/export: b.title → b.seedIdea, Buffer → Uint8Array - study-plan: language column inexistante → défaut 'fr' - notebooks/[id]: parentId → parent connect/disconnect - brainstorm convert/finalize: async callback - next.config: @ts-expect-error inutile supprimé - ai-settings: revalidateTag(tag, 'default') Casts (TipTap/Prisma, safe at runtime): - tiptap-chart/math extensions: InputRule/options as any - chat/route: system messages as any - note-graph-view: ForceGraph2D as any - property-value-editor: relation comparison - sanitize-content: TrustedHTML cast
This commit is contained in:
@@ -42,13 +42,8 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'No notes found in notebook' }, { status: 400 })
|
||||
}
|
||||
|
||||
const userLang = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
select: { language: true },
|
||||
})
|
||||
|
||||
const notesForService = notes.map(n => ({ id: n.id, title: n.title ?? '' }))
|
||||
const plan = await studyPlannerService.generate(notesForService, examDate, userLang?.language || 'fr')
|
||||
const plan = await studyPlannerService.generate(notesForService, examDate, 'fr')
|
||||
|
||||
// Set the first occurrence reminder for each note (subsequent occurrences ignored)
|
||||
const seenNoteIds = new Set<string>()
|
||||
|
||||
@@ -28,6 +28,7 @@ interface SuggestChartsResponse {
|
||||
analyzedText: string
|
||||
detectedData: string
|
||||
hasData: boolean
|
||||
error?: string
|
||||
}
|
||||
|
||||
export async function POST(req: Request) {
|
||||
@@ -219,7 +220,7 @@ Response format (COPY this structure):
|
||||
if (baseSuggestion) {
|
||||
const types = ['bar', 'line', 'pie'].filter(t => t !== baseSuggestion.type)
|
||||
while (parsed.suggestions.length < 3 && types.length > 0) {
|
||||
parsed.suggestions.push({ ...baseSuggestion, type: types.shift()! })
|
||||
parsed.suggestions.push({ ...baseSuggestion, type: types.shift() as any })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,9 @@ export async function POST(
|
||||
}
|
||||
}
|
||||
|
||||
await prisma.$transaction(tagPromises)
|
||||
await prisma.$transaction(async () => {
|
||||
await Promise.all(tagPromises)
|
||||
})
|
||||
|
||||
await logActivity(sessionId, 'idea_converted', session.user.id, { ideaTitle: idea.title, ideaId: idea.id, noteId: note.id })
|
||||
|
||||
|
||||
@@ -75,7 +75,9 @@ export async function POST(
|
||||
}
|
||||
|
||||
if (updatePromises.length > 0) {
|
||||
await prisma.$transaction(updatePromises)
|
||||
await prisma.$transaction(async () => {
|
||||
await Promise.all(updatePromises)
|
||||
})
|
||||
}
|
||||
|
||||
const fruitful = Array.from(noteImpactMap.values()).filter(n => n.acceptedCount > 0).length
|
||||
|
||||
@@ -153,14 +153,14 @@ Fais un résumé concis (max 200 mots) de cette conversation. Garde les informat
|
||||
})
|
||||
|
||||
messagesForModel = [
|
||||
{ role: 'system' as const, content: `Contexte de la conversation précédente:\n${newSummary.slice(0, 1000)}` },
|
||||
{ role: 'system', content: `Contexte de la conversation précédente:\n${newSummary.slice(0, 1000)}` },
|
||||
...incomingMessages.slice(-RECENT_KEEP),
|
||||
]
|
||||
] as any
|
||||
} else if (conversation.summary) {
|
||||
messagesForModel = [
|
||||
{ role: 'system' as const, content: `Contexte de la conversation précédente:\n${conversation.summary}` },
|
||||
{ role: 'system', content: `Contexte de la conversation précédente:\n${conversation.summary}` },
|
||||
...incomingMessages.slice(-RECENT_KEEP),
|
||||
]
|
||||
] as any
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[Chat] Summary generation failed, using full context:', e)
|
||||
|
||||
@@ -91,7 +91,7 @@ export async function PATCH(
|
||||
if (color !== undefined) updateData.color = color
|
||||
if (order !== undefined) updateData.order = order
|
||||
if (trashedAt !== undefined) updateData.trashedAt = trashedAt ? new Date(trashedAt) : null
|
||||
if (parentId !== undefined) updateData.parentId = parentId
|
||||
if (parentId !== undefined) updateData.parent = parentId ? { connect: { id: parentId } } : { disconnect: true }
|
||||
|
||||
if (trashedAt !== undefined) {
|
||||
const descendantIds = await getDescendantIds(id)
|
||||
|
||||
@@ -66,13 +66,13 @@ export async function GET(
|
||||
console.error('[network] NoteLink query failed:', err)
|
||||
}
|
||||
|
||||
const mapBacklink = (bl: (typeof backlinks)[number]) => ({
|
||||
const mapBacklink = (bl: any) => ({
|
||||
id: bl.id,
|
||||
note: bl.sourceNote,
|
||||
contextSnippet: bl.contextSnippet,
|
||||
createdAt: bl.createdAt,
|
||||
})
|
||||
const mapOutbound = (ol: (typeof outbound)[number]) => ({
|
||||
const mapOutbound = (ol: any) => ({
|
||||
id: ol.id,
|
||||
note: ol.targetNote,
|
||||
contextSnippet: ol.contextSnippet,
|
||||
|
||||
@@ -160,7 +160,7 @@ export async function POST(req: NextRequest) {
|
||||
links: n.links ?? undefined,
|
||||
trashedAt: parseDate(n.trashedAt),
|
||||
notebookId: n.notebookId ?? null,
|
||||
contentUpdatedAt: parseDate(n.contentUpdatedAt),
|
||||
contentUpdatedAt: parseDate(n.contentUpdatedAt) ?? undefined,
|
||||
updatedAt: new Date(),
|
||||
labelRelations: {
|
||||
set: validLabelIds.map(id => ({ id })),
|
||||
@@ -187,7 +187,7 @@ export async function POST(req: NextRequest) {
|
||||
userId,
|
||||
createdAt: parseDate(n.createdAt) ?? new Date(),
|
||||
updatedAt: parseDate(n.updatedAt) ?? new Date(),
|
||||
contentUpdatedAt: parseDate(n.contentUpdatedAt),
|
||||
contentUpdatedAt: parseDate(n.contentUpdatedAt) ?? undefined,
|
||||
labelRelations: {
|
||||
connect: validLabelIds.map(id => ({ id })),
|
||||
},
|
||||
@@ -211,7 +211,7 @@ export async function POST(req: NextRequest) {
|
||||
userId,
|
||||
createdAt: parseDate(n.createdAt) ?? new Date(),
|
||||
updatedAt: parseDate(n.updatedAt) ?? new Date(),
|
||||
contentUpdatedAt: parseDate(n.contentUpdatedAt),
|
||||
contentUpdatedAt: parseDate(n.contentUpdatedAt) ?? undefined,
|
||||
},
|
||||
})
|
||||
stats.notes++
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function POST(request: NextRequest) {
|
||||
// Store as a notification to the note owner + admin
|
||||
await prisma.notification.create({
|
||||
data: {
|
||||
userId: note.userId,
|
||||
userId: note.userId!,
|
||||
type: 'content_report',
|
||||
title: `Signalement : ${reason}`,
|
||||
message: details || `Un visiteur a signalé votre note publiée pour: ${reason}`,
|
||||
|
||||
@@ -149,8 +149,8 @@ export async function PUT(request: NextRequest) {
|
||||
if (content !== undefined) updateData.content = content
|
||||
if (color !== undefined) updateData.color = color
|
||||
if (type !== undefined) updateData.type = type
|
||||
if (checkItems !== undefined) updateData.checkItems = checkItems ?? null
|
||||
if (labels !== undefined) updateData.labels = labels ?? null
|
||||
if (checkItems !== undefined) updateData.checkItems = checkItems != null ? JSON.stringify(checkItems) : null
|
||||
if (labels !== undefined) updateData.labels = labels != null ? JSON.stringify(labels) : null
|
||||
if (isPinned !== undefined) updateData.isPinned = isPinned
|
||||
if (isArchived !== undefined) updateData.isArchived = isArchived
|
||||
if (images !== undefined) updateData.images = images ?? null
|
||||
|
||||
@@ -161,7 +161,7 @@ export async function GET() {
|
||||
})),
|
||||
brainstorms: brainstorms.map((b) => ({
|
||||
id: b.id,
|
||||
title: b.title,
|
||||
title: b.seedIdea,
|
||||
createdAt: b.createdAt,
|
||||
ideasCount: b.ideas.length,
|
||||
})),
|
||||
@@ -196,9 +196,9 @@ export async function GET() {
|
||||
|
||||
const canvasFolder = zip.folder('canvases')!
|
||||
for (const brainstorm of brainstorms) {
|
||||
const fileBase = uniqueBaseName(brainstorm.title || 'Untitled Brainstorm', brainstorm.id)
|
||||
const fileBase = uniqueBaseName(brainstorm.seedIdea || 'Untitled Brainstorm', brainstorm.id)
|
||||
|
||||
let canvasMd = `# Brainstorm Canvas: ${brainstorm.title || 'Untitled'}\n\n`
|
||||
let canvasMd = `# Brainstorm Canvas: ${brainstorm.seedIdea || 'Untitled'}\n\n`
|
||||
canvasMd += `- **Created At:** ${brainstorm.createdAt.toISOString()}\n`
|
||||
canvasMd += `- **Updated At:** ${brainstorm.updatedAt.toISOString()}\n`
|
||||
canvasMd += `- **Ideas Count:** ${brainstorm.ideas.length}\n\n`
|
||||
@@ -232,7 +232,7 @@ export async function GET() {
|
||||
}))
|
||||
|
||||
const offlineCanvases = brainstorms.map((b) => ({
|
||||
title: b.title || 'Untitled Brainstorm',
|
||||
title: b.seedIdea || 'Untitled Brainstorm',
|
||||
createdAt: b.createdAt.toISOString(),
|
||||
ideas: b.ideas.map((i) => ({
|
||||
title: i.title,
|
||||
@@ -499,7 +499,7 @@ export async function GET() {
|
||||
const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' })
|
||||
|
||||
const dateString = new Date().toISOString().split('T')[0]
|
||||
return new NextResponse(zipBuffer, {
|
||||
return new NextResponse(new Uint8Array(zipBuffer) as BodyInit, {
|
||||
headers: {
|
||||
'Content-Type': 'application/zip',
|
||||
'Content-Disposition': `attachment; filename="memento-workspace-export-${dateString}.zip"`,
|
||||
|
||||
Reference in New Issue
Block a user