1e9c8f53e0ff150deefbda076afd7c5a56e11a5a
[motion-next.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
1 const a312_0x5bc5=['getFields','fields','catch','nolimit','filters','../../components/parsers/qs','getDescriptions','SugarcrmConfiguration','map','attributes','destroy','end','sequelize','model','Content-Range','like','intersection','update','json','fieldName','api','order','query','type','sendStatus','send','count','filter','includeAll','rawAttributes','index','stack','then','options','error','../../config/logger','rows','name','offset','body','limit','getSubjects','where','findOne','SugarcrmField','undefined','merge','pick','keys','findAll','length','sort','status','show','include','create','set','params','../../mysqldb'];(function(_0x5d78af,_0x5bc5f0){const _0x297a35=function(_0x2addca){while(--_0x2addca){_0x5d78af['push'](_0x5d78af['shift']());}};_0x297a35(++_0x5bc5f0);}(a312_0x5bc5,0x154));const a312_0x297a=function(_0x5d78af,_0x5bc5f0){_0x5d78af=_0x5d78af-0x0;let _0x297a35=a312_0x5bc5[_0x5d78af];return _0x297a35;};const _0xbcb6d9=a312_0x297a;'use strict';const _=require('lodash'),qs=require(_0xbcb6d9('0x13')),logger=require(_0xbcb6d9('0x31'))(_0xbcb6d9('0x22')),db=require(_0xbcb6d9('0xd'))['db'],{Op}=require(_0xbcb6d9('0x1a'));function respondWithResult(_0x2addca,_0x4357e8){return _0x4357e8=_0x4357e8||0xc8,function(_0x62c8d2){if(_0x62c8d2)return _0x2addca['status'](_0x4357e8)['json'](_0x62c8d2);};}function respondWithFilteredResult(_0x5a334b,_0x52061e){return function(_0x165e2){const _0x147f62=a312_0x297a;if(_0x165e2){const _0x5e7d3e=_0x165e2[_0x147f62('0x28')],_0x3811b9=_0x52061e[_0x147f62('0x34')];let _0x5e495e=_0x52061e[_0x147f62('0x34')]+_0x52061e[_0x147f62('0x36')],_0x53be44;return _0x5e495e>=_0x5e7d3e?(_0x5e495e=_0x5e7d3e,_0x53be44=0xc8):_0x53be44=0xce,_0x5a334b[_0x147f62('0x7')](_0x53be44),_0x5a334b[_0x147f62('0xb')](_0x147f62('0x1c'),_0x3811b9+'-'+_0x5e495e+'/'+_0x5e7d3e)[_0x147f62('0x20')](_0x165e2);}return null;};}function saveUpdates(_0xb4259){return function(_0x400164){const _0x294e69=a312_0x297a;if(_0x400164)return _0x400164[_0x294e69('0x1f')](_0xb4259)['then'](function(_0x3fb73a){return _0x3fb73a;});return null;};}function removeEntity(_0x14bfac){return function(_0x2afaa0){const _0x1e7b0a=a312_0x297a;if(_0x2afaa0)return _0x2afaa0[_0x1e7b0a('0x18')]()[_0x1e7b0a('0x2e')](function(){const _0x5c28fd=_0x1e7b0a;_0x14bfac['status'](0xcc)[_0x5c28fd('0x19')]();});};}function handleEntityNotFound(_0x31c1bb){return function(_0x500d35){const _0x5a97a9=a312_0x297a;return!_0x500d35&&_0x31c1bb[_0x5a97a9('0x26')](0x194),_0x500d35;};}function handleError(_0x294df7,_0x541c35){return _0x541c35=_0x541c35||0x1f4,function(_0x557bf8){const _0x35ec3c=a312_0x297a;logger[_0x35ec3c('0x30')](_0x557bf8[_0x35ec3c('0x2d')]),_0x557bf8['name']&&delete _0x557bf8[_0x35ec3c('0x33')],_0x294df7[_0x35ec3c('0x7')](_0x541c35)[_0x35ec3c('0x27')](_0x557bf8);};}exports[_0xbcb6d9('0x2c')]=function(_0x39e4b3,_0x5f4b8a){const _0xef4841=_0xbcb6d9;let _0xe98b91={};const _0x1bb32f={},_0x157f38={'count':0x0,'rows':[]},_0x10f507=_[_0xef4841('0x16')](db[_0xef4841('0x15')][_0xef4841('0x2b')],function(_0x4bbd3d){const _0x14c1f1=_0xef4841;return{'name':_0x4bbd3d[_0x14c1f1('0x21')],'type':_0x4bbd3d[_0x14c1f1('0x25')]['key']};});_0x1bb32f[_0xef4841('0x1b')]=_[_0xef4841('0x16')](_0x10f507,_0xef4841('0x33')),_0x1bb32f[_0xef4841('0x24')]=_['keys'](_0x39e4b3[_0xef4841('0x24')]),_0x1bb32f[_0xef4841('0x12')]=_[_0xef4841('0x1e')](_0x1bb32f[_0xef4841('0x1b')],_0x1bb32f[_0xef4841('0x24')]),_0xe98b91[_0xef4841('0x17')]=_['intersection'](_0x1bb32f[_0xef4841('0x1b')],qs['fields'](_0x39e4b3['query'][_0xef4841('0xf')])),_0xe98b91['attributes']=_0xe98b91['attributes'][_0xef4841('0x5')]?_0xe98b91[_0xef4841('0x17')]:_0x1bb32f[_0xef4841('0x1b')];typeof _0x39e4b3[_0xef4841('0x24')][_0xef4841('0x11')]==='undefined'&&(_0xe98b91['limit']=qs['limit'](_0x39e4b3[_0xef4841('0x24')]['limit']),_0xe98b91[_0xef4841('0x34')]=qs[_0xef4841('0x34')](_0x39e4b3[_0xef4841('0x24')]['offset']));_0xe98b91[_0xef4841('0x23')]=qs['sort'](_0x39e4b3[_0xef4841('0x24')][_0xef4841('0x6')]),_0xe98b91[_0xef4841('0x38')]=qs[_0xef4841('0x12')](_[_0xef4841('0x2')](_0x39e4b3[_0xef4841('0x24')],_0x1bb32f[_0xef4841('0x12')]),_0x10f507);_0x39e4b3['query'][_0xef4841('0x29')]&&(_0xe98b91[_0xef4841('0x38')]=_[_0xef4841('0x1')](_0xe98b91[_0xef4841('0x38')],{[Op['or']]:_['map'](_0x10f507,function(_0x3ba014){const _0x6fcfcd=_0xef4841;if(_0x3ba014[_0x6fcfcd('0x25')]!=='VIRTUAL'){const _0x180218={};return _0x180218[_0x3ba014[_0x6fcfcd('0x33')]]={[Op[_0x6fcfcd('0x1d')]]:'%'+_0x39e4b3[_0x6fcfcd('0x24')]['filter']+'%'},_0x180218;}})}));_0xe98b91=_[_0xef4841('0x1')]({},_0xe98b91,_0x39e4b3['options']);const _0x5bf084={'where':_0xe98b91['where']};return db[_0xef4841('0x15')][_0xef4841('0x28')](_0x5bf084)['then'](function(_0x1cd38c){const _0x28d972=_0xef4841;return _0x157f38[_0x28d972('0x28')]=_0x1cd38c,_0x39e4b3['query'][_0x28d972('0x2a')]&&(_0xe98b91[_0x28d972('0x9')]=[{'all':!![]}]),db[_0x28d972('0x15')][_0x28d972('0x4')](_0xe98b91);})['then'](function(_0x41ce90){const _0x54f301=_0xef4841;return _0x157f38[_0x54f301('0x32')]=_0x41ce90,_0x157f38;})[_0xef4841('0x2e')](respondWithFilteredResult(_0x5f4b8a,_0xe98b91))['catch'](handleError(_0x5f4b8a,null));},exports[_0xbcb6d9('0x8')]=function(_0x3bb64f,_0x4993a3){const _0x5bd670=_0xbcb6d9;let _0x438d31={'raw':![],'where':{'id':_0x3bb64f['params']['id']}};const _0x1cfe81={};return _0x1cfe81[_0x5bd670('0x1b')]=_['keys'](db[_0x5bd670('0x15')][_0x5bd670('0x2b')]),_0x1cfe81[_0x5bd670('0x24')]=_['keys'](_0x3bb64f[_0x5bd670('0x24')]),_0x1cfe81[_0x5bd670('0x12')]=_['intersection'](_0x1cfe81[_0x5bd670('0x1b')],_0x1cfe81[_0x5bd670('0x24')]),_0x438d31[_0x5bd670('0x17')]=_[_0x5bd670('0x1e')](_0x1cfe81[_0x5bd670('0x1b')],qs[_0x5bd670('0xf')](_0x3bb64f[_0x5bd670('0x24')][_0x5bd670('0xf')])),_0x438d31[_0x5bd670('0x17')]=_0x438d31[_0x5bd670('0x17')][_0x5bd670('0x5')]?_0x438d31[_0x5bd670('0x17')]:_0x1cfe81[_0x5bd670('0x1b')],_0x3bb64f[_0x5bd670('0x24')]['includeAll']&&(_0x438d31[_0x5bd670('0x9')]=[{'all':!![]}]),_0x438d31=_['merge']({},_0x438d31,_0x3bb64f[_0x5bd670('0x2f')]),db[_0x5bd670('0x15')][_0x5bd670('0x39')](_0x438d31)[_0x5bd670('0x2e')](handleEntityNotFound(_0x4993a3,null))[_0x5bd670('0x2e')](respondWithResult(_0x4993a3,null))[_0x5bd670('0x10')](handleError(_0x4993a3,null));},exports[_0xbcb6d9('0xa')]=function(_0x4c2b31,_0xaab340){const _0x507e21=_0xbcb6d9;return db['SugarcrmConfiguration'][_0x507e21('0xa')](_0x4c2b31[_0x507e21('0x35')],{})[_0x507e21('0x2e')](respondWithResult(_0xaab340,0xc9))[_0x507e21('0x10')](handleError(_0xaab340,null));},exports[_0xbcb6d9('0x1f')]=function(_0x2006d3,_0x400c93){const _0x390ad7=_0xbcb6d9;return _0x2006d3['body']['id']&&delete _0x2006d3[_0x390ad7('0x35')]['id'],db[_0x390ad7('0x15')][_0x390ad7('0x39')]({'where':{'id':_0x2006d3[_0x390ad7('0xc')]['id']}})[_0x390ad7('0x2e')](handleEntityNotFound(_0x400c93,null))[_0x390ad7('0x2e')](saveUpdates(_0x2006d3[_0x390ad7('0x35')],null))[_0x390ad7('0x2e')](respondWithResult(_0x400c93,null))[_0x390ad7('0x10')](handleError(_0x400c93,null));},exports[_0xbcb6d9('0x18')]=function(_0x2fad3c,_0x5aefd3){const _0x337c4b=_0xbcb6d9;return db[_0x337c4b('0x15')][_0x337c4b('0x39')]({'where':{'id':_0x2fad3c['params']['id']}})['then'](handleEntityNotFound(_0x5aefd3,null))[_0x337c4b('0x2e')](removeEntity(_0x5aefd3,null))[_0x337c4b('0x10')](handleError(_0x5aefd3,null));},exports[_0xbcb6d9('0xe')]=function(_0x223d5d,_0x151122){const _0x3ee13f=_0xbcb6d9;let _0x43669c={};const _0x400799={};let _0x4e84bb,_0x4083c8;return db['SugarcrmConfiguration'][_0x3ee13f('0x39')]({'where':{'id':_0x223d5d[_0x3ee13f('0xc')]['id']}})[_0x3ee13f('0x2e')](handleEntityNotFound(_0x151122,null))[_0x3ee13f('0x2e')](function(_0x41c01d){const _0x3c112d=_0x3ee13f;if(_0x41c01d)return _0x4e84bb=_0x41c01d,_0x400799[_0x3c112d('0x1b')]=_[_0x3c112d('0x3')](db[_0x3c112d('0x3a')][_0x3c112d('0x2b')]),_0x400799[_0x3c112d('0x24')]=_[_0x3c112d('0x3')](_0x223d5d[_0x3c112d('0x24')]),_0x400799['filters']=_[_0x3c112d('0x1e')](_0x400799[_0x3c112d('0x1b')],_0x400799['query']),_0x43669c[_0x3c112d('0x17')]=_[_0x3c112d('0x1e')](_0x400799[_0x3c112d('0x1b')],qs[_0x3c112d('0xf')](_0x223d5d[_0x3c112d('0x24')]['fields'])),_0x43669c[_0x3c112d('0x17')]=_0x43669c[_0x3c112d('0x17')]['length']?_0x43669c[_0x3c112d('0x17')]:_0x400799[_0x3c112d('0x1b')],_0x43669c[_0x3c112d('0x23')]=qs['sort'](_0x223d5d[_0x3c112d('0x24')][_0x3c112d('0x6')]),_0x43669c[_0x3c112d('0x38')]=qs['filters'](_['pick'](_0x223d5d[_0x3c112d('0x24')],_0x400799[_0x3c112d('0x12')])),_0x223d5d[_0x3c112d('0x24')][_0x3c112d('0x29')]&&(_0x43669c[_0x3c112d('0x38')]=_['merge'](_0x43669c[_0x3c112d('0x38')],{[Op['or']]:_[_0x3c112d('0x16')](_0x43669c['attributes'],function(_0x4f2346){const _0x418006=_0x3c112d,_0x32cf6a={};return _0x32cf6a[_0x4f2346]={[Op['like']]:'%'+_0x223d5d[_0x418006('0x24')][_0x418006('0x29')]+'%'},_0x32cf6a;})})),_0x43669c=_[_0x3c112d('0x1')]({},_0x43669c,_0x223d5d[_0x3c112d('0x2f')]),_0x4e84bb[_0x3c112d('0xe')](_0x43669c);})['then'](function(_0x22d450){const _0x2e75e8=_0x3ee13f;if(_0x22d450)return _0x4083c8=_0x22d450[_0x2e75e8('0x5')],typeof _0x223d5d[_0x2e75e8('0x24')][_0x2e75e8('0x11')]==='undefined'&&(_0x43669c[_0x2e75e8('0x36')]=qs[_0x2e75e8('0x36')](_0x223d5d[_0x2e75e8('0x24')][_0x2e75e8('0x36')]),_0x43669c['offset']=qs[_0x2e75e8('0x34')](_0x223d5d[_0x2e75e8('0x24')][_0x2e75e8('0x34')])),_0x4e84bb['getFields'](_0x43669c);})[_0x3ee13f('0x2e')](function(_0x321a99){if(_0x321a99)return _0x321a99?{'count':_0x4083c8,'rows':_0x321a99}:null;})[_0x3ee13f('0x2e')](respondWithResult(_0x151122,null))[_0x3ee13f('0x10')](handleError(_0x151122,null));},exports['getSubjects']=function(_0x5c7cc2,_0x47dc4d){const _0x237f5c=_0xbcb6d9;let _0x1dddfd={};const _0x2ca56b={};let _0x39b1e5,_0x2baac8;return db[_0x237f5c('0x15')][_0x237f5c('0x39')]({'where':{'id':_0x5c7cc2[_0x237f5c('0xc')]['id']}})['then'](handleEntityNotFound(_0x47dc4d,null))['then'](function(_0x1765c9){const _0x4c11f8=_0x237f5c;if(_0x1765c9)return _0x39b1e5=_0x1765c9,_0x2ca56b[_0x4c11f8('0x1b')]=_[_0x4c11f8('0x3')](db['SugarcrmField'][_0x4c11f8('0x2b')]),_0x2ca56b[_0x4c11f8('0x24')]=_[_0x4c11f8('0x3')](_0x5c7cc2[_0x4c11f8('0x24')]),_0x2ca56b[_0x4c11f8('0x12')]=_[_0x4c11f8('0x1e')](_0x2ca56b[_0x4c11f8('0x1b')],_0x2ca56b[_0x4c11f8('0x24')]),_0x1dddfd[_0x4c11f8('0x17')]=_['intersection'](_0x2ca56b[_0x4c11f8('0x1b')],qs[_0x4c11f8('0xf')](_0x5c7cc2[_0x4c11f8('0x24')]['fields'])),_0x1dddfd[_0x4c11f8('0x17')]=_0x1dddfd[_0x4c11f8('0x17')][_0x4c11f8('0x5')]?_0x1dddfd['attributes']:_0x2ca56b['model'],_0x1dddfd[_0x4c11f8('0x23')]=qs[_0x4c11f8('0x6')](_0x5c7cc2[_0x4c11f8('0x24')]['sort']),_0x1dddfd[_0x4c11f8('0x38')]=qs['filters'](_[_0x4c11f8('0x2')](_0x5c7cc2[_0x4c11f8('0x24')],_0x2ca56b['filters'])),_0x5c7cc2['query'][_0x4c11f8('0x29')]&&(_0x1dddfd['where']=_[_0x4c11f8('0x1')](_0x1dddfd[_0x4c11f8('0x38')],{[Op['or']]:_[_0x4c11f8('0x16')](_0x1dddfd[_0x4c11f8('0x17')],function(_0x5550ff){const _0xa77ae6=_0x4c11f8,_0x1c6894={};return _0x1c6894[_0x5550ff]={[Op['like']]:'%'+_0x5c7cc2[_0xa77ae6('0x24')][_0xa77ae6('0x29')]+'%'},_0x1c6894;})})),_0x1dddfd=_[_0x4c11f8('0x1')]({},_0x1dddfd,_0x5c7cc2[_0x4c11f8('0x2f')]),_0x39b1e5[_0x4c11f8('0x37')](_0x1dddfd);})['then'](function(_0x3d91ae){const _0x335173=_0x237f5c;if(_0x3d91ae)return _0x2baac8=_0x3d91ae[_0x335173('0x5')],typeof _0x5c7cc2[_0x335173('0x24')][_0x335173('0x11')]===_0x335173('0x0')&&(_0x1dddfd[_0x335173('0x36')]=qs[_0x335173('0x36')](_0x5c7cc2[_0x335173('0x24')][_0x335173('0x36')]),_0x1dddfd[_0x335173('0x34')]=qs['offset'](_0x5c7cc2['query'][_0x335173('0x34')])),_0x39b1e5[_0x335173('0x37')](_0x1dddfd);})[_0x237f5c('0x2e')](function(_0x45e762){if(_0x45e762)return _0x45e762?{'count':_0x2baac8,'rows':_0x45e762}:null;})[_0x237f5c('0x2e')](respondWithResult(_0x47dc4d,null))[_0x237f5c('0x10')](handleError(_0x47dc4d,null));},exports[_0xbcb6d9('0x14')]=function(_0x174010,_0x2629a8){const _0x5cfdc6=_0xbcb6d9;let _0xb92d2c={};const _0x1ebe49={};let _0x18dee1,_0x52f6a8;return db[_0x5cfdc6('0x15')]['findOne']({'where':{'id':_0x174010[_0x5cfdc6('0xc')]['id']}})[_0x5cfdc6('0x2e')](handleEntityNotFound(_0x2629a8,null))[_0x5cfdc6('0x2e')](function(_0x15f876){const _0x1ccf2d=_0x5cfdc6;if(_0x15f876)return _0x18dee1=_0x15f876,_0x1ebe49['model']=_[_0x1ccf2d('0x3')](db[_0x1ccf2d('0x3a')][_0x1ccf2d('0x2b')]),_0x1ebe49['query']=_[_0x1ccf2d('0x3')](_0x174010[_0x1ccf2d('0x24')]),_0x1ebe49[_0x1ccf2d('0x12')]=_[_0x1ccf2d('0x1e')](_0x1ebe49[_0x1ccf2d('0x1b')],_0x1ebe49['query']),_0xb92d2c[_0x1ccf2d('0x17')]=_[_0x1ccf2d('0x1e')](_0x1ebe49[_0x1ccf2d('0x1b')],qs[_0x1ccf2d('0xf')](_0x174010[_0x1ccf2d('0x24')][_0x1ccf2d('0xf')])),_0xb92d2c[_0x1ccf2d('0x17')]=_0xb92d2c[_0x1ccf2d('0x17')][_0x1ccf2d('0x5')]?_0xb92d2c[_0x1ccf2d('0x17')]:_0x1ebe49[_0x1ccf2d('0x1b')],_0xb92d2c[_0x1ccf2d('0x23')]=qs['sort'](_0x174010[_0x1ccf2d('0x24')]['sort']),_0xb92d2c[_0x1ccf2d('0x38')]=qs[_0x1ccf2d('0x12')](_[_0x1ccf2d('0x2')](_0x174010[_0x1ccf2d('0x24')],_0x1ebe49[_0x1ccf2d('0x12')])),_0x174010['query'][_0x1ccf2d('0x29')]&&(_0xb92d2c[_0x1ccf2d('0x38')]=_[_0x1ccf2d('0x1')](_0xb92d2c['where'],{[Op['or']]:_[_0x1ccf2d('0x16')](_0xb92d2c[_0x1ccf2d('0x17')],function(_0x416d7e){const _0x17b735=_0x1ccf2d,_0x38615c={};return _0x38615c[_0x416d7e]={[Op['like']]:'%'+_0x174010[_0x17b735('0x24')]['filter']+'%'},_0x38615c;})})),_0xb92d2c=_[_0x1ccf2d('0x1')]({},_0xb92d2c,_0x174010[_0x1ccf2d('0x2f')]),_0x18dee1['getDescriptions'](_0xb92d2c);})[_0x5cfdc6('0x2e')](function(_0x4f5538){const _0xfa4ea8=_0x5cfdc6;if(_0x4f5538)return _0x52f6a8=_0x4f5538['length'],typeof _0x174010[_0xfa4ea8('0x24')]['nolimit']==='undefined'&&(_0xb92d2c['limit']=qs['limit'](_0x174010[_0xfa4ea8('0x24')][_0xfa4ea8('0x36')]),_0xb92d2c[_0xfa4ea8('0x34')]=qs[_0xfa4ea8('0x34')](_0x174010[_0xfa4ea8('0x24')]['offset'])),_0x18dee1['getDescriptions'](_0xb92d2c);})['then'](function(_0x1ad78f){if(_0x1ad78f)return _0x1ad78f?{'count':_0x52f6a8,'rows':_0x1ad78f}:null;})[_0x5cfdc6('0x2e')](respondWithResult(_0x2629a8,null))[_0x5cfdc6('0x10')](handleError(_0x2629a8,null));};