"use strict";(()=>{var e={};e.id=1132,e.ids=[1132],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},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")},18885:(e,r,t)=>{t.r(r),t.d(r,{config:()=>b,default:()=>q,routeModule:()=>f});var a={};t.r(a),t.d(a,{default:()=>m});var s=t(89947),d=t(2706),i=t(96762),u=t(41520),l=t(31495),o=t(60125),n=t(67619),c=t(69842),p=t(30802);async function m(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let{user:t,appData:a}=await (0,c.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{dbSlug:s,tableName:d,payload:i,entryId:m,tableSchema:q,delegated:b,dbId:f}=e.body;delete i.id,delete i.uuid,delete i.date_created,delete i.date_created_code,delete i.date_created_timestamp,delete i.date_updated,delete i.date_updated_code,delete i.date_updated_timestamp;try{let a=await (0,o.A)({databaseSlug:s,request:e,user:t,query:e.query}),n=a?.rootUserId?`datasquirel_user_${a.rootUserId}_${s}`:`datasquirel_user_${t.id}_${s}`;if(!await (0,l.A)({user:t,confirmedDelegetedUser:a,database:s,table:d,dbId:f,priviledgeRegex:/Update Entries/i}))return r.json({success:!1,msg:"Unauthorized"});let c=await (0,p.A)({dbContext:"Dsql User",dbFullName:n,tableName:d,identifierColumnName:"id",identifierValue:m,data:i,tableSchema:q});if(c?.error)throw Error(c.error);if(!c)throw Error("No result returned!");await (0,u.A)({dbName:n,entryId:m,entryOrder:i.order,tableName:d,tableSchema:q}),r.json({success:!0,payload:c})}catch(e){(0,n.A)({component:"/api/updateTableEntry/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!",err:e.message})}}let q=(0,i.M)(a,"default"),b=(0,i.M)(a,"config"),f=new s.PagesAPIRouteModule({definition:{kind:d.A.PAGES_API,page:"/api/updateTableEntry",pathname:"/api/updateTableEntry",bundlePath:"",filename:""},userland:a})}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[2984],()=>t(18885));module.exports=a})();