@nocobase/plugin-workflow-parallel 0.17.0-alpha.4

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.
Files changed (46) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +9 -0
  3. package/README.zh-CN.md +9 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/ParallelInstruction.d.ts +30 -0
  7. package/dist/client/index.d.ts +6 -0
  8. package/dist/client/index.js +21 -0
  9. package/dist/externalVersion.js +9 -0
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +39 -0
  12. package/dist/locale/en-US.json +11 -0
  13. package/dist/locale/es-ES.json +10 -0
  14. package/dist/locale/fr-FR.json +10 -0
  15. package/dist/locale/index.d.ts +3 -0
  16. package/dist/locale/index.js +39 -0
  17. package/dist/locale/ja-JP.json +7 -0
  18. package/dist/locale/pt-BR.json +10 -0
  19. package/dist/locale/ru-RU.json +7 -0
  20. package/dist/locale/tr-TR.json +7 -0
  21. package/dist/locale/zh-CN.json +11 -0
  22. package/dist/server/ParallelInstruction.d.ts +10 -0
  23. package/dist/server/ParallelInstruction.js +124 -0
  24. package/dist/server/Plugin.d.ts +6 -0
  25. package/dist/server/Plugin.js +42 -0
  26. package/dist/server/index.d.ts +1 -0
  27. package/dist/server/index.js +33 -0
  28. package/package.json +25 -0
  29. package/server.d.ts +2 -0
  30. package/server.js +1 -0
  31. package/src/client/ParallelInstruction.tsx +147 -0
  32. package/src/client/index.ts +19 -0
  33. package/src/index.ts +2 -0
  34. package/src/locale/en-US.json +11 -0
  35. package/src/locale/es-ES.json +10 -0
  36. package/src/locale/fr-FR.json +10 -0
  37. package/src/locale/index.ts +12 -0
  38. package/src/locale/ja-JP.json +7 -0
  39. package/src/locale/pt-BR.json +10 -0
  40. package/src/locale/ru-RU.json +7 -0
  41. package/src/locale/tr-TR.json +7 -0
  42. package/src/locale/zh-CN.json +11 -0
  43. package/src/server/ParallelInstruction.ts +119 -0
  44. package/src/server/Plugin.ts +14 -0
  45. package/src/server/__tests__/instruction.test.ts +560 -0
  46. package/src/server/index.ts +1 -0
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { RadioWithTooltip, Instruction } from '@nocobase/plugin-workflow/client';
3
+ export default class extends Instruction {
4
+ title: string;
5
+ type: string;
6
+ group: string;
7
+ description: string;
8
+ fieldset: {
9
+ mode: {
10
+ type: string;
11
+ title: string;
12
+ 'x-decorator': string;
13
+ 'x-component': string;
14
+ 'x-component-props': {
15
+ options: {
16
+ value: string;
17
+ label: string;
18
+ tooltip: string;
19
+ }[];
20
+ };
21
+ default: string;
22
+ };
23
+ };
24
+ components: {
25
+ RadioWithTooltip: typeof RadioWithTooltip;
26
+ };
27
+ Component({ data }: {
28
+ data: any;
29
+ }): React.JSX.Element;
30
+ }
@@ -0,0 +1,6 @@
1
+ import { Plugin } from '@nocobase/client';
2
+ export default class extends Plugin {
3
+ afterAdd(): Promise<void>;
4
+ beforeLoad(): Promise<void>;
5
+ load(): Promise<void>;
6
+ }
@@ -0,0 +1,21 @@
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`
2
+ padding-top: 2em;
3
+
4
+ > button {
5
+ .anticon {
6
+ transform: rotate(45deg);
7
+ }
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`
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`
12
+ position: relative;
13
+ top: 1em;
14
+ transform-origin: center;
15
+ transform: rotate(45deg);
16
+
17
+ .anticon {
18
+ transform-origin: center;
19
+ transform: rotate(-45deg);
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"}})});
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ "react": "18.2.0",
3
+ "antd": "5.8.6",
4
+ "@ant-design/icons": "5.1.4",
5
+ "@nocobase/client": "0.17.0-alpha.4",
6
+ "@nocobase/plugin-workflow": "0.17.0-alpha.4",
7
+ "react-i18next": "11.18.6",
8
+ "@nocobase/server": "0.17.0-alpha.4"
9
+ };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ __reExport(src_exports, require("./server"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./server")
39
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "Parallel branch": "Parallel branch",
3
+ "Run multiple branch processes in parallel.": "Run multiple branch processes in parallel.",
4
+ "Add branch": "Add branch",
5
+ "All succeeded": "All succeeded",
6
+ "Any succeeded": "Any succeeded",
7
+ "Any succeeded or failed": "Any succeeded or failed",
8
+ "Continue after all branches succeeded": "Continue after all branches succeeded",
9
+ "Continue after any branch succeeded": "Continue after any branch succeeded",
10
+ "Continue after any branch succeeded, or exit after any branch failed.": "Continue after any branch succeeded, or exit after any branch failed."
11
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "Parallel branch": "Rama paralela",
3
+ "Add branch": "Añadir rama",
4
+ "All succeeded": "Todo correcto",
5
+ "Any succeeded": "Cualquiera con éxito",
6
+ "Any succeeded or failed": "Cualquiera tuvo éxito o falló",
7
+ "Continue after all branches succeeded": "Continuar después que todas las ramas han tenido éxito",
8
+ "Continue after any branch succeeded": "Continuar después que cualquier rama tenga éxito",
9
+ "Continue after any branch succeeded, or exit after any branch failed": "Continuar después de que cualquier rama tenga éxito, o salir después de que cualquier rama falle"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "Parallel branch": "Branche parallèle",
3
+ "Add branch": "Ajouter une branche",
4
+ "All succeeded": "Tous réussis",
5
+ "Any succeeded": "Un réussi",
6
+ "Any succeeded or failed": "Un réussi ou un échoué",
7
+ "Continue after all branches succeeded": "Continuer après la réussite de toutes les branches",
8
+ "Continue after any branch succeeded": "Continuer après la réussite d'une branche",
9
+ "Continue after any branch succeeded, or exit after any branch failed": "Continuer après la réussite d'une branche, ou quitter après l'échec d'une branche"
10
+ }
@@ -0,0 +1,3 @@
1
+ export declare const NAMESPACE = "workflow-parallel";
2
+ export declare function useLang(key: string, options?: {}): string;
3
+ export declare function usePluginTranslation(options: any): import("react-i18next").UseTranslationResponse<"workflow-parallel", undefined>;
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var locale_exports = {};
19
+ __export(locale_exports, {
20
+ NAMESPACE: () => NAMESPACE,
21
+ useLang: () => useLang,
22
+ usePluginTranslation: () => usePluginTranslation
23
+ });
24
+ module.exports = __toCommonJS(locale_exports);
25
+ var import_react_i18next = require("react-i18next");
26
+ const NAMESPACE = "workflow-parallel";
27
+ function useLang(key, options = {}) {
28
+ const { t } = usePluginTranslation(options);
29
+ return t(key);
30
+ }
31
+ function usePluginTranslation(options) {
32
+ return (0, import_react_i18next.useTranslation)(NAMESPACE, options);
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ NAMESPACE,
37
+ useLang,
38
+ usePluginTranslation
39
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "Parallel branch": "分岐",
3
+ "All succeeded": "すべて成功",
4
+ "Any succeeded": "いずれかが成功",
5
+ "Continue after all branches succeeded": "すべての分岐が成功した後に続行",
6
+ "Continue after any branch succeeded": "いずれかの分岐が成功した後に続行"
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "Parallel branch": "Ramo paralelo",
3
+ "Add branch": "Adicionar ramo",
4
+ "All succeeded": "Todos com sucesso",
5
+ "Any succeeded": "Qualquer um com sucesso",
6
+ "Any succeeded or failed": "Qualquer um com sucesso ou falha",
7
+ "Continue after all branches succeeded": "Continuar após todos os ramos com sucesso",
8
+ "Continue after any branch succeeded": "Continuar após qualquer ramo com sucesso",
9
+ "Continue after any branch succeeded, or exit after any branch failed": "Continuar após qualquer ramo com sucesso ou sair após qualquer ramo falhar"
10
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "Parallel branch": "Параллельная ветвь",
3
+ "All succeeded": "Всё успешно",
4
+ "Any succeeded": "Что-то успешно",
5
+ "Continue after all branches succeeded": "Продолжать после успеха на всех ветвях",
6
+ "Continue after any branch succeeded": "Продолжать после успеха на любой из ветвей"
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "Parallel branch": "Paralel dal",
3
+ "All succeeded": "Hepsi başarılı",
4
+ "Any succeeded": "Herhangi biri başarılı",
5
+ "Continue after all branches succeeded": "Tüm dallar başarılı olduktan sonra devam et",
6
+ "Continue after any branch succeeded": "Herhangi bir dal başarılı olduktan sonra devam et"
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "Parallel branch": "分支",
3
+ "Run multiple branch processes in parallel.": "并行运行多个分支流程。",
4
+ "Add branch": "增加分支",
5
+ "All succeeded": "全部成功",
6
+ "Any succeeded": "任意成功",
7
+ "Any succeeded or failed": "任意成功或失败",
8
+ "Continue after all branches succeeded": "全部分支都成功后才能继续",
9
+ "Continue after any branch succeeded": "任意分支成功后就继续",
10
+ "Continue after any branch succeeded, or exit after any branch failed.": "任意分支成功就继续流程,或者任意分支失败就退出流程。"
11
+ }
@@ -0,0 +1,10 @@
1
+ import { Processor, Instruction, FlowNodeModel, JobModel } from '@nocobase/plugin-workflow';
2
+ export declare const PARALLEL_MODE: {
3
+ readonly ALL: "all";
4
+ readonly ANY: "any";
5
+ readonly RACE: "race";
6
+ };
7
+ export default class extends Instruction {
8
+ run(node: FlowNodeModel, prevJob: JobModel, processor: Processor): Promise<any>;
9
+ resume(node: FlowNodeModel, branchJob: any, processor: Processor): Promise<any>;
10
+ }
@@ -0,0 +1,124 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var ParallelInstruction_exports = {};
19
+ __export(ParallelInstruction_exports, {
20
+ PARALLEL_MODE: () => PARALLEL_MODE,
21
+ default: () => ParallelInstruction_default
22
+ });
23
+ module.exports = __toCommonJS(ParallelInstruction_exports);
24
+ var import_plugin_workflow = require("@nocobase/plugin-workflow");
25
+ const PARALLEL_MODE = {
26
+ ALL: "all",
27
+ ANY: "any",
28
+ RACE: "race"
29
+ };
30
+ const Modes = {
31
+ [PARALLEL_MODE.ALL]: {
32
+ next(previous) {
33
+ return previous.status >= import_plugin_workflow.JOB_STATUS.PENDING;
34
+ },
35
+ getStatus(result) {
36
+ const failedStatus = result.find((status) => status != null && status < import_plugin_workflow.JOB_STATUS.PENDING);
37
+ if (typeof failedStatus !== "undefined") {
38
+ return failedStatus;
39
+ }
40
+ if (result.every((status) => status != null && status === import_plugin_workflow.JOB_STATUS.RESOLVED)) {
41
+ return import_plugin_workflow.JOB_STATUS.RESOLVED;
42
+ }
43
+ return import_plugin_workflow.JOB_STATUS.PENDING;
44
+ }
45
+ },
46
+ [PARALLEL_MODE.ANY]: {
47
+ next(previous) {
48
+ return previous.status <= import_plugin_workflow.JOB_STATUS.PENDING;
49
+ },
50
+ getStatus(result) {
51
+ if (result.some((status) => status != null && status === import_plugin_workflow.JOB_STATUS.RESOLVED)) {
52
+ return import_plugin_workflow.JOB_STATUS.RESOLVED;
53
+ }
54
+ if (result.some((status) => status != null ? status === import_plugin_workflow.JOB_STATUS.PENDING : true)) {
55
+ return import_plugin_workflow.JOB_STATUS.PENDING;
56
+ }
57
+ return import_plugin_workflow.JOB_STATUS.FAILED;
58
+ }
59
+ },
60
+ [PARALLEL_MODE.RACE]: {
61
+ next(previous) {
62
+ return previous.status === import_plugin_workflow.JOB_STATUS.PENDING;
63
+ },
64
+ getStatus(result) {
65
+ if (result.some((status) => status != null && status === import_plugin_workflow.JOB_STATUS.RESOLVED)) {
66
+ return import_plugin_workflow.JOB_STATUS.RESOLVED;
67
+ }
68
+ const failedStatus = result.find((status) => status != null && status < import_plugin_workflow.JOB_STATUS.PENDING);
69
+ if (typeof failedStatus !== "undefined") {
70
+ return failedStatus;
71
+ }
72
+ return import_plugin_workflow.JOB_STATUS.PENDING;
73
+ }
74
+ }
75
+ };
76
+ class ParallelInstruction_default extends import_plugin_workflow.Instruction {
77
+ async run(node, prevJob, processor) {
78
+ const branches = processor.getBranches(node);
79
+ const job = await processor.saveJob({
80
+ status: import_plugin_workflow.JOB_STATUS.PENDING,
81
+ result: Array(branches.length).fill(null),
82
+ nodeId: node.id,
83
+ upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
84
+ });
85
+ const { mode = PARALLEL_MODE.ALL } = node.config;
86
+ await branches.reduce(
87
+ (promise, branch, i) => promise.then(async (previous) => {
88
+ if (i && !Modes[mode].next(previous)) {
89
+ return previous;
90
+ }
91
+ await processor.run(branch, job);
92
+ return processor.findBranchLastJob(branch, job);
93
+ }),
94
+ Promise.resolve()
95
+ );
96
+ return null;
97
+ }
98
+ async resume(node, branchJob, processor) {
99
+ const job = processor.findBranchParentJob(branchJob, node);
100
+ const { result, status } = job;
101
+ if (status !== import_plugin_workflow.JOB_STATUS.PENDING) {
102
+ return processor.exit();
103
+ }
104
+ const jobNode = processor.nodesMap.get(branchJob.nodeId);
105
+ const branchStartNode = processor.findBranchStartNode(jobNode, node);
106
+ const branches = processor.getBranches(node);
107
+ const branchIndex = branches.indexOf(branchStartNode);
108
+ const { mode = PARALLEL_MODE.ALL } = node.config || {};
109
+ const newResult = [...result.slice(0, branchIndex), branchJob.status, ...result.slice(branchIndex + 1)];
110
+ job.set({
111
+ result: newResult,
112
+ status: Modes[mode].getStatus(newResult)
113
+ });
114
+ if (job.status === import_plugin_workflow.JOB_STATUS.PENDING) {
115
+ await job.save({ transaction: processor.transaction });
116
+ return processor.exit();
117
+ }
118
+ return job;
119
+ }
120
+ }
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ PARALLEL_MODE
124
+ });
@@ -0,0 +1,6 @@
1
+ import { Plugin } from '@nocobase/server';
2
+ import WorkflowPlugin from '@nocobase/plugin-workflow';
3
+ export default class extends Plugin {
4
+ workflow: WorkflowPlugin;
5
+ load(): Promise<void>;
6
+ }
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var Plugin_exports = {};
29
+ __export(Plugin_exports, {
30
+ default: () => Plugin_default
31
+ });
32
+ module.exports = __toCommonJS(Plugin_exports);
33
+ var import_server = require("@nocobase/server");
34
+ var import_ParallelInstruction = __toESM(require("./ParallelInstruction"));
35
+ class Plugin_default extends import_server.Plugin {
36
+ workflow;
37
+ async load() {
38
+ const workflowPlugin = this.app.getPlugin("workflow");
39
+ this.workflow = workflowPlugin;
40
+ workflowPlugin.instructions.register("parallel", new import_ParallelInstruction.default(workflowPlugin));
41
+ }
42
+ }
@@ -0,0 +1 @@
1
+ export { default } from './Plugin';
@@ -0,0 +1,33 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var server_exports = {};
29
+ __export(server_exports, {
30
+ default: () => import_Plugin.default
31
+ });
32
+ module.exports = __toCommonJS(server_exports);
33
+ var import_Plugin = __toESM(require("./Plugin"));
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@nocobase/plugin-workflow-parallel",
3
+ "displayName": "Workflow: Parallel node",
4
+ "displayName.zh-CN": "工作流:并行分支节点",
5
+ "description": "Could be used for parallel execution of branch processes in the workflow.",
6
+ "description.zh-CN": "用于在工作流中需要并行执行的分支流程。",
7
+ "version": "0.17.0-alpha.4",
8
+ "license": "AGPL-3.0",
9
+ "main": "./dist/server/index.js",
10
+ "devDependencies": {
11
+ "@ant-design/icons": "5.x",
12
+ "antd": "5.x",
13
+ "react": "18.x",
14
+ "react-i18next": "^11.15.1"
15
+ },
16
+ "peerDependencies": {
17
+ "@nocobase/client": "0.x",
18
+ "@nocobase/database": "0.x",
19
+ "@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
20
+ "@nocobase/plugin-workflow-test": ">=0.17.0-alpha.3",
21
+ "@nocobase/server": "0.x",
22
+ "@nocobase/test": "0.x"
23
+ },
24
+ "gitHead": "663b03a3799a70ba1a2bc6a0d686e679331a50ad"
25
+ }
package/server.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/server';
2
+ export { default } from './dist/server';
package/server.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/server/index.js');