@nocobase/plugin-workflow-action-trigger 1.7.0-beta.3 → 1.7.0-beta.31

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("@formily/react"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-action-trigger",["react-i18next","@formily/react","@nocobase/client","@nocobase/plugin-workflow/client","react"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-action-trigger"]=t(require("react-i18next"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react")):e["@nocobase/plugin-workflow-action-trigger"]=t(e["react-i18next"],e["@formily/react"],e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e.react)}(self,function(e,t,o,r,n){return function(){"use strict";var i={505:function(e){e.exports=t},772:function(e){e.exports=o},433:function(e){e.exports=r},156:function(e){e.exports=n},238: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.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};a.r(l),a.d(l,{default:function(){return N}});var u=a("772"),s=a("433"),f=a("505"),p=a("238"),d="workflow-action-trigger";function b(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,function(e){return(0,p.useTranslation)(d,e)}(t).t)(e)}var y=a("156"),m=a.n(y);function g(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 h(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)}}function v(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function O(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){v(e,t,o[t])})}return e}function x(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o.push.apply(o,r)}return o})(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(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 j(e,t){if(e){if("string"==typeof e)return g(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 g(e,t)}}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}var T="create",C="update";function W(e,t){var o,r,n,i=(o=(0,u.parseCollectionName)(e.collection),r=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var o,r,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i=[],c=!0,a=!1;try{for(n=n.call(e);!(c=(o=n.next()).done)&&(i.push(o.value),!t||i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{!c&&null!=n.return&&n.return()}finally{if(a)throw r}}return i}}(o,2)||j(o,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=i[0],a=i[1],l=(0,u.useCompile)(),f=(0,s.useGetCollectionFields)(c),p=(0,s.useGetCollectionFields)(),d=b("Trigger data"),y=b("User acted"),m=b("Role of user acted");return k((0,s.getCollectionFieldOptions)(x(O({appends:["data"].concat(k((null===(n=e.appends)||void 0===n?void 0:n.map(function(e){return"data.".concat(e)}))||[]))},t),{fields:[{collectionName:a,name:"data",type:"hasOne",target:a,uiSchema:{title:d}}],compile:l,getCollectionFields:f}))).concat(k((0,s.getCollectionFieldOptions)(x(O({appends:["user"]},t),{fields:[{collectionName:"users",name:"user",type:"hasOne",target:"users",uiSchema:{title:y}},{name:"roleName",uiSchema:{title:m}}],compile:l,getCollectionFields:p}))))}var A=function(e){var t,o,r;function n(){var e,t,o,r;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),t=this,o=n,r=arguments,o=w(o),v(e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,P()?Reflect.construct(o,r||[],w(t).constructor):o.apply(t,r)),"title",'{{t("Post-action event", { ns: "'.concat(d,'" })}}')),v(e,"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(d,'" })}}')),v(e,"fieldset",{collection:{type:"string",required:!0,"x-decorator":"FormItem","x-decorator-props":{tooltip:'{{t("The collection to which the triggered data belongs.", { ns: "'.concat(d,'" })}}')},"x-component":"DataSourceCollectionCascader","x-disabled":"{{ useWorkflowAnyExecuted() }}",title:'{{t("Collection", { ns: "'.concat(d,'" })}}'),"x-reactions":[{target:"appends",effects:["onFieldValueChange"],fulfill:{state:{value:[]}}}]},global:{type:"boolean",title:'{{t("Trigger mode", { ns: "'.concat(d,'" })}}'),"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(d,'" })}}'),value:!1},{label:'{{t("Global mode, triggered after the completion of the following actions", { ns: "'.concat(d,'" })}}'),value:!0}]},default:!1,"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]},actions:{type:"number",title:'{{t("Select actions", { ns: "'.concat(d,'" })}}'),"x-decorator":"FormItem","x-component":"CheckboxGroupWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Create record action", { ns: "'.concat(d,'" })}}'),value:T},{label:'{{t("Update record action", { ns: "'.concat(d,'" })}}'),value:C}]},required:!0,"x-reactions":[{dependencies:["collection","global"],fulfill:{state:{visible:"{{!!$deps[0] && !!$deps[1]}}"}}}]},appends:{type:"array",title:'{{t("Associations to use", { ns: "'.concat(d,'" })}}'),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,f.useForm)().values;return null==e?void 0:e.collection}},"x-reactions":[{dependencies:["collection"],fulfill:{state:{visible:"{{!!$deps[0]}}"}}}]}}),v(e,"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(d,'" })}}'),"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(e){return m().createElement(u.RemoteSelect,O({fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1},e))}},default:null,required:!0},roleName:{type:"string",title:'{{t("Role of user acted", { ns: "'.concat(d,'" })}}'),"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(e){return m().createElement(u.RemoteSelect,O({fieldNames:{label:"title",value:"name"},service:{resource:"roles"},manual:!1},e))}},default:null}}),v(e,"scope",{useCollectionDataSource:u.useCollectionDataSource,useWorkflowAnyExecuted:s.useWorkflowAnyExecuted}),v(e,"components",{RadioWithTooltip:s.RadioWithTooltip,CheckboxGroupWithTooltip:s.CheckboxGroupWithTooltip,TriggerCollectionRecordSelect:s.TriggerCollectionRecordSelect,WorkflowVariableWrapper:s.WorkflowVariableWrapper}),v(e,"isActionTriggerable",function(e,t){return!e.global&&["submit","customize:save","customize:update"].includes(t.buttonAction)}),v(e,"useVariables",W),e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(n,e),t=n,o=[{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(d,'" })}}'),Component:s.CollectionBlockInitializer,collection:e.collection,dataPath:"$context.data"}:null}}],h(t.prototype,o),n}(s.Trigger);function F(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 _(e,t,o){return(_=D()?Reflect.construct:function(e,t,o){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return o&&q(n,o.prototype),n}).apply(null,arguments)}function R(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)}}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){var t="function"==typeof Map?new Map:void 0;return(I=function(e){var o;if(null===e||(o=e,-1===Function.toString.call(o).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 _(e,arguments,E(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),q(r,e)})(e)}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}var N=function(e){var t,o,r;function n(){var e,t,o;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,n),e=this,t=n,o=arguments,t=E(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,D()?Reflect.construct(t,o||[],E(e).constructor):t.apply(e,o))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&q(e,t)}(n,e),t=n,o=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var o,r,n,i,c={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw TypeError("Generator is already executing.");for(;c;)try{if(o=1,r&&(n=2&i[0]?r.return:i[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,i[1])).done)return n;switch(r=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(n=(n=c.trys).length>0&&n[n.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){c.label=i[1];break}if(6===i[0]&&c.label<n[1]){c.label=n[1],n=i;break}if(n&&c.label<n[2]){c.label=n[2],c.ops.push(i);break}n[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],r=0}finally{o=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(e){return t.app.pm.get("workflow").registerTrigger("action",A),t.app.addScopes({useTriggerWorkflowsActionProps:s.useTriggerWorkflowsActionProps,useRecordTriggerWorkflowsActionProps:s.useRecordTriggerWorkflowsActionProps}),[2]})},function(){var t=this,o=arguments;return new Promise(function(r,n){var i=e.apply(t,o);function c(e){F(i,r,n,c,a,"next",e)}function a(e){F(i,r,n,c,a,"throw",e)}c(void 0)})})()}}],R(t.prototype,o),n}(I(u.Plugin));return l}()});
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"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-action-trigger",["react","@formily/react","@nocobase/client","@nocobase/plugin-workflow/client","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-action-trigger"]=t(require("react"),require("@formily/react"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):e["@nocobase/plugin-workflow-action-trigger"]=t(e.react,e["@formily/react"],e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e["react-i18next"])}(self,function(e,t,o,r,n){return function(){"use strict";var i={505:function(e){e.exports=t},772:function(e){e.exports=o},433:function(e){e.exports=r},156:function(t){t.exports=e},238:function(e){e.exports=n}},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.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return!function(){a.r(l),a.d(l,{default:function(){return T}});var e=a(772),t=a(433),o=a(505),r=a(238),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(156),u=a.n(c);function s(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 f(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){f(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,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o.push.apply(o,r)}return o})(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(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 g(e,t){if(e){if("string"==typeof e)return s(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 s(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=(n=(0,e.parseCollectionName)(o.collection),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var o,r,n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i=[],c=!0,a=!1;try{for(n=n.call(e);!(c=(o=n.next()).done)&&(i.push(o.value),i.length!==t);c=!0);}catch(e){a=!0,r=e}finally{try{c||null==n.return||n.return()}finally{if(a)throw r}}return i}}(n,2)||g(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)(),f=(0,t.useGetCollectionFields)(l),p=(0,t.useGetCollectionFields)(),y=i("Trigger data"),h=i("User acted"),v=i("Role of user acted");return m((0,t.getCollectionFieldOptions)(b(d({appends:["data"].concat(m((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:y}}],compile:s,getCollectionFields:f}))).concat(m((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,getCollectionFields:p}))))}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),f(r=function(e,t){var o;if(t&&("object"==((o=t)&&"undefined"!=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,'" })}}')),f(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,'" })}}')),f(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":"{{ useWorkflowAnyExecuted() }}",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]}}"}}}]}}),f(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 u().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 u().createElement(e.RemoteSelect,d({fieldNames:{label:"title",value:"name"},service:{resource:"roles"},manual:!1},t))}},default:null}}),f(r,"scope",{useCollectionDataSource:e.useCollectionDataSource,useWorkflowAnyExecuted:t.useWorkflowAnyExecuted}),f(r,"components",{RadioWithTooltip:t.RadioWithTooltip,CheckboxGroupWithTooltip:t.CheckboxGroupWithTooltip,TriggerCollectionRecordSelect:t.TriggerCollectionRecordSelect,WorkflowVariableWrapper:t.WorkflowVariableWrapper}),f(r,"isActionTriggerable",function(e,t){return!e.global&&["submit","customize:save","customize:update"].includes(t.buttonAction)}),f(r,"useVariables",v),r}return c.prototype=Object.create(r&&r.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),r&&y(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}}],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=P()?Reflect.construct:function(e,t,o){var r=[null];r.push.apply(r,t);var n=new(Function.bind.apply(e,r));return o&&k(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 k(e,t){return(k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function j(e){var t="function"==typeof Map?new Map:void 0;return(j=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}}),k(o,e)})(e)}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}var T=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)&&"undefined"!=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,P()?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&&k(r,e),o=[{key:"load",value:function(){var e,o=this;return(e=function(){return function(e,t){var o,r,n,i,c={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var l=[i,a];if(o)throw TypeError("Generator is already executing.");for(;c;)try{if(o=1,r&&(n=2&l[0]?r.return:l[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,l[1])).done)return n;switch(r=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return c.label++,{value:l[1],done:!1};case 5:c.label++,r=l[1],l=[0];continue;case 7:l=c.ops.pop(),c.trys.pop();continue;default:if(!(n=(n=c.trys).length>0&&n[n.length-1])&&(6===l[0]||2===l[0])){c=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){c.label=l[1];break}if(6===l[0]&&c.label<n[1]){c.label=n[1],n=l;break}if(n&&c.label<n[2]){c.label=n[2],c.ops.push(l);break}n[2]&&c.ops.pop(),c.trys.pop();continue}l=t.call(e,c)}catch(e){l=[6,e],r=0}finally{o=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return o.app.pm.get("workflow").registerTrigger("action",w),o.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)})})()}}],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}(j(e.Plugin))}(),l}()});
@@ -9,18 +9,18 @@
9
9
 
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.0",
12
- "@nocobase/client": "1.7.0-beta.3",
13
- "@nocobase/plugin-workflow": "1.7.0-beta.3",
12
+ "@nocobase/client": "1.7.0-beta.31",
13
+ "@nocobase/plugin-workflow": "1.7.0-beta.31",
14
14
  "react": "18.2.0",
