@nocobase/plugin-workflow-manual 1.6.0-alpha.3 → 1.6.0-alpha.31

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,21 @@
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
+ export declare const NAMESPACE = "workflow-manual";
10
+ export declare const MANUAL_TASK_TYPE = "manual";
11
+ export declare const TASK_STATUS: {
12
+ PENDING: number;
13
+ RESOLVED: number;
14
+ REJECTED: number;
15
+ };
16
+ export declare const TaskStatusOptions: {
17
+ value: number;
18
+ label: string;
19
+ color: string;
20
+ }[];
21
+ export declare const TaskStatusOptionsMap: {};
@@ -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-alpha.3",
11
+ "@nocobase/client": "1.6.0-alpha.31",
12
12
  "react": "18.2.0",
13
13
  "@formily/react": "2.3.0",
14
+ "@formily/antd-v5": "1.1.9",
14
15
  "antd": "5.12.8",
16
+ "@ant-design/icons": "5.6.1",
17
+ "antd-style": "3.7.1",
15
18
  "dayjs": "1.11.10",
16
- "@nocobase/plugin-workflow": "1.6.0-alpha.3",
17
- "@ant-design/icons": "5.2.6",
18
19
  "react-i18next": "11.18.6",
19
- "@nocobase/utils": "1.6.0-alpha.3",
20
- "@nocobase/server": "1.6.0-alpha.3",
21
- "@nocobase/actions": "1.6.0-alpha.3",
22
- "@nocobase/resourcer": "1.6.0-alpha.3",
23
- "@nocobase/test": "1.6.0-alpha.3",
24
- "@nocobase/plugin-workflow-test": "1.6.0-alpha.3",
20
+ "lodash": "4.17.21",
21
+ "@nocobase/plugin-workflow": "1.6.0-alpha.31",
22
+ "@nocobase/utils": "1.6.0-alpha.31",
23
+ "@nocobase/server": "1.6.0-alpha.31",
24
+ "@nocobase/actions": "1.6.0-alpha.31",
25
+ "@nocobase/resourcer": "1.6.0-alpha.31",
26
+ "@nocobase/test": "1.6.0-alpha.31",
27
+ "@nocobase/plugin-workflow-test": "1.6.0-alpha.31",
25
28
  "@formily/core": "2.3.0",
26
- "@formily/antd-v5": "1.1.9",
27
- "@nocobase/database": "1.6.0-alpha.3",
28
- "lodash": "4.17.21"
29
+ "@nocobase/database": "1.6.0-alpha.31"
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
+ }
@@ -28,5 +28,8 @@
28
28
  "Workflow todos": "工作流待办",
29
29
  "Task node": "任务节点",
30
30
  "Unprocessed": "未处理",
31
- "Please check one of your update record form, and add at least one filter condition in form settings.": "请检查您的其中的更新数据表单,并在表单设置中至少添加一个筛选条件。"
31
+ "Please check one of your update record form, and add at least one filter condition in form settings.": "请检查您的其中的更新数据表单,并在表单设置中至少添加一个筛选条件。",
32
+ "My manual tasks": "我的人工任务",
33
+ "Task title": "任务名称",
34
+ "Title of each task item. Default to node title.": "每项任务的名称。默认为节点名称。"
32
35
  }
@@ -25,6 +25,7 @@ export interface ManualConfig {
25
25
  };
26
26
  assignees?: (number | string)[];
27
27
  mode?: number;
28
+ title?: string;
28
29
  }
