import { z } from 'zod'; import { BackendEvent } from '../event'; /** * Enum of all possible consumable notification types received via WebSocket. * Now fully aligned with backend naming conventions. */ export declare enum ConsumableEvent { EVENT = "event", MISSED = "notifications_missed", SYNCHRONIZATION = "synchronization" } /** * Notification type for synchronization messages sent by the server * to indicate the end of the message queue at the time of connection. * * This message is **only included** if the client initiated the WebSocket * connection using a `sync_marker` query parameter. * @TODO when BackendEvent is typed in zod use: * export type ConsumableNotificationSynchronization = z.infer; */ export interface ConsumableNotificationSynchronization { /** * Always set to "synchronization" to distinguish from other message types. */ type: ConsumableEvent.SYNCHRONIZATION; data: { /** * Unique delivery tag assigned by the server for this synchronization message. * Must be acknowledged once processed to allow server-side cleanup. */ delivery_tag: number; /** * Unique identifier (UUID) that matches the `sync_marker` value the client provided * during the WebSocket connection initiation. Used to ensure the message * corresponds to the current synchronization session. */ marker_id: string; }; } /** * Notification type received when the client has missed messages due to being offline too long. * Requires a full re-sync before consuming more notifications. * @TODO when BackendEvent is typed in zod use: * export type ConsumableNotificationMissed = z.infer; */ export interface ConsumableNotificationMissed { type: ConsumableEvent.MISSED; } /** * Notification type for actual backend events, contains one or more event payloads. * Includes a delivery tag for acknowledgment. * @TODO when BackendEvent is typed in zod use: * export type ConsumableNotificationEvent = z.infer; */ export interface ConsumableNotificationEvent { type: ConsumableEvent.EVENT; data: { delivery_tag: number; event: { id: string; payload: BackendEvent[]; }; }; } /** * Union of all valid notification types supported by the WebSocket backend. * @TODO when BackendEvent is typed in zod use: * export const ConsumableNotificationSchema = z.discriminatedUnion('type', [ * ConsumableNotificationMissedSchema, * ConsumableNotificationEventSchema, *. ConsumableNotificationSynchronization * ]); */ export type ConsumableNotification = ConsumableNotificationMissed | ConsumableNotificationEvent | ConsumableNotificationSynchronization; export declare const ConsumableNotificationSynchronizationSchema: z.ZodObject<{ type: z.ZodLiteral; data: z.ZodObject<{ delivery_tag: z.ZodNumber; marker_id: z.ZodString; }, "strip", z.ZodTypeAny, { delivery_tag: number; marker_id: string; }, { delivery_tag: number; marker_id: string; }>; }, "strip", z.ZodTypeAny, { type: ConsumableEvent.SYNCHRONIZATION; data: { delivery_tag: number; marker_id: string; }; }, { type: ConsumableEvent.SYNCHRONIZATION; data: { delivery_tag: number; marker_id: string; }; }>; export declare const ConsumableNotificationMissedSchema: z.ZodObject<{ type: z.ZodLiteral; }, "strip", z.ZodTypeAny, { type: ConsumableEvent.MISSED; }, { type: ConsumableEvent.MISSED; }>; export declare const ConsumableNotificationEventSchema: z.ZodObject<{ type: z.ZodLiteral; data: z.ZodObject<{ delivery_tag: z.ZodNumber; event: z.ZodObject<{ id: z.ZodString; payload: z.ZodArray; }, "strip", z.ZodTypeAny, { id: string; payload: unknown[]; }, { id: string; payload: unknown[]; }>; }, "strip", z.ZodTypeAny, { event: { id: string; payload: unknown[]; }; delivery_tag: number; }, { event: { id: string; payload: unknown[]; }; delivery_tag: number; }>; }, "strip", z.ZodTypeAny, { type: ConsumableEvent.EVENT; data: { event: { id: string; payload: unknown[]; }; delivery_tag: number; }; }, { type: ConsumableEvent.EVENT; data: { event: { id: string; payload: unknown[]; }; delivery_tag: number; }; }>; export declare const ConsumableNotificationSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ type: z.ZodLiteral; }, "strip", z.ZodTypeAny, { type: ConsumableEvent.MISSED; }, { type: ConsumableEvent.MISSED; }>, z.ZodObject<{ type: z.ZodLiteral; data: z.ZodObject<{ delivery_tag: z.ZodNumber; event: z.ZodObject<{ id: z.ZodString; payload: z.ZodArray; }, "strip", z.ZodTypeAny, { id: string; payload: unknown[]; }, { id: string; payload: unknown[]; }>; }, "strip", z.ZodTypeAny, { event: { id: string; payload: unknown[]; }; delivery_tag: number; }, { event: { id: string; payload: unknown[]; }; delivery_tag: number; }>; }, "strip", z.ZodTypeAny, { type: ConsumableEvent.EVENT; data: { event: { id: string; payload: unknown[]; }; delivery_tag: number; }; }, { type: ConsumableEvent.EVENT; data: { event: { id: string; payload: unknown[]; }; delivery_tag: number; }; }>, z.ZodObject<{ type: z.ZodLiteral; data: z.ZodObject<{ delivery_tag: z.ZodNumber; marker_id: z.ZodString; }, "strip", z.ZodTypeAny, { delivery_tag: number; marker_id: string; }, { delivery_tag: number; marker_id: string; }>; }, "strip", z.ZodTypeAny, { type: ConsumableEvent.SYNCHRONIZATION; data: { delivery_tag: number; marker_id: string; }; }, { type: ConsumableEvent.SYNCHRONIZATION; data: { delivery_tag: number; marker_id: string; }; }>]>; //# sourceMappingURL=ConsumableNotification.d.ts.map