15
15
  "react-i18next": "11.18.6",
16
16
  "lodash": "4.17.21",
17
17
  "sequelize": "6.35.2",
18
- "@nocobase/database": "1.7.0-beta.3",
19
- "@nocobase/server": "1.7.0-beta.3",
20
- "@nocobase/actions": "1.7.0-beta.3",
21
- "@nocobase/plugin-error-handler": "1.7.0-beta.3",
22
- "@nocobase/data-source-manager": "1.7.0-beta.3",
23
- "@nocobase/plugin-workflow-test": "1.7.0-beta.3",
24
- "@nocobase/test": "1.7.0-beta.3",
25
- "@nocobase/utils": "1.7.0-beta.3"
18
+ "@nocobase/database": "1.7.0-beta.31",
19
+ "@nocobase/server": "1.7.0-beta.31",
20
+ "@nocobase/actions": "1.7.0-beta.31",
21
+ "@nocobase/plugin-error-handler": "1.7.0-beta.31",
22
+ "@nocobase/data-source-manager": "1.7.0-beta.31",
23
+ "@nocobase/plugin-workflow-test": "1.7.0-beta.31",
24
+ "@nocobase/test": "1.7.0-beta.31",
25
+ "@nocobase/utils": "1.7.0-beta.31"
26
26
  };
