import { FlowNode } from 'bpmn-moddle'; import { SchedulerLike } from 'rxjs'; import BpmnProcessInstance from './BpmnProcessInstance'; import { ExportedProcessState, ProcessState } from './state/reducers'; import { LogState } from './state/reducers/log'; interface StartArgs { messageRef?: string; signalRef?: string; variables?: { [key: string]: { value: unknown; log?: { changedTime: number; changedBy?: string; oldValue?: any; newValue: any; }[]; }; }; token?: { [key: string]: any; }; } interface StartAtArgs { globalStartTime?: number; instanceId?: string; tokens: { tokenId?: string; currentFlowElementId: string; [key: string]: any; }[]; variables?: { [key: string]: { value: unknown; log?: { changedTime: number; changedBy?: string; oldValue?: any; newValue: any; }[]; }; }; log?: LogState; } interface ProcessHooks { shouldPassTokenHook?: (processId: string, processInstanceId: string, from: string, to: string, tokenId: string, state: ProcessState) => Promise; shouldActivateFlowNodeHook?: (processId: string, processInstanceId: string, tokenId: string, flowNode: FlowNode, state: ExportedProcessState) => Promise; sendSignalHook?: (processId: string, processInstanceId: string, signalId: string) => any; sendMessageHook?: (processId: string, processInstanceId: string, messageId: string) => any; } interface MigrationArgs { tokenMapping?: { add?: { targetFlowElementId: string; [key: string]: any; }[]; move?: { tokenId: string; targetFlowElementId: string; [key: string]: any; }[]; remove?: string[]; }; flowElementMapping?: { [sourceElementId: string]: string[]; }; } declare const STATIC_INITIALIZER: unique symbol; /** * @class BPMN process blueprint, which is responsible for instantiating * new process instances */ export default class BpmnProcess { private static processes; private static variablesService; /** * Run code here for global static init */ static [STATIC_INITIALIZER]: () => void; private id; private moddleDefinitions; private deployed; private hooks; private instance$; private constructor(); /** * Factory method to construct a BPMN Process Object from a BPMN XML * @param {string} id identifier of the process, will be prefixed to process instance id * @param {string} bpmnXml BPMN XML representation * @returns {Promise} a promise which eventually gives the initialized object of BpmnProcess * @throws {InvalidBpmnXmlError} Given XML should be a valid process */ static fromXml(id: string, bpmnXml: string, hooks?: ProcessHooks): Promise; /** * Get the id of the process * @return {string} id */ getId(): string; /** * Get the stream of instances to subscribe to */ getInstance$(): import("rxjs").Observable; /** * Get all the instances created so far * @returns {BpmnProcessInstance[]} array of instances created so far */ getAllInstances(): BpmnProcessInstance[]; /** * Get an instance by its id * @param {string} id id of the required instance */ getInstanceById(id: string): BpmnProcessInstance; /** * Delete an instance by its id * @param {string} id id of the instance to delete */ deleteInstanceById(id: string): void; /** * Marks the BPMN process ready to start instances. Auto-starts * the timer start event, listens for signals and messages in case * such start events are defined. If auto-starts are not defined, * a subsequent call to start() with optional message/signal is required * to create a new process instance. * TODO: Consider renaming this to start() */ deploy(): void; /** * Stop upcoming scheduled deployments. */ undeploy(): void; /** * @returns {boolean} true if process is ready to start instances else false. */ isDeployed(): boolean; /** * Start a new process instance with messageRef and initial variables. * @param {StartArgs} startArgs arguments for starting the process * @param {string} startArgs.messageRef optional string reference id of the message for the start event * @param {string} startArgs.signalRef optional string reference id of the signal for the start event * @param {object} startArgs.variables optional initial process variables * @param {object} startArgs.token optional initial attributes for token * @throws {BpmnProcessNotDeployedError} Instance can only be started when in deployed state * @throws {NoStartEventSpecifiedError} Start event should exist in bpmn * @throws {MessageRefNotFoundError} Given messageRef must exist in definition * @throws {SignalRefNotFoundError} Given signalRef must exist in definition */ start(startArgs?: StartArgs): BpmnProcessInstance; /** * Non-standard start at an arbitrary element with custom variables. Also use * the same method for multiple None start events. * @param {StartAtArgs} startAtArgs * @param {object} startAtArgs.tokens startElement and optional attributes of token * @param {object} startAtArgs.variables optional initial process variables * @param {string} startAtArgs.instanceId optional id of instance * @param {number} startAtArgs.globalStartTime optional global start time of instance * @param {object} startAtArgs.log optional log of already executed flownode elements of instance * @throws {BpmnElementNotFoundError} provided element id must exist */ startAt(startAtArgs: StartAtArgs): BpmnProcessInstance; /** * Convenience method for calling deploy and start together */ deployAndStart(args?: StartArgs): BpmnProcessInstance; /** * Convenience method for calling deploy and startAt together */ deployAndStartAt(args: StartAtArgs): BpmnProcessInstance; /** * Get flow elements from current moddle definition */ private getFlowElements; static migrate(currentProcessId: string, targetProcessId: string, instanceIds: string[], { tokenMapping, flowElementMapping }: MigrationArgs): void; /** * Reducer for internal redux store */ private storeReducer; /** * Keep track of instances */ private store; /** * Internal test, used for testing with virtual scheduler */ __deploy_scheduler__: SchedulerLike | undefined; __set_deploy_scheduler(scheduler: SchedulerLike): void; __restore_deploy_scheduler(): void; } export {}; //# sourceMappingURL=BpmnProcess.d.ts.map