1 line
7.1 KiB
JavaScript
1 line
7.1 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),o=r(92652),s=r(30802),l=r(48786),c=r(37275),i=r(68829),u=r(7971);async function d({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:d,tableSchema:p,duplicateColumnName:f,duplicateColumnValue:_,update:g,encryptionKey:h,encryptionSalt:y,useLocal:S}){let E=!!S||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),m=S?u.A:E?l.A:c.default;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,f&&"string"==typeof f){let a=E?await m(`SELECT * FROM \`${n}\` WHERE \`${f}\`=?`,[_]):await m({paradigm:"Read Only",queryString:`SELECT * FROM \`${r}\`.\`${n}\` WHERE \`${f}\`=?`,queryValues:[_]});if(a?.[0]&&!g)return null;if(a&&a[0]&&g)return await (0,s.A)({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:d,tableSchema:p,encryptionKey:h,encryptionSalt:y,identifierColumnName:f,identifierValue:_||""})}let D=Object.keys(d),A=[],N=[];for(let e=0;e<D.length;e++)try{let t=D[e],r=d?.[t],n=p?p?.fields?.filter(e=>e.fieldName==t):null,s=n&&n[0]?n[0]:null;if(null==r||void 0==r||s?.dataType?.match(/int$/i)&&"string"==typeof r&&!r?.match(/./))continue;s?.encrypted&&(r=(0,i.default)({data:r,encryptionKey:h,encryptionSalt:y}),console.log("DSQL: Encrypted value =>",r));let l=/<[^>]+>/g;(s?.richText||String(r).match(l))&&(r=a()(r,o.A)),s?.pattern&&!new RegExp(s.pattern,s.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),A.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?N.push(String(r)):N.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message);continue}d?.date_created||(A.push("`date_created`"),N.push(Date())),d?.date_created_code||(A.push("`date_created_code`"),N.push(Date.now())),d?.date_updated||(A.push("`date_updated`"),N.push(Date())),d?.date_updated_code||(A.push("`date_updated_code`"),N.push(Date.now()));let L=`INSERT INTO \`${r}\`.\`${n}\` (${A.join(",")}) VALUES (${N.map(()=>"?").join(",")})`;return E?await m(L,N):await m({paradigm:t,queryString:L,queryValues:N})}},30802:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(72583),a=r.n(n),o=r(92652),s=r(48786),l=r(37275),c=r(68829),i=r(7971);async function u({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:u,tableSchema:d,identifierColumnName:p,identifierValue:f,encryptionKey:_,encryptionSalt:g,useLocal:h}){if(!u||!Object.keys(u).length)return null;let y=!!h||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),S=h?i.A:y?s.A:l.default,E=Object.keys(u),m=[],D=[];for(let e=0;e<E.length;e++)try{let t=E[e],r=u[t],n=d?d?.fields?.filter(e=>e.fieldName===t):null,s=n&&n[0]?n[0]:null;if(null==r||void 0==r)continue;let l=/<[^>]+>/g;(s?.richText||String(r).match(l))&&(r=a()(r,o.A)),s?.encrypted&&(r=(0,c.default)({data:r,encryptionKey:_,encryptionSalt:g})),"object"==typeof r&&(r=JSON.stringify(r)),s?.pattern&&!new RegExp(s.pattern,s.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"}}),m.push(`\`${t}\`=?`),"number"==typeof r?D.push(String(r)):D.push(r)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}m.push(`date_updated='${Date()}'`),m.push(`date_updated_code='${Date.now()}'`);let A=`UPDATE \`${r}\`.\`${n}\` SET ${m.join(",")} WHERE \`${p}\`=?`;return D.push(f),y?await S(A,D):await S({paradigm:t,queryString:A,queryValues:D})}},92652:(e,t,r)=>{r.d(t,{A:()=>n});let n={allowedTags:["b","i","em","strong","a","p","span","
|