@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/OnifySequenceFlow.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {SequenceFlow} from 'bpmn-elements';
|
|
2
|
-
import {getExtensions} from './getExtensions.js';
|
|
1
|
+
import { SequenceFlow } from 'bpmn-elements';
|
|
2
|
+
import { getExtensions } from './getExtensions.js';
|
|
3
3
|
|
|
4
4
|
export class OnifySequenceFlow extends SequenceFlow {
|
|
5
5
|
constructor(flowDef, context) {
|
|
@@ -10,9 +10,14 @@ export class OnifySequenceFlow extends SequenceFlow {
|
|
|
10
10
|
_activate() {
|
|
11
11
|
if (!this.extensions.listeners?.onTake) return;
|
|
12
12
|
|
|
13
|
-
this.broker.subscribeTmp(
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
this.broker.subscribeTmp(
|
|
14
|
+
'event',
|
|
15
|
+
'flow.take',
|
|
16
|
+
(_, msg) => {
|
|
17
|
+
this._executeListeners(msg);
|
|
18
|
+
},
|
|
19
|
+
{ noAck: true, consumerTag: '_onify-execution-listener' },
|
|
20
|
+
);
|
|
16
21
|
}
|
|
17
22
|
async _executeListeners(message) {
|
|
18
23
|
try {
|
|
@@ -25,7 +30,18 @@ export class OnifySequenceFlow extends SequenceFlow {
|
|
|
25
30
|
const properties = this.extensions.properties;
|
|
26
31
|
if (!properties) return super.evaluate(fromMessage, callback);
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
try {
|
|
34
|
+
const preProperties = properties.resolve(this.getApi(fromMessage));
|
|
35
|
+
var evaluateMessage = fromMessage;
|
|
36
|
+
evaluateMessage.content.properties = {
|
|
37
|
+
...fromMessage.content.properties,
|
|
38
|
+
...preProperties,
|
|
39
|
+
};
|
|
40
|
+
} catch (err) {
|
|
41
|
+
return callback(err);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
super.evaluate(evaluateMessage, (err, result) => {
|
|
29
45
|
if (err) return callback(err);
|
|
30
46
|
|
|
31
47
|
try {
|
|
@@ -33,7 +49,7 @@ export class OnifySequenceFlow extends SequenceFlow {
|
|
|
33
49
|
if (result) {
|
|
34
50
|
overriddenResult = {
|
|
35
51
|
...(typeof result === 'object' && result),
|
|
36
|
-
properties: properties.resolve(this.getApi(
|
|
52
|
+
properties: properties.resolve(this.getApi(evaluateMessage)),
|
|
37
53
|
};
|
|
38
54
|
}
|
|
39
55
|
return callback(err, overriddenResult);
|
|
@@ -1,46 +1,76 @@
|
|
|
1
|
-
import { OnifyElementExtensions } from './OnifyElementExtensions.js';
|
|
2
|
-
|
|
3
|
-
export class OnifySubProcessExtensions extends OnifyElementExtensions {
|
|
4
|
-
constructor(activity, context) {
|
|
5
|
-
super(activity, context);
|
|
6
|
-
}
|
|
7
|
-
activate(runMessage) {
|
|
8
|
-
const activity = this.activity;
|
|
9
|
-
const broker = activity.broker;
|
|
10
|
-
const executionListeners = this.extensions.listeners;
|
|
11
|
-
|
|
12
|
-
if (runMessage.fields.redelivered && runMessage.fields.routingKey === 'run.start') {
|
|
13
|
-
this._setupListener(
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import { OnifyElementExtensions } from './OnifyElementExtensions.js';
|
|
2
|
+
|
|
3
|
+
export class OnifySubProcessExtensions extends OnifyElementExtensions {
|
|
4
|
+
constructor(activity, context) {
|
|
5
|
+
super(activity, context);
|
|
6
|
+
}
|
|
7
|
+
activate(runMessage) {
|
|
8
|
+
const activity = this.activity;
|
|
9
|
+
const broker = activity.broker;
|
|
10
|
+
const executionListeners = this.extensions.listeners;
|
|
11
|
+
|
|
12
|
+
if (runMessage.fields.redelivered && runMessage.fields.routingKey === 'run.start') {
|
|
13
|
+
this._setupListener(
|
|
14
|
+
broker,
|
|
15
|
+
'activity.start',
|
|
16
|
+
(elementApi) => {
|
|
17
|
+
return this._asyncFormatOnEnter(elementApi);
|
|
18
|
+
},
|
|
19
|
+
'_onify-extension-on-enter',
|
|
20
|
+
);
|
|
21
|
+
} else {
|
|
22
|
+
this._setupListener(
|
|
23
|
+
broker,
|
|
24
|
+
'activity.enter',
|
|
25
|
+
(elementApi) => {
|
|
26
|
+
return this._asyncFormatOnEnter(elementApi);
|
|
27
|
+
},
|
|
28
|
+
'_onify-extension-on-enter',
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this._setupListener(
|
|
33
|
+
broker,
|
|
34
|
+
'activity.execution.completed',
|
|
35
|
+
(elementApi) => {
|
|
36
|
+
return this._onExecutionCompleted(elementApi);
|
|
37
|
+
},
|
|
38
|
+
'_onify-extension-on-executed',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (executionListeners?.onStart) {
|
|
42
|
+
this._setupListener(
|
|
43
|
+
broker,
|
|
44
|
+
'activity.start',
|
|
45
|
+
(elementApi) => {
|
|
46
|
+
this._executeExecutionListener('start', elementApi);
|
|
47
|
+
},
|
|
48
|
+
'_onify-extension-on-listenerstart',
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (executionListeners?.onEnd) {
|
|
53
|
+
this._setupListener(
|
|
54
|
+
broker,
|
|
55
|
+
'activity.end',
|
|
56
|
+
(elementApi) => {
|
|
57
|
+
this._executeExecutionListener('end', elementApi);
|
|
58
|
+
},
|
|
59
|
+
'_onify-extension-on-listenerend',
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
_setupListener(broker, routingKey, callback, consumerTag) {
|
|
64
|
+
const activity = this.activity;
|
|
65
|
+
broker.subscribeTmp(
|
|
66
|
+
'event',
|
|
67
|
+
routingKey,
|
|
68
|
+
(_, message) => {
|
|
69
|
+
if (activity.id !== message.content.id) return;
|
|
70
|
+
|
|
71
|
+
return callback(activity.getApi(message));
|
|
72
|
+
},
|
|
73
|
+
{ noAck: true, consumerTag },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TimerEventDefinition } from 'bpmn-elements';
|
|
2
1
|
import cronParser from 'cron-parser';
|
|
2
|
+
import { TimerEventDefinition } from 'bpmn-elements';
|
|
3
3
|
|
|
4
4
|
export class OnifyTimerEventDefinition extends TimerEventDefinition {
|
|
5
5
|
constructor(activity, def) {
|
|
@@ -14,12 +14,14 @@ export class OnifyTimerEventDefinition extends TimerEventDefinition {
|
|
|
14
14
|
if (cron.expressions?.length) {
|
|
15
15
|
// cronParser.parseString expressions disregards seconds, so we have to parse again
|
|
16
16
|
const expireAt = cronParser.parseExpression(value).next().toDate();
|
|
17
|
+
|
|
17
18
|
return {
|
|
18
19
|
expireAt,
|
|
19
20
|
delay: expireAt - Date.now(),
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
return super.parse(timerType, value);
|
|
24
26
|
}
|
|
25
27
|
}
|
package/src/ServiceExpression.js
CHANGED
package/src/formatters.js
CHANGED
|
@@ -1,98 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
return {
|
|
79
|
-
...(user?.length && {candidateStarterUsers: user}),
|
|
80
|
-
...(groups?.length && {candidateStarterGroups: groups}),
|
|
81
|
-
...(!elementApi.content.description && description && {description: elementApi.resolveExpression(description)}),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function resolveAndSplit(elementApi, str) {
|
|
87
|
-
if (Array.isArray(str)) return str.filter(Boolean);
|
|
88
|
-
if (typeof str !== 'string') return;
|
|
89
|
-
|
|
90
|
-
const resolved = elementApi.resolveExpression(str);
|
|
91
|
-
if (Array.isArray(resolved)) return resolved.filter(Boolean);
|
|
92
|
-
if (typeof resolved !== 'string') return;
|
|
93
|
-
|
|
94
|
-
return resolved
|
|
95
|
-
.split(',')
|
|
96
|
-
.map((g) => g.trim && g.trim().toLowerCase())
|
|
97
|
-
.filter(Boolean);
|
|
98
|
-
}
|
|
1
|
+
export class FormatActivity {
|
|
2
|
+
constructor(activity) {
|
|
3
|
+
this.activity = activity;
|
|
4
|
+
this.resultVariable = activity.behaviour.resultVariable;
|
|
5
|
+
|
|
6
|
+
let timeCycles;
|
|
7
|
+
if (activity.eventDefinitions) {
|
|
8
|
+
for (const ed of activity.eventDefinitions.filter((e) => e.type === 'bpmn:TimerEventDefinition')) {
|
|
9
|
+
if (!ed.supports?.includes('cron')) continue;
|
|
10
|
+
if (!('timeCycle' in ed)) continue;
|
|
11
|
+
timeCycles = timeCycles || [];
|
|
12
|
+
timeCycles.push(ed.timeCycle);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
this.timeCycles = timeCycles;
|
|
16
|
+
}
|
|
17
|
+
resolve(elementApi) {
|
|
18
|
+
let user, groups, assigneeValue, description;
|
|
19
|
+
const activity = this.activity;
|
|
20
|
+
const { documentation, candidateUsers, candidateGroups, scheduledStart, assignee } = activity.behaviour;
|
|
21
|
+
|
|
22
|
+
if (candidateUsers) user = resolveAndSplit(elementApi, candidateUsers);
|
|
23
|
+
if (candidateGroups) groups = resolveAndSplit(elementApi, candidateGroups);
|
|
24
|
+
if (assignee) assigneeValue = elementApi.resolveExpression(assignee);
|
|
25
|
+
if (documentation) description = documentation[0]?.text;
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
...(this.resultVariable && { resultVariable: this.resultVariable }),
|
|
29
|
+
...(scheduledStart && activity.parent.type === 'bpmn:Process' && { scheduledStart }),
|
|
30
|
+
...(user?.length && { candidateUsers: user }),
|
|
31
|
+
...(groups?.length && { candidateGroups: groups }),
|
|
32
|
+
...(!elementApi.content.description && description && { description: elementApi.resolveExpression(description) }),
|
|
33
|
+
...(assigneeValue && { assignee: assigneeValue }),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class FormatProcess {
|
|
39
|
+
constructor(bp) {
|
|
40
|
+
this.process = bp;
|
|
41
|
+
this._historyTTL = undefined;
|
|
42
|
+
if (bp.behaviour.historyTimeToLive) {
|
|
43
|
+
this._historyTTL = bp.context.definitionContext.getTimersByElementId(bp.id).find((t) => t.timer.type === 'historyTimeToLive');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
resolve(elementApi) {
|
|
47
|
+
let user, groups, description;
|
|
48
|
+
const bp = this.process;
|
|
49
|
+
const { documentation, candidateStarterUsers, candidateStarterGroups } = bp.behaviour;
|
|
50
|
+
|
|
51
|
+
if (candidateStarterUsers) user = resolveAndSplit(elementApi, candidateStarterUsers);
|
|
52
|
+
if (candidateStarterGroups) groups = resolveAndSplit(elementApi, candidateStarterGroups);
|
|
53
|
+
if (documentation) description = documentation[0]?.text;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...(user?.length && { candidateStarterUsers: user }),
|
|
57
|
+
...(groups?.length && { candidateStarterGroups: groups }),
|
|
58
|
+
...(!elementApi.content.description && description && { description: elementApi.resolveExpression(description) }),
|
|
59
|
+
...(this._historyTTL && { historyTimeToLive: this._historyTTL.timer.value }),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function resolveAndSplit(elementApi, str) {
|
|
65
|
+
if (Array.isArray(str)) return str.filter(Boolean);
|
|
66
|
+
if (typeof str !== 'string') return;
|
|
67
|
+
|
|
68
|
+
const resolved = elementApi.resolveExpression(str);
|
|
69
|
+
if (Array.isArray(resolved)) return resolved.filter(Boolean);
|
|
70
|
+
if (typeof resolved !== 'string') return;
|
|
71
|
+
|
|
72
|
+
return resolved
|
|
73
|
+
.split(',')
|
|
74
|
+
.map((g) => g.trim && g.trim().toLowerCase())
|
|
75
|
+
.filter(Boolean);
|
|
76
|
+
}
|
package/src/getExtensions.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import {FormatActivity, FormatProcess} from './formatters.js';
|
|
2
|
-
import {InputOutput} from './IO.js';
|
|
3
|
-
import Connector from './Connector.js';
|
|
4
|
-
import ExecutionListeners from './ExecutionListeners.js';
|
|
5
|
-
import IOForm from './IOForm.js';
|
|
6
|
-
import IOProperties from './IOProperties.js';
|
|
7
|
-
import ServiceExpression from './ServiceExpression.js';
|
|
8
|
-
|
|
9
|
-
export function getExtensions(element, context) {
|
|
10
|
-
const result = {};
|
|
11
|
-
|
|
12
|
-
switch (element.type) {
|
|
13
|
-
case 'bpmn:SequenceFlow':
|
|
14
|
-
break;
|
|
15
|
-
case 'bpmn:Process':
|
|
16
|
-
result.format = new FormatProcess(element);
|
|
17
|
-
break;
|
|
18
|
-
default:
|
|
19
|
-
result.format = new FormatActivity(element);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let listenerPosition = 0;
|
|
23
|
-
const listeners = new ExecutionListeners(element, context);
|
|
24
|
-
|
|
25
|
-
const expression = element.behaviour.expression;
|
|
26
|
-
if (expression) result.Service = ServiceExpression;
|
|
27
|
-
|
|
28
|
-
const extensions = element.behaviour.extensionElements?.values;
|
|
29
|
-
if (extensions) {
|
|
30
|
-
for (const ext of extensions) {
|
|
31
|
-
switch (ext.$type) {
|
|
32
|
-
case 'camunda:Properties':
|
|
33
|
-
if (ext.values?.length) result.properties = new IOProperties(element, ext);
|
|
34
|
-
break;
|
|
35
|
-
case 'camunda:InputOutput':
|
|
36
|
-
result.io = new InputOutput(element.id, ext, context);
|
|
37
|
-
break;
|
|
38
|
-
case 'camunda:FormData':
|
|
39
|
-
if (ext.fields?.length) result.form = new IOForm(element, ext);
|
|
40
|
-
break;
|
|
41
|
-
case 'camunda:Connector': {
|
|
42
|
-
const {connectorId, inputOutput} = ext;
|
|
43
|
-
const io = inputOutput && new InputOutput(`${element.id}/${ext.$type.toLowerCase()}`, inputOutput, context);
|
|
44
|
-
result.Service = Connector.bind(Connector, connectorId, io);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
case 'camunda:ExecutionListener':
|
|
48
|
-
listeners.add(ext, listenerPosition++);
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (listeners.length) result.listeners = listeners;
|
|
55
|
-
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
1
|
+
import { FormatActivity, FormatProcess } from './formatters.js';
|
|
2
|
+
import { InputOutput } from './IO.js';
|
|
3
|
+
import Connector from './Connector.js';
|
|
4
|
+
import ExecutionListeners from './ExecutionListeners.js';
|
|
5
|
+
import IOForm from './IOForm.js';
|
|
6
|
+
import IOProperties from './IOProperties.js';
|
|
7
|
+
import ServiceExpression from './ServiceExpression.js';
|
|
8
|
+
|
|
9
|
+
export function getExtensions(element, context) {
|
|
10
|
+
const result = {};
|
|
11
|
+
|
|
12
|
+
switch (element.type) {
|
|
13
|
+
case 'bpmn:SequenceFlow':
|
|
14
|
+
break;
|
|
15
|
+
case 'bpmn:Process':
|
|
16
|
+
result.format = new FormatProcess(element);
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
result.format = new FormatActivity(element);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let listenerPosition = 0;
|
|
23
|
+
const listeners = new ExecutionListeners(element, context);
|
|
24
|
+
|
|
25
|
+
const expression = element.behaviour.expression;
|
|
26
|
+
if (expression) result.Service = ServiceExpression;
|
|
27
|
+
|
|
28
|
+
const extensions = element.behaviour.extensionElements?.values;
|
|
29
|
+
if (extensions) {
|
|
30
|
+
for (const ext of extensions) {
|
|
31
|
+
switch (ext.$type) {
|
|
32
|
+
case 'camunda:Properties':
|
|
33
|
+
if (ext.values?.length) result.properties = new IOProperties(element, ext);
|
|
34
|
+
break;
|
|
35
|
+
case 'camunda:InputOutput':
|
|
36
|
+
result.io = new InputOutput(element.id, ext, context);
|
|
37
|
+
break;
|
|
38
|
+
case 'camunda:FormData':
|
|
39
|
+
if (ext.fields?.length) result.form = new IOForm(element, ext);
|
|
40
|
+
break;
|
|
41
|
+
case 'camunda:Connector': {
|
|
42
|
+
const { connectorId, inputOutput } = ext;
|
|
43
|
+
const io = inputOutput && new InputOutput(`${element.id}/${ext.$type.toLowerCase()}`, inputOutput, context);
|
|
44
|
+
result.Service = Connector.bind(Connector, connectorId, io);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 'camunda:ExecutionListener':
|
|
48
|
+
listeners.add(ext, listenerPosition++);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (listeners.length) result.listeners = listeners;
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
}
|
package/src/index.js
CHANGED
|
@@ -21,9 +21,28 @@ export function extensions(element, context) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function extendFn(behaviour, context) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
switch (behaviour.$type) {
|
|
25
|
+
case 'bpmn:StartEvent': {
|
|
26
|
+
if (!behaviour.eventDefinitions) break;
|
|
27
|
+
|
|
28
|
+
const timer = behaviour.eventDefinitions.find(
|
|
29
|
+
({ type, behaviour: edBehaviour }) => edBehaviour && type === 'bpmn:TimerEventDefinition',
|
|
30
|
+
);
|
|
31
|
+
if (timer && timer.behaviour.timeCycle) Object.assign(behaviour, { scheduledStart: timer.behaviour.timeCycle });
|
|
32
|
+
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case 'bpmn:Process': {
|
|
36
|
+
if (!behaviour.isExecutable) break;
|
|
37
|
+
|
|
38
|
+
const { historyTimeToLive, isExecutable } = behaviour;
|
|
39
|
+
|
|
40
|
+
if (historyTimeToLive && isExecutable) {
|
|
41
|
+
context.addTimer(behaviour.id + ':historyTimeToLive', getHistoryTimeToLiveTimer(behaviour));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
27
46
|
}
|
|
28
47
|
|
|
29
48
|
if (!Array.isArray(behaviour.extensionElements?.values)) return;
|
|
@@ -47,8 +66,8 @@ export function extendFn(behaviour, context) {
|
|
|
47
66
|
function registerIOScripts(parentId, context, type, ioBehaviour) {
|
|
48
67
|
if (!ioBehaviour) return;
|
|
49
68
|
|
|
50
|
-
const {inputParameters = [], outputParameters = []} = ioBehaviour;
|
|
51
|
-
for (const {$type, name, definition} of inputParameters.concat(outputParameters)) {
|
|
69
|
+
const { inputParameters = [], outputParameters = [] } = ioBehaviour;
|
|
70
|
+
for (const { $type, name, definition } of inputParameters.concat(outputParameters)) {
|
|
52
71
|
if (!definition) continue;
|
|
53
72
|
if (definition.$type !== 'camunda:Script') continue;
|
|
54
73
|
|
|
@@ -59,14 +78,14 @@ function registerIOScripts(parentId, context, type, ioBehaviour) {
|
|
|
59
78
|
id: filename,
|
|
60
79
|
scriptFormat: definition.scriptFormat,
|
|
61
80
|
type: ioType,
|
|
62
|
-
...(definition.value && {body: definition.value}),
|
|
63
|
-
...(definition.resource && {resource: definition.resource}),
|
|
81
|
+
...(definition.value && { body: definition.value }),
|
|
82
|
+
...(definition.resource && { resource: definition.resource }),
|
|
64
83
|
});
|
|
65
84
|
}
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
function registerListenerScript(parentId, context, type, listener, pos) {
|
|
69
|
-
const {event, script} = listener;
|
|
88
|
+
const { event, script } = listener;
|
|
70
89
|
if (!script) return;
|
|
71
90
|
|
|
72
91
|
const id = `${parentId}/${type}/${event}/${pos}`;
|
|
@@ -74,7 +93,23 @@ function registerListenerScript(parentId, context, type, listener, pos) {
|
|
|
74
93
|
id,
|
|
75
94
|
scriptFormat: script.scriptFormat,
|
|
76
95
|
type,
|
|
77
|
-
...(script.value && {body: script.value}),
|
|
78
|
-
...(script.resource && {resource: script.resource}),
|
|
96
|
+
...(script.value && { body: script.value }),
|
|
97
|
+
...(script.resource && { resource: script.resource }),
|
|
79
98
|
});
|
|
80
99
|
}
|
|
100
|
+
|
|
101
|
+
function getHistoryTimeToLiveTimer(behaviour) {
|
|
102
|
+
const { id, $type: type, historyTimeToLive } = behaviour;
|
|
103
|
+
|
|
104
|
+
let value = historyTimeToLive;
|
|
105
|
+
if (/^\d+$/.test(historyTimeToLive)) {
|
|
106
|
+
value = `P${historyTimeToLive}D`;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
id: `${type}/${id}:historyTimeToLive`,
|
|
110
|
+
type: 'historyTimeToLive',
|
|
111
|
+
timerType: 'timeDuration',
|
|
112
|
+
value,
|
|
113
|
+
parent: { id, type },
|
|
114
|
+
};
|
|
115
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
Changelog
|
|
2
|
-
=========
|
|
3
|
-
|
|
4
|
-
# 7.0.0
|
|
5
|
-
|
|
6
|
-
Attempting to mitigate Boundary Event formatting interrupting normal execution flow. Asynchronous formatting prevents catching events from attached task. Should probably be done in bpmn-elements but the developer is busy.
|
|
7
|
-
|
|
8
|
-
## Breaking
|
|
9
|
-
|
|
10
|
-
- No async formatting on boundary events before end
|
|
11
|
-
- Boundary event start execution listener will be executed but _without_ formatting capabilities and detached from execution. Occasional error will just be logged
|
|
12
|
-
- Boundary event end execution listener is still executed _with_ formatting capabilities
|
|
13
|
-
|
|
14
|
-
# 6.0.0
|
|
15
|
-
|
|
16
|
-
- Require peer dependency `bpmn-elements >= 8`
|
|
17
|
-
- Support timer event definition cron time cycle by overloading parse function. Requires `bpmn-elements >= 10`
|
|
18
|
-
|
|
19
|
-
# 5.0.2
|
|
20
|
-
|
|
21
|
-
- Correct package module file...
|
|
22
|
-
|
|
23
|
-
# 5.0.1
|
|
24
|
-
|
|
25
|
-
- Doh! Add neglected package.json file to common js dist folder
|
|
26
|
-
|
|
27
|
-
# 5.0.0
|
|
28
|
-
|
|
29
|
-
- Turn into module with exports for node
|
|
30
|
-
- Add type declaration
|
|
31
|
-
|
|
32
|
-
# 4.1.0
|
|
33
|
-
|
|
34
|
-
- Support sequence flow properties and take execution listener. Requires `bpmn-elements >= 9.2`
|
|
35
|
-
|
|
36
|
-
# 4.0.0
|
|
37
|
-
|
|
38
|
-
- make sure sub-process extensions are only triggered once. Sub process activities unintentionally trigger formatting since events bubble
|
|
39
|
-
- add script element type to registered scripts
|
|
40
|
-
- restructure and split up index.js to separate files
|
|
41
|
-
- abide to new lint rules
|
|
42
|
-
|
|
43
|
-
# 3.0.0
|
|
44
|
-
|
|
45
|
-
- Support activity script and expression execution listeners
|
|
46
|
-
- Remove default behaviour of saving activity output even if output is not declared. Output **was** saved to `environment.output._<Activity ID>` if no result variable or output was declared. The reason was that there was no easy way of getting output from SubProcess or a multi-instance task. Now SubProcess output can be defined and multi-instance output can be solved with execution listener
|
|
47
|
-
|
|
48
|
-
# 2.0.0
|
|
49
|
-
|
|
50
|
-
- fix resume extension when recovered mid formatting
|
|
51
|
-
- drop node 12 support
|
|
52
|
-
|
|
53
|
-
# 1.1.0
|
|
54
|
-
|
|
55
|
-
- allow ISO8601 repeating interval and duration in timeCycle
|
|
56
|
-
|
|
57
|
-
# 1.0.0
|
|
58
|
-
|
|
59
|
-
- proper routing keys for end formatting
|
|
60
|
-
|
|
61
|
-
# 0.1.0
|
|
62
|
-
|
|
63
|
-
- catch errors when resolving service expression
|
|
64
|
-
- test with bpmn-engine@14
|
|
65
|
-
|
|
66
|
-
# 0.0.2
|
|
67
|
-
|
|
68
|
-
- allow expressions in timeCycle
|
|
69
|
-
- test with bpmn-engine@13
|
|
70
|
-
- error message changed in node 16
|