import { EffectMethod } from './effect'; import { Metadata } from './metadata'; import { GrpcStatus } from './grpc-status'; /** * Side effect for a reply. * * @public */ export declare class Effect { readonly method: EffectMethod; readonly message: any; readonly synchronous: boolean; readonly metadata?: Metadata | undefined; /** * @param method - the entity service method to invoke * @param message - the message to send to that service * @param synchronous - whether the effect should be execute synchronously or not, default is false * @param metadata - metadata to send with the effect */ constructor(method: EffectMethod, message: any, synchronous?: boolean, metadata?: Metadata | undefined); } /** * A return type to allow returning forwards or failures, and attaching effects to messages. * * @typeParam Message - the type of the reply message * * @public */ export declare class Reply { private method?; private message?; private metadata?; private forward?; private failure?; private effects; constructor(method?: EffectMethod | undefined, message?: Message | undefined, metadata?: Metadata | undefined, forward?: Reply | undefined, failure?: Failure | undefined, effects?: Effect[]); /** * Create a message reply. * * @typeParam Message - the type of the reply message * @param message - the message to reply with * @param metadata - optional metadata to pass with the reply * @returns a message reply */ static message(message: Message, metadata?: Metadata): Reply; /** * Create a forward reply. * * @typeParam Message - the type of the reply message * @param method - the service call representing the forward * @param message - the message to forward * @param metadata - optional metadata to pass with the forwarded message * @returns a forward reply */ static forward(method: EffectMethod, message: any, metadata?: Metadata): Reply; /** * Create a failure reply. * * @typeParam Message - the type of the reply message * @param description - description of the failure * @param status - the GRPC status, defaults to Unknown * @returns a failure reply */ static failure(description: string, status?: GrpcStatus): Reply; /** * Create a reply that contains neither a message nor a forward nor a failure. * * This may be useful for emitting effects while sending an empty message. * * @typeParam Message - the type of the reply message * @returns an empty reply */ static empty(): Reply; /** * @returns the protobuf method for a forwarding reply */ getMethod(): EffectMethod | undefined; /** * Set the protobuf service method for a forwarding reply. * * @param method - the protobuf service method * @returns the updated reply */ setMethod(method: EffectMethod): Reply; /** * @returns the reply message */ getMessage(): Message | undefined; /** * Set the message for this reply. * @param message - the reply message * @returns the updated reply */ setMessage(message: Message): Reply; /** * @returns the metadata attached to the reply */ getMetadata(): Metadata | undefined; /** * Attach metadata to this reply. * * @param metadata - metadata to send with the reply * @returns the updated reply */ setMetadata(metadata?: Metadata): Reply; /** * @returns the forwarding reply */ getForward(): Reply | undefined; /** * Make this a forwarding reply. * * @param forward - the forward reply * @returns the updated reply */ setForward(forward: Reply): Reply; /** * @returns the failure */ getFailure(): Failure | undefined; /** * Make this a failure reply. * * @param description - the failure description * @param status - the status code to fail with, defaults to Unknown. * @returns the updated reply */ setFailure(description: string, status?: GrpcStatus): Reply; /** * @returns the side effects for this reply */ getEffects(): Effect[]; /** * Attach the given effect to this reply. * * @param method - the entity service method to invoke * @param message - the message to send to that service * @param synchronous - whether the effect should be execute synchronously or not, default is false * @param metadata - metadata to send with the effect * @returns this reply after adding the effect */ addEffect(method: EffectMethod, message: any, synchronous?: boolean, metadata?: Metadata | undefined): Reply; /** * Attach the given effects to this reply. * * @param effects - service calls to execute as side effects * @returns this reply after adding the effects */ addEffects(effects: Effect[]): Reply; /** * Whether this reply is empty: does not have a message, forward, or failure. * * @returns whether the reply is empty */ isEmpty(): boolean; } /** * Create a message reply. * * @typeParam Message - the type of the reply message * @param message - the message to reply with * @param metadata - optional metadata to pass with the reply * @returns a message reply * * @see also provided by {@link Reply.message} * * @public */ export declare function message(message: Message, metadata?: Metadata): Reply; /** * Create a forward reply. * * @typeParam Message - the type of the reply message * @param method - the service call representing the forward * @param message - the message to forward * @param metadata - optional metadata to pass with the forwarded message * @returns a forward reply * * @see also provided by {@link Reply.forward} * * @public */ export declare function forward(method: EffectMethod, message: any, metadata?: Metadata): Reply; /** * Create a failure reply. * * @typeParam Message - the type of the reply message * @param description - description of the failure * @param status - the GRPC status, defaults to Unknown * @returns a failure reply * * @see also provided by {@link Reply.failure} * * @public */ export declare function failure(description: string, status?: GrpcStatus): Reply; /** * Create a reply that contains neither a message nor a forward nor a failure. * * This may be useful for emitting effects while sending an empty message. * * @typeParam Message - the type of the reply message * @returns an empty reply * * @see also provided by {@link Reply.empty} * * @public */ export declare function emptyReply(): Reply; /** @public */ export declare class Failure { private description; private status?; constructor(description: string, status?: GrpcStatus | undefined); getDescription(): string; getStatus(): GrpcStatus | undefined; }