@nocobase/plugin-workflow 0.21.0-alpha.6 → 0.21.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/dist/client/hooks/useRefreshActionProps.d.ts +3 -0
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.js +28 -28
- package/dist/client/nodes/index.d.ts +6 -0
- package/dist/client/schemas/executions.d.ts +9 -0
- package/dist/client/triggers/index.d.ts +3 -0
- package/dist/externalVersion.js +10 -10
- package/dist/locale/zh-CN.json +2 -1
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.d.ts +20 -2
- package/dist/server/Plugin.js +40 -22
- package/dist/server/Processor.d.ts +50 -1
- package/dist/server/Processor.js +49 -2
- package/package.json +3 -4
|
@@ -38,7 +38,13 @@ export declare abstract class Instruction {
|
|
|
38
38
|
}
|
|
39
39
|
export declare const NodeContext: React.Context<any>;
|
|
40
40
|
export declare function useNodeContext(): any;
|
|
41
|
+
/**
|
|
42
|
+
* @experimental
|
|
43
|
+
*/
|
|
41
44
|
export declare function useAvailableUpstreams(node: any, filter?: any): any[];
|
|
45
|
+
/**
|
|
46
|
+
* @experimental
|
|
47
|
+
*/
|
|
42
48
|
export declare function useUpstreamScopes(node: any): any[];
|
|
43
49
|
export declare function Node({ data }: {
|
|
44
50
|
data: any;
|
|
@@ -160,6 +160,15 @@ export declare const executionSchema: {
|
|
|
160
160
|
};
|
|
161
161
|
};
|
|
162
162
|
properties: {
|
|
163
|
+
refresher: {
|
|
164
|
+
type: string;
|
|
165
|
+
title: string;
|
|
166
|
+
'x-component': string;
|
|
167
|
+
'x-use-component-props': string;
|
|
168
|
+
'x-component-props': {
|
|
169
|
+
icon: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
163
172
|
clear: {
|
|
164
173
|
type: string;
|
|
165
174
|
title: string;
|
|
@@ -22,4 +22,7 @@ export declare abstract class Trigger {
|
|
|
22
22
|
isActionTriggerable?: boolean | ((config: object, context?: object) => boolean);
|
|
23
23
|
}
|
|
24
24
|
export declare const TriggerConfig: () => React.JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* @experimental
|
|
27
|
+
*/
|
|
25
28
|
export declare function useTrigger(): any;
|
package/dist/externalVersion.js
CHANGED
|
@@ -2,23 +2,23 @@ module.exports = {
|
|
|
2
2
|
"react": "18.2.0",
|
|
3
3
|
"antd": "5.12.8",
|
|
4
4
|
"@ant-design/icons": "5.2.6",
|
|
5
|
-
"@nocobase/client": "0.21.0-alpha.
|
|
5
|
+
"@nocobase/client": "0.21.0-alpha.7",
|
|
6
6
|
"react-router-dom": "6.21.0",
|
|
7
|
-
"@nocobase/utils": "0.21.0-alpha.
|
|
7
|
+
"@nocobase/utils": "0.21.0-alpha.7",
|
|
8
8
|
"react-i18next": "11.18.6",
|
|
9
9
|
"@formily/core": "2.3.0",
|
|
10
10
|
"@formily/react": "2.3.0",
|
|
11
|
-
"@nocobase/database": "0.21.0-alpha.
|
|
12
|
-
"@nocobase/server": "0.21.0-alpha.
|
|
13
|
-
"@nocobase/logger": "0.21.0-alpha.
|
|
14
|
-
"@nocobase/evaluators": "0.21.0-alpha.
|
|
11
|
+
"@nocobase/database": "0.21.0-alpha.7",
|
|
12
|
+
"@nocobase/server": "0.21.0-alpha.7",
|
|
13
|
+
"@nocobase/logger": "0.21.0-alpha.7",
|
|
14
|
+
"@nocobase/evaluators": "0.21.0-alpha.7",
|
|
15
15
|
"@formily/shared": "2.3.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@formily/antd-v5": "1.1.9",
|
|
18
|
-
"@nocobase/actions": "0.21.0-alpha.
|
|
19
|
-
"@nocobase/data-source-manager": "0.21.0-alpha.
|
|
18
|
+
"@nocobase/actions": "0.21.0-alpha.7",
|
|
19
|
+
"@nocobase/data-source-manager": "0.21.0-alpha.7",
|
|
20
20
|
"sequelize": "6.35.2",
|
|
21
|
-
"@nocobase/plugin-workflow-test": "0.21.0-alpha.
|
|
22
|
-
"@nocobase/test": "0.21.0-alpha.
|
|
21
|
+
"@nocobase/plugin-workflow-test": "0.21.0-alpha.7",
|
|
22
|
+
"@nocobase/test": "0.21.0-alpha.7",
|
|
23
23
|
"dayjs": "1.11.10"
|
|
24
24
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"Clear executions will not reset executed count, and started executions will not be deleted, are you sure you want to delete them all?":
|
|
6
6
|
"清空执行记录不会重置执行次数,且执行中的也不会被删除,确定要删除所有执行记录吗?",
|
|
7
7
|
"Executed": "已执行",
|
|
8
|
+
"Sync": "同步",
|
|
8
9
|
"Sync enabled status of all workflows from database": "从数据库同步所有工作流的启用状态",
|
|
9
10
|
"Trigger type": "触发方式",
|
|
10
11
|
"Status": "状态",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
|
|
38
39
|
"Bind workflows": "绑定工作流",
|
|
39
40
|
"Workflow will be triggered before or after submitting succeeded based on workflow type.": "工作流会基于其类型在提交成功之前或之后触发。",
|
|
40
|
-
"Workflow will be triggered directly once the button clicked, without data saving.": "
|
|
41
|
+
"Workflow will be triggered directly once the button clicked, without data saving. Only supports \"Post-action event\" for now.": "按钮点击后直接触发工作流,但不会保存数据。目前仅支持“操作后事件”。",
|
|
41
42
|
"Workflow will be triggered before deleting succeeded.": "删除成功之前触发工作流。",
|
|
42
43
|
"Submit to workflow": "提交至工作流",
|
|
43
44
|
"Add workflow": "添加工作流",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-04-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-04-13T01:50:29.953Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-04-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-04-13T01:50:29.640Z"}
|
package/dist/server/Plugin.d.ts
CHANGED
|
@@ -20,9 +20,17 @@ export default class PluginWorkflowServer extends Plugin {
|
|
|
20
20
|
private eventsCount;
|
|
21
21
|
private loggerCache;
|
|
22
22
|
private meter;
|
|
23
|
+
private onBeforeSave;
|
|
24
|
+
/**
|
|
25
|
+
* @experimental
|
|
26
|
+
*/
|
|
23
27
|
getLogger(workflowId: ID): Logger;
|
|
28
|
+
/**
|
|
29
|
+
* @experimental
|
|
30
|
+
* @param {WorkflowModel} workflow
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
24
33
|
isWorkflowSync(workflow: WorkflowModel): boolean;
|
|
25
|
-
private onBeforeSave;
|
|
26
34
|
registerTrigger<T extends Trigger>(type: string, trigger: T | {
|
|
27
35
|
new (p: Plugin): T;
|
|
28
36
|
}): void;
|
|
@@ -31,8 +39,11 @@ export default class PluginWorkflowServer extends Plugin {
|
|
|
31
39
|
}): void;
|
|
32
40
|
private initTriggers;
|
|
33
41
|
private initInstructions;
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
34
45
|
load(): Promise<void>;
|
|
35
|
-
toggle
|
|
46
|
+
private toggle;
|
|
36
47
|
trigger(workflow: WorkflowModel, context: object, options?: {
|
|
37
48
|
[key: string]: any;
|
|
38
49
|
} & Transactionable): void | Promise<Processor | null>;
|
|
@@ -43,6 +54,13 @@ export default class PluginWorkflowServer extends Plugin {
|
|
|
43
54
|
private prepare;
|
|
44
55
|
private dispatch;
|
|
45
56
|
private process;
|
|
57
|
+
/**
|
|
58
|
+
* @experimental
|
|
59
|
+
* @param {string} dataSourceName
|
|
60
|
+
* @param {Transaction} transaction
|
|
61
|
+
* @param {boolean} create
|
|
62
|
+
* @returns {Trasaction}
|
|
63
|
+
*/
|
|
46
64
|
useDataSourceTransaction(dataSourceName: string, transaction: any, create?: boolean): any;
|
|
47
65
|
}
|
|
48
66
|
export {};
|
package/dist/server/Plugin.js
CHANGED
|
@@ -60,28 +60,6 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
60
60
|
eventsCount = 0;
|
|
61
61
|
loggerCache;
|
|
62
62
|
meter = null;
|
|
63
|
-
getLogger(workflowId) {
|
|
64
|
-
const now = /* @__PURE__ */ new Date();
|
|
65
|
-
const date = `${now.getFullYear()}-${`0${now.getMonth() + 1}`.slice(-2)}-${`0${now.getDate()}`.slice(-2)}`;
|
|
66
|
-
const key = `${date}-${workflowId}}`;
|
|
67
|
-
if (this.loggerCache.has(key)) {
|
|
68
|
-
return this.loggerCache.get(key);
|
|
69
|
-
}
|
|
70
|
-
const logger = this.createLogger({
|
|
71
|
-
dirname: import_path.default.join("workflows", date),
|
|
72
|
-
filename: `${workflowId}.log`,
|
|
73
|
-
transports: [...process.env.NODE_ENV !== "production" ? ["console"] : ["file"]]
|
|
74
|
-
});
|
|
75
|
-
this.loggerCache.set(key, logger);
|
|
76
|
-
return logger;
|
|
77
|
-
}
|
|
78
|
-
isWorkflowSync(workflow) {
|
|
79
|
-
const trigger = this.triggers.get(workflow.type);
|
|
80
|
-
if (!trigger) {
|
|
81
|
-
throw new Error(`invalid trigger type ${workflow.type} of workflow ${workflow.id}`);
|
|
82
|
-
}
|
|
83
|
-
return trigger.sync ?? workflow.sync;
|
|
84
|
-
}
|
|
85
63
|
onBeforeSave = async (instance, options) => {
|
|
86
64
|
const Model = instance.constructor;
|
|
87
65
|
if (instance.enabled) {
|
|
@@ -121,6 +99,36 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
121
99
|
this.toggle(previous, false);
|
|
122
100
|
}
|
|
123
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* @experimental
|
|
104
|
+
*/
|
|
105
|
+
getLogger(workflowId) {
|
|
106
|
+
const now = /* @__PURE__ */ new Date();
|
|
107
|
+
const date = `${now.getFullYear()}-${`0${now.getMonth() + 1}`.slice(-2)}-${`0${now.getDate()}`.slice(-2)}`;
|
|
108
|
+
const key = `${date}-${workflowId}}`;
|
|
109
|
+
if (this.loggerCache.has(key)) {
|
|
110
|
+
return this.loggerCache.get(key);
|
|
111
|
+
}
|
|
112
|
+
const logger = this.createLogger({
|
|
113
|
+
dirname: import_path.default.join("workflows", date),
|
|
114
|
+
filename: `${workflowId}.log`,
|
|
115
|
+
transports: [...process.env.NODE_ENV !== "production" ? ["console"] : ["file"]]
|
|
116
|
+
});
|
|
117
|
+
this.loggerCache.set(key, logger);
|
|
118
|
+
return logger;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* @experimental
|
|
122
|
+
* @param {WorkflowModel} workflow
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
*/
|
|
125
|
+
isWorkflowSync(workflow) {
|
|
126
|
+
const trigger = this.triggers.get(workflow.type);
|
|
127
|
+
if (!trigger) {
|
|
128
|
+
throw new Error(`invalid trigger type ${workflow.type} of workflow ${workflow.id}`);
|
|
129
|
+
}
|
|
130
|
+
return trigger.sync ?? workflow.sync;
|
|
131
|
+
}
|
|
124
132
|
registerTrigger(type, trigger) {
|
|
125
133
|
if (typeof trigger === "function") {
|
|
126
134
|
this.triggers.register(type, new trigger(this));
|
|
@@ -158,6 +166,9 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
158
166
|
this.registerInstruction(name, instruction);
|
|
159
167
|
}
|
|
160
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
161
172
|
async load() {
|
|
162
173
|
const { db, options } = this;
|
|
163
174
|
(0, import_actions.default)(this);
|
|
@@ -434,6 +445,13 @@ class PluginWorkflowServer extends import_server.Plugin {
|
|
|
434
445
|
}
|
|
435
446
|
return processor;
|
|
436
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* @experimental
|
|
450
|
+
* @param {string} dataSourceName
|
|
451
|
+
* @param {Transaction} transaction
|
|
452
|
+
* @param {boolean} create
|
|
453
|
+
* @returns {Trasaction}
|
|
454
|
+
*/
|
|
437
455
|
useDataSourceTransaction(dataSourceName = "main", transaction, create = false) {
|
|
438
456
|
const { db } = this.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager;
|
|
439
457
|
if (!db) {
|
|
@@ -20,13 +20,31 @@ export default class Processor {
|
|
|
20
20
|
[-6]: -6;
|
|
21
21
|
};
|
|
22
22
|
logger: Logger;
|
|
23
|
+
/**
|
|
24
|
+
* @experimental
|
|
25
|
+
*/
|
|
23
26
|
transaction: Transaction;
|
|
27
|
+
/**
|
|
28
|
+
* @experimental
|
|
29
|
+
*/
|
|
24
30
|
nodes: FlowNodeModel[];
|
|
31
|
+
/**
|
|
32
|
+
* @experimental
|
|
33
|
+
*/
|
|
25
34
|
nodesMap: Map<number, FlowNodeModel>;
|
|
35
|
+
/**
|
|
36
|
+
* @experimental
|
|
37
|
+
*/
|
|
26
38
|
jobsMap: Map<number, JobModel>;
|
|
39
|
+
/**
|
|
40
|
+
* @experimental
|
|
41
|
+
*/
|
|
27
42
|
jobsMapByNodeKey: {
|
|
28
43
|
[key: string]: any;
|
|
29
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* @experimental
|
|
47
|
+
*/
|
|
30
48
|
lastSavedJob: JobModel | null;
|
|
31
49
|
constructor(execution: ExecutionModel, options: ProcessorOptions);
|
|
32
50
|
private makeNodes;
|
|
@@ -37,15 +55,43 @@ export default class Processor {
|
|
|
37
55
|
private exec;
|
|
38
56
|
run(node: any, input?: any): any;
|
|
39
57
|
end(node: any, job: JobModel): Promise<any>;
|
|
40
|
-
recall
|
|
58
|
+
private recall;
|
|
41
59
|
exit(s?: number): Promise<any>;
|
|
60
|
+
/**
|
|
61
|
+
* @experimental
|
|
62
|
+
* @param {JobModel | Record<string, any>} payload
|
|
63
|
+
* @returns {JobModel}
|
|
64
|
+
*/
|
|
42
65
|
saveJob(payload: any): Promise<any>;
|
|
66
|
+
/**
|
|
67
|
+
* @experimental
|
|
68
|
+
*/
|
|
43
69
|
getBranches(node: FlowNodeModel): FlowNodeModel[];
|
|
70
|
+
/**
|
|
71
|
+
* @experimental
|
|
72
|
+
* find the first node in current branch
|
|
73
|
+
*/
|
|
44
74
|
findBranchStartNode(node: FlowNodeModel, parent?: FlowNodeModel): FlowNodeModel | null;
|
|
75
|
+
/**
|
|
76
|
+
* @experimental
|
|
77
|
+
* find the node start current branch
|
|
78
|
+
*/
|
|
45
79
|
findBranchParentNode(node: FlowNodeModel): FlowNodeModel | null;
|
|
80
|
+
/**
|
|
81
|
+
* @experimental
|
|
82
|
+
*/
|
|
46
83
|
findBranchEndNode(node: FlowNodeModel): FlowNodeModel | null;
|
|
84
|
+
/**
|
|
85
|
+
* @experimental
|
|
86
|
+
*/
|
|
47
87
|
findBranchParentJob(job: JobModel, node: FlowNodeModel): JobModel | null;
|
|
88
|
+
/**
|
|
89
|
+
* @experimental
|
|
90
|
+
*/
|
|
48
91
|
findBranchLastJob(node: FlowNodeModel, job: JobModel): JobModel | null;
|
|
92
|
+
/**
|
|
93
|
+
* @experimental
|
|
94
|
+
*/
|
|
49
95
|
getScope(sourceNodeId: number): {
|
|
50
96
|
$context: any;
|
|
51
97
|
$jobsMapByNodeKey: {
|
|
@@ -54,5 +100,8 @@ export default class Processor {
|
|
|
54
100
|
$system: {};
|
|
55
101
|
$scopes: {};
|
|
56
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* @experimental
|
|
105
|
+
*/
|
|
57
106
|
getParsedValue(value: any, sourceNodeId: number, additionalScope?: object): any;
|
|
58
107
|
}
|
package/dist/server/Processor.js
CHANGED
|
@@ -42,11 +42,29 @@ class Processor {
|
|
|
42
42
|
[import_constants.JOB_STATUS.RETRY_NEEDED]: import_constants.EXECUTION_STATUS.RETRY_NEEDED
|
|
43
43
|
};
|
|
44
44
|
logger;
|
|
45
|
+
/**
|
|
46
|
+
* @experimental
|
|
47
|
+
*/
|
|
45
48
|
transaction;
|
|
49
|
+
/**
|
|
50
|
+
* @experimental
|
|
51
|
+
*/
|
|
46
52
|
nodes = [];
|
|
53
|
+
/**
|
|
54
|
+
* @experimental
|
|
55
|
+
*/
|
|
47
56
|
nodesMap = /* @__PURE__ */ new Map();
|
|
57
|
+
/**
|
|
58
|
+
* @experimental
|
|
59
|
+
*/
|
|
48
60
|
jobsMap = /* @__PURE__ */ new Map();
|
|
61
|
+
/**
|
|
62
|
+
* @experimental
|
|
63
|
+
*/
|
|
49
64
|
jobsMapByNodeKey = {};
|
|
65
|
+
/**
|
|
66
|
+
* @experimental
|
|
67
|
+
*/
|
|
50
68
|
lastSavedJob = null;
|
|
51
69
|
// make dual linked nodes list then cache
|
|
52
70
|
makeNodes(nodes = []) {
|
|
@@ -185,6 +203,11 @@ class Processor {
|
|
|
185
203
|
return null;
|
|
186
204
|
}
|
|
187
205
|
// TODO(optimize)
|
|
206
|
+
/**
|
|
207
|
+
* @experimental
|
|
208
|
+
* @param {JobModel | Record<string, any>} payload
|
|
209
|
+
* @returns {JobModel}
|
|
210
|
+
*/
|
|
188
211
|
async saveJob(payload) {
|
|
189
212
|
const { database } = this.execution.constructor;
|
|
190
213
|
const { transaction } = this;
|
|
@@ -209,10 +232,16 @@ class Processor {
|
|
|
209
232
|
this.jobsMapByNodeKey[job.nodeKey] = job.result;
|
|
210
233
|
return job;
|
|
211
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* @experimental
|
|
237
|
+
*/
|
|
212
238
|
getBranches(node) {
|
|
213
239
|
return this.nodes.filter((item) => item.upstream === node && item.branchIndex !== null).sort((a, b) => Number(a.branchIndex) - Number(b.branchIndex));
|
|
214
240
|
}
|
|
215
|
-
|
|
241
|
+
/**
|
|
242
|
+
* @experimental
|
|
243
|
+
* find the first node in current branch
|
|
244
|
+
*/
|
|
216
245
|
findBranchStartNode(node, parent) {
|
|
217
246
|
for (let n = node; n; n = n.upstream) {
|
|
218
247
|
if (!parent) {
|
|
@@ -227,7 +256,10 @@ class Processor {
|
|
|
227
256
|
}
|
|
228
257
|
return null;
|
|
229
258
|
}
|
|
230
|
-
|
|
259
|
+
/**
|
|
260
|
+
* @experimental
|
|
261
|
+
* find the node start current branch
|
|
262
|
+
*/
|
|
231
263
|
findBranchParentNode(node) {
|
|
232
264
|
for (let n = node; n; n = n.upstream) {
|
|
233
265
|
if (n.branchIndex !== null) {
|
|
@@ -236,6 +268,9 @@ class Processor {
|
|
|
236
268
|
}
|
|
237
269
|
return null;
|
|
238
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* @experimental
|
|
273
|
+
*/
|
|
239
274
|
findBranchEndNode(node) {
|
|
240
275
|
for (let n = node; n; n = n.downstream) {
|
|
241
276
|
if (!n.downstream) {
|
|
@@ -244,6 +279,9 @@ class Processor {
|
|
|
244
279
|
}
|
|
245
280
|
return null;
|
|
246
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* @experimental
|
|
284
|
+
*/
|
|
247
285
|
findBranchParentJob(job, node) {
|
|
248
286
|
for (let j = job; j; j = this.jobsMap.get(j.upstreamId)) {
|
|
249
287
|
if (j.nodeId === node.id) {
|
|
@@ -252,6 +290,9 @@ class Processor {
|
|
|
252
290
|
}
|
|
253
291
|
return null;
|
|
254
292
|
}
|
|
293
|
+
/**
|
|
294
|
+
* @experimental
|
|
295
|
+
*/
|
|
255
296
|
findBranchLastJob(node, job) {
|
|
256
297
|
const allJobs = Array.from(this.jobsMap.values());
|
|
257
298
|
const branchJobs = [];
|
|
@@ -268,6 +309,9 @@ class Processor {
|
|
|
268
309
|
}
|
|
269
310
|
return null;
|
|
270
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* @experimental
|
|
314
|
+
*/
|
|
271
315
|
getScope(sourceNodeId) {
|
|
272
316
|
const node = this.nodesMap.get(sourceNodeId);
|
|
273
317
|
const systemFns = {};
|
|
@@ -292,6 +336,9 @@ class Processor {
|
|
|
292
336
|
$scopes
|
|
293
337
|
};
|
|
294
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* @experimental
|
|
341
|
+
*/
|
|
295
342
|
getParsedValue(value, sourceNodeId, additionalScope) {
|
|
296
343
|
const template = (0, import_utils.parse)(value);
|
|
297
344
|
const scope = Object.assign(this.getScope(sourceNodeId), additionalScope);
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
6
6
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
7
|
-
"version": "0.21.0-alpha.
|
|
7
|
+
"version": "0.21.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",
|
|
11
11
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nocobase/plugin-workflow-test": "0.21.0-alpha.
|
|
13
|
+
"@nocobase/plugin-workflow-test": "0.21.0-alpha.7"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@ant-design/icons": "5.x",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"@formily/react": "2.x",
|
|
20
20
|
"@types/ejs": "^3.1.1",
|
|
21
21
|
"antd": "5.x",
|
|
22
|
-
"axios": "^0.26.1",
|
|
23
22
|
"classnames": "^2.3.1",
|
|
24
23
|
"cron-parser": "4.4.0",
|
|
25
24
|
"dayjs": "^1.11.8",
|
|
@@ -45,7 +44,7 @@
|
|
|
45
44
|
"@nocobase/test": "0.x",
|
|
46
45
|
"@nocobase/utils": "0.x"
|
|
47
46
|
},
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "b1be3993f8aa81173d01bc390aa8e4c5adcc0e2d",
|
|
49
48
|
"keywords": [
|
|
50
49
|
"Workflow"
|
|
51
50
|
]
|