plugin-block-cross-join 0.1.0
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/client.d.ts +1 -0
- package/client.js +1 -0
- package/dist/client/index.js +10 -0
- package/dist/externalVersion.js +18 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +23 -0
- package/dist/locale/zh-CN.json +23 -0
- package/dist/server/actions/cross-join-query.js +192 -0
- package/dist/server/index.js +42 -0
- package/dist/server/plugin.js +54 -0
- package/package.json +33 -0
- package/server.d.ts +1 -0
- package/server.js +1 -0
package/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/client';
|
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client');
|
|
@@ -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
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("plugin-block-cross-join",["react","@nocobase/client","@formily/react","@ant-design/icons","antd"],t):"object"==typeof exports?exports["plugin-block-cross-join"]=t(require("react"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("antd")):e["plugin-block-cross-join"]=t(e.react,e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o){return function(){"use strict";var a={482:function(e){e.exports=r},505:function(e){e.exports=n},772:function(e){e.exports=t},721:function(e){e.exports=o},156:function(t){t.exports=e}},i={};function l(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return a[e](n,n.exports,l),n.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){l.r(c),l.d(c,{PluginBlockCrossJoinClient:function(){return R},default:function(){return _}});var e=l(772),t=l(156),n=l.n(t),r=l(505);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(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 o(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 u=(0,t.createContext)(null),s=function(o){var l,c,s=o.children,f=(0,r.useFieldSchema)(),d=(0,e.useAPIClient)(),p=(null==f?void 0:f["x-decorator-props"])||{},m=p.config,y=(0,t.useMemo)(function(){return m},[JSON.stringify(m)]),b=i((0,t.useState)([]),2),v=b[0],g=b[1],h=i((0,t.useState)(!1),2),S=h[0],O=h[1],w=i((0,t.useState)(1),2),C=w[0],j=w[1],E=i((0,t.useState)((null==(c=p.params)?void 0:c.pageSize)||20),2),x=E[0],k=E[1],P=i((0,t.useState)(0),2),I=P[0],T=P[1],B=(0,t.useCallback)((l=function(){var e,t,n,r;return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)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 i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}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(o){switch(o.label){case 0:if(!(null==y||null==(e=y.primarySource)?void 0:e.collection))return[2];O(!0),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,d.request({url:"crossJoin:query",method:"post",data:{config:y,page:C,pageSize:x}})];case 2:return g((null==(r=null==(n=o.sent())?void 0:n.data)?void 0:r.data)||[]),T((null==r||null==(t=r.meta)?void 0:t.count)||0),[3,5];case 3:return console.error("CrossJoin query failed:",o.sent()),g([]),[3,5];case 4:return O(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=l.apply(e,t);function i(e){a(o,n,r,i,c,"next",e)}function c(e){a(o,n,r,i,c,"throw",e)}i(void 0)})}),[d,y,C,x]);return(0,t.useEffect)(function(){B()},[B]),n().createElement(u.Provider,{value:{data:v,loading:S,pagination:{page:C,pageSize:x,total:I},config:y,refresh:B,setPage:j,setPageSize:k}},s)},f=l(721);function d(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var p=function(){var e,r=(0,t.useContext)(u),o=(0,t.useMemo)(function(){if(!(null==r||null==(i=r.data)?void 0:i.length))return[];var e=r.config;if(null==e||null==(l=e.columns)?void 0:l.length){var t=[],n=!0,o=!1,a=void 0;try{for(var i,l,c,u=e.columns[Symbol.iterator]();!(n=(c=u.next()).done);n=!0){var s=c.value;if(null==(y=s.jsonExpand)?void 0:y.length){var f=!0,p=!1,m=void 0;try{for(var y,b,v=s.jsonExpand[Symbol.iterator]();!(f=(b=v.next()).done);f=!0){var g=b.value,h=s.alias?"".concat(s.alias,".").concat(g):"".concat(s.field,".").concat(g);t.push({title:h,dataIndex:h,key:h,ellipsis:!0,render:function(e){return null!=e?String(e):"-"}})}}catch(e){p=!0,m=e}finally{try{f||null==v.return||v.return()}finally{if(p)throw m}}}else{var S=s.alias||s.field;t.push({title:S,dataIndex:S,key:S,ellipsis:!0,render:function(e){return null==e?"-":(void 0===e?"undefined":d(e))==="object"?JSON.stringify(e):String(e)}})}}}catch(e){o=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return t}return Object.keys(r.data[0]).map(function(e){return{title:e,dataIndex:e,key:e,ellipsis:!0,render:function(t,n){var r=n[e];return null==r?"-":(void 0===r?"undefined":d(r))==="object"?JSON.stringify(r):String(r)}}})},[null==r?void 0:r.data,null==r?void 0:r.config]);return r?r.loading?n().createElement("div",{style:{textAlign:"center",padding:40}},n().createElement(f.Spin,null)):(null==(e=r.data)?void 0:e.length)?n().createElement(f.Table,{dataSource:r.data,columns:o,rowKey:function(e,t){return String(t)},size:"middle",scroll:{x:"max-content"},pagination:{current:r.pagination.page,pageSize:r.pagination.pageSize,total:r.pagination.total,showSizeChanger:!0,showTotal:function(e){return"Total ".concat(e," rows")},onChange:function(e,t){r.setPage(e),r.setPageSize(t)}}}):n().createElement(f.Empty,{description:"No data"}):null},m=l(482);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function b(e){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 v(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 g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(e,t)||S(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 h(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(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 S(e,t){if(e){if("string"==typeof e)return y(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 y(e,t)}}var O=f.Typography.Text;function w(){var n=(0,e.useDataSourceManager)(),r=(null==n?void 0:n.getDataSources())||[];return(0,t.useMemo)(function(){return r.filter(function(e){return"loaded"===e.status}).map(function(e){return{label:e.displayName||e.key,value:e.key,ds:e}})},[r])}function C(n){var r=(0,e.useDataSourceManager)();return(0,t.useMemo)(function(){if(!n||!r)return[];var e=r.getDataSource(n);return e?(e.collectionManager.getCollections()||[]).map(function(e){return{label:e.title||e.name,value:e.name}}):[]},[r,n])}function j(n,r){var o=(0,e.useDataSourceManager)();return(0,t.useMemo)(function(){if(!n||!r||!o)return[];var e=o.getDataSource(n);if(!e)return[];var t=e.collectionManager.getCollection(r);return t?(t.getFields()||[]).map(function(e){var t;return{label:(null==(t=e.uiSchema)?void 0:t.title)||e.name,value:e.name,type:e.type,interface:e.interface}}):[]},[o,n,r])}var E=function(e){var t=e.value,r=e.onChange,o=w(),a=C(t.dataSource);return n().createElement(f.Form,{layout:"vertical"},n().createElement(f.Form.Item,{label:"Datasource"},n().createElement(f.Select,{value:t.dataSource,options:o,placeholder:"Select datasource",onChange:function(e){return r({dataSource:e,collection:""})},showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})),n().createElement(f.Form.Item,{label:"Collection"},n().createElement(f.Select,{value:t.collection||void 0,options:a,placeholder:"Select collection",onChange:function(e){return r(v(b({},t),{collection:e}))},showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())},disabled:!t.dataSource})))},x=function(e){var t=e.join,r=e.index,o=e.primaryDs,a=e.primaryCollection,i=e.onChange,l=e.onRemove,c=w(),u=C(t.dataSource),s=j(o,a),d=j(t.dataSource,t.collection);return n().createElement("div",{style:{border:"1px solid #d9d9d9",borderRadius:6,padding:16,marginBottom:12}},n().createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:8}},n().createElement(O,{strong:!0},"Join #",r+1),n().createElement(f.Button,{type:"text",danger:!0,icon:n().createElement(m.DeleteOutlined,null),onClick:function(){return l(r)}})),n().createElement(f.Form,{layout:"vertical",size:"small"},n().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12}},n().createElement(f.Form.Item,{label:"Datasource",style:{marginBottom:8}},n().createElement(f.Select,{value:t.dataSource,options:c,onChange:function(e){return i(r,v(b({},t),{dataSource:e,collection:"",rightField:""}))},showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})),n().createElement(f.Form.Item,{label:"Collection",style:{marginBottom:8}},n().createElement(f.Select,{value:t.collection||void 0,options:u,onChange:function(e){return i(r,v(b({},t),{collection:e,rightField:""}))},disabled:!t.dataSource,showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}}))),n().createElement(f.Form.Item,{label:"Join Type",style:{marginBottom:8}},n().createElement(f.Radio.Group,{value:t.joinType,onChange:function(e){return i(r,v(b({},t),{joinType:e.target.value}))}},n().createElement(f.Radio,{value:"left"},"Left Join"),n().createElement(f.Radio,{value:"inner"},"Inner Join"))),n().createElement("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12}},n().createElement(f.Form.Item,{label:"Left Field (primary)",style:{marginBottom:0}},n().createElement(f.Select,{value:t.leftField||void 0,options:s,onChange:function(e){return i(r,v(b({},t),{leftField:e}))},placeholder:"Field from primary",showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})),n().createElement(f.Form.Item,{label:"Right Field (join)",style:{marginBottom:0}},n().createElement(f.Select,{value:t.rightField||void 0,options:d,onChange:function(e){return i(r,v(b({},t),{rightField:e}))},placeholder:"Field from join table",disabled:!t.collection,showSearch:!0,filterOption:function(e,t){var n;return null==t||null==(n=t.label)?void 0:n.toLowerCase().includes(e.toLowerCase())}})))))},k=function(e){var t=e.joins,r=e.primaryDs,o=e.primaryCollection,a=e.onChange,i=function(e,n){var r=h(t);r[e]=n,a(r)},l=function(e){a(t.filter(function(t,n){return n!==e}))};return n().createElement("div",null,t.map(function(e,t){return n().createElement(x,{key:t,join:e,index:t,primaryDs:r,primaryCollection:o,onChange:i,onRemove:l})}),n().createElement(f.Button,{type:"dashed",icon:n().createElement(m.PlusOutlined,null),onClick:function(){a(h(t).concat([{dataSource:"main",collection:"",joinType:"left",leftField:"",rightField:""}]))},block:!0},"Add Join"))},P=function(e){var r=e.columns,o=e.primaryDs,a=e.primaryCollection,i=(e.joins,e.onChange),l=j(o,a),c=(0,t.useMemo)(function(){var e=[],t=!0,n=!1,r=void 0;try{for(var o,i=l[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var c=o.value;e.push({source:0,sourceName:a,field:c.value,label:"".concat(a,".").concat(c.label),type:c.type})}}catch(e){n=!0,r=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw r}}return e},[l,a]),u=(0,t.useCallback)(function(){i(c.map(function(e){return{source:e.source,field:e.field,selected:!0}}))},[c,i]),s=[{title:"Include",dataIndex:"selected",width:70,render:function(e,t,o){return n().createElement(f.Checkbox,{checked:!1!==t.selected,onChange:function(e){var t=h(r);t[o]=v(b({},t[o]),{selected:e.target.checked}),i(t)}})}},{title:"Source",dataIndex:"source",width:100,render:function(e){return 0===e?"Primary":"Join #".concat(e)}},{title:"Field",dataIndex:"field",width:150},{title:"Alias",dataIndex:"alias",width:150,render:function(e,t,o){return n().createElement(f.Input,{size:"small",value:t.alias||"",placeholder:t.field,onChange:function(e){var t=h(r);t[o]=v(b({},t[o]),{alias:e.target.value||void 0}),i(t)}})}}];return n().createElement("div",null,n().createElement("div",{style:{marginBottom:12}},n().createElement(f.Button,{size:"small",onClick:u},"Auto-populate from sources")),r.length>0?n().createElement(f.Table,{dataSource:r,columns:s,rowKey:function(e,t){return String(t)},size:"small",pagination:!1,scroll:{y:300}}):n().createElement(O,{type:"secondary"},'Click "Auto-populate" to add fields from all configured sources, or they will be auto-detected at runtime.'))},I=function(e){var r=e.visible,o=e.onCancel,a=e.onSubmit,i=e.initialConfig,l=g((0,t.useState)((null==i?void 0:i.primarySource)||{dataSource:"main",collection:""}),2),c=l[0],u=l[1],s=g((0,t.useState)((null==i?void 0:i.joins)||[]),2),d=s[0],p=s[1],m=g((0,t.useState)((null==i?void 0:i.columns)||[]),2),y=m[0],b=m[1],v=c.dataSource&&c.collection;return n().createElement(f.Modal,{title:"Configure Cross Join",open:r,onCancel:o,onOk:function(){a({primarySource:c,joins:d,columns:y.filter(function(e){return!1!==e.selected}).map(function(e){return e.selected,function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(e,["selected"])})})},okButtonProps:{disabled:!v},width:720,destroyOnClose:!0},n().createElement(f.Tabs,{items:[{key:"primary",label:"Primary Source",children:n().createElement(E,{value:c,onChange:u})},{key:"joins",label:"Joins (".concat(d.length,")"),children:n().createElement(k,{joins:d,primaryDs:c.dataSource,primaryCollection:c.collection,onChange:p})},{key:"columns",label:"Columns",children:n().createElement(P,{columns:y,primaryDs:c.dataSource,primaryCollection:c.collection,joins:d,onChange:b})}]}))};function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var B=function(){var r,o,a,i=(0,e.useSchemaInitializer)().insert,l=(0,e.useSchemaInitializerItem)(),c=(r=(0,t.useState)(!1),function(e){if(Array.isArray(e))return e}(r)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),a.length!==t);i=!0);}catch(e){l=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw r}}return a}}(r,2)||function(e,t){if(e){if("string"==typeof e)return T(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return T(e,t)}}(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=c[0],s=c[1];return n().createElement(n().Fragment,null,n().createElement(e.SchemaInitializerItem,(o=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}({},l),a=a={icon:n().createElement(m.MergeCellsOutlined,null),onClick:function(){return s(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(a)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(a)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(a,e))}),o)),n().createElement(I,{visible:u,onCancel:function(){return s(!1)},onSubmit:function(e){i({type:"void","x-settings":"blockSettings:crossJoin","x-toolbar":"BlockSchemaToolbar","x-decorator":"CrossJoinBlockProvider","x-decorator-props":{config:e,params:{pageSize:20}},"x-component":"CardItem","x-component-props":{name:"crossJoin"},properties:{table:{type:"void","x-component":"CrossJoinTable"}}}),s(!1)}}))},J=new e.SchemaSettings({name:"blockSettings:crossJoin",items:[{name:"title",Component:e.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:e.SchemaSettingsBlockHeightItem},{name:"editMapping",type:"modal",useComponentProps:function(){return{title:"Edit Mapping"}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]});function A(e,t,n,r,o,a,i){try{var l=e[a](i),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function F(e,t,n){return(F=L()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&D(o,n.prototype),o}).apply(null,arguments)}function M(e){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function z(e){var t="function"==typeof Map?new Map:void 0;return(z=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 F(e,arguments,M(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),D(n,e)})(e)}function L(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(L=function(){return!!e})()}var q=function(t){var r=t.children;return n().createElement(e.SchemaComponentOptions,{components:{CrossJoinBlockProvider:s,CrossJoinTable:p,CrossJoinBlockInitializer:B}},r)},R=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=M(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,L()?Reflect.construct(e,t||[],M(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&D(n,e),t=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var c=[a,l];if(n)throw TypeError("Generator is already executing.");for(;i;)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 i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}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(e){return t.app.use(q),t.app.schemaSettingsManager.add(J),t.app.schemaInitializerManager.addItem("page:addBlock","otherBlocks.crossJoin",{title:'{{t("Cross Join")}}',Component:"CrossJoinBlockInitializer"}),t.app.schemaInitializerManager.addItem("popup:common:addBlock","otherBlocks.crossJoin",{title:'{{t("Cross Join")}}',Component:"CrossJoinBlockInitializer"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){A(a,r,o,i,l,"next",e)}function l(e){A(a,r,o,i,l,"throw",e)}i(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}(z(e.Plugin)),_=R}(),c}()});
|
|
@@ -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
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
"react": "18.2.0",
|
|
12
|
+
"@ant-design/icons": "5.6.1",
|
|
13
|
+
"@nocobase/client": "2.0.32",
|
|
14
|
+
"@formily/react": "2.3.7",
|
|
15
|
+
"antd": "5.24.2",
|
|
16
|
+
"@nocobase/server": "2.0.32",
|
|
17
|
+
"@nocobase/actions": "2.0.32"
|
|
18
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var src_exports = {};
|
|
39
|
+
__export(src_exports, {
|
|
40
|
+
default: () => import_server.default
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(src_exports);
|
|
43
|
+
__reExport(src_exports, require("./server"), module.exports);
|
|
44
|
+
var import_server = __toESM(require("./server"));
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
...require("./server")
|
|
48
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Cross Join": "Cross Join",
|
|
3
|
+
"Cross Join Block": "Cross Join Block",
|
|
4
|
+
"Configure cross join": "Configure cross join",
|
|
5
|
+
"Primary Source": "Primary Source",
|
|
6
|
+
"Joins": "Joins",
|
|
7
|
+
"Columns": "Columns",
|
|
8
|
+
"Datasource": "Datasource",
|
|
9
|
+
"Collection": "Collection",
|
|
10
|
+
"Join Type": "Join Type",
|
|
11
|
+
"Left Join": "Left Join",
|
|
12
|
+
"Inner Join": "Inner Join",
|
|
13
|
+
"Left Field": "Left Field",
|
|
14
|
+
"Right Field": "Right Field",
|
|
15
|
+
"Add Join": "Add Join",
|
|
16
|
+
"Field": "Field",
|
|
17
|
+
"Alias": "Alias",
|
|
18
|
+
"Source": "Source",
|
|
19
|
+
"Edit mapping": "Edit mapping",
|
|
20
|
+
"Expand JSON keys": "Expand JSON keys",
|
|
21
|
+
"No data": "No data",
|
|
22
|
+
"Loading...": "Loading..."
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Cross Join": "跨源联合",
|
|
3
|
+
"Cross Join Block": "跨源联合区块",
|
|
4
|
+
"Configure cross join": "配置跨源联合",
|
|
5
|
+
"Primary Source": "主数据源",
|
|
6
|
+
"Joins": "联合配置",
|
|
7
|
+
"Columns": "列配置",
|
|
8
|
+
"Datasource": "数据源",
|
|
9
|
+
"Collection": "数据表",
|
|
10
|
+
"Join Type": "联合类型",
|
|
11
|
+
"Left Join": "左联合",
|
|
12
|
+
"Inner Join": "内联合",
|
|
13
|
+
"Left Field": "左字段",
|
|
14
|
+
"Right Field": "右字段",
|
|
15
|
+
"Add Join": "添加联合",
|
|
16
|
+
"Field": "字段",
|
|
17
|
+
"Alias": "别名",
|
|
18
|
+
"Source": "来源",
|
|
19
|
+
"Edit mapping": "编辑映射",
|
|
20
|
+
"Expand JSON keys": "展开JSON键",
|
|
21
|
+
"No data": "暂无数据",
|
|
22
|
+
"Loading...": "加载中..."
|
|
23
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
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 cross_join_query_exports = {};
|
|
28
|
+
__export(cross_join_query_exports, {
|
|
29
|
+
crossJoinQuery: () => crossJoinQuery
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(cross_join_query_exports);
|
|
32
|
+
function toPlainObject(row) {
|
|
33
|
+
if (row && typeof row.toJSON === "function") {
|
|
34
|
+
return row.toJSON();
|
|
35
|
+
}
|
|
36
|
+
return row;
|
|
37
|
+
}
|
|
38
|
+
function buildJoinMap(rows, keyField) {
|
|
39
|
+
const map = /* @__PURE__ */ new Map();
|
|
40
|
+
for (const row of rows) {
|
|
41
|
+
const key = String(row[keyField] ?? "");
|
|
42
|
+
if (!map.has(key)) {
|
|
43
|
+
map.set(key, []);
|
|
44
|
+
}
|
|
45
|
+
map.get(key).push(row);
|
|
46
|
+
}
|
|
47
|
+
return map;
|
|
48
|
+
}
|
|
49
|
+
function prefixRow(row, prefix) {
|
|
50
|
+
const result = {};
|
|
51
|
+
for (const [k, v] of Object.entries(row)) {
|
|
52
|
+
result[`${prefix}.${k}`] = v;
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
function applyJoin(leftRows, rightRows, joinConfig, joinIndex) {
|
|
57
|
+
const rightMap = buildJoinMap(rightRows, joinConfig.rightField);
|
|
58
|
+
const rightPrefix = `join${joinIndex}`;
|
|
59
|
+
const result = [];
|
|
60
|
+
for (const leftRow of leftRows) {
|
|
61
|
+
const key = String(leftRow[`primary.${joinConfig.leftField}`] ?? leftRow[joinConfig.leftField] ?? "");
|
|
62
|
+
const matches = rightMap.get(key);
|
|
63
|
+
if (matches && matches.length > 0) {
|
|
64
|
+
for (const match of matches) {
|
|
65
|
+
result.push({ ...leftRow, ...prefixRow(match, rightPrefix) });
|
|
66
|
+
}
|
|
67
|
+
} else if (joinConfig.joinType === "left") {
|
|
68
|
+
result.push({ ...leftRow });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
function applyColumnMapping(rows, columns) {
|
|
74
|
+
return rows.map((row) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const mapped = {};
|
|
77
|
+
for (const col of columns) {
|
|
78
|
+
const prefix = col.source === 0 ? "primary" : `join${col.source - 1}`;
|
|
79
|
+
const fullKey = `${prefix}.${col.field}`;
|
|
80
|
+
const value = row[fullKey];
|
|
81
|
+
if (((_a = col.jsonExpand) == null ? void 0 : _a.length) && value != null) {
|
|
82
|
+
try {
|
|
83
|
+
const parsed = typeof value === "string" ? JSON.parse(value) : value;
|
|
84
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
85
|
+
for (const jsonKey of col.jsonExpand) {
|
|
86
|
+
const alias = col.alias ? `${col.alias}.${jsonKey}` : `${col.field}.${jsonKey}`;
|
|
87
|
+
mapped[alias] = parsed[jsonKey] ?? null;
|
|
88
|
+
}
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const outputKey = col.alias || col.field;
|
|
95
|
+
mapped[outputKey] = value ?? null;
|
|
96
|
+
}
|
|
97
|
+
return mapped;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async function crossJoinQuery(ctx, next) {
|
|
101
|
+
const { config, page = 1, pageSize = 20, sort } = ctx.action.params.values || ctx.action.params;
|
|
102
|
+
if (!(config == null ? void 0 : config.primarySource)) {
|
|
103
|
+
ctx.throw(400, "Missing primarySource in config");
|
|
104
|
+
}
|
|
105
|
+
const dsManager = ctx.app.dataSourceManager;
|
|
106
|
+
const { primarySource, joins = [], columns = [] } = config;
|
|
107
|
+
const primaryDS = dsManager.get(primarySource.dataSource);
|
|
108
|
+
if (!primaryDS) {
|
|
109
|
+
ctx.throw(400, `Datasource "${primarySource.dataSource}" not found`);
|
|
110
|
+
}
|
|
111
|
+
const primaryRepo = primaryDS.collectionManager.getRepository(primarySource.collection);
|
|
112
|
+
if (!primaryRepo) {
|
|
113
|
+
ctx.throw(400, `Collection "${primarySource.collection}" not found in datasource "${primarySource.dataSource}"`);
|
|
114
|
+
}
|
|
115
|
+
const hasInnerJoin = joins.some((j) => j.joinType === "inner");
|
|
116
|
+
let primaryRows;
|
|
117
|
+
let totalPrimaryCount;
|
|
118
|
+
if (hasInnerJoin) {
|
|
119
|
+
const MAX_ROWS = 1e4;
|
|
120
|
+
const rawRows = await primaryRepo.find({
|
|
121
|
+
filter: primarySource.filter || {},
|
|
122
|
+
sort: sort || config.defaultSort,
|
|
123
|
+
limit: MAX_ROWS
|
|
124
|
+
});
|
|
125
|
+
primaryRows = rawRows.map(toPlainObject);
|
|
126
|
+
totalPrimaryCount = primaryRows.length;
|
|
127
|
+
} else {
|
|
128
|
+
const [rawRows, count] = await Promise.all([
|
|
129
|
+
primaryRepo.find({
|
|
130
|
+
filter: primarySource.filter || {},
|
|
131
|
+
sort: sort || config.defaultSort,
|
|
132
|
+
limit: Number(pageSize),
|
|
133
|
+
offset: (Number(page) - 1) * Number(pageSize)
|
|
134
|
+
}),
|
|
135
|
+
primaryRepo.count({
|
|
136
|
+
filter: primarySource.filter || {}
|
|
137
|
+
})
|
|
138
|
+
]);
|
|
139
|
+
primaryRows = rawRows.map(toPlainObject);
|
|
140
|
+
totalPrimaryCount = Number(count);
|
|
141
|
+
}
|
|
142
|
+
let joinedRows = primaryRows.map((row) => prefixRow(row, "primary"));
|
|
143
|
+
for (let i = 0; i < joins.length; i++) {
|
|
144
|
+
const joinDef = joins[i];
|
|
145
|
+
const joinDS = dsManager.get(joinDef.dataSource);
|
|
146
|
+
if (!joinDS) {
|
|
147
|
+
ctx.throw(400, `Datasource "${joinDef.dataSource}" not found`);
|
|
148
|
+
}
|
|
149
|
+
const joinRepo = joinDS.collectionManager.getRepository(joinDef.collection);
|
|
150
|
+
if (!joinRepo) {
|
|
151
|
+
ctx.throw(400, `Collection "${joinDef.collection}" not found in datasource "${joinDef.dataSource}"`);
|
|
152
|
+
}
|
|
153
|
+
const leftKeyPath = `primary.${joinDef.leftField}`;
|
|
154
|
+
const distinctKeys = [...new Set(joinedRows.map((r) => r[leftKeyPath]).filter((v) => v != null))];
|
|
155
|
+
if (distinctKeys.length === 0) {
|
|
156
|
+
joinedRows = joinDef.joinType === "left" ? joinedRows : [];
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const joinRawRows = await joinRepo.find({
|
|
160
|
+
filter: {
|
|
161
|
+
[joinDef.rightField]: { $in: distinctKeys.map(String) }
|
|
162
|
+
},
|
|
163
|
+
limit: 1e4
|
|
164
|
+
});
|
|
165
|
+
const joinRows = joinRawRows.map(toPlainObject);
|
|
166
|
+
joinedRows = applyJoin(joinedRows, joinRows, joinDef, i);
|
|
167
|
+
}
|
|
168
|
+
let totalCount;
|
|
169
|
+
let paginatedRows;
|
|
170
|
+
if (hasInnerJoin) {
|
|
171
|
+
totalCount = joinedRows.length;
|
|
172
|
+
const start = (Number(page) - 1) * Number(pageSize);
|
|
173
|
+
paginatedRows = joinedRows.slice(start, start + Number(pageSize));
|
|
174
|
+
} else {
|
|
175
|
+
totalCount = totalPrimaryCount;
|
|
176
|
+
paginatedRows = joinedRows;
|
|
177
|
+
}
|
|
178
|
+
const finalRows = columns.length > 0 ? applyColumnMapping(paginatedRows, columns) : paginatedRows;
|
|
179
|
+
ctx.body = {
|
|
180
|
+
data: finalRows,
|
|
181
|
+
meta: {
|
|
182
|
+
page: Number(page),
|
|
183
|
+
pageSize: Number(pageSize),
|
|
184
|
+
count: totalCount
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
await next();
|
|
188
|
+
}
|
|
189
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
+
0 && (module.exports = {
|
|
191
|
+
crossJoinQuery
|
|
192
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var server_exports = {};
|
|
38
|
+
__export(server_exports, {
|
|
39
|
+
default: () => import_plugin.default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(server_exports);
|
|
42
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -0,0 +1,54 @@
|
|
|
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 plugin_exports = {};
|
|
28
|
+
__export(plugin_exports, {
|
|
29
|
+
PluginBlockCrossJoinServer: () => PluginBlockCrossJoinServer,
|
|
30
|
+
default: () => plugin_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
33
|
+
var import_server = require("@nocobase/server");
|
|
34
|
+
var import_cross_join_query = require("./actions/cross-join-query");
|
|
35
|
+
class PluginBlockCrossJoinServer extends import_server.Plugin {
|
|
36
|
+
async load() {
|
|
37
|
+
this.app.resourcer.define({
|
|
38
|
+
name: "crossJoin",
|
|
39
|
+
actions: {
|
|
40
|
+
query: import_cross_join_query.crossJoinQuery
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
this.app.acl.allow("crossJoin", "query", "loggedIn");
|
|
44
|
+
this.app.acl.registerSnippet({
|
|
45
|
+
name: "ui.crossJoin",
|
|
46
|
+
actions: ["crossJoin:*"]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var plugin_default = PluginBlockCrossJoinServer;
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
PluginBlockCrossJoinServer
|
|
54
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "plugin-block-cross-join",
|
|
3
|
+
"displayName": "Block: Cross Join",
|
|
4
|
+
"displayName.zh-CN": "区块:跨数据源联合查询",
|
|
5
|
+
"description": "Create a block that joins and displays data from multiple collections across different datasources in a single unified table.",
|
|
6
|
+
"description.zh-CN": "创建一个区块,可以跨不同数据源联合查询多个表的数据,并在单一表格中展示。",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"main": "./dist/server/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"client.js",
|
|
13
|
+
"client.d.ts",
|
|
14
|
+
"server.js",
|
|
15
|
+
"server.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@ant-design/icons": "5.x",
|
|
19
|
+
"@formily/react": "2.x",
|
|
20
|
+
"@formily/shared": "2.x",
|
|
21
|
+
"antd": "5.x",
|
|
22
|
+
"react": "^18.2.0",
|
|
23
|
+
"react-i18next": "^11.15.1"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@nocobase/client": "2.x",
|
|
27
|
+
"@nocobase/server": "2.x",
|
|
28
|
+
"@nocobase/data-source-manager": "2.x"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"Blocks"
|
|
32
|
+
]
|
|
33
|
+
}
|
package/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/server';
|
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/server');
|