Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intFreshsalesField / intFreshsalesField.controller.js
index 6bebfb6..278766f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x06ac=['show','params','length','create','body','find','zip-dir','fast-json-patch','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','undefined','limit','count','set','Content-Range','update','then','destroy','sendStatus','stack','name','send','index','FreshsalesField','rawAttributes','fieldName','type','key','map','query','keys','filters','model','attributes','intersection','fields','hasOwnProperty','offset','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','rows','catch'];(function(_0x4619a7,_0x4239cd){var _0x46afbb=function(_0x4a46b7){while(--_0x4a46b7){_0x4619a7['push'](_0x4619a7['shift']());}};_0x46afbb(++_0x4239cd);}(_0x06ac,0x17d));var _0xc06a=function(_0x3a781b,_0x19f452){_0x3a781b=_0x3a781b-0x0;var _0x3a7770=_0x06ac[_0x3a781b];return _0x3a7770;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xc06a('0x0'));var jsonpatch=require(_0xc06a('0x1'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xc06a('0x2'));var Mustache=require(_0xc06a('0x3'));var util=require('util');var path=require(_0xc06a('0x4'));var sox=require(_0xc06a('0x5'));var csv=require(_0xc06a('0x6'));var ejs=require(_0xc06a('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc06a('0x8'));var squel=require(_0xc06a('0x9'));var crypto=require(_0xc06a('0xa'));var jsforce=require(_0xc06a('0xb'));var deskjs=require(_0xc06a('0xc'));var toCsv=require(_0xc06a('0x6'));var querystring=require(_0xc06a('0xd'));var Papa=require(_0xc06a('0xe'));var Redis=require(_0xc06a('0xf'));var authService=require(_0xc06a('0x10'));var qs=require(_0xc06a('0x11'));var as=require(_0xc06a('0x12'));var hardwareService=require(_0xc06a('0x13'));var logger=require(_0xc06a('0x14'))(_0xc06a('0x15'));var utils=require(_0xc06a('0x16'));var config=require(_0xc06a('0x17'));var licenseUtil=require(_0xc06a('0x18'));var db=require(_0xc06a('0x19'))['db'];function respondWithStatusCode(_0x8c5b9,_0x705a84){_0x705a84=_0x705a84||0xcc;return function(_0x32fd54){if(_0x32fd54){return _0x8c5b9['sendStatus'](_0x705a84);}return _0x8c5b9[_0xc06a('0x1a')](_0x705a84)[_0xc06a('0x1b')]();};}function respondWithResult(_0x4539f1,_0x9d822c){_0x9d822c=_0x9d822c||0xc8;return function(_0x310976){if(_0x310976){return _0x4539f1[_0xc06a('0x1a')](_0x9d822c)[_0xc06a('0x1c')](_0x310976);}};}function respondWithFilteredResult(_0x2fa6ca,_0x1ee5ba){return function(_0x17c776){if(_0x17c776){var _0x582135=typeof _0x1ee5ba['offset']===_0xc06a('0x1d')&&typeof _0x1ee5ba[_0xc06a('0x1e')]===_0xc06a('0x1d');var _0x449ccc=_0x17c776[_0xc06a('0x1f')];var _0x4834b0=_0x582135?0x0:_0x1ee5ba['offset'];var _0x50a7e6=_0x582135?_0x17c776[_0xc06a('0x1f')]:_0x1ee5ba['offset']+_0x1ee5ba[_0xc06a('0x1e')];var _0xfdb9b;if(_0x50a7e6>=_0x449ccc){_0x50a7e6=_0x449ccc;_0xfdb9b=0xc8;}else{_0xfdb9b=0xce;}_0x2fa6ca[_0xc06a('0x1a')](_0xfdb9b);return _0x2fa6ca[_0xc06a('0x20')](_0xc06a('0x21'),_0x4834b0+'-'+_0x50a7e6+'/'+_0x449ccc)[_0xc06a('0x1c')](_0x17c776);}return null;};}function patchUpdates(_0x19ad99){return function(_0x5264d2){try{jsonpatch['apply'](_0x5264d2,_0x19ad99,!![]);}catch(_0x334528){return BPromise['reject'](_0x334528);}return _0x5264d2['save']();};}function saveUpdates(_0x1f6d97,_0x5415c5){return function(_0x2668a){if(_0x2668a){return _0x2668a[_0xc06a('0x22')](_0x1f6d97)[_0xc06a('0x23')](function(_0x14ba92){return _0x14ba92;});}return null;};}function removeEntity(_0x1fec39,_0x349ccb){return function(_0x135646){if(_0x135646){return _0x135646[_0xc06a('0x24')]()[_0xc06a('0x23')](function(){_0x1fec39[_0xc06a('0x1a')](0xcc)[_0xc06a('0x1b')]();});}};}function handleEntityNotFound(_0x2030ef,_0x3d9557){return function(_0x5d77b9){if(!_0x5d77b9){_0x2030ef[_0xc06a('0x25')](0x194);}return _0x5d77b9;};}function handleError(_0x487dde,_0x4f09df){_0x4f09df=_0x4f09df||0x1f4;return function(_0x3c23c4){logger['error'](_0x3c23c4[_0xc06a('0x26')]);if(_0x3c23c4['name']){delete _0x3c23c4[_0xc06a('0x27')];}_0x487dde['status'](_0x4f09df)[_0xc06a('0x28')](_0x3c23c4);};}exports[_0xc06a('0x29')]=function(_0x38997b,_0x2f5c32){var _0xa554de={},_0x344991={},_0x58f3d3={'count':0x0,'rows':[]};var _0xafe8fd=_['map'](db[_0xc06a('0x2a')][_0xc06a('0x2b')],function(_0x4b53b1){return{'name':_0x4b53b1[_0xc06a('0x2c')],'type':_0x4b53b1[_0xc06a('0x2d')][_0xc06a('0x2e')]};});_0x344991['model']=_[_0xc06a('0x2f')](_0xafe8fd,_0xc06a('0x27'));_0x344991[_0xc06a('0x30')]=_[_0xc06a('0x31')](_0x38997b[_0xc06a('0x30')]);_0x344991[_0xc06a('0x32')]=_['intersection'](_0x344991[_0xc06a('0x33')],_0x344991[_0xc06a('0x30')]);_0xa554de[_0xc06a('0x34')]=_[_0xc06a('0x35')](_0x344991[_0xc06a('0x33')],qs[_0xc06a('0x36')](_0x38997b[_0xc06a('0x30')][_0xc06a('0x36')]));_0xa554de[_0xc06a('0x34')]=_0xa554de[_0xc06a('0x34')]['length']?_0xa554de[_0xc06a('0x34')]:_0x344991[_0xc06a('0x33')];if(!_0x38997b[_0xc06a('0x30')][_0xc06a('0x37')]('nolimit')){_0xa554de['limit']=qs[_0xc06a('0x1e')](_0x38997b[_0xc06a('0x30')]['limit']);_0xa554de['offset']=qs[_0xc06a('0x38')](_0x38997b[_0xc06a('0x30')][_0xc06a('0x38')]);}_0xa554de[_0xc06a('0x39')]=qs[_0xc06a('0x3a')](_0x38997b['query'][_0xc06a('0x3a')]);_0xa554de[_0xc06a('0x3b')]=qs[_0xc06a('0x32')](_[_0xc06a('0x3c')](_0x38997b[_0xc06a('0x30')],_0x344991[_0xc06a('0x32')]),_0xafe8fd);if(_0x38997b[_0xc06a('0x30')][_0xc06a('0x3d')]){_0xa554de[_0xc06a('0x3b')]=_[_0xc06a('0x3e')](_0xa554de[_0xc06a('0x3b')],{'$or':_['map'](_0xafe8fd,function(_0xdf13eb){if(_0xdf13eb['type']!==_0xc06a('0x3f')){var _0x2f8d42={};_0x2f8d42[_0xdf13eb[_0xc06a('0x27')]]={'$like':'%'+_0x38997b['query'][_0xc06a('0x3d')]+'%'};return _0x2f8d42;}})});}_0xa554de=_[_0xc06a('0x3e')]({},_0xa554de,_0x38997b[_0xc06a('0x40')]);var _0x85e7f={'where':_0xa554de[_0xc06a('0x3b')]};return db[_0xc06a('0x2a')][_0xc06a('0x1f')](_0x85e7f)[_0xc06a('0x23')](function(_0x392a75){_0x58f3d3[_0xc06a('0x1f')]=_0x392a75;if(_0x38997b[_0xc06a('0x30')][_0xc06a('0x41')]){_0xa554de[_0xc06a('0x42')]=[{'all':!![]}];}return db['FreshsalesField']['findAll'](_0xa554de);})['then'](function(_0x7b3bef){_0x58f3d3[_0xc06a('0x43')]=_0x7b3bef;return _0x58f3d3;})[_0xc06a('0x23')](respondWithFilteredResult(_0x2f5c32,_0xa554de))[_0xc06a('0x44')](handleError(_0x2f5c32,null));};exports[_0xc06a('0x45')]=function(_0x39c62c,_0x298eb5){var _0x4af8a4={'raw':!![],'where':{'id':_0x39c62c[_0xc06a('0x46')]['id']}},_0xb6574={};_0xb6574[_0xc06a('0x33')]=_['keys'](db[_0xc06a('0x2a')]['rawAttributes']);_0xb6574[_0xc06a('0x30')]=_[_0xc06a('0x31')](_0x39c62c[_0xc06a('0x30')]);_0xb6574[_0xc06a('0x32')]=_[_0xc06a('0x35')](_0xb6574[_0xc06a('0x33')],_0xb6574[_0xc06a('0x30')]);_0x4af8a4[_0xc06a('0x34')]=_[_0xc06a('0x35')](_0xb6574['model'],qs[_0xc06a('0x36')](_0x39c62c[_0xc06a('0x30')][_0xc06a('0x36')]));_0x4af8a4[_0xc06a('0x34')]=_0x4af8a4[_0xc06a('0x34')][_0xc06a('0x47')]?_0x4af8a4[_0xc06a('0x34')]:_0xb6574['model'];if(_0x39c62c['query'][_0xc06a('0x41')]){_0x4af8a4['include']=[{'all':!![]}];}_0x4af8a4=_['merge']({},_0x4af8a4,_0x39c62c[_0xc06a('0x40')]);return db[_0xc06a('0x2a')]['find'](_0x4af8a4)[_0xc06a('0x23')](handleEntityNotFound(_0x298eb5,null))['then'](respondWithResult(_0x298eb5,null))['catch'](handleError(_0x298eb5,null));};exports[_0xc06a('0x48')]=function(_0x174f9e,_0x35bafb){return db[_0xc06a('0x2a')][_0xc06a('0x48')](_0x174f9e[_0xc06a('0x49')],{})['then'](respondWithResult(_0x35bafb,0xc9))[_0xc06a('0x44')](handleError(_0x35bafb,null));};exports[_0xc06a('0x22')]=function(_0x253c01,_0x385429){if(_0x253c01['body']['id']){delete _0x253c01[_0xc06a('0x49')]['id'];}return db[_0xc06a('0x2a')][_0xc06a('0x4a')]({'where':{'id':_0x253c01['params']['id']}})[_0xc06a('0x23')](handleEntityNotFound(_0x385429,null))[_0xc06a('0x23')](saveUpdates(_0x253c01['body'],null))[_0xc06a('0x23')](respondWithResult(_0x385429,null))[_0xc06a('0x44')](handleError(_0x385429,null));};exports['destroy']=function(_0x24b50e,_0x518582){return db[_0xc06a('0x2a')][_0xc06a('0x4a')]({'where':{'id':_0x24b50e[_0xc06a('0x46')]['id']}})[_0xc06a('0x23')](handleEntityNotFound(_0x518582,null))[_0xc06a('0x23')](removeEntity(_0x518582,null))[_0xc06a('0x44')](handleError(_0x518582,null));};
\ No newline at end of file
+var _0x198a=['index','map','FreshsalesField','keys','query','intersection','model','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filters','filter','merge','type','VIRTUAL','name','options','includeAll','include','findAll','rows','show','params','rawAttributes','find','catch','create','body','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','limit','set','Content-Range','apply','save','update','then','destroy','error','send'];(function(_0x3470ef,_0x3bc4b3){var _0x4286a4=function(_0x597635){while(--_0x597635){_0x3470ef['push'](_0x3470ef['shift']());}};_0x4286a4(++_0x3bc4b3);}(_0x198a,0x1e3));var _0xa198=function(_0x3e89ca,_0x41c7e0){_0x3e89ca=_0x3e89ca-0x0;var _0x3e93d8=_0x198a[_0x3e89ca];return _0x3e93d8;};'use strict';var emlformat=require(_0xa198('0x0'));var rimraf=require(_0xa198('0x1'));var zipdir=require(_0xa198('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xa198('0x3'));var BPromise=require(_0xa198('0x4'));var Mustache=require(_0xa198('0x5'));var util=require(_0xa198('0x6'));var path=require('path');var sox=require(_0xa198('0x7'));var csv=require(_0xa198('0x8'));var ejs=require(_0xa198('0x9'));var fs=require('fs');var fs_extra=require(_0xa198('0xa'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xa198('0xb'));var jsforce=require(_0xa198('0xc'));var deskjs=require(_0xa198('0xd'));var toCsv=require('to-csv');var querystring=require(_0xa198('0xe'));var Papa=require('papaparse');var Redis=require(_0xa198('0xf'));var authService=require(_0xa198('0x10'));var qs=require(_0xa198('0x11'));var as=require(_0xa198('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xa198('0x13'))(_0xa198('0x14'));var utils=require(_0xa198('0x15'));var config=require(_0xa198('0x16'));var licenseUtil=require(_0xa198('0x17'));var db=require(_0xa198('0x18'))['db'];function respondWithStatusCode(_0x3d4034,_0x1c862a){_0x1c862a=_0x1c862a||0xcc;return function(_0x7616eb){if(_0x7616eb){return _0x3d4034[_0xa198('0x19')](_0x1c862a);}return _0x3d4034['status'](_0x1c862a)[_0xa198('0x1a')]();};}function respondWithResult(_0x4f5e7b,_0x19ebbf){_0x19ebbf=_0x19ebbf||0xc8;return function(_0x3305af){if(_0x3305af){return _0x4f5e7b[_0xa198('0x1b')](_0x19ebbf)[_0xa198('0x1c')](_0x3305af);}};}function respondWithFilteredResult(_0xb3f12d,_0x42f94a){return function(_0x4f893a){if(_0x4f893a){var _0x2c3848=typeof _0x42f94a[_0xa198('0x1d')]==='undefined'&&typeof _0x42f94a['limit']===_0xa198('0x1e');var _0x55e892=_0x4f893a[_0xa198('0x1f')];var _0x561c42=_0x2c3848?0x0:_0x42f94a[_0xa198('0x1d')];var _0x3e1a1f=_0x2c3848?_0x4f893a[_0xa198('0x1f')]:_0x42f94a[_0xa198('0x1d')]+_0x42f94a[_0xa198('0x20')];var _0x30e00e;if(_0x3e1a1f>=_0x55e892){_0x3e1a1f=_0x55e892;_0x30e00e=0xc8;}else{_0x30e00e=0xce;}_0xb3f12d[_0xa198('0x1b')](_0x30e00e);return _0xb3f12d[_0xa198('0x21')](_0xa198('0x22'),_0x561c42+'-'+_0x3e1a1f+'/'+_0x55e892)[_0xa198('0x1c')](_0x4f893a);}return null;};}function patchUpdates(_0x1e3ba6){return function(_0x172ed4){try{jsonpatch[_0xa198('0x23')](_0x172ed4,_0x1e3ba6,!![]);}catch(_0x1ac010){return BPromise['reject'](_0x1ac010);}return _0x172ed4[_0xa198('0x24')]();};}function saveUpdates(_0x168344,_0x40d4aa){return function(_0x134941){if(_0x134941){return _0x134941[_0xa198('0x25')](_0x168344)[_0xa198('0x26')](function(_0x3fc065){return _0x3fc065;});}return null;};}function removeEntity(_0x1ee730,_0x11aa3e){return function(_0xa00f01){if(_0xa00f01){return _0xa00f01[_0xa198('0x27')]()['then'](function(){_0x1ee730[_0xa198('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5a1f81,_0x452c81){return function(_0x5a4b6b){if(!_0x5a4b6b){_0x5a1f81[_0xa198('0x19')](0x194);}return _0x5a4b6b;};}function handleError(_0x59ebf9,_0x424f29){_0x424f29=_0x424f29||0x1f4;return function(_0x475506){logger[_0xa198('0x28')](_0x475506['stack']);if(_0x475506['name']){delete _0x475506['name'];}_0x59ebf9[_0xa198('0x1b')](_0x424f29)[_0xa198('0x29')](_0x475506);};}exports[_0xa198('0x2a')]=function(_0x14511,_0x2521ef){var _0x5cc51f={},_0x2eeb35={},_0x57fba6={'count':0x0,'rows':[]};var _0x27e5a8=_[_0xa198('0x2b')](db[_0xa198('0x2c')]['rawAttributes'],function(_0x164ec5){return{'name':_0x164ec5['fieldName'],'type':_0x164ec5['type']['key']};});_0x2eeb35['model']=_['map'](_0x27e5a8,'name');_0x2eeb35['query']=_[_0xa198('0x2d')](_0x14511[_0xa198('0x2e')]);_0x2eeb35['filters']=_[_0xa198('0x2f')](_0x2eeb35[_0xa198('0x30')],_0x2eeb35[_0xa198('0x2e')]);_0x5cc51f['attributes']=_[_0xa198('0x2f')](_0x2eeb35[_0xa198('0x30')],qs[_0xa198('0x31')](_0x14511[_0xa198('0x2e')][_0xa198('0x31')]));_0x5cc51f[_0xa198('0x32')]=_0x5cc51f[_0xa198('0x32')][_0xa198('0x33')]?_0x5cc51f[_0xa198('0x32')]:_0x2eeb35[_0xa198('0x30')];if(!_0x14511[_0xa198('0x2e')][_0xa198('0x34')]('nolimit')){_0x5cc51f[_0xa198('0x20')]=qs[_0xa198('0x20')](_0x14511['query']['limit']);_0x5cc51f[_0xa198('0x1d')]=qs[_0xa198('0x1d')](_0x14511[_0xa198('0x2e')][_0xa198('0x1d')]);}_0x5cc51f[_0xa198('0x35')]=qs[_0xa198('0x36')](_0x14511[_0xa198('0x2e')][_0xa198('0x36')]);_0x5cc51f[_0xa198('0x37')]=qs['filters'](_[_0xa198('0x38')](_0x14511[_0xa198('0x2e')],_0x2eeb35[_0xa198('0x39')]),_0x27e5a8);if(_0x14511[_0xa198('0x2e')][_0xa198('0x3a')]){_0x5cc51f[_0xa198('0x37')]=_[_0xa198('0x3b')](_0x5cc51f[_0xa198('0x37')],{'$or':_[_0xa198('0x2b')](_0x27e5a8,function(_0xf0ef21){if(_0xf0ef21[_0xa198('0x3c')]!==_0xa198('0x3d')){var _0x1c3ede={};_0x1c3ede[_0xf0ef21[_0xa198('0x3e')]]={'$like':'%'+_0x14511['query'][_0xa198('0x3a')]+'%'};return _0x1c3ede;}})});}_0x5cc51f=_[_0xa198('0x3b')]({},_0x5cc51f,_0x14511[_0xa198('0x3f')]);var _0x123192={'where':_0x5cc51f['where']};return db[_0xa198('0x2c')][_0xa198('0x1f')](_0x123192)['then'](function(_0x595a09){_0x57fba6['count']=_0x595a09;if(_0x14511[_0xa198('0x2e')][_0xa198('0x40')]){_0x5cc51f[_0xa198('0x41')]=[{'all':!![]}];}return db[_0xa198('0x2c')][_0xa198('0x42')](_0x5cc51f);})[_0xa198('0x26')](function(_0x5de2d6){_0x57fba6[_0xa198('0x43')]=_0x5de2d6;return _0x57fba6;})[_0xa198('0x26')](respondWithFilteredResult(_0x2521ef,_0x5cc51f))['catch'](handleError(_0x2521ef,null));};exports[_0xa198('0x44')]=function(_0x2f920a,_0x6d2564){var _0x426e24={'raw':!![],'where':{'id':_0x2f920a[_0xa198('0x45')]['id']}},_0x393e3d={};_0x393e3d['model']=_[_0xa198('0x2d')](db[_0xa198('0x2c')][_0xa198('0x46')]);_0x393e3d[_0xa198('0x2e')]=_[_0xa198('0x2d')](_0x2f920a[_0xa198('0x2e')]);_0x393e3d[_0xa198('0x39')]=_['intersection'](_0x393e3d[_0xa198('0x30')],_0x393e3d[_0xa198('0x2e')]);_0x426e24[_0xa198('0x32')]=_[_0xa198('0x2f')](_0x393e3d['model'],qs[_0xa198('0x31')](_0x2f920a[_0xa198('0x2e')]['fields']));_0x426e24[_0xa198('0x32')]=_0x426e24[_0xa198('0x32')][_0xa198('0x33')]?_0x426e24[_0xa198('0x32')]:_0x393e3d['model'];if(_0x2f920a['query'][_0xa198('0x40')]){_0x426e24['include']=[{'all':!![]}];}_0x426e24=_['merge']({},_0x426e24,_0x2f920a[_0xa198('0x3f')]);return db[_0xa198('0x2c')][_0xa198('0x47')](_0x426e24)[_0xa198('0x26')](handleEntityNotFound(_0x6d2564,null))[_0xa198('0x26')](respondWithResult(_0x6d2564,null))[_0xa198('0x48')](handleError(_0x6d2564,null));};exports[_0xa198('0x49')]=function(_0x43b819,_0x3ab666){return db['FreshsalesField']['create'](_0x43b819[_0xa198('0x4a')],{})[_0xa198('0x26')](respondWithResult(_0x3ab666,0xc9))[_0xa198('0x48')](handleError(_0x3ab666,null));};exports[_0xa198('0x25')]=function(_0x437a1c,_0x5b5c40){if(_0x437a1c[_0xa198('0x4a')]['id']){delete _0x437a1c[_0xa198('0x4a')]['id'];}return db[_0xa198('0x2c')]['find']({'where':{'id':_0x437a1c[_0xa198('0x45')]['id']}})[_0xa198('0x26')](handleEntityNotFound(_0x5b5c40,null))[_0xa198('0x26')](saveUpdates(_0x437a1c['body'],null))['then'](respondWithResult(_0x5b5c40,null))[_0xa198('0x48')](handleError(_0x5b5c40,null));};exports[_0xa198('0x27')]=function(_0x56fb39,_0x5714f2){return db[_0xa198('0x2c')][_0xa198('0x47')]({'where':{'id':_0x56fb39[_0xa198('0x45')]['id']}})[_0xa198('0x26')](handleEntityNotFound(_0x5714f2,null))[_0xa198('0x26')](removeEntity(_0x5714f2,null))['catch'](handleError(_0x5714f2,null));};
\ No newline at end of file