Collapsed collection actions now move, rename, delete, and rerun every part so chains stay together. Identity mode follows the v2u3 Ref2VA picture wiring. Co-authored-by: Cursor <cursoragent@cursor.com>
24 lines
1010 B
TypeScript
24 lines
1010 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
const { owner } = assertLibraryOwner(event)
|
|
const id = String(getRouterParam(event, 'id') || '')
|
|
const body = await readBody<{ folderId?: string; name?: string; family?: boolean }>(event).catch(() => ({} as { folderId?: string; name?: string; family?: boolean }))
|
|
const folderId = String(body?.folderId || '')
|
|
const hasName = typeof body?.name === 'string'
|
|
const family = body?.family === true
|
|
if (!folderId && !hasName) {
|
|
throw createError({ statusCode: 400, statusMessage: 'Choose a library folder or a new name' })
|
|
}
|
|
const clip = getClip(owner, id)
|
|
assertFolderAccess(event, clip.folderId)
|
|
if (folderId) {
|
|
assertFolderExists(event, folderId)
|
|
if (family) await moveClipFamily(owner, id, folderId)
|
|
else await moveClip(owner, id, folderId)
|
|
}
|
|
if (hasName) {
|
|
if (family) await renameClipFamily(owner, id, body.name || '')
|
|
else await renameClip(owner, id, body.name || '')
|
|
}
|
|
return publicLibrary(event)
|
|
})
|