@nocobase/plugin-workflow-request 1.8.0-beta.9 → 1.9.0-alpha.1

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.
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- import { Instruction, WorkflowVariableJSON, WorkflowVariableRawTextArea, WorkflowVariableTextArea } from '@nocobase/plugin-workflow/client';
10
+ import { Instruction, WorkflowVariableJSON, WorkflowVariableRawTextArea, WorkflowVariableTextArea, WorkflowVariableInput } from '@nocobase/plugin-workflow/client';
11
11
  declare function BodyComponent(props: any): React.JSX.Element;
12
12
  export default class extends Instruction {
13
13
  title: string;
@@ -202,6 +202,7 @@ export default class extends Instruction {
202
202
  WorkflowVariableJSON: typeof WorkflowVariableJSON;
203
203
  WorkflowVariableTextArea: typeof WorkflowVariableTextArea;
204
204
  WorkflowVariableRawTextArea: typeof WorkflowVariableRawTextArea;
205
+ WorkflowVariableInput: typeof WorkflowVariableInput;
205
206
  };
206
207
  useVariables({ key, title, config }: {
207
208
  key: any;
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@formily/core"),require("@formily/antd-v5"),require("@formily/react"),require("@formily/shared"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-request",["react","@formily/core","@formily/antd-v5","@formily/react","@formily/shared","@nocobase/client","@ant-design/icons","@nocobase/plugin-workflow/client","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-request"]=t(require("react"),require("@formily/core"),require("@formily/antd-v5"),require("@formily/react"),require("@formily/shared"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):e["@nocobase/plugin-workflow-request"]=t(e.react,e["@formily/core"],e["@formily/antd-v5"],e["@formily/react"],e["@formily/shared"],e["@nocobase/client"],e["@ant-design/icons"],e["@nocobase/plugin-workflow/client"],e["react-i18next"])}(self,function(e,t,r,o,n,a,i,c,l){return function(){"use strict";var u={482:function(e){e.exports=i},632:function(e){e.exports=r},563:function(e){e.exports=t},505:function(e){e.exports=o},875:function(e){e.exports=n},772:function(e){e.exports=a},433:function(e){e.exports=c},156:function(t){t.exports=e},238:function(e){e.exports=l}},p={};function s(e){var t=p[e];if(void 0!==t)return t.exports;var r=p[e]={exports:{}};return u[e](r,r.exports,s),r.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var f={};return!function(){s.r(f),s.d(f,{default:function(){return _}});var e=s(772),t=s(156),r=s.n(t),o=s(563),n=s(875),a=s(505),i=s(632),c=s(482),l=s(433),u=s(238),p="workflow-request";function m(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=r,(0,u.useTranslation)(p,t)).t)(e)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function w(){var e=v(["\n font-size: 80%;\n font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n "]);return w=function(){return e},e}function g(){var e=v(["\n font-size: 80%;\n font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n "]);return g=function(){return e},e}function O(){var e=v(["\n & > .ant-space-item:first-child,\n & > .ant-space-item:last-child {\n flex-shrink: 0;\n }\n "]);return O=function(){return e},e}function j(){var e=v(["\n & > .ant-space-item:first-child,\n & > .ant-space-item:last-child {\n flex-shrink: 0;\n }\n "]);return j=function(){return e},e}var T={"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: "'.concat(p,'" })}}')}}}},"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: "'.concat(p,'" })}}'),"x-component":"ArrayItems.Addition"}}}}},"application/xml":{type:"void",properties:{data:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{placeholder:'<?xml version="1.0" encoding="UTF-8"?>',autoSize:{minRows:10},className:(0,e.css)(w())}}}},"text/plain":{type:"void",properties:{data:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{autoSize:{minRows:10},className:(0,e.css)(g())}}}}};function I(i){var c,l=(0,a.useField)(),u=(0,a.useForm)(),p=u.values,s=u.setValuesIn,f=u.clearFormGraph,m=p.contentType,b=(c=(0,t.useState)(T[m]),function(e){if(Array.isArray(e))return e}(c)||function(e,t){var r,o,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(c,2)||function(e,t){if(e){if("string"==typeof e)return d(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}}(c,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),x=b[0],v=b[1];return(0,a.useFormEffects)(function(){(0,o.onFieldValueChange)("contentType",function(e){var t,r;f("".concat(l.address,".*")),v((t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){y(e,t,r[t])})}return e}({},T[e.value]),r=r={name:(0,n.uid)()},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t)),s("data",null)})}),r().createElement(e.SchemaComponent,{basePath:l.address,schema:x,onlyRenderProperties:!0})}var S=function(t){var o;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,o,a;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return o=n,a=arguments,o=b(o),y(t=function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,h()?Reflect.construct(o,a||[],b(this).constructor):o.apply(this,a)),"title",'{{t("HTTP request", { ns: "'.concat(p,'" })}}')),y(t,"type","request"),y(t,"group","extended"),y(t,"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: "'.concat(p,'" })}}')),y(t,"icon",r().createElement(c.GlobalOutlined,null)),y(t,"fieldset",{method:{type:"string",required:!0,title:'{{t("HTTP method", { ns: "'.concat(p,'" })}}'),"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: "'.concat(p,'" })}}'),"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: "'.concat(p,'" })}}'),"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: "'.concat(p,'" })}}'),description:'{{t(\'"Content-Type" will be ignored from headers.\', { ns: "'.concat(p,'" })}}'),items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%"},className:(0,e.css)(O())},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 request header", { ns: "'.concat(p,'" })}}'),"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:'{{t("Parameters", { ns: "'.concat(p,'" })}}'),items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%"},className:(0,e.css)(j())},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: "'.concat(p,'" })}}'),"x-component":"ArrayItems.Addition"}}},data:{type:"void",title:'{{t("Body", { ns: "'.concat(p,'" })}}'),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"BodyComponent"},timeout:{type:"number",title:'{{t("Timeout config", { ns: "'.concat(p,'" })}}'),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:'{{t("ms", { ns: "'.concat(p,'" })}}'),min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean","x-content":'{{t("Ignore failed request and continue workflow", { ns: "'.concat(p,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox"}}),y(t,"components",{ArrayItems:i.ArrayItems,BodyComponent:I,WorkflowVariableJSON:l.WorkflowVariableJSON,WorkflowVariableTextArea:l.WorkflowVariableTextArea,WorkflowVariableRawTextArea:l.WorkflowVariableRawTextArea}),y(t,"testable",!0),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&x(n,t),o=[{key:"useVariables",value:function(e,t){var r,o,n,a,i=e.key,c=e.title,u=e.config;t.types;var p=m("Status code"),s=m("Data"),f=m("Response headers");return y(a={},l.defaultFieldNames.value,i),y(a,l.defaultFieldNames.label,c),y(a,l.defaultFieldNames.children,u.onlyData?null:[(y(r={},l.defaultFieldNames.value,"status"),y(r,l.defaultFieldNames.label,p),r),(y(o={},l.defaultFieldNames.value,"data"),y(o,l.defaultFieldNames.label,s),o),(y(n={},l.defaultFieldNames.value,"headers"),y(n,l.defaultFieldNames.label,f),n)]),a}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,o),n}(l.Instruction);function P(e,t,r,o,n,a,i){try{var c=e[a](i),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(o,n)}function k(e){return function(){var t=this,r=arguments;return new Promise(function(o,n){var a=e.apply(t,r);function i(e){P(a,o,n,i,c,"next",e)}function c(e){P(a,o,n,i,c,"throw",e)}i(void 0)})}}function A(e,t,r){return(A=N()?Reflect.construct:function(e,t,r){var o=[null];o.push.apply(o,t);var n=new(Function.bind.apply(e,o));return r&&q(n,r.prototype),n}).apply(null,arguments)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(e){var t="function"==typeof Map?new Map:void 0;return(E=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return A(e,arguments,F(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),q(r,e)})(e)}function N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(N=function(){return!!e})()}function R(e,t){var r,o,n,a,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){var l=[a,c];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,o&&(n=2&l[0]?o.return:l[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,l[1])).done)return n;switch(o=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(n=(n=i.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){i.label=l[1];break}if(6===l[0]&&i.label<n[1]){i.label=n[1],n=l;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(l);break}n[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{r=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var _=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=F(e),function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,N()?Reflect.construct(e,t||[],F(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&q(r,e),t=[{key:"afterAdd",value:function(){return k(function(){return R(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return k(function(){return R(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return k(function(){return R(this,function(t){return e.app.pm.get("workflow").registerInstruction("request",S),[2]})})()}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(r.prototype,t),r}(E(e.Plugin))}(),f}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@formily/core"),require("@formily/antd-v5"),require("@formily/react"),require("@formily/shared"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-request",["react","@formily/core","@formily/antd-v5","@formily/react","@formily/shared","@nocobase/client","@ant-design/icons","@nocobase/plugin-workflow/client","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-request"]=t(require("react"),require("@formily/core"),require("@formily/antd-v5"),require("@formily/react"),require("@formily/shared"),require("@nocobase/client"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):e["@nocobase/plugin-workflow-request"]=t(e.react,e["@formily/core"],e["@formily/antd-v5"],e["@formily/react"],e["@formily/shared"],e["@nocobase/client"],e["@ant-design/icons"],e["@nocobase/plugin-workflow/client"],e["react-i18next"])}(self,function(e,t,r,o,n,a,i,c,l){return function(){"use strict";var p={482:function(e){e.exports=i},632:function(e){e.exports=r},563:function(e){e.exports=t},505:function(e){e.exports=o},875:function(e){e.exports=n},772:function(e){e.exports=a},433:function(e){e.exports=c},156:function(t){t.exports=e},238:function(e){e.exports=l}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var r=u[e]={exports:{}};return p[e](r,r.exports,s),r.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var f={};return!function(){s.r(f),s.d(f,{default:function(){return N}});var e=s(772),t=s(156),r=s.n(t),o=s(563),n=s(875),a=s(505),i=s(632),c=s(482),l=s(433),p=s(238),u="workflow-request";function m(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=r,(0,p.useTranslation)(u,t)).t)(e)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function w(){var e=v(["\n font-size: 80%;\n font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n "]);return w=function(){return e},e}function g(){var e=v(["\n font-size: 80%;\n font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;\n "]);return g=function(){return e},e}function O(){var e=v(["\n & > .ant-space-item:first-child,\n & > .ant-space-item:last-child {\n flex-shrink: 0;\n }\n "]);return O=function(){return e},e}function I(){var e=v(["\n & > .ant-space-item:first-child,\n & > .ant-space-item:last-child {\n flex-shrink: 0;\n }\n "]);return I=function(){return e},e}var T={"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: "'.concat(u,'" })}}')}}}},"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: "'.concat(u,'" })}}'),"x-component":"ArrayItems.Addition"}}}}},"multipart/form-data":{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")}}'}},valueType:{type:"string","x-decorator":"FormItem","x-component":"Select","x-component-props":{allowClear:!1},enum:[{value:"text",label:"Text"},{value:"file",label:"File"}],default:"text"},text:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableTextArea","x-component-props":{useTypedConstant:!0},"x-reactions":[{dependencies:[".valueType"],fulfill:{state:{visible:'{{ $deps[0]==="text" }}'}}}]},file:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{variableOptions:{types:[function(e,t){var r,o=t.collectionManager;return!!e.target&&("attachments"===e.target||(null==(r=o.getCollection(e.target))?void 0:r.template)==="file")}]}},"x-reactions":[{dependencies:[".valueType"],fulfill:{state:{visible:'{{ $deps[0]==="file" }}'}}}]},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:'{{t("Add key-value pairs", { ns: "'.concat(u,'" })}}'),"x-component":"ArrayItems.Addition"}}}}},"application/xml":{type:"void",properties:{data:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{placeholder:'<?xml version="1.0" encoding="UTF-8"?>',autoSize:{minRows:10},className:(0,e.css)(w())}}}},"text/plain":{type:"void",properties:{data:{type:"string","x-decorator":"FormItem","x-component":"WorkflowVariableRawTextArea","x-component-props":{autoSize:{minRows:10},className:(0,e.css)(g())}}}}};function j(i){var c,l=(0,a.useField)(),p=(0,a.useForm)(),u=p.values,s=p.setValuesIn,f=p.clearFormGraph,m=u.contentType,b=(c=(0,t.useState)(T[m]),function(e){if(Array.isArray(e))return e}(c)||function(e,t){var r,o,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(c,2)||function(e,t){if(e){if("string"==typeof e)return d(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}}(c,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),x=b[0],v=b[1];return(0,a.useFormEffects)(function(){(0,o.onFieldValueChange)("contentType",function(e){var t,r;f("".concat(l.address,".*")),v((t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){y(e,t,r[t])})}return e}({},T[e.value]),r=r={name:(0,n.uid)()},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r.push.apply(r,o)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t)),s("data",null)})}),r().createElement(e.SchemaComponent,{basePath:l.address,schema:x,onlyRenderProperties:!0})}var F=function(t){var o;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");function n(){var t,o,a;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return o=n,a=arguments,o=b(o),y(t=function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,h()?Reflect.construct(o,a||[],b(this).constructor):o.apply(this,a)),"title",'{{t("HTTP request", { ns: "'.concat(u,'" })}}')),y(t,"type","request"),y(t,"group","extended"),y(t,"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: "'.concat(u,'" })}}')),y(t,"icon",r().createElement(c.GlobalOutlined,null)),y(t,"fieldset",{method:{type:"string",required:!0,title:'{{t("HTTP method", { ns: "'.concat(u,'" })}}'),"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: "'.concat(u,'" })}}'),"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: "'.concat(u,'" })}}'),"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:"multipart/form-data",value:"multipart/form-data"},{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: "'.concat(u,'" })}}'),description:'{{t(\'"Content-Type" will be ignored from headers.\', { ns: "'.concat(u,'" })}}'),items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%"},className:(0,e.css)(O())},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 request header", { ns: "'.concat(u,'" })}}'),"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:'{{t("Parameters", { ns: "'.concat(u,'" })}}'),items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%"},className:(0,e.css)(I())},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: "'.concat(u,'" })}}'),"x-component":"ArrayItems.Addition"}}},data:{type:"void",title:'{{t("Body", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"BodyComponent"},timeout:{type:"number",title:'{{t("Timeout config", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:'{{t("ms", { ns: "'.concat(u,'" })}}'),min:1,step:1e3,defaultValue:5e3}},ignoreFail:{type:"boolean","x-content":'{{t("Ignore failed request and continue workflow", { ns: "'.concat(u,'" })}}'),"x-decorator":"FormItem","x-component":"Checkbox"}}),y(t,"components",{ArrayItems:i.ArrayItems,BodyComponent:j,WorkflowVariableJSON:l.WorkflowVariableJSON,WorkflowVariableTextArea:l.WorkflowVariableTextArea,WorkflowVariableRawTextArea:l.WorkflowVariableRawTextArea,WorkflowVariableInput:l.WorkflowVariableInput}),y(t,"testable",!0),t}return n.prototype=Object.create(t&&t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),t&&x(n,t),o=[{key:"useVariables",value:function(e,t){var r,o,n,a,i=e.key,c=e.title,p=e.config;t.types;var u=m("Status code"),s=m("Data"),f=m("Response headers");return y(a={},l.defaultFieldNames.value,i),y(a,l.defaultFieldNames.label,c),y(a,l.defaultFieldNames.children,p.onlyData?null:[(y(r={},l.defaultFieldNames.value,"status"),y(r,l.defaultFieldNames.label,u),r),(y(o={},l.defaultFieldNames.value,"data"),y(o,l.defaultFieldNames.label,s),o),(y(n={},l.defaultFieldNames.value,"headers"),y(n,l.defaultFieldNames.label,f),n)]),a}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,o),n}(l.Instruction);function S(e,t,r,o,n,a,i){try{var c=e[a](i),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(o,n)}function k(e){return function(){var t=this,r=arguments;return new Promise(function(o,n){var a=e.apply(t,r);function i(e){S(a,o,n,i,c,"next",e)}function c(e){S(a,o,n,i,c,"throw",e)}i(void 0)})}}function A(e,t,r){return(A=C()?Reflect.construct:function(e,t,r){var o=[null];o.push.apply(o,t);var n=new(Function.bind.apply(e,o));return r&&q(n,r.prototype),n}).apply(null,arguments)}function P(e){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function V(e){var t="function"==typeof Map?new Map:void 0;return(V=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return A(e,arguments,P(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),q(r,e)})(e)}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}function E(e,t){var r,o,n,a,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){var l=[a,c];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,o&&(n=2&l[0]?o.return:l[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,l[1])).done)return n;switch(o=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,o=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(n=(n=i.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){i.label=l[1];break}if(6===l[0]&&i.label<n[1]){i.label=n[1],n=l;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(l);break}n[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],o=0}finally{r=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var N=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=P(e),function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,C()?Reflect.construct(e,t||[],P(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&q(r,e),t=[{key:"afterAdd",value:function(){return k(function(){return E(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return k(function(){return E(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return k(function(){return E(this,function(t){return e.app.pm.get("workflow").registerInstruction("request",F),[2]})})()}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(r.prototype,t),r}(V(e.Plugin))}(),f}()});
@@ -14,10 +14,11 @@ module.exports = {
14
14
  "@formily/react": "2.3.0",
15
15
  "@formily/antd-v5": "1.2.3",
16
16
  "@ant-design/icons": "5.6.1",
17
- "@nocobase/client": "1.8.0-beta.9",
18
- "@nocobase/plugin-workflow": "1.8.0-beta.9",
17
+ "@nocobase/client": "1.9.0-alpha.1",
18
+ "@nocobase/plugin-workflow": "1.9.0-alpha.1",
19
19
  "react-i18next": "11.18.6",
20
- "@nocobase/server": "1.8.0-beta.9",
20
+ "@nocobase/server": "1.9.0-alpha.1",
21
21
  "axios": "1.7.7",
22
- "lodash": "4.17.21"
22
+ "lodash": "4.17.21",
23
+ "@nocobase/plugin-file-manager": "1.9.0-alpha.1"
23
24
  };
@@ -42,17 +42,50 @@ module.exports = __toCommonJS(RequestInstruction_exports);
42
42
  var import_axios = __toESM(require("axios"));
43
43
  var import_lodash = require("lodash");
44
44
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
45
- const ContentTypeTransformers = {
46
- "text/plain"(data) {
47
- return data.toString();
48
- },
49
- "application/x-www-form-urlencoded"(data) {
50
- return new URLSearchParams(
51
- data.filter(({ name, value }) => name && typeof value !== "undefined").map(({ name, value }) => [name, value])
52
- ).toString();
45
+ var import_plugin_file_manager = __toESM(require("@nocobase/plugin-file-manager"));
46
+ function getContentTypeTransformer(mimeType, app) {
47
+ switch (mimeType) {
48
+ case "text/plain":
49
+ return function(data) {
50
+ return data.toString();
51
+ };
52
+ case "application/x-www-form-urlencoded":
53
+ return function(data) {
54
+ return new URLSearchParams(
55
+ data.filter(({ name, value }) => name && typeof value !== "undefined").map(({ name, value }) => [name, value])
56
+ ).toString();
57
+ };
58
+ case "multipart/form-data":
59
+ return async function(data) {
60
+ const form = new FormData();
61
+ for (const record of data) {
62
+ if (record.valueType === "text") {
63
+ form.append(record.name, record.text);
64
+ continue;
65
+ }
66
+ if (record.valueType === "file") {
67
+ if (record.file == null) {
68
+ continue;
69
+ }
70
+ const plugin = app.pm.get(import_plugin_file_manager.default);
71
+ const files = Array.isArray(record.file) ? record.file : [record.file];
72
+ for (const file of files) {
73
+ const { stream, contentType } = await plugin.getFileStream(file);
74
+ const chunks = [];
75
+ for await (const chunk of stream) {
76
+ chunks.push(chunk);
77
+ }
78
+ form.append(record.name, new Blob(chunks, { type: contentType }), file.filename);
79
+ }
80
+ continue;
81
+ }
82
+ throw new Error(`Invalid value type: ${JSON.stringify(record)}`);
83
+ }
84
+ return form;
85
+ };
53
86
  }
54
- };
55
- async function request(config) {
87
+ }
88
+ async function request(config, app) {
56
89
  const { url, method = "POST", contentType = "application/json", data, timeout = 5e3 } = config;
57
90
  const headers = (config.headers ?? []).reduce((result, header) => {
58
91
  const name = (0, import_lodash.trim)(header.name);
@@ -65,8 +98,10 @@ async function request(config) {
65
98
  (result, param) => Object.assign(result, { [param.name]: (0, import_lodash.trim)(param.value) }),
66
99
  {}
67
100
  );
68
- headers["Content-Type"] = contentType;
69
- const transformer = ContentTypeTransformers[contentType];
101
+ if (contentType !== "multipart/form-data") {
102
+ headers["Content-Type"] = contentType;
103
+ }
104
+ const transformer = getContentTypeTransformer(contentType, app);
70
105
  return import_axios.default.request({
71
106
  url: (0, import_lodash.trim)(url),
72
107
  method,
@@ -74,7 +109,7 @@ async function request(config) {
74
109
  params,
75
110
  timeout,
76
111
  ...method.toLowerCase() !== "get" && data != null ? {
77
- data: transformer ? transformer(data) : data
112
+ data: transformer ? await transformer(data) : data
78
113
  } : {}
79
114
  });
80
115
  }
@@ -114,7 +149,7 @@ class RequestInstruction_default extends import_plugin_workflow.Instruction {
114
149
  const sync = this.workflow.isWorkflowSync(workflow);
115
150
  if (sync) {
116
151
  try {
117
- const response = await request(config);
152
+ const response = await request(config, this.workflow.app);
118
153
  return {
119
154
  status: import_plugin_workflow.JOB_STATUS.RESOLVED,
120
155
  result: responseSuccess(response, config.onlyData)
@@ -132,7 +167,7 @@ class RequestInstruction_default extends import_plugin_workflow.Instruction {
132
167
  nodeKey: node.key,
133
168
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
134
169
  });
135
- request(config).then((response) => {
170
+ request(config, this.workflow.app).then((response) => {
136
171
  processor.logger.info(`request (#${node.id}) response success, status: ${response.status}`);
137
172
  job.set({
138
173
  status: import_plugin_workflow.JOB_STATUS.RESOLVED,
@@ -173,7 +208,7 @@ class RequestInstruction_default extends import_plugin_workflow.Instruction {
173
208
  }
174
209
  async test(config) {
175
210
  try {
176
- const response = await request(config);
211
+ const response = await request(config, this.workflow.app);
177
212
  return {
178
213
  status: import_plugin_workflow.JOB_STATUS.RESOLVED,
179
214
  result: responseSuccess(response, config.onlyData)
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.8.0-beta.9",
7
+ "version": "1.9.0-alpha.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-request",
@@ -18,11 +18,12 @@
18
18
  "peerDependencies": {
19
19
  "@nocobase/client": "1.x",
20
20
  "@nocobase/database": "1.x",
21
+ "@nocobase/plugin-file-manager": "1.x",
21
22
  "@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
22
23
  "@nocobase/server": "1.x",
23
24
  "@nocobase/test": "1.x"
24
25
  },
25
- "gitHead": "a3449d646c72965845f8c52e52fff9dba759c564",
26
+ "gitHead": "71ebde8a27da3c5c4d64194571804eeab6e95ce0",
26
27
  "keywords": [
27
28
  "Workflow"
28
29
  ]