Files
aigen/server/api/library/stills/[id].patch.ts
T
TowstyandCursor e89b47b5f9 Add same-mode extra passes to Image v2, and hide Shot script from image Recommend.
Library tiles show a check when selected, and xAIGen can hide a preview from the details pane.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-30 18:17:17 -05:00

26 lines
1.2 KiB
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; hideInput?: boolean }>(event).catch(() => ({} as { folderId?: string; name?: string; family?: boolean; hideInput?: boolean }))
const folderId = String(body?.folderId || '')
const hasName = typeof body?.name === 'string'
const family = body?.family === true
const hasHide = typeof body?.hideInput === 'boolean'
if (!folderId && !hasName && !hasHide) {
throw createError({ statusCode: 400, statusMessage: 'Choose a library folder or a new name' })
}
const still = getStill(owner, id)
assertFolderAccess(event, still.folderId)
if (folderId) {
assertFolderExists(event, folderId)
if (family) await moveStillFamily(owner, id, folderId)
else await moveStill(owner, id, folderId)
}
if (hasName) {
if (family) await renameStillFamily(owner, id, body.name || '')
else await renameStill(owner, id, body.name || '')
}
if (hasHide) setStillHidden(owner, id, body.hideInput === true)
return publicLibrary(event)
})