feat(portfolio): add rendition management controls

This commit is contained in:
2026-02-12 22:50:18 +01:00
parent 697b3ab5e7
commit 81983cfe40
5 changed files with 67 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ export const mediaAssetTypeSchema = z.enum([
"generic",
])
export const artworkRenditionSlotSchema = z.enum(["thumbnail", "card", "full", "custom"])
export const artworkRenditionSlotSchema = z.enum(["thumbnail", "card", "full", "retina", "custom"])
export const createMediaAssetInputSchema = z.object({
id: z.string().uuid().optional(),

View File

@@ -24,6 +24,7 @@ export {
createGallery,
createMediaAsset,
createTag,
deleteArtworkRendition,
deleteGrouping,
deleteMediaAsset,
getMediaAssetById,

View File

@@ -33,10 +33,14 @@ export async function listArtworks(limit = 24) {
take: limit,
include: {
renditions: {
orderBy: [{ isPrimary: "desc" }, { updatedAt: "desc" }],
select: {
id: true,
slot: true,
mediaAssetId: true,
width: true,
height: true,
isPrimary: true,
},
},
galleryLinks: {
@@ -340,6 +344,12 @@ export async function attachArtworkRendition(input: unknown) {
})
}
export async function deleteArtworkRendition(id: string) {
return db.artworkRendition.delete({
where: { id },
})
}
export async function getMediaFoundationSummary() {
const [mediaAssets, artworks, galleries, albums, categories, tags] = await Promise.all([
db.mediaAsset.count(),
@@ -473,6 +483,7 @@ export async function listPublishedArtworks(input: ListPublishedArtworksInput =
isPublished: true,
},
},
orderBy: [{ isPrimary: "desc" }, { updatedAt: "desc" }],
include: {
mediaAsset: {
select: {
@@ -547,6 +558,7 @@ export async function getPublishedArtworkBySlug(slug: string) {
isPublished: true,
},
},
orderBy: [{ isPrimary: "desc" }, { updatedAt: "desc" }],
include: {
mediaAsset: {
select: {