import { Type } from '@nestjs/common'; import { ModuleRef } from '@nestjs/core'; import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper'; import 'reflect-metadata'; import { Command } from './classes'; import { CqrsModuleOptions, ICommand, ICommandBus, ICommandHandler, ICommandPublisher } from './interfaces/index'; import { AsyncContext } from './scopes/async.context'; import { ObservableBus } from './utils/observable-bus'; export type CommandHandlerType = Type>; /** * @publicApi */ export declare class CommandBus extends ObservableBus implements ICommandBus { private readonly moduleRef; private readonly options?; private readonly logger; private handlers; private _publisher; constructor(moduleRef: ModuleRef, options?: CqrsModuleOptions | undefined); /** * Returns the publisher. * Default publisher is `DefaultCommandPubSub` (in memory). */ get publisher(): ICommandPublisher; /** * Sets the publisher. * Default publisher is `DefaultCommandPubSub` (in memory). * @param _publisher The publisher to set. */ set publisher(_publisher: ICommandPublisher); /** * Executes a command. * @param command The command to execute. * @returns A promise that, when resolved, will contain the result returned by the command's handler. */ execute(command: Command): Promise; /** * Executes a command. * @param command The command to execute. * @param context The context to use. Optional. * @returns A promise that, when resolved, will contain the result returned by the command's handler. */ execute(command: Command, context?: AsyncContext): Promise; /** * Executes a command. * @param command The command to execute. * @param context The context to use. Optional. * @returns A promise that, when resolved, will contain the result returned by the command's handler. */ execute(command: T, context?: AsyncContext): Promise; bind(handler: InstanceWrapper>, id: string): void; register(handlers?: InstanceWrapper>[]): void; protected registerHandler(handler: InstanceWrapper>): void; private getCommandId; private getCommandName; private reflectCommandId; private useDefaultPublisher; }