feat(media): scaffold mvp1 media and portfolio foundation

This commit is contained in:
2026-02-11 22:46:24 +01:00
parent 5b47fafe89
commit d727ab8b5b
14 changed files with 674 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
import { PrismaPg } from "@prisma/adapter-pg"
import { PrismaClient } from "@prisma/client"
import { Pool } from "pg"
import { PrismaClient } from "../prisma/generated/client/client"
const connectionString = process.env.DATABASE_URL

View File

@@ -1,4 +1,5 @@
export { db } from "./client"
export { getMediaFoundationSummary, listArtworks, listMediaAssets } from "./media-foundation"
export {
createPost,
deletePost,

View File

@@ -0,0 +1,88 @@
import { db } from "./client"
export async function listMediaAssets(limit = 24) {
return db.mediaAsset.findMany({
orderBy: { updatedAt: "desc" },
take: limit,
})
}
export async function listArtworks(limit = 24) {
return db.artwork.findMany({
orderBy: { updatedAt: "desc" },
take: limit,
include: {
renditions: {
select: {
id: true,
slot: true,
mediaAssetId: true,
},
},
galleryLinks: {
include: {
gallery: {
select: {
id: true,
name: true,
slug: true,
},
},
},
},
albumLinks: {
include: {
album: {
select: {
id: true,
name: true,
slug: true,
},
},
},
},
categoryLinks: {
include: {
category: {
select: {
id: true,
name: true,
slug: true,
},
},
},
},
tagLinks: {
include: {
tag: {
select: {
id: true,
name: true,
slug: true,
},
},
},
},
},
})
}
export async function getMediaFoundationSummary() {
const [mediaAssets, artworks, galleries, albums, categories, tags] = await Promise.all([
db.mediaAsset.count(),
db.artwork.count(),
db.gallery.count(),
db.album.count(),
db.category.count(),
db.tag.count(),
])
return {
mediaAssets,
artworks,
galleries,
albums,
categories,
tags,
}
}

View File

@@ -5,7 +5,7 @@ import {
updatePostInputSchema,
} from "@cms/content"
import { type CrudAuditHook, type CrudMutationContext, createCrudService } from "@cms/crud"
import type { Post } from "@prisma/client"
import type { Post } from "../prisma/generated/client/client"
import { db } from "./client"