@nocobase/plugin-workflow-request 1.4.0-alpha.20241016084738 → 1.4.0-alpha.20241020025811

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.
@@ -186,7 +186,7 @@ export default class extends Instruction {
186
186
  };
187
187
  ignoreFail: {
188
188
  type: string;
189
- title: string;
189
+ 'x-content': string;
190
190
  'x-decorator': string;
191
191
  'x-component': string;
192
192
  };
@@ -216,5 +216,6 @@ export default class extends Instruction {
216
216
  label: string;
217
217
  }[];
218
218
  };
219
+ testable: boolean;
219
220
  }
220
221
  export {};
@@ -13,7 +13,7 @@
13
13
  `}}}},"text/plain":{type:"void",properties:{data:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{autoSize:{minRows:10},className:o.css`
14
14
  font-size: 80%;
15
15
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
16
- `}}}}};function g(s){const p=l.useField(),{values:d,setValuesIn:w,clearFormGraph:h}=l.useForm(),{contentType:A}=d,[b,v]=x.useState(F[A]);return l.useFormEffects(()=>{c.onFieldValueChange("contentType",I=>{h(`${p.address}.*`),v(q(S({},F[I.value]),{name:f.uid()})),w("data",null)})}),r.jsx(o.SchemaComponent,{basePath:p.address,schema:b,onlyRenderProperties:!0})}class V extends t.Instruction{constructor(){super(...arguments);n(this,"title",`{{t("HTTP request", { ns: "${a}" })}}`);n(this,"type","request");n(this,"group","extended");n(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: "${a}" })}}`);n(this,"fieldset",{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${a}" })}}`,"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: "${a}" })}}`,"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: "${a}" })}}`,"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"},{label:"application/xml",value:"application/xml"},{label:"text/plain",value:"text/plain"}],default:"application/json"},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${a}" })}}`,description:`{{t('"Content-Type" will be ignored from headers.', { ns: "${a}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%"},className:o.css`
16
+ `}}}}};function g(s){const p=l.useField(),{values:d,setValuesIn:w,clearFormGraph:b}=l.useForm(),{contentType:A}=d,[h,v]=x.useState(F[A]);return l.useFormEffects(()=>{c.onFieldValueChange("contentType",I=>{b(`${p.address}.*`),v(q(S({},F[I.value]),{name:f.uid()})),w("data",null)})}),r.jsx(o.SchemaComponent,{basePath:p.address,schema:h,onlyRenderProperties:!0})}class V extends t.Instruction{constructor(){super(...arguments);n(this,"title",`{{t("HTTP request", { ns: "${a}" })}}`);n(this,"type","request");n(this,"group","extended");n(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: "${a}" })}}`);n(this,"fieldset",{method:{type:"string",required:!0,title:`{{t("HTTP method", { ns: "${a}" })}}`,"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: "${a}" })}}`,"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: "${a}" })}}`,"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"},{label:"application/xml",value:"application/xml"},{label:"text/plain",value:"text/plain"}],default:"application/json"},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:`{{t("Headers", { ns: "${a}" })}}`,description:`{{t('"Content-Type" will be ignored from headers.', { ns: "${a}" })}}`,items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%"},className:o.css`
17
17
  & > .ant-space-item:first-child,
