@nocobase/plugin-workflow 0.8.1-alpha.4 → 0.9.0-alpha.2
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/LICENSE +661 -201
- package/lib/client/WorkflowProvider.js +1 -0
- package/lib/client/locale/en-US.d.ts +42 -17
- package/lib/client/locale/en-US.js +43 -18
- package/lib/client/locale/index.js +12 -29
- package/lib/server/Plugin.d.ts +1 -1
- package/lib/server/Plugin.js +69 -46
- package/lib/server/Processor.js +6 -10
- package/lib/server/instructions/request.d.ts +4 -1
- package/lib/server/instructions/request.js +74 -89
- package/package.json +13 -16
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _constants = require("../constants");
|
|
9
|
-
|
|
10
8
|
function _ejs() {
|
|
11
9
|
const data = require("ejs");
|
|
12
10
|
|
|
@@ -27,15 +25,7 @@ function _axios() {
|
|
|
27
25
|
return data;
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
const data = _interopRequireDefault(require("lodash"));
|
|
32
|
-
|
|
33
|
-
_lodash = function _lodash() {
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
28
|
+
var _constants = require("../constants");
|
|
39
29
|
|
|
40
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
31
|
|
|
@@ -43,96 +33,91 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
43
33
|
|
|
44
34
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
class _default {
|
|
37
|
+
constructor(plugin) {
|
|
38
|
+
var _this = this;
|
|
39
|
+
|
|
40
|
+
this.plugin = void 0;
|
|
41
|
+
|
|
42
|
+
this.request = /*#__PURE__*/function () {
|
|
43
|
+
var _ref = _asyncToGenerator(function* (node, job, processor) {
|
|
44
|
+
const templateVars = {
|
|
45
|
+
node: processor.jobsMapByNodeId,
|
|
46
|
+
ctx: processor.execution.context,
|
|
47
|
+
$jobsMapByNodeId: processor.jobsMapByNodeId,
|
|
48
|
+
$context: processor.execution.context
|
|
49
|
+
};
|
|
50
|
+
const requestConfig = node.config; // default headers
|
|
51
|
+
|
|
52
|
+
const headers = {
|
|
53
|
+
'Content-Type': 'application/json'
|
|
54
|
+
};
|
|
55
|
+
const _requestConfig$header = requestConfig.headers,
|
|
56
|
+
headerArr = _requestConfig$header === void 0 ? [] : _requestConfig$header,
|
|
57
|
+
_requestConfig$method = requestConfig.method,
|
|
58
|
+
method = _requestConfig$method === void 0 ? 'POST' : _requestConfig$method,
|
|
59
|
+
_requestConfig$timeou = requestConfig.timeout,
|
|
60
|
+
timeout = _requestConfig$timeou === void 0 ? 5000 : _requestConfig$timeou;
|
|
61
|
+
headerArr.forEach(header => headers[header.name] = header.value);
|
|
62
|
+
let url, data;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
url = yield (0, _ejs().render)(requestConfig.url.trim(), templateVars, {
|
|
66
|
+
async: true
|
|
67
|
+
});
|
|
68
|
+
data = requestConfig.data ? yield (0, _ejs().render)(requestConfig.data.trim(), templateVars, {
|
|
69
|
+
async: true
|
|
70
|
+
}) : undefined;
|
|
71
|
+
} catch (error2) {
|
|
72
|
+
// console.error(error2);
|
|
73
|
+
job.set({
|
|
74
|
+
status: _constants.JOB_STATUS.REJECTED,
|
|
75
|
+
result: error2.message
|
|
76
|
+
});
|
|
77
|
+
}
|
|
62
78
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
79
|
+
try {
|
|
80
|
+
const response = yield _axios().default.request({
|
|
81
|
+
url,
|
|
82
|
+
method,
|
|
83
|
+
headers,
|
|
84
|
+
data,
|
|
85
|
+
timeout
|
|
86
|
+
});
|
|
87
|
+
job.set({
|
|
88
|
+
status: _constants.JOB_STATUS.RESOLVED,
|
|
89
|
+
result: response.data
|
|
90
|
+
});
|
|
91
|
+
} catch (error1) {
|
|
92
|
+
// console.error('axios error?', error1);
|
|
93
|
+
job.set({
|
|
94
|
+
status: _constants.JOB_STATUS.REJECTED,
|
|
95
|
+
result: error1.isAxiosError ? error1.toJSON() : error1.message
|
|
96
|
+
});
|
|
97
|
+
}
|
|
66
98
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
job.set('status', status);
|
|
70
|
-
job.set('result', result);
|
|
71
|
-
return plugin.resume(job);
|
|
72
|
-
});
|
|
73
|
-
return _triggerResume.apply(this, arguments);
|
|
74
|
-
}
|
|
99
|
+
return _this.plugin.resume(job);
|
|
100
|
+
});
|
|
75
101
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return _asyncToGenerator(function* () {
|
|
79
|
-
const templateVars = {
|
|
80
|
-
node: processor.jobsMapByNodeId,
|
|
81
|
-
ctx: processor.execution.context
|
|
102
|
+
return function (_x, _x2, _x3) {
|
|
103
|
+
return _ref.apply(this, arguments);
|
|
82
104
|
};
|
|
83
|
-
|
|
105
|
+
}();
|
|
84
106
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
const _requestConfig$header = requestConfig.headers,
|
|
89
|
-
headerArr = _requestConfig$header === void 0 ? [] : _requestConfig$header,
|
|
90
|
-
_requestConfig$ignore = requestConfig.ignoreFail,
|
|
91
|
-
ignoreFail = _requestConfig$ignore === void 0 ? false : _requestConfig$ignore,
|
|
92
|
-
_requestConfig$method = requestConfig.method,
|
|
93
|
-
method = _requestConfig$method === void 0 ? 'POST' : _requestConfig$method,
|
|
94
|
-
_requestConfig$timeou = requestConfig.timeout,
|
|
95
|
-
timeout = _requestConfig$timeou === void 0 ? 5000 : _requestConfig$timeou;
|
|
96
|
-
headerArr.forEach(header => headers[header.name] = header.value);
|
|
97
|
-
let url, data;
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
url = yield renderData(requestConfig.url, templateVars);
|
|
101
|
-
} catch (e) {
|
|
102
|
-
console.warn(e);
|
|
103
|
-
throw new Error(`ejs can't render url, please check url format!${e === null || e === void 0 ? void 0 : e.message}`);
|
|
104
|
-
}
|
|
107
|
+
this.plugin = plugin;
|
|
108
|
+
}
|
|
105
109
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} catch (e) {
|
|
109
|
-
console.warn(e);
|
|
110
|
-
throw new Error(`ejs can't render request data, please check request data format!${e === null || e === void 0 ? void 0 : e.message}`);
|
|
111
|
-
}
|
|
110
|
+
run(node, input, processor) {
|
|
111
|
+
var _this2 = this;
|
|
112
112
|
|
|
113
|
+
return _asyncToGenerator(function* () {
|
|
113
114
|
const job = yield processor.saveJob({
|
|
114
115
|
status: _constants.JOB_STATUS.PENDING,
|
|
115
116
|
nodeId: node.id
|
|
116
117
|
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
_axios().default.request({
|
|
120
|
-
method,
|
|
121
|
-
timeout,
|
|
122
|
-
headers,
|
|
123
|
-
url,
|
|
124
|
-
data
|
|
125
|
-
}).then(resp => {
|
|
126
|
-
if (resp.status >= 200 && resp.status < 300) {
|
|
127
|
-
triggerResume(plugin, job, _constants.JOB_STATUS.RESOLVED, resp.data);
|
|
128
|
-
} else {
|
|
129
|
-
triggerResume(plugin, job, _constants.JOB_STATUS.REJECTED, resp);
|
|
130
|
-
}
|
|
131
|
-
}).catch(e => {
|
|
132
|
-
console.warn(e);
|
|
133
|
-
triggerResume(plugin, job, _constants.JOB_STATUS.REJECTED, e === null || e === void 0 ? void 0 : e.message);
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
_this2.request(node, job, processor);
|
|
134
120
|
});
|
|
135
|
-
|
|
136
121
|
return job;
|
|
137
122
|
})();
|
|
138
123
|
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"license": "
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"type": "Apache-2.0",
|
|
9
|
-
"url": "http://www.apache.org/licenses/LICENSE-2.0"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
3
|
+
"version": "0.9.0-alpha.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "AGPL-3.0",
|
|
6
|
+
"main": "./lib/index.js",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
12
8
|
"dependencies": {
|
|
13
|
-
"@nocobase/actions": "0.
|
|
14
|
-
"@nocobase/client": "0.
|
|
15
|
-
"@nocobase/database": "0.
|
|
16
|
-
"@nocobase/server": "0.
|
|
17
|
-
"@nocobase/utils": "0.
|
|
9
|
+
"@nocobase/actions": "0.9.0-alpha.2",
|
|
10
|
+
"@nocobase/client": "0.9.0-alpha.2",
|
|
11
|
+
"@nocobase/database": "0.9.0-alpha.2",
|
|
12
|
+
"@nocobase/server": "0.9.0-alpha.2",
|
|
13
|
+
"@nocobase/utils": "0.9.0-alpha.2",
|
|
18
14
|
"antd": "4.22.8",
|
|
15
|
+
"axios": "^0.27.2",
|
|
19
16
|
"classnames": "^2.3.1",
|
|
20
17
|
"cron-parser": "4.4.0",
|
|
21
18
|
"ejs": "^3.1.8",
|
|
@@ -25,8 +22,8 @@
|
|
|
25
22
|
"react-js-cron": "^1.4.0"
|
|
26
23
|
},
|
|
27
24
|
"devDependencies": {
|
|
28
|
-
"@nocobase/test": "0.
|
|
25
|
+
"@nocobase/test": "0.9.0-alpha.2",
|
|
29
26
|
"@types/ejs": "^3.1.1"
|
|
30
27
|
},
|
|
31
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "b8f76ad38e60e677c5bb4aab0a4cdb28d98a0f49"
|
|
32
29
|
}
|