@@ -1,9 +1,17 @@
1
1
  {
2
- "Form event": "Evento modulo",
3
- "Event triggers when submitted a workflow bound form action.": "L'evento si attiva quando viene inviata un'azione di un modulo associato a un workflow.",
4
- "Form data model": "Modello dati modulo",
5
- "Use a collection to match form data.": "Utilizza una raccolta per abbinare i dati del modulo.",
2
+ "Post-action event": "Evento post-azione",
3
+ "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.":
4
+ "Attivato dopo il completamento con esito positivo di una richiesta avviata tramite un pulsante di azione o un'API, ad esempio dopo l'aggiunta o l'aggiornamento di dati. Adatto per l'elaborazione dei dati, l'invio di notifiche, ecc. dopo il completamento delle azioni.",
5
+ "Collection": "Raccolta",
6
+ "The collection to which the triggered data belongs.": "La raccolta a cui appartengono i dati attivati.",
7
+ "Trigger mode": "Modalità di attivazione",
8
+ "Local mode, triggered after the completion of actions bound to this workflow": "Modalità locale, attivata dopo il completamento delle azioni associate a questo workflow",
9
+ "Global mode, triggered after the completion of the following actions": "Modalità globale, attivata dopo il completamento delle seguenti azioni",
10
+ "Select actions": "Seleziona azioni",
11
+ "Create record action": "Azione di creazione record",
12
+ "Update record action": "Azione di aggiornamento record",
6
13
  "Associations to use": "Associazioni da utilizzare",
7
- "User submitted form": "Modulo inviato dall'utente",
8
- "Role of user submitted form": "Ruolo del modulo inviato dall'utente"
14
+ "Trigger data": "Dati attivazione",
15
+ "User acted": "Utente che ha agito",
16
+ "Role of user acted": "Ruolo dell'utente che ha agito"
9
17
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "Form event": "Form event",
3
- "Event triggers when submitted a workflow bound form action.": "Event triggers when submitted a workflow bound form action.",
4
- "Form data model": "Form data model",
5
- "Use a collection to match form data.": "Use a collection to match form data.",
6
- "Associations to use": "Associations to use",
7
- "User submitted form": "User submitted form",
8
- "Role of user submitted form": "Role of user submitted form"
9
- }
2
+ "Form event": "Formuliergebeurtenis",
3
+ "Event triggers when submitted a workflow bound form action.": "De gebeurtenis wordt geactiveerd wanneer een formulieractie die aan een workflow is gekoppeld wordt ingediend.",
4
+ "Form data model": "Formuliergegevensmodel",
5
+ "Use a collection to match form data.": "Gebruik een collectie om formuliergegevens te matchen.",
6
+ "Associations to use": "Associaties om te gebruiken",
7
+ "User submitted form": "Gebruiker heeft formulier ingediend",
8
+ "Role of user submitted form": "Rol van de ingediende formuliergebruiker"
9
+ }
@@ -100,7 +100,7 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
100
100
  const { currentUser, currentRole } = context.state;
