2025-01-14 15:27:08 +00:00
|
|
|
"use strict";(()=>{var e={};e.id=7214,e.ids=[7214],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")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},21820:e=>{e.exports=require("os")},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}}})},53382:(e,r,t)=>{t.r(r),t.d(r,{config:()=>D,default:()=>y,routeModule:()=>g});var n={};t.r(n),t.d(n,{default:()=>_});var a=t(89947),s=t(2706),o=t(96762),l=t(29021),i=t.n(l),c=t(21820),u=t.n(c),d=t(79646),p=t(30802),f=t(67619),S=t(69842),m=t(30944);async function _(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=await (0,S.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{id:n,db_name:a,db_slug:s,db_description:o,db_image:l,db_full_name:c,active_clone:_,active_clone_parent_db:y}=e.body;c?.match(/datasquirel_user_.*/)||r.json({success:!1,msg:"Unauthorized"});let D=`datasquirel_user_${t.id}_${s}`;if(await (0,p.A)({dbFullName:"datasquirel",tableName:"user_databases",identifierColumnName:"id",identifierValue:n,data:{db_name:a,db_slug:s,db_description:o,db_image:l,db_full_name:D}}),c&&c!==D){console.log("Renaming Database");let e=u().platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql.exe'":"mysql",r=u().platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump";try{await (0,m.A)({queryString:`CREATE DATABASE \`${D}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin`});let t={cwd:process.cwd()};u().platform().match(/win/i)&&(t.shell="bash.exe");let n=`${r} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD} ${c} > tmpDbFile.sql`;console.log(`updateUserDatabase.ts exe => ${n}`),(0,d.execSync)(n,t),(0,d.execSync)(`${e} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD} ${D} < tmpDbFile.sql`,t),await (0,m.A)({queryString:`DROP DATABASE \`${c}\``})}catch(e){(0,f.A)({component:"/api/updateUserDatabase/lines-88-111",message:e.message,user:t})}}try{let e=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,n=JSON.parse(i().readFileSync(e,"utf8")),u=n.filter(e=>e.dbFullName===c);if(u[0].dbName=a,u[0].dbFullName=D,u[0].dbDescription=o,u[0].dbImage=l,u[0].dbSlug=s,_){let e=n.filter(e=>e.dbFullName===u[0].childDatabaseDbFullName)[0],r=e.childrenDatabases?.find(e=>e.dbFullName===c);r&&(r.dbFullName=D)}i().writeFileSync(`${e}`,JSON.stringify(n),"utf8"),r.json({success:!0})}catch(e){(0,f.A)({component:"/api/updateUserDatabase/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}let y=(0,o.M)(n,"default"),D=(0,o.M)(n,"config"),g=new a.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/updateUserDatabase",pathname:"/api/updateUserDatabase",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(39908),a=t.n(n);async function s(e,r,t){let n=a()({req:e,level:t?"deep":void 0});return console.log(n),n.payload}},30802:(e,r,t)=>{t.d(r,{A:()=>u});var n=t(72583),a=t.n(n),s=t(92652),o=t(48786),l=t(37897),i=t(68829),c=t(62050);async function u({dbContext:e,paradigm:r,dbFullName:t,tableName:n,data:u,tableSchema:d,identifierColumnName:p,identifierValue:f,encryptionKey:S,encryptionSalt:m,useLocal:_}){if(!u||!Object.keys(u).length)return null;let y=!!_||!e?.match(/dsql.user/i)&&(!t||!!t.match(/^datasquirel$/)),D=_?c.A:y?o.A:l.A,g=Object.keys(u),A=[],h=[];for(let e=0;e<g.length;e++)try{let r=g[e],t=u[r],n=d?d?.fields?.filter(e=>e.fieldName===r):null,o=n&&n[0]?n[0]:null;if(null==t||void 0==t)continue;let l=/<[^>]+>/g;(o?.richText||Strin
|
2025-01-14 06:19:19 +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&&(n+=`
|
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}`),s?.url&&(n+=`
|
|
|
|
URL: ${s.url}`),s?.body&&(n+=`
|
|
|
|
Request Body: ${JSON.stringify(s.body,null,4)}`),l&&(n+=`
|
|
|
|
IP: ${l}`),n+=`
|
2025-01-14 06:19:19 +00:00
|
|
|
Date: ${o.toDateString()}
|
2025-01-14 15:27:08 +00:00
|
|
|
========================================`,a().existsSync("./.tmp/error.log")||a().writeFileSync("./.tmp/error.log","","utf-8");let i=a().readFileSync("./.tmp/error.log","utf-8");a().writeFileSync("./.tmp/error.log",n),a().appendFileSync("./.tmp/error.log",`
|
2024-12-08 19:56:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-01-14 15:27:08 +00:00
|
|
|
${i}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},30944:(e,r,t)=>{t.d(r,{A:()=>l});var n=t(43775),a=t(67619),s=t(7447),o=t(64292);async function l({queryString:e,queryValuesArray:r,database:t,tableSchema:l,useLocal:i,debug:c}){let u=(0,s.A)({fa:!0});i&&(u=(0,s.A)({local:!0})),t?.match(/^datasquirel$/)&&(u=(0,s.A)()),c&&(console.log("varDatabaseDbHandler:query:",e),console.log("varDatabaseDbHandler:values:",r));let d=await (0,o.A)(u,e,r);if(c&&console.log("varDatabaseDbHandler:results:",d),d&&l)try{return await (0,n.A)({unparsedResults:d,tableSchema:l})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",t,e),(0,a.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(d)return d;else return null}},95969:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(55511),a=t(79428),s=t(32443);function o({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:o,salt:l,keyLen:i,algorithm:c,bufferAllocSize:u}=(0,s.A)({encryptionKey:r});if(!o?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!l?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let d=(0,n.scryptSync)(o,l,i),p=a.Buffer.alloc(u,0),f=(0,n.createDecipheriv)(c,d,p);try{let r=f.update(e,"hex","utf8");return r+=f.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},68829:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(55511),a=t(79428),s=t(32443);function o({data:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:o,salt:l,keyLen:i,algorithm:c,bufferAllocSize:u}=(0,s.A)({encryptionKey:r});if(!o?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!l?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let d=(0,n.scryptSync)(o,l,i),p=a.Buffer.alloc(u,0),f=(0,n.createCipheriv)(c,d,p);try{let r=f.update(e,"utf8","hex");return r+=f.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},48786:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(7447);async function a(...e){let r=(0,n.A)();try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let t=await r.query(...e);return JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},37897:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(64292),a=t(7447);async function s({paradigm:e,queryString:r,queryValues:t}){let s="Read Only"==e?(0,a.A)({ro:!0}):(0,a.A)({fa:!0});try{return await (0,n.A)(s,r,t)}catch(e){return console.log(`DSQL_USER_DB_HANDLER Error: ${e.message}`),null}finally{s?.end()}}},62050:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(7447);async function a(...e){let r=(0,n.A)();console.log("Querying ...");try{let t=await r.query(...e);return JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e.message),{success:!1,error:e.message}}finally{await r?.end()}}},64292:(e,r,t)=>{async function n(e,r,t){try{if("string"==typeof r){let n=await e.query(a(r),t);return JSON.parse(JSON.stringify(n))}if("object"!=typeof r)return null;{let t=[];for(let n=0;n<r.length;n++)try{let s=r[n],o=await e.query(a(s.query),s.values);t.push(JSON.parse(JSON.stringify(o)))}catch(e){t.push(null)}return t}}catch(e){return null}finally{e.end()}}function a(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(r,{A:()=>n})},7447:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(9973),a=t.n(n);function s(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||a()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||a()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||a()({config:{host:process.env.DSQL_DB_HOST,user:pr
|