29
30
  export default class extends Instruction {
30
31
  workflow: WorkflowPlugin;
@@ -120,40 +120,48 @@ class ManualInstruction_default extends import_plugin_workflow.Instruction {
120
120
  if (!assignees.length) {
121
121
  return job;
122
122
  }
123
- const UserJobModel = this.workflow.app.db.getModel("users_jobs");
124
- await UserJobModel.bulkCreate(
125
- assignees.map((userId) => ({
123
+ const title = config.title ? processor.getParsedValue(config.title, node.id) : node.title;
124
+ const TaskRepo = this.workflow.app.db.getRepository("workflowManualTasks");
125
+ await TaskRepo.createMany({
126
+ records: assignees.map((userId) => ({
126
127
  userId,
127
128
  jobId: job.id,
128
129
  nodeId: node.id,
129
130
  executionId: job.executionId,
130
131
  workflowId: node.workflowId,
131
- status: import_plugin_workflow.JOB_STATUS.PENDING
132
+ status: import_plugin_workflow.JOB_STATUS.PENDING,
133
+ title
132
134
  })),
133
- {
134
- // transaction: processor.transaction,
135
- }
136
- );
135
+ transaction: processor.mainTransaction
136
+ });
137
137
  return job;
138
138
  }
139
139
  async resume(node, job, processor) {
140
140
  var _a;
141
141
  const { mode } = node.config;
142
- const assignees = [...new Set(processor.getParsedValue(node.config.assignees, node.id).flat().filter(Boolean))];
143
- const UserJobModel = this.workflow.app.db.getModel("users_jobs");
144
- const distribution = await UserJobModel.count({
142
+ const TaskRepo = this.workflow.app.db.getRepository("workflowManualTasks");
143
+ const tasks = await TaskRepo.find({
145
144
  where: {
146
145
  jobId: job.id
147
146
  },
148
- group: ["status"]
149
- // transaction: processor.transaction,
147
+ transaction: processor.mainTransaction
150
148
  });
151
- const submitted = distribution.reduce(
152
- (count, item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING ? count + item.count : count,
153
- 0
154
- );
149
+ const assignees = [];
150
+ const distributionMap = tasks.reduce((result2, item) => {
151
+ if (result2[item.status] == null) {
152
+ result2[item.status] = 0;
153
+ }
154
+ result2[item.status] += 1;
155
+ assignees.push(item.userId);
156
+ return result2;
157
+ }, {});
158
+ const distribution = Object.keys(distributionMap).map((status2) => ({
159
+ status: Number.parseInt(status2, 10),
160
+ count: distributionMap[status2]
161
+ }));
162
+ const submitted = tasks.reduce((count, item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING ? count + 1 : count, 0);
155
163
  const status = job.status || (getMode(mode).getStatus(distribution, assignees) ?? import_plugin_workflow.JOB_STATUS.PENDING);
156
- 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;
157
165
  processor.logger.debug(`manual resume job and next status: ${status}`);
158
166
  job.set({
159
167
  status,
@@ -42,14 +42,13 @@ module.exports = __toCommonJS(Plugin_exports);
42
42
  var import_server = require("@nocobase/server");
43
43
  var import_actions = __toESM(require("@nocobase/actions"));
44
44
  var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
45
- var import_path = __toESM(require("path"));
46
- var import_actions2 = require("./actions");
45
+ var jobActions = __toESM(require("./actions"));
47
46
  var import_ManualInstruction = __toESM(require("./ManualInstruction"));
47
+ var import_constants = require("../common/constants");
48
48
  class Plugin_default extends import_server.Plugin {
49
49
  async load() {
50
- await this.importCollections(import_path.default.resolve(__dirname, "collections"));
51
- this.app.resource({
52
- name: "users_jobs",
50
+ this.app.resourceManager.define({
51
+ name: "workflowManualTasks",
53
52
  actions: {
54
53
  list: {
55
54
  filter: {
@@ -67,11 +66,23 @@ class Plugin_default extends import_server.Plugin {
67
66
  },
68
67
  handler: import_actions.default.list
69
68
  },
70
- submit: import_actions2.submit
69
+ ...jobActions
71
70
  }
72
71
  });
73
- this.app.acl.allow("users_jobs", ["list", "get", "submit"], "loggedIn");
72
+ this.app.acl.allow("workflowManualTasks", ["list", "get", "submit"], "loggedIn");
74
73
  const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
75
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
+ });
76
87
  }
77
88
  }
@@ -51,7 +51,7 @@ async function submit(context, next) {
51
51
  }
52
52
  const plugin = context.app.getPlugin(import_plugin_workflow.default);
53
53
  const instruction = plugin.instructions.get("manual");
54
- const userJob = await repository.findOne({
54
+ const task = await repository.findOne({
55
55
  filterByTk,
56
56
  // filter: {
57
57
  // userId: currentUser?.id
@@ -59,24 +59,24 @@ async function submit(context, next) {
59
59
  appends: ["job", "node", "execution", "workflow"],
60
60
  context
61
61
  });
62
- if (!userJob) {
62
+ if (!task) {
63
63
  return context.throw(404);
64
64
  }
65
- const { forms = {} } = userJob.node.config;
65
+ const { forms = {} } = task.node.config;
66
66
  const [formKey] = Object.keys(values.result ?? {}).filter((key) => key !== "_");
67
67
  const actionKey = (_a = values.result) == null ? void 0 : _a._;
68
68
  const actionItem = (_c = (_b = forms[formKey]) == null ? void 0 : _b.actions) == null ? void 0 : _c.find((item) => item.key === actionKey);
69
- 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) {
70
70
  return context.throw(400);
71
71
  }
72
- userJob.execution.workflow = userJob.workflow;
73
- const processor = plugin.createProcessor(userJob.execution);
72
+ task.execution.workflow = task.workflow;
73
+ const processor = plugin.createProcessor(task.execution);
74
74
  await processor.prepare();
75
- const assignees = processor.getParsedValue(userJob.node.config.assignees ?? [], userJob.nodeId).flat().filter(Boolean);
76
- 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) {
77
77
  return context.throw(403);
78
78
  }
79
- const presetValues = processor.getParsedValue(actionItem.values ?? {}, userJob.nodeId, {
79
+ const presetValues = processor.getParsedValue(actionItem.values ?? {}, task.nodeId, {
80
80
  additionalScope: {
81
81
  // @deprecated
82
82
  currentUser,
@@ -91,23 +91,23 @@ async function submit(context, next) {
91
91
  }
92
92
  }
93
93
  });
94
- userJob.set({
94
+ task.set({
95
95
  status: actionItem.status,
96
- result: actionItem.status > import_plugin_workflow.JOB_STATUS.PENDING ? { [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)
97
97
  });
98
98
  const handler = instruction.formTypes.get(forms[formKey].type);
99
- if (handler && userJob.status) {
100
- await handler.call(instruction, userJob, forms[formKey], processor);
99
+ if (handler && task.status) {
100
+ await handler.call(instruction, task, forms[formKey], processor);
101
101
  }
102
- await userJob.save();
102
+ await task.save();
103
103
  await processor.exit();
104
- context.body = userJob;
104
+ context.body = task;
105
105
  context.status = 202;
106
106
  await next();
107
- userJob.job.execution = userJob.execution;
108
- userJob.job.latestUserJob = userJob;
109
- processor.logger.info(`manual node (${userJob.nodeId}) action trigger execution (${userJob.execution.id}) to resume`);
110
- plugin.resume(userJob.job);
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);
111
111
  }
112
112
  // Annotate the CommonJS export names for ESM import in node:
113
113
  0 && (module.exports = {
@@ -24,17 +24,19 @@ 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
  },
39
+ migrationRules: ["schema-only"],
38
40
  shared: true,
39
41
  fields: [
40
42
  {
@@ -57,6 +59,16 @@ var users_jobs_default = (0, import_database.defineCollection)({
57
59
  foreignKey: "userId",
58
60
  primaryKey: false
59
61
  },
62
+ {
63
+ type: "string",
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
+ }
71
+ },
60
72
  {
61
73
  type: "belongsTo",
62
74
  name: "execution"
@@ -68,7 +80,21 @@ var users_jobs_default = (0, import_database.defineCollection)({
68
80
  },
69
81
  {
70
82
  type: "belongsTo",
71
- 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
+ }
72
98
  },
73
99
  {
74
100
  type: "integer",
@@ -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
+ }
@@ -24,24 +24,41 @@ 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_exports = {};
28
- __export(users_exports, {
29
- default: () => users_default
30
- });
31
- module.exports = __toCommonJS(users_exports);
32
- var import_database = require("@nocobase/database");
33
- var users_default = (0, import_database.extendCollection)({
34
- name: "users",
35
- fields: [
36
- {
37
- type: "belongsToMany",
38
- name: "jobs",
39
- through: "users_jobs"
40
- },
41
- {
42
- type: "hasMany",
43
- name: "usersJobs",
44
- target: "users_jobs"
45
- }
46
- ]
27
+ var add_task_title_exports = {};
28
+ __export(add_task_title_exports, {
29
+ default: () => add_task_title_default
47
30
  });
31
+ module.exports = __toCommonJS(add_task_title_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class add_task_title_default extends import_server.Migration {
34
+ appVersion = "<1.6.0-alpha.13";
35
+ async up() {
36
+ const { db } = this.context;
37
+ const NodeRepo = db.getRepository("flow_nodes");
38
+ const TaskRepo = db.getRepository("workflowManualTasks");
39
+ await db.sequelize.transaction(async (transaction) => {
40
+ const nodes = await NodeRepo.find({
41
+ filter: {
42
+ type: "manual"
43
+ },
44
+ transaction
45
+ });
46
+ await nodes.reduce(
47
+ (promise, node) => promise.then(() => {
48
+ return TaskRepo.update({
49
+ filter: {
50
+ nodeId: node.id
51
+ },
52
+ values: {
53
+ title: node.title
54
+ },
55
+ individualHooks: false,
56
+ silent: true,
57
+ transaction
58
+ });
59
+ }),
60
+ Promise.resolve()
61
+ );
62
+ });
63
+ }
64
+ }
@@ -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
+ }
@@ -0,0 +1,13 @@
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
+ import { Migration } from '@nocobase/server';
10
+ export default class extends Migration {
11
+ appVersion: string;
12
+ up(): Promise<void>;
13
+ }