"use strict";(()=>{var e={};e.id=7317,e.ids=[7317],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},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,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},86254:(e,t,r)=>{r.r(t),r.d(t,{config:()=>P,default:()=>p,routeModule:()=>A});var n={};r.r(n),r.d(n,{default:()=>f});var a=r(89947),o=r(2706),i=r(96762),u=r(29021),s=r.n(u),d=r(33873),l=r.n(d),c=r(69842);async function f(e,t){if("GET"!==e.method)return t.json({msg:"Failed!"});let r=await (0,c.A)(e,t,!0);if(!r)return t.json({success:!1,msg:"Unauthorized"});let{dbName:n}=e.query;try{let e=l().resolve(String(process.env.DSQL_USER_DB_SCHEMA_PATH),`user-${r.id}/main.json`);if(!s().existsSync(e))return t.end();let a=JSON.parse(s().readFileSync(e,"utf-8")).find(e=>e.dbFullName==n);if(!a)throw Error("Database not found!");let o=l().resolve(process.cwd(),"./.tmp/_tmp.json");s().writeFileSync(o,JSON.stringify(a),"utf-8");let i=s().createReadStream(o);i.pipe(t),i.on("close",()=>{s().unlinkSync(o)})}catch(e){return console.log(e),t.end()}}let p=(0,i.M)(n,"default"),P=(0,i.M)(n,"config"),A=new a.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/downloadDatabaseSchema",pathname:"/api/downloadDatabaseSchema",bundlePath:"",filename:""},userland:n})},69842:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(39908),a=r.n(n);async function o(e,t,r){let n=a()({req:e,level:r?"deep":void 0});return console.log(n),n.payload}},2706:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}});var r=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,t,r)=>{e.exports=r(75600)}};var t=require("../../webpack-api-runtime.js");t.C(e);var r=t(t.s=86254);module.exports=r})();