19 lines
667 B
TypeScript
19 lines
667 B
TypeScript
import z from "zod";
|
|
|
|
/**
|
|
* Zod schema for SSE events accepted by `SseService.broadcast`. `data`
|
|
* may be any JSON-serialisable value (object, array, string, number,
|
|
* boolean, null) so application payloads flow through without forcing
|
|
* callers to pre-stringify. The handler is responsible for JSON
|
|
* serialisation on the wire.
|
|
*/
|
|
export const SseEventSchema = z.object({
|
|
id: z.string().min(1).optional(),
|
|
event: z.string().min(1).optional(),
|
|
data: z.unknown(),
|
|
retry: z.number().int().positive().optional(),
|
|
});
|
|
|
|
export type SseEventInputParsed = z.input<typeof SseEventSchema>;
|
|
export type SseEventResolved = z.output<typeof SseEventSchema>;
|