101
101
  const { model: UserModel } = this.workflow.db.getCollection("users");
102
102
  const userInfo = {
103
- user: UserModel.build(currentUser).desensitize(),
103
+ user: UserModel.build(currentUser).desensitize().toJSON(),
104
104
  roleName: currentRole
105
105
  };
106
106
  const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
@@ -176,7 +176,7 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
176
176
  });
177
177
  }
178
178
  }
179
- event.push({ data: (0, import_plugin_workflow.toJSON)(payload), ...userInfo });
179
+ (workflow.sync ? syncGroup : asyncGroup).push([workflow, { data: (0, import_plugin_workflow.toJSON)(payload), ...userInfo }]);
180
180
  }
181
181
  } else {
182
182
  const { filterTargetKey, repository } = context.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
@@ -188,9 +188,8 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
188
188
  appends
189
189
  });
190
190
  }
191
- event.push({ data, ...userInfo });
191
+ (workflow.sync ? syncGroup : asyncGroup).push([workflow, { data, ...userInfo }]);
192
192
  }
193
- (workflow.sync ? syncGroup : asyncGroup).push(event);
194
193
  }
195
194
  for (const event of syncGroup) {
196
195
  const processor = await this.workflow.trigger(event[0], event[1], { httpContext: context });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:操作后事件",
5
5
  "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.",
6
6
  "description.zh-CN": "通过操作按钮或 API 发起请求并在执行完成后触发,比如新增、更新、删除数据或者“提交至工作流”之后。适用于在操作完成后进行数据处理、发送通知等。",
7
- "version": "1.7.0-beta.3",
7
+ "version": "1.7.0-beta.31",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
@@ -21,7 +21,7 @@
21
21
  "@nocobase/server": "1.x",
22
22
  "@nocobase/test": "1.x"
23
23
  },
24
- "gitHead": "8d52cb1d366a968f87c1cd3f98f55f24be3056a5",
24
+ "gitHead": "84bf8bcfeeaf3a05086e24cef00507ca209ac3c5",
25
25
  "keywords": [
26
26
  "Workflow"
27
27
  ]