@nocobase/plugin-workflow 0.14.0-alpha.7 → 0.14.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.
- package/dist/client/AddButton.d.ts +2 -1
- package/dist/client/Branch.d.ts +4 -2
- package/dist/client/constants.d.ts +2 -0
- package/dist/client/hooks/useGetAriaLabelOfAddButton.d.ts +6 -0
- package/dist/client/index.d.ts +8 -2
- package/dist/client/index.js +100 -97
- package/dist/client/nodes/aggregate.d.ts +3 -3
- package/dist/client/nodes/calculation.d.ts +6 -5
- package/dist/client/nodes/create.d.ts +3 -2
- package/dist/client/nodes/index.d.ts +1 -1
- package/dist/client/nodes/manual/index.d.ts +3 -3
- package/dist/client/nodes/query.d.ts +3 -2
- package/dist/client/schemas/collection.d.ts +1 -0
- package/dist/client/triggers/collection.d.ts +1 -0
- package/dist/client/triggers/form.d.ts +2 -0
- package/dist/client/triggers/index.d.ts +4 -0
- package/dist/client/variable.d.ts +1 -0
- package/dist/externalVersion.js +9 -10
- package/dist/locale/zh-CN.d.ts +5 -3
- package/dist/locale/zh-CN.js +5 -3
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.js +4 -1
- package/dist/server/Processor.d.ts +4 -4
- package/dist/server/Processor.js +9 -6
- package/dist/server/actions/workflows.d.ts +1 -0
- package/dist/server/actions/workflows.js +13 -52
- package/dist/server/collections/flow_nodes.js +4 -0
- package/dist/server/constants.d.ts +2 -0
- package/dist/server/constants.js +4 -2
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +2 -0
- package/dist/server/instructions/index.d.ts +3 -1
- package/dist/server/migrations/20230221162902-jsonb-to-json.js +0 -16
- package/dist/server/migrations/20230809113132-workflow-options.js +5 -2
- package/dist/server/migrations/20231024172342-add-node-key.d.ts +4 -0
- package/dist/server/migrations/20231024172342-add-node-key.js +80 -0
- package/dist/server/triggers/form.d.ts +3 -3
- package/dist/server/triggers/form.js +15 -11
- package/dist/server/triggers/index.d.ts +2 -0
- package/dist/server/triggers/index.js +1 -1
- package/dist/server/triggers/schedule.js +1 -1
- package/dist/server/utils.js +5 -4
- package/package.json +2 -3
|
@@ -48,22 +48,6 @@ class jsonb_to_json_default extends import_server.Migration {
|
|
|
48
48
|
},
|
|
49
49
|
{ transaction }
|
|
50
50
|
);
|
|
51
|
-
await queryInterface.changeColumn(
|
|
52
|
-
db.getCollection("executions").model.getTableName(),
|
|
53
|
-
"context",
|
|
54
|
-
{
|
|
55
|
-
type: import_database.DataTypes.JSON
|
|
56
|
-
},
|
|
57
|
-
{ transaction }
|
|
58
|
-
);
|
|
59
|
-
await queryInterface.changeColumn(
|
|
60
|
-
db.getCollection("jobs").model.getTableName(),
|
|
61
|
-
"result",
|
|
62
|
-
{
|
|
63
|
-
type: import_database.DataTypes.JSON
|
|
64
|
-
},
|
|
65
|
-
{ transaction }
|
|
66
|
-
);
|
|
67
51
|
});
|
|
68
52
|
}
|
|
69
53
|
}
|
|
@@ -23,18 +23,21 @@ module.exports = __toCommonJS(workflow_options_exports);
|
|
|
23
23
|
var import_server = require("@nocobase/server");
|
|
24
24
|
class workflow_options_default extends import_server.Migration {
|
|
25
25
|
async up() {
|
|
26
|
-
const match = await this.app.version.satisfies("<0.
|
|
26
|
+
const match = await this.app.version.satisfies("<0.14.0-alpha.8");
|
|
27
27
|
if (!match) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const { db } = this.context;
|
|
31
|
-
const WorkflowRepo = db.getRepository("
|
|
31
|
+
const WorkflowRepo = db.getRepository("workflows");
|
|
32
32
|
await db.sequelize.transaction(async (transaction) => {
|
|
33
33
|
const workflows = await WorkflowRepo.find({
|
|
34
34
|
transaction
|
|
35
35
|
});
|
|
36
36
|
await workflows.reduce(
|
|
37
37
|
(promise, workflow) => promise.then(() => {
|
|
38
|
+
if (!workflow.useTransaction) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
38
41
|
workflow.set("options", {
|
|
39
42
|
useTransaction: workflow.get("useTransaction")
|
|
40
43
|
});
|
|
@@ -0,0 +1,80 @@
|
|
|
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 add_node_key_exports = {};
|
|
19
|
+
__export(add_node_key_exports, {
|
|
20
|
+
default: () => add_node_key_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(add_node_key_exports);
|
|
23
|
+
var import_sequelize = require("sequelize");
|
|
24
|
+
var import_server = require("@nocobase/server");
|
|
25
|
+
var import_utils = require("@nocobase/utils");
|
|
26
|
+
function migrateNodeConfig(config = {}, nodesMap) {
|
|
27
|
+
Object.keys(config).forEach((key) => {
|
|
28
|
+
const valueType = typeof config[key];
|
|
29
|
+
if (valueType === "string") {
|
|
30
|
+
config[key] = config[key].replace(/{{\s*\$jobsMapByNodeId\.(\d+)(\.[^}]+)?\s*}}/g, (matched, id, path) => {
|
|
31
|
+
return `{{$jobsMapByNodeKey.${nodesMap[id].key}${path || ""}}}`;
|
|
32
|
+
}).replace(/{{\s*\$scopes\.(\d+)(\.[^}]+)?\s*}}/g, (matched, id, path) => {
|
|
33
|
+
return `{{$scopes.${nodesMap[id].key}${path || ""}}}`;
|
|
34
|
+
});
|
|
35
|
+
} else if (valueType === "object" && config[key]) {
|
|
36
|
+
migrateNodeConfig(config[key], nodesMap);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
class add_node_key_default extends import_server.Migration {
|
|
42
|
+
async up() {
|
|
43
|
+
const match = await this.app.version.satisfies("<0.14.0-alpha.8");
|
|
44
|
+
if (!match) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const { db } = this.context;
|
|
48
|
+
const NodeCollection = db.getCollection("flow_nodes");
|
|
49
|
+
const NodeRepo = NodeCollection.repository;
|
|
50
|
+
const tableName = NodeCollection.getTableNameWithSchema();
|
|
51
|
+
await db.sequelize.transaction(async (transaction) => {
|
|
52
|
+
if (!await NodeCollection.getField("key").existsInDb()) {
|
|
53
|
+
await this.queryInterface.addColumn(tableName, "key", import_sequelize.DataTypes.STRING, {
|
|
54
|
+
transaction
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const nodes = await NodeRepo.find({
|
|
58
|
+
transaction
|
|
59
|
+
});
|
|
60
|
+
const nodesMap = nodes.reduce((map, node) => {
|
|
61
|
+
map[node.id] = node;
|
|
62
|
+
if (!node.get("key")) {
|
|
63
|
+
node.set("key", (0, import_utils.uid)());
|
|
64
|
+
}
|
|
65
|
+
return map;
|
|
66
|
+
}, {});
|
|
67
|
+
await nodes.reduce(
|
|
68
|
+
(promise, node) => promise.then(() => {
|
|
69
|
+
node.set("config", migrateNodeConfig(node.config, nodesMap));
|
|
70
|
+
node.changed("config", true);
|
|
71
|
+
return node.save({
|
|
72
|
+
silent: true,
|
|
73
|
+
transaction
|
|
74
|
+
});
|
|
75
|
+
}),
|
|
76
|
+
Promise.resolve()
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -3,9 +3,9 @@ import Plugin from '..';
|
|
|
3
3
|
import { WorkflowModel } from '../types';
|
|
4
4
|
export default class FormTrigger extends Trigger {
|
|
5
5
|
constructor(plugin: Plugin);
|
|
6
|
-
triggerAction
|
|
7
|
-
middleware: (context: any, next: any) => Promise<
|
|
8
|
-
trigger
|
|
6
|
+
triggerAction(context: any, next: any): Promise<any>;
|
|
7
|
+
middleware: (context: any, next: any) => Promise<any>;
|
|
8
|
+
private trigger;
|
|
9
9
|
on(workflow: WorkflowModel): void;
|
|
10
10
|
off(workflow: WorkflowModel): void;
|
|
11
11
|
}
|
|
@@ -28,11 +28,8 @@ class FormTrigger extends import__.Trigger {
|
|
|
28
28
|
constructor(plugin) {
|
|
29
29
|
super(plugin);
|
|
30
30
|
plugin.app.resourcer.use(this.middleware);
|
|
31
|
-
plugin.app.actions({
|
|
32
|
-
["workflows:trigger"]: this.triggerAction
|
|
33
|
-
});
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
async triggerAction(context, next) {
|
|
36
33
|
const { triggerWorkflows } = context.action.params;
|
|
37
34
|
if (!triggerWorkflows) {
|
|
38
35
|
return context.throw(400);
|
|
@@ -40,20 +37,27 @@ class FormTrigger extends import__.Trigger {
|
|
|
40
37
|
context.status = 202;
|
|
41
38
|
await next();
|
|
42
39
|
this.trigger(context);
|
|
43
|
-
}
|
|
40
|
+
}
|
|
44
41
|
middleware = async (context, next) => {
|
|
42
|
+
const {
|
|
43
|
+
resourceName,
|
|
44
|
+
actionName,
|
|
45
|
+
params: { triggerWorkflows }
|
|
46
|
+
} = context.action;
|
|
47
|
+
if (resourceName === "workflows" && actionName === "trigger") {
|
|
48
|
+
return this.triggerAction(context, next);
|
|
49
|
+
}
|
|
45
50
|
await next();
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
if (!triggerWorkflows) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!["create", "update"].includes(actionName)) {
|
|
48
55
|
return;
|
|
49
56
|
}
|
|
50
57
|
this.trigger(context);
|
|
51
58
|
};
|
|
52
59
|
async trigger(context) {
|
|
53
|
-
const { triggerWorkflows, values } = context.action.params;
|
|
54
|
-
if (!triggerWorkflows) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
60
|
+
const { triggerWorkflows = "", values } = context.action.params;
|
|
57
61
|
const { currentUser } = context.state;
|
|
58
62
|
const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
|
|
59
63
|
const workflowRepo = this.plugin.db.getRepository("workflows");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Transactionable } from '@nocobase/database';
|
|
1
2
|
import Plugin from '..';
|
|
2
3
|
import type { WorkflowModel } from '../types';
|
|
3
4
|
export declare abstract class Trigger {
|
|
@@ -5,6 +6,7 @@ export declare abstract class Trigger {
|
|
|
5
6
|
constructor(plugin: Plugin);
|
|
6
7
|
abstract on(workflow: WorkflowModel): void;
|
|
7
8
|
abstract off(workflow: WorkflowModel): void;
|
|
9
|
+
duplicateConfig?(workflow: WorkflowModel, options: Transactionable): object | Promise<object>;
|
|
8
10
|
}
|
|
9
11
|
export default function <T extends Trigger>(plugin: any, more?: {
|
|
10
12
|
[key: string]: {
|
|
@@ -31,8 +31,8 @@ __export(triggers_exports, {
|
|
|
31
31
|
default: () => triggers_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(triggers_exports);
|
|
34
|
-
var import_utils = require("@nocobase/utils");
|
|
35
34
|
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_utils = require("@nocobase/utils");
|
|
36
36
|
class Trigger {
|
|
37
37
|
constructor(plugin) {
|
|
38
38
|
this.plugin = plugin;
|
|
@@ -362,7 +362,7 @@ class ScheduleTrigger extends import__.Trigger {
|
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
init() {
|
|
365
|
-
if (this.plugin.app.name !== "main") {
|
|
365
|
+
if (this.plugin.app.getPlugin("multi-app-share-collection").enabled && this.plugin.app.name !== "main") {
|
|
366
366
|
return;
|
|
367
367
|
}
|
|
368
368
|
if (this.timer) {
|
package/dist/server/utils.js
CHANGED
|
@@ -20,16 +20,17 @@ __export(utils_exports, {
|
|
|
20
20
|
toJSON: () => toJSON
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(utils_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
23
24
|
function toJSON(data) {
|
|
24
|
-
if (typeof data !== "object" || !data) {
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
25
|
if (Array.isArray(data)) {
|
|
28
26
|
return data.map(toJSON);
|
|
29
27
|
}
|
|
28
|
+
if (!(data instanceof import_database.Model) || !data) {
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
30
31
|
const result = data.get();
|
|
31
32
|
Object.keys(data.constructor.associations).forEach((key) => {
|
|
32
|
-
if (result[key] != null) {
|
|
33
|
+
if (result[key] != null && typeof result[key] === "object") {
|
|
33
34
|
result[key] = toJSON(result[key]);
|
|
34
35
|
}
|
|
35
36
|
});
|
package/package.json
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful workflow plugin designed to support business process management and automation.",
|
|
6
6
|
"description.zh-CN": "工作流插件,为业务流程管理和自动化提供支持。",
|
|
7
|
-
"version": "0.14.0-alpha.
|
|
7
|
+
"version": "0.14.0-alpha.8",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@ant-design/icons": "5.x",
|
|
12
|
-
"@emotion/css": "^11.7.1",
|
|
13
12
|
"@formily/antd-v5": "1.x",
|
|
14
13
|
"@formily/core": "2.x",
|
|
15
14
|
"@formily/react": "2.x",
|
|
@@ -42,5 +41,5 @@
|
|
|
42
41
|
"@nocobase/test": "0.x",
|
|
43
42
|
"@nocobase/utils": "0.x"
|
|
44
43
|
},
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "59c82fef6e34707802b5841f5ec4d9b3b6b68abb"
|
|
46
45
|
}
|