bpmn-elements 5.1.3 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +322 -0
- package/README.md +9 -3
- package/dist/index.js +71 -39
- package/dist/src/Api.js +77 -76
- package/dist/src/Context.js +169 -164
- package/dist/src/Environment.js +90 -102
- package/dist/src/EventBroker.js +89 -88
- package/dist/src/ExtensionsMapper.js +2 -2
- package/dist/src/MessageFormatter.js +164 -95
- package/dist/src/Scripts.js +6 -2
- package/dist/src/Timers.js +4 -6
- package/dist/src/activity/Activity.js +1108 -901
- package/dist/src/activity/ActivityExecution.js +342 -297
- package/dist/src/activity/Dummy.js +3 -3
- package/dist/src/definition/Definition.js +498 -444
- package/dist/src/definition/DefinitionExecution.js +722 -409
- package/dist/src/error/Errors.js +17 -7
- package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
- package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
- package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
- package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
- package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
- package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
- package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
- package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
- package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
- package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
- package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
- package/dist/src/events/BoundaryEvent.js +180 -144
- package/dist/src/events/EndEvent.js +18 -23
- package/dist/src/events/IntermediateCatchEvent.js +44 -58
- package/dist/src/events/IntermediateThrowEvent.js +18 -23
- package/dist/src/events/StartEvent.js +109 -94
- package/dist/src/flows/Association.js +94 -101
- package/dist/src/flows/MessageFlow.js +86 -103
- package/dist/src/flows/SequenceFlow.js +172 -184
- package/dist/src/gateways/EventBasedGateway.js +88 -84
- package/dist/src/gateways/ExclusiveGateway.js +13 -16
- package/dist/src/gateways/InclusiveGateway.js +11 -14
- package/dist/src/gateways/ParallelGateway.js +11 -14
- package/dist/src/getPropertyValue.js +34 -34
- package/dist/src/io/BpmnIO.js +31 -0
- package/dist/src/io/EnvironmentDataObject.js +33 -29
- package/dist/src/io/EnvironmentDataStore.js +52 -0
- package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
- package/dist/src/io/InputOutputSpecification.js +177 -168
- package/dist/src/io/Properties.js +252 -0
- package/dist/src/messageHelper.js +1 -1
- package/dist/src/process/Process.js +433 -359
- package/dist/src/process/ProcessExecution.js +744 -645
- package/dist/src/shared.js +3 -6
- package/dist/src/tasks/CallActivity.js +160 -0
- package/dist/src/tasks/LoopCharacteristics.js +309 -330
- package/dist/src/tasks/ReceiveTask.js +233 -182
- package/dist/src/tasks/ScriptTask.js +35 -41
- package/dist/src/tasks/ServiceImplementation.js +13 -20
- package/dist/src/tasks/ServiceTask.js +82 -75
- package/dist/src/tasks/SignalTask.js +97 -93
- package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/dist/src/tasks/SubProcess.js +195 -175
- package/dist/src/tasks/Task.js +17 -19
- package/index.js +8 -0
- package/package.json +16 -15
- package/src/Api.js +65 -59
- package/src/Context.js +142 -132
- package/src/Environment.js +88 -100
- package/src/EventBroker.js +67 -68
- package/src/ExtensionsMapper.js +2 -2
- package/src/MessageFormatter.js +132 -74
- package/src/Timers.js +4 -4
- package/src/activity/Activity.js +916 -757
- package/src/activity/ActivityExecution.js +293 -247
- package/src/activity/Dummy.js +2 -2
- package/src/definition/Definition.js +436 -401
- package/src/definition/DefinitionExecution.js +603 -343
- package/src/error/Errors.js +11 -6
- package/src/eventDefinitions/CancelEventDefinition.js +164 -121
- package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
- package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
- package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
- package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
- package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
- package/src/eventDefinitions/LinkEventDefinition.js +160 -129
- package/src/eventDefinitions/MessageEventDefinition.js +178 -121
- package/src/eventDefinitions/SignalEventDefinition.js +162 -106
- package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
- package/src/eventDefinitions/TimerEventDefinition.js +202 -167
- package/src/events/BoundaryEvent.js +156 -115
- package/src/events/EndEvent.js +15 -18
- package/src/events/IntermediateCatchEvent.js +40 -44
- package/src/events/IntermediateThrowEvent.js +15 -18
- package/src/events/StartEvent.js +84 -50
- package/src/flows/Association.js +98 -113
- package/src/flows/MessageFlow.js +81 -97
- package/src/flows/SequenceFlow.js +145 -163
- package/src/gateways/EventBasedGateway.js +75 -68
- package/src/gateways/ExclusiveGateway.js +8 -13
- package/src/gateways/InclusiveGateway.js +8 -13
- package/src/gateways/ParallelGateway.js +8 -13
- package/src/getPropertyValue.js +34 -33
- package/src/io/BpmnIO.js +20 -0
- package/src/io/EnvironmentDataObject.js +29 -18
- package/src/io/EnvironmentDataStore.js +33 -0
- package/src/io/EnvironmentDataStoreReference.js +33 -0
- package/src/io/InputOutputSpecification.js +154 -157
- package/src/io/Properties.js +199 -0
- package/src/process/Process.js +374 -333
- package/src/process/ProcessExecution.js +606 -554
- package/src/shared.js +1 -5
- package/src/tasks/CallActivity.js +130 -0
- package/src/tasks/LoopCharacteristics.js +290 -289
- package/src/tasks/ReceiveTask.js +174 -107
- package/src/tasks/ScriptTask.js +27 -30
- package/src/tasks/ServiceImplementation.js +13 -18
- package/src/tasks/ServiceTask.js +67 -60
- package/src/tasks/SignalTask.js +77 -52
- package/src/tasks/StandardLoopCharacteristics.js +1 -1
- package/src/tasks/SubProcess.js +184 -157
- package/src/tasks/Task.js +15 -19
package/src/flows/Association.js
CHANGED
|
@@ -3,127 +3,112 @@ import {EventBroker} from '../EventBroker';
|
|
|
3
3
|
import {FlowApi} from '../Api';
|
|
4
4
|
import {getUniqueId} from '../shared';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const {id, type = 'association', name, parent: originalParent, targetId, sourceId, behaviour = {}} = associationDef;
|
|
8
|
-
const parent = cloneParent(originalParent);
|
|
9
|
-
const logger = environment.Logger(type.toLowerCase());
|
|
6
|
+
const countersSymbol = Symbol.for('counters');
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
export default function Association(associationDef, {environment}) {
|
|
9
|
+
const {id, type = 'association', name, parent, targetId, sourceId, behaviour = {}} = associationDef;
|
|
10
|
+
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.parent = cloneParent(parent);
|
|
15
|
+
this.behaviour = behaviour;
|
|
16
|
+
this.sourceId = sourceId;
|
|
17
|
+
this.targetId = targetId;
|
|
18
|
+
this.isAssociation = true;
|
|
19
|
+
this.environment = environment;
|
|
20
|
+
const logger = this.logger = environment.Logger(type.toLowerCase());
|
|
21
|
+
|
|
22
|
+
this[countersSymbol] = {
|
|
12
23
|
complete: 0,
|
|
13
24
|
take: 0,
|
|
14
25
|
discard: 0,
|
|
15
26
|
};
|
|
16
27
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
behaviour,
|
|
23
|
-
sourceId,
|
|
24
|
-
targetId,
|
|
25
|
-
isAssociation: true,
|
|
26
|
-
environment,
|
|
27
|
-
get counters() {
|
|
28
|
-
return {...counters};
|
|
29
|
-
},
|
|
30
|
-
complete,
|
|
31
|
-
discard,
|
|
32
|
-
getApi,
|
|
33
|
-
getState,
|
|
34
|
-
recover,
|
|
35
|
-
stop,
|
|
36
|
-
take,
|
|
37
|
-
};
|
|
28
|
+
const {broker, on, once, waitFor} = new EventBroker(this, {prefix: 'association', durable: true, autoDelete: false});
|
|
29
|
+
this.broker = broker;
|
|
30
|
+
this.on = on;
|
|
31
|
+
this.once = once;
|
|
32
|
+
this.waitFor = waitFor;
|
|
38
33
|
|
|
39
|
-
|
|
34
|
+
logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
|
|
35
|
+
}
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
associationApi.once = once;
|
|
43
|
-
associationApi.waitFor = waitFor;
|
|
37
|
+
const proto = Association.prototype;
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
Object.defineProperty(proto, 'counters', {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get() {
|
|
42
|
+
return {...this[countersSymbol]};
|
|
43
|
+
},
|
|
44
|
+
});
|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
proto.take = function take(content = {}) {
|
|
47
|
+
this.logger.debug(`<${this.id}> take target <${this.targetId}>`);
|
|
48
|
+
++this[countersSymbol].take;
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function recover(state) {
|
|
118
|
-
Object.assign(counters, state.counters);
|
|
119
|
-
broker.recover(state.broker);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function getApi(message) {
|
|
123
|
-
return FlowApi(broker, message || {content: createMessageContent()});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function stop() {
|
|
127
|
-
broker.stop();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
50
|
+
this._publishEvent('take', content);
|
|
51
|
+
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
proto.discard = function discard(content = {}) {
|
|
56
|
+
this.logger.debug(`<${this.id}> discard target <${this.targetId}>`);
|
|
57
|
+
++this[countersSymbol].discard;
|
|
58
|
+
|
|
59
|
+
this._publishEvent('discard', content);
|
|
60
|
+
|
|
61
|
+
return true;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
proto.complete = function complete(content = {}) {
|
|
65
|
+
this.logger.debug(`<${this.id}> completed target <${this.targetId}>`);
|
|
66
|
+
++this[countersSymbol].complete;
|
|
67
|
+
|
|
68
|
+
this._publishEvent('complete', content);
|
|
69
|
+
|
|
70
|
+
return true;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
proto.getState = function getState() {
|
|
74
|
+
return this._createMessageContent({
|
|
75
|
+
counters: this.counters,
|
|
76
|
+
broker: this.broker.getState(true),
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
proto.recover = function recover(state) {
|
|
81
|
+
Object.assign(this[countersSymbol], state.counters);
|
|
82
|
+
this.broker.recover(state.broker);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
proto.getApi = function getApi(message) {
|
|
86
|
+
return FlowApi(this.broker, message || {content: this._createMessageContent()});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
proto.stop = function stop() {
|
|
90
|
+
this.broker.stop();
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
proto._publishEvent = function publishEvent(action, content) {
|
|
94
|
+
const eventContent = this._createMessageContent({
|
|
95
|
+
action,
|
|
96
|
+
message: content,
|
|
97
|
+
sequenceId: getUniqueId(this.id),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
this.broker.publish('event', `association.${action}`, eventContent, {type: action});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
proto._createMessageContent = function createMessageContent(override) {
|
|
104
|
+
return {
|
|
105
|
+
...override,
|
|
106
|
+
id: this.id,
|
|
107
|
+
type: this.type,
|
|
108
|
+
name: this.name,
|
|
109
|
+
sourceId: this.sourceId,
|
|
110
|
+
targetId: this.targetId,
|
|
111
|
+
isAssociation: true,
|
|
112
|
+
parent: cloneParent(this.parent),
|
|
113
|
+
};
|
|
114
|
+
};
|
package/src/flows/MessageFlow.js
CHANGED
|
@@ -2,108 +2,92 @@ import {brokerSafeId} from '../shared';
|
|
|
2
2
|
import {cloneParent} from '../messageHelper';
|
|
3
3
|
import {MessageFlowBroker} from '../EventBroker';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const sourceElement = context.getActivityById(source.id) || context.getProcessById(source.processId);
|
|
8
|
-
const sourceEndConsumerTag = `_message-on-end-${brokerSafeId(id)}`;
|
|
9
|
-
const sourceMessageConsumerTag = `_message-on-message-${brokerSafeId(id)}`;
|
|
10
|
-
const {debug} = context.environment.Logger(type.toLowerCase());
|
|
11
|
-
|
|
12
|
-
if (!sourceElement) return;
|
|
5
|
+
const countersSymbol = Symbol.for('counters');
|
|
6
|
+
const sourceElementSymbol = Symbol.for('sourceElement');
|
|
13
7
|
|
|
14
|
-
|
|
8
|
+
export default function MessageFlow(flowDef, context) {
|
|
9
|
+
const {id, type = 'messageflow', name, target, source, behaviour, parent} = flowDef;
|
|
10
|
+
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.parent = cloneParent(parent);
|
|
15
|
+
this.source = source;
|
|
16
|
+
this.target = target;
|
|
17
|
+
this.behaviour = behaviour;
|
|
18
|
+
this.environment = context.environment;
|
|
19
|
+
this.context = context;
|
|
20
|
+
|
|
21
|
+
this[countersSymbol] = {
|
|
15
22
|
messages: 0,
|
|
16
|
-
discard: 0,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const flowApi = {
|
|
20
|
-
id,
|
|
21
|
-
type,
|
|
22
|
-
name,
|
|
23
|
-
target,
|
|
24
|
-
source,
|
|
25
|
-
behaviour,
|
|
26
|
-
get counters() {
|
|
27
|
-
return {...counters};
|
|
28
|
-
},
|
|
29
|
-
activate,
|
|
30
|
-
deactivate,
|
|
31
|
-
getApi,
|
|
32
|
-
getState,
|
|
33
|
-
recover,
|
|
34
|
-
resume,
|
|
35
|
-
stop,
|
|
36
23
|
};
|
|
37
24
|
|
|
38
|
-
const {broker, on, once, emit, waitFor} = MessageFlowBroker(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Object.defineProperty(flowApi, 'broker', {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: () => broker,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return flowApi;
|
|
51
|
-
|
|
52
|
-
function onSourceEnd({content}) {
|
|
53
|
-
++counters.messages;
|
|
54
|
-
debug(`<${id}> sending message from <${source.processId}.${source.id}> to`, target.id ? `<${target.processId}.${target.id}>` : `<${target.processId}>`);
|
|
55
|
-
broker.publish('event', 'message.outbound', createMessage(content.message));
|
|
56
|
-
}
|
|
25
|
+
const {broker, on, once, emit, waitFor} = MessageFlowBroker(this);
|
|
26
|
+
this.broker = broker;
|
|
27
|
+
this.on = on;
|
|
28
|
+
this.once = once;
|
|
29
|
+
this.emit = emit;
|
|
30
|
+
this.waitFor = waitFor;
|
|
57
31
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
function createMessage(message) {
|
|
63
|
-
return {
|
|
64
|
-
id,
|
|
65
|
-
type,
|
|
66
|
-
name,
|
|
67
|
-
source: {...source},
|
|
68
|
-
target: {...target},
|
|
69
|
-
parent: parent && cloneParent(parent),
|
|
70
|
-
message,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function stop() {
|
|
75
|
-
deactivate();
|
|
76
|
-
broker.stop();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function getState() {
|
|
80
|
-
return {
|
|
81
|
-
id,
|
|
82
|
-
type,
|
|
83
|
-
counters: {...counters},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function recover(state) {
|
|
88
|
-
Object.assign(counters, state.counters);
|
|
89
|
-
broker.recover(state.broker);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function resume() {
|
|
93
|
-
broker.resume();
|
|
94
|
-
}
|
|
32
|
+
this[sourceElementSymbol] = context.getActivityById(source.id) || context.getProcessById(source.processId);
|
|
33
|
+
this.logger = context.environment.Logger(type.toLowerCase());
|
|
34
|
+
}
|
|
95
35
|
|
|
96
|
-
|
|
97
|
-
return flowApi;
|
|
98
|
-
}
|
|
36
|
+
const proto = MessageFlow.prototype;
|
|
99
37
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
38
|
+
Object.defineProperty(proto, 'counters', {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get() {
|
|
41
|
+
return {...this[countersSymbol]};
|
|
42
|
+
},
|
|
43
|
+
});
|
|
104
44
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
45
|
+
proto.getState = function getState() {
|
|
46
|
+
return {
|
|
47
|
+
id: this.id,
|
|
48
|
+
type: this.type,
|
|
49
|
+
counters: this.counters,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
proto.recover = function recover(state) {
|
|
54
|
+
Object.assign(this[countersSymbol], state.counters);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
proto.getApi = function getApi() {
|
|
58
|
+
return this;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
proto.activate = function activate() {
|
|
62
|
+
const sourceElement = this[sourceElementSymbol];
|
|
63
|
+
const safeId = brokerSafeId(this.id);
|
|
64
|
+
sourceElement.on('message', this.deactivate.bind(this), {consumerTag: `_message-on-message-${safeId}`});
|
|
65
|
+
sourceElement.on('end', this._onSourceEnd.bind(this), {consumerTag: `_message-on-end-${safeId}`});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
proto.deactivate = function deactivate() {
|
|
69
|
+
const sourceElement = this[sourceElementSymbol];
|
|
70
|
+
const safeId = brokerSafeId(this.id);
|
|
71
|
+
sourceElement.broker.cancel(`_message-on-end-${safeId}`);
|
|
72
|
+
sourceElement.broker.cancel(`_message-on-message-${safeId}`);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
proto._onSourceEnd = function onSourceEnd({content}) {
|
|
76
|
+
++this[countersSymbol].messages;
|
|
77
|
+
const source = this.source;
|
|
78
|
+
const target = this.target;
|
|
79
|
+
this.logger.debug(`<${this.id}> sending message from <${source.processId}.${source.id}> to <${target.id ? `${target.processId}.${target.id}` : target.processId}>`);
|
|
80
|
+
this.broker.publish('event', 'message.outbound', this._createMessage(content.message));
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
proto._createMessage = function createMessage(message) {
|
|
84
|
+
return {
|
|
85
|
+
id: this.id,
|
|
86
|
+
type: this.type,
|
|
87
|
+
name: this.name,
|
|
88
|
+
source: {...this.source},
|
|
89
|
+
target: {...this.target},
|
|
90
|
+
parent: cloneParent(this.parent),
|
|
91
|
+
message,
|
|
92
|
+
};
|
|
93
|
+
};
|