import { BaseError, EngineEvent, EngineEventType, FlowNodeInstance, FlowNodeInstanceState, LogLevel, Logger, Model, Subscription } from '@5minds/processcube_engine_sdk';
import { DataObjectValueCollection, FlowNodeInstanceTypeSpecificData, OnInterruptionCallback } from '../../Contracts/InternalDataModels/index';
import { FlowNodeInstanceDatabaseAdapter } from '../../Tools/DatabaseAdaptersSequelize/index';
import { EventMiddlewareHandler } from '../../Tools/EventMiddlewareHandler';
import { ProcessInstance } from '../ProcessInstance';
import { FlowNodeHandlerFactory } from './FlowNodeHandlerFactory';
export type InternalEngineEvent = Omit<EngineEvent, 'executeRuntimeExpression'>;
export declare abstract class FlowNodeHandler<TFlowNode extends Model.Base.FlowNode> {
    protected readonly flowNode: TFlowNode;
    protected readonly processInstance: ProcessInstance;
    protected set flowNodeInstanceId(value: string);
    protected get flowNodeInstanceId(): string;
    protected previousFlowNodeInstanceId: string;
    protected state: FlowNodeInstanceState;
    protected processToken: Record<string, any>;
    protected processEventSubscriptions: Array<Subscription>;
    protected flowNodeHandlerFactory: FlowNodeHandlerFactory;
    protected flowNodeInstanceAdapter: FlowNodeInstanceDatabaseAdapter;
    protected eventMiddlewareHandler: EventMiddlewareHandler;
    protected logger: Logger;
    protected startedAt: Date;
    protected finishedAt: Date;
    private _flowNodeInstanceId;
    private loggingMetaData;
    private interruptionCallback;
    constructor(eventMiddlewareHandler: EventMiddlewareHandler, flowNodeHandlerFactory: FlowNodeHandlerFactory, flowNodeInstanceAdapter: FlowNodeInstanceDatabaseAdapter, flowNode: TFlowNode, processInstance: ProcessInstance, namespace: string);
    /**
     * Gets the callback that gets called when the Flow Node was interrupted.
     * This happens, when an interrupting Boundary Event was triggered, or the Process Instance gets terminated.
     */
    protected get onInterruptedCallback(): OnInterruptionCallback;
    protected set onInterruptedCallback(value: OnInterruptionCallback);
    getInstanceId(): string;
    getFlowNode(): TFlowNode;
    abstract execute(previousFlowNodeInstanceId?: string, previousResult?: any, executionCanceledCallback?: Function, triggeredByFlowNodeInstanceId?: string): Promise<void>;
    abstract resume(flowNodeInstanceForHandler: FlowNodeInstance, allFlowNodeInstances: Array<FlowNodeInstance>, executionCanceledCallback?: Function): Promise<void>;
    cancel(processToken: Record<string, any>): Promise<void>;
    protected beforeExecute(): Promise<void>;
    protected afterExecute(): Promise<void>;
    /**
     * Hook for triggering Flow Node execution. Includes "beforeExecute" and "afterExecute" hooks.
     */
    protected abstract startExecution(executionCanceledCallback?: Function): Promise<Array<Model.Base.FlowNode>>;
    /**
     * Hook for triggering Flow Node resumption. Includes "beforeExecute" and "afterExecute" hooks.
     */
    protected abstract resumeFromState(flowNodeInstance: FlowNodeInstance, processFlowNodeInstances?: Array<FlowNodeInstance>, resumptionCanceledCallback?: Function): Promise<Array<Model.Base.FlowNode>>;
    /**
     * Hook for resuming a Flow Node Handler that is currently in a suspended state.
     */
    protected resumeAfterSuspend(flowNodeInstance: FlowNodeInstance, resumptionCanceledCallback?: Function): Promise<Array<Model.Base.FlowNode>>;
    /**
     * Main hook for executing and a FlowNode type specific handler.
     */
    protected executeHandler(resumptionCanceledCallback?: Function): Promise<Array<Model.Base.FlowNode>>;
    protected persistOnEnter<TFlowNodeData extends FlowNodeInstanceTypeSpecificData>(previousFlowNodeInstanceIds?: Array<string>, typeData?: TFlowNodeData): Promise<void>;
    protected persistOnSuspend<TFlowNodeData extends FlowNodeInstanceTypeSpecificData>(updatedTokenPayload?: any, typeData?: TFlowNodeData): Promise<void>;
    protected persistOnExit<TFlowNodeData extends FlowNodeInstanceTypeSpecificData>(typeData?: TFlowNodeData): Promise<void>;
    protected persistOnCancel<TFlowNodeData extends FlowNodeInstanceTypeSpecificData>(typeData?: TFlowNodeData): Promise<void>;
    protected persistOnTerminate<TFlowNodeData extends FlowNodeInstanceTypeSpecificData>(typeData?: TFlowNodeData): Promise<void>;
    protected persistOnError<TFlowNodeData extends FlowNodeInstanceTypeSpecificData>(error: BaseError, typeData?: TFlowNodeData): Promise<void>;
    protected subscribeToProcessKilledEvent(rejectionFunction: Function): Subscription;
    protected subscribeToProcessError(rejectionFunction: Function): Subscription;
    protected subscribeToTerminateEndEventReached(resolveFunction: Function): Subscription;
    protected subscribeToMiddlewareEvent(): void;
    protected handleNextFlowNode(nextFlowNode: Model.Base.FlowNode, allFlowNodeInstancesToResume?: Array<FlowNodeInstance>): Promise<void>;
    protected findNextFlowNodeInstance(allFlowNodeInstances: Array<FlowNodeInstance>, nextFlowNodeId: string): FlowNodeInstance;
    protected handleError(error: BaseError, resolveCallback: Function, rejectCallback: Function): Promise<void>;
    protected ensureHasClaim(): void;
    /**
     * Executes all expressions for updating some meta property on the containing ProcessInstance.
     * For example "engine.setProcessInstanceMetadata.propertyName" or "engine.setCorrelationMetadata.propertyName".
     *
     * These expressions can be found within the FlowNode's extension properties.
     *
     * @async
     */
    protected executeRuntimePropertyExpressionsOnFlowNode(): Promise<Record<'correlationMetdata' | 'processInstanceMetadata', any>>;
    protected postEventToEventMiddlewares(payload: InternalEngineEvent): Promise<void>;
    private setCorrelationMetadata;
    private setProcessInstanceMetadata;
    private runPreScript;
    protected runPostScript(): Promise<void>;
    protected runOutgoingDataObjectExpressions(): Promise<DataObjectValueCollection>;
    private parseDataObjectExpression;
    protected logFlowNodePersistenceEvent(eventType: EngineEventType, logLevel: LogLevel, additionalData?: Record<string, any>): Promise<void>;
    private publishProcessInstanceMetadataChangedNotification;
    private publishCorrelationMetadataChangedNotification;
}
