@nocobase/plugin-workflow-manual 1.6.0-beta.9 → 1.6.1

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.
@@ -0,0 +1,71 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var constants_exports = {};
28
+ __export(constants_exports, {
29
+ MANUAL_TASK_TYPE: () => MANUAL_TASK_TYPE,
30
+ NAMESPACE: () => NAMESPACE,
31
+ TASK_STATUS: () => TASK_STATUS,
32
+ TaskStatusOptions: () => TaskStatusOptions,
33
+ TaskStatusOptionsMap: () => TaskStatusOptionsMap
34
+ });
35
+ module.exports = __toCommonJS(constants_exports);
36
+ const NAMESPACE = "workflow-manual";
37
+ const MANUAL_TASK_TYPE = "manual";
38
+ const TASK_STATUS = {
39
+ PENDING: 0,
40
+ RESOLVED: 1,
41
+ REJECTED: -1
42
+ };
43
+ const TaskStatusOptions = [
44
+ {
45
+ value: TASK_STATUS.PENDING,
46
+ label: `{{t("Pending", { ns: "workflow" })}}`,
47
+ color: "gold"
48
+ },
49
+ {
50
+ value: TASK_STATUS.RESOLVED,
51
+ label: `{{t("Resolved", { ns: "workflow" })}}`,
52
+ color: "green"
53
+ },
54
+ {
55
+ value: TASK_STATUS.REJECTED,
56
+ label: `{{t("Rejected", { ns: "workflow" })}}`,
57
+ color: "red"
58
+ }
59
+ ];
60
+ const TaskStatusOptionsMap = TaskStatusOptions.reduce(
61
+ (map, item) => Object.assign(map, { [item.value]: item }),
62
+ {}
63
+ );
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ MANUAL_TASK_TYPE,
67
+ NAMESPACE,
68
+ TASK_STATUS,
69
+ TaskStatusOptions,
70
+ TaskStatusOptionsMap
71
+ });
@@ -8,22 +8,23 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.6.0-beta.9",
11
+ "@nocobase/client": "1.6.1",
12
12
  "react": "18.2.0",
13
- "@nocobase/plugin-workflow": "1.6.0-beta.9",
14
13
  "@formily/react": "2.3.0",
14
+ "@formily/antd-v5": "1.1.9",
15
15
  "antd": "5.12.8",
16
+ "@ant-design/icons": "5.6.1",
17
+ "antd-style": "3.7.1",
16
18
  "dayjs": "1.11.10",
17
- "@ant-design/icons": "5.2.6",
18
19
  "react-i18next": "11.18.6",
19
- "@nocobase/utils": "1.6.0-beta.9",
20
- "@nocobase/server": "1.6.0-beta.9",
21
- "@nocobase/actions": "1.6.0-beta.9",
22
- "@nocobase/resourcer": "1.6.0-beta.9",
23
- "@nocobase/test": "1.6.0-beta.9",
24
- "@nocobase/plugin-workflow-test": "1.6.0-beta.9",
20
+ "lodash": "4.17.21",
21
+ "@nocobase/plugin-workflow": "1.6.1",
22
+ "@nocobase/utils": "1.6.1",
23
+ "@nocobase/server": "1.6.1",
24
+ "@nocobase/actions": "1.6.1",
25
+ "@nocobase/resourcer": "1.6.1",
26
+ "@nocobase/test": "1.6.1",
27
+ "@nocobase/plugin-workflow-test": "1.6.1",
25
28
  "@formily/core": "2.3.0",
26
- "@formily/antd-v5": "1.1.9",
27
- "@nocobase/database": "1.6.0-beta.9",
28
- "lodash": "4.17.21"
29
+ "@nocobase/database": "1.6.1"
29
30
  };
@@ -6,7 +6,8 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- export declare const NAMESPACE = "workflow-manual";
9
+ import { NAMESPACE } from '../common/constants';
10
+ export { NAMESPACE };
10
11
  export declare function useLang(key: string, options?: {}): string;
11
12
  export declare const lang: typeof useLang;
12
13
  export declare function usePluginTranslation(options?: any): import("react-i18next").UseTranslationResponse<"workflow-manual", undefined>;
