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/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,181 +3,191 @@ 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 = {}, 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
- getInboundAssociations,
30
- getInboundSequenceFlows,
31
- getMessageFlows,
32
- getOutboundSequenceFlows,
33
- getOutboundAssociations,
34
- getProcessById,
35
- getProcesses,
36
- getSequenceFlowById,
37
- getSequenceFlows,
38
- getStartActivities,
39
- 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: [],
40
30
  };
31
+ }
41
32
 
42
- const extensionsMapper = ExtensionsMapper(context);
33
+ ContextInstance.prototype.getActivityById = function getActivityById(activityId) {
34
+ const activityInstance = this.refs.activityRefs[activityId];
35
+ if (activityInstance) return activityInstance;
36
+ const activity = this.definitionContext.getActivityById(activityId);
37
+ if (!activity) return null;
38
+ return this.upsertActivity(activity);
39
+ };
43
40
 
44
- return context;
41
+ ContextInstance.prototype.upsertActivity = function upsertActivity(activityDef) {
42
+ let activityInstance = this.refs.activityRefs[activityDef.id];
43
+ if (activityInstance) return activityInstance;
45
44
 
46
- function getActivityById(activityId) {
47
- const activityInstance = activityRefs[activityId];
48
- if (activityInstance) return activityInstance;
49
- const activity = definitionContext.getActivityById(activityId);
50
- if (!activity) return null;
51
- return upsertActivity(activity);
52
- }
45
+ activityInstance = this.refs.activityRefs[activityDef.id] = new activityDef.Behaviour(activityDef, this);
53
46
 
54
- function upsertActivity(activityDef) {
55
- let activityInstance = activityRefs[activityDef.id];
56
- if (activityInstance) return activityInstance;
47
+ return activityInstance;
48
+ };
57
49
 
58
- activityInstance = activityRefs[activityDef.id] = activityDef.Behaviour(activityDef, context);
50
+ ContextInstance.prototype.getSequenceFlowById = function getSequenceFlowById(sequenceFlowId) {
51
+ const flowInstance = this.refs.sequenceFlowRefs[sequenceFlowId];
52
+ if (flowInstance) return flowInstance;
59
53
 
60
- return activityInstance;
61
- }
54
+ const flowDef = this.definitionContext.getSequenceFlowById(sequenceFlowId);
55
+ if (!flowDef) return null;
56
+ return this.upsertSequenceFlow(flowDef);
57
+ };
62
58
 
63
- function getSequenceFlowById(sequenceFlowId) {
64
- const flowInstance = sequenceFlowRefs[sequenceFlowId];
65
- if (flowInstance) return flowInstance;
59
+ ContextInstance.prototype.getInboundSequenceFlows = function getInboundSequenceFlows(activityId) {
60
+ return (this.definitionContext.getInboundSequenceFlows(activityId) || []).map((flow) => this.upsertSequenceFlow(flow));
61
+ };
66
62
 
67
- const flowDef = definitionContext.getSequenceFlowById(sequenceFlowId);
68
- if (!flowDef) return null;
69
- return upsertSequenceFlow(flowDef);
70
- }
63
+ ContextInstance.prototype.getOutboundSequenceFlows = function getOutboundSequenceFlows(activityId) {
64
+ return (this.definitionContext.getOutboundSequenceFlows(activityId) || []).map((flow) => this.upsertSequenceFlow(flow));
65
+ };
71
66
 
72
- function getInboundSequenceFlows(activityId) {
73
- return (definitionContext.getInboundSequenceFlows(activityId) || []).map((flow) => upsertSequenceFlow(flow));
74
- }
67
+ ContextInstance.prototype.getInboundAssociations = function getInboundAssociations(activityId) {
68
+ return (this.definitionContext.getInboundAssociations(activityId) || []).map((association) => this.upsertAssociation(association));
69
+ };
75
70
 
76
- function getOutboundSequenceFlows(activityId) {
77
- return (definitionContext.getOutboundSequenceFlows(activityId) || []).map((flow) => upsertSequenceFlow(flow));
78
- }
71
+ ContextInstance.prototype.getOutboundAssociations = function getOutboundAssociations(activityId) {
72
+ return (this.definitionContext.getOutboundAssociations(activityId) || []).map((association) => this.upsertAssociation(association));
73
+ };
79
74
 
80
- function getInboundAssociations(activityId) {
81
- return (definitionContext.getInboundAssociations(activityId) || []).map((association) => upsertAssociation(association));
82
- }
75
+ ContextInstance.prototype.getActivities = function getActivities(scopeId) {
76
+ return (this.definitionContext.getActivities(scopeId) || []).map((activityDef) => this.upsertActivity(activityDef));
77
+ };
83
78
 
