Built motion from commit (unavailable).|2.5.28
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index e2252c2..4cc1e1f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x814b=['error','code','message','result','catch','sendStatus','status','end','json','offset','set','Content-Range','save','destroy','stack','name','index','map','rawAttributes','fieldName','type','key','model','keys','filters','query','fields','attributes','hasOwnProperty','nolimit','limit','where','pick','merge','filter','options','count','includeAll','include','FreshsalesConfiguration','findAll','params','intersection','length','find','create','body','update','findOne','FreshsalesField','order','getSubjects','sort','getFields','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','FreshsalesConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshsalesConfiguration,\x20%s,\x20%s,\x20%s'];(function(_0x269e23,_0x14d11c){var _0x69ad53=function(_0x34066c){while(--_0x34066c){_0x269e23['push'](_0x269e23['shift']());}};_0x69ad53(++_0x14d11c);}(_0x814b,0x1a2));var _0xb814=function(_0x43a6cd,_0x503d1a){_0x43a6cd=_0x43a6cd-0x0;var _0x5acb36=_0x814b[_0x43a6cd];return _0x5acb36;};'use strict';var pdf=require(_0xb814('0x0'));var emlformat=require(_0xb814('0x1'));var rimraf=require(_0xb814('0x2'));var zipdir=require(_0xb814('0x3'));var jsonpatch=require(_0xb814('0x4'));var rp=require(_0xb814('0x5'));var moment=require('moment');var BPromise=require(_0xb814('0x6'));var Mustache=require(_0xb814('0x7'));var util=require(_0xb814('0x8'));var path=require(_0xb814('0x9'));var sox=require(_0xb814('0xa'));var csv=require(_0xb814('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xb814('0xc'));var squel=require(_0xb814('0xd'));var crypto=require('crypto');var jsforce=require(_0xb814('0xe'));var deskjs=require(_0xb814('0xf'));var toCsv=require(_0xb814('0xb'));var querystring=require(_0xb814('0x10'));var Papa=require(_0xb814('0x11'));var Redis=require(_0xb814('0x12'));var authService=require(_0xb814('0x13'));var qs=require(_0xb814('0x14'));var as=require(_0xb814('0x15'));var hardwareService=require(_0xb814('0x16'));var logger=require(_0xb814('0x17'))('api');var utils=require(_0xb814('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0xb814('0x19'));var db=require(_0xb814('0x1a'))['db'];var jayson=require(_0xb814('0x1b'));var client=jayson[_0xb814('0x1c')][_0xb814('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x3bde14,_0x1438e7,_0x41ed7b,_0xa0a2e5){return new BPromise(function(_0x2ab627,_0x3f4881){var _0x44fb96=_0xa0a2e5||client;return _0x44fb96[_0xb814('0x1e')](_0x3bde14,_0x41ed7b)[_0xb814('0x1f')](function(_0x303aca){logger[_0xb814('0x20')](_0xb814('0x21'),_0x1438e7,_0xb814('0x22'));logger[_0xb814('0x23')](_0xb814('0x24'),_0x1438e7,_0xb814('0x22'),JSON['stringify'](_0x303aca));if(_0x303aca[_0xb814('0x25')]){if(_0x303aca['error'][_0xb814('0x26')]===0x1f4){logger[_0xb814('0x25')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x1438e7,_0x303aca['error']['message']);return _0x3f4881(_0x303aca[_0xb814('0x25')]['message']);}logger['error'](_0xb814('0x21'),_0x1438e7,_0x303aca[_0xb814('0x25')][_0xb814('0x27')]);return _0x2ab627(_0x303aca['error'][_0xb814('0x27')]);}else{logger['info'](_0xb814('0x21'),_0x1438e7,_0xb814('0x22'));_0x2ab627(_0x303aca[_0xb814('0x28')][_0xb814('0x27')]);}})[_0xb814('0x29')](function(_0x2bd039){logger[_0xb814('0x25')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x1438e7,_0x2bd039);_0x3f4881(_0x2bd039);});});}function respondWithStatusCode(_0x2ead86,_0x52b7a3){_0x52b7a3=_0x52b7a3||0xcc;return function(_0x3f81d0){if(_0x3f81d0){return _0x2ead86[_0xb814('0x2a')](_0x52b7a3);}return _0x2ead86[_0xb814('0x2b')](_0x52b7a3)[_0xb814('0x2c')]();};}function respondWithResult(_0x1c8a2e,_0xb9e57d){_0xb9e57d=_0xb9e57d||0xc8;return function(_0x3d836c){if(_0x3d836c){return _0x1c8a2e['status'](_0xb9e57d)[_0xb814('0x2d')](_0x3d836c);}};}function respondWithFilteredResult(_0xc0ef66,_0x1c2625){return function(_0x349394){if(_0x349394){var _0x32ed56=_0x349394['count'],_0x1d5965=_0x1c2625[_0xb814('0x2e')],_0x3f0150=_0x1c2625[_0xb814('0x2e')]+_0x1c2625['limit'],_0x1e4e89;if(_0x3f0150>=_0x32ed56){_0x3f0150=_0x32ed56;_0x1e4e89=0xc8;}else{_0x1e4e89=0xce;}_0xc0ef66[_0xb814('0x2b')](_0x1e4e89);return _0xc0ef66[_0xb814('0x2f')](_0xb814('0x30'),_0x1d5965+'-'+_0x3f0150+'/'+_0x32ed56)['json'](_0x349394);}return null;};}function patchUpdates(_0x20577b){return function(_0x2051d0){try{jsonpatch['apply'](_0x2051d0,_0x20577b,!![]);}catch(_0x338a28){return BPromise['reject'](_0x338a28);}return _0x2051d0[_0xb814('0x31')]();};}function saveUpdates(_0x5f3e9b,_0x4cfc58){return function(_0x419cd9){if(_0x419cd9){return _0x419cd9['update'](_0x5f3e9b)[_0xb814('0x1f')](function(_0x19469b){return _0x19469b;});}return null;};}function removeEntity(_0x2b91bd,_0x599f9f){return function(_0x51d5ae){if(_0x51d5ae){return _0x51d5ae[_0xb814('0x32')]()[_0xb814('0x1f')](function(){_0x2b91bd['status'](0xcc)[_0xb814('0x2c')]();});}};}function handleEntityNotFound(_0xe558d5,_0x692c72){return function(_0x217b7e){if(!_0x217b7e){_0xe558d5[_0xb814('0x2a')](0x194);}return _0x217b7e;};}function handleError(_0x60024d,_0x3672f3){_0x3672f3=_0x3672f3||0x1f4;return function(_0x4df4e6){logger[_0xb814('0x25')](_0x4df4e6[_0xb814('0x33')]);if(_0x4df4e6[_0xb814('0x34')]){delete _0x4df4e6[_0xb814('0x34')];}_0x60024d[_0xb814('0x2b')](_0x3672f3)['send'](_0x4df4e6);};}exports[_0xb814('0x35')]=function(_0x57e6e6,_0x43db67){var _0x16e21c={},_0xe0f509={},_0x492d5e={'count':0x0,'rows':[]};var _0x40b885=_[_0xb814('0x36')](db['FreshsalesConfiguration'][_0xb814('0x37')],function(_0x2d0e27){return{'name':_0x2d0e27[_0xb814('0x38')],'type':_0x2d0e27[_0xb814('0x39')][_0xb814('0x3a')]};});_0xe0f509[_0xb814('0x3b')]=_['map'](_0x40b885,_0xb814('0x34'));_0xe0f509['query']=_[_0xb814('0x3c')](_0x57e6e6['query']);_0xe0f509[_0xb814('0x3d')]=_['intersection'](_0xe0f509[_0xb814('0x3b')],_0xe0f509[_0xb814('0x3e')]);_0x16e21c['attributes']=_['intersection'](_0xe0f509['model'],qs['fields'](_0x57e6e6[_0xb814('0x3e')][_0xb814('0x3f')]));_0x16e21c[_0xb814('0x40')]=_0x16e21c[_0xb814('0x40')]['length']?_0x16e21c['attributes']:_0xe0f509[_0xb814('0x3b')];if(!_0x57e6e6['query'][_0xb814('0x41')](_0xb814('0x42'))){_0x16e21c[_0xb814('0x43')]=qs[_0xb814('0x43')](_0x57e6e6[_0xb814('0x3e')][_0xb814('0x43')]);_0x16e21c[_0xb814('0x2e')]=qs[_0xb814('0x2e')](_0x57e6e6[_0xb814('0x3e')]['offset']);}_0x16e21c['order']=qs['sort'](_0x57e6e6[_0xb814('0x3e')]['sort']);_0x16e21c[_0xb814('0x44')]=qs['filters'](_[_0xb814('0x45')](_0x57e6e6[_0xb814('0x3e')],_0xe0f509[_0xb814('0x3d')]),_0x40b885);if(_0x57e6e6[_0xb814('0x3e')]['filter']){_0x16e21c[_0xb814('0x44')]=_[_0xb814('0x46')](_0x16e21c[_0xb814('0x44')],{'$or':_[_0xb814('0x36')](_0x40b885,function(_0x7d92aa){if(_0x7d92aa[_0xb814('0x39')]!=='VIRTUAL'){var _0x69f060={};_0x69f060[_0x7d92aa[_0xb814('0x34')]]={'$like':'%'+_0x57e6e6[_0xb814('0x3e')][_0xb814('0x47')]+'%'};return _0x69f060;}})});}_0x16e21c=_[_0xb814('0x46')]({},_0x16e21c,_0x57e6e6[_0xb814('0x48')]);var _0x263152={'where':_0x16e21c['where']};return db['FreshsalesConfiguration'][_0xb814('0x49')](_0x263152)[_0xb814('0x1f')](function(_0x4c08d6){_0x492d5e[_0xb814('0x49')]=_0x4c08d6;if(_0x57e6e6[_0xb814('0x3e')][_0xb814('0x4a')]){_0x16e21c[_0xb814('0x4b')]=[{'all':!![]}];}return db[_0xb814('0x4c')][_0xb814('0x4d')](_0x16e21c);})[_0xb814('0x1f')](function(_0xe73300){_0x492d5e['rows']=_0xe73300;return _0x492d5e;})[_0xb814('0x1f')](respondWithFilteredResult(_0x43db67,_0x16e21c))[_0xb814('0x29')](handleError(_0x43db67,null));};exports['show']=function(_0x338e80,_0x55234d){var _0x2fb0f7={'raw':![],'where':{'id':_0x338e80[_0xb814('0x4e')]['id']}},_0x37866f={};_0x37866f[_0xb814('0x3b')]=_[_0xb814('0x3c')](db[_0xb814('0x4c')][_0xb814('0x37')]);_0x37866f[_0xb814('0x3e')]=_[_0xb814('0x3c')](_0x338e80[_0xb814('0x3e')]);_0x37866f['filters']=_['intersection'](_0x37866f[_0xb814('0x3b')],_0x37866f[_0xb814('0x3e')]);_0x2fb0f7[_0xb814('0x40')]=_[_0xb814('0x4f')](_0x37866f[_0xb814('0x3b')],qs[_0xb814('0x3f')](_0x338e80[_0xb814('0x3e')]['fields']));_0x2fb0f7[_0xb814('0x40')]=_0x2fb0f7[_0xb814('0x40')][_0xb814('0x50')]?_0x2fb0f7['attributes']:_0x37866f[_0xb814('0x3b')];if(_0x338e80['query'][_0xb814('0x4a')]){_0x2fb0f7['include']=[{'all':!![]}];}_0x2fb0f7=_[_0xb814('0x46')]({},_0x2fb0f7,_0x338e80[_0xb814('0x48')]);return db['FreshsalesConfiguration'][_0xb814('0x51')](_0x2fb0f7)[_0xb814('0x1f')](handleEntityNotFound(_0x55234d,null))[_0xb814('0x1f')](respondWithResult(_0x55234d,null))['catch'](handleError(_0x55234d,null));};exports[_0xb814('0x52')]=function(_0x5f0e58,_0x13bdcf){return db[_0xb814('0x4c')]['create'](_0x5f0e58[_0xb814('0x53')],{})['then'](respondWithResult(_0x13bdcf,0xc9))['catch'](handleError(_0x13bdcf,null));};exports[_0xb814('0x54')]=function(_0x35f59a,_0x34935b){if(_0x35f59a['body']['id']){delete _0x35f59a[_0xb814('0x53')]['id'];}return db['FreshsalesConfiguration'][_0xb814('0x51')]({'where':{'id':_0x35f59a[_0xb814('0x4e')]['id']}})['then'](handleEntityNotFound(_0x34935b,null))[_0xb814('0x1f')](saveUpdates(_0x35f59a['body'],null))[_0xb814('0x1f')](respondWithResult(_0x34935b,null))[_0xb814('0x29')](handleError(_0x34935b,null));};exports[_0xb814('0x32')]=function(_0x113fe5,_0x251d44){return db[_0xb814('0x4c')][_0xb814('0x51')]({'where':{'id':_0x113fe5[_0xb814('0x4e')]['id']}})['then'](handleEntityNotFound(_0x251d44,null))[_0xb814('0x1f')](removeEntity(_0x251d44,null))[_0xb814('0x29')](handleError(_0x251d44,null));};exports['getSubjects']=function(_0x29a127,_0xe14249,_0x4d13db){var _0x371000={};var _0x58b9a6={};var _0x48362c;var _0x2114ca;return db['FreshsalesConfiguration'][_0xb814('0x55')]({'where':{'id':_0x29a127[_0xb814('0x4e')]['id']}})[_0xb814('0x1f')](handleEntityNotFound(_0xe14249,null))['then'](function(_0x1a0ef4){if(_0x1a0ef4){_0x48362c=_0x1a0ef4;_0x58b9a6['model']=_[_0xb814('0x3c')](db[_0xb814('0x56')][_0xb814('0x37')]);_0x58b9a6[_0xb814('0x3e')]=_[_0xb814('0x3c')](_0x29a127[_0xb814('0x3e')]);_0x58b9a6[_0xb814('0x3d')]=_[_0xb814('0x4f')](_0x58b9a6[_0xb814('0x3b')],_0x58b9a6['query']);_0x371000[_0xb814('0x40')]=_[_0xb814('0x4f')](_0x58b9a6[_0xb814('0x3b')],qs[_0xb814('0x3f')](_0x29a127[_0xb814('0x3e')][_0xb814('0x3f')]));_0x371000['attributes']=_0x371000[_0xb814('0x40')]['length']?_0x371000[_0xb814('0x40')]:_0x58b9a6[_0xb814('0x3b')];_0x371000[_0xb814('0x57')]=qs['sort'](_0x29a127[_0xb814('0x3e')]['sort']);_0x371000[_0xb814('0x44')]=qs['filters'](_[_0xb814('0x45')](_0x29a127[_0xb814('0x3e')],_0x58b9a6[_0xb814('0x3d')]));if(_0x29a127[_0xb814('0x3e')][_0xb814('0x47')]){_0x371000[_0xb814('0x44')]=_[_0xb814('0x46')](_0x371000['where'],{'$or':_[_0xb814('0x36')](_0x371000['attributes'],function(_0x255047){var _0x22c73f={};_0x22c73f[_0x255047]={'$like':'%'+_0x29a127[_0xb814('0x3e')][_0xb814('0x47')]+'%'};return _0x22c73f;})});}_0x371000=_[_0xb814('0x46')]({},_0x371000,_0x29a127[_0xb814('0x48')]);return _0x48362c['getSubjects'](_0x371000);}})[_0xb814('0x1f')](function(_0x1a2603){if(_0x1a2603){_0x2114ca=_0x1a2603['length'];if(!_0x29a127[_0xb814('0x3e')][_0xb814('0x41')](_0xb814('0x42'))){_0x371000[_0xb814('0x43')]=qs[_0xb814('0x43')](_0x29a127['query'][_0xb814('0x43')]);_0x371000['offset']=qs[_0xb814('0x2e')](_0x29a127[_0xb814('0x3e')][_0xb814('0x2e')]);}return _0x48362c[_0xb814('0x58')](_0x371000);}})[_0xb814('0x1f')](function(_0x41bcaf){if(_0x41bcaf){return _0x41bcaf?{'count':_0x2114ca,'rows':_0x41bcaf}:null;}})['then'](respondWithResult(_0xe14249,null))['catch'](handleError(_0xe14249,null));};exports['getDescriptions']=function(_0x25c776,_0x490e5c,_0x45a8b9){var _0x1d3954={};var _0x25db89={};var _0x5e966c;var _0x1b76fa;return db[_0xb814('0x4c')][_0xb814('0x55')]({'where':{'id':_0x25c776['params']['id']}})[_0xb814('0x1f')](handleEntityNotFound(_0x490e5c,null))[_0xb814('0x1f')](function(_0x1f39c0){if(_0x1f39c0){_0x5e966c=_0x1f39c0;_0x25db89[_0xb814('0x3b')]=_['keys'](db['FreshsalesField'][_0xb814('0x37')]);_0x25db89[_0xb814('0x3e')]=_[_0xb814('0x3c')](_0x25c776[_0xb814('0x3e')]);_0x25db89[_0xb814('0x3d')]=_[_0xb814('0x4f')](_0x25db89[_0xb814('0x3b')],_0x25db89[_0xb814('0x3e')]);_0x1d3954[_0xb814('0x40')]=_[_0xb814('0x4f')](_0x25db89[_0xb814('0x3b')],qs[_0xb814('0x3f')](_0x25c776[_0xb814('0x3e')][_0xb814('0x3f')]));_0x1d3954[_0xb814('0x40')]=_0x1d3954['attributes'][_0xb814('0x50')]?_0x1d3954[_0xb814('0x40')]:_0x25db89[_0xb814('0x3b')];_0x1d3954[_0xb814('0x57')]=qs[_0xb814('0x59')](_0x25c776[_0xb814('0x3e')]['sort']);_0x1d3954[_0xb814('0x44')]=qs['filters'](_[_0xb814('0x45')](_0x25c776[_0xb814('0x3e')],_0x25db89[_0xb814('0x3d')]));if(_0x25c776[_0xb814('0x3e')][_0xb814('0x47')]){_0x1d3954['where']=_['merge'](_0x1d3954[_0xb814('0x44')],{'$or':_[_0xb814('0x36')](_0x1d3954[_0xb814('0x40')],function(_0x1cbf0c){var _0x488ef2={};_0x488ef2[_0x1cbf0c]={'$like':'%'+_0x25c776[_0xb814('0x3e')]['filter']+'%'};return _0x488ef2;})});}_0x1d3954=_[_0xb814('0x46')]({},_0x1d3954,_0x25c776[_0xb814('0x48')]);return _0x5e966c['getDescriptions'](_0x1d3954);}})['then'](function(_0x2fa6b7){if(_0x2fa6b7){_0x1b76fa=_0x2fa6b7['length'];if(!_0x25c776[_0xb814('0x3e')][_0xb814('0x41')](_0xb814('0x42'))){_0x1d3954[_0xb814('0x43')]=qs[_0xb814('0x43')](_0x25c776[_0xb814('0x3e')][_0xb814('0x43')]);_0x1d3954['offset']=qs[_0xb814('0x2e')](_0x25c776['query'][_0xb814('0x2e')]);}return _0x5e966c['getDescriptions'](_0x1d3954);}})[_0xb814('0x1f')](function(_0x43ee60){if(_0x43ee60){return _0x43ee60?{'count':_0x1b76fa,'rows':_0x43ee60}:null;}})['then'](respondWithResult(_0x490e5c,null))[_0xb814('0x29')](handleError(_0x490e5c,null));};exports['getFields']=function(_0x37adec,_0x356875,_0x4e15c2){var _0x5a0c4a={};var _0x9e2e16={};var _0x25d976;var _0x3309c5;return db[_0xb814('0x4c')][_0xb814('0x55')]({'where':{'id':_0x37adec[_0xb814('0x4e')]['id']}})[_0xb814('0x1f')](handleEntityNotFound(_0x356875,null))[_0xb814('0x1f')](function(_0x8cb107){if(_0x8cb107){_0x25d976=_0x8cb107;_0x9e2e16[_0xb814('0x3b')]=_['keys'](db['FreshsalesField']['rawAttributes']);_0x9e2e16['query']=_['keys'](_0x37adec[_0xb814('0x3e')]);_0x9e2e16[_0xb814('0x3d')]=_[_0xb814('0x4f')](_0x9e2e16['model'],_0x9e2e16[_0xb814('0x3e')]);_0x5a0c4a[_0xb814('0x40')]=_[_0xb814('0x4f')](_0x9e2e16[_0xb814('0x3b')],qs[_0xb814('0x3f')](_0x37adec[_0xb814('0x3e')][_0xb814('0x3f')]));_0x5a0c4a[_0xb814('0x40')]=_0x5a0c4a['attributes'][_0xb814('0x50')]?_0x5a0c4a[_0xb814('0x40')]:_0x9e2e16[_0xb814('0x3b')];_0x5a0c4a[_0xb814('0x57')]=qs['sort'](_0x37adec[_0xb814('0x3e')][_0xb814('0x59')]);_0x5a0c4a[_0xb814('0x44')]=qs[_0xb814('0x3d')](_[_0xb814('0x45')](_0x37adec['query'],_0x9e2e16['filters']));if(_0x37adec[_0xb814('0x3e')]['filter']){_0x5a0c4a[_0xb814('0x44')]=_[_0xb814('0x46')](_0x5a0c4a['where'],{'$or':_[_0xb814('0x36')](_0x5a0c4a['attributes'],function(_0xe17e86){var _0x520d0f={};_0x520d0f[_0xe17e86]={'$like':'%'+_0x37adec[_0xb814('0x3e')][_0xb814('0x47')]+'%'};return _0x520d0f;})});}_0x5a0c4a=_[_0xb814('0x46')]({},_0x5a0c4a,_0x37adec[_0xb814('0x48')]);return _0x25d976[_0xb814('0x5a')](_0x5a0c4a);}})[_0xb814('0x1f')](function(_0x455b22){if(_0x455b22){_0x3309c5=_0x455b22['length'];if(!_0x37adec['query'][_0xb814('0x41')]('nolimit')){_0x5a0c4a['limit']=qs[_0xb814('0x43')](_0x37adec[_0xb814('0x3e')][_0xb814('0x43')]);_0x5a0c4a['offset']=qs[_0xb814('0x2e')](_0x37adec['query'][_0xb814('0x2e')]);}return _0x25d976[_0xb814('0x5a')](_0x5a0c4a);}})[_0xb814('0x1f')](function(_0x2d2b6c){if(_0x2d2b6c){return _0x2d2b6c?{'count':_0x3309c5,'rows':_0x2d2b6c}:null;}})['then'](respondWithResult(_0x356875,null))[_0xb814('0x29')](handleError(_0x356875,null));};
\ No newline at end of file
+var _0x7a54=['mustache','util','path','sox','to-csv','fs-extra','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','request','info','FreshsalesConfiguration,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error','message','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','stack','name','send','FreshsalesConfiguration','rawAttributes','fieldName','type','key','model','map','keys','query','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','filters','pick','VIRTUAL','options','includeAll','include','findAll','rows','params','length','merge','find','create','body','findOne','FreshsalesField','filter','getSubjects','getDescriptions','getFields','eml-format','rimraf','zip-dir','request-promise','moment'];(function(_0x2e531d,_0x5593d4){var _0x46156f=function(_0xf5f842){while(--_0xf5f842){_0x2e531d['push'](_0x2e531d['shift']());}};_0x46156f(++_0x5593d4);}(_0x7a54,0x106));var _0x47a5=function(_0x405b86,_0x220fc6){_0x405b86=_0x405b86-0x0;var _0x4e6ebd=_0x7a54[_0x405b86];return _0x4e6ebd;};'use strict';var emlformat=require(_0x47a5('0x0'));var rimraf=require(_0x47a5('0x1'));var zipdir=require(_0x47a5('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x47a5('0x3'));var moment=require(_0x47a5('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x47a5('0x5'));var util=require(_0x47a5('0x6'));var path=require(_0x47a5('0x7'));var sox=require(_0x47a5('0x8'));var csv=require(_0x47a5('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x47a5('0xa'));var _=require('lodash');var squel=require(_0x47a5('0xb'));var crypto=require(_0x47a5('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x47a5('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x47a5('0xe'));var authService=require(_0x47a5('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x47a5('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x47a5('0x11'));var utils=require(_0x47a5('0x12'));var config=require(_0x47a5('0x13'));var licenseUtil=require(_0x47a5('0x14'));var db=require(_0x47a5('0x15'))['db'];var jayson=require(_0x47a5('0x16'));var client=jayson[_0x47a5('0x17')]['http']({'port':0x232a});function respondWithRpcPromise(_0x44bd3e,_0x221b54,_0x1cf309,_0x711793){return new BPromise(function(_0x139f25,_0x620ee9){var _0x3c6c46=_0x711793||client;return _0x3c6c46[_0x47a5('0x18')](_0x44bd3e,_0x1cf309)['then'](function(_0x362359){logger[_0x47a5('0x19')](_0x47a5('0x1a'),_0x221b54,_0x47a5('0x1b'));logger[_0x47a5('0x1c')]('FreshsalesConfiguration,\x20%s,\x20%s,\x20%s',_0x221b54,'request\x20sent',JSON[_0x47a5('0x1d')](_0x362359));if(_0x362359['error']){if(_0x362359['error'][_0x47a5('0x1e')]===0x1f4){logger[_0x47a5('0x1f')](_0x47a5('0x1a'),_0x221b54,_0x362359[_0x47a5('0x1f')][_0x47a5('0x20')]);return _0x620ee9(_0x362359[_0x47a5('0x1f')][_0x47a5('0x20')]);}logger[_0x47a5('0x1f')](_0x47a5('0x1a'),_0x221b54,_0x362359['error'][_0x47a5('0x20')]);return _0x139f25(_0x362359[_0x47a5('0x1f')]['message']);}else{logger[_0x47a5('0x19')](_0x47a5('0x1a'),_0x221b54,_0x47a5('0x1b'));_0x139f25(_0x362359['result'][_0x47a5('0x20')]);}})[_0x47a5('0x21')](function(_0x23db32){logger[_0x47a5('0x1f')]('FreshsalesConfiguration,\x20%s,\x20%s',_0x221b54,_0x23db32);_0x620ee9(_0x23db32);});});}function respondWithStatusCode(_0xe2dea9,_0x385687){_0x385687=_0x385687||0xcc;return function(_0x513981){if(_0x513981){return _0xe2dea9[_0x47a5('0x22')](_0x385687);}return _0xe2dea9[_0x47a5('0x23')](_0x385687)[_0x47a5('0x24')]();};}function respondWithResult(_0x129ce5,_0x3abd6a){_0x3abd6a=_0x3abd6a||0xc8;return function(_0x50bf17){if(_0x50bf17){return _0x129ce5['status'](_0x3abd6a)[_0x47a5('0x25')](_0x50bf17);}};}function respondWithFilteredResult(_0x5686db,_0x1ea9c8){return function(_0x5b6c4e){if(_0x5b6c4e){var _0x23cb77=_0x5b6c4e[_0x47a5('0x26')],_0x378208=_0x1ea9c8[_0x47a5('0x27')],_0x36ad34=_0x1ea9c8[_0x47a5('0x27')]+_0x1ea9c8[_0x47a5('0x28')],_0x1dac65;if(_0x36ad34>=_0x23cb77){_0x36ad34=_0x23cb77;_0x1dac65=0xc8;}else{_0x1dac65=0xce;}_0x5686db[_0x47a5('0x23')](_0x1dac65);return _0x5686db[_0x47a5('0x29')](_0x47a5('0x2a'),_0x378208+'-'+_0x36ad34+'/'+_0x23cb77)[_0x47a5('0x25')](_0x5b6c4e);}return null;};}function patchUpdates(_0x3ad507){return function(_0x528582){try{jsonpatch[_0x47a5('0x2b')](_0x528582,_0x3ad507,!![]);}catch(_0x51833b){return BPromise[_0x47a5('0x2c')](_0x51833b);}return _0x528582[_0x47a5('0x2d')]();};}function saveUpdates(_0x16901f,_0x4d6b57){return function(_0x256650){if(_0x256650){return _0x256650[_0x47a5('0x2e')](_0x16901f)[_0x47a5('0x2f')](function(_0x1f1c68){return _0x1f1c68;});}return null;};}function removeEntity(_0x51cc81,_0x50d875){return function(_0x6f9a12){if(_0x6f9a12){return _0x6f9a12[_0x47a5('0x30')]()['then'](function(){_0x51cc81['status'](0xcc)[_0x47a5('0x24')]();});}};}function handleEntityNotFound(_0x51544e,_0x57bff6){return function(_0x42f70c){if(!_0x42f70c){_0x51544e['sendStatus'](0x194);}return _0x42f70c;};}function handleError(_0x122ed6,_0xd972c){_0xd972c=_0xd972c||0x1f4;return function(_0x5c5162){logger['error'](_0x5c5162[_0x47a5('0x31')]);if(_0x5c5162['name']){delete _0x5c5162[_0x47a5('0x32')];}_0x122ed6[_0x47a5('0x23')](_0xd972c)[_0x47a5('0x33')](_0x5c5162);};}exports['index']=function(_0x18f7e9,_0x50c086){var _0x53c754={},_0x65542e={},_0x5a8a7c={'count':0x0,'rows':[]};var _0x25cce0=_['map'](db[_0x47a5('0x34')][_0x47a5('0x35')],function(_0x38c8d4){return{'name':_0x38c8d4[_0x47a5('0x36')],'type':_0x38c8d4[_0x47a5('0x37')][_0x47a5('0x38')]};});_0x65542e[_0x47a5('0x39')]=_[_0x47a5('0x3a')](_0x25cce0,_0x47a5('0x32'));_0x65542e['query']=_[_0x47a5('0x3b')](_0x18f7e9[_0x47a5('0x3c')]);_0x65542e['filters']=_[_0x47a5('0x3d')](_0x65542e[_0x47a5('0x39')],_0x65542e[_0x47a5('0x3c')]);_0x53c754['attributes']=_[_0x47a5('0x3d')](_0x65542e[_0x47a5('0x39')],qs['fields'](_0x18f7e9[_0x47a5('0x3c')][_0x47a5('0x3e')]));_0x53c754['attributes']=_0x53c754['attributes']['length']?_0x53c754[_0x47a5('0x3f')]:_0x65542e['model'];if(!_0x18f7e9[_0x47a5('0x3c')][_0x47a5('0x40')](_0x47a5('0x41'))){_0x53c754[_0x47a5('0x28')]=qs[_0x47a5('0x28')](_0x18f7e9[_0x47a5('0x3c')][_0x47a5('0x28')]);_0x53c754[_0x47a5('0x27')]=qs[_0x47a5('0x27')](_0x18f7e9[_0x47a5('0x3c')][_0x47a5('0x27')]);}_0x53c754[_0x47a5('0x42')]=qs[_0x47a5('0x43')](_0x18f7e9['query'][_0x47a5('0x43')]);_0x53c754[_0x47a5('0x44')]=qs[_0x47a5('0x45')](_[_0x47a5('0x46')](_0x18f7e9['query'],_0x65542e[_0x47a5('0x45')]),_0x25cce0);if(_0x18f7e9['query']['filter']){_0x53c754['where']=_['merge'](_0x53c754[_0x47a5('0x44')],{'$or':_['map'](_0x25cce0,function(_0x2bb502){if(_0x2bb502[_0x47a5('0x37')]!==_0x47a5('0x47')){var _0x494526={};_0x494526[_0x2bb502[_0x47a5('0x32')]]={'$like':'%'+_0x18f7e9[_0x47a5('0x3c')]['filter']+'%'};return _0x494526;}})});}_0x53c754=_['merge']({},_0x53c754,_0x18f7e9[_0x47a5('0x48')]);var _0x4edf7f={'where':_0x53c754[_0x47a5('0x44')]};return db[_0x47a5('0x34')][_0x47a5('0x26')](_0x4edf7f)[_0x47a5('0x2f')](function(_0x34a9ae){_0x5a8a7c[_0x47a5('0x26')]=_0x34a9ae;if(_0x18f7e9[_0x47a5('0x3c')][_0x47a5('0x49')]){_0x53c754[_0x47a5('0x4a')]=[{'all':!![]}];}return db[_0x47a5('0x34')][_0x47a5('0x4b')](_0x53c754);})[_0x47a5('0x2f')](function(_0xe28d76){_0x5a8a7c[_0x47a5('0x4c')]=_0xe28d76;return _0x5a8a7c;})[_0x47a5('0x2f')](respondWithFilteredResult(_0x50c086,_0x53c754))[_0x47a5('0x21')](handleError(_0x50c086,null));};exports['show']=function(_0x2d38de,_0x23bb04){var _0x49eab1={'raw':![],'where':{'id':_0x2d38de[_0x47a5('0x4d')]['id']}},_0x52b3a8={};_0x52b3a8['model']=_[_0x47a5('0x3b')](db[_0x47a5('0x34')]['rawAttributes']);_0x52b3a8['query']=_[_0x47a5('0x3b')](_0x2d38de['query']);_0x52b3a8[_0x47a5('0x45')]=_[_0x47a5('0x3d')](_0x52b3a8[_0x47a5('0x39')],_0x52b3a8[_0x47a5('0x3c')]);_0x49eab1[_0x47a5('0x3f')]=_[_0x47a5('0x3d')](_0x52b3a8[_0x47a5('0x39')],qs['fields'](_0x2d38de['query'][_0x47a5('0x3e')]));_0x49eab1[_0x47a5('0x3f')]=_0x49eab1[_0x47a5('0x3f')][_0x47a5('0x4e')]?_0x49eab1[_0x47a5('0x3f')]:_0x52b3a8[_0x47a5('0x39')];if(_0x2d38de[_0x47a5('0x3c')]['includeAll']){_0x49eab1[_0x47a5('0x4a')]=[{'all':!![]}];}_0x49eab1=_[_0x47a5('0x4f')]({},_0x49eab1,_0x2d38de[_0x47a5('0x48')]);return db['FreshsalesConfiguration'][_0x47a5('0x50')](_0x49eab1)['then'](handleEntityNotFound(_0x23bb04,null))[_0x47a5('0x2f')](respondWithResult(_0x23bb04,null))[_0x47a5('0x21')](handleError(_0x23bb04,null));};exports[_0x47a5('0x51')]=function(_0xf03bd5,_0x588551){return db[_0x47a5('0x34')][_0x47a5('0x51')](_0xf03bd5[_0x47a5('0x52')],{})[_0x47a5('0x2f')](respondWithResult(_0x588551,0xc9))[_0x47a5('0x21')](handleError(_0x588551,null));};exports[_0x47a5('0x2e')]=function(_0x24e9f4,_0x481089){if(_0x24e9f4[_0x47a5('0x52')]['id']){delete _0x24e9f4[_0x47a5('0x52')]['id'];}return db[_0x47a5('0x34')][_0x47a5('0x50')]({'where':{'id':_0x24e9f4[_0x47a5('0x4d')]['id']}})[_0x47a5('0x2f')](handleEntityNotFound(_0x481089,null))['then'](saveUpdates(_0x24e9f4[_0x47a5('0x52')],null))[_0x47a5('0x2f')](respondWithResult(_0x481089,null))[_0x47a5('0x21')](handleError(_0x481089,null));};exports['destroy']=function(_0x4c5ed,_0x3c78b7){return db[_0x47a5('0x34')]['find']({'where':{'id':_0x4c5ed['params']['id']}})[_0x47a5('0x2f')](handleEntityNotFound(_0x3c78b7,null))[_0x47a5('0x2f')](removeEntity(_0x3c78b7,null))['catch'](handleError(_0x3c78b7,null));};exports['getSubjects']=function(_0x6d6b2b,_0x4d6a82,_0x16bb8a){var _0x5d383d={};var _0x482de6={};var _0x389ed9;var _0x46d2d3;return db['FreshsalesConfiguration'][_0x47a5('0x53')]({'where':{'id':_0x6d6b2b[_0x47a5('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4d6a82,null))['then'](function(_0x16b4fd){if(_0x16b4fd){_0x389ed9=_0x16b4fd;_0x482de6[_0x47a5('0x39')]=_[_0x47a5('0x3b')](db[_0x47a5('0x54')]['rawAttributes']);_0x482de6[_0x47a5('0x3c')]=_[_0x47a5('0x3b')](_0x6d6b2b[_0x47a5('0x3c')]);_0x482de6['filters']=_[_0x47a5('0x3d')](_0x482de6['model'],_0x482de6[_0x47a5('0x3c')]);_0x5d383d[_0x47a5('0x3f')]=_[_0x47a5('0x3d')](_0x482de6[_0x47a5('0x39')],qs[_0x47a5('0x3e')](_0x6d6b2b['query'][_0x47a5('0x3e')]));_0x5d383d['attributes']=_0x5d383d['attributes']['length']?_0x5d383d['attributes']:_0x482de6[_0x47a5('0x39')];_0x5d383d[_0x47a5('0x42')]=qs[_0x47a5('0x43')](_0x6d6b2b['query']['sort']);_0x5d383d[_0x47a5('0x44')]=qs[_0x47a5('0x45')](_[_0x47a5('0x46')](_0x6d6b2b[_0x47a5('0x3c')],_0x482de6[_0x47a5('0x45')]));if(_0x6d6b2b['query'][_0x47a5('0x55')]){_0x5d383d['where']=_[_0x47a5('0x4f')](_0x5d383d[_0x47a5('0x44')],{'$or':_['map'](_0x5d383d[_0x47a5('0x3f')],function(_0x345104){var _0x132854={};_0x132854[_0x345104]={'$like':'%'+_0x6d6b2b[_0x47a5('0x3c')][_0x47a5('0x55')]+'%'};return _0x132854;})});}_0x5d383d=_[_0x47a5('0x4f')]({},_0x5d383d,_0x6d6b2b[_0x47a5('0x48')]);return _0x389ed9[_0x47a5('0x56')](_0x5d383d);}})['then'](function(_0x2dcc3b){if(_0x2dcc3b){_0x46d2d3=_0x2dcc3b[_0x47a5('0x4e')];if(!_0x6d6b2b[_0x47a5('0x3c')][_0x47a5('0x40')](_0x47a5('0x41'))){_0x5d383d['limit']=qs[_0x47a5('0x28')](_0x6d6b2b[_0x47a5('0x3c')][_0x47a5('0x28')]);_0x5d383d[_0x47a5('0x27')]=qs[_0x47a5('0x27')](_0x6d6b2b[_0x47a5('0x3c')][_0x47a5('0x27')]);}return _0x389ed9[_0x47a5('0x56')](_0x5d383d);}})[_0x47a5('0x2f')](function(_0x44cb90){if(_0x44cb90){return _0x44cb90?{'count':_0x46d2d3,'rows':_0x44cb90}:null;}})[_0x47a5('0x2f')](respondWithResult(_0x4d6a82,null))[_0x47a5('0x21')](handleError(_0x4d6a82,null));};exports[_0x47a5('0x57')]=function(_0x1cdadc,_0x3edd17,_0x5a6161){var _0x42dd7d={};var _0x284fb8={};var _0x30504e;var _0x4b42f3;return db[_0x47a5('0x34')][_0x47a5('0x53')]({'where':{'id':_0x1cdadc[_0x47a5('0x4d')]['id']}})[_0x47a5('0x2f')](handleEntityNotFound(_0x3edd17,null))['then'](function(_0x3ac402){if(_0x3ac402){_0x30504e=_0x3ac402;_0x284fb8['model']=_[_0x47a5('0x3b')](db['FreshsalesField'][_0x47a5('0x35')]);_0x284fb8['query']=_[_0x47a5('0x3b')](_0x1cdadc[_0x47a5('0x3c')]);_0x284fb8[_0x47a5('0x45')]=_['intersection'](_0x284fb8['model'],_0x284fb8['query']);_0x42dd7d[_0x47a5('0x3f')]=_[_0x47a5('0x3d')](_0x284fb8[_0x47a5('0x39')],qs[_0x47a5('0x3e')](_0x1cdadc['query'][_0x47a5('0x3e')]));_0x42dd7d[_0x47a5('0x3f')]=_0x42dd7d[_0x47a5('0x3f')][_0x47a5('0x4e')]?_0x42dd7d[_0x47a5('0x3f')]:_0x284fb8[_0x47a5('0x39')];_0x42dd7d[_0x47a5('0x42')]=qs[_0x47a5('0x43')](_0x1cdadc[_0x47a5('0x3c')][_0x47a5('0x43')]);_0x42dd7d[_0x47a5('0x44')]=qs[_0x47a5('0x45')](_['pick'](_0x1cdadc[_0x47a5('0x3c')],_0x284fb8['filters']));if(_0x1cdadc[_0x47a5('0x3c')][_0x47a5('0x55')]){_0x42dd7d[_0x47a5('0x44')]=_[_0x47a5('0x4f')](_0x42dd7d[_0x47a5('0x44')],{'$or':_[_0x47a5('0x3a')](_0x42dd7d[_0x47a5('0x3f')],function(_0x448981){var _0x11c1db={};_0x11c1db[_0x448981]={'$like':'%'+_0x1cdadc[_0x47a5('0x3c')][_0x47a5('0x55')]+'%'};return _0x11c1db;})});}_0x42dd7d=_[_0x47a5('0x4f')]({},_0x42dd7d,_0x1cdadc[_0x47a5('0x48')]);return _0x30504e[_0x47a5('0x57')](_0x42dd7d);}})[_0x47a5('0x2f')](function(_0x4de126){if(_0x4de126){_0x4b42f3=_0x4de126['length'];if(!_0x1cdadc['query']['hasOwnProperty'](_0x47a5('0x41'))){_0x42dd7d[_0x47a5('0x28')]=qs['limit'](_0x1cdadc[_0x47a5('0x3c')][_0x47a5('0x28')]);_0x42dd7d[_0x47a5('0x27')]=qs[_0x47a5('0x27')](_0x1cdadc[_0x47a5('0x3c')][_0x47a5('0x27')]);}return _0x30504e[_0x47a5('0x57')](_0x42dd7d);}})[_0x47a5('0x2f')](function(_0x2e9a96){if(_0x2e9a96){return _0x2e9a96?{'count':_0x4b42f3,'rows':_0x2e9a96}:null;}})[_0x47a5('0x2f')](respondWithResult(_0x3edd17,null))[_0x47a5('0x21')](handleError(_0x3edd17,null));};exports['getFields']=function(_0x18fa31,_0x1fbd42,_0x420671){var _0x4f35ff={};var _0x340846={};var _0x32f393;var _0x17b61d;return db['FreshsalesConfiguration'][_0x47a5('0x53')]({'where':{'id':_0x18fa31['params']['id']}})['then'](handleEntityNotFound(_0x1fbd42,null))[_0x47a5('0x2f')](function(_0x292d9c){if(_0x292d9c){_0x32f393=_0x292d9c;_0x340846[_0x47a5('0x39')]=_[_0x47a5('0x3b')](db[_0x47a5('0x54')][_0x47a5('0x35')]);_0x340846['query']=_['keys'](_0x18fa31[_0x47a5('0x3c')]);_0x340846['filters']=_[_0x47a5('0x3d')](_0x340846[_0x47a5('0x39')],_0x340846[_0x47a5('0x3c')]);_0x4f35ff[_0x47a5('0x3f')]=_['intersection'](_0x340846[_0x47a5('0x39')],qs['fields'](_0x18fa31['query'][_0x47a5('0x3e')]));_0x4f35ff[_0x47a5('0x3f')]=_0x4f35ff['attributes'][_0x47a5('0x4e')]?_0x4f35ff[_0x47a5('0x3f')]:_0x340846[_0x47a5('0x39')];_0x4f35ff['order']=qs[_0x47a5('0x43')](_0x18fa31['query'][_0x47a5('0x43')]);_0x4f35ff[_0x47a5('0x44')]=qs[_0x47a5('0x45')](_['pick'](_0x18fa31[_0x47a5('0x3c')],_0x340846[_0x47a5('0x45')]));if(_0x18fa31[_0x47a5('0x3c')]['filter']){_0x4f35ff[_0x47a5('0x44')]=_['merge'](_0x4f35ff[_0x47a5('0x44')],{'$or':_['map'](_0x4f35ff[_0x47a5('0x3f')],function(_0x20d8bd){var _0x20a742={};_0x20a742[_0x20d8bd]={'$like':'%'+_0x18fa31[_0x47a5('0x3c')]['filter']+'%'};return _0x20a742;})});}_0x4f35ff=_[_0x47a5('0x4f')]({},_0x4f35ff,_0x18fa31[_0x47a5('0x48')]);return _0x32f393[_0x47a5('0x58')](_0x4f35ff);}})[_0x47a5('0x2f')](function(_0x22d84a){if(_0x22d84a){_0x17b61d=_0x22d84a['length'];if(!_0x18fa31['query'][_0x47a5('0x40')]('nolimit')){_0x4f35ff[_0x47a5('0x28')]=qs[_0x47a5('0x28')](_0x18fa31[_0x47a5('0x3c')]['limit']);_0x4f35ff[_0x47a5('0x27')]=qs[_0x47a5('0x27')](_0x18fa31['query'][_0x47a5('0x27')]);}return _0x32f393[_0x47a5('0x58')](_0x4f35ff);}})[_0x47a5('0x2f')](function(_0x113beb){if(_0x113beb){return _0x113beb?{'count':_0x17b61d,'rows':_0x113beb}:null;}})['then'](respondWithResult(_0x1fbd42,null))['catch'](handleError(_0x1fbd42,null));};
\ No newline at end of file