@nocobase/plugin-data-source-manager 2.0.0-alpha.21 → 2.0.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/1a8cce8035a89dd9.js +1 -1
- package/dist/client/2695e7fbad1ec078.js +10 -0
- package/dist/client/8a2abe0ad7b0a9d2.js +10 -0
- package/dist/client/a279f7ca19e59f87.js +10 -0
- package/dist/client/component/MainDataSourceManager/Configuration/db-sync/LoadCollectionAction.d.ts +15 -0
- package/dist/client/component/MainDataSourceManager/Configuration/db-sync/SyncFieldChangesAction.d.ts +10 -0
- package/dist/client/component/MainDataSourceManager/Configuration/db-sync/SyncFromDatabaseAction.d.ts +10 -0
- package/dist/client/dbf5ddf434ab29c0.js +10 -0
- package/dist/client/e7a513a5b431455b.js +10 -0
- package/dist/client/fdae18574fda07af.js +10 -0
- package/dist/client/hooks/index.d.ts +3 -4
- package/dist/client/hooks/useDataSourceActions.d.ts +14 -0
- package/dist/client/hooks/useDataSourceRefresh.d.ts +18 -0
- package/dist/client/hooks/useResourceData.d.ts +31 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +9 -8
- package/dist/locale/en-US.json +7 -0
- package/dist/locale/zh-CN.json +7 -2
- package/dist/server/actions/data-sources.d.ts +17 -0
- package/dist/server/actions/data-sources.js +114 -0
- package/dist/server/middlewares/load-tables.d.ts +10 -0
- package/dist/server/middlewares/load-tables.js +74 -0
- package/dist/server/plugin.js +10 -96
- package/dist/server/resourcers/data-sources-collections.d.ts +0 -2
- package/dist/server/resourcers/data-sources-collections.js +0 -83
- package/dist/server/utils.d.ts +3 -0
- package/dist/server/utils.js +45 -0
- package/package.json +2 -2
- package/dist/client/0e6cf640dde183c8.js +0 -10
- package/dist/client/7b6cb59b157f5087.js +0 -10
- package/dist/client/9aff90e19fbd41b6.js +0 -10
- package/dist/client/b3873b8560b4de87.js +0 -10
- package/dist/client/cab6d8ac1e107ea5.js +0 -10
- package/dist/client/cc4271412c5e6495.js +0 -10
|
@@ -0,0 +1,10 @@
|
|
|
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([["296"],{919:function(e,t,n){n.r(t),n.d(t,{DatabaseConnectionManagerPane:function(){return H}});var r=n(875),o=n(772),a=n(721),l=n(156),i=n.n(l),c=n(238),u=n(329),s=n(469),p=n(347),f=n(482),d=n(505),m=n(241),y=n(551);function b(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 v(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function h(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 g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function x(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=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return b(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 b(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 C=(0,d.observer)(function(e){var t,n,r,c,u,s,p,d,m,y,b,C=(0,o.useAPIClient)(),A=x((0,l.useState)(!1),2),S=A[0],w=A[1],k=x((0,l.useState)(""),2),O=k[0],E=k[1],P=x((0,l.useState)([]),2),j=P[0],D=P[1],T=x((0,l.useState)(new Map),2),I=T[0],M=T[1],q=x((0,l.useState)(!1),2),R=q[0],F=q[1],V=(0,l.useRef)(),_=e.NAMESPACE,$=e.t,L=(null==(r=e.formValues)||null==(n=r.options)?void 0:n.addAllCollections)===void 0||(null==(u=e.formValues)||null==(c=u.options)?void 0:c.addAllCollections),N=x((0,l.useState)(L),2),B=N[0],W=N[1],z=(0,l.useMemo)(function(){var t=e.value&&e.value.length>0?e.value:j;return O.trim()&&(t=t.filter(function(e){var t;return null==(t=e.name)?void 0:t.toLowerCase().includes(O.toLowerCase())})),t},[e.value,j,O]),U=(0,l.useMemo)(function(){return e.value&&e.value.length>0?e.value:j},[e.value,j]),K=(0,l.useMemo)(function(){var t,n=null==(t=e.options)?void 0:t.tablePrefix;return z.map(function(e){var t,r=!1;return e.required||R?r=!0:I.get(e.name)&&(!n||!n.trim()||(null==(t=e.name)?void 0:t.startsWith(n.trim())))&&(r=!0),g(h({},e),{selected:r})})},[z,I,R,null==(s=e.options)?void 0:s.tablePrefix]),G=(0,l.useRef)(null==(p=e.options)?void 0:p.tablePrefix);(0,l.useEffect)(function(){var t=null==(n=e.options)?void 0:n.tablePrefix;if(G.current!==t&&j.length>0){G.current=t;var n,r,o=j.map(function(e){var n,r=!1;return e.required?r=!0:I.get(e.name)&&(!t||!t.trim()||(null==(n=e.name)?void 0:n.startsWith(t.trim())))&&(r=!0),g(h({},e),{selected:r})});null==(r=e.onChange)||r.call(e,o)}},[null==(d=e.options)?void 0:d.tablePrefix,j.length,I]),(0,l.useEffect)(function(){if(U.length>0){var e=new Map;U.forEach(function(t){t.selected&&e.set(t.name,!0)}),M(e),F(!1)}},[U.length]);var H=(0,l.useCallback)(function(t){W(t),e.formSetValues&&e.formSetValues("options.addAllCollections",t)},[e.formSetValues]),J=(0,l.useCallback)((t=function(){var t,n,r,o,l,i,c,u,s,p,f,d,m;return function(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[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 c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(y){switch(y.label){case 0:if(t=e.dataSourceKey,n=e.formValues,r=e.onChange,o=e.from,l=(null==n?void 0:n.options)||{},i=$("is required"),"oracle"!==n.type){if(!t)return a.message.error($("Data source name",{ns:_})+i),[2];if(!l.host)return a.message.error($("Host",{ns:_})+i),[2];if(!l.port)return a.message.error($("Port",{ns:_})+i),[2];if(!l.database)return a.message.error($("Database",{ns:_})+i),[2];if(!l.username)return a.message.error($("Username",{ns:_})+i),[2]}w(!0),y.label=1;case 1:return y.trys.push([1,3,4,5]),[4,C.resource("dataSources").readTables({values:h({dataSourceKey:t},"create"===o?{dbOptions:g(h({},l),{type:n.type||"mysql"})}:{})})];case 2:return D(u=((null==(c=y.sent())?void 0:c.data)||{}).data||[]),s=0===I.size&&e.value&&e.value.length>0,p=I,s&&(f=new Map,e.value.forEach(function(e){e.selected&&f.set(e.name,!0)}),M(f),p=f),d=l.tablePrefix,m=u.map(function(e){var t,n=!1;return e.required?n=!0:p.get(e.name)&&(!d||!d.trim()||(null==(t=e.name)?void 0:t.startsWith(d.trim())))&&(n=!0),g(h({},e),{selected:n})}),r&&r(m),[3,5];case 3:return console.error("Error loading collections:",y.sent()),a.message.error($("Failed to load collections",{ns:_})),[3,5];case 4:return w(!1),[7];case 5:return[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,o){var a=t.apply(e,n);function l(e){v(a,r,o,l,i,"next",e)}function i(e){v(a,r,o,l,i,"throw",e)}l(void 0)})}),[e.dataSourceKey,e.formValues,e.options,e.from,e.tablePrefix,C,$,_]),Q=(0,l.useCallback)(function(e){V.current&&clearTimeout(V.current),V.current=setTimeout(function(){E(e)},300)},[]);(0,l.useEffect)(function(){return function(){V.current&&clearTimeout(V.current)}},[]);var X=(0,l.useMemo)(function(){var t,n=null==(t=e.options)?void 0:t.tablePrefix,r=U.filter(function(e){var t;return!!e.required||!!I.get(e.name)&&!!(!n||!n.trim()||(null==(t=e.name)?void 0:t.startsWith(n.trim())))}).length,o=K.filter(function(e){return!e.required}),a=K.filter(function(e){return e.selected||e.required}).length;return{isAllSelected:o.length>0&&a===K.length,isIndeterminate:a>0&&a<K.length,selectedCount:r,isAtLimit:r>=500}},[K,U,I,null==(m=e.options)?void 0:m.tablePrefix]),Y=X.isAllSelected,Z=X.isIndeterminate,ee=X.selectedCount,et=X.isAtLimit,en=(0,l.useCallback)(function(t){var n,r=null==(n=e.options)?void 0:n.tablePrefix;if(t){var o=U.filter(function(e){var t;return!!e.required||!!I.get(e.name)&&!!(!r||!r.trim()||(null==(t=e.name)?void 0:t.startsWith(r.trim())))}).length,l=z.filter(function(e){return!e.required&&!I.get(e.name)}).length;if(o>=500)return;l>500-o&&a.message.warning($("Maximum selection limit exceeded. To ensure system performance, you can select up to {{limit}} collections.",{ns:_,limit:500}))}F(t);var i=function(){var n,o=new Map(I),a=0,l=500-U.filter(function(e){var t;return!!e.required||!!I.get(e.name)&&!!(!r||!r.trim()||(null==(t=e.name)?void 0:t.startsWith(r.trim())))}).length;z.forEach(function(e){!e.required&&(t?a<l&&!I.get(e.name)&&(o.set(e.name,!0),a++):o.delete(e.name))}),M(o);var i=U.map(function(e){var t,n=!1;return e.required?n=!0:o.get(e.name)&&(!r||!r.trim()||(null==(t=e.name)?void 0:t.startsWith(r.trim())))&&(n=!0),g(h({},e),{selected:n})});null==(n=e.onChange)||n.call(e,i),F(!1)};if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port2.onmessage=function(){return i()},c.port1.postMessage(null)}else setTimeout(i,0)},[z,U,I,e.onChange,null==(y=e.options)?void 0:y.tablePrefix,$,_]),er=(0,l.useCallback)(function(t,n){var r=K[t];if(r&&r.selected!==n){if(n){var o,l=null==(o=e.options)?void 0:o.tablePrefix,i=U.filter(function(e){var t;return!!e.required||!!I.get(e.name)&&!!(!l||!l.trim()||(null==(t=e.name)?void 0:t.startsWith(l.trim())))}).length;if(i>=500)return;i+1===500&&a.message.warning($("Maximum selection limit reached. To ensure system performance, you can select up to {{limit}} collections at once.",{ns:_,limit:500}))}var c=new Map(I);n?c.set(r.name,!0):(c.delete(r.name),F(!1)),M(c),setTimeout(function(){var t,n,r=null==(t=e.options)?void 0:t.tablePrefix,o=U.map(function(e){var t,n=!1;return e.required?n=!0:c.get(e.name)&&(!r||!r.trim()||(null==(t=e.name)?void 0:t.startsWith(r.trim())))&&(n=!0),g(h({},e),{selected:n})});null==(n=e.onChange)||n.call(e,o)},0)}},[K,U,I,e.onChange,null==(b=e.options)?void 0:b.tablePrefix,$,_]),eo=(0,l.useCallback)(function(e){Q(e)},[Q]),ea=(0,l.useCallback)(function(){E(""),V.current&&clearTimeout(V.current)},[]),el=(0,l.useCallback)(function(){M(new Map),F(!1);var t,n=U.map(function(e){return g(h({},e),{selected:e.required||!1})});null==(t=e.onChange)||t.call(e,n)},[U,e.onChange]),ei=(0,l.useMemo)(function(){var e=i().memo(function(e){var t=e.selected,n=e.required,r=e.index,o=e.onChange,l=(e.name,e.disabled);return i().createElement(a.Checkbox,{checked:n||t,disabled:n||l,onChange:function(e){return o(r,e.target.checked)}})}),t=i().memo(function(e){var t=e.text;return i().createElement("span",{style:{paddingLeft:"40px"}},t)}),n=[{title:i().createElement("div",{style:{textAlign:"center"}},$("Display name",{ns:_})),dataIndex:"name",key:"name",align:"left",width:"50%",render:function(e){return i().createElement(t,{text:e})}}];if(!B){var r=ee>=450,o=U.filter(function(e){return I.get(e.name)||e.required}).length,l=K.filter(function(e){return!e.selected&&!e.required}).length;n.push({title:i().createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4}},i().createElement(a.Checkbox,{checked:Y,indeterminate:Z,disabled:et&&!Y&&!(o+l<=500),onChange:function(e){return en(e.target.checked)}}),i().createElement("span",{style:r?{color:"#ff7a00"}:{}},$("Add",{ns:_})," (",ee,"/",U.length,")"),ee>0&&i().createElement(a.Tooltip,{title:$("Reset selection",{ns:_})},i().createElement(a.Button,{type:"text",size:"small",icon:i().createElement(f.ClearOutlined,null),onClick:el,style:{padding:"0 4px",height:"16px",minWidth:"16px",fontSize:"12px",color:"#666"}}))),dataIndex:"selected",key:"selected",align:"center",width:"30%",render:function(t,n,r){var o=et&&!t&&!n.required;return i().createElement(e,{selected:t,required:n.required,index:r,name:n.name,disabled:o,onChange:er})}})}return n},[$,Y,Z,en,er,B,_,ee,U.length,et,I,K,el]);return i().createElement("div",null,i().createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"8px 0"}},i().createElement("div",null,i().createElement(a.Checkbox,{checked:B,onChange:function(e){return H(e.target.checked)}},$("Add all collections",{ns:_}))),i().createElement(a.Input.Search,{placeholder:$("Search collection name",{ns:_}),allowClear:!0,style:{width:250},onSearch:eo,onChange:function(e){return eo(e.target.value)},onClear:ea}),i().createElement(a.Button,{icon:i().createElement(f.ReloadOutlined,null),onClick:function(){return J()},loading:S},$("Load Collections",{ns:_}))),i().createElement(a.Table,{columns:ei,dataSource:K,loading:S,pagination:!1,scroll:{x:B?300:550,y:400},virtual:!0,bordered:!0,rowKey:"name",size:"small"}))}),A=function(e){var t=e.NAMESPACE,n=e.t;return{CollectionsTable:function(e){return i().createElement(C,g(h({},e),{NAMESPACE:t,t:n}))},createCollectionsSchema:function(e,n){return{type:"array",title:'{{t("Collections",{ ns: "'.concat(t,'" })}}'),"x-decorator":"FormItem","x-component":"CollectionsTable","x-component-props":{from:e,loadCollections:n,formValues:"{{$form.values}}",options:"{{$form.values.options}}",formSetValues:"{{$form.setValuesIn}}"},"x-reactions":[{dependencies:["..key","..options","..addAllCollections"],fulfill:{schema:{"x-component-props.dataSourceKey":"{{$deps[0]}}","x-component-props.options":"{{$deps[1]}}","x-component-props.addAllCollectionsValue":"{{$deps[2]}}"}}},{dependencies:["..options.tablePrefix"],fulfill:{run:"\n $self.forceUpdate && $self.forceUpdate();\n "}},{dependencies:["..key"],fulfill:{run:"\n if ($deps[0] && from === 'edit' && loadCollections) {\n (async () => {\n const {data} = await loadCollections($deps[0]);\n $self.value = data || [];\n $form.setValuesIn('collections', data || []);\n })();\n }\n "}}]}},Text:(0,d.observer)(function(e){return i().createElement("span",null,e.value)}),addAllCollectionsSchema:{type:"boolean","x-component":"Checkbox","x-display":"hidden",default:!0}}};function S(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 w(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(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=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||P(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 E(e){return function(e){if(Array.isArray(e))return S(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||P(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 P(e,t){if(e){if("string"==typeof e)return S(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 S(e,t)}}var j=function(e){var t=(0,d.useForm)(),n=(0,d.useField)(),r=(0,o.useActionContext)(),a=(0,o.useResourceActionContext)().refresh,l=(0,o.useResourceContext)().resource;return{run:function(){var o;return(o=function(){var o,i,c;return function(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[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 c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(u){switch(u.label){case 0:return u.trys.push([0,4,,5]),[4,t.submit()];case 1:var s,p;return u.sent(),n.data=n.data||{},n.data.loading=!0,i=t.values.collections||[],[4,l.create({values:(s=function(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){k(e,t,n[t])})}return e}({},t.values),p=p={collections:i.filter(function(e){return e.selected}).map(function(e){return e.name})},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(p)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(p)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(p,e))}),s)})];case 2:return c=u.sent(),r.setVisible(!1),null==e||e(null==c||null==(o=c.data)?void 0:o.data),[4,t.reset()];case 3:return u.sent(),n.data.loading=!1,a(),[3,5];case 4:return u.sent(),n.data&&(n.data.loading=!1),[3,5];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function l(e){w(a,n,r,l,i,"next",e)}function i(e){w(a,n,r,l,i,"throw",e)}l(void 0)})})()}}},D=function(){var e=O((0,l.useState)({}),2),t=e[0],n=e[1],s=(0,o.usePlugin)(u.default),p=(0,o.useCompile)(),d=O((0,l.useState)(!1),2),b=d[0],v=d[1],h=(0,c.useTranslation)().t,g=O((0,l.useState)(null),2),x=g[0],C=g[1],S=(0,o.useAPIClient)(),w=(0,m.useLoadCollections)();return i().createElement("div",null,i().createElement(o.ActionContext.Provider,{value:{visible:b,setVisible:v}},i().createElement(a.Dropdown,{menu:{onClick:function(e){if("__empty__"!==e.key){var t=s.types.get(e.key);C(e.key),v(!0),n({type:"object",properties:k({},(0,r.uid)(),{type:"void","x-component":"Action.Drawer","x-component-props":{width:650},"x-decorator":"Form","x-decorator-props":{initialValue:{type:e.key,key:"d_".concat((0,r.uid)())}},title:p("{{t('Add new')}}")+" - "+p(t.label),properties:{body:{type:"void","x-component":t.DataSourceSettingsForm.bind(null,{CollectionsTableField:A,loadCollections:w,from:"create"})},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==t?void 0:t.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:"{{ useCreateAction }}",actionCallback:"{{ dataSourceCreateCallback }}"}}}}}})})}},items:[s.types.size?null:{key:"__empty__",label:i().createElement(a.Empty,{image:a.Empty.PRESENTED_IMAGE_SIMPLE,description:i().createElement(i().Fragment,null,h("No external data source plugin installed",{ns:y.A7}),i().createElement("br",null)," ",i().createElement("a",{target:"_blank",href:"zh-CN"===S.auth.locale?"https://docs-cn.nocobase.com/handbook/data-source-manager":"https://docs.nocobase.com/handbook/data-source-manager",rel:"noreferrer"},h("View documentation",{ns:y.A7})))})}].filter(Boolean).concat(E(s.types.keys()).map(function(e){var t=s.types.get(e);return{key:e,label:p(null==t?void 0:t.label)}}))}},i().createElement(a.Button,{type:"primary",icon:i().createElement(f.PlusOutlined,null)},h("Add new")," ",i().createElement(f.DownOutlined,null))),i().createElement(o.SchemaComponent,{scope:{createOnly:!1,useTestConnectionAction:m.useTestConnectionAction,dialect:x,useDialectDataSource:function(e){e.dataSource=E(s.types.keys()).map(function(e){var t=s.types.get(e);return{value:t.name,label:p(t.label)}})},useCreateAction:j},schema:t})))},T=n(467),I=n.n(T);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 q(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,o)}function R(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(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=[],l=!0,i=!1;try{for(o=o.call(e);!(l=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);l=!0);}catch(e){i=!0,r=e}finally{try{l||null==o.return||o.return()}finally{if(i)throw r}}return a}}(e,t)||function(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)}}(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 V=function(){var e=(0,o.useRecord)(),t=F((0,l.useState)({}),2),n=t[0],a=t[1],s=(0,o.usePlugin)(u.default),p=(0,o.useCompile)(),f=F((0,l.useState)(!1),2),b=f[0],v=f[1],h=(0,c.useTranslation)().t,g=(0,o.useDataSourceManager)(),x=(0,m.useLoadCollections)();return(0,o.useAPIClient)(),i().createElement("div",null,i().createElement(o.ActionContext.Provider,{value:{visible:b,setVisible:v}},"main"!==e.key&&i().createElement("a",{onClick:function(){v(!0);var t=s.types.get(e.type);a({type:"object",properties:R({},(0,r.uid)(),{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:e},"x-component-props":{width:650},title:p("{{t('Edit')}}")+" - "+p(e.displayName),properties:{body:{type:"void","x-component":t.DataSourceSettingsForm.bind(null,{CollectionsTableField:A,loadCollections:x,from:"edit"})},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==t?void 0:t.disableTestConnection},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateAction }}"}}}}}})})}},h("Edit")),i().createElement(o.SchemaComponent,{scope:{createOnly:!0,useUpdateAction:function(){var e=(0,d.useField)(),t=(0,d.useForm)(),n=(0,o.useActionContext)(),r=(0,o.useResourceActionContext)().refresh,a=(0,o.useResourceContext)().resource,l=(0,o.useRecord)().key;return{run:function(){var o;return(o=function(){var o;return function(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[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 c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,t.submit()];case 1:i.sent(),e.data=e.data||{},e.data.loading=!0,o=t.values.collections||[],i.label=2;case 2:var c,u;return i.trys.push([2,5,6,7]),[4,a.update({filterByTk:l,values:(c=function(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){R(e,t,n[t])})}return e}({},t.values),u=u={collections:o.filter(function(e){return e.selected}).map(function(e){return e.name})},Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(u)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(u)).forEach(function(e){Object.defineProperty(c,e,Object.getOwnPropertyDescriptor(u,e))}),c)})];case 3:return i.sent(),n.setVisible(!1),g.getDataSource(l).setOptions(I().omit(t.values,"collections")),g.getDataSource(l).reload(),[4,t.reset()];case 4:return i.sent(),r(),[3,7];case 5:return console.log(i.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 l(e){q(a,n,r,l,i,"next",e)}function i(e){q(a,n,r,l,i,"throw",e)}l(void 0)})})()}}},loadCollections:x},schema:n})))},_=n(964),$=n(128),L=function(e){var t=e.key,n=e.type;return"/admin/settings/data-source-manager/".concat(t,"/collections?type=").concat(n)};function N(){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 N=function(){return n},n}var B=function(){var e=(0,o.useRecord)(),t=(0,$.useNavigate)(),n=(0,c.useTranslation)().t;return i().createElement("div",{className:e.enabled?void 0:(0,_.css)(N())},i().createElement(a.Button,{type:"link",style:{padding:"0px"},disabled:!e.enabled,onClick:function(){t(L(e))},role:"button","aria-label":"".concat(null==e?void 0:e.key,"-Configure")},n("Configure")))};function W(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 z(e,t,n,r,o,a,l){try{var i=e[a](l),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).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 l(e){z(a,r,o,l,i,"next",e)}function i(e){z(a,r,o,l,i,"throw",e)}l(void 0)})}}function K(e){return function(e){if(Array.isArray(e))return W(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 W(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 W(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 G(e,t){var n,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[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 c=[a,i];if(n)throw TypeError("Generator is already executing.");for(;l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var H=function(){var e,t=(0,c.useTranslation)().t,n=(0,o.usePlugin)(u.default),f=(0,o.useDataSourceManager)();(0,o.useAPIClient)();var d=(0,l.useCallback)(function(e){f.setDataSources((null==e?void 0:e.data)||[]),f.reload()},[f]),m=K(n.types.keys()).map(function(e){var r=n.types.get(e);return{value:e,label:t(null==r?void 0:r.label)}}).concat([{value:"main",label:t("Main")}]),y=i().useRef([]);(0,l.useEffect)(function(){return function(){f.getDataSources().forEach(function(e){y.current.includes(e.key)&&e.reload()})}},[y]);var b=(0,l.useCallback)(function(e){f.removeDataSources(e)},[f]),v=(0,l.useCallback)((e=U(function(e){return G(this,function(t){return f.addDataSource(p.F,e),y.current=K(y.current).concat([e.key]),[2]})}),function(t){return e.apply(this,arguments)}),[f]);return i().createElement(a.Card,{bordered:!1},i().createElement(o.SchemaComponent,{components:{CreateDatabaseConnectAction:D,EditDatabaseConnectionAction:V,ViewDatabaseConnectionAction:B},scope:{useNewId:function(e){return"".concat(e).concat((0,r.uid)())},types:m,useRefreshActionProps:function(){var e=(0,o.useResourceActionContext)();return{onClick:function(){return U(function(){var t,n,r,o,a;return G(this,function(l){switch(l.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=f.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:l.sent(),l.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 U(function(){return G(this,function(r){switch(r.label){case 0:return[4,t.destroy({filterByTk:n})];case 1:return r.sent(),b([n]),e(),[2]}})})()}}},dataSourceDeleteCallback:b,dataSourceCreateCallback:v,dataSourceListCallback:d,useIsAbleDelete:function(e){e.visible="main"!==(0,o.useRecord)().key}},schema:s.j}))}},469:function(e,t,n){n.d(t,{$:function(){return c},j:function(){return s}});var r,o,a,l=n(875),i=n(551),c=[{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,l.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:c}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},s={type:"object",properties:(r={},o=(0,l.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 }}",onSuccess:"{{ dataSourceListCallback }}"},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)}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
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([["236"],{612:function(e,t,r){r.r(t),r.d(t,{DataSourceContext:function(){return l},DatabaseConnectionProvider:function(){return i}});var n=r(772),a=r(156),o=r.n(a),u=r(241);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var l=(0,a.createContext)(null);l.displayName="DataSourceContext";var i=function(e){var t,r=(t=(0,a.useState)(null),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,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=(r=a.next()).done)&&(o.push(r.value),o.length!==t);u=!0);}catch(e){c=!0,n=e}finally{try{u||null==a.return||a.return()}finally{if(c)throw n}}return o}}(t,2)||function(e,t){if(e){if("string"==typeof e)return c(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))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.")}()),i=r[0],s=r[1];return o().createElement(l.Provider,{value:{dataSource:i,setDataSource:s}},o().createElement(n.SchemaComponentOptions,{scope:u,components:{}},e.children))}},507:function(e,t,r){r.d(t,{H:function(){return s}});var n=r(505),a=r(772),o=r(721),u=r(156),c=r(238),l=r(612);function i(e,t,r,n,a,o,u){try{var c=e[o](u),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,a)}var s=function(e){var t=e.dataSourceName,r=e.onSuccess,s=e.onError,f=e.showMessage,b=void 0===f||f,d=(0,c.useTranslation)().t,p=(0,u.useContext)(a.ResourceActionContext),y=(0,a.useAPIClient)(),v=(0,n.useField)(),h=(0,a.useDataSourceManager)(),m=(0,u.useContext)(l.DataSourceContext),g=m.setDataSource,S=m.dataSource;return v.data=v.data||{},{onClick:function(){var e;return(e=function(){var e,n,a,u,c;return function(e,t){var r,n,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 l=[o,c];if(r)throw TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(a=2&l[0]?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,n=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===l[0]||2===l[0])){u=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){u.label=l[1];break}if(6===l[0]&&u.label<a[1]){u.label=a[1],a=l;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(l);break}a[2]&&u.ops.pop(),u.trys.pop();continue}l=t.call(e,u)}catch(e){l=[6,e],n=0}finally{r=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:v.data.loading=!0,l.label=1;case 1:return l.trys.push([1,4,,5]),[4,y.request({url:"".concat("main"===t?"mainDataSource":"dataSources",":refresh?filterByTk=").concat(t,"&clientStatus=").concat((null==S?void 0:S.status)||"loaded"),method:"post"})];case 2:var i,f;return a=l.sent().data,v.data.loading=!1,g((i=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},null==a?void 0:a.data),f=f={name:t},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(f)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(f)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(f,e))}),i)),(null==a||null==(e=a.data)?void 0:e.status)==="reloading"?b&&o.message.warning(d("Data source synchronization in progress")):(null==a||null==(n=a.data)?void 0:n.status)==="loaded"&&(b&&o.message.success(d("Data source synchronization successful")),null==p||null==(u=p.refresh)||u.call(p)),[4,h.getDataSource(t).reload()];case 3:return l.sent(),null==r||r(),[3,5];case 4:return c=l.sent(),v.data.loading=!1,b&&o.message.error(d("Data source synchronization failed")),null==s||s(c),[3,5];case 5:return[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function u(e){i(o,n,a,u,c,"next",e)}function c(e){i(o,n,a,u,c,"throw",e)}u(void 0)})})()},get loading(){return v.data.loading}}}},491:function(e,t,r){r.d(t,{t:function(){return f},u:function(){return s}});var n=r(772),a=r(156);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t,r,n,a,o,u){try{var c=e[o](u),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,a)}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,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=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);u=!0);}catch(e){c=!0,n=e}finally{try{u||null==a.return||a.return()}finally{if(c)throw n}}return o}}(e,t)||i(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 i(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(e,t)}}var s=function(e){var t,r,c,s=e.resourceName,f=e.resourceParams,b=e.getParams,d=void 0===b?{}:b,p=e.deps,y=e.enabled,v=void 0===y||y,h=e.onSuccess,m=e.onError,g=(0,n.useAPIClient)(),S=l((0,a.useState)(null),2),w=S[0],O=S[1],P=l((0,a.useState)(!1),2),C=P[0],j=P[1],k=l((0,a.useState)(null),2),D=k[0],x=k[1],A=f?g.resource(s,f):g.resource(s),E=(t=function(){var e,t,r;return function(e,t){var r,n,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 l=[o,c];if(r)throw TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(a=2&l[0]?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,n=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===l[0]||2===l[0])){u=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){u.label=l[1];break}if(6===l[0]&&u.label<a[1]){u.label=a[1],a=l;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(l);break}a[2]&&u.ops.pop(),u.trys.pop();continue}l=t.call(e,u)}catch(e){l=[6,e],n=0}finally{r=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:if(!v)return[2];j(!0),x(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,A.get(d)];case 2:return O(t=null==(e=n.sent())?void 0:e.data),null==h||h(t),[3,5];case 3:return x(r=n.sent()),null==m||m(r),console.error("Failed to fetch ".concat(s," data:"),r),[3,5];case 4:return j(!1),[7];case 5:return[2]}})},r=function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function c(e){u(o,n,a,c,l,"next",e)}function l(e){u(o,n,a,c,l,"throw",e)}c(void 0)})},function(){return r.apply(this,arguments)});return(0,a.useEffect)(function(){E()},[s,v].concat(function(e){if(Array.isArray(e))return o(e)}(c=void 0===p?[]:p)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(c)||i(c)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())),{data:w,loading:C,error:D,refresh:function(){E()}}},f=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.getParams,n=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(t,["getParams"]);return s(c({resourceName:"dataSources",resourceParams:e,getParams:c({filterByTk:e},void 0===r?{}:r),deps:[e]},n))}},241:function(e,t,r){r.r(t),r.d(t,{useLoadCollections:function(){return w},useResourceData:function(){return a.u},useCreateDatabaseServer:function(){return g},useTestConnectionAction:function(){return S},useDataSourceData:function(){return a.t},useDataSourceActions:function(){return s},useDataSourceRefresh:function(){return n.H}});var n=r(507),a=r(491),o=r(772),u=r(156);function c(e,t,r,n,a,o,u){try{var c=e[o](u),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,a)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function u(e){c(o,n,a,u,l,"next",e)}function l(e){c(o,n,a,u,l,"throw",e)}u(void 0)})}}function i(e,t){var r,n,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 l=[o,c];if(r)throw TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(a=2&l[0]?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,n=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===l[0]||2===l[0])){u=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){u.label=l[1];break}if(6===l[0]&&u.label<a[1]){u.label=a[1],a=l;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(l);break}a[2]&&u.ops.pop(),u.trys.pop();continue}l=t.call(e,u)}catch(e){l=[6,e],n=0}finally{r=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var s=function(){var e,t,r=(0,o.useDataSourceManager)(),n=(0,o.useAPIClient)(),a=(0,o.useResourceActionContext)().data,c=(0,u.useCallback)(function(e){null==e||e.forEach(function(e){r.getDataSource(e.key)})},[r]);return(0,u.useEffect)(function(){(null==a?void 0:a.data)&&c(a.data)},[a,c]),{reloadAllDataSources:(0,u.useCallback)(l(function(){return i(this,function(e){switch(e.label){case 0:return[4,Promise.all(r.getDataSources().map(function(e){return e.reload()}))];case 1:return e.sent(),[2]}})}),[r]),reloadDataSource:(0,u.useCallback)((e=l(function(e){var t;return i(this,function(n){switch(n.label){case 0:if(!(t=r.getDataSource(e)))return[3,2];return[4,t.reload()];case 1:n.sent(),n.label=2;case 2:return[2]}})}),function(t){return e.apply(this,arguments)}),[r]),getDataSourceCollections:(0,u.useCallback)(function(e){var t=r.getDataSource(e);return(null==t?void 0:t.collectionManager.getCollections())||[]},[r]),testConnection:(0,u.useCallback)((t=l(function(e){var t;return i(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n.request({resource:"dataSources",action:"testConnection",params:{values:{key:e}}})];case 1:return r.sent(),[2,!0];case 2:return t=r.sent(),console.error("Failed to test connection for ".concat(e,":"),t),[2,!1];case 3:return[2]}})}),function(e){return t.apply(this,arguments)}),[n])}},f=r(505),b=r(721),d=r(238),p=r(551);function y(e,t,r,n,a,o,u){try{var c=e[o](u),l=c.value}catch(e){r(e);return}c.done?t(l):Promise.resolve(l).then(n,a)}function v(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var o=e.apply(t,r);function u(e){y(o,n,a,u,c,"next",e)}function c(e){y(o,n,a,u,c,"throw",e)}u(void 0)})}}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function m(e,t){var r,n,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 l=[o,c];if(r)throw TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(a=2&l[0]?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=0,a&&(l=[2&l[0],a.value]),l[0]){case 0:case 1:a=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,n=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!(a=(a=u.trys).length>0&&a[a.length-1])&&(6===l[0]||2===l[0])){u=0;continue}if(3===l[0]&&(!a||l[1]>a[0]&&l[1]<a[3])){u.label=l[1];break}if(6===l[0]&&u.label<a[1]){u.label=a[1],a=l;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(l);break}a[2]&&u.ops.pop(),u.trys.pop();continue}l=t.call(e,u)}catch(e){l=[6,e],n=0}finally{r=a=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var g=function(e){var t=(0,f.useForm)(),r=(0,o.useActionContext)(),n=(0,o.useAPIClient)(),a=(0,d.useTranslation)().t,u=(0,f.useField)();return u.data=u.data||{},{run:function(){return v(function(){var o,c;return m(this,function(l){switch(l.label){case 0:return[4,t.submit()];case 1:l.sent(),l.label=2;case 2:return l.trys.push([2,5,,6]),u.data.loading=!0,[4,n.resource("databaseServers").create({values:h({},t.values)})];case 3:return o=l.sent().data,u.data.loading=!1,r.setVisible(!1),[4,t.reset()];case 4:return l.sent(),null==e||e(null==o?void 0:o.data),b.message.success(a("Saved successfully")),[3,6];case 5:return c=l.sent(),u.data.loading=!1,console.log(c),[3,6];case 6:return[2]}})})()}}},S=function(){var e=(0,f.useForm)(),t=(0,o.useAPIClient)(),r=(0,d.useTranslation)().t,n=(0,f.useField)();return n.data=n.data||{},{run:function(){return v(function(){var a;return m(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]),n.data.loading=!0,[4,t.resource("dataSources").testConnection({values:h({},e.values)})];case 3:return o.sent(),n.data.loading=!1,b.message.success(r("Connection successful",{ns:p.A7})),[3,5];case 4:return a=o.sent(),n.data.loading=!1,console.log(a),[3,5];case 5:return[2]}})})()}}},w=function(){var e,t=(0,o.useAPIClient)();return e=v(function(e){return m(this,function(r){switch(r.label){case 0:return[4,t.resource("dataSources").readTables({values:{dataSourceKey:e}})];case 1:return[2,r.sent().data]}})}),function(t){return e.apply(this,arguments)}}}}]);
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
export * from './useDataSourceRefresh';
|
|
10
|
+
export * from './useResourceData';
|
|
11
|
+
export * from './useDataSourceActions';
|
|
9
12
|
export declare const useCreateDatabaseServer: (handleDataServerChange: any) => {
|
|
10
13
|
run(): Promise<void>;
|
|
11
14
|
};
|
|
@@ -13,7 +16,3 @@ export declare const useTestConnectionAction: () => {
|
|
|
13
16
|
run(): Promise<void>;
|
|
14
17
|
};
|
|
15
18
|
export declare const useLoadCollections: () => (key: any) => Promise<any>;
|
|
16
|
-
export declare const addDatasourceCollections: (api: any, filterByTk: any, options: {
|
|
17
|
-
collections;
|
|
18
|
-
dbOptions;
|
|
19
|
-
}) => Promise<void>;
|
|
@@ -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
|
+
export declare const useDataSourceActions: () => {
|
|
10
|
+
reloadAllDataSources: () => Promise<void>;
|
|
11
|
+
reloadDataSource: (key: string) => Promise<void>;
|
|
12
|
+
getDataSourceCollections: (key: string) => import("@nocobase/client").Collection[];
|
|
13
|
+
testConnection: (key: string) => Promise<boolean>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export interface UseDataSourceRefreshOptions {
|
|
10
|
+
dataSourceName: string;
|
|
11
|
+
onSuccess?: () => void;
|
|
12
|
+
onError?: (error: any) => void;
|
|
13
|
+
showMessage?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const useDataSourceRefresh: (options: UseDataSourceRefreshOptions) => {
|
|
16
|
+
onClick(): Promise<void>;
|
|
17
|
+
readonly loading: any;
|
|
18
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
export interface UseResourceDataOptions {
|
|
10
|
+
resourceName: string;
|
|
11
|
+
resourceParams?: string | string[];
|
|
12
|
+
getParams?: Record<string, any>;
|
|
13
|
+
deps?: any[];
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
onSuccess?: (data: any) => void;
|
|
16
|
+
onError?: (error: any) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const useResourceData: (options: UseResourceDataOptions) => {
|
|
19
|
+
data: any;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: any;
|
|
22
|
+
refresh: () => void;
|
|
23
|
+
};
|
|
24
|
+
export declare const useDataSourceData: (dataSourceName: string, options?: Omit<UseResourceDataOptions, 'resourceName' | 'resourceParams' | 'getParams'> & {
|
|
25
|
+
getParams?: Record<string, any>;
|
|
26
|
+
}) => {
|
|
27
|
+
data: any;
|
|
28
|
+
loading: boolean;
|
|
29
|
+
error: any;
|
|
30
|
+
refresh: () => void;
|
|
31
|
+
};
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("@formily/antd-v5"),require("react"),require("@emotion/css"),require("lodash"),require("@nocobase/plugin-acl/client"),require("@formily/shared"),require("@nocobase/client"),require("react-router-dom"),require("@dnd-kit/core"),require("@formily/reactive"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd"),require("antd-style"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-data-source-manager",["@formily/core","@formily/antd-v5","react","@emotion/css","lodash","@nocobase/plugin-acl/client","@formily/shared","@nocobase/client","react-router-dom","@dnd-kit/core","@formily/reactive","@formily/react","@nocobase/utils/client","@ant-design/icons","antd","antd-style","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-data-source-manager"]=t(require("@formily/core"),require("@formily/antd-v5"),require("react"),require("@emotion/css"),require("lodash"),require("@nocobase/plugin-acl/client"),require("@formily/shared"),require("@nocobase/client"),require("react-router-dom"),require("@dnd-kit/core"),require("@formily/reactive"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd"),require("antd-style"),require("react-i18next")):e["@nocobase/plugin-data-source-manager"]=t(e["@formily/core"],e["@formily/antd-v5"],e.react,e["@emotion/css"],e.lodash,e["@nocobase/plugin-acl/client"],e["@formily/shared"],e["@nocobase/client"],e["react-router-dom"],e["@dnd-kit/core"],e["@formily/reactive"],e["@formily/react"],e["@nocobase/utils/client"],e["@ant-design/icons"],e.antd,e["antd-style"],e["react-i18next"])}(self,function(e,t,n,r,o,i,a,c,u,s,l,f,p,d,b,y,m){return function(){var g,h,v,_,w,O,P={329:function(e,t,n){"use strict";n.r(t),n.d(t,{PluginDataSourceManagerClient:function(){return A}});var r=n(772),o=n(465),i=n.n(o),a=n(584),c=n(156),u=n.n(c),s=n(347),l=n(551),f=n(581);function p(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){p(i,r,o,a,c,"next",e)}function c(e){p(i,r,o,a,c,"throw",e)}a(void 0)})}}function b(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function y(e,t,n){return(y=O()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&_(o,n.prototype),o}).apply(null,arguments)}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),e}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t="function"==typeof Map?new Map:void 0;return(w=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return y(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),_(n,e)})(e)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function P(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var S=(0,r.lazy)(function(){return f("imported_174m4o3_component",n.e("539").then(n.bind(n,612)))},"DatabaseConnectionProvider").DatabaseConnectionProvider,x=(0,r.lazy)(function(){return f("imported_-1bdhn46_component",n.e("65").then(n.bind(n,130)))},"BreadcumbTitle").BreadcumbTitle,k=(0,r.lazy)(function(){return f("imported_l1a36j_component",Promise.all([n.e("398"),n.e("10")]).then(n.bind(n,645)))},"CollectionManagerPage").CollectionManagerPage,j=(0,r.lazy)(function(){return f("imported_k8ts4l_component",n.e("296").then(n.bind(n,919)))},"DatabaseConnectionManagerPane").DatabaseConnectionManagerPane,q=(0,r.lazy)(function(){return f("imported_1cub3nb_component",Promise.all([n.e("398"),n.e("926")]).then(n.bind(n,93)))},"MainDataSourceManager").MainDataSourceManager,C=(0,r.lazy)(function(){return f("imported_-1b29440_component",n.e("674").then(n.bind(n,937)))},"DataSourcePermissionManager").DataSourcePermissionManager,M=(0,r.lazy)(function(){return f("imported_cef22q_component",n.e("746").then(n.bind(n,62)))},"CollectionMainProvider").CollectionMainProvider,T=function(){function e(t){b(this,e),h(this,"plugin",void 0),h(this,"componentRegistry",void 0),this.plugin=t,this.componentRegistry=new a.Registry}return g(e,[{key:"registerManagerAction",value:function(e){var t=e.order,n=e.component,r="managerAction";this.componentRegistry.get(r)||this.componentRegistry.register(r,[]),this.componentRegistry.get(r).push({order:null!=t?t:0,component:n})}},{key:"getManagerActions",value:function(){var e;return null!=(e=this.componentRegistry.get("managerAction"))?e:[]}}]),e}(),A=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,r;return b(this,t),n=t,r=arguments,n=v(n),h(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,O()?Reflect.construct(n,r||[],v(this).constructor):n.apply(this,r)),"types",new Map),h(e,"extensionManager",new T(e)),h(e,"extendedTabs",{}),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e),g(t,[{key:"getExtendedTabs",value:function(){return this.extendedTabs}},{key:"registerPermissionTab",value:function(e){this.extendedTabs[(0,a.uid)()]=e}},{key:"load",value:function(){var e=this;return d(function(){return P(this,function(t){return e.app.pm.get(i()).settingsUI.addPermissionsTab(function(e){var t=e.t,n=e.TabLayout,r=e.activeRole;return{key:"dataSource",label:t("Data sources"),sort:15,children:u().createElement(n,null,u().createElement(C,{role:r}))}}),e.app.use(S),e.app.pluginSettingsManager.add(l.A7,{title:'{{t("Data sources", { ns: "'.concat(l.A7,'" })}}'),icon:"ClusterOutlined",isPinned:!0,sort:100,showTabs:!1,aclSnippet:"pm.data-source-manager*"}),e.app.pluginSettingsManager.add("".concat(l.A7,".list"),{title:'{{t("Data sources", { ns: "'.concat(l.A7,'" })}}'),Component:j,sort:1,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),e.app.pluginSettingsManager.add("".concat(l.A7,"/:name"),{title:u().createElement(x,null),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),e.app.pluginSettingsManager.add("".concat(l.A7,"/main"),{title:u().createElement(x,null),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main",Component:M}),e.app.pluginSettingsManager.add("".concat(l.A7,"/main.collections"),{title:'{{t("Collections", { ns: "'.concat(l.A7,'" })}}'),Component:q,topLevelName:"".concat(l.A7,"/main"),pluginKey:l.A7,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),e.app.pluginSettingsManager.add("".concat(l.A7,"/:name.collections"),{title:'{{t("Collections", { ns: "'.concat(l.A7,'" })}}'),Component:k,topLevelName:"".concat(l.A7,"/:name"),pluginKey:l.A7,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),e.app.dataSourceManager.addDataSources(e.getThirdDataSource.bind(e),s.F),[2]})})()}},{key:"setDataSources",value:function(){var e=this;return d(function(){var t,n;return P(this,function(r){switch(r.label){case 0:return[4,e.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1}})];case 1:return[2,null==(n=r.sent())||null==(t=n.data)?void 0:t.data]}})})()}},{key:"getThirdDataSource",value:function(){var e=this;return d(function(){var t,n;return P(this,function(r){switch(r.label){case 0:return[4,e.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1,appends:["collections"]}})];case 1:return[2,null==(n=r.sent())||null==(t=n.data)?void 0:t.data]}})})()}},{key:"registerType",value:function(e,t){this.types.set(e,t)}}]),t}(w(r.Plugin));t.default=A},347:function(e,t,n){"use strict";n.d(t,{F:function(){return u}});var r=n(772);function o(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=i(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,c()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&a(n,e),t=[{key:"getDataSource",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){switch(e.label){case 0:return[4,t.app.apiClient.request({url:"dataSources:get/".concat(t.key),params:{appends:["collections"]}})];case 1:return[2,e.sent().data.data]}})},function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function c(e){o(a,r,i,c,u,"next",e)}function u(e){o(a,r,i,c,u,"throw",e)}c(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(r.DataSource)},551:function(e,t,n){"use strict";n.d(t,{A7:function(){return i},EL:function(){return c},KQ:function(){return a}});var r=n(772),o=n(238),i="data-source-manager";function a(e){var t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r.i18n.t(e,(t=function(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}({},o),n=n={ns:i},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}function c(){return(0,o.useTranslation)([i,"client"],{nsMode:"fallback"})}},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=d},948:function(e){"use strict";e.exports=s},964:function(e){"use strict";e.exports=r},632:function(e){"use strict";e.exports=t},563:function(t){"use strict";t.exports=e},505:function(e){"use strict";e.exports=f},229:function(e){"use strict";e.exports=l},875:function(e){"use strict";e.exports=a},772:function(e){"use strict";e.exports=c},465:function(e){"use strict";e.exports=i},584:function(e){"use strict";e.exports=p},721:function(e){"use strict";e.exports=b},933:function(e){"use strict";e.exports=y},467:function(e){"use strict";e.exports=o},156:function(e){"use strict";e.exports=n},238:function(e){"use strict";e.exports=m},128:function(e){"use strict";e.exports=u}},S={};function x(e){var t=S[e];if(void 0!==t)return t.exports;var n=S[e]={exports:{}};return P[e](n,n.exports,x),n.exports}return x.m=P,x.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return x.d(t,{a:t}),t},x.d=function(e,t){for(var n in t)x.o(t,n)&&!x.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},x.f={},x.e=function(e){return Promise.all(Object.keys(x.f).reduce(function(t,n){return x.f[n](e,t),t},[]))},x.u=function(e){return""+({10:"7b6cb59b157f5087",296:"cc4271412c5e6495",398:"cab6d8ac1e107ea5",539:"9aff90e19fbd41b6",65:"0e6cf640dde183c8",674:"276bcf3de74bebd1",746:"1a8cce8035a89dd9",926:"b3873b8560b4de87"})[e]+".js"},x.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),x.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},g={},h="@nocobase/plugin-data-source-manager:",x.l=function(e,t,n,r){if(g[e])return void g[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var u=a[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==h+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,x.nc&&o.setAttribute("nonce",x.nc),o.setAttribute("data-webpack",h+n),o.src=e),g[e]=[t];var s=function(t,n){o.onerror=o.onload=null,clearTimeout(l);var r=g[e];if(delete g[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},l=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),i&&document.head.appendChild(o)},x.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(v=window.__nocobase_public_path__||"/").endsWith("/")||(v+="/"),x.p=v+"static/plugins/@nocobase/plugin-data-source-manager/dist/client/",_={909:0},x.f.j=function(e,t){var n=x.o(_,e)?_[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=_[e]=[t,r]});t.push(n[2]=r);var o=x.p+x.u(e),i=Error();x.l(o,function(t){if(x.o(_,e)&&(0!==(n=_[e])&&(_[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},w=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==_[e]})){for(n in i)x.o(i,n)&&(x.m[n]=i[n]);a&&a(x)}for(e&&e(t);c<o.length;c++)r=o[c],x.o(_,r)&&_[r]&&_[r][0](),_[r]=0},(O=self.webpackChunk_nocobase_plugin_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).forEach(w.bind(null,0)),O.push=w.bind(null,O.push.bind(O)),x(329)}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("@formily/antd-v5"),require("react"),require("@emotion/css"),require("lodash"),require("@nocobase/plugin-acl/client"),require("@formily/shared"),require("@nocobase/client"),require("react-router-dom"),require("@dnd-kit/core"),require("@formily/reactive"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd"),require("antd-style"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-data-source-manager",["@formily/core","@formily/antd-v5","react","@emotion/css","lodash","@nocobase/plugin-acl/client","@formily/shared","@nocobase/client","react-router-dom","@dnd-kit/core","@formily/reactive","@formily/react","@nocobase/utils/client","@ant-design/icons","antd","antd-style","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-data-source-manager"]=t(require("@formily/core"),require("@formily/antd-v5"),require("react"),require("@emotion/css"),require("lodash"),require("@nocobase/plugin-acl/client"),require("@formily/shared"),require("@nocobase/client"),require("react-router-dom"),require("@dnd-kit/core"),require("@formily/reactive"),require("@formily/react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd"),require("antd-style"),require("react-i18next")):e["@nocobase/plugin-data-source-manager"]=t(e["@formily/core"],e["@formily/antd-v5"],e.react,e["@emotion/css"],e.lodash,e["@nocobase/plugin-acl/client"],e["@formily/shared"],e["@nocobase/client"],e["react-router-dom"],e["@dnd-kit/core"],e["@formily/reactive"],e["@formily/react"],e["@nocobase/utils/client"],e["@ant-design/icons"],e.antd,e["antd-style"],e["react-i18next"])}(self,function(e,t,n,r,o,i,a,c,u,s,l,f,p,d,b,y,m){return function(){var g,h,v,_,w,O,P={329:function(e,t,n){"use strict";n.r(t),n.d(t,{PluginDataSourceManagerClient:function(){return A}});var r=n(772),o=n(465),i=n.n(o),a=n(584),c=n(156),u=n.n(c),s=n(347),l=n(551),f=n(581);function p(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){p(i,r,o,a,c,"next",e)}function c(e){p(i,r,o,a,c,"throw",e)}a(void 0)})}}function b(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function y(e,t,n){return(y=O()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&_(o,n.prototype),o}).apply(null,arguments)}function m(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,t,n){return t&&m(e.prototype,t),n&&m(e,n),e}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t="function"==typeof Map?new Map:void 0;return(w=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return y(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),_(n,e)})(e)}function O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function P(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var S=(0,r.lazy)(function(){return f("imported_174m4o3_component",n.e("236").then(n.bind(n,612)))},"DatabaseConnectionProvider").DatabaseConnectionProvider,x=(0,r.lazy)(function(){return f("imported_-1bdhn46_component",Promise.all([n.e("236"),n.e("65")]).then(n.bind(n,130)))},"BreadcumbTitle").BreadcumbTitle,k=(0,r.lazy)(function(){return f("imported_l1a36j_component",Promise.all([n.e("236"),n.e("398"),n.e("10")]).then(n.bind(n,645)))},"CollectionManagerPage").CollectionManagerPage,j=(0,r.lazy)(function(){return f("imported_k8ts4l_component",Promise.all([n.e("236"),n.e("296")]).then(n.bind(n,919)))},"DatabaseConnectionManagerPane").DatabaseConnectionManagerPane,q=(0,r.lazy)(function(){return f("imported_1cub3nb_component",Promise.all([n.e("236"),n.e("398"),n.e("843")]).then(n.bind(n,439)))},"MainDataSourceManager").MainDataSourceManager,C=(0,r.lazy)(function(){return f("imported_-1b29440_component",n.e("674").then(n.bind(n,937)))},"DataSourcePermissionManager").DataSourcePermissionManager,M=(0,r.lazy)(function(){return f("imported_cef22q_component",n.e("746").then(n.bind(n,93)))},"CollectionMainProvider").CollectionMainProvider,T=function(){function e(t){b(this,e),h(this,"plugin",void 0),h(this,"componentRegistry",void 0),this.plugin=t,this.componentRegistry=new a.Registry}return g(e,[{key:"registerManagerAction",value:function(e){var t=e.order,n=e.component,r="managerAction";this.componentRegistry.get(r)||this.componentRegistry.register(r,[]),this.componentRegistry.get(r).push({order:null!=t?t:0,component:n})}},{key:"getManagerActions",value:function(){var e;return null!=(e=this.componentRegistry.get("managerAction"))?e:[]}}]),e}(),A=function(e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(){var e,n,r;return b(this,t),n=t,r=arguments,n=v(n),h(e=function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,O()?Reflect.construct(n,r||[],v(this).constructor):n.apply(this,r)),"types",new Map),h(e,"extensionManager",new T(e)),h(e,"extendedTabs",{}),e}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_(t,e),g(t,[{key:"getExtendedTabs",value:function(){return this.extendedTabs}},{key:"registerPermissionTab",value:function(e){this.extendedTabs[(0,a.uid)()]=e}},{key:"load",value:function(){var e=this;return d(function(){return P(this,function(t){return e.app.pm.get(i()).settingsUI.addPermissionsTab(function(e){var t=e.t,n=e.TabLayout,r=e.activeRole;return{key:"dataSource",label:t("Data sources"),sort:15,children:u().createElement(n,null,u().createElement(C,{role:r}))}}),e.app.use(S),e.app.pluginSettingsManager.add(l.A7,{title:'{{t("Data sources", { ns: "'.concat(l.A7,'" })}}'),icon:"ClusterOutlined",isPinned:!0,sort:100,showTabs:!1,aclSnippet:"pm.data-source-manager*"}),e.app.pluginSettingsManager.add("".concat(l.A7,".list"),{title:'{{t("Data sources", { ns: "'.concat(l.A7,'" })}}'),Component:j,sort:1,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),e.app.pluginSettingsManager.add("".concat(l.A7,"/:name"),{title:u().createElement(x,null),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager"}),e.app.pluginSettingsManager.add("".concat(l.A7,"/main"),{title:u().createElement(x,null),icon:"ClusterOutlined",isTopLevel:!1,sort:100,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main",Component:M}),e.app.pluginSettingsManager.add("".concat(l.A7,"/main.collections"),{title:'{{t("Collections", { ns: "'.concat(l.A7,'" })}}'),Component:q,topLevelName:"".concat(l.A7,"/main"),pluginKey:l.A7,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),e.app.pluginSettingsManager.add("".concat(l.A7,"/:name.collections"),{title:'{{t("Collections", { ns: "'.concat(l.A7,'" })}}'),Component:k,topLevelName:"".concat(l.A7,"/:name"),pluginKey:l.A7,skipAclConfigure:!0,aclSnippet:"pm.data-source-manager.data-source-main"}),e.app.dataSourceManager.addDataSources(e.getThirdDataSource.bind(e),s.F),[2]})})()}},{key:"setDataSources",value:function(){var e=this;return d(function(){var t,n;return P(this,function(r){switch(r.label){case 0:return[4,e.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1}})];case 1:return[2,null==(n=r.sent())||null==(t=n.data)?void 0:t.data]}})})()}},{key:"getThirdDataSource",value:function(){var e=this;return d(function(){var t,n;return P(this,function(r){switch(r.label){case 0:return[4,e.app.apiClient.request({resource:"dataSources",action:"listEnabled",params:{paginate:!1,appends:["collections"]}})];case 1:return[2,null==(n=r.sent())||null==(t=n.data)?void 0:t.data]}})})()}},{key:"registerType",value:function(e,t){this.types.set(e,t)}}]),t}(w(r.Plugin));t.default=A},347:function(e,t,n){"use strict";n.d(t,{F:function(){return u}});var r=n(772);function o(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var u=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=i(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,c()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&a(n,e),t=[{key:"getDataSource",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){switch(e.label){case 0:return[4,t.app.apiClient.request({url:"dataSources:get/".concat(t.key),params:{appends:["collections"]}})];case 1:return[2,e.sent().data.data]}})},function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function c(e){o(a,r,i,c,u,"next",e)}function u(e){o(a,r,i,c,u,"throw",e)}c(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(r.DataSource)},551:function(e,t,n){"use strict";n.d(t,{A7:function(){return i},EL:function(){return c},KQ:function(){return a}});var r=n(772),o=n(238),i="data-source-manager";function a(e){var t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r.i18n.t(e,(t=function(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}({},o),n=n={ns:i},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}function c(){return(0,o.useTranslation)([i,"client"],{nsMode:"fallback"})}},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=d},948:function(e){"use strict";e.exports=s},964:function(e){"use strict";e.exports=r},632:function(e){"use strict";e.exports=t},563:function(t){"use strict";t.exports=e},505:function(e){"use strict";e.exports=f},229:function(e){"use strict";e.exports=l},875:function(e){"use strict";e.exports=a},772:function(e){"use strict";e.exports=c},465:function(e){"use strict";e.exports=i},584:function(e){"use strict";e.exports=p},721:function(e){"use strict";e.exports=b},933:function(e){"use strict";e.exports=y},467:function(e){"use strict";e.exports=o},156:function(e){"use strict";e.exports=n},238:function(e){"use strict";e.exports=m},128:function(e){"use strict";e.exports=u}},S={};function x(e){var t=S[e];if(void 0!==t)return t.exports;var n=S[e]={exports:{}};return P[e](n,n.exports,x),n.exports}return x.m=P,x.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return x.d(t,{a:t}),t},x.d=function(e,t){for(var n in t)x.o(t,n)&&!x.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},x.f={},x.e=function(e){return Promise.all(Object.keys(x.f).reduce(function(t,n){return x.f[n](e,t),t},[]))},x.u=function(e){return""+({10:"a279f7ca19e59f87",236:"fdae18574fda07af",296:"e7a513a5b431455b",398:"8a2abe0ad7b0a9d2",65:"2695e7fbad1ec078",674:"276bcf3de74bebd1",746:"1a8cce8035a89dd9",843:"dbf5ddf434ab29c0"})[e]+".js"},x.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),x.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},g={},h="@nocobase/plugin-data-source-manager:",x.l=function(e,t,n,r){if(g[e])return void g[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var u=a[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==h+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,x.nc&&o.setAttribute("nonce",x.nc),o.setAttribute("data-webpack",h+n),o.src=e),g[e]=[t];var s=function(t,n){o.onerror=o.onload=null,clearTimeout(l);var r=g[e];if(delete g[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},l=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),i&&document.head.appendChild(o)},x.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(v=window.__nocobase_public_path__||"/").endsWith("/")||(v+="/"),x.p=v+"static/plugins/@nocobase/plugin-data-source-manager/dist/client/",_={909:0},x.f.j=function(e,t){var n=x.o(_,e)?_[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=_[e]=[t,r]});t.push(n[2]=r);var o=x.p+x.u(e),i=Error();x.l(o,function(t){if(x.o(_,e)&&(0!==(n=_[e])&&(_[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},w=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==_[e]})){for(n in i)x.o(i,n)&&(x.m[n]=i[n]);a&&a(x)}for(e&&e(t);c<o.length;c++)r=o[c],x.o(_,r)&&_[r]&&_[r][0](),_[r]=0},(O=self.webpackChunk_nocobase_plugin_data_source_manager=self.webpackChunk_nocobase_plugin_data_source_manager||[]).forEach(w.bind(null,0)),O.push=w.bind(null,O.push.bind(O)),x(329)}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.0.0-alpha.
|
|
11
|
+
"@nocobase/client": "2.0.0-alpha.23",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/plugin-acl": "2.0.0-alpha.
|
|
14
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
15
|
-
"@nocobase/server": "2.0.0-alpha.
|
|
16
|
-
"@nocobase/data-source-manager": "2.0.0-alpha.
|
|
13
|
+
"@nocobase/plugin-acl": "2.0.0-alpha.23",
|
|
14
|
+
"@nocobase/utils": "2.0.0-alpha.23",
|
|
15
|
+
"@nocobase/server": "2.0.0-alpha.23",
|
|
16
|
+
"@nocobase/data-source-manager": "2.0.0-alpha.23",
|
|
17
17
|
"lodash": "4.17.21",
|
|
18
|
-
"@nocobase/acl": "2.0.0-alpha.
|
|
18
|
+
"@nocobase/acl": "2.0.0-alpha.23",
|
|
19
19
|
"@ant-design/icons": "5.6.1",
|
|
20
20
|
"antd": "5.24.2",
|
|
21
21
|
"react-router-dom": "6.30.1",
|
|
@@ -23,9 +23,10 @@ module.exports = {
|
|
|
23
23
|
"@formily/shared": "2.3.7",
|
|
24
24
|
"react-i18next": "11.18.6",
|
|
25
25
|
"@emotion/css": "11.13.0",
|
|
26
|
-
"@nocobase/
|
|
26
|
+
"@nocobase/actions": "2.0.0-alpha.23",
|
|
27
|
+
"@nocobase/database": "2.0.0-alpha.23",
|
|
27
28
|
"sequelize": "6.35.2",
|
|
28
|
-
"@nocobase/test": "2.0.0-alpha.
|
|
29
|
+
"@nocobase/test": "2.0.0-alpha.23",
|
|
29
30
|
"@formily/antd-v5": "1.2.3",
|
|
30
31
|
"@formily/core": "2.3.7",
|
|
31
32
|
"@formily/reactive": "2.3.7",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Field synchronization confirmation prompt": "Are you sure you want to synchronize fields from database? Depends on the number of tables and fields, This operation may take anywhere from a few seconds to several dozen seconds. If you only need to sync specific tables, please use the \"Configure Fields\" - \"Sync from database\" for those tables.",
|
|
3
|
+
"Load tables from database": "Load tables from database",
|
|
4
|
+
"Sync field changes from database": "Sync field changes from database",
|
|
5
|
+
"Available tables": "Available tables",
|
|
6
|
+
"Selected tables": "Selected tables"
|
|
7
|
+
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -30,11 +30,16 @@
|
|
|
30
30
|
"Reloading": "加载中",
|
|
31
31
|
"Data source synchronization in progress": "数据源同步中",
|
|
32
32
|
"Data source synchronization successful": "数据源同步成功",
|
|
33
|
-
"Filter target key":"筛选目标键",
|
|
33
|
+
"Filter target key": "筛选目标键",
|
|
34
34
|
"Select field": "选择字段",
|
|
35
35
|
"OK": "确定",
|
|
36
36
|
"Please select a field.": "请选择一个字段。",
|
|
37
37
|
"Are you sure you want to set the \"{{title}}\" field as a record unique key? This setting cannot be changed after it's been set.": "你确定将 “{{title}}” 字段设置为主键吗?设置成功后不可修改。",
|
|
38
38
|
"If a collection lacks a primary key, you must configure a unique record key to locate row records within a block, failure to configure this will prevent the creation of data blocks for the collection.": "当数据表没有主键时,你需要配置记录唯一标识符,用于在区块中定位行记录,不配置将无法创建该表的数据区块。",
|
|
39
|
-
"Filter data based on the specific field, with the requirement that the field value must be unique.": "根据特定的字段筛选数据,字段值必须具备唯一性。"
|
|
39
|
+
"Filter data based on the specific field, with the requirement that the field value must be unique.": "根据特定的字段筛选数据,字段值必须具备唯一性。",
|
|
40
|
+
"Field synchronization confirmation prompt": "确认要对所有数据表执行字段同步吗?取决于数据表和字段数量,可能会耗时几秒到几十秒。若只需同步个别表,请使用相应表的“配置字段” - “从数据库同步”进行操作。",
|
|
41
|
+
"Load tables from database": "从数据库加载表",
|
|
42
|
+
"Sync field changes from database": "从数据库同步字段变更",
|
|
43
|
+
"Available tables": "可选数据表",
|
|
44
|
+
"Selected tables": "已选数据表"
|
|
40
45
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Context, Next } from '@nocobase/actions';
|
|
10
|
+
declare const _default: {
|
|
11
|
+
"dataSources:listEnabled"(ctx: Context, next: Next): Promise<void>;
|
|
12
|
+
"dataSources:testConnection"(ctx: Context, next: Next): Promise<void>;
|
|
13
|
+
"dataSources:refresh"(ctx: Context, next: Next): Promise<void>;
|
|
14
|
+
"dataSources:readTables"(ctx: Context, next: Next): Promise<void>;
|
|
15
|
+
"dataSources:loadTables"(ctx: Context, next: Next): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var data_sources_exports = {};
|
|
28
|
+
__export(data_sources_exports, {
|
|
29
|
+
default: () => data_sources_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(data_sources_exports);
|
|
32
|
+
var import_utils = require("../utils");
|
|
33
|
+
const canRefreshStatus = ["loaded", "loading-failed", "reloading-failed"];
|
|
34
|
+
var data_sources_default = {
|
|
35
|
+
async ["dataSources:listEnabled"](ctx, next) {
|
|
36
|
+
const dataSources = await ctx.db.getRepository("dataSources").find({
|
|
37
|
+
filter: {
|
|
38
|
+
enabled: true,
|
|
39
|
+
"type.$ne": "main"
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
ctx.body = dataSources.map((dataSourceModel) => {
|
|
43
|
+
return (0, import_utils.mapDataSourceWithCollection)(ctx.app, dataSourceModel);
|
|
44
|
+
});
|
|
45
|
+
await next();
|
|
46
|
+
},
|
|
47
|
+
async ["dataSources:testConnection"](ctx, next) {
|
|
48
|
+
const { values } = ctx.action.params;
|
|
49
|
+
const { options, type } = values;
|
|
50
|
+
const klass = ctx.app.dataSourceManager.factory.getClass(type);
|
|
51
|
+
try {
|
|
52
|
+
await klass.testConnection(ctx.app.environment.renderJsonTemplate(options));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw new Error(`Test connection failed: ${error.message}`);
|
|
55
|
+
}
|
|
56
|
+
ctx.body = {
|
|
57
|
+
success: true
|
|
58
|
+
};
|
|
59
|
+
await next();
|
|
60
|
+
},
|
|
61
|
+
async ["dataSources:refresh"](ctx, next) {
|
|
62
|
+
const plugin = ctx.app.pm.get("data-source-manager");
|
|
63
|
+
const { filterByTk, clientStatus } = ctx.action.params;
|
|
64
|
+
const dataSourceModel = await ctx.db.getRepository("dataSources").findOne({
|
|
65
|
+
filter: {
|
|
66
|
+
key: filterByTk
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const currentStatus = plugin.dataSourceStatus[filterByTk];
|
|
70
|
+
if (canRefreshStatus.includes(currentStatus) && (clientStatus ? clientStatus && canRefreshStatus.includes(clientStatus) : true)) {
|
|
71
|
+
dataSourceModel.loadIntoApplication({
|
|
72
|
+
app: ctx.app,
|
|
73
|
+
refresh: true
|
|
74
|
+
});
|
|
75
|
+
ctx.app.syncMessageManager.publish(plugin.name, {
|
|
76
|
+
type: "loadDataSource",
|
|
77
|
+
dataSourceKey: dataSourceModel.get("key")
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
ctx.body = {
|
|
81
|
+
status: plugin.dataSourceStatus[filterByTk]
|
|
82
|
+
};
|
|
83
|
+
await next();
|
|
84
|
+
},
|
|
85
|
+
async ["dataSources:readTables"](ctx, next) {
|
|
86
|
+
const { dataSourceKey, dbOptions } = ctx.action.params.values || {};
|
|
87
|
+
const dataSourceManager = ctx.app.dataSourceManager;
|
|
88
|
+
let dataSource;
|
|
89
|
+
if (dbOptions) {
|
|
90
|
+
dataSource = dataSourceManager.factory.create(dbOptions.type, {
|
|
91
|
+
name: dataSourceKey,
|
|
92
|
+
...dbOptions
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
dataSource = dataSourceManager.dataSources.get(dataSourceKey);
|
|
96
|
+
if (!dataSource) {
|
|
97
|
+
throw new Error(`dataSource ${dataSourceKey} not found`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const tables = await dataSource.readTables();
|
|
101
|
+
ctx.body = tables;
|
|
102
|
+
await next();
|
|
103
|
+
},
|
|
104
|
+
async ["dataSources:loadTables"](ctx, next) {
|
|
105
|
+
const { dataSourceKey, tables } = ctx.action.params.values || {};
|
|
106
|
+
const dataSourceManager = ctx.app.dataSourceManager;
|
|
107
|
+
const dataSource = dataSourceManager.dataSources.get(dataSourceKey);
|
|
108
|
+
if (!dataSource) {
|
|
109
|
+
throw new Error(`dataSource ${dataSourceKey} not found`);
|
|
110
|
+
}
|
|
111
|
+
await dataSource.loadTables(ctx, tables);
|
|
112
|
+
await next();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { Context, Next } from '@nocobase/actions';
|
|
10
|
+
export declare function loadDataSourceTablesIntoCollections(ctx: Context, next: Next): Promise<any>;
|
|
@@ -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 load_tables_exports = {};
|
|
28
|
+
__export(load_tables_exports, {
|
|
29
|
+
loadDataSourceTablesIntoCollections: () => loadDataSourceTablesIntoCollections
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(load_tables_exports);
|
|
32
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
33
|
+
var import_constants = require("../constants");
|
|
34
|
+
async function loadDataSourceTablesIntoCollections(ctx, next) {
|
|
35
|
+
const { actionName, resourceName, params } = ctx.action;
|
|
36
|
+
if (resourceName === "dataSources" && (actionName === "create" || actionName === "update")) {
|
|
37
|
+
const { options, type, collections, key } = params.values || {};
|
|
38
|
+
let dataSource;
|
|
39
|
+
if (actionName === "create") {
|
|
40
|
+
dataSource = ctx.app.dataSourceManager.factory.create(type, {
|
|
41
|
+
name: key,
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
44
|
+
dataSource.setLogger(ctx.logger);
|
|
45
|
+
} else {
|
|
46
|
+
const { filterByTk: dataSourceKey } = params;
|
|
47
|
+
dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
|
|
48
|
+
if (!dataSource) {
|
|
49
|
+
throw new Error(`dataSource ${dataSourceKey} not found`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!(dataSource instanceof import_data_source_manager.DatabaseDataSource)) {
|
|
53
|
+
return next();
|
|
54
|
+
}
|
|
55
|
+
if (options == null ? void 0 : options.addAllCollections) {
|
|
56
|
+
const allTables = await dataSource.introspector.getTables();
|
|
57
|
+
if (allTables.length > import_constants.ALLOW_MAX_COLLECTIONS_COUNT) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`The number of collections exceeds the limit of ${import_constants.ALLOW_MAX_COLLECTIONS_COUNT}. Please remove some collections before adding new ones.`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
await dataSource.loadTables(ctx, collections);
|
|
64
|
+
}
|
|
65
|
+
if (collections) {
|
|
66
|
+
delete ctx.action.params.values.collections;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
await next();
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
loadDataSourceTablesIntoCollections
|
|
74
|
+
});
|