@nocobase/plugin-workflow-loop 1.6.0-beta.8 → 1.7.0-alpha.1

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("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next"),require("@ant-design/icons"),require("@formily/react"),require("@nocobase/client"),require("@formily/antd-v5"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-loop",["antd","@nocobase/plugin-workflow/client","react-i18next","@ant-design/icons","@formily/react","@nocobase/client","@formily/antd-v5","react"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-loop"]=t(require("antd"),require("@nocobase/plugin-workflow/client"),require("react-i18next"),require("@ant-design/icons"),require("@formily/react"),require("@nocobase/client"),require("@formily/antd-v5"),require("react")):e["@nocobase/plugin-workflow-loop"]=t(e.antd,e["@nocobase/plugin-workflow/client"],e["react-i18next"],e["@ant-design/icons"],e["@formily/react"],e["@nocobase/client"],e["@formily/antd-v5"],e.react)}(self,function(e,t,n,r,o,i,a,l){return function(){"use strict";var c={482:function(e){e.exports=r},632:function(e){e.exports=a},505:function(e){e.exports=o},772:function(e){e.exports=i},433:function(e){e.exports=t},721:function(t){t.exports=e},156:function(e){e.exports=l},238:function(e){e.exports=n}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var f={};s.r(f),s.d(f,{default:function(){return Y}});var p=s("772"),d=s("156"),b=s.n(d),y=s("482"),m=s("721"),v=s("632"),h=s("505"),g=s("433"),w=s("238"),O="workflow-loop";function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,function(e){return(0,w.useTranslation)(O,e)}(t).t)(e)}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(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 E(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){E(e,t,n[t])})}return e}function S(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function q(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(F=function(){return!!e})()}function I(){var e=q(["\n padding-left: 4em;\n "]);return I=function(){return e},e}function W(){var e=q(["\n width: 100%;\n\n .variable {\n flex: 1;\n }\n\n .ant-input.null-value {\n width: 100%;\n }\n "]);return W=function(){return e},e}function A(e){var t=e.value,n=e.onChange,r=(0,w.useTranslation)().t,o=(0,d.useCallback)(function(e){n(S(P({},t),{checkpoint:e.target.value}))},[t,n]),i=(0,d.useCallback)(function(e){n(S(P({},t),{continueOnFalse:e.target.value}))},[t,n]),a=(0,d.useCallback)(function(e){n(S(P({},t),{calculation:e}))},[t,n]);return b().createElement(b().Fragment,null,b().createElement(m.Checkbox,{checked:!!t,onChange:function(e){n(!!e.target.checked&&{checkpoint:0,continueOnFalse:!1,calculation:{group:{type:"and",calculations:[]}}})}},r("Enable loop condition",{ns:O})),t?b().createElement(m.Card,null,b().createElement(v.FormLayout,{layout:"vertical"},b().createElement(v.FormItem,{label:r("Condition",{ns:O})},b().createElement(g.CalculationConfig,{value:t.calculation,onChange:a,useVariableHook:L})),b().createElement(v.FormItem,{label:r("When to check",{ns:O})},b().createElement(g.RadioWithTooltip,{value:t.checkpoint,onChange:o,options:[{label:r("Before each starts",{ns:O}),value:0},{label:r("After each ends",{ns:O}),value:1}]})),b().createElement(v.FormItem,{label:r("When condition is not met on item",{ns:O})},b().createElement(g.RadioWithTooltip,{value:t.continueOnFalse,onChange:i,options:[{label:r("Exit loop",{ns:O}),value:!1},{label:r("Continue on next item",{ns:O}),value:!0}]})))):null)}function R(e,t){var n,r,o,i,a=(0,p.useCompile)(),l=x("Loop target"),c=x("Loop index (starts from 0)"),u=x("Loop sequence (starts from 1)"),s=x("Loop length"),f=e.config.target;if(null==f)return null;var d=t.fieldNames,b=void 0===d?g.defaultFieldNames:d,y=t.scope,m=(E(n={key:"item"},b.value,"item"),E(n,b.label,l),n);if("string"==typeof f&&f.startsWith("{{")&&f.endsWith("}}")){var v=f.slice(2,-2).split(".").map(function(e){return e.trim()});m=Object.assign({},function(e,t){for(var n=e,r=null,o=0;o<t.length;o++){var i=function(e){var o=t[e],i=n.find(function(e){return e.value===o});if(!i)return{v:null};r=i,!i.isLeaf&&i.loadChildren&&i.loadChildren(i),i.children&&(n=i.children)}(o);if("object"===_(i))return i.v}return r}(null!=y?y:[g.scopeOptions,g.nodesOptions,g.triggerOptions].map(function(n){var r,o=n.useOptions(S(P({},t),{current:e})).filter(Boolean);return E(r={},b.label,a(n.label)),E(r,b.value,n.value),E(r,"key",n.value),E(r,b.children,o),E(r,"disabled",o&&!o.length),r}),v),m)}return[m,(E(r={key:"index"},b.value,"index"),E(r,b.label,c),r),(E(o={key:"sequence"},b.value,"sequence"),E(o,b.label,u),o),(E(i={key:"length"},b.value,"length"),E(i,b.label,s),i)]}function L(){var e,t,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=(0,h.useForm)().values,i=(0,g.useNodeContext)(),a=S(P({},i),{config:S(P({},i.config),{target:o.target})}),l=(0,g.useWorkflowVariableOptions)(r),c=R(a,S(P({},r),{scope:l.filter(function(e){return["$scopes","$jobsMapByNodeKey","$context"].includes(e.key)})})),u=r.fieldNames,s=void 0===u?g.defaultFieldNames:u;if(!c)return l;var f=l.find(function(e){return"$scopes"===e[s.value]});return f&&(!f[s.children]&&(f[s.children]=[]),f[s.children].unshift((E(n={key:i.key},s.value,i.key),E(n,s.label,null!==(t=i.title)&&void 0!==t?t:"#".concat(i.id)),E(n,s.children,c),n)),f.disabled=!1),function(e){if(Array.isArray(e))return k(e)}(e=l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return k(e,t)}}(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 N(e){var t=e.variableOptions,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}(e,["variableOptions"]),r=L(t);return b().createElement(p.Variable.TextArea,P({scope:r},n))}var V=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=C(n),E(e=function(e,t){return t&&("object"===_(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,F()?Reflect.construct(n,r||[],C(t).constructor):n.apply(t,r)),"title",'{{t("Loop", { ns: "'.concat(O,'" })}}')),E(e,"type","loop"),E(e,"group","control"),E(e,"description",'{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "'.concat(O,'" })}}')),E(e,"icon",b().createElement(y.RollbackOutlined,{style:{}})),E(e,"fieldset",{target:{type:"string",title:'{{t("Loop target", { ns: "'.concat(O,'" })}}'),description:'{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,nullable:!1,useTypedConstant:["string",["number",{step:1,min:0,precision:0}]],className:(0,p.css)(W())},required:!0,default:1,"x-reactions":[{target:"calculation",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"expression",effects:["onFieldValueChange"],fulfill:{state:{value:""}}}]},condition:{type:"boolean","x-decorator":"FormItem","x-component":"LoopCondition","x-reactions":[{dependencies:["target"],fulfill:{state:{visible:"{{Boolean($deps[0])}}"}}}],default:!1},exit:{type:"number",title:'{{t("When node inside loop failed", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Exit workflow", { ns: "'.concat(O,'" })}}'),value:0},{label:'{{t("Exit loop and continue workflow", { ns: "'.concat(O,'" })}}'),value:1},{label:'{{t("Continue loop on next item", { ns: "'.concat(O,'" })}}'),value:2}]},default:0}}),E(e,"branching",!0),E(e,"scope",{renderEngineReference:g.renderEngineReference}),E(e,"components",{LoopCondition:A,WorkflowVariableInput:g.WorkflowVariableInput,WorkflowVariableTextArea:g.WorkflowVariableTextArea,LoopVariableTextArea:N,RadioWithTooltip:g.RadioWithTooltip,CalculationConfig:g.CalculationConfig}),E(e,"useScopeVariables",R),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&&T(e,t)}(o,e),t=o,n=[{key:"Component",value:function(e){var t,n=e.data,r=(0,g.useFlowContext)().nodes,o=(0,g.useStyles)().styles,i=r.find(function(e){return e.upstreamId===n.id&&null!=e.branchIndex});return b().createElement(g.NodeDefaultView,{data:n},b().createElement("div",{className:o.nodeSubtreeClass},b().createElement("div",{className:(0,p.cx)(o.branchBlockClass,(0,p.css)(I()))},b().createElement(g.Branch,{from:n,entry:i,branchIndex:null!==(t=null==i?void 0:i.branchIndex)&&void 0!==t?t:0}),b().createElement("div",{className:o.branchClass,style:{minWidth:"4em"}},b().createElement("div",{className:"workflow-branch-lines"}),b().createElement("div",{className:o.loopLineClass},b().createElement(y.ArrowUpOutlined,null))))))}}],j(t.prototype,n),o}(g.Instruction);function B(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function M(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){B(i,r,o,a,l,"next",e)}function l(e){B(i,r,o,a,l,"throw",e)}a(void 0)})}}function $(e,t,n){return($=G()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&H(o,n.prototype),o}).apply(null,arguments)}function D(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 z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function H(e,t){return(H=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function U(e){var t="function"==typeof Map?new Map:void 0;return(U=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,arguments,z(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),H(r,e)})(e)}function G(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(G=function(){return!!e})()}function K(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var Y=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=z(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,G()?Reflect.construct(t,n||[],z(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&&H(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return M(function(){return K(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return M(function(){return K(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return M(function(){return K(this,function(t){return e.app.pm.get("workflow").registerInstruction("loop",V),[2]})})()}}],D(t.prototype,n),o}(U(p.Plugin));return f}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("antd"),require("@nocobase/plugin-workflow/client"),require("@ant-design/icons"),require("@formily/react"),require("react-i18next"),require("@nocobase/client"),require("@formily/antd-v5"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-workflow-loop",["antd","@nocobase/plugin-workflow/client","@ant-design/icons","@formily/react","react-i18next","@nocobase/client","@formily/antd-v5","react"],t):"object"==typeof exports?exports["@nocobase/plugin-workflow-loop"]=t(require("antd"),require("@nocobase/plugin-workflow/client"),require("@ant-design/icons"),require("@formily/react"),require("react-i18next"),require("@nocobase/client"),require("@formily/antd-v5"),require("react")):e["@nocobase/plugin-workflow-loop"]=t(e.antd,e["@nocobase/plugin-workflow/client"],e["@ant-design/icons"],e["@formily/react"],e["react-i18next"],e["@nocobase/client"],e["@formily/antd-v5"],e.react)}(self,function(e,t,n,r,o,i,a,l){return function(){"use strict";var c={482:function(e){e.exports=n},632:function(e){e.exports=a},505:function(e){e.exports=r},772:function(e){e.exports=i},433:function(e){e.exports=t},721:function(t){t.exports=e},156:function(e){e.exports=l},238:function(e){e.exports=o}},u={};function s(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e](n,n.exports,s),n.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var f={};s.r(f),s.d(f,{default:function(){return Y}});var p=s("772"),d=s("156"),b=s.n(d),y=s("482"),m=s("721"),v=s("632"),h=s("505"),g=s("433"),w=s("238"),O="workflow-loop";function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,function(e){return(0,w.useTranslation)(O,e)}(t).t)(e)}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(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 E(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){E(e,t,n[t])})}return e}function S(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function q(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(F=function(){return!!e})()}function I(){var e=q(["\n padding-left: 4em;\n "]);return I=function(){return e},e}function W(){var e=q(["\n width: 100%;\n\n .variable {\n flex: 1;\n }\n\n .ant-input.null-value {\n width: 100%;\n }\n "]);return W=function(){return e},e}function A(e){var t=e.value,n=e.onChange,r=(0,w.useTranslation)().t,o=(0,d.useCallback)(function(e){n(S(P({},t),{checkpoint:e.target.value}))},[t,n]),i=(0,d.useCallback)(function(e){n(S(P({},t),{continueOnFalse:e.target.value}))},[t,n]),a=(0,d.useCallback)(function(e){n(S(P({},t),{calculation:e}))},[t,n]);return b().createElement(b().Fragment,null,b().createElement(m.Checkbox,{checked:!!t,onChange:function(e){n(!!e.target.checked&&{checkpoint:0,continueOnFalse:!1,calculation:{group:{type:"and",calculations:[]}}})}},r("Enable loop condition",{ns:O})),t?b().createElement(m.Card,null,b().createElement(v.FormLayout,{layout:"vertical"},b().createElement(v.FormItem,{label:r("Condition",{ns:O})},b().createElement(g.CalculationConfig,{value:t.calculation,onChange:a,useVariableHook:L})),b().createElement(v.FormItem,{label:r("When to check",{ns:O})},b().createElement(g.RadioWithTooltip,{value:t.checkpoint,onChange:o,options:[{label:r("Before each starts",{ns:O}),value:0},{label:r("After each ends",{ns:O}),value:1}]})),b().createElement(v.FormItem,{label:r("When condition is not met on item",{ns:O})},b().createElement(g.RadioWithTooltip,{value:t.continueOnFalse,onChange:i,options:[{label:r("Exit loop",{ns:O}),value:!1},{label:r("Continue on next item",{ns:O}),value:!0}]})))):null)}function R(e,t){var n,r,o,i,a=(0,p.useCompile)(),l=x("Loop target"),c=x("Loop index (starts from 0)"),u=x("Loop sequence (starts from 1)"),s=x("Loop length"),f=e.config.target;if(null==f)return null;var d=t.fieldNames,b=void 0===d?g.defaultFieldNames:d,y=t.scope,m=(E(n={key:"item"},b.value,"item"),E(n,b.label,l),n);if("string"==typeof f&&f.startsWith("{{")&&f.endsWith("}}")){var v=f.slice(2,-2).split(".").map(function(e){return e.trim()});m=Object.assign({},function(e,t){for(var n=e,r=null,o=0;o<t.length;o++){var i=function(e){var o=t[e],i=n.find(function(e){return e.value===o});if(!i)return{v:null};r=i,!i.isLeaf&&i.loadChildren&&i.loadChildren(i),i.children&&(n=i.children)}(o);if("object"===_(i))return i.v}return r}(null!=y?y:[g.scopeOptions,g.nodesOptions,g.triggerOptions].map(function(n){var r,o=n.useOptions(S(P({},t),{current:e})).filter(Boolean);return E(r={},b.label,a(n.label)),E(r,b.value,n.value),E(r,"key",n.value),E(r,b.children,o),E(r,"disabled",o&&!o.length),r}),v),m)}return[m,(E(r={key:"index"},b.value,"index"),E(r,b.label,c),r),(E(o={key:"sequence"},b.value,"sequence"),E(o,b.label,u),o),(E(i={key:"length"},b.value,"length"),E(i,b.label,s),i)]}function L(){var e,t,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=(0,h.useForm)().values,i=(0,g.useNodeContext)(),a=S(P({},i),{config:S(P({},i.config),{target:o.target})}),l=(0,g.useWorkflowVariableOptions)(r),c=R(a,S(P({},r),{scope:l.filter(function(e){return["$scopes","$jobsMapByNodeKey","$context"].includes(e.key)})})),u=r.fieldNames,s=void 0===u?g.defaultFieldNames:u;if(!c)return l;var f=l.find(function(e){return"$scopes"===e[s.value]});return f&&(!f[s.children]&&(f[s.children]=[]),f[s.children].unshift((E(n={key:i.key},s.value,i.key),E(n,s.label,null!==(t=i.title)&&void 0!==t?t:"#".concat(i.id)),E(n,s.children,c),n)),f.disabled=!1),function(e){if(Array.isArray(e))return k(e)}(e=l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return k(e,t)}}(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 N(e){var t=e.variableOptions,n=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],!(t.indexOf(n)>=0)&&(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++){if(n=i[r],!(t.indexOf(n)>=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}}return o}(e,["variableOptions"]),r=L(t);return b().createElement(p.Variable.TextArea,P({scope:r},n))}var V=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=C(n),E(e=function(e,t){return t&&("object"===_(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,F()?Reflect.construct(n,r||[],C(t).constructor):n.apply(t,r)),"title",'{{t("Loop", { ns: "'.concat(O,'" })}}')),E(e,"type","loop"),E(e,"group","control"),E(e,"description",'{{t("By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.", { ns: "'.concat(O,'" })}}')),E(e,"icon",b().createElement(y.RollbackOutlined,{style:{}})),E(e,"fieldset",{target:{type:"string",title:'{{t("Loop target", { ns: "'.concat(O,'" })}}'),description:'{{t("A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,nullable:!1,useTypedConstant:["string",["number",{step:1,min:0,precision:0}]],className:(0,p.css)(W())},required:!0,default:1,"x-reactions":[{target:"calculation",effects:["onFieldValueChange"],fulfill:{state:{value:null}}},{target:"expression",effects:["onFieldValueChange"],fulfill:{state:{value:""}}}]},condition:{type:"boolean","x-decorator":"FormItem","x-component":"LoopCondition","x-reactions":[{dependencies:["target"],fulfill:{state:{visible:"{{Boolean($deps[0])}}"}}}],default:!1},exit:{type:"number",title:'{{t("When node inside loop failed", { ns: "'.concat(O,'" })}}'),"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:'{{t("Exit workflow", { ns: "'.concat(O,'" })}}'),value:0},{label:'{{t("Exit loop and continue workflow", { ns: "'.concat(O,'" })}}'),value:1},{label:'{{t("Continue loop on next item", { ns: "'.concat(O,'" })}}'),value:2}]},default:0}}),E(e,"branching",!0),E(e,"scope",{renderEngineReference:g.renderEngineReference}),E(e,"components",{LoopCondition:A,WorkflowVariableInput:g.WorkflowVariableInput,WorkflowVariableTextArea:g.WorkflowVariableTextArea,LoopVariableTextArea:N,RadioWithTooltip:g.RadioWithTooltip,CalculationConfig:g.CalculationConfig}),E(e,"useScopeVariables",R),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&&T(e,t)}(o,e),t=o,n=[{key:"Component",value:function(e){var t,n=e.data,r=(0,g.useFlowContext)().nodes,o=(0,g.useStyles)().styles,i=r.find(function(e){return e.upstreamId===n.id&&null!=e.branchIndex});return b().createElement(g.NodeDefaultView,{data:n},b().createElement("div",{className:o.nodeSubtreeClass},b().createElement("div",{className:(0,p.cx)(o.branchBlockClass,(0,p.css)(I()))},b().createElement(g.Branch,{from:n,entry:i,branchIndex:null!==(t=null==i?void 0:i.branchIndex)&&void 0!==t?t:0}),b().createElement("div",{className:o.branchClass,style:{minWidth:"4em"}},b().createElement("div",{className:"workflow-branch-lines"}),b().createElement("div",{className:o.loopLineClass},b().createElement(y.ArrowUpOutlined,null))))))}}],j(t.prototype,n),o}(g.Instruction);function B(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function M(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){B(i,r,o,a,l,"next",e)}function l(e){B(i,r,o,a,l,"throw",e)}a(void 0)})}}function $(e,t,n){return($=G()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&H(o,n.prototype),o}).apply(null,arguments)}function D(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 z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function H(e,t){return(H=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function U(e){var t="function"==typeof Map?new Map:void 0;return(U=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,arguments,z(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),H(r,e)})(e)}function G(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(G=function(){return!!e})()}function K(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}var Y=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=z(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,G()?Reflect.construct(t,n||[],z(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&&H(e,t)}(o,e),t=o,n=[{key:"afterAdd",value:function(){return M(function(){return K(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return M(function(){return K(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return M(function(){return K(this,function(t){return e.app.pm.get("workflow").registerInstruction("loop",V),[2]})})()}}],D(t.prototype,n),o}(U(p.Plugin));return f}()});
@@ -9,13 +9,13 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@ant-design/icons": "5.2.6",
12
+ "@ant-design/icons": "5.6.1",
13
13
  "antd": "5.12.8",
14
14
  "@formily/antd-v5": "1.1.9",
15
15
  "@formily/react": "2.3.0",
16
- "@nocobase/client": "1.6.0-beta.8",
17
- "@nocobase/plugin-workflow": "1.6.0-beta.8",
16
+ "@nocobase/client": "1.7.0-alpha.1",
17
+ "@nocobase/plugin-workflow": "1.7.0-alpha.1",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/evaluators": "1.6.0-beta.8",
20
- "@nocobase/server": "1.6.0-beta.8"
19
+ "@nocobase/evaluators": "1.7.0-alpha.1",
20
+ "@nocobase/server": "1.7.0-alpha.1"
21
21
  };
@@ -0,0 +1,9 @@
1
+ {
2
+ "Loop": "Ciclo",
3
+ "Loop target": "Destinazione ciclo",
4
+ "Loop index": "Indice ciclo",
5
+ "Loop length": "Lunghezza ciclo",
6
+ "By using a loop node, you can perform the same operation on multiple sets of data. The source of these sets can be either multiple records from a query node or multiple associated records of a single record. Loop node can also be used for iterating a certain number of times or for looping through each character in a string. However, excessive looping may cause performance issues, so use with caution.": "Utilizzando un nodo ciclo, puoi eseguire la stessa operazione su più insiemi di dati. L' origine di questi insiemi può essere costituita da record multipli di un nodo query o da record multipli associati di singolo record. Il nodo ciclo può essere utilizzato anche per iterare un certo numero di volte o per scorrere ogni carattere in una stringa. Tuttavia, un numero eccessivamente elevato di cicli può causare problemi di prestazioni, quindi usalo con cautela.",
7
+ "Scope variables": "Variabili ambito",
8
+ "A single number will be treated as a loop count, a single string will be treated as an array of characters, and other non-array values will be converted to arrays. The loop node ends when the loop count is reached, or when the array loop is completed. You can also add condition nodes to the loop to terminate it.": "Un singolo numero verrà trattato come conteggio del ciclo, una singola stringa verrà trattata come un array di caratteri e altri valori non-array verranno convertiti in array. Il nodo ciclo termina quando viene raggiunto il conteggio del ciclo o quando il ciclo dell'array è completato. Puoi anche aggiungere nodi condizione al ciclo per terminarlo."
9
+ }
@@ -101,7 +101,11 @@ class LoopInstruction_default extends import_plugin_workflow.Instruction {
101
101
  const [branch] = processor.getBranches(node);
102
102
  const { result, status } = job;
103
103
  if (status !== import_plugin_workflow.JOB_STATUS.PENDING) {
104
- return processor.exit();
104
+ processor.logger.warn(`loop (${job.nodeId}) has been done, ignore newly resumed event`);
105
+ return null;
106
+ }
107
+ if (branchJob.id !== job.id && branchJob.status === import_plugin_workflow.JOB_STATUS.PENDING) {
108
+ return null;
105
109
  }
106
110
  const nextIndex = result.looped + 1;
107
111
  const target = processor.getParsedValue(loop.config.target, node.id);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:循环节点",
5
5
  "description": "Used to repeat the sub-process processing of each value in an array, and can also be used for fixed times of sub-process processing.",
6
6
  "description.zh-CN": "用于对一个数组中的每个值进行重复的子流程处理,也可用于固定次数的重复子流程处理。",
7
- "version": "1.6.0-beta.8",
7
+ "version": "1.7.0-alpha.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-loop",
@@ -22,7 +22,7 @@
22
22
  "@nocobase/server": "1.x",
23
23
  "@nocobase/test": "1.x"
24
24
  },
25
- "gitHead": "2257b50e1cf0b2a2873673a630e5ecc80ec2e01a",
25
+ "gitHead": "e411c9728b4d1f16b0beac16e40dd3499352b052",
26
26
  "keywords": [
27
27
  "Workflow"
28
28
  ]