@nocobase/plugin-workflow-parallel 0.17.0-alpha.7 → 0.18.0-alpha.8

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.
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","react/jsx-runtime","react","antd","@ant-design/icons","react-i18next"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@nocobase/plugin-workflow-parallel"]={},e["@nocobase/client"],e["@nocobase/plugin-workflow"],e.jsxRuntime,e.react,e.antd,e["@ant-design/icons"],e["react-i18next"]))})(this,function(e,t,n,a,f,d,b,u){"use strict";var M=Object.defineProperty;var S=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var l=(e,t,n)=>(S(e,typeof t!="symbol"?t+"":t,n),n);var m=(e,t,n)=>new Promise((a,f)=>{var d=s=>{try{u(n.next(s))}catch(p){f(p)}},b=s=>{try{u(n.throw(s))}catch(p){f(p)}},u=s=>s.done?a(s.value):Promise.resolve(s.value).then(d,b);u((n=n.apply(e,t)).next())});const s="workflow-parallel";function p(h,x={}){const{t:r}=v(x);return r(h)}function v(h){return u.useTranslation(s,h)}class $ extends n.Instruction{constructor(){super(...arguments);l(this,"title",`{{t("Parallel branch", { ns: "${s}" })}}`);l(this,"type","parallel");l(this,"group","control");l(this,"description",`{{t("Run multiple branch processes in parallel.", { ns: "${s}" })}}`);l(this,"fieldset",{mode:{type:"string",title:`{{t("Mode", { ns: "${s}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${s}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${s}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${s}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${s}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${s}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${s}" })}}`}]},default:"all"}});l(this,"components",{RadioWithTooltip:n.RadioWithTooltip})}Component({data:r}){const{styles:A}=n.useStyles(),{id:w,config:{mode:L}}=r,{workflow:y,nodes:T}=n.useFlowContext(),i=T.reduce((o,c)=>c.upstreamId===w&&c.branchIndex!=null?o.concat(c):o,[]).sort((o,c)=>o.branchIndex-c.branchIndex),[g,C]=f.useState(Math.max(2,i.length)),{getAriaLabel:q}=n.useGetAriaLabelOfAddButton(r),N=p("Add branch"),j=Array(Math.max(0,g-i.length)).fill(null),I=i[i.length-1];return a.jsx(n.NodeDefaultView,{data:r,children:a.jsxs("div",{className:A.nodeSubtreeClass,children:[a.jsxs("div",{className:A.branchBlockClass,children:[i.map(o=>a.jsx(n.Branch,{from:r,entry:o,branchIndex:o.branchIndex},o.id)),j.map((o,c)=>a.jsx(n.Branch,{from:r,branchIndex:(I?I.branchIndex:0)+c+1,controller:i.length+c>1?a.jsx("div",{className:t.css`
1
+ (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("@nocobase/plugin-workflow/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("react-i18next")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/plugin-workflow/client","react/jsx-runtime","react","antd","@ant-design/icons","react-i18next"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e["@nocobase/plugin-workflow-parallel"]={},e["@nocobase/client"],e["@nocobase/plugin-workflow"],e.jsxRuntime,e.react,e.antd,e["@ant-design/icons"],e["react-i18next"]))})(this,function(e,t,n,r,f,d,b,u){"use strict";var M=Object.defineProperty;var S=(e,t,n)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var l=(e,t,n)=>(S(e,typeof t!="symbol"?t+"":t,n),n);var x=(e,t,n)=>new Promise((r,f)=>{var d=a=>{try{u(n.next(a))}catch(p){f(p)}},b=a=>{try{u(n.throw(a))}catch(p){f(p)}},u=a=>a.done?r(a.value):Promise.resolve(a.value).then(d,b);u((n=n.apply(e,t)).next())});const a="workflow-parallel";function p(h,m={}){const{t:c}=v(m);return c(h)}function v(h){return u.useTranslation(a,h)}class $ extends n.Instruction{constructor(){super(...arguments);l(this,"title",`{{t("Parallel branch", { ns: "${a}" })}}`);l(this,"type","parallel");l(this,"group","control");l(this,"description",`{{t("Run multiple branch processes in parallel.", { ns: "${a}" })}}`);l(this,"fieldset",{mode:{type:"string",title:`{{t("Mode", { ns: "${a}" })}}`,"x-decorator":"FormItem","x-component":"RadioWithTooltip","x-component-props":{options:[{value:"all",label:`{{t('All succeeded', { ns: "${a}" })}}`,tooltip:`{{t('Continue after all branches succeeded', { ns: "${a}" })}}`},{value:"any",label:`{{t('Any succeeded', { ns: "${a}" })}}`,tooltip:`{{t('Continue after any branch succeeded', { ns: "${a}" })}}`},{value:"race",label:`{{t('Any succeeded or failed', { ns: "${a}" })}}`,tooltip:`{{t('Continue after any branch succeeded, or exit after any branch failed.', { ns: "${a}" })}}`}]},default:"all"}});l(this,"components",{RadioWithTooltip:n.RadioWithTooltip})}Component({data:c}){const{styles:A}=n.useStyles(),{id:B,config:{mode:L}}=c,{workflow:y,nodes:T}=n.useFlowContext(),i=T.reduce((s,o)=>o.upstreamId===B&&o.branchIndex!=null?s.concat(o):s,[]).sort((s,o)=>s.branchIndex-o.branchIndex),[g,C]=f.useState(Math.max(2,i.length)),{getAriaLabel:q}=n.useGetAriaLabelOfAddButton(c),N=p("Add branch"),j=Array(Math.max(0,g-i.length)).fill(null),I=i[i.length-1];return r.jsx(n.NodeDefaultView,{data:c,children:r.jsxs("div",{className:A.nodeSubtreeClass,children:[r.jsxs("div",{className:A.branchBlockClass,children:[i.map(s=>r.jsx(n.Branch,{from:c,entry:s,branchIndex:s.branchIndex},s.id)),j.map((s,o)=>r.jsx(n.Branch,{from:c,branchIndex:(I?I.branchIndex:0)+o+1,controller:i.length+o>1?r.jsx("div",{className:t.css`
2
2
  padding-top: 2em;
3
3
 
4
4
  > button {
@@ -6,9 +6,9 @@
6
6
  transform: rotate(45deg);
7
7
  }
8
8
  }
9
- `,children:a.jsx(d.Button,{shape:"circle",icon:a.jsx(b.PlusOutlined,{}),onClick:()=>C(g-1),disabled:y.executed})}):null},`temp_${i.length+c}`))]}),a.jsx(d.Tooltip,{title:N,className:t.css`
9
+ `,children:r.jsx(d.Button,{shape:"circle",icon:r.jsx(b.PlusOutlined,{}),onClick:()=>C(g-1),disabled:y.executed})}):null},`temp_${i.length+o}`))]}),r.jsx(d.Tooltip,{title:N,className:t.css`
10
10
  visibility: ${y.executed?"hidden":"visible"};
11
- `,children:a.jsx(d.Button,{"aria-label":q("add-branch"),icon:a.jsx(b.PlusOutlined,{}),className:t.css`
11
+ `,children:r.jsx(d.Button,{"aria-label":q("add-branch"),icon:r.jsx(b.PlusOutlined,{}),className:t.css`
12
12
  position: relative;
13
13
  top: 1em;
14
14
  transform-origin: center;
@@ -18,4 +18,4 @@
18
18
  transform-origin: center;
19
19
  transform: rotate(-45deg);
20
20
  }
21
- `,onClick:()=>C(g+1),disabled:y.executed})})]})})}}class B extends t.Plugin{afterAdd(){return m(this,null,function*(){})}beforeLoad(){return m(this,null,function*(){})}load(){return m(this,null,function*(){const x=this.app.pm.get(n),r=new $;x.instructions.register(r.type,r)})}}e.default=B,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
21
+ `,onClick:()=>C(g+1),disabled:y.executed})})]})})}}class w extends t.Plugin{afterAdd(){return x(this,null,function*(){})}beforeLoad(){return x(this,null,function*(){})}load(){return x(this,null,function*(){this.app.pm.get(n).registerInstruction("parallel",$)})}}e.default=w,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,9 +1,9 @@
1
1
  module.exports = {
2
2
  "react": "18.2.0",
3
- "antd": "5.8.6",
4
- "@ant-design/icons": "5.1.4",
5
- "@nocobase/client": "0.17.0-alpha.7",
6
- "@nocobase/plugin-workflow": "0.17.0-alpha.7",
3
+ "antd": "5.12.2",
4
+ "@ant-design/icons": "5.2.6",
5
+ "@nocobase/client": "0.18.0-alpha.8",
6
+ "@nocobase/plugin-workflow": "0.18.0-alpha.8",
7
7
  "react-i18next": "11.18.6",
8
- "@nocobase/server": "0.17.0-alpha.7"
8
+ "@nocobase/server": "0.18.0-alpha.8"
9
9
  };
@@ -112,7 +112,7 @@ class ParallelInstruction_default extends import_plugin_workflow.Instruction {
112
112
  status: Modes[mode].getStatus(newResult)
113
113
  });
