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
package/src/Api.js CHANGED
@@ -10,80 +10,86 @@ export {
10
10
  };
11
11
 
12
12
  function ActivityApi(broker, apiMessage, environment) {
13
- return Api('activity', broker, apiMessage, environment);
13
+ return new Api('activity', broker, apiMessage, environment);
14
14
  }
15
15
 
16
16
  function DefinitionApi(broker, apiMessage, environment) {
17
- return Api('definition', broker, apiMessage, environment);
17
+ return new Api('definition', broker, apiMessage, environment);
18
18
  }
19
19
 
20
20
  function ProcessApi(broker, apiMessage, environment) {
21
- return Api('process', broker, apiMessage, environment);
21
+ return new Api('process', broker, apiMessage, environment);
22
22
  }
23
23
 
24
24
  function FlowApi(broker, apiMessage, environment) {
25
- return Api('flow', broker, apiMessage, environment);
25
+ return new Api('flow', broker, apiMessage, environment);
26
26
  }
27
27
 
28
28
  function Api(pfx, broker, sourceMessage, environment) {
29
29
  if (!sourceMessage) throw new Error('Api requires message');
30
30
 
31
31
  const apiMessage = cloneMessage(sourceMessage);
32
- const apiContent = apiMessage.content;
33
- const {id, type, name} = apiContent;
34
- const executionId = apiContent.executionId;
35
- const owner = broker.owner;
36
- environment = environment || broker.owner.environment;
37
32
 
33
+ const {id, type, name, executionId} = apiMessage.content;
34
+ this.id = id;
35
+ this.type = type;
36
+ this.name = name;
37
+ this.executionId = executionId;
38
+ this.environment = environment || broker.owner.environment;
39
+ this.content = apiMessage.content;
40
+ this.fields = apiMessage.fields;
41
+ this.messageProperties = apiMessage.properties;
42
+ this.broker = broker;
43
+ this.owner = broker.owner;
44
+ this.messagePrefix = pfx;
45
+ }
46
+
47
+ const proto = Api.prototype;
48
+
49
+ proto.cancel = function cancel(message, options) {
50
+ this.sendApiMessage('cancel', {message}, options);
51
+ };
52
+
53
+ proto.discard = function discard() {
54
+ this.sendApiMessage('discard');
55
+ };
56
+
57
+ proto.fail = function fail(error) {
58
+ this.sendApiMessage('error', {error});
59
+ };
60
+
61
+ proto.signal = function signal(message, options) {
62
+ this.sendApiMessage('signal', {message}, options);
63
+ };
64
+
65
+ proto.stop = function stop() {
66
+ this.sendApiMessage('stop');
67
+ };
68
+
69
+ proto.resolveExpression = function resolveExpression(expression) {
70
+ return this.environment.resolveExpression(expression, {
71
+ fields: this.fields,
72
+ content: this.content,
73
+ properties: this.messageProperties,
74
+ }, this.owner);
75
+ };
76
+
77
+ proto.sendApiMessage = function sendApiMessage(action, content, options) {
78
+ const correlationId = (options && options.correlationId) || getUniqueId(`${this.id || this.messagePrefix}_signal`);
79
+ let key = `${this.messagePrefix}.${action}`;
80
+ if (this.executionId) key += `.${this.executionId}`;
81
+ this.broker.publish('api', key, this.createMessage(content), {...options, correlationId, type: action});
82
+ };
83
+
84
+ proto.getPostponed = function getPostponed(...args) {
85
+ if (this.owner.getPostponed) return this.owner.getPostponed(...args);
86
+ if (this.owner.isSubProcess && this.owner.execution) return this.owner.execution.getPostponed(...args);
87
+ return [];
88
+ };
89
+
90
+ proto.createMessage = function createMessage(content) {
38
91
  return {
39
- id,
40
- type,
41
- name,
42
- executionId,
43
- environment,
44
- fields: apiMessage.fields,
45
- content: apiContent,
46
- messageProperties: apiMessage.properties,
47
- get owner() {
48
- return owner;
49
- },
50
- cancel(message, options) {
51
- sendApiMessage('cancel', {message}, options);
52
- },
53
- discard() {
54
- sendApiMessage('discard');
55
- },
56
- signal(message, options) {
57
- sendApiMessage('signal', {message}, options);
58
- },
59
- stop() {
60
- sendApiMessage('stop');
61
- },
62
- resolveExpression(expression) {
63
- return environment.resolveExpression(expression, apiMessage, broker.owner);
64
- },
65
- sendApiMessage,
66
- createMessage,
67
- getPostponed,
92
+ ...this.content,
93
+ ...content,
68
94
  };
69
-
70
- function sendApiMessage(action, content, options = {}) {
71
- if (!options.correlationId) options = {...options, correlationId: getUniqueId(`${id || pfx}_signal`)};
72
- let key = `${pfx}.${action}`;
73
- if (executionId) key += `.${executionId}`;
74
- broker.publish('api', key, createMessage(content), {...options, type: action});
75
- }
76
-
77
- function getPostponed(...args) {
78
- if (owner.getPostponed) return owner.getPostponed(...args);
79
- if (owner.isSubProcess && owner.execution) return owner.execution.getPostponed(...args);
80
- return [];
81
- }
82
-
83
- function createMessage(content = {}) {
84
- return {
85
- ...apiContent,
86
- ...content,
87
- };
88
- }
89
- }
95
+ };
package/src/Context.js CHANGED
@@ -3,194 +3,199 @@ import ExtensionsMapper from './ExtensionsMapper';
3
3
  import {getUniqueId} from './shared';
