
import { getAllNotes } from '../app/actions/notes'
import { prisma } from '../lib/prisma'

async function main() {
    console.log('🕵️‍♀️ Debugging getAllNotes...')

    // 1. Get raw DB data for a sample note
    const rawNote = await prisma.note.findFirst({
        where: { size: { not: 'small' } }
    })

    if (rawNote) {
        console.log('📊 Raw DB Note (should be large/medium):', {
            id: rawNote.id,
            size: rawNote.size
        })
    } else {
        console.log('⚠️ No notes with size != small found in DB directly.')
    }

    // 2. Mock auth/session if needed (actions check session)
    // Since we can't easily mock next-auth in this script environment without setup,
    // we might need to rely on the direct DB check above or check if getAllNotes extracts userId safely.
    // getAllNotes checks `auth()`. In this script context, `auth()` will arguably return null.
    // So we can't easily run `getAllNotes` directly if it guards auth.

    // Let's modify the plan: We will check the DB directly to confirm PERMANENCE.
    // Then we will manually simulate `parseNote` logic.

    const notes = await prisma.note.findMany({ take: 5 })
    console.log('📋 Checking first 5 notes sizes in DB:')
    notes.forEach(n => console.log(`- ${n.id}: ${n.size}`))
}

main().catch(console.error).finally(() => prisma.$disconnect())
