UNPKG

lambdaorm

Version:
1 lines 9.47 kB
'use strict';function a115s(){const s5=['Update','8305722kKbEeI','SchemaError','action','dml','filter','from','__esModule','not\x20found\x20mapping\x20for\x20','11607RTqjer','Insert','values','lambdaorm-base','buildArrowFunction','properties','query','build','buildSelectSentence','mapping','map','Obj','push','Oracle','{entityAlias}','buildDeleteSentence','source','dialect','../../../../query/domain','7152507DbyXhb','{1}','getSentenceType','delimiter','buildField','map\x20operand\x20not\x20found','OperandType','insert','insert\x20operand\x20not\x20found','Join','columns','alias','{autoIncrementField}','PostgreSQL','BulkInsert','parameters','operator','{value}','1224XkkvSG','getSentenceCategory','mapping\x20undefined\x20on\x20','{assigns}','Delete','delete\x20operand\x20not\x20found','3xpr','Query','1878340DrOrRG','20bytgpK','sequence','length','822943owCzMa','includes','buildObject','fieldName','SqlDmlBuilder','DmlBuilderBase','children','12WZhyky','36015ZcoBnc','column','getAutoIncrement','{name}','5zoMeXT','buildJoins','having','../base/dmlBuilder','buildPage','replace','entity','{relation}','getProperty','buildInsertSentence','other','sort','{fields}','helper','function','From','str','join','name','662peUAIc','buildFrom','{alias}','template','existsProperty','trim','bulkInsert','constraints','\x20entity','page','find','buildOperand','getEntity','29963230VnSMzv','{values}','{0}'];a115s=function(){return s5;};return a115s();}const a115l=a115y;(function(s,y){const b=a115y,g=s();while(!![]){try{const x=parseInt(b(0x108))/0x1+parseInt(b(0x127))/0x2*(parseInt(b(0xd7))/0x3)+-parseInt(b(0x104))/0x4*(-parseInt(b(0x114))/0x5)+-parseInt(b(0xcf))/0x6+parseInt(b(0x110))/0x7*(parseInt(b(0xfc))/0x8)+parseInt(b(0xea))/0x9*(parseInt(b(0x105))/0xa)+parseInt(b(0x134))/0xb*(-parseInt(b(0x10f))/0xc);if(x===y)break;else g['push'](g['shift']());}catch(m){g['push'](g['shift']());}}}(a115s,0xcd76d));Object['defineProperty'](exports,a115l(0xd5),{'value':!![]}),exports['SqlDmlBuilder']=void 0x0;const dmlBuilder_1=require(a115l(0x117)),_3xpr_1=require(a115l(0x102)),lambdaorm_base_1=require(a115l(0xda)),domain_1=require(a115l(0xe9));class SqlDmlBuilder extends dmlBuilder_1[a115l(0x10d)]{[a115l(0xde)](s){const u=a115l;return new domain_1[(u(0x103))]({'action':s[u(0xd1)],'category':this[u(0x121)]['query'][u(0xfd)](s[u(0xd1)]),'type':this['helper'][u(0xdd)][u(0xec)](s['action']),'description':s['action']+'\x20'+s['entity'],'dialect':this[u(0xe7)][u(0xe8)],'source':this[u(0xe7)][u(0x126)],'sentence':this['buildSentence'](s),'entity':s[u(0x11a)],'columns':s[u(0xf4)],'parameters':s[u(0xf9)],'constraints':s[u(0x12e)],'values':s[u(0xd9)],'defaults':s['defaults']});}[a115l(0xdf)](s){const e=a115l,y=s[e(0x10e)][e(0x131)](r=>r[e(0x126)]===e(0xe1)),g=s[e(0x10e)][e(0x131)](r=>r instanceof lambdaorm_base_1[e(0x123)]),x=s[e(0x10e)][e(0xd3)](r=>r instanceof lambdaorm_base_1[e(0xf3)]),m=s['children'][e(0x131)](r=>r['name']==='filter'),w=s['children']['find'](r=>r[e(0x126)]==='groupBy'),t=s[e(0x10e)][e(0x131)](r=>r[e(0x126)]===e(0x116)),v=s[e(0x10e)][e(0x131)](r=>r[e(0x126)]===e(0x11f)),a=s[e(0x10e)][e(0x131)](r=>r[e(0x126)]===e(0x130)),c=this[e(0xe0)][e(0x133)](s[e(0x11a)]);if(c===undefined)throw new lambdaorm_base_1[(e(0xd0))](e(0xfe)+s[e(0x11a)]+e(0x12f));if(y===undefined)throw new lambdaorm_base_1[(e(0xd0))](e(0xef));if(g===undefined)throw new lambdaorm_base_1['SchemaError']('from\x20operand\x20not\x20found');let k=this[e(0xdb)](y)+'\x20'+this['buildFrom'](g)+'\x20'+this['buildJoins'](c,x);return m&&(k=k+this[e(0xdb)](m)+'\x20'),w&&(k=k+this[e(0xdb)](w)+'\x20'),t&&(k=k+this['buildArrowFunction'](t)+'\x20'),v&&(k=k+this[e(0xdb)](v)+'\x20'),a&&(k=this[e(0x118)](k,a)),k;}[a115l(0x11d)](s){const n=a115l;var y;const g=s[n(0xd1)]==='bulkInsert'?s[n(0x10e)][n(0x131)](c=>c instanceof lambdaorm_base_1[n(0xf8)]):s[n(0x10e)]['find'](c=>c instanceof lambdaorm_base_1[n(0xd8)]),x=this[n(0xe0)][n(0x133)](s[n(0x11a)]);if(x===undefined)throw new lambdaorm_base_1[(n(0xd0))](n(0xfe)+s[n(0x11a)]+'\x20entity');if(g===undefined)throw new lambdaorm_base_1[(n(0xd0))](n(0xf2));let m=this[n(0xe8)][n(0xd2)](g instanceof lambdaorm_base_1[n(0xf8)]?n(0x12d):n(0xf1));const w=this[n(0xe8)][n(0x11e)](n(0x111)),t=[],v=[],a=this[n(0xe0)][n(0x112)](x[n(0x126)]);if(a&&x['sequence']){const c=this[n(0xe8)][n(0x11e)]('sequenceNextVal');t['push'](this[n(0x121)][n(0x124)][n(0x119)](w,n(0x113),this['dialect'][n(0xed)](a[n(0xe0)]))),v[n(0xe3)](this[n(0x121)][n(0x124)][n(0x119)](c,'{name}',x[n(0x106)]));}if(g[n(0x10e)][0x0]['type']===_3xpr_1[n(0xf0)][n(0xe2)]){const k=g[n(0x10e)][0x0];for(const r in k[n(0x10e)]){const z=k[n(0x10e)][r],d=(y=x['properties'])===null||y===void 0x0?void 0x0:y[n(0x131)](o=>o[n(0x126)]===z[n(0x126)]);let i;d?i=d[n(0xe0)]:i=z[n(0x126)],t[n(0xe3)](this[n(0x121)][n(0x124)][n(0x119)](w,n(0x113),this[n(0xe8)][n(0xed)](i))),v['push'](this[n(0x132)](z[n(0x10e)][0x0]));}}return m=this[n(0x121)][n(0x124)][n(0x119)](m,'{name}',this[n(0xe8)][n(0xed)](x[n(0xe0)]||x[n(0x126)])),m=this[n(0x121)][n(0x124)][n(0x119)](m,n(0x120),t['join'](',')),m=this[n(0x121)]['str']['replace'](m,n(0x135),v[n(0x125)](',')),m=this[n(0x121)]['str'][n(0x119)](m,n(0xf6),a&&a[n(0xe0)]?a[n(0xe0)]:'0'),m[n(0x12c)]();}['buildUpdateSentence'](s){const h=a115l;var y;const g=s['children'][h(0x131)](k=>k instanceof lambdaorm_base_1[h(0xce)]),x=s[h(0x10e)]['find'](k=>k[h(0x126)]===h(0xd3)),m=this[h(0xe0)][h(0x133)](s['entity']);if(m===undefined)throw new lambdaorm_base_1[(h(0xd0))]('mapping\x20undefined\x20on\x20'+s['entity']+h(0x12f));if(g===undefined)throw new lambdaorm_base_1['SchemaError']('update\x20operand\x20not\x20found');let w=this[h(0xe8)][h(0xd2)]('update');const t=this[h(0xe8)][h(0x11e)](h(0x111)),v=this[h(0xe8)][h(0xfa)]('=',0x2),a=[];if(g[h(0x10e)][0x0]instanceof Object){const k=g[h(0x10e)][0x0];for(const r in k['children']){const z=k[h(0x10e)][r];let d;const i=(y=m[h(0xdc)])===null||y===void 0x0?void 0x0:y['find'](j=>j[h(0x126)]===z[h(0x126)]);i?d=i[h(0xe0)]:d=z[h(0x126)];const o=this[h(0x121)][h(0x124)][h(0x119)](t,h(0x113),this['dialect'][h(0xed)](d)),f=this['buildOperand'](z[h(0x10e)][0x0]);let q=this[h(0x121)][h(0x124)][h(0x119)](v,h(0x136),o);q=this[h(0x121)][h(0x124)]['replace'](q,h(0xeb),f),a['push'](q);}}w=this[h(0x121)][h(0x124)][h(0x119)](w,h(0x113),this[h(0xe8)][h(0xed)](m[h(0xe0)]||m[h(0x126)])),w=this['helper'][h(0x124)][h(0x119)](w,h(0x129),g[h(0xf5)]),w=this[h(0x121)][h(0x124)][h(0x119)](w,h(0xff),a[h(0x125)](','));let c=w[h(0x12c)]()+'\x20';if(x)c=c+this['buildArrowFunction'](x)+'\x20';return c;}[a115l(0xe6)](s){const s0=a115l,y=s[s0(0x10e)]['find'](v=>v instanceof lambdaorm_base_1[s0(0x100)]),g=s['children'][s0(0x131)](v=>v[s0(0x126)]===s0(0xd3)),x=this['mapping'][s0(0x133)](s[s0(0x11a)]);if(x===undefined)throw new lambdaorm_base_1[(s0(0xd0))]('mapping\x20undefined\x20on\x20'+s[s0(0x11a)]+s0(0x12f));if(y===undefined)throw new lambdaorm_base_1[(s0(0xd0))](s0(0x101));const m=g?'delete':'deleteAll';let w=this[s0(0xe8)][s0(0xd2)](m);w=this[s0(0x121)][s0(0x124)]['replace'](w,s0(0x113),this[s0(0xe8)][s0(0xed)](x[s0(0xe0)]||x[s0(0x126)])),w=this['helper'][s0(0x124)][s0(0x119)](w,'{alias}',y['alias']);let t=w['trim']()+'\x20';if(g)t=t+this[s0(0xdb)](g)+'\x20';return t;}[a115l(0x128)](s){const s1=a115l;let y=this[s1(0xe8)][s1(0xd2)](s1(0xd4));const g=this[s1(0xe0)]['entityMapping'](s['entity']);if(g===undefined)throw new lambdaorm_base_1[(s1(0xd0))]('not\x20found\x20mapping\x20for\x20'+s[s1(0x11a)]);return y=this[s1(0x121)]['str']['replace'](y,s1(0x113),this[s1(0xe8)][s1(0xed)](g)),y=this[s1(0x121)][s1(0x124)][s1(0x119)](y,s1(0x129),s['alias']),y[s1(0x12c)]();}[a115l(0x115)](s,y){const s2=a115l,g=[],x=this[s2(0xe8)][s2(0xd2)]('join');for(const m of y){const w=this[s2(0xe0)][s2(0x133)](m['name']);if(w===undefined)throw new lambdaorm_base_1[(s2(0xd0))](s2(0xd6)+m[s2(0x126)]);let t=this[s2(0x121)][s2(0x124)][s2(0x119)](x,'{name}',this[s2(0xe8)][s2(0xed)](w['mapping']||w[s2(0x126)]));t=this[s2(0x121)][s2(0x124)][s2(0x119)](t,s2(0x129),m['alias']),t=this[s2(0x121)][s2(0x124)][s2(0x119)](t,s2(0x11b),this[s2(0x132)](m[s2(0x10e)][0x0]))['trim'](),g[s2(0xe3)](t);}return g[s2(0x125)]('\x20')+'\x20';}[a115l(0xee)](s){const s3=a115l;if(this[s3(0xe0)][s3(0x12b)](s[s3(0x11a)],s[s3(0x10b)]())){const y=this['mapping'][s3(0x11c)](s[s3(0x11a)],s[s3(0x10b)]());if(s['alias']===undefined)return this[s3(0x121)][s3(0x124)][s3(0x119)](this[s3(0xe8)]['other'](s3(0x111)),s3(0x113),this[s3(0xe8)][s3(0xed)](y['mapping'],!![]));else{let g=this[s3(0xe8)]['other']('field');return g=this['helper']['str']['replace'](g,s3(0xe5),s[s3(0xf5)]),g=this[s3(0x121)]['str'][s3(0x119)](g,s3(0x113),this[s3(0xe8)][s3(0xed)](y[s3(0xe0)])),g;}}else{const x=[s3(0xf7),s3(0xe4)]['includes'](this[s3(0xe8)][s3(0x126)]);return this[s3(0x121)][s3(0x124)]['replace'](this[s3(0xe8)][s3(0x11e)]('column'),'{name}',this[s3(0xe8)][s3(0xed)](s[s3(0x126)],x));}}[a115l(0x10a)](s){const s4=a115l;let y='';const g=this[s4(0xe8)][s4(0x122)]('as')[s4(0x12a)];for(let x=0x0;x<s[s4(0x10e)][s4(0x107)];x++){const m=this['buildOperand'](s[s4(0x10e)][x]),w=['PostgreSQL',s4(0xe4)][s4(0x109)](this['dialect']['name']),t=this[s4(0xe8)][s4(0xed)](s[s4(0x10e)][x]['name'],w);let v=this[s4(0x121)]['str'][s4(0x119)](g,s4(0xfb),m);v=this['helper'][s4(0x124)][s4(0x119)](v,s4(0x129),t),y+=(x>0x0?',\x20':'')+v;}return y;}}function a115y(s,y){const O=a115s();return a115y=function(D,g){D=D-0xce;let M=O[D];return M;},a115y(s,y);}exports[a115l(0x10c)]=SqlDmlBuilder;