@nocobase/plugin-data-source-manager 1.8.0-alpha.1 → 1.8.0-alpha.11

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.
@@ -8,24 +8,24 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.8.0-alpha.1",
11
+ "@nocobase/client": "1.8.0-alpha.11",
12
12
  "react": "18.2.0",
13
- "@nocobase/plugin-acl": "1.8.0-alpha.1",
14
- "@nocobase/utils": "1.8.0-alpha.1",
15
- "@nocobase/server": "1.8.0-alpha.1",
16
- "@nocobase/data-source-manager": "1.8.0-alpha.1",
13
+ "@nocobase/plugin-acl": "1.8.0-alpha.11",
14
+ "@nocobase/utils": "1.8.0-alpha.11",
15
+ "@nocobase/server": "1.8.0-alpha.11",
16
+ "@nocobase/data-source-manager": "1.8.0-alpha.11",
17
17
  "lodash": "4.17.21",
18
- "@nocobase/acl": "1.8.0-alpha.1",
18
+ "@nocobase/acl": "1.8.0-alpha.11",
19
19
  "@ant-design/icons": "5.6.1",
20
20
  "antd": "5.24.2",
21
21
  "react-router-dom": "6.28.1",
22
+ "@formily/react": "2.3.0",
22
23
  "@formily/shared": "2.3.2",
23
24
  "react-i18next": "11.18.6",
24
- "@formily/react": "2.3.0",
25
25
  "@emotion/css": "11.13.0",
26
- "@nocobase/database": "1.8.0-alpha.1",
26
+ "@nocobase/database": "1.8.0-alpha.11",
27
27
  "sequelize": "6.35.2",
28
- "@nocobase/test": "1.8.0-alpha.1",
28
+ "@nocobase/test": "1.8.0-alpha.11",
29
29
  "@formily/antd-v5": "1.2.3",
30
30
  "@formily/core": "2.3.0",
31
31
  "@formily/reactive": "2.3.0",
