@nocobase/plugin-workflow 0.9.0-alpha.1 → 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.
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
Workflow: string;
|
|
3
3
|
"Execution history": string;
|
|
4
|
+
Executed: string;
|
|
4
5
|
"Trigger type": string;
|
|
5
6
|
Status: string;
|
|
6
7
|
On: string;
|
|
7
8
|
Off: string;
|
|
8
9
|
Version: string;
|
|
9
10
|
"Copy to new version": string;
|
|
11
|
+
Duplicate: string;
|
|
12
|
+
Loading: string;
|
|
10
13
|
"Load failed": string;
|
|
11
14
|
Trigger: string;
|
|
15
|
+
"Trigger variables": string;
|
|
16
|
+
"Trigger data": string;
|
|
17
|
+
"Trigger time": string;
|
|
18
|
+
"Triggered at": string;
|
|
12
19
|
"Collection event": string;
|
|
13
20
|
"Trigger on": string;
|
|
14
21
|
"After record added": string;
|
|
@@ -24,6 +31,7 @@ declare const _default: {
|
|
|
24
31
|
"Based on date field of collection": string;
|
|
25
32
|
"Starts on": string;
|
|
26
33
|
"Ends on": string;
|
|
34
|
+
"No end": string;
|
|
27
35
|
"Exactly at": string;
|
|
28
36
|
"Repeat mode": string;
|
|
29
37
|
"Repeat limit": string;
|
|
@@ -45,36 +53,51 @@ declare const _default: {
|
|
|
45
53
|
"By custom date": string;
|
|
46
54
|
Advanced: string;
|
|
47
55
|
End: string;
|
|
48
|
-
"Trigger variables": string;
|
|
49
56
|
"Node result": string;
|
|
50
57
|
Constant: string;
|
|
58
|
+
Null: string;
|
|
51
59
|
Boolean: string;
|
|
52
60
|
String: string;
|
|
61
|
+
Calculator: string;
|
|
53
62
|
"Arithmetic calculation": string;
|
|
54
63
|
"String operation": string;
|
|
64
|
+
"Executed at": string;
|
|
65
|
+
Queueing: string;
|
|
55
66
|
"On going": string;
|
|
56
67
|
Succeeded: string;
|
|
57
68
|
Failed: string;
|
|
69
|
+
Pending: string;
|
|
58
70
|
Canceled: string;
|
|
59
71
|
"This node contains branches, deleting will also be preformed to them, are you sure?": string;
|
|
60
72
|
Control: string;
|
|
61
73
|
"Collection operations": string;
|
|
74
|
+
"Extended types": string;
|
|
62
75
|
"Node type": string;
|
|
63
76
|
Calculation: string;
|
|
64
77
|
"Configure calculation": string;
|
|
65
78
|
"Calculation result": string;
|
|
66
79
|
True: string;
|
|
67
80
|
False: string;
|
|
81
|
+
concat: string;
|
|
68
82
|
Condition: string;
|
|
69
83
|
Mode: string;
|
|
70
84
|
"Continue when \"Yes\"": string;
|
|
71
85
|
"Branch into \"Yes\" and \"No\"": string;
|
|
72
86
|
Conditions: string;
|
|
73
87
|
"Parallel branch": string;
|
|
88
|
+
"Add branch": string;
|
|
74
89
|
"All succeeded": string;
|
|
75
90
|
"Any succeeded": string;
|
|
91
|
+
"Any succeeded or failed": string;
|
|
76
92
|
"Continue after all branches succeeded": string;
|
|
77
93
|
"Continue after any branch succeeded": string;
|
|
94
|
+
"Continue after any branch succeeded, or exit after any branch failed": string;
|
|
95
|
+
Delay: string;
|
|
96
|
+
Duration: string;
|
|
97
|
+
"End Status": string;
|
|
98
|
+
"Select status": string;
|
|
99
|
+
"Succeed and continue": string;
|
|
100
|
+
"Fail and exit": string;
|
|
78
101
|
"Create record": string;
|
|
79
102
|
"Update record": string;
|
|
80
103
|
"Query record": string;
|
|
@@ -84,22 +107,24 @@ declare const _default: {
|
|
|
84
107
|
"Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": string;
|
|
85
108
|
"Trigger in executed workflow cannot be modified": string;
|
|
86
109
|
"Node in executed workflow cannot be modified": string;
|
|
87
|
-
|
|
110
|
+
"Can not delete": string;
|
|
111
|
+
"The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.": string;
|
|
112
|
+
"HTTP request": string;
|
|
88
113
|
URL: string;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
"You can use the above available variables in URL.": string;
|
|
115
|
+
"Request headers": string;
|
|
116
|
+
"Name(e.g. Content-Type)": string;
|
|
117
|
+
"Value(e.g. Application/json)": string;
|
|
118
|
+
"Add request header": string;
|
|
119
|
+
"HTTP method": string;
|
|
120
|
+
"Request data": string;
|
|
121
|
+
"Input request data": string;
|
|
122
|
+
"You can use the above available variables in request data.": string;
|
|
123
|
+
"Copy success!": string;
|
|
124
|
+
"Copy variable output template statement": string;
|
|
125
|
+
"Default headers is Content-Type: application/json": string;
|
|
126
|
+
"Ignore fail request and continue workflow": string;
|
|
127
|
+
"Syntax see": string;
|
|
128
|
+
"Show available variable tool": string;
|
|
104
129
|
};
|
|
105
130
|
export default _default;
|
|
@@ -7,14 +7,21 @@ exports.default = void 0;
|
|
|
7
7
|
var _default = {
|
|
8
8
|
"Workflow": "Workflow",
|
|
9
9
|
"Execution history": "Execution history",
|
|
10
|
+
"Executed": "Executed",
|
|
10
11
|
"Trigger type": "Trigger type",
|
|
11
12
|
"Status": "Status",
|
|
12
13
|
"On": "On",
|
|
13
14
|
"Off": "Off",
|
|
14
15
|
"Version": "Version",
|
|
15
16
|
"Copy to new version": "Copy to new version",
|
|
17
|
+
"Duplicate": "Duplicate",
|
|
18
|
+
"Loading": "Loading",
|
|
16
19
|
"Load failed": "Load failed",
|
|
17
20
|
"Trigger": "Trigger",
|
|
21
|
+
"Trigger variables": "Trigger variables",
|
|
22
|
+
"Trigger data": "Trigger data",
|
|
23
|
+
"Trigger time": "Trigger time",
|
|
24
|
+
"Triggered at": "Triggered at",
|
|
18
25
|
"Collection event": "Collection event",
|
|
19
26
|
"Trigger on": "Trigger on",
|
|
20
27
|
"After record added": "After record added",
|
|
@@ -30,6 +37,7 @@ var _default = {
|
|
|
30
37
|
"Based on date field of collection": "Based on date field of collection",
|
|
31
38
|
"Starts on": "Starts on",
|
|
32
39
|
"Ends on": "Ends on",
|
|
40
|
+
"No end": "No end",
|
|
33
41
|
"Exactly at": "Exactly at",
|
|
34
42
|
"Repeat mode": "Repeat mode",
|
|
35
43
|
"Repeat limit": "Repeat limit",
|
|
@@ -51,36 +59,51 @@ var _default = {
|
|
|
51
59
|
"By custom date": "By custom date",
|
|
52
60
|
"Advanced": "Advanced",
|
|
53
61
|
"End": "End",
|
|
54
|
-
"Trigger variables": "Trigger variables",
|
|
55
62
|
"Node result": "Node result",
|
|
56
63
|
"Constant": "Constant",
|
|
64
|
+
"Null": "Null",
|
|
57
65
|
"Boolean": "Boolean",
|
|
58
66
|
"String": "String",
|
|
67
|
+
"Calculator": "Calculator",
|
|
59
68
|
"Arithmetic calculation": "Arithmetic calculation",
|
|
60
69
|
"String operation": "String operation",
|
|
70
|
+
"Executed at": "Executed at",
|
|
71
|
+
"Queueing": "Queueing",
|
|
61
72
|
"On going": "On going",
|
|
62
73
|
"Succeeded": "Succeeded",
|
|
63
74
|
"Failed": "Failed",
|
|
75
|
+
"Pending": "Pending",
|
|
64
76
|
"Canceled": "Canceled",
|
|
65
77
|
"This node contains branches, deleting will also be preformed to them, are you sure?": "This node contains branches, deleting will also be preformed to them, are you sure?",
|
|
66
78
|
"Control": "Control",
|
|
67
79
|
"Collection operations": "Collection operations",
|
|
80
|
+
"Extended types": "Extended types",
|
|
68
81
|
"Node type": "Node type",
|
|
69
82
|
"Calculation": "Calculation",
|
|
70
83
|
"Configure calculation": "Configure calculation",
|
|
71
84
|
"Calculation result": "Calculation result",
|
|
72
85
|
"True": "True",
|
|
73
86
|
"False": "False",
|
|
87
|
+
"concat": "concat",
|
|
74
88
|
"Condition": "Condition",
|
|
75
89
|
"Mode": "Mode",
|
|
76
90
|
"Continue when \"Yes\"": "Continue when \"Yes\"",
|
|
77
91
|
"Branch into \"Yes\" and \"No\"": "Branch into \"Yes\" and \"No\"",
|
|
78
92
|
"Conditions": "Conditions",
|
|
79
93
|
"Parallel branch": "Parallel branch",
|
|
94
|
+
"Add branch": "Add branch",
|
|
80
95
|
"All succeeded": "All succeeded",
|
|
81
96
|
"Any succeeded": "Any succeeded",
|
|
97
|
+
"Any succeeded or failed": "Any succeeded or failed",
|
|
82
98
|
"Continue after all branches succeeded": "Continue after all branches succeeded",
|
|
83
99
|
"Continue after any branch succeeded": "Continue after any branch succeeded",
|
|
100
|
+
"Continue after any branch succeeded, or exit after any branch failed": "Continue after any branch succeeded, or exit after any branch failed",
|
|
101
|
+
"Delay": "Delay",
|
|
102
|
+
"Duration": "Duration",
|
|
103
|
+
"End Status": "End Status",
|
|
104
|
+
"Select status": "Select status",
|
|
105
|
+
"Succeed and continue": "Succeed and continue",
|
|
106
|
+
"Fail and exit": "Fail and exit",
|
|
84
107
|
"Create record": "Create record",
|
|
85
108
|
"Update record": "Update record",
|
|
86
109
|
"Query record": "Query record",
|
|
@@ -90,22 +113,24 @@ var _default = {
|
|
|
90
113
|
"Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.",
|
|
91
114
|
"Trigger in executed workflow cannot be modified": "Trigger in executed workflow cannot be modified",
|
|
92
115
|
"Node in executed workflow cannot be modified": "Node in executed workflow cannot be modified",
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
"Can not delete": "Can not delete",
|
|
117
|
+
"The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.": "The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.",
|
|
118
|
+
"HTTP request": "HTTP request",
|
|
119
|
+
"URL": "URL",
|
|
120
|
+
"You can use the above available variables in URL.": "You can use the above available variables in URL.",
|
|
121
|
+
"Request headers": "Request headers",
|
|
122
|
+
"Name(e.g. Content-Type)": "Name(e.g. Content-Type)",
|
|
123
|
+
"Value(e.g. Application/json)": "Value(e.g. Application/json)",
|
|
124
|
+
"Add request header": "Add request header",
|
|
125
|
+
"HTTP method": "HTTP method",
|
|
126
|
+
"Request data": "Request data",
|
|
127
|
+
"Input request data": "Input request data",
|
|
128
|
+
"You can use the above available variables in request data.": "You can use the above available variables in request data.",
|
|
129
|
+
"Copy success!": "Copy success!",
|
|
130
|
+
"Copy variable output template statement": "Copy variable output template statement",
|
|
131
|
+
"Default headers is Content-Type: application/json": "Default headers is Content-Type: application/json",
|
|
132
|
+
"Ignore fail request and continue workflow": "Ignore fail request and continue workflow",
|
|
133
|
+
"Syntax see": "Syntax see",
|
|
134
|
+
"Show available variable tool": "Show available variable tool"
|
|
110
135
|
};
|
|
111
136
|
exports.default = _default;
|
|
@@ -7,56 +7,39 @@ exports.NAMESPACE = void 0;
|
|
|
7
7
|
exports.lang = lang;
|
|
8
8
|
exports.useWorkflowTranslation = useWorkflowTranslation;
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
const data = require("
|
|
10
|
+
function _client() {
|
|
11
|
+
const data = require("@nocobase/client");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
_client = function _client() {
|
|
14
14
|
return data;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
return data;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function
|
|
21
|
-
const data = require("
|
|
20
|
+
function _reactI18next() {
|
|
21
|
+
const data = require("react-i18next");
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
_reactI18next = function _reactI18next() {
|
|
24
24
|
return data;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
return data;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var _zhCN = _interopRequireDefault(require("./zh-CN"));
|
|
31
|
-
|
|
32
|
-
var _enUS = _interopRequireDefault(require("./en-US"));
|
|
33
|
-
|
|
34
|
-
var _jaJP = _interopRequireDefault(require("./ja-JP"));
|
|
35
|
-
|
|
36
|
-
var _ruRU = _interopRequireDefault(require("./ru-RU"));
|
|
37
|
-
|
|
38
|
-
var _trTR = _interopRequireDefault(require("./tr-TR"));
|
|
39
|
-
|
|
40
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
-
|
|
42
30
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
31
|
|
|
44
32
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
45
33
|
|
|
46
34
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
35
|
|
|
48
|
-
const NAMESPACE = 'workflow';
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_client().i18n.addResources('en-US', NAMESPACE, _enUS.default);
|
|
36
|
+
const NAMESPACE = 'workflow'; // i18n.addResources('zh-CN', NAMESPACE, zhCN);
|
|
37
|
+
// i18n.addResources('en-US', NAMESPACE, enUS);
|
|
38
|
+
// i18n.addResources('ja-JP', NAMESPACE, jaJP);
|
|
39
|
+
// i18n.addResources('ru-RU', NAMESPACE, ruRU);
|
|
40
|
+
// i18n.addResources('tr-TR', NAMESPACE, trTR);
|
|
54
41
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
_client().i18n.addResources('ru-RU', NAMESPACE, _ruRU.default);
|
|
58
|
-
|
|
59
|
-
_client().i18n.addResources('tr-TR', NAMESPACE, _trTR.default);
|
|
42
|
+
exports.NAMESPACE = NAMESPACE;
|
|
60
43
|
|
|
61
44
|
function lang(key, options = {}) {
|
|
62
45
|
return _client().i18n.t(key, _objectSpread(_objectSpread({}, options), {}, {
|
package/lib/server/Processor.js
CHANGED
|
@@ -250,15 +250,13 @@ class Processor {
|
|
|
250
250
|
|
|
251
251
|
return _asyncToGenerator(function* () {
|
|
252
252
|
const instructions = _this7.options.plugin.instructions;
|
|
253
|
+
const instruction = instructions.get(node.type);
|
|
253
254
|
|
|
254
|
-
|
|
255
|
-
run = _instructions$get.run;
|
|
256
|
-
|
|
257
|
-
if (typeof run !== 'function') {
|
|
255
|
+
if (typeof instruction.run !== 'function') {
|
|
258
256
|
return Promise.reject(new Error('`run` should be implemented for customized execution of the node'));
|
|
259
257
|
}
|
|
260
258
|
|
|
261
|
-
return _this7.exec(run, node, input);
|
|
259
|
+
return _this7.exec(instruction.run.bind(instruction), node, input);
|
|
262
260
|
})();
|
|
263
261
|
} // parent node should take over the control
|
|
264
262
|
|
|
@@ -286,15 +284,13 @@ class Processor {
|
|
|
286
284
|
|
|
287
285
|
return _asyncToGenerator(function* () {
|
|
288
286
|
const instructions = _this9.options.plugin.instructions;
|
|
287
|
+
const instruction = instructions.get(node.type);
|
|
289
288
|
|
|
290
|
-
|
|
291
|
-
resume = _instructions$get2.resume;
|
|
292
|
-
|
|
293
|
-
if (typeof resume !== 'function') {
|
|
289
|
+
if (typeof instruction.resume !== 'function') {
|
|
294
290
|
return Promise.reject(new Error('`resume` should be implemented'));
|
|
295
291
|
}
|
|
296
292
|
|
|
297
|
-
return _this9.exec(resume, node, job);
|
|
293
|
+
return _this9.exec(instruction.resume.bind(instruction), node, job);
|
|
298
294
|
})();
|
|
299
295
|
}
|
|
300
296
|
|
|
@@ -2,13 +2,16 @@ import { AxiosRequestConfig } from 'axios';
|
|
|
2
2
|
import { Instruction } from './index';
|
|
3
3
|
export interface Header {
|
|
4
4
|
name: string;
|
|
5
|
-
value:
|
|
5
|
+
value: string;
|
|
6
6
|
}
|
|
7
7
|
export declare type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'data' | 'timeout'> & {
|
|
8
8
|
headers: Array<Header>;
|
|
9
9
|
ignoreFail: boolean;
|
|
10
10
|
};
|
|
11
11
|
export default class implements Instruction {
|
|
12
|
+
plugin: any;
|
|
13
|
+
constructor(plugin: any);
|
|
14
|
+
request: (node: any, job: any, processor: any) => Promise<any>;
|
|
12
15
|
run(node: any, input: any, processor: any): Promise<any>;
|
|
13
16
|
resume(node: any, job: any, processor: any): Promise<any>;
|
|
14
17
|
}
|
|
@@ -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,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow",
|
|
3
|
-
"version": "0.9.0-alpha.
|
|
3
|
+
"version": "0.9.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/actions": "0.9.0-alpha.
|
|
10
|
-
"@nocobase/client": "0.9.0-alpha.
|
|
11
|
-
"@nocobase/database": "0.9.0-alpha.
|
|
12
|
-
"@nocobase/server": "0.9.0-alpha.
|
|
13
|
-
"@nocobase/utils": "0.9.0-alpha.
|
|
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",
|
|
14
14
|
"antd": "4.22.8",
|
|
15
|
+
"axios": "^0.27.2",
|
|
15
16
|
"classnames": "^2.3.1",
|
|
16
17
|
"cron-parser": "4.4.0",
|
|
17
18
|
"ejs": "^3.1.8",
|
|
@@ -21,8 +22,8 @@
|
|
|
21
22
|
"react-js-cron": "^1.4.0"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
|
-
"@nocobase/test": "0.9.0-alpha.
|
|
25
|
+
"@nocobase/test": "0.9.0-alpha.2",
|
|
25
26
|
"@types/ejs": "^3.1.1"
|
|
26
27
|
},
|
|
27
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "b8f76ad38e60e677c5bb4aab0a4cdb28d98a0f49"
|
|
28
29
|
}
|