4
4
 
5
5
  export default function Context(definitionContext, environment) {
6
- environment = environment ? environment.clone() : Environment();
7
- return ContextInstance(definitionContext, environment);
6
+ environment = environment ? environment.clone() : new Environment();
7
+ return new ContextInstance(definitionContext, environment);
8
8
  }
9
9
 
10
10
  function ContextInstance(definitionContext, environment) {
11
11
  const {id = 'Def', name, type = 'context'} = definitionContext;
12
12
  const sid = getUniqueId(id);
13
-
14
- const activityRefs = {}, dataObjectRefs = {}, dataStoreRefs = {}, messageFlows = [], processes = [], processRefs = {}, sequenceFlowRefs = {}, sequenceFlows = [], associationRefs = [];
15
-
16
- const context = {
17
- id,
18
- name,
19
- type,
20
- sid,
21
- definitionContext,
22
- environment,
23
- clone,
24
- getActivities,
25
- getActivityById,
26
- getAssociations,
27
- getExecutableProcesses,
28
- getDataObjectById,
29
- getDataStoreById,
30
- getInboundAssociations,
31
- getInboundSequenceFlows,
32
- getMessageFlows,
33
- getOutboundSequenceFlows,
34
- getOutboundAssociations,
35
- getProcessById,
36
- getProcesses,
37
- getSequenceFlowById,
38
- getSequenceFlows,
39
- getStartActivities,
40
- loadExtensions,
13
+ this.id = id;
14
+ this.name = name;
15
+ this.type = type;
16
+ this.sid = sid;
17
+ this.definitionContext = definitionContext;
18
+ this.environment = environment;
19
+ this.extensionsMapper = ExtensionsMapper(this);
20
+ this.refs = {
21
+ activityRefs: {},
22
+ associationRefs: [],
23
+ dataObjectRefs: {},
24
+ dataStoreRefs: {},
25
+ messageFlows: [],
26
+ processes: [],
27
+ processRefs: {},
28
+ sequenceFlowRefs: {},
29
+ sequenceFlows: [],
41
30
  };
31
+ }
42
32
 
43
- const extensionsMapper = ExtensionsMapper(context);
33
+ const proto = ContextInstance.prototype;
44
34
 
45
- return context;
35
+ proto.getActivityById = function getActivityById(activityId) {
36
+ const activityInstance = this.refs.activityRefs[activityId];
37
+ if (activityInstance) return activityInstance;
38
+ const activity = this.definitionContext.getActivityById(activityId);
39
+ if (!activity) return null;
40
+ return this.upsertActivity(activity);
41
+ };
46
42
 
47
- function getActivityById(activityId) {
48
- const activityInstance = activityRefs[activityId];
49
- if (activityInstance) return activityInstance;
50
- const activity = definitionContext.getActivityById(activityId);
51
- if (!activity) return null;
52
- return upsertActivity(activity);
53
- }
43
+ proto.upsertActivity = function upsertActivity(activityDef) {
44
+ let activityInstance = this.refs.activityRefs[activityDef.id];
45
+ if (activityInstance) return activityInstance;
54
46
 
55
- function upsertActivity(activityDef) {
56
- let activityInstance = activityRefs[activityDef.id];
57
- if (activityInstance) return activityInstance;
47
+ activityInstance = this.refs.activityRefs[activityDef.id] = new activityDef.Behaviour(activityDef, this);
58
48
 
59
- activityInstance = activityRefs[activityDef.id] = activityDef.Behaviour(activityDef, context);
49
+ return activityInstance;
50
+ };
60
51
 
61
- return activityInstance;
62
- }
52
+ proto.getSequenceFlowById = function getSequenceFlowById(sequenceFlowId) {
53
+ const flowInstance = this.refs.sequenceFlowRefs[sequenceFlowId];
54
+ if (flowInstance) return flowInstance;
63
55
 
64
- function getSequenceFlowById(sequenceFlowId) {
65
- const flowInstance = sequenceFlowRefs[sequenceFlowId];
66
- if (flowInstance) return flowInstance;
56
+ const flowDef = this.definitionContext.getSequenceFlowById(sequenceFlowId);
57
+ if (!flowDef) return null;
58
+ return this.upsertSequenceFlow(flowDef);
59
+ };
67
60
 
68
- const flowDef = definitionContext.getSequenceFlowById(sequenceFlowId);
69
- if (!flowDef) return null;
70
- return upsertSequenceFlow(flowDef);
71
- }
61
+ proto.getInboundSequenceFlows = function getInboundSequenceFlows(activityId) {
62
+ return (this.definitionContext.getInboundSequenceFlows(activityId) || []).map((flow) => this.upsertSequenceFlow(flow));
63
+ };
72
64
 
73
- function getInboundSequenceFlows(activityId) {
74
- return (definitionContext.getInboundSequenceFlows(activityId) || []).map((flow) => upsertSequenceFlow(flow));
75
- }
65
+ proto.getOutboundSequenceFlows = function getOutboundSequenceFlows(activityId) {
66
+ return (this.definitionContext.getOutboundSequenceFlows(activityId) || []).map((flow) => this.upsertSequenceFlow(flow));
67
+ };
76
68
 
77
- function getOutboundSequenceFlows(activityId) {
78
- return (definitionContext.getOutboundSequenceFlows(activityId) || []).map((flow) => upsertSequenceFlow(flow));
79
- }
69
+ proto.getInboundAssociations = function getInboundAssociations(activityId) {
70
+ return (this.definitionContext.getInboundAssociations(activityId) || []).map((association) => this.upsertAssociation(association));
71
+ };
80
72
 
81
- function getInboundAssociations(activityId) {
82
- return (definitionContext.getInboundAssociations(activityId) || []).map((association) => upsertAssociation(association));
83
- }
73
+ proto.getOutboundAssociations = function getOutboundAssociations(activityId) {
74
+ return (this.definitionContext.getOutboundAssociations(activityId) || []).map((association) => this.upsertAssociation(association));
75
+ };
84
76
 
85
- function getOutboundAssociations(activityId) {
86
- return (definitionContext.getOutboundAssociations(activityId) || []).map((association) => upsertAssociation(association));
87
- }
77
+ proto.getActivities = function getActivities(scopeId) {
78
+ return (this.definitionContext.getActivities(scopeId) || []).map((activityDef) => this.upsertActivity(activityDef));
79
+ };
88
80
 
89
- function getActivities(scopeId) {
90
- return (definitionContext.getActivities(scopeId) || []).map((activityDef) => upsertActivity(activityDef));
91
- }
81
+ proto.getSequenceFlows = function getSequenceFlows(scopeId) {
82
+ return (this.definitionContext.getSequenceFlows(scopeId) || []).map((flow) => this.upsertSequenceFlow(flow));
83
+ };
92
84
 
93
- function getSequenceFlows(scopeId) {
94
- return (definitionContext.getSequenceFlows(scopeId) || []).map((flow) => upsertSequenceFlow(flow));
95
- }
85
+ proto.upsertSequenceFlow = function upsertSequenceFlow(flowDefinition) {
86
+ const refs = this.refs.sequenceFlowRefs;
87
+ let flowInstance = refs[flowDefinition.id];
88
+ if (flowInstance) return flowInstance;
96
89
 
97
- function upsertSequenceFlow(flowDefinition) {
98
- let flowInstance = sequenceFlowRefs[flowDefinition.id];
99
- if (flowInstance) return flowInstance;
90
+ flowInstance = refs[flowDefinition.id] = new flowDefinition.Behaviour(flowDefinition, this);
91
+ this.refs.sequenceFlows.push(flowInstance);
100
92
 
101
- flowInstance = sequenceFlowRefs[flowDefinition.id] = flowDefinition.Behaviour(flowDefinition, context);
102
- sequenceFlows.push(flowInstance);
93
+ return flowInstance;
94
+ };
103
95
 
104
- return flowInstance;
105
- }
96
+ proto.getAssociations = function getAssociations(scopeId) {
97
+ return (this.definitionContext.getAssociations(scopeId) || []).map((association) => this.upsertAssociation(association));
98
+ };
106
99
 
107
- function getAssociations(scopeId) {
108
- return (definitionContext.getAssociations(scopeId) || []).map((association) => upsertAssociation(association));
109
- }
100
+ proto.upsertAssociation = function upsertAssociation(associationDefinition) {
101
+ const refs = this.refs.associationRefs;
102
+ let instance = refs[associationDefinition.id];
103
+ if (instance) return instance;
110
104
 
111
- function upsertAssociation(associationDefinition) {
112
- let instance = associationRefs[associationDefinition.id];
113
- if (instance) return instance;
105
+ instance = refs[associationDefinition.id] = new associationDefinition.Behaviour(associationDefinition, this);
114
106
 
115
- instance = associationRefs[associationDefinition.id] = associationDefinition.Behaviour(associationDefinition, context);
107
+ return instance;
108
+ };
116
109
 
117
- return instance;
118
- }
110
+ proto.clone = function clone(newEnvironment) {
111
+ return new ContextInstance(this.definitionContext, newEnvironment || this.environment);
112
+ };
119
113
 
120
- function clone(newEnvironment) {
121
- return ContextInstance(definitionContext, newEnvironment || environment);
122
- }
114
+ proto.getProcessById = function getProcessById(processId) {
115
+ const refs = this.refs.processRefs;
116
+ let bp = this.refs.processRefs[processId];
117
+ if (bp) return bp;
123
118
 
124
- function getProcessById(processId) {
125
- let processInstance = processRefs[processId];
126
- if (processInstance) return processInstance;
119
+ const processDefinition = this.definitionContext.getProcessById(processId);
120
+ if (!processDefinition) return null;
127
121
 
128
- const processDefinition = definitionContext.getProcessById(processId);
129
- if (!processDefinition) return null;
130
- processInstance = processRefs[processId] = processDefinition.Behaviour(processDefinition, context);
131
- processes.push(processInstance);
122
+ const bpContext = this.clone(this.environment.clone());
123
+ bp = refs[processId] = new processDefinition.Behaviour(processDefinition, bpContext);
124
+ this.refs.processes.push(bp);
132
125
 
133
- return processInstance;
134
- }
126
+ return bp;
127
+ };
135
128
 
136
- function getProcesses() {
137
- return definitionContext.getProcesses().map(({id: processId}) => getProcessById(processId));
138
- }
129
+ proto.getNewProcessById = function getNewProcessById(processId) {
130
+ if (!this.getProcessById(processId)) return null;
131
+ const bpDef = this.definitionContext.getProcessById(processId);
132
+ const bp = new bpDef.Behaviour(bpDef, this.clone(this.environment.clone()));
133
+ return bp;
134
+ };
139
135
 
140
- function getExecutableProcesses() {
141
- return definitionContext.getExecutableProcesses().map(({id: processId}) => getProcessById(processId));
142
- }
136
+ proto.getProcesses = function getProcesses() {
137
+ return this.definitionContext.getProcesses().map(({id: processId}) => this.getProcessById(processId));
138
+ };
143
139
 
144
- function getMessageFlows(sourceId) {
145
- if (!messageFlows.length) {
146
- const flows = definitionContext.getMessageFlows() || [];
147
- messageFlows.push(...flows.map((flow) => flow.Behaviour(flow, context)));
148
- }
140
+ proto.getExecutableProcesses = function getExecutableProcesses() {
141
+ return this.definitionContext.getExecutableProcesses().map(({id: processId}) => this.getProcessById(processId));
142
+ };
149
143
 
150
- return messageFlows.filter((flow) => flow.source.processId === sourceId);
144
+ proto.getMessageFlows = function getMessageFlows(sourceId) {
145
+ if (!this.refs.messageFlows.length) {
146
+ const flows = this.definitionContext.getMessageFlows() || [];
147
+ this.refs.messageFlows.push(...flows.map((flow) => new flow.Behaviour(flow, this)));
151
148
  }
152
149
 
153
- function getDataObjectById(referenceId) {
154
- let dataObject;
155
- if ((dataObject = dataObjectRefs[referenceId])) return dataObject;
150
+ return this.refs.messageFlows.filter((flow) => flow.source.processId === sourceId);
151
+ };
156
152
 
157
- const dataObjectDef = definitionContext.getDataObjectById(referenceId);
158
- if (!dataObjectDef) return;
153
+ proto.getDataObjectById = function getDataObjectById(referenceId) {
154
+ let dataObject;
155
+ if ((dataObject = this.refs.dataObjectRefs[referenceId])) return dataObject;
159
156
 
160
- dataObject = dataObjectRefs[dataObjectDef.id] = dataObjectDef.Behaviour(dataObjectDef, context);
157
+ const dataObjectDef = this.definitionContext.getDataObjectById(referenceId);
158
+ if (!dataObjectDef) return;
161
159
 
162
- return dataObject;
163
- }
160
+ dataObject = this.refs.dataObjectRefs[dataObjectDef.id] = new dataObjectDef.Behaviour(dataObjectDef, this);
164
161
 
165
- function getDataStoreById(referenceId) {
166
- let dataStore;
167
- if ((dataStore = dataStoreRefs[referenceId])) return dataStore;
162
+ return dataObject;
163
+ };
168
164
 
169
- const dataStoreDef = definitionContext.getDataStoreById(referenceId) || definitionContext.getDataStoreReferenceById(referenceId);
170
- if (!dataStoreDef) return;
165
+ proto.getDataStoreById = function getDataStoreById(referenceId) {
166
+ let dataStore;
167
+ if ((dataStore = this.refs.dataStoreRefs[referenceId])) return dataStore;
171
168
 
172
- dataStore = dataStoreRefs[dataStoreDef.id] = dataStoreDef.Behaviour(dataStoreDef, context);
169
+ const dataStoreDef = this.definitionContext.getDataStoreById(referenceId) || this.definitionContext.getDataStoreReferenceById(referenceId);
170
+ if (!dataStoreDef) return;
173
171
 
174
- return dataStore;
175
- }
172
+ dataStore = this.refs.dataStoreRefs[dataStoreDef.id] = new dataStoreDef.Behaviour(dataStoreDef, this);
173
+
174
+ return dataStore;
175
+ };
176
176
 
177
- function getStartActivities(filterOptions, scopeId) {
178
- const {referenceId, referenceType = 'unknown'} = filterOptions || {};
179
- return getActivities().filter((activity) => {
180
- if (!activity.isStart) return false;
181
- if (scopeId && activity.parent.id !== scopeId) return false;
182
- if (!filterOptions) return true;
177
+ proto.getStartActivities = function getStartActivities(filterOptions, scopeId) {
178
+ const {referenceId, referenceType = 'unknown'} = filterOptions || {};
179
+ const result = [];
180
+ for (const activity of this.getActivities()) {
181
+ if (!activity.isStart) continue;
182
+ if (scopeId && activity.parent.id !== scopeId) continue;
183
+ if (!filterOptions) {
184
+ result.push(activity);
185
+ continue;
186
+ }
183
187
 
184
- if (!activity.behaviour.eventDefinitions && !activity.behaviour.eventDefinitions) return false;
188
+ if (!activity.behaviour.eventDefinitions && !activity.behaviour.eventDefinitions) continue;
185
189
 
186
- return activity.eventDefinitions.some((ed) => {
187
- return ed.reference && ed.reference.id === referenceId && ed.reference.referenceType === referenceType;
188
- });
190
+ const ref = activity.eventDefinitions.some((ed) => {
191
+ return ed.reference && ed.reference.id === referenceId && ed.reference.referenceType === referenceType;
189
192
  });
193
+ if (ref) result.push(activity);
190
194
  }
195
+ return result;
196
+ };
191
197
 
192
- function loadExtensions(activity) {
193
- return extensionsMapper.get(activity);
194
- }
195
- }
198
+ proto.loadExtensions = function loadExtensions(activity) {
199
+ return this.extensionsMapper.get(activity);
200
+ };
196
201