fix: update masonry grid sizing logic and notebook list padding

This commit is contained in:
Sepehr Ramezani
2026-02-14 14:20:32 +01:00
parent a0ffc9043b
commit 8f9031f076
580 changed files with 9789 additions and 42619 deletions

View File

@@ -0,0 +1,25 @@
import { prisma } from '../lib/prisma'
async function main() {
console.log('🔍 Checking users in database...')
console.log('Database URL used:', process.env.DATABASE_URL || "file:./dev.db")
const users = await prisma.user.findMany()
if (users.length === 0) {
console.log('❌ No users found in database!')
} else {
console.log(`✅ Found ${users.length} users:`)
console.table(users.map(u => ({
email: u.email,
role: u.role,
id: u.id,
hasPassword: !!u.password
})))
}
}
main()
.catch(e => console.error(e))
.finally(async () => await prisma.$disconnect())

View File

@@ -0,0 +1,41 @@
import { siteConfig } from '../config/site'
import { PrismaClient } from '@prisma/client'
async function main() {
console.log('🕵️‍♀️ Comparing Databases...')
// 1. Check Root DB
console.log('--- ROOT DB (./dev.db) ---')
const prismaRoot = new PrismaClient({
datasources: { db: { url: 'file:./dev.db' } }
})
try {
const countRoot = await prismaRoot.note.count()
console.log(`📦 Note Count: ${countRoot}`)
const usersRoot = await prismaRoot.user.count()
console.log(`👥 User Count: ${usersRoot}`)
} catch (e) {
console.log('❌ Failed to connect to Root DB', e)
} finally {
await prismaRoot.$disconnect()
}
// 2. Check Prisma Folder DB
console.log('\n--- PRISMA DB (./prisma/dev.db) ---')
const prismaPrisma = new PrismaClient({
datasources: { db: { url: 'file:./prisma/dev.db' } }
})
try {
const countPrisma = await prismaPrisma.note.count()
console.log(`📦 Note Count: ${countPrisma}`)
const usersPrisma = await prismaPrisma.user.count()
console.log(`👥 User Count: ${usersPrisma}`)
} catch (e) {
console.log('❌ Failed to connect to Prisma DB', e)
} finally {
await prismaPrisma.$disconnect()
}
}
main().catch(console.error)

View File

@@ -0,0 +1,36 @@
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())

View File

@@ -0,0 +1,24 @@
import { prisma } from '../lib/prisma'
async function main() {
console.log('👑 Granting ADMIN access to ALL users...')
try {
const result = await prisma.user.updateMany({
data: {
role: 'ADMIN'
}
})
console.log(`✅ Success! Updated ${result.count} users to ADMIN role.`)
} catch (error) {
console.error('❌ Error updating users:', error)
process.exit(1)
}
}
main()
.catch(e => console.error(e))
.finally(async () => await prisma.$disconnect())

View File

@@ -0,0 +1,36 @@
import { prisma } from '../lib/prisma'
import bcrypt from 'bcryptjs'
async function main() {
const email = 'test@example.com'
const newPassword = 'password123'
console.log(`Resetting password for ${email}...`)
const hashedPassword = await bcrypt.hash(newPassword, 10)
try {
const user = await prisma.user.update({
where: { email },
data: {
password: hashedPassword,
resetToken: null,
resetTokenExpiry: null
},
})
console.log(`✅ Password successfully reset for ${user.email}`)
} catch (error) {
console.error('❌ Error resetting password:', error)
process.exit(1)
}
}
main()
.catch(e => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})

View File

@@ -0,0 +1,63 @@
import { prisma } from '../lib/prisma'
// Copy of parseNote from app/actions/notes.ts (since it's not exported)
function parseNote(dbNote: any) {
const embedding = dbNote.embedding ? JSON.parse(dbNote.embedding) : null
if (embedding && Array.isArray(embedding)) {
// Simplified validation check for test
if (embedding.length !== 1536 && embedding.length !== 768 && embedding.length !== 384) {
return {
...dbNote,
checkItems: dbNote.checkItems ? JSON.parse(dbNote.checkItems) : null,
labels: dbNote.labels ? JSON.parse(dbNote.labels) : null,
images: dbNote.images ? JSON.parse(dbNote.images) : null,
links: dbNote.links ? JSON.parse(dbNote.links) : null,
embedding: null,
sharedWith: dbNote.sharedWith ? JSON.parse(dbNote.sharedWith) : [],
size: dbNote.size || 'small',
}
}
}
return {
...dbNote,
checkItems: dbNote.checkItems ? JSON.parse(dbNote.checkItems) : null,
labels: dbNote.labels ? JSON.parse(dbNote.labels) : null,
images: dbNote.images ? JSON.parse(dbNote.images) : null,
links: dbNote.links ? JSON.parse(dbNote.links) : null,
embedding,
sharedWith: dbNote.sharedWith ? JSON.parse(dbNote.sharedWith) : [],
size: dbNote.size || 'small',
}
}
async function main() {
console.log('🧪 Testing parseNote logic...')
// 1. Fetch a real note from DB that is KNOWN to be large
const rawNote = await prisma.note.findFirst({
where: { size: 'large' }
})
if (!rawNote) {
console.error('❌ No large note found in DB. Create one first.')
return
}
console.log('📊 Raw Note from DB:', { id: rawNote.id, size: rawNote.size })
// 2. Pass it through parseNote
const parsed = parseNote(rawNote)
console.log('🔄 Parsed Note:', { id: parsed.id, size: parsed.size })
if (parsed.size === 'large') {
console.log('✅ parseNote preserves size correctly.')
} else {
console.error('❌ parseNote returned wrong size:', parsed.size)
}
}
main().catch(console.error).finally(() => prisma.$disconnect())

View File

@@ -0,0 +1,56 @@
import { prisma } from '../lib/prisma'
import { updateSize } from '../app/actions/notes'
async function main() {
console.log('🧪 Starting Note Size Persistence Verification...')
// 1. Create a test note
const note = await prisma.note.create({
data: {
content: 'Size Test Note',
userId: (await prisma.user.findFirst())?.id || '',
size: 'small', // Start small
}
})
console.log(`📝 Created test note (${note.id}) with size: ${note.size}`)
if (!note.userId) {
console.error('❌ No user found to create note. Aborting.')
return
}
try {
// 2. Update size to LARGE
console.log('🔄 Updating size to LARGE...')
// We mock the session for the action or call prisma directly if action fails (actions usually need auth context)
// Since we're running as script, we'll use prisma update directly to simulate what the action does at DB level
// OR we can try to invoke the action if we can mock auth.
// Let's test the DB interaction first which is the critical "persistence" part.
await prisma.note.update({
where: { id: note.id },
data: { size: 'large' }
})
// 3. Fetch back
const updatedNote = await prisma.note.findUnique({ where: { id: note.id } })
console.log(`🔍 Fetched note after update. Size is: ${updatedNote?.size}`)
if (updatedNote?.size === 'large') {
console.log('✅ BACKEND PERSISTENCE: PASSED')
} else {
console.error('❌ BACKEND PERSISTENCE: FAILED (Size reverted or did not update)')
}
} catch (error) {
console.error('❌ Error during test:', error)
} finally {
// Cleanup
await prisma.note.delete({ where: { id: note.id } })
console.log('🧹 Cleaned up test note')
await prisma.$disconnect()
}
}
main().catch(console.error)