4f89722114158d492a89b339fe421a389e8fadaa
[motion-next.git] / server / api / integration / integration.controller.js
1 const a359_0x382d=['limit','rawAttributes','params','end','sendStatus','keys','options','length','includeAll','order','filter','map','like','body','../../config/logger','include','destroy','count','sort','create','lodash','offset','stack','model','rows','intersection','filters','Content-Range','json','sequelize','pick','status','../../mysqldb','error','catch','key','then','findOne','fields','send','merge','Integration','nolimit','query','fieldName','update','type','where','name','attributes'];(function(_0x3fe9aa,_0x382db0){const _0x3b8a74=function(_0x50e24c){while(--_0x50e24c){_0x3fe9aa['push'](_0x3fe9aa['shift']());}};_0x3b8a74(++_0x382db0);}(a359_0x382d,0x1b3));const a359_0x3b8a=function(_0x3fe9aa,_0x382db0){_0x3fe9aa=_0x3fe9aa-0x0;let _0x3b8a74=a359_0x382d[_0x3fe9aa];return _0x3b8a74;};const _0x38894d=a359_0x3b8a;'use strict';const _=require(_0x38894d('0x23')),qs=require('../../components/parsers/qs'),logger=require(_0x38894d('0x1d'))('api'),db=require(_0x38894d('0x2f'))['db'],{Op}=require(_0x38894d('0x2c'));function respondWithResult(_0x50e24c,_0x8b93eb){return _0x8b93eb=_0x8b93eb||0xc8,function(_0x19d15e){const _0x4d7ead=a359_0x3b8a;if(_0x19d15e)return _0x50e24c[_0x4d7ead('0x2e')](_0x8b93eb)[_0x4d7ead('0x2b')](_0x19d15e);};}function respondWithFilteredResult(_0x272d92,_0x4fe9e8){return function(_0x45ec5b){const _0x530e75=a359_0x3b8a;if(_0x45ec5b){const _0x28f933=_0x45ec5b['count'],_0x818d4c=_0x4fe9e8['offset'];let _0x2d0b7=_0x4fe9e8[_0x530e75('0x24')]+_0x4fe9e8[_0x530e75('0xf')],_0x171bf7;return _0x2d0b7>=_0x28f933?(_0x2d0b7=_0x28f933,_0x171bf7=0xc8):_0x171bf7=0xce,_0x272d92['status'](_0x171bf7),_0x272d92['set'](_0x530e75('0x2a'),_0x818d4c+'-'+_0x2d0b7+'/'+_0x28f933)[_0x530e75('0x2b')](_0x45ec5b);}return null;};}function saveUpdates(_0x44fbd8){return function(_0x5b7097){const _0x57f5f0=a359_0x3b8a;if(_0x5b7097)return _0x5b7097[_0x57f5f0('0xa')](_0x44fbd8)[_0x57f5f0('0x1')](function(_0x2921f8){return _0x2921f8;});return null;};}function removeEntity(_0x320c53){return function(_0x35b4e1){const _0x1f0584=a359_0x3b8a;if(_0x35b4e1)return _0x35b4e1[_0x1f0584('0x1f')]()[_0x1f0584('0x1')](function(){const _0x37d6d0=_0x1f0584;_0x320c53['status'](0xcc)[_0x37d6d0('0x12')]();});};}function handleEntityNotFound(_0x482d9){return function(_0x574546){const _0x10e315=a359_0x3b8a;return!_0x574546&&_0x482d9[_0x10e315('0x13')](0x194),_0x574546;};}function handleError(_0x391333,_0x48dfd6){return _0x48dfd6=_0x48dfd6||0x1f4,function(_0x38b9a9){const _0x234e34=a359_0x3b8a;logger[_0x234e34('0x30')](_0x38b9a9[_0x234e34('0x25')]),_0x38b9a9[_0x234e34('0xd')]&&delete _0x38b9a9[_0x234e34('0xd')],_0x391333[_0x234e34('0x2e')](_0x48dfd6)[_0x234e34('0x4')](_0x38b9a9);};}exports['index']=function(_0x2894c1,_0xaa4df3){const _0x34ba46=_0x38894d;let _0x275c69={};const _0x2c6001={},_0x5726aa={'count':0x0,'rows':[]},_0x1d85bd=_[_0x34ba46('0x1a')](db['Integration'][_0x34ba46('0x10')],function(_0x11b0c0){const _0x56c63a=_0x34ba46;return{'name':_0x11b0c0[_0x56c63a('0x9')],'type':_0x11b0c0[_0x56c63a('0xb')][_0x56c63a('0x0')]};});_0x2c6001[_0x34ba46('0x26')]=_[_0x34ba46('0x1a')](_0x1d85bd,'name'),_0x2c6001[_0x34ba46('0x8')]=_[_0x34ba46('0x14')](_0x2894c1[_0x34ba46('0x8')]),_0x2c6001[_0x34ba46('0x29')]=_[_0x34ba46('0x28')](_0x2c6001[_0x34ba46('0x26')],_0x2c6001[_0x34ba46('0x8')]),_0x275c69[_0x34ba46('0xe')]=_[_0x34ba46('0x28')](_0x2c6001['model'],qs[_0x34ba46('0x3')](_0x2894c1['query'][_0x34ba46('0x3')])),_0x275c69[_0x34ba46('0xe')]=_0x275c69['attributes']['length']?_0x275c69['attributes']:_0x2c6001['model'];typeof _0x2894c1[_0x34ba46('0x8')][_0x34ba46('0x7')]==='undefined'&&(_0x275c69[_0x34ba46('0xf')]=qs['limit'](_0x2894c1[_0x34ba46('0x8')][_0x34ba46('0xf')]),_0x275c69[_0x34ba46('0x24')]=qs[_0x34ba46('0x24')](_0x2894c1[_0x34ba46('0x8')][_0x34ba46('0x24')]));_0x275c69[_0x34ba46('0x18')]=qs[_0x34ba46('0x21')](_0x2894c1[_0x34ba46('0x8')][_0x34ba46('0x21')]),_0x275c69['where']=qs[_0x34ba46('0x29')](_[_0x34ba46('0x2d')](_0x2894c1[_0x34ba46('0x8')],_0x2c6001[_0x34ba46('0x29')]),_0x1d85bd);_0x2894c1[_0x34ba46('0x8')][_0x34ba46('0x19')]&&(_0x275c69[_0x34ba46('0xc')]=_['merge'](_0x275c69[_0x34ba46('0xc')],{[Op['or']]:_[_0x34ba46('0x1a')](_0x1d85bd,function(_0x5249a5){const _0x5f5a54=_0x34ba46;if(_0x5249a5[_0x5f5a54('0xb')]!=='VIRTUAL'){const _0x2af8a0={};return _0x2af8a0[_0x5249a5[_0x5f5a54('0xd')]]={[Op[_0x5f5a54('0x1b')]]:'%'+_0x2894c1[_0x5f5a54('0x8')]['filter']+'%'},_0x2af8a0;}})}));_0x275c69=_[_0x34ba46('0x5')]({},_0x275c69,_0x2894c1[_0x34ba46('0x15')]);const _0x536f70={'where':_0x275c69[_0x34ba46('0xc')]};return db[_0x34ba46('0x6')][_0x34ba46('0x20')](_0x536f70)[_0x34ba46('0x1')](function(_0x4f02b0){const _0x3b5baa=_0x34ba46;return _0x5726aa[_0x3b5baa('0x20')]=_0x4f02b0,_0x2894c1['query'][_0x3b5baa('0x17')]&&(_0x275c69['include']=[{'all':!![]}]),db[_0x3b5baa('0x6')]['findAll'](_0x275c69);})[_0x34ba46('0x1')](function(_0x1ddeb8){const _0x47a3fc=_0x34ba46;return _0x5726aa[_0x47a3fc('0x27')]=_0x1ddeb8,_0x5726aa;})[_0x34ba46('0x1')](respondWithFilteredResult(_0xaa4df3,_0x275c69))[_0x34ba46('0x31')](handleError(_0xaa4df3,null));},exports['show']=function(_0x2bd9ff,_0x5001c1){const _0x389373=_0x38894d;let _0x2b62ee={'raw':![],'where':{'id':_0x2bd9ff[_0x389373('0x11')]['id']}};const _0xde2422={};return _0xde2422[_0x389373('0x26')]=_['keys'](db['Integration']['rawAttributes']),_0xde2422[_0x389373('0x8')]=_[_0x389373('0x14')](_0x2bd9ff['query']),_0xde2422[_0x389373('0x29')]=_[_0x389373('0x28')](_0xde2422['model'],_0xde2422[_0x389373('0x8')]),_0x2b62ee[_0x389373('0xe')]=_['intersection'](_0xde2422[_0x389373('0x26')],qs[_0x389373('0x3')](_0x2bd9ff[_0x389373('0x8')][_0x389373('0x3')])),_0x2b62ee[_0x389373('0xe')]=_0x2b62ee[_0x389373('0xe')][_0x389373('0x16')]?_0x2b62ee[_0x389373('0xe')]:_0xde2422[_0x389373('0x26')],_0x2bd9ff[_0x389373('0x8')][_0x389373('0x17')]&&(_0x2b62ee[_0x389373('0x1e')]=[{'all':!![]}]),_0x2b62ee=_[_0x389373('0x5')]({},_0x2b62ee,_0x2bd9ff[_0x389373('0x15')]),db[_0x389373('0x6')]['findOne'](_0x2b62ee)[_0x389373('0x1')](handleEntityNotFound(_0x5001c1,null))['then'](respondWithResult(_0x5001c1,null))['catch'](handleError(_0x5001c1,null));},exports[_0x38894d('0x22')]=function(_0x2d201f,_0x5b0bf5){const _0x203eeb=_0x38894d;return db[_0x203eeb('0x6')][_0x203eeb('0x22')](_0x2d201f['body'],{})[_0x203eeb('0x1')](respondWithResult(_0x5b0bf5,0xc9))['catch'](handleError(_0x5b0bf5,null));},exports['update']=function(_0x5d9c89,_0x1674bc){const _0xb80f4b=_0x38894d;return _0x5d9c89[_0xb80f4b('0x1c')]['id']&&delete _0x5d9c89[_0xb80f4b('0x1c')]['id'],db[_0xb80f4b('0x6')][_0xb80f4b('0x2')]({'where':{'id':_0x5d9c89['params']['id']}})[_0xb80f4b('0x1')](handleEntityNotFound(_0x1674bc,null))[_0xb80f4b('0x1')](saveUpdates(_0x5d9c89[_0xb80f4b('0x1c')],null))[_0xb80f4b('0x1')](respondWithResult(_0x1674bc,null))[_0xb80f4b('0x31')](handleError(_0x1674bc,null));},exports[_0x38894d('0x1f')]=function(_0x4e12ab,_0x44ea2a){const _0x5244c9=_0x38894d;return db[_0x5244c9('0x6')][_0x5244c9('0x2')]({'where':{'id':_0x4e12ab[_0x5244c9('0x11')]['id']}})['then'](handleEntityNotFound(_0x44ea2a,null))[_0x5244c9('0x1')](removeEntity(_0x44ea2a,null))[_0x5244c9('0x31')](handleError(_0x44ea2a,null));};