@nocobase/plugin-workflow-delay 1.7.0-beta.3 → 1.7.0-beta.30

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,11 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- import { Instruction } from '@nocobase/plugin-workflow/client';
11
- declare function Duration({ value, onChange }: {
12
- value?: number;
13
- onChange: any;
14
- }): React.JSX.Element;
10
+ import { Instruction, WorkflowVariableInput } from '@nocobase/plugin-workflow/client';
15
11
  export default class extends Instruction {
16
12
  title: string;
17
13
  type: string;
@@ -24,8 +20,41 @@ export default class extends Instruction {
24
20
  title: string;
25
21
  'x-decorator': string;
26
22
  'x-component': string;
27
- default: number;
28
23
  required: boolean;
24
+ properties: {
25
+ unit: {
26
+ type: string;
27
+ 'x-decorator': string;
28
+ 'x-component': string;
29
+ 'x-component-props': {
30
+ placeholder: string;
31
+ className: string;
32
+ allowClear: boolean;
33
+ };
34
+ enum: {
35
+ value: number;
36
+ label: string;
37
+ }[];
38
+ default: number;
39
+ };
40
+ duration: {
41
+ type: string;
42
+ 'x-decorator': string;
43
+ 'x-component': string;
44
+ 'x-component-props': {
45
+ placeholder: string;
46
+ useTypedConstant: (string | {
47
+ min: number;
48
+ })[][];
49
+ nullable: boolean;
50
+ parseOptions: {
51
+ defaultTypeOnNull: string;
52
+ };
53
+ };
54
+ default: number;
55
+ required: boolean;
56
+ };
57
+ };
29
58
  };
30
59
  endStatus: {
31
60
  type: string;
@@ -41,7 +70,10 @@ export default class extends Instruction {
41
70
  };
42
71
  };
43
72
  components: {
44
- Duration: typeof Duration;
73
+ WorkflowVariableInput: typeof WorkflowVariableInput;
74
+ Space: React.ForwardRefExoticComponent<import("antd").SpaceProps & React.RefAttributes<HTMLDivElement>> & {
75
+ Compact: React.FC<import("antd/es/space/Compact").SpaceCompactProps>;
76
+ };
45
77
  };
46
78
  isAvailable({ engine, workflow, upstream, branchIndex }: {
47
79
  engine: any;
@@ -50,4 +82,3 @@ export default class extends Instruction {
50
82
  branchIndex: any;
51
83
  }): boolean;
52
84
  }
53
- export {};
@@ -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("antd"),require("react-i18next"),require("@ant-design/icons"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-delay",["antd","react-i18next","@ant-design/icons","@nocobase/client","@nocobase/plugin-workflow/client","react"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-delay"]=t(require("antd"),require("react-i18next"),require("@ant-design/icons"),require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react")):e["@nocobase/plugin-workflow-delay"]=t(e.antd,e["react-i18next"],e["@ant-design/icons"],e["@nocobase/client"],e["@nocobase/plugin-workflow/client"],e.react)}(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=r},433:function(e){e.exports=o},721:function(t){t.exports=e},156:function(e){e.exports=u},238:function(e){e.exports=t}},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={};c.r(l),c.d(l,{default:function(){return C}});var f=c("772"),s=c("156"),p=c.n(s),b=c("721"),d=c("482"),y=c("433");c("238");var v="workflow-delay";function h(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)}}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function x(){var e,t,n=(e=["\n display: flex;\n gap: 0.5em;\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return x=function(){return n},n}var S=[{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\" })}}"}];function k(e){var t,n=e.value,r=void 0===n?6e4:n,o=e.onChange,u=(0,f.useCompile)();var i=(t=r,S.slice().reverse().find(function(e){return!(t%e.value)})),a=Math.round(r/i.value);return p().createElement("fieldset",{className:(0,f.css)(x())},p().createElement(b.InputNumber,{min:1,value:a,onChange:function(e){return o(Math.round(e*i.value))},className:"auto-width"}),p().createElement(b.Select,{role:"button","data-testid":"select-time-unit",popupMatchSelectWidth:!1,value:i.value,onChange:function(e){return o(Math.round(a*e))},className:"auto-width",options:S.map(function(e){return{value:e.value,label:u(e.label)}})}))}var j=function(e){var t,n,r;function o(){var e,t,n,r;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=m(n),w(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,O()?Reflect.construct(n,r||[],m(t).constructor):n.apply(t,r)),"title",'{{t("Delay", { ns: "'.concat(v,'" })}}')),w(e,"type","delay"),w(e,"group","control"),w(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(v,'" })}}')),w(e,"icon",p().createElement(d.HourglassOutlined,{style:{}})),w(e,"fieldset",{duration:{type:"number",title:'{{t("Duration", { ns: "'.concat(v,'" })}}'),"x-decorator":"FormItem","x-component":"Duration",default:6e4,required:!0},endStatus:{type:"number",title:'{{t("End status", { ns: "'.concat(v,'" })}}'),"x-decorator":"FormItem","x-component":"Radio.Group",enum:[{label:'{{t("Succeed and continue", { ns: "'.concat(v,'" })}}'),value:y.JOB_STATUS.RESOLVED},{label:'{{t("Fail and exit", { ns: "'.concat(v,'" })}}'),value:y.JOB_STATUS.FAILED}],required:!0,default:y.JOB_STATUS.RESOLVED}}),w(e,"components",{Duration:k}),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&&g(e,t)}(o,e),t=o,n=[{key:"isAvailable",value:function(e){var t=e.engine,n=e.workflow;return e.upstream,e.branchIndex,!t.isWorkflowSync(n)}}],h(t.prototype,n),o}(y.Instruction);function _(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 P(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var u=e.apply(t,n);function i(e){_(u,r,o,i,a,"next",e)}function a(e){_(u,r,o,i,a,"throw",e)}i(void 0)})}}function E(e,t,n){return(E=D()?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 q(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)}}function T(e){return(T=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 R(e){var t="function"==typeof Map?new Map:void 0;return(R=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).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(e,arguments,T(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),M(r,e)})(e)}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}function B(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){return function(u){if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=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(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}var C=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=T(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,n||[],T(e).constructor):t.apply(e,n))}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&&M(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return P(function(){return B(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return P(function(){return B(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return P(function(){return B(this,function(t){return e.app.pm.get("workflow").registerInstruction("delay",j),[2]})})()}}],q(t.prototype,n),o}(R(f.Plugin));return l}()});
10
+ !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}()});
@@ -9,10 +9,10 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "antd": "5.12.8",
12
+ "antd": "5.24.2",
13
13
  "@ant-design/icons": "5.6.1",