84
- function getOutboundAssociations(activityId) {
85
- return (definitionContext.getOutboundAssociations(activityId) || []).map((association) => upsertAssociation(association));
86
- }
79
+ ContextInstance.prototype.getSequenceFlows = function getSequenceFlows(scopeId) {
80
+ return (this.definitionContext.getSequenceFlows(scopeId) || []).map((flow) => this.upsertSequenceFlow(flow));
81
+ };
87
82
 
88
- function getActivities(scopeId) {
89
- return (definitionContext.getActivities(scopeId) || []).map((activityDef) => upsertActivity(activityDef));
90
- }
83
+ ContextInstance.prototype.upsertSequenceFlow = function upsertSequenceFlow(flowDefinition) {
84
+ const refs = this.refs.sequenceFlowRefs;
85
+ let flowInstance = refs[flowDefinition.id];
86
+ if (flowInstance) return flowInstance;
91
87
 
92
- function getSequenceFlows(scopeId) {
93
- return (definitionContext.getSequenceFlows(scopeId) || []).map((flow) => upsertSequenceFlow(flow));
94
- }
88
+ flowInstance = refs[flowDefinition.id] = new flowDefinition.Behaviour(flowDefinition, this);
89
+ this.refs.sequenceFlows.push(flowInstance);
95
90
 
96
- function upsertSequenceFlow(flowDefinition) {
97
- let flowInstance = sequenceFlowRefs[flowDefinition.id];
98
- if (flowInstance) return flowInstance;
91
+ return flowInstance;
92
+ };
99
93
 
100
- flowInstance = sequenceFlowRefs[flowDefinition.id] = flowDefinition.Behaviour(flowDefinition, context);
101
- sequenceFlows.push(flowInstance);
94
+ ContextInstance.prototype.getAssociations = function getAssociations(scopeId) {
95
+ return (this.definitionContext.getAssociations(scopeId) || []).map((association) => this.upsertAssociation(association));
96
+ };
102
97
 
103
- return flowInstance;
104
- }
98
+ ContextInstance.prototype.upsertAssociation = function upsertAssociation(associationDefinition) {
99
+ const refs = this.refs.associationRefs;
100
+ let instance = refs[associationDefinition.id];
101
+ if (instance) return instance;
105
102
 
106
- function getAssociations(scopeId) {
107
- return (definitionContext.getAssociations(scopeId) || []).map((association) => upsertAssociation(association));
108
- }
103
+ instance = refs[associationDefinition.id] = new associationDefinition.Behaviour(associationDefinition, this);
109
104
 
110
- function upsertAssociation(associationDefinition) {
111
- let instance = associationRefs[associationDefinition.id];
112
- if (instance) return instance;
105
+ return instance;
106
+ };
113
107
 
114
- instance = associationRefs[associationDefinition.id] = associationDefinition.Behaviour(associationDefinition, context);
108
+ ContextInstance.prototype.clone = function clone(newEnvironment) {
109
+ return new ContextInstance(this.definitionContext, newEnvironment || this.environment);
110
+ };
115
111
 
116
- return instance;
117
- }
112
+ ContextInstance.prototype.getProcessById = function getProcessById(processId) {
113
+ const refs = this.refs.processRefs;
114
+ let processInstance = this.refs.processRefs[processId];
115
+ if (processInstance) return processInstance;
118
116
 
119
- function clone(newEnvironment) {
120
- return ContextInstance(definitionContext, newEnvironment || environment);
121
- }
117
+ const processDefinition = this.definitionContext.getProcessById(processId);
118
+ if (!processDefinition) return null;
122
119
 
123
- function getProcessById(processId) {
124
- let processInstance = processRefs[processId];
125
- if (processInstance) return processInstance;
120
+ processInstance = refs[processId] = new processDefinition.Behaviour(processDefinition, this);
121
+ this.refs.processes.push(processInstance);
126
122
 
127
- const processDefinition = definitionContext.getProcessById(processId);
128
- if (!processDefinition) return null;
129
- processInstance = processRefs[processId] = processDefinition.Behaviour(processDefinition, context);
130
- processes.push(processInstance);
123
+ return processInstance;
124
+ };
131
125
 
132
- return processInstance;
133
- }
126
+ ContextInstance.prototype.getNewProcessById = function getNewProcessById(processId, processOptions) {
127
+ if (!this.getProcessById(processId)) return null;
128
+ const processDefinition = this.definitionContext.getProcessById(processId);
129
+ const processInstance = new processDefinition.Behaviour(processDefinition, this.clone(this.environment.clone({output: {}, ...processOptions})));
130
+ return processInstance;
131
+ };
134
132
 
