import { randomUUID } from 'node:crypto' import { db } from '~/data/db' import { media, posts, type Media, type Post } from '~/data/schema' import { postTypeId } from './post-types' import type { EntryInput } from '~/lib/entry-types' export async function makeMedia(projectId: string, alt: string | null = 'Ein Bild'): Promise { const id = randomUUID() const rows = await db.insert(media).values({ id, projectId, kind: 'image', originalFilename: 'bild.png', path: `${projectId}/${id}/original.png`, mime: 'image/png', width: 1200, height: 800, byteSize: 2048, variants: [], alt, }).returning() return rows[0]! } export async function makePost(projectId: string, values: Partial = {}): Promise { const rows = await db.insert(posts).values({ projectId, number: 1, slug: 'ein-beitrag', title: 'Ein Beitrag', ...values, }).returning() return rows[0]! } export function entryInput(projectId: string, overrides: Partial = {}): EntryInput { return { projectId, title: 'Regel-Engine', teaser: 'Bedingung trifft Aktion.', typeId: postTypeId('feature'), audience: 'internal', coverMediaId: null, blocks: [{ type: 'text', data: { text: 'Der Worker prüft jede Bedingung.' } }], ...overrides, } }