"use strict";exports.id=4050,exports.ids=[4050],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}}})},47670:(e,t,r)=>{let s=r(72583),n=r(16570);r(33364);let a=r(33364);r(27825);let o=r(51348),c=r(21339),i=r(20503),l=r(44900);async function u({dbContext:e,paradigm:t,dbFullName:r,tableName:u,data:d,tableSchema:p,duplicateColumnName:_,duplicateColumnValue:S,update:D,encryptionKey:f,encryptionSalt:g,useLocal:h}){let E=!!h||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),y=h?l:E?o:c;if(d?.date_created_timestamp&&delete d.date_created_timestamp,d?.date_updated_timestamp&&delete d.date_updated_timestamp,d?.date_updated&&delete d.date_updated,d?.date_updated_code&&delete d.date_updated_code,d?.date_created&&delete d.date_created,d?.date_created_code&&delete d.date_created_code,_&&"string"==typeof _){let s=E?await y(`SELECT * FROM \`${u}\` WHERE \`${_}\`=?`,[S]):await y({paradigm:"Read Only",database:r,queryString:`SELECT * FROM \`${u}\` WHERE \`${_}\`=?`,queryValues:[S]});if(s?.[0]&&!D)return null;if(s&&s[0]&&D)return await a({dbContext:e,paradigm:t,dbFullName:r,tableName:u,data:d,tableSchema:p,encryptionKey:f,encryptionSalt:g,identifierColumnName:_,identifierValue:S||""})}let m=Object.keys(d),L=[],O=[];for(let e=0;ee.fieldName==t):null,o=a&&a[0]?a[0]:null;if(null==r||void 0==r||o?.dataType?.match(/int$/i)&&"string"==typeof r&&!r?.match(/./))continue;o?.encrypted&&(r=i({data:r,encryptionKey:f,encryptionSalt:g}),console.log("DSQL: Encrypted value =>",r)),o?.richText&&(r=s(r,n)),o?.pattern&&!new RegExp(o.pattern,o.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),L.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?O.push(String(r)):O.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message);continue}d?.date_created||(L.push("`date_created`"),O.push(Date())),d?.date_created_code||(L.push("`date_created_code`"),O.push(Date.now())),d?.date_updated||(L.push("`date_updated`"),O.push(Date())),d?.date_updated_code||(L.push("`date_updated_code`"),O.push(Date.now()));let A=`INSERT INTO \`${u}\` (${L.join(",")}) VALUES (${O.map(()=>"?").join(",")})`;return E?await y(A,O):await y({paradigm:t,database:r,queryString:A,queryValues:O})}e.exports=u},33364:(e,t,r)=>{let s=r(72583),n=r(16570),a=r(51348),o=r(21339),c=r(20503),i=r(44900);async function l({dbContext:e,paradigm:t,dbFullName:r,tableName:l,data:u,tableSchema:d,identifierColumnName:p,identifierValue:_,encryptionKey:S,encryptionSalt:D,useLocal:f}){if(!u||!Object.keys(u).length)return null;let g=!!f||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),h=f?i:g?a:o,E=Object.keys(u),y=[],m=[];for(let e=0;ee.fieldName===t):null,o=a&&a[0]?a[0]:null;if(null==r||void 0==r)continue;o?.richText&&(r=s(r,n)),o?.encrypted&&(r=c({data:r,encryptionKey:S,encryptionSalt:D})),"object"==typeof r&&(r=JSON.stringify(r)),o?.pattern&&!new RegExp(o.pattern,o.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"}}),y.push(`\`${t}\`=?`),"number"==typeof r?m.push(String(r)):m.push(r)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}y.push(`date_updated='${Date()}'`),y.push(`date_updated_code='${Date.now()}'`);let L=`UPDATE ${l} SET ${y.join(",")} WHERE \`${p}\`=?`;return m.push(_),g?await h(L,m):await h({paradigm:t,database:r,queryString:L,queryValues:m})}e.exports=l},16570:e=>{e.exports={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"]}}},20503:(e,t,r)=>{let{scryptSync:s,createCipheriv:n}=r(55511),{Buffer:a}=r(79428);e.exports=({data:e,encryptionKey:t,encryptionSalt:r})=>{if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let o=t||process.env.DSQL_ENCRYPTION_PASSWORD,c=r||process.env.DSQL_ENCRYPTION_SALT,i=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!o?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!c?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let l=n("aes-192-cbc",s(o,c,i),a.alloc(16,0));try{let t=l.update(e,"utf8","hex");return t+=l.final("hex")}catch(t){return console.log("Error in encrypting =>",t.message),e}}},51348:(e,t,r)=>{let s=r(9973),n=r(21580),a=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:n()}});async function o(...e){try{let t=await a.query(...e);return await a.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=o},21339:(e,t,r)=>{let s=r(29021);r(33873);let n=r(9973),a=r(21580),o=n({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,charset:"utf8mb4",ssl:a()}});e.exports=function({paradigm:e,database:t,queryString:r,queryValues:c}){try{return new Promise((i,l)=>{let u=!!e?.match(/full.access|^fa$/i);try{function d(e){o.end(),i(JSON.parse(JSON.stringify(e)))}function p(e){o.end(),i({error:e.message,queryStringGenerated:r,queryValuesGenerated:c,sql:e.sql})}o=u?n({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,database:t,ssl:a()}}):n({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,database:t,ssl:a()}}),c&&Array.isArray(c)&&c[0]?o.query(r,c).then(d).catch(p):o.query(r).then(d).catch(p)}catch(e){s.appendFileSync("./.tmp/dbErrorLogs.txt",e.message+"\n"+Date()+"\n\n\n","utf8"),i({error:e.message})}})}catch(e){return{success:!1,error:e.message}}}},44900:(e,t,r)=>{let s=r(9973),n=r(21580);async function a(...e){let t=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:n()},onConnect:()=>{console.log("Connection Successful!")},onConnectError:e=>{console.log("Connection Error",e.message)},onError:e=>{console.log("Client Error",e.message)}});console.log("Querying ...");try{let r=await t.query(...e);return await t.end(),JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e.message),{success:!1,error:e.message}}}e.exports=a},21580:(e,t,r)=>{let s=r(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!s.existsSync(t)){console.log(`${t} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},2706:(e,t)=>{var r;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(r||(r={}))},89947:(e,t,r)=>{e.exports=r(75600)}};