@nocobase/plugin-data-source-manager 1.8.0-beta.6 → 1.8.0-beta.8

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,14 +8,14 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.8.0-beta.6",
11
+ "@nocobase/client": "1.8.0-beta.8",
12
12
  "react": "18.2.0",
13
- "@nocobase/plugin-acl": "1.8.0-beta.6",
14
- "@nocobase/utils": "1.8.0-beta.6",
15
- "@nocobase/server": "1.8.0-beta.6",
16
- "@nocobase/data-source-manager": "1.8.0-beta.6",
13
+ "@nocobase/plugin-acl": "1.8.0-beta.8",
14
+ "@nocobase/utils": "1.8.0-beta.8",
15
+ "@nocobase/server": "1.8.0-beta.8",
16
+ "@nocobase/data-source-manager": "1.8.0-beta.8",
17
17
  "lodash": "4.17.21",
18
- "@nocobase/acl": "1.8.0-beta.6",
18
+ "@nocobase/acl": "1.8.0-beta.8",
19
19
  "@ant-design/icons": "5.6.1",
20
20
  "antd": "5.24.2",
21
21
  "react-router-dom": "6.28.1",
@@ -23,9 +23,9 @@ module.exports = {
23
23
  "react-i18next": "11.18.6",
24
24
  "@formily/react": "2.3.0",
25
25
  "@emotion/css": "11.13.0",
26
- "@nocobase/database": "1.8.0-beta.6",
26
+ "@nocobase/database": "1.8.0-beta.8",
27
27
  "sequelize": "6.35.2",
28
- "@nocobase/test": "1.8.0-beta.6",
28
+ "@nocobase/test": "1.8.0-beta.8",
29
29
  "@formily/antd-v5": "1.2.3",
30
30
  "@formily/core": "2.3.0",
31
31
  "@formily/reactive": "2.3.0",
@@ -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
+ on: string;
12
+ appVersion: string;
13
+ up(): Promise<void>;
14
+ }
@@ -0,0 +1,74 @@
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 clean_datasource_collection_schema_exports = {};
28
+ __export(clean_datasource_collection_schema_exports, {
29
+ default: () => clean_datasource_collection_schema_default
30
+ });
31
+ module.exports = __toCommonJS(clean_datasource_collection_schema_exports);
32
+ var import_database = require("@nocobase/database");
33
+ var import_server = require("@nocobase/server");
34
+ /* istanbul ignore file -- @preserve */
35
+ class clean_datasource_collection_schema_default extends import_server.Migration {
36
+ on = "afterLoad";
37
+ appVersion = "<1.8.0";
38
+ async up() {
39
+ const repository = this.context.db.getRepository("dataSourcesCollections");
40
+ const transaction = await repository.model.sequelize.transaction();
41
+ try {
42
+ const collections = await repository.find({
43
+ where: {
44
+ [import_database.Op.or]: [
45
+ { "options.schema": "{{$deps[0].split('@')?.[0]}}" },
46
+ { "options.viewName": "{{$deps[0].split('@')?.[1]}}" }
47
+ ]
48
+ },
49
+ transaction
50
+ });
51
+ for (const collection of collections) {
52
+ const { key, options } = collection;
53
+ const newOptions = { ...options };
54
+ if (options.schema === "{{$deps[0].split('@')?.[0]}}") {
55
+ newOptions.schema = "";
56
+ }
57
+ if (options.viewName === "{{$deps[0].split('@')?.[1]}}") {
58
+ newOptions.viewName = "";
59
+ }
60
+ await repository.model.update(
61
+ { options: newOptions },
62
+ {
63
+ where: { key },
64
+ transaction
65
+ }
66
+ );
67
+ }
68
+ await transaction.commit();
69
+ } catch (error) {
70
+ console.error("Error during migration:", error);
71
+ await transaction.rollback();
72
+ }
73
+ }
74
+ }
@@ -503,6 +503,26 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
503
503
  );
504
504
  }
505
505
  );
506
+ this.app.db.on("dataSourcesRolesResourcesScopes.afterSaveWithAssociations", async (model, options) => {
507
+ const { transaction } = options;
508
+ const dataSourcesRolesResourcesActions = await this.app.db.getRepository("dataSourcesRolesResourcesActions").find({
509
+ filter: { scopeId: model.get("id") },
510
+ transaction
511
+ });
512
+ const rolesRolesResourceIds = dataSourcesRolesResourcesActions.map((x) => x.get("rolesResourceId"));
513
+ const dataSourcesRolesResources = await this.app.db.getRepository("dataSourcesRolesResources").find({
514
+ filter: {
515
+ id: rolesRolesResourceIds
516
+ },
517
+ transaction
518
+ });
519
+ for (const instance of dataSourcesRolesResources) {
520
+ await this.app.db.emitAsync(`dataSourcesRolesResources.afterSaveWithAssociations`, instance, {
521
+ ...options,
522
+ transaction
523
+ });
524
+ }
525
+ });
506
526
  this.app.db.on(
507
527
  "dataSourcesRolesResourcesActions.afterUpdateWithAssociations",
508
528
  async (model, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-source-manager",
3
- "version": "1.8.0-beta.6",
3
+ "version": "1.8.0-beta.8",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "Data source manager",
6
6
  "displayName.zh-CN": "数据源管理",
@@ -17,5 +17,5 @@
17
17
  "keywords": [
18
18
  "Data model tools"
19
19
  ],
20
- "gitHead": "10404c6aadde1f3d48c7dba610386db4575785a6"
20
+ "gitHead": "b8871f494a7c9f21f7ed474a4e4fb3ccc38c23dd"
21
21
  }