import { Message , MessageAttributes } from '@node-ts/bus-messages' ; import { ClassConstructor } from '../util' ; /**
 * Defines the types of messages that the bus can handle
 */ export type MessageBase = Message | object ; /**
 * Implemented by a class to indicate it acts as a handler for a given message
 */ export interface Handler < TMessage extends MessageBase = MessageBase , TMessageAttributes extends MessageAttributes = MessageAttributes > { /**
     * The type of message the class handles
     */ messageType : ClassConstructor < TMessage > ; param message param attributes handle ( message , attributes ) : void | Promise < void > ; } export type FunctionHandler < TMessage extends MessageBase , TMessageAttributes extends MessageAttributes = MessageAttributes > = ( message : TMessage , attributes : TMessageAttributes ) => void | Promise < void > ; export type HandlerDefinition < TMessage extends MessageBase = MessageBase , TMessageAttributes extends MessageAttributes = MessageAttributes > = FunctionHandler < TMessage , TMessageAttributes > | ClassConstructor < Handler < TMessage , TMessageAttributes > > ; /**
 * A naive but best guess effort into if a handler is class based and should be resolved from a container
 */ export const isClassHandler = ( handler ) => handler . prototype ?. handle && handler . prototype ?. constructor ?. name ;