@5minds/processcube_engine
Version:
The ProcessCube Engine. Stores and executes BPMNs.
84 lines (83 loc) • 5.01 kB
TypeScript
import { FlowNodeInstance, FlowNodeInstanceState, Logger, Model } from '@5minds/processcube_engine_sdk';
import { FlowNodeInstanceTypeSpecificData } from '../../../Contracts/InternalDataModels/index';
import { FlowNodeInstanceDatabaseAdapter } from '../../../Tools/DatabaseAdaptersSequelize/index';
import { EventMiddlewareHandler } from '../../../Tools/EventMiddlewareHandler';
import { ProcessInstance } from '../../ProcessInstance';
import { InternalEngineEvent } from '../FlowNodeHandler';
import { FlowNodeHandlerFactory } from '../FlowNodeHandlerFactory';
export type BoundaryEventTriggerData = {
boundaryInstanceId: string;
nextFlowNode: Model.Base.FlowNode;
interruptHandler: boolean;
canTriggerMultipleTimes: boolean;
eventPayload?: any;
};
export type BoundaryEventTriggerCallback = (data: BoundaryEventTriggerData) => void | Promise<void>;
/**
* The base implementation for a BoundaryEventHandler.
*/
export declare abstract class BoundaryEventHandler<TBoundaryEvent extends Model.Events.BoundaryEvent> {
protected attachedFlowNodeInstanceId: string;
protected readonly processInstance: ProcessInstance;
protected boundaryEventModel: TBoundaryEvent;
protected processToken: Record<string, any>;
protected flowNodeInstanceDatabaseAdapter: FlowNodeInstanceDatabaseAdapter;
protected eventMiddlewareHandler: EventMiddlewareHandler;
protected flowNodeHandlerFactory: FlowNodeHandlerFactory;
protected boundaryEventInstanceId: string;
protected flowNodeInstance?: FlowNodeInstance;
protected state: FlowNodeInstanceState;
protected logger: Logger;
eventWasTriggered: boolean;
protected executionPromise: {
promise: Promise<any>;
controller: AbortController;
isPending: boolean;
};
protected executionFinishCallback: Function;
protected startedAt: Date;
protected finishedAt: Date;
protected triggeredByFlowNodeInstanceId: string;
protected lastWrittenDataObjectValues: Record<string, any>;
constructor(eventMiddlewareHandler: EventMiddlewareHandler, flowNodeInstanceDatabaseAdapter: FlowNodeInstanceDatabaseAdapter, flowNodeHandlerFactory: FlowNodeHandlerFactory, boundaryEventModel: TBoundaryEvent, processInstance: ProcessInstance, processTokenOfAttachedFlowNode: Record<string, any>, namespace: string);
protected createExecutionPromise(executor: (resolve?: (value?: any) => void, reject?: (reason?: any) => void) => void): {
promise: Promise<any>;
controller: AbortController;
isPending: boolean;
};
protected get boundaryEventInstance(): FlowNodeInstance;
protected set boundaryEventInstance(boundaryEventInstance: FlowNodeInstance);
getInstanceId(): string;
getModelId(): string;
getModelName(): string;
getState(): FlowNodeInstanceState;
abstract execute(onTriggeredCallback: BoundaryEventTriggerCallback, attachedFlowNodeInstanceId: string, decoratedFlowNodeRejectFunc: Function): Promise<void>;
abstract resume(boundaryEventInstance: FlowNodeInstance, onTriggeredCallback: BoundaryEventTriggerCallback, attachedFlowNodeInstanceId: string, decoratedFlowNodeRejectFunc: Function, flowNodeInstances?: Array<FlowNodeInstance>): Promise<void>;
finish(): Promise<void>;
cancel(): Promise<void>;
getNextFlowNode(): Model.Base.FlowNode;
protected initialize(attachedFlowNodeInstanceId: string, boundaryEventInstance?: FlowNodeInstance, typeData?: FlowNodeInstanceTypeSpecificData): Promise<void>;
protected saveTokenInDataObjects(token: Record<string, any> | Array<any>, boundaryEventModelId: string): Promise<void>;
protected executeRuntimePropertyExpressionsOnFlowNode(): Promise<Record<'correlationMetdata' | 'processInstanceMetadata', any>>;
protected postEventToEventMiddlewares(payload: InternalEngineEvent): Promise<void>;
protected persistOnEnter(typeData?: FlowNodeInstanceTypeSpecificData): Promise<void>;
protected persistOnExit(): Promise<void>;
protected persistOnCancel(): Promise<void>;
protected persistOnError(error: Error): Promise<void>;
protected sendBoundaryEventWaitingNotification(eventName?: string): void;
protected sendBoundaryEventTriggeredNotification(eventName?: string): void;
protected sendBoundaryEventFinishedNotification(eventName?: string): void;
protected runPreScript(): Promise<void>;
protected runPostScript(): Promise<void>;
protected boundaryEventWasTriggered(flowNodeInstances: Array<FlowNodeInstance>): boolean;
protected handleNextFlowNodes(flowNodeInstances?: Array<FlowNodeInstance>): Promise<any>;
private setCorrelationMetadata;
private setProcessInstanceMetadata;
private logFlowNodePersistenceEvent;
private publishProcessInstanceMetadataChangedNotification;
private publishCorrelationMetadataChangedNotification;
private buildEventMessage;
private runOutgoingDataObjectExpressions;
private parseDataObjectExpression;
private persistDataObjectValues;
}