@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,48 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var server_exports = {};
|
|
39
|
+
__export(server_exports, {
|
|
40
|
+
default: () => import_plugin.default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(server_exports);
|
|
43
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
44
|
+
__reExport(server_exports, require("./utils"), module.exports);
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
...require("./utils")
|
|
48
|
+
});
|
|
@@ -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
|
+
import { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
on: string;
|
|
12
|
+
appVersion: string;
|
|
13
|
+
up(): Promise<void>;
|
|
14
|
+
doUp(transaction: any): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
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 migrate_acl_resources_exports = {};
|
|
28
|
+
__export(migrate_acl_resources_exports, {
|
|
29
|
+
default: () => migrate_acl_resources_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(migrate_acl_resources_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
var import_utils = require("@nocobase/utils");
|
|
34
|
+
/* istanbul ignore file -- @preserve */
|
|
35
|
+
class migrate_acl_resources_default extends import_server.Migration {
|
|
36
|
+
on = "afterSync";
|
|
37
|
+
// 'beforeLoad' or 'afterLoad'
|
|
38
|
+
appVersion = "<0.19.0-alpha.10";
|
|
39
|
+
async up() {
|
|
40
|
+
const transaction = await this.db.sequelize.transaction();
|
|
41
|
+
try {
|
|
42
|
+
await this.doUp(transaction);
|
|
43
|
+
await transaction.commit();
|
|
44
|
+
} catch (e) {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async doUp(transaction) {
|
|
49
|
+
const scopeMap = {};
|
|
50
|
+
const oldScopes = await this.db.getRepository("rolesResourcesScopes").find({
|
|
51
|
+
transaction
|
|
52
|
+
});
|
|
53
|
+
for (const oldScope of oldScopes) {
|
|
54
|
+
const key = oldScope.key;
|
|
55
|
+
const newScope = await this.db.getRepository("dataSourcesRolesResourcesScopes").firstOrCreate({
|
|
56
|
+
values: {
|
|
57
|
+
key,
|
|
58
|
+
name: oldScope.name,
|
|
59
|
+
resourceName: oldScope.resourceName,
|
|
60
|
+
scope: oldScope.scope,
|
|
61
|
+
dataSourceKey: "main"
|
|
62
|
+
},
|
|
63
|
+
filterKeys: ["key", "dataSourceKey"],
|
|
64
|
+
hooks: false,
|
|
65
|
+
transaction
|
|
66
|
+
});
|
|
67
|
+
scopeMap[key] = newScope.id;
|
|
68
|
+
}
|
|
69
|
+
const roles = await this.db.getRepository("roles").find({
|
|
70
|
+
transaction
|
|
71
|
+
});
|
|
72
|
+
for (const role of roles) {
|
|
73
|
+
await this.app.db.getRepository("dataSourcesRoles").updateOrCreate({
|
|
74
|
+
values: {
|
|
75
|
+
roleName: role.get("name"),
|
|
76
|
+
dataSourceKey: "main",
|
|
77
|
+
strategy: role.get("strategy"),
|
|
78
|
+
id: (0, import_utils.uid)()
|
|
79
|
+
},
|
|
80
|
+
filterKeys: ["roleName", "dataSourceKey"],
|
|
81
|
+
hooks: false,
|
|
82
|
+
transaction
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const oldResources = await this.db.getRepository("rolesResources").find({
|
|
86
|
+
appends: ["actions"],
|
|
87
|
+
transaction
|
|
88
|
+
});
|
|
89
|
+
for (const oldResource of oldResources) {
|
|
90
|
+
const role = await this.db.getRepository("roles").findOne({
|
|
91
|
+
filter: {
|
|
92
|
+
name: oldResource.roleName
|
|
93
|
+
},
|
|
94
|
+
transaction
|
|
95
|
+
});
|
|
96
|
+
if (!role) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const newResource = await this.db.getRepository("dataSourcesRolesResources").firstOrCreate({
|
|
100
|
+
values: {
|
|
101
|
+
name: oldResource.name,
|
|
102
|
+
roleName: oldResource.roleName,
|
|
103
|
+
usingActionsConfig: oldResource.usingActionsConfig,
|
|
104
|
+
dataSourceKey: "main"
|
|
105
|
+
},
|
|
106
|
+
transaction,
|
|
107
|
+
filterKeys: ["name"],
|
|
108
|
+
hooks: false
|
|
109
|
+
});
|
|
110
|
+
for (const oldAction of oldResource.actions) {
|
|
111
|
+
const newActionValues = {
|
|
112
|
+
resource: newResource.id,
|
|
113
|
+
name: oldAction.name,
|
|
114
|
+
fields: oldAction.fields
|
|
115
|
+
};
|
|
116
|
+
if (oldAction.scope) {
|
|
117
|
+
newActionValues.scope = scopeMap[oldAction.scope];
|
|
118
|
+
}
|
|
119
|
+
await this.db.getRepository("dataSourcesRolesResourcesActions").create({
|
|
120
|
+
values: newActionValues,
|
|
121
|
+
hooks: false,
|
|
122
|
+
transaction
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 { Migration } from '@nocobase/server';
|
|
10
|
+
export default class extends Migration {
|
|
11
|
+
on: string;
|
|
12
|
+
appVersion: string;
|
|
13
|
+
up(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 update_snippet_name_exports = {};
|
|
28
|
+
__export(update_snippet_name_exports, {
|
|
29
|
+
default: () => update_snippet_name_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(update_snippet_name_exports);
|
|
32
|
+
var import_server = require("@nocobase/server");
|
|
33
|
+
class update_snippet_name_default extends import_server.Migration {
|
|
34
|
+
on = "afterLoad";
|
|
35
|
+
// 'beforeLoad' or 'afterLoad'
|
|
36
|
+
appVersion = "<0.21.0-alpha.8";
|
|
37
|
+
async up() {
|
|
38
|
+
const roles = await this.db.getRepository("roles").find();
|
|
39
|
+
for (const role of roles) {
|
|
40
|
+
const snippets = await role.get("snippets");
|
|
41
|
+
let roleNeedsUpdate = false;
|
|
42
|
+
for (let i = 0; i < snippets.length; i++) {
|
|
43
|
+
if (snippets[i].includes("pm.database-connections.manager")) {
|
|
44
|
+
snippets[i] = snippets[i].replace("pm.database-connections.manager", "pm.data-source-manager");
|
|
45
|
+
roleNeedsUpdate = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (roleNeedsUpdate) {
|
|
49
|
+
await this.db.getRepository("roles").update({
|
|
50
|
+
filter: {
|
|
51
|
+
name: role.get("name")
|
|
52
|
+
},
|
|
53
|
+
values: {
|
|
54
|
+
snippets: JSON.parse(JSON.stringify(snippets))
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { RoleResourceActionModel } from '@nocobase/plugin-acl';
|
|
10
|
+
export declare class DataSourcesRolesResourcesActionModel extends RoleResourceActionModel {
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 connections_roles_resources_action_exports = {};
|
|
28
|
+
__export(connections_roles_resources_action_exports, {
|
|
29
|
+
DataSourcesRolesResourcesActionModel: () => DataSourcesRolesResourcesActionModel
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(connections_roles_resources_action_exports);
|
|
32
|
+
var import_plugin_acl = require("@nocobase/plugin-acl");
|
|
33
|
+
class DataSourcesRolesResourcesActionModel extends import_plugin_acl.RoleResourceActionModel {
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
DataSourcesRolesResourcesActionModel
|
|
38
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { RoleResourceModel } from '@nocobase/plugin-acl';
|
|
10
|
+
export declare class DataSourcesRolesResourcesModel extends RoleResourceModel {
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 connections_roles_resources_exports = {};
|
|
28
|
+
__export(connections_roles_resources_exports, {
|
|
29
|
+
DataSourcesRolesResourcesModel: () => DataSourcesRolesResourcesModel
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(connections_roles_resources_exports);
|
|
32
|
+
var import_plugin_acl = require("@nocobase/plugin-acl");
|
|
33
|
+
class DataSourcesRolesResourcesModel extends import_plugin_acl.RoleResourceModel {
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
DataSourcesRolesResourcesModel
|
|
38
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { Model, Transaction } from '@nocobase/database';
|
|
10
|
+
import { Application } from '@nocobase/server';
|
|
11
|
+
import { ACL } from '@nocobase/acl';
|
|
12
|
+
export declare class DataSourceModel extends Model {
|
|
13
|
+
isMainRecord(): boolean;
|
|
14
|
+
loadIntoACL(options: {
|
|
15
|
+
app: Application;
|
|
16
|
+
acl: ACL;
|
|
17
|
+
transaction?: Transaction;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
loadIntoApplication(options: {
|
|
20
|
+
app: Application;
|
|
21
|
+
transaction?: Transaction;
|
|
22
|
+
loadAtAfterStart?: boolean;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
private loadLocalData;
|
|
25
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
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_source_exports = {};
|
|
28
|
+
__export(data_source_exports, {
|
|
29
|
+
DataSourceModel: () => DataSourceModel
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(data_source_exports);
|
|
32
|
+
var import_database = require("@nocobase/database");
|
|
33
|
+
var import_plugin_acl = require("@nocobase/plugin-acl");
|
|
34
|
+
const availableActions = {
|
|
35
|
+
create: {
|
|
36
|
+
displayName: '{{t("Add new")}}',
|
|
37
|
+
type: "new-data",
|
|
38
|
+
onNewRecord: true,
|
|
39
|
+
allowConfigureFields: true
|
|
40
|
+
},
|
|
41
|
+
// import: {
|
|
42
|
+
// displayName: '{{t("Import")}}',
|
|
43
|
+
// type: 'new-data',
|
|
44
|
+
// scope: false,
|
|
45
|
+
// },
|
|
46
|
+
// export: {
|
|
47
|
+
// displayName: '{{t("Export")}}',
|
|
48
|
+
// type: 'old-data',
|
|
49
|
+
// allowConfigureFields: true,
|
|
50
|
+
// },
|
|
51
|
+
view: {
|
|
52
|
+
displayName: '{{t("View")}}',
|
|
53
|
+
type: "old-data",
|
|
54
|
+
aliases: ["get", "list"],
|
|
55
|
+
allowConfigureFields: true
|
|
56
|
+
},
|
|
57
|
+
update: {
|
|
58
|
+
displayName: '{{t("Edit")}}',
|
|
59
|
+
type: "old-data",
|
|
60
|
+
aliases: ["update", "move"],
|
|
61
|
+
allowConfigureFields: true
|
|
62
|
+
},
|
|
63
|
+
destroy: {
|
|
64
|
+
displayName: '{{t("Delete")}}',
|
|
65
|
+
type: "old-data"
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
class DataSourceModel extends import_database.Model {
|
|
69
|
+
isMainRecord() {
|
|
70
|
+
return this.get("type") === "main";
|
|
71
|
+
}
|
|
72
|
+
async loadIntoACL(options) {
|
|
73
|
+
const { app, acl } = options;
|
|
74
|
+
const loadRoleIntoACL = async (model) => {
|
|
75
|
+
await model.writeToAcl({
|
|
76
|
+
acl
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const rolesModel = await app.db.getRepository("dataSourcesRoles").find({
|
|
80
|
+
transaction: options.transaction,
|
|
81
|
+
filter: {
|
|
82
|
+
dataSourceKey: this.get("key")
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
for (const roleModel of rolesModel) {
|
|
86
|
+
await loadRoleIntoACL(roleModel);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async loadIntoApplication(options) {
|
|
90
|
+
const { app, loadAtAfterStart } = options;
|
|
91
|
+
const dataSourceKey = this.get("key");
|
|
92
|
+
const pluginDataSourceManagerServer = app.pm.get("data-source-manager");
|
|
93
|
+
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === "loaded") {
|
|
94
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "reloading";
|
|
95
|
+
} else {
|
|
96
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "loading";
|
|
97
|
+
}
|
|
98
|
+
const type = this.get("type");
|
|
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
|
+
});
|
|
105
|
+
if (loadAtAfterStart) {
|
|
106
|
+
dataSource.on("loadMessage", ({ message }) => {
|
|
107
|
+
app.setMaintainingMessage(`${message} in data source ${this.get("displayName")}`);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const acl = dataSource.acl;
|
|
111
|
+
for (const [actionName, actionParams] of Object.entries(availableActions)) {
|
|
112
|
+
acl.setAvailableAction(actionName, actionParams);
|
|
113
|
+
}
|
|
114
|
+
acl.allow("*", "*", (ctx) => {
|
|
115
|
+
return ctx.state.currentRole === "root";
|
|
116
|
+
});
|
|
117
|
+
dataSource.resourceManager.use(import_plugin_acl.setCurrentRole, { tag: "setCurrentRole", before: "acl", after: "auth" });
|
|
118
|
+
await this.loadIntoACL({ app, acl, transaction: options.transaction });
|
|
119
|
+
try {
|
|
120
|
+
await app.dataSourceManager.add(dataSource, {
|
|
121
|
+
localData: await this.loadLocalData()
|
|
122
|
+
});
|
|
123
|
+
} catch (e) {
|
|
124
|
+
app.logger.error(`load data source failed, ${e}`);
|
|
125
|
+
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === "loading") {
|
|
126
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "loading-failed";
|
|
127
|
+
}
|
|
128
|
+
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === "reloading") {
|
|
129
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "reloading-failed";
|
|
130
|
+
}
|
|
131
|
+
pluginDataSourceManagerServer.dataSourceErrors[dataSourceKey] = e;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "loaded";
|
|
135
|
+
}
|
|
136
|
+
async loadLocalData() {
|
|
137
|
+
const dataSourceKey = this.get("key");
|
|
138
|
+
const remoteCollections = await this.db.getRepository("dataSourcesCollections").find({
|
|
139
|
+
filter: {
|
|
140
|
+
dataSourceKey
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const remoteFields = await this.db.getRepository("dataSourcesFields").find({
|
|
144
|
+
filter: {
|
|
145
|
+
dataSourceKey
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const localData = {};
|
|
149
|
+
for (const remoteCollection of remoteCollections) {
|
|
150
|
+
const remoteCollectionOptions = remoteCollection.toJSON();
|
|
151
|
+
localData[remoteCollectionOptions.name] = remoteCollectionOptions;
|
|
152
|
+
}
|
|
153
|
+
for (const remoteField of remoteFields) {
|
|
154
|
+
const remoteFieldOptions = remoteField.toJSON();
|
|
155
|
+
const collectionName = remoteFieldOptions.collectionName;
|
|
156
|
+
if (!localData[collectionName]) {
|
|
157
|
+
localData[collectionName] = {
|
|
158
|
+
name: collectionName,
|
|
159
|
+
fields: []
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (!localData[collectionName].fields) {
|
|
163
|
+
localData[collectionName].fields = [];
|
|
164
|
+
}
|
|
165
|
+
localData[collectionName].fields.push(remoteFieldOptions);
|
|
166
|
+
}
|
|
167
|
+
return localData;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
+
0 && (module.exports = {
|
|
172
|
+
DataSourceModel
|
|
173
|
+
});
|
|
@@ -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
|
+
import { MagicAttributeModel } from '@nocobase/database';
|
|
10
|
+
import { Application } from '@nocobase/server';
|
|
11
|
+
export declare class DataSourcesCollectionModel extends MagicAttributeModel {
|
|
12
|
+
load(loadOptions: {
|
|
13
|
+
app: Application;
|
|
14
|
+
}): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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_collection_model_exports = {};
|
|
28
|
+
__export(data_sources_collection_model_exports, {
|
|
29
|
+
DataSourcesCollectionModel: () => DataSourcesCollectionModel
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(data_sources_collection_model_exports);
|
|
32
|
+
var import_database = require("@nocobase/database");
|
|
33
|
+
class DataSourcesCollectionModel extends import_database.MagicAttributeModel {
|
|
34
|
+
load(loadOptions) {
|
|
35
|
+
const { app } = loadOptions;
|
|
36
|
+
const collectionOptions = this.get();
|
|
37
|
+
const dataSourceName = this.get("dataSourceKey");
|
|
38
|
+
const dataSource = app.dataSourceManager.dataSources.get(dataSourceName);
|
|
39
|
+
const collection = dataSource.collectionManager.getCollection(collectionOptions.name);
|
|
40
|
+
collection.updateOptions(collectionOptions);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
DataSourcesCollectionModel
|
|
46
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { MagicAttributeModel } from '@nocobase/database';
|
|
10
|
+
import { Application } from '@nocobase/server';
|
|
11
|
+
type LoadOptions = {
|
|
12
|
+
app: Application;
|
|
13
|
+
};
|
|
14
|
+
export declare class DataSourcesFieldModel extends MagicAttributeModel {
|
|
15
|
+
load(loadOptions: LoadOptions): void;
|
|
16
|
+
unload(loadOptions: LoadOptions): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|