@nocobase/plugin-data-source-manager 1.4.0-alpha.20241025010959 → 1.4.0-alpha.20241031134640
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.
package/dist/externalVersion.js
CHANGED
|
@@ -8,26 +8,27 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.4.0-alpha.
|
|
11
|
+
"@nocobase/client": "1.4.0-alpha.20241031134640",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/plugin-acl": "1.4.0-alpha.
|
|
14
|
-
"@nocobase/utils": "1.4.0-alpha.
|
|
15
|
-
"@nocobase/server": "1.4.0-alpha.
|
|
13
|
+
"@nocobase/plugin-acl": "1.4.0-alpha.20241031134640",
|
|
14
|
+
"@nocobase/utils": "1.4.0-alpha.20241031134640",
|
|
15
|
+
"@nocobase/server": "1.4.0-alpha.20241031134640",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
|
+
"@nocobase/data-source-manager": "1.4.0-alpha.20241031134640",
|
|
17
18
|
"@ant-design/icons": "5.2.6",
|
|
18
19
|
"antd": "5.12.8",
|
|
19
20
|
"react-router-dom": "6.21.0",
|
|
20
|
-
"@formily/shared": "2.3.
|
|
21
|
+
"@formily/shared": "2.3.2",
|
|
21
22
|
"react-i18next": "11.18.6",
|
|
22
23
|
"@formily/react": "2.3.0",
|
|
23
24
|
"@emotion/css": "11.13.0",
|
|
24
|
-
"@nocobase/database": "1.4.0-alpha.
|
|
25
|
-
"@nocobase/acl": "1.4.0-alpha.
|
|
25
|
+
"@nocobase/database": "1.4.0-alpha.20241031134640",
|
|
26
|
+
"@nocobase/acl": "1.4.0-alpha.20241031134640",
|
|
26
27
|
"sequelize": "6.35.2",
|
|
27
|
-
"@nocobase/test": "1.4.0-alpha.
|
|
28
|
+
"@nocobase/test": "1.4.0-alpha.20241031134640",
|
|
28
29
|
"@formily/antd-v5": "1.1.9",
|
|
29
30
|
"@formily/core": "2.3.0",
|
|
30
31
|
"@formily/reactive": "2.3.0",
|
|
31
32
|
"@dnd-kit/core": "6.1.0",
|
|
32
|
-
"antd-style": "3.
|
|
33
|
+
"antd-style": "3.7.1"
|
|
33
34
|
};
|
|
@@ -97,27 +97,30 @@ class DataSourceModel extends import_database.Model {
|
|
|
97
97
|
}
|
|
98
98
|
const type = this.get("type");
|
|
99
99
|
const createOptions = this.get("options");
|
|
100
|
-
const dataSource = app.dataSourceManager.factory.create(type, {
|
|
101
|
-
...createOptions,
|
|
102
|
-
name: dataSourceKey,
|
|
103
|
-
logger: app.logger.child({ dataSourceKey }),
|
|
104
|
-
sqlLogger: app.sqlLogger.child({ dataSourceKey })
|
|
105
|
-
});
|
|
106
|
-
if (loadAtAfterStart) {
|
|
107
|
-
dataSource.on("loadMessage", ({ message }) => {
|
|
108
|
-
app.setMaintainingMessage(`${message} in data source ${this.get("displayName")}`);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
const acl = dataSource.acl;
|
|
112
|
-
for (const [actionName, actionParams] of Object.entries(availableActions)) {
|
|
113
|
-
acl.setAvailableAction(actionName, actionParams);
|
|
114
|
-
}
|
|
115
|
-
acl.allow("*", "*", (ctx) => {
|
|
116
|
-
return ctx.state.currentRole === "root";
|
|
117
|
-
});
|
|
118
|
-
dataSource.resourceManager.use(import_plugin_acl.setCurrentRole, { tag: "setCurrentRole", before: "acl", after: "auth" });
|
|
119
|
-
await this.loadIntoACL({ app, acl, transaction: options.transaction });
|
|
120
100
|
try {
|
|
101
|
+
const dataSource = app.dataSourceManager.factory.create(type, {
|
|
102
|
+
...createOptions,
|
|
103
|
+
name: dataSourceKey,
|
|
104
|
+
logger: app.logger.child({ dataSourceKey }),
|
|
105
|
+
sqlLogger: app.sqlLogger.child({ dataSourceKey })
|
|
106
|
+
});
|
|
107
|
+
dataSource.on("loadingProgress", (progress) => {
|
|
108
|
+
pluginDataSourceManagerServer.dataSourceLoadingProgress[dataSourceKey] = progress;
|
|
109
|
+
});
|
|
110
|
+
if (loadAtAfterStart) {
|
|
111
|
+
dataSource.on("loadMessage", ({ message }) => {
|
|
112
|
+
app.setMaintainingMessage(`${message} in data source ${this.get("displayName")}`);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const acl = dataSource.acl;
|
|
116
|
+
for (const [actionName, actionParams] of Object.entries(availableActions)) {
|
|
117
|
+
acl.setAvailableAction(actionName, actionParams);
|
|
118
|
+
}
|
|
119
|
+
acl.allow("*", "*", (ctx) => {
|
|
120
|
+
return ctx.state.currentRole === "root";
|
|
121
|
+
});
|
|
122
|
+
dataSource.resourceManager.use(import_plugin_acl.setCurrentRole, { tag: "setCurrentRole", before: "acl", after: "auth" });
|
|
123
|
+
await this.loadIntoACL({ app, acl, transaction: options.transaction });
|
|
121
124
|
await app.dataSourceManager.add(dataSource, {
|
|
122
125
|
localData: await this.loadLocalData()
|
|
123
126
|
});
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Plugin } from '@nocobase/server';
|
|
10
|
+
import { LoadingProgress } from '@nocobase/data-source-manager';
|
|
10
11
|
type DataSourceState = 'loading' | 'loaded' | 'loading-failed' | 'reloading' | 'reloading-failed';
|
|
11
12
|
export declare class PluginDataSourceManagerServer extends Plugin {
|
|
12
13
|
dataSourceErrors: {
|
|
@@ -15,6 +16,9 @@ export declare class PluginDataSourceManagerServer extends Plugin {
|
|
|
15
16
|
dataSourceStatus: {
|
|
16
17
|
[dataSourceKey: string]: DataSourceState;
|
|
17
18
|
};
|
|
19
|
+
dataSourceLoadingProgress: {
|
|
20
|
+
[dataSourceKey: string]: LoadingProgress;
|
|
21
|
+
};
|
|
18
22
|
beforeLoad(): Promise<void>;
|
|
19
23
|
load(): Promise<void>;
|
|
20
24
|
}
|
package/dist/server/plugin.js
CHANGED
|
@@ -58,6 +58,7 @@ const canRefreshStatus = ["loaded", "loading-failed", "reloading-failed"];
|
|
|
58
58
|
class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
59
59
|
dataSourceErrors = {};
|
|
60
60
|
dataSourceStatus = {};
|
|
61
|
+
dataSourceLoadingProgress = {};
|
|
61
62
|
async beforeLoad() {
|
|
62
63
|
this.app.db.registerModels({
|
|
63
64
|
DataSourcesCollectionModel: import_data_sources_collection_model.DataSourcesCollectionModel,
|
|
@@ -98,6 +99,9 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
|
98
99
|
const dataSourceOptions = model.get("options");
|
|
99
100
|
const type = model.get("type");
|
|
100
101
|
const klass = this.app.dataSourceManager.factory.getClass(type);
|
|
102
|
+
if (!klass) {
|
|
103
|
+
throw new Error(`Data source type "${type}" is not registered`);
|
|
104
|
+
}
|
|
101
105
|
try {
|
|
102
106
|
await klass.testConnection(dataSourceOptions);
|
|
103
107
|
} catch (error) {
|
|
@@ -305,7 +309,9 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
|
305
309
|
});
|
|
306
310
|
this.app.db.on("dataSourcesCollections.afterDestroy", async (model) => {
|
|
307
311
|
const dataSource = this.app.dataSourceManager.dataSources.get(model.get("dataSourceKey"));
|
|
308
|
-
dataSource
|
|
312
|
+
if (dataSource) {
|
|
313
|
+
dataSource.collectionManager.removeCollection(model.get("name"));
|
|
314
|
+
}
|
|
309
315
|
});
|
|
310
316
|
this.app.db.on("dataSourcesFields.afterSaveWithAssociations", async (model) => {
|
|
311
317
|
model.load({
|
|
@@ -48,6 +48,22 @@ var data_sources_collections_default = {
|
|
|
48
48
|
const params = ctx.action.params;
|
|
49
49
|
const { associatedIndex: dataSourceKey } = params;
|
|
50
50
|
const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
51
|
+
const plugin = ctx.app.pm.get("data-source-manager");
|
|
52
|
+
const dataSourceStatus = plugin.dataSourceStatus[dataSourceKey];
|
|
53
|
+
if (dataSourceStatus === "loading-failed") {
|
|
54
|
+
const error = plugin.dataSourceErrors[dataSourceKey];
|
|
55
|
+
if (error) {
|
|
56
|
+
throw new Error(`dataSource ${dataSourceKey} loading failed: ${error.message}`);
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`dataSource ${dataSourceKey} loading failed`);
|
|
59
|
+
}
|
|
60
|
+
if (["loading", "reloading"].includes(dataSourceStatus)) {
|
|
61
|
+
const progress = plugin.dataSourceLoadingProgress[dataSourceKey];
|
|
62
|
+
if (progress) {
|
|
63
|
+
throw new Error(`dataSource ${dataSourceKey} is ${dataSourceStatus} (${progress.loaded}/${progress.total})`);
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`dataSource ${dataSourceKey} is ${dataSourceStatus}`);
|
|
66
|
+
}
|
|
51
67
|
if (!dataSource) {
|
|
52
68
|
throw new Error(`dataSource ${dataSourceKey} not found`);
|
|
53
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-data-source-manager",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.20241031134640",
|
|
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": "
|
|
20
|
+
"gitHead": "78cd6d9010f81b1c4d13d7673f6adf2eb0e598be"
|
|
21
21
|
}
|