@onify/flow-extensions 6.0.0 → 7.1.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.
- package/CHANGELOG.md +17 -2
- package/README.md +9 -10
- package/dist/OnifyBoundaryEventExtensions.js +86 -0
- package/dist/OnifyElementExtensions.js +64 -84
- package/dist/OnifySubProcessExtensions.js +50 -0
- package/dist/formatters.js +7 -0
- package/dist/index.js +59 -10
- package/package.json +13 -12
- package/src/Connector.js +3 -3
- package/src/Errors.js +2 -2
- package/src/ExecutionListeners.js +8 -12
- package/src/IO.js +13 -13
- package/src/IOForm.js +4 -4
- package/src/IOProperties.js +1 -1
- package/src/OnifyBoundaryEventExtensions.js +77 -0
- package/src/OnifyElementExtensions.js +153 -150
- package/src/OnifyProcessExtensions.js +49 -40
- package/src/OnifySequenceFlow.js +10 -5
- package/src/OnifySubProcessExtensions.js +76 -0
- package/src/ServiceExpression.js +1 -1
- package/src/formatters.js +93 -98
- package/src/getExtensions.js +57 -57
- package/src/index.js +59 -12
|
@@ -10,7 +10,7 @@ class Listener {
|
|
|
10
10
|
_getScope(message, extend) {
|
|
11
11
|
const environment = this.environment;
|
|
12
12
|
|
|
13
|
-
const {fields, content, properties} = message;
|
|
13
|
+
const { fields, content, properties } = message;
|
|
14
14
|
const scope = {
|
|
15
15
|
...extend,
|
|
16
16
|
type: this.type,
|
|
@@ -33,7 +33,7 @@ class Listener {
|
|
|
33
33
|
const fields = this.extension.fields;
|
|
34
34
|
if (!fields?.length) return;
|
|
35
35
|
const result = {};
|
|
36
|
-
for (const {name, expression, string} of fields) {
|
|
36
|
+
for (const { name, expression, string } of fields) {
|
|
37
37
|
result['' + name] = expression ? environment.resolveExpression(expression, scope) : string;
|
|
38
38
|
}
|
|
39
39
|
return result;
|
|
@@ -43,15 +43,15 @@ class Listener {
|
|
|
43
43
|
class ScriptListener extends Listener {
|
|
44
44
|
constructor(activity, context, extension, pos) {
|
|
45
45
|
super(activity, context, extension);
|
|
46
|
-
const id = this.id = `${activity.id}/${extension.script.$type}/${this.event}/${pos}
|
|
46
|
+
const id = (this.id = `${activity.id}/${extension.script.$type}/${this.event}/${pos}`);
|
|
47
47
|
this._register(context, id, extension.script);
|
|
48
48
|
}
|
|
49
49
|
execute(api) {
|
|
50
50
|
const environment = this.environment;
|
|
51
|
-
const scope = this._getScope(api, {id: this.id, resolveExpression});
|
|
51
|
+
const scope = this._getScope(api, { id: this.id, resolveExpression });
|
|
52
52
|
const listenerFields = this._getFields(environment, scope);
|
|
53
53
|
if (listenerFields) scope.listener.fields = listenerFields;
|
|
54
|
-
const script = this.environment.scripts.getScript(this.extension.scriptFormat, {id: this.id});
|
|
54
|
+
const script = this.environment.scripts.getScript(this.extension.scriptFormat, { id: this.id });
|
|
55
55
|
|
|
56
56
|
return new Promise((resolve, reject) => {
|
|
57
57
|
return script.execute(scope, (err, result) => {
|
|
@@ -65,11 +65,7 @@ class ScriptListener extends Listener {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
_register(context, id, script) {
|
|
68
|
-
const {
|
|
69
|
-
scriptFormat,
|
|
70
|
-
value,
|
|
71
|
-
resource,
|
|
72
|
-
} = script;
|
|
68
|
+
const { scriptFormat, value, resource } = script;
|
|
73
69
|
|
|
74
70
|
context.environment.scripts.register({
|
|
75
71
|
id,
|
|
@@ -90,7 +86,7 @@ class ScriptListener extends Listener {
|
|
|
90
86
|
class ExpressionListener extends Listener {
|
|
91
87
|
execute(message) {
|
|
92
88
|
const scope = this._getScope(message);
|
|
93
|
-
return {expression: this.environment.resolveExpression(this.extension.expression, scope)};
|
|
89
|
+
return { expression: this.environment.resolveExpression(this.extension.expression, scope) };
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
92
|
|
|
@@ -113,7 +109,7 @@ export default class ExecutionListeners {
|
|
|
113
109
|
return this.listeners.some((l) => l.event === 'take');
|
|
114
110
|
}
|
|
115
111
|
add(extension, pos) {
|
|
116
|
-
const {script, expression} = extension;
|
|
112
|
+
const { script, expression } = extension;
|
|
117
113
|
if (!script && !expression) return;
|
|
118
114
|
|
|
119
115
|
const list = this.listeners;
|
package/src/IO.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export class IOBase {
|
|
2
2
|
constructor(parm) {
|
|
3
3
|
this.name = parm.name;
|
|
4
|
-
this.type = parm.definition && parm.definition.$type || 'string';
|
|
4
|
+
this.type = (parm.definition && parm.definition.$type) || 'string';
|
|
5
5
|
this.behaviour = parm;
|
|
6
6
|
}
|
|
7
7
|
getValue(activity, executionMessage) {
|
|
@@ -18,12 +18,12 @@ class IOMap extends IOBase {
|
|
|
18
18
|
getValue(activity, executionMessage) {
|
|
19
19
|
const name = this.name;
|
|
20
20
|
const entries = this.behaviour.definition.entries;
|
|
21
|
-
if (!Array.isArray(entries)) return {[name]: {}};
|
|
21
|
+
if (!Array.isArray(entries)) return { [name]: {} };
|
|
22
22
|
|
|
23
23
|
const environment = activity.environment;
|
|
24
24
|
|
|
25
25
|
const result = {};
|
|
26
|
-
for (const {key, value} of entries) {
|
|
26
|
+
for (const { key, value } of entries) {
|
|
27
27
|
if (!key) continue;
|
|
28
28
|
|
|
29
29
|
const val = environment.resolveExpression(value, executionMessage);
|
|
@@ -33,7 +33,7 @@ class IOMap extends IOBase {
|
|
|
33
33
|
if (Array.isArray(current)) {
|
|
34
34
|
current.push(val);
|
|
35
35
|
} else {
|
|
36
|
-
const items = result[key] = [];
|
|
36
|
+
const items = (result[key] = []);
|
|
37
37
|
if (current !== undefined) items.push(current);
|
|
38
38
|
items.push(val);
|
|
39
39
|
}
|
|
@@ -42,7 +42,7 @@ class IOMap extends IOBase {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
return {[name]: result};
|
|
45
|
+
return { [name]: result };
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -55,7 +55,7 @@ export class IOList extends IOBase {
|
|
|
55
55
|
const items = this.behaviour.definition.items;
|
|
56
56
|
|
|
57
57
|
const result = [];
|
|
58
|
-
if (!Array.isArray(items)) return {[name]: result};
|
|
58
|
+
if (!Array.isArray(items)) return { [name]: result };
|
|
59
59
|
|
|
60
60
|
const environment = activity.environment;
|
|
61
61
|
for (const item of items) {
|
|
@@ -80,7 +80,7 @@ export class IOScript extends IOBase {
|
|
|
80
80
|
const name = this.name;
|
|
81
81
|
const environment = activity.environment;
|
|
82
82
|
|
|
83
|
-
const {fields, content, properties, ...rest} = executionMessage;
|
|
83
|
+
const { fields, content, properties, ...rest } = executionMessage;
|
|
84
84
|
const scope = {
|
|
85
85
|
id: this.id,
|
|
86
86
|
type: this.type,
|
|
@@ -94,12 +94,12 @@ export class IOScript extends IOBase {
|
|
|
94
94
|
...rest,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
const script = environment.scripts.getScript(definition.scriptFormat, {id: this.id});
|
|
97
|
+
const script = environment.scripts.getScript(definition.scriptFormat, { id: this.id });
|
|
98
98
|
|
|
99
99
|
return new Promise((resolve, reject) => {
|
|
100
100
|
return script.execute(scope, (err, result) => {
|
|
101
101
|
if (err) return reject(err);
|
|
102
|
-
resolve({[name]: result});
|
|
102
|
+
resolve({ [name]: result });
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
|
|
@@ -113,7 +113,7 @@ export class InputOutput {
|
|
|
113
113
|
constructor(parentId, behaviour, context) {
|
|
114
114
|
this.parentId = parentId;
|
|
115
115
|
this.context = context;
|
|
116
|
-
const {inputParameters, outputParameters} = behaviour;
|
|
116
|
+
const { inputParameters, outputParameters } = behaviour;
|
|
117
117
|
this.input = this._map(parentId, inputParameters, 'input', context);
|
|
118
118
|
this.output = this._map(parentId, outputParameters, 'output', context);
|
|
119
119
|
}
|
|
@@ -145,7 +145,7 @@ export class InputOutput {
|
|
|
145
145
|
}
|
|
146
146
|
case 'camunda:Script': {
|
|
147
147
|
const id = `${parentId}/${ioType}/${type}/${parm.name}`;
|
|
148
|
-
const {scriptFormat, value, resource} = definition;
|
|
148
|
+
const { scriptFormat, value, resource } = definition;
|
|
149
149
|
|
|
150
150
|
if (!value && !resource) break;
|
|
151
151
|
|
|
@@ -154,8 +154,8 @@ export class InputOutput {
|
|
|
154
154
|
type: parm.$type,
|
|
155
155
|
behaviour: {
|
|
156
156
|
scriptFormat,
|
|
157
|
-
...(value && {script: value}),
|
|
158
|
-
...(resource && {resource}),
|
|
157
|
+
...(value && { script: value }),
|
|
158
|
+
...(resource && { resource }),
|
|
159
159
|
},
|
|
160
160
|
});
|
|
161
161
|
|
package/src/IOForm.js
CHANGED
|
@@ -8,11 +8,11 @@ export default class IOForm {
|
|
|
8
8
|
resolve(elementApi) {
|
|
9
9
|
const form = {};
|
|
10
10
|
for (const field of this.behaviour.fields) {
|
|
11
|
-
const f = form[field.id] = {
|
|
11
|
+
const f = (form[field.id] = {
|
|
12
12
|
...field,
|
|
13
|
-
...(field.label && {defaultValue: elementApi.resolveExpression(field.label)}),
|
|
14
|
-
...(field.defaultValue && {defaultValue: elementApi.resolveExpression(field.defaultValue)}),
|
|
15
|
-
};
|
|
13
|
+
...(field.label && { defaultValue: elementApi.resolveExpression(field.label) }),
|
|
14
|
+
...(field.defaultValue && { defaultValue: elementApi.resolveExpression(field.defaultValue) }),
|
|
15
|
+
});
|
|
16
16
|
if (f.properties) {
|
|
17
17
|
f.properties = new IOProperties(this.activity, f.properties).resolve(elementApi);
|
|
18
18
|
}
|
package/src/IOProperties.js
CHANGED
|
@@ -6,7 +6,7 @@ export default class IOProperties {
|
|
|
6
6
|
resolve(elementApi) {
|
|
7
7
|
const properties = {};
|
|
8
8
|
|
|
9
|
-
for (const {id, name, value} of this.behaviour.values) {
|
|
9
|
+
for (const { id, name, value } of this.behaviour.values) {
|
|
10
10
|
properties[id || name] = elementApi.resolveExpression(value);
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { OnifyElementExtensions } from './OnifyElementExtensions.js';
|
|
2
|
+
|
|
3
|
+
export class OnifyBoundaryEventExtensions extends OnifyElementExtensions {
|
|
4
|
+
constructor(activity, context) {
|
|
5
|
+
super(activity, context);
|
|
6
|
+
this._syncFormatOnEnter = this._syncFormatOnEnter.bind(this);
|
|
7
|
+
}
|
|
8
|
+
activate(message) {
|
|
9
|
+
const activity = this.activity;
|
|
10
|
+
const formatQ = activity.broker.getQueue('format-run-q');
|
|
11
|
+
const executionListeners = this.extensions.listeners;
|
|
12
|
+
|
|
13
|
+
if (message.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
14
|
+
activity.on('start', this._syncFormatOnEnter, { consumerTag: '_onify-extension-on-enter' });
|
|
15
|
+
} else {
|
|
16
|
+
activity.on('enter', this._syncFormatOnEnter, { consumerTag: '_onify-extension-on-enter' });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
activity.on(
|
|
20
|
+
'activity.execution.completed',
|
|
21
|
+
(elementApi) => {
|
|
22
|
+
return this._onExecutionCompleted(elementApi, formatQ);
|
|
23
|
+
},
|
|
24
|
+
{ consumerTag: '_onify-extension-on-executed' },
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if (executionListeners?.onStart) {
|
|
28
|
+
activity.on(
|
|
29
|
+
'start',
|
|
30
|
+
async (elementApi) => {
|
|
31
|
+
try {
|
|
32
|
+
await executionListeners.execute('start', elementApi);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
return activity.logger.error(`<${activity.id}> execution listener error`, err);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{ consumerTag: '_onify-extension-on-listenerstart' },
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (executionListeners?.onEnd) {
|
|
41
|
+
activity.on(
|
|
42
|
+
'end',
|
|
43
|
+
(elementApi) => {
|
|
44
|
+
this._executeExecutionListener('end', elementApi, formatQ);
|
|
45
|
+
},
|
|
46
|
+
{ consumerTag: '_onify-extension-on-listenerend' },
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
_syncFormatOnEnter(elementApi) {
|
|
51
|
+
try {
|
|
52
|
+
var format = this._onEnterSync(elementApi);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
return elementApi.broker.publish('format', 'run.enter.error', { error: err }, { persistent: false });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
elementApi.broker.publish('format', 'run.enter.complete', format, { persistent: false });
|
|
58
|
+
}
|
|
59
|
+
_onEnterSync(elementApi) {
|
|
60
|
+
const { format, properties, io } = this.extensions;
|
|
61
|
+
|
|
62
|
+
const result = {};
|
|
63
|
+
Object.assign(result, format.resolve(elementApi));
|
|
64
|
+
Object.assign(elementApi.content, result);
|
|
65
|
+
|
|
66
|
+
if (properties) {
|
|
67
|
+
Object.assign(result, { properties: properties.resolve(elementApi) });
|
|
68
|
+
Object.assign(elementApi.content, result);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (io?.output?.length) {
|
|
72
|
+
result.assignToOutput = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,150 +1,153 @@
|
|
|
1
|
-
import {getExtensions} from './getExtensions.js';
|
|
2
|
-
|
|
3
|
-
export class OnifyElementExtensions {
|
|
4
|
-
constructor(activity, context) {
|
|
5
|
-
this.activity = activity;
|
|
6
|
-
this.context = context;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Object.assign(result, {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
import { getExtensions } from './getExtensions.js';
|
|
2
|
+
|
|
3
|
+
export class OnifyElementExtensions {
|
|
4
|
+
constructor(activity, context) {
|
|
5
|
+
this.activity = activity;
|
|
6
|
+
this.context = context;
|
|
7
|
+
this.formatQ = activity.broker.getQueue('format-run-q');
|
|
8
|
+
this._asyncFormatOnEnter = this._asyncFormatOnEnter.bind(this);
|
|
9
|
+
|
|
10
|
+
const { Service } = (this.extensions = getExtensions(activity, context));
|
|
11
|
+
if (Service) {
|
|
12
|
+
activity.behaviour.Service = Service;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
activate(message) {
|
|
16
|
+
const activity = this.activity;
|
|
17
|
+
const executionListeners = this.extensions.listeners;
|
|
18
|
+
|
|
19
|
+
if (message.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
20
|
+
activity.on('start', this._asyncFormatOnEnter, { consumerTag: '_onify-extension-on-enter' });
|
|
21
|
+
} else {
|
|
22
|
+
activity.on('enter', this._asyncFormatOnEnter, { consumerTag: '_onify-extension-on-enter' });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
activity.on(
|
|
26
|
+
'activity.execution.completed',
|
|
27
|
+
(elementApi) => {
|
|
28
|
+
return this._onExecutionCompleted(elementApi);
|
|
29
|
+
},
|
|
30
|
+
{ consumerTag: '_onify-extension-on-executed' },
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (executionListeners?.onStart) {
|
|
34
|
+
activity.on(
|
|
35
|
+
'start',
|
|
36
|
+
(elementApi) => {
|
|
37
|
+
this._executeExecutionListener('start', elementApi);
|
|
38
|
+
},
|
|
39
|
+
{ consumerTag: '_onify-extension-on-listenerstart' },
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (executionListeners?.onEnd) {
|
|
44
|
+
activity.on(
|
|
45
|
+
'end',
|
|
46
|
+
(elementApi) => {
|
|
47
|
+
this._executeExecutionListener('end', elementApi);
|
|
48
|
+
},
|
|
49
|
+
{ consumerTag: '_onify-extension-on-listenerend' },
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
deactivate() {
|
|
54
|
+
const broker = this.activity.broker;
|
|
55
|
+
broker.cancel('_onify-extension-on-enter');
|
|
56
|
+
broker.cancel('_onify-extension-on-executed');
|
|
57
|
+
broker.cancel('_onify-extension-on-listenerstart');
|
|
58
|
+
broker.cancel('_onify-extension-on-listenerend');
|
|
59
|
+
}
|
|
60
|
+
async _asyncFormatOnEnter(elementApi) {
|
|
61
|
+
this.formatQ.queueMessage({ routingKey: 'run.enter.format' }, { endRoutingKey: 'run.enter.complete' }, { persistent: false });
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
var format = await this._onEnterAsync(elementApi);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
return elementApi.broker.publish('format', 'run.enter.error', { error: err }, { persistent: false });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
elementApi.broker.publish('format', 'run.enter.complete', format, { persistent: false });
|
|
70
|
+
}
|
|
71
|
+
async _onExecutionCompleted(elementApi) {
|
|
72
|
+
this.formatQ.queueMessage({ routingKey: 'run.end.format' }, { endRoutingKey: 'run.end.complete' }, { persistent: false });
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
var format = await this._onExecuted(elementApi);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
return elementApi.broker.publish('format', 'run.end.error', { error: err }, { persistent: false });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
elementApi.broker.publish('format', 'run.end.complete', { ...format }, { persistent: false });
|
|
81
|
+
}
|
|
82
|
+
async _onEnterAsync(elementApi) {
|
|
83
|
+
const { format, properties, io, form } = this.extensions;
|
|
84
|
+
|
|
85
|
+
const result = {};
|
|
86
|
+
Object.assign(result, format.resolve(elementApi));
|
|
87
|
+
Object.assign(elementApi.content, result);
|
|
88
|
+
|
|
89
|
+
if (properties) {
|
|
90
|
+
Object.assign(result, { properties: properties.resolve(elementApi) });
|
|
91
|
+
Object.assign(elementApi.content, result);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (io) {
|
|
95
|
+
if (io.input?.length) {
|
|
96
|
+
const input = await io.getInput(this.activity, elementApi);
|
|
97
|
+
Object.assign(result, { input });
|
|
98
|
+
Object.assign(elementApi.content, result);
|
|
99
|
+
}
|
|
100
|
+
if (io.output?.length) {
|
|
101
|
+
result.assignToOutput = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (form) {
|
|
106
|
+
Object.assign(result, { form: form.resolve(elementApi) });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
async _onExecuted(elementApi) {
|
|
112
|
+
const { properties, io } = this.extensions;
|
|
113
|
+
|
|
114
|
+
const result = {};
|
|
115
|
+
if (io?.output.length) {
|
|
116
|
+
const output = await io.getOutput(this.activity, elementApi);
|
|
117
|
+
Object.assign(result, { output });
|
|
118
|
+
Object.assign(elementApi.content, { output });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (properties) {
|
|
122
|
+
const props = properties.resolve(elementApi);
|
|
123
|
+
Object.assign(result, { properties: props });
|
|
124
|
+
Object.assign(elementApi.content, { properties: props });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const { output, assignToOutput, resultVariable } = elementApi.content;
|
|
128
|
+
|
|
129
|
+
if (output !== undefined && output !== null) {
|
|
130
|
+
if (assignToOutput && typeof output === 'object') {
|
|
131
|
+
Object.assign(this.activity.environment.output, output);
|
|
132
|
+
} else if (resultVariable) {
|
|
133
|
+
elementApi.environment.output[resultVariable] = output;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
async _executeExecutionListener(eventName, elementApi) {
|
|
140
|
+
const routingKey = 'run.listener.' + eventName;
|
|
141
|
+
const endRoutingKey = routingKey + '.complete';
|
|
142
|
+
|
|
143
|
+
this.formatQ.queueMessage({ routingKey }, { endRoutingKey }, { persistent: false });
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
var format = await this.extensions.listeners.execute(eventName, elementApi);
|
|
147
|
+
} catch (err) {
|
|
148
|
+
return elementApi.broker.publish('format', routingKey + '.error', { error: err }, { persistent: false });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
elementApi.broker.publish('format', endRoutingKey, { ...format }, { persistent: false });
|
|
152
|
+
}
|
|
153
|
+
}
|