114
114
  if (job.status === import_plugin_workflow.JOB_STATUS.PENDING) {
115
- await job.save({ transaction: processor.transaction });
115
+ await job.save();
116
116
  return processor.exit();
117
117
  }
118
118
  return job;
@@ -1,6 +1,4 @@
1
1
  import { Plugin } from '@nocobase/server';
2
- import WorkflowPlugin from '@nocobase/plugin-workflow';
3
2
  export default class extends Plugin {
4
- workflow: WorkflowPlugin;
5
3
  load(): Promise<void>;
6
4
  }
@@ -31,12 +31,11 @@ __export(Plugin_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(Plugin_exports);
33
33
  var import_server = require("@nocobase/server");
34
+ var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
34
35
  var import_ParallelInstruction = __toESM(require("./ParallelInstruction"));
35
36
  class Plugin_default extends import_server.Plugin {
36
- workflow;
37
37
  async load() {
38
- const workflowPlugin = this.app.getPlugin("workflow");
39
- this.workflow = workflowPlugin;
40
- workflowPlugin.instructions.register("parallel", new import_ParallelInstruction.default(workflowPlugin));
38
+ const workflowPlugin = this.app.getPlugin(import_plugin_workflow.default);
39
+ workflowPlugin.registerInstruction("parallel", import_ParallelInstruction.default);
41
40
  }
42
41
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:并行分支节点",
5
5
  "description": "Could be used for parallel execution of branch processes in the workflow.",
6
6
  "description.zh-CN": "用于在工作流中需要并行执行的分支流程。",
7
- "version": "0.17.0-alpha.7",
7
+ "version": "0.18.0-alpha.8",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -17,9 +17,8 @@
17
17
  "@nocobase/client": "0.x",
18
18
  "@nocobase/database": "0.x",
19
19
  "@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
20
- "@nocobase/plugin-workflow-test": ">=0.17.0-alpha.3",
21
20
  "@nocobase/server": "0.x",
22
21
  "@nocobase/test": "0.x"
23
22
  },
24
- "gitHead": "91377a3abd1124f79fb3819f2d0e80905e091a32"
23
+ "gitHead": "727d42f6f14e5f863831da3dbf3255ba1165b567"
25
24
  }
