"use strict";(()=>{vare={};e.id=4065,e.ids=[4065],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")},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")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},63177:(e,r,t)=>{t.r(r),t.d(r,{config:()=>h,default:()=>y,routeModule:()=>A});varn={};t.r(n),t.d(n,{default:()=>g});vara=t(89947),s=t(2706),o=t(96762),i=t(76856),l=t(29021),c=t.n(l),u=t(33873),d=t.n(u);letp=async({userId:e,dbSchema:r,targetDb:t})=>(await(0,i.A)({userId:e,targetDatabase:t}),`User ${e} Db Schema Updated`),_=async({userId:e,dbSchema:r,database:t})=>{letn=d().resolve(String(process.env.DSQL_USER_DB_SCHEMA_PATH),`user-${e}`,"main.json"),a=JSON.parse(c().readFileSync(n,"utf-8")),s=a.findIndex(e=>e.dbFullName==t.db_full_name);if(s<0)throwError("Target Database not found in user schema data");leto={...a[s]};returna[s]=r,a[s].dbName=o.dbName,a[s].dbFullName=o.dbFullName,a[s].dbSlug=o.dbSlug,a[s].dbImage=o.dbImage,awaitp({dbSchema:a,userId:e,targetDb:t.db_full_name})};varf=t(67619),S=t(69842),m=t(30802);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,S.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{url:n,key:a,database:s,dbSchema:o,type:i,remoteDbs:l,targetDb:c}=e.body;try{if(!c?.tables)throwError("No Target Database");await(0,m.A)({tableName:"user_databases",data:{remote_connected:1,remote_connection_host:n,remote_connection_key:a,remote_connection_type:i,remote_db_full_name:c.dbFullName},identifierColumnName:"db_full_name",identifierValue:s.db_full_name}),await_({dbSchema:c,database:s,userId:t.id}),r.json({success:!0})}catch(e){console.log("Connect Handshake Error, =>",e.message),(0,f.A)({component:"/api/connect/verify/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Operation Failed!"})}}lety=(0,o.M)(n,"default"),h=(0,o.M)(n,"config"),A=newa.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/connect/handshake",pathname:"/api/connect/handshake",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>s});varn=t(39908),a=t.n(n);asyncfunctions(e,r,t){letn=a()({req:e,level:t?"deep":void0});returnconsole.log(n),n.payload}},30802:(e,r,t)=>{t.d(r,{A:()=>u});varn=t(72583),a=t.n(n),s=t(92652),o=t(48786),i=t(37897),l=t(68829),c=t(62050);asyncfunctionu({dbContext:e,paradigm:r,dbFullName:t,tableName:n,data:u,tableSchema:d,identifierColumnName:p,identifierValue:_,encryptionKey:f,encryptionSalt:S,useLocal:m}){if(!u||!Object.keys(u).length)returnnull;letg=!!m||!e?.match(/dsql.user/i)&&(!t||!!t.match(/^datasquirel$/)),y=m?c.A:g?o.A:i.A,h=Object.keys(u),A=[],D=[];for(lete=0;e<h.length;e++)try{letr=h[e],t=u[r],n=d?d?.fields?.filter(e=>e.fieldName===r):null,o=n&&n[0]?n[0]:null;if(null==t||void0==t)continue;leti=/<[^>]+>/g;(o?.richText||String(t).match(i))&&(t=a()(t,s.A)),o?.encrypted&&(t=(0,l.A)({data:t,encryptionKey:f,encryptionSalt:S})),"object"==typeoft&&(t=JSON.stringify(t)),o?.pattern&&!newRegExp(o.pattern,o.patternFlags||"").test(t)&&(console.log("DSQL: Pattern not matched =>",t),t=""),"string"==typeoft&&t.match(/^null$/i)&&(t={toSqlString:function(){return"NULL"}}),"string"!=typeoft||t.match(/./i)||(t={toSqlString:function(){return"NULL"}}),A.push(`\`${r}\`=?`),"number"==typeoft?D.push(String(t)):D.push(t)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}A.push(`date_updated='${Date()}'`),A.push(`date_updated_code='${Date.now()}'`);letN=`UPDATE \`${t}\`.\`${n}\` SET ${A.join(",")} WHERE \`${p}\`=?`;returnD.push(_),g?awaity(N,D):awaity({paradigm:r,query