plugin-migration-manager 2.0.0 → 2.0.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.
@@ -1,10 +1 @@
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
1
  "use strict";(self.webpackChunkplugin_migration_manager=self.webpackChunkplugin_migration_manager||[]).push([["545"],{797:function(e,t,n){n.r(t),n.d(t,{MigrationPage:function(){return k}});var l=n(156),r=n.n(l),o=n(721),a=n(482),i=n(772);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,l=Array(t);n<t;n++)l[n]=e[n];return l}function u(e,t,n,l,r,o,a){try{var i=e[o](a),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(l,r)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(l,r){var o=e.apply(t,n);function a(e){u(o,l,r,a,i,"next",e)}function i(e){u(o,l,r,a,i,"throw",e)}a(void 0)})}}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},l=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(l=l.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),l.forEach(function(t){var l;l=n[t],t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l})}return e}function m(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 l=Object.getOwnPropertySymbols(e);n.push.apply(n,l)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,l,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){i=!0,l=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw l}}return o}}(e,t)||g(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 f(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return c(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 c(e,t)}}function h(e,t){var n,l,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){var c=[o,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,l&&(r=2&c[0]?l.return:c[0]?l.throw||((r=l.return)&&r.call(l),0):l.next)&&!(r=r.call(l,c[1])).done)return r;switch(l=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,l=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){a.label=c[1];break}if(6===c[0]&&a.label<r[1]){a.label=r[1],r=c;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(c);break}r[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],l=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var y=o.Typography.Title,v=o.Typography.Text,w=o.Input.Search;function E(e){var t,n,l;return null!=(l=null!=(n=null==e||null==(t=e.data)?void 0:t.data)?n:null==e?void 0:e.data)?l:e}function S(e){return e?e.replace(/\{\{t\("(.+?)"\)\}\}/g,"$1").replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}):""}var b=function(e){return new Promise(function(t){return setTimeout(t,e)})},k=function(){var e,t,n,c=(0,i.useAPIClient)(),u=p((0,l.useState)("export"),2),g=u[0],k=u[1],C=p((0,l.useState)({collections:[],workflows:[],uiSchemas:[]}),2),x=C[0],O=C[1],I=p((0,l.useState)([]),2),T=I[0],z=I[1],j=p((0,l.useState)([]),2),U=j[0],A=j[1],P=p((0,l.useState)([]),2),M=P[0],R=P[1],D=p((0,l.useState)(!1),2),L=D[0],N=D[1],W=p((0,l.useState)(!1),2),K=W[0],q=W[1],B=p((0,l.useState)(null),2),F=B[0],_=B[1],J=p((0,l.useState)(!1),2),G=J[0],V=J[1],$=p((0,l.useState)(""),2),H=$[0],Y=$[1],Q=p((0,l.useState)(""),2),X=Q[0],Z=Q[1],ee=p((0,l.useState)(""),2),et=ee[0],en=ee[1],el=p((0,l.useState)({current:1,pageSize:10}),2),er=el[0],eo=el[1],ea=p((0,l.useState)({current:1,pageSize:10}),2),ei=ea[0],ec=ea[1],eu=p((0,l.useState)({current:1,pageSize:10}),2),es=eu[0],ed=eu[1];(0,l.useEffect)(function(){var e=function(e){(L||K)&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),function(){return window.removeEventListener("beforeunload",e)}},[L,K]);var em=(0,i.useRequest)({url:"migration:list",method:"get"},{manual:!1,onSuccess:function(e){var t,n,l,r=E(e);O({collections:null!=(t=null==r?void 0:r.collections)?t:[],workflows:null!=(n=null==r?void 0:r.workflows)?n:[],uiSchemas:null!=(l=null==r?void 0:r.uiSchemas)?l:[]})},onError:function(){return O({collections:[],workflows:[],uiSchemas:[]})}}),ep=em.run,ef=em.loading,eg=(0,i.useRequest)({url:"migration:export",method:"post"},{manual:!0,onSuccess:function(e){var t,n,l,r,a,i,c,u,s=E(e);if(!((null==s||null==(t=s.collections)?void 0:t.length)>0||(null==s||null==(n=s.workflows)?void 0:n.length)>0||(null==s||null==(l=s.uiSchemas)?void 0:l.length)>0||(null==s||null==(r=s.desktopRoutes)?void 0:r.length)>0))return void o.message.warning("Export succeeded but no data.");var d=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),m=URL.createObjectURL(d),p=document.createElement("a");p.href=m,p.download="nocobase-migration-".concat(Date.now(),".json"),p.click(),URL.revokeObjectURL(m),o.message.success("Export successful! ".concat((null==(a=s.collections)?void 0:a.length)||0," collections, ").concat((null==(i=s.workflows)?void 0:i.length)||0," workflows, ").concat((null==(c=s.uiSchemas)?void 0:c.length)||0," UI schemas, ").concat((null==(u=s.desktopRoutes)?void 0:u.length)||0," routes"))},onError:function(e){return o.message.error("Export failed: ".concat(e.message))}}),eh=eg.run,ey=eg.loading,ev=(e=s(function(){var e,t,n=arguments;return h(this,function(l){switch(l.label){case 0:e=n.length>0&&void 0!==n[0]?n[0]:1e4,t=n.length>1&&void 0!==n[1]?n[1]:2e3,N(!0),l.label=1;case 1:return l.trys.push([1,,5,6]),[4,c.request({url:"app:restart",method:"post",timeout:6e4})];case 2:return l.sent(),[4,b(e)];case 3:return l.sent(),[4,b(t)];case 4:return l.sent(),[3,6];case 5:return N(!1),[7];case 6:return[2]}})}),function(){return e.apply(this,arguments)}),ew=(t=s(function(e){var t,n,l,r,o,a,i=arguments;return h(this,function(u){switch(u.label){case 0:t=i.length>1&&void 0!==i[1]?i[1]:15,n=i.length>2&&void 0!==i[2]?i[2]:1500,l=null,r=0,u.label=1;case 1:if(!(r<t))return[3,8];u.label=2;case 2:return u.trys.push([2,4,,7]),[4,c.request({url:"migration:apply",method:"post",data:{data:{collections:e}},headers:{"Content-Type":"application/json"},timeout:6e5})];case 3:return[2,E(u.sent())];case 4:if(l=o=u.sent(),!((null==o||null==(a=o.response)?void 0:a.status)===503||String((null==o?void 0:o.message)||"").includes("APP_COMMANDING")))return[3,6];return[4,b(n)];case 5:return u.sent(),[3,7];case 6:throw o;case 7:return r++,[3,1];case 8:throw l||Error("Apply failed after several attempts.")}})}),function(e){return t.apply(this,arguments)}),eE=(0,i.useRequest)(function(e){return c.request({url:"migration:import",method:"post",data:{data:e},headers:{"Content-Type":"application/json"},timeout:6e5})},{manual:!0,onSuccess:(n=s(function(e){var t,n,l,i,c,u,p,g,y,v,w,S,b,k,C,x,O,I,T,z,j;return h(this,function(U){return(O=(x=E(e)||{}).needsConfirmation,I=x.results,O)?(z=(null==I||null==(T=I.collections)?void 0:T.conflicts)||[],o.Modal.confirm({title:"Confirm Potentially Data-Altering Changes",icon:r().createElement(a.ExclamationCircleOutlined,null),width:760,okText:"Proceed & Override",cancelText:"Cancel",content:r().createElement("div",null,r().createElement(o.Alert,{type:"warning",showIcon:!0,message:"Conflicts were found on existing fields.",style:{marginBottom:12}}),r().createElement("div",{style:{maxHeight:360,overflow:"auto"}},r().createElement(o.Table,{size:"small",pagination:!1,rowKey:function(e){return"".concat(e.collection,".").concat(e.field)},dataSource:z,columns:[{title:"Collection",dataIndex:"collection"},{title:"Field",dataIndex:"field"},{title:"Current",render:function(e,t){return"type=".concat(t.current.type,", interface=").concat(t.current.interface,", unique=").concat(String(t.current.unique),", allowNull=").concat(String(t.current.allowNull),", pk=").concat(String(t.current.primaryKey))}},{title:"Incoming",render:function(e,t){return"type=".concat(t.incoming.type,", interface=").concat(t.incoming.interface,", unique=").concat(String(t.incoming.unique),", allowNull=").concat(String(t.incoming.allowNull),", pk=").concat(String(t.incoming.primaryKey))}}]}))),onOk:function(){F&&(V(!1),eS(m(d({},F),{options:{forceOverride:!0}})))}})):G&&F?(V(!1),eS(F)):(j=I||{},o.Modal.success({title:"Import Successful",content:r().createElement("div",null,r().createElement("p",null,"Collections: ",(null==(t=j.collections)?void 0:t.success)||0," succeeded, ",(null==(n=j.collections)?void 0:n.failed)||0," failed"),r().createElement("p",null,"Workflows: ",(null==(l=j.workflows)?void 0:l.success)||0," succeeded, ",(null==(i=j.workflows)?void 0:i.failed)||0," failed"),r().createElement("p",null,"UI Schemas: ",(null==(c=j.uiSchemas)?void 0:c.success)||0," succeeded, ",(null==(u=j.uiSchemas)?void 0:u.failed)||0," failed"),((null==(g=j.collections)||null==(p=g.errors)?void 0:p.length)>0||(null==(v=j.workflows)||null==(y=v.errors)?void 0:y.length)>0||(null==(S=j.uiSchemas)||null==(w=S.errors)?void 0:w.length)>0)&&r().createElement(o.Alert,{message:"Some errors occurred",description:r().createElement("ul",null,f((null==(b=j.collections)?void 0:b.errors)||[]).concat(f((null==(k=j.workflows)?void 0:k.errors)||[]),f((null==(C=j.uiSchemas)?void 0:C.errors)||[])).map(function(e,t){return r().createElement("li",{key:t},e.error||String(e))})),type:"warning",style:{marginTop:10}})),okText:"Continue",onOk:s(function(){var e,t,n,l,a;return h(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,4,5]),q(!0),[4,ev(12e3,2e3)];case 1:return i.sent(),[4,ew(((null==F?void 0:F.collections)||[]).map(function(e){return"string"==typeof e?{name:e}:e}),15,1500)];case 2:return l=i.sent(),o.Modal.success({title:"Apply Complete",content:r().createElement("div",null,r().createElement("p",null,"The changes have been successfully applied. Click ",r().createElement("strong",null,"Continue")," to refresh the page for the changes to take effect."),(null==l||null==(t=l.results)||null==(e=t.errors)?void 0:e.length)>0&&r().createElement(o.Alert,{type:"warning",message:"Errors occurred during apply",description:r().createElement("ul",{style:{marginBottom:0}},((null==l||null==(n=l.results)?void 0:n.errors)||[]).map(function(e,t){return r().createElement("li",{key:t},e.collection||e.route||e.schema||"item",": ",e.error)}))})),okText:"Continue",onOk:function(){window.location.reload()}}),[3,5];case 3:return a=i.sent(),o.message.error((null==a?void 0:a.message)||"Apply failed"),[3,5];case 4:return q(!1),_(null),ep(),[7];case 5:return[2]}})})}),ep()),[2]})}),function(e){return n.apply(this,arguments)}),onError:function(e){return o.message.error("Import failed: ".concat(e.message))}}),eS=eE.run,eb=eE.loading,ek=(0,l.useMemo)(function(){var e=H.trim().toLowerCase(),t=(x.collections||[]).filter(function(t){return(t.title||t.name||"").toLowerCase().includes(e)});return{total:t.length,data:t}},[x.collections,H]),eC=(0,l.useMemo)(function(){var e=(er.current-1)*er.pageSize;return ek.data.slice(e,e+er.pageSize)},[ek,er]),ex=(0,l.useMemo)(function(){var e=X.trim().toLowerCase(),t=(x.workflows||[]).filter(function(t){return(t.title||"").toLowerCase().includes(e)});return{total:t.length,data:t}},[x.workflows,X]),eO=(0,l.useMemo)(function(){var e=(ei.current-1)*ei.pageSize;return ex.data.slice(e,e+ei.pageSize)},[ex,ei]),eI=(0,l.useMemo)(function(){var e=et.trim().toLowerCase(),t=(x.uiSchemas||[]).filter(function(t){return(t.displayTitle||t.title||t.name||"").toLowerCase().includes(e)});return{total:t.length,data:t}},[x.uiSchemas,et]),eT=(0,l.useMemo)(function(){var e=(es.current-1)*es.pageSize;return eI.data.slice(e,e+es.pageSize)},[eI,es]);return r().createElement("div",{style:{padding:24,position:"relative"}},r().createElement(o.Card,null,r().createElement(y,{level:2},"Migration Manager"),r().createElement(v,{type:"secondary"},"Export and import collections, workflows, and UI schemas across NocoBase instances"),r().createElement(o.Tabs,{activeKey:g,onChange:k,items:[{label:"Export",key:"export",children:r().createElement(o.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement(o.Card,{title:r().createElement(o.Space,null,r().createElement(a.DatabaseOutlined,null),"Collections"),size:"small"},r().createElement("div",{style:{marginBottom:12}},r().createElement(w,{allowClear:!0,placeholder:"Filter by Title",onSearch:function(e){Y(e),eo(m(d({},er),{current:1}))},onChange:function(e){Y(e.target.value),eo(m(d({},er),{current:1}))},value:H,style:{maxWidth:320}})),r().createElement(o.Table,{rowSelection:{selectedRowKeys:T,onChange:function(e){return z(e)}},columns:[{title:"Name",dataIndex:"name",key:"name"},{title:"Title",dataIndex:"title",key:"title",render:S},{title:"Fields",dataIndex:"fields",key:"fields"}],dataSource:eC,rowKey:"name",loading:ef,pagination:{current:er.current,pageSize:er.pageSize,total:ek.total,showSizeChanger:!0,onChange:function(e,t){return eo({current:e,pageSize:t})}},size:"small"})),r().createElement(o.Card,{title:r().createElement(o.Space,null,r().createElement(a.BranchesOutlined,null),"Workflows"),size:"small"},r().createElement("div",{style:{marginBottom:12}},r().createElement(w,{allowClear:!0,placeholder:"Filter by Title",onSearch:function(e){Z(e),ec(m(d({},ei),{current:1}))},onChange:function(e){Z(e.target.value),ec(m(d({},ei),{current:1}))},value:X,style:{maxWidth:320}})),r().createElement(o.Table,{rowSelection:{selectedRowKeys:U,onChange:function(e){return A(e)}},columns:[{title:"Title",dataIndex:"title",key:"title"},{title:"Key",dataIndex:"key",key:"key"},{title:"Status",dataIndex:"enabled",key:"enabled",render:function(e){return e?"Enabled":"Disabled"}}],dataSource:eO,rowKey:"id",loading:ef,pagination:{current:ei.current,pageSize:ei.pageSize,total:ex.total,showSizeChanger:!0,onChange:function(e,t){return ec({current:e,pageSize:t})}},size:"small"})),r().createElement(o.Card,{title:r().createElement(o.Space,null,r().createElement(a.LayoutOutlined,null),"UI Schemas"),size:"small"},r().createElement("div",{style:{marginBottom:12}},r().createElement(w,{allowClear:!0,placeholder:"Filter by Title",onSearch:function(e){en(e),ed(m(d({},es),{current:1}))},onChange:function(e){en(e.target.value),ed(m(d({},es),{current:1}))},value:et,style:{maxWidth:320}})),r().createElement(o.Table,{rowSelection:{selectedRowKeys:M,onChange:function(e){return R(e)}},columns:[{title:"Menu / Page",dataIndex:"displayTitle",key:"displayTitle",render:function(e,t){return r().createElement(o.Space,null,r().createElement(v,null,(null==t?void 0:t.displayTitle)||(null==t?void 0:t.title)||(null==t?void 0:t.name)||"Untitled"),r().createElement(o.Tag,null,null==t?void 0:t.type))}},{title:"UID",dataIndex:"schemaUid",key:"schemaUid"}],dataSource:eT,rowKey:"schemaUid",loading:ef,pagination:{current:es.current,pageSize:es.pageSize,total:eI.total,showSizeChanger:!0,onChange:function(e,t){return ed({current:e,pageSize:t})}},size:"small"})),r().createElement(o.Button,{type:"primary",icon:r().createElement(a.DownloadOutlined,null),onClick:function(){if(!T.length&&!U.length&&!M.length)return void o.message.warning("Select at least one item to export");o.Modal.confirm({title:"Export Confirmation",icon:r().createElement(a.ExclamationCircleOutlined,null),content:r().createElement("div",null,r().createElement("p",null,"You will export:"),r().createElement("ul",null,r().createElement("li",null,T.length," Collections"),r().createElement("li",null,U.length," Workflows"),r().createElement("li",null,M.length," UI Schemas/Routes")),r().createElement(o.Alert,{message:"Note",description:"Export includes collection structure, workflow config, UI schema subtree, and desktop routes.",type:"info",style:{marginTop:10}})),onOk:function(){eh({data:{collections:T,workflows:U,uiSchemas:[],desktopRoutes:M}})}})},loading:ey,size:"large",disabled:L||K},"Export Selected Items"))},{label:"Import",key:"import",children:r().createElement(o.Space,{direction:"vertical",size:"large",style:{width:"100%"}},r().createElement(o.Alert,{message:"Import from Development to Production",description:r().createElement("div",null,r().createElement("p",null,"Upload the exported JSON file from the development server."),r().createElement("p",null,r().createElement("strong",null,"What will be imported:")),r().createElement("ul",null,r().createElement("li",null,"Collection structure (without data)"),r().createElement("li",null,"Workflow configuration"),r().createElement("li",null,"UI Schema/Page design")),r().createElement("p",null,r().createElement("strong",null,"What will NOT be affected:")),r().createElement("ul",null,r().createElement("li",null,"Data within collections"),r().createElement("li",null,"Collections not present in the import file"))),type:"info"}),r().createElement(o.Upload,{accept:".json",beforeUpload:function(e){var t=new FileReader;return t.onload=function(e){try{var t,n,l,i,c=JSON.parse(null==(t=e.target)?void 0:t.result);_(c),V(!0),o.Modal.confirm({title:"Import Confirmation",icon:r().createElement(a.ExclamationCircleOutlined,null),content:r().createElement("div",null,r().createElement("p",null,"The file will import:"),r().createElement("ul",null,r().createElement("li",null,(null==(n=c.collections)?void 0:n.length)||0," Collections"),r().createElement("li",null,(null==(l=c.workflows)?void 0:l.length)||0," Workflows"),r().createElement("li",null,(null==(i=c.uiSchemas)?void 0:i.length)||0," UI Schemas")),r().createElement(o.Alert,{message:"Warning",description:"The first step will run a PREVIEW. If safe, the process will proceed automatically.",type:"warning",style:{marginTop:10}})),onOk:function(){return eS(m(d({},c),{options:{preview:!0}}))}})}catch(e){o.message.error("Invalid or corrupt file")}},t.readAsText(e),!1},showUploadList:!1,disabled:L||K},r().createElement(o.Button,{type:"primary",icon:r().createElement(a.UploadOutlined,null),loading:eb,size:"large",disabled:L||K},"Upload Migration File (.json)")))}]})),(L||K)&&r().createElement("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(255,255,255,0.8)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999}},r().createElement(o.Spin,{size:"large",tip:L?"Restarting...":"Applying..."})))}}}]);
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@nocobase/client';
2
+ export declare class PluginMigrationManagerClient extends Plugin {
3
+ load(): Promise<void>;
4
+ }
5
+ export default PluginMigrationManagerClient;
@@ -1,10 +1 @@
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
1
  !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("plugin-migration-manager",["@nocobase/client","react","@nocobase/utils/client","@ant-design/icons","antd"],t):"object"==typeof exports?exports["plugin-migration-manager"]=t(require("@nocobase/client"),require("react"),require("@nocobase/utils/client"),require("@ant-design/icons"),require("antd")):e["plugin-migration-manager"]=t(e["@nocobase/client"],e.react,e["@nocobase/utils/client"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o){return function(){var i,u,a,c,l,f,s={581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=r},772:function(t){"use strict";t.exports=e},584:function(e){"use strict";e.exports=n},721:function(e){"use strict";e.exports=o},156:function(e){"use strict";e.exports=t}},p={};function d(e){var t=p[e];if(void 0!==t)return t.exports;var n=p[e]={exports:{}};return s[e](n,n.exports,d),n.exports}d.m=s,d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.f={},d.e=function(e){return Promise.all(Object.keys(d.f).reduce(function(t,n){return d.f[n](e,t),t},[]))},d.u=function(e){return"bf902aacdcc9b8b8.js"},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i={},u="plugin-migration-manager:",d.l=function(e,t,n,r){if(i[e])return void i[e].push(t);if(void 0!==n)for(var o,a,c=document.getElementsByTagName("script"),l=0;l<c.length;l++){var f=c[l];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==u+n){o=f;break}}o||(a=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,d.nc&&o.setAttribute("nonce",d.nc),o.setAttribute("data-webpack",u+n),o.src=e),i[e]=[t];var s=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=i[e];if(delete i[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),a&&document.head.appendChild(o)},d.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(a=window.__webpack_public_path__||"/").endsWith("/")||(a+="/"),d.p=a+"static/plugins/plugin-migration-manager/dist/client/",c={909:0},d.f.j=function(e,t){var n=d.o(c,e)?c[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=c[e]=[t,r]});t.push(n[2]=r);var o=d.p+d.u(e),i=Error();d.l(o,function(t){if(d.o(c,e)&&(0!==(n=c[e])&&(c[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},l=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],a=0;if(o.some(function(e){return 0!==c[e]})){for(n in i)d.o(i,n)&&(d.m[n]=i[n]);u&&u(d)}for(e&&e(t);a<o.length;a++)r=o[a],d.o(c,r)&&c[r]&&c[r][0](),c[r]=0},(f=self.webpackChunkplugin_migration_manager=self.webpackChunkplugin_migration_manager||[]).forEach(l.bind(null,0)),f.push=l.bind(null,f.push.bind(f));var b={};return!function(){"use strict";d.r(b),d.d(b,{PluginMigrationManagerClient:function(){return f}});var e=d(772),t=d(584),n=d(581);function r(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function o(e,t,n){return(o=c()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&u(o,n.prototype),o}).apply(null,arguments)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e){var t="function"==typeof Map?new Map:void 0;return(a=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 o(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}var l=(0,e.lazy)(function(){return n("imported_1rtsqtf_component",d.e("545").then(d.bind(d,797)))},"MigrationPage").MigrationPage,f=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,t;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return e=o,t=arguments,e=i(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,c()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&u(o,e),n=[{key:"load",value:function(){var e,n=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}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 n.app.pluginSettingsManager.add("migration-manager",{title:(0,t.tval)("Migration Manager"),icon:"SwapOutlined",Component:l,aclSnippet:"pm.migration.manager"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var u=e.apply(t,n);function a(e){r(u,o,i,a,c,"next",e)}function c(e){r(u,o,i,a,c,"throw",e)}a(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)}}(o.prototype,n),o}(a(e.Plugin));b.default=f}(),b}()});
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const MigrationPage: React.FC;
@@ -1,18 +1,9 @@
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
1
  module.exports = {
11
- "@nocobase/client": "2.0.11",
12
- "@nocobase/utils": "2.0.11",
13
- "@nocobase/server": "2.0.11",
2
+ "@nocobase/client": "2.0.32",
3
+ "@nocobase/utils": "2.0.32",
4
+ "@nocobase/server": "2.0.32",
14
5
  "react": "18.2.0",
15
6
  "antd": "5.24.2",
16
7
  "@ant-design/icons": "5.6.1",
17
- "@nocobase/actions": "2.0.11"
8
+ "@nocobase/actions": "2.0.32"
18
9
  };
@@ -0,0 +1,2 @@
1
+ export * from './server';
2
+ export { default } from './server';
package/dist/index.js CHANGED
@@ -1,12 +1,3 @@
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
1
  var __create = Object.create;
11
2
  var __defProp = Object.defineProperty;
12
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -0,0 +1,27 @@
1
+ import { Context } from '@nocobase/actions';
2
+ type Id = string | number;
3
+ export interface ExportBody {
4
+ collections?: string[];
5
+ workflows?: Id[];
6
+ uiSchemas?: string[];
7
+ }
8
+ export interface FieldRow {
9
+ name: string;
10
+ type?: string;
11
+ interface?: string;
12
+ options?: any;
13
+ }
14
+ export interface CollectionBundle {
15
+ name: string;
16
+ title?: string;
17
+ primaryKey?: string;
18
+ fields?: FieldRow[];
19
+ }
20
+ export declare class MigrationController {
21
+ static export(ctx: Context): Promise<void>;
22
+ static import(ctx: Context): Promise<void>;
23
+ static list(ctx: Context): Promise<void>;
24
+ static validate(ctx: Context): Promise<void>;
25
+ static apply(ctx: Context): Promise<void>;
26
+ }
27
+ export {};
@@ -1,12 +1,3 @@
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
1
  var __defProp = Object.defineProperty;
11
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -0,0 +1,12 @@
1
+ import { Plugin } from '@nocobase/server';
2
+ export declare const namespace: string;
3
+ export declare class PluginMigrationManagerServer extends Plugin {
4
+ afterAdd(): Promise<void>;
5
+ beforeLoad(): Promise<void>;
6
+ load(): Promise<void>;
7
+ install(): Promise<void>;
8
+ afterEnable(): Promise<void>;
9
+ afterDisable(): Promise<void>;
10
+ remove(): Promise<void>;
11
+ }
12
+ export default PluginMigrationManagerServer;
@@ -1,12 +1,3 @@
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
1
  var __defProp = Object.defineProperty;
11
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -51,7 +42,11 @@ class PluginMigrationManagerServer extends import_server.Plugin {
51
42
  apply: import_migration.MigrationController.apply
52
43
  }
53
44
  });
54
- this.app.acl.allow("migration", "*", "admin");
45
+ this.app.acl.allow("migration", "*", (ctx) => {
46
+ var _a;
47
+ const role = (_a = ctx.state) == null ? void 0 : _a.currentRole;
48
+ return role === "root" || role === "admin";
49
+ });
55
50
  }
56
51
  async install() {
57
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-migration-manager",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "displayName": "Migration Manager",
5
5
  "displayName.id-ID": "Migration Manager",
6
6
  "description": "Migrate collections, workflows, and UI schemas between Nocobase instances",
@@ -21,7 +21,10 @@ export class PluginMigrationManagerServer extends Plugin {
21
21
  },
22
22
  });
23
23
 
24
- this.app.acl.allow('migration', '*', 'admin');
24
+ this.app.acl.allow('migration', '*', (ctx) => {
25
+ const role = ctx.state?.currentRole;
26
+ return role === 'root' || role === 'admin';
27
+ });
25
28
  }
26
29
 
27
30
  async install() {}
Binary file