Merge pull request 'fix: TypeScript error in import route - cast item to access id' (#6) from develop into main
Some checks failed
Personal/recall/pipeline/head There was a failure building this commit

Reviewed-on: #6
This commit was merged in pull request #6.
This commit is contained in:
2026-03-24 02:05:45 +00:00

View File

@@ -105,21 +105,22 @@ export async function POST(req: NextRequest) {
const createdAt = parseDate((item as { createdAt?: string }).createdAt) const createdAt = parseDate((item as { createdAt?: string }).createdAt)
const updatedAt = parseDate((item as { updatedAt?: string }).updatedAt) const updatedAt = parseDate((item as { updatedAt?: string }).updatedAt)
const itemWithId = item as { id?: string }
if (item.id) { if (itemWithId.id) {
const existing = await tx.note.findUnique({ where: { id: item.id } }) const existing = await tx.note.findUnique({ where: { id: itemWithId.id } })
if (existing) { if (existing) {
await tx.note.update({ await tx.note.update({
where: { id: item.id }, where: { id: itemWithId.id },
data: { ...noteData, createdAt, updatedAt }, data: { ...noteData, createdAt, updatedAt },
}) })
await tx.noteTag.deleteMany({ where: { noteId: item.id } }) await tx.noteTag.deleteMany({ where: { noteId: itemWithId.id } })
processed++ processed++
} else { } else {
await tx.note.create({ await tx.note.create({
data: { data: {
...noteData, ...noteData,
id: item.id, id: itemWithId.id,
createdAt, createdAt,
updatedAt, updatedAt,
creationSource: 'import', creationSource: 'import',
@@ -150,8 +151,8 @@ export async function POST(req: NextRequest) {
processed++ processed++
} }
const noteId = item.id const noteId = itemWithId.id
? (await tx.note.findUnique({ where: { id: item.id } }))?.id ? (await tx.note.findUnique({ where: { id: itemWithId.id } }))?.id
: (await tx.note.findFirst({ where: { title: item.title } }))?.id : (await tx.note.findFirst({ where: { title: item.title } }))?.id
if (noteId && tags.length > 0) { if (noteId && tags.length > 0) {