bpmn-elements 6.0.0 → 8.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +335 -0
  2. package/README.md +3 -0
  3. package/dist/index.js +52 -44
  4. package/dist/src/Api.js +77 -76
  5. package/dist/src/Context.js +176 -172
  6. package/dist/src/Environment.js +110 -102
  7. package/dist/src/EventBroker.js +89 -88
  8. package/dist/src/ExtensionsMapper.js +2 -2
  9. package/dist/src/MessageFormatter.js +164 -95
  10. package/dist/src/Scripts.js +6 -2
  11. package/dist/src/activity/Activity.js +1106 -916
  12. package/dist/src/activity/ActivityExecution.js +342 -297
  13. package/dist/src/activity/Dummy.js +3 -3
  14. package/dist/src/definition/Definition.js +498 -444
  15. package/dist/src/definition/DefinitionExecution.js +710 -408
  16. package/dist/src/error/Errors.js +17 -7
  17. package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
  18. package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
  19. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
  20. package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
  21. package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
  22. package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
  23. package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
  24. package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
  25. package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
  26. package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
  27. package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
  28. package/dist/src/events/BoundaryEvent.js +180 -144
  29. package/dist/src/events/EndEvent.js +18 -23
  30. package/dist/src/events/IntermediateCatchEvent.js +44 -58
  31. package/dist/src/events/IntermediateThrowEvent.js +18 -23
  32. package/dist/src/events/StartEvent.js +109 -94
  33. package/dist/src/flows/Association.js +94 -100
  34. package/dist/src/flows/MessageFlow.js +86 -103
  35. package/dist/src/flows/SequenceFlow.js +173 -182
  36. package/dist/src/gateways/EventBasedGateway.js +88 -84
  37. package/dist/src/gateways/ExclusiveGateway.js +13 -16
  38. package/dist/src/gateways/InclusiveGateway.js +11 -14
  39. package/dist/src/gateways/ParallelGateway.js +11 -14
  40. package/dist/src/getPropertyValue.js +34 -34
  41. package/dist/src/io/BpmnIO.js +17 -14
  42. package/dist/src/io/EnvironmentDataObject.js +33 -29
  43. package/dist/src/io/EnvironmentDataStore.js +33 -29
  44. package/dist/src/io/EnvironmentDataStoreReference.js +35 -31
  45. package/dist/src/io/InputOutputSpecification.js +177 -168
  46. package/dist/src/io/Properties.js +117 -124
  47. package/dist/src/messageHelper.js +1 -1
  48. package/dist/src/process/Process.js +439 -362
  49. package/dist/src/process/ProcessExecution.js +748 -646
  50. package/dist/src/shared.js +2 -2
  51. package/dist/src/tasks/CallActivity.js +160 -0
  52. package/dist/src/tasks/LoopCharacteristics.js +309 -330
  53. package/dist/src/tasks/ReceiveTask.js +233 -182
  54. package/dist/src/tasks/ScriptTask.js +35 -41
  55. package/dist/src/tasks/ServiceImplementation.js +13 -20
  56. package/dist/src/tasks/ServiceTask.js +82 -75
  57. package/dist/src/tasks/SignalTask.js +97 -93
  58. package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
  59. package/dist/src/tasks/SubProcess.js +193 -175
  60. package/dist/src/tasks/Task.js +17 -19
  61. package/index.js +2 -0
  62. package/package.json +15 -15
  63. package/src/Api.js +65 -59
  64. package/src/Context.js +145 -140
  65. package/src/Environment.js +116 -100
  66. package/src/EventBroker.js +67 -68
  67. package/src/ExtensionsMapper.js +2 -2
  68. package/src/MessageFormatter.js +132 -74
  69. package/src/activity/Activity.js +915 -775
  70. package/src/activity/ActivityExecution.js +293 -247
  71. package/src/activity/Dummy.js +2 -2
  72. package/src/definition/Definition.js +437 -401
  73. package/src/definition/DefinitionExecution.js +598 -340
  74. package/src/error/Errors.js +11 -6
  75. package/src/eventDefinitions/CancelEventDefinition.js +164 -121
  76. package/src/eventDefinitions/CompensateEventDefinition.js +159 -124
  77. package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
  78. package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
  79. package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
  80. package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
  81. package/src/eventDefinitions/LinkEventDefinition.js +160 -129
  82. package/src/eventDefinitions/MessageEventDefinition.js +178 -121
  83. package/src/eventDefinitions/SignalEventDefinition.js +162 -106
  84. package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
  85. package/src/eventDefinitions/TimerEventDefinition.js +202 -167
  86. package/src/events/BoundaryEvent.js +156 -115
  87. package/src/events/EndEvent.js +15 -18
  88. package/src/events/IntermediateCatchEvent.js +40 -44
  89. package/src/events/IntermediateThrowEvent.js +15 -18
  90. package/src/events/StartEvent.js +84 -50
  91. package/src/flows/Association.js +98 -112
  92. package/src/flows/MessageFlow.js +81 -97
  93. package/src/flows/SequenceFlow.js +146 -160
  94. package/src/gateways/EventBasedGateway.js +75 -68
  95. package/src/gateways/ExclusiveGateway.js +8 -13
  96. package/src/gateways/InclusiveGateway.js +8 -13
  97. package/src/gateways/ParallelGateway.js +8 -13
  98. package/src/getPropertyValue.js +34 -33
  99. package/src/io/BpmnIO.js +20 -15
  100. package/src/io/EnvironmentDataObject.js +29 -18
  101. package/src/io/EnvironmentDataStore.js +29 -18
  102. package/src/io/EnvironmentDataStoreReference.js +31 -20
  103. package/src/io/InputOutputSpecification.js +154 -157
  104. package/src/io/Properties.js +95 -97
  105. package/src/process/Process.js +378 -333
  106. package/src/process/ProcessExecution.js +603 -553
  107. package/src/tasks/CallActivity.js +130 -0
  108. package/src/tasks/LoopCharacteristics.js +290 -289
  109. package/src/tasks/ReceiveTask.js +174 -107
  110. package/src/tasks/ScriptTask.js +27 -30
  111. package/src/tasks/ServiceImplementation.js +13 -18
  112. package/src/tasks/ServiceTask.js +67 -60
  113. package/src/tasks/SignalTask.js +77 -52
  114. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  115. package/src/tasks/SubProcess.js +184 -157
  116. package/src/tasks/Task.js +15 -19
