"use strict";exports.id=8540,exports.ids=[8540],exports.modules={77619:(e,t,r)=>{leta=r(29021),l=r(72835);e.exports=({key:e,database:t,table:r,user_id:s,media:n})=>{if(!e||!s)returnnull;try{leti=process.env.DSQL_API_KEYS_PATH;if(!i)throwError("process.env.DSQL_API_KEYS_PATH variable not found");leto=l({encryptedString:e}),c=JSON.parse(o||""),u=a.existsSync(`${i}/${c.sign}`);if(String(c.user_id)!==String(s)||!u)returnnull;if(!c.target_database||n)returnc;if(!t&&c.target_database)returnnull;letd=c.target_database?.split(",").includes(String(t));if(d&&!c.target_table)returnc;if(d&&!r&&c.target_table)returnnull;if(c.target_table?.split(",").includes(String(r)))returnc;returnnull}catch(e){returnconsole.log(`api-cred ERROR: ${e.message}`),{error:`api-cred ERROR: ${e.message}`}}}},64122:(e,t,r)=>{leta=r(51348),l=r(21339),s=r(44900);asyncfunctionn({dbContext:e,paradigm:t,dbFullName:r,tableName:n,identifierColumnName:i,identifierValue:o,useLocal:c}){try{letu=!!c||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),d=c?s:u?a:l,p=`DELETE FROM ${n} WHERE \`${i}\`=?`;returnu?awaitd(p,[o]):awaitd({paradigm:t,queryString:p,database:r,queryValues:[o]})}catch(e){returnnull}}e.exports=n},8238:(e,t,r)=>{r(29021),r(44900);leta=r(94709),l=r(96064),s=r(48225),n=r(47670),i=r(33364),o=r(64122);r(6061);letc=r(33872);asyncfunctionu({dbFullName:e,query:t,readOnly:r,dbSchema:u,queryValuesArray:d,tableName:p,local:m}){letg,f,y;if(u)try{lete=p||("string"==typeoft?null:t?t?.table:null);if(!e)throwError("No table name provided");y=u.tables.filter(t=>t?.tableName===e)[0]}catch(e){}try{if("string"==typeoft){lets=c(t);if(r&&s.match(/^alter|^delete|information_schema|^create/i))throwError("Wrong Input!");g=r?awaitl({queryString:s,queryValuesArray:d?.map(e=>String(e)),database:e,tableSchema:y,useLocal:m}):awaita({queryString:s,queryValuesArray:d?.map(e=>String(e)),database:e,tableSchema:y,local:m})}elseif("object"==typeoft){let{data:r,action:a,table:l,identifierColumnName:s,identifierValue:c,update:u,duplicateColumnName:d,duplicateColumnValue:p}=t;switch(a.toLowerCase()){case"insert":g=awaitn({dbContext:m?"Master":"Dsql User",paradigm:"Full Access",dbFullName:e,tableName:l,data:r,update:u,duplicateColumnName:d,duplicateColumnValue:p,tableSchema:y,useLocal:m}),g?.insertId||(f=Error("Couldn't insert data"));break;case"update":g=awaiti({dbContext:m?"Master":"Dsql User",paradigm:"Full Access",dbFullName:e,tableName:l,data:r,identifierColumnName:s,identifierValue:c,tableSchema:y,useLocal:m});break;case"delete":g=awaito({dbContext:m?"Master":"Dsql User",paradigm:"Full Access",dbFullName:e,tableName:l,identifierColumnName:s,identifierValue:c,tableSchema:y,useLocal:m});break;default:g=null}}}catch(e){s({component:"functions/backend/runQuery",message:e.message}),g=null,e=e.message}return{result:g,error:f}}e.exports=u},30003:e=>{e.exports=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/},94709:(e,t,r)=>{leta=r(21339),l=r(44900),s=r(6061),n=r(48225);e.exports=asyncfunction({queryString:e,database:t,tableSchema:r,queryValuesArray:i,local:o}){letc;try{c=o?awaitl(e,i):awaita({paradigm:"Full Access",database:t,queryString:e,queryValues:i})}catch(e){returnn({component:"fullAccessDbHandler",message:e.message}),e.message}if(c&&r){lete=c;returnawaits({unparsedResults:e,tableSchema:r})}returnc||null}},6061:(e,t,r)=>{leta=r(72835),l=r(30003);e.exports=asyncfunction({unparsedResults:e,tableSchema:t}){letr=[];try{for(lets=0;s<e.length;s++){letn=e[s],i=Object.keys(n);for(lete=0;e<i.length;e++){letr=i[e],s=t?.fields[e];if(r?.match(l))continue;leto=n[r];("number"==typeofo||o)&&s?.encrypted&&o?.match(/./)&&(n[r]=a({encryptedString:o}))}r.push(n)}returnr}catch(t){returnconsole.log("ERROR in parseDbResults Function =>",t.message),e}}},48225:(e,t,r)=>{leta=r(29021),{IncomingMessage:l}=r(81630);e.exports=asyncfunction({user:e,message:t,component:r,noMail:l,req:s}){letn=newDate,i=(()=>{if(!s)returnnull;try{lete=s.headers["x-forwarde