import BullQueue from 'bull'; import { Subject } from 'rxjs'; import { AbstractAuthUser } from '../auth/base.entities'; import { IAsunaAction, IAsunaCommand, IAsunaEvent, IAsunaRule } from './interfaces'; export declare const AsunaSystemQueue: { UPLOAD: string; IN_MEMORY_UPLOAD: string; IN_MEMORY_JOB: string; }; export declare class AsunaEvent implements IAsunaEvent { payload: any; source: string; name: string; type: string; createdAt: any; createdBy: any; rules: IAsunaRule[]; identifier: any; constructor(opts: { payload: any; source: string; name: string; type?: any; user?: AbstractAuthUser; identifier?: any; }); } export declare type AsunaQueue = { name: string; opts?: BullQueue.QueueOptions; queue: BullQueue.Queue; handle?: (payload: any) => Promise; }; export declare type EventRuleResolver = { identifier: { version: 'default/v1alpha'; type: 'EventRule'; }; resolve: (event: IAsunaEvent) => IAsunaAction[]; }; export declare type CommandResolver = { identifier: { version: 'default/v1alpha'; type: 'Command'; }; resolve: (command: IAsunaCommand) => IAsunaEvent[]; }; export declare class HermesExchange { private static _commands; private static _resolvers; private static _eventRules; static get resolvers(): { [key: string]: CommandResolver; }; static regCommandResolver(key: string, commandResolver: CommandResolver): void; static regEventRule(key: string, eventRuleResolver: EventRuleResolver): void; } export declare class Hermes { private static subject; private static observers; private static initialized; private static instance; private static queues; private static inMemoryQueues; constructor(); initialize(): void; static emitEvents(source: string, events: IAsunaEvent[]): void; static emit(source: string, event: string, payload: any, extras?: { identifier?: any; user?: AbstractAuthUser; type?: string; }): void; static regInMemoryQueue(queueName: string): InMemoryAsunaQueue; static getInMemoryQueue(queueName: string): InMemoryAsunaQueue; static regQueue(queueName: string, opts?: BullQueue.QueueOptions): AsunaQueue; static getQueue(queueName: string): AsunaQueue; /** * return index * @param queueName * @param handle */ static setupJobProcessor(queueName: string, handle: (payload: any) => Promise): void; static subscribe(source: string, routePattern: 'fanout' | RegExp, next?: (event: IAsunaEvent) => void): void; } export declare class HermesProcessManager { static initialized: boolean; static queue: InMemoryAsunaQueue; static start(): void; static handleCommand(command: IAsunaCommand): void; static dispatch(event: IAsunaEvent): void; } export declare class AsunaDefaultEvent implements IAsunaEvent { createdAt: any; createdBy: any; name: string; payload: any; rules: IAsunaRule[]; source: string; type: string; constructor(name: string, source: string, type: string, data: any, process: (data: any) => Promise); } export interface InMemoryAsunaQueue { name: string; queue: Subject; next: (data: any) => { jobId: string; }; handle?: (payload: any) => Promise; status?: { [jobId: string]: { state: string; events: any[]; }; }; }