UNPKG

@nocobase/plugin-workflow-delay

Version:

Could be used in workflow parallel branch for waiting other branches.

10 lines (9 loc) 8.97 kB
/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-delay",["react","@nocobase/client","@ant-design/icons","antd","@nocobase/plugin-workflow/client","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-delay"]=t(require("react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):e["@nocobase/plugin-workflow-delay"]=t(e.react,e["@nocobase/client"],e["@ant-design/icons"],e.antd,e["@nocobase/plugin-workflow/client"],e["react-i18next"])}(self,function(e,t,n,r,o,u){return function(){"use strict";var i={482:function(e){e.exports=n},772:function(e){e.exports=t},433:function(e){e.exports=o},721:function(e){e.exports=r},156:function(t){t.exports=e},238:function(e){e.exports=u}},a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return i[e](n,n.exports,c),n.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 n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.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(){c.r(l),c.d(l,{default:function(){return S}});var e=c(772),t=c(156),n=c.n(t),r=c(721),o=c(482),u=c(433);c(238);var i="workflow-delay";function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}var b=[{value:1e3,label:"{{t('Seconds', { ns: \"workflow\" })}}"},{value:6e4,label:"{{t('Minutes', { ns: \"workflow\" })}}"},{value:36e5,label:"{{t('Hours', { ns: \"workflow\" })}}"},{value:864e5,label:"{{t('Days', { ns: \"workflow\" })}}"},{value:6048e5,label:"{{t('Weeks', { ns: \"workflow\" })}}"}],y=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function c(){var e,t,l;if(!(this instanceof c))throw TypeError("Cannot call a class as a function");return t=c,l=arguments,t=f(t),a(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"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(t,l||[],f(this).constructor):t.apply(this,l)),"title",'{{t("Delay", { ns: "'.concat(i,'" })}}')),a(e,"type","delay"),a(e,"group","control"),a(e,"description",'{{t("Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.", { ns: "'.concat(i,'" })}}')),a(e,"icon",n().createElement(o.HourglassOutlined,{style:{}})),a(e,"fieldset",{duration:{type:"void",title:'{{t("Duration", { ns: "'.concat(i,'" })}}'),"x-decorator":"FormItem","x-component":"Space.Compact",required:!0,properties:{unit:{type:"number","x-decorator":"FormItem","x-component":"Select","x-component-props":{placeholder:'{{t("Unit", { ns: "'.concat(i,'" })}}'),className:"auto-width",allowClear:!1},enum:b,default:6e4},duration:{type:"number","x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{placeholder:'{{t("Duration", { ns: "'.concat(i,'" })}}'),useTypedConstant:[["number",{min:1}]],nullable:!1,parseOptions:{defaultTypeOnNull:"number"}},default:1,required:!0}}},endStatus:{type:"number",title:'{{t("End status", { ns: "'.concat(i,'" })}}'),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:'{{t("Succeed and continue", { ns: "'.concat(i,'" })}}'),value:u.JOB_STATUS.RESOLVED},{label:'{{t("Fail and exit", { ns: "'.concat(i,'" })}}'),value:u.JOB_STATUS.FAILED}],required:!0,default:u.JOB_STATUS.RESOLVED}}),a(e,"components",{WorkflowVariableInput:u.WorkflowVariableInput,Space:r.Space}),e}return c.prototype=Object.create(e&&e.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),e&&s(c,e),t=[{key:"isAvailable",value:function(e){var t=e.engine,n=e.workflow;return e.upstream,e.branchIndex,!t.isWorkflowSync(n)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(c.prototype,t),c}(u.Instruction);function d(e,t,n,r,o,u,i){try{var a=e[u](i),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var u=e.apply(t,n);function i(e){d(u,r,o,i,a,"next",e)}function a(e){d(u,r,o,i,a,"throw",e)}i(void 0)})}}function w(e,t,n){return(w=x()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&m(o,n.prototype),o}).apply(null,arguments)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){var t="function"==typeof Map?new Map:void 0;return(g=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,n)}function n(){return w(e,arguments,h(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)})(e)}function x(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(x=function(){return!!e})()}function O(e,t){var n,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(u){return function(a){var c=[u,a];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var S=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=h(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,x()?Reflect.construct(e,t||[],h(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&m(n,e),t=[{key:"afterAdd",value:function(){return v(function(){return O(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return v(function(){return O(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return v(function(){return O(this,function(t){return e.app.pm.get("workflow").registerInstruction("delay",y),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(g(e.Plugin))}(),l}()});