@tachybase/module-data-source 1.5.1 → 1.6.1

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.
@@ -35,7 +35,7 @@
35
35
  justify-content: flex-end;
36
36
  display: flex;
37
37
  margin-bottom: 16px;
38
- `,children:[c.jsx(s.Action,I({},O)),c.jsx(s.SyncFieldsAction,I({},j)),c.jsx(s.SyncSQLFieldsAction,{refreshCMList:F}),c.jsx(s.SchemaComponent,{schema:{type:"object",properties:I({},w.configureActions)}}),c.jsx(s.AddCollectionField,I({},A))]}),c.jsx(T.Table,{rowKey:"key",columns:x,dataSource:S.filter(P=>P.fields.length),pagination:!1,className:Ul,expandable:{defaultExpandAllRows:!0,defaultExpandedRowKeys:S.map(P=>P.key),expandedRowRender:P=>P.inherit?c.jsx(Hl,{fields:P.fields,collectionResource:b,refreshAsync:F}):c.jsx(zl,{fields:P.fields,collectionResource:b,refreshAsync:F})}})]})})}))};var De={exports:{}},Wl=De.exports,Rs;function Jl(){return Rs||(Rs=1,function(e,t){(function(r,o){o()})(Wl,function(){function r(u,m){return typeof m=="undefined"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function o(u,m,d){var h=new XMLHttpRequest;h.open("GET",u),h.responseType="blob",h.onload=function(){p(h.response,m,d)},h.onerror=function(){console.error("could not download file")},h.send()}function n(u){var m=new XMLHttpRequest;m.open("HEAD",u,!1);try{m.send()}catch(d){}return 200<=m.status&&299>=m.status}function a(u){try{u.dispatchEvent(new MouseEvent("click"))}catch(d){var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(m)}}var i=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof te=="object"&&te.global===te?te:void 0,l=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=i.saveAs||(typeof window!="object"||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(u,m,d){var h=i.URL||i.webkitURL,b=document.createElement("a");m=m||u.name||"download",b.download=m,b.rel="noopener",typeof u=="string"?(b.href=u,b.origin===location.origin?a(b):n(b.href)?o(u,m,d):a(b,b.target="_blank")):(b.href=h.createObjectURL(u),setTimeout(function(){h.revokeObjectURL(b.href)},4e4),setTimeout(function(){a(b)},0))}:"msSaveOrOpenBlob"in navigator?function(u,m,d){if(m=m||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(r(u,d),m);else if(n(u))o(u,m,d);else{var h=document.createElement("a");h.href=u,h.target="_blank",setTimeout(function(){a(h)})}}:function(u,m,d,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof u=="string")return o(u,m,d);var b=u.type==="application/octet-stream",F=/constructor/i.test(i.HTMLElement)||i.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||b&&F||l)&&typeof FileReader!="undefined"){var v=new FileReader;v.onloadend=function(){var y=v.result;y=w?y:y.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=y:location=y,h=null},v.readAsDataURL(u)}else{var x=i.URL||i.webkitURL,f=x.createObjectURL(u);h?h.location=f:location.href=f,h=null,setTimeout(function(){x.revokeObjectURL(f)},4e4)}});i.saveAs=p.saveAs=p,e.exports=p})}(De)),De.exports}var Ql=Jl();const Gs=e=>C.Schema.compile(e,{t:s.i18n.t}),Zl={type:"object",properties:{block1:{type:"void","x-collection":"collections","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"collections",filterTargetKey:"name",targetKey:"name",sortable:!0,fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{ t("Collection display name") }}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{ t("Collection name") }}',type:"string","x-component":"Input",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'}},{type:"string",name:"template",interface:"input",uiSchema:{title:'{{ t("Collection Template") }}',type:"string","x-component":"Input"}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}},{type:"hasMany",name:"inherits",interface:"select",uiSchema:{title:'{{ t("Inherits") }}',type:"string","x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"input",uiSchema:{title:'{{ t("Description") }}',type:"string","x-component":"Input"}}]},dragSort:!0,request:{resource:"collections",action:"list",params:{pageSize:50,sort:"sort",filter:{"hidden.$isFalsy":!0},appends:["category"]}}},properties:{tabs:{type:"void","x-component":"ConfigurationTabs"}}}}},Us={type:"object",properties:{[C.uid()]:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button",isBulk:!0}},create:{type:"void",title:'{{ t("Create collection") }}',"x-component":"AddCollection","x-component-props":{type:"primary"}}}},[C.uid()]:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const e=s.useAPIClient(),{t}=$.useTranslation();return{move(o,n){return M(this,null,function*(){yield e.resource("collections").move({sourceId:o.key,targetId:n.key}),T.message.success(t("Saved successfully"),.2)})}}}},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{"x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Collection template")}}',properties:{template:{"x-component":s.CollectionTemplateTag,"x-read-pretty":!0}}},column4:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column","x-visible":"categoryVisible",title:'{{t("Collection category")}}',properties:{category:{"x-component":s.CollectionCategory,"x-read-pretty":!0}}},column5:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{"x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},column6:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{ t("Configure fields") }}',"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{destroyOnClose:!0,width:"70%"},"x-reactions":e=>{const t=e.path.segments[1],r=e.path.segments[0],o=e.form.getValuesIn(`${r}.${t}`);o&&(e.title=`${Gs(o.title)} - ${Gs('{{ t("Configure fields") }}')}`)},properties:{collectionFieldSchema:{type:"void","x-component":"CollectionFields"}}}}},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"EditCollection","x-component-props":{role:"button","aria-label":'{{ "edit-button-" + $record.name }}',type:"primary"}},export:{type:"void",title:'{{ t("Export") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{resource:e,targetKey:t}=s.useResourceContext(),{[t]:r}=s.useRecord();return{run(){return M(this,null,function*(){const{data:n}=yield e.exportMeta({collectionName:r},{method:"get"}),a=new Blob([JSON.stringify(n.data,null,2)],{type:"application/json"});Ql.saveAs(a,`${r}.json`)})}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button","aria-label":'{{ "delete-button-" + $record.name }}',type:"primary",className:"tb-action-link"}}}}}}}}}},Xl={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateCategry }}",style:{marginLeft:"8px"}}}}}}}}},Yl={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},eu=(e,t)=>(r,o)=>{r.loading=!0,e(r,o,t).then(C.action.bound(n=>{r.dataSource=n,r.loading=!1})).catch(console.error)},tu=()=>{const[e,t]=g.useState([]);return[e,t]},ru=()=>{const e=s.useRecord(),t=C.useForm();return{run(){return M(this,null,function*(){var n,a,i;const o=(i=(a=(n=t.values)==null?void 0:n.children)==null?void 0:a.slice)==null?void 0:i.call(a);t.setValuesIn("children",o.filter(l=>l.name!==e.name))})}}},ou=()=>({run(){return M(this,null,function*(){})}}),nu=()=>{const e=s.useRecord(),{getCollectionFields:t}=s.useCollectionManager_deprecated();return e.__parent&&e.__parent.interface==="subTable"?g.useContext(s.DataSourceContext_deprecated).dataSource:t(e.collectionName||e.name)},au=e=>`${e||""}${C.uid()}`,su=()=>{const{t:e}=$.useTranslation(),{interfaces:t,getCollections:r,getCollection:o}=s.useCollectionManager_deprecated(),{data:{database:n}}=s.useCurrentAppInfo(),a=g.useContext(s.CollectionCategroriesContext),i=s.useAPIClient(),l=i.resource("dbViews"),p=s.useCompile(),u=s.useApp(),m=(v,x,f)=>M(null,null,function*(){var O;const{targetScope:y}=x,S=((O=v.props)==null?void 0:O.name)==="inherits";return r().filter(A=>{var q;if(f!=null&&f.includes(A.template)||A.autoCreate&&A.isThrough||S&&A.template==="view")return!1;const P=!(y!=null&&y.template)||y.template.includes(A.template),_=!(y!=null&&y[(q=v.props)==null?void 0:q.name])||y[v.props.name].includes(A.name);return P&&_}).map(A=>({label:p(A.title),value:A.name}))}),d=()=>M(null,null,function*(){return a.data.map(v=>({label:p(v.name),value:v.id}))}),h=()=>M(null,null,function*(){return l.list().then(({data:v})=>{var x;return(x=v==null?void 0:v.data)==null?void 0:x.map(f=>{const y=f.schema;return{label:y?`${y}.${p(f.name)}`:f.name,value:y?`${y}_${f.name}`:f.name}})})}),b=v=>M(null,null,function*(){const{name:x,fields:f}=v.form.values,{fields:y}=o(x)||{};return Promise.resolve({data:y||f}).then(({data:S})=>{var D;return(D=S.filter(O=>O.interface?!!u.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(O.interface).titleUsable:!1))==null?void 0:D.map(O=>{var A;return{label:p((A=O.uiSchema)==null?void 0:A.title)||O.name,value:O.name}})})}),F=()=>M(null,null,function*(){return i.resource("storages").list().then(({data:v})=>{var x;return(x=v==null?void 0:v.data)==null?void 0:x.map(f=>({label:e(p(f.title)),value:f.name}))})}),w=g.useContext(s.SchemaComponentContext);return c.jsx(s.SchemaComponentContext.Provider,{value:B(I({},w),{designable:!1}),children:c.jsx(s.SchemaComponent,{schema:Zl,components:{AddSubFieldAction:s.AddSubFieldAction,EditSubFieldAction:s.EditSubFieldAction,FieldSummary:s.FieldSummary,TemplateSummay:s.TemplateSummary,CollectionFieldsTable:hu,CollectionFields:Ls},scope:{loadFilterTargetKeys:b,useDestroySubField:ru,useBulkDestroySubField:ou,useSelectedRowKeys:tu,useAsyncDataSource:eu,loadCollections:m,loadCategories:d,loadDBViews:h,loadStorages:F,useCurrentFields:nu,useNewId:au,useCancelAction:s.useCancelAction,interfaces:t,enableInherits:(n==null?void 0:n.dialect)==="postgres",isPG:(n==null?void 0:n.dialect)==="postgres"}})})},iu=e=>{var t;return((t=e["x-component"])==null?void 0:t.endsWith(".Column"))>-1},cu={body:{row:e=>c.jsx("tr",I({},e)),cell:e=>c.jsx("td",B(I({},e),{className:s.cx(e.className,s.css`
38
+ `,children:[c.jsx(s.Action,I({},O)),c.jsx(s.SyncFieldsAction,I({},j)),c.jsx(s.SyncSQLFieldsAction,{refreshCMList:F}),c.jsx(s.SchemaComponent,{schema:{type:"object",properties:I({},w.configureActions)}}),c.jsx(s.AddCollectionField,I({},A))]}),c.jsx(T.Table,{rowKey:"key",columns:x,dataSource:S.filter(P=>P.fields.length),pagination:!1,className:Ul,expandable:{defaultExpandAllRows:!0,defaultExpandedRowKeys:S.map(P=>P.key),expandedRowRender:P=>P.inherit?c.jsx(Hl,{fields:P.fields,collectionResource:b,refreshAsync:F}):c.jsx(zl,{fields:P.fields,collectionResource:b,refreshAsync:F})}})]})})}))};var De={exports:{}},Wl=De.exports,Rs;function Jl(){return Rs||(Rs=1,function(e,t){(function(r,o){o()})(Wl,function(){function r(u,m){return typeof m=="undefined"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function o(u,m,d){var h=new XMLHttpRequest;h.open("GET",u),h.responseType="blob",h.onload=function(){p(h.response,m,d)},h.onerror=function(){console.error("could not download file")},h.send()}function n(u){var m=new XMLHttpRequest;m.open("HEAD",u,!1);try{m.send()}catch(d){}return 200<=m.status&&299>=m.status}function a(u){try{u.dispatchEvent(new MouseEvent("click"))}catch(d){var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(m)}}var i=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof te=="object"&&te.global===te?te:void 0,l=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=i.saveAs||(typeof window!="object"||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(u,m,d){var h=i.URL||i.webkitURL,b=document.createElement("a");m=m||u.name||"download",b.download=m,b.rel="noopener",typeof u=="string"?(b.href=u,b.origin===location.origin?a(b):n(b.href)?o(u,m,d):a(b,b.target="_blank")):(b.href=h.createObjectURL(u),setTimeout(function(){h.revokeObjectURL(b.href)},4e4),setTimeout(function(){a(b)},0))}:"msSaveOrOpenBlob"in navigator?function(u,m,d){if(m=m||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(r(u,d),m);else if(n(u))o(u,m,d);else{var h=document.createElement("a");h.href=u,h.target="_blank",setTimeout(function(){a(h)})}}:function(u,m,d,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof u=="string")return o(u,m,d);var b=u.type==="application/octet-stream",F=/constructor/i.test(i.HTMLElement)||i.safari,w=/CriOS\/[\d]+/.test(navigator.userAgent);if((w||b&&F||l)&&typeof FileReader!="undefined"){var v=new FileReader;v.onloadend=function(){var y=v.result;y=w?y:y.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=y:location=y,h=null},v.readAsDataURL(u)}else{var x=i.URL||i.webkitURL,f=x.createObjectURL(u);h?h.location=f:location.href=f,h=null,setTimeout(function(){x.revokeObjectURL(f)},4e4)}});i.saveAs=p.saveAs=p,e.exports=p})}(De)),De.exports}var Ql=Jl();const Gs=e=>C.Schema.compile(e,{t:s.i18n.t}),Zl={type:"object",properties:{block1:{type:"void","x-collection":"collections","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:{name:"collections",filterTargetKey:"name",targetKey:"name",sortable:!0,fields:[{type:"integer",name:"title",interface:"input",uiSchema:{title:'{{ t("Collection display name") }}',type:"number","x-component":"Input",required:!0}},{type:"string",name:"name",interface:"input",uiSchema:{title:'{{ t("Collection name") }}',type:"string","x-component":"Input",description:'{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'}},{type:"string",name:"template",interface:"input",uiSchema:{title:'{{ t("Collection Template") }}',type:"string","x-component":"Input"}},{type:"hasMany",name:"fields",target:"fields",collectionName:"collections",sourceKey:"name",targetKey:"name",uiSchema:{}},{type:"hasMany",name:"inherits",interface:"select",uiSchema:{title:'{{ t("Inherits") }}',type:"string","x-component":"Select","x-component-props":{mode:"multiple"}}},{type:"string",name:"description",interface:"input",uiSchema:{title:'{{ t("Description") }}',type:"string","x-component":"Input"}}]},dragSort:!0,request:{resource:"collections",action:"list",params:{pageSize:50,sort:"sort",filter:{"hidden.$isFalsy":!0},appends:["category"]}}},properties:{tabs:{type:"void","x-component":"ConfigurationTabs"}}}}},Us={type:"object",properties:{[C.uid()]:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}},{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"cm.useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button",isBulk:!0}},create:{type:"void",title:'{{ t("Create collection") }}',"x-component":"AddCollection","x-component-props":{type:"primary"}}}},[C.uid()]:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"name",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const e=s.useAPIClient(),{t}=$.useTranslation();return{move(o,n){return M(this,null,function*(){yield e.resource("collections").move({sourceId:o.key,targetId:n.key}),T.message.success(t("Saved successfully"),.2)})}}}},properties:{column1:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{"x-component":"CollectionField","x-component-props":{style:{minWidth:500}},"x-read-pretty":!0}}},column2:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{t("Collection template")}}',properties:{template:{"x-component":s.CollectionTemplateTag,"x-read-pretty":!0}}},column4:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column","x-visible":"categoryVisible",title:'{{t("Collection category")}}',properties:{category:{"x-component":s.CollectionCategory,"x-read-pretty":!0}}},column5:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{"x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},column6:{type:"void",title:'{{ t("Actions") }}',"x-component":"Table.Column","x-component-props":{fixed:"right"},properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{view:{type:"void",title:'{{ t("Configure fields") }}',"x-component":"Action.Link","x-component-props":{},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{destroyOnClose:!0,width:"70%"},"x-reactions":e=>{const t=e.path.segments[1],r=e.path.segments[0],o=e.form.getValuesIn(`${r}.${t}`);o&&(e.title=`${Gs(o.title)} - ${Gs('{{ t("Configure fields") }}')}`)},properties:{collectionFieldSchema:{type:"void","x-component":"CollectionFields"}}}}},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"EditCollection","x-component-props":{role:"button","aria-label":'{{ "edit-button-" + $record.name }}',type:"primary"}},export:{type:"void",title:'{{ t("Export") }}',"x-component":"Action.Link","x-component-props":{useAction(){const{resource:e,targetKey:t}=s.useResourceContext(),{[t]:r}=s.useRecord();return{run(){return M(this,null,function*(){const{data:n}=yield e.exportMeta({collectionName:r},{method:"get"}),a=new Blob([JSON.stringify(n.data,null,2)],{type:"application/json"});Ql.saveAs(a,`${r}.json`)})}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"DeleteCollection","x-component-props":{role:"button","aria-label":'{{ "delete-button-" + $record.name }}',type:"primary",className:"tb-action-link"}}}}}}}}}},Xl={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateCategry }}",style:{marginLeft:"8px"}}}}}}}}},Yl={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},eu=(e,t)=>(r,o)=>{r.loading=!0,e(r,o,t).then(C.action.bound(n=>{r.dataSource=n,r.loading=!1})).catch(console.error)},tu=()=>{const[e,t]=g.useState([]);return[e,t]},ru=()=>{const e=s.useRecord(),t=C.useForm();return{run(){return M(this,null,function*(){var n,a,i;const o=(i=(a=(n=t.values)==null?void 0:n.children)==null?void 0:a.slice)==null?void 0:i.call(a);t.setValuesIn("children",o.filter(l=>l.name!==e.name))})}}},ou=()=>({run(){return M(this,null,function*(){})}}),nu=()=>{const e=s.useRecord(),{getCollectionFields:t}=s.useCollectionManager_deprecated();return e.__parent&&e.__parent.interface==="subTable"?g.useContext(s.DataSourceContext_deprecated).dataSource:t(e.collectionName||e.name)},au=e=>`${e||""}${C.uid()}`,su=()=>{const{t:e}=$.useTranslation(),{interfaces:t,getCollections:r,getCollection:o}=s.useCollectionManager_deprecated(),{data:{database:n}}=s.useCurrentAppInfo(),a=g.useContext(s.CollectionCategroriesContext),i=s.useAPIClient(),l=i.resource("dbViews"),p=s.useCompile(),u=s.useApp(),m=(v,x,f)=>M(null,null,function*(){var O;const{targetScope:y}=x,S=((O=v.props)==null?void 0:O.name)==="inherits";return r().filter(A=>{var q;if(f!=null&&f.includes(A.template)||A.autoCreate&&A.isThrough||S&&A.template==="view")return!1;const P=!(y!=null&&y.template)||y.template.includes(A.template),_=!(y!=null&&y[(q=v.props)==null?void 0:q.name])||y[v.props.name].includes(A.name);return P&&_}).map(A=>({label:p(A.title),value:A.name}))}),d=()=>M(null,null,function*(){return a.data.map(v=>({label:p(v.name),value:v.id}))}),h=()=>M(null,null,function*(){return l.list().then(({data:v})=>{var x;return(x=v==null?void 0:v.data)==null?void 0:x.map(f=>{const y=f.schema;return{label:y?`${y}.${p(f.name)}`:f.name,value:y?`${y}_${f.name}`:f.name}})})}),b=v=>M(null,null,function*(){const{name:x,fields:f}=v.form.values,{fields:y}=o(x)||{};return Promise.resolve({data:y||f}).then(({data:S})=>{var D;return(D=S.filter(O=>O.interface?!!u.dataSourceManager.collectionFieldInterfaceManager.getFieldInterface(O.interface).titleUsable:!1))==null?void 0:D.map(O=>{var A;return{label:p((A=O.uiSchema)==null?void 0:A.title)||O.name,value:O.name}})})}),F=()=>M(null,null,function*(){return i.resource("storages").list().then(({data:v})=>{var x;return(x=v==null?void 0:v.data)==null?void 0:x.map(f=>({label:e(p(f.title)),value:f.name}))})}),w=g.useContext(s.SchemaComponentContext);return c.jsx(s.SchemaComponentContext.Provider,{value:B(I({},w),{designable:!1}),children:c.jsx(s.SchemaComponent,{schema:Zl,components:{AddSubFieldAction:s.AddSubFieldAction,EditSubFieldAction:s.EditSubFieldAction,FieldSummary:s.FieldSummary,TemplateSummay:s.TemplateSummary,CollectionFieldsTable:hu,CollectionFields:Ls},scope:{loadFilterTargetKeys:b,useDestroySubField:ru,useBulkDestroySubField:ou,useSelectedRowKeys:tu,useAsyncDataSource:eu,loadCollections:m,loadCategories:d,loadDBViews:h,loadStorages:F,useCurrentFields:nu,useNewId:au,useCancelAction:s.useCancelAction,interfaces:t,enableInherits:(n==null?void 0:n.dialect)==="postgres",isPG:(n==null?void 0:n.dialect)==="postgres"}})})},iu=e=>{var t;return((t=e["x-component"])==null?void 0:t.endsWith(".Column"))>-1},cu={body:{row:e=>c.jsx("tr",I({},e)),cell:e=>c.jsx("td",B(I({},e),{className:s.cx(e.className,s.css`
39
39
  max-width: 300px;