@@ -3,126 +3,112 @@ import {EventBroker} from '../EventBroker';
3
3
  import {FlowApi} from '../Api';
4
4
  import {getUniqueId} from '../shared';
5
5
 
6
- export default function Association(associationDef, {environment}) {
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 kCounters = Symbol.for('counters');
10
7
 
11
- const counters = {
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[kCounters] = {
12
23
  complete: 0,
13
24
  take: 0,
14
25
  discard: 0,
15
26
  };
16
27
 
17
- const associationApi = {
18
- id,
19
- type,
20
- name,
21
- parent,
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
- const {broker, on, once, waitFor} = EventBroker(associationApi, {prefix: 'association', durable: true, autoDelete: false});
34
+ logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
35
+ }
40
36
 
41
- associationApi.on = on;
42
- associationApi.once = once;
43
- associationApi.waitFor = waitFor;
37
+ const proto = Association.prototype;
44
38
 
45
- Object.defineProperty(associationApi, 'broker', {
46
- enumerable: true,
47
- get: () => broker,
48
- });
39
+ Object.defineProperty(proto, 'counters', {
40
+ enumerable: true,
41
+ get() {
42
+ return {...this[kCounters]};
43
+ },
44
+ });
49
45
 
50
- logger.debug(`<${id}> init, <${sourceId}> -> <${targetId}>`);
46
+ proto.take = function take(content = {}) {
47
+ this.logger.debug(`<${this.id}> take target <${this.targetId}>`);
48
+ ++this[kCounters].take;
51
49
 
52
- return associationApi;
53
-
54
- function take(content = {}) {
55
- logger.debug(`<${id}> take target <${targetId}>`);
56
- ++counters.take;
57
-
58
- publishEvent('take', content);
59
-
60
- return true;
61
- }
62
-
63
- function discard(content = {}) {
64
- logger.debug(`<${id}> discard target <${targetId}>`);
65
- ++counters.discard;
66
-
67
- publishEvent('discard', content);
68
-
69
- return true;
70
- }
71
-
72
- function complete(content = {}) {
73
- logger.debug(`<${id}> completed target <${targetId}>`);
74
- ++counters.complete;
75
-
76
- publishEvent('complete', content);
77
-
78
- return true;
79
- }
80
-
81
- function publishEvent(action, content) {
82
- const eventContent = createMessageContent({
83
- action,
84
- message: content,
85
- sequenceId: getUniqueId(id),
86
- });
87
-
88
- broker.publish('event', `association.${action}`, eventContent, {type: action});
89
- }
90
-
91
- function createMessageContent(override = {}) {
92
- return {
93
- ...override,
94
- id,
95
- type,
96
- name,
97
- sourceId,
98
- targetId,
99
- isAssociation: true,
100
- parent: cloneParent(parent),
101
- };
102
- }
103
-
104
- function getState() {
105
- return {
106
- id,
107
- type,
108
- name,
109
- sourceId,
110
- targetId,
111
- counters: {...counters},
112
- broker: broker.getState(true),
113
- };
114
- }
115
-
116
- function recover(state) {
117
- Object.assign(counters, state.counters);
118
- broker.recover(state.broker);
119
- }
120
-
121
- function getApi(message) {
122
- return FlowApi(broker, message || {content: createMessageContent()});
123
- }
124
-
125
- function stop() {
126
- broker.stop();
127
- }
128
- }
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[kCounters].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[kCounters].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[kCounters], 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
+ };
@@ -2,108 +2,92 @@ import {brokerSafeId} from '../shared';
2
2
  import {cloneParent} from '../messageHelper';
3
3
  import {MessageFlowBroker} from '../EventBroker';
4
4
 
5
- export default function MessageFlow(flowDef, context) {
6
- const {id, type = 'message', name, target, source, behaviour, parent} = flowDef;
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 kCounters = Symbol.for('counters');
6
+ const kSourceElement = Symbol.for('sourceElement');
13
7
 
14
- const counters = {
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[kCounters] = {
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(flowApi);
39
-
40
- flowApi.on = on;
41
- flowApi.once = once;
42
- flowApi.emit = emit;
43
- flowApi.waitFor = waitFor;
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
- function onSourceMessage() {
59
- deactivate();
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[kSourceElement] = context.getActivityById(source.id) || context.getProcessById(source.processId);
33
+ this.logger = context.environment.Logger(type.toLowerCase());
34
+ }
95
35
 
96
- function getApi() {
97
- return flowApi;
98
- }
36
+ const proto = MessageFlow.prototype;
99
37
 
100
- function activate() {
101
- sourceElement.on('message', onSourceMessage, {consumerTag: sourceMessageConsumerTag});
102
- sourceElement.on('end', onSourceEnd, {consumerTag: sourceEndConsumerTag});
103
- }
38
+ Object.defineProperty(proto, 'counters', {
39
+ enumerable: true,
40
+ get() {
41
+ return {...this[kCounters]};
42
+ },
43
+ });
104
44
 
105
- function deactivate() {
106
- sourceElement.broker.cancel(sourceMessageConsumerTag);
107
- sourceElement.broker.cancel(sourceEndConsumerTag);
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[kCounters], state.counters);
55
+ };
56
+
57
+ proto.getApi = function getApi() {
58
+ return this;
59
+ };
60
+
61
+ proto.activate = function activate() {
62
+ const sourceElement = this[kSourceElement];
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[kSourceElement];
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[kCounters].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
+ };