feat(notes): vues structurées tableau/kanban, flashcards et MCP robuste
Some checks failed
CI / Lint, Test & Build (push) Failing after 57s
CI / Deploy production (on server) (push) Has been skipped

Ajoute la base organisable par carnet (schéma, champs partagés, valeurs par note)
avec activation guidée, tableau éditable, kanban et suppression de colonnes.
Corrige le multiselect en vue tableau et enrichit sidebar, grille et i18n FR/EN.
Inclut aussi les améliorations flashcards SM-2, l'audit consentement IA et la
robustesse du serveur MCP (config, validation, rate-limit, métriques).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Antigravity
2026-05-24 23:03:16 +00:00
parent ecd7e57c2e
commit 0784c94242
63 changed files with 10133 additions and 619 deletions

View File

@@ -5,10 +5,12 @@ export interface DeckSummary {
id: string
name: string
notebookId: string | null
notebookName: string | null
totalCards: number
dueCount: number
masteredCount: number
lastReviewedAt: string | null
nextReviewAt: string | null
createdAt: string
}
@@ -17,6 +19,7 @@ export async function listDeckSummaries(userId: string): Promise<DeckSummary[]>
const decks = await prisma.flashcardDeck.findMany({
where: { userId },
include: {
notebook: { select: { name: true } },
flashcards: {
select: {
id: true,
@@ -36,19 +39,27 @@ export async function listDeckSummaries(userId: string): Promise<DeckSummary[]>
return decks.map((deck) => {
const totalCards = deck.flashcards.length
const dueCount = deck.flashcards.filter((c) => c.nextReviewAt <= now).length
const masteredCount = deck.flashcards.filter((c) => isCardMastered(c.interval)).length
// Maîtrisée = interval >= 7 jours (une semaine de bonne mémorisation)
const masteredCount = deck.flashcards.filter((c) => c.interval >= 7).length
const lastReview = deck.flashcards
.flatMap((c) => c.reviews.map((r) => r.reviewedAt))
.sort((a, b) => b.getTime() - a.getTime())[0]
// Date de la prochaine carte à réviser (la plus proche dans le futur)
const nextReviewAt = deck.flashcards
.map((c) => c.nextReviewAt)
.sort((a, b) => a.getTime() - b.getTime())[0] ?? null
return {
id: deck.id,
name: deck.name,
notebookId: deck.notebookId,
notebookName: deck.notebook?.name ?? null,
totalCards,
dueCount,
masteredCount,
lastReviewedAt: lastReview ? lastReview.toISOString() : null,
nextReviewAt: nextReviewAt ? nextReviewAt.toISOString() : null,
createdAt: deck.createdAt.toISOString(),
}
})

View File

@@ -1,4 +1,5 @@
import prisma from '@/lib/prisma'
import { prisma } from '@/lib/prisma'
import { Prisma } from '@prisma/client'
export async function getOrCreateDeckForNotebook(params: {
userId: string
@@ -28,6 +29,14 @@ export async function getOrCreateDeckForNotebook(params: {
notebookId,
name: notebook.name,
},
}).catch(async (error) => {
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === 'P2002') {
const raced = await prisma.flashcardDeck.findFirst({
where: { userId, notebookId },
})
if (raced) return raced
}
throw error
})
}