@nocobase/plugin-data-source-manager 1.9.31 → 1.9.33

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.9.31",
11
+ "@nocobase/client": "1.9.33",
12
12
  "react": "18.2.0",
13
- "@nocobase/plugin-acl": "1.9.31",
14
- "@nocobase/utils": "1.9.31",
15
- "@nocobase/server": "1.9.31",
16
- "@nocobase/data-source-manager": "1.9.31",
13
+ "@nocobase/plugin-acl": "1.9.33",
14
+ "@nocobase/utils": "1.9.33",
15
+ "@nocobase/server": "1.9.33",
16
+ "@nocobase/data-source-manager": "1.9.33",
17
17
  "lodash": "4.17.21",
18
- "@nocobase/acl": "1.9.31",
18
+ "@nocobase/acl": "1.9.33",
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
  "@formily/shared": "2.3.2",
24
24
  "react-i18next": "11.18.6",
25
25
  "@emotion/css": "11.13.0",
26
- "@nocobase/database": "1.9.31",
26
+ "@nocobase/database": "1.9.33",
27
27
  "sequelize": "6.35.2",
28
- "@nocobase/test": "1.9.31",
28
+ "@nocobase/test": "1.9.33",
29
29
  "@formily/antd-v5": "1.2.3",
30
30
  "@formily/core": "2.3.0",
31
31
  "@formily/reactive": "2.3.0",
@@ -21,6 +21,7 @@ export declare class DataSourceModel extends Model {
21
21
  transaction?: Transaction;
22
22
  loadAtAfterStart?: boolean;
23
23
  refresh?: boolean;
24
+ reuseDB?: boolean;
24
25
  }): Promise<void>;
25
26
  private loadLocalData;
26
27
  }
@@ -98,7 +98,7 @@ class DataSourceModel extends import_database.Model {
98
98
  }
99
99
  }
100
100
  async loadIntoApplication(options) {
101
- const { app, loadAtAfterStart, refresh } = options;
101
+ const { app, loadAtAfterStart, refresh, reuseDB } = options;
102
102
  const dataSourceKey = this.get("key");
103
103
  const pluginDataSourceManagerServer = app.pm.get("data-source-manager");
104
104
  if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === "loaded") {
@@ -109,13 +109,16 @@ class DataSourceModel extends import_database.Model {
109
109
  const type = this.get("type");
110
110
  const createOptions = this.get("options");
111
111
  try {
112
+ const oldDataSource = app.dataSourceManager.get(dataSourceKey);
113
+ const { db: databaseInstance = void 0 } = reuseDB === true ? (oldDataSource == null ? void 0 : oldDataSource.collectionManager) ?? {} : {};
112
114
  const dataSource = app.dataSourceManager.factory.create(type, {
113
115
  ...createOptions,
114
116
  name: dataSourceKey,
115
117
  logger: app.logger.child({ dataSourceKey }),
116
118
  sqlLogger: app.sqlLogger.child({ dataSourceKey }),
117
119
  cache: app.cache,
118
- storagePath: import_path.default.join(process.cwd(), "storage", "cache", "apps", app.name)
120
+ storagePath: import_path.default.join(process.cwd(), "storage", "cache", "apps", app.name),
121
+ databaseInstance
119
122
  });
120
123
  dataSource.on("loadingProgress", (progress) => {
121
124
  pluginDataSourceManagerServer.dataSourceLoadingProgress[dataSourceKey] = progress;
@@ -137,7 +140,8 @@ class DataSourceModel extends import_database.Model {
137
140
  await this.loadIntoACL({ app, acl, transaction: options.transaction });
138
141
  await app.dataSourceManager.add(dataSource, {
139
142
  localData: await this.loadLocalData(),
140
- refresh
143
+ refresh,
144
+ reuseDB
141
145
  });
142
146
  } catch (e) {
143
147
  app.logger.error(`load data source failed`, { cause: e });
@@ -397,7 +397,8 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
397
397
  if (canRefreshStatus.includes(currentStatus) && (clientStatus ? clientStatus && canRefreshStatus.includes(clientStatus) : true)) {
398
398
  dataSourceModel.loadIntoApplication({
399
399
  app: ctx.app,
400
- refresh: true
400
+ refresh: true,
401
+ reuseDB: true
401
402
  });
402
403
  ctx.app.syncMessageManager.publish(self.name, {
403
404
  type: "loadDataSource",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-source-manager",
3
- "version": "1.9.31",
3
+ "version": "1.9.33",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "Data source manager",
6
6
  "displayName.ru-RU": "Менеджер управления источниками данных",
@@ -20,5 +20,5 @@
20
20
  "keywords": [
21
21
  "Data model tools"
22
22
  ],
23
- "gitHead": "c148b30b66f88ff14fb44bab78998ffe55c92ca0"
23
+ "gitHead": "705580251f0deffaf2a8c7c85006c770741941d3"
24
24
  }