@onify/flow-extensions 9.1.1 → 10.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/dist/Connector.js +1 -1
- package/dist/ExecutionListeners.js +42 -8
- package/dist/FlowScripts.js +50 -4
- package/dist/IO.js +34 -5
- package/dist/IOForm.js +8 -5
- package/dist/IOProperties.js +6 -2
- package/dist/OnifyBoundaryEventExtensions.js +28 -13
- package/dist/OnifyElementExtensions.js +27 -13
- package/dist/OnifyProcessExtensions.js +4 -0
- package/dist/OnifySequenceFlow.js +12 -4
- package/dist/OnifySubProcessExtensions.js +15 -14
- package/dist/OnifyTimerEventDefinition.js +14 -6
- package/dist/ServiceExpression.js +1 -1
- package/dist/formatters.js +26 -0
- package/dist/getExtensions.js +29 -12
- package/dist/index.js +41 -14
- package/package.json +21 -12
- package/src/Connector.js +1 -1
- package/src/ExecutionListeners.js +40 -6
- package/src/IO.js +34 -5
- package/src/IOForm.js +6 -2
- package/src/IOProperties.js +5 -1
- package/src/OnifyBoundaryEventExtensions.js +27 -12
- package/src/OnifyElementExtensions.js +23 -12
- package/src/OnifyProcessExtensions.js +4 -0
- package/src/OnifySequenceFlow.js +12 -4
- package/src/OnifySubProcessExtensions.js +26 -25
- package/src/OnifyTimerEventDefinition.js +12 -6
- package/src/ServiceExpression.js +1 -1
- package/src/formatters.js +27 -0
- package/src/getExtensions.js +24 -6
- package/src/index.js +39 -8
- package/types/index.d.ts +309 -51
- package/types/index.d.ts.map +52 -0
package/dist/Connector.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.Connector = Connector;
|
|
7
7
|
var _Errors = require("./Errors.js");
|
|
8
8
|
function Connector(connectorId, io, activity, executionMessage) {
|
|
9
9
|
if (!(this instanceof Connector)) return new Connector(connectorId, io, activity, executionMessage);
|
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ExecutionListeners = void 0;
|
|
7
7
|
class Listener {
|
|
8
|
+
/**
|
|
9
|
+
* @param {import('bpmn-elements').Activity | import('bpmn-elements').SequenceFlow} activity
|
|
10
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
11
|
+
* @param {{$type:string, event:string, [x:string]: any}} extension
|
|
12
|
+
*/
|
|
8
13
|
constructor(activity, context, extension) {
|
|
9
14
|
this.activity = activity;
|
|
10
15
|
this.environment = this.activity.environment;
|
|
@@ -13,13 +18,24 @@ class Listener {
|
|
|
13
18
|
this.type = extension.$type;
|
|
14
19
|
this.event = extension.event;
|
|
15
20
|
}
|
|
16
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @param {import('bpmn-elements').IApi<any>} _api
|
|
23
|
+
* @returns {Promise<any>}
|
|
24
|
+
*/
|
|
25
|
+
// eslint-disable-next-line no-unused-vars
|
|
26
|
+
execute(_api) {}
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
* @param {import('bpmn-elements').IApi<any>} api
|
|
30
|
+
* @param {Record<string, any>} [extend]
|
|
31
|
+
*/
|
|
32
|
+
_getScope(api, extend) {
|
|
17
33
|
const environment = this.environment;
|
|
18
34
|
const {
|
|
19
35
|
fields,
|
|
20
36
|
content,
|
|
21
37
|
properties
|
|
22
|
-
} =
|
|
38
|
+
} = api;
|
|
23
39
|
const scope = {
|
|
24
40
|
...extend,
|
|
25
41
|
type: this.type,
|
|
@@ -36,6 +52,12 @@ class Listener {
|
|
|
36
52
|
if (listenerFields) scope.listener.fields = listenerFields;
|
|
37
53
|
return scope;
|
|
38
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* @param {import('bpmn-elements').Environment} environment
|
|
58
|
+
* @param {any} scope
|
|
59
|
+
* @returns {Record<string, any>}
|
|
60
|
+
*/
|
|
39
61
|
_getFields(environment, scope) {
|
|
40
62
|
const fields = this.extension.fields;
|
|
41
63
|
if (!fields?.length) return;
|
|
@@ -51,6 +73,12 @@ class Listener {
|
|
|
51
73
|
}
|
|
52
74
|
}
|
|
53
75
|
class ScriptListener extends Listener {
|
|
76
|
+
/**
|
|
77
|
+
* @param {import('bpmn-elements').Activity | import('bpmn-elements').SequenceFlow} activity
|
|
78
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
79
|
+
* @param {{script: {$type:string, [x:string]: any}, [x:string]: any}} extension
|
|
80
|
+
* @param {Number} pos execution listener position
|
|
81
|
+
*/
|
|
54
82
|
constructor(activity, context, extension, pos) {
|
|
55
83
|
super(activity, context, extension);
|
|
56
84
|
const id = this.id = `${activity.id}/${extension.script.$type}/${this.event}/${pos}`;
|
|
@@ -100,17 +128,23 @@ class ScriptListener extends Listener {
|
|
|
100
128
|
}
|
|
101
129
|
}
|
|
102
130
|
class ExpressionListener extends Listener {
|
|
103
|
-
execute(
|
|
104
|
-
const scope = this._getScope(
|
|
105
|
-
return {
|
|
131
|
+
execute(api) {
|
|
132
|
+
const scope = this._getScope(api);
|
|
133
|
+
return Promise.resolve({
|
|
106
134
|
expression: this.environment.resolveExpression(this.extension.expression, scope)
|
|
107
|
-
};
|
|
135
|
+
});
|
|
108
136
|
}
|
|
109
137
|
}
|
|
110
138
|
class ExecutionListeners {
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
* @param {import('bpmn-elements').Activity | import('bpmn-elements').SequenceFlow} activity
|
|
142
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
143
|
+
*/
|
|
111
144
|
constructor(activity, context) {
|
|
112
145
|
this.activity = activity;
|
|
113
146
|
this.context = context;
|
|
147
|
+
/** @type {(ScriptListener | ExpressionListener)[]} */
|
|
114
148
|
this.listeners = [];
|
|
115
149
|
}
|
|
116
150
|
get length() {
|
|
@@ -144,4 +178,4 @@ class ExecutionListeners {
|
|
|
144
178
|
return format;
|
|
145
179
|
}
|
|
146
180
|
}
|
|
147
|
-
exports.
|
|
181
|
+
exports.ExecutionListeners = ExecutionListeners;
|
package/dist/FlowScripts.js
CHANGED
|
@@ -14,6 +14,7 @@ var _nodeVm = require("node:vm");
|
|
|
14
14
|
const kSyntaxError = Symbol.for('syntax error');
|
|
15
15
|
const kResources = Symbol.for('resources base');
|
|
16
16
|
class FlowScriptError extends Error {
|
|
17
|
+
/** @param {Error} fromErr */
|
|
17
18
|
constructor(fromErr) {
|
|
18
19
|
super(fromErr.message);
|
|
19
20
|
this.name = this.constructor.name;
|
|
@@ -35,6 +36,7 @@ class FlowScriptError extends Error {
|
|
|
35
36
|
}
|
|
36
37
|
exports.FlowScriptError = FlowScriptError;
|
|
37
38
|
class FlowSyntaxError extends Error {
|
|
39
|
+
/** @param {Error} fromErr */
|
|
38
40
|
constructor(fromErr) {
|
|
39
41
|
super(fromErr.message);
|
|
40
42
|
this.name = this.constructor.name;
|
|
@@ -56,20 +58,38 @@ class FlowSyntaxError extends Error {
|
|
|
56
58
|
}
|
|
57
59
|
exports.FlowSyntaxError = FlowSyntaxError;
|
|
58
60
|
class FlowResourceError extends FlowScriptError {
|
|
61
|
+
/**
|
|
62
|
+
* @param {Error} fromErr
|
|
63
|
+
* @param {string} [filename]
|
|
64
|
+
*/
|
|
59
65
|
constructor(fromErr, filename) {
|
|
60
66
|
super(fromErr);
|
|
61
67
|
this.filename = filename;
|
|
62
68
|
this.inner = fromErr;
|
|
63
69
|
}
|
|
64
70
|
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Flow scripts provider
|
|
74
|
+
* @param {string} flowName Flow name
|
|
75
|
+
* @param {string} resourceBase External resource base
|
|
76
|
+
* @param {any} [runContext] Optional script globals
|
|
77
|
+
* @param {number} [timeout] Optional execution timeout in milliseconds, default 60000
|
|
78
|
+
*/
|
|
65
79
|
exports.FlowResourceError = FlowResourceError;
|
|
66
80
|
function FlowScripts(flowName, resourceBase, runContext, timeout = 60000) {
|
|
67
81
|
this.flowName = flowName;
|
|
82
|
+
/** @type {Map<string, JavaScript | JavaScriptResource>} */
|
|
68
83
|
this.scripts = new Map();
|
|
69
84
|
this.timeout = timeout;
|
|
70
85
|
this.runContext = runContext;
|
|
71
86
|
this[kResources] = resourceBase;
|
|
72
87
|
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Register script element
|
|
91
|
+
* @param {import('moddle-context-serializer').SerializableElement} element
|
|
92
|
+
*/
|
|
73
93
|
FlowScripts.prototype.register = function register({
|
|
74
94
|
id,
|
|
75
95
|
type,
|
|
@@ -94,7 +114,6 @@ FlowScripts.prototype.register = function register({
|
|
|
94
114
|
}
|
|
95
115
|
if (!language) return;
|
|
96
116
|
if (!['js', 'javascript'].includes(language.toLowerCase().trim())) return;
|
|
97
|
-
language = 'javascript';
|
|
98
117
|
const flowName = this.flowName;
|
|
99
118
|
const filename = `${flowName}/${type}/${id}`;
|
|
100
119
|
if (scriptBody) {
|
|
@@ -109,6 +128,12 @@ FlowScripts.prototype.register = function register({
|
|
|
109
128
|
}));
|
|
110
129
|
}
|
|
111
130
|
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get registered script
|
|
134
|
+
* @param {string} scriptType
|
|
135
|
+
* @param {{ id: string }} identifier
|
|
136
|
+
*/
|
|
112
137
|
FlowScripts.prototype.getScript = function getScript(scriptType, {
|
|
113
138
|
id
|
|
114
139
|
}) {
|
|
@@ -120,7 +145,7 @@ FlowScripts.prototype.getScript = function getScript(scriptType, {
|
|
|
120
145
|
* @param {string} flowName
|
|
121
146
|
* @param {string|Buffer} scriptBody
|
|
122
147
|
* @param {any} [runContext]
|
|
123
|
-
* @param {import('node:vm').ScriptOptions} options
|
|
148
|
+
* @param {import('node:vm').ScriptOptions & { filename?: string, timeout?: number }} [options]
|
|
124
149
|
*/
|
|
125
150
|
function JavaScript(flowName, scriptBody, runContext, options) {
|
|
126
151
|
this.flowName = flowName;
|
|
@@ -133,6 +158,12 @@ function JavaScript(flowName, scriptBody, runContext, options) {
|
|
|
133
158
|
this[kSyntaxError] = new FlowSyntaxError(err);
|
|
134
159
|
}
|
|
135
160
|
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Execute script
|
|
164
|
+
* @param {import('bpmn-elements').ExecutionScope} executionContext
|
|
165
|
+
* @param {CallableFunction} callback
|
|
166
|
+
*/
|
|
136
167
|
JavaScript.prototype.execute = async function execute(executionContext, callback) {
|
|
137
168
|
let callbackCalled;
|
|
138
169
|
const syntaxError = this[kSyntaxError];
|
|
@@ -163,6 +194,15 @@ JavaScript.prototype.execute = async function execute(executionContext, callback
|
|
|
163
194
|
callback(null, ...args);
|
|
164
195
|
}
|
|
165
196
|
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Java script resource
|
|
200
|
+
* @param {string} flowName
|
|
201
|
+
* @param {string} resource Resource name or path
|
|
202
|
+
* @param {string} resourceBase Resource base
|
|
203
|
+
* @param {any} [runContext]
|
|
204
|
+
* @param {import('node:vm').ScriptOptions & { filename?: string, timeout?: number }} [options]
|
|
205
|
+
*/
|
|
166
206
|
function JavaScriptResource(flowName, resource, resourceBase, runContext, options) {
|
|
167
207
|
this.flowName = flowName;
|
|
168
208
|
this.resource = resource;
|
|
@@ -175,12 +215,18 @@ function JavaScriptResource(flowName, resource, resourceBase, runContext, option
|
|
|
175
215
|
/**
|
|
176
216
|
* Get javascript resource content
|
|
177
217
|
* @param {string} resourceBase Resource base
|
|
178
|
-
* @param {
|
|
179
|
-
* @returns {Promise<string|Buffer} Resource content
|
|
218
|
+
* @param {string} resource Resolved resource name or path
|
|
219
|
+
* @returns {Promise<string|Buffer>} Resource content
|
|
180
220
|
*/
|
|
181
221
|
JavaScriptResource.prototype.getResourceContent = function getResourceContent(resourceBase, resource) {
|
|
182
222
|
return _nodeFs.promises.readFile((0, _nodePath.join)(resourceBase, resource));
|
|
183
223
|
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Execute script resource
|
|
227
|
+
* @param {import('bpmn-elements').ExecutionScope} executionContext
|
|
228
|
+
* @param {CallableFunction} callback
|
|
229
|
+
*/
|
|
184
230
|
JavaScriptResource.prototype.execute = async function execute(executionContext, callback) {
|
|
185
231
|
let resource;
|
|
186
232
|
try {
|
package/dist/IO.js
CHANGED
|
@@ -6,10 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.InputOutput = exports.IOScript = exports.IOList = exports.IOBase = void 0;
|
|
7
7
|
class IOBase {
|
|
8
8
|
constructor(parm) {
|
|
9
|
+
/** @type {string} */
|
|
9
10
|
this.name = parm.name;
|
|
11
|
+
/** @type {string} */
|
|
10
12
|
this.type = parm.definition && parm.definition.$type || 'string';
|
|
13
|
+
/** @type {any} */
|
|
11
14
|
this.behaviour = parm;
|
|
12
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* @param {import('bpmn-elements').Activity} activity
|
|
18
|
+
* @param {import('bpmn-elements').ElementBrokerMessage} executionMessage
|
|
19
|
+
* @returns {Promise<{name: any}>}
|
|
20
|
+
*/
|
|
13
21
|
getValue(activity, executionMessage) {
|
|
14
22
|
return {
|
|
15
23
|
[this.name]: activity.environment.resolveExpression(this.behaviour.value, executionMessage)
|
|
@@ -18,9 +26,6 @@ class IOBase {
|
|
|
18
26
|
}
|
|
19
27
|
exports.IOBase = IOBase;
|
|
20
28
|
class IOMap extends IOBase {
|
|
21
|
-
constructor(parm) {
|
|
22
|
-
super(parm);
|
|
23
|
-
}
|
|
24
29
|
getValue(activity, executionMessage) {
|
|
25
30
|
const name = this.name;
|
|
26
31
|
const entries = this.behaviour.definition.entries;
|
|
@@ -122,30 +127,54 @@ class IOScript extends IOBase {
|
|
|
122
127
|
}
|
|
123
128
|
exports.IOScript = IOScript;
|
|
124
129
|
class InputOutput {
|
|
130
|
+
/**
|
|
131
|
+
* @param {string} parentId
|
|
132
|
+
* @param {any} behaviour
|
|
133
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
134
|
+
*/
|
|
125
135
|
constructor(parentId, behaviour, context) {
|
|
126
136
|
this.parentId = parentId;
|
|
127
137
|
this.context = context;
|
|
128
138
|
const {
|
|
129
139
|
inputParameters,
|
|
130
140
|
outputParameters
|
|
131
|
-
} = behaviour;
|
|
141
|
+
} = behaviour ?? {};
|
|
132
142
|
this.input = this._map(parentId, inputParameters, 'input', context);
|
|
133
143
|
this.output = this._map(parentId, outputParameters, 'output', context);
|
|
134
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* @param {import('bpmn-elements').Activity} activity
|
|
147
|
+
* @param {import('bpmn-elements').ElementBrokerMessage} executionMessage
|
|
148
|
+
* @returns {Promise<Record<string, any>}
|
|
149
|
+
*/
|
|
135
150
|
async getInput(activity, executionMessage) {
|
|
136
151
|
const input = this.input;
|
|
137
152
|
const values = await Promise.all(input.map(parm => parm.getValue(activity, executionMessage)));
|
|
138
153
|
return values.reduce((result, parm) => Object.assign(result, parm), {});
|
|
139
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* @param {import('bpmn-elements').Activity} activity
|
|
157
|
+
* @param {import('bpmn-elements').ElementBrokerMessage} executionMessage
|
|
158
|
+
* @returns {Promise<Record<string, any>}
|
|
159
|
+
*/
|
|
140
160
|
async getOutput(activity, executionMessage) {
|
|
141
161
|
const output = this.output;
|
|
142
162
|
const values = await Promise.all(output.map(parm => parm.getValue(activity, executionMessage)));
|
|
143
163
|
return values.reduce((result, parm) => Object.assign(result, parm), {});
|
|
144
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* @internal
|
|
167
|
+
* @param {string} parentId parent element id
|
|
168
|
+
* @param {any[]} list list of IO behaviours
|
|
169
|
+
* @param {string} ioType type of IO
|
|
170
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
171
|
+
* @returns {IOBase[]}
|
|
172
|
+
*/
|
|
145
173
|
_map(parentId, list, ioType, context) {
|
|
146
174
|
const mapped = [];
|
|
147
|
-
if (!list) return mapped;
|
|
175
|
+
if (!Array.isArray(list)) return mapped;
|
|
148
176
|
for (const parm of list) {
|
|
177
|
+
if (!parm) continue;
|
|
149
178
|
const definition = parm.definition;
|
|
150
179
|
const type = definition && definition.$type;
|
|
151
180
|
switch (type) {
|
package/dist/IOForm.js
CHANGED
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _IOProperties =
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
exports.IOForm = void 0;
|
|
7
|
+
var _IOProperties = require("./IOProperties.js");
|
|
9
8
|
class IOForm {
|
|
10
9
|
constructor(activity, behaviour) {
|
|
11
10
|
this.activity = activity;
|
|
12
11
|
this.behaviour = behaviour;
|
|
13
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* @param {import('bpmn-elements').IApi<import('bpmn-elements').Activity>} elementApi
|
|
15
|
+
* @returns {Record<string, any>}
|
|
16
|
+
*/
|
|
14
17
|
resolve(elementApi) {
|
|
15
18
|
const form = {};
|
|
16
19
|
for (const field of this.behaviour.fields) {
|
|
@@ -24,10 +27,10 @@ class IOForm {
|
|
|
24
27
|
})
|
|
25
28
|
};
|
|
26
29
|
if (f.properties) {
|
|
27
|
-
f.properties = new _IOProperties.
|
|
30
|
+
f.properties = new _IOProperties.IOProperties(this.activity, f.properties).resolve(elementApi);
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
return form;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
|
-
exports.
|
|
36
|
+
exports.IOForm = IOForm;
|
package/dist/IOProperties.js
CHANGED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.IOProperties = void 0;
|
|
7
7
|
class IOProperties {
|
|
8
8
|
constructor(activity, behaviour) {
|
|
9
9
|
this.activity = activity;
|
|
10
10
|
this.behaviour = behaviour;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* @param {elementApi: import('bpmn-elements').IApi<any>} elementApi
|
|
14
|
+
* @returns {Record<string, any>}
|
|
15
|
+
*/
|
|
12
16
|
resolve(elementApi) {
|
|
13
17
|
const properties = {};
|
|
14
18
|
for (const {
|
|
@@ -21,4 +25,4 @@ class IOProperties {
|
|
|
21
25
|
return properties;
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
|
-
exports.
|
|
28
|
+
exports.IOProperties = IOProperties;
|
|
@@ -6,28 +6,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.OnifyBoundaryEventExtensions = void 0;
|
|
7
7
|
var _OnifyElementExtensions = require("./OnifyElementExtensions.js");
|
|
8
8
|
class OnifyBoundaryEventExtensions extends _OnifyElementExtensions.OnifyElementExtensions {
|
|
9
|
+
#syncFormatOnEnter;
|
|
9
10
|
constructor(activity, context) {
|
|
10
11
|
super(activity, context);
|
|
11
|
-
this
|
|
12
|
+
this.#syncFormatOnEnter = this._syncFormatOnEnter.bind(this);
|
|
12
13
|
}
|
|
13
14
|
activate(message) {
|
|
14
15
|
const activity = this.activity;
|
|
15
16
|
const formatQ = activity.broker.getQueue('format-run-q');
|
|
16
17
|
const executionListeners = this.extensions.listeners;
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
if (this._formatOnEnter) {
|
|
19
|
+
if (message.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
20
|
+
activity.on('start', this.#syncFormatOnEnter, {
|
|
21
|
+
consumerTag: '_onify-extension-on-enter'
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
activity.on('enter', this.#syncFormatOnEnter, {
|
|
25
|
+
consumerTag: '_onify-extension-on-enter'
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (this._formatOnEnd) {
|
|
30
|
+
activity.on('activity.execution.completed', elementApi => {
|
|
31
|
+
return this._onExecutionCompleted(elementApi, formatQ);
|
|
32
|
+
}, {
|
|
33
|
+
consumerTag: '_onify-extension-on-executed'
|
|
24
34
|
});
|
|
25
35
|
}
|
|
26
|
-
activity.on('activity.execution.completed', elementApi => {
|
|
27
|
-
return this._onExecutionCompleted(elementApi, formatQ);
|
|
28
|
-
}, {
|
|
29
|
-
consumerTag: '_onify-extension-on-executed'
|
|
30
|
-
});
|
|
31
36
|
if (executionListeners?.onStart) {
|
|
32
37
|
activity.on('start', async elementApi => {
|
|
33
38
|
try {
|
|
@@ -47,6 +52,11 @@ class OnifyBoundaryEventExtensions extends _OnifyElementExtensions.OnifyElementE
|
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* @param {import('bpmn-elements').IApi<import('bpmn-elements').Activity>} elementApi
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
50
60
|
_syncFormatOnEnter(elementApi) {
|
|
51
61
|
try {
|
|
52
62
|
var format = this._onEnterSync(elementApi);
|
|
@@ -61,6 +71,11 @@ class OnifyBoundaryEventExtensions extends _OnifyElementExtensions.OnifyElementE
|
|
|
61
71
|
persistent: false
|
|
62
72
|
});
|
|
63
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @internal
|
|
76
|
+
* @param {import('bpmn-elements').IApi<import('bpmn-elements').Activity>} elementApi
|
|
77
|
+
* @returns {void}
|
|
78
|
+
*/
|
|
64
79
|
_onEnterSync(elementApi) {
|
|
65
80
|
const {
|
|
66
81
|
format,
|
|
@@ -6,35 +6,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.OnifyElementExtensions = void 0;
|
|
7
7
|
var _getExtensions = require("./getExtensions.js");
|
|
8
8
|
class OnifyElementExtensions {
|
|
9
|
+
/**
|
|
10
|
+
* @param {import('bpmn-elements').Activity} activity
|
|
11
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
12
|
+
*/
|
|
9
13
|
constructor(activity, context) {
|
|
10
14
|
this.activity = activity;
|
|
11
15
|
this.context = context;
|
|
12
16
|
this.formatQ = activity.broker.getQueue('format-run-q');
|
|
13
17
|
this._asyncFormatOnEnter = this._asyncFormatOnEnter.bind(this);
|
|
14
18
|
const {
|
|
15
|
-
Service
|
|
19
|
+
Service,
|
|
20
|
+
format,
|
|
21
|
+
properties,
|
|
22
|
+
io,
|
|
23
|
+
form
|
|
16
24
|
} = this.extensions = (0, _getExtensions.getExtensions)(activity, context);
|
|
17
25
|
if (Service) {
|
|
18
26
|
activity.behaviour.Service = Service;
|
|
19
27
|
}
|
|
28
|
+
this._formatOnEnter = Boolean(format?.hasFormatting || properties || form || io?.input.length || io?.output.length);
|
|
29
|
+
this._formatOnEnd = Boolean(properties || io?.output.length || format?.resultVariable);
|
|
20
30
|
}
|
|
21
31
|
activate(message) {
|
|
22
32
|
const activity = this.activity;
|
|
23
33
|
const executionListeners = this.extensions.listeners;
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
if (this._formatOnEnter) {
|
|
35
|
+
if (message.fields.redelivered && message.fields.routingKey === 'run.start') {
|
|
36
|
+
activity.on('start', this._asyncFormatOnEnter, {
|
|
37
|
+
consumerTag: '_onify-extension-on-enter'
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
activity.on('enter', this._asyncFormatOnEnter, {
|
|
41
|
+
consumerTag: '_onify-extension-on-enter'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (this._formatOnEnd) {
|
|
46
|
+
activity.on('activity.execution.completed', elementApi => {
|
|
47
|
+
return this._onExecutionCompleted(elementApi);
|
|
48
|
+
}, {
|
|
49
|
+
consumerTag: '_onify-extension-on-executed'
|
|
31
50
|
});
|
|
32
51
|
}
|
|
33
|
-
activity.on('activity.execution.completed', elementApi => {
|
|
34
|
-
return this._onExecutionCompleted(elementApi);
|
|
35
|
-
}, {
|
|
36
|
-
consumerTag: '_onify-extension-on-executed'
|
|
37
|
-
});
|
|
38
52
|
if (executionListeners?.onStart) {
|
|
39
53
|
activity.on('start', elementApi => {
|
|
40
54
|
this._executeExecutionListener('start', elementApi);
|
|
@@ -7,6 +7,10 @@ exports.OnifyProcessExtensions = void 0;
|
|
|
7
7
|
var _Errors = require("./Errors.js");
|
|
8
8
|
var _getExtensions = require("./getExtensions.js");
|
|
9
9
|
class OnifyProcessExtensions {
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('bpmn-elements').Process} bp
|
|
12
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
13
|
+
*/
|
|
10
14
|
constructor(bp, context) {
|
|
11
15
|
this.process = bp;
|
|
12
16
|
this.context = context;
|
|
@@ -7,27 +7,35 @@ exports.OnifySequenceFlow = void 0;
|
|
|
7
7
|
var _bpmnElements = require("bpmn-elements");
|
|
8
8
|
var _getExtensions = require("./getExtensions.js");
|
|
9
9
|
class OnifySequenceFlow extends _bpmnElements.SequenceFlow {
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('bpmn-elements').SequenceFlowDefinition} flowDef
|
|
12
|
+
* @param {import('bpmn-elements').ContextInstance} context
|
|
13
|
+
*/
|
|
10
14
|
constructor(flowDef, context) {
|
|
11
15
|
super(flowDef, context);
|
|
12
16
|
this.extensions = (0, _getExtensions.getExtensions)(this, context);
|
|
13
|
-
this
|
|
17
|
+
this.#activate();
|
|
14
18
|
}
|
|
15
|
-
|
|
19
|
+
#activate() {
|
|
16
20
|
if (!this.extensions.listeners?.onTake) return;
|
|
17
21
|
this.broker.subscribeTmp('event', 'flow.take', (_, msg) => {
|
|
18
|
-
this
|
|
22
|
+
this.#executeListeners(msg);
|
|
19
23
|
}, {
|
|
20
24
|
noAck: true,
|
|
21
25
|
consumerTag: '_onify-execution-listener'
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
|
-
async
|
|
28
|
+
async #executeListeners(message) {
|
|
25
29
|
try {
|
|
26
30
|
await this.extensions.listeners.execute('take', message);
|
|
27
31
|
} catch (err) {
|
|
28
32
|
this.logger.error(`<${this.id}> execution listener error: ${err}`);
|
|
29
33
|
}
|
|
30
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @param {import('bpmn-elements').ElementBrokerMessage} fromMessage
|
|
37
|
+
* @param {(err: Error | null, result?: boolean | unknown) => void} callback
|
|
38
|
+
*/
|
|
31
39
|
evaluate(fromMessage, callback) {
|
|
32
40
|
const properties = this.extensions.properties;
|
|
33
41
|
if (!properties) return super.evaluate(fromMessage, callback);
|
|
@@ -6,25 +6,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.OnifySubProcessExtensions = void 0;
|
|
7
7
|
var _OnifyElementExtensions = require("./OnifyElementExtensions.js");
|
|
8
8
|
class OnifySubProcessExtensions extends _OnifyElementExtensions.OnifyElementExtensions {
|
|
9
|
-
constructor(activity, context) {
|
|
10
|
-
super(activity, context);
|
|
11
|
-
}
|
|
12
9
|
activate(runMessage) {
|
|
13
10
|
const activity = this.activity;
|
|
14
11
|
const broker = activity.broker;
|
|
15
12
|
const executionListeners = this.extensions.listeners;
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
if (this._formatOnEnter) {
|
|
14
|
+
if (runMessage.fields.redelivered && runMessage.fields.routingKey === 'run.start') {
|
|
15
|
+
this._setupListener(broker, 'activity.start', elementApi => {
|
|
16
|
+
return this._asyncFormatOnEnter(elementApi);
|
|
17
|
+
}, '_onify-extension-on-enter');
|
|
18
|
+
} else {
|
|
19
|
+
this._setupListener(broker, 'activity.enter', elementApi => {
|
|
20
|
+
return this._asyncFormatOnEnter(elementApi);
|
|
21
|
+
}, '_onify-extension-on-enter');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (this._formatOnEnd) {
|
|
25
|
+
this._setupListener(broker, 'activity.execution.completed', elementApi => {
|
|
26
|
+
return this._onExecutionCompleted(elementApi);
|
|
27
|
+
}, '_onify-extension-on-executed');
|
|
24
28
|
}
|
|
25
|
-
this._setupListener(broker, 'activity.execution.completed', elementApi => {
|
|
26
|
-
return this._onExecutionCompleted(elementApi);
|
|
27
|
-
}, '_onify-extension-on-executed');
|
|
28
29
|
if (executionListeners?.onStart) {
|
|
29
30
|
this._setupListener(broker, 'activity.start', elementApi => {
|
|
30
31
|
this._executeExecutionListener('start', elementApi);
|
|
@@ -7,12 +7,18 @@ exports.OnifyTimerEventDefinition = void 0;
|
|
|
7
7
|
var _croner = require("croner");
|
|
8
8
|
var _bpmnElements = require("bpmn-elements");
|
|
9
9
|
class OnifyTimerEventDefinition extends _bpmnElements.TimerEventDefinition {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Supported timeCycle formats
|
|
12
|
+
* @returns {string[]}
|
|
13
|
+
*/
|
|
14
|
+
get supports() {
|
|
15
|
+
return ['cron', 'iso8601'];
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @param {import('bpmn-elements').TimerType} timerType
|
|
19
|
+
* @param {string} value
|
|
20
|
+
* @returns {import('bpmn-elements').parsedTimer}
|
|
21
|
+
*/
|
|
16
22
|
parse(timerType, value) {
|
|
17
23
|
if (timerType === 'timeCycle') {
|
|
18
24
|
try {
|
|
@@ -29,7 +35,9 @@ class OnifyTimerEventDefinition extends _bpmnElements.TimerEventDefinition {
|
|
|
29
35
|
} catch (err) {
|
|
30
36
|
this.logger.error(`<${this.activity?.id}> failed to parse timeCycle: ${rangeError.message}`);
|
|
31
37
|
this.logger.error(`<${this.activity?.id}> failed to parse timeCycle as cron: ${err.message}`);
|
|
32
|
-
throw new RangeError(`Failed to parse timeCycle <${value?.substring(0, 255)}> as ISO 8601 interval or cron
|
|
38
|
+
throw new RangeError(`Failed to parse timeCycle <${value?.substring(0, 255)}> as ISO 8601 interval or cron`, {
|
|
39
|
+
cause: err
|
|
40
|
+
});
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
43
|
return super.parse(timerType, value);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.ServiceExpression = ServiceExpression;
|
|
7
7
|
var _Errors = require("./Errors.js");
|
|
8
8
|
function ServiceExpression(activity) {
|
|
9
9
|
if (!(this instanceof ServiceExpression)) return new ServiceExpression(activity);
|