Initial Commit
This commit is contained in:
18
packages/api-stack/api/api-plugin-sse/src/schemas/event.ts
Normal file
18
packages/api-stack/api/api-plugin-sse/src/schemas/event.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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>;
|
||||
Reference in New Issue
Block a user