@nocobase/plugin-workflow-request-interceptor 2.1.0-alpha.12 → 2.1.0-alpha.14
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
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("react"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-request-interceptor",["react","@formily/react","@nocobase/client","@nocobase/plugin-workflow/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-request-interceptor"]=t(require("react"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client")):e["@nocobase/plugin-workflow-request-interceptor"]=t(e.react,e["@formily/react"],e["@nocobase/client"],e["@nocobase/plugin-workflow/client"])}(self,function(e,t,r,o){return function(){"use strict";var n={230:function(e){e.exports=t},342:function(e){e.exports=r},990:function(e){e.exports=o},155:function(t){t.exports=e}},i={};function c(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return n[e](r,r.exports,c),r.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(a=c.g.location+"");var a,l=c.g.document;if(!a&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(a=l.currentScript.src),!a)){var u=l.getElementsByTagName("script");if(u.length)for(var s=u.length-1;s>-1&&(!a||!/^http(s?):/.test(a));)a=u[s--].src}if(!a)throw Error("Automatic publicPath is not supported in this browser");c.p=a.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={},f=window.__nocobase_public_path__||"";if(!f&&window.location&&window.location.pathname){var b=window.location.pathname||"/",d=b.indexOf("/v2/");f=d>=0?b.slice(0,d+1):"/"}return f&&(f=f.replace(/\/v2\/?$/,"/")),f||(f="/"),"/"!==f.charAt(f.length-1)&&(f+="/"),c.p=f+"static/plugins/@nocobase/plugin-workflow-request-interceptor/dist/client/",!function(){c.r(p),c.d(p,{PluginWorkflowRequestInterceptorClient:function(){return T},default:function(){return _}});var e=c(342),t=c(990),r="@nocobase/plugin-workflow-request-interceptor";function o(t){var o,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.i18n.t(t,(o=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){var o;o=r[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},i),n=n={ns:r},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(n)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(n,e))}),o))}var n=c(230),i="destroy",a=c(155),l=c.n(a);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){s(e,t,r[t])})}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(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 m(e,t){if(e){if("string"==typeof e)return u(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 u(e,t)}}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var v=[{label:"{{t('Create record', { ns: '".concat(r,"' })}}"),value:"create"},{label:"{{t('Update record', { ns: '".concat(r,"' })}}"),value:"update"},{label:"{{t('Delete record', { ns: '".concat(r,"' })}}"),value:i}];function w(r,n){var c,a,l,u,s=(0,e.useCompile)(),p=(0,t.useGetDataSourceCollectionManager)(),f=(0,t.getCollectionFieldOptions)(d(b({appends:["user"]},n),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:o("User acted")}},{name:"roleName",uiSchema:{title:o("Role of user acted")}}],compile:s,collectionManager:p})),y=[{label:o("Parameters"),value:"params",children:(a=(function(e){if(Array.isArray(e))return e}(c=(0,e.parseCollectionName)(r.collection))||function(e){var t,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var n=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(n.push(t.value),1!==n.length);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw r}}return n}}(c)||m(c,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],l=(0,e.useCompile)(),u=(0,t.useGetDataSourceCollectionManager)(a),[{label:o("ID"),value:"filterByTk"}].concat(g(r.action!==i?[{label:o("Values submitted"),value:"values",children:(0,t.getCollectionFieldOptions)(d(b({},n),{appends:null,depth:3,collection:r.collection,compile:l,collectionManager:u}))}]:[])))}];return g(f).concat(g(y))}var O=function(o){var c;if("function"!=typeof o&&null!==o)throw TypeError("Super expression must either be null or a function");function a(){var o,c,u;if(!(this instanceof a))throw TypeError("Cannot call a class as a function");return c=a,u=arguments,c=f(c),s(o=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,h()?Reflect.construct(c,u||[],f(this).constructor):c.apply(this,u)),"sync",!0),s(o,"title",'{{t("Pre-action event", { ns: "'.concat(r,'" })}}')),s(o,"description",'{{t(\'Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the "End process" node.\', { ns: "'.concat(r,'" })}}')),s(o,"presetFieldset",{collection:{type:"string",title:'{{t("Collection")}}',required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"}}),s(o,"fieldset",{collection:s({type:"string",title:'{{t("Collection")}}',required:!0,"x-disabled":!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},"x-reactions",[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]),global:{type:"boolean",title:'{{t("Trigger mode", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Local mode, triggered before executing the actions bound to this workflow", { ns: "'.concat(r,'" })}}'),value:!1},{label:'{{t("Global mode, triggered before executing the following actions", { ns: "'.concat(r,'" })}}'),value:!0}]},default:!1},actions:{type:"number",title:'{{t("Select actions", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:v},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}}),s(o,"triggerFieldset",{action:{type:"string",title:'{{t("Action type")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{allowClear:!1},enum:v,default:"create",required:!0},target:{type:"string",title:'{{t("Record to submit", { ns: "'.concat(r,'" })}}'),description:'{{t("Choose a record or primary key of a record in the collection to trigger.", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"TriggerCollectionRecordSelect",default:null,required:!0},userId:{type:"number",title:'{{t("User acted", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableWrapper","x-component-props":{nullable:!1,changeOnSelect:!0,variableOptions:{types:[function(e){return e.isForeignKey||"context"===e.type?"users"===e.target:"users"===e.collectionName&&"id"===e.name}]},render:function(t){return l().createElement(e.RemoteSelect,b({fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1},t))}},default:null,required:!0},roleName:{type:"string",title:'{{t("Role of user acted", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableWrapper","x-component-props":{nullable:!1,changeOnSelect:!0,variableOptions:{types:[function(e){return e.isForeignKey?"roles"===e.target:"roles"===e.collectionName&&"name"===e.name}]},render:function(t){return l().createElement(e.RemoteSelect,b({fieldNames:{label:"title",value:"name"},service:{resource:"roles"},manual:!1},t))}},default:null}}),s(o,"scope",{useCollectionDataSource:e.useCollectionDataSource,useValueObject:function(){return(0,n.useForm)().values.action!==i}}),s(o,"components",{FieldsSelect:t.FieldsSelect,RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip,WorkflowVariableWrapper:t.WorkflowVariableWrapper,TriggerCollectionRecordSelect:t.TriggerCollectionRecordSelect}),s(o,"isActionTriggerable_deprecated",function(e,t){return!e.global&&["submit","customize:save","customize:update","destroy"].includes(t.buttonAction)}),s(o,"actionTriggerableScope",function(e,t){return!e.global&&["form"].includes(t)}),s(o,"useVariables",w),o}return a.prototype=Object.create(o&&o.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),o&&y(a,o),c=[{key:"validate",value:function(e){return e.collection}},{key:"useInitializers",value:function(e){return e.collection?{name:"triggerData",type:"item",key:"triggerData",title:'{{t("Trigger data", { ns: "workflow" })}}',Component:t.CollectionBlockInitializer,collection:e.collection,dataPath:"$context.params.values"}:null}},{key:"getCreateModelMenuItem",value:function(e){return{key:"triggerData",label:'{{t("Trigger data", { ns: "workflow" })}}',useModel:"NodeDetailsModel",createModelOptions:{use:"NodeDetailsModel",stepParams:{resourceSettings:{init:{dataSourceKey:"main",collectionName:e.config.collection,dataPath:"$context.params.values"}},cardSettings:{titleDescription:{title:'{{t("Trigger data", { ns: "workflow" })}}'}}},subModels:{grid:{use:"NodeDetailsGridModel",subType:"object"}}}}}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(a.prototype,c),a}(t.Trigger);function j(e,t,r,o,n,i,c){try{var a=e[i](c),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(o,n)}function S(e,t,r){return(S=C()?Reflect.construct:function(e,t,r){var o=[null];o.push.apply(o,t);var n=new(Function.bind.apply(e,o));return r&&P(n,r.prototype),n}).apply(null,arguments)}function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function P(e,t){return(P=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e){var t="function"==typeof Map?new Map:void 0;return(k=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 S(e,arguments,x(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),P(r,e)})(e)}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}var T=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=x(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,C()?Reflect.construct(e,t||[],x(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&P(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,o,n,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(c,"next",{value:l(0)}),a(c,"throw",{value:l(1)}),a(c,"return",{value:l(2)}),"function"==typeof Symbol&&a(c,Symbol.iterator,{value:function(){return this}}),c;function l(a){return function(l){var u=[a,l];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,u[0]&&(i=0)),i;)try{if(r=1,o&&(n=2&u[0]?o.return:u[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,u[1])).done)return n;switch(o=0,n&&(u=[2&u[0],n.value]),u[0]){case 0:case 1:n=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,o=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(n=(n=i.trys).length>0&&n[n.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!n||u[1]>n[0]&&u[1]<n[3])){i.label=u[1];break}if(6===u[0]&&i.label<n[1]){i.label=n[1],n=u;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(u);break}n[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],o=0}finally{r=n=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.pm.get("workflow").registerTrigger("request-interception",O),[2]})},function(){var t=this,r=arguments;return new Promise(function(o,n){var i=e.apply(t,r);function c(e){j(i,o,n,c,a,"next",e)}function a(e){j(i,o,n,c,a,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(r.prototype,t),r}(k(e.Plugin)),_=T}(),p}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-request-interceptor",["react","@nocobase/client","@formily/react","@nocobase/plugin-workflow/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-request-interceptor"]=t(require("react"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-workflow/client")):e["@nocobase/plugin-workflow-request-interceptor"]=t(e.react,e["@nocobase/client"],e["@formily/react"],e["@nocobase/plugin-workflow/client"])}(self,function(e,t,r,o){return function(){"use strict";var n={230:function(e){e.exports=r},342:function(e){e.exports=t},990:function(e){e.exports=o},155:function(t){t.exports=e}},i={};function c(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return n[e](r,r.exports,c),r.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(l=c.g.location+"");var l,a=c.g.document;if(!l&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(l=a.currentScript.src),!l)){var u=a.getElementsByTagName("script");if(u.length)for(var s=u.length-1;s>-1&&(!l||!/^http(s?):/.test(l));)l=u[s--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");c.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-workflow-request-interceptor/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var o=window.location.pathname||"/",n=o.indexOf("/v2/");e=n>=0?o.slice(0,n+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-request-interceptor/dist/client/"}c.p=e}(),!function(){c.r(p),c.d(p,{PluginWorkflowRequestInterceptorClient:function(){return C},default:function(){return T}});var e=c(342),t=c(990),r="@nocobase/plugin-workflow-request-interceptor";function o(t){var o,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.i18n.t(t,(o=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){var o;o=r[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}({},i),n=n={ns:r},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(n)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(n,e))}),o))}var n=c(230),i="destroy",l=c(155),a=c.n(l);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){s(e,t,r[t])})}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||m(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 m(e,t){if(e){if("string"==typeof e)return u(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 u(e,t)}}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}var v=[{label:"{{t('Create record', { ns: '".concat(r,"' })}}"),value:"create"},{label:"{{t('Update record', { ns: '".concat(r,"' })}}"),value:"update"},{label:"{{t('Delete record', { ns: '".concat(r,"' })}}"),value:i}];function w(r,n){var c,l,a,u,s=(0,e.useCompile)(),p=(0,t.useGetDataSourceCollectionManager)(),f=(0,t.getCollectionFieldOptions)(d(b({appends:["user"]},n),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:o("User acted")}},{name:"roleName",uiSchema:{title:o("Role of user acted")}}],compile:s,collectionManager:p})),y=[{label:o("Parameters"),value:"params",children:(l=(function(e){if(Array.isArray(e))return e}(c=(0,e.parseCollectionName)(r.collection))||function(e){var t,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var n=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(n.push(t.value),1!==n.length);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw r}}return n}}(c)||m(c,1)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],a=(0,e.useCompile)(),u=(0,t.useGetDataSourceCollectionManager)(l),[{label:o("ID"),value:"filterByTk"}].concat(g(r.action!==i?[{label:o("Values submitted"),value:"values",children:(0,t.getCollectionFieldOptions)(d(b({},n),{appends:null,depth:3,collection:r.collection,compile:a,collectionManager:u}))}]:[])))}];return g(f).concat(g(y))}var O=function(o){var c;if("function"!=typeof o&&null!==o)throw TypeError("Super expression must either be null or a function");function l(){var o,c,u;if(!(this instanceof l))throw TypeError("Cannot call a class as a function");return c=l,u=arguments,c=f(c),s(o=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,h()?Reflect.construct(c,u||[],f(this).constructor):c.apply(this,u)),"sync",!0),s(o,"title",'{{t("Pre-action event", { ns: "'.concat(r,'" })}}')),s(o,"description",'{{t(\'Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the "End process" node.\', { ns: "'.concat(r,'" })}}')),s(o,"presetFieldset",{collection:{type:"string",title:'{{t("Collection")}}',required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"}}),s(o,"fieldset",{collection:s({type:"string",title:'{{t("Collection")}}',required:!0,"x-disabled":!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"},"x-reactions",[{target:"changed",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]),global:{type:"boolean",title:'{{t("Trigger mode", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Local mode, triggered before executing the actions bound to this workflow", { ns: "'.concat(r,'" })}}'),value:!1},{label:'{{t("Global mode, triggered before executing the following actions", { ns: "'.concat(r,'" })}}'),value:!0}]},default:!1},actions:{type:"number",title:'{{t("Select actions", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:v},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]}}),s(o,"triggerFieldset",{action:{type:"string",title:'{{t("Action type")}}',"x-decorator":"FormItem","x-component":"Select","x-component-props":{allowClear:!1},enum:v,default:"create",required:!0},target:{type:"string",title:'{{t("Record to submit", { ns: "'.concat(r,'" })}}'),description:'{{t("Choose a record or primary key of a record in the collection to trigger.", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"TriggerCollectionRecordSelect",default:null,required:!0},userId:{type:"number",title:'{{t("User acted", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableWrapper","x-component-props":{nullable:!1,changeOnSelect:!0,variableOptions:{types:[function(e){return e.isForeignKey||"context"===e.type?"users"===e.target:"users"===e.collectionName&&"id"===e.name}]},render:function(t){return a().createElement(e.RemoteSelect,b({fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1},t))}},default:null,required:!0},roleName:{type:"string",title:'{{t("Role of user acted", { ns: "'.concat(r,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableWrapper","x-component-props":{nullable:!1,changeOnSelect:!0,variableOptions:{types:[function(e){return e.isForeignKey?"roles"===e.target:"roles"===e.collectionName&&"name"===e.name}]},render:function(t){return a().createElement(e.RemoteSelect,b({fieldNames:{label:"title",value:"name"},service:{resource:"roles"},manual:!1},t))}},default:null}}),s(o,"scope",{useCollectionDataSource:e.useCollectionDataSource,useValueObject:function(){return(0,n.useForm)().values.action!==i}}),s(o,"components",{FieldsSelect:t.FieldsSelect,RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip,WorkflowVariableWrapper:t.WorkflowVariableWrapper,TriggerCollectionRecordSelect:t.TriggerCollectionRecordSelect}),s(o,"isActionTriggerable_deprecated",function(e,t){return!e.global&&["submit","customize:save","customize:update","destroy"].includes(t.buttonAction)}),s(o,"actionTriggerableScope",function(e,t){return!e.global&&["form"].includes(t)}),s(o,"useVariables",w),o}return l.prototype=Object.create(o&&o.prototype,{constructor:{value:l,writable:!0,configurable:!0}}),o&&y(l,o),c=[{key:"validate",value:function(e){return e.collection}},{key:"useInitializers",value:function(e){return e.collection?{name:"triggerData",type:"item",key:"triggerData",title:'{{t("Trigger data", { ns: "workflow" })}}',Component:t.CollectionBlockInitializer,collection:e.collection,dataPath:"$context.params.values"}:null}},{key:"getCreateModelMenuItem",value:function(e){return{key:"triggerData",label:'{{t("Trigger data", { ns: "workflow" })}}',useModel:"NodeDetailsModel",createModelOptions:{use:"NodeDetailsModel",stepParams:{resourceSettings:{init:{dataSourceKey:"main",collectionName:e.config.collection,dataPath:"$context.params.values"}},cardSettings:{titleDescription:{title:'{{t("Trigger data", { ns: "workflow" })}}'}}},subModels:{grid:{use:"NodeDetailsGridModel",subType:"object"}}}}}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(l.prototype,c),l}(t.Trigger);function j(e,t,r,o,n,i,c){try{var l=e[i](c),a=l.value}catch(e){r(e);return}l.done?t(a):Promise.resolve(a).then(o,n)}function S(e,t,r){return(S=_()?Reflect.construct:function(e,t,r){var o=[null];o.push.apply(o,t);var n=new(Function.bind.apply(e,o));return r&&P(n,r.prototype),n}).apply(null,arguments)}function x(e){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function P(e,t){return(P=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e){var t="function"==typeof Map?new Map:void 0;return(k=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 S(e,arguments,x(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),P(r,e)})(e)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}var C=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=x(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">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,_()?Reflect.construct(e,t||[],x(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&P(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,o,n,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(c,"next",{value:a(0)}),l(c,"throw",{value:a(1)}),l(c,"return",{value:a(2)}),"function"==typeof Symbol&&l(c,Symbol.iterator,{value:function(){return this}}),c;function a(l){return function(a){var u=[l,a];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,u[0]&&(i=0)),i;)try{if(r=1,o&&(n=2&u[0]?o.return:u[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,u[1])).done)return n;switch(o=0,n&&(u=[2&u[0],n.value]),u[0]){case 0:case 1:n=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,o=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(n=(n=i.trys).length>0&&n[n.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!n||u[1]>n[0]&&u[1]<n[3])){i.label=u[1];break}if(6===u[0]&&i.label<n[1]){i.label=n[1],n=u;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(u);break}n[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],o=0}finally{r=n=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return this.app.pm.get("workflow").registerTrigger("request-interception",O),[2]})},function(){var t=this,r=arguments;return new Promise(function(o,n){var i=e.apply(t,r);function c(e){j(i,o,n,c,l,"next",e)}function l(e){j(i,o,n,c,l,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(r.prototype,t),r}(k(e.Plugin)),T=C}(),p}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.1.0-alpha.
|
|
12
|
-
"@nocobase/plugin-workflow": "2.1.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.1.0-alpha.14",
|
|
12
|
+
"@nocobase/plugin-workflow": "2.1.0-alpha.14",
|
|
13
13
|
"@formily/react": "2.3.7",
|
|
14
14
|
"react": "18.2.0",
|
|
15
|
-
"@nocobase/flow-engine": "2.1.0-alpha.
|
|
16
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
15
|
+
"@nocobase/flow-engine": "2.1.0-alpha.14",
|
|
16
|
+
"@nocobase/server": "2.1.0-alpha.14",
|
|
17
17
|
"lodash": "4.17.21",
|
|
18
|
-
"@nocobase/plugin-error-handler": "2.1.0-alpha.
|
|
19
|
-
"@nocobase/data-source-manager": "2.1.0-alpha.
|
|
18
|
+
"@nocobase/plugin-error-handler": "2.1.0-alpha.14",
|
|
19
|
+
"@nocobase/data-source-manager": "2.1.0-alpha.14"
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-
|
|
1
|
+
{"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-04-07T15:55:37.766Z"}
|
|
@@ -56,7 +56,20 @@ class RequestInterceptionError extends Error {
|
|
|
56
56
|
class RequestInterceptionTrigger extends import_plugin_workflow.Trigger {
|
|
57
57
|
static TYPE = "request-interception";
|
|
58
58
|
configSchema = import_joi.default.object({
|
|
59
|
-
collection: import_joi.default.string().required()
|
|
59
|
+
collection: import_joi.default.string().required(),
|
|
60
|
+
global: import_joi.default.boolean().optional(),
|
|
61
|
+
actions: import_joi.default.when("global", {
|
|
62
|
+
is: true,
|
|
63
|
+
then: import_joi.default.array().items(
|
|
64
|
+
import_joi.default.string().valid(
|
|
65
|
+
import_constants.INTERCEPTABLE_ACTIONS.CREATE,
|
|
66
|
+
import_constants.INTERCEPTABLE_ACTIONS.UPDATE,
|
|
67
|
+
import_constants.INTERCEPTABLE_ACTIONS.UPSERT,
|
|
68
|
+
import_constants.INTERCEPTABLE_ACTIONS.DESTROY
|
|
69
|
+
)
|
|
70
|
+
).min(1).required().messages({ "array.min": "At least one action is required in global mode" }),
|
|
71
|
+
otherwise: import_joi.default.array().items(import_joi.default.string()).optional()
|
|
72
|
+
})
|
|
60
73
|
});
|
|
61
74
|
validateConfig(config) {
|
|
62
75
|
const errors = super.validateConfig(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow-request-interceptor",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.14",
|
|
4
4
|
"displayName": "Workflow: Pre-action event",
|
|
5
5
|
"displayName.zh-CN": "工作流:操作前事件",
|
|
6
6
|
"description": "Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the \"End process\" node.",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
"keywords": [
|
|
31
31
|
"Workflow"
|
|
32
32
|
],
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "d8735b541de0ff9557bba704de49c799b4962672",
|
|
34
34
|
"license": "Apache-2.0"
|
|
35
35
|
}
|