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
|
@@ -13,6 +13,10 @@ var _messageHelper = require("../messageHelper");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
+
const completedSymbol = Symbol.for('completed');
|
|
17
|
+
const messageQSymbol = Symbol.for('messageQ');
|
|
18
|
+
const executeMessageSymbol = Symbol.for('executeMessage');
|
|
19
|
+
|
|
16
20
|
function LinkEventDefinition(activity, eventDefinition) {
|
|
17
21
|
const {
|
|
18
22
|
id,
|
|
@@ -21,170 +25,191 @@ function LinkEventDefinition(activity, eventDefinition) {
|
|
|
21
25
|
isThrowing
|
|
22
26
|
} = activity;
|
|
23
27
|
const {
|
|
24
|
-
type
|
|
28
|
+
type = 'LinkEventDefinition',
|
|
29
|
+
behaviour
|
|
25
30
|
} = eventDefinition;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
const linkQueueName = `link-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(reference.linkName)}-q`;
|
|
33
|
-
if (!isThrowing) setupCatch();else setupThrow();
|
|
34
|
-
const source = {
|
|
35
|
-
id,
|
|
36
|
-
type,
|
|
37
|
-
reference: { ...reference,
|
|
38
|
-
referenceType: 'link'
|
|
39
|
-
},
|
|
40
|
-
execute: isThrowing ? executeThrow : executeCatch
|
|
31
|
+
this.id = id;
|
|
32
|
+
this.type = type;
|
|
33
|
+
const reference = this.reference = {
|
|
34
|
+
linkName: behaviour.name,
|
|
35
|
+
referenceType: 'link'
|
|
41
36
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
broker.consume(linkQueueName, onCatchLink, {
|
|
54
|
-
noAck: true,
|
|
55
|
-
consumerTag: `_api-link-${executionId}`
|
|
37
|
+
this.isThrowing = isThrowing;
|
|
38
|
+
this.activity = activity;
|
|
39
|
+
this.broker = broker;
|
|
40
|
+
this.logger = environment.Logger(type.toLowerCase());
|
|
41
|
+
this[completedSymbol] = false;
|
|
42
|
+
|
|
43
|
+
if (!isThrowing) {
|
|
44
|
+
const messageQueueName = `${reference.referenceType}-${(0, _shared.brokerSafeId)(id)}-${(0, _shared.brokerSafeId)(reference.linkName)}-q`;
|
|
45
|
+
this[messageQSymbol] = broker.assertQueue(messageQueueName, {
|
|
46
|
+
autoDelete: false,
|
|
47
|
+
durable: true
|
|
56
48
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
noAck: true,
|
|
60
|
-
consumerTag: `_api-parent-${parentExecutionId}`
|
|
49
|
+
broker.bindQueue(messageQueueName, 'api', `*.${reference.referenceType}.#`, {
|
|
50
|
+
durable: true
|
|
61
51
|
});
|
|
62
|
-
|
|
52
|
+
} else {
|
|
53
|
+
broker.subscribeTmp('event', 'activity.discard', this._onDiscard.bind(this), {
|
|
63
54
|
noAck: true,
|
|
64
|
-
consumerTag:
|
|
65
|
-
});
|
|
66
|
-
debug(`<${executionId} (${id})> expect ${description}`);
|
|
67
|
-
broker.publish('event', 'activity.wait', { ...messageContent,
|
|
68
|
-
executionId: parentExecutionId,
|
|
69
|
-
parent: (0, _messageHelper.shiftParent)(parent),
|
|
70
|
-
link: { ...reference
|
|
71
|
-
}
|
|
55
|
+
consumerTag: '_link-parent-discard'
|
|
72
56
|
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
73
59
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
60
|
+
const proto = LinkEventDefinition.prototype;
|
|
61
|
+
Object.defineProperty(proto, 'executionId', {
|
|
62
|
+
get() {
|
|
63
|
+
const message = this[executeMessageSymbol];
|
|
64
|
+
return message && message.content.executionId;
|
|
65
|
+
}
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
const messageType = message.properties.type;
|
|
82
|
-
|
|
83
|
-
switch (messageType) {
|
|
84
|
-
case 'link':
|
|
85
|
-
{
|
|
86
|
-
return complete('got link with', message.content.message);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
case 'discard':
|
|
90
|
-
{
|
|
91
|
-
return discard();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
case 'stop':
|
|
95
|
-
{
|
|
96
|
-
stop();
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
67
|
+
});
|
|
101
68
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
debug(`<${executionId} (${id})> ${verb} ${description}`);
|
|
106
|
-
broker.publish('event', 'activity.catch', { ...messageContent,
|
|
107
|
-
link: { ...reference
|
|
108
|
-
},
|
|
109
|
-
message: { ...output
|
|
110
|
-
},
|
|
111
|
-
executionId: parentExecutionId || executionId,
|
|
112
|
-
parent: (0, _messageHelper.shiftParent)(executeMessage.content.parent)
|
|
113
|
-
}, {
|
|
114
|
-
type: 'catch'
|
|
115
|
-
});
|
|
116
|
-
return broker.publish('execution', 'execute.completed', { ...messageContent,
|
|
117
|
-
output,
|
|
118
|
-
state: 'catch'
|
|
119
|
-
});
|
|
120
|
-
}
|
|
69
|
+
proto.execute = function execute(executeMessage) {
|
|
70
|
+
return this.isThrowing ? this.executeThrow(executeMessage) : this.executeCatch(executeMessage);
|
|
71
|
+
};
|
|
121
72
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
73
|
+
proto.executeCatch = function executeCatch(executeMessage) {
|
|
74
|
+
this[executeMessageSymbol] = executeMessage;
|
|
75
|
+
this[completedSymbol] = false;
|
|
76
|
+
const executeContent = executeMessage.content;
|
|
77
|
+
const {
|
|
78
|
+
executionId,
|
|
79
|
+
parent
|
|
80
|
+
} = executeContent;
|
|
81
|
+
const parentExecutionId = parent.executionId;
|
|
82
|
+
this[messageQSymbol].consume(this._onCatchLink.bind(this), {
|
|
83
|
+
noAck: true,
|
|
84
|
+
consumerTag: `_api-link-${executionId}`
|
|
85
|
+
});
|
|
86
|
+
if (this[completedSymbol]) return;
|
|
87
|
+
const broker = this.broker;
|
|
88
|
+
|
|
89
|
+
const onApiMessage = this._onApiMessage.bind(this);
|
|
90
|
+
|
|
91
|
+
broker.subscribeTmp('api', `activity.stop.${parentExecutionId}`, onApiMessage, {
|
|
92
|
+
noAck: true,
|
|
93
|
+
consumerTag: `_api-parent-${executionId}`
|
|
94
|
+
});
|
|
95
|
+
broker.subscribeTmp('api', `activity.#.${executionId}`, onApiMessage, {
|
|
96
|
+
noAck: true,
|
|
97
|
+
consumerTag: `_api-${executionId}`
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
this._debug(`expect link ${this.reference.linkName}`);
|
|
101
|
+
|
|
102
|
+
const waitContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
103
|
+
executionId: parentExecutionId,
|
|
104
|
+
link: { ...this.reference
|
|
127
105
|
}
|
|
106
|
+
});
|
|
107
|
+
waitContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
108
|
+
broker.publish('event', 'activity.wait', waitContent);
|
|
109
|
+
};
|
|
128
110
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
111
|
+
proto.executeThrow = function executeThrow(executeMessage) {
|
|
112
|
+
const executeContent = executeMessage.content;
|
|
113
|
+
const {
|
|
114
|
+
executionId,
|
|
115
|
+
parent
|
|
116
|
+
} = executeContent;
|
|
117
|
+
const parentExecutionId = parent && parent.executionId;
|
|
118
|
+
this.logger.debug(`<${executionId} (${this.activity.id})> throw link ${this.reference.linkName}`);
|
|
119
|
+
const broker = this.broker;
|
|
120
|
+
const linkContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
121
|
+
executionId: parentExecutionId,
|
|
122
|
+
message: { ...this.reference
|
|
123
|
+
},
|
|
124
|
+
state: 'throw'
|
|
125
|
+
});
|
|
126
|
+
linkContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
127
|
+
broker.publish('event', 'activity.link', linkContent, {
|
|
128
|
+
type: 'link',
|
|
129
|
+
delegate: true
|
|
130
|
+
});
|
|
131
|
+
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
proto._onCatchLink = function onCatchLink(routingKey, message) {
|
|
135
|
+
if ((0, _getPropertyValue.default)(message, 'content.message.linkName') !== this.reference.linkName) return;
|
|
136
|
+
if (message.content.state === 'discard') return this._discard();
|
|
137
|
+
return this._complete('caught', message.content.message);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
proto._onApiMessage = function onApiMessage(routingKey, message) {
|
|
141
|
+
const messageType = message.properties.type;
|
|
142
|
+
|
|
143
|
+
switch (messageType) {
|
|
144
|
+
case 'discard':
|
|
145
|
+
{
|
|
146
|
+
return this._discard();
|
|
147
|
+
}
|
|
136
148
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
executionId,
|
|
141
|
-
parent
|
|
142
|
-
} = messageContent;
|
|
143
|
-
const parentExecutionId = parent && parent.executionId;
|
|
144
|
-
const description = messageDescription();
|
|
145
|
-
debug(`<${executionId} (${id})> throw ${description}`);
|
|
146
|
-
broker.publish('event', 'activity.link', { ...(0, _messageHelper.cloneContent)(messageContent),
|
|
147
|
-
executionId: parentExecutionId,
|
|
148
|
-
parent: (0, _messageHelper.shiftParent)(parent),
|
|
149
|
-
message: { ...reference
|
|
150
|
-
},
|
|
151
|
-
state: 'throw'
|
|
152
|
-
}, {
|
|
153
|
-
type: 'link',
|
|
154
|
-
delegate: true
|
|
155
|
-
});
|
|
156
|
-
return broker.publish('execution', 'execute.completed', messageContent);
|
|
157
|
-
}
|
|
149
|
+
case 'stop':
|
|
150
|
+
{
|
|
151
|
+
this._stop();
|
|
158
152
|
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
161
155
|
}
|
|
156
|
+
};
|
|
162
157
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
autoDelete: false,
|
|
166
|
-
durable: true
|
|
167
|
-
});
|
|
168
|
-
broker.bindQueue(linkQueueName, 'api', '*.link.#', {
|
|
169
|
-
durable: true
|
|
170
|
-
});
|
|
171
|
-
}
|
|
158
|
+
proto._complete = function complete(verb, output) {
|
|
159
|
+
this[completedSymbol] = true;
|
|
172
160
|
|
|
173
|
-
|
|
174
|
-
broker.subscribeTmp('event', 'activity.discard', onDiscard, {
|
|
175
|
-
noAck: true,
|
|
176
|
-
consumerTag: '_link-parent-discard'
|
|
177
|
-
});
|
|
161
|
+
this._stop();
|
|
178
162
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
163
|
+
this._debug(`${verb} link ${this.reference.linkName}`);
|
|
164
|
+
|
|
165
|
+
const executeContent = this[executeMessageSymbol].content;
|
|
166
|
+
const parent = executeContent.parent;
|
|
167
|
+
const catchContent = (0, _messageHelper.cloneContent)(executeContent, {
|
|
168
|
+
link: { ...this.reference
|
|
169
|
+
},
|
|
170
|
+
message: { ...output
|
|
171
|
+
},
|
|
172
|
+
executionId: parent.executionId
|
|
173
|
+
});
|
|
174
|
+
catchContent.parent = (0, _messageHelper.shiftParent)(parent);
|
|
175
|
+
const broker = this.broker;
|
|
176
|
+
broker.publish('event', 'activity.catch', catchContent, {
|
|
177
|
+
type: 'catch'
|
|
178
|
+
});
|
|
179
|
+
return broker.publish('execution', 'execute.completed', (0, _messageHelper.cloneContent)(executeContent, {
|
|
180
|
+
output,
|
|
181
|
+
state: 'catch'
|
|
182
|
+
}));
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
proto._discard = function discard() {
|
|
186
|
+
this[completedSymbol] = true;
|
|
187
|
+
|
|
188
|
+
this._stop();
|
|
189
|
+
|
|
190
|
+
return this.broker.publish('execution', 'execute.discard', (0, _messageHelper.cloneContent)(this[executeMessageSymbol].content));
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
proto._stop = function stop() {
|
|
194
|
+
const broker = this.broker,
|
|
195
|
+
executionId = this.executionId;
|
|
196
|
+
broker.cancel(`_api-link-${executionId}`);
|
|
197
|
+
broker.cancel(`_api-parent-${executionId}`);
|
|
198
|
+
broker.cancel(`_api-${executionId}`);
|
|
199
|
+
this[messageQSymbol].purge();
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
proto._onDiscard = function onDiscard(_, message) {
|
|
203
|
+
this.broker.publish('event', 'activity.link.discard', (0, _messageHelper.cloneContent)(message.content, {
|
|
204
|
+
message: { ...this.reference
|
|
205
|
+
},
|
|
206
|
+
state: 'discard'
|
|
207
|
+
}), {
|
|
208
|
+
type: 'link',
|
|
209
|
+
delegate: true
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
proto._debug = function debug(msg) {
|
|
214
|
+
this.logger.debug(`<${this.executionId} (${this.activity.id})> ${msg}`);
|
|
215
|
+
};
|