14
- "@nocobase/client": "1.7.0-beta.3",
15
- "@nocobase/plugin-workflow": "1.7.0-beta.3",
14
+ "@nocobase/plugin-workflow": "1.7.0-beta.30",
15
+ "@nocobase/client": "1.7.0-beta.30",
16
16
  "react-i18next": "11.18.6",
17
- "@nocobase/server": "1.7.0-beta.3"
17
+ "@nocobase/server": "1.7.0-beta.30"
18
18
  };
@@ -1,9 +1,9 @@
1
1
  {
2
- "Delay": "Delay",
3
- "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.": "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.",
4
- "Duration": "Duration",
5
- "End status": "End status",
6
- "Select status": "Select status",
7
- "Succeed and continue": "Succeed and continue",
8
- "Fail and exit": "Fail and exit"
9
- }
2
+ "Delay": "Vertraging",
3
+ "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.": "Wacht een periode en ga dan verder of beëindig het proces. Kan worden gebruikt om wachttijden of time-outs in parallelle takken in te stellen.",
4
+ "Duration": "Duur",
5
+ "End status": "Eindstatus",
6
+ "Select status": "Selecteer status",
7
+ "Succeed and continue": "Succes en ga verder",
8
+ "Fail and exit": "Mislukt en stop"
9
+ }
@@ -2,6 +2,7 @@
2
2
  "Delay": "延时",
3
3
  "Delay a period of time and then continue or exit the process. Can be used to set wait or timeout times in parallel branches.": "延时一段时间,然后继续或退出流程。可以用于并行分支中等待其他分支或设置超时时间。",
