@nocobase/plugin-workflow-loop 1.4.0-alpha.6 → 1.4.0-alpha.7

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.
package/README.md CHANGED
@@ -1,9 +1,30 @@
1
- # workflow
1
+ # NocoBase
2
2
 
3
- English | [中文](./README.zh-CN.md)
3
+ <video width="100%" controls>
4
+ <source src="https://static-docs.nocobase.com/NocoBase0510.mp4" type="video/mp4">
5
+ </video>
4
6
 
5
- ## 安装激活
6
7
 
7
- 内置插件无需手动安装激活。
8
+ ## What is NocoBase
8
9
 
9
- ## 使用方法
10
+ NocoBase is a scalability-first, open-source no-code development platform.
11
+ Instead of investing years of time and millions of dollars in research and development, deploy NocoBase in a few minutes and you'll have a private, controllable, and extremely scalable no-code development platform!
12
+
13
+ Homepage:
14
+ https://www.nocobase.com/
15
+
16
+ Online Demo:
17
+ https://demo.nocobase.com/new
18
+
19
+ Documents:
20
+ https://docs.nocobase.com/
21
+
22
+ Commericial license & plugins:
23
+ https://www.nocobase.com/en/commercial
24
+
25
+ License agreement:
26
+ https://www.nocobase.com/en/agreement
27
+
28
+
29
+ ## Contact Us:
30
+ hello@nocobase.com
@@ -80,6 +80,7 @@ export default class extends Instruction {
80
80
  default: number;
81
81
  };
82
82
  };
