import * as z from "zod/mini"; /** * Monotonically increasing identifier for one protocol document generation. * Hosts use it to reject messages from replaced documents. */ export const generationSchema = z .number() .check(z.int(), z.minimum(0)) .brand("Generation"); export type Generation = z.output; export function createGeneration(value: number): Generation { const result = generationSchema.safeParse(value); if (!result.success) { throw new Error(`Invalid generation: ${value}`); } return result.data; }