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.
Files changed (119) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/README.md +9 -3
  3. package/dist/index.js +71 -39
  4. package/dist/src/Api.js +77 -76
  5. package/dist/src/Context.js +169 -164
  6. package/dist/src/Environment.js +90 -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/Timers.js +4 -6
  12. package/dist/src/activity/Activity.js +1108 -901
  13. package/dist/src/activity/ActivityExecution.js +342 -297
  14. package/dist/src/activity/Dummy.js +3 -3
  15. package/dist/src/definition/Definition.js +498 -444
  16. package/dist/src/definition/DefinitionExecution.js +722 -409
  17. package/dist/src/error/Errors.js +17 -7
  18. package/dist/src/eventDefinitions/CancelEventDefinition.js +190 -150
  19. package/dist/src/eventDefinitions/CompensateEventDefinition.js +194 -161
  20. package/dist/src/eventDefinitions/ConditionalEventDefinition.js +197 -135
  21. package/dist/src/eventDefinitions/ErrorEventDefinition.js +207 -165
  22. package/dist/src/eventDefinitions/EscalationEventDefinition.js +175 -141
  23. package/dist/src/eventDefinitions/EventDefinitionExecution.js +157 -129
  24. package/dist/src/eventDefinitions/LinkEventDefinition.js +174 -149
  25. package/dist/src/eventDefinitions/MessageEventDefinition.js +213 -176
  26. package/dist/src/eventDefinitions/SignalEventDefinition.js +203 -161
  27. package/dist/src/eventDefinitions/TerminateEventDefinition.js +21 -23
  28. package/dist/src/eventDefinitions/TimerEventDefinition.js +243 -228
  29. package/dist/src/events/BoundaryEvent.js +180 -144
  30. package/dist/src/events/EndEvent.js +18 -23
  31. package/dist/src/events/IntermediateCatchEvent.js +44 -58
  32. package/dist/src/events/IntermediateThrowEvent.js +18 -23
  33. package/dist/src/events/StartEvent.js +109 -94
  34. package/dist/src/flows/Association.js +94 -101
  35. package/dist/src/flows/MessageFlow.js +86 -103
  36. package/dist/src/flows/SequenceFlow.js +172 -184
  37. package/dist/src/gateways/EventBasedGateway.js +88 -84
  38. package/dist/src/gateways/ExclusiveGateway.js +13 -16
  39. package/dist/src/gateways/InclusiveGateway.js +11 -14
  40. package/dist/src/gateways/ParallelGateway.js +11 -14
  41. package/dist/src/getPropertyValue.js +34 -34
  42. package/dist/src/io/BpmnIO.js +31 -0
  43. package/dist/src/io/EnvironmentDataObject.js +33 -29
  44. package/dist/src/io/EnvironmentDataStore.js +52 -0
  45. package/dist/src/io/EnvironmentDataStoreReference.js +52 -0
  46. package/dist/src/io/InputOutputSpecification.js +177 -168
  47. package/dist/src/io/Properties.js +252 -0
  48. package/dist/src/messageHelper.js +1 -1
  49. package/dist/src/process/Process.js +433 -359
  50. package/dist/src/process/ProcessExecution.js +744 -645
  51. package/dist/src/shared.js +3 -6
  52. package/dist/src/tasks/CallActivity.js +160 -0
  53. package/dist/src/tasks/LoopCharacteristics.js +309 -330
  54. package/dist/src/tasks/ReceiveTask.js +233 -182
  55. package/dist/src/tasks/ScriptTask.js +35 -41
  56. package/dist/src/tasks/ServiceImplementation.js +13 -20
  57. package/dist/src/tasks/ServiceTask.js +82 -75
  58. package/dist/src/tasks/SignalTask.js +97 -93
  59. package/dist/src/tasks/StandardLoopCharacteristics.js +1 -1
  60. package/dist/src/tasks/SubProcess.js +195 -175
  61. package/dist/src/tasks/Task.js +17 -19
  62. package/index.js +8 -0
  63. package/package.json +16 -15
  64. package/src/Api.js +65 -59
  65. package/src/Context.js +142 -132
  66. package/src/Environment.js +88 -100
  67. package/src/EventBroker.js +67 -68
  68. package/src/ExtensionsMapper.js +2 -2
  69. package/src/MessageFormatter.js +132 -74
  70. package/src/Timers.js +4 -4
  71. package/src/activity/Activity.js +916 -757
  72. package/src/activity/ActivityExecution.js +293 -247
  73. package/src/activity/Dummy.js +2 -2
  74. package/src/definition/Definition.js +436 -401
  75. package/src/definition/DefinitionExecution.js +603 -343
  76. package/src/error/Errors.js +11 -6
  77. package/src/eventDefinitions/CancelEventDefinition.js +164 -121
  78. package/src/eventDefinitions/CompensateEventDefinition.js +158 -124
  79. package/src/eventDefinitions/ConditionalEventDefinition.js +147 -104
  80. package/src/eventDefinitions/ErrorEventDefinition.js +190 -131
  81. package/src/eventDefinitions/EscalationEventDefinition.js +139 -101
  82. package/src/eventDefinitions/EventDefinitionExecution.js +127 -95
  83. package/src/eventDefinitions/LinkEventDefinition.js +160 -129
  84. package/src/eventDefinitions/MessageEventDefinition.js +178 -121
  85. package/src/eventDefinitions/SignalEventDefinition.js +162 -106
  86. package/src/eventDefinitions/TerminateEventDefinition.js +19 -19
  87. package/src/eventDefinitions/TimerEventDefinition.js +202 -167
  88. package/src/events/BoundaryEvent.js +156 -115
  89. package/src/events/EndEvent.js +15 -18
  90. package/src/events/IntermediateCatchEvent.js +40 -44
  91. package/src/events/IntermediateThrowEvent.js +15 -18
  92. package/src/events/StartEvent.js +84 -50
  93. package/src/flows/Association.js +98 -113
  94. package/src/flows/MessageFlow.js +81 -97
  95. package/src/flows/SequenceFlow.js +145 -163
  96. package/src/gateways/EventBasedGateway.js +75 -68
  97. package/src/gateways/ExclusiveGateway.js +8 -13
  98. package/src/gateways/InclusiveGateway.js +8 -13
  99. package/src/gateways/ParallelGateway.js +8 -13
  100. package/src/getPropertyValue.js +34 -33
  101. package/src/io/BpmnIO.js +20 -0
  102. package/src/io/EnvironmentDataObject.js +29 -18
  103. package/src/io/EnvironmentDataStore.js +33 -0
  104. package/src/io/EnvironmentDataStoreReference.js +33 -0
  105. package/src/io/InputOutputSpecification.js +154 -157
  106. package/src/io/Properties.js +199 -0
  107. package/src/process/Process.js +374 -333
  108. package/src/process/ProcessExecution.js +606 -554
  109. package/src/shared.js +1 -5
  110. package/src/tasks/CallActivity.js +130 -0
  111. package/src/tasks/LoopCharacteristics.js +290 -289
  112. package/src/tasks/ReceiveTask.js +174 -107
  113. package/src/tasks/ScriptTask.js +27 -30
  114. package/src/tasks/ServiceImplementation.js +13 -18
  115. package/src/tasks/ServiceTask.js +67 -60
  116. package/src/tasks/SignalTask.js +77 -52
  117. package/src/tasks/StandardLoopCharacteristics.js +1 -1
  118. package/src/tasks/SubProcess.js +184 -157
  119. package/src/tasks/Task.js +15 -19
