Built motion from commit f861bcb808219e66da88ba48b61bddb35224a65e. Version 3.0.0...
[motion-next.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
1 'use strict';const a374_0x205f=['catch','19IKuKnU','update','keys','12BiZKdC','create','1997RWHvNV','key','query','name','86225iKVFJS','count','json','@mysqldb','length','668739Trbkot','merge','set','filters','order','109667SEsrXA','end','Content-Range','@components/parsers/qs','show','limit','nolimit','stack','SugarcrmField','473894NiSgci','getFields','undefined','attributes','params','type','then','offset','fields','pick','body','1mQkbrH','rows','includeAll','1457648TfuIgy','map','index','api','getSubjects','destroy','lodash','model','error','findOne','intersection','options','8auIVwW','getDescriptions','include','1384472MtJwDU','SugarcrmConfiguration','sort','filter','status','where','rawAttributes','@config/logger'];const a374_0xb675=function(_0x503c79,_0x1988e9){_0x503c79=_0x503c79-0x89;let _0x205f1a=a374_0x205f[_0x503c79];return _0x205f1a;};const a374_0x449015=a374_0xb675;(function(_0x49b914,_0x1717ba){const _0xc3d9a9=a374_0xb675;while(!![]){try{const _0x3c592e=parseInt(_0xc3d9a9(0xbe))+parseInt(_0xc3d9a9(0xa1))+-parseInt(_0xc3d9a9(0xaf))+parseInt(_0xc3d9a9(0xac))*parseInt(_0xc3d9a9(0x93))+parseInt(_0xc3d9a9(0x8a))*-parseInt(_0xc3d9a9(0xc7))+-parseInt(_0xc3d9a9(0x98))*-parseInt(_0xc3d9a9(0xbb))+parseInt(_0xc3d9a9(0xca))*-parseInt(_0xc3d9a9(0x8e));if(_0x3c592e===_0x1717ba)break;else _0x49b914['push'](_0x49b914['shift']());}catch(_0x5d2a04){_0x49b914['push'](_0x49b914['shift']());}}}(a374_0x205f,0xd56a6));const _=require(a374_0x449015(0xb5)),qs=require(a374_0x449015(0x9b)),logger=require(a374_0x449015(0xc5))(a374_0x449015(0xb2)),{db}=require(a374_0x449015(0x91)),{filterAttributes}=require('@utils/filter-attributes');function respondWithResult(_0x164aee,_0x5ec895){return _0x5ec895=_0x5ec895||0xc8,function(_0x51a790){const _0xe2a148=a374_0xb675;if(_0x51a790)return _0x164aee[_0xe2a148(0xc2)](_0x5ec895)[_0xe2a148(0x90)](_0x51a790);};}function respondWithFilteredResult(_0x24a729,_0x492e7f){return function(_0x1a0eb3){const _0x32dfa6=a374_0xb675;if(_0x1a0eb3){const _0x30b2e5=_0x1a0eb3['count'],_0x3ebefc=_0x492e7f['offset'];let _0x155a6b=_0x492e7f[_0x32dfa6(0xa8)]+_0x492e7f[_0x32dfa6(0x9d)],_0xa383a2;return _0x155a6b>=_0x30b2e5?(_0x155a6b=_0x30b2e5,_0xa383a2=0xc8):_0xa383a2=0xce,_0x24a729[_0x32dfa6(0xc2)](_0xa383a2),_0x24a729[_0x32dfa6(0x95)](_0x32dfa6(0x9a),_0x3ebefc+'-'+_0x155a6b+'/'+_0x30b2e5)[_0x32dfa6(0x90)](_0x1a0eb3);}return null;};}function saveUpdates(_0x518a1a){return function(_0x38a875){const _0x94c64e=a374_0xb675;if(_0x38a875)return _0x38a875[_0x94c64e(0xc8)](_0x518a1a)[_0x94c64e(0xa7)](function(_0x314ff1){return _0x314ff1;});return null;};}function removeEntity(_0x405389){return function(_0x3f871c){const _0x4d17a7=a374_0xb675;if(_0x3f871c)return _0x3f871c[_0x4d17a7(0xb4)]()[_0x4d17a7(0xa7)](function(){const _0xdd69b2=_0x4d17a7;_0x405389[_0xdd69b2(0xc2)](0xcc)[_0xdd69b2(0x99)]();});};}function handleEntityNotFound(_0x39c91){return function(_0xe456cf){return!_0xe456cf&&_0x39c91['sendStatus'](0x194),_0xe456cf;};}function handleError(_0x2538fe,_0x516a41){return _0x516a41=_0x516a41||0x1f4,function(_0x49f90a){const _0x66a3b2=a374_0xb675;logger[_0x66a3b2(0xb7)](_0x49f90a[_0x66a3b2(0x9f)]),_0x49f90a[_0x66a3b2(0x8d)]&&delete _0x49f90a[_0x66a3b2(0x8d)],_0x2538fe[_0x66a3b2(0xc2)](_0x516a41)['send'](_0x49f90a);};}exports[a374_0x449015(0xb1)]=function(_0x173df4,_0xbcf16a){const _0x5d2d48=a374_0x449015;let _0x3f3c97={};const _0x357691={},_0x728429={'count':0x0,'rows':[]},_0x2f0ab4=_[_0x5d2d48(0xb0)](db[_0x5d2d48(0xbf)][_0x5d2d48(0xc4)],function(_0x5cd3e3){const _0x4faf06=_0x5d2d48;return{'name':_0x5cd3e3['fieldName'],'type':_0x5cd3e3[_0x4faf06(0xa6)][_0x4faf06(0x8b)]};});_0x357691['model']=_[_0x5d2d48(0xb0)](_0x2f0ab4,'name'),_0x357691[_0x5d2d48(0x8c)]=_[_0x5d2d48(0xc9)](_0x173df4[_0x5d2d48(0x8c)]),_0x357691[_0x5d2d48(0x96)]=_['intersection'](_0x357691[_0x5d2d48(0xb6)],_0x357691[_0x5d2d48(0x8c)]),_0x3f3c97[_0x5d2d48(0xa4)]=_[_0x5d2d48(0xb9)](_0x357691['model'],qs[_0x5d2d48(0xa9)](_0x173df4[_0x5d2d48(0x8c)][_0x5d2d48(0xa9)])),_0x3f3c97[_0x5d2d48(0xa4)]=_0x3f3c97['attributes'][_0x5d2d48(0x92)]?_0x3f3c97[_0x5d2d48(0xa4)]:_0x357691[_0x5d2d48(0xb6)];typeof _0x173df4[_0x5d2d48(0x8c)][_0x5d2d48(0x9e)]===_0x5d2d48(0xa3)&&(_0x3f3c97[_0x5d2d48(0x9d)]=qs[_0x5d2d48(0x9d)](_0x173df4['query'][_0x5d2d48(0x9d)]),_0x3f3c97['offset']=qs[_0x5d2d48(0xa8)](_0x173df4['query']['offset']));_0x3f3c97[_0x5d2d48(0x97)]=qs[_0x5d2d48(0xc0)](_0x173df4['query']['sort']),_0x3f3c97[_0x5d2d48(0xc3)]=qs[_0x5d2d48(0x96)](_[_0x5d2d48(0xaa)](_0x173df4[_0x5d2d48(0x8c)],_0x357691[_0x5d2d48(0x96)]),_0x2f0ab4),_0x3f3c97=filterAttributes(_0x3f3c97,_0x173df4['query']['filter'],_0x2f0ab4,_0x173df4[_0x5d2d48(0xba)]);const _0x46e1d7={'where':_0x3f3c97[_0x5d2d48(0xc3)]};return db[_0x5d2d48(0xbf)][_0x5d2d48(0x8f)](_0x46e1d7)[_0x5d2d48(0xa7)](function(_0xaf4937){const _0x3d62ad=_0x5d2d48;return _0x728429[_0x3d62ad(0x8f)]=_0xaf4937,_0x173df4['query'][_0x3d62ad(0xae)]&&(_0x3f3c97[_0x3d62ad(0xbd)]=[{'all':!![]}]),db[_0x3d62ad(0xbf)]['findAll'](_0x3f3c97);})['then'](function(_0x20e02b){const _0x5a362f=_0x5d2d48;return _0x728429[_0x5a362f(0xad)]=_0x20e02b,_0x728429;})[_0x5d2d48(0xa7)](respondWithFilteredResult(_0xbcf16a,_0x3f3c97))[_0x5d2d48(0xc6)](handleError(_0xbcf16a,null));},exports[a374_0x449015(0x9c)]=function(_0x472ddc,_0x265ee3){const _0x2209bb=a374_0x449015;let _0x4b76ac={'raw':![],'where':{'id':_0x472ddc[_0x2209bb(0xa5)]['id']}};const _0x1d7441={};return _0x1d7441[_0x2209bb(0xb6)]=_['keys'](db[_0x2209bb(0xbf)]['rawAttributes']),_0x1d7441[_0x2209bb(0x8c)]=_['keys'](_0x472ddc[_0x2209bb(0x8c)]),_0x1d7441['filters']=_[_0x2209bb(0xb9)](_0x1d7441['model'],_0x1d7441[_0x2209bb(0x8c)]),_0x4b76ac[_0x2209bb(0xa4)]=_[_0x2209bb(0xb9)](_0x1d7441[_0x2209bb(0xb6)],qs['fields'](_0x472ddc[_0x2209bb(0x8c)][_0x2209bb(0xa9)])),_0x4b76ac[_0x2209bb(0xa4)]=_0x4b76ac[_0x2209bb(0xa4)][_0x2209bb(0x92)]?_0x4b76ac[_0x2209bb(0xa4)]:_0x1d7441['model'],_0x472ddc[_0x2209bb(0x8c)][_0x2209bb(0xae)]&&(_0x4b76ac['include']=[{'all':!![]}]),_0x4b76ac=_[_0x2209bb(0x94)]({},_0x4b76ac,_0x472ddc[_0x2209bb(0xba)]),db[_0x2209bb(0xbf)]['findOne'](_0x4b76ac)[_0x2209bb(0xa7)](handleEntityNotFound(_0x265ee3,null))['then'](respondWithResult(_0x265ee3,null))['catch'](handleError(_0x265ee3,null));},exports[a374_0x449015(0x89)]=function(_0xc9cc0e,_0x1ed64a){const _0x398ec6=a374_0x449015;return db['SugarcrmConfiguration'][_0x398ec6(0x89)](_0xc9cc0e[_0x398ec6(0xab)],{})['then'](respondWithResult(_0x1ed64a,0xc9))['catch'](handleError(_0x1ed64a,null));},exports[a374_0x449015(0xc8)]=function(_0xc5930b,_0x25d3bf){const _0x28ef21=a374_0x449015;return _0xc5930b[_0x28ef21(0xab)]['id']&&delete _0xc5930b[_0x28ef21(0xab)]['id'],db['SugarcrmConfiguration'][_0x28ef21(0xb8)]({'where':{'id':_0xc5930b[_0x28ef21(0xa5)]['id']}})[_0x28ef21(0xa7)](handleEntityNotFound(_0x25d3bf,null))[_0x28ef21(0xa7)](saveUpdates(_0xc5930b['body'],null))[_0x28ef21(0xa7)](respondWithResult(_0x25d3bf,null))['catch'](handleError(_0x25d3bf,null));},exports['destroy']=function(_0x5e9ed0,_0x84b32d){const _0x21ed46=a374_0x449015;return db[_0x21ed46(0xbf)][_0x21ed46(0xb8)]({'where':{'id':_0x5e9ed0[_0x21ed46(0xa5)]['id']}})[_0x21ed46(0xa7)](handleEntityNotFound(_0x84b32d,null))[_0x21ed46(0xa7)](removeEntity(_0x84b32d,null))['catch'](handleError(_0x84b32d,null));},exports[a374_0x449015(0xa2)]=function(_0x15aa46,_0x668ba7){const _0x5befcf=a374_0x449015;let _0x181bf5={};const _0x20d600={};let _0x578439,_0x57e02c;return db[_0x5befcf(0xbf)][_0x5befcf(0xb8)]({'where':{'id':_0x15aa46[_0x5befcf(0xa5)]['id']}})[_0x5befcf(0xa7)](handleEntityNotFound(_0x668ba7,null))[_0x5befcf(0xa7)](function(_0x186c20){const _0x42b4ac=_0x5befcf;if(_0x186c20)return _0x578439=_0x186c20,_0x20d600[_0x42b4ac(0xb6)]=_['keys'](db[_0x42b4ac(0xa0)]['rawAttributes']),_0x20d600['query']=_[_0x42b4ac(0xc9)](_0x15aa46['query']),_0x20d600['filters']=_['intersection'](_0x20d600[_0x42b4ac(0xb6)],_0x20d600[_0x42b4ac(0x8c)]),_0x181bf5[_0x42b4ac(0xa4)]=_[_0x42b4ac(0xb9)](_0x20d600[_0x42b4ac(0xb6)],qs[_0x42b4ac(0xa9)](_0x15aa46[_0x42b4ac(0x8c)][_0x42b4ac(0xa9)])),_0x181bf5['attributes']=_0x181bf5[_0x42b4ac(0xa4)][_0x42b4ac(0x92)]?_0x181bf5[_0x42b4ac(0xa4)]:_0x20d600[_0x42b4ac(0xb6)],_0x181bf5['order']=qs['sort'](_0x15aa46[_0x42b4ac(0x8c)][_0x42b4ac(0xc0)]),_0x181bf5['where']=qs[_0x42b4ac(0x96)](_['pick'](_0x15aa46[_0x42b4ac(0x8c)],_0x20d600['filters'])),_0x181bf5=filterAttributes(_0x181bf5,_0x15aa46[_0x42b4ac(0x8c)][_0x42b4ac(0xc1)],_0x181bf5[_0x42b4ac(0xa4)],_0x15aa46[_0x42b4ac(0xba)],![]),_0x578439['getFields'](_0x181bf5);})[_0x5befcf(0xa7)](function(_0x524e38){const _0x50cb67=_0x5befcf;if(_0x524e38)return _0x57e02c=_0x524e38[_0x50cb67(0x92)],typeof _0x15aa46[_0x50cb67(0x8c)][_0x50cb67(0x9e)]===_0x50cb67(0xa3)&&(_0x181bf5['limit']=qs[_0x50cb67(0x9d)](_0x15aa46[_0x50cb67(0x8c)]['limit']),_0x181bf5['offset']=qs[_0x50cb67(0xa8)](_0x15aa46[_0x50cb67(0x8c)][_0x50cb67(0xa8)])),_0x578439[_0x50cb67(0xa2)](_0x181bf5);})['then'](function(_0x3f7e81){if(_0x3f7e81)return _0x3f7e81?{'count':_0x57e02c,'rows':_0x3f7e81}:null;})['then'](respondWithResult(_0x668ba7,null))['catch'](handleError(_0x668ba7,null));},exports['getSubjects']=function(_0x4aa4cb,_0x5f1a11){const _0xc8e12e=a374_0x449015;let _0x8e5f41={};const _0x1ed607={};let _0x318de3,_0xd93f2b;return db['SugarcrmConfiguration'][_0xc8e12e(0xb8)]({'where':{'id':_0x4aa4cb[_0xc8e12e(0xa5)]['id']}})[_0xc8e12e(0xa7)](handleEntityNotFound(_0x5f1a11,null))[_0xc8e12e(0xa7)](function(_0x54ee68){const _0x4a03b2=_0xc8e12e;if(_0x54ee68)return _0x318de3=_0x54ee68,_0x1ed607[_0x4a03b2(0xb6)]=_[_0x4a03b2(0xc9)](db[_0x4a03b2(0xa0)]['rawAttributes']),_0x1ed607['query']=_[_0x4a03b2(0xc9)](_0x4aa4cb['query']),_0x1ed607[_0x4a03b2(0x96)]=_[_0x4a03b2(0xb9)](_0x1ed607[_0x4a03b2(0xb6)],_0x1ed607[_0x4a03b2(0x8c)]),_0x8e5f41[_0x4a03b2(0xa4)]=_[_0x4a03b2(0xb9)](_0x1ed607[_0x4a03b2(0xb6)],qs[_0x4a03b2(0xa9)](_0x4aa4cb[_0x4a03b2(0x8c)][_0x4a03b2(0xa9)])),_0x8e5f41['attributes']=_0x8e5f41[_0x4a03b2(0xa4)]['length']?_0x8e5f41[_0x4a03b2(0xa4)]:_0x1ed607[_0x4a03b2(0xb6)],_0x8e5f41['order']=qs[_0x4a03b2(0xc0)](_0x4aa4cb['query']['sort']),_0x8e5f41['where']=qs[_0x4a03b2(0x96)](_['pick'](_0x4aa4cb['query'],_0x1ed607[_0x4a03b2(0x96)])),_0x8e5f41=filterAttributes(_0x8e5f41,_0x4aa4cb['query'][_0x4a03b2(0xc1)],_0x8e5f41[_0x4a03b2(0xa4)],_0x4aa4cb[_0x4a03b2(0xba)],![]),_0x318de3[_0x4a03b2(0xb3)](_0x8e5f41);})['then'](function(_0x28e812){const _0x80d53b=_0xc8e12e;if(_0x28e812)return _0xd93f2b=_0x28e812[_0x80d53b(0x92)],typeof _0x4aa4cb['query']['nolimit']===_0x80d53b(0xa3)&&(_0x8e5f41[_0x80d53b(0x9d)]=qs[_0x80d53b(0x9d)](_0x4aa4cb['query'][_0x80d53b(0x9d)]),_0x8e5f41[_0x80d53b(0xa8)]=qs[_0x80d53b(0xa8)](_0x4aa4cb[_0x80d53b(0x8c)][_0x80d53b(0xa8)])),_0x318de3[_0x80d53b(0xb3)](_0x8e5f41);})[_0xc8e12e(0xa7)](function(_0x743590){if(_0x743590)return _0x743590?{'count':_0xd93f2b,'rows':_0x743590}:null;})['then'](respondWithResult(_0x5f1a11,null))[_0xc8e12e(0xc6)](handleError(_0x5f1a11,null));},exports[a374_0x449015(0xbc)]=function(_0x4597d1,_0x37aa2b){const _0x5b290f=a374_0x449015;let _0x2713e1={};const _0x4fd523={};let _0x36334f,_0x1f4e21;return db[_0x5b290f(0xbf)][_0x5b290f(0xb8)]({'where':{'id':_0x4597d1[_0x5b290f(0xa5)]['id']}})[_0x5b290f(0xa7)](handleEntityNotFound(_0x37aa2b,null))[_0x5b290f(0xa7)](function(_0x4e75ea){const _0x21f6c4=_0x5b290f;if(_0x4e75ea)return _0x36334f=_0x4e75ea,_0x4fd523[_0x21f6c4(0xb6)]=_[_0x21f6c4(0xc9)](db['SugarcrmField'][_0x21f6c4(0xc4)]),_0x4fd523[_0x21f6c4(0x8c)]=_[_0x21f6c4(0xc9)](_0x4597d1[_0x21f6c4(0x8c)]),_0x4fd523[_0x21f6c4(0x96)]=_['intersection'](_0x4fd523[_0x21f6c4(0xb6)],_0x4fd523[_0x21f6c4(0x8c)]),_0x2713e1[_0x21f6c4(0xa4)]=_[_0x21f6c4(0xb9)](_0x4fd523['model'],qs[_0x21f6c4(0xa9)](_0x4597d1['query'][_0x21f6c4(0xa9)])),_0x2713e1[_0x21f6c4(0xa4)]=_0x2713e1['attributes'][_0x21f6c4(0x92)]?_0x2713e1['attributes']:_0x4fd523[_0x21f6c4(0xb6)],_0x2713e1[_0x21f6c4(0x97)]=qs[_0x21f6c4(0xc0)](_0x4597d1[_0x21f6c4(0x8c)][_0x21f6c4(0xc0)]),_0x2713e1[_0x21f6c4(0xc3)]=qs[_0x21f6c4(0x96)](_['pick'](_0x4597d1[_0x21f6c4(0x8c)],_0x4fd523[_0x21f6c4(0x96)])),_0x2713e1=filterAttributes(_0x2713e1,_0x4597d1['query']['filter'],_0x2713e1['attributes'],_0x4597d1[_0x21f6c4(0xba)],![]),_0x36334f[_0x21f6c4(0xbc)](_0x2713e1);})[_0x5b290f(0xa7)](function(_0x48e092){const _0x36810e=_0x5b290f;if(_0x48e092)return _0x1f4e21=_0x48e092['length'],typeof _0x4597d1[_0x36810e(0x8c)]['nolimit']===_0x36810e(0xa3)&&(_0x2713e1['limit']=qs[_0x36810e(0x9d)](_0x4597d1[_0x36810e(0x8c)][_0x36810e(0x9d)]),_0x2713e1[_0x36810e(0xa8)]=qs[_0x36810e(0xa8)](_0x4597d1[_0x36810e(0x8c)][_0x36810e(0xa8)])),_0x36334f[_0x36810e(0xbc)](_0x2713e1);})[_0x5b290f(0xa7)](function(_0x42a45f){if(_0x42a45f)return _0x42a45f?{'count':_0x1f4e21,'rows':_0x42a45f}:null;})['then'](respondWithResult(_0x37aa2b,null))[_0x5b290f(0xc6)](handleError(_0x37aa2b,null));};