dsql-admin/dsql-app/.local_dist/server/pages/api/exportTableData.js

16 lines
3.5 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
"use strict";(()=>{var e={};e.id=4727,e.ids=[4727],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")},27310:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>c,routeModule:()=>m});var a={};t.r(a),t.d(a,{config:()=>u,default:()=>d});var s=t(89947),o=t(2706),i=t(96762),l=t(69842),n=t(33170);let u={api:{responseLimit:"1mb",bodyParser:{sizeLimit:"200mb"}}};async function d(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=await (0,l.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{paradigm:a,dbName:s,tableName:o,payload:i}=e.body;try{let e=await (0,n.A)({dbName:s,paradigm:a,payload:i,tableName:o,userId:t.id,payloadType:"base64"});if(!e)return r.json({success:!1,msg:"Operation Failed!"});r.json({success:!0,msg:"Success!",data:e?.tableData})}catch(e){r.json({success:!1,msg:e.message})}}let c=(0,i.M)(a,"default"),p=(0,i.M)(a,"config"),m=new s.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/exportTableData",pathname:"/api/exportTableData",bundlePath:"",filename:""},userland:a})},33170:(e,r,t)=>{t.d(r,{A:()=>i});var a=t(98e3),s=t(67619),o=t(48786);async function i({paradigm:e,userId:r,dbName:t,tableName:i,payload:l,payloadType:n}){let u={};try{let s=`${process.env.DSQL_USER_DB_PREFIX}${r}_${t.replace(/ /g,"")}`;switch(e){case"export":let d=await (0,o.A)(`SELECT * FROM \`${s}\`.\`${i}\``);u.tableData=d;break;case"import":let c="base64"==n?Buffer.from(l,"base64").toString():l,p="object"===n?l:JSON.parse(c);for(let e=0;e<p.length;e++){let r=p[e],t=await (0,a.A)({data:r,dbFullName:s,tableName:i,dbContext:"Dsql User",paradigm:"Full Access",duplicateColumnName:"id",duplicateColumnValue:r?.id,update:!0});if(t.error)throw Error(t.error)}break;default:return null}return u}catch(e){return(0,s.A)({component:"/functions/backend/importExportTableDataFn",message:e.message}),null}}},69842:(e,r,t)=>{t.d(r,{A:()=>o});var a=t(39908),s=t.n(a);async function o(e,r,t){let a=s()({req:e,level:t?"deep":void 0});return console.log(a),a.payload}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var a=t(29021),s=t.n(a);async function o({user:e,message:r,component:t,noMail:a,req:o}){let i=new Date,l=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],a=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||a||r||o.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let a=`🚀 SERVER ERROR ===========================
2024-12-08 19:56:57 +00:00
Error Message: ${r}
2025-01-14 15:27:08 +00:00
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(a+=`
2024-12-08 19:56:57 +00:00
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
2025-01-14 15:27:08 +00:00
User Email: ${e?.email}`),o?.url&&(a+=`
URL: ${o.url}`),o?.body&&(a+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),l&&(a+=`
IP: ${l}`),a+=`
Date: ${i.toDateString()}
========================================`,s().existsSync("./.tmp/error.log")||s().writeFileSync("./.tmp/error.log","","utf-8");let n=s().readFileSync("./.tmp/error.log","utf-8");s().writeFileSync("./.tmp/error.log",a),s().appendFileSync("./.tmp/error.log",`
2024-12-08 19:56:57 +00:00
2025-01-14 15:27:08 +00:00
${n}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[1251],()=>t(27310));module.exports=a})();