@@ -0,0 +1 @@
1
+ export declare const ALLOW_MAX_COLLECTIONS_COUNT = 100;
@@ -0,0 +1,36 @@
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 constants_exports = {};
28
+ __export(constants_exports, {
29
+ ALLOW_MAX_COLLECTIONS_COUNT: () => ALLOW_MAX_COLLECTIONS_COUNT
30
+ });
31
+ module.exports = __toCommonJS(constants_exports);
32
+ const ALLOW_MAX_COLLECTIONS_COUNT = 100;
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ ALLOW_MAX_COLLECTIONS_COUNT
36
+ });
@@ -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,74 @@
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 clean_datasource_collection_schema_exports = {};
28
+ __export(clean_datasource_collection_schema_exports, {
29
+ default: () => clean_datasource_collection_schema_default
30
+ });
31
+ module.exports = __toCommonJS(clean_datasource_collection_schema_exports);
32
+ var import_database = require("@nocobase/database");
33
+ var import_server = require("@nocobase/server");
34
+ /* istanbul ignore file -- @preserve */
35
+ class clean_datasource_collection_schema_default extends import_server.Migration {
36
+ on = "afterLoad";
37
+ appVersion = "<1.8.0";
38
+ async up() {
39
+ const repository = this.context.db.getRepository("dataSourcesCollections");
40
+ const transaction = await repository.model.sequelize.transaction();
41
+ try {
42
+ const collections = await repository.find({
43
+ where: {
44
+ [import_database.Op.or]: [
45
+ { "options.schema": "{{$deps[0].split('@')?.[0]}}" },
46
+ { "options.viewName": "{{$deps[0].split('@')?.[1]}}" }
47
+ ]
48
+ },
49
+ transaction
50
+ });
51
+ for (const collection of collections) {
52
+ const { key, options } = collection;
53
+ const newOptions = { ...options };
54
+ if (options.schema === "{{$deps[0].split('@')?.[0]}}") {
55
+ newOptions.schema = "";
56
+ }
57
+ if (options.viewName === "{{$deps[0].split('@')?.[1]}}") {
58
+ newOptions.viewName = "";
59
+ }
60
+ await repository.model.update(
61
+ { options: newOptions },
62
+ {
63
+ where: { key },
64
+ transaction
65
+ }
66
+ );
67
+ }
68
+ await transaction.commit();
69
+ } catch (error) {
70
+ console.error("Error during migration:", error);
71
+ await transaction.rollback();
72
+ }
73
+ }
74
+ }
@@ -55,6 +55,7 @@ var import_connections_roles_resources_action = require("./models/connections-ro
55
55
  var import_data_source = require("./models/data-source");
56
56
  var import_data_sources_roles_model = require("./models/data-sources-roles-model");
57
57
  var import_acl = require("@nocobase/acl");
58
+ var import_constants = require("./constants");
58
59
  const canRefreshStatus = ["loaded", "loading-failed", "reloading-failed"];
59
60
  class PluginDataSourceManagerServer extends import_server.Plugin {
60
61
  dataSourceErrors = {};
@@ -191,7 +192,8 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
191
192
  this.app.db.on("dataSources.afterSave", async (model, options) => {
192
193
  if (model.changed("options") && !model.isMainRecord()) {
193
194
  model.loadIntoApplication({
194
- app: this.app
195
+ app: this.app,
196
+ refresh: true
195
197
  });
196
198
  this.sendSyncMessage(
197
199
  {
@@ -310,6 +312,41 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
310
312
  }
311
313
  await next();
312
314
  });
315
+ this.app.resourceManager.use(async function verifyDatasourceCollectionsCount(ctx, next) {
316
+ var _a;
317
+ if (!ctx.action) {
318
+ await next();
319
+ return;
320
+ }
321
+ const { actionName, resourceName, params } = ctx.action;
322
+ if (resourceName === "dataSources" && (actionName === "add" || actionName === "update")) {
323
+ const { values, filterByTk: dataSourceKey } = params;
324
+ if ((_a = values.options) == null ? void 0 : _a.addAllCollections) {
325
+ let introspector = null;
326
+ const dataSourceManager = ctx.app["dataSourceManager"];
327
+ if (actionName === "add") {
328
+ const klass = dataSourceManager.factory.getClass(values.options.type);
329
+ const dataSource = new klass(dbOptions);
330
+ introspector = dataSource.collectionManager.dataSource.createDatabaseIntrospector(
331
+ dataSource.collectionManager.db
332
+ );
333
+ } else {
334
+ const dataSource = dataSourceManager.dataSources.get(dataSourceKey);
335
+ if (!dataSource) {
336
+ throw new Error(`dataSource ${dataSourceKey} not found`);
337
+ }
338
+ introspector = dataSource["introspector"];
339
+ }
340
+ const allCollections = await introspector.getCollections();
341
+ if (allCollections.length > import_constants.ALLOW_MAX_COLLECTIONS_COUNT) {
342
+ throw new Error(
343
+ `The number of collections exceeds the limit of ${import_constants.ALLOW_MAX_COLLECTIONS_COUNT}. Please remove some collections before adding new ones.`
344
+ );
345
+ }
346
+ }
347
+ }
348
+ await next();
349
+ });
313
350
  this.app.use(async function handleAppendDataSourceCollection(ctx, next) {
314
351
  await next();
315
352
  if (!ctx.action) {
@@ -503,6 +540,26 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
503
540
  );
504
541
  }
505
542
  );
543
+ this.app.db.on("dataSourcesRolesResourcesScopes.afterSaveWithAssociations", async (model, options) => {
544
+ const { transaction } = options;
545
+ const dataSourcesRolesResourcesActions = await this.app.db.getRepository("dataSourcesRolesResourcesActions").find({
546
+ filter: { scopeId: model.get("id") },
547
+ transaction
548
+ });
549
+ const rolesRolesResourceIds = dataSourcesRolesResourcesActions.map((x) => x.get("rolesResourceId"));
550
+ const dataSourcesRolesResources = await this.app.db.getRepository("dataSourcesRolesResources").find({
551
+ filter: {
552
+ id: rolesRolesResourceIds
553
+ },
554
+ transaction
555
+ });
556
+ for (const instance of dataSourcesRolesResources) {
557
+ await this.app.db.emitAsync(`dataSourcesRolesResources.afterSaveWithAssociations`, instance, {
558
+ ...options,
559
+ transaction
560
+ });
561
+ }
562
+ });
506
563
  this.app.db.on(
507
564
  "dataSourcesRolesResourcesActions.afterUpdateWithAssociations",
508
565
  async (model, options) => {
@@ -75,6 +75,9 @@ var data_sources_collections_fields_default = {
75
75
  dataSourceKey
76
76
  }
77
77
  });
78
+ if (values.possibleTypes) {
79
+ delete values.possibleTypes;
80
+ }
78
81
  if (!fieldRecord) {
79
82
  fieldRecord = await mainDb.getRepository("dataSourcesFields").create({
80
83
  values: {
@@ -114,6 +117,9 @@ var data_sources_collections_fields_default = {
114
117
  `Field name ${name} already exists in collection ${collectionName} of data source ${dataSourceKey}`
115
118
  );
116
119
  }
120
+ if (values.possibleTypes) {
121
+ delete values.possibleTypes;
122
+ }
117
123
  const fieldRecord = await mainDb.getRepository("dataSourcesFields").create({
118
124
  values: {
119
125
  ...values,
@@ -11,6 +11,8 @@ declare const _default: {
11
11
  actions: {
12
12
  list(ctx: any, next: any): Promise<void>;
13
13
  update(ctx: any, next: any): Promise<void>;
14
+ all(ctx: any, next: any): Promise<void>;
15
+ add(ctx: any, next: any): Promise<void>;
14
16
  };
15
17
  };
16
18
  export default _default;
@@ -41,6 +41,8 @@ __export(data_sources_collections_exports, {
41
41
  module.exports = __toCommonJS(data_sources_collections_exports);
42
42
  var import_lodash = __toESM(require("lodash"));
43
43
  var import_database = require("@nocobase/database");
44
+ var import_lodash2 = __toESM(require("lodash"));
45
+ var import_constants = require("../constants");
44
46
  var data_sources_collections_default = {
45
47
  name: "dataSources.collections",
46
48
  actions: {
@@ -134,6 +136,87 @@ var data_sources_collections_default = {
134
136
  });
135
137
  ctx.body = dataSourceCollectionRecord.toJSON();
136
138
  await next();
139
+ },
140
+ async all(ctx, next) {
141
+ const params = ctx.action.params;
142
+ const { associatedIndex: dataSourceKey, isFirst, dbOptions } = params;
143
+ const dataSourceManager = ctx.app.dataSourceManager;
144
+ let introspector = null;
145
+ if (isFirst) {
146
+ const klass = dataSourceManager.factory.getClass(dbOptions.type);
147
+ const dataSource = new klass(dbOptions);
148
+ introspector = dataSource.collectionManager.dataSource.createDatabaseIntrospector(
149
+ dataSource.collectionManager.db
150
+ );
151
+ } else {
152
+ const dataSource = dataSourceManager.dataSources.get(dataSourceKey);
153
+ if (!dataSource) {
154
+ throw new Error(`dataSource ${dataSourceKey} not found`);
155
+ }
156
+ introspector = dataSource["introspector"];
157
+ }
158
+ const allCollections = await introspector.getCollections();
159
+ const selectedCollections = await ctx.db.getRepository("dataSourcesCollections").find({
160
+ filter: { dataSourceKey }
161
+ });
162
+ const selectedMap = import_lodash2.default.keyBy(selectedCollections, (x) => x.name);
163
+ const result = allCollections.map((collection) => {
164
+ return {
165
+ name: collection,
166
+ selected: !!selectedMap[collection]
167
+ };
168
+ });
169
+ ctx.body = result;
170
+ await next();
171
+ },
172
+ async add(ctx, next) {
173
+ const params = ctx.action.params;
174
+ const { associatedIndex: dataSourceKey, values } = params;
175
+ const collections = values.collections || [];
176
+ const dbOptions = values.dbOptions || {};
177
+ if (dbOptions.addAllCollections !== false) {
178
+ await next();
179
+ return;
180
+ }
181
+ if (collections.length > import_constants.ALLOW_MAX_COLLECTIONS_COUNT) {
182
+ throw new Error(
183
+ `The number of collections exceeds the limit of ${import_constants.ALLOW_MAX_COLLECTIONS_COUNT}. Please remove some collections before adding new ones.`
184
+ );
185
+ }
186
+ const transaction = await ctx.db.sequelize.transaction();
187
+ const repo = ctx.db.getRepository("dataSourcesCollections");
188
+ const alreadyInserted = await repo.find({
189
+ filter: {
190
+ dataSourceKey
191
+ },
192
+ transaction
193
+ });
194
+ const alreadyInsertedNames = import_lodash2.default.keyBy(alreadyInserted, (x) => x.name);
195
+ const incomingCollections = import_lodash2.default.keyBy(collections);
196
+ const toBeInserted = collections.filter((collection) => !alreadyInsertedNames[collection]);
197
+ const toBeDeleted = Object.keys(alreadyInsertedNames).filter((name) => !incomingCollections[name]);
198
+ if (toBeInserted.length > 0) {
199
+ const insertCollections = toBeInserted.map((collection) => {
200
+ return { name: collection, dataSourceKey };
201
+ });
202
+ await repo.model.bulkCreate(insertCollections, { transaction });
203
+ }
204
+ if (toBeDeleted.length > 0) {
205
+ await repo.model.destroy({
206
+ where: {
207
+ dataSourceKey,
208
+ name: toBeDeleted
209
+ },
210
+ transaction
211
+ });
212
+ }
213
+ await transaction.commit();
214
+ const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
215
+ if (dataSource) {
216
+ await dataSource.load({ refresh: true });
217
+ }
218
+ ctx.body = true;
219
+ await next();
137
220
  }
138
221
  }
139
222
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-data-source-manager",
3
- "version": "1.8.0-alpha.1",
3
+ "version": "1.8.0-alpha.11",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "Data source manager",
6
6
  "displayName.zh-CN": "数据源管理",
@@ -17,5 +17,5 @@
17
17
  "keywords": [
18
18
  "Data model tools"
19
19
  ],
20
- "gitHead": "bc81ea73ed91b18dfb7cfad0f353b825881b4cc7"
20
+ "gitHead": "ca21882066ded53ac54e7340d3f5fdd2d4275a76"
21
21
  }
@@ -1,10 +0,0 @@
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
- "use strict";(self.webpackChunk_nocobase_plugin_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["16"],{473:function(e,t,n){n.r(t),n.d(t,{DataSourceContext:function(){return s},DatabaseConnectionProvider:function(){return l}});var r=n(772),a=n(156),o=n.n(a),u=n(611);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var s=(0,a.createContext)(null);s.displayName="DataSourceContext";var l=function(e){var t,n=(t=(0,a.useState)(null),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],u=!0,c=!1;try{for(a=a.call(e);!(u=(n=a.next()).done)&&(o.push(n.value),o.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{u||null==a.return||a.return()}finally{if(c)throw r}}return o}}(t,2)||function(e,t){if(e){if("string"==typeof e)return c(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=n[0],i=n[1];return o().createElement(s.Provider,{value:{dataSource:l,setDataSource:i}},o().createElement(r.SchemaComponentOptions,{scope:u,components:{}},e.children))}},611:function(e,t,n){n.r(t),n.d(t,{useCreateDatabaseServer:function(){return d},useTestConnectionAction:function(){return b}});var r=n(505),a=n(721),o=n(238),u=n(772),c=n(748);function s(e,t,n,r,a,o,u){try{var c=e[o](u),s=c.value}catch(e){n(e);return}c.done?t(s):Promise.resolve(s).then(r,a)}function l(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var o=e.apply(t,n);function u(e){s(o,r,a,u,c,"next",e)}function c(e){s(o,r,a,u,c,"throw",e)}u(void 0)})}}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function f(e,t){var n,r,a,o,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){var s=[o,c];if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return u.label++,{value:s[1],done:!1};case 5:u.label++,r=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){u=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){u.label=s[1];break}if(6===s[0]&&u.label<a[1]){u.label=a[1],a=s;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(s);break}a[2]&&u.ops.pop(),u.trys.pop();continue}s=t.call(e,u)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var d=function(e){var t=(0,r.useForm)(),n=(0,u.useActionContext)(),c=(0,u.useAPIClient)(),s=(0,o.useTranslation)().t,d=(0,r.useField)();return d.data=d.data||{},{run:function(){return l(function(){var r,o;return f(this,function(u){switch(u.label){case 0:return[4,t.submit()];case 1:u.sent(),u.label=2;case 2:return u.trys.push([2,5,,6]),d.data.loading=!0,[4,c.resource("databaseServers").create({values:i({},t.values)})];case 3:return r=u.sent().data,d.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return u.sent(),null==e||e(null==r?void 0:r.data),a.message.success(s("Saved successfully")),[3,6];case 5:return o=u.sent(),d.data.loading=!1,console.log(o),[3,6];case 6:return[2]}})})()}}},b=function(){var e=(0,r.useForm)(),t=(0,u.useAPIClient)(),n=(0,o.useTranslation)().t,s=(0,r.useField)();return s.data=s.data||{},{run:function(){return l(function(){var r;return f(this,function(o){switch(o.label){case 0:return[4,e.submit()];case 1:o.sent(),o.label=2;case 2:return o.trys.push([2,4,,5]),s.data.loading=!0,[4,t.resource("dataSources").testConnection({values:i({},e.values)})];case 3:return o.sent(),s.data.loading=!1,a.message.success(n("Connection successful",{ns:c.A7})),[3,5];case 4:return r=o.sent(),s.data.loading=!1,console.log(r),[3,5];case 5:return[2]}})})()}}}}}]);
@@ -1,10 +0,0 @@
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
- "use strict";(self.webpackChunk_nocobase_plugin_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["256"],{848:function(e,t,n){n.r(t),n.d(t,{DatabaseConnectionManagerPane:function(){return R}});var r=n(875),o=n(772),a=n(721),i=n(156),c=n.n(i),l=n(238),u=n(636),s=n(933),p=n(864),d=n(482),f=n(611),y=n(748);function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw r}}return a}}(e,t)||h(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){if(e){if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}}var g=function(){var e=b((0,i.useState)({}),2),t=e[0],n=e[1],s=(0,o.usePlugin)(u.default),p=(0,o.useCompile)(),m=b((0,i.useState)(!1),2),h=m[0],g=m[1],x=(0,l.useTranslation)().t,A=b((0,i.useState)(null),2),C=A[0],S=A[1],k=(0,o.useAPIClient)();return c().createElement("div",null,c().createElement(o.ActionContext.Provider,{value:{visible:h,setVisible:g}},c().createElement(a.Dropdown,{menu:{onClick:function(e){if("__empty__"!==e.key){var t,o,a,i=s.types.get(e.key);S(e.key),g(!0),n({type:"object",properties:(t={},o=(0,r.uid)(),a={type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{type:e.key,key:"d_".concat((0,r.uid)())}},title:p("{{t('Add new')}}")+" - "+p(i.label),properties:{body:{type:"void","x-component":i.DataSourceSettingsForm},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{testConnection:{title:'{{ t("Test Connection",{ ns: "'.concat(y.A7,'" }) }}'),"x-component":"Action","x-component-props":{useAction:"{{ useTestConnectionAction }}"},"x-hidden":null==i?void 0:i.disableTestConnection},cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}",actionCallback:"{{ dataSourceCreateCallback }}"}}}}}},o in t?Object.defineProperty(t,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[o]=a,t)})}},items:[s.types.size?null:{key:"__empty__",label:c().createElement(a.Empty,{image:a.Empty.PRESENTED_IMAGE_SIMPLE,description:c().createElement(c().Fragment,null,x("No external data source plugin installed",{ns:y.A7}),c().createElement("br",null)," ",c().createElement("a",{target:"_blank",href:"zh-CN"===k.auth.locale?"https://docs-cn.nocobase.com/handbook/data-source-manager":"https://docs.nocobase.com/handbook/data-source-manager",rel:"noreferrer"},x("View documentation",{ns:y.A7})))})}].filter(Boolean).concat(v(s.types.keys()).map(function(e){var t=s.types.get(e);return{key:e,label:p(null==t?void 0:t.label)}}))}},c().createElement(a.Button,{type:"primary",icon:c().createElement(d.PlusOutlined,null)},x("Add new")," ",c().createElement(d.DownOutlined,null))),c().createElement(o.SchemaComponent,{scope:{createOnly:!1,useTestConnectionAction:f.useTestConnectionAction,dialect:C,useDialectDataSource:function(e){e.dataSource=v(s.types.keys()).map(function(e){var t=s.types.get(e);return{value:t.name,label:p(t.label)}})}},schema:t})))},x=n(505);function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function C(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var k=function(){var e=(0,o.useRecord)(),t=S((0,i.useState)({}),2),n=t[0],a=t[1],s=(0,o.usePlugin)(u.default),p=(0,o.useCompile)(),d=S((0,i.useState)(!1),2),f=d[0],m=d[1],b=(0,l.useTranslation)().t,v=(0,o.useDataSourceManager)();return c().createElement("div",null,c().createElement(o.ActionContext.Provider,{value:{visible:f,setVisible:m}},"main"!==e.key&&c().createElement("a",{onClick:function(){m(!0);var t,n,o,i=s.types.get(e.type);a({type:"object",properties:(t={},n=(0,r.uid)(),o={type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:e},title:p("{{t('Edit')}}")+" - "+p(e.displayName),properties:{body:{type:"void","x-component":i.DataSourceSettingsForm},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},testConnectiion:{title:'{{ t("Test Connection",{ ns: "'.concat(y.A7,'" }) }}'),"x-component":"Action","x-component-props":{useAction:"{{ useTestConnectionAction }}"},"x-hidden":null==i?void 0:i.disableTestConnection},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}}}}},n in t?Object.defineProperty(t,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[n]=o,t)})}},b("Edit")),c().createElement(o.SchemaComponent,{scope:{createOnly:!0,useUpdateAction:function(){var e=(0,x.useField)(),t=(0,x.useForm)(),n=(0,o.useActionContext)(),r=(0,o.useResourceActionContext)().refresh,a=(0,o.useResourceContext)().resource,i=(0,o.useRecord)().key;return{run:function(){var o;return(o=function(){return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,t.submit()];case 1:o.sent(),e.data=e.data||{},e.data.loading=!0,o.label=2;case 2:return o.trys.push([2,5,6,7]),[4,a.update({filterByTk:i,values:t.values})];case 3:return o.sent(),n.setVisible(!1),v.getDataSource(i).setOptions(t.values),v.getDataSource(i).reload(),[4,t.reset()];case 4:return o.sent(),r(),[3,7];case 5:return console.log(o.sent()),[3,7];case 6:return e.data.loading=!1,[7];case 7:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function i(e){C(a,n,r,i,c,"next",e)}function c(e){C(a,n,r,i,c,"throw",e)}i(void 0)})})()}}}},schema:n})))},w=n(964),D=n(128),E=function(e){var t=e.key,n=e.type;return"/admin/settings/data-source-manager/".concat(t,"/collections?type=").concat(n)};function T(){var e,t,n=(e=["\n .ant-btn-link {\n &:hover {\n color: rgba(0, 0, 0, 0.25) !important;\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return T=function(){return n},n}var P=function(){var e=(0,o.useRecord)(),t=(0,D.useNavigate)(),n=(0,l.useTranslation)().t;return c().createElement("div",{className:e.enabled?void 0:(0,w.css)(T())},c().createElement(a.Button,{type:"link",style:{padding:"0px"},disabled:!e.enabled,onClick:function(){t(E(e))},role:"button","aria-label":"".concat(null==e?void 0:e.key,"-Configure")},n("Configure")))};function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function _(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){j(a,r,o,i,c,"next",e)}function c(e){j(a,r,o,i,c,"throw",e)}i(void 0)})}}function I(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return O(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var R=function(){var e=(0,l.useTranslation)().t,t=(0,o.usePlugin)(u.default),n=I(t.types.keys()).map(function(n){var r=t.types.get(n);return{value:n,label:e(null==r?void 0:r.label)}}).concat([{value:"main",label:e("Main")}]),d=(0,o.useDataSourceManager)(),f=c().useRef([]);(0,i.useEffect)(function(){return function(){d.getDataSources().forEach(function(e){f.current.includes(e.key)&&e.reload()})}},[f]);var y=(0,i.useCallback)(function(e){d.removeDataSources(e)},[d]),m=(0,i.useCallback)(function(e){d.addDataSource(p.F,e),f.current=I(f.current).concat([e.key])},[]);return c().createElement(a.Card,{bordered:!1},c().createElement(o.SchemaComponent,{components:{CreateDatabaseConnectAction:g,EditDatabaseConnectionAction:k,ViewDatabaseConnectionAction:P},scope:{useNewId:function(e){return"".concat(e).concat((0,r.uid)())},types:n,useRefreshActionProps:function(){var e=(0,o.useResourceActionContext)();return{onClick:function(){return _(function(){var t,n,r,o,a;return F(this,function(i){switch(i.label){case 0:if(!(null==(r=null==e||null==(t=e.data)?void 0:t.data.filter(function(e){return"loaded"!==e.status}))?void 0:r.length))return[3,2];return o=d.getDataSources(),a=r.map(function(e){return e.key}),[4,Promise.all(o.filter(function(e){return a.includes(e.key)}).map(function(e){return e.reload()}))];case 1:i.sent(),i.label=2;case 2:return null==e||null==(n=e.refresh)||n.call(e),[2]}})})()}}},useDestroyAction:function(){var e=(0,o.useResourceActionContext)().refresh,t=(0,o.useResourceContext)().resource,n=(0,o.useRecord)().key;return{run:function(){return _(function(){return F(this,function(r){switch(r.label){case 0:return[4,t.destroy({filterByTk:n})];case 1:return r.sent(),y([n]),e(),[2]}})})()}}},dataSourceDeleteCallback:y,dataSourceCreateCallback:m,useIsAbleDelete:function(e){e.visible="main"!==(0,o.useRecord)().key}},schema:s.j}))}},611:function(e,t,n){n.r(t),n.d(t,{useCreateDatabaseServer:function(){return d},useTestConnectionAction:function(){return f}});var r=n(505),o=n(721),a=n(238),i=n(772),c=n(748);function l(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(r,o)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){l(a,r,o,i,c,"next",e)}function c(e){l(a,r,o,i,c,"throw",e)}i(void 0)})}}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function p(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){var l=[a,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var d=function(e){var t=(0,r.useForm)(),n=(0,i.useActionContext)(),c=(0,i.useAPIClient)(),l=(0,a.useTranslation)().t,d=(0,r.useField)();return d.data=d.data||{},{run:function(){return u(function(){var r,a;return p(this,function(i){switch(i.label){case 0:return[4,t.submit()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,6]),d.data.loading=!0,[4,c.resource("databaseServers").create({values:s({},t.values)})];case 3:return r=i.sent().data,d.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return i.sent(),null==e||e(null==r?void 0:r.data),o.message.success(l("Saved successfully")),[3,6];case 5:return a=i.sent(),d.data.loading=!1,console.log(a),[3,6];case 6:return[2]}})})()}}},f=function(){var e=(0,r.useForm)(),t=(0,i.useAPIClient)(),n=(0,a.useTranslation)().t,l=(0,r.useField)();return l.data=l.data||{},{run:function(){return u(function(){var r;return p(this,function(a){switch(a.label){case 0:return[4,e.submit()];case 1:a.sent(),a.label=2;case 2:return a.trys.push([2,4,,5]),l.data.loading=!0,[4,t.resource("dataSources").testConnection({values:s({},e.values)})];case 3:return a.sent(),l.data.loading=!1,o.message.success(n("Connection successful",{ns:c.A7})),[3,5];case 4:return r=a.sent(),l.data.loading=!1,console.log(r),[3,5];case 5:return[2]}})})()}}}},933:function(e,t,n){n.d(t,{$:function(){return l},j:function(){return s}});var r,o,a,i=n(875),c=n(748),l=[{value:"loading",label:'{{t("Loading",{ns:"'.concat(c.A7,'"})}}'),color:"orange"},{value:"loading-failed",label:'{{t("Failed",{ns:"'.concat(c.A7,'"})}}'),color:"red"},{value:"loaded",label:'{{t("Loaded",{ns:"'.concat(c.A7,'"})}}'),color:"green"},{value:"reloading",label:'{{t("Reloading",{ns:"'.concat(c.A7,'"})}}'),color:"orange"}],u={name:"collections-"+(0,i.uid)(),fields:[{type:"string",name:"key",interface:"input",uiSchema:{title:'{{t("Data source name",{ ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"displayName",interface:"input",uiSchema:{title:'{{t("Data source display name",{ ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Type", { ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Select",enum:"{{types}}"}},{type:"string",name:"status",interface:"select",uiSchema:{title:'{{t("Status", { ns: "'.concat(c.A7,'" })}}'),type:"string","x-component":"Select",enum:l}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},s={type:"object",properties:(r={},o=(0,i.uid)(),a={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:u,resourceName:"dataSources",request:{resource:"dataSources",action:"list",params:{pageSize:50,appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:u},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"},actionCallback:"{{ dataSourceDeleteCallback }}"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateDatabaseConnectAction","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{key:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},displayName:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{},properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"ViewDatabaseConnectionAction","x-component-props":{type:"primary"}},update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditDatabaseConnectionAction","x-component-props":{type:"primary"},"x-reactions":["{{useIsAbleDelete($self)}}"]},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{useDestroyAction}}"},"x-reactions":["{{useIsAbleDelete($self)}}"]}}}}}}}}},o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a,r)}}}]);
@@ -1,10 +0,0 @@
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
- "use strict";(self.webpackChunk_nocobase_plugin_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).push([["47"],{473:function(e,t,n){n.r(t),n.d(t,{DataSourceContext:function(){return l},DatabaseConnectionProvider:function(){return u}});var o=n(772),r=n(156),a=n.n(r),c=n(611);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}var l=(0,r.createContext)(null);l.displayName="DataSourceContext";var u=function(e){var t,n=(t=(0,r.useState)(null),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],c=!0,i=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){i=!0,o=e}finally{try{c||null==r.return||r.return()}finally{if(i)throw o}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return i(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=n[0],s=n[1];return a().createElement(l.Provider,{value:{dataSource:u,setDataSource:s}},a().createElement(o.SchemaComponentOptions,{scope:c,components:{}},e.children))}},36:function(e,t,n){n.r(t),n.d(t,{BreadcumbTitle:function(){return d}});var o=n(482),r=n(772),a=n(721),c=n(156),i=n.n(c),l=n(128),u=n(473),s=n(748),p=n(933),d=function(){var e=(0,r.useApp)(),t=(0,l.useParams)().name,n=(0,r.useCompile)(),d=(0,r.useDataSourceManager)(),m=(d.getDataSource(t)||{}).displayName,y=(0,c.useContext)(u.DataSourceContext).dataSource,f=(0,c.useMemo)(function(){return y&&(null==y?void 0:y.name)===t?y:d.getDataSource(t)},[y,t]),b=(0,c.useMemo)(function(){var t=null==f?void 0:f.status,o=p.$.find(function(e){return e.value===t}),r=[{title:i().createElement(l.Link,{to:e.pluginSettingsManager.getRoutePath(s.A7)},(0,s.KQ)("Data source manager"))}];return f&&r.push({title:i().createElement(a.Space,null,i().createElement("span",null,n(m)),t&&i().createElement(a.Tag,{key:t,color:null==o?void 0:o.color},n(null==o?void 0:o.label)))}),r},[f]);return i().createElement(a.Breadcrumb,{separator:i().createElement(o.RightOutlined,null),items:b})}},611:function(e,t,n){n.r(t),n.d(t,{useCreateDatabaseServer:function(){return d},useTestConnectionAction:function(){return m}});var o=n(505),r=n(721),a=n(238),c=n(772),i=n(748);function l(e,t,n,o,r,a,c){try{var i=e[a](c),l=i.value}catch(e){n(e);return}i.done?t(l):Promise.resolve(l).then(o,r)}function u(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var a=e.apply(t,n);function c(e){l(a,o,r,c,i,"next",e)}function i(e){l(a,o,r,c,i,"throw",e)}c(void 0)})}}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function p(e,t){var n,o,r,a,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){var l=[a,i];if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return c.label++,{value:l[1],done:!1};case 5:c.label++,o=l[1],l=[0];continue;case 7:l=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===l[0]||2===l[0])){c=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){c.label=l[1];break}if(6===l[0]&&c.label<r[1]){c.label=r[1],r=l;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(l);break}r[2]&&c.ops.pop(),c.trys.pop();continue}l=t.call(e,c)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var d=function(e){var t=(0,o.useForm)(),n=(0,c.useActionContext)(),i=(0,c.useAPIClient)(),l=(0,a.useTranslation)().t,d=(0,o.useField)();return d.data=d.data||{},{run:function(){return u(function(){var o,a;return p(this,function(c){switch(c.label){case 0:return[4,t.submit()];case 1:c.sent(),c.label=2;case 2:return c.trys.push([2,5,,6]),d.data.loading=!0,[4,i.resource("databaseServers").create({values:s({},t.values)})];case 3:return o=c.sent().data,d.data.loading=!1,n.setVisible(!1),[4,t.reset()];case 4:return c.sent(),null==e||e(null==o?void 0:o.data),r.message.success(l("Saved successfully")),[3,6];case 5:return a=c.sent(),d.data.loading=!1,console.log(a),[3,6];case 6:return[2]}})})()}}},m=function(){var e=(0,o.useForm)(),t=(0,c.useAPIClient)(),n=(0,a.useTranslation)().t,l=(0,o.useField)();return l.data=l.data||{},{run:function(){return u(function(){var o;return p(this,function(a){switch(a.label){case 0:return[4,e.submit()];case 1:a.sent(),a.label=2;case 2:return a.trys.push([2,4,,5]),l.data.loading=!0,[4,t.resource("dataSources").testConnection({values:s({},e.values)})];case 3:return a.sent(),l.data.loading=!1,r.message.success(n("Connection successful",{ns:i.A7})),[3,5];case 4:return o=a.sent(),l.data.loading=!1,console.log(o),[3,5];case 5:return[2]}})})()}}}},933:function(e,t,n){n.d(t,{$:function(){return l},j:function(){return s}});var o,r,a,c=n(875),i=n(748),l=[{value:"loading",label:'{{t("Loading",{ns:"'.concat(i.A7,'"})}}'),color:"orange"},{value:"loading-failed",label:'{{t("Failed",{ns:"'.concat(i.A7,'"})}}'),color:"red"},{value:"loaded",label:'{{t("Loaded",{ns:"'.concat(i.A7,'"})}}'),color:"green"},{value:"reloading",label:'{{t("Reloading",{ns:"'.concat(i.A7,'"})}}'),color:"orange"}],u={name:"collections-"+(0,c.uid)(),fields:[{type:"string",name:"key",interface:"input",uiSchema:{title:'{{t("Data source name",{ ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"displayName",interface:"input",uiSchema:{title:'{{t("Data source display name",{ ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:'{{t("Type", { ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Select",enum:"{{types}}"}},{type:"string",name:"status",interface:"select",uiSchema:{title:'{{t("Status", { ns: "'.concat(i.A7,'" })}}'),type:"string","x-component":"Select",enum:l}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},s={type:"object",properties:(o={},r=(0,c.uid)(),a={type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:u,resourceName:"dataSources",request:{resource:"dataSources",action:"list",params:{pageSize:50,appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:u},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"},actionCallback:"{{ dataSourceDeleteCallback }}"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"CreateDatabaseConnectAction","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"key",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{key:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{key:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},displayName:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{displayName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{status:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{},properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"ViewDatabaseConnectionAction","x-component-props":{type:"primary"}},update:{type:"void",title:'{{t("Edit")}}',"x-component":"EditDatabaseConnectionAction","x-component-props":{type:"primary"},"x-reactions":["{{useIsAbleDelete($self)}}"]},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:'{{t("Delete")}}',content:'{{t("Are you sure you want to delete it?")}}'},useAction:"{{useDestroyAction}}"},"x-reactions":["{{useIsAbleDelete($self)}}"]}}}}}}}}},r in o?Object.defineProperty(o,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[r]=a,o)}}}]);