@nocobase/plugin-workflow-action-trigger 2.1.0-alpha.45 → 2.1.0-alpha.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,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-i18next"),require("react"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-action-trigger",["react-i18next","react","@nocobase/client","@formily/react","@nocobase/plugin-workflow/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-action-trigger"]=t(require("react-i18next"),require("react"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-workflow/client")):e["@nocobase/plugin-workflow-action-trigger"]=t(e["react-i18next"],e.react,e["@nocobase/client"],e["@formily/react"],e["@nocobase/plugin-workflow/client"])}(self,function(e,t,o,r,n){return function(){"use strict";var i={230:function(e){e.exports=r},342:function(e){e.exports=o},990:function(e){e.exports=n},155:function(e){e.exports=t},953:function(t){t.exports=e}},c={};function a(e){var t=c[e];if(void 0!==t)return t.exports;var o=c[e]={exports:{}};return i[e](o,o.exports,a),o.exports}a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,{a:t}),t},a.d=function(e,t){for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(l=a.g.location+"");var l,u=a.g.document;if(!l&&u&&(u.currentScript&&"SCRIPT"===u.currentScript.tagName.toUpperCase()&&(l=u.currentScript.src),!l)){var s=u.getElementsByTagName("script");if(s.length)for(var p=s.length-1;p>-1&&(!l||!/^http(s?):/.test(l));)l=s[p--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");a.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var f={};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 o=window.__webpack_public_path__||"";o&&("/"!==o.charAt(o.length-1)&&(o+="/"),e=o+"static/plugins/@nocobase/plugin-workflow-action-trigger/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var r=window.location.pathname||"/",n=r.indexOf("/v2/");e=n>=0?r.slice(0,n+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-action-trigger/dist/client/"}a.p=e}(),!function(){a.r(f),a.d(f,{default:function(){return P}});var e=a(342),t=a(990),o=a(230),r=a(953),n="workflow-action-trigger";function i(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=o,(0,r.useTranslation)(n,t)).t)(e)}var c=a(155),l=a.n(c);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=Array(t);o<t;o++)r[o]=e[o];return r}function s(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){s(e,t,o[t])})}return e}function b(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 o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t})(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(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 o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return u(e,t)}}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function v(o,r){var n,c,a=function(e){if(Array.isArray(e))return e}(n=(0,e.parseCollectionName)(o.collection))||function(e){var t,o,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(n.push(t.value),2!==n.length);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return n}}(n)||m(n,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.")}(),l=a[0],u=a[1],s=(0,e.useCompile)(),p=(0,t.useGetDataSourceCollectionManager)(l),f=(0,t.useGetDataSourceCollectionManager)(),g=i("Trigger data"),h=i("User acted"),v=i("Role of user acted");return y((0,t.getCollectionFieldOptions)(b(d({appends:["data"].concat(y((null==(c=o.appends)?void 0:c.map(function(e){return"data.".concat(e)}))||[]))},r),{fields:[{collectionName:u,name:"data",type:"hasOne",target:u,uiSchema:{title:g}}],compile:s,collectionManager:p}))).concat(y((0,t.getCollectionFieldOptions)(b(d({appends:["user"]},r),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:h}},{name:"roleName",uiSchema:{title:v}}],compile:s,collectionManager:f}))))}var w=function(r){var i;if("function"!=typeof r&&null!==r)throw TypeError("Super expression must either be null or a function");function c(){var r,i,a;if(!(this instanceof c))throw TypeError("Cannot call a class as a function");return i=c,a=arguments,i=p(i),s(r=function(e,t){var o;if(t&&("object"==((o=t)&&"u">typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"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(i,a||[],p(this).constructor):i.apply(this,a)),"title",'{{t("Post-action event", { ns: "'.concat(n,'" })}}')),s(r,"description","{{t('Triggered after the completion of a request initiated through an action button or API, such as after adding or updating data. Suitable for data processing, sending notifications, etc., after actions are completed.', { ns: \"".concat(n,'" })}}')),s(r,"presetFieldset",{collection:{type:"string",title:'{{t("Collection", { ns: "'.concat(n,'" })}}'),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"}}),s(r,"fieldset",{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-decorator-props":{tooltip:'{{t("The collection to which the triggered data belongs.", { ns: "'.concat(n,'" })}}')},"x-component":"DataSourceCollectionCascader","x-disabled":!0,title:'{{t("Collection", { ns: "'.concat(n,'" })}}'),"x-reactions":[{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:'{{t("Trigger mode", { ns: "'.concat(n,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Local mode, triggered after the completion of actions bound to this workflow", { ns: "'.concat(n,'" })}}'),value:!1},{label:'{{t("Global mode, triggered after the completion of the following actions", { ns: "'.concat(n,'" })}}'),value:!0}]},default:!1,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},actions:{type:"number",title:'{{t("Select actions", { ns: "'.concat(n,'" })}}'),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Create record action", { ns: "'.concat(n,'" })}}'),value:"create"},{label:'{{t("Update record action", { ns: "'.concat(n,'" })}}'),value:"update"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]},appends:{type:"array",title:'{{t("Associations to use", { ns: "'.concat(n,'" })}}'),description:'{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:function(){var e=(0,o.useForm)().values;return null==e?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}),s(r,"triggerFieldset",{data:{type:"object",title:'{{t("Trigger data", { ns: "workflow" })}}',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(n,'" })}}'),"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,d({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(n,'" })}}'),"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,d({fieldNames:{label:"title",value:"name"},service:{resource:"roles"},manual:!1},t))}},default:null}}),s(r,"scope",{useCollectionDataSource:e.useCollectionDataSource,useWorkflowAnyExecuted:t.useWorkflowAnyExecuted}),s(r,"components",{RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip,TriggerCollectionRecordSelect:t.TriggerCollectionRecordSelect,WorkflowVariableWrapper:t.WorkflowVariableWrapper}),s(r,"isActionTriggerable_deprecated",function(e,t){return!e.global&&["submit","customize:save","customize:update"].includes(t.buttonAction)}),s(r,"actionTriggerableScope",function(e,t){return!e.global&&["form"].includes(t)}),s(r,"useVariables",v),r}return c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&g(c,r),i=[{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: "'.concat(n,'" })}}'),Component:t.CollectionBlockInitializer,collection:e.collection,dataPath:"$context.data"}:null}},{key:"getCreateModelMenuItem",value:function(e){var t=e.config;return(null==t?void 0:t.collection)?{key:"triggerData",label:'{{t("Trigger data", { ns: "'.concat(n,'" })}}'),useModel:"NodeDetailsModel",createModelOptions:{use:"NodeDetailsModel",stepParams:{resourceSettings:{init:{dataSourceKey:"main",collectionName:t.collection,dataPath:"$context.data"}},cardSettings:{titleDescription:{title:'{{t("Trigger data", { ns: "'.concat(n,'" })}}')}}},subModels:{grid:{use:"NodeDetailsGridModel",subType:"object"}}}}:null}}],function(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(c.prototype,i),c}(t.Trigger);function O(e,t,o,r,n,i,c){try{var a=e[i](c),l=a.value}catch(e){o(e);return}a.done?t(l):Promise.resolve(l).then(r,n)}function x(e,t,o){return(x=T()?Reflect.construct:function(e,t,o){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return o&&j(n,o.prototype),n}).apply(null,arguments)}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=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,o)}function o(){return x(e,arguments,S(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),j(o,e)})(e)}function T(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(T=function(){return!!e})()}var P=function(e){var o;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=S(e),function(e,t){var o;if(t&&("object"==((o=t)&&"u">typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,T()?Reflect.construct(e,t||[],S(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&j(r,e),o=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var o,r,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(o)throw TypeError("Generator is already executing.");for(;c&&(c=0,u[0]&&(i=0)),i;)try{if(o=1,r&&(n=2&u[0]?r.return:u[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,u[1])).done)return n;switch(r=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++,r=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],r=0}finally{o=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("action",w),this.app.addScopes({useTriggerWorkflowsActionProps:t.useTriggerWorkflowsActionProps,useRecordTriggerWorkflowsActionProps:t.useRecordTriggerWorkflowsActionProps}),[2]})},function(){var t=this,o=arguments;return new Promise(function(r,n){var i=e.apply(t,o);function c(e){O(i,r,n,c,a,"next",e)}function a(e){O(i,r,n,c,a,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,o),r}(k(e.Plugin))}(),f}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-action-trigger",["react-i18next","react","@nocobase/client","@formily/react","@nocobase/plugin-workflow/client"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-action-trigger"]=t(require("react-i18next"),require("react"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-workflow/client")):e["@nocobase/plugin-workflow-action-trigger"]=t(e["react-i18next"],e.react,e["@nocobase/client"],e["@formily/react"],e["@nocobase/plugin-workflow/client"])}(self,function(e,t,o,r,n){return function(){"use strict";var i={230:function(e){e.exports=r},342:function(e){e.exports=o},990:function(e){e.exports=n},155:function(e){e.exports=t},953:function(t){t.exports=e}},c={};function a(e){var t=c[e];if(void 0!==t)return t.exports;var o=c[e]={exports:{}};return i[e](o,o.exports,a),o.exports}a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,{a:t}),t},a.d=function(e,t){for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(l=a.g.location+"");var l,u=a.g.document;if(!l&&u&&(u.currentScript&&"SCRIPT"===u.currentScript.tagName.toUpperCase()&&(l=u.currentScript.src),!l)){var s=u.getElementsByTagName("script");if(s.length)for(var p=s.length-1;p>-1&&(!l||!/^http(s?):/.test(l));)l=s[p--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");a.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var f={};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 o=window.__webpack_public_path__||"";o&&("/"!==o.charAt(o.length-1)&&(o+="/"),e=o+"static/plugins/@nocobase/plugin-workflow-action-trigger/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",n="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",c=i.indexOf(n);e=c>=0?i.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-workflow-action-trigger/dist/client/"}a.p=e}(),!function(){a.r(f),a.d(f,{default:function(){return _}});var e=a(342),t=a(990),o=a(230),r=a(953),n="workflow-action-trigger";function i(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,(t=o,(0,r.useTranslation)(n,t)).t)(e)}var c=a(155),l=a.n(c);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,r=Array(t);o<t;o++)r[o]=e[o];return r}function s(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){s(e,t,o[t])})}return e}function b(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 o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t})(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(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 o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return u(e,t)}}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function v(o,r){var n,c,a=function(e){if(Array.isArray(e))return e}(n=(0,e.parseCollectionName)(o.collection))||function(e){var t,o,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(n.push(t.value),2!==n.length);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return n}}(n)||m(n,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.")}(),l=a[0],u=a[1],s=(0,e.useCompile)(),p=(0,t.useGetDataSourceCollectionManager)(l),f=(0,t.useGetDataSourceCollectionManager)(),g=i("Trigger data"),h=i("User acted"),v=i("Role of user acted");return y((0,t.getCollectionFieldOptions)(b(d({appends:["data"].concat(y((null==(c=o.appends)?void 0:c.map(function(e){return"data.".concat(e)}))||[]))},r),{fields:[{collectionName:u,name:"data",type:"hasOne",target:u,uiSchema:{title:g}}],compile:s,collectionManager:p}))).concat(y((0,t.getCollectionFieldOptions)(b(d({appends:["user"]},r),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:h}},{name:"roleName",uiSchema:{title:v}}],compile:s,collectionManager:f}))))}var w=function(r){var i;if("function"!=typeof r&&null!==r)throw TypeError("Super expression must either be null or a function");function c(){var r,i,a;if(!(this instanceof c))throw TypeError("Cannot call a class as a function");return i=c,a=arguments,i=p(i),s(r=function(e,t){var o;if(t&&("object"==((o=t)&&"u">typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"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(i,a||[],p(this).constructor):i.apply(this,a)),"title",'{{t("Post-action event", { ns: "'.concat(n,'" })}}')),s(r,"description","{{t('Triggered after the completion of a request initiated through an action button or API, such as after adding or updating data. Suitable for data processing, sending notifications, etc., after actions are completed.', { ns: \"".concat(n,'" })}}')),s(r,"presetFieldset",{collection:{type:"string",title:'{{t("Collection", { ns: "'.concat(n,'" })}}'),required:!0,"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader"}}),s(r,"fieldset",{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-decorator-props":{tooltip:'{{t("The collection to which the triggered data belongs.", { ns: "'.concat(n,'" })}}')},"x-component":"DataSourceCollectionCascader","x-disabled":!0,title:'{{t("Collection", { ns: "'.concat(n,'" })}}'),"x-reactions":[{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:'{{t("Trigger mode", { ns: "'.concat(n,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Local mode, triggered after the completion of actions bound to this workflow", { ns: "'.concat(n,'" })}}'),value:!1},{label:'{{t("Global mode, triggered after the completion of the following actions", { ns: "'.concat(n,'" })}}'),value:!0}]},default:!1,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},actions:{type:"number",title:'{{t("Select actions", { ns: "'.concat(n,'" })}}'),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Create record action", { ns: "'.concat(n,'" })}}'),value:"create"},{label:'{{t("Update record action", { ns: "'.concat(n,'" })}}'),value:"update"}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]},appends:{type:"array",title:'{{t("Associations to use", { ns: "'.concat(n,'" })}}'),description:'{{t("Please select the associated fields that need to be accessed in subsequent nodes. With more than two levels of to-many associations may cause performance issue, please use with caution.", { ns: "workflow" })}}',"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:function(){var e=(0,o.useForm)().values;return null==e?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}),s(r,"triggerFieldset",{data:{type:"object",title:'{{t("Trigger data", { ns: "workflow" })}}',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(n,'" })}}'),"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,d({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(n,'" })}}'),"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,d({fieldNames:{label:"title",value:"name"},service:{resource:"roles"},manual:!1},t))}},default:null}}),s(r,"scope",{useCollectionDataSource:e.useCollectionDataSource,useWorkflowAnyExecuted:t.useWorkflowAnyExecuted}),s(r,"components",{RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip,TriggerCollectionRecordSelect:t.TriggerCollectionRecordSelect,WorkflowVariableWrapper:t.WorkflowVariableWrapper}),s(r,"isActionTriggerable_deprecated",function(e,t){return!e.global&&["submit","customize:save","customize:update"].includes(t.buttonAction)}),s(r,"actionTriggerableScope",function(e,t){return!e.global&&["form"].includes(t)}),s(r,"useVariables",v),r}return c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&g(c,r),i=[{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: "'.concat(n,'" })}}'),Component:t.CollectionBlockInitializer,collection:e.collection,dataPath:"$context.data"}:null}},{key:"getCreateModelMenuItem",value:function(e){var t=e.config;return(null==t?void 0:t.collection)?{key:"triggerData",label:'{{t("Trigger data", { ns: "'.concat(n,'" })}}'),useModel:"NodeDetailsModel",createModelOptions:{use:"NodeDetailsModel",stepParams:{resourceSettings:{init:{dataSourceKey:"main",collectionName:t.collection,dataPath:"$context.data"}},cardSettings:{titleDescription:{title:'{{t("Trigger data", { ns: "'.concat(n,'" })}}')}}},subModels:{grid:{use:"NodeDetailsGridModel",subType:"object"}}}}:null}}],function(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(c.prototype,i),c}(t.Trigger);function O(e,t,o,r,n,i,c){try{var a=e[i](c),l=a.value}catch(e){o(e);return}a.done?t(l):Promise.resolve(l).then(r,n)}function x(e,t,o){return(x=T()?Reflect.construct:function(e,t,o){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return o&&j(n,o.prototype),n}).apply(null,arguments)}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=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,o)}function o(){return x(e,arguments,S(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),j(o,e)})(e)}function T(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(T=function(){return!!e})()}var _=function(e){var o;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=S(e),function(e,t){var o;if(t&&("object"==((o=t)&&"u">typeof Symbol&&o.constructor===Symbol?"symbol":typeof o)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,T()?Reflect.construct(e,t||[],S(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&j(r,e),o=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var o,r,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(o)throw TypeError("Generator is already executing.");for(;c&&(c=0,u[0]&&(i=0)),i;)try{if(o=1,r&&(n=2&u[0]?r.return:u[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,u[1])).done)return n;switch(r=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++,r=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],r=0}finally{o=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("action",w),this.app.addScopes({useTriggerWorkflowsActionProps:t.useTriggerWorkflowsActionProps,useRecordTriggerWorkflowsActionProps:t.useRecordTriggerWorkflowsActionProps}),[2]})},function(){var t=this,o=arguments;return new Promise(function(r,n){var i=e.apply(t,o);function c(e){O(i,r,n,c,a,"next",e)}function a(e){O(i,r,n,c,a,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,o),r}(k(e.Plugin))}(),f}()});
@@ -9,19 +9,19 @@
9
9
 
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.7",
12
- "@nocobase/client": "2.1.0-alpha.45",
13
- "@nocobase/plugin-workflow": "2.1.0-alpha.45",
12
+ "@nocobase/client": "2.1.0-alpha.47",
13
+ "@nocobase/plugin-workflow": "2.1.0-alpha.47",
14
14
  "react": "18.2.0",
15
- "@nocobase/flow-engine": "2.1.0-alpha.45",
15
+ "@nocobase/flow-engine": "2.1.0-alpha.47",
16
16
  "react-i18next": "11.18.6",
17
17
  "lodash": "4.18.1",
18
18
  "sequelize": "6.35.2",
19
- "@nocobase/database": "2.1.0-alpha.45",
20
- "@nocobase/server": "2.1.0-alpha.45",
21
- "@nocobase/actions": "2.1.0-alpha.45",
22
- "@nocobase/plugin-error-handler": "2.1.0-alpha.45",
23
- "@nocobase/data-source-manager": "2.1.0-alpha.45",
24
- "@nocobase/plugin-workflow-test": "2.1.0-alpha.45",
25
- "@nocobase/test": "2.1.0-alpha.45",
26
- "@nocobase/utils": "2.1.0-alpha.45"
19
+ "@nocobase/database": "2.1.0-alpha.47",
20
+ "@nocobase/server": "2.1.0-alpha.47",
21
+ "@nocobase/actions": "2.1.0-alpha.47",
22
+ "@nocobase/plugin-error-handler": "2.1.0-alpha.47",
23
+ "@nocobase/data-source-manager": "2.1.0-alpha.47",
24
+ "@nocobase/plugin-workflow-test": "2.1.0-alpha.47",
25
+ "@nocobase/test": "2.1.0-alpha.47",
26
+ "@nocobase/utils": "2.1.0-alpha.47"
27
27
  };
@@ -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-05-29T12:51:10.137Z"}
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-06-08T04:02:55.097Z"}
@@ -16,6 +16,7 @@ export default class extends Trigger {
16
16
  constructor(workflow: WorkflowPlugin);
17
17
  getTargetCollection(collection: Collection, association: string): Collection<any, any>;
18
18
  private collectionTriggerAction;
19
+ private scheduleAsyncWorkflowTriggers;
19
20
  execute(workflow: WorkflowModel, values: any, options: EventOptions): Promise<void | import("@nocobase/plugin-workflow").Processor>;
20
21
  validateContext(values: any): {
21
22
  data: string;
@@ -45,6 +45,7 @@ var import_plugin_error_handler = __toESM(require("@nocobase/plugin-error-handle
45
45
  var import_joi = __toESM(require("joi"));
46
46
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
47
47
  var import_data_source_manager = require("@nocobase/data-source-manager");
48
+ const ASYNC_WORKFLOW_TRIGGER_DELAY_MS = 200;
48
49
  class RequestOnActionTriggerError extends Error {
49
50
  status = 400;
50
51
  messages = [];
@@ -276,9 +277,34 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
276
277
  });
277
278
  return context.throw(500, "Workflow on your action hangs, please contact the administrator");
278
279
  }
279
- for (const event of asyncGroup) {
280
- this.workflow.trigger(event[0], event[1]);
280
+ this.scheduleAsyncWorkflowTriggers(context, asyncGroup);
281
+ }
282
+ scheduleAsyncWorkflowTriggers(context, events) {
283
+ if (!events.length) {
284
+ return;
285
+ }
286
+ const triggerAsyncWorkflows = () => {
287
+ const triggerAsyncWorkflow = async (workflow, values) => {
288
+ await this.workflow.trigger(workflow, values);
289
+ };
290
+ setTimeout(() => {
291
+ for (const [workflow, values] of events) {
292
+ triggerAsyncWorkflow(workflow, values).catch((error) => {
293
+ context.logger.error("[Workflow post-action]: async workflow trigger failed", {
294
+ error,
295
+ workflowId: workflow.id,
296
+ workflowKey: workflow.key,
297
+ workflowTitle: workflow.title
298
+ });
299
+ });
300
+ }
301
+ }, ASYNC_WORKFLOW_TRIGGER_DELAY_MS);
302
+ };
303
+ if (context.res.writableEnded) {
304
+ triggerAsyncWorkflows();
305
+ return;
281
306
  }
307
+ context.res.once("finish", triggerAsyncWorkflows);
282
308
  }
283
309
  async execute(workflow, values, options) {
284
310
  var _a, _b;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or \"submit to workflow\". Suitable for data processing, sending notifications, etc., after actions are completed.",
7
7
  "description.ru-RU": "Срабатывает после завершения запроса, инициированного кнопкой действия или API, например после добавления, обновления, удаления данных или «отправки в рабочий процесс». Подходит для обработки данных, отправки уведомлений и т.д. после выполнения действий.",
8
8
  "description.zh-CN": "通过操作按钮或 API 发起请求并在执行完成后触发,比如新增、更新、删除数据或者“提交至工作流”之后。适用于在操作完成后进行数据处理、发送通知等。",
9
- "version": "2.1.0-alpha.45",
9
+ "version": "2.1.0-alpha.47",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
@@ -26,7 +26,7 @@
26
26
  "@nocobase/server": "2.x",
27
27
  "@nocobase/test": "2.x"
28
28
  },
29
- "gitHead": "e9e24987e12d0ad10a5db8815b1e1b7b447f1938",
29
+ "gitHead": "66196b57f9043ea0ac6ebdafbc732bfb98af1396",
30
30
  "keywords": [
31
31
  "Workflow"
32
32
  ]