@nocobase/plugin-workflow-manual 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.
- package/LICENSE +661 -0
- package/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/WorkflowTodo.d.ts +5 -0
- package/dist/client/WorkflowTodoBlockInitializer.d.ts +2 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +13 -0
- package/dist/client/instruction/AssigneesSelect.d.ts +6 -0
- package/dist/client/instruction/DetailsBlockProvider.d.ts +2 -0
- package/dist/client/instruction/FormBlockInitializer.d.ts +2 -0
- package/dist/client/instruction/FormBlockProvider.d.ts +2 -0
- package/dist/client/instruction/ModeConfig.d.ts +5 -0
- package/dist/client/instruction/SchemaConfig.d.ts +49 -0
- package/dist/client/instruction/forms/create.d.ts +3 -0
- package/dist/client/instruction/forms/custom.d.ts +5 -0
- package/dist/client/instruction/forms/update.d.ts +3 -0
- package/dist/client/instruction/index.d.ts +83 -0
- package/dist/client/instruction/utils.d.ts +1 -0
- package/dist/externalVersion.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +30 -0
- package/dist/locale/index.d.ts +3 -0
- package/dist/locale/index.js +39 -0
- package/dist/locale/zh-CN.json +30 -0
- package/dist/server/ManualInstruction.d.ts +28 -0
- package/dist/server/ManualInstruction.js +150 -0
- package/dist/server/Plugin.d.ts +6 -0
- package/dist/server/Plugin.js +73 -0
- package/dist/server/actions.d.ts +2 -0
- package/dist/server/actions.js +94 -0
- package/dist/server/collecions/jobs.d.ts +19 -0
- package/dist/server/collecions/jobs.js +39 -0
- package/dist/server/collecions/users.d.ts +15 -0
- package/dist/server/collecions/users.js +37 -0
- package/dist/server/collecions/users_jobs.d.ts +3 -0
- package/dist/server/collecions/users_jobs.js +70 -0
- package/dist/server/forms/create.d.ts +5 -0
- package/dist/server/forms/create.js +41 -0
- package/dist/server/forms/index.d.ts +6 -0
- package/dist/server/forms/index.js +38 -0
- package/dist/server/forms/update.d.ts +6 -0
- package/dist/server/forms/update.js +41 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/package.json +33 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
- package/src/client/WorkflowTodo.tsx +618 -0
- package/src/client/WorkflowTodoBlockInitializer.tsx +30 -0
- package/src/client/index.ts +44 -0
- package/src/client/instruction/AssigneesSelect.tsx +39 -0
- package/src/client/instruction/DetailsBlockProvider.tsx +85 -0
- package/src/client/instruction/FormBlockInitializer.tsx +72 -0
- package/src/client/instruction/FormBlockProvider.tsx +84 -0
- package/src/client/instruction/ModeConfig.tsx +85 -0
- package/src/client/instruction/SchemaConfig.tsx +538 -0
- package/src/client/instruction/forms/create.tsx +112 -0
- package/src/client/instruction/forms/custom.tsx +403 -0
- package/src/client/instruction/forms/update.tsx +150 -0
- package/src/client/instruction/index.tsx +157 -0
- package/src/client/instruction/utils.ts +19 -0
- package/src/index.ts +2 -0
- package/src/locale/en-US.json +30 -0
- package/src/locale/index.ts +12 -0
- package/src/locale/zh-CN.json +30 -0
- package/src/server/ManualInstruction.ts +151 -0
- package/src/server/Plugin.ts +48 -0
- package/src/server/__tests__/collections/categories.ts +15 -0
- package/src/server/__tests__/collections/comments.ts +24 -0
- package/src/server/__tests__/collections/posts.ts +40 -0
- package/src/server/__tests__/collections/replies.ts +9 -0
- package/src/server/__tests__/collections/tags.ts +15 -0
- package/src/server/__tests__/instruction.test.ts +1154 -0
- package/src/server/actions.ts +100 -0
- package/src/server/collecions/jobs.ts +17 -0
- package/src/server/collecions/users.ts +15 -0
- package/src/server/collecions/users_jobs.ts +50 -0
- package/src/server/forms/create.ts +23 -0
- package/src/server/forms/index.ts +13 -0
- package/src/server/forms/update.ts +23 -0
- package/src/server/index.ts +1 -0
|
@@ -0,0 +1,150 @@
|
|
|
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 ManualInstruction_exports = {};
|
|
29
|
+
__export(ManualInstruction_exports, {
|
|
30
|
+
default: () => ManualInstruction_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(ManualInstruction_exports);
|
|
33
|
+
var import_utils = require("@nocobase/utils");
|
|
34
|
+
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
35
|
+
var import_forms = __toESM(require("./forms"));
|
|
36
|
+
const MULTIPLE_ASSIGNED_MODE = {
|
|
37
|
+
SINGLE: Symbol("single"),
|
|
38
|
+
ALL: Symbol("all"),
|
|
39
|
+
ANY: Symbol("any"),
|
|
40
|
+
ALL_PERCENTAGE: Symbol("all percentage"),
|
|
41
|
+
ANY_PERCENTAGE: Symbol("any percentage")
|
|
42
|
+
};
|
|
43
|
+
const Modes = {
|
|
44
|
+
[MULTIPLE_ASSIGNED_MODE.SINGLE]: {
|
|
45
|
+
getStatus(distribution, assignees) {
|
|
46
|
+
const done = distribution.find((item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING && item.count > 0);
|
|
47
|
+
return done ? done.status : null;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[MULTIPLE_ASSIGNED_MODE.ALL]: {
|
|
51
|
+
getStatus(distribution, assignees) {
|
|
52
|
+
const resolved = distribution.find((item) => item.status === import_plugin_workflow.JOB_STATUS.RESOLVED);
|
|
53
|
+
if (resolved && resolved.count === assignees.length) {
|
|
54
|
+
return import_plugin_workflow.JOB_STATUS.RESOLVED;
|
|
55
|
+
}
|
|
56
|
+
const rejected = distribution.find((item) => item.status < import_plugin_workflow.JOB_STATUS.PENDING);
|
|
57
|
+
if (rejected && rejected.count) {
|
|
58
|
+
return rejected.status;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
[MULTIPLE_ASSIGNED_MODE.ANY]: {
|
|
64
|
+
getStatus(distribution, assignees) {
|
|
65
|
+
const resolved = distribution.find((item) => item.status === import_plugin_workflow.JOB_STATUS.RESOLVED);
|
|
66
|
+
if (resolved && resolved.count) {
|
|
67
|
+
return import_plugin_workflow.JOB_STATUS.RESOLVED;
|
|
68
|
+
}
|
|
69
|
+
const rejectedCount = distribution.reduce(
|
|
70
|
+
(count, item) => item.status < import_plugin_workflow.JOB_STATUS.PENDING ? count + item.count : count,
|
|
71
|
+
0
|
|
72
|
+
);
|
|
73
|
+
if (rejectedCount === assignees.length) {
|
|
74
|
+
return import_plugin_workflow.JOB_STATUS.REJECTED;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
function getMode(mode) {
|
|
81
|
+
switch (true) {
|
|
82
|
+
case mode === 1:
|
|
83
|
+
return Modes[MULTIPLE_ASSIGNED_MODE.ALL];
|
|
84
|
+
case mode === -1:
|
|
85
|
+
return Modes[MULTIPLE_ASSIGNED_MODE.ANY];
|
|
86
|
+
case mode > 0:
|
|
87
|
+
return Modes[MULTIPLE_ASSIGNED_MODE.ALL_PERCENTAGE];
|
|
88
|
+
case mode < 0:
|
|
89
|
+
return Modes[MULTIPLE_ASSIGNED_MODE.ANY_PERCENTAGE];
|
|
90
|
+
default:
|
|
91
|
+
return Modes[MULTIPLE_ASSIGNED_MODE.SINGLE];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
class ManualInstruction_default extends import_plugin_workflow.Instruction {
|
|
95
|
+
constructor(plugin) {
|
|
96
|
+
super(plugin);
|
|
97
|
+
this.plugin = plugin;
|
|
98
|
+
(0, import_forms.default)(this);
|
|
99
|
+
}
|
|
100
|
+
formTypes = new import_utils.Registry();
|
|
101
|
+
async run(node, prevJob, processor) {
|
|
102
|
+
const { mode, ...config } = node.config;
|
|
103
|
+
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id) || [])];
|
|
104
|
+
const job = await processor.saveJob({
|
|
105
|
+
status: import_plugin_workflow.JOB_STATUS.PENDING,
|
|
106
|
+
result: mode ? [] : null,
|
|
107
|
+
nodeId: node.id,
|
|
108
|
+
upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
|
|
109
|
+
});
|
|
110
|
+
const UserJobModel = processor.options.plugin.db.getModel("users_jobs");
|
|
111
|
+
await UserJobModel.bulkCreate(
|
|
112
|
+
assignees.map((userId) => ({
|
|
113
|
+
userId,
|
|
114
|
+
jobId: job.id,
|
|
115
|
+
nodeId: node.id,
|
|
116
|
+
executionId: job.executionId,
|
|
117
|
+
workflowId: node.workflowId,
|
|
118
|
+
status: import_plugin_workflow.JOB_STATUS.PENDING
|
|
119
|
+
})),
|
|
120
|
+
{
|
|
121
|
+
transaction: processor.transaction
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
return job;
|
|
125
|
+
}
|
|
126
|
+
async resume(node, job, processor) {
|
|
127
|
+
var _a;
|
|
128
|
+
const { assignees = [], mode } = node.config;
|
|
129
|
+
const UserJobModel = processor.options.plugin.db.getModel("users_jobs");
|
|
130
|
+
const distribution = await UserJobModel.count({
|
|
131
|
+
where: {
|
|
132
|
+
jobId: job.id
|
|
133
|
+
},
|
|
134
|
+
group: ["status"],
|
|
135
|
+
transaction: processor.transaction
|
|
136
|
+
});
|
|
137
|
+
const submitted = distribution.reduce(
|
|
138
|
+
(count, item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING ? count + item.count : count,
|
|
139
|
+
0
|
|
140
|
+
);
|
|
141
|
+
const status = job.status || (getMode(mode).getStatus(distribution, assignees) ?? import_plugin_workflow.JOB_STATUS.PENDING);
|
|
142
|
+
const result = mode ? (submitted || 0) / assignees.length : ((_a = job.latestUserJob) == null ? void 0 : _a.result) ?? job.result;
|
|
143
|
+
processor.logger.debug(`manual resume job and next status: ${status}`);
|
|
144
|
+
job.set({
|
|
145
|
+
status,
|
|
146
|
+
result
|
|
147
|
+
});
|
|
148
|
+
return job;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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_actions = __toESM(require("@nocobase/actions"));
|
|
35
|
+
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
36
|
+
var import_jobs = __toESM(require("./collecions/jobs"));
|
|
37
|
+
var import_users = __toESM(require("./collecions/users"));
|
|
38
|
+
var import_users_jobs = __toESM(require("./collecions/users_jobs"));
|
|
39
|
+
var import_actions2 = require("./actions");
|
|
40
|
+
var import_ManualInstruction = __toESM(require("./ManualInstruction"));
|
|
41
|
+
class Plugin_default extends import_server.Plugin {
|
|
42
|
+
workflow;
|
|
43
|
+
async load() {
|
|
44
|
+
this.app.db.collection(import_users_jobs.default);
|
|
45
|
+
this.app.db.extendCollection(import_users.default);
|
|
46
|
+
this.app.db.extendCollection(import_jobs.default);
|
|
47
|
+
this.app.resource({
|
|
48
|
+
name: "users_jobs",
|
|
49
|
+
actions: {
|
|
50
|
+
list: {
|
|
51
|
+
filter: {
|
|
52
|
+
$or: [
|
|
53
|
+
{
|
|
54
|
+
"workflow.enabled": true
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"workflow.enabled": false,
|
|
58
|
+
status: {
|
|
59
|
+
$ne: import_plugin_workflow.JOB_STATUS.PENDING
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
handler: import_actions.default.list
|
|
65
|
+
},
|
|
66
|
+
submit: import_actions2.submit
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const workflowPlugin = this.app.getPlugin("workflow");
|
|
70
|
+
this.workflow = workflowPlugin;
|
|
71
|
+
workflowPlugin.instructions.register("manual", new import_ManualInstruction.default(workflowPlugin));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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 actions_exports = {};
|
|
19
|
+
__export(actions_exports, {
|
|
20
|
+
submit: () => submit
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(actions_exports);
|
|
23
|
+
var import_actions = require("@nocobase/actions");
|
|
24
|
+
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
25
|
+
async function submit(context, next) {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
28
|
+
const { filterByTk, values } = context.action.params;
|
|
29
|
+
const { currentUser } = context.state;
|
|
30
|
+
if (!currentUser) {
|
|
31
|
+
return context.throw(401);
|
|
32
|
+
}
|
|
33
|
+
const plugin = context.app.pm.get("workflow");
|
|
34
|
+
const instruction = plugin.instructions.get("manual");
|
|
35
|
+
const userJob = await repository.findOne({
|
|
36
|
+
filterByTk,
|
|
37
|
+
// filter: {
|
|
38
|
+
// userId: currentUser?.id
|
|
39
|
+
// },
|
|
40
|
+
appends: ["job", "node", "execution", "workflow"],
|
|
41
|
+
context
|
|
42
|
+
});
|
|
43
|
+
if (!userJob) {
|
|
44
|
+
return context.throw(404);
|
|
45
|
+
}
|
|
46
|
+
const { forms = {} } = userJob.node.config;
|
|
47
|
+
const [formKey] = Object.keys(values.result ?? {}).filter((key) => key !== "_");
|
|
48
|
+
const actionKey = (_a = values.result) == null ? void 0 : _a._;
|
|
49
|
+
const actionItem = (_c = (_b = forms[formKey]) == null ? void 0 : _b.actions) == null ? void 0 : _c.find((item) => item.key === actionKey);
|
|
50
|
+
if (userJob.status !== import_plugin_workflow.JOB_STATUS.PENDING || userJob.job.status !== import_plugin_workflow.JOB_STATUS.PENDING || userJob.execution.status !== import_plugin_workflow.EXECUTION_STATUS.STARTED || !userJob.workflow.enabled || !actionKey || (actionItem == null ? void 0 : actionItem.status) == null) {
|
|
51
|
+
return context.throw(400);
|
|
52
|
+
}
|
|
53
|
+
userJob.execution.workflow = userJob.workflow;
|
|
54
|
+
const processor = plugin.createProcessor(userJob.execution);
|
|
55
|
+
await processor.prepare();
|
|
56
|
+
const assignees = processor.getParsedValue(userJob.node.config.assignees ?? [], userJob.nodeId);
|
|
57
|
+
if (!assignees.includes(currentUser.id) || userJob.userId !== currentUser.id) {
|
|
58
|
+
return context.throw(403);
|
|
59
|
+
}
|
|
60
|
+
const presetValues = processor.getParsedValue(actionItem.values ?? {}, userJob.nodeId, {
|
|
61
|
+
// @deprecated
|
|
62
|
+
currentUser: currentUser.toJSON(),
|
|
63
|
+
// @deprecated
|
|
64
|
+
currentRecord: values.result[formKey],
|
|
65
|
+
// @deprecated
|
|
66
|
+
currentTime: /* @__PURE__ */ new Date(),
|
|
67
|
+
$user: currentUser.toJSON(),
|
|
68
|
+
$nForm: values.result[formKey],
|
|
69
|
+
$nDate: {
|
|
70
|
+
now: /* @__PURE__ */ new Date()
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
userJob.set({
|
|
74
|
+
status: actionItem.status,
|
|
75
|
+
result: actionItem.status > import_plugin_workflow.JOB_STATUS.PENDING ? { [formKey]: Object.assign(values.result[formKey], presetValues), _: actionKey } : Object.assign(userJob.result ?? {}, values.result)
|
|
76
|
+
});
|
|
77
|
+
const handler = instruction.formTypes.get(forms[formKey].type);
|
|
78
|
+
if (handler && userJob.status) {
|
|
79
|
+
await handler.call(instruction, userJob, forms[formKey], processor);
|
|
80
|
+
}
|
|
81
|
+
await userJob.save({ transaction: processor.transaction });
|
|
82
|
+
await processor.exit();
|
|
83
|
+
context.body = userJob;
|
|
84
|
+
context.status = 202;
|
|
85
|
+
await next();
|
|
86
|
+
userJob.job.execution = userJob.execution;
|
|
87
|
+
userJob.job.latestUserJob = userJob;
|
|
88
|
+
processor.logger.info(`manual node (${userJob.nodeId}) action trigger execution (${userJob.execution.id}) to resume`);
|
|
89
|
+
plugin.resume(userJob.job);
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
submit
|
|
94
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
name: string;
|
|
3
|
+
fields: ({
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
through: string;
|
|
7
|
+
target?: undefined;
|
|
8
|
+
foreignKey?: undefined;
|
|
9
|
+
onDelete?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
type: string;
|
|
12
|
+
name: string;
|
|
13
|
+
target: string;
|
|
14
|
+
foreignKey: string;
|
|
15
|
+
onDelete: string;
|
|
16
|
+
through?: undefined;
|
|
17
|
+
})[];
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -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 jobs_exports = {};
|
|
19
|
+
__export(jobs_exports, {
|
|
20
|
+
default: () => jobs_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(jobs_exports);
|
|
23
|
+
var jobs_default = {
|
|
24
|
+
name: "jobs",
|
|
25
|
+
fields: [
|
|
26
|
+
{
|
|
27
|
+
type: "belongsToMany",
|
|
28
|
+
name: "users",
|
|
29
|
+
through: "users_jobs"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "hasMany",
|
|
33
|
+
name: "usersJobs",
|
|
34
|
+
target: "users_jobs",
|
|
35
|
+
foreignKey: "jobId",
|
|
36
|
+
onDelete: "CASCADE"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
name: string;
|
|
3
|
+
fields: ({
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
through: string;
|
|
7
|
+
target?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
type: string;
|
|
10
|
+
name: string;
|
|
11
|
+
target: string;
|
|
12
|
+
through?: undefined;
|
|
13
|
+
})[];
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 users_exports = {};
|
|
19
|
+
__export(users_exports, {
|
|
20
|
+
default: () => users_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(users_exports);
|
|
23
|
+
var users_default = {
|
|
24
|
+
name: "users",
|
|
25
|
+
fields: [
|
|
26
|
+
{
|
|
27
|
+
type: "belongsToMany",
|
|
28
|
+
name: "jobs",
|
|
29
|
+
through: "users_jobs"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "hasMany",
|
|
33
|
+
name: "usersJobs",
|
|
34
|
+
target: "users_jobs"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 users_jobs_exports = {};
|
|
19
|
+
__export(users_jobs_exports, {
|
|
20
|
+
default: () => users_jobs_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(users_jobs_exports);
|
|
23
|
+
var users_jobs_default = {
|
|
24
|
+
namespace: "workflow.executionLogs",
|
|
25
|
+
name: "users_jobs",
|
|
26
|
+
duplicator: "optional",
|
|
27
|
+
fields: [
|
|
28
|
+
{
|
|
29
|
+
type: "bigInt",
|
|
30
|
+
name: "id",
|
|
31
|
+
primaryKey: true,
|
|
32
|
+
autoIncrement: true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "belongsTo",
|
|
36
|
+
name: "job",
|
|
37
|
+
target: "jobs",
|
|
38
|
+
foreignKey: "jobId",
|
|
39
|
+
primaryKey: false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "belongsTo",
|
|
43
|
+
name: "user",
|
|
44
|
+
target: "users",
|
|
45
|
+
foreignKey: "userId",
|
|
46
|
+
primaryKey: false
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: "belongsTo",
|
|
50
|
+
name: "execution"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: "belongsTo",
|
|
54
|
+
name: "node",
|
|
55
|
+
target: "flow_nodes"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: "belongsTo",
|
|
59
|
+
name: "workflow"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: "integer",
|
|
63
|
+
name: "status"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: "jsonb",
|
|
67
|
+
name: "result"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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 create_exports = {};
|
|
19
|
+
__export(create_exports, {
|
|
20
|
+
default: () => create_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(create_exports);
|
|
23
|
+
async function create_default(instance, { collection }, processor) {
|
|
24
|
+
const repo = this.plugin.db.getRepository(collection);
|
|
25
|
+
if (!repo) {
|
|
26
|
+
throw new Error(`collection ${collection} for create data on manual node not found`);
|
|
27
|
+
}
|
|
28
|
+
const { _, ...form } = instance.result;
|
|
29
|
+
const [values] = Object.values(form);
|
|
30
|
+
await repo.create({
|
|
31
|
+
values: {
|
|
32
|
+
...values ?? {},
|
|
33
|
+
createdBy: instance.userId,
|
|
34
|
+
updatedBy: instance.userId
|
|
35
|
+
},
|
|
36
|
+
context: {
|
|
37
|
+
executionId: processor.execution.id
|
|
38
|
+
},
|
|
39
|
+
transaction: processor.transaction
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Processor } from '@nocobase/plugin-workflow';
|
|
2
|
+
import ManualInstruction from '../ManualInstruction';
|
|
3
|
+
export type FormHandler = (this: ManualInstruction, instance: any, formConfig: any, processor: Processor) => Promise<void>;
|
|
4
|
+
export default function ({ formTypes }: {
|
|
5
|
+
formTypes: any;
|
|
6
|
+
}): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 forms_exports = {};
|
|
29
|
+
__export(forms_exports, {
|
|
30
|
+
default: () => forms_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(forms_exports);
|
|
33
|
+
var import_create = __toESM(require("./create"));
|
|
34
|
+
var import_update = __toESM(require("./update"));
|
|
35
|
+
function forms_default({ formTypes }) {
|
|
36
|
+
formTypes.register("create", import_create.default);
|
|
37
|
+
formTypes.register("update", import_update.default);
|
|
38
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Processor } from '@nocobase/plugin-workflow';
|
|
2
|
+
import ManualInstruction from '../ManualInstruction';
|
|
3
|
+
export default function (this: ManualInstruction, instance: any, { collection, filter }: {
|
|
4
|
+
collection: any;
|
|
5
|
+
filter?: {};
|
|
6
|
+
}, processor: Processor): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 update_exports = {};
|
|
19
|
+
__export(update_exports, {
|
|
20
|
+
default: () => update_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(update_exports);
|
|
23
|
+
async function update_default(instance, { collection, filter = {} }, processor) {
|
|
24
|
+
const repo = this.plugin.db.getRepository(collection);
|
|
25
|
+
if (!repo) {
|
|
26
|
+
throw new Error(`collection ${collection} for update data on manual node not found`);
|
|
27
|
+
}
|
|
28
|
+
const { _, ...form } = instance.result;
|
|
29
|
+
const [values] = Object.values(form);
|
|
30
|
+
await repo.update({
|
|
31
|
+
filter: processor.getParsedValue(filter, instance.nodeId),
|
|
32
|
+
values: {
|
|
33
|
+
...values ?? {},
|
|
34
|
+
updatedBy: instance.userId
|
|
35
|
+
},
|
|
36
|
+
context: {
|
|
37
|
+
executionId: processor.execution.id
|
|
38
|
+
},
|
|
39
|
+
transaction: processor.transaction
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Plugin';
|