Files
movies-diary/spa/src/lib/api/common.ts
Gabriel Kaszewski bb2001b9cc Add Spoiler Flag with veil, AP content-warning encoding, and full-stack plumbing
Authors can flag a review's comment as containing spoilers; the comment is
blurred behind a reveal control for every viewer except the author, omitted
from RSS, and federates as containsSpoilers plus an AP summary content
warning (ADR-0011) so Mastodon-class clients also collapse it. Flag follows
the general-edit path (ADR-0001) across domain, both DB backends, REST,
HTML templates, SPA (shadcn), TUI fixtures, and exports.
2026-10-17 21:12:56 +02:00

47 lines
1.2 KiB
TypeScript

import { z } from "zod"
export const movieDtoSchema = z.object({
id: z.string().uuid(),
title: z.string(),
release_year: z.number(),
director: z.string().optional(),
poster_path: z.string().optional(),
genres: z.array(z.string()),
runtime_minutes: z.number().optional(),
original_language: z.string().optional(),
overview: z.string().optional(),
collection_name: z.string().optional(),
})
export type MovieDto = z.infer<typeof movieDtoSchema>
export const reviewDtoSchema = z.object({
id: z.string().uuid(),
rating: z.number(),
comment: z.string().optional(),
watched_at: z.string(),
watch_medium: z.string().optional(),
spoilers: z.boolean().optional(),
})
export type ReviewDto = z.infer<typeof reviewDtoSchema>
export const diaryEntryDtoSchema = z.object({
movie: movieDtoSchema,
review: reviewDtoSchema,
})
export type DiaryEntryDto = z.infer<typeof diaryEntryDtoSchema>
export function paginatedSchema<T extends z.ZodType>(itemSchema: T) {
return z.object({
items: z.array(itemSchema),
total_count: z.number(),
limit: z.number(),
offset: z.number(),
})
}
export type Paginated<T> = {
items: T[]
total_count: number
limit: number
offset: number
}