40
40
  overflow: hidden;
41
41
  text-overflow: ellipsis;
@@ -1,16 +1,16 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.5.1",
4
- "@tego/server": "1.3.52",
3
+ "@tachybase/client": "1.6.1",
4
+ "@tego/server": "1.6.0-alpha.9",
5
5
  "lodash": "4.17.21",
6
- "@ant-design/icons": "5.6.1",
6
+ "@ant-design/icons": "6.1.0",
7
7
  "antd": "5.22.5",
8
8
  "react-router-dom": "6.28.1",
9
- "@tachybase/schema": "1.3.52",
9
+ "@tachybase/schema": "1.6.0-alpha.9",
10
10
  "react-i18next": "16.2.1",
11
- "@tachybase/module-acl": "1.5.1",
11
+ "@tachybase/module-acl": "1.6.1",
12
12
  "sequelize": "6.37.5",
13
- "@tego/client": "1.3.52",
13
+ "@tego/client": "1.6.0-alpha.9",
14
14
  "@dnd-kit/core": "6.3.1",
15
15
  "ahooks": "3.9.0"
16
16
  };
File without changes
@@ -9,6 +9,5 @@ export declare class PluginDataSourceManagerServer extends Plugin {
9
9
  };
10
10
  renderJsonTemplate(template: any): any;
