@nocobase/plugin-data-source-manager 1.3.0-alpha.20240710084543 → 1.3.0-alpha.20240710155619
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/client/DatabaseConnectionProvider.d.ts +11 -0
- package/dist/client/ThridDataSource.d.ts +12 -0
- package/dist/client/component/BreadcumbTitle.d.ts +10 -0
- package/dist/client/component/CollectionsManager/AddFieldAction.d.ts +13 -0
- package/dist/client/component/CollectionsManager/CollectionFields.d.ts +16 -0
- package/dist/client/component/CollectionsManager/CollectionTitle.d.ts +9 -0
- package/dist/client/component/CollectionsManager/ConfigurationTable.d.ts +10 -0
- package/dist/client/component/CollectionsManager/ConfigurationTabs.d.ts +10 -0
- package/dist/client/component/CollectionsManager/EditCollectionAction.d.ts +14 -0
- package/dist/client/component/CollectionsManager/EditFieldAction.d.ts +10 -0
- package/dist/client/component/CollectionsManager/FilterTargetKeyAlert.d.ts +12 -0
- package/dist/client/component/CollectionsManager/SetFilterTargetKey.d.ts +10 -0
- package/dist/client/component/CollectionsManager/components/CollectionFieldInterfaceSelect.d.ts +10 -0
- package/dist/client/component/CollectionsManager/components/CollectionName.d.ts +9 -0
- package/dist/client/component/CollectionsManager/components/FieldTitleInput.d.ts +10 -0
- package/dist/client/component/CollectionsManager/components/FieldType.d.ts +10 -0
- package/dist/client/component/CollectionsManager/components/TitleField.d.ts +10 -0
- package/dist/client/component/CollectionsManager/components/UnSupportFields.d.ts +10 -0
- package/dist/client/component/CollectionsManager/components/index.d.ts +14 -0
- package/dist/client/component/CollectionsManager/hooks.d.ts +20 -0
- package/dist/client/component/CollectionsManager/index.d.ts +10 -0
- package/dist/client/component/CollectionsManager/schema/collectionFields.d.ts +12 -0
- package/dist/client/component/CollectionsManager/schema/collections.d.ts +72 -0
- package/dist/client/component/CreateDatabaseConnectAction.d.ts +10 -0
- package/dist/client/component/DatabaseConnectionManager.d.ts +10 -0
- package/dist/client/component/EditDatabaseConnectionAction.d.ts +10 -0
- package/dist/client/component/MainDataSourceManager/Configuration/AddCategoryAction.d.ts +11 -0
- package/dist/client/component/MainDataSourceManager/Configuration/CollectionFields.d.ts +11 -0
- package/dist/client/component/MainDataSourceManager/Configuration/ConfigurationTable.d.ts +10 -0
- package/dist/client/component/MainDataSourceManager/Configuration/ConfigurationTabs.d.ts +10 -0
- package/dist/client/component/MainDataSourceManager/Configuration/EditCategoryAction.d.ts +11 -0
- package/dist/client/component/MainDataSourceManager/Configuration/index.d.ts +13 -0
- package/dist/client/component/MainDataSourceManager/Configuration/interfaces.d.ts +24 -0
- package/dist/client/component/MainDataSourceManager/Configuration/schemas/collectionFields.d.ts +10 -0
- package/dist/client/component/MainDataSourceManager/Configuration/schemas/collections.d.ts +15 -0
- package/dist/client/component/MainDataSourceManager/index.d.ts +10 -0
- package/dist/client/component/PermissionManager/DataSourceTable.d.ts +11 -0
- package/dist/client/component/PermissionManager/PermisionProvider.d.ts +13 -0
- package/dist/client/component/PermissionManager/RoleConfigure.d.ts +10 -0
- package/dist/client/component/PermissionManager/RolesResourcesActions.d.ts +11 -0
- package/dist/client/component/PermissionManager/ScopeSelect.d.ts +11 -0
- package/dist/client/component/PermissionManager/StrategyActions.d.ts +10 -0
- package/dist/client/component/PermissionManager/index.d.ts +11 -0
- package/dist/client/component/PermissionManager/schemas/dataSourceTable.d.ts +10 -0
- package/dist/client/component/PermissionManager/schemas/roleCollections.d.ts +10 -0
- package/dist/client/component/PermissionManager/schemas/scopes.d.ts +130 -0
- package/dist/client/component/PermissionManager/schemas/useRoleResourceValues.d.ts +16 -0
- package/dist/client/component/PermissionManager/schemas/useSaveRoleResourceAction.d.ts +11 -0
- package/dist/client/component/PermissionManager/style.d.ts +9 -0
- package/dist/client/component/ViewDatabaseConnectionAction.d.ts +10 -0
- package/dist/client/constant.d.ts +9 -0
- package/dist/client/hooks/index.d.ts +14 -0
- package/dist/client/index.d.ts +17 -0
- package/dist/client/index.js +59 -0
- package/dist/client/locale/index.d.ts +11 -0
- package/dist/client/schema/index.d.ts +15 -0
- package/dist/externalVersion.js +33 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/zh-CN.json +40 -0
- package/dist/server/collections/data-sources-collections.d.ts +10 -0
- package/dist/server/collections/data-sources-collections.js +75 -0
- package/dist/server/collections/data-sources-fields.d.ts +10 -0
- package/dist/server/collections/data-sources-fields.js +96 -0
- package/dist/server/collections/data-sources-roles-resources-actions.d.ts +10 -0
- package/dist/server/collections/data-sources-roles-resources-actions.js +61 -0
- package/dist/server/collections/data-sources-roles-resources-scopes.d.ts +10 -0
- package/dist/server/collections/data-sources-roles-resources-scopes.js +65 -0
- package/dist/server/collections/data-sources-roles-resources.d.ts +10 -0
- package/dist/server/collections/data-sources-roles-resources.js +71 -0
- package/dist/server/collections/data-sources-roles.d.ts +10 -0
- package/dist/server/collections/data-sources-roles.js +63 -0
- package/dist/server/collections/data-sources.d.ts +10 -0
- package/dist/server/collections/data-sources.js +80 -0
- package/dist/server/errors/type-infer-error.d.ts +10 -0
- package/dist/server/errors/type-infer-error.js +37 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.js +48 -0
- package/dist/server/migrations/20240301164024-migrate-acl-resources.d.ts +15 -0
- package/dist/server/migrations/20240301164024-migrate-acl-resources.js +127 -0
- package/dist/server/migrations/20240414103927-update-snippet-name.d.ts +14 -0
- package/dist/server/migrations/20240414103927-update-snippet-name.js +60 -0
- package/dist/server/models/connections-roles-resources-action.d.ts +11 -0
- package/dist/server/models/connections-roles-resources-action.js +38 -0
- package/dist/server/models/connections-roles-resources.d.ts +11 -0
- package/dist/server/models/connections-roles-resources.js +38 -0
- package/dist/server/models/data-source.d.ts +25 -0
- package/dist/server/models/data-source.js +173 -0
- package/dist/server/models/data-sources-collection-model.d.ts +15 -0
- package/dist/server/models/data-sources-collection-model.js +46 -0
- package/dist/server/models/data-sources-field-model.d.ts +18 -0
- package/dist/server/models/data-sources-field-model.js +63 -0
- package/dist/server/models/data-sources-roles-model.d.ts +17 -0
- package/dist/server/models/data-sources-roles-model.js +64 -0
- package/dist/server/plugin.d.ts +21 -0
- package/dist/server/plugin.js +443 -0
- package/dist/server/resourcers/data-sources-collections-fields.d.ts +19 -0
- package/dist/server/resourcers/data-sources-collections-fields.js +140 -0
- package/dist/server/resourcers/data-sources-collections.d.ts +16 -0
- package/dist/server/resourcers/data-sources-collections.js +115 -0
- package/dist/server/resourcers/data-sources-resources.d.ts +17 -0
- package/dist/server/resourcers/data-sources-resources.js +97 -0
- package/dist/server/resourcers/data-sources-roles.d.ts +16 -0
- package/dist/server/resourcers/data-sources-roles.js +98 -0
- package/dist/server/resourcers/roles-data-sources-collections.d.ts +15 -0
- package/dist/server/resourcers/roles-data-sources-collections.js +111 -0
- package/dist/server/services/full-data-repository.d.ts +16 -0
- package/dist/server/services/full-data-repository.js +60 -0
- package/dist/server/services/type-interface-map.d.ts +202 -0
- package/dist/server/services/type-interface-map.js +267 -0
- package/dist/server/utils.d.ts +9 -0
- package/dist/server/utils.js +47 -0
- package/package.json +2 -2
|
@@ -0,0 +1,140 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var data_sources_collections_fields_exports = {};
|
|
38
|
+
__export(data_sources_collections_fields_exports, {
|
|
39
|
+
default: () => data_sources_collections_fields_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(data_sources_collections_fields_exports);
|
|
42
|
+
var import_lodash = __toESM(require("lodash"));
|
|
43
|
+
var data_sources_collections_fields_default = {
|
|
44
|
+
name: "dataSourcesCollections.fields",
|
|
45
|
+
actions: {
|
|
46
|
+
async list(ctx, next) {
|
|
47
|
+
const { associatedIndex: collectionNameWithDataSourceKey } = ctx.action.params;
|
|
48
|
+
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
49
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
50
|
+
const collection = dataSource.collectionManager.getCollection(collectionName);
|
|
51
|
+
const fields = collection.getFields();
|
|
52
|
+
ctx.body = import_lodash.default.sortBy(
|
|
53
|
+
fields.map((field) => field.options),
|
|
54
|
+
"name"
|
|
55
|
+
);
|
|
56
|
+
await next();
|
|
57
|
+
},
|
|
58
|
+
async get(ctx, next) {
|
|
59
|
+
const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name } = ctx.action.params;
|
|
60
|
+
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
61
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
62
|
+
const collection = dataSource.collectionManager.getCollection(collectionName);
|
|
63
|
+
const field = collection.getField(name);
|
|
64
|
+
ctx.body = field.options;
|
|
65
|
+
await next();
|
|
66
|
+
},
|
|
67
|
+
async update(ctx, next) {
|
|
68
|
+
const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name, values } = ctx.action.params;
|
|
69
|
+
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
70
|
+
const mainDb = ctx.app.db;
|
|
71
|
+
let fieldRecord = await mainDb.getRepository("dataSourcesFields").findOne({
|
|
72
|
+
filter: {
|
|
73
|
+
name,
|
|
74
|
+
collectionName,
|
|
75
|
+
dataSourceKey
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (!fieldRecord) {
|
|
79
|
+
fieldRecord = await mainDb.getRepository("dataSourcesFields").create({
|
|
80
|
+
values: {
|
|
81
|
+
...values,
|
|
82
|
+
name,
|
|
83
|
+
collectionName,
|
|
84
|
+
dataSourceKey
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
await fieldRecord.update({
|
|
89
|
+
...values
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const field = ctx.app.dataSourceManager.dataSources.get(dataSourceKey).collectionManager.getCollection(collectionName).getField(name);
|
|
93
|
+
ctx.body = field.options;
|
|
94
|
+
await next();
|
|
95
|
+
},
|
|
96
|
+
async create(ctx, next) {
|
|
97
|
+
const { associatedIndex: collectionNameWithDataSourceKey, values } = ctx.action.params;
|
|
98
|
+
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
99
|
+
const mainDb = ctx.app.db;
|
|
100
|
+
const name = values.name;
|
|
101
|
+
if (await mainDb.getRepository("dataSourcesFields").findOne({
|
|
102
|
+
filter: {
|
|
103
|
+
name,
|
|
104
|
+
collectionName,
|
|
105
|
+
dataSourceKey
|
|
106
|
+
}
|
|
107
|
+
})) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`Field name ${name} already exists in collection ${collectionName} of data source ${dataSourceKey}`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
const fieldRecord = await mainDb.getRepository("dataSourcesFields").create({
|
|
113
|
+
values: {
|
|
114
|
+
...values,
|
|
115
|
+
collectionName,
|
|
116
|
+
dataSourceKey
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
ctx.body = fieldRecord.toJSON();
|
|
120
|
+
await next();
|
|
121
|
+
},
|
|
122
|
+
async destroy(ctx, next) {
|
|
123
|
+
const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name } = ctx.action.params;
|
|
124
|
+
const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
|
|
125
|
+
const mainDb = ctx.app.db;
|
|
126
|
+
const fieldRecord = await mainDb.getRepository("dataSourcesFields").findOne({
|
|
127
|
+
filter: {
|
|
128
|
+
name,
|
|
129
|
+
collectionName,
|
|
130
|
+
dataSourceKey
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (fieldRecord) {
|
|
134
|
+
await fieldRecord.destroy();
|
|
135
|
+
}
|
|
136
|
+
ctx.body = "ok";
|
|
137
|
+
await next();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
declare const _default: {
|
|
10
|
+
name: string;
|
|
11
|
+
actions: {
|
|
12
|
+
list(ctx: any, next: any): Promise<void>;
|
|
13
|
+
update(ctx: any, next: any): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,115 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var data_sources_collections_exports = {};
|
|
38
|
+
__export(data_sources_collections_exports, {
|
|
39
|
+
default: () => data_sources_collections_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(data_sources_collections_exports);
|
|
42
|
+
var import_lodash = __toESM(require("lodash"));
|
|
43
|
+
var data_sources_collections_default = {
|
|
44
|
+
name: "dataSources.collections",
|
|
45
|
+
actions: {
|
|
46
|
+
async list(ctx, next) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const params = ctx.action.params;
|
|
49
|
+
const { associatedIndex: dataSourceKey } = params;
|
|
50
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
51
|
+
if (!dataSource) {
|
|
52
|
+
throw new Error(`dataSource ${dataSourceKey} not found`);
|
|
53
|
+
}
|
|
54
|
+
const { paginate, filter } = ctx.action.params;
|
|
55
|
+
const filterTitle = (_a = import_lodash.default.get(filter, "$and.0.title.$includes")) == null ? void 0 : _a.toLowerCase();
|
|
56
|
+
const filterName = (_b = import_lodash.default.get(filter, "$and.0.name.$includes")) == null ? void 0 : _b.toLowerCase();
|
|
57
|
+
const collections = import_lodash.default.sortBy(
|
|
58
|
+
dataSource.collectionManager.getCollections().filter((collection) => {
|
|
59
|
+
var _a2;
|
|
60
|
+
return (!filterTitle || ((_a2 = import_lodash.default.get(collection, "options.title")) == null ? void 0 : _a2.toLowerCase().includes(filterTitle))) && (!filterName || collection.options.name.toLowerCase().includes(filterName));
|
|
61
|
+
}),
|
|
62
|
+
"name"
|
|
63
|
+
);
|
|
64
|
+
const mapCollection = (collections2) => {
|
|
65
|
+
return collections2.map((collection) => {
|
|
66
|
+
return {
|
|
67
|
+
...collection.options,
|
|
68
|
+
fields: collection.getFields().map((field) => field.options)
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
if (paginate === false || paginate === "false") {
|
|
73
|
+
ctx.body = mapCollection(collections);
|
|
74
|
+
} else {
|
|
75
|
+
const { page = 1, pageSize = 20 } = ctx.action.params;
|
|
76
|
+
ctx.withoutDataWrapping = true;
|
|
77
|
+
ctx.body = {
|
|
78
|
+
data: mapCollection(collections.slice((page - 1) * pageSize, page * pageSize)),
|
|
79
|
+
meta: {
|
|
80
|
+
count: collections.length,
|
|
81
|
+
page,
|
|
82
|
+
pageSize,
|
|
83
|
+
totalPage: Math.ceil(collections.length / pageSize)
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
await next();
|
|
88
|
+
},
|
|
89
|
+
async update(ctx, next) {
|
|
90
|
+
const params = ctx.action.params;
|
|
91
|
+
const { filterByTk: collectionName, associatedIndex: dataSourceKey } = params;
|
|
92
|
+
let dataSourceCollectionRecord = await ctx.db.getRepository("dataSourcesCollections").findOne({
|
|
93
|
+
filter: {
|
|
94
|
+
name: collectionName,
|
|
95
|
+
dataSourceKey
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (!dataSourceCollectionRecord) {
|
|
99
|
+
dataSourceCollectionRecord = await ctx.db.getRepository("dataSourcesCollections").create({
|
|
100
|
+
values: {
|
|
101
|
+
...params.values,
|
|
102
|
+
name: collectionName,
|
|
103
|
+
dataSourceKey
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
await dataSourceCollectionRecord.update({
|
|
108
|
+
...params.values
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
ctx.body = dataSourceCollectionRecord.toJSON();
|
|
112
|
+
await next();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
declare const _default: {
|
|
10
|
+
name: string;
|
|
11
|
+
actions: {
|
|
12
|
+
create(ctx: any, next: any): Promise<void>;
|
|
13
|
+
update(ctx: any, next: any): Promise<void>;
|
|
14
|
+
get(ctx: any, next: any): Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 data_sources_resources_exports = {};
|
|
28
|
+
__export(data_sources_resources_exports, {
|
|
29
|
+
default: () => data_sources_resources_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(data_sources_resources_exports);
|
|
32
|
+
var data_sources_resources_default = {
|
|
33
|
+
name: "roles.dataSourceResources",
|
|
34
|
+
actions: {
|
|
35
|
+
async create(ctx, next) {
|
|
36
|
+
const { associatedIndex: roleName } = ctx.action.params;
|
|
37
|
+
const db = ctx.db;
|
|
38
|
+
const transaction = await db.sequelize.transaction();
|
|
39
|
+
const dataSourceKey = ctx.action.params.values.dataSourceKey;
|
|
40
|
+
if (!dataSourceKey) {
|
|
41
|
+
throw new Error("dataSourceKey is required");
|
|
42
|
+
}
|
|
43
|
+
const connectionRole = await db.getRepository("dataSourcesRoles").findOne({
|
|
44
|
+
filter: {
|
|
45
|
+
roleName,
|
|
46
|
+
dataSourceKey
|
|
47
|
+
},
|
|
48
|
+
transaction
|
|
49
|
+
});
|
|
50
|
+
if (!connectionRole) {
|
|
51
|
+
await db.getRepository("dataSourcesRoles").create({
|
|
52
|
+
values: {
|
|
53
|
+
roleName,
|
|
54
|
+
dataSourceKey
|
|
55
|
+
},
|
|
56
|
+
transaction
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const record = await db.getRepository("dataSourcesRolesResources").create({
|
|
60
|
+
values: {
|
|
61
|
+
roleName,
|
|
62
|
+
...ctx.action.params.values
|
|
63
|
+
},
|
|
64
|
+
transaction
|
|
65
|
+
});
|
|
66
|
+
await transaction.commit();
|
|
67
|
+
ctx.body = record.toJSON();
|
|
68
|
+
await next();
|
|
69
|
+
},
|
|
70
|
+
async update(ctx, next) {
|
|
71
|
+
const { associatedIndex: roleName } = ctx.action.params;
|
|
72
|
+
ctx.body = await ctx.db.getRepository("dataSourcesRolesResources").update({
|
|
73
|
+
filter: {
|
|
74
|
+
roleName,
|
|
75
|
+
dataSourceKey: ctx.action.params.filter.dataSourceKey,
|
|
76
|
+
name: ctx.action.params.filter.name
|
|
77
|
+
},
|
|
78
|
+
values: ctx.action.params.values,
|
|
79
|
+
updateAssociationValues: ["actions"]
|
|
80
|
+
});
|
|
81
|
+
await next();
|
|
82
|
+
},
|
|
83
|
+
async get(ctx, next) {
|
|
84
|
+
const { associatedIndex: roleName } = ctx.action.params;
|
|
85
|
+
const record = await ctx.db.getRepository("dataSourcesRolesResources").findOne({
|
|
86
|
+
filter: {
|
|
87
|
+
roleName,
|
|
88
|
+
dataSourceKey: ctx.action.params.filter.dataSourceKey,
|
|
89
|
+
name: ctx.action.params.filter.name
|
|
90
|
+
},
|
|
91
|
+
appends: ctx.action.params.appends
|
|
92
|
+
});
|
|
93
|
+
ctx.body = record;
|
|
94
|
+
await next();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
declare const _default: {
|
|
10
|
+
name: string;
|
|
11
|
+
actions: {
|
|
12
|
+
update(ctx: any, next: any): Promise<void>;
|
|
13
|
+
get(ctx: any, next: any): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,98 @@
|
|
|
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 data_sources_roles_exports = {};
|
|
28
|
+
__export(data_sources_roles_exports, {
|
|
29
|
+
default: () => data_sources_roles_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(data_sources_roles_exports);
|
|
32
|
+
var data_sources_roles_default = {
|
|
33
|
+
name: "dataSources.roles",
|
|
34
|
+
actions: {
|
|
35
|
+
async update(ctx, next) {
|
|
36
|
+
const params = ctx.action.params;
|
|
37
|
+
const { filterByTk: name, associatedIndex: dataSourceKey } = params;
|
|
38
|
+
let connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").findOne({
|
|
39
|
+
filter: {
|
|
40
|
+
roleName: name,
|
|
41
|
+
dataSourceKey
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (!connectionRoleRecord) {
|
|
45
|
+
connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").create({
|
|
46
|
+
values: {
|
|
47
|
+
...params.values,
|
|
48
|
+
roleName: name,
|
|
49
|
+
dataSourceKey
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
await connectionRoleRecord.update({
|
|
54
|
+
...params.values
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (params.values.resources) {
|
|
58
|
+
await ctx.db.getRepository("dataSourcesRolesResources").destroy({
|
|
59
|
+
filter: {
|
|
60
|
+
roleName: name,
|
|
61
|
+
dataSourceKey
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
for (const resource of params.values.resources) {
|
|
65
|
+
await ctx.db.getRepository("dataSourcesRolesResources").create({
|
|
66
|
+
values: {
|
|
67
|
+
...resource,
|
|
68
|
+
roleName: name,
|
|
69
|
+
dataSourceKey
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
ctx.body = connectionRoleRecord.toJSON();
|
|
75
|
+
await next();
|
|
76
|
+
},
|
|
77
|
+
async get(ctx, next) {
|
|
78
|
+
const params = ctx.action.params;
|
|
79
|
+
const { filterByTk: name, associatedIndex: dataSourceKey } = params;
|
|
80
|
+
let connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").findOne({
|
|
81
|
+
filter: {
|
|
82
|
+
roleName: name,
|
|
83
|
+
dataSourceKey
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (!connectionRoleRecord) {
|
|
87
|
+
connectionRoleRecord = await ctx.db.getRepository("dataSourcesRoles").create({
|
|
88
|
+
values: {
|
|
89
|
+
roleName: name,
|
|
90
|
+
dataSourceKey
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
ctx.body = connectionRoleRecord.toJSON();
|
|
95
|
+
await next();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
declare const rolesRemoteCollectionsResourcer: {
|
|
10
|
+
name: string;
|
|
11
|
+
actions: {
|
|
12
|
+
list(ctx: any, next: any): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export { rolesRemoteCollectionsResourcer };
|
|
@@ -0,0 +1,111 @@
|
|
|
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 __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var roles_data_sources_collections_exports = {};
|
|
38
|
+
__export(roles_data_sources_collections_exports, {
|
|
39
|
+
rolesRemoteCollectionsResourcer: () => rolesRemoteCollectionsResourcer
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(roles_data_sources_collections_exports);
|
|
42
|
+
var import_full_data_repository = require("../services/full-data-repository");
|
|
43
|
+
var import_lodash = __toESM(require("lodash"));
|
|
44
|
+
function totalPage(total, pageSize) {
|
|
45
|
+
return Math.ceil(total / pageSize);
|
|
46
|
+
}
|
|
47
|
+
const rolesRemoteCollectionsResourcer = {
|
|
48
|
+
name: "roles.dataSourcesCollections",
|
|
49
|
+
actions: {
|
|
50
|
+
async list(ctx, next) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const role = ctx.action.params.associatedIndex;
|
|
53
|
+
const { page = 1, pageSize = 20 } = ctx.action.params;
|
|
54
|
+
const { filter } = ctx.action.params;
|
|
55
|
+
const { dataSourceKey } = filter;
|
|
56
|
+
const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
57
|
+
const collectionRepository = new import_full_data_repository.FullDataRepository(dataSource.collectionManager.getCollections());
|
|
58
|
+
const [collections] = await collectionRepository.findAndCount();
|
|
59
|
+
const filterItem = import_lodash.default.get(filter, "$and");
|
|
60
|
+
const filterByTitle = filterItem == null ? void 0 : filterItem.find((item) => item.title);
|
|
61
|
+
const filterByName = filterItem == null ? void 0 : filterItem.find((item) => item.name);
|
|
62
|
+
const filterTitle = (_a = import_lodash.default.get(filterByTitle, "title.$includes")) == null ? void 0 : _a.toLowerCase();
|
|
63
|
+
const filterName = (_b = import_lodash.default.get(filterByName, "name.$includes")) == null ? void 0 : _b.toLowerCase();
|
|
64
|
+
const roleResources = await ctx.app.db.getRepository("dataSourcesRolesResources").find({
|
|
65
|
+
filter: {
|
|
66
|
+
roleName: role,
|
|
67
|
+
dataSourceKey
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const roleResourcesNames = roleResources.map((roleResource) => roleResource.get("name"));
|
|
71
|
+
const roleResourceActionResourceNames = roleResources.filter((roleResources2) => roleResources2.get("usingActionsConfig")).map((roleResources2) => roleResources2.get("name"));
|
|
72
|
+
const filtedCollections = collections.filter((collection) => {
|
|
73
|
+
var _a2;
|
|
74
|
+
return (!filterTitle || ((_a2 = import_lodash.default.get(collection, "options.title")) == null ? void 0 : _a2.toLowerCase().includes(filterTitle))) && (!filterName || collection.options.name.toLowerCase().includes(filterName));
|
|
75
|
+
});
|
|
76
|
+
const items = import_lodash.default.sortBy(
|
|
77
|
+
filtedCollections.map((collection, i) => {
|
|
78
|
+
var _a2;
|
|
79
|
+
const collectionName = collection.options.name;
|
|
80
|
+
const exists = roleResourcesNames.includes(collectionName);
|
|
81
|
+
const usingConfig = roleResourceActionResourceNames.includes(collectionName) ? "resourceAction" : "strategy";
|
|
82
|
+
return {
|
|
83
|
+
type: "collection",
|
|
84
|
+
name: collectionName,
|
|
85
|
+
collectionName,
|
|
86
|
+
title: ((_a2 = collection.options.uiSchema) == null ? void 0 : _a2.title) || collection.options.title,
|
|
87
|
+
roleName: role,
|
|
88
|
+
usingConfig,
|
|
89
|
+
exists,
|
|
90
|
+
fields: [...collection.fields.values()].map((field) => {
|
|
91
|
+
return field.options;
|
|
92
|
+
})
|
|
93
|
+
};
|
|
94
|
+
}),
|
|
95
|
+
"name"
|
|
96
|
+
);
|
|
97
|
+
ctx.body = {
|
|
98
|
+
count: filtedCollections.length,
|
|
99
|
+
rows: items,
|
|
100
|
+
page: Number(page),
|
|
101
|
+
pageSize: Number(pageSize),
|
|
102
|
+
totalPage: totalPage(filtedCollections.length, pageSize)
|
|
103
|
+
};
|
|
104
|
+
await next();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
rolesRemoteCollectionsResourcer
|
|
111
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { CountOptions, FindOptions } from '@nocobase/database';
|
|
10
|
+
export declare class FullDataRepository<T> {
|
|
11
|
+
data: Array<T>;
|
|
12
|
+
constructor(data: Array<T>);
|
|
13
|
+
count(countOptions?: CountOptions): Promise<number>;
|
|
14
|
+
find(options?: FindOptions): Promise<Array<T>>;
|
|
15
|
+
findAndCount(options?: {}): Promise<[Array<T>, number]>;
|
|
16
|
+
}
|