83
+ branching: boolean;
83
84
  scope: {
84
85
  renderEngineReference: (key: string) => React.JSX.Element;
85
86
  };
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(o,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("antd"),require("@formily/antd-v5"),require("@formily/react"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","@ant-design/icons","antd","@formily/antd-v5","@formily/react","@nocobase/plugin-workflow/client","react-i18next"],n):(o=typeof globalThis!="undefined"?globalThis:o||self,n(o["@nocobase/plugin-workflow-loop"]={},o["@nocobase/client"],o.jsxRuntime,o.react,o["@ant-design/icons"],o.antd,o["@formily/antd-v5"],o["@formily/react"],o["@nocobase/plugin-workflow"],o["react-i18next"]))})(this,function(o,n,e,d,v,L,y,C,a,w){"use strict";var U=Object.defineProperty,Y=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var q=(o,n,e)=>n in o?U(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,g=(o,n)=>{for(var e in n||(n={}))A.call(n,e)&&q(o,e,n[e]);if(F)for(var e of F(n))B.call(n,e)&&q(o,e,n[e]);return o},m=(o,n)=>Y(o,z(n));var S=(o,n)=>{var e={};for(var d in o)A.call(o,d)&&n.indexOf(d)<0&&(e[d]=o[d]);if(o!=null&&F)for(var d of F(o))n.indexOf(d)<0&&B.call(o,d)&&(e[d]=o[d]);return e};var b=(o,n,e)=>(q(o,typeof n!="symbol"?n+"":n,e),e);var O=(o,n,e)=>new Promise((d,v)=>{var L=a=>{try{C(e.next(a))}catch(w){v(w)}},y=a=>{try{C(e.throw(a))}catch(w){v(w)}},C=a=>a.done?d(a.value):Promise.resolve(a.value).then(L,y);C((e=e.apply(o,n)).next())});const c="workflow-loop";function T(s,l={}){const{t:r}=E(l);return r(s)}function E(s){return w.useTranslation(c,s)}function $(s,l){let r=s,f=null;for(let i=0;i<l.length;i++){const h=l[i],t=r.find(u=>u.value===h);if(!t)return null;f=t,!t.isLeaf&&t.loadChildren&&t.loadChildren(t),t.children&&(r=t.children)}return f}function j({value:s,onChange:l}){const{t:r}=w.useTranslation(),f=d.useCallback(t=>{l(m(g({},s),{checkpoint:t.target.value}))},[s,l]),i=d.useCallback(t=>{l(m(g({},s),{continueOnFalse:t.target.value}))},[s,l]),h=d.useCallback(t=>{l(m(g({},s),{calculation:t}))},[s,l]);return e.jsxs(e.Fragment,{children:[e.jsx(L.Checkbox,{checked:!!s,onChange:t=>{l(t.target.checked?{checkpoint:0,continueOnFalse:!1,calculation:{group:{type:"and",calculations:[]}}}:!1)},children:r("Enable loop condition",{ns:c})}),s?e.jsx(L.Card,{children:e.jsxs(y.FormLayout,{layout:"vertical",children:[e.jsx(y.FormItem,{label:r("Condition",{ns:c}),children:e.jsx(a.CalculationConfig,{value:s.calculation,onChange:h,useVariableHook:V})}),e.jsx(y.FormItem,{label:r("When to check",{ns:c}),children:e.jsx(a.RadioWithTooltip,{value:s.checkpoint,onChange:f,options:[{label:r("Before each starts",{ns:c}),value:0},{label:r("After each ends",{ns:c}),value:1}]})}),e.jsx(y.FormItem,{label:r("When condition is not met on item",{ns:c}),children:e.jsx(a.RadioWithTooltip,{value:s.continueOnFalse,onChange:i,options:[{label:r("Exit loop",{ns:c}),value:!1},{label:r("Continue on next item",{ns:c}),value:!0}]})})]})}):null]})}function N(s,l){const r=n.useCompile(),f=T("Loop target"),i=T("Loop index (starts from 0)"),h=T("Loop sequence (starts from 1)"),t=T("Loop length"),{target:u}=s.config;if(u==null)return null;const{fieldNames:p=a.defaultFieldNames,scope:x}=l;let I={key:"item",[p.value]:"item",[p.label]:f};if(typeof u=="string"&&u.startsWith("{{")&&u.endsWith("}}")){const _=u.slice(2,-2).split(".").map(k=>k.trim()),D=x!=null?x:[a.scopeOptions,a.nodesOptions,a.triggerOptions].map(k=>{const W=k.useOptions(m(g({},l),{current:s})).filter(Boolean);return{[p.label]:r(k.label),[p.value]:k.value,key:k.value,[p.children]:W,disabled:W&&!W.length}}),K=$(D,_);I=Object.assign({},K,I)}return[I,{key:"index",[p.value]:"index",[p.label]:i},{key:"sequence",[p.value]:"sequence",[p.label]:h},{key:"length",[p.value]:"length",[p.label]:t}]}function V(s={}){var p;const{values:l}=C.useForm(),r=a.useNodeContext(),f=m(g({},r),{config:m(g({},r.config),{target:l.target})}),i=a.useWorkflowVariableOptions(s),h=N(f,m(g({},s),{scope:i.filter(x=>["$scopes","$jobsMapByNodeKey","$context"].includes(x.key))})),{fieldNames:t=a.defaultFieldNames}=s;if(!h)return i;const u=i.find(x=>x[t.value]==="$scopes");return u&&(u[t.children]||(u[t.children]=[]),u[t.children].unshift({key:r.key,[t.value]:r.key,[t.label]:(p=r.title)!=null?p:`#${r.id}`,[t.children]:h}),u.disabled=!1),[...i]}function M(r){var f=r,{variableOptions:s}=f,l=S(f,["variableOptions"]);const i=V(s);return e.jsx(n.Variable.TextArea,g({scope:i},l))}class P extends a.Instruction{constructor(){super(...arguments);b(this,"title",`{{t("Loop", { ns: "${c}" })}}`);b(this,"type","loop");b(this,"group","control");b(this,"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: "${c}" })}}`);b(this,"fieldset",{target:{type:"string",title:`{{t("Loop target", { ns: "${c}" })}}`,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: "${c}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,nullable:!1,useTypedConstant:["string",["number",{step:1,min:0,precision:0}]],className:n.css`
10
+ (function(o,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("@ant-design/icons"),require("antd"),require("@formily/antd-v5"),require("@formily/react"),require("@nocobase/plugin-workflow/client"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","@ant-design/icons","antd","@formily/antd-v5","@formily/react","@nocobase/plugin-workflow/client","react-i18next"],n):(o=typeof globalThis!="undefined"?globalThis:o||self,n(o["@nocobase/plugin-workflow-loop"]={},o["@nocobase/client"],o.jsxRuntime,o.react,o["@ant-design/icons"],o.antd,o["@formily/antd-v5"],o["@formily/react"],o["@nocobase/plugin-workflow"],o["react-i18next"]))})(this,function(o,n,e,d,v,L,y,C,a,w){"use strict";var U=Object.defineProperty,Y=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var q=(o,n,e)=>n in o?U(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,b=(o,n)=>{for(var e in n||(n={}))A.call(n,e)&&q(o,e,n[e]);if(F)for(var e of F(n))B.call(n,e)&&q(o,e,n[e]);return o},m=(o,n)=>Y(o,z(n));var S=(o,n)=>{var e={};for(var d in o)A.call(o,d)&&n.indexOf(d)<0&&(e[d]=o[d]);if(o!=null&&F)for(var d of F(o))n.indexOf(d)<0&&B.call(o,d)&&(e[d]=o[d]);return e};var g=(o,n,e)=>(q(o,typeof n!="symbol"?n+"":n,e),e);var O=(o,n,e)=>new Promise((d,v)=>{var L=a=>{try{C(e.next(a))}catch(w){v(w)}},y=a=>{try{C(e.throw(a))}catch(w){v(w)}},C=a=>a.done?d(a.value):Promise.resolve(a.value).then(L,y);C((e=e.apply(o,n)).next())});const c="workflow-loop";function T(s,l={}){const{t:r}=E(l);return r(s)}function E(s){return w.useTranslation(c,s)}function $(s,l){let r=s,f=null;for(let i=0;i<l.length;i++){const h=l[i],t=r.find(u=>u.value===h);if(!t)return null;f=t,!t.isLeaf&&t.loadChildren&&t.loadChildren(t),t.children&&(r=t.children)}return f}function j({value:s,onChange:l}){const{t:r}=w.useTranslation(),f=d.useCallback(t=>{l(m(b({},s),{checkpoint:t.target.value}))},[s,l]),i=d.useCallback(t=>{l(m(b({},s),{continueOnFalse:t.target.value}))},[s,l]),h=d.useCallback(t=>{l(m(b({},s),{calculation:t}))},[s,l]);return e.jsxs(e.Fragment,{children:[e.jsx(L.Checkbox,{checked:!!s,onChange:t=>{l(t.target.checked?{checkpoint:0,continueOnFalse:!1,calculation:{group:{type:"and",calculations:[]}}}:!1)},children:r("Enable loop condition",{ns:c})}),s?e.jsx(L.Card,{children:e.jsxs(y.FormLayout,{layout:"vertical",children:[e.jsx(y.FormItem,{label:r("Condition",{ns:c}),children:e.jsx(a.CalculationConfig,{value:s.calculation,onChange:h,useVariableHook:V})}),e.jsx(y.FormItem,{label:r("When to check",{ns:c}),children:e.jsx(a.RadioWithTooltip,{value:s.checkpoint,onChange:f,options:[{label:r("Before each starts",{ns:c}),value:0},{label:r("After each ends",{ns:c}),value:1}]})}),e.jsx(y.FormItem,{label:r("When condition is not met on item",{ns:c}),children:e.jsx(a.RadioWithTooltip,{value:s.continueOnFalse,onChange:i,options:[{label:r("Exit loop",{ns:c}),value:!1},{label:r("Continue on next item",{ns:c}),value:!0}]})})]})}):null]})}function N(s,l){const r=n.useCompile(),f=T("Loop target"),i=T("Loop index (starts from 0)"),h=T("Loop sequence (starts from 1)"),t=T("Loop length"),{target:u}=s.config;if(u==null)return null;const{fieldNames:p=a.defaultFieldNames,scope:x}=l;let I={key:"item",[p.value]:"item",[p.label]:f};if(typeof u=="string"&&u.startsWith("{{")&&u.endsWith("}}")){const _=u.slice(2,-2).split(".").map(k=>k.trim()),D=x!=null?x:[a.scopeOptions,a.nodesOptions,a.triggerOptions].map(k=>{const W=k.useOptions(m(b({},l),{current:s})).filter(Boolean);return{[p.label]:r(k.label),[p.value]:k.value,key:k.value,[p.children]:W,disabled:W&&!W.length}}),K=$(D,_);I=Object.assign({},K,I)}return[I,{key:"index",[p.value]:"index",[p.label]:i},{key:"sequence",[p.value]:"sequence",[p.label]:h},{key:"length",[p.value]:"length",[p.label]:t}]}function V(s={}){var p;const{values:l}=C.useForm(),r=a.useNodeContext(),f=m(b({},r),{config:m(b({},r.config),{target:l.target})}),i=a.useWorkflowVariableOptions(s),h=N(f,m(b({},s),{scope:i.filter(x=>["$scopes","$jobsMapByNodeKey","$context"].includes(x.key))})),{fieldNames:t=a.defaultFieldNames}=s;if(!h)return i;const u=i.find(x=>x[t.value]==="$scopes");return u&&(u[t.children]||(u[t.children]=[]),u[t.children].unshift({key:r.key,[t.value]:r.key,[t.label]:(p=r.title)!=null?p:`#${r.id}`,[t.children]:h}),u.disabled=!1),[...i]}function M(r){var f=r,{variableOptions:s}=f,l=S(f,["variableOptions"]);const i=V(s);return e.jsx(n.Variable.TextArea,b({scope:i},l))}class P extends a.Instruction{constructor(){super(...arguments);g(this,"title",`{{t("Loop", { ns: "${c}" })}}`);g(this,"type","loop");g(this,"group","control");g(this,"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: "${c}" })}}`);g(this,"fieldset",{target:{type:"string",title:`{{t("Loop target", { ns: "${c}" })}}`,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: "${c}" })}}`,"x-decorator":"FormItem","x-component":"WorkflowVariableInput","x-component-props":{changeOnSelect:!0,nullable:!1,useTypedConstant:["string",["number",{step:1,min:0,precision:0}]],className:n.css`
11
11
  width: 100%;
12
12
 
13
13
  .variable {
@@ -17,6 +17,6 @@
17
17
  .ant-input.null-value {
18
18
  width: 100%;
19
19
  }
20
- `},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: "${c}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Exit workflow", { ns: "${c}" })}}`,value:0},{label:`{{t("Exit loop and continue workflow", { ns: "${c}" })}}`,value:1},{label:`{{t("Continue loop on next item", { ns: "${c}" })}}`,value:2}]},default:0}});b(this,"scope",{renderEngineReference:a.renderEngineReference});b(this,"components",{LoopCondition:j,WorkflowVariableInput:a.WorkflowVariableInput,WorkflowVariableTextArea:a.WorkflowVariableTextArea,LoopVariableTextArea:M,RadioWithTooltip:a.RadioWithTooltip,CalculationConfig:a.CalculationConfig});b(this,"useScopeVariables",N)}Component({data:r}){var t;const{nodes:f}=a.useFlowContext(),{styles:i}=a.useStyles(),h=f.find(u=>u.upstreamId===r.id&&u.branchIndex!=null);return e.jsx(a.NodeDefaultView,{data:r,children:e.jsx("div",{className:i.nodeSubtreeClass,children:e.jsxs("div",{className:n.cx(i.branchBlockClass,n.css`
20
+ `},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: "${c}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{direction:"vertical",options:[{label:`{{t("Exit workflow", { ns: "${c}" })}}`,value:0},{label:`{{t("Exit loop and continue workflow", { ns: "${c}" })}}`,value:1},{label:`{{t("Continue loop on next item", { ns: "${c}" })}}`,value:2}]},default:0}});g(this,"branching",!0);g(this,"scope",{renderEngineReference:a.renderEngineReference});g(this,"components",{LoopCondition:j,WorkflowVariableInput:a.WorkflowVariableInput,WorkflowVariableTextArea:a.WorkflowVariableTextArea,LoopVariableTextArea:M,RadioWithTooltip:a.RadioWithTooltip,CalculationConfig:a.CalculationConfig});g(this,"useScopeVariables",N)}Component({data:r}){var t;const{nodes:f}=a.useFlowContext(),{styles:i}=a.useStyles(),h=f.find(u=>u.upstreamId===r.id&&u.branchIndex!=null);return e.jsx(a.NodeDefaultView,{data:r,children:e.jsx("div",{className:i.nodeSubtreeClass,children:e.jsxs("div",{className:n.cx(i.branchBlockClass,n.css`
21
21
  padding-left: 20em;
