@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,18 @@
|
|
|
1
|
+
import { ACL } from '@tachybase/acl';
|
|
2
|
+
import { Model, Transaction } from '@tachybase/database';
|
|
3
|
+
import { Application } from '@tachybase/server';
|
|
4
|
+
export declare class DataSourceModel extends Model {
|
|
5
|
+
isMainRecord(): boolean;
|
|
6
|
+
loadIntoACL(options: {
|
|
7
|
+
app: Application;
|
|
8
|
+
acl: ACL;
|
|
9
|
+
transaction?: Transaction;
|
|
10
|
+
loadAtAfterStart?: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
loadIntoApplication(options: {
|
|
13
|
+
app: Application;
|
|
14
|
+
transaction?: Transaction;
|
|
15
|
+
loadAtAfterStart?: boolean;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
private loadLocalData;
|
|
18
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
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_source_exports = {};
|
|
19
|
+
__export(data_source_exports, {
|
|
20
|
+
DataSourceModel: () => DataSourceModel
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(data_source_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var import_module_acl = require("@tachybase/module-acl");
|
|
25
|
+
const availableActions = {
|
|
26
|
+
create: {
|
|
27
|
+
displayName: '{{t("Add new")}}',
|
|
28
|
+
type: "new-data",
|
|
29
|
+
onNewRecord: true,
|
|
30
|
+
allowConfigureFields: true
|
|
31
|
+
},
|
|
32
|
+
// import: {
|
|
33
|
+
// displayName: '{{t("Import")}}',
|
|
34
|
+
// type: 'new-data',
|
|
35
|
+
// scope: false,
|
|
36
|
+
// },
|
|
37
|
+
// export: {
|
|
38
|
+
// displayName: '{{t("Export")}}',
|
|
39
|
+
// type: 'old-data',
|
|
40
|
+
// allowConfigureFields: true,
|
|
41
|
+
// },
|
|
42
|
+
view: {
|
|
43
|
+
displayName: '{{t("View")}}',
|
|
44
|
+
type: "old-data",
|
|
45
|
+
aliases: ["get", "list"],
|
|
46
|
+
allowConfigureFields: true
|
|
47
|
+
},
|
|
48
|
+
update: {
|
|
49
|
+
displayName: '{{t("Edit")}}',
|
|
50
|
+
type: "old-data",
|
|
51
|
+
aliases: ["update", "move"],
|
|
52
|
+
allowConfigureFields: true
|
|
53
|
+
},
|
|
54
|
+
destroy: {
|
|
55
|
+
displayName: '{{t("Delete")}}',
|
|
56
|
+
type: "old-data"
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
class DataSourceModel extends import_database.Model {
|
|
60
|
+
isMainRecord() {
|
|
61
|
+
return this.get("type") === "main";
|
|
62
|
+
}
|
|
63
|
+
async loadIntoACL(options) {
|
|
64
|
+
const { app, acl } = options;
|
|
65
|
+
const loadRoleIntoACL = async (model) => {
|
|
66
|
+
const pluginACL = app.pm.get("acl");
|
|
67
|
+
const params = {
|
|
68
|
+
grantHelper: pluginACL.grantHelper,
|
|
69
|
+
associationFieldsActions: pluginACL.associationFieldsActions,
|
|
70
|
+
acl
|
|
71
|
+
};
|
|
72
|
+
if (!options.loadAtAfterStart) {
|
|
73
|
+
params.app = app;
|
|
74
|
+
}
|
|
75
|
+
await model.writeToAcl(params);
|
|
76
|
+
};
|
|
77
|
+
const rolesModel = await app.db.getRepository("dataSourcesRoles").find({
|
|
78
|
+
transaction: options.transaction,
|
|
79
|
+
filter: {
|
|
80
|
+
dataSourceKey: this.get("key")
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
for (const roleModel of rolesModel) {
|
|
84
|
+
await loadRoleIntoACL(roleModel);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async loadIntoApplication(options) {
|
|
88
|
+
const { app, loadAtAfterStart } = options;
|
|
89
|
+
const dataSourceKey = this.get("key");
|
|
90
|
+
const pluginDataSourceManagerServer = app.pm.get("data-source");
|
|
91
|
+
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === "loaded") {
|
|
92
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "reloading";
|
|
93
|
+
} else {
|
|
94
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "loading";
|
|
95
|
+
}
|
|
96
|
+
const type = this.get("type");
|
|
97
|
+
const createOptions = this.get("options");
|
|
98
|
+
const dataSource = app.dataSourceManager.factory.create(type, {
|
|
99
|
+
...createOptions,
|
|
100
|
+
name: this.get("key")
|
|
101
|
+
});
|
|
102
|
+
if (loadAtAfterStart) {
|
|
103
|
+
dataSource.on("loadMessage", ({ message }) => {
|
|
104
|
+
app.setMaintainingMessage(`${message} in data source ${this.get("displayName")}`);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const acl = dataSource.acl;
|
|
108
|
+
for (const [actionName, actionParams] of Object.entries(availableActions)) {
|
|
109
|
+
acl.setAvailableAction(actionName, actionParams);
|
|
110
|
+
}
|
|
111
|
+
acl.allow("*", "*", (ctx) => {
|
|
112
|
+
return ctx.state.currentRole === "root";
|
|
113
|
+
});
|
|
114
|
+
dataSource.resourceManager.use(import_module_acl.setCurrentRole, { tag: "setCurrentRole", before: "acl", after: "auth" });
|
|
115
|
+
await this.loadIntoACL({ app, acl, transaction: options.transaction });
|
|
116
|
+
try {
|
|
117
|
+
await app.dataSourceManager.add(dataSource, {
|
|
118
|
+
localData: await this.loadLocalData()
|
|
119
|
+
});
|
|
120
|
+
} catch (e) {
|
|
121
|
+
app.logger.error(`load data source failed, ${e}`);
|
|
122
|
+
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === "loading") {
|
|
123
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "loading-failed";
|
|
124
|
+
}
|
|
125
|
+
if (pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] === "reloading") {
|
|
126
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "reloading-failed";
|
|
127
|
+
}
|
|
128
|
+
pluginDataSourceManagerServer.dataSourceErrors[dataSourceKey] = e;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
pluginDataSourceManagerServer.dataSourceStatus[dataSourceKey] = "loaded";
|
|
132
|
+
}
|
|
133
|
+
async loadLocalData() {
|
|
134
|
+
const dataSourceKey = this.get("key");
|
|
135
|
+
const remoteCollections = await this.db.getRepository("dataSourcesCollections").find({
|
|
136
|
+
filter: {
|
|
137
|
+
dataSourceKey
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const remoteFields = await this.db.getRepository("dataSourcesFields").find({
|
|
141
|
+
filter: {
|
|
142
|
+
dataSourceKey
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const localData = {};
|
|
146
|
+
for (const remoteCollection of remoteCollections) {
|
|
147
|
+
const remoteCollectionOptions = remoteCollection.toJSON();
|
|
148
|
+
localData[remoteCollectionOptions.name] = remoteCollectionOptions;
|
|
149
|
+
}
|
|
150
|
+
for (const remoteField of remoteFields) {
|
|
151
|
+
const remoteFieldOptions = remoteField.toJSON();
|
|
152
|
+
const collectionName = remoteFieldOptions.collectionName;
|
|
153
|
+
if (!localData[collectionName]) {
|
|
154
|
+
localData[collectionName] = {
|
|
155
|
+
name: collectionName,
|
|
156
|
+
fields: []
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!localData[collectionName].fields) {
|
|
160
|
+
localData[collectionName].fields = [];
|
|
161
|
+
}
|
|
162
|
+
localData[collectionName].fields.push(remoteFieldOptions);
|
|
163
|
+
}
|
|
164
|
+
return localData;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
DataSourceModel
|
|
170
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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_collection_model_exports = {};
|
|
19
|
+
__export(data_sources_collection_model_exports, {
|
|
20
|
+
DataSourcesCollectionModel: () => DataSourcesCollectionModel
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(data_sources_collection_model_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
class DataSourcesCollectionModel extends import_database.MagicAttributeModel {
|
|
25
|
+
load(loadOptions) {
|
|
26
|
+
const { app } = loadOptions;
|
|
27
|
+
const collectionOptions = this.get();
|
|
28
|
+
const dataSourceName = this.get("dataSourceKey");
|
|
29
|
+
const dataSource = app.dataSourceManager.dataSources.get(dataSourceName);
|
|
30
|
+
const collection = dataSource.collectionManager.getCollection(collectionOptions.name);
|
|
31
|
+
collection.updateOptions(collectionOptions);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
DataSourcesCollectionModel
|
|
37
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MagicAttributeModel } from '@tachybase/database';
|
|
2
|
+
import { Application } from '@tachybase/server';
|
|
3
|
+
type LoadOptions = {
|
|
4
|
+
app: Application;
|
|
5
|
+
};
|
|
6
|
+
export declare class DataSourcesFieldModel extends MagicAttributeModel {
|
|
7
|
+
load(loadOptions: LoadOptions): void;
|
|
8
|
+
unload(loadOptions: LoadOptions): void;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
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_field_model_exports = {};
|
|
19
|
+
__export(data_sources_field_model_exports, {
|
|
20
|
+
DataSourcesFieldModel: () => DataSourcesFieldModel
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(data_sources_field_model_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var import_utils = require("../utils");
|
|
25
|
+
class DataSourcesFieldModel extends import_database.MagicAttributeModel {
|
|
26
|
+
load(loadOptions) {
|
|
27
|
+
const { app } = loadOptions;
|
|
28
|
+
const options = this.get();
|
|
29
|
+
const { collectionName, name, dataSourceKey } = options;
|
|
30
|
+
const dataSource = app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
31
|
+
const collection = dataSource.collectionManager.getCollection(collectionName);
|
|
32
|
+
const oldField = collection.getField(name);
|
|
33
|
+
const newOptions = (0, import_utils.mergeOptions)(oldField ? oldField.options : {}, options);
|
|
34
|
+
collection.setField(name, newOptions);
|
|
35
|
+
}
|
|
36
|
+
unload(loadOptions) {
|
|
37
|
+
const { app } = loadOptions;
|
|
38
|
+
const options = this.get();
|
|
39
|
+
const { collectionName, name, dataSourceKey } = options;
|
|
40
|
+
const dataSource = app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
41
|
+
if (!dataSource) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const collection = dataSource.collectionManager.getCollection(collectionName);
|
|
45
|
+
if (!collection) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
collection.removeField(name);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
DataSourcesFieldModel
|
|
54
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ACL } from '@tachybase/acl';
|
|
2
|
+
import { Model } from '@tachybase/database';
|
|
3
|
+
import Application from '@tachybase/server';
|
|
4
|
+
import { Transaction } from 'sequelize';
|
|
5
|
+
export declare class DataSourcesRolesModel extends Model {
|
|
6
|
+
writeToAcl(options: {
|
|
7
|
+
acl: ACL;
|
|
8
|
+
transaction?: Transaction;
|
|
9
|
+
associationFieldsActions: any;
|
|
10
|
+
grantHelper: any;
|
|
11
|
+
app?: Application;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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_model_exports = {};
|
|
19
|
+
__export(data_sources_roles_model_exports, {
|
|
20
|
+
DataSourcesRolesModel: () => DataSourcesRolesModel
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(data_sources_roles_model_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
class DataSourcesRolesModel extends import_database.Model {
|
|
25
|
+
async writeToAcl(options) {
|
|
26
|
+
const { acl, transaction } = options;
|
|
27
|
+
const roleName = this.get("roleName");
|
|
28
|
+
let role = acl.getRole(roleName);
|
|
29
|
+
if (!role) {
|
|
30
|
+
role = acl.define({
|
|
31
|
+
role: roleName
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
role.setStrategy({
|
|
35
|
+
...this.get("strategy") || {}
|
|
36
|
+
});
|
|
37
|
+
const resources = await this.db.getRepository("dataSourcesRolesResources").find({
|
|
38
|
+
filter: {
|
|
39
|
+
roleName,
|
|
40
|
+
dataSourceKey: this.get("dataSourceKey")
|
|
41
|
+
},
|
|
42
|
+
transaction
|
|
43
|
+
});
|
|
44
|
+
for (const resource of resources) {
|
|
45
|
+
await resource.writeToACL({
|
|
46
|
+
acl,
|
|
47
|
+
transaction,
|
|
48
|
+
grantHelper: options.grantHelper,
|
|
49
|
+
associationFieldsActions: options.associationFieldsActions,
|
|
50
|
+
app: options.app
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
DataSourcesRolesModel
|
|
58
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Plugin } from '@tachybase/server';
|
|
2
|
+
type DataSourceState = 'loading' | 'loaded' | 'loading-failed' | 'reloading' | 'reloading-failed';
|
|
3
|
+
export declare class PluginDataSourceManagerServer extends Plugin {
|
|
4
|
+
dataSourceErrors: {
|
|
5
|
+
[dataSourceKey: string]: Error;
|
|
6
|
+
};
|
|
7
|
+
dataSourceStatus: {
|
|
8
|
+
[dataSourceKey: string]: DataSourceState;
|
|
9
|
+
};
|
|
10
|
+
beforeLoad(): Promise<void>;
|
|
11
|
+
load(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export default PluginDataSourceManagerServer;
|