"use strict";(()=>{vare={};e.id=460,e.ids=[460],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")},66912:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>p,routeModule:()=>y});vara={};t.r(a),t.d(a,{default:()=>m});vars=t(89947),i=t(2706),l=t(96762),o=t(77377),d=t(98e3),n=t(31495),u=t(60125),c=t(67619),g=t(69842);asyncfunctionm(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,g.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"User Auth Failed"});let{tableName:a,payload:s,tableSchema:i,dbSlug:l,dbId:m,delegated:p}=e.body;try{letc=await(0,u.A)({databaseSlug:l,request:e,user:t,query:e.query});if(!await(0,n.A)({user:t,confirmedDelegetedUser:c,database:l,table:a,dbId:m,priviledgeRegex:/Update Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});letg=c?.rootUserId?`datasquirel_user_${c.rootUserId}_${l}`:`datasquirel_user_${t.id}_${l}`,p=await(0,d.A)({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:g,tableName:a,data:s,tableSchema:i});if(!p.insertId)throwconsole.log("Table Insertion Failed =>",p),Error(p?.error||"Table Insertion Failed");await(0,o.A)({dbName:g,entryId:p.insertId,entryOrder:s.order,tableName:a,tableSchema:i}),r.json({success:!0})}catch(e){(0,c.A)({component:"/api/addTableEntry/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!",err:e.message})}}letp=(0,l.M)(a,"default"),f=(0,l.M)(a,"config"),y=news.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/addTableEntry",pathname:"/api/addTableEntry",bundlePath:"",filename:""},userland:a})},31495:(e,r,t)=>{t.d(r,{A:()=>i});vara=t(48786),s=t(67619);asyncfunctioni({user:e,confirmedDelegetedUser:r,database:t,table:i,priviledgeRegex:l,dbId:o}){letd,n;try{r?.delegated?(d=await(0,a.A)("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,i]),n=d[0]?.priviledge?.match(l)):(d=await(0,a.A)("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,i,o]),n=!0)}catch(r){(0,s.A)({component:"checkUserRights",message:r.message,user:e})}return!!d&&!!d[0]&&!!n}},60125:(e,r,t)=>{t.d(r,{A:()=>s});vara=t(95969);asyncfunctions({request:e,databaseSlug:r,user:t,query:s}){try{leti=t.id,l=null;if(!s?.delegated)return{dbUserId:i};leto=s.dbUserId,d=`${process.env.DSQL_USER_DB_PREFIX}${o}_${r}`,n=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${d}`;try{if(!e.cookies?.[n])throwError("Cookie not present");lett=(0,a.A)({encryptedString:e.cookies[n]});if(!t)throwError("Invalid Token");if((l=JSON.parse(t)).databaseSlug===r)return{dbUserId:i=l.rootUserId,rootUserId:l.rootUserId,rootUserName:l.rootUserName,rootUserEmail:l.rootUserEmail,rootUserImage:l.rootUserImage,databaseFullName:l.databaseFullName,databaseSlug:l.databaseSlug,allowedTables:l.allowedTables,priviledges:l.priviledges,database:l.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:i}}catch(e){returnnull}}},77377:(e,r,t)=>{t.d(r,{A:()=>s});vara=t(37897);asyncfunctions({dbName:e,entryId:r,entryOrder:t,tableName:s,tableSchema:i}){try{if(i.fields.find(e=>!!e.fieldName?.match(/^order$/i))&&t){lete=await(0,a.A)({paradigm:"Full Access",queryString:`SELECT * FROM ${s} WHERE \`order\` = '${t}' AND id != ?`,queryValues:[String(r)]});if(!e?.[0])throwError("No Existing Order");await(0,a.A)({paradigm:"Full Access",queryString:`UPDATE ${s} SET \`order\` = \`order\` + 1 WHERE \`order\` >= ${t} AND id != ?`,queryValues:[String(r)]})}return!0}catch(e){return!1}}},69842:(e,r,t)=>{t.d(r,{A:()=>i});vara=t(39908),s=t.n(a);asyncfunctioni(e,r,t){leta=s()({req:e,level:t?"deep":void0});returnconsole.log(a),a.payload}},67619:(e,r,t)=>{t.d(r,{A:()=>i});vara=t(29021),s=