22
22
  `),children:[e.jsx(a.Branch,{from:r,entry:h,branchIndex:(t=h==null?void 0:h.branchIndex)!=null?t:0}),e.jsxs("div",{className:i.branchClass,children:[e.jsx("div",{className:"workflow-branch-lines"}),e.jsx("div",{className:n.cx(i.addButtonClass,i.loopLineClass),children:e.jsx(v.ArrowUpOutlined,{})})]})]})})})}}class H extends n.Plugin{afterAdd(){return O(this,null,function*(){})}beforeLoad(){return O(this,null,function*(){})}load(){return O(this,null,function*(){this.app.pm.get("workflow").registerInstruction("loop",P)})}}o.default=H,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -13,9 +13,9 @@ module.exports = {
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.4.0-alpha.6",
17
- "@nocobase/plugin-workflow": "1.4.0-alpha.6",
16
+ "@nocobase/client": "1.4.0-alpha.7",
17
+ "@nocobase/plugin-workflow": "1.4.0-alpha.7",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/evaluators": "1.4.0-alpha.6",
20
- "@nocobase/server": "1.4.0-alpha.6"
19
+ "@nocobase/evaluators": "1.4.0-alpha.7",
20
+ "@nocobase/server": "1.4.0-alpha.7"
21
21
  };
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.4.0-alpha.6",
7
+ "version": "1.4.0-alpha.7",
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": "7d8583704a1f7ae0caeab72a19fd0bce0a4cec0f",
25
+ "gitHead": "52bb98fe5fd95cc25baeaaef5aeae9cdd1a0e2fa",
26
26
  "keywords": [
27
27
  "Workflow"
28
28
  ]
package/README.zh-CN.md DELETED
@@ -1,9 +0,0 @@
1
- # workflow
2
-
3
- [English](./README.md) | 中文
4
-
5
- ## 安装激活
6
-
7
- 内置插件无需手动安装激活。
8
-
9
- ## 使用方法