"use strict";exports.id=2319,exports.ids=[2319],exports.modules={96762:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},67580:(e,t,r)=>{r.d(t,{A:()=>_});var n=r(47795),a=r.n(n),s=r(48786),o=r(47546),l=r(98e3),i=r(68829),c=r(62050);async function _({userId:e}){try{let t=process.env.DSQL_DB_HOST||"127.0.0.1",r=`dsql_user_${e}`,n=a().generate({length:16,numbers:!0,symbols:!0,uppercase:!0,exclude:"*#.'`\""}),_=(0,i.A)({data:n}),u=`CREATE USER IF NOT EXISTS '${r}'@'127.0.0.1' IDENTIFIED BY '${n}'`;global.DSQL_USE_LOCAL?await (0,c.A)(u):await (0,o.A)(u);let d="UPDATE users SET mariadb_user = ?, mariadb_host = '127.0.0.1', mariadb_pass = ? WHERE id = ?",p=[r,_,e];global.DSQL_USE_LOCAL?await (0,c.A)(d,p):await (0,s.A)(d,p),await (0,l.A)({tableName:"mariadb_users",data:{user_id:e,username:r,host:t,password:_,primary:"1",grants:'[{"database":"*","table":"*","privileges":["ALL"]}]'},dbContext:"Master"}),console.log(`User ${e} SQL credentials successfully added.`)}catch(e){console.log("Error in adding SQL user in 'addMariadbUser' function =>",e.message)}}},98e3:(e,t,r)=>{r.d(t,{A:()=>_});var n=r(72583),a=r.n(n),s=r(92652),o=r(30802),l=r(68829),i=r(64292),c=r(52939);async function _({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:_,tableSchema:u,duplicateColumnName:d,duplicateColumnValue:p,update:S,encryptionKey:D,encryptionSalt:L,forceLocal:A}){let g=!!A||(0,c.A)({dbContext:e,dbFullName:r}),f=g?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN,E=g?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;if(_?.date_created_timestamp&&delete _.date_created_timestamp,_?.date_updated_timestamp&&delete _.date_updated_timestamp,_?.date_updated&&delete _.date_updated,_?.date_updated_code&&delete _.date_updated_code,_?.date_created&&delete _.date_created,_?.date_created_code&&delete _.date_created_code,d&&"string"==typeof d){let t=`SELECT * FROM ${g?"":`\`${r}\`.`}\`${n}\` WHERE \`${d}\`=?`,a=await (0,i.A)(E,t,[p]);if(a?.[0]&&!S)return null;if(a&&a[0]&&S)return await (0,o.A)({dbContext:e,dbFullName:r,tableName:n,data:_,tableSchema:u,encryptionKey:D,encryptionSalt:L,identifierColumnName:d,identifierValue:p||""})}let N=Object.keys(_),y=[],h=[];for(let e=0;ee.fieldName==t):null,o=n&&n[0]?n[0]:null;if(null==r||void 0==r||o?.dataType?.match(/int$/i)&&"string"==typeof r&&!r?.match(/./))continue;o?.encrypted&&(r=(0,l.A)({data:r,encryptionKey:D,encryptionSalt:L}),console.log("DSQL: Encrypted value =>",r));let i=/<[^>]+>/g;(o?.richText||String(r).match(i))&&(r=a()(r,s.A)),o?.pattern&&!new RegExp(o.pattern,o.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),y.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?h.push(String(r)):h.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message),global.ERROR_CALLBACK?.("Error parsing Data Keys",e);continue}_?.date_created||(y.push("`date_created`"),h.push(Date())),_?.date_created_code||(y.push("`date_created_code`"),h.push(Date.now())),_?.date_updated||(y.push("`date_updated`"),h.push(Date())),_?.date_updated_code||(y.push("`date_updated_code`"),h.push(Date.now()));let m=`INSERT INTO ${g?"":`\`${r}\`.`}\`${n}\` (${y.join(",")}) VALUES (${h.map(()=>"?").join(",")})`;return await (0,i.A)(f,m,h)}},30802:(e,t,r)=>{r.d(t,{A:()=>c});var n=r(72583),a=r.n(n),s=r(92652),o=r(68829),l=r(52939),i=r(64292);async function c({dbContext:e,dbFullName:t,tableName:r,data:n,tableSchema:c,identifierColumnName:_,identifierValue:u,encryptionKey:d,encryptionSalt:p,forceLocal:S}){if(!n||!Object.keys(n).length)return null;let D=!!S||(0,l.A)({dbContext:e,dbFullName:t}),L=D?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN;D?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;let A=Object.keys(n),g=[],f=[];for(let e=0;ee.fieldName===t):null,i=l&&l[0]?l[0]:null;if(null==r||void 0==r)continue;let _=/<[^>]+>/g;(i?.richText||String(r).match(_))&&(r=a()(r,s.A)),i?.encrypted&&(r=(0,o.A)({data:r,encryptionKey:d,encryptionSalt:p})),"object"==typeof r&&(r=JSON.stringify(r)),i?.pattern&&!new RegExp(i.pattern,i.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),"string"==typeof r&&r.match(/^null$/i)&&(r={toSqlString:function(){return"NULL"}}),"string"!=typeof r||r.match(/./i)||(r={toSqlString:function(){return"NULL"}}),g.push(`\`${t}\`=?`),"number"==typeof r?f.push(String(r)):f.push(r)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}g.push(`date_updated='${Date()}'`),g.push(`date_updated_code='${Date.now()}'`);let E=`UPDATE ${D?"":`\`${t}\`.`}\`${r}\` SET ${g.join(",")} WHERE \`${_}\`=?`;return f.push(u),await (0,i.A)(L,E,f)}},96052:(e,t,r)=>{r.d(t,{A:()=>l});var n=r(29021),a=r.n(n),s=r(21572);let o=r.n(s)().createTransport({host:process.env.DSQL_MAIL_HOST,port:465,secure:!0,auth:{user:process.env.DSQL_MAIL_EMAIL,pass:process.env.DSQL_MAIL_PASSWORD}});async function l({to:e,subject:t,text:r,html:n,alias:s,senderName:l}){let i;if(!process.env.DSQL_MAIL_HOST||!process.env.DSQL_MAIL_EMAIL||!process.env.DSQL_MAIL_PASSWORD)return null;let c=(s?.match(/support/i),process.env.DSQL_MAIL_EMAIL);if(!a().existsSync("./email/index.html"))return;let _=a().readFileSync("./email/index.html","utf8").replace(/{{email_body}}/,n||"").replace(/{{issue_date}}/,Date().substring(0,24));try{let n={};n.from=`"${l||"Datasquirel"}" <${c}>`,n.sender=c,s&&(n.replyTo=c),n.to=e,n.subject=t,n.text=r,n.html=_,i=await o.sendMail(n)}catch(e){console.log("ERROR in handleNodemailer Function =>",e.message)}return i}},92652:(e,t,r)=>{r.d(t,{A:()=>n});let n={allowedTags:["b","i","em","strong","a","p","span","ul","ol","li","h1","h2","h3","h4","h5","h6","img","div","button","pre","code","br"],allowedAttributes:{a:["href"],img:["src","alt","width","height","class","style"],"*":["style","class"]}}},67619:(e,t,r)=>{r.d(t,{A:()=>s});var n=r(29021),a=r.n(n);async function s({user:e,message:t,component:r,noMail:n,req:s}){let o=new Date,l=(()=>{if(!s)return null;try{let e=s.headers["x-forwarded-for"],t=s.headers["x-real-ip"],r=s.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],a=r||n||t||s.socket.remoteAddress;if(!a)return null;return String(a)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR =========================== Error Message: ${t} Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=` User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} 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+=` Date: ${o.toDateString()} ========================================`,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",` ${i}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},68829:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(55511),a=r(79428),s=r(31542);function o({data:e,encryptionKey:t,encryptionSalt:r}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:o,salt:l,keyLen:i,algorithm:c,bufferAllocSize:_}=(0,s.A)({encryptionKey:t});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 u=(0,n.scryptSync)(o,l,i),d=a.Buffer.alloc(_,0),p=(0,n.createCipheriv)(c,u,d);try{let t=p.update(e,"utf8","hex");return t+=p.final("hex")}catch(t){return console.log("Error in encrypting =>",t.message),global.ERROR_CALLBACK?.("Error Encrypting Data",t),e}}},48786:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(7447);async function a(...e){let t=(0,n.A)();try{if(!t)throw Error("No Connection provided to DB_HANDLER function!");let r=await t.query(...e);return JSON.parse(JSON.stringify(r))}catch(e){return global.ERROR_CALLBACK?.("DB_HANDLER Error",e),{success:!1,error:e.message}}finally{await t?.end()}}},62050:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(7447);async function a(...e){let t=(0,n.A)();try{let r=await t.query(...e);return JSON.parse(JSON.stringify(r))}catch(e){return global.ERROR_CALLBACK?.("LOCAL_DB_HANDLER Error",e),{success:!1,error:e.message}}finally{await t?.end()}}},47546:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(7447);function a(...e){let t=(0,n.A)();try{return new Promise((r,n)=>{t.query(...e).then(e=>{t.end(),r(JSON.parse(JSON.stringify(e)))}).catch(e=>{t.end(),r({error:e.message,sql:e.sql})})})}catch(e){return global.ERROR_CALLBACK?.("NO_DB_HANDLER Error",e),{success:!1,error:e.message}}finally{t?.end()}}},52939:(e,t,r)=>{r.d(t,{A:()=>n});function n({dbContext:e,dbFullName:t}){return!e?.match(/dsql.user/i)&&(!!global.DSQL_USE_LOCAL||!t||!!t.match(/^datasquirel$/))}},64292:(e,t,r)=>{async function n(e,t,r){try{if(!e)throw Error("No Connection Found!");if(!t)throw Error("Query String Required!");if("string"==typeof t){let n=await e.query(a(t),r);return JSON.parse(JSON.stringify(n))}if("object"!=typeof t)return null;{let r=[];for(let n=0;nn})},7447:(e,t,r)=>{r.d(t,{A:()=>s});var n=r(9973),a=r.n(n);function s(e){return global.DSQL_USE_LOCAL||e?.local?global.DSQL_DB_CONN||a()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.ro?global.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:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},31542:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(82535);function a(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?(0,n.A)(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},82535:(e,t,r)=>{r.d(t,{A:()=>n});function n(e,t){try{let r=Number(e);if("number"!=typeof r||isNaN(r))return 0;if(t)return Number(r.toFixed(t));return Math.round(r)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},2706:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}});var r=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,t,r)=>{e.exports=r(75600)}};