Executable BPMN 2 definition. Pass context and execute.
Arguments:
context: context instance, see Contextoptions: optional options that will be passed to environment
Returns api with properties:
id: definition idname: definition nametype: definition typelogger: logger instancecontext: passed contextcounters: countersexecutionId: current execution idstatus: statusexecution: current executionenvironment: definition environment instance, see EnvironmentisRunning: boolean indicating if the definition is runningactivityStatus: activity executing status. Can be used to decide when to save state,timerandwaitis recommended.idle: idle, not running anythingexecuting: at least one activity is executing, e.g. a service task making a asynchronous requesttimer: at least one activity is waiting for a timer to complete, usually only TimerEventDefinition'swait: at least one activity is waiting for a signal of some sort, e.g. user tasks, intermediate catch events, etc
broker: definition message broker
Run definition with optional options and/or callback. The callback will be called on error, when run completes, or run is stopped.
Arguments:
options: optional optionsprocessId: string with process id, run a specific process. Also works for a non-executable process
callback: optional callbackerr: occasional errorapi: api
Get activity by id
Shake out the sequences in processes starting with start events, or by declaring an activity.
Arguments:
activityId: optional activity id to shake out sequences from
Returns: Object with activity id(s) as property and sequences. The sequence property is an array since there can be looped sequences.
Delegate a signal message to all interested parties, usually MessageEventDefinition, SignalEventDefinition, SignalTask (user, manual), and ReceiveTask.
Arguments:
message: optional objectid: optional task/element id to signal, also matched with Message and Signal id. If not passed only anonymous Signal- and MessageEventDefinitions will pick up the signal.executionId: optional execution id to signal, specially for looped tasks, also works for signal tasks that are not looped[name]*: any other properties will be forwarded as message to activity
Delegate a cancel message to all interested parties.
Arguments:
message: optional objectid: optional task/element id to cancelexecutionId: optional execution id to cancel[name]*: any other properties will be forwarded as message to activity
Get list of elements that are in a postponed state.
Get all processes.
Get process by id.
Get all executable processes.
Get definition state.
Recover definition.
Arguments:
state: state from definitiongetState()
Returns definition.
Resume stopped or recovered definition with optional callback. The callback will be called on error, when run completes, or run is stopped.
Arguments:
callback: optional callbackerr: occasional errorapi: api
Returns definition.
Listen for events.
Arguments:
eventName: name of eventhandler: required function called when events occurapi: element api
eventOptions: passed to underlying broker as consume options
Listen for event.
Arguments:
eventName: name of eventhandler: required function called when event occurapi: element api
eventOptions: passed to underlying broker as consume options
Stop definition run.
Wait for event to occur as promised.
Arguments:
eventName: name of eventonMessage: optional message callback for event filtering purposes. Return false if the promise should not resolve. Called with the following argumentsroutingKey: broker message routing keymessage: actual message that match event nameowner: broker owner, in this case probably the actual definition
Returns Promise that will resolve with element api on event name or reject on error.