Built motion from commit aab208717af8d15f4fa224cdb6a202877019af9b. Version 3.0.0...
[motion-next.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
1 const a312_0x56e1=['keys','nolimit','type','filter','show','undefined','query','rows','findOne','findAll','getFields','merge','SugarcrmField','intersection','model','end','VIRTUAL','attributes','includeAll','json','then','error','Content-Range','fieldName','../../components/parsers/qs','set','sendStatus','getSubjects','options','name','like','filters','length','include','where','params','rawAttributes','sort','stack','sequelize','status','send','limit','map','order','catch','index','api','update','count','getDescriptions','body','pick','offset','create','fields','SugarcrmConfiguration','destroy'];(function(_0x304f23,_0x56e149){const _0x258445=function(_0xac959e){while(--_0xac959e){_0x304f23['push'](_0x304f23['shift']());}};_0x258445(++_0x56e149);}(a312_0x56e1,0x1ee));const a312_0x2584=function(_0x304f23,_0x56e149){_0x304f23=_0x304f23-0x0;let _0x258445=a312_0x56e1[_0x304f23];return _0x258445;};const _0x5a1108=a312_0x2584;'use strict';const _=require('lodash'),qs=require(_0x5a1108('0x34')),logger=require('../../config/logger')(_0x5a1108('0x11')),db=require('../../mysqldb')['db'],{Op}=require(_0x5a1108('0x9'));function respondWithResult(_0xac959e,_0x241c6f){return _0x241c6f=_0x241c6f||0xc8,function(_0x694d65){const _0x4f6298=a312_0x2584;if(_0x694d65)return _0xac959e['status'](_0x241c6f)[_0x4f6298('0x2f')](_0x694d65);};}function respondWithFilteredResult(_0x144293,_0x5cb0d8){return function(_0x4f3cd3){const _0x1f961a=a312_0x2584;if(_0x4f3cd3){const _0x414f83=_0x4f3cd3[_0x1f961a('0x13')],_0x35ea70=_0x5cb0d8[_0x1f961a('0x17')];let _0x57727d=_0x5cb0d8[_0x1f961a('0x17')]+_0x5cb0d8[_0x1f961a('0xc')],_0x455326;return _0x57727d>=_0x414f83?(_0x57727d=_0x414f83,_0x455326=0xc8):_0x455326=0xce,_0x144293[_0x1f961a('0xa')](_0x455326),_0x144293[_0x1f961a('0x35')](_0x1f961a('0x32'),_0x35ea70+'-'+_0x57727d+'/'+_0x414f83)[_0x1f961a('0x2f')](_0x4f3cd3);}return null;};}function saveUpdates(_0x246a99){return function(_0x1f6be0){const _0x138fc0=a312_0x2584;if(_0x1f6be0)return _0x1f6be0[_0x138fc0('0x12')](_0x246a99)[_0x138fc0('0x30')](function(_0x5f5b04){return _0x5f5b04;});return null;};}function removeEntity(_0x4532ae){return function(_0x50191f){if(_0x50191f)return _0x50191f['destroy']()['then'](function(){const _0x2ddb90=a312_0x2584;_0x4532ae['status'](0xcc)[_0x2ddb90('0x2b')]();});};}function handleEntityNotFound(_0x2791bd){return function(_0x5cf0b0){const _0x177e73=a312_0x2584;return!_0x5cf0b0&&_0x2791bd[_0x177e73('0x36')](0x194),_0x5cf0b0;};}function handleError(_0x5822b5,_0x470426){return _0x470426=_0x470426||0x1f4,function(_0x56c40b){const _0x14451=a312_0x2584;logger[_0x14451('0x31')](_0x56c40b[_0x14451('0x8')]),_0x56c40b[_0x14451('0x39')]&&delete _0x56c40b[_0x14451('0x39')],_0x5822b5[_0x14451('0xa')](_0x470426)[_0x14451('0xb')](_0x56c40b);};}exports[_0x5a1108('0x10')]=function(_0x3209a8,_0x4c7030){const _0x5a0748=_0x5a1108;let _0x31078c={};const _0x2d5b94={},_0x2bd723={'count':0x0,'rows':[]},_0x5d4fdf=_[_0x5a0748('0xd')](db[_0x5a0748('0x1a')][_0x5a0748('0x6')],function(_0x24095e){const _0x199a1b=_0x5a0748;return{'name':_0x24095e[_0x199a1b('0x33')],'type':_0x24095e['type']['key']};});_0x2d5b94[_0x5a0748('0x2a')]=_[_0x5a0748('0xd')](_0x5d4fdf,_0x5a0748('0x39')),_0x2d5b94['query']=_[_0x5a0748('0x1c')](_0x3209a8[_0x5a0748('0x22')]),_0x2d5b94[_0x5a0748('0x1')]=_[_0x5a0748('0x29')](_0x2d5b94[_0x5a0748('0x2a')],_0x2d5b94[_0x5a0748('0x22')]),_0x31078c[_0x5a0748('0x2d')]=_['intersection'](_0x2d5b94[_0x5a0748('0x2a')],qs['fields'](_0x3209a8[_0x5a0748('0x22')][_0x5a0748('0x19')])),_0x31078c[_0x5a0748('0x2d')]=_0x31078c[_0x5a0748('0x2d')][_0x5a0748('0x2')]?_0x31078c[_0x5a0748('0x2d')]:_0x2d5b94[_0x5a0748('0x2a')];typeof _0x3209a8[_0x5a0748('0x22')]['nolimit']===_0x5a0748('0x21')&&(_0x31078c[_0x5a0748('0xc')]=qs[_0x5a0748('0xc')](_0x3209a8[_0x5a0748('0x22')]['limit']),_0x31078c[_0x5a0748('0x17')]=qs[_0x5a0748('0x17')](_0x3209a8[_0x5a0748('0x22')][_0x5a0748('0x17')]));_0x31078c[_0x5a0748('0xe')]=qs[_0x5a0748('0x7')](_0x3209a8[_0x5a0748('0x22')][_0x5a0748('0x7')]),_0x31078c['where']=qs[_0x5a0748('0x1')](_[_0x5a0748('0x16')](_0x3209a8[_0x5a0748('0x22')],_0x2d5b94['filters']),_0x5d4fdf);_0x3209a8['query'][_0x5a0748('0x1f')]&&(_0x31078c[_0x5a0748('0x4')]=_[_0x5a0748('0x27')](_0x31078c[_0x5a0748('0x4')],{[Op['or']]:_[_0x5a0748('0xd')](_0x5d4fdf,function(_0x422876){const _0x144f7e=_0x5a0748;if(_0x422876[_0x144f7e('0x1e')]!==_0x144f7e('0x2c')){const _0x2a69a7={};return _0x2a69a7[_0x422876[_0x144f7e('0x39')]]={[Op[_0x144f7e('0x0')]]:'%'+_0x3209a8['query']['filter']+'%'},_0x2a69a7;}})}));_0x31078c=_['merge']({},_0x31078c,_0x3209a8['options']);const _0x299a47={'where':_0x31078c[_0x5a0748('0x4')]};return db[_0x5a0748('0x1a')][_0x5a0748('0x13')](_0x299a47)[_0x5a0748('0x30')](function(_0x320bef){const _0x4d505e=_0x5a0748;return _0x2bd723[_0x4d505e('0x13')]=_0x320bef,_0x3209a8[_0x4d505e('0x22')][_0x4d505e('0x2e')]&&(_0x31078c[_0x4d505e('0x3')]=[{'all':!![]}]),db[_0x4d505e('0x1a')][_0x4d505e('0x25')](_0x31078c);})['then'](function(_0x294896){const _0x31958a=_0x5a0748;return _0x2bd723[_0x31958a('0x23')]=_0x294896,_0x2bd723;})[_0x5a0748('0x30')](respondWithFilteredResult(_0x4c7030,_0x31078c))[_0x5a0748('0xf')](handleError(_0x4c7030,null));},exports[_0x5a1108('0x20')]=function(_0x3e18de,_0x144516){const _0x1146a1=_0x5a1108;let _0x2d51c3={'raw':![],'where':{'id':_0x3e18de[_0x1146a1('0x5')]['id']}};const _0x2f86bf={};return _0x2f86bf[_0x1146a1('0x2a')]=_[_0x1146a1('0x1c')](db[_0x1146a1('0x1a')]['rawAttributes']),_0x2f86bf[_0x1146a1('0x22')]=_[_0x1146a1('0x1c')](_0x3e18de[_0x1146a1('0x22')]),_0x2f86bf[_0x1146a1('0x1')]=_[_0x1146a1('0x29')](_0x2f86bf[_0x1146a1('0x2a')],_0x2f86bf[_0x1146a1('0x22')]),_0x2d51c3[_0x1146a1('0x2d')]=_[_0x1146a1('0x29')](_0x2f86bf[_0x1146a1('0x2a')],qs[_0x1146a1('0x19')](_0x3e18de['query']['fields'])),_0x2d51c3[_0x1146a1('0x2d')]=_0x2d51c3[_0x1146a1('0x2d')][_0x1146a1('0x2')]?_0x2d51c3[_0x1146a1('0x2d')]:_0x2f86bf[_0x1146a1('0x2a')],_0x3e18de['query']['includeAll']&&(_0x2d51c3['include']=[{'all':!![]}]),_0x2d51c3=_['merge']({},_0x2d51c3,_0x3e18de[_0x1146a1('0x38')]),db[_0x1146a1('0x1a')][_0x1146a1('0x24')](_0x2d51c3)['then'](handleEntityNotFound(_0x144516,null))['then'](respondWithResult(_0x144516,null))[_0x1146a1('0xf')](handleError(_0x144516,null));},exports[_0x5a1108('0x18')]=function(_0x3dee0a,_0x19e6f0){const _0x3c856c=_0x5a1108;return db['SugarcrmConfiguration'][_0x3c856c('0x18')](_0x3dee0a[_0x3c856c('0x15')],{})[_0x3c856c('0x30')](respondWithResult(_0x19e6f0,0xc9))[_0x3c856c('0xf')](handleError(_0x19e6f0,null));},exports[_0x5a1108('0x12')]=function(_0x3e7124,_0x365609){const _0x7685ce=_0x5a1108;return _0x3e7124[_0x7685ce('0x15')]['id']&&delete _0x3e7124[_0x7685ce('0x15')]['id'],db[_0x7685ce('0x1a')][_0x7685ce('0x24')]({'where':{'id':_0x3e7124[_0x7685ce('0x5')]['id']}})['then'](handleEntityNotFound(_0x365609,null))[_0x7685ce('0x30')](saveUpdates(_0x3e7124[_0x7685ce('0x15')],null))[_0x7685ce('0x30')](respondWithResult(_0x365609,null))[_0x7685ce('0xf')](handleError(_0x365609,null));},exports[_0x5a1108('0x1b')]=function(_0x31bbd2,_0x4e41bd){const _0x29f7bf=_0x5a1108;return db[_0x29f7bf('0x1a')]['findOne']({'where':{'id':_0x31bbd2[_0x29f7bf('0x5')]['id']}})[_0x29f7bf('0x30')](handleEntityNotFound(_0x4e41bd,null))[_0x29f7bf('0x30')](removeEntity(_0x4e41bd,null))[_0x29f7bf('0xf')](handleError(_0x4e41bd,null));},exports[_0x5a1108('0x26')]=function(_0x8df5f9,_0x16555e){const _0x5ce569=_0x5a1108;let _0x3892ec={};const _0x421d92={};let _0x5b4bf1,_0x5d2013;return db[_0x5ce569('0x1a')][_0x5ce569('0x24')]({'where':{'id':_0x8df5f9[_0x5ce569('0x5')]['id']}})[_0x5ce569('0x30')](handleEntityNotFound(_0x16555e,null))[_0x5ce569('0x30')](function(_0xba93a2){const _0x2fe023=_0x5ce569;if(_0xba93a2)return _0x5b4bf1=_0xba93a2,_0x421d92[_0x2fe023('0x2a')]=_[_0x2fe023('0x1c')](db[_0x2fe023('0x28')]['rawAttributes']),_0x421d92['query']=_[_0x2fe023('0x1c')](_0x8df5f9['query']),_0x421d92[_0x2fe023('0x1')]=_[_0x2fe023('0x29')](_0x421d92[_0x2fe023('0x2a')],_0x421d92[_0x2fe023('0x22')]),_0x3892ec[_0x2fe023('0x2d')]=_[_0x2fe023('0x29')](_0x421d92[_0x2fe023('0x2a')],qs[_0x2fe023('0x19')](_0x8df5f9[_0x2fe023('0x22')][_0x2fe023('0x19')])),_0x3892ec[_0x2fe023('0x2d')]=_0x3892ec[_0x2fe023('0x2d')]['length']?_0x3892ec['attributes']:_0x421d92[_0x2fe023('0x2a')],_0x3892ec[_0x2fe023('0xe')]=qs['sort'](_0x8df5f9[_0x2fe023('0x22')][_0x2fe023('0x7')]),_0x3892ec[_0x2fe023('0x4')]=qs[_0x2fe023('0x1')](_[_0x2fe023('0x16')](_0x8df5f9['query'],_0x421d92[_0x2fe023('0x1')])),_0x8df5f9[_0x2fe023('0x22')][_0x2fe023('0x1f')]&&(_0x3892ec[_0x2fe023('0x4')]=_[_0x2fe023('0x27')](_0x3892ec['where'],{[Op['or']]:_['map'](_0x3892ec[_0x2fe023('0x2d')],function(_0x220e5d){const _0x54ee96=_0x2fe023,_0x50a305={};return _0x50a305[_0x220e5d]={[Op[_0x54ee96('0x0')]]:'%'+_0x8df5f9[_0x54ee96('0x22')][_0x54ee96('0x1f')]+'%'},_0x50a305;})})),_0x3892ec=_[_0x2fe023('0x27')]({},_0x3892ec,_0x8df5f9[_0x2fe023('0x38')]),_0x5b4bf1[_0x2fe023('0x26')](_0x3892ec);})[_0x5ce569('0x30')](function(_0x163364){const _0x312251=_0x5ce569;if(_0x163364)return _0x5d2013=_0x163364[_0x312251('0x2')],typeof _0x8df5f9[_0x312251('0x22')][_0x312251('0x1d')]==='undefined'&&(_0x3892ec[_0x312251('0xc')]=qs[_0x312251('0xc')](_0x8df5f9[_0x312251('0x22')][_0x312251('0xc')]),_0x3892ec[_0x312251('0x17')]=qs[_0x312251('0x17')](_0x8df5f9[_0x312251('0x22')][_0x312251('0x17')])),_0x5b4bf1[_0x312251('0x26')](_0x3892ec);})[_0x5ce569('0x30')](function(_0x51ae75){if(_0x51ae75)return _0x51ae75?{'count':_0x5d2013,'rows':_0x51ae75}:null;})[_0x5ce569('0x30')](respondWithResult(_0x16555e,null))[_0x5ce569('0xf')](handleError(_0x16555e,null));},exports[_0x5a1108('0x37')]=function(_0x293d94,_0x58a4c8){const _0x1cf07b=_0x5a1108;let _0x6e2521={};const _0x51840a={};let _0x11a5ae,_0x30981a;return db['SugarcrmConfiguration'][_0x1cf07b('0x24')]({'where':{'id':_0x293d94[_0x1cf07b('0x5')]['id']}})[_0x1cf07b('0x30')](handleEntityNotFound(_0x58a4c8,null))[_0x1cf07b('0x30')](function(_0x4efc1a){const _0x5d5a40=_0x1cf07b;if(_0x4efc1a)return _0x11a5ae=_0x4efc1a,_0x51840a[_0x5d5a40('0x2a')]=_[_0x5d5a40('0x1c')](db[_0x5d5a40('0x28')][_0x5d5a40('0x6')]),_0x51840a[_0x5d5a40('0x22')]=_['keys'](_0x293d94[_0x5d5a40('0x22')]),_0x51840a[_0x5d5a40('0x1')]=_['intersection'](_0x51840a['model'],_0x51840a[_0x5d5a40('0x22')]),_0x6e2521[_0x5d5a40('0x2d')]=_['intersection'](_0x51840a[_0x5d5a40('0x2a')],qs[_0x5d5a40('0x19')](_0x293d94[_0x5d5a40('0x22')][_0x5d5a40('0x19')])),_0x6e2521[_0x5d5a40('0x2d')]=_0x6e2521[_0x5d5a40('0x2d')][_0x5d5a40('0x2')]?_0x6e2521[_0x5d5a40('0x2d')]:_0x51840a['model'],_0x6e2521[_0x5d5a40('0xe')]=qs['sort'](_0x293d94[_0x5d5a40('0x22')][_0x5d5a40('0x7')]),_0x6e2521[_0x5d5a40('0x4')]=qs[_0x5d5a40('0x1')](_[_0x5d5a40('0x16')](_0x293d94['query'],_0x51840a['filters'])),_0x293d94[_0x5d5a40('0x22')][_0x5d5a40('0x1f')]&&(_0x6e2521[_0x5d5a40('0x4')]=_['merge'](_0x6e2521[_0x5d5a40('0x4')],{[Op['or']]:_['map'](_0x6e2521[_0x5d5a40('0x2d')],function(_0x389173){const _0x3e0932=_0x5d5a40,_0x22737d={};return _0x22737d[_0x389173]={[Op['like']]:'%'+_0x293d94[_0x3e0932('0x22')][_0x3e0932('0x1f')]+'%'},_0x22737d;})})),_0x6e2521=_[_0x5d5a40('0x27')]({},_0x6e2521,_0x293d94[_0x5d5a40('0x38')]),_0x11a5ae[_0x5d5a40('0x37')](_0x6e2521);})[_0x1cf07b('0x30')](function(_0x60a509){const _0x48177a=_0x1cf07b;if(_0x60a509)return _0x30981a=_0x60a509[_0x48177a('0x2')],typeof _0x293d94[_0x48177a('0x22')][_0x48177a('0x1d')]==='undefined'&&(_0x6e2521[_0x48177a('0xc')]=qs[_0x48177a('0xc')](_0x293d94[_0x48177a('0x22')][_0x48177a('0xc')]),_0x6e2521['offset']=qs['offset'](_0x293d94[_0x48177a('0x22')][_0x48177a('0x17')])),_0x11a5ae[_0x48177a('0x37')](_0x6e2521);})[_0x1cf07b('0x30')](function(_0x55e7cb){if(_0x55e7cb)return _0x55e7cb?{'count':_0x30981a,'rows':_0x55e7cb}:null;})['then'](respondWithResult(_0x58a4c8,null))[_0x1cf07b('0xf')](handleError(_0x58a4c8,null));},exports['getDescriptions']=function(_0x44a350,_0x3d50c3){const _0x43aeaf=_0x5a1108;let _0xafe9a0={};const _0x313a5d={};let _0x1443bc,_0x57e113;return db[_0x43aeaf('0x1a')]['findOne']({'where':{'id':_0x44a350['params']['id']}})[_0x43aeaf('0x30')](handleEntityNotFound(_0x3d50c3,null))['then'](function(_0x5a5fac){const _0x9c81c6=_0x43aeaf;if(_0x5a5fac)return _0x1443bc=_0x5a5fac,_0x313a5d[_0x9c81c6('0x2a')]=_[_0x9c81c6('0x1c')](db['SugarcrmField']['rawAttributes']),_0x313a5d[_0x9c81c6('0x22')]=_[_0x9c81c6('0x1c')](_0x44a350[_0x9c81c6('0x22')]),_0x313a5d[_0x9c81c6('0x1')]=_[_0x9c81c6('0x29')](_0x313a5d[_0x9c81c6('0x2a')],_0x313a5d[_0x9c81c6('0x22')]),_0xafe9a0[_0x9c81c6('0x2d')]=_[_0x9c81c6('0x29')](_0x313a5d[_0x9c81c6('0x2a')],qs[_0x9c81c6('0x19')](_0x44a350['query']['fields'])),_0xafe9a0['attributes']=_0xafe9a0[_0x9c81c6('0x2d')][_0x9c81c6('0x2')]?_0xafe9a0[_0x9c81c6('0x2d')]:_0x313a5d[_0x9c81c6('0x2a')],_0xafe9a0[_0x9c81c6('0xe')]=qs['sort'](_0x44a350[_0x9c81c6('0x22')][_0x9c81c6('0x7')]),_0xafe9a0[_0x9c81c6('0x4')]=qs[_0x9c81c6('0x1')](_[_0x9c81c6('0x16')](_0x44a350[_0x9c81c6('0x22')],_0x313a5d[_0x9c81c6('0x1')])),_0x44a350[_0x9c81c6('0x22')][_0x9c81c6('0x1f')]&&(_0xafe9a0[_0x9c81c6('0x4')]=_[_0x9c81c6('0x27')](_0xafe9a0[_0x9c81c6('0x4')],{[Op['or']]:_['map'](_0xafe9a0['attributes'],function(_0x20fe08){const _0x129d46=_0x9c81c6,_0xcfacaa={};return _0xcfacaa[_0x20fe08]={[Op['like']]:'%'+_0x44a350['query'][_0x129d46('0x1f')]+'%'},_0xcfacaa;})})),_0xafe9a0=_['merge']({},_0xafe9a0,_0x44a350[_0x9c81c6('0x38')]),_0x1443bc['getDescriptions'](_0xafe9a0);})[_0x43aeaf('0x30')](function(_0x5085f8){const _0x34fbb5=_0x43aeaf;if(_0x5085f8)return _0x57e113=_0x5085f8[_0x34fbb5('0x2')],typeof _0x44a350['query']['nolimit']===_0x34fbb5('0x21')&&(_0xafe9a0[_0x34fbb5('0xc')]=qs[_0x34fbb5('0xc')](_0x44a350[_0x34fbb5('0x22')][_0x34fbb5('0xc')]),_0xafe9a0[_0x34fbb5('0x17')]=qs[_0x34fbb5('0x17')](_0x44a350['query'][_0x34fbb5('0x17')])),_0x1443bc[_0x34fbb5('0x14')](_0xafe9a0);})['then'](function(_0x11b673){if(_0x11b673)return _0x11b673?{'count':_0x57e113,'rows':_0x11b673}:null;})['then'](respondWithResult(_0x3d50c3,null))[_0x43aeaf('0xf')](handleError(_0x3d50c3,null));};