"use strict";(()=>{var e={};e.id=7317,e.ids=[7317],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},86254:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>S,routeModule:()=>f});var n={};t.r(n),t.d(n,{default:()=>c});var a=t(89947),s=t(2706),i=t(96762),o=t(29021),u=t.n(o),d=t(33873),l=t.n(d),_=t(69842);async function c(e,r){if("GET"!==e.method)return r.json({msg:"Failed!"});let{user:t}=await (0,_.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{dbName:n}=e.query;try{let e=l().resolve(String(process.env.DSQL_USER_DB_SCHEMA_PATH),`user-${t.id}/main.json`);if(!u().existsSync(e))return r.end();let a=JSON.parse(u().readFileSync(e,"utf-8")).find(e=>e.dbFullName==n);if(!a)throw Error("Database not found!");let s=l().resolve(process.cwd(),"./.tmp/_tmp.json");u().writeFileSync(s,JSON.stringify(a),"utf-8");let i=u().createReadStream(s);i.pipe(r),i.on("close",()=>{u().unlinkSync(s)})}catch(e){return console.log(e),r.end()}}let S=(0,i.M)(n,"default"),p=(0,i.M)(n,"config"),f=new a.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/downloadDatabaseSchema",pathname:"/api/downloadDatabaseSchema",bundlePath:"",filename:""},userland:n})},55153:(e,r,t)=>{t.d(r,{On:()=>a.a,_n:()=>i}),t(76102);var n=t(65967),a=t.n(n);t(30889);var s=t(93726);let i=t.n(s)()},69842:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(39383),a=t.n(n),s=t(55153);async function i(e,r,t,n){let i=a()({req:e,level:t?"deep":void 0}),o={DSQL_REMOTE_SQL_HOST:process.env.DSQL_REMOTE_SQL_HOST,DSQL_SU_USER_ID:process.env.DSQL_SU_USER_ID,DSQL_HOST_ENV:process.env.DSQL_HOST_ENV,DSQL_HOST:process.env.DSQL_HOST,DSQL_STATIC_HOST:process.env.DSQL_STATIC_HOST,DSQL_GOOGLE_CLIENT_ID:process.env.DSQL_GOOGLE_CLIENT_ID,DSQL_TINY_MCE_API_KEY:process.env.DSQL_TINY_MCE_API_KEY};return n&&i.payload?.id&&(0,s._n)(process.env.DSQL_SU_USER_ID)!==i.payload.id?{user:null,appData:o}:{user:i.payload,appData:o}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=86254);module.exports=t})();