@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.
Files changed (84) 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/WorkflowTodo.d.ts +5 -0
  7. package/dist/client/WorkflowTodoBlockInitializer.d.ts +2 -0
  8. package/dist/client/index.d.ts +6 -0
  9. package/dist/client/index.js +13 -0
  10. package/dist/client/instruction/AssigneesSelect.d.ts +6 -0
  11. package/dist/client/instruction/DetailsBlockProvider.d.ts +2 -0
  12. package/dist/client/instruction/FormBlockInitializer.d.ts +2 -0
  13. package/dist/client/instruction/FormBlockProvider.d.ts +2 -0
  14. package/dist/client/instruction/ModeConfig.d.ts +5 -0
  15. package/dist/client/instruction/SchemaConfig.d.ts +49 -0
  16. package/dist/client/instruction/forms/create.d.ts +3 -0
  17. package/dist/client/instruction/forms/custom.d.ts +5 -0
  18. package/dist/client/instruction/forms/update.d.ts +3 -0
  19. package/dist/client/instruction/index.d.ts +83 -0
  20. package/dist/client/instruction/utils.d.ts +1 -0
  21. package/dist/externalVersion.js +18 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +39 -0
  24. package/dist/locale/en-US.json +30 -0
  25. package/dist/locale/index.d.ts +3 -0
  26. package/dist/locale/index.js +39 -0
  27. package/dist/locale/zh-CN.json +30 -0
  28. package/dist/server/ManualInstruction.d.ts +28 -0
  29. package/dist/server/ManualInstruction.js +150 -0
  30. package/dist/server/Plugin.d.ts +6 -0
  31. package/dist/server/Plugin.js +73 -0
  32. package/dist/server/actions.d.ts +2 -0
  33. package/dist/server/actions.js +94 -0
  34. package/dist/server/collecions/jobs.d.ts +19 -0
  35. package/dist/server/collecions/jobs.js +39 -0
  36. package/dist/server/collecions/users.d.ts +15 -0
  37. package/dist/server/collecions/users.js +37 -0
  38. package/dist/server/collecions/users_jobs.d.ts +3 -0
  39. package/dist/server/collecions/users_jobs.js +70 -0
  40. package/dist/server/forms/create.d.ts +5 -0
  41. package/dist/server/forms/create.js +41 -0
  42. package/dist/server/forms/index.d.ts +6 -0
  43. package/dist/server/forms/index.js +38 -0
  44. package/dist/server/forms/update.d.ts +6 -0
  45. package/dist/server/forms/update.js +41 -0
  46. package/dist/server/index.d.ts +1 -0
  47. package/dist/server/index.js +33 -0
  48. package/package.json +33 -0
  49. package/server.d.ts +2 -0
  50. package/server.js +1 -0
  51. package/src/client/WorkflowTodo.tsx +618 -0
  52. package/src/client/WorkflowTodoBlockInitializer.tsx +30 -0
  53. package/src/client/index.ts +44 -0
  54. package/src/client/instruction/AssigneesSelect.tsx +39 -0
  55. package/src/client/instruction/DetailsBlockProvider.tsx +85 -0
  56. package/src/client/instruction/FormBlockInitializer.tsx +72 -0
  57. package/src/client/instruction/FormBlockProvider.tsx +84 -0
  58. package/src/client/instruction/ModeConfig.tsx +85 -0
  59. package/src/client/instruction/SchemaConfig.tsx +538 -0
  60. package/src/client/instruction/forms/create.tsx +112 -0
  61. package/src/client/instruction/forms/custom.tsx +403 -0
  62. package/src/client/instruction/forms/update.tsx +150 -0
  63. package/src/client/instruction/index.tsx +157 -0
  64. package/src/client/instruction/utils.ts +19 -0
  65. package/src/index.ts +2 -0
  66. package/src/locale/en-US.json +30 -0
  67. package/src/locale/index.ts +12 -0
  68. package/src/locale/zh-CN.json +30 -0
  69. package/src/server/ManualInstruction.ts +151 -0
  70. package/src/server/Plugin.ts +48 -0
  71. package/src/server/__tests__/collections/categories.ts +15 -0
  72. package/src/server/__tests__/collections/comments.ts +24 -0
  73. package/src/server/__tests__/collections/posts.ts +40 -0
  74. package/src/server/__tests__/collections/replies.ts +9 -0
  75. package/src/server/__tests__/collections/tags.ts +15 -0
  76. package/src/server/__tests__/instruction.test.ts +1154 -0
  77. package/src/server/actions.ts +100 -0
  78. package/src/server/collecions/jobs.ts +17 -0
  79. package/src/server/collecions/users.ts +15 -0
  80. package/src/server/collecions/users_jobs.ts +50 -0
  81. package/src/server/forms/create.ts +23 -0
  82. package/src/server/forms/index.ts +13 -0
  83. package/src/server/forms/update.ts +23 -0
  84. 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,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,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,2 @@
1
+ import { Context } from '@nocobase/actions';
2
+ export declare function submit(context: Context, next: any): Promise<never>;
@@ -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,3 @@
1
+ import { CollectionOptions } from '@nocobase/database';
2
+ declare const _default: CollectionOptions;
3
+ export default _default;
@@ -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,5 @@
1
+ import { Processor } from '@nocobase/plugin-workflow';
2
+ import ManualInstruction from '../ManualInstruction';
3
+ export default function (this: ManualInstruction, instance: any, { collection }: {
4
+ collection: any;
5
+ }, 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 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';