@nocobase/plugin-workflow-manual 1.7.0-beta.2 → 1.7.0-beta.3

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.
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.7.0-beta.2",
11
+ "@nocobase/client": "1.7.0-beta.3",
12
12
  "react": "18.2.0",
13
13
  "@formily/react": "2.3.0",
14
14
  "@formily/antd-v5": "1.1.9",
@@ -18,13 +18,14 @@ module.exports = {
18
18
  "dayjs": "1.11.10",
19
19
  "react-i18next": "11.18.6",
20
20
  "lodash": "4.17.21",
21
- "@nocobase/plugin-workflow": "1.7.0-beta.2",
22
- "@nocobase/utils": "1.7.0-beta.2",
23
- "@nocobase/server": "1.7.0-beta.2",
24
- "@nocobase/actions": "1.7.0-beta.2",
25
- "@nocobase/resourcer": "1.7.0-beta.2",
26
- "@nocobase/test": "1.7.0-beta.2",
27
- "@nocobase/plugin-workflow-test": "1.7.0-beta.2",
21
+ "@nocobase/plugin-workflow": "1.7.0-beta.3",
22
+ "@nocobase/utils": "1.7.0-beta.3",
23
+ "@nocobase/server": "1.7.0-beta.3",
24
+ "@nocobase/actions": "1.7.0-beta.3",
25
+ "@nocobase/resourcer": "1.7.0-beta.3",
26
+ "@nocobase/test": "1.7.0-beta.3",
27
+ "@nocobase/plugin-workflow-test": "1.7.0-beta.3",
28
28
  "@formily/core": "2.3.0",
29
- "@nocobase/database": "1.7.0-beta.2"
29
+ "@nocobase/database": "1.7.0-beta.3",
30
+ "sequelize": "6.35.2"
30
31
  };
@@ -7,9 +7,11 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
+ var __create = Object.create;
10
11
  var __defProp = Object.defineProperty;
11
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
13
15
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
16
  var __export = (target, all) => {
15
17
  for (var name in all)
@@ -23,13 +25,23 @@ var __copyProps = (to, from, except, desc) => {
23
25
  }
24
26
  return to;
25
27
  };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
26
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
37
  var change_table_name_exports = {};
28
38
  __export(change_table_name_exports, {
29
39
  default: () => change_table_name_default
30
40
  });
31
41
  module.exports = __toCommonJS(change_table_name_exports);
42
+ var import_sequelize = require("sequelize");
32
43
  var import_server = require("@nocobase/server");
44
+ var import_workflowManualTasks = __toESM(require("../collections/workflowManualTasks"));
33
45
  class change_table_name_default extends import_server.Migration {
34
46
  appVersion = "<1.7.0";
35
47
  on = "beforeLoad";
@@ -37,20 +49,26 @@ class change_table_name_default extends import_server.Migration {
37
49
  const { db } = this.context;
38
50
  const queryInterface = db.sequelize.getQueryInterface();
39
51
  const usersJobsCollection = db.collection({
40
- name: "users_jobs",
41
- fields: [{ name: "id", type: "bigInt" }]
52
+ ...import_workflowManualTasks.default,
53
+ name: "users_jobs"
42
54
  });
43
55
  const workflowManualTasksCollection = db.collection({
44
- name: "workflowManualTasks",
45
- fields: [{ name: "id", type: "bigInt" }]
56
+ ...import_workflowManualTasks.default
46
57
  });
47
58
  const oldTableName = usersJobsCollection.getTableNameWithSchema();
48
59
  const oldTableNameWithQuotes = usersJobsCollection.getRealTableName(true);
49
60
  const newTableName = workflowManualTasksCollection.getTableNameWithSchema();
50
61
  const newTableNameWithQuotes = workflowManualTasksCollection.getRealTableName(true);
51
- await db.sequelize.transaction(async (transaction) => {
52
- const exists = await queryInterface.tableExists(oldTableName, { transaction });
53
- if (exists) {
62
+ const exists = await queryInterface.tableExists(oldTableName);
63
+ if (!exists) {
64
+ return;
65
+ }
66
+ const constraints = await queryInterface.showConstraint(oldTableName);
67
+ await db.sequelize.transaction(
68
+ {
69
+ isolationLevel: import_sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE
70
+ },
71
+ async (transaction) => {
54
72
  const newExists = await queryInterface.tableExists(newTableName, { transaction });
55
73
  if (newExists) {
56
74
  await queryInterface.dropTable(newTableName, { transaction });
@@ -65,6 +83,18 @@ class change_table_name_default extends import_server.Migration {
65
83
  } else {
66
84
  await queryInterface.renameTable(oldTableName, newTableName, { transaction });
67
85
  }
86
+ if (this.db.isPostgresCompatibleDialect()) {
87
+ const primaryKeys = constraints.filter((item) => item.constraintType === "PRIMARY KEY");
88
+ if (primaryKeys.length) {
89
+ for (const primaryKey of primaryKeys) {
90
+ await queryInterface.removeConstraint(newTableName, primaryKey.constraintName, { transaction });
91
+ }
92
+ }
93
+ } else if (this.db.isMySQLCompatibleDialect()) {
94
+ await db.sequelize.query(`ALTER TABLE ${newTableNameWithQuotes} DROP PRIMARY KEY, ADD PRIMARY KEY (id)`, {
95
+ transaction
96
+ });
97
+ }
68
98
  const indexes = await queryInterface.showIndex(newTableName, { transaction });
69
99
  const oldIndexPrefix = `${db.options.tablePrefix || ""}users_jobs`;
70
100
  const newIndexPrefix = `${db.options.tablePrefix || ""}workflow_manual_tasks`;
@@ -87,7 +117,7 @@ class change_table_name_default extends import_server.Migration {
87
117
  }
88
118
  }
89
119
  }
90
- });
120
+ );
91
121
  db.removeCollection("users_jobs");
92
122
  db.removeCollection("workflowManualTasks");
93
123
  }
@@ -0,0 +1,14 @@
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
+ on: string;
13
+ up(): Promise<void>;
14
+ }
@@ -0,0 +1,57 @@
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 remove_m2m_fields_exports = {};
28
+ __export(remove_m2m_fields_exports, {
29
+ default: () => remove_m2m_fields_default
30
+ });
31
+ module.exports = __toCommonJS(remove_m2m_fields_exports);
32
+ var import_server = require("@nocobase/server");
33
+ class remove_m2m_fields_default extends import_server.Migration {
34
+ appVersion = "<1.7.0";
35
+ on = "afterLoad";
36
+ async up() {
37
+ const { db } = this.context;
38
+ await db.sequelize.transaction(async (transaction) => {
39
+ const FieldRepo = db.getCollection("fields").repository;
40
+ await FieldRepo.destroy({
41
+ filter: {
42
+ collectionName: "users",
43
+ name: "jobs"
44
+ },
45
+ transaction
46
+ });
47
+ await FieldRepo.destroy({
48
+ filter: {
49
+ collectionName: "jobs",
50
+ name: "users"
51
+ },
52
+ transaction
53
+ });
54
+ db.removeCollection("fields");
55
+ });
56
+ }
57
+ }
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.7.0-beta.2",
7
+ "version": "1.7.0-beta.3",
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": "58b206bdfca521e79a69989ca55dd19075dca523",
33
+ "gitHead": "8d52cb1d366a968f87c1cd3f98f55f24be3056a5",
34
34
  "keywords": [
35
35
  "Workflow"
36
36
  ]