"use strict";(()=>{var e={};e.id=8446,e.ids=[8446],e.modules={27825:e=>{e.exports=require("lodash")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},55591:e=>{e.exports=require("https")},33873:e=>{e.exports=require("path")},7671:(e,r,t)=>{t.r(r),t.d(r,{config:()=>g,default:()=>y,routeModule:()=>h});var a={};t.r(a),t.d(a,{default:()=>f});var s=t(89947),i=t(2706),l=t(96762);t(27825);var u=t(79681),n=t.n(u),o=t(48225),d=t.n(o),c=t(77619),p=t.n(c);let m=t(29021);async function f(e,r){if("GET"!==e.method)return r.json({msg:"Failed!"});try{let t,a;let s=e.query,{query:i,db:l}=s,u=s?.tableName?String(s.tableName):void 0,o=e.headers.authorization;if(!o)return r.json({success:!1,msg:"Unauthorized"});let d=p()({key:o,database:l,table:u,user_id:String(e.query.user_id)});if(!d?.user_id)throw Error("Api Credentials invalid!");let{user_id:c}=d;if(s?.queryValues&&"string"==typeof s?.queryValues)try{t=JSON.parse(s.queryValues)}catch(e){}let f=`datasquirel_user_${c}_${l}`,y=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${c.toString().replace(/\//g,"")}/main.json`;if(m.existsSync(y))try{a=JSON.parse(m.readFileSync(y,"utf8")).filter(e=>e.dbFullName===f)[0]}catch(e){}let g=await n()({dbFullName:f,query:i,tableName:u,queryValues:t,dbSchema:a});r.json(g)}catch(t){d()({component:"/api/query/get/main-catch-error",message:t.message,req:e}),r.json({success:!1,msg:"Wrong Credentials"})}}let y=(0,l.M)(a,"default"),g=(0,l.M)(a,"config"),h=new s.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/query/[user_id]/get",pathname:"/api/query/[user_id]/get",bundlePath:"",filename:""},userland:a})},79681:(e,r,t)=>{let a=t(27825),s=t(48225),i=t(8238);e.exports=async function({query:e,dbFullName:r,queryValues:t,tableName:l,dbSchema:u,useLocal:n}){if("string"==typeof e&&e.match(/^alter|^delete|information_schema|databases|^create/i))return{success:!1,msg:"Wrong Input."};try{let s,{result:o,error:d}=await i({dbFullName:r,query:e,queryValuesArray:t,readOnly:!0,dbSchema:u,tableName:l,local:n});if(u){let e=u.tables.find(e=>e.tableName===l);if(e){let r=a.cloneDeep(e);delete r.childTable,delete r.childTableDbFullName,delete r.childTableName,delete r.childrenTables,delete r.updateData,delete r.tableNameOld,delete r.indexes,s=r}}if(d)throw d;if(o.error)throw Error(o.error);return{success:!0,payload:o,schema:l&&s?s:void 0}}catch(e){return s({component:"/api/query/get/lines-85-94",message:e.message}),{success:!1,payload:null,error:e.message}}}}};var r=require("../../../../webpack-api-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[4050,8540],()=>t(7671));module.exports=a})();