@tachybase/module-data-source 1.5.1 → 1.6.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.
@@ -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,6 +1,6 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.5.1",
3
+ "@tachybase/client": "1.6.0",
4
4
  "@tego/server": "1.3.52",
5
5
  "lodash": "4.17.21",
6
6
  "@ant-design/icons": "5.6.1",
@@ -8,7 +8,7 @@ module.exports = {
8
8
  "react-router-dom": "6.28.1",
9
9
  "@tachybase/schema": "1.3.52",
10
10
  "react-i18next": "16.2.1",
11
- "@tachybase/module-acl": "1.5.1",
11
+ "@tachybase/module-acl": "1.6.0",
12
12
  "sequelize": "6.37.5",
13
13
  "@tego/client": "1.3.52",
14
14
  "@dnd-kit/core": "6.3.1",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-data-source",
3
3
  "displayName": "Data source manager",
4
- "version": "1.5.1",
4
+ "version": "1.6.0",
5
5
  "description": "Manage data sources, including the built-in Master database, external databases, APIs, etc.",
6
6
  "keywords": [
7
7
  "Data model tools"
@@ -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.0",
26
+ "@tachybase/module-acl": "1.6.0"
27
27
  },
28
28
  "description.zh-CN": "管理数据源,包括内置的 Master 数据库,外部的数据库、API。",
29
29
  "displayName.zh-CN": "数据源管理",