import { ConsumedEventMessage, EventConsumerClass } from "./types.mjs"; import { ObjectValidator, ValidationResult } from "@warlock.js/seal"; //#region ../@warlock.js/herald/src/message-managers/event-consumer.d.ts declare abstract class EventConsumer> { /** * Event name */ static eventName: string; private static _consumerId?; static get consumerId(): string; get eventName(): string; /** * Min version accepted to be consumed by this class */ static minVersion?: number; /** * Max version accepted to be consumed by this class */ static maxVersion?: number; /** * Payload validation to auto reject the received event before accessing it in the handle method */ schema?: ObjectValidator; /** * The method that will be called when the event is received */ abstract handle(payload: Payload, event: ConsumedEventMessage): Promise; /** * Determine whether this is accepted version to be used by this consumer */ static isAcceptedVersion(version: number): boolean; /** * Validate the given data */ validate(data: Payload): Promise; } /** * Define Consumer options */ type ConsumerOptions = { /** * Payload validation to auto reject the received event before accessing it in the handle method */ schema?: ObjectValidator; /** * Handle data */ handle: (payload: Payload, event: ConsumedEventMessage) => Promise; /** * Validate the payload before executing `handle` */ validate?: (payload: Payload) => Promise; }; /** * A shorthand to define an event consumer without declaring an entire class */ declare function defineConsumer>(eventName: string, options: ConsumerOptions): EventConsumerClass; //#endregion export { EventConsumer, defineConsumer }; //# sourceMappingURL=event-consumer.d.mts.map