package/src/shared.js CHANGED
@@ -1,11 +1,7 @@
1
1
  const safePattern = /[./\\#*:\s]/g;
2
2
 
3
3
  export function generateId() {
4
- const min = 100000000;
5
- const max = 999999999;
6
- const rand = Math.floor(Math.random() * (max - min)) + min;
7
-
8
- return rand.toString(16);
4
+ return Math.random().toString(16).substring(2, 12);
9
5
  }
10
6
 
11
7
  export function brokerSafeId(id) {
@@ -0,0 +1,130 @@
1
+ import Activity from '../activity/Activity';
2
+ import {ActivityError} from '../error/Errors';
3
+ import {cloneContent} from '../messageHelper';
4
+
5
+ export default function CallActivity(activityDef, context) {
6
+ return new Activity(CallActivityBehaviour, activityDef, context);
7
+ }
8
+
9
+ export function CallActivityBehaviour(activity) {
10
+ const {id, type, behaviour = {}} = activity;
11
+
12
+ this.id = id;
13
+ this.type = type;
14
+ this.calledElement = behaviour.calledElement;
15
+ this.loopCharacteristics = behaviour.loopCharacteristics && new behaviour.loopCharacteristics.Behaviour(activity, behaviour.loopCharacteristics);
16
+ this.activity = activity;
17
+ this.broker = activity.broker;
18
+ this.environment = activity.environment;
19
+ }
20
+
21
+ const proto = CallActivityBehaviour.prototype;
22
+
23
+ proto.execute = function execute(executeMessage) {
24
+ const executeContent = executeMessage.content;
25
+ const loopCharacteristics = this.loopCharacteristics;
26
+ if (loopCharacteristics && executeContent.isRootScope) {
27
+ return loopCharacteristics.execute(executeMessage);
28
+ }
29
+
30
+ const broker = this.broker;
31
+ try {
32
+ var calledElement = this.environment.resolveExpression(this.calledElement); // eslint-disable-line no-var
33
+ } catch (err) {
34
+ return broker.publish('execution', 'execute.error', cloneContent(executeContent, {
35
+ error: new ActivityError(err.message, executeMessage, err),
36
+ }, {
37
+ mandatory: true,
38
+ }));
39
+ }
40
+
41
+ const executionId = executeContent.executionId;
42
+ broker.subscribeTmp('api', `activity.#.${executionId}`, (...args) => {
43
+ this._onApiMessage(calledElement, executeMessage, ...args);
44
+ }, {
45
+ noAck: true,
46
+ consumerTag: `_api-${executionId}`,
47
+ priority: 300,
48
+ });
49
+ broker.subscribeTmp('api', '#.signal.*', (...args) => this._onDelegatedApiMessage(calledElement, executeMessage, ...args), {
50
+ noAck: true,
51
+ consumerTag: `_api-delegated-${executionId}`,
52
+ });
53
+
54
+ broker.publish('event', 'activity.call', cloneContent(executeContent, {
55
+ state: 'wait',
56
+ calledElement,
57
+ }), {
58
+ type: 'call',
59
+ });
60
+ };
61
+
62
+ proto._onDelegatedApiMessage = function onDelegatedApiMessage(calledElement, executeMessage, routingKey, message) {
63
+ if (!message.properties.delegate) return;
64
+ const {content: delegateContent} = message;
65
+ if (!delegateContent || !delegateContent.message) return;
66
+
67
+ const executeContent = executeMessage.content;
68
+
69
+ const {id: signalId, executionId: signalExecutionId} = delegateContent.message;
70
+ if (this.loopCharacteristics && signalExecutionId !== executeContent.executionId) return;
71
+ if (signalId !== this.id && signalExecutionId !== executeContent.executionId) return;
72
+
73
+ const {type: messageType, correlationId} = message.properties;
74
+
75
+ this.broker.publish('event', 'activity.consumed', cloneContent(executeContent, {
76
+ message: { ...delegateContent.message},
77
+ }), {
78
+ correlationId,
79
+ type: messageType,
80
+ });
81
+
82
+ return this._onApiMessage(calledElement, executeMessage, routingKey, message);
83
+ };
84
+
85
+ proto._onApiMessage = function onApiMessage(calledElement, executeMessage, routingKey, message) {
86
+ const {type: messageType, correlationId} = message.properties;
87
+ const executeContent = executeMessage.content;
88
+
89
+ switch (messageType) {
90
+ case 'stop':
91
+ return this._stop(executeContent.executionId);
92
+ case 'cancel': {
93
+ this.broker.publish('event', 'activity.call.cancel', cloneContent(executeContent, {
94
+ state: 'cancel',
95
+ calledElement,
96
+ }), {
97
+ type: 'cancel',
98
+ });
99
+ }
100
+ case 'signal':
101
+ this._stop(executeContent.executionId);
102
+ return this.broker.publish('execution', 'execute.completed', cloneContent(executeContent, {
103
+ output: message.content.message,
104
+ state: messageType,
105
+ }), {
106
+ correlationId,
107
+ });
108
+ case 'error':
109
+ this._stop(executeContent.executionId);
110
+ return this.broker.publish('execution', 'execute.error', cloneContent(executeContent, {
111
+ error: new ActivityError(message.content.message, executeMessage, message.content),
112
+ }, {
113
+ mandatory: true,
114
+ correlationId,
115
+ }));
116
+ case 'discard':
117
+ return this.broker.publish('event', 'activity.call.cancel', cloneContent(executeContent, {
118
+ state: 'discard',
119
+ calledElement,
120
+ }), {
121
+ type: 'discard',
122
+ });
123
+ }
124
+ };
125
+
126
+ proto._stop = function stop(executionId) {
127
+ const broker = this.broker;
128
+ broker.cancel(`_api-${executionId}`);
129
+ broker.cancel(`_api-delegated-${executionId}`);
130
+ };