4
4
  "Duration": "时长",
5
+ "Unit": "单位",
5
6
  "End status": "到时状态",
6
7
  "Select status": "选择状态",
7
8
  "Succeed and continue": "通过并继续",
@@ -76,7 +76,7 @@ class DelayInstruction_default extends import_plugin_workflow.Instruction {
76
76
  schedule(job) {
77
77
  const now = /* @__PURE__ */ new Date();
78
78
  const createdAt = Date.parse(job.createdAt);
79
- const delay = createdAt + job.node.config.duration - now.getTime();
79
+ const delay = createdAt + job.result - now.getTime();
80
80
  if (delay > 0) {
81
81
  const trigger = this.trigger.bind(this, job);
82
82
  this.timers.set(job.id, setTimeout(trigger, delay));
@@ -96,16 +96,17 @@ class DelayInstruction_default extends import_plugin_workflow.Instruction {
96
96
  }
97
97
  }
98
98
  async run(node, prevJob, processor) {
99
+ const duration = processor.getParsedValue(node.config.duration || 1, node.id) * (node.config.unit || 1e3);
99
100
  const job = await processor.saveJob({
100
101
  status: import_plugin_workflow.JOB_STATUS.PENDING,
101
- result: null,
102
+ result: duration,
102
103
  nodeId: node.id,
103
104
  nodeKey: node.key,
104
105
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
105
106
  });
106
107
  job.node = node;
107
108
  this.schedule(job);
108
- return processor.exit();
109
+ return null;
109
110
  }
110
111
  async resume(node, prevJob, processor) {
111
112
  const { endStatus } = node.config;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Migration } from '@nocobase/server';
10
+ export default class extends Migration {
11
+ appVersion: string;
12
+ up(): Promise<void>;
13
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var add_duration_unit_exports = {};
28
+ __export(add_duration_unit_exports, {
29
+ default: () => add_duration_unit_default
30
+ });
31
+ module.exports = __toCommonJS(add_duration_unit_exports);
32
+ var import_server = require("@nocobase/server");
33
+ const UnitOptions = [6048e5, 864e5, 36e5, 6e4, 1e3];
34
+ function getNumberOption(v) {
35
+ return UnitOptions.find((item) => !(v % item));
36
+ }
37
+ class add_duration_unit_default extends import_server.Migration {
38
+ appVersion = "<1.7.0";
39
+ async up() {
40
+ const { db } = this.context;
41
+ const NodeRepo = db.getRepository("flow_nodes");
42
+ await db.sequelize.transaction(async (transaction) => {
43
+ const nodes = await NodeRepo.find({
44
+ filter: {
45
+ type: "delay"
46
+ },
47
+ transaction
48
+ });
49
+ await nodes.reduce(
50
+ (promise, node) => promise.then(async () => {
51
+ if (node.config.unit) {
52
+ return;
53
+ }
54
+ if (!node.config.duration) {
55
+ return;
56
+ }
57
+ const unit = getNumberOption(node.config.duration);
58
+ const duration = node.config.duration / unit;
59
+ node.set("config", { ...node.config, duration, unit });
60
+ node.changed("config", true);
61
+ await node.save({
62
+ silent: true,
63
+ transaction
64
+ });
65
+ }),
66
+ Promise.resolve()
67
+ );
68
+ });
69
+ }
70
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:延时节点",
5
5
  "description": "Could be used in workflow parallel branch for waiting other branches.",
6
6
  "description.zh-CN": "可用于工作流并行分支中等待其他分支执行完成。",
7
- "version": "1.7.0-beta.3",
7
+ "version": "1.7.0-beta.30",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-delay",
@@ -21,7 +21,7 @@
21
21
  "@nocobase/server": "1.x",
22
22
  "@nocobase/test": "1.x"
23
23
  },
24
- "gitHead": "8d52cb1d366a968f87c1cd3f98f55f24be3056a5",
24
+ "gitHead": "d83e6ab1ebfb90a97e021127ee632f38869e5ea1",
25
25
  "keywords": [
26
26
  "Workflow"
27
27
  ]