@onify/flow-extensions 7.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.
- package/README.md +9 -10
- package/dist/Connector.js +1 -1
- package/dist/ExecutionListeners.js +1 -1
- package/dist/FlowScripts.js +1 -1
- package/dist/OnifyBoundaryEventExtensions.js +3 -4
- package/dist/OnifyElementExtensions.js +5 -6
- package/dist/OnifyScriptTask.js +3 -0
- package/dist/OnifySequenceFlow.js +13 -4
- package/dist/OnifySubProcessExtensions.js +2 -2
- package/dist/OnifyTimerEventDefinition.js +2 -3
- package/dist/formatters.js +14 -26
- package/dist/getExtensions.js +3 -4
- package/dist/index.js +47 -10
- package/package.json +15 -14
- 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 -65
- package/src/OnifyElementExtensions.js +153 -141
- package/src/OnifyProcessExtensions.js +49 -40
- package/src/OnifySequenceFlow.js +23 -7
- package/src/OnifySubProcessExtensions.js +76 -46
- package/src/OnifyTimerEventDefinition.js +3 -1
- package/src/ServiceExpression.js +1 -1
- package/src/formatters.js +76 -98
- package/src/getExtensions.js +57 -57
- package/src/index.js +45 -10
- package/CHANGELOG.md +0 -70
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
|
|
|
@@ -1,65 +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
|
-
|
|
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
|
-
|
|
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,141 +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
|
-
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
|
-
|
|
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
|
-
|
|
106
|
-
Object.assign(
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
+
}
|
|
@@ -1,40 +1,49 @@
|
|
|
1
|
-
import {FormatError} from './Errors.js';
|
|
2
|
-
import {getExtensions} from './getExtensions.js';
|
|
3
|
-
|
|
4
|
-
export class OnifyProcessExtensions {
|
|
5
|
-
constructor(bp, context) {
|
|
6
|
-
this.process = bp;
|
|
7
|
-
this.context = context;
|
|
8
|
-
this.extensions = getExtensions(bp, context);
|
|
9
|
-
this._activate();
|
|
10
|
-
}
|
|
11
|
-
_activate() {
|
|
12
|
-
const bp = this.process;
|
|
13
|
-
bp.on(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import { FormatError } from './Errors.js';
|
|
2
|
+
import { getExtensions } from './getExtensions.js';
|
|
3
|
+
|
|
4
|
+
export class OnifyProcessExtensions {
|
|
5
|
+
constructor(bp, context) {
|
|
6
|
+
this.process = bp;
|
|
7
|
+
this.context = context;
|
|
8
|
+
this.extensions = getExtensions(bp, context);
|
|
9
|
+
this._activate();
|
|
10
|
+
}
|
|
11
|
+
_activate() {
|
|
12
|
+
const bp = this.process;
|
|
13
|
+
bp.on(
|
|
14
|
+
'process.enter',
|
|
15
|
+
(elementApi) => {
|
|
16
|
+
try {
|
|
17
|
+
const result = this._onEnter(elementApi);
|
|
18
|
+
const environment = elementApi.environment;
|
|
19
|
+
environment.assignVariables(result);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
elementApi.broker.publish(
|
|
22
|
+
'event',
|
|
23
|
+
'process.error',
|
|
24
|
+
{
|
|
25
|
+
...elementApi.content,
|
|
26
|
+
error: new FormatError(bp.id, err),
|
|
27
|
+
},
|
|
28
|
+
{ mandatory: true, type: 'error' },
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{ consumerTag: '_onify-extension-on-enter' },
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
_onEnter(elementApi) {
|
|
36
|
+
const { format, properties } = this.extensions;
|
|
37
|
+
const result = {};
|
|
38
|
+
|
|
39
|
+
Object.assign(result, format.resolve(elementApi));
|
|
40
|
+
Object.assign(elementApi.content, result);
|
|
41
|
+
|
|
42
|
+
if (properties) {
|
|
43
|
+
Object.assign(result, properties.resolve(elementApi));
|
|
44
|
+
Object.assign(elementApi.content, result);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
}
|