135
- function getProcesses() {
136
- return definitionContext.getProcesses().map(({id: processId}) => getProcessById(processId));
137
- }
133
+ ContextInstance.prototype.getProcesses = function getProcesses() {
134
+ return this.definitionContext.getProcesses().map(({id: processId}) => this.getProcessById(processId));
135
+ };
136
+
137
+ ContextInstance.prototype.getExecutableProcesses = function getExecutableProcesses() {
138
+ return this.definitionContext.getExecutableProcesses().map(({id: processId}) => this.getProcessById(processId));
139
+ };
138
140
 
139
- function getExecutableProcesses() {
140
- return definitionContext.getExecutableProcesses().map(({id: processId}) => getProcessById(processId));
141
+ ContextInstance.prototype.getMessageFlows = function getMessageFlows(sourceId) {
142
+ if (!this.refs.messageFlows.length) {
143
+ const flows = this.definitionContext.getMessageFlows() || [];
144
+ this.refs.messageFlows.push(...flows.map((flow) => new flow.Behaviour(flow, this)));
141
145
  }
142
146
 
143
- function getMessageFlows(sourceId) {
144
- if (!messageFlows.length) {
145
- const flows = definitionContext.getMessageFlows() || [];
146
- messageFlows.push(...flows.map((flow) => flow.Behaviour(flow, context)));
147
- }
147
+ return this.refs.messageFlows.filter((flow) => flow.source.processId === sourceId);
148
+ };
148
149
 
149
- return messageFlows.filter((flow) => flow.source.processId === sourceId);
150
- }
150
+ ContextInstance.prototype.getDataObjectById = function getDataObjectById(referenceId) {
151
+ let dataObject;
152
+ if ((dataObject = this.refs.dataObjectRefs[referenceId])) return dataObject;
151
153
 
152
- function getDataObjectById(dataObjectId) {
153
- let dataObject;
154
- if ((dataObject = dataObjectRefs[dataObjectId])) return dataObject;
154
+ const dataObjectDef = this.definitionContext.getDataObjectById(referenceId);
155
+ if (!dataObjectDef) return;
155
156
 
156
- const dataObjectDef = definitionContext.getDataObjectById(dataObjectId);
157
- if (!dataObjectDef) return;
157
+ dataObject = this.refs.dataObjectRefs[dataObjectDef.id] = new dataObjectDef.Behaviour(dataObjectDef, this);
158
158
 
159
- dataObject = dataObjectRefs[dataObjectDef.id] = dataObjectDef.Behaviour(dataObjectDef, context);
159
+ return dataObject;
160
+ };
160
161
 
161
- return dataObject;
162
- }
162
+ ContextInstance.prototype.getDataStoreById = function getDataStoreById(referenceId) {
163
+ let dataStore;
164
+ if ((dataStore = this.refs.dataStoreRefs[referenceId])) return dataStore;
165
+
166
+ const dataStoreDef = this.definitionContext.getDataStoreById(referenceId) || this.definitionContext.getDataStoreReferenceById(referenceId);
167
+ if (!dataStoreDef) return;
163
168
 
164
- function getStartActivities(filterOptions, scopeId) {
165
- const {referenceId, referenceType = 'unknown'} = filterOptions || {};
166
- return getActivities().filter((activity) => {
167
- if (!activity.isStart) return false;
168
- if (scopeId && activity.parent.id !== scopeId) return false;
169
- if (!filterOptions) return true;
169
+ dataStore = this.refs.dataStoreRefs[dataStoreDef.id] = new dataStoreDef.Behaviour(dataStoreDef, this);
170
170
 
171
- if (!activity.behaviour.eventDefinitions && !activity.behaviour.eventDefinitions) return false;
171
+ return dataStore;
172
+ };
172
173
 
173
- return activity.eventDefinitions.some((ed) => {
174
- return ed.reference && ed.reference.id === referenceId && ed.reference.referenceType === referenceType;
175
- });
174
+ ContextInstance.prototype.getStartActivities = function getStartActivities(filterOptions, scopeId) {
175
+ const {referenceId, referenceType = 'unknown'} = filterOptions || {};
176
+ return this.getActivities().filter((activity) => {
177
+ if (!activity.isStart) return false;
178
+ if (scopeId && activity.parent.id !== scopeId) return false;
179
+ if (!filterOptions) return true;
180
+
181
+ if (!activity.behaviour.eventDefinitions && !activity.behaviour.eventDefinitions) return false;
182
+
183
+
184
+ return activity.eventDefinitions.some((ed) => {
185
+ return ed.reference && ed.reference.id === referenceId && ed.reference.referenceType === referenceType;
176
186
  });
177
- }
187
+ });
188
+ };
178
189
 
179
- function loadExtensions(activity) {
180
- return extensionsMapper.get(activity);
181
- }
182
- }
190
+ ContextInstance.prototype.loadExtensions = function loadExtensions(activity) {
191
+ return this.extensionsMapper.get(activity);
192
+ };
183
193