@onify/flow-extensions 0.0.1 → 1.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/CHANGELOG.md +17 -0
- package/dist/index.js +2 -2
- package/dist/src/Connector.js +2 -11
- package/dist/src/Errors.js +19 -0
- package/dist/src/IO.js +1 -3
- package/dist/src/ServiceExpression.js +10 -1
- package/index.js +2 -2
- package/package.json +17 -13
- package/src/Connector.js +1 -7
- package/src/Errors.js +11 -0
- package/src/IO.js +1 -1
- package/src/ServiceExpression.js +10 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Changelog
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
# 1.0.0
|
|
5
|
+
|
|
6
|
+
- proper routing keys for end formatting
|
|
7
|
+
|
|
8
|
+
# 0.1.0
|
|
9
|
+
|
|
10
|
+
- catch errors when resolving service expression
|
|
11
|
+
- test with bpmn-engine@14
|
|
12
|
+
|
|
13
|
+
# 0.0.2
|
|
14
|
+
|
|
15
|
+
- allow expressions in timeCycle
|
|
16
|
+
- test with bpmn-engine@13
|
|
17
|
+
- error message changed in node 16
|
package/dist/index.js
CHANGED
|
@@ -130,7 +130,7 @@ class OnifyElementExtensions {
|
|
|
130
130
|
activity.on('activity.execution.completed', async elementApi => {
|
|
131
131
|
if (elementApi.fields.redelivered) return;
|
|
132
132
|
formatQ.queueMessage({
|
|
133
|
-
routingKey: 'run.end.
|
|
133
|
+
routingKey: 'run.end.format'
|
|
134
134
|
}, {
|
|
135
135
|
endRoutingKey: 'run.end.complete'
|
|
136
136
|
}, {
|
|
@@ -140,7 +140,7 @@ class OnifyElementExtensions {
|
|
|
140
140
|
try {
|
|
141
141
|
var format = await this._onExecuted(elementApi);
|
|
142
142
|
} catch (err) {
|
|
143
|
-
return broker.publish('format', 'run.
|
|
143
|
+
return broker.publish('format', 'run.end.error', {
|
|
144
144
|
error: err
|
|
145
145
|
}, {
|
|
146
146
|
persistent: false
|
package/dist/src/Connector.js
CHANGED
|
@@ -5,16 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = Connector;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
constructor(serviceId) {
|
|
10
|
-
super(`${serviceId} service function not found`);
|
|
11
|
-
this.code = 'EFLOW_NOT_IMPLEMENTED';
|
|
12
|
-
this.output = {
|
|
13
|
-
statusCode: 501
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
8
|
+
var _Errors = require("./Errors");
|
|
18
9
|
|
|
19
10
|
function Connector(connectorId, io, activity, executionMessage) {
|
|
20
11
|
if (!(this instanceof Connector)) return new Connector(connectorId, io, activity, executionMessage);
|
|
@@ -33,7 +24,7 @@ Connector.prototype.execute = async function execute(...args) {
|
|
|
33
24
|
const connectorId = this.connectorId;
|
|
34
25
|
const executionMessage = this.executionMessage;
|
|
35
26
|
const serviceFunction = environment.services[connectorId];
|
|
36
|
-
if (!serviceFunction) return callback(new NotImplemented(connectorId));
|
|
27
|
+
if (!serviceFunction) return callback(new _Errors.NotImplemented(connectorId));
|
|
37
28
|
|
|
38
29
|
try {
|
|
39
30
|
const input = io && (await io.getInput(activity, executionMessage));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NotImplemented = void 0;
|
|
7
|
+
|
|
8
|
+
class NotImplemented extends Error {
|
|
9
|
+
constructor(serviceId) {
|
|
10
|
+
super(`${serviceId} service function not found`);
|
|
11
|
+
this.code = 'EFLOW_NOT_IMPLEMENTED';
|
|
12
|
+
this.output = {
|
|
13
|
+
statusCode: 501
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.NotImplemented = NotImplemented;
|
package/dist/src/IO.js
CHANGED
|
@@ -159,10 +159,8 @@ class IOList extends IOBase {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
getValue(activity, executionMessage) {
|
|
162
|
-
var _this$behaviour$defin;
|
|
163
|
-
|
|
164
162
|
const name = this.name;
|
|
165
|
-
const items =
|
|
163
|
+
const items = this.behaviour.definition.items;
|
|
166
164
|
const result = [];
|
|
167
165
|
if (!Array.isArray(items)) return {
|
|
168
166
|
[name]: result
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = ServiceExpression;
|
|
7
7
|
|
|
8
|
+
var _Errors = require("./Errors");
|
|
9
|
+
|
|
8
10
|
function ServiceExpression(activity) {
|
|
9
11
|
if (!(this instanceof ServiceExpression)) return new ServiceExpression(activity);
|
|
10
12
|
this.activity = activity;
|
|
@@ -13,7 +15,14 @@ function ServiceExpression(activity) {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
ServiceExpression.prototype.execute = function execute(executionMessage, callback) {
|
|
16
|
-
|
|
18
|
+
try {
|
|
19
|
+
const expression = this.expression;
|
|
20
|
+
var serviceFn = this.activity.environment.resolveExpression(expression, executionMessage);
|
|
21
|
+
if (typeof serviceFn !== 'function') throw new _Errors.NotImplemented(`expression "${expression}"`);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return callback(err);
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
serviceFn.call(this.activity, executionMessage, (err, result) => {
|
|
18
27
|
callback(err, result);
|
|
19
28
|
});
|
package/index.js
CHANGED
|
@@ -90,12 +90,12 @@ class OnifyElementExtensions {
|
|
|
90
90
|
activity.on('activity.execution.completed', async (elementApi) => {
|
|
91
91
|
if (elementApi.fields.redelivered) return;
|
|
92
92
|
|
|
93
|
-
formatQ.queueMessage({routingKey: 'run.end.
|
|
93
|
+
formatQ.queueMessage({routingKey: 'run.end.format'}, {endRoutingKey: 'run.end.complete'}, {persistent: false});
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
96
|
var format = await this._onExecuted(elementApi);
|
|
97
97
|
} catch (err) {
|
|
98
|
-
return broker.publish('format', 'run.
|
|
98
|
+
return broker.publish('format', 'run.end.error', {error: err}, {persistent: false});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
broker.publish('format', 'run.end.complete', {...format}, {persistent: false});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onify/flow-extensions",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Onify Flow extensions",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"bpmn-engine",
|
|
25
25
|
"extensions"
|
|
26
26
|
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git://github.com/onify/flow-extensions.git"
|
|
30
|
+
},
|
|
27
31
|
"author": {
|
|
28
32
|
"name": "Onify",
|
|
29
33
|
"url": "https://github.com/onify"
|
|
@@ -31,26 +35,26 @@
|
|
|
31
35
|
"license": "MIT",
|
|
32
36
|
"devDependencies": {
|
|
33
37
|
"@aircall/expression-parser": "^1.0.4",
|
|
34
|
-
"@babel/cli": "^7.17.
|
|
35
|
-
"@babel/core": "^7.
|
|
36
|
-
"@babel/preset-env": "^7.
|
|
37
|
-
"@babel/register": "^7.
|
|
38
|
-
"bpmn-elements": "^
|
|
39
|
-
"bpmn-engine": "^
|
|
38
|
+
"@babel/cli": "^7.17.10",
|
|
39
|
+
"@babel/core": "^7.18.5",
|
|
40
|
+
"@babel/preset-env": "^7.18.2",
|
|
41
|
+
"@babel/register": "^7.17.7",
|
|
42
|
+
"bpmn-elements": "^8.0.1",
|
|
43
|
+
"bpmn-engine": "^14.0.0",
|
|
40
44
|
"bpmn-moddle": "^7.1.2",
|
|
41
|
-
"c8": "^7.11.
|
|
45
|
+
"c8": "^7.11.3",
|
|
42
46
|
"camunda-bpmn-moddle": "^6.1.2",
|
|
43
47
|
"chai": "^4.3.6",
|
|
44
48
|
"chronokinesis": "^3.1.2",
|
|
45
|
-
"debug": "^4.3.
|
|
49
|
+
"debug": "^4.3.4",
|
|
46
50
|
"eslint": "^7.32.0",
|
|
47
|
-
"mocha": "^
|
|
51
|
+
"mocha": "^10.0.0",
|
|
48
52
|
"mocha-cakes-2": "^3.3.0",
|
|
49
|
-
"moddle-context-serializer": "^2.
|
|
50
|
-
"nock": "^13.2.
|
|
53
|
+
"moddle-context-serializer": "^2.1.0",
|
|
54
|
+
"nock": "^13.2.6"
|
|
51
55
|
},
|
|
52
56
|
"dependencies": {
|
|
53
|
-
"cron-parser": "^4.
|
|
57
|
+
"cron-parser": "^4.4.0"
|
|
54
58
|
},
|
|
55
59
|
"files": [
|
|
56
60
|
"src",
|
package/src/Connector.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
constructor(serviceId) {
|
|
3
|
-
super(`${serviceId} service function not found`);
|
|
4
|
-
this.code = 'EFLOW_NOT_IMPLEMENTED';
|
|
5
|
-
this.output = {statusCode: 501};
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
import {NotImplemented} from './Errors';
|
|
8
2
|
|
|
9
3
|
export default function Connector(connectorId, io, activity, executionMessage) {
|
|
10
4
|
if (!(this instanceof Connector)) return new Connector(connectorId, io, activity, executionMessage);
|
package/src/Errors.js
ADDED
package/src/IO.js
CHANGED
|
@@ -123,7 +123,7 @@ class IOList extends IOBase {
|
|
|
123
123
|
}
|
|
124
124
|
getValue(activity, executionMessage) {
|
|
125
125
|
const name = this.name;
|
|
126
|
-
const items = this.behaviour.definition
|
|
126
|
+
const items = this.behaviour.definition.items;
|
|
127
127
|
|
|
128
128
|
const result = [];
|
|
129
129
|
if (!Array.isArray(items)) return {[name]: result};
|
package/src/ServiceExpression.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {NotImplemented} from './Errors';
|
|
2
|
+
|
|
1
3
|
export default function ServiceExpression(activity) {
|
|
2
4
|
if (!(this instanceof ServiceExpression)) return new ServiceExpression(activity);
|
|
3
5
|
this.activity = activity;
|
|
@@ -6,7 +8,14 @@ export default function ServiceExpression(activity) {
|
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
ServiceExpression.prototype.execute = function execute(executionMessage, callback) {
|
|
9
|
-
|
|
11
|
+
try {
|
|
12
|
+
const expression = this.expression;
|
|
13
|
+
var serviceFn = this.activity.environment.resolveExpression(expression, executionMessage);
|
|
14
|
+
if (typeof serviceFn !== 'function') throw new NotImplemented(`expression "${expression}"`);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
return callback(err);
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
serviceFn.call(this.activity, executionMessage, (err, result) => {
|
|
11
20
|
callback(err, result);
|
|
12
21
|
});
|