import { z } from 'zod'; /** * Page schemas and views shared between api and web (issue #23). A page * carries a Yjs document from day one (ADR 0003); in M2 its state is * saved wholesale over REST as a base64 string. */ export const pageTitleSchema = z .string() .trim() .min(1, 'validation.required') .max(200, 'validation.tooLong'); export const pageSlugSchema = z .string() .trim() .min(1, 'validation.required') .max(60, 'validation.tooLong'); export const createPageInputSchema = z.object({ title: pageTitleSchema, }); export type CreatePageInput = z.infer; export const updatePageInputSchema = z .object({ title: pageTitleSchema, slug: pageSlugSchema, }) .partial(); export type UpdatePageInput = z.infer; export const savePageStateInputSchema = z.object({ /** Base64-encoded Yjs state (`Y.encodeStateAsUpdate`). */ state: z.string().min(1, 'validation.required'), }); export type SavePageStateInput = z.infer; /** Max Yjs document size (operations.md §Limits) — a fixed operational * ceiling, not a per-pond/user quota. */ export const MAX_PAGE_DOCUMENT_BYTES = 5 * 1024 * 1024; export interface PageView { id: string; pondId: string; title: string; slug: string; sortKey: string; createdAt: string; updatedAt: string; deletedAt: string | null; } /** What `GET /pages/:id` returns: page meta plus its base64 Yjs state. */ export interface PageStateView extends PageView { state: string; }