UNPKG

@4players/odin-common

Version:

Commonly used type definitions and utility functions across ODIN web projects

26 lines (25 loc) 1.15 kB
import type { infer as ZodInfer, ZodType } from 'zod'; import type { PeerUpdate } from './schema/peer.ts'; import type { MessageReceived } from './schema/message.ts'; import type { WebRtcUpdate } from './schema/webrtc.ts'; import type { RpcSchema } from './serialization.ts'; import { RoomV1 } from './schema/room.ts'; export type Notifications = Record<string, RpcSchema>; export type ParsedNotification<N extends Notifications, K extends keyof N = keyof N> = { [Name in K]: { name: Name; properties: ZodInfer<N[Name]>; }; }[K]; export declare function parseNotification<N extends Notifications, K extends keyof N>(name: K, properties: unknown, schema: N): ParsedNotification<N, K> | undefined; export type MainNotifications = { WebRtcUpdate: ZodType<WebRtcUpdate>; }; export declare const MainNotificationsRpc: MainNotifications; export type RoomNotifications = { RoomStatusChanged: ZodType<RoomV1.RoomStatusChanged>; RoomUpdated: ZodType<RoomV1.RoomUpdates>; PeerUpdated: ZodType<PeerUpdate>; MessageReceived: ZodType<MessageReceived>; }; export declare const RoomNotificationsRpc: RoomNotifications;