UNPKG

lambdaorm

Version:
1 lines 14.7 kB
'use strict';const a113l=a113y;function a113s(){const sM=['getChildrenMap','\x20not\x20found','570048fgCoQN','Insert','first','getInfo','str','buildInsertSentence','OperandType','buildSentence','buildObject','../base/dmlBuilder','helper','Filter','composite','}\x20}','{prefix}','1674302roBPHj','type','getEntity','action','buildField','mapping\x20undefined\x20on\x20','CallFunc','stringify','\x20entity','length','List','replaceRoot','defaults','\x22$$this.','map\x20operator\x20not\x20found','filter','map','obj','dql','SintaxisError','replace','\x20,\x20','{in}','category','_id','2DPYORc','min','parameters','rootMap','hadGroupFunction','isNumber','columns','function','field','delimiter','buildArrowFunction','source','Query','solveHaving','entity','groupBy','271796KVlnvJ','operator','Include','find','rootFilter','getProperty','1505043rsdvzD','values','buildUpdateSentence','Update','mapping','$project','buildSelectSentence','template','rootGroupBy','name','other','relation\x20','buildJoins','buildDeleteSentence','getCompositeIncludes','properties','parse','prefix','slice','update','{toProperty}','\x22$\x5c\x22','last','\x22$this.','2183688chkvcL','dialect','alias','!==','getFieldMapping','Operand','{input}','split','5108336pSrFSQ','joinField','relations','{1}','{entityAlias}','Operator','Obj','parent\x20entity\x20\x20','relation','$group','3xpr','existsProperty','\x5c\x22\x22','children','dml','equal','getGroupBy','query','insert','{value}','buildFilter','join','{alias}','SchemaError','getMap','count','lambdaorm-base','{0}','page','setPrefixToField','\x20not\x20found\x20in\x20','val','avg','entries','update\x20operand\x20not\x20found','push','buildReplaceRoot','bulkInsert','column','2456730feGlKR','DmlBuilderBase','buildOperand','NoSqlDmlBuilder','getComposite','build','getHaving','{name}'];a113s=function(){return sM;};return a113s();}(function(s,y){const b=a113y,g=s();while(!![]){try{const x=-parseInt(b(0x12e))/0x1+-parseInt(b(0x1ad))/0x2*(parseInt(b(0x134))/0x3)+-parseInt(b(0x185))/0x4+parseInt(b(0x17b))/0x5+parseInt(b(0x14c))/0x6+-parseInt(b(0x194))/0x7+parseInt(b(0x154))/0x8;if(x===y)break;else g['push'](g['shift']());}catch(m){g['push'](g['shift']());}}}(a113s,0x52ae5));function a113y(s,y){const O=a113s();return a113y=function(D,g){D=D-0x121;let M=O[D];return M;},a113y(s,y);}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[a113l(0x17e)]=void 0x0;const _3xpr_1=require(a113l(0x15e)),lambdaorm_base_1=require(a113l(0x16e)),domain_1=require('../../../../query/domain'),dmlBuilder_1=require(a113l(0x18e));class NoSqlDmlBuilder extends dmlBuilder_1[a113l(0x17c)]{[a113l(0x180)](s){const u=a113l,y=this[u(0x18f)][u(0x165)][u(0x188)](s['action'],s[u(0x12c)]),g=[];if(y[u(0x195)]!==lambdaorm_base_1['SentenceType'][u(0x1a6)]){const m=s['getCompositeIncludes']();for(const w of m){const t=w[u(0x161)][0x0],v=this[u(0x180)](t),a=new domain_1[(u(0x130))](w[u(0x13d)],v,w[u(0x15c)]);g[u(0x177)](a);}}const x=this[u(0x18c)](s);return new domain_1[(u(0x12a))]({'action':y[u(0x197)],'type':y[u(0x195)],'category':y[u(0x1ab)],'description':y['action']+'\x20'+s[u(0x12c)],'dialect':this[u(0x129)][u(0x14d)],'source':this[u(0x129)][u(0x13d)],'sentence':x,'entity':s['entity'],'columns':s[u(0x124)],'parameters':s[u(0x1af)],'constraints':s['constraints'],'values':s[u(0x135)],'defaults':s[u(0x1a0)],'includes':g});}[a113l(0x13a)](s){const e=a113l,y=s[e(0x161)][e(0x131)](z=>z['name']===e(0x1a4)),g=s['children'][e(0x1a3)](z=>z instanceof lambdaorm_base_1['Join']),x=s['children'][e(0x131)](z=>z['name']==='filter'),m=s['children'][e(0x131)](z=>z[e(0x13d)]===e(0x12d)),w=s[e(0x161)]['find'](z=>z[e(0x13d)]==='having'),t=s[e(0x161)][e(0x131)](z=>z[e(0x13d)]==='sort'),v=s['children']['find'](z=>z['name']===e(0x170)),a=this[e(0x138)][e(0x196)](s[e(0x12c)]);if(a===undefined)throw new lambdaorm_base_1[(e(0x16b))](e(0x199)+s[e(0x12c)]+'\x20entity');if(y===undefined)throw new lambdaorm_base_1[(e(0x16b))]('map\x20operator\x20not\x20found');const c=[];a[e(0x191)]&&c[e(0x177)](...this[e(0x178)](a));g['length']>0x0&&c[e(0x177)](...this[e(0x140)](a,g));x&&c['push'](...this[e(0x168)](x));m||this['hadGroupFunction'](y)?(c[e(0x177)](...this['getGroupBy'](y,s)),w&&c[e(0x177)](...this[e(0x181)](c,w))):c[e(0x177)](...this[e(0x16c)](y,s));if(t){const z=this['buildArrowFunction'](t);c[e(0x177)](JSON['parse'](z));}const k=c[e(0x1a3)](d=>d[e(0x139)]!==undefined);if(k[e(0x19d)]>0x0)for(const d of k){for(const i of Object[e(0x175)](d['$project'])){i[0x0]!==e(0x1ac)&&this[e(0x18f)][e(0x173)][e(0x123)](i[0x1])&&(d[e(0x139)][i[0x0]]={'$literal':i[0x1]});}}else c[e(0x177)]({'$project':{'_id':0x0}});let r=JSON['stringify'](c);return v?(r=r['substring'](0x1),r=r['substring'](0x0,r[e(0x19d)]-0x1),r=this['buildPage'](r,v),'['+r+']'):r;}[a113l(0x18a)](s){const n=a113l;var y;const g=s[n(0x197)]===n(0x179)?s[n(0x161)]['find'](v=>v instanceof lambdaorm_base_1['BulkInsert']):s['children']['find'](v=>v instanceof lambdaorm_base_1[n(0x186)]),x=this[n(0x138)][n(0x196)](s['entity']);if(x===undefined)throw new lambdaorm_base_1[(n(0x16b))]('mapping\x20undefined\x20on\x20'+s[n(0x12c)]+n(0x19c));if(g===undefined)throw new lambdaorm_base_1[(n(0x16b))]('insert\x20operand\x20not\x20found');const m=[],w=this[n(0x14d)][n(0x162)](n(0x166)),t=this[n(0x14d)][n(0x12f)]('=',0x2);if(g['children'][0x0][n(0x195)]===_3xpr_1['OperandType'][n(0x15a)]){const v=g[n(0x161)][0x0];for(const a in v[n(0x161)]){const c=v[n(0x161)][a];let k;const r=(y=x[n(0x143)])===null||y===void 0x0?void 0x0:y['find'](i=>i[n(0x13d)]===c['name']);r?k=r['mapping']:k=c['name'];const z=this[n(0x17d)](c[n(0x161)][0x0]);let d=this[n(0x18f)][n(0x189)][n(0x1a8)](t,n(0x16f),k);d=this[n(0x18f)][n(0x189)][n(0x1a8)](d,n(0x157),z),m[n(0x177)](d);}}return this[n(0x18f)][n(0x189)]['replace'](w,'{assigns}',m[n(0x169)](','));}[a113l(0x136)](s){const h=a113l;var y;const g=s[h(0x161)][h(0x131)](k=>k instanceof lambdaorm_base_1[h(0x190)]),x=this[h(0x138)][h(0x196)](s['entity']),m=s[h(0x161)][h(0x131)](k=>k instanceof lambdaorm_base_1[h(0x137)]);if(x===undefined)throw new lambdaorm_base_1[(h(0x16b))](h(0x199)+s[h(0x12c)]+h(0x19c));if(m===undefined)throw new lambdaorm_base_1[(h(0x1a7))](h(0x176));const w=this[h(0x14d)][h(0x162)](h(0x147)),t=this[h(0x14d)]['operator']('=',0x2),v=[];if(m['children'][0x0]['type']===_3xpr_1[h(0x18b)][h(0x15a)]){const k=m[h(0x161)][0x0];for(const r in k[h(0x161)]){const z=k[h(0x161)][r];let d;const i=(y=x[h(0x143)])===null||y===void 0x0?void 0x0:y[h(0x131)](j=>j[h(0x13d)]===z['name']);i?d=i['mapping']:d=z['name'];const o=this['dialect'][h(0x127)](d,![],!![]),f=this[h(0x17d)](z[h(0x161)][0x0]);let q=this[h(0x18f)][h(0x189)][h(0x1a8)](t,h(0x16f),o);q=this[h(0x18f)]['str'][h(0x1a8)](q,h(0x157),f),v['push'](q);}}const a=this['helper']['str'][h(0x1a8)](w,'{assigns}',v[h(0x169)](',')),c={'set':a,'filter':g?this[h(0x128)](g):'{}'};return JSON[h(0x19b)](c);}[a113l(0x141)](s){const s0=a113l,y=this[s0(0x138)][s0(0x196)](s[s0(0x12c)]),g=s[s0(0x161)][s0(0x131)](m=>m[s0(0x13d)]===s0(0x1a3));if(y===undefined)throw new lambdaorm_base_1['SchemaError']('mapping\x20undefined\x20on\x20'+s[s0(0x12c)]+'\x20entity');const x={'filter':g?this['buildArrowFunction'](g):{}};return JSON['stringify'](x);}[a113l(0x198)](s){const s1=a113l;if(this[s1(0x138)]['existsProperty'](s[s1(0x12c)],s['name'])){const y=this[s1(0x138)][s1(0x133)](s['entity'],s['name']);let g;if(s['alias']===undefined)g=s1(0x17a);else s['isRoot']?g=s1(0x126):g=s['prefix']?'projectJoinField':s1(0x155);let x=this['dialect'][s1(0x13e)](g);return x=this[s1(0x18f)][s1(0x189)]['replace'](x,s1(0x158),s[s1(0x14e)]||''),x=this[s1(0x18f)][s1(0x189)]['replace'](x,s1(0x193),s[s1(0x145)]||''),x=this['helper']['str'][s1(0x1a8)](x,s1(0x182),y[s1(0x138)]),x;}else return this[s1(0x14d)][s1(0x127)](s[s1(0x13d)],!![]);}[a113l(0x18d)](s){const s2=a113l;let y='';const g=this[s2(0x14d)][s2(0x125)]('as')[s2(0x13b)];for(let x=0x0;x<s[s2(0x161)]['length'];x++){const m=s['children'][x],w=this[s2(0x17d)](m);if(m[s2(0x161)]['length']===0x1&&[_3xpr_1[s2(0x18b)][s2(0x19e)],_3xpr_1['OperandType'][s2(0x15a)]]['includes'](m['children'][0x0][s2(0x195)]))y=w;else{const t=this['dialect'][s2(0x127)](m[s2(0x13d)],!![]);let v=this[s2(0x18f)][s2(0x189)][s2(0x1a8)](g,s2(0x167),w);v=this[s2(0x18f)][s2(0x189)][s2(0x1a8)](v,s2(0x16a),t),y+=(x>0x0?',\x20':'')+v;}}return y;}['buildReplaceRoot'](s){const s3=a113l,y=s[s3(0x13d)][s3(0x153)]('.'),g=[];for(let k=0x1;k<y[s3(0x19d)];k++){const r=y[s3(0x146)](0x0,k+0x1)[s3(0x169)]('.'),z=this[s3(0x138)][s3(0x196)](r);if(z===undefined)throw new lambdaorm_base_1[(s3(0x16b))]('child\x20entity\x20\x20'+r+s3(0x172)+s[s3(0x13d)]);g[s3(0x177)](this[s3(0x14d)][s3(0x127)](z[s3(0x138)]||z[s3(0x13d)],!![]));}const x=y['slice'](0x0,y['length']-0x1)[s3(0x169)]('.'),m=this[s3(0x138)][s3(0x196)](x);if(m===undefined)throw new lambdaorm_base_1[(s3(0x16b))](s3(0x15b)+x+s3(0x172)+s[s3(0x13d)]);const w=y[y['length']-0x1],t=m[s3(0x156)]?m[s3(0x156)]['find'](d=>d['name']===w):undefined;if(t===undefined)throw new lambdaorm_base_1[(s3(0x16b))](s3(0x13f)+w+s3(0x172)+x);let v='$'+g['join']('.');v=this[s3(0x18f)]['str'][s3(0x1a8)](v,'\x22','\x5c\x22');let a='';t['type']===lambdaorm_base_1['RelationType']['manyToOne']&&(a=this[s3(0x18f)][s3(0x189)][s3(0x1a8)](this[s3(0x14d)][s3(0x162)]('unwind'),s3(0x16f),v));const c=this['dialect'][s3(0x162)](s3(0x19f));return v=this['helper'][s3(0x189)][s3(0x1a8)](c,s3(0x16f),v),a=a!==''?a+',\x20'+v:v,JSON['parse']('['+a+']');}[a113l(0x181)](s,y){const s4=a113l,g=s[s4(0x131)](t=>t[s4(0x15d)]!==undefined),x=Object[s4(0x175)](g[s4(0x15d)]),m=[];this[s4(0x12b)](y[s4(0x161)][0x0],x,m);let w=this[s4(0x128)](y);for(const t of m){w=this[s4(0x18f)][s4(0x189)][s4(0x1a8)](w,t[0x0],'\x22'+t[0x1]+'\x22');}return w=this[s4(0x18f)][s4(0x189)]['replace'](w,'{\x20{','{'),w=this[s4(0x18f)]['str'][s4(0x1a8)](w,s4(0x192),'}'),JSON['parse']('['+w+']');}['solveHaving'](s,y,g){const s5=a113l;for(let x=0x0,m=s[s5(0x161)]['length'];x<m;x++){const w=s[s5(0x161)][x];if(this[s5(0x122)](w)){const t=this[s5(0x17d)](w),v=y[s5(0x131)](a=>this[s5(0x18f)][s5(0x189)][s5(0x163)](JSON[s5(0x19b)](a[0x1]),t,{'normalize':!![]}));v&&g[s5(0x177)]([t,v[0x0]]);}else w[s5(0x161)]&&w[s5(0x161)][s5(0x19d)]>0x0&&this['solveHaving'](w,y,g);}}[a113l(0x164)](s,y){const s6=a113l;this[s6(0x171)](s,'$');let g='';const x=[],m=[];if(s[s6(0x161)][0x0]['type']===_3xpr_1[s6(0x18b)][s6(0x15a)]){const r=s[s6(0x161)][0x0];for(const z in r[s6(0x161)]){const d=r[s6(0x161)][z];let i;this[s6(0x122)](d[s6(0x161)][0x0])?(m[s6(0x177)](d),i='\x22'+d[s6(0x13d)]+'\x22:\x22$'+d[s6(0x13d)]+'\x22'):(x[s6(0x177)](d),i='\x22'+d[s6(0x13d)]+'\x22:\x22$_id.'+d[s6(0x13d)]+'\x22'),g?g=g+s6(0x1a9)+i:g=''+i;}}let w=this['buildOperand'](new _3xpr_1['Operand'](s['pos'],s6(0x1a5),_3xpr_1['OperandType'][s6(0x15a)],x));const t=this[s6(0x17d)](new _3xpr_1[(s6(0x151))](s['pos'],s6(0x1a5),_3xpr_1[s6(0x18b)][s6(0x15a)],m)),v=this['getComposite'](y);v&&(w=w+'\x20,'+v);const a=this[s6(0x14d)][s6(0x162)](s6(0x13c)),c=this[s6(0x14d)][s6(0x162)](s6(0x121));let k=this[s6(0x18f)][s6(0x189)][s6(0x1a8)](a,s6(0x16f),w);return k=this[s6(0x18f)][s6(0x189)][s6(0x1a8)](k,s6(0x157),t),k=k+',\x20'+this['helper'][s6(0x189)]['replace'](c,s6(0x16f),g),k=this['helper']['str'][s6(0x1a8)](k,s6(0x14b),s6(0x1a1)),JSON[s6(0x144)]('['+k+']');}[a113l(0x16c)](s,y){const s7=a113l;this[s7(0x171)](s,'$');let g=this[s7(0x128)](s);const x=this[s7(0x17f)](y);x&&(g=g+'\x20,'+x);if(s[s7(0x161)][0x0][s7(0x195)]===_3xpr_1[s7(0x18b)][s7(0x19a)]&&s[s7(0x161)][0x0]['name']==='distinct')return JSON['parse']('['+g+']');else{const m=this[s7(0x14d)][s7(0x162)](s7(0x121)),w=this['helper']['str'][s7(0x1a8)](m,s7(0x16f),g);return JSON[s7(0x144)]('['+w+']');}}[a113l(0x17f)](s){const s8=a113l,y=s[s8(0x142)]();if(y['length']>0x0){let g='';const x=this['dialect'][s8(0x162)](s8(0x191));for(const m in y){const w=y[m],t=this[s8(0x138)][s8(0x196)](w[s8(0x15c)][s8(0x12c)]);if(t===undefined)throw new lambdaorm_base_1[(s8(0x16b))]('EntityMapping\x20'+w[s8(0x15c)]['entity']+s8(0x184));const v=s8(0x149)+t['mapping']+s8(0x160),a=this[s8(0x183)](w['children'][0x0]);let c=this[s8(0x18f)][s8(0x189)][s8(0x1a8)](x,s8(0x182),w[s8(0x15c)][s8(0x13d)]);c=this[s8(0x18f)]['str'][s8(0x1a8)](c,s8(0x152),v),c=this[s8(0x18f)]['str'][s8(0x1a8)](c,s8(0x1aa),a),g=g===''?c:g+'\x20,'+c;}return g;}else return undefined;}[a113l(0x183)](s){const s9=a113l,y=s[s9(0x161)]['find'](m=>m[s9(0x13d)]===s9(0x1a4));if(y===undefined)throw new lambdaorm_base_1[(s9(0x16b))](s9(0x1a2));this[s9(0x171)](y,'$$this.');let g=this[s9(0x128)](y);const x=this[s9(0x17f)](s);return x&&(g=g+'\x20,'+x),g;}[a113l(0x140)](s,y){const ss=a113l;let g='';const x=this[ss(0x14d)][ss(0x162)](ss(0x169));for(const m of y){this[ss(0x171)](m,'$');const w=this['mapping'][ss(0x196)](m[ss(0x13d)]);if(w===undefined)throw new lambdaorm_base_1[(ss(0x16b))]('not\x20found\x20mapping\x20for\x20'+m['name']);const t=m[ss(0x161)][0x0][ss(0x161)][0x0],v=m['children'][0x0][ss(0x161)][0x1],a=s['name']!==m[ss(0x12c)]?v[ss(0x14e)]:undefined;let c=this['helper'][ss(0x189)]['replace'](x,ss(0x182),this['dialect']['delimiter'](w[ss(0x138)]||w[ss(0x13d)],!![]));c=this[ss(0x18f)][ss(0x189)]['replace'](c,'{fromProperty}',this[ss(0x150)](v)),c=this[ss(0x18f)]['str'][ss(0x1a8)](c,ss(0x148),this[ss(0x150)](t,a)),c=this[ss(0x18f)]['str'][ss(0x1a8)](c,ss(0x16a),this['dialect']['delimiter'](m[ss(0x14e)],!![])),g=g!==''?g+',\x20'+c:c;}return JSON['parse']('['+g+']');}[a113l(0x168)](s){const sy=a113l,y=this[sy(0x14d)][sy(0x162)](sy(0x132)),g=this[sy(0x18f)][sy(0x189)][sy(0x1a8)](y,sy(0x16f),this[sy(0x128)](s));return JSON[sy(0x144)]('['+g+']');}[a113l(0x150)](s,y){const sO=a113l;let g='';if(this[sO(0x138)][sO(0x15f)](s[sO(0x12c)],s[sO(0x13d)])){const x=this['mapping'][sO(0x133)](s[sO(0x12c)],s[sO(0x13d)]);g=x[sO(0x138)];}else g=s['name'];return y?this['dialect']['delimiter'](y+'.'+g,!![]):this[sO(0x14d)]['delimiter'](g,!![]);}['setPrefixToField'](s,y){const sD=a113l;s instanceof lambdaorm_base_1['Field']&&(s[sD(0x145)]=y);if(s[sD(0x161)]!==null&&s[sD(0x161)]!==undefined)for(const g in s[sD(0x161)]){const x=s[sD(0x161)][g];if(x['type']===_3xpr_1[sD(0x18b)][sD(0x159)]&&(x[sD(0x13d)]==='='||x[sD(0x13d)]==='=='||x['name']==='==='||x['name']==='!='||x[sD(0x13d)]===sD(0x14f))){const m=x[sD(0x161)][0x1];this[sD(0x171)](m,y);}else this[sD(0x171)](x,y);}}[a113l(0x122)](s){const sg=a113l;if(s[sg(0x195)]===_3xpr_1[sg(0x18b)][sg(0x19a)]&&[sg(0x174),sg(0x16d),sg(0x187),sg(0x14a),'max',sg(0x1ae),'sum']['includes'](s[sg(0x13d)]))return!![];if(s[sg(0x161)])for(const y in s[sg(0x161)]){const g=s[sg(0x161)][y];if(this['hadGroupFunction'](g))return!![];}return![];}}exports['NoSqlDmlBuilder']=NoSqlDmlBuilder;