@@ -26,21 +26,21 @@ var __copyProps = (to, from, except, desc) => {
26
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
27
  var locale_exports = {};
28
28
  __export(locale_exports, {
29
- NAMESPACE: () => NAMESPACE,
29
+ NAMESPACE: () => import_constants.NAMESPACE,
30
30
  lang: () => lang,
31
31
  useLang: () => useLang,
32
32
  usePluginTranslation: () => usePluginTranslation
33
33
  });
34
34
  module.exports = __toCommonJS(locale_exports);
35
35
  var import_react_i18next = require("react-i18next");
36
- const NAMESPACE = "workflow-manual";
36
+ var import_constants = require("../common/constants");
37
37
  function useLang(key, options = {}) {
38
38
  const { t } = usePluginTranslation(options);
39
39
  return t(key);
40
40
  }
41
41
  const lang = useLang;
42
42
  function usePluginTranslation(options) {
43
- return (0, import_react_i18next.useTranslation)(NAMESPACE, options);
43
+ return (0, import_react_i18next.useTranslation)(import_constants.NAMESPACE, options);
44
44
  }
45
45
  // Annotate the CommonJS export names for ESM import in node:
46
46
  0 && (module.exports = {
@@ -0,0 +1,30 @@
1
+ {
2
+ "Manual": "Manuale",
3
+ "Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.": "Può essere utilizzato per l'invio manuale di dati e per determinare se continuare o uscire. Il workflow genererà un elemento 'da fare' per l'utente assegnato quando raggiunge un nodo manuale e continuerà l'elaborazione dopo che l'utente avrà inviato il modulo.",
4
+ "Values preset in this form will override user submitted ones when continue or reject.": "I valori preimpostati in questo modulo sovrascriveranno quelli inviati dall'utente quando si continua o si rifiuta.",
5
+ "Assignee": "Assegnatario",
6
+ "Assignees": "Assegnatari",
7
+ "User interface": "Interfaccia utente",
8
+ "Configure user interface": "Configura interfaccia utente",
9
+ "View user interface": "Visualizza interfaccia utente",
10
+ "Separately": "Separato",
11
+ "Each user has own task": "Ogni utente ha il proprio compito",
12
+ "Collaboratively": "Collaborativo",
13
+ "Everyone shares one task": "Tutti condividono un compito",
14
+ "Negotiation": "Negoziazione",
15
+ "All pass": "Tutti passano",
16
+ "Everyone should pass": "Tutti dovrebbero passare",
17
+ "Any pass": "Qualcuno passa",
18
+ "Anyone pass": "Chiunque passa",
19
+ "Field name existed in form": "Nome campo esistente nel modulo",
20
+ "Continue the process": "Continua il processo",
21
+ "Terminate the process": "Termina il processo",
22
+ "Save temporarily": "Salva temporaneamente",
23
+ "Custom form": "Modulo personalizzato",
24
+ "Data record": "Record dati",
25
+ "Create record form": "Modulo creazione record",
26
+ "Update record form": "Modulo aggiornamento record",
27
+ "Filter settings": "Impostazioni filtro",
28
+ "Workflow todos": "'Da fare' del workflow",
29
+ "Task": "Compito"
30
+ }
@@ -121,9 +121,9 @@ class ManualInstruction_default extends import_plugin_workflow.Instruction {
121
121
  return job;
122
122
  }
123
123
  const title = config.title ? processor.getParsedValue(config.title, node.id) : node.title;
124
- const UserJobModel = this.workflow.app.db.getModel("users_jobs");
125
- await UserJobModel.bulkCreate(
126
- assignees.map((userId) => ({
124
+ const TaskRepo = this.workflow.app.db.getRepository("workflowManualTasks");
125
+ await TaskRepo.createMany({
126
+ records: assignees.map((userId) => ({
127
127
  userId,
128
128
  jobId: job.id,
129
129
  nodeId: node.id,
@@ -132,24 +132,22 @@ class ManualInstruction_default extends import_plugin_workflow.Instruction {
132
132
  status: import_plugin_workflow.JOB_STATUS.PENDING,
133
133
  title
134
134
  })),
135
- {
136
- transaction: processor.mainTransaction
137
- }
138
- );
135
+ transaction: processor.mainTransaction
136
+ });
139
137
  return job;
140
138
  }
141
139
  async resume(node, job, processor) {
142
140
  var _a;
143
141
  const { mode } = node.config;
144
- const UserJobRepo = this.workflow.app.db.getRepository("users_jobs");
145
- const jobs = await UserJobRepo.find({
142
+ const TaskRepo = this.workflow.app.db.getRepository("workflowManualTasks");
143
+ const tasks = await TaskRepo.find({
146
144
  where: {
147
145
  jobId: job.id
148
146
  },
149
147
  transaction: processor.mainTransaction
150
148
  });
151
149
  const assignees = [];
152
- const distributionMap = jobs.reduce((result2, item) => {
150
+ const distributionMap = tasks.reduce((result2, item) => {
153
151
  if (result2[item.status] == null) {
154
152
  result2[item.status] = 0;
155
153
  }
@@ -161,9 +159,9 @@ class ManualInstruction_default extends import_plugin_workflow.Instruction {
161
159
  status: Number.parseInt(status2, 10),
162
160
  count: distributionMap[status2]
163
161
  }));
164
- const submitted = jobs.reduce((count, item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING ? count + 1 : count, 0);
162
+ const submitted = tasks.reduce((count, item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING ? count + 1 : count, 0);
165
163
  const status = job.status || (getMode(mode).getStatus(distribution, assignees) ?? import_plugin_workflow.JOB_STATUS.PENDING);
166
- const result = mode ? (submitted || 0) / assignees.length : ((_a = job.latestUserJob) == null ? void 0 : _a.result) ?? job.result;
164
+ const result = mode ? (submitted || 0) / assignees.length : ((_a = job.latestTask) == null ? void 0 : _a.result) ?? job.result;
167
165
  processor.logger.debug(`manual resume job and next status: ${status}`);
168
166
  job.set({
169
167
  status,
@@ -44,10 +44,11 @@ var import_actions = __toESM(require("@nocobase/actions"));
44
44
  var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
45
45
  var jobActions = __toESM(require("./actions"));
46
46
  var import_ManualInstruction = __toESM(require("./ManualInstruction"));
47
+ var import_constants = require("../common/constants");
47
48
  class Plugin_default extends import_server.Plugin {
48
49
  async load() {
49
50
  this.app.resourceManager.define({
50
- name: "users_jobs",
51
+ name: "workflowManualTasks",
51
52
  actions: {
52
53
  list: {
53
54
  filter: {
@@ -68,8 +69,20 @@ class Plugin_default extends import_server.Plugin {
68
69
  ...jobActions
69
70
  }
70
71
  });
71
- this.app.acl.allow("users_jobs", ["list", "get", "submit", "countMine"], "loggedIn");
72
+ this.app.acl.allow("workflowManualTasks", ["list", "get", "submit"], "loggedIn");
72
73
  const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
73
74
  workflowPlugin.registerInstruction("manual", import_ManualInstruction.default);
75
+ this.db.on("workflowManualTasks.afterSave", async (task, options) => {
76
+ await workflowPlugin.toggleTaskStatus(
77
+ {
78
+ type: import_constants.MANUAL_TASK_TYPE,
79
+ key: `${task.id}`,
80
+ userId: task.userId,
81
+ workflowId: task.workflowId
82
+ },
83
+ Boolean(task.status),
84
+ options
85
+ );
86
+ });
74
87
  }
75
88
  }
@@ -8,4 +8,3 @@
8
8
  */
9
9
  import { Context } from '@nocobase/actions';
10
10
  export declare function submit(context: Context, next: any): Promise<never>;
11
- export declare function countMine(context: Context, next: any): Promise<void>;
@@ -36,7 +36,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var actions_exports = {};
38
38
  __export(actions_exports, {
39
- countMine: () => countMine,
40
39
  submit: () => submit
41
40
  });
42
41
  module.exports = __toCommonJS(actions_exports);
@@ -52,7 +51,7 @@ async function submit(context, next) {
52
51
  }
53
52
  const plugin = context.app.getPlugin(import_plugin_workflow.default);
54
53
  const instruction = plugin.instructions.get("manual");
55
- const userJob = await repository.findOne({
54
+ const task = await repository.findOne({
56
55
  filterByTk,
57
56
  // filter: {
58
57
  // userId: currentUser?.id
@@ -60,24 +59,24 @@ async function submit(context, next) {
60
59
  appends: ["job", "node", "execution", "workflow"],
61
60
  context
62
61
  });
63
- if (!userJob) {
62
+ if (!task) {
64
63
  return context.throw(404);
65
64
  }
66
- const { forms = {} } = userJob.node.config;
65
+ const { forms = {} } = task.node.config;
67
66
  const [formKey] = Object.keys(values.result ?? {}).filter((key) => key !== "_");
68
67
  const actionKey = (_a = values.result) == null ? void 0 : _a._;
69
68
  const actionItem = (_c = (_b = forms[formKey]) == null ? void 0 : _b.actions) == null ? void 0 : _c.find((item) => item.key === actionKey);
70
- 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) {
69
+ if (task.status !== import_plugin_workflow.JOB_STATUS.PENDING || task.job.status !== import_plugin_workflow.JOB_STATUS.PENDING || task.execution.status !== import_plugin_workflow.EXECUTION_STATUS.STARTED || !task.workflow.enabled || !actionKey || (actionItem == null ? void 0 : actionItem.status) == null) {
71
70
  return context.throw(400);
72
71
  }
73
- userJob.execution.workflow = userJob.workflow;
74
- const processor = plugin.createProcessor(userJob.execution);
72
+ task.execution.workflow = task.workflow;
73
+ const processor = plugin.createProcessor(task.execution);
75
74
  await processor.prepare();
76
- const assignees = processor.getParsedValue(userJob.node.config.assignees ?? [], userJob.nodeId).flat().filter(Boolean);
77
- if (!assignees.includes(currentUser.id) || userJob.userId !== currentUser.id) {
75
+ const assignees = processor.getParsedValue(task.node.config.assignees ?? [], task.nodeId).flat().filter(Boolean);
76
+ if (!assignees.includes(currentUser.id) || task.userId !== currentUser.id) {
78
77
  return context.throw(403);
79
78
  }
80
- const presetValues = processor.getParsedValue(actionItem.values ?? {}, userJob.nodeId, {
79
+ const presetValues = processor.getParsedValue(actionItem.values ?? {}, task.nodeId, {
81
80
  additionalScope: {
82
81
  // @deprecated
83
82
  currentUser,
@@ -92,46 +91,25 @@ async function submit(context, next) {
92
91
  }
93
92
  }
94
93
  });
95
- userJob.set({
94
+ task.set({
96
95
  status: actionItem.status,
97
- result: actionItem.status ? { [formKey]: Object.assign(values.result[formKey], presetValues), _: actionKey } : Object.assign(userJob.result ?? {}, values.result)
96
+ result: actionItem.status ? { [formKey]: Object.assign(values.result[formKey], presetValues), _: actionKey } : Object.assign(task.result ?? {}, values.result)
98
97
  });
99
98
  const handler = instruction.formTypes.get(forms[formKey].type);
100
- if (handler && userJob.status) {
101
- await handler.call(instruction, userJob, forms[formKey], processor);
99
+ if (handler && task.status) {
100
+ await handler.call(instruction, task, forms[formKey], processor);
102
101
  }
103
- await userJob.save();
102
+ await task.save();
104
103
  await processor.exit();
105
- context.body = userJob;
104
+ context.body = task;
106
105
  context.status = 202;
107
106
  await next();
108
- userJob.job.execution = userJob.execution;
109
- userJob.job.latestUserJob = userJob;
110
- processor.logger.info(`manual node (${userJob.nodeId}) action trigger execution (${userJob.execution.id}) to resume`);
111
- plugin.resume(userJob.job);
112
- }
113
- async function countMine(context, next) {
114
- const repository = import_actions.utils.getRepositoryFromParams(context);
115
- const { currentUser } = context.state;
116
- const count = await repository.count({
117
- filter: {
118
- $and: [
119
- {
120
- "workflow.enabled": true
121
- },
122
- context.action.params.filter ?? {},
123
- {
124
- userId: currentUser.id
125
- }
126
- ]
127
- },
128
- context
129
- });
130
- context.body = count;
131
- await next();
107
+ task.job.execution = task.execution;
108
+ task.job.latestTask = task;
109
+ processor.logger.info(`manual node (${task.nodeId}) action trigger execution (${task.execution.id}) to resume`);
110
+ plugin.resume(task.job);
132
111
  }
133
112
  // Annotate the CommonJS export names for ESM import in node:
134
113
  0 && (module.exports = {
135
- countMine,
136
114
  submit
137
115
  });
@@ -24,14 +24,15 @@ var __copyProps = (to, from, except, desc) => {
24
24
  return to;
25
25
  };
26
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var users_jobs_exports = {};
28
- __export(users_jobs_exports, {
29
- default: () => users_jobs_default
27
+ var workflowManualTasks_exports = {};
28
+ __export(workflowManualTasks_exports, {
29
+ default: () => workflowManualTasks_default
30
30
  });
31
- module.exports = __toCommonJS(users_jobs_exports);
31
+ module.exports = __toCommonJS(workflowManualTasks_exports);
32
32
  var import_database = require("@nocobase/database");
33
- var users_jobs_default = (0, import_database.defineCollection)({
34
- name: "users_jobs",
33
+ var import_constants = require("../../common/constants");
34
+ var workflowManualTasks_default = (0, import_database.defineCollection)({
35
+ name: "workflowManualTasks",
35
36
  dumpRules: {
36
37
  group: "log"
37
38
  },
@@ -60,7 +61,13 @@ var users_jobs_default = (0, import_database.defineCollection)({
60
61
  },
61
62
  {
62
63
  type: "string",
63
- name: "title"
64
+ name: "title",
65
+ interface: "input",
66
+ uiSchema: {
67
+ type: "string",
68
+ title: `{{t("Task title", { ns: "${import_constants.NAMESPACE}" })}}`,
69
+ "x-component": "Input"
70
+ }
64
71
  },
65
72
  {
66
73
  type: "belongsTo",
@@ -73,7 +80,21 @@ var users_jobs_default = (0, import_database.defineCollection)({
73
80
  },
74
81
  {
75
82
  type: "belongsTo",
76
- name: "workflow"
83
+ name: "workflow",
84
+ target: "workflows",
85
+ foreignKey: "workflowId",
86
+ interface: "m2o",
87
+ uiSchema: {
88
+ type: "object",
89
+ title: `{{t("Workflow", { ns: "workflow" })}}`,
90
+ "x-component": "AssociationField",
91
+ "x-component-props": {
92
+ fieldNames: {
93
+ label: "title",
94
+ value: "id"
95
+ }
96
+ }
97
+ }
77
98
  },
78
99
  {
79
100
  type: "integer",
@@ -35,7 +35,7 @@ class add_task_title_default extends import_server.Migration {
35
35
  async up() {
36
36
  const { db } = this.context;
37
37
  const NodeRepo = db.getRepository("flow_nodes");
38
- const TaskRepo = db.getRepository("users_jobs");
38
+ const TaskRepo = db.getRepository("workflowManualTasks");
39
39
  await db.sequelize.transaction(async (transaction) => {
40
40
  const nodes = await NodeRepo.find({
41
41
  filter: {
@@ -6,9 +6,9 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- declare const _default: {
10
- collectionOptions: import("@nocobase/database").CollectionOptions;
11
- mergeOptions: import("deepmerge").Options;
12
- extend: boolean;
13
- };
14
- export default _default;
9
+ import { Migration } from '@nocobase/server';
10
+ export default class extends Migration {
11
+ appVersion: string;
12
+ on: string;
13
+ up(): Promise<void>;
14
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var change_table_name_exports = {};
28
+ __export(change_table_name_exports, {
29
+ default: () => change_table_name_default
30
+ });
31
+ module.exports = __toCommonJS(change_table_name_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class change_table_name_default extends import_server.Migration {
34
+ appVersion = "<1.6.0";
35
+ on = "beforeLoad";
36
+ async up() {
37
+ const { db } = this.context;
38
+ const queryInterface = db.sequelize.getQueryInterface();
39
+ await db.sequelize.transaction(async (transaction) => {
40
+ const exists = await queryInterface.tableExists("users_jobs", { transaction });
41
+ if (exists) {
42
+ const newTableName = db.options.underscored ? "workflow_manual_tasks" : "workflowManualTasks";
43
+ await queryInterface.renameTable("users_jobs", newTableName, { transaction });
44
+ const indexes = await queryInterface.showIndex(newTableName, { transaction });
45
+ for (const item of indexes) {
46
+ if (item.name.startsWith("users_jobs")) {
47
+ if (this.db.isPostgresCompatibleDialect()) {
48
+ await db.sequelize.query(
49
+ `ALTER INDEX "${item.name}" RENAME TO "${item.name.replace("users_jobs", "workflow_manual_tasks")}";`,
50
+ { transaction }
51
+ );
52
+ } else if (this.db.isMySQLCompatibleDialect()) {
53
+ await db.sequelize.query(
54
+ `ALTER TABLE ${newTableName} RENAME INDEX ${item.name} TO ${item.name.replace(
55
+ "users_jobs",
56
+ "workflow_manual_tasks"
57
+ )};`,
58
+ { transaction }
59
+ );
60
+ }
61
+ }
62
+ }
63
+ }
64
+ });
65
+ }
66
+ }
@@ -6,9 +6,8 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- declare const _default: {
10
- collectionOptions: import("@nocobase/database").CollectionOptions;
11
- mergeOptions: import("deepmerge").Options;
12
- extend: boolean;
13
- };
14
- export default _default;
9
+ import { Migration } from '@nocobase/server';
10
+ export default class extends Migration {
11
+ appVersion: string;
12
+ up(): Promise<void>;
13
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var add_pending_tasks_exports = {};
28
+ __export(add_pending_tasks_exports, {
29
+ default: () => add_pending_tasks_default
30
+ });
31
+ module.exports = __toCommonJS(add_pending_tasks_exports);
32
+ var import_plugin_workflow = require("@nocobase/plugin-workflow");
33
+ var import_server = require("@nocobase/server");
34
+ var import_constants = require("../../common/constants");
35
+ class add_pending_tasks_default extends import_server.Migration {
36
+ appVersion = "<1.6.0";
37
+ async up() {
38
+ const { db } = this.context;
39
+ const WorkflowTaskModel = db.getModel("workflowTasks");
40
+ const WorkflowManualTaskRepo = db.getRepository("workflowManualTasks");
41
+ await db.sequelize.transaction(async (transaction) => {
42
+ const tasks = await WorkflowManualTaskRepo.find({
43
+ filter: {
44
+ status: import_plugin_workflow.JOB_STATUS.PENDING,
45
+ "execution.status": import_plugin_workflow.EXECUTION_STATUS.STARTED,
46
+ "workflow.enabled": true
47
+ },
48
+ transaction
49
+ });
50
+ const records = tasks.map((item) => ({
51
+ type: import_constants.MANUAL_TASK_TYPE,
52
+ key: `${item.id}`,
53
+ userId: item.userId,
54
+ workflowId: item.workflowId
55
+ }));
56
+ for (const record of records) {
57
+ await WorkflowTaskModel.upsert(record, {
58
+ transaction
59
+ });
60
+ }
61
+ });
62
+ }
63
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:人工处理节点",
5
5
  "description": "Could be used for workflows which some of decisions are made by users.",
6
6
  "description.zh-CN": "用于人工控制部分决策的流程。",
7
- "version": "1.6.0-beta.9",
7
+ "version": "1.6.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-manual",
@@ -30,7 +30,7 @@
30
30
  "@nocobase/test": "1.x",
31
31
  "@nocobase/utils": "1.x"
32
32
  },
33
- "gitHead": "eb1ff948fcf7a51175626a1a56a8b8d9b90be006",
33
+ "gitHead": "a784836ebbe1ddd514bf09c477ca0cff176dcbfd",
34
34
  "keywords": [
35
35
  "Workflow"
36
36
  ]