1 line
7.9 KiB
JavaScript
1 line
7.9 KiB
JavaScript
"use strict";exports.id=1251,exports.ids=[1251],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}}})},98e3:(e,t,r)=>{r.d(t,{A:()=>d});var n=r(72583),a=r.n(n),s=r(92652),o=r(30802),i=r(48786),c=r(37897),l=r(68829),u=r(62050);async function d({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:d,tableSchema:p,duplicateColumnName:_,duplicateColumnValue:S,update:f,encryptionKey:y,encryptionSalt:h,useLocal:g}){let D=!!g||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),A=g?u.A:D?i.A:c.A;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 a=D?await A(`SELECT * FROM \`${n}\` WHERE \`${_}\`=?`,[S]):await A({paradigm:"Read Only",queryString:`SELECT * FROM \`${r}\`.\`${n}\` WHERE \`${_}\`=?`,queryValues:[S]});if(a?.[0]&&!f)return null;if(a&&a[0]&&f)return await (0,o.A)({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:d,tableSchema:p,encryptionKey:y,encryptionSalt:h,identifierColumnName:_,identifierValue:S||""})}let E=Object.keys(d),L=[],m=[];for(let e=0;e<E.length;e++)try{let t=E[e],r=d?.[t],n=p?p?.fields?.filter(e=>e.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:y,encryptionSalt:h}),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=""),L.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?m.push(String(r)):m.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message);continue}d?.date_created||(L.push("`date_created`"),m.push(Date())),d?.date_created_code||(L.push("`date_created_code`"),m.push(Date.now())),d?.date_updated||(L.push("`date_updated`"),m.push(Date())),d?.date_updated_code||(L.push("`date_updated_code`"),m.push(Date.now()));let N=`INSERT INTO \`${r}\`.\`${n}\` (${L.join(",")}) VALUES (${m.map(()=>"?").join(",")})`;return D?await A(N,m):await A({paradigm:t,queryString:N,queryValues:m})}},30802:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(72583),a=r.n(n),s=r(92652),o=r(48786),i=r(37897),c=r(68829),l=r(62050);async function u({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:u,tableSchema:d,identifierColumnName:p,identifierValue:_,encryptionKey:S,encryptionSalt:f,useLocal:y}){if(!u||!Object.keys(u).length)return null;let h=!!y||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),g=y?l.A:h?o.A:i.A,D=Object.keys(u),A=[],E=[];for(let e=0;e<D.length;e++)try{let t=D[e],r=u[t],n=d?d?.fields?.filter(e=>e.fieldName===t):null,o=n&&n[0]?n[0]:null;if(null==r||void 0==r)continue;let i=/<[^>]+>/g;(o?.richText||String(r).match(i))&&(r=a()(r,s.A)),o?.encrypted&&(r=(0,c.A)({data:r,encryptionKey:S,encryptionSalt:f})),"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"}}),A.push(`\`${t}\`=?`),"number"==typeof r?E.push(String(r)):E.push(r)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}A.push(`date_updated='${Date()}'`),A.push(`date_updated_code='${Date.now()}'`);let L=`UPDATE \`${r}\`.\`${n}\` SET ${A.join(",")} WHERE \`${p}\`=?`;return E.push(_),h?await g(L,E):await g({paradigm:t,queryString:L,queryValues:E})}},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"]}}},68829:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(55511),a=r(79428),s=r(32443);function o({data:e,encryptionKey:t,encryptionSalt:r}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:o,salt:i,keyLen:c,algorithm:l,bufferAllocSize:u}=(0,s.A)({encryptionKey:t});if(!o?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let d=(0,n.scryptSync)(o,i,c),p=a.Buffer.alloc(u,0),_=(0,n.createCipheriv)(l,d,p);try{let t=_.update(e,"utf8","hex");return t+=_.final("hex")}catch(t){return console.log("Error in encrypting =>",t.message),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 console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await t?.end()}}},37897:(e,t,r)=>{r.d(t,{A:()=>s});var n=r(64292),a=r(7447);async function s({paradigm:e,queryString:t,queryValues:r}){let s="Read Only"==e?(0,a.A)({ro:!0}):(0,a.A)({fa:!0});try{return await (0,n.A)(s,t,r)}catch(e){return console.log(`DSQL_USER_DB_HANDLER Error: ${e.message}`),null}finally{s?.end()}}},62050:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(7447);async function a(...e){let t=(0,n.A)();console.log("Querying ...");try{let r=await t.query(...e);return JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e.message),{success:!1,error:e.message}}finally{await t?.end()}}},64292:(e,t,r)=>{async function n(e,t,r){try{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;n<t.length;n++)try{let s=t[n],o=await e.query(a(s.query),s.values);r.push(JSON.parse(JSON.stringify(o)))}catch(e){r.push(null)}return r}}catch(e){return null}finally{e.end()}}function a(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}r.d(t,{A:()=>n})},7447:(e,t,r)=>{r.d(t,{A:()=>s});var n=r(9973),a=r.n(n);function s(e){return e?.ro?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"}})}},32443:(e,t,r)=>{r.d(t,{A:()=>n});function n(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?function(e,t){try{let t=Number(e);if("number"!=typeof t||isNaN(t))return 0;return Math.round(t)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},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)}}; |