18
18
  & > .ant-space-item:last-child {
19
19
  flex-shrink: 0;
@@ -23,4 +23,4 @@
23
23
  & > .ant-space-item:last-child {
24
24
  flex-shrink: 0;
25
25
  }
26
- `},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,placeholder:'{{t("Value")}}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${a}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"void",title:`{{t("Body", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"BodyComponent"},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${a}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean",title:`{{t("Ignore failed request and continue workflow", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}});n(this,"components",{ArrayItems:i.ArrayItems,BodyComponent:g,WorkflowVariableJSON:t.WorkflowVariableJSON,WorkflowVariableTextArea:t.WorkflowVariableTextArea,WorkflowVariableRawTextArea:t.WorkflowVariableRawTextArea})}useVariables({key:d,title:w,config:h},{types:A}){const b=y("Status code"),v=y("Data"),I=y("Response headers");return{[t.defaultFieldNames.value]:d,[t.defaultFieldNames.label]:w,[t.defaultFieldNames.children]:h.onlyData?null:[{[t.defaultFieldNames.value]:"status",[t.defaultFieldNames.label]:b},{[t.defaultFieldNames.value]:"data",[t.defaultFieldNames.label]:v},{[t.defaultFieldNames.value]:"headers",[t.defaultFieldNames.label]:I}]}}}class C extends o.Plugin{afterAdd(){return u(this,null,function*(){})}beforeLoad(){return u(this,null,function*(){})}load(){return u(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",V)})}}e.default=C,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
26
+ `},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,placeholder:'{{t("Value")}}'}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:`{{t("Add parameter", { ns: "${a}" })}}`,"x-component":"ArrayItems.Addition"}}},data:{type:"void",title:`{{t("Body", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"BodyComponent"},timeout:{type:"number",title:`{{t("Timeout config", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:`{{t("ms", { ns: "${a}" })}}`,min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean","x-content":`{{t("Ignore failed request and continue workflow", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"Checkbox"}});n(this,"components",{ArrayItems:i.ArrayItems,BodyComponent:g,WorkflowVariableJSON:t.WorkflowVariableJSON,WorkflowVariableTextArea:t.WorkflowVariableTextArea,WorkflowVariableRawTextArea:t.WorkflowVariableRawTextArea});n(this,"testable",!0)}useVariables({key:d,title:w,config:b},{types:A}){const h=y("Status code"),v=y("Data"),I=y("Response headers");return{[t.defaultFieldNames.value]:d,[t.defaultFieldNames.label]:w,[t.defaultFieldNames.children]:b.onlyData?null:[{[t.defaultFieldNames.value]:"status",[t.defaultFieldNames.label]:h},{[t.defaultFieldNames.value]:"data",[t.defaultFieldNames.label]:v},{[t.defaultFieldNames.value]:"headers",[t.defaultFieldNames.label]:I}]}}}class C extends o.Plugin{afterAdd(){return u(this,null,function*(){})}beforeLoad(){return u(this,null,function*(){})}load(){return u(this,null,function*(){this.app.pm.get("workflow").registerInstruction("request",V)})}}e.default=C,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -13,10 +13,10 @@ module.exports = {
13
13
  "@formily/shared": "2.3.0",
14
14
  "@formily/react": "2.3.0",
15
15
  "@formily/antd-v5": "1.1.9",
16
- "@nocobase/plugin-workflow": "1.4.0-alpha.20241016084738",
17
- "@nocobase/client": "1.4.0-alpha.20241016084738",
16
+ "@nocobase/plugin-workflow": "1.4.0-alpha.20241020025811",
17
+ "@nocobase/client": "1.4.0-alpha.20241020025811",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/server": "1.4.0-alpha.20241016084738",
19
+ "@nocobase/server": "1.4.0-alpha.20241020025811",
20
20
  "axios": "1.7.7",
21
21
  "lodash": "4.17.21"
22
22
  };
@@ -12,8 +12,8 @@
12
12
  "Add key-value pairs": "添加键值对",
13
13
  "Format": "格式化",
14
14
  "Insert": "插入",
15
- "Timeout config": "超时设置",
16
- "ms": "毫秒",
15
+ "Timeout": "超时设置",
16
+ "Milliseconds": "毫秒",
17
17
  "Input request data": "输入请求数据",
18
18
  "Only support standard JSON data": "仅支持标准 JSON 数据",
19
19
  "\"Content-Type\" will be ignored from headers.": "请求头中配置的 \"Content-Type\" 将被忽略。",
@@ -12,13 +12,17 @@ export interface Header {
12
12
  name: string;
13
13
  value: string;
14
14
  }
15
- export type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params' | 'data' | 'timeout'> & {
16
- headers: Array<Header>;
15
+ export type RequestInstructionConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params' | 'data' | 'timeout'> & {
16
+ headers?: Header[];
17
17
  contentType: string;
18
- ignoreFail: boolean;
18
+ ignoreFail?: boolean;
19
19
  onlyData?: boolean;
20
20
  };
21
21
  export default class extends Instruction {
22
22
  run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<any>;
23
23
  resume(node: FlowNodeModel, job: any, processor: Processor): Promise<any>;
24
+ test(config: RequestInstructionConfig): Promise<{
25
+ status: 1 | -1;
26
+ result: any;
27
+ }>;
24
28
  }
@@ -170,4 +170,18 @@ class RequestInstruction_default extends import_plugin_workflow.Instruction {
170
170
  }
171
171
  return job;
172
172
  }
173
+ async test(config) {
174
+ try {
175
+ const response = await request(config);
176
+ return {
177
+ status: import_plugin_workflow.JOB_STATUS.RESOLVED,
178
+ result: responseSuccess(response, config.onlyData)
179
+ };
180
+ } catch (error) {
181
+ return {
182
+ status: config.ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
183
+ result: error.isAxiosError ? error.toJSON() : error.message
184
+ };
185
+ }
186
+ }
173
187
  }
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.4.0-alpha.20241016084738",
7
+ "version": "1.4.0-alpha.20241020025811",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-request",
@@ -22,7 +22,7 @@
22
22
  "@nocobase/server": "1.x",
23
23
  "@nocobase/test": "1.x"
24
24
  },
25
- "gitHead": "01d1423c8664a07cf946331659881990def53d1e",
25
+ "gitHead": "22c4d58a897af2661a4c0b48382ae17b1d61077e",
26
26
  "keywords": [
27
27
  "Workflow"
28
28
  ]