@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.
Files changed (122) hide show
  1. package/.turbo/turbo-build.log +14 -0
  2. package/LICENSE +201 -0
  3. package/README.md +1 -0
  4. package/client.d.ts +2 -0
  5. package/client.js +1 -0
  6. package/dist/client/DatabaseConnectionProvider.d.ts +3 -0
  7. package/dist/client/ThridDataSource.d.ts +4 -0
  8. package/dist/client/component/BreadcumbTitle.d.ts +2 -0
  9. package/dist/client/component/CollectionsManager/AddFieldAction.d.ts +5 -0
  10. package/dist/client/component/CollectionsManager/CollectionFields.d.ts +8 -0
  11. package/dist/client/component/CollectionsManager/ConfigurationTable.d.ts +2 -0
  12. package/dist/client/component/CollectionsManager/ConfigurationTabs.d.ts +2 -0
  13. package/dist/client/component/CollectionsManager/EditCollectionAction.d.ts +6 -0
  14. package/dist/client/component/CollectionsManager/EditFieldAction.d.ts +2 -0
  15. package/dist/client/component/CollectionsManager/components/CollectionFieldInterfaceSelect.d.ts +2 -0
  16. package/dist/client/component/CollectionsManager/components/CollectionName.d.ts +1 -0
  17. package/dist/client/component/CollectionsManager/components/FieldTitleInput.d.ts +2 -0
  18. package/dist/client/component/CollectionsManager/components/FieldType.d.ts +2 -0
  19. package/dist/client/component/CollectionsManager/components/TitleField.d.ts +2 -0
  20. package/dist/client/component/CollectionsManager/components/UnSupportFields.d.ts +2 -0
  21. package/dist/client/component/CollectionsManager/components/index.d.ts +6 -0
  22. package/dist/client/component/CollectionsManager/hooks.d.ts +12 -0
  23. package/dist/client/component/CollectionsManager/index.d.ts +2 -0
  24. package/dist/client/component/CollectionsManager/schema/collectionFields.d.ts +4 -0
  25. package/dist/client/component/CollectionsManager/schema/collections.d.ts +8 -0
  26. package/dist/client/component/CreateDatabaseConnectAction.d.ts +2 -0
  27. package/dist/client/component/DatabaseConnectionManager.d.ts +2 -0
  28. package/dist/client/component/DatasourceLink.d.ts +2 -0
  29. package/dist/client/component/EditDatabaseConnectionAction.d.ts +2 -0
  30. package/dist/client/component/MainDataSourceManager/Configuration/AddCategoryAction.d.ts +3 -0
  31. package/dist/client/component/MainDataSourceManager/Configuration/CollectionFields.d.ts +2 -0
  32. package/dist/client/component/MainDataSourceManager/Configuration/CollectionFieldsTable.d.ts +15 -0
  33. package/dist/client/component/MainDataSourceManager/Configuration/CollectionFieldsTableArray.d.ts +8 -0
  34. package/dist/client/component/MainDataSourceManager/Configuration/ConfigurationTable.d.ts +2 -0
  35. package/dist/client/component/MainDataSourceManager/Configuration/ConfigurationTabs.d.ts +2 -0
  36. package/dist/client/component/MainDataSourceManager/Configuration/EditCategoryAction.d.ts +3 -0
  37. package/dist/client/component/MainDataSourceManager/Configuration/index.d.ts +6 -0
  38. package/dist/client/component/MainDataSourceManager/Configuration/interfaces.d.ts +16 -0
  39. package/dist/client/component/MainDataSourceManager/Configuration/schemas/collectionFields.d.ts +5 -0
  40. package/dist/client/component/MainDataSourceManager/Configuration/schemas/collections.d.ts +7 -0
  41. package/dist/client/component/MainDataSourceManager/index.d.ts +2 -0
  42. package/dist/client/component/PermissionManager/DataSourceTable.d.ts +3 -0
  43. package/dist/client/component/PermissionManager/PermisionProvider.d.ts +5 -0
  44. package/dist/client/component/PermissionManager/RoleConfigure.d.ts +2 -0
  45. package/dist/client/component/PermissionManager/RolesResourcesActions.d.ts +3 -0
  46. package/dist/client/component/PermissionManager/ScopeSelect.d.ts +3 -0
  47. package/dist/client/component/PermissionManager/StrategyActions.d.ts +2 -0
  48. package/dist/client/component/PermissionManager/index.d.ts +3 -0
  49. package/dist/client/component/PermissionManager/schemas/dataSourceTable.d.ts +2 -0
  50. package/dist/client/component/PermissionManager/schemas/roleCollections.d.ts +2 -0
  51. package/dist/client/component/PermissionManager/schemas/scopes.d.ts +11 -0
  52. package/dist/client/component/PermissionManager/schemas/useRoleResourceValues.d.ts +8 -0
  53. package/dist/client/component/PermissionManager/schemas/useSaveRoleResourceAction.d.ts +3 -0
  54. package/dist/client/component/PermissionManager/style.d.ts +1 -0
  55. package/dist/client/component/ViewDatabaseConnectionAction.d.ts +2 -0
  56. package/dist/client/constant.d.ts +4 -0
  57. package/dist/client/hooks/index.d.ts +6 -0
  58. package/dist/client/index.d.ts +9 -0
  59. package/dist/client/index.js +56 -0
  60. package/dist/client/locale/index.d.ts +3 -0
  61. package/dist/client/schema/index.d.ts +7 -0
  62. package/dist/externalVersion.js +19 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +39 -0
  65. package/dist/locale/zh-CN.json +35 -0
  66. package/dist/server/collections/data-sources-collections.d.ts +2 -0
  67. package/dist/server/collections/data-sources-collections.js +66 -0
  68. package/dist/server/collections/data-sources-fields.d.ts +2 -0
  69. package/dist/server/collections/data-sources-fields.js +87 -0
  70. package/dist/server/collections/data-sources-roles-resources-actions.d.ts +2 -0
  71. package/dist/server/collections/data-sources-roles-resources-actions.js +52 -0
  72. package/dist/server/collections/data-sources-roles-resources-scopes.d.ts +2 -0
  73. package/dist/server/collections/data-sources-roles-resources-scopes.js +56 -0
  74. package/dist/server/collections/data-sources-roles-resources.d.ts +2 -0
  75. package/dist/server/collections/data-sources-roles-resources.js +62 -0
  76. package/dist/server/collections/data-sources-roles.d.ts +2 -0
  77. package/dist/server/collections/data-sources-roles.js +54 -0
  78. package/dist/server/collections/data-sources.d.ts +2 -0
  79. package/dist/server/collections/data-sources.js +71 -0
  80. package/dist/server/errors/type-infer-error.d.ts +2 -0
  81. package/dist/server/errors/type-infer-error.js +28 -0
  82. package/dist/server/index.d.ts +2 -0
  83. package/dist/server/index.js +39 -0
  84. package/dist/server/migrations/20240301164024-migrate-acl-resources.d.ts +7 -0
  85. package/dist/server/migrations/20240301164024-migrate-acl-resources.js +117 -0
  86. package/dist/server/models/connections-roles-resources-action.d.ts +3 -0
  87. package/dist/server/models/connections-roles-resources-action.js +29 -0
  88. package/dist/server/models/connections-roles-resources.d.ts +3 -0
  89. package/dist/server/models/connections-roles-resources.js +29 -0
  90. package/dist/server/models/data-source.d.ts +18 -0
  91. package/dist/server/models/data-source.js +170 -0
  92. package/dist/server/models/data-sources-collection-model.d.ts +7 -0
  93. package/dist/server/models/data-sources-collection-model.js +37 -0
  94. package/dist/server/models/data-sources-field-model.d.ts +10 -0
  95. package/dist/server/models/data-sources-field-model.js +54 -0
  96. package/dist/server/models/data-sources-roles-model.d.ts +13 -0
  97. package/dist/server/models/data-sources-roles-model.js +58 -0
  98. package/dist/server/plugin.d.ts +13 -0
  99. package/dist/server/plugin.js +448 -0
  100. package/dist/server/resourcers/data-sources-collections-fields.d.ts +11 -0
  101. package/dist/server/resourcers/data-sources-collections-fields.js +131 -0
  102. package/dist/server/resourcers/data-sources-collections.d.ts +8 -0
  103. package/dist/server/resourcers/data-sources-collections.js +106 -0
  104. package/dist/server/resourcers/data-sources-resources.d.ts +9 -0
  105. package/dist/server/resourcers/data-sources-resources.js +88 -0
  106. package/dist/server/resourcers/data-sources-roles.d.ts +8 -0
  107. package/dist/server/resourcers/data-sources-roles.js +89 -0
  108. package/dist/server/resourcers/roles-data-sources-collections.d.ts +7 -0
  109. package/dist/server/resourcers/roles-data-sources-collections.js +102 -0
  110. package/dist/server/services/collection-manager.d.ts +6 -0
  111. package/dist/server/services/collection-manager.js +33 -0
  112. package/dist/server/services/database-introspector.d.ts +70 -0
  113. package/dist/server/services/database-introspector.js +235 -0
  114. package/dist/server/services/full-data-repository.d.ts +8 -0
  115. package/dist/server/services/full-data-repository.js +51 -0
  116. package/dist/server/services/type-interface-map.d.ts +183 -0
  117. package/dist/server/services/type-interface-map.js +243 -0
  118. package/dist/server/utils.d.ts +1 -0
  119. package/dist/server/utils.js +38 -0
  120. package/package.json +36 -0
  121. package/server.d.ts +2 -0
  122. 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,7 @@
1
+ import { MagicAttributeModel } from '@tachybase/database';
2
+ import { Application } from '@tachybase/server';
3
+ export declare class DataSourcesCollectionModel extends MagicAttributeModel {
4
+ load(loadOptions: {
5
+ app: Application;
6
+ }): void;
7
+ }
@@ -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;