11
11
  beforeLoad(): Promise<void>;
12
- load(): Promise<void>;
13
12
  }
14
13
  export default PluginDataSourceManagerServer;
@@ -31,7 +31,6 @@ __export(plugin_exports, {
31
31
  default: () => plugin_default
32
32
  });
33
33
  module.exports = __toCommonJS(plugin_exports);
34
- var import_node_path = require("node:path");
35
34
  var import_server = require("@tego/server");
36
35
  var import_lodash = __toESM(require("lodash"));
37
36
  var import_connections_roles_resources = require("./models/connections-roles-resources");
@@ -235,7 +234,7 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
235
234
  },
236
235
  { tag: "dataSourcesget" }
237
236
  );
238
- this.app.actions({
237
+ this.app.resourcer.registerActions({
239
238
  async ["dataSources:listEnabled"](ctx, next) {
240
239
  const dataSources = await ctx.db.getRepository("dataSources").find({
241
240
  filter: {
@@ -251,7 +250,7 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
251
250
  async ["dataSources:testConnection"](ctx, next) {
252
251
  const { values } = ctx.action.params;
253
252
  const { options, type } = values;
254
- const klass = ctx.app.dataSourceManager.factory.getClass(type);
253
+ const klass = ctx.tego.dataSourceManager.factory.getClass(type);
255
254
  try {
256
255
  await klass.testConnection(this.renderJsonTemplate(options || {}));
257
256
  } catch (error) {
@@ -272,7 +271,7 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
272
271
  const currentStatus = plugin.dataSourceStatus[filterByTk];
273
272
  if (canRefreshStatus.includes(currentStatus) && (clientStatus ? clientStatus && canRefreshStatus.includes(clientStatus) : true)) {
274
273
  dataSourceModel.loadIntoApplication({
275
- app: ctx.app
274
+ app: ctx.tego
276
275
  });
277
276
  }
278
277
  ctx.body = {
@@ -480,9 +479,6 @@ class PluginDataSourceManagerServer extends import_server.Plugin {
480
479
  };
481
480
  });
482
481
  }
483
- async load() {
484
- await this.importCollections((0, import_node_path.resolve)(__dirname, "collections"));
485
- }
486
482
  }
487
483
  var plugin_default = PluginDataSourceManagerServer;
488
484
  // Annotate the CommonJS export names for ESM import in node:
@@ -37,7 +37,7 @@ var data_sources_collections_fields_default = {
37
37
  async list(ctx, next) {
38
38
  const { associatedIndex: collectionNameWithDataSourceKey } = ctx.action.params;
39
39
  const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
40
- const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
40
+ const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
41
41
  const collection = dataSource.collectionManager.getCollection(collectionName);
42
42
  const fields = collection.getFields();
43
43
  ctx.body = import_lodash.default.sortBy(
@@ -49,7 +49,7 @@ var data_sources_collections_fields_default = {
49
49
  async get(ctx, next) {
50
50
  const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name } = ctx.action.params;
51
51
  const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
52
- const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
52
+ const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
53
53
  const collection = dataSource.collectionManager.getCollection(collectionName);
54
54
  const field = collection.getField(name);
55
55
  ctx.body = field.options;
@@ -58,7 +58,7 @@ var data_sources_collections_fields_default = {
58
58
  async update(ctx, next) {
59
59
  const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name, values } = ctx.action.params;
60
60
  const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
61
- const mainDb = ctx.app.db;
61
+ const mainDb = ctx.tego.db;
62
62
  let fieldRecord = await mainDb.getRepository("dataSourcesFields").findOne({
63
63
  filter: {
64
64
  name,
@@ -85,14 +85,14 @@ var data_sources_collections_fields_default = {
85
85
  values
86
86
  });
87
87
  }
88
- const field = ctx.app.dataSourceManager.dataSources.get(dataSourceKey).collectionManager.getCollection(collectionName).getField(name);
88
+ const field = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey).collectionManager.getCollection(collectionName).getField(name);
89
89
  ctx.body = field.options;
90
90
  await next();
91
91
  },
92
92
  async create(ctx, next) {
93
93
  const { associatedIndex: collectionNameWithDataSourceKey, values } = ctx.action.params;
94
94
  const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
95
- const mainDb = ctx.app.db;
95
+ const mainDb = ctx.tego.db;
96
96
  const name = values.name;
97
97
  if (await mainDb.getRepository("dataSourcesFields").findOne({
98
98
  filter: {
@@ -118,7 +118,7 @@ var data_sources_collections_fields_default = {
118
118
  async destroy(ctx, next) {
119
119
  const { associatedIndex: collectionNameWithDataSourceKey, filterByTk: name } = ctx.action.params;
120
120
  const [dataSourceKey, collectionName] = collectionNameWithDataSourceKey.split(".");
121
- const mainDb = ctx.app.db;
121
+ const mainDb = ctx.tego.db;
122
122
  const fieldRecord = await mainDb.getRepository("dataSourcesFields").findOne({
123
123
  filter: {
124
124
  name,
@@ -38,7 +38,7 @@ var data_sources_collections_default = {
38
38
  var _a, _b;
39
39
  const params = ctx.action.params;
40
40
  const { associatedIndex: dataSourceKey } = params;
41
- const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
41
+ const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
42
42
  if (!dataSource) {
43
43
  throw new Error(`dataSource ${dataSourceKey} not found`);
44
44
  }
@@ -44,7 +44,7 @@ const rolesRemoteCollectionsResourcer = {
44
44
  const { page = 1, pageSize = 20 } = ctx.action.params;
45
45
  const { filter } = ctx.action.params;
46
46
  const { dataSourceKey } = filter;
47
- const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
47
+ const dataSource = ctx.tego.dataSourceManager.dataSources.get(dataSourceKey);
48
48
  const collectionRepository = new import_full_data_repository.FullDataRepository(dataSource.collectionManager.getCollections());
49
49
  const [collections] = await collectionRepository.findAndCount();
50
50
  const filterItem = import_lodash.default.get(filter, "$and");
@@ -52,7 +52,7 @@ const rolesRemoteCollectionsResourcer = {
52
52
  const filterByName = filterItem == null ? void 0 : filterItem.find((item) => item.name);
53
53
  const filterTitle = (_a = import_lodash.default.get(filterByTitle, "title.$includes")) == null ? void 0 : _a.toLowerCase();
54
54
  const filterName = (_b = import_lodash.default.get(filterByName, "name.$includes")) == null ? void 0 : _b.toLowerCase();
55
- const roleResources = await ctx.app.db.getRepository("dataSourcesRolesResources").find({
55
+ const roleResources = await ctx.tego.db.getRepository("dataSourcesRolesResources").find({
56
56
  filter: {
57
57
  roleName: role,
58
58
  dataSourceKey
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@tachybase/module-data-source",
3
3
  "displayName": "Data source manager",
4
- "version": "1.5.1",
4
+ "version": "1.6.1",
5
5
  "description": "Manage data sources, including the built-in Master database, external databases, APIs, etc.",
6
6
  "keywords": [
7
7
  "Data model tools"
8
8
  ],
9
9
  "main": "dist/server/index.js",
10
10
  "devDependencies": {
11
- "@ant-design/icons": "^5.6.1",
11
+ "@ant-design/icons": "^6.1.0",
12
12
  "@dnd-kit/core": "^6.3.1",
13
- "@tachybase/schema": "1.3.52",
14
- "@tachybase/test": "1.3.52",
15
- "@tego/client": "1.3.52",
16
- "@tego/server": "1.3.52",
13
+ "@tachybase/schema": "1.6.0-alpha.9",
14
+ "@tachybase/test": "1.6.0-alpha.9",
15
+ "@tego/client": "1.6.0-alpha.9",
16
+ "@tego/server": "1.6.0-alpha.9",
17
17
  "@types/lodash": "^4.17.20",
18
18
  "ahooks": "^3.9.0",
19
19
  "antd": "5.22.5",
@@ -22,8 +22,8 @@
22
22
  "react-i18next": "16.2.1",
23
23
  "react-router-dom": "6.28.1",
24
24
  "sequelize": "6.37.5",
25
- "@tachybase/client": "1.5.1",
26
- "@tachybase/module-acl": "1.5.1"
25
+ "@tachybase/client": "1.6.1",
26
+ "@tachybase/module-acl": "1.6.1"
27
27
  },
28
28
  "description.zh-CN": "管理数据源,包括内置的 Master 数据库,外部的数据库、API。",
29
29
  "displayName.zh-CN": "数据源管理",