@tachybase/module-data-source 0.23.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.
- package/.turbo/turbo-build.log +14 -0
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/DatabaseConnectionProvider.d.ts +3 -0
- package/dist/client/ThridDataSource.d.ts +4 -0
- package/dist/client/component/BreadcumbTitle.d.ts +2 -0
- package/dist/client/component/CollectionsManager/AddFieldAction.d.ts +5 -0
- package/dist/client/component/CollectionsManager/CollectionFields.d.ts +8 -0
- package/dist/client/component/CollectionsManager/ConfigurationTable.d.ts +2 -0
- package/dist/client/component/CollectionsManager/ConfigurationTabs.d.ts +2 -0
- package/dist/client/component/CollectionsManager/EditCollectionAction.d.ts +6 -0
- package/dist/client/component/CollectionsManager/EditFieldAction.d.ts +2 -0
- package/dist/client/component/CollectionsManager/components/CollectionFieldInterfaceSelect.d.ts +2 -0
- package/dist/client/component/CollectionsManager/components/CollectionName.d.ts +1 -0
- package/dist/client/component/CollectionsManager/components/FieldTitleInput.d.ts +2 -0
- package/dist/client/component/CollectionsManager/components/FieldType.d.ts +2 -0
- package/dist/client/component/CollectionsManager/components/TitleField.d.ts +2 -0
- package/dist/client/component/CollectionsManager/components/UnSupportFields.d.ts +2 -0
- package/dist/client/component/CollectionsManager/components/index.d.ts +6 -0
- package/dist/client/component/CollectionsManager/hooks.d.ts +12 -0
- package/dist/client/component/CollectionsManager/index.d.ts +2 -0
- package/dist/client/component/CollectionsManager/schema/collectionFields.d.ts +4 -0
- package/dist/client/component/CollectionsManager/schema/collections.d.ts +8 -0
- package/dist/client/component/CreateDatabaseConnectAction.d.ts +2 -0
- package/dist/client/component/DatabaseConnectionManager.d.ts +2 -0
- package/dist/client/component/DatasourceLink.d.ts +2 -0
- package/dist/client/component/EditDatabaseConnectionAction.d.ts +2 -0
- package/dist/client/component/MainDataSourceManager/Configuration/AddCategoryAction.d.ts +3 -0
- package/dist/client/component/MainDataSourceManager/Configuration/CollectionFields.d.ts +2 -0
- package/dist/client/component/MainDataSourceManager/Configuration/CollectionFieldsTable.d.ts +15 -0
- package/dist/client/component/MainDataSourceManager/Configuration/CollectionFieldsTableArray.d.ts +8 -0
- package/dist/client/component/MainDataSourceManager/Configuration/ConfigurationTable.d.ts +2 -0
- package/dist/client/component/MainDataSourceManager/Configuration/ConfigurationTabs.d.ts +2 -0
- package/dist/client/component/MainDataSourceManager/Configuration/EditCategoryAction.d.ts +3 -0
- package/dist/client/component/MainDataSourceManager/Configuration/index.d.ts +6 -0
- package/dist/client/component/MainDataSourceManager/Configuration/interfaces.d.ts +16 -0
- package/dist/client/component/MainDataSourceManager/Configuration/schemas/collectionFields.d.ts +5 -0
- package/dist/client/component/MainDataSourceManager/Configuration/schemas/collections.d.ts +7 -0
- package/dist/client/component/MainDataSourceManager/index.d.ts +2 -0
- package/dist/client/component/PermissionManager/DataSourceTable.d.ts +3 -0
- package/dist/client/component/PermissionManager/PermisionProvider.d.ts +5 -0
- package/dist/client/component/PermissionManager/RoleConfigure.d.ts +2 -0
- package/dist/client/component/PermissionManager/RolesResourcesActions.d.ts +3 -0
- package/dist/client/component/PermissionManager/ScopeSelect.d.ts +3 -0
- package/dist/client/component/PermissionManager/StrategyActions.d.ts +2 -0
- package/dist/client/component/PermissionManager/index.d.ts +3 -0
- package/dist/client/component/PermissionManager/schemas/dataSourceTable.d.ts +2 -0
- package/dist/client/component/PermissionManager/schemas/roleCollections.d.ts +2 -0
- package/dist/client/component/PermissionManager/schemas/scopes.d.ts +11 -0
- package/dist/client/component/PermissionManager/schemas/useRoleResourceValues.d.ts +8 -0
- package/dist/client/component/PermissionManager/schemas/useSaveRoleResourceAction.d.ts +3 -0
- package/dist/client/component/PermissionManager/style.d.ts +1 -0
- package/dist/client/component/ViewDatabaseConnectionAction.d.ts +2 -0
- package/dist/client/constant.d.ts +4 -0
- package/dist/client/hooks/index.d.ts +6 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +56 -0
- package/dist/client/locale/index.d.ts +3 -0
- package/dist/client/schema/index.d.ts +7 -0
- package/dist/externalVersion.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/zh-CN.json +35 -0
- package/dist/server/collections/data-sources-collections.d.ts +2 -0
- package/dist/server/collections/data-sources-collections.js +66 -0
- package/dist/server/collections/data-sources-fields.d.ts +2 -0
- package/dist/server/collections/data-sources-fields.js +87 -0
- package/dist/server/collections/data-sources-roles-resources-actions.d.ts +2 -0
- package/dist/server/collections/data-sources-roles-resources-actions.js +52 -0
- package/dist/server/collections/data-sources-roles-resources-scopes.d.ts +2 -0
- package/dist/server/collections/data-sources-roles-resources-scopes.js +56 -0
- package/dist/server/collections/data-sources-roles-resources.d.ts +2 -0
- package/dist/server/collections/data-sources-roles-resources.js +62 -0
- package/dist/server/collections/data-sources-roles.d.ts +2 -0
- package/dist/server/collections/data-sources-roles.js +54 -0
- package/dist/server/collections/data-sources.d.ts +2 -0
- package/dist/server/collections/data-sources.js +71 -0
- package/dist/server/errors/type-infer-error.d.ts +2 -0
- package/dist/server/errors/type-infer-error.js +28 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +39 -0
- package/dist/server/migrations/20240301164024-migrate-acl-resources.d.ts +7 -0
- package/dist/server/migrations/20240301164024-migrate-acl-resources.js +117 -0
- package/dist/server/models/connections-roles-resources-action.d.ts +3 -0
- package/dist/server/models/connections-roles-resources-action.js +29 -0
- package/dist/server/models/connections-roles-resources.d.ts +3 -0
- package/dist/server/models/connections-roles-resources.js +29 -0
- package/dist/server/models/data-source.d.ts +18 -0
- package/dist/server/models/data-source.js +170 -0
- package/dist/server/models/data-sources-collection-model.d.ts +7 -0
- package/dist/server/models/data-sources-collection-model.js +37 -0
- package/dist/server/models/data-sources-field-model.d.ts +10 -0
- package/dist/server/models/data-sources-field-model.js +54 -0
- package/dist/server/models/data-sources-roles-model.d.ts +13 -0
- package/dist/server/models/data-sources-roles-model.js +58 -0
- package/dist/server/plugin.d.ts +13 -0
- package/dist/server/plugin.js +448 -0
- package/dist/server/resourcers/data-sources-collections-fields.d.ts +11 -0
- package/dist/server/resourcers/data-sources-collections-fields.js +131 -0
- package/dist/server/resourcers/data-sources-collections.d.ts +8 -0
- package/dist/server/resourcers/data-sources-collections.js +106 -0
- package/dist/server/resourcers/data-sources-resources.d.ts +9 -0
- package/dist/server/resourcers/data-sources-resources.js +88 -0
- package/dist/server/resourcers/data-sources-roles.d.ts +8 -0
- package/dist/server/resourcers/data-sources-roles.js +89 -0
- package/dist/server/resourcers/roles-data-sources-collections.d.ts +7 -0
- package/dist/server/resourcers/roles-data-sources-collections.js +102 -0
- package/dist/server/services/collection-manager.d.ts +6 -0
- package/dist/server/services/collection-manager.js +33 -0
- package/dist/server/services/database-introspector.d.ts +70 -0
- package/dist/server/services/database-introspector.js +235 -0
- package/dist/server/services/full-data-repository.d.ts +8 -0
- package/dist/server/services/full-data-repository.js +51 -0
- package/dist/server/services/type-interface-map.d.ts +183 -0
- package/dist/server/services/type-interface-map.js +243 -0
- package/dist/server/utils.d.ts +1 -0
- package/dist/server/utils.js +38 -0
- package/package.json +36 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var data_sources_collections_exports = {};
|
|
29
|
+
__export(data_sources_collections_exports, {
|
|
30
|
+
default: () => data_sources_collections_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(data_sources_collections_exports);
|
|
33
|
+
var import_lodash = __toESM(require("lodash"));
|
|
34
|
+
var data_sources_collections_default = {
|
|
35
|
+
name: "dataSources.collections",
|
|
36
|
+
actions: {
|
|
37
|
+
async list(ctx, next) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const params = ctx.action.params;
|
|
40
|
+
const { associatedIndex: dataSourceKey } = params;
|
|
41
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
42
|
+
if (!dataSource) {
|
|
43
|
+
throw new Error(`dataSource ${dataSourceKey} not found`);
|
|
44
|
+
}
|
|
45
|
+
const { paginate, filter } = ctx.action.params;
|
|
46
|
+
const filterTitle = (_a = import_lodash.default.get(filter, "$and.0.title.$includes")) == null ? void 0 : _a.toLowerCase();
|
|
47
|
+
const filterName = (_b = import_lodash.default.get(filter, "$and.0.name.$includes")) == null ? void 0 : _b.toLowerCase();
|
|
48
|
+
const collections = import_lodash.default.sortBy(
|
|
49
|
+
dataSource.collectionManager.getCollections().filter((collection) => {
|
|
50
|
+
var _a2;
|
|
51
|
+
return (!filterTitle || ((_a2 = import_lodash.default.get(collection, "options.title")) == null ? void 0 : _a2.toLowerCase().includes(filterTitle))) && (!filterName || collection.options.name.toLowerCase().includes(filterName));
|
|
52
|
+
}),
|
|
53
|
+
"name"
|
|
54
|
+
);
|
|
55
|
+
const mapCollection = (collections2) => {
|
|
56
|
+
return collections2.map((collection) => {
|
|
57
|
+
return {
|
|
58
|
+
...collection.options,
|
|
59
|
+
fields: collection.getFields().map((field) => field.options)
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
if (paginate === false || paginate === "false") {
|
|
64
|
+
ctx.body = mapCollection(collections);
|
|
65
|
+
} else {
|
|
66
|
+
const { page = 1, pageSize = 20 } = ctx.action.params;
|
|
67
|
+
ctx.withoutDataWrapping = true;
|
|
68
|
+
ctx.body = {
|
|
69
|
+
data: mapCollection(collections.slice((page - 1) * pageSize, page * pageSize)),
|
|
70
|
+
meta: {
|
|
71
|
+
count: collections.length,
|
|
72
|
+
page,
|
|
73
|
+
pageSize,
|
|
74
|
+
totalPage: Math.ceil(collections.length / pageSize)
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
await next();
|
|
79
|
+
},
|
|
80
|
+
async update(ctx, next) {
|
|
81
|
+
const params = ctx.action.params;
|
|
82
|
+
const { filterByTk: collectionName, associatedIndex: dataSourceKey } = params;
|
|
83
|
+
let dataSourceCollectionRecord = await ctx.db.getRepository("dataSourcesCollections").findOne({
|
|
84
|
+
filter: {
|
|
85
|
+
name: collectionName,
|
|
86
|
+
dataSourceKey
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (!dataSourceCollectionRecord) {
|
|
90
|
+
dataSourceCollectionRecord = await ctx.db.getRepository("dataSourcesCollections").create({
|
|
91
|
+
values: {
|
|
92
|
+
...params.values,
|
|
93
|
+
name: collectionName,
|
|
94
|
+
dataSourceKey
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
await dataSourceCollectionRecord.update({
|
|
99
|
+
...params.values
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
ctx.body = dataSourceCollectionRecord.toJSON();
|
|
103
|
+
await next();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var data_sources_resources_exports = {};
|
|
19
|
+
__export(data_sources_resources_exports, {
|
|
20
|
+
default: () => data_sources_resources_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(data_sources_resources_exports);
|
|
23
|
+
var data_sources_resources_default = {
|
|
24
|
+
name: "roles.dataSourceResources",
|
|
25
|
+
actions: {
|
|
26
|
+
async create(ctx, next) {
|
|
27
|
+
const { associatedIndex: roleName } = ctx.action.params;
|
|
28
|
+
const db = ctx.db;
|
|
29
|
+
const transaction = await db.sequelize.transaction();
|
|
30
|
+
const dataSourceKey = ctx.action.params.values.dataSourceKey;
|
|
31
|
+
if (!dataSourceKey) {
|
|
32
|
+
throw new Error("dataSourceKey is required");
|
|
33
|
+
}
|
|
34
|
+
const connectionRole = await db.getRepository("dataSourcesRoles").findOne({
|
|
35
|
+
filter: {
|
|
36
|
+
roleName,
|
|
37
|
+
dataSourceKey
|
|
38
|
+
},
|
|
39
|
+
transaction
|
|
40
|
+
});
|
|
41
|
+
if (!connectionRole) {
|
|
42
|
+
await db.getRepository("dataSourcesRoles").create({
|
|
43
|
+
values: {
|
|
44
|
+
roleName,
|
|
45
|
+
dataSourceKey
|
|
46
|
+
},
|
|
47
|
+
transaction
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const record = await db.getRepository("dataSourcesRolesResources").create({
|
|
51
|
+
values: {
|
|
52
|
+
roleName,
|
|
53
|
+
...ctx.action.params.values
|
|
54
|
+
},
|
|
55
|
+
transaction
|
|
56
|
+
});
|
|
57
|
+
await transaction.commit();
|
|
58
|
+
ctx.body = record.toJSON();
|
|
59
|
+
await next();
|
|
60
|
+
},
|
|
61
|
+
async update(ctx, next) {
|
|
62
|
+
const { associatedIndex: roleName } = ctx.action.params;
|
|
63
|
+
ctx.body = await ctx.db.getRepository("dataSourcesRolesResources").update({
|
|
64
|
+
filter: {
|
|
65
|
+
roleName,
|
|
66
|
+
dataSourceKey: ctx.action.params.filter.dataSourceKey,
|
|
67
|
+
name: ctx.action.params.filter.name
|
|
68
|
+
},
|
|
69
|
+
values: ctx.action.params.values,
|
|
70
|
+
updateAssociationValues: ["actions"]
|
|
71
|
+
});
|
|
72
|
+
await next();
|
|
73
|
+
},
|
|
74
|
+
async get(ctx, next) {
|
|
75
|
+
const { associatedIndex: roleName } = ctx.action.params;
|
|
76
|
+
const record = await ctx.db.getRepository("dataSourcesRolesResources").findOne({
|
|
77
|
+
filter: {
|
|
78
|
+
roleName,
|
|
79
|
+
dataSourceKey: ctx.action.params.filter.dataSourceKey,
|
|
80
|
+
name: ctx.action.params.filter.name
|
|
81
|
+
},
|
|
82
|
+
appends: ctx.action.params.appends
|
|
83
|
+
});
|
|
84
|
+
ctx.body = record;
|
|
85
|
+
await next();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var data_sources_roles_exports = {};
|
|
19
|
+
__export(data_sources_roles_exports, {
|
|
20
|
+
default: () => data_sources_roles_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(data_sources_roles_exports);
|
|
23
|
+
var data_sources_roles_default = {
|
|
24
|
+
name: "dataSources.roles",
|
|
25
|
+
actions: {
|
|
26
|
+
async update(ctx, next) {
|
|
27
|
+
const params = ctx.action.params;
|
|
28
|
+
const { filterByTk: name, associatedIndex: dataSourceKey } = params;
|
|
29
|
+
let connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").findOne({
|
|
30
|
+
filter: {
|
|
31
|
+
roleName: name,
|
|
32
|
+
dataSourceKey
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!connectionRoleRecord) {
|
|
36
|
+
connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").create({
|
|
37
|
+
values: {
|
|
38
|
+
...params.values,
|
|
39
|
+
roleName: name,
|
|
40
|
+
dataSourceKey
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
await connectionRoleRecord.update({
|
|
45
|
+
...params.values
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (params.values.resources) {
|
|
49
|
+
await ctx.db.getRepository("dataSourcesRolesResources").destroy({
|
|
50
|
+
filter: {
|
|
51
|
+
roleName: name,
|
|
52
|
+
dataSourceKey
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
for (const resource of params.values.resources) {
|
|
56
|
+
await ctx.db.getRepository("dataSourcesRolesResources").create({
|
|
57
|
+
values: {
|
|
58
|
+
...resource,
|
|
59
|
+
roleName: name,
|
|
60
|
+
dataSourceKey
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ctx.body = connectionRoleRecord.toJSON();
|
|
66
|
+
await next();
|
|
67
|
+
},
|
|
68
|
+
async get(ctx, next) {
|
|
69
|
+
const params = ctx.action.params;
|
|
70
|
+
const { filterByTk: name, associatedIndex: dataSourceKey } = params;
|
|
71
|
+
let connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").findOne({
|
|
72
|
+
filter: {
|
|
73
|
+
roleName: name,
|
|
74
|
+
dataSourceKey
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
if (!connectionRoleRecord) {
|
|
78
|
+
connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").create({
|
|
79
|
+
values: {
|
|
80
|
+
roleName: name,
|
|
81
|
+
dataSourceKey
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
ctx.body = connectionRoleRecord.toJSON();
|
|
86
|
+
await next();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var roles_data_sources_collections_exports = {};
|
|
29
|
+
__export(roles_data_sources_collections_exports, {
|
|
30
|
+
rolesRemoteCollectionsResourcer: () => rolesRemoteCollectionsResourcer
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(roles_data_sources_collections_exports);
|
|
33
|
+
var import_lodash = __toESM(require("lodash"));
|
|
34
|
+
var import_full_data_repository = require("../services/full-data-repository");
|
|
35
|
+
function totalPage(total, pageSize) {
|
|
36
|
+
return Math.ceil(total / pageSize);
|
|
37
|
+
}
|
|
38
|
+
const rolesRemoteCollectionsResourcer = {
|
|
39
|
+
name: "roles.dataSourcesCollections",
|
|
40
|
+
actions: {
|
|
41
|
+
async list(ctx, next) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const role = ctx.action.params.associatedIndex;
|
|
44
|
+
const { page = 1, pageSize = 20 } = ctx.action.params;
|
|
45
|
+
const { filter } = ctx.action.params;
|
|
46
|
+
const { dataSourceKey } = filter;
|
|
47
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
48
|
+
const collectionRepository = new import_full_data_repository.FullDataRepository(dataSource.collectionManager.getCollections());
|
|
49
|
+
const [collections] = await collectionRepository.findAndCount();
|
|
50
|
+
const filterItem = import_lodash.default.get(filter, "$and");
|
|
51
|
+
const filterByTitle = filterItem == null ? void 0 : filterItem.find((item) => item.title);
|
|
52
|
+
const filterByName = filterItem == null ? void 0 : filterItem.find((item) => item.name);
|
|
53
|
+
const filterTitle = (_a = import_lodash.default.get(filterByTitle, "title.$includes")) == null ? void 0 : _a.toLowerCase();
|
|
54
|
+
const filterName = (_b = import_lodash.default.get(filterByName, "name.$includes")) == null ? void 0 : _b.toLowerCase();
|
|
55
|
+
const roleResources = await ctx.app.db.getRepository("dataSourcesRolesResources").find({
|
|
56
|
+
filter: {
|
|
57
|
+
roleName: role,
|
|
58
|
+
dataSourceKey
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const roleResourcesNames = roleResources.map((roleResource) => roleResource.get("name"));
|
|
62
|
+
const roleResourceActionResourceNames = roleResources.filter((roleResources2) => roleResources2.get("usingActionsConfig")).map((roleResources2) => roleResources2.get("name"));
|
|
63
|
+
const filtedCollections = collections.filter((collection) => {
|
|
64
|
+
var _a2;
|
|
65
|
+
return (!filterTitle || ((_a2 = import_lodash.default.get(collection, "options.title")) == null ? void 0 : _a2.toLowerCase().includes(filterTitle))) && (!filterName || collection.options.name.toLowerCase().includes(filterName));
|
|
66
|
+
});
|
|
67
|
+
const items = import_lodash.default.sortBy(
|
|
68
|
+
filtedCollections.map((collection, i) => {
|
|
69
|
+
var _a2;
|
|
70
|
+
const collectionName = collection.options.name;
|
|
71
|
+
const exists = roleResourcesNames.includes(collectionName);
|
|
72
|
+
const usingConfig = roleResourceActionResourceNames.includes(collectionName) ? "resourceAction" : "strategy";
|
|
73
|
+
return {
|
|
74
|
+
type: "collection",
|
|
75
|
+
name: collectionName,
|
|
76
|
+
collectionName,
|
|
77
|
+
title: ((_a2 = collection.options.uiSchema) == null ? void 0 : _a2.title) || collection.options.title,
|
|
78
|
+
roleName: role,
|
|
79
|
+
usingConfig,
|
|
80
|
+
exists,
|
|
81
|
+
fields: [...collection.fields.values()].map((field) => {
|
|
82
|
+
return field.options;
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
}),
|
|
86
|
+
"name"
|
|
87
|
+
);
|
|
88
|
+
ctx.body = {
|
|
89
|
+
count: filtedCollections.length,
|
|
90
|
+
rows: items,
|
|
91
|
+
page: Number(page),
|
|
92
|
+
pageSize: Number(pageSize),
|
|
93
|
+
totalPage: totalPage(filtedCollections.length, pageSize)
|
|
94
|
+
};
|
|
95
|
+
await next();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
rolesRemoteCollectionsResourcer
|
|
102
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var collection_manager_exports = {};
|
|
19
|
+
__export(collection_manager_exports, {
|
|
20
|
+
CollectionManager: () => CollectionManager
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(collection_manager_exports);
|
|
23
|
+
class CollectionManager {
|
|
24
|
+
constructor(db) {
|
|
25
|
+
this.db = db;
|
|
26
|
+
}
|
|
27
|
+
findAndCount() {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
CollectionManager
|
|
33
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Database } from '@tachybase/database';
|
|
2
|
+
type tableInfo = {
|
|
3
|
+
tableName: string;
|
|
4
|
+
schema?: string;
|
|
5
|
+
};
|
|
6
|
+
type GetCollectionOptions = {
|
|
7
|
+
tableInfo: tableInfo;
|
|
8
|
+
localOptions?: PartialCollectionOptions;
|
|
9
|
+
};
|
|
10
|
+
export type LocalData = {
|
|
11
|
+
[collectionName: string]: PartialCollectionOptions;
|
|
12
|
+
};
|
|
13
|
+
type GetCollectionsOptions = {
|
|
14
|
+
localData?: LocalData;
|
|
15
|
+
};
|
|
16
|
+
export type PartialCollectionOptions = Partial<Omit<CollectionOptions, 'fields'> & {
|
|
17
|
+
fields?: Partial<FieldOptions>[];
|
|
18
|
+
}>;
|
|
19
|
+
interface CollectionOptions {
|
|
20
|
+
name: string;
|
|
21
|
+
schema?: string;
|
|
22
|
+
tableName: string;
|
|
23
|
+
title?: string;
|
|
24
|
+
timestamps?: boolean;
|
|
25
|
+
filterTargetKey?: string;
|
|
26
|
+
fields: FieldOptions[];
|
|
27
|
+
unsupportedFields?: UnsupportedFieldOptions[];
|
|
28
|
+
}
|
|
29
|
+
interface UnsupportedFieldOptions {
|
|
30
|
+
rawType: string;
|
|
31
|
+
name: string;
|
|
32
|
+
supported: false;
|
|
33
|
+
}
|
|
34
|
+
interface FieldOptions {
|
|
35
|
+
name: string;
|
|
36
|
+
field: string;
|
|
37
|
+
rawType: string;
|
|
38
|
+
type: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
interface?: string;
|
|
41
|
+
uiSchema?: any;
|
|
42
|
+
possibleTypes?: string[];
|
|
43
|
+
defaultValue?: any;
|
|
44
|
+
primaryKey: boolean;
|
|
45
|
+
unique: boolean;
|
|
46
|
+
allowNull?: boolean;
|
|
47
|
+
autoIncrement?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare class DatabaseIntrospector {
|
|
50
|
+
private db;
|
|
51
|
+
constructor(db: Database);
|
|
52
|
+
getCollections(options?: GetCollectionsOptions): Promise<Array<CollectionOptions>>;
|
|
53
|
+
getCollection(options: GetCollectionOptions): Promise<CollectionOptions>;
|
|
54
|
+
loadCollection(options: CollectionOptions): void;
|
|
55
|
+
loadCollections(options: {
|
|
56
|
+
collections: CollectionOptions[];
|
|
57
|
+
}): void;
|
|
58
|
+
tableInfoToCollectionOptions(tableInfo: tableInfo): {
|
|
59
|
+
name: string;
|
|
60
|
+
schema?: string;
|
|
61
|
+
tableName: string;
|
|
62
|
+
title?: string;
|
|
63
|
+
};
|
|
64
|
+
private collectionOptionsByFields;
|
|
65
|
+
private mergeLocalDataIntoCollectionOptions;
|
|
66
|
+
private columnInfoToFieldOptions;
|
|
67
|
+
private getDefaultInterfaceByType;
|
|
68
|
+
private columnAttribute;
|
|
69
|
+
}
|
|
70
|
+
export {};
|