@onify/flow-extensions 7.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 +7 -2
- package/README.md +9 -10
- package/dist/formatters.js +7 -0
- package/dist/index.js +46 -8
- package/package.json +9 -8
- 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 +10 -5
- package/src/OnifySubProcessExtensions.js +76 -46
- package/src/ServiceExpression.js +1 -1
- package/src/formatters.js +93 -98
- package/src/getExtensions.js +57 -57
- package/src/index.js +45 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
Changelog
|
|
2
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
# 7.1.0
|
|
4
|
+
|
|
5
|
+
- add process attribute `historyTimeToLive` to process environment variables when running
|
|
6
|
+
- add process attribute `historyTimeToLive` as timer to definition context via `extendFn`, formatted as ISO8601 duration
|
|
7
|
+
- use prettier since eslint will deprecate formatting rules in the next major release
|
|
3
8
|
|
|
4
9
|
# 7.0.0
|
|
5
10
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Onify Flow Extensions
|
|
2
|
-
=====================
|
|
1
|
+
# Onify Flow Extensions
|
|
3
2
|
|
|
4
3
|
[](https://github.com/onify/flow-extensions/actions/workflows/build-latest.yaml)[](https://coveralls.io/github/onify/flow-extensions?branch=default)
|
|
5
4
|
|
|
@@ -13,8 +12,8 @@ Onify Flow Extensions
|
|
|
13
12
|
## Bpmn engine example
|
|
14
13
|
|
|
15
14
|
```js
|
|
16
|
-
const {Engine} = require('bpmn-engine');
|
|
17
|
-
const {extensions} = require('@onify/flow-extensions');
|
|
15
|
+
const { Engine } = require('bpmn-engine');
|
|
16
|
+
const { extensions } = require('@onify/flow-extensions');
|
|
18
17
|
const FlowScripts = require('@onify/flow-extensions/dist/src/FlowScripts');
|
|
19
18
|
|
|
20
19
|
const source = `
|
|
@@ -41,8 +40,8 @@ const engine = new Engine({
|
|
|
41
40
|
},
|
|
42
41
|
services: {
|
|
43
42
|
serviceFn(scope, callback) {
|
|
44
|
-
callback(null, {data: 1});
|
|
45
|
-
}
|
|
43
|
+
callback(null, { data: 1 });
|
|
44
|
+
},
|
|
46
45
|
},
|
|
47
46
|
extensions: {
|
|
48
47
|
onify: extensions,
|
|
@@ -63,11 +62,11 @@ engine.execute((err, instance) => {
|
|
|
63
62
|
## Extract scripts with extend function
|
|
64
63
|
|
|
65
64
|
```js
|
|
66
|
-
const {extendFn} = require('@onify/flow-extensions');
|
|
65
|
+
const { extendFn } = require('@onify/flow-extensions');
|
|
67
66
|
|
|
68
67
|
const BpmnModdle = require('bpmn-moddle');
|
|
69
68
|
const Elements = require('bpmn-elements');
|
|
70
|
-
const {default: Serializer, TypeResolver} = require('moddle-context-serializer');
|
|
69
|
+
const { default: Serializer, TypeResolver } = require('moddle-context-serializer');
|
|
71
70
|
|
|
72
71
|
const source = `
|
|
73
72
|
<definitions id="Def_0" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
|
@@ -124,9 +123,9 @@ function getModdleContext(source, options) {
|
|
|
124
123
|
## Extend sequence flow with properties and take listeners
|
|
125
124
|
|
|
126
125
|
```js
|
|
127
|
-
const {OnifySequenceFlow, extensions} = require('@onify/flow-extensions');
|
|
126
|
+
const { OnifySequenceFlow, extensions } = require('@onify/flow-extensions');
|
|
128
127
|
const FlowScripts = require('@onify/flow-extensions/dist/src/FlowScripts');
|
|
129
|
-
const {Engine} = require('bpmn-engine');
|
|
128
|
+
const { Engine } = require('bpmn-engine');
|
|
130
129
|
const Elements = require('bpmn-elements');
|
|
131
130
|
|
|
132
131
|
const source = `
|
package/dist/formatters.js
CHANGED
|
@@ -77,6 +77,10 @@ exports.FormatActivity = FormatActivity;
|
|
|
77
77
|
class FormatProcess {
|
|
78
78
|
constructor(bp) {
|
|
79
79
|
this.process = bp;
|
|
80
|
+
this._historyTTL = undefined;
|
|
81
|
+
if (bp.behaviour.historyTimeToLive) {
|
|
82
|
+
this._historyTTL = bp.context.definitionContext.getTimersByElementId(bp.id).find(t => t.timer.type === 'historyTimeToLive');
|
|
83
|
+
}
|
|
80
84
|
}
|
|
81
85
|
resolve(elementApi) {
|
|
82
86
|
var _documentation$2, _user2, _groups2;
|
|
@@ -99,6 +103,9 @@ class FormatProcess {
|
|
|
99
103
|
}),
|
|
100
104
|
...(!elementApi.content.description && description && {
|
|
101
105
|
description: elementApi.resolveExpression(description)
|
|
106
|
+
}),
|
|
107
|
+
...(this._historyTTL && {
|
|
108
|
+
historyTimeToLive: this._historyTTL.timer.value
|
|
102
109
|
})
|
|
103
110
|
};
|
|
104
111
|
}
|
package/dist/index.js
CHANGED
|
@@ -38,14 +38,31 @@ function extensions(element, context) {
|
|
|
38
38
|
}
|
|
39
39
|
function extendFn(behaviour, context) {
|
|
40
40
|
var _behaviour$extensionE;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
switch (behaviour.$type) {
|
|
42
|
+
case 'bpmn:StartEvent':
|
|
43
|
+
{
|
|
44
|
+
if (!behaviour.eventDefinitions) break;
|
|
45
|
+
const timer = behaviour.eventDefinitions.find(({
|
|
46
|
+
type,
|
|
47
|
+
behaviour: edBehaviour
|
|
48
|
+
}) => edBehaviour && type === 'bpmn:TimerEventDefinition');
|
|
49
|
+
if (timer && timer.behaviour.timeCycle) Object.assign(behaviour, {
|
|
50
|
+
scheduledStart: timer.behaviour.timeCycle
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case 'bpmn:Process':
|
|
55
|
+
{
|
|
56
|
+
if (!behaviour.isExecutable) break;
|
|
57
|
+
const {
|
|
58
|
+
historyTimeToLive,
|
|
59
|
+
isExecutable
|
|
60
|
+
} = behaviour;
|
|
61
|
+
if (historyTimeToLive && isExecutable) {
|
|
62
|
+
context.addTimer(behaviour.id + ':historyTimeToLive', getHistoryTimeToLiveTimer(behaviour));
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
49
66
|
}
|
|
50
67
|
if (!Array.isArray((_behaviour$extensionE = behaviour.extensionElements) === null || _behaviour$extensionE === void 0 ? void 0 : _behaviour$extensionE.values)) return;
|
|
51
68
|
let listener = 0;
|
|
@@ -109,4 +126,25 @@ function registerListenerScript(parentId, context, type, listener, pos) {
|
|
|
109
126
|
resource: script.resource
|
|
110
127
|
})
|
|
111
128
|
});
|
|
129
|
+
}
|
|
130
|
+
function getHistoryTimeToLiveTimer(behaviour) {
|
|
131
|
+
const {
|
|
132
|
+
id,
|
|
133
|
+
$type: type,
|
|
134
|
+
historyTimeToLive
|
|
135
|
+
} = behaviour;
|
|
136
|
+
let value = historyTimeToLive;
|
|
137
|
+
if (/^\d+$/.test(historyTimeToLive)) {
|
|
138
|
+
value = `P${historyTimeToLive}D`;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
id: `${type}/${id}:historyTimeToLive`,
|
|
142
|
+
type: 'historyTimeToLive',
|
|
143
|
+
timerType: 'timeDuration',
|
|
144
|
+
value,
|
|
145
|
+
parent: {
|
|
146
|
+
id,
|
|
147
|
+
type
|
|
148
|
+
}
|
|
149
|
+
};
|
|
112
150
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onify/flow-extensions",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "Onify Flow extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"test": "mocha -R dot",
|
|
16
16
|
"posttest": "npm run lint && npm run dist",
|
|
17
|
-
"lint": "eslint . --cache",
|
|
17
|
+
"lint": "eslint . --cache && prettier . --check --cache",
|
|
18
18
|
"prepare": "npm run dist",
|
|
19
19
|
"dist": "babel src -d dist && babel test/helpers/FlowScripts.js -d dist",
|
|
20
20
|
"test:lcov": "c8 -r lcov mocha && npm run lint",
|
|
@@ -39,23 +39,24 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@aircall/expression-parser": "^1.0.4",
|
|
41
41
|
"@babel/cli": "^7.23.4",
|
|
42
|
-
"@babel/core": "^7.23.
|
|
43
|
-
"@babel/preset-env": "^7.23.
|
|
44
|
-
"@babel/register": "^7.
|
|
42
|
+
"@babel/core": "^7.23.7",
|
|
43
|
+
"@babel/preset-env": "^7.23.8",
|
|
44
|
+
"@babel/register": "^7.23.7",
|
|
45
45
|
"bpmn-elements-8-1": "npm:bpmn-elements@8.1",
|
|
46
46
|
"bpmn-engine": "^18.0.0",
|
|
47
47
|
"bpmn-engine-14": "npm:bpmn-engine@14",
|
|
48
48
|
"bpmn-moddle": "^8.1.0",
|
|
49
|
-
"c8": "^
|
|
49
|
+
"c8": "^9.1.0",
|
|
50
50
|
"camunda-bpmn-moddle": "^7.0.1",
|
|
51
|
-
"chai": "^
|
|
51
|
+
"chai": "^5.0.0",
|
|
52
52
|
"chronokinesis": "^6.0.0",
|
|
53
53
|
"debug": "^4.3.4",
|
|
54
54
|
"eslint": "^8.56.0",
|
|
55
55
|
"eslint-plugin-import": "^2.29.1",
|
|
56
56
|
"mocha": "^10.2.0",
|
|
57
57
|
"mocha-cakes-2": "^3.3.0",
|
|
58
|
-
"moddle-context-serializer": "^4.1.1"
|
|
58
|
+
"moddle-context-serializer": "^4.1.1",
|
|
59
|
+
"prettier": "^3.2.4"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
62
|
"bpmn-elements": ">=8"
|
package/src/Connector.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {NotImplemented} from './Errors.js';
|
|
1
|
+
import { NotImplemented } from './Errors.js';
|
|
2
2
|
|
|
3
3
|
export default function Connector(connectorId, io, activity, executionMessage) {
|
|
4
4
|
if (!(this instanceof Connector)) return new Connector(connectorId, io, activity, executionMessage);
|
|
@@ -22,7 +22,7 @@ Connector.prototype.execute = async function execute(...args) {
|
|
|
22
22
|
if (!serviceFunction) return callback(new NotImplemented(connectorId));
|
|
23
23
|
|
|
24
24
|
try {
|
|
25
|
-
const input = io && await io.getInput(activity, executionMessage);
|
|
25
|
+
const input = io && (await io.getInput(activity, executionMessage));
|
|
26
26
|
await serviceFunction.call(activity, input, ...args);
|
|
27
27
|
} catch (err) {
|
|
28
28
|
return callback(err);
|
|
@@ -33,7 +33,7 @@ Connector.prototype.execute = async function execute(...args) {
|
|
|
33
33
|
if (!io?.output.length) return callback(null, result);
|
|
34
34
|
|
|
35
35
|
try {
|
|
36
|
-
const formattedResult = await io.getOutput(activity, {...executionMessage, ...result});
|
|
36
|
+
const formattedResult = await io.getOutput(activity, { ...executionMessage, ...result });
|
|
37
37
|
return callback(null, formattedResult);
|
|
38
38
|
} catch (err) {
|
|
39
39
|
return callback(err);
|
package/src/Errors.js
CHANGED
|
@@ -2,7 +2,7 @@ export class NotImplemented extends Error {
|
|
|
2
2
|
constructor(serviceId) {
|
|
3
3
|
super(`${serviceId} service function not found`);
|
|
4
4
|
this.code = 'EFLOW_NOT_IMPLEMENTED';
|
|
5
|
-
this.output = {statusCode: 501};
|
|
5
|
+
this.output = { statusCode: 501 };
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -10,6 +10,6 @@ export class FormatError extends Error {
|
|
|
10
10
|
constructor(elementId, err) {
|
|
11
11
|
super(`<${elementId}> ${err.message}`);
|
|
12
12
|
this.code = 'EFLOW_FORMAT';
|
|
13
|
-
this.output = {statusCode: 500};
|
|
13
|
+
this.output = { statusCode: 500 };
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -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
|
|
|
@@ -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
|
+
}
|