import { type BroadcastDriver, type Broadcaster } from "laravel-echo"; export type Connection = Broadcaster[T]["public"] | Broadcaster[T]["private"] | Broadcaster[T]["presence"]; export type ChannelData = { count: number; connection: Connection; }; export type Channel = { name: string; id: string; visibility: "private" | "public" | "presence"; }; export type BroadcastNotification = TPayload & { id: string; type: string; }; export type Dependency = unknown; export type ChannelReturnType = V extends "presence" ? Broadcaster[T]["presence"] : V extends "private" ? Broadcaster[T]["private"] : Broadcaster[T]["public"]; export type ConfigDefaults = Record; export type ModelPayload = { model: T; connection: string | null; queue: string | null; afterCommit: boolean; }; export type ModelName = T extends `${infer _}.${infer U}` ? ModelName : T; type ModelEvent = "Retrieved" | "Creating" | "Created" | "Updating" | "Updated" | "Saving" | "Saved" | "Deleting" | "Deleted" | "Trashed" | "ForceDeleting" | "ForceDeleted" | "Restoring" | "Restored" | "Replicating"; export type ModelEvents = `.${ModelName}${ModelEvent}` | `${ModelName}${ModelEvent}`; /** * Global Events interface for type inference * Users can extend this in their .d.ts files to define event payload types * * @example * // In user's types/echo.d.ts file (simplest approach): * interface Events { * OrganizationUpdated: { * id: number; * name: string; * updated_at: string; * }; * UserCreated: { * id: number; * email: string; * name: string; * }; * } * * @example * // Alternative: Module augmentation * declare module '@laravel/echo-vue' { * interface Events { * OrganizationUpdated: { * id: number; * name: string; * updated_at: string; * }; * } * } */ declare global { interface Events { } } /** * Type alias for event names - helps with autocomplete suggestions */ export type EventName = keyof Events & string; /** * Type utility to infer payload type from event name */ export type InferEventPayload = TEvent extends keyof Events ? Events[TEvent] : unknown; export {};