@tachybase/module-data-source 1.6.0 → 1.6.1
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 +6 -6
- package/dist/server/collections/.gitkeep +0 -0
- package/dist/server/plugin.d.ts +0 -1
- package/dist/server/plugin.js +3 -7
- package/dist/server/resourcers/data-sources-collections-fields.js +6 -6
- package/dist/server/resourcers/data-sources-collections.js +1 -1
- package/dist/server/resourcers/roles-data-sources-collections.js +2 -2
- package/package.json +8 -8
package/dist/externalVersion.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.6.
|
|
4
|
-
"@tego/server": "1.
|
|
3
|
+
"@tachybase/client": "1.6.1",
|
|
4
|
+
"@tego/server": "1.6.0-alpha.9",
|
|
5
5
|
"lodash": "4.17.21",
|
|
6
|
-
"@ant-design/icons": "
|
|
6
|
+
"@ant-design/icons": "6.1.0",
|
|
7
7
|
"antd": "5.22.5",
|
|
8
8
|
"react-router-dom": "6.28.1",
|
|
9
|
-
"@tachybase/schema": "1.
|
|
9
|
+
"@tachybase/schema": "1.6.0-alpha.9",
|
|
10
10
|
"react-i18next": "16.2.1",
|
|
11
|
-
"@tachybase/module-acl": "1.6.
|
|
11
|
+
"@tachybase/module-acl": "1.6.1",
|
|
12
12
|
"sequelize": "6.37.5",
|
|
13
|
-
"@tego/client": "1.
|
|
13
|
+
"@tego/client": "1.6.0-alpha.9",
|
|
14
14
|
"@dnd-kit/core": "6.3.1",
|
|
15
15
|
"ahooks": "3.9.0"
|
|
16
16
|
};
|
|
File without changes
|
package/dist/server/plugin.d.ts
CHANGED
package/dist/server/plugin.js
CHANGED
|
@@ -31,7 +31,6 @@ __export(plugin_exports, {
|
|
|
31
31
|
default: () => plugin_default
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
-
var import_node_path = require("node:path");
|
|
35
34
|
var import_server = require("@tego/server");
|
|
36
35
|
var import_lodash = __toESM(require("lodash"));
|
|
37
36
|
var import_connections_roles_resources = require("./models/connections-roles-resources");
|
|
@@ -235,7 +234,7 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
|
235
234
|
},
|
|
236
235
|
{ tag: "dataSourcesget" }
|
|
237
236
|
);
|
|
238
|
-
this.app.
|
|
237
|
+
this.app.resourcer.registerActions({
|
|
239
238
|
async ["dataSources:listEnabled"](ctx, next) {
|
|
240
239
|
const dataSources = await ctx.db.getRepository("dataSources").find({
|
|
241
240
|
filter: {
|
|
@@ -251,7 +250,7 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
|
251
250
|
async ["dataSources:testConnection"](ctx, next) {
|
|
252
251
|
const { values } = ctx.action.params;
|
|
253
252
|
const { options, type } = values;
|
|
254
|
-
const klass = ctx.
|
|
253
|
+
const klass = ctx.tego.dataSourceManager.factory.getClass(type);
|
|
255
254
|
try {
|
|
256
255
|
await klass.testConnection(this.renderJsonTemplate(options || {}));
|
|
257
256
|
} catch (error) {
|
|
@@ -272,7 +271,7 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
|
272
271
|
const currentStatus = plugin.dataSourceStatus[filterByTk];
|
|
273
272
|
if (canRefreshStatus.includes(currentStatus) && (clientStatus ? clientStatus && canRefreshStatus.includes(clientStatus) : true)) {
|
|
274
273
|
dataSourceModel.loadIntoApplication({
|
|
275
|
-
app: ctx.
|
|
274
|
+
app: ctx.tego
|
|
276
275
|
});
|
|
277
276
|
}
|
|
278
277
|
ctx.body = {
|
|
@@ -480,9 +479,6 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
|
|
|
480
479
|
};
|
|
481
480
|
});
|
|
482
481
|
}
|
|
483
|
-
async load() {
|
|
484
|
-
await this.importCollections((0, import_node_path.resolve)(__dirname, "collections"));
|
|
485
|
-
}
|
|
486
482
|
}
|
|
487
483
|
var plugin_default = PluginDataSourceManagerServer;
|
|
488
484
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -37,7 +37,7 @@ var data_sources_collections_fields_default = {
|
|
|
37
37
|
async list(ctx, next) {
|
|
38
38
|
const { associatedIndex: collectionNameWithDataSourceKey } = ctx.action.params;
|
|
39
39
|
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
40
|
-
const dataSource = ctx.
|
|
40
|
+
const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
|
|
41
41
|
const collection = dataSource.collectionManager.getCollection(collectionName);
|
|
42
42
|
const fields = collection.getFields();
|
|
43
43
|
ctx.body = import_lodash.default.sortBy(
|
|
@@ -49,7 +49,7 @@ var data_sources_collections_fields_default = {
|
|
|
49
49
|
async get(ctx, next) {
|
|
50
50
|
const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name } = ctx.action.params;
|
|
51
51
|
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
52
|
-
const dataSource = ctx.
|
|
52
|
+
const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
|
|
53
53
|
const collection = dataSource.collectionManager.getCollection(collectionName);
|
|
54
54
|
const field = collection.getField(name);
|
|
55
55
|
ctx.body = field.options;
|
|
@@ -58,7 +58,7 @@ var data_sources_collections_fields_default = {
|
|
|
58
58
|
async update(ctx, next) {
|
|
59
59
|
const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name, values } = ctx.action.params;
|
|
60
60
|
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
61
|
-
const mainDb = ctx.
|
|
61
|
+
const mainDb = ctx.tego.db;
|
|
62
62
|
let fieldRecord = await mainDb.getRepository("dataSourcesFields").findOne({
|
|
63
63
|
filter: {
|
|
64
64
|
name,
|
|
@@ -85,14 +85,14 @@ var data_sources_collections_fields_default = {
|
|
|
85
85
|
values
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
const field = ctx.
|
|
88
|
+
const field = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey).collectionManager.getCollection(collectionName).getField(name);
|
|
89
89
|
ctx.body = field.options;
|
|
90
90
|
await next();
|
|
91
91
|
},
|
|
92
92
|
async create(ctx, next) {
|
|
93
93
|
const { associatedIndex: collectionNameWithDataSourceKey, values } = ctx.action.params;
|
|
94
94
|
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
95
|
-
const mainDb = ctx.
|
|
95
|
+
const mainDb = ctx.tego.db;
|
|
96
96
|
const name = values.name;
|
|
97
97
|
if (await mainDb.getRepository("dataSourcesFields").findOne({
|
|
98
98
|
filter: {
|
|
@@ -118,7 +118,7 @@ var data_sources_collections_fields_default = {
|
|
|
118
118
|
async destroy(ctx, next) {
|
|
119
119
|
const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name } = ctx.action.params;
|
|
120
120
|
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
121
|
-
const mainDb = ctx.
|
|
121
|
+
const mainDb = ctx.tego.db;
|
|
122
122
|
const fieldRecord = await mainDb.getRepository("dataSourcesFields").findOne({
|
|
123
123
|
filter: {
|
|
124
124
|
name,
|
|
@@ -38,7 +38,7 @@ var data_sources_collections_default = {
|
|
|
38
38
|
var _a, _b;
|
|
39
39
|
const params = ctx.action.params;
|
|
40
40
|
const { associatedIndex: dataSourceKey } = params;
|
|
41
|
-
const dataSource = ctx.
|
|
41
|
+
const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
|
|
42
42
|
if (!dataSource) {
|
|
43
43
|
throw new Error(`dataSource ${dataSourceKey} not found`);
|
|
44
44
|
}
|
|
@@ -44,7 +44,7 @@ const rolesRemoteCollectionsResourcer = {
|
|
|
44
44
|
const { page = 1, pageSize = 20 } = ctx.action.params;
|
|
45
45
|
const { filter } = ctx.action.params;
|
|
46
46
|
const { dataSourceKey } = filter;
|
|
47
|
-
const dataSource = ctx.
|
|
47
|
+
const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
|
|
48
48
|
const collectionRepository = new import_full_data_repository.FullDataRepository(dataSource.collectionManager.getCollections());
|
|
49
49
|
const [collections] = await collectionRepository.findAndCount();
|
|
50
50
|
const filterItem = import_lodash.default.get(filter, "$and");
|
|
@@ -52,7 +52,7 @@ const rolesRemoteCollectionsResourcer = {
|
|
|
52
52
|
const filterByName = filterItem == null ? void 0 : filterItem.find((item) => item.name);
|
|
53
53
|
const filterTitle = (_a = import_lodash.default.get(filterByTitle, "title.$includes")) == null ? void 0 : _a.toLowerCase();
|
|
54
54
|
const filterName = (_b = import_lodash.default.get(filterByName, "name.$includes")) == null ? void 0 : _b.toLowerCase();
|
|
55
|
-
const roleResources = await ctx.
|
|
55
|
+
const roleResources = await ctx.tego.db.getRepository("dataSourcesRolesResources").find({
|
|
56
56
|
filter: {
|
|
57
57
|
roleName: role,
|
|
58
58
|
dataSourceKey
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-data-source",
|
|
3
3
|
"displayName": "Data source manager",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"description": "Manage data sources, including the built-in Master database, external databases, APIs, etc.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Data model tools"
|
|
8
8
|
],
|
|
9
9
|
"main": "dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@ant-design/icons": "^
|
|
11
|
+
"@ant-design/icons": "^6.1.0",
|
|
12
12
|
"@dnd-kit/core": "^6.3.1",
|
|
13
|
-
"@tachybase/schema": "1.
|
|
14
|
-
"@tachybase/test": "1.
|
|
15
|
-
"@tego/client": "1.
|
|
16
|
-
"@tego/server": "1.
|
|
13
|
+
"@tachybase/schema": "1.6.0-alpha.9",
|
|
14
|
+
"@tachybase/test": "1.6.0-alpha.9",
|
|
15
|
+
"@tego/client": "1.6.0-alpha.9",
|
|
16
|
+
"@tego/server": "1.6.0-alpha.9",
|
|
17
17
|
"@types/lodash": "^4.17.20",
|
|
18
18
|
"ahooks": "^3.9.0",
|
|
19
19
|
"antd": "5.22.5",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"react-i18next": "16.2.1",
|
|
23
23
|
"react-router-dom": "6.28.1",
|
|
24
24
|
"sequelize": "6.37.5",
|
|
25
|
-
"@tachybase/client": "1.6.
|
|
26
|
-
"@tachybase/module-acl": "1.6.
|
|
25
|
+
"@tachybase/client": "1.6.1",
|
|
26
|
+
"@tachybase/module-acl": "1.6.1"
|
|
27
27
|
},
|
|
28
28
|
"description.zh-CN": "管理数据源,包括内置的 Master 数据库,外部的数据库、API。",
|
|
29
29
|
"displayName.zh-CN": "数据源管理",
|