bpmn-elements 18.0.3 → 18.0.4

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.
@@ -116,6 +116,16 @@ ProcessExecution.prototype.execute = function execute(executeMessage) {
116
116
  });
117
117
  this[_constants.K_STOPPED] = false;
118
118
  this.environment.assignVariables(executeMessage);
119
+
120
+ // Seed input from the execute content (sub process) or a single inbound trigger (call activity forwarding its formatted input).
121
+ const content = executeMessage.content;
122
+ const inbound = content.inbound;
123
+ const input = content.input ?? (inbound?.length === 1 && inbound[0].input);
124
+ if (input) {
125
+ this.environment.assignVariables({
126
+ input
127
+ });
128
+ }
119
129
  this[K_ACTIVITY_Q] = this.broker.assertQueue(`execute-${executionId}-q`, {
120
130
  durable: true,
121
131
  autoDelete: false
@@ -73,10 +73,25 @@ CallActivityBehaviour.prototype.execute = function execute(executeMessage) {
73
73
  noAck: true,
74
74
  consumerTag: `_api-delegated-cancel-${executionId}`
75
75
  });
76
- broker.publish('event', 'activity.call', (0, _messageHelper.cloneContent)(executeContent, {
76
+ const callContent = {
77
77
  state: 'wait',
78
78
  calledElement
79
- }), {
79
+ };
80
+
81
+ // Forward the multi-instance loop context as input to the called process; any current content input takes precedence.
82
+ if (executeContent.isMultiInstance) {
83
+ const input = {
84
+ isSequential: executeContent.isSequential,
85
+ index: executeContent.index,
86
+ cardinality: executeContent.loopCardinality
87
+ };
88
+ const elementVariable = loopCharacteristics?.elementVariable;
89
+ if (elementVariable && elementVariable in executeContent) {
90
+ input[elementVariable] = executeContent[elementVariable];
91
+ }
92
+ callContent.input = Object.assign(input, executeContent.input);
93
+ }
94
+ broker.publish('event', 'activity.call', (0, _messageHelper.cloneContent)(executeContent, callContent), {
80
95
  type: 'call'
81
96
  });
82
97
  };
@@ -96,8 +96,29 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
96
96
  if (loopCharacteristics && isRootScope) {
97
97
  return loopCharacteristics.execute(executeMessage);
98
98
  }
99
- const processExecution = this._upsertExecution(executeMessage);
100
- return processExecution.execute(executeMessage);
99
+
100
+ // Forward the multi-instance loop context as input to the sub process execution; any current content input takes precedence.
101
+ let message = executeMessage;
102
+ const content = executeMessage.content;
103
+ if (content.isMultiInstance) {
104
+ const input = {
105
+ isSequential: content.isSequential,
106
+ index: content.index,
107
+ cardinality: content.loopCardinality
108
+ };
109
+ const elementVariable = loopCharacteristics?.elementVariable;
110
+ if (elementVariable && elementVariable in content) {
111
+ input[elementVariable] = content[elementVariable];
112
+ }
113
+ message = (0, _messageHelper.cloneMessage)(executeMessage, {
114
+ input: {
115
+ ...input,
116
+ ...content.input
117
+ }
118
+ });
119
+ }
120
+ const processExecution = this._upsertExecution(message);
121
+ return processExecution.execute(message);
101
122
  };
102
123
  SubProcessBehaviour.prototype.getState = function getState() {
103
124
  const states = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-elements",
3
- "version": "18.0.3",
3
+ "version": "18.0.4",
4
4
  "description": "Executable workflow elements based on BPMN 2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -112,6 +112,15 @@ ProcessExecution.prototype.execute = function execute(executeMessage) {
112
112
  this[K_STOPPED] = false;
113
113
 
114
114
  this.environment.assignVariables(executeMessage);
115
+
116
+ // Seed input from the execute content (sub process) or a single inbound trigger (call activity forwarding its formatted input).
117
+ const content = executeMessage.content;
118
+ const inbound = content.inbound;
119
+ const input = content.input ?? (inbound?.length === 1 && inbound[0].input);
120
+ if (input) {
121
+ this.environment.assignVariables({ input });
122
+ }
123
+
115
124
  this[K_ACTIVITY_Q] = this.broker.assertQueue(`execute-${executionId}-q`, { durable: true, autoDelete: false });
116
125
 
117
126
  if (executeMessage.fields.redelivered) {
@@ -80,17 +80,28 @@ CallActivityBehaviour.prototype.execute = function execute(executeMessage) {
80
80
  consumerTag: `_api-delegated-cancel-${executionId}`,
81
81
  });
82
82
 
83
- broker.publish(
84
- 'event',
85
- 'activity.call',
86
- cloneContent(executeContent, {
87
- state: 'wait',
88
- calledElement,
89
- }),
90
- {
91
- type: 'call',
83
+ const callContent = {
84
+ state: 'wait',
85
+ calledElement,
86
+ };
87
+
88
+ // Forward the multi-instance loop context as input to the called process; any current content input takes precedence.
89
+ if (executeContent.isMultiInstance) {
90
+ const input = {
91
+ isSequential: executeContent.isSequential,
92
+ index: executeContent.index,
93
+ cardinality: executeContent.loopCardinality,
94
+ };
95
+ const elementVariable = loopCharacteristics?.elementVariable;
96
+ if (elementVariable && elementVariable in executeContent) {
97
+ input[elementVariable] = executeContent[elementVariable];
92
98
  }
93
- );
99
+ callContent.input = Object.assign(input, executeContent.input);
100
+ }
101
+
102
+ broker.publish('event', 'activity.call', cloneContent(executeContent, callContent), {
103
+ type: 'call',
104
+ });
94
105
  };
95
106
 
96
107
  CallActivityBehaviour.prototype._onDelegatedApiMessage = function onDelegatedApiMessage(
@@ -1,6 +1,6 @@
1
1
  import { Activity } from '../activity/Activity.js';
2
2
  import { ProcessExecution } from '../process/ProcessExecution.js';
3
- import { cloneContent } from '../messageHelper.js';
3
+ import { cloneContent, cloneMessage } from '../messageHelper.js';
4
4
 
5
5
  const K_EXECUTIONS = Symbol.for('executions');
6
6
  const K_ON_EXECUTION_COMPLETED = Symbol.for('execution completed handler');
@@ -81,8 +81,24 @@ SubProcessBehaviour.prototype.execute = function execute(executeMessage) {
81
81
  return loopCharacteristics.execute(executeMessage);
82
82
  }
83
83
 
84
- const processExecution = this._upsertExecution(executeMessage);
85
- return processExecution.execute(executeMessage);
84
+ // Forward the multi-instance loop context as input to the sub process execution; any current content input takes precedence.
85
+ let message = executeMessage;
86
+ const content = executeMessage.content;
87
+ if (content.isMultiInstance) {
88
+ const input = {
89
+ isSequential: content.isSequential,
90
+ index: content.index,
91
+ cardinality: content.loopCardinality,
92
+ };
93
+ const elementVariable = loopCharacteristics?.elementVariable;
94
+ if (elementVariable && elementVariable in content) {
95
+ input[elementVariable] = content[elementVariable];
96
+ }
97
+ message = cloneMessage(executeMessage, { input: { ...input, ...content.input } });
98
+ }
99
+
100
+ const processExecution = this._upsertExecution(message);
101
+ return processExecution.execute(message);
86
102
  };
87
103
 
88
104
  SubProcessBehaviour.prototype.getState = function getState() {