/** * Modifies an event key to reflect propagation by prefixing with the topic. */ export type PropagatedEventType = `${Topic}-${Type}`; /** * Modifies an event shape to reflect propagation to a parent topic. The 'type' field * is prefixed with the original topic, and a new property is added with the original topic's identity. */ export type PropagatedEvent = Event extends infer E extends { type: string; } ? Omit & { type: PropagatedEventType; } : never; /** * Handler for an event on an EventEmitter; selects the correct type for the event * payload from the provided union based on the provided string literal type. */ export type EventHandler = (payload: Extract, ...args: any[]) => void; export type BaseEvent = { topic: string; type: string; }; export type IdentityEvent = BaseEvent & { uuid: string; }; export type NamedEvent = IdentityEvent & { name: string; };