@nocobase/plugin-action-custom-request 2.1.0-alpha.7 → 2.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +1 -1
- package/dist/client/models/FlowJsonWithContextSelector.d.ts +16 -0
- package/dist/client/models/customRequestFlowAction.d.ts +9 -0
- package/dist/client/models/customRequestFlowActionTypes.d.ts +24 -0
- package/dist/client/models/customRequestFlowActionUiSchema.d.ts +217 -0
- package/dist/client/models/utils.d.ts +16 -0
- package/dist/externalVersion.js +10 -8
- package/dist/locale/en-US.json +9 -1
- package/dist/locale/zh-CN.json +9 -1
- package/dist/server/actions/send.js +41 -16
- package/package.json +2 -2
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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("file-saver"),require("@nocobase/client"),require("@formily/shared"),require("@formily/antd-v5"),require("react"),require("@formily/react"),require("@nocobase/utils/client"),require("lodash"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-custom-request",["file-saver","@nocobase/client","@formily/shared","@formily/antd-v5","react","@formily/react","@nocobase/utils/client","lodash","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-action-custom-request"]=t(require("file-saver"),require("@nocobase/client"),require("@formily/shared"),require("@formily/antd-v5"),require("react"),require("@formily/react"),require("@nocobase/utils/client"),require("lodash"),require("antd"),require("react-i18next")):e["@nocobase/plugin-action-custom-request"]=t(e["file-saver"],e["@nocobase/client"],e["@formily/shared"],e["@formily/antd-v5"],e.react,e["@formily/react"],e["@nocobase/utils/client"],e.lodash,e.antd,e["react-i18next"])}(self,function(e,t,r,n,o,i,a,u,c,s){return function(){"use strict";var l={632:function(e){e.exports=n},505:function(e){e.exports=i},875:function(e){e.exports=r},772:function(e){e.exports=t},584:function(e){e.exports=a},721:function(e){e.exports=c},346:function(t){t.exports=e},467:function(e){e.exports=u},156:function(e){e.exports=o},238:function(e){e.exports=s}},p={};function f(e){var t=p[e];if(void 0!==t)return t.exports;var r=p[e]={exports:{}};return l[e](r,r.exports,f),r.exports}f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var r in t)f.o(t,r)&&!f.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var m={};return!function(){f.r(m),f.d(m,{default:function(){return ec},PluginActionCustomRequestClient:function(){return eu}});var e,t,r,n=f(772),o=f(156),i=f.n(o),a=f(505),u=f(584),c=f(721),s=f(346);function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){p(i,n,o,a,u,"next",e)}function u(e){p(i,n,o,a,u,"throw",e)}a(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function y(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var c=[i,u];if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var h=function(){var e=(0,n.useAPIClient)(),t=(0,n.useNavigateNoUpdate)(),r=(0,a.useFieldSchema)(),o=(0,n.useBlockRequestContext)().field,i=(0,n.useCompile)(),p=(0,a.useForm)(),f=((0,n.useBlockContext)()||{}).name,m=(0,n.useCollectionRecordData)(),h=(0,a.useFieldSchema)(),v=(0,a.useField)(),g=(0,n.useActionContext)().setVisible,O=c.App.useApp(),x=O.modal,S=O.message,w=(0,n.useDataSourceKey)(),P=(0,n.useContextVariable)().ctx,j=(0,n.useLocalVariables)(),A=(0,n.useVariables)();return{onClick:function(a,c){return d(function(){var a,O,C,q,k,R,T,I,E,D,F,V,M,B,$,_,U,N,L,z,G,K,H,J;return y(this,function(N){switch(N.label){case 0:if(q=(null==o||null==(a=o.data)?void 0:a.selectedRowData)?null==o||null==(O=o.data)?void 0:O.selectedRowData:P,T=(R=null!=(k=null==r?void 0:r["x-action-settings"])?k:{}).skipValidator,E=(I=R.onSuccess||{}).manualClose,D=I.redirecting,F=I.redirectTo,V=I.successMessage,M=I.actionAfterSuccess,B=V,$=F,_=null==r?void 0:r["x-action"],!0===T||"customize:form:request"!==_)return[3,2];return[4,p.submit()];case 1:N.sent(),N.label=2;case 2:U=b({},m),"customize:form:request"===_&&(U=p.values),null!=(C=v).data||(C.data={}),v.data.loading=!0,N.label=3;case 3:return N.trys.push([3,,8,9]),z=h["x-custom-request-id"]||h["x-uid"],[4,e.request({url:"/customRequests:send/".concat(z),method:"POST",data:{currentRecord:{dataSourceKey:w,data:U},$nForm:"form"===f?p.values:void 0,$nSelectedRecord:q},responseType:"stream"===h["x-response-type"]?"blob":"json"})];case 4:return G=N.sent(),[4,(0,n.getVariableValue)(B,{variables:A,localVariables:((function(e){if(Array.isArray(e))return l(e)})(j)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(j)||function(e,t){if(e){if("string"==typeof e)return l(e,void 0);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 l(e,t)}}(j)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([{name:"$nResponse",ctx:new Proxy(b({},null==G||null==(L=G.data)?void 0:L.data,null==G?void 0:G.data),{})}])})];case 5:if(B=N.sent(),!F)return[3,7];return[4,(0,n.getVariableValue)(F,{variables:A,localVariables:j})];case 6:$=N.sent(),N.label=7;case 7:if(G.headers["content-disposition"]&&(H=(K=G.headers["content-disposition"]).match(/filename\*=utf-8''([^;]+)/i),J=K.match(/filename="([^"]+)"/i),H?(0,s.saveAs)(G.data,decodeURIComponent(H[1])):J&&(0,s.saveAs)(G.data,J[1])),v.data.loading=!1,c&&(null==c||c()),"previous"!==M&&(M||!0===D)||null==g||g(!1),!B)return(D&&!M||"redirect"===M)&&$&&((0,u.isURL)($)?window.location.href=$:t($)),[2];return E?x.success({title:i(B),onOk:d(function(){return y(this,function(e){return(D&&!M||"redirect"===M)&&$&&((0,u.isURL)($)?window.location.href=$:t($)),[2]})})}):(S.success(i(B)),(D&&!M||"redirect"===M)&&$&&((0,u.isURL)($)?window.location.href=$:t($))),[3,9];case 8:return v.data.loading=!1,[7];case 9:return[2]}})})()}}},v=function(){var e=(0,a.useFieldSchema)(),t=e["x-custom-request-id"]||e["x-uid"],r="customRequests:get/".concat(t);return(0,n.useRequest)({url:r,params:{appends:["roles"]}},{manual:!0,cacheKey:r})},g=f(467),O=f(238),x="action-custom-request";function S(e){return"{{t('".concat(e,"', { ns: '").concat(x,"', nsMode: 'fallback' })}}")}function w(){return(0,O.useTranslation)(x,{nsMode:"fallback"})}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function j(e){return function(e){if(Array.isArray(e))return P(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||A(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){if(e){if("string"==typeof e)return P(e,t);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 P(e,t)}}var C=function(){var e,t=(0,n.useCurrentPopupContext)().params,r=(0,n.useCollectionRecordData)(),o=(0,n.useTableBlockContext)();if(r)return!1;var i=null==(e=(0,n.getStoredPopupContext)(null==t?void 0:t.popupuid))?void 0:e.tableBlockContext;return!(0,g.isEmpty)(i)||!(0,g.isEmpty)(o)},q=function(){var e,t=(0,n.useCollection_deprecated)(),r=w().t,i=(0,n.useCollectionFilterOptions)(t),a=(0,n.useCollectionFilterOptions)("users",n.DEFAULT_DATA_SOURCE_KEY),u=(0,n.useCompile)(),c=(0,n.useCollectionRecordData)(),s=((0,n.useBlockContext)()||{}).name,l=(0,n.useFormBlockContext)().form,p=(e=(0,o.useMemo)(function(){return[u(i),u(a)]},[i,a]),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),i.length!==t);a=!0);}catch(e){u=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw n}}return i}}(e,2)||A(e,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.")}()),f=p[0],m=p[1],d=(0,n.useGlobalVariable)("$env"),b=(0,n.useContextAssociationFields)({maxDepth:2,contextCollectionName:t.name}),y=C();return(0,o.useMemo)(function(){var e,t;return[d,c&&{name:"currentRecord",title:r("Current record",{ns:"client"}),children:j(f)},("form"===s||l)&&{name:"$nForm",title:r("Current form",{ns:"client"}),children:j(f)},{name:"currentUser",title:r("Current user",{ns:"client"}),children:m},{name:"currentTime",title:r("Current time",{ns:"client"}),children:null},{name:"$nToken",title:"API token",children:null},y&&(e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},b),t=t={name:"$nSelectedRecord",title:b.label},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e)].filter(Boolean)},[c,r,f,s,m,y])},k=f(632),R=function(){return(0,n.useAPIClient)().resource("customRequests")},T={value:"name",label:"title"},I=function(){return{scope:q(),fieldNames:T,useTypedConstant:!0}},E={type:"object",properties:{method:{type:"string",required:!0,title:S("HTTP method"),"x-decorator-props":{tooltip:S("When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data")},"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:S("URL"),"x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":I,"x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:S("Headers"),description:S('"Content-Type" only support "application/json", and no need to specify'),items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:S("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":I},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:S("Add request header"),"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:S("Parameters"),items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:S("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":I},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:S("Add parameter"),"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:S("Body"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Variable.JSON","x-component-props":{scope:"{{useCustomRequestVariableOptions}}",fieldNames:{value:"name",label:"title"},changeOnSelect:!0,autoSize:{minRows:10},placeholder:S("Input request data")},description:S("Only support standard JSON data")},timeout:{type:"number",title:S("Timeout config"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:S("ms"),min:1,step:1e3,defaultValue:5e3}},responseType:{type:"string",title:S("Response type"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Select",default:"json",enum:[{value:"json",label:"JSON"},{value:"stream",label:"Stream"}]}}};function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function F(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function V(){return(V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function B(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function $(){var e,t,r,u=w().t,c=(0,n.useCollection_deprecated)().name,s=(0,n.useDataSourceKey)(),l=(0,a.useFieldSchema)(),p=R(),f=v(),m=f.data,d=f.refresh,b=(0,n.useDesignable)().dn,y=(0,o.useMemo)(function(){var e,t=M({},null==m||null==(e=m.data)?void 0:e.options);return t.data&&"string"!=typeof t.data&&(t.data=JSON.stringify(t.data,null,2)),t},[null==m||null==(r=m.data)?void 0:r.options]);return i().createElement(i().Fragment,null,i().createElement(n.SchemaSettingsActionModalItem,{title:u("Request settings"),components:{ArrayItems:k.ArrayItems},beforeOpen:function(){return!m&&d()},scope:{useCustomRequestVariableOptions:q},schema:E,initialValues:y,onSubmit:(e=function(e){var t,r,n;return function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var c=[i,u];if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return t=V({},function(e){if(null==e)throw TypeError("Cannot destructure "+e);return e}(e)),l["x-response-type"]=t.responseType,r=!l["x-custom-request-id"]||l["x-custom-request-id"]===l["x-uid"],[4,p.updateOrCreate({values:{key:l["x-uid"],options:B(M({},t),{collectionName:c,dataSourceKey:s})},filterKeys:["key"]})];case 1:return o.sent(),n={"x-response-type":t.responseType,"x-uid":l["x-uid"]},!r&&l["x-custom-request-id"]&&(n["x-custom-request-id"]=l["x-uid"],l["x-custom-request-id"]=l["x-uid"]),[4,b.emit("patch",{schema:n})];case 2:return o.sent(),b.refresh(),d(),[2]}})},t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){F(i,n,o,a,u,"next",e)}function u(e){F(i,n,o,a,u,"throw",e)}a(void 0)})},function(e){return t.apply(this,arguments)})}))}var _=new n.SchemaSettings({name:"CustomRequestActionSettings",items:[B(M({},n.actionSettingsItems["0"]),{children:((function(e){if(Array.isArray(e))return D(e)})(e=n.actionSettingsItems["0"].children)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return D(e,void 0);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)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([{name:"request settings",Component:$},n.SchemaSettingAccessControl])})]}),U={"customize:table:request":n.Action.Link},N=(0,n.withDynamicSchemaProps)(function(e){var t,r,o=U[(0,a.useFieldSchema)()["x-action"]]||n.Action;return i().createElement(o,(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),r=r={useProps:h},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))});N.Designer=function(){var e=R(),t=(0,a.useFieldSchema)();return i().createElement(n.Action.Designer,{linkageAction:!0,schemaSettings:"CustomRequestActionSettings",buttonEditorProps:{isLink:"customize:table:request"===t["x-action"]},linkageRulesProps:{type:"button"},removeButtonProps:{onConfirmOk:function(){return e.destroy({filterByTk:t["x-uid"]})}}})},N.Decorator=function(e){return(0,n.useAPIClient)(),i().createElement(n.ACLActionProvider,null,e.children)};var L=f(875);function z(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}var G=function(e){var t,r,o,a=R(),u=(0,n.useSchemaInitializerItem)(),c=(0,n.useSchemaInitializer)().insert,s={title:'{{ t("Custom request") }}',"x-component":"CustomRequestAction","x-action":"customize:form:request","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:customRequest","x-decorator":"CustomRequestAction.Decorator","x-uid":(0,L.uid)(),"x-action-settings":{onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Request success")}}'}}};return i().createElement(n.SchemaInitializerItem,(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},u),o=o={onClick:(t=function(){var e,t;return function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var c=[i,u];if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return t=(0,L.merge)(s||{},u.schema||{}),null==u||null==(e=u.schemaInitialize)||e.call(u,t),[4,a.create({values:{key:t["x-uid"]}})];case 1:return r.sent(),c(t),[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(e){z(i,n,o,a,u,"next",e)}function u(e){z(i,n,o,a,u,"throw",e)}a(void 0)})})},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r))};function K(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function H(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){H(e,t,r[t])})}return e}function W(e){return function(e){if(Array.isArray(e))return K(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return K(e,void 0);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 K(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Y=function(){var e=(0,n.useAfterSuccessOptions)();return[{value:"$nResponse",label:(0,(0,O.useTranslation)().t)("Response",{ns:"client"}),children:null}].concat(W(e.filter(function(e){return["currentUser","currentTime","$nRole"].includes(e.value)}))).filter(Boolean)},Q=function(){var e=(0,n.useAfterSuccessOptions)(),t=(0,n.useGlobalVariable)("$env");return W(e.filter(function(e){return"$record"!==e.value})).concat([t]).filter(Boolean)},X=function(){return{scope:Q(),useTypedConstant:!0}},Z=new n.SchemaSettings({name:"actionSettings:customRequest",items:[{name:"editButton",Component:n.ButtonEditor,useComponentProps:function(){return{isLink:"customize:table:request"===(0,a.useFieldSchema)()["x-action"]}}},{name:"linkageRules",Component:n.SchemaSettingsLinkageRules,useComponentProps:function(){return J({},(0,n.useSchemaToolbar)().linkageRulesProps)}},{name:"secondConFirm",Component:n.SecondConFirm},{name:"afterSuccessfulSubmission",Component:function(){var e,t=(0,n.useDesignable)().dn,r=(0,O.useTranslation)().t,o=(0,a.useFieldSchema)(),u=((null==o?void 0:o["x-action-settings"])||{}).onSuccess,c=(0,n.usePlugin)("@nocobase/plugin-block-template"),s=null==c||null==(e=c.isInBlockTemplateConfigPage)?void 0:e.call(c);return i().createElement(n.SchemaSettingsModalItem,{dialogRootClassName:"dialog-after-successful-submission",width:700,title:r("After successful submission"),initialValues:u?J({actionAfterSuccess:(null==u?void 0:u.redirecting)?"redirect":"previous"},u):{manualClose:!1,redirecting:!1,successMessage:'{{t("Saved successfully")}}',actionAfterSuccess:"previous"},schema:{type:"object",title:r("After successful submission"),properties:{successMessage:{title:r("Popup message"),"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:Y,style:{minWidth:"220px"}}},manualClose:{title:r("Message popup close method"),enum:[{label:r("Automatic close"),value:!1},{label:r("Manually close"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{}},redirecting:{title:r("Then"),"x-hidden":!0,enum:[{label:r("Stay on current page"),value:!1},{label:r("Redirect to"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{!!$self.value}}"}}}},actionAfterSuccess:{title:r("Action after successful submission"),enum:[{label:r("Stay on the current popup or page"),value:"stay"},{label:r("Return to the previous popup or page"),value:"previous"},{label:r("Redirect to"),value:"redirect"}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{$self.value==='redirect'}}"}}}},redirectTo:{title:r("Link"),"x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":X},blocksToRefresh:{type:"array",title:r("Refresh data blocks"),"x-decorator":"FormItem","x-use-decorator-props":function(){return{tooltip:r("After successful submission, the selected data blocks will be automatically refreshed.")}},"x-component":n.BlocksSelector,"x-hidden":s}}},onSubmit:function(e){var r;o["x-action-settings"].onSuccess=e,t.emit("patch",{schema:(H(r={},"x-uid",o["x-uid"]),H(r,"x-action-settings",o["x-action-settings"]),r)})}})}},{name:"request settings",Component:$},(t=J({},n.SchemaSettingAccessControl),r=r={useVisible:function(){return!0}},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t),{name:"refreshDataBlockRequest",Component:n.RefreshDataBlockRequest,useComponentProps:function(){return{isPopupAction:!1}},useVisible:function(){return!!(0,n.useCollection)()}},{name:"delete",sort:100,Component:n.RemoveButton,useComponentProps:function(){return(0,n.useSchemaToolbar)().removeButtonProps}}]});function ee(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function et(e,t,r){return(et=ei()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&en(o,r.prototype),o}).apply(null,arguments)}function er(e){return(er=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function en(e,t){return(en=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eo(e){var t="function"==typeof Map?new Map:void 0;return(eo=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 et(e,arguments,er(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),en(r,e)})(e)}function ei(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ei=function(){return!!e})()}var ea=function(e){return i().createElement(n.SchemaComponentOptions,{scope:{CustomRequestConfigurationFieldsSchema:E},components:{CustomRequestAction:N,CustomRequestInitializer:G}},e.children)},eu=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=er(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,ei()?Reflect.construct(e,t||[],er(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&en(r,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var c=[i,u];if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return t.app.use(ea),t.app.schemaSettingsManager.add(Z),t.app.schemaSettingsManager.add(_),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){ee(i,n,o,a,u,"next",e)}function u(e){ee(i,n,o,a,u,"throw",e)}a(void 0)})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(eo(n.Plugin)),ec=eu}(),m}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@formily/antd-v5"),require("react"),require("@nocobase/flow-engine"),require("@emotion/css"),require("lodash"),require("file-saver"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/utils/client"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-action-custom-request",["react-i18next","@formily/antd-v5","react","@nocobase/flow-engine","@emotion/css","lodash","file-saver","@formily/shared","@nocobase/client","@formily/react","@nocobase/utils/client","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-action-custom-request"]=t(require("react-i18next"),require("@formily/antd-v5"),require("react"),require("@nocobase/flow-engine"),require("@emotion/css"),require("lodash"),require("file-saver"),require("@formily/shared"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/utils/client"),require("antd")):e["@nocobase/plugin-action-custom-request"]=t(e["react-i18next"],e["@formily/antd-v5"],e.react,e["@nocobase/flow-engine"],e["@emotion/css"],e.lodash,e["file-saver"],e["@formily/shared"],e["@nocobase/client"],e["@formily/react"],e["@nocobase/utils/client"],e.antd)}(self,function(e,t,r,n,o,a,i,u,l,c,s,p){return function(){"use strict";var f={964:function(e){e.exports=o},632:function(e){e.exports=t},505:function(e){e.exports=c},875:function(e){e.exports=u},772:function(e){e.exports=l},667:function(e){e.exports=n},584:function(e){e.exports=s},721:function(e){e.exports=p},346:function(e){e.exports=i},467:function(e){e.exports=a},156:function(e){e.exports=r},238:function(t){t.exports=e}},m={};function d(e){var t=m[e];if(void 0!==t)return t.exports;var r=m[e]={exports:{}};return f[e](r,r.exports,d),r.exports}d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var r in t)d.o(t,r)&&!d.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var y={};return!function(){d.r(y),d.d(y,{default:function(){return eF},PluginActionCustomRequestClient:function(){return eR}});var e,t,r,n,o,a,i=d(772),u=d(156),l=d.n(u),c=d(505),s=d(584),p=d(721),f=d(346);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function b(e,t,r,n,o,a,i){try{var u=e[a](i),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}function v(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){b(a,n,o,i,u,"next",e)}function u(e){b(a,n,o,i,u,"throw",e)}i(void 0)})}}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function g(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){var l=[a,u];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var x=function(){var e=(0,i.useAPIClient)(),t=(0,i.useNavigateNoUpdate)(),r=(0,c.useFieldSchema)(),n=(0,i.useBlockRequestContext)().field,o=(0,i.useCompile)(),a=(0,c.useForm)(),u=((0,i.useBlockContext)()||{}).name,l=(0,i.useCollectionRecordData)(),d=(0,c.useFieldSchema)(),y=(0,c.useField)(),b=(0,i.useActionContext)().setVisible,x=p.App.useApp(),O=x.modal,S=x.message,w=(0,i.useDataSourceKey)(),P=(0,i.useContextVariable)().ctx,j=(0,i.useLocalVariables)(),A=(0,i.useVariables)();return{onClick:function(c,p){return v(function(){var c,x,T,C,k,I,q,E,R,F,D,N,M,V,B,U,z,_,L,$,G,K,W,H;return g(this,function(_){switch(_.label){case 0:if(C=(null==n||null==(c=n.data)?void 0:c.selectedRowData)?null==n||null==(x=n.data)?void 0:x.selectedRowData:P,q=(I=null!=(k=null==r?void 0:r["x-action-settings"])?k:{}).skipValidator,R=(E=I.onSuccess||{}).manualClose,F=E.redirecting,D=E.redirectTo,N=E.successMessage,M=E.actionAfterSuccess,V=N,B=D,U=null==r?void 0:r["x-action"],!0===q||"customize:form:request"!==U)return[3,2];return[4,a.submit()];case 1:_.sent(),_.label=2;case 2:z=h({},l),"customize:form:request"===U&&(z=a.values),null!=(T=y).data||(T.data={}),y.data.loading=!0,_.label=3;case 3:return _.trys.push([3,,8,9]),$=d["x-custom-request-id"]||d["x-uid"],[4,e.request({url:"/customRequests:send/".concat($),method:"POST",data:{currentRecord:{dataSourceKey:w,data:z},$nForm:"form"===u?a.values:void 0,$nSelectedRecord:C},responseType:"stream"===d["x-response-type"]?"blob":"json"})];case 4:return G=_.sent(),[4,(0,i.getVariableValue)(V,{variables:A,localVariables:((function(e){if(Array.isArray(e))return m(e)})(j)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(j)||function(e,t){if(e){if("string"==typeof e)return m(e,void 0);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 m(e,t)}}(j)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([{name:"$nResponse",ctx:new Proxy(h({},null==G||null==(L=G.data)?void 0:L.data,null==G?void 0:G.data),{})}])})];case 5:if(V=_.sent(),!D)return[3,7];return[4,(0,i.getVariableValue)(D,{variables:A,localVariables:j})];case 6:B=_.sent(),_.label=7;case 7:if(G.headers["content-disposition"]&&(W=(K=G.headers["content-disposition"]).match(/filename\*=utf-8''([^;]+)/i),H=K.match(/filename="([^"]+)"/i),W?(0,f.saveAs)(G.data,decodeURIComponent(W[1])):H&&(0,f.saveAs)(G.data,H[1])),y.data.loading=!1,p&&(null==p||p()),"previous"!==M&&(M||!0===F)||null==b||b(!1),!V)return(F&&!M||"redirect"===M)&&B&&((0,s.isURL)(B)?window.location.href=B:t(B)),[2];return R?O.success({title:o(V),onOk:v(function(){return g(this,function(e){return(F&&!M||"redirect"===M)&&B&&((0,s.isURL)(B)?window.location.href=B:t(B)),[2]})})}):(S.success(o(V)),(F&&!M||"redirect"===M)&&B&&((0,s.isURL)(B)?window.location.href=B:t(B))),[3,9];case 8:return y.data.loading=!1,[7];case 9:return[2]}})})()}}},O=function(){var e=(0,c.useFieldSchema)(),t=e["x-custom-request-id"]||e["x-uid"],r="customRequests:get/".concat(t);return(0,i.useRequest)({url:r,params:{appends:["roles"]}},{manual:!0,cacheKey:r})},S=d(467),w=d(238),P="action-custom-request";function j(e){return"{{t('".concat(e,"', { ns: '").concat(P,"', nsMode: 'fallback' })}}")}function A(){return(0,w.useTranslation)(P,{nsMode:"fallback"})}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function C(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||k(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){if(e){if("string"==typeof e)return T(e,t);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 T(e,t)}}var I=function(){var e,t=(0,i.useCurrentPopupContext)().params,r=(0,i.useCollectionRecordData)(),n=(0,i.useTableBlockContext)();if(r)return!1;var o=null==(e=(0,i.getStoredPopupContext)(null==t?void 0:t.popupuid))?void 0:e.tableBlockContext;return!(0,S.isEmpty)(o)||!(0,S.isEmpty)(n)},q=function(){var e,t=(0,i.useCollection_deprecated)(),r=A().t,n=(0,i.useCollectionFilterOptions)(t),o=(0,i.useCollectionFilterOptions)("users",i.DEFAULT_DATA_SOURCE_KEY),a=(0,i.useCompile)(),l=(0,i.useCollectionRecordData)(),c=((0,i.useBlockContext)()||{}).name,s=(0,i.useFormBlockContext)().form,p=(e=(0,u.useMemo)(function(){return[a(n),a(o)]},[n,o]),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,u=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),a.length!==t);i=!0);}catch(e){u=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw n}}return a}}(e,2)||k(e,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.")}()),f=p[0],m=p[1],d=(0,i.useGlobalVariable)("$env"),y=(0,i.useContextAssociationFields)({maxDepth:2,contextCollectionName:t.name}),b=I();return(0,u.useMemo)(function(){var e,t;return[d,l&&{name:"currentRecord",title:r("Current record",{ns:"client"}),children:C(f)},("form"===c||s)&&{name:"$nForm",title:r("Current form",{ns:"client"}),children:C(f)},{name:"currentUser",title:r("Current user",{ns:"client"}),children:m},{name:"currentTime",title:r("Current time",{ns:"client"}),children:null},{name:"$nToken",title:"API token",children:null},b&&(e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},y),t=t={name:"$nSelectedRecord",title:y.label},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e)].filter(Boolean)},[l,r,f,c,m,b])},E=d(632),R=function(){return(0,i.useAPIClient)().resource("customRequests")},F={value:"name",label:"title"},D=function(){return{scope:q(),fieldNames:F,useTypedConstant:!0}},N={type:"object",properties:{method:{type:"string",required:!0,title:j("HTTP method"),"x-decorator-props":{tooltip:j("When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data")},"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:j("URL"),"x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":D,"x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:j("Headers"),description:j('"Content-Type" only support "application/json", and no need to specify'),items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:j("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":D},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:j("Add request header"),"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:j("Parameters"),items:{type:"object",properties:{space:{type:"void","x-component":"Space",properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:j("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":D},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:j("Add parameter"),"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:j("Body"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Variable.JSON","x-component-props":{scope:"{{useCustomRequestVariableOptions}}",fieldNames:{value:"name",label:"title"},changeOnSelect:!0,autoSize:{minRows:10},placeholder:j("Input request data")},description:j("Only support standard JSON data")},timeout:{type:"number",title:j("Timeout config"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"InputNumber","x-component-props":{addonAfter:j("ms"),min:1,step:1e3,defaultValue:5e3}},responseType:{type:"string",title:j("Response type"),"x-decorator":"FormItem","x-decorator-props":{},"x-component":"Select",default:"json",enum:[{value:"json",label:"JSON"},{value:"stream",label:"Stream"}]}}};function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function V(e,t,r,n,o,a,i){try{var u=e[a](i),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}function B(){return(B=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function z(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function _(){var e,t,r,n=A().t,o=(0,i.useCollection_deprecated)().name,a=(0,i.useDataSourceKey)(),s=(0,c.useFieldSchema)(),p=R(),f=O(),m=f.data,d=f.refresh,y=(0,i.useDesignable)().dn,b=(0,u.useMemo)(function(){var e,t=U({},null==m||null==(e=m.data)?void 0:e.options);return t.data&&"string"!=typeof t.data&&(t.data=JSON.stringify(t.data,null,2)),t},[null==m||null==(r=m.data)?void 0:r.options]);return l().createElement(l().Fragment,null,l().createElement(i.SchemaSettingsActionModalItem,{title:n("Request settings"),components:{ArrayItems:E.ArrayItems},beforeOpen:function(){return!m&&d()},scope:{useCustomRequestVariableOptions:q},schema:N,initialValues:b,onSubmit:(e=function(e){var t,r,n;return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){var l=[a,u];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return t=B({},function(e){if(null==e)throw TypeError("Cannot destructure "+e);return e}(e)),s["x-response-type"]=t.responseType,r=!s["x-custom-request-id"]||s["x-custom-request-id"]===s["x-uid"],[4,p.updateOrCreate({values:{key:s["x-uid"],options:z(U({},t),{collectionName:o,dataSourceKey:a})},filterKeys:["key"]})];case 1:return i.sent(),n={"x-response-type":t.responseType,"x-uid":s["x-uid"]},!r&&s["x-custom-request-id"]&&(n["x-custom-request-id"]=s["x-uid"],s["x-custom-request-id"]=s["x-uid"]),[4,y.emit("patch",{schema:n})];case 2:return i.sent(),y.refresh(),d(),[2]}})},t=function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){V(a,n,o,i,u,"next",e)}function u(e){V(a,n,o,i,u,"throw",e)}i(void 0)})},function(e){return t.apply(this,arguments)})}))}var L=new i.SchemaSettings({name:"CustomRequestActionSettings",items:[z(U({},i.actionSettingsItems["0"]),{children:((function(e){if(Array.isArray(e))return M(e)})(e=i.actionSettingsItems["0"].children)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return M(e,void 0);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 M(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([{name:"request settings",Component:_},i.SchemaSettingAccessControl])})]}),$={"customize:table:request":i.Action.Link},G=(0,i.withDynamicSchemaProps)(function(e){var t,r,n=$[(0,c.useFieldSchema)()["x-action"]]||i.Action;return l().createElement(n,(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),r=r={useProps:x},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))});G.Designer=function(){var e=R(),t=(0,c.useFieldSchema)();return l().createElement(i.Action.Designer,{linkageAction:!0,schemaSettings:"CustomRequestActionSettings",buttonEditorProps:{isLink:"customize:table:request"===t["x-action"]},linkageRulesProps:{type:"button"},removeButtonProps:{onConfirmOk:function(){return e.destroy({filterByTk:t["x-uid"]})}}})},G.Decorator=function(e){return(0,i.useAPIClient)(),l().createElement(i.ACLActionProvider,null,e.children)};var K=d(875);function W(e,t,r,n,o,a,i){try{var u=e[a](i),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}var H=function(e){var t,r,n,o=R(),a=(0,i.useSchemaInitializerItem)(),u=(0,i.useSchemaInitializer)().insert,c={title:'{{ t("Custom request") }}',"x-component":"CustomRequestAction","x-action":"customize:form:request","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:customRequest","x-decorator":"CustomRequestAction.Decorator","x-uid":(0,K.uid)(),"x-action-settings":{onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Request success")}}'}}};return l().createElement(i.SchemaInitializerItem,(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},a),n=n={onClick:(t=function(){var e,t;return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){var l=[a,u];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return t=(0,K.merge)(c||{},a.schema||{}),null==a||null==(e=a.schemaInitialize)||e.call(a,t),[4,o.create({values:{key:t["x-uid"]}})];case 1:return r.sent(),u(t),[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(e){W(a,n,o,i,u,"next",e)}function u(e){W(a,n,o,i,u,"throw",e)}i(void 0)})})},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}),r))},J=d(667),Y=d(964);function Q(){var e,t,r=(e=["\n &:not(:hover) {\n border-right-color: transparent;\n border-top-color: transparent;\n background-color: transparent;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return Q=function(){return r},r}var X=i.Input.JSON;function Z(){return"request-".concat((0,s.uid)())}function ee(e){return Array.isArray(e)?e.map(function(e){return{name:String((null==e?void 0:e.name)||"").trim(),value:void 0===(null==e?void 0:e.value)||(null==e?void 0:e.value)===null?"":e.value}}).filter(function(e){return!!e.name}):[]}function et(e,t,r,n,o,a,i){try{var u=e[a](i),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}function er(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function en(){var e=er(["\n & > .ant-space-item:first-child {\n flex: 3;\n }\n & > .ant-space-item:nth-child(2) {\n flex-shrink: 0;\n flex: 5;\n }\n & > .ant-space-item:last-child {\n flex-shrink: 0;\n flex: 1;\n }\n "]);return en=function(){return e},e}function eo(){var e=er(["\n & > .ant-space-item:first-child {\n flex: 3;\n }\n & > .ant-space-item:nth-child(2) {\n flex-shrink: 0;\n flex: 5;\n }\n & > .ant-space-item:last-child {\n flex-shrink: 0;\n flex: 1;\n }\n "]);return eo=function(){return e},e}var ea=new Map,ei={key:{type:"string",title:j("Key"),"x-decorator":"FormItem","x-decorator-props":{style:{display:"none"}},"x-component":function(e){var t=e.value,r=e.onChange,n=(0,J.useFlowContext)(),o=(0,c.useForm)(),a=l().useRef(null);return l().useEffect(function(){t||null==r||r(Z())},[t,r]),l().useEffect(function(){if(t&&a.current!==t){var e,r=!0;return(e=function(){var e,i,u,l,c,s,p,f,m,d,y;return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){var l=[a,u];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(b){switch(b.label){case 0:return b.trys.push([0,2,,3]),(s=ea.get(t))||(s=n.request({url:"/customRequests:get/".concat(t),method:"GET",params:{appends:["roles"]}}).finally(function(){ea.delete(t)}),ea.set(t,s)),[4,s];case 1:if(m=(null==(f=null==(p=b.sent())||null==(e=p.data)?void 0:e.data)?void 0:f.options)||{},d=Array.isArray(null==f?void 0:f.roles)?f.roles.map(function(e){return null==e?void 0:e.name}).filter(Boolean):[],!r)return[2];return y=void 0===(null==m?void 0:m.data)||(null==m?void 0:m.data)===null?void 0:"string"==typeof(null==m?void 0:m.data)?m.data:JSON.stringify(m.data,null,2),o.setValues({method:(null==m?void 0:m.method)||(null==(i=o.values)?void 0:i.method)||"POST",url:(null==m?void 0:m.url)||(null==(u=o.values)?void 0:u.url),headers:Array.isArray(null==m?void 0:m.headers)?m.headers:[],params:Array.isArray(null==m?void 0:m.params)?m.params:[],data:y,timeout:(null==m?void 0:m.timeout)||(null==(l=o.values)?void 0:l.timeout)||5e3,responseType:(null==m?void 0:m.responseType)||(null==(c=o.values)?void 0:c.responseType)||"json",roles:d}),a.current=t,[3,3];case 2:return b.sent(),[3,3];case 3:return[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){et(a,n,o,i,u,"next",e)}function u(e){et(a,n,o,i,u,"throw",e)}i(void 0)})})(),function(){r=!1}}},[t,n,o]),l().createElement(p.Input,{value:t,disabled:!0})}},method:{type:"string",title:j("HTTP method"),required:!0,"x-decorator-props":{tooltip:j("When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data")},"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1,className:"auto-width"},default:"POST",enum:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}]},url:{type:"string",title:j("URL"),required:!0,"x-decorator":"FormItem","x-component":i.TextAreaWithContextSelector,"x-component-props":{placeholder:"https://www.nocobase.com"}},headers:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:j("Headers"),items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%",display:"flex"},className:(0,Y.css)(en())},properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:j("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":i.TextAreaWithContextSelector,"x-component-props":{rows:1}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:j("Add request header"),"x-component":"ArrayItems.Addition"}}},params:{type:"array","x-component":"ArrayItems","x-decorator":"FormItem",title:j("Parameters"),items:{type:"object",properties:{space:{type:"void","x-component":"Space","x-component-props":{style:{flexWrap:"nowrap",maxWidth:"100%",display:"flex"},className:(0,Y.css)(eo())},properties:{name:{type:"string","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:j("Name")}},value:{type:"string","x-decorator":"FormItem","x-component":i.TextAreaWithContextSelector,"x-component-props":{rows:1}},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}}}},properties:{add:{type:"void",title:j("Add parameter"),"x-component":"ArrayItems.Addition"}}},data:{type:"string",title:j("Body"),"x-decorator":"FormItem","x-component":function(e){var t=e.value,r=e.onChange,n=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["value","onChange"]),o=(0,J.useFlowContext)(),a=(0,u.useRef)(null),i=(0,u.useCallback)(function(e){var t,r,n,o,i=null==(r=a.current)||null==(t=r.resizableTextArea)?void 0:t.textArea;if(i){var u,l,c=i.value||"",s=null!=(n=i.selectionStart)?n:c.length,p=null!=(o=i.selectionEnd)?o:s,f=c.slice(0,s)+e+c.slice(p);null==(l=null==(u=Object.getOwnPropertyDescriptor(i.constructor.prototype,"value"))?void 0:u.set)||l.call(i,f),i.dispatchEvent(new Event("input",{bubbles:!0})),requestAnimationFrame(function(){var t=s+e.length;i.setSelectionRange(t,t),i.focus()})}},[]),c=(0,u.useCallback)(function(e){e&&i(e)},[i]),s=(0,u.useMemo)(function(){return function(){var e;return null==(e=o.getPropertyMetaTree)?void 0:e.call(o)}},[o]);return l().createElement("div",{style:{position:"relative",width:"100%"}},l().createElement(X,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({ref:a,value:t,onChange:r},n)),l().createElement("div",{style:{position:"absolute",top:0,right:0,zIndex:1,lineHeight:0}},l().createElement(J.FlowContextSelector,{metaTree:s,onChange:function(e){return c(e)}},l().createElement(p.Button,{type:"default",style:{fontStyle:"italic",fontFamily:"New York, Times New Roman, Times, serif"},className:(0,Y.css)(Q())},"x"))))},"x-component-props":{autoSize:{minRows:10},placeholder:j("Input request data")},description:j("Only support standard JSON data")},timeout:{type:"number",title:j("Timeout config"),"x-decorator":"FormItem","x-component":p.InputNumber,"x-component-props":{min:1,step:1e3,addonAfter:j("ms"),style:{width:"100%"}},default:5e3},responseType:{type:"string",title:j("Response type"),"x-decorator":"FormItem","x-component":"Select",default:"json",enum:[{value:"json",label:"JSON"},{value:"stream",label:j("Stream")}]},roles:{type:"array",title:j("Access control"),"x-decorator":"FormItem","x-decorator-props":{tooltip:j("If not set, all roles can access this request")},"x-component":function(e){var t=e.value,r=e.onChange;return l().createElement(i.RemoteSelect,{mode:"multiple",manual:!1,value:void 0===t?[]:t,service:{resource:"roles"},fieldNames:{label:"title",value:"name"},allowClear:!0,onChange:function(e){return null==r?void 0:r(Array.isArray(e)?e.map(function(e){return"string"==typeof e?e:e&&(void 0===e?"undefined":e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"?(null==e?void 0:e.name)||(null==e?void 0:e.value)||(null==e?void 0:e.roleName):void 0}).filter(Boolean):[])}})}}};function eu(e,t,r,n,o,a,i){try{var u=e[a](i),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}function el(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){eu(a,n,o,i,u,"next",e)}function u(e){eu(a,n,o,i,u,"throw",e)}i(void 0)})}}function ec(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function es(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){var l=[a,u];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var ep=/\{\{\s*([^{}]+?)\s*\}\}/g,ef=function(e){if(null!=e&&("string"!=typeof e||""!==e.trim())){if("string"!=typeof e)return e;var t=e.trim();if(!t)return e;try{return JSON.parse(t)}catch(t){return e}}},em=function(e){var t=e.match(/filename\*=utf-8''([^;]+)/i);if(t)return decodeURIComponent(t[1]);var r=e.match(/filename="([^"]+)"/i);if(r)return r[1]},ed=function(e,t){if("string"==typeof e){var r=e.matchAll(ep),n=!0,o=!1,a=void 0;try{for(var i,u=r[Symbol.iterator]();!(n=(i=u.next()).done);n=!0){var l,c=i.value,s=null==c||null==(l=c[1])?void 0:l.trim();s&&s.startsWith("ctx.")&&t.add(s)}}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return}if(Array.isArray(e))return void e.forEach(function(e){return ed(e,t)});e&&(void 0===e?"undefined":ec(e))==="object"&&Object.values(e).forEach(function(e){return ed(e,t)})},ey=function(e){var t=[null==e?void 0:e.url,null==e?void 0:e.headers,null==e?void 0:e.params,null==e?void 0:e.data],r=new Set;return t.forEach(function(e){return ed(e,r)}),Array.from(r)},eb=(t=el(function(e,t){var r,n;return es(this,function(o){switch(o.label){case 0:if(!Array.isArray(t)||!t.length||"function"!=typeof(null==e?void 0:e.resolveJsonTemplate))return[2,void 0];o.label=1;case 1:return o.trys.push([1,3,,4]),r=t.reduce(function(e,t){return e[t]="{{".concat(t,"}}"),e},{}),[4,e.resolveJsonTemplate(r)];case 2:if(!(n=o.sent())||(void 0===n?"undefined":ec(n))!=="object")return[2,void 0];return[2,t.reduce(function(e,t){var r=n[t];return void 0===r||"string"==typeof r&&r.trim()==="{{".concat(t,"}}")||(e[t]=r),e},{})];case 3:return o.sent(),[2,void 0];case 4:return[2]}})}),function(e,r){return t.apply(this,arguments)}),ev=(0,J.defineAction)({name:"customRequest",title:(0,J.tExpr)("Custom request"),scene:[J.ActionScene.DYNAMIC_EVENT_FLOW],paramsRequired:!0,sort:700,uiSchema:ei,defaultParams:el(function(){return es(this,function(e){return[2,{key:Z(),method:"POST",timeout:5e3,responseType:"json",headers:[],params:[]}]})}),beforeParamsSave:(r=el(function(e,t){var r,n,o,a,i,u,l,c,s,p,f,m;return es(this,function(d){switch(d.label){case 0:var y;return c=(null==t?void 0:t.key)||Z(),s=(null==(r=e.collection)?void 0:r.name)||(null==(n=e.collectionField)?void 0:n.collectionName)||(null==(o=e.resource)?void 0:o.name)||e.resourceName,p=(null==(a=e.collection)?void 0:a.dataSourceKey)||(null==(i=e.dataSource)?void 0:i.key)||(null==(l=e.resource)||null==(u=l.getDataSourceKey)?void 0:u.call(l)),f=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({method:(null==t?void 0:t.method)||"POST",url:null==t?void 0:t.url,headers:ee(null==t?void 0:t.headers),params:ee(null==t?void 0:t.params),data:ef(null==t?void 0:t.data),timeout:null==t?void 0:t.timeout,responseType:(null==t?void 0:t.responseType)||"json"},s?{collectionName:s}:{},p?{dataSourceKey:p}:{}),m=ey(t),[4,e.api.resource("customRequests").updateOrCreate({filterKeys:["key"],values:{key:c,options:f,roles:Array.isArray(y=null==t?void 0:t.roles)?y.map(function(e){return"string"==typeof e?e:e&&(void 0===e?"undefined":ec(e))==="object"?e.name||e.value||e.roleName:void 0}).map(function(e){return"string"==typeof e?e.trim():""}).filter(Boolean):[]}})];case 1:return d.sent(),Object.keys(t||{}).forEach(function(e){["key","variablePaths","responseType"].includes(e)||delete t[e]}),t.key=c,t.variablePaths=m,t.responseType=(null==t?void 0:t.responseType)||"json",[2]}})}),function(e,t){return r.apply(this,arguments)}),handler:(n=el(function(e,t){var r,n,o,a,i,u,l,c,s;return es(this,function(p){switch(p.label){case 0:if(!(r=null==t?void 0:t.key))return[2,{ok:!1,status:400,error:{message:"custom request key is required"}}];return n=(null==t?void 0:t.responseType)||"json",[4,eb(e,null==t?void 0:t.variablePaths)];case 1:o=p.sent(),p.label=2;case 2:return p.trys.push([2,4,,5]),[4,e.request({url:"/customRequests:send/".concat(r),method:"POST",responseType:"stream"===n?"blob":"json",data:{vars:o}})];case 3:if(a=p.sent(),"stream"===n)return(l=(null==a||null==(i=a.headers)?void 0:i["content-disposition"])||(null==a||null==(u=a.headers)?void 0:u["Content-Disposition"]))&&(c=em(l))&&(0,f.saveAs)(a.data,c),[2];return[2,a];case 4:if(s=p.sent(),"stream"===n)throw s;return[2,s];case 5:return[2]}})}),function(e,t){return n.apply(this,arguments)})});function eh(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function eg(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ex(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){eg(e,t,r[t])})}return e}function eO(e){return function(e){if(Array.isArray(e))return eh(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return eh(e,void 0);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 eh(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eS=function(){var e=(0,i.useAfterSuccessOptions)();return[{value:"$nResponse",label:(0,(0,w.useTranslation)().t)("Response",{ns:"client"}),children:null}].concat(eO(e.filter(function(e){return["currentUser","currentTime","$nRole"].includes(e.value)}))).filter(Boolean)},ew=function(){var e=(0,i.useAfterSuccessOptions)(),t=(0,i.useGlobalVariable)("$env");return eO(e.filter(function(e){return"$record"!==e.value})).concat([t]).filter(Boolean)},eP=function(){return{scope:ew(),useTypedConstant:!0}},ej=new i.SchemaSettings({name:"actionSettings:customRequest",items:[{name:"editButton",Component:i.ButtonEditor,useComponentProps:function(){return{isLink:"customize:table:request"===(0,c.useFieldSchema)()["x-action"]}}},{name:"linkageRules",Component:i.SchemaSettingsLinkageRules,useComponentProps:function(){return ex({},(0,i.useSchemaToolbar)().linkageRulesProps)}},{name:"secondConFirm",Component:i.SecondConFirm},{name:"afterSuccessfulSubmission",Component:function(){var e,t=(0,i.useDesignable)().dn,r=(0,w.useTranslation)().t,n=(0,c.useFieldSchema)(),o=((null==n?void 0:n["x-action-settings"])||{}).onSuccess,a=(0,i.usePlugin)("@nocobase/plugin-block-template"),u=null==a||null==(e=a.isInBlockTemplateConfigPage)?void 0:e.call(a);return l().createElement(i.SchemaSettingsModalItem,{dialogRootClassName:"dialog-after-successful-submission",width:700,title:r("After successful submission"),initialValues:o?ex({actionAfterSuccess:(null==o?void 0:o.redirecting)?"redirect":"previous"},o):{manualClose:!1,redirecting:!1,successMessage:'{{t("Saved successfully")}}',actionAfterSuccess:"previous"},schema:{type:"object",title:r("After successful submission"),properties:{successMessage:{title:r("Popup message"),"x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:eS,style:{minWidth:"220px"}}},manualClose:{title:r("Message popup close method"),enum:[{label:r("Automatic close"),value:!1},{label:r("Manually close"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{}},redirecting:{title:r("Then"),"x-hidden":!0,enum:[{label:r("Stay on current page"),value:!1},{label:r("Redirect to"),value:!0}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{!!$self.value}}"}}}},actionAfterSuccess:{title:r("Action after successful submission"),enum:[{label:r("Stay on the current popup or page"),value:"stay"},{label:r("Return to the previous popup or page"),value:"previous"},{label:r("Redirect to"),value:"redirect"}],"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{},"x-reactions":{target:"redirectTo",fulfill:{state:{visible:"{{$self.value==='redirect'}}"}}}},redirectTo:{title:r("Link"),"x-decorator":"FormItem","x-component":"Variable.TextArea","x-use-component-props":eP},blocksToRefresh:{type:"array",title:r("Refresh data blocks"),"x-decorator":"FormItem","x-use-decorator-props":function(){return{tooltip:r("After successful submission, the selected data blocks will be automatically refreshed.")}},"x-component":i.BlocksSelector,"x-hidden":u}}},onSubmit:function(e){var r;n["x-action-settings"].onSuccess=e,t.emit("patch",{schema:(eg(r={},"x-uid",n["x-uid"]),eg(r,"x-action-settings",n["x-action-settings"]),r)})}})}},{name:"request settings",Component:_},(o=ex({},i.SchemaSettingAccessControl),a=a={useVisible:function(){return!0}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(a)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(a)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(a,e))}),o),{name:"refreshDataBlockRequest",Component:i.RefreshDataBlockRequest,useComponentProps:function(){return{isPopupAction:!1}},useVisible:function(){return!!(0,i.useCollection)()}},{name:"delete",sort:100,Component:i.RemoveButton,useComponentProps:function(){return(0,i.useSchemaToolbar)().removeButtonProps}}]});function eA(e,t,r,n,o,a,i){try{var u=e[a](i),l=u.value}catch(e){r(e);return}u.done?t(l):Promise.resolve(l).then(n,o)}function eT(e,t,r){return(eT=eq()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&ek(o,r.prototype),o}).apply(null,arguments)}function eC(e){return(eC=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ek(e,t){return(ek=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eI(e){var t="function"==typeof Map?new Map:void 0;return(eI=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 eT(e,arguments,eC(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ek(r,e)})(e)}function eq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eq=function(){return!!e})()}var eE=function(e){return l().createElement(i.SchemaComponentOptions,{scope:{CustomRequestConfigurationFieldsSchema:N},components:{CustomRequestAction:G,CustomRequestInitializer:H}},e.children)},eR=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=eC(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,eq()?Reflect.construct(e,t||[],eC(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&ek(r,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){var l=[a,u];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return t.app.use(eE),t.app.flowEngine.registerActions({customRequestFlowAction:ev}),t.app.schemaSettingsManager.add(ej),t.app.schemaSettingsManager.add(L),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){eA(a,n,o,i,u,"next",e)}function u(e){eA(a,n,o,i,u,"throw",e)}i(void 0)})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(eI(i.Plugin)),eF=eR}(),y}()});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { TextAreaProps } from 'antd/es/input';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
export type FlowJsonWithContextSelectorProps = TextAreaProps & {
|
|
12
|
+
value?: any;
|
|
13
|
+
onChange?: (value: any) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const FlowJsonWithContextSelector: React.FC<FlowJsonWithContextSelectorProps>;
|
|
16
|
+
export default FlowJsonWithContextSelector;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const customRequestFlowAction: import("@nocobase/flow-engine").ActionDefinition<import("@nocobase/flow-engine").FlowModel<import("@nocobase/flow-engine").DefaultStructure>, import("@nocobase/flow-engine").FlowContext>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export type RequestNameValue = {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export type CustomRequestStepParams = {
|
|
14
|
+
key?: string;
|
|
15
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
16
|
+
url?: string;
|
|
17
|
+
headers?: RequestNameValue[];
|
|
18
|
+
params?: RequestNameValue[];
|
|
19
|
+
data?: unknown;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
responseType?: 'json' | 'stream';
|
|
22
|
+
variablePaths?: string[];
|
|
23
|
+
roles?: string[];
|
|
24
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare const customRequestFlowActionUiSchema: {
|
|
11
|
+
key: {
|
|
12
|
+
type: string;
|
|
13
|
+
title: string;
|
|
14
|
+
'x-decorator': string;
|
|
15
|
+
'x-decorator-props': {
|
|
16
|
+
style: {
|
|
17
|
+
display: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
'x-component': (props: {
|
|
21
|
+
value?: string;
|
|
22
|
+
onChange?: (value: string) => void;
|
|
23
|
+
}) => React.JSX.Element;
|
|
24
|
+
};
|
|
25
|
+
method: {
|
|
26
|
+
type: string;
|
|
27
|
+
title: string;
|
|
28
|
+
required: boolean;
|
|
29
|
+
'x-decorator-props': {
|
|
30
|
+
tooltip: string;
|
|
31
|
+
};
|
|
32
|
+
'x-decorator': string;
|
|
33
|
+
'x-component': string;
|
|
34
|
+
'x-component-props': {
|
|
35
|
+
showSearch: boolean;
|
|
36
|
+
allowClear: boolean;
|
|
37
|
+
className: string;
|
|
38
|
+
};
|
|
39
|
+
default: string;
|
|
40
|
+
enum: {
|
|
41
|
+
label: string;
|
|
42
|
+
value: string;
|
|
43
|
+
}[];
|
|
44
|
+
};
|
|
45
|
+
url: {
|
|
46
|
+
type: string;
|
|
47
|
+
title: string;
|
|
48
|
+
required: boolean;
|
|
49
|
+
'x-decorator': string;
|
|
50
|
+
'x-component': React.FC<import("@nocobase/client").TextAreaWithContextSelectorProps>;
|
|
51
|
+
'x-component-props': {
|
|
52
|
+
placeholder: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
headers: {
|
|
56
|
+
type: string;
|
|
57
|
+
'x-component': string;
|
|
58
|
+
'x-decorator': string;
|
|
59
|
+
title: string;
|
|
60
|
+
items: {
|
|
61
|
+
type: string;
|
|
62
|
+
properties: {
|
|
63
|
+
space: {
|
|
64
|
+
type: string;
|
|
65
|
+
'x-component': string;
|
|
66
|
+
'x-component-props': {
|
|
67
|
+
style: {
|
|
68
|
+
flexWrap: string;
|
|
69
|
+
maxWidth: string;
|
|
70
|
+
display: string;
|
|
71
|
+
};
|
|
72
|
+
className: string;
|
|
73
|
+
};
|
|
74
|
+
properties: {
|
|
75
|
+
name: {
|
|
76
|
+
type: string;
|
|
77
|
+
'x-decorator': string;
|
|
78
|
+
'x-component': string;
|
|
79
|
+
'x-component-props': {
|
|
80
|
+
placeholder: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
value: {
|
|
84
|
+
type: string;
|
|
85
|
+
'x-decorator': string;
|
|
86
|
+
'x-component': React.FC<import("@nocobase/client").TextAreaWithContextSelectorProps>;
|
|
87
|
+
'x-component-props': {
|
|
88
|
+
rows: number;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
remove: {
|
|
92
|
+
type: string;
|
|
93
|
+
'x-decorator': string;
|
|
94
|
+
'x-component': string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
properties: {
|
|
101
|
+
add: {
|
|
102
|
+
type: string;
|
|
103
|
+
title: string;
|
|
104
|
+
'x-component': string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
params: {
|
|
109
|
+
type: string;
|
|
110
|
+
'x-component': string;
|
|
111
|
+
'x-decorator': string;
|
|
112
|
+
title: string;
|
|
113
|
+
items: {
|
|
114
|
+
type: string;
|
|
115
|
+
properties: {
|
|
116
|
+
space: {
|
|
117
|
+
type: string;
|
|
118
|
+
'x-component': string;
|
|
119
|
+
'x-component-props': {
|
|
120
|
+
style: {
|
|
121
|
+
flexWrap: string;
|
|
122
|
+
maxWidth: string;
|
|
123
|
+
display: string;
|
|
124
|
+
};
|
|
125
|
+
className: string;
|
|
126
|
+
};
|
|
127
|
+
properties: {
|
|
128
|
+
name: {
|
|
129
|
+
type: string;
|
|
130
|
+
'x-decorator': string;
|
|
131
|
+
'x-component': string;
|
|
132
|
+
'x-component-props': {
|
|
133
|
+
placeholder: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
value: {
|
|
137
|
+
type: string;
|
|
138
|
+
'x-decorator': string;
|
|
139
|
+
'x-component': React.FC<import("@nocobase/client").TextAreaWithContextSelectorProps>;
|
|
140
|
+
'x-component-props': {
|
|
141
|
+
rows: number;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
remove: {
|
|
145
|
+
type: string;
|
|
146
|
+
'x-decorator': string;
|
|
147
|
+
'x-component': string;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
properties: {
|
|
154
|
+
add: {
|
|
155
|
+
type: string;
|
|
156
|
+
title: string;
|
|
157
|
+
'x-component': string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
data: {
|
|
162
|
+
type: string;
|
|
163
|
+
title: string;
|
|
164
|
+
'x-decorator': string;
|
|
165
|
+
'x-component': React.FC<import("./FlowJsonWithContextSelector").FlowJsonWithContextSelectorProps>;
|
|
166
|
+
'x-component-props': {
|
|
167
|
+
autoSize: {
|
|
168
|
+
minRows: number;
|
|
169
|
+
};
|
|
170
|
+
placeholder: string;
|
|
171
|
+
};
|
|
172
|
+
description: string;
|
|
173
|
+
};
|
|
174
|
+
timeout: {
|
|
175
|
+
type: string;
|
|
176
|
+
title: string;
|
|
177
|
+
'x-decorator': string;
|
|
178
|
+
'x-component': (<T extends import("rc-input-number").ValueType = import("rc-input-number").ValueType>(props: import("antd").InputNumberProps<T> & {
|
|
179
|
+
children?: React.ReactNode;
|
|
180
|
+
} & React.RefAttributes<HTMLInputElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & {
|
|
181
|
+
displayName?: string;
|
|
182
|
+
_InternalPanelDoNotUseOrYouWillBeFired: React.FC<import("antd").InputNumberProps<import("rc-input-number").ValueType>>;
|
|
183
|
+
};
|
|
184
|
+
'x-component-props': {
|
|
185
|
+
min: number;
|
|
186
|
+
step: number;
|
|
187
|
+
addonAfter: string;
|
|
188
|
+
style: {
|
|
189
|
+
width: string;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
default: number;
|
|
193
|
+
};
|
|
194
|
+
responseType: {
|
|
195
|
+
type: string;
|
|
196
|
+
title: string;
|
|
197
|
+
'x-decorator': string;
|
|
198
|
+
'x-component': string;
|
|
199
|
+
default: string;
|
|
200
|
+
enum: {
|
|
201
|
+
value: string;
|
|
202
|
+
label: string;
|
|
203
|
+
}[];
|
|
204
|
+
};
|
|
205
|
+
roles: {
|
|
206
|
+
type: string;
|
|
207
|
+
title: string;
|
|
208
|
+
'x-decorator': string;
|
|
209
|
+
'x-decorator-props': {
|
|
210
|
+
tooltip: string;
|
|
211
|
+
};
|
|
212
|
+
'x-component': (props: {
|
|
213
|
+
value?: string[];
|
|
214
|
+
onChange?: (value: string[]) => void;
|
|
215
|
+
}) => React.JSX.Element;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
type RequestNameValue = {
|
|
10
|
+
name: string;
|
|
11
|
+
value: unknown;
|
|
12
|
+
};
|
|
13
|
+
export declare function makeRequestKey(): string;
|
|
14
|
+
export declare function parseJsonString(input: unknown): any;
|
|
15
|
+
export declare function normalizeNameValueArray(arr: any): RequestNameValue[];
|
|
16
|
+
export {};
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,21 +8,23 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.1.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.1.0-alpha.9",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"react-i18next": "11.18.6",
|
|
14
14
|
"@formily/react": "2.3.7",
|
|
15
|
-
"@nocobase/logger": "2.1.0-alpha.
|
|
16
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
17
|
-
"@nocobase/test": "2.1.0-alpha.
|
|
15
|
+
"@nocobase/logger": "2.1.0-alpha.9",
|
|
16
|
+
"@nocobase/server": "2.1.0-alpha.9",
|
|
17
|
+
"@nocobase/test": "2.1.0-alpha.9",
|
|
18
18
|
"@formily/antd-v5": "1.2.3",
|
|
19
19
|
"lodash": "4.17.21",
|
|
20
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
20
|
+
"@nocobase/utils": "2.1.0-alpha.9",
|
|
21
21
|
"antd": "5.24.2",
|
|
22
22
|
"file-saver": "2.0.5",
|
|
23
23
|
"@formily/shared": "2.3.7",
|
|
24
|
-
"@
|
|
25
|
-
"@nocobase/
|
|
24
|
+
"@emotion/css": "11.13.0",
|
|
25
|
+
"@nocobase/flow-engine": "2.1.0-alpha.9",
|
|
26
|
+
"@nocobase/actions": "2.1.0-alpha.9",
|
|
27
|
+
"@nocobase/evaluators": "2.1.0-alpha.9",
|
|
26
28
|
"axios": "1.7.7",
|
|
27
|
-
"@nocobase/database": "2.1.0-alpha.
|
|
29
|
+
"@nocobase/database": "2.1.0-alpha.9"
|
|
28
30
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -5,22 +5,30 @@
|
|
|
5
5
|
"Add request header": "Add request header",
|
|
6
6
|
"Body": "Body",
|
|
7
7
|
"Custom Request": "Custom Request",
|
|
8
|
+
"Custom request": "Custom request",
|
|
8
9
|
"Enter description info": "Enter description info",
|
|
9
10
|
"Format": "Format",
|
|
10
11
|
"HTTP method": "HTTP method",
|
|
11
12
|
"Headers": "Headers",
|
|
12
13
|
"If not set, all roles can see this action": "If not set, all roles can see this action",
|
|
14
|
+
"If not set, all roles can access this request": "If not set, all roles can access this request",
|
|
13
15
|
"Input request data": "Input request data",
|
|
14
16
|
"Insert": "Insert",
|
|
17
|
+
"Key": "Key",
|
|
18
|
+
"Name": "Name",
|
|
15
19
|
"Only support standard JSON data": "Only support standard JSON data",
|
|
16
20
|
"Parameters": "Parameters",
|
|
17
21
|
"Please configure the request settings first": "Please configure the request settings first",
|
|
18
22
|
"Request settings": "Request settings",
|
|
23
|
+
"Response type": "Response type",
|
|
19
24
|
"Roles": "Roles",
|
|
25
|
+
"Stream": "Stream",
|
|
20
26
|
"Timeout config": "Timeout config",
|
|
21
27
|
"Title": "Title",
|
|
22
28
|
"URL": "URL",
|
|
23
29
|
"Use variable": "Use variable",
|
|
30
|
+
"You do not have permission to access this custom request": "You do not have permission to access this custom request",
|
|
31
|
+
"Value": "Value",
|
|
24
32
|
"When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data": "When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data",
|
|
25
33
|
"ms": "ms"
|
|
26
|
-
}
|
|
34
|
+
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -5,22 +5,30 @@
|
|
|
5
5
|
"Add request header": "添加请求头",
|
|
6
6
|
"Body": "请求体",
|
|
7
7
|
"Custom Request": "自定义请求",
|
|
8
|
+
"Custom request": "自定义请求",
|
|
8
9
|
"Enter description info": "输入描述信息",
|
|
9
10
|
"Format": "格式化",
|
|
10
11
|
"HTTP method": "HTTP 方法",
|
|
11
12
|
"Headers": "请求头",
|
|
12
13
|
"If not set, all roles can see this action": "如果不设置,所有角色都可以看到这个自定义请求",
|
|
14
|
+
"If not set, all roles can access this request": "如果不设置,所有角色都可以访问此请求",
|
|
13
15
|
"Input request data": "输入请求数据",
|
|
14
16
|
"Insert": "插入",
|
|
17
|
+
"Key": "标识",
|
|
18
|
+
"Name": "名称",
|
|
15
19
|
"Only support standard JSON data": "仅支持标准 JSON 数据",
|
|
16
20
|
"Parameters": "参数",
|
|
17
21
|
"Please configure the request settings first": "请先配置请求设置",
|
|
18
22
|
"Request settings": "请求设置",
|
|
23
|
+
"Response type": "响应类型",
|
|
19
24
|
"Roles": "角色",
|
|
25
|
+
"Stream": "流",
|
|
20
26
|
"Timeout config": "超时设置",
|
|
21
27
|
"Title": "标题",
|
|
22
28
|
"URL": "URL",
|
|
23
29
|
"Use variable": "使用变量",
|
|
30
|
+
"You do not have permission to access this custom request": "你没有权限访问此自定义请求",
|
|
31
|
+
"Value": "值",
|
|
24
32
|
"When the HTTP method is Post, Put or Patch, and this custom request inside the form, the request body will be automatically filled in with the form data": "当请求方法为 Post、Put 或 Patch 时,且此自定义请求在表单内,请求体将自动填充表单数据",
|
|
25
33
|
"ms": "毫秒"
|
|
26
|
-
}
|
|
34
|
+
}
|
|
@@ -43,6 +43,22 @@ module.exports = __toCommonJS(send_exports);
|
|
|
43
43
|
var import_utils = require("@nocobase/utils");
|
|
44
44
|
var import_evaluators = require("@nocobase/evaluators");
|
|
45
45
|
var import_axios = __toESM(require("axios"));
|
|
46
|
+
var import_set = __toESM(require("lodash/set"));
|
|
47
|
+
const UnsafePathSegments = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
48
|
+
const hasUnsafePathSegment = (path) => {
|
|
49
|
+
return path.split(/[.[\]]+/).filter(Boolean).some((segment) => UnsafePathSegments.has(segment));
|
|
50
|
+
};
|
|
51
|
+
const applyVarsToVariables = (variables, vars) => {
|
|
52
|
+
if (!vars || typeof vars !== "object" || Array.isArray(vars)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
56
|
+
if (!key || typeof key !== "string" || hasUnsafePathSegment(key)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
(0, import_set.default)(variables, key, value);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
46
62
|
function toJSON(value) {
|
|
47
63
|
if (typeof value === "string") {
|
|
48
64
|
try {
|
|
@@ -75,7 +91,7 @@ const omitNullAndUndefined = (obj) => {
|
|
|
75
91
|
return acc;
|
|
76
92
|
}, {});
|
|
77
93
|
};
|
|
78
|
-
const CurrentUserVariableRegExp = /{{\s*(currentUser[^}]+)\s*}}/g;
|
|
94
|
+
const CurrentUserVariableRegExp = /{{\s*(?:ctx\.)?(currentUser[^}]+)\s*}}/g;
|
|
79
95
|
const getCurrentUserAppends = (str, user) => {
|
|
80
96
|
const matched = str.matchAll(CurrentUserVariableRegExp);
|
|
81
97
|
return Array.from(matched).map((item) => {
|
|
@@ -104,18 +120,30 @@ async function send(ctx, next) {
|
|
|
104
120
|
data: {}
|
|
105
121
|
},
|
|
106
122
|
$nForm,
|
|
107
|
-
$nSelectedRecord
|
|
123
|
+
$nSelectedRecord,
|
|
124
|
+
vars,
|
|
125
|
+
options: runtimeOptions
|
|
108
126
|
} = values;
|
|
109
127
|
if (ctx.state.currentRole !== "root") {
|
|
110
|
-
const
|
|
111
|
-
const
|
|
128
|
+
const schemaRoleRepo = ctx.db.getRepository("uiButtonSchemasRoles");
|
|
129
|
+
const customRequestRoleRepo = ctx.db.getRepository("customRequestsRoles");
|
|
130
|
+
const schemaRoles = await schemaRoleRepo.find({
|
|
112
131
|
filter: {
|
|
113
132
|
uid: filterByTk
|
|
114
133
|
}
|
|
115
134
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
const customRequestRoles = await customRequestRoleRepo.find({
|
|
136
|
+
filter: {
|
|
137
|
+
customRequestKey: filterByTk
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const roleRows = [...schemaRoles, ...customRequestRoles];
|
|
141
|
+
if (roleRows.length) {
|
|
142
|
+
if (!roleRows.some((item) => ctx.state.currentRoles.includes(item.roleName))) {
|
|
143
|
+
return ctx.throw(
|
|
144
|
+
403,
|
|
145
|
+
ctx.t("You do not have permission to access this custom request", { ns: "action-custom-request" })
|
|
146
|
+
);
|
|
119
147
|
}
|
|
120
148
|
}
|
|
121
149
|
}
|
|
@@ -129,15 +157,11 @@ async function send(ctx, next) {
|
|
|
129
157
|
ctx.throw(404, "request config not found");
|
|
130
158
|
}
|
|
131
159
|
ctx.withoutDataWrapping = true;
|
|
132
|
-
const {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
params = [],
|
|
138
|
-
data = {},
|
|
139
|
-
...options
|
|
140
|
-
} = requestConfig.options || {};
|
|
160
|
+
const mergedOptions = {
|
|
161
|
+
...requestConfig.options || {},
|
|
162
|
+
...omitNullAndUndefined(runtimeOptions || {})
|
|
163
|
+
};
|
|
164
|
+
const { dataSourceKey, collectionName, url, headers = [], params = [], data = {}, ...options } = mergedOptions;
|
|
141
165
|
if (!url) {
|
|
142
166
|
return ctx.throw(400, ctx.t("Please configure the request settings first", { ns: "action-custom-request" }));
|
|
143
167
|
}
|
|
@@ -174,6 +198,7 @@ async function send(ctx, next) {
|
|
|
174
198
|
$env: ctx.app.environment.getVariables(),
|
|
175
199
|
$nSelectedRecord
|
|
176
200
|
};
|
|
201
|
+
applyVarsToVariables(variables, vars);
|
|
177
202
|
const axiosRequestConfig = {
|
|
178
203
|
baseURL: ctx.origin,
|
|
179
204
|
...options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-action-custom-request",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.9",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/action-custom-request",
|
|
6
6
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/action-custom-request",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@nocobase/server": "2.x",
|
|
32
32
|
"@nocobase/test": "2.x"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "f9c6c53772bd5002fa419188d15ab227224f1962",
|
|
35
35
|
"keywords": [
|
|
36
36
|
"Actions"
|
|
37
37
|
]
|