dsql-admin/dsql-app/.local_dist/server/chunks/5194.js

16 lines
9.3 KiB
JavaScript
Raw Normal View History

2025-01-28 18:43:16 +00:00
"use strict";exports.id=5194,exports.ids=[5194],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}}})},96551:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(9288),a=r.n(n),o=r(67619),l=r(45185);async function i({imageSourceBase64:e,imageName:t,userId:r,mimeType:n,thumbnailSize:i,folder:s,isPrivate:u}){try{let o=Buffer.from(e,"base64"),c=i?parseInt(i.toString()):400,d=a()(o),p=a()(o),_=(0,l.A)({isPrivate:u,userId:r,folder:s});if(!_)return null;let{fileRootPath:f,urlRootPath:g,relativePath:m}=_,{width:S,height:h,format:y}=await d.metadata(),E=n||y;S&&h&&S>1800&&d.resize(1800,Math.round(1800/S*h),{fit:"cover"}),d.toFormat(E,{quality:80}),await d.metadata();let N=`${t}.${E}`;if(await d.toFile(f+N),S&&h&&S>c){let e=c/S;p.resize(c,Math.round(h*e),{fit:"cover"})}else S&&h&&p.resize(150,Math.round(150/S*h),{fit:"cover"});p.toFormat(E,{quality:80});let A=`${t}_thumbnail.${E}`;return await p.toFile(f+A),{urlPath:g+N,urlThumbnailPath:g+A,urlRelativePath:m+N,urlThumbnailRelativePath:m+A}}catch(e){return console.log("Write Image to Disk error =>",e.message),(0,o.A)({component:"functions/backend/fsWriteImageToDiskFromBase64",message:e.message}),null}}},45185:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(29021),a=r.n(n),o=r(33873),l=r.n(o);function i({isPrivate:e,userId:t,folder:r,video:n,pathOnly:o}){"production".match(/production/);let i=process.env.DSQL_STATIC_SERVER_DIR;if(!i)return console.log("Static File ENV not Found!"),null;let s=e?`@/${n?"videos":"media"}/${r?r+"/":""}`:n?`/videos/user-videos/user-${t}/${r?r+"/":""}`:`/images/user-images/user-${t}/${r?r+"/":""}`,u=e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t}/media/${r?r+"/":""}`:l().join(i,s);return a().existsSync(u)||o||a().mkdirSync(u,{recursive:!0}),{fileRootPath:u,urlRootPath:e?`@/media/${r?r+"/":""}`:`${process.env.DSQL_STATIC_HOST}${s}`,relativePath:s}}},98e3:(e,t,r)=>{r.d(t,{A:()=>c});var n=r(72583),a=r.n(n),o=r(92652),l=r(30802),i=r(68829),s=r(64292),u=r(52939);async function c({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:c,tableSchema:d,duplicateColumnName:p,duplicateColumnValue:_,update:f,encryptionKey:g,encryptionSalt:m}){let S=(0,u.A)({dbContext:e,dbFullName:r}),h=S?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN,y=S?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;if(c?.date_created_timestamp&&delete c.date_created_timestamp,c?.date_updated_timestamp&&delete c.date_updated_timestamp,c?.date_updated&&delete c.date_updated,c?.date_updated_code&&delete c.date_updated_code,c?.date_created&&delete c.date_created,c?.date_created_code&&delete c.date_created_code,p&&"string"==typeof p){let t=`SELECT * FROM ${S?"":`\`${r}\`.`}\`${n}\` WHERE \`${p}\`=?`,a=await (0,s.A)(y,t,[_]);if(a?.[0]&&!f)return null;if(a&&a[0]&&f)return await (0,l.A)({dbContext:e,dbFullName:r,tableName:n,data:c,tableSchema:d,encryptionKey:g,encryptionSalt:m,identifierColumnName:p,identifierValue:_||""})}let E=Object.keys(c),N=[],A=[];for(let e=0;e<E.length;e++)try{let t=E[e],r=c?.[t],n=d?d?.fields?.filter(e=>e.fieldName==t):null,l=n&&n[0]?n[0]:null;if(null==r||void 0==r||l?.dataType?.match(/int$/i)&&"string"==typeof r&&!r?.match(/./))continue;l?.encrypted&&(r=(0,i.A)({data:r,encryptionKey:g,encryptionSalt:m}),console.log("DSQL: Encrypted value =>",r));let s=/<[^>]+>/g;(l?.richText||String(r).match(s))&&(r=a()(r,o.A)),l?.pattern&&!new RegExp(l.pattern,l.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),N.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?A.push(String(r)):A.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message);continue}c?.date_created||(N.push("`date_created`"),A.push(Date())),c?.date_created_code||(N.push("`date_created_code`"),A.push(Date.now())),c?.date_updated||(N.push("`date_updated`"),A.push(Date())),c?.date_updated_code||(N.push("`date_updated_code`"),A.push(Date.now()));let D=`INSE
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}`),o?.url&&(n+=`
URL: ${o.url}`),o?.body&&(n+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),i&&(n+=`
IP: ${i}`),n+=`
Date: ${l.toDateString()}
========================================`,a().existsSync("./.tmp/error.log")||a().writeFileSync("./.tmp/error.log","","utf-8");let s=a().readFileSync("./.tmp/error.log","utf-8");a().writeFileSync("./.tmp/error.log",n),a().appendFileSync("./.tmp/error.log",`
${s}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},68829:(e,t,r)=>{r.d(t,{A:()=>l});var n=r(55511),a=r(79428),o=r(32443);function l({data:e,encryptionKey:t,encryptionSalt:r}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:l,salt:i,keyLen:s,algorithm:u,bufferAllocSize:c}=(0,o.A)({encryptionKey:t});if(!l?.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)(l,i,s),p=a.Buffer.alloc(c,0),_=(0,n.createCipheriv)(u,d,p);try{let t=_.update(e,"utf8","hex");return t+=_.final("hex")}catch(t){return console.log("Error in encrypting =>",t.message),e}}},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;n<t.length;n++)try{let o=t[n],l=await e.query(a(o.query),o.values);r.push(JSON.parse(JSON.stringify(l)))}catch(e){console.log(`connDbHandler Query Error: ${e.message}`),r.push(null)}return r}}catch(e){return console.log(`connDbHandler Error: ${e.message}`),null}finally{e?.end()}}function a(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}r.d(t,{A:()=>n})},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)}};