@nocobase/plugin-workflow-request 1.0.0-alpha.6 → 1.0.0-alpha.8
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.
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Instruction, WorkflowVariableJSON, WorkflowVariableTextArea } from '@nocobase/plugin-workflow/client';
|
|
11
|
+
declare function BodyComponent(props: any): React.JSX.Element;
|
|
10
12
|
export default class extends Instruction {
|
|
11
13
|
title: string;
|
|
12
14
|
type: string;
|
|
@@ -41,6 +43,20 @@ export default class extends Instruction {
|
|
|
41
43
|
placeholder: string;
|
|
42
44
|
};
|
|
43
45
|
};
|
|
46
|
+
contentType: {
|
|
47
|
+
type: string;
|
|
48
|
+
title: string;
|
|
49
|
+
'x-decorator': string;
|
|
50
|
+
'x-component': string;
|
|
51
|
+
'x-component-props': {
|
|
52
|
+
allowClear: boolean;
|
|
53
|
+
};
|
|
54
|
+
enum: {
|
|
55
|
+
label: string;
|
|
56
|
+
value: string;
|
|
57
|
+
}[];
|
|
58
|
+
default: string;
|
|
59
|
+
};
|
|
44
60
|
headers: {
|
|
45
61
|
type: string;
|
|
46
62
|
'x-component': string;
|
|
@@ -138,14 +154,6 @@ export default class extends Instruction {
|
|
|
138
154
|
'x-decorator': string;
|
|
139
155
|
'x-decorator-props': {};
|
|
140
156
|
'x-component': string;
|
|
141
|
-
'x-component-props': {
|
|
142
|
-
changeOnSelect: boolean;
|
|
143
|
-
autoSize: {
|
|
144
|
-
minRows: number;
|
|
145
|
-
};
|
|
146
|
-
placeholder: string;
|
|
147
|
-
};
|
|
148
|
-
description: string;
|
|
149
157
|
};
|
|
150
158
|
timeout: {
|
|
151
159
|
type: string;
|
|
@@ -168,12 +176,12 @@ export default class extends Instruction {
|
|
|
168
176
|
};
|
|
169
177
|
};
|
|
170
178
|
components: {
|
|
171
|
-
ArrayItems: import("@formily/
|
|
172
|
-
Item: import("@formily/
|
|
179
|
+
ArrayItems: import("@formily/react").ReactFC<React.HTMLAttributes<HTMLDivElement>> & import("@formily/antd-v5").ArrayBaseMixins & {
|
|
180
|
+
Item: import("@formily/react").ReactFC<React.HTMLAttributes<HTMLDivElement> & {
|
|
173
181
|
type?: "card" | "divide";
|
|
174
182
|
}>;
|
|
175
183
|
};
|
|
176
|
-
|
|
184
|
+
BodyComponent: typeof BodyComponent;
|
|
177
185
|
WorkflowVariableTextArea: typeof WorkflowVariableTextArea;
|
|
178
186
|
WorkflowVariableJSON: typeof WorkflowVariableJSON;
|
|
179
187
|
};
|
|
@@ -192,3 +200,4 @@ export default class extends Instruction {
|
|
|
192
200
|
label: any;
|
|
193
201
|
};
|
|
194
202
|
}
|
|
203
|
+
export {};
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(
|
|
10
|
+
(function(e,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("@formily/core"),require("@formily/shared"),require("@formily/react"),require("@formily/antd-v5"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","@formily/core","@formily/shared","@formily/react","@formily/antd-v5","@nocobase/plugin-workflow/client","react-i18next"],o):(e=typeof globalThis!="undefined"?globalThis:e||self,o(e["@nocobase/plugin-workflow-request"]={},e["@nocobase/client"],e.jsxRuntime,e.react,e["@formily/core"],e["@formily/shared"],e["@formily/react"],e["@formily/antd-v5"],e["@nocobase/plugin-workflow"]))})(this,function(e,o,t,l,i,u,p,s,n){"use strict";var P=Object.defineProperty,$=Object.defineProperties;var C=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var f=(e,o,t)=>o in e?P(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,b=(e,o)=>{for(var t in o||(o={}))j.call(o,t)&&f(e,t,o[t]);if(T)for(var t of T(o))V.call(o,t)&&f(e,t,o[t]);return e},h=(e,o)=>$(e,C(o));var a=(e,o,t)=>(f(e,typeof o!="symbol"?o+"":o,t),t);var d=(e,o,t)=>new Promise((l,i)=>{var u=n=>{try{s(t.next(n))}catch(r){i(r)}},p=n=>{try{s(t.throw(n))}catch(r){i(r)}},s=n=>n.done?l(n.value):Promise.resolve(n.value).then(u,p);s((t=t.apply(e,o)).next())});const r="workflow-request",w={"application/json":{type:"void",properties:{data:{type:"object","x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableJSON","x-component-props":{changeOnSelect:!0,autoSize:{minRows:10},placeholder:`{{t("Input request data", { ns: "${r}" })}}`}}}},"application/x-www-form-urlencoded":{type:"void",properties:{data:{type:"array","x-decorator":"FormItem","x-decorator-props":{},"x-component":"ArrayItems",items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add key-value pairs", { ns: "${r}" })}}`,"x-component":"ArrayItems.Addition"}}}}}};function A(I){const m=p.useField(),{values:x,setValuesIn:y,clearFormGraph:v}=p.useForm(),{contentType:c}=x,[S,k]=l.useState(w[c]);return p.useFormEffects(()=>{i.onFieldValueChange("contentType",g=>{v(`${m.address}.*`),k(h(b({},w[g.value]),{name:u.uid()})),y("data",null)})}),t.jsx(o.SchemaComponent,{basePath:m.address,schema:S,onlyRenderProperties:!0})}class F extends n.Instruction{constructor(){super(...arguments);a(this,"title",`{{t("HTTP request", { ns: "${r}" })}}`);a(this,"type","request");a(this,"group","extended");a(this,"description",`{{t("Send HTTP request to a URL. You can use the variables in the upstream nodes as request headers, parameters and request body.", { ns: "${r}" })}}`);a(this,"fieldset",{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${r}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}],default:"POST"},url:{type:"string",required:!0,title:`{{t("URL", { ns: "${r}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"WorkflowVariableTextArea","x-component-props":{placeholder:"https://www.nocobase.com"}},contentType:{type:"string",title:`{{t("Content-Type", { ns: "${r}" })}}`,"x-decorator":"FormItem","x-component":"Select","x-component-props":{allowClear:!1},enum:[{label:"application/json",value:"application/json"},{label:"application/x-www-form-urlencoded",value:"application/x-www-form-urlencoded"}],default:"application/json"},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${r}" })}}`,description:`{{t('"Content-Type" will be ignored from headers.', { ns: "${r}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add request header", { ns: "${r}" })}}`,"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Parameters", { ns: "${r}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:'{{t("Name")}}'}},value:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{useTypedConstant:!0}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${r}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"void",title:`{{t("Body", { ns: "${r}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"BodyComponent"},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${r}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${r}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${r}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}});a(this,"components",{ArrayItems:s.ArrayItems,BodyComponent:A,WorkflowVariableTextArea:n.WorkflowVariableTextArea,WorkflowVariableJSON:n.WorkflowVariableJSON})}useVariables({key:x,title:y},{types:v,fieldNames:c=n.defaultFieldNames}){return{[c.value]:x,[c.label]:y}}}class q extends o.Plugin{afterAdd(){return d(this,null,function*(){})}beforeLoad(){return d(this,null,function*(){})}load(){return d(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",F)})}}e.default=q,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
+
"react": "18.2.0",
|
|
12
|
+
"@formily/core": "2.3.0",
|
|
13
|
+
"@formily/shared": "2.3.0",
|
|
14
|
+
"@formily/react": "2.3.0",
|
|
11
15
|
"@formily/antd-v5": "1.1.9",
|
|
12
|
-
"@nocobase/plugin-workflow": "1.0.0-alpha.
|
|
13
|
-
"@nocobase/client": "1.0.0-alpha.
|
|
16
|
+
"@nocobase/plugin-workflow": "1.0.0-alpha.8",
|
|
17
|
+
"@nocobase/client": "1.0.0-alpha.8",
|
|
14
18
|
"react-i18next": "11.18.6",
|
|
15
|
-
"@nocobase/server": "1.0.0-alpha.
|
|
19
|
+
"@nocobase/server": "1.0.0-alpha.8",
|
|
16
20
|
"axios": "0.26.1"
|
|
17
21
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
"Add parameter": "添加参数",
|
|
10
10
|
"Body": "请求体",
|
|
11
11
|
"Use variable": "使用变量",
|
|
12
|
+
"Add key-value pairs": "添加键值对",
|
|
12
13
|
"Format": "格式化",
|
|
13
14
|
"Insert": "插入",
|
|
14
15
|
"Timeout config": "超时设置",
|
|
15
16
|
"ms": "毫秒",
|
|
16
17
|
"Input request data": "输入请求数据",
|
|
17
18
|
"Only support standard JSON data": "仅支持标准 JSON 数据",
|
|
18
|
-
"\"Content-Type\"
|
|
19
|
+
"\"Content-Type\" will be ignored from headers.": "请求头中配置的 \"Content-Type\" 将被忽略。",
|
|
19
20
|
"Ignore failed request and continue workflow": "忽略失败的请求并继续工作流"
|
|
20
21
|
}
|
|
@@ -14,6 +14,7 @@ export interface Header {
|
|
|
14
14
|
}
|
|
15
15
|
export type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params' | 'data' | 'timeout'> & {
|
|
16
16
|
headers: Array<Header>;
|
|
17
|
+
contentType: string;
|
|
17
18
|
ignoreFail: boolean;
|
|
18
19
|
};
|
|
19
20
|
export default class extends Instruction {
|
|
@@ -41,8 +41,18 @@ __export(RequestInstruction_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(RequestInstruction_exports);
|
|
42
42
|
var import_axios = __toESM(require("axios"));
|
|
43
43
|
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
44
|
+
const ContentTypeTransformers = {
|
|
45
|
+
"application/json"(data) {
|
|
46
|
+
return data;
|
|
47
|
+
},
|
|
48
|
+
"application/x-www-form-urlencoded"(data) {
|
|
49
|
+
return new URLSearchParams(
|
|
50
|
+
data.filter(({ name, value }) => name && typeof value !== "undefined").map(({ name, value }) => [name, value])
|
|
51
|
+
).toString();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
44
54
|
async function request(config) {
|
|
45
|
-
const { url, method = "POST", data, timeout = 5e3 } = config;
|
|
55
|
+
const { url, method = "POST", contentType = "application/json", data, timeout = 5e3 } = config;
|
|
46
56
|
const headers = (config.headers ?? []).reduce((result, header) => {
|
|
47
57
|
if (header.name.toLowerCase() === "content-type") {
|
|
48
58
|
return result;
|
|
@@ -53,14 +63,16 @@ async function request(config) {
|
|
|
53
63
|
(result, param) => Object.assign(result, { [param.name]: param.value }),
|
|
54
64
|
{}
|
|
55
65
|
);
|
|
56
|
-
headers["Content-Type"] =
|
|
66
|
+
headers["Content-Type"] = contentType;
|
|
57
67
|
return import_axios.default.request({
|
|
58
68
|
url,
|
|
59
69
|
method,
|
|
60
70
|
headers,
|
|
61
71
|
params,
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
timeout,
|
|
73
|
+
...method.toLowerCase() !== "get" && data != null ? {
|
|
74
|
+
data: ContentTypeTransformers[contentType](data)
|
|
75
|
+
} : {}
|
|
64
76
|
});
|
|
65
77
|
}
|
|
66
78
|
class RequestInstruction_default extends import_plugin_workflow.Instruction {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:HTTP 请求节点",
|
|
5
5
|
"description": "Send HTTP requests to any HTTP service for data interaction in workflow.",
|
|
6
6
|
"description.zh-CN": "可用于在工作流中向任意 HTTP 服务发送请求,进行数据交互。",
|
|
7
|
-
"version": "1.0.0-alpha.
|
|
7
|
+
"version": "1.0.0-alpha.8",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow-request",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@nocobase/server": "1.x",
|
|
25
25
|
"@nocobase/test": "1.x"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "3c4e978f6fc366c01621c9d625678e91f53f8662",
|
|
28
28
|
"keywords": [
|
|
29
29
|
"Workflow"
|
|
30
30
|
]
|