@@ -13,7 +13,6 @@ export default class extends Plugin {
13
13
  // You can get and modify the app instance here
14
14
  async load() {
15
15
  const workflow = this.app.pm.get(WorkflowPlugin);
16
- const parallelInstruction = new ParallelInstruction();
17
- workflow.instructions.register(parallelInstruction.type, parallelInstruction);
16
+ workflow.registerInstruction('parallel', ParallelInstruction);
18
17
  }
19
18
  }
@@ -110,7 +110,7 @@ export default class extends Instruction {
110
110
  });
111
111
 
112
112
  if (job.status === JOB_STATUS.PENDING) {
113
- await job.save({ transaction: processor.transaction });
113
+ await job.save();
114
114
  return processor.exit();
115
115
  }
116
116
 
@@ -4,11 +4,8 @@ import WorkflowPlugin from '@nocobase/plugin-workflow';
4
4
  import ParallelInstruction from './ParallelInstruction';
5
5
 
6
6
  export default class extends Plugin {
7
- workflow: WorkflowPlugin;
8
-
9
7
  async load() {
10
- const workflowPlugin = this.app.getPlugin('workflow') as WorkflowPlugin;
11
- this.workflow = workflowPlugin;
12
- workflowPlugin.instructions.register('parallel', new ParallelInstruction(workflowPlugin));
8
+ const workflowPlugin = this.app.getPlugin<WorkflowPlugin>(WorkflowPlugin);
9
+ workflowPlugin.registerInstruction('parallel', ParallelInstruction);
13
10
  }
14
11
  }
@@ -1,6 +1,6 @@
1
1
  import Database from '@nocobase/database';
2
2
  import { Application } from '@nocobase/server';
3
- import { BRANCH_INDEX, EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
3
+ import { EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
4
4
  import { getApp, sleep } from '@nocobase/plugin-workflow-test';
5
5
 
6
6
  import Plugin from '..';
@@ -453,7 +453,7 @@ describe('workflow > instructions > parallel', () => {
453
453
 
454
454
  const n2 = await workflow.createNode({
455
455
  type: 'parallel',
456
- branchIndex: BRANCH_INDEX.ON_TRUE,
456
+ branchIndex: 1,
457
457
  upstreamId: n1.id,
458
458
  });
459
459
 
@@ -521,7 +521,7 @@ describe('workflow > instructions > parallel', () => {
521
521
  const n4 = await workflow.createNode({
522
522
  type: 'echo',
523
523
  upstreamId: n3.id,
524
- branchIndex: BRANCH_INDEX.ON_TRUE,
524
+ branchIndex: 1,
525
525
  });
526
526
 
527
527
  const n5 = await workflow.createNode({