Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index ade30e6..2d807f5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2bfa=['reject','destroy','then','error','stack','name','send','index','map','rawAttributes','fieldName','key','keys','filters','intersection','model','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','includeAll','include','FreshsalesConfiguration','findAll','rows','catch','params','options','find','create','body','getSubjects','findOne','FreshsalesField','getDescriptions','getFields','rimraf','zip-dir','request-promise','bluebird','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','apply'];(function(_0x5f309e,_0x66e31){var _0x487b5e=function(_0x44f203){while(--_0x44f203){_0x5f309e['push'](_0x5f309e['shift']());}};_0x487b5e(++_0x66e31);}(_0x2bfa,0x7c));var _0xa2bf=function(_0x5d0930,_0x5254a0){_0x5d0930=_0x5d0930-0x0;var _0x4ac860=_0x2bfa[_0x5d0930];return _0x4ac860;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xa2bf('0x0'));var zipdir=require(_0xa2bf('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xa2bf('0x2'));var moment=require('moment');var BPromise=require(_0xa2bf('0x3'));var Mustache=require('mustache');var util=require(_0xa2bf('0x4'));var path=require('path');var sox=require(_0xa2bf('0x5'));var csv=require(_0xa2bf('0x6'));var ejs=require(_0xa2bf('0x7'));var fs=require('fs');var fs_extra=require(_0xa2bf('0x8'));var _=require('lodash');var squel=require(_0xa2bf('0x9'));var crypto=require(_0xa2bf('0xa'));var jsforce=require(_0xa2bf('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xa2bf('0x6'));var querystring=require(_0xa2bf('0xc'));var Papa=require('papaparse');var Redis=require(_0xa2bf('0xd'));var authService=require(_0xa2bf('0xe'));var qs=require(_0xa2bf('0xf'));var as=require(_0xa2bf('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xa2bf('0x11'));var utils=require(_0xa2bf('0x12'));var config=require(_0xa2bf('0x13'));var licenseUtil=require(_0xa2bf('0x14'));var db=require(_0xa2bf('0x15'))['db'];function respondWithStatusCode(_0x33420b,_0x5cb939){_0x5cb939=_0x5cb939||0xcc;return function(_0x5deaae){if(_0x5deaae){return _0x33420b[_0xa2bf('0x16')](_0x5cb939);}return _0x33420b[_0xa2bf('0x17')](_0x5cb939)[_0xa2bf('0x18')]();};}function respondWithResult(_0x4abf2b,_0x1bee7e){_0x1bee7e=_0x1bee7e||0xc8;return function(_0x2f9d95){if(_0x2f9d95){return _0x4abf2b[_0xa2bf('0x17')](_0x1bee7e)[_0xa2bf('0x19')](_0x2f9d95);}};}function respondWithFilteredResult(_0x5e48af,_0x3baaa5){return function(_0x4dcc52){if(_0x4dcc52){var _0x233ccd=typeof _0x3baaa5[_0xa2bf('0x1a')]==='undefined'&&typeof _0x3baaa5['limit']===_0xa2bf('0x1b');var _0x1daecd=_0x4dcc52['count'];var _0x2dd590=_0x233ccd?0x0:_0x3baaa5[_0xa2bf('0x1a')];var _0x13114e=_0x233ccd?_0x4dcc52[_0xa2bf('0x1c')]:_0x3baaa5['offset']+_0x3baaa5[_0xa2bf('0x1d')];var _0x3f3354;if(_0x13114e>=_0x1daecd){_0x13114e=_0x1daecd;_0x3f3354=0xc8;}else{_0x3f3354=0xce;}_0x5e48af[_0xa2bf('0x17')](_0x3f3354);return _0x5e48af[_0xa2bf('0x1e')]('Content-Range',_0x2dd590+'-'+_0x13114e+'/'+_0x1daecd)[_0xa2bf('0x19')](_0x4dcc52);}return null;};}function patchUpdates(_0x3e692c){return function(_0x1908f2){try{jsonpatch[_0xa2bf('0x1f')](_0x1908f2,_0x3e692c,!![]);}catch(_0x139ec6){return BPromise[_0xa2bf('0x20')](_0x139ec6);}return _0x1908f2['save']();};}function saveUpdates(_0x20018a,_0x564b2e){return function(_0x11f65c){if(_0x11f65c){return _0x11f65c['update'](_0x20018a)['then'](function(_0x1831b9){return _0x1831b9;});}return null;};}function removeEntity(_0x306e5c,_0x296f39){return function(_0x3477a5){if(_0x3477a5){return _0x3477a5[_0xa2bf('0x21')]()[_0xa2bf('0x22')](function(){_0x306e5c['status'](0xcc)[_0xa2bf('0x18')]();});}};}function handleEntityNotFound(_0x5c691b,_0x3193f2){return function(_0x31064a){if(!_0x31064a){_0x5c691b[_0xa2bf('0x16')](0x194);}return _0x31064a;};}function handleError(_0x231d21,_0x1534b1){_0x1534b1=_0x1534b1||0x1f4;return function(_0x144394){logger[_0xa2bf('0x23')](_0x144394[_0xa2bf('0x24')]);if(_0x144394[_0xa2bf('0x25')]){delete _0x144394[_0xa2bf('0x25')];}_0x231d21[_0xa2bf('0x17')](_0x1534b1)[_0xa2bf('0x26')](_0x144394);};}exports[_0xa2bf('0x27')]=function(_0x573efc,_0x2bf332){var _0x32e342={},_0x42d696={},_0x1838e4={'count':0x0,'rows':[]};var _0xa58435=_[_0xa2bf('0x28')](db['FreshsalesConfiguration'][_0xa2bf('0x29')],function(_0x399c64){return{'name':_0x399c64[_0xa2bf('0x2a')],'type':_0x399c64['type'][_0xa2bf('0x2b')]};});_0x42d696['model']=_[_0xa2bf('0x28')](_0xa58435,'name');_0x42d696['query']=_[_0xa2bf('0x2c')](_0x573efc['query']);_0x42d696[_0xa2bf('0x2d')]=_[_0xa2bf('0x2e')](_0x42d696[_0xa2bf('0x2f')],_0x42d696[_0xa2bf('0x30')]);_0x32e342[_0xa2bf('0x31')]=_[_0xa2bf('0x2e')](_0x42d696[_0xa2bf('0x2f')],qs[_0xa2bf('0x32')](_0x573efc[_0xa2bf('0x30')][_0xa2bf('0x32')]));_0x32e342[_0xa2bf('0x31')]=_0x32e342[_0xa2bf('0x31')][_0xa2bf('0x33')]?_0x32e342[_0xa2bf('0x31')]:_0x42d696[_0xa2bf('0x2f')];if(!_0x573efc[_0xa2bf('0x30')][_0xa2bf('0x34')](_0xa2bf('0x35'))){_0x32e342['limit']=qs[_0xa2bf('0x1d')](_0x573efc['query'][_0xa2bf('0x1d')]);_0x32e342[_0xa2bf('0x1a')]=qs['offset'](_0x573efc[_0xa2bf('0x30')]['offset']);}_0x32e342[_0xa2bf('0x36')]=qs['sort'](_0x573efc[_0xa2bf('0x30')][_0xa2bf('0x37')]);_0x32e342[_0xa2bf('0x38')]=qs['filters'](_[_0xa2bf('0x39')](_0x573efc['query'],_0x42d696[_0xa2bf('0x2d')]),_0xa58435);if(_0x573efc[_0xa2bf('0x30')][_0xa2bf('0x3a')]){_0x32e342[_0xa2bf('0x38')]=_[_0xa2bf('0x3b')](_0x32e342[_0xa2bf('0x38')],{'$or':_[_0xa2bf('0x28')](_0xa58435,function(_0x197967){if(_0x197967[_0xa2bf('0x3c')]!==_0xa2bf('0x3d')){var _0x1372c2={};_0x1372c2[_0x197967[_0xa2bf('0x25')]]={'$like':'%'+_0x573efc['query'][_0xa2bf('0x3a')]+'%'};return _0x1372c2;}})});}_0x32e342=_[_0xa2bf('0x3b')]({},_0x32e342,_0x573efc['options']);var _0xd1229c={'where':_0x32e342[_0xa2bf('0x38')]};return db['FreshsalesConfiguration'][_0xa2bf('0x1c')](_0xd1229c)['then'](function(_0x3b6e58){_0x1838e4[_0xa2bf('0x1c')]=_0x3b6e58;if(_0x573efc[_0xa2bf('0x30')][_0xa2bf('0x3e')]){_0x32e342[_0xa2bf('0x3f')]=[{'all':!![]}];}return db[_0xa2bf('0x40')][_0xa2bf('0x41')](_0x32e342);})[_0xa2bf('0x22')](function(_0x37dadf){_0x1838e4[_0xa2bf('0x42')]=_0x37dadf;return _0x1838e4;})['then'](respondWithFilteredResult(_0x2bf332,_0x32e342))[_0xa2bf('0x43')](handleError(_0x2bf332,null));};exports['show']=function(_0x2bbb5b,_0x45aa60){var _0x1960c1={'raw':![],'where':{'id':_0x2bbb5b[_0xa2bf('0x44')]['id']}},_0x4a4d80={};_0x4a4d80['model']=_[_0xa2bf('0x2c')](db['FreshsalesConfiguration'][_0xa2bf('0x29')]);_0x4a4d80[_0xa2bf('0x30')]=_[_0xa2bf('0x2c')](_0x2bbb5b[_0xa2bf('0x30')]);_0x4a4d80[_0xa2bf('0x2d')]=_['intersection'](_0x4a4d80['model'],_0x4a4d80['query']);_0x1960c1[_0xa2bf('0x31')]=_['intersection'](_0x4a4d80['model'],qs[_0xa2bf('0x32')](_0x2bbb5b['query'][_0xa2bf('0x32')]));_0x1960c1[_0xa2bf('0x31')]=_0x1960c1['attributes'][_0xa2bf('0x33')]?_0x1960c1[_0xa2bf('0x31')]:_0x4a4d80[_0xa2bf('0x2f')];if(_0x2bbb5b[_0xa2bf('0x30')][_0xa2bf('0x3e')]){_0x1960c1[_0xa2bf('0x3f')]=[{'all':!![]}];}_0x1960c1=_[_0xa2bf('0x3b')]({},_0x1960c1,_0x2bbb5b[_0xa2bf('0x45')]);return db[_0xa2bf('0x40')][_0xa2bf('0x46')](_0x1960c1)[_0xa2bf('0x22')](handleEntityNotFound(_0x45aa60,null))[_0xa2bf('0x22')](respondWithResult(_0x45aa60,null))[_0xa2bf('0x43')](handleError(_0x45aa60,null));};exports[_0xa2bf('0x47')]=function(_0x3bd96e,_0xea594){return db['FreshsalesConfiguration']['create'](_0x3bd96e[_0xa2bf('0x48')],{})[_0xa2bf('0x22')](respondWithResult(_0xea594,0xc9))[_0xa2bf('0x43')](handleError(_0xea594,null));};exports['update']=function(_0x2f2bbc,_0x213687){if(_0x2f2bbc[_0xa2bf('0x48')]['id']){delete _0x2f2bbc['body']['id'];}return db[_0xa2bf('0x40')][_0xa2bf('0x46')]({'where':{'id':_0x2f2bbc[_0xa2bf('0x44')]['id']}})[_0xa2bf('0x22')](handleEntityNotFound(_0x213687,null))[_0xa2bf('0x22')](saveUpdates(_0x2f2bbc[_0xa2bf('0x48')],null))['then'](respondWithResult(_0x213687,null))[_0xa2bf('0x43')](handleError(_0x213687,null));};exports[_0xa2bf('0x21')]=function(_0x255464,_0xba5625){return db['FreshsalesConfiguration']['find']({'where':{'id':_0x255464['params']['id']}})[_0xa2bf('0x22')](handleEntityNotFound(_0xba5625,null))['then'](removeEntity(_0xba5625,null))['catch'](handleError(_0xba5625,null));};exports[_0xa2bf('0x49')]=function(_0x3219ac,_0x37bc22,_0x961cf3){var _0x113395={};var _0x1b7c84={};var _0x318e1c;var _0x4fea46;return db[_0xa2bf('0x40')][_0xa2bf('0x4a')]({'where':{'id':_0x3219ac[_0xa2bf('0x44')]['id']}})['then'](handleEntityNotFound(_0x37bc22,null))[_0xa2bf('0x22')](function(_0x5404ce){if(_0x5404ce){_0x318e1c=_0x5404ce;_0x1b7c84[_0xa2bf('0x2f')]=_[_0xa2bf('0x2c')](db[_0xa2bf('0x4b')][_0xa2bf('0x29')]);_0x1b7c84[_0xa2bf('0x30')]=_[_0xa2bf('0x2c')](_0x3219ac[_0xa2bf('0x30')]);_0x1b7c84[_0xa2bf('0x2d')]=_['intersection'](_0x1b7c84[_0xa2bf('0x2f')],_0x1b7c84[_0xa2bf('0x30')]);_0x113395[_0xa2bf('0x31')]=_[_0xa2bf('0x2e')](_0x1b7c84[_0xa2bf('0x2f')],qs[_0xa2bf('0x32')](_0x3219ac['query']['fields']));_0x113395[_0xa2bf('0x31')]=_0x113395['attributes'][_0xa2bf('0x33')]?_0x113395[_0xa2bf('0x31')]:_0x1b7c84['model'];_0x113395[_0xa2bf('0x36')]=qs['sort'](_0x3219ac[_0xa2bf('0x30')]['sort']);_0x113395[_0xa2bf('0x38')]=qs['filters'](_[_0xa2bf('0x39')](_0x3219ac[_0xa2bf('0x30')],_0x1b7c84[_0xa2bf('0x2d')]));if(_0x3219ac[_0xa2bf('0x30')][_0xa2bf('0x3a')]){_0x113395['where']=_[_0xa2bf('0x3b')](_0x113395[_0xa2bf('0x38')],{'$or':_[_0xa2bf('0x28')](_0x113395[_0xa2bf('0x31')],function(_0x755706){var _0x2706c3={};_0x2706c3[_0x755706]={'$like':'%'+_0x3219ac[_0xa2bf('0x30')][_0xa2bf('0x3a')]+'%'};return _0x2706c3;})});}_0x113395=_[_0xa2bf('0x3b')]({},_0x113395,_0x3219ac[_0xa2bf('0x45')]);return _0x318e1c[_0xa2bf('0x49')](_0x113395);}})['then'](function(_0x3ca913){if(_0x3ca913){_0x4fea46=_0x3ca913[_0xa2bf('0x33')];if(!_0x3219ac['query'][_0xa2bf('0x34')](_0xa2bf('0x35'))){_0x113395[_0xa2bf('0x1d')]=qs[_0xa2bf('0x1d')](_0x3219ac['query'][_0xa2bf('0x1d')]);_0x113395[_0xa2bf('0x1a')]=qs[_0xa2bf('0x1a')](_0x3219ac[_0xa2bf('0x30')][_0xa2bf('0x1a')]);}return _0x318e1c[_0xa2bf('0x49')](_0x113395);}})[_0xa2bf('0x22')](function(_0x2a8ca3){if(_0x2a8ca3){return _0x2a8ca3?{'count':_0x4fea46,'rows':_0x2a8ca3}:null;}})[_0xa2bf('0x22')](respondWithResult(_0x37bc22,null))['catch'](handleError(_0x37bc22,null));};exports['getDescriptions']=function(_0x570c4e,_0x63d862,_0x4e78ab){var _0xb791ce={};var _0x1299f6={};var _0x542245;var _0x559edb;return db[_0xa2bf('0x40')][_0xa2bf('0x4a')]({'where':{'id':_0x570c4e[_0xa2bf('0x44')]['id']}})[_0xa2bf('0x22')](handleEntityNotFound(_0x63d862,null))[_0xa2bf('0x22')](function(_0x3dcdaf){if(_0x3dcdaf){_0x542245=_0x3dcdaf;_0x1299f6[_0xa2bf('0x2f')]=_['keys'](db[_0xa2bf('0x4b')][_0xa2bf('0x29')]);_0x1299f6['query']=_['keys'](_0x570c4e[_0xa2bf('0x30')]);_0x1299f6[_0xa2bf('0x2d')]=_[_0xa2bf('0x2e')](_0x1299f6['model'],_0x1299f6[_0xa2bf('0x30')]);_0xb791ce['attributes']=_[_0xa2bf('0x2e')](_0x1299f6[_0xa2bf('0x2f')],qs['fields'](_0x570c4e[_0xa2bf('0x30')][_0xa2bf('0x32')]));_0xb791ce[_0xa2bf('0x31')]=_0xb791ce[_0xa2bf('0x31')]['length']?_0xb791ce['attributes']:_0x1299f6[_0xa2bf('0x2f')];_0xb791ce[_0xa2bf('0x36')]=qs['sort'](_0x570c4e['query'][_0xa2bf('0x37')]);_0xb791ce[_0xa2bf('0x38')]=qs[_0xa2bf('0x2d')](_[_0xa2bf('0x39')](_0x570c4e[_0xa2bf('0x30')],_0x1299f6[_0xa2bf('0x2d')]));if(_0x570c4e['query'][_0xa2bf('0x3a')]){_0xb791ce[_0xa2bf('0x38')]=_[_0xa2bf('0x3b')](_0xb791ce[_0xa2bf('0x38')],{'$or':_['map'](_0xb791ce[_0xa2bf('0x31')],function(_0x2beafb){var _0x38788a={};_0x38788a[_0x2beafb]={'$like':'%'+_0x570c4e[_0xa2bf('0x30')][_0xa2bf('0x3a')]+'%'};return _0x38788a;})});}_0xb791ce=_[_0xa2bf('0x3b')]({},_0xb791ce,_0x570c4e[_0xa2bf('0x45')]);return _0x542245[_0xa2bf('0x4c')](_0xb791ce);}})[_0xa2bf('0x22')](function(_0xa54ceb){if(_0xa54ceb){_0x559edb=_0xa54ceb[_0xa2bf('0x33')];if(!_0x570c4e[_0xa2bf('0x30')][_0xa2bf('0x34')](_0xa2bf('0x35'))){_0xb791ce[_0xa2bf('0x1d')]=qs[_0xa2bf('0x1d')](_0x570c4e[_0xa2bf('0x30')]['limit']);_0xb791ce['offset']=qs['offset'](_0x570c4e[_0xa2bf('0x30')][_0xa2bf('0x1a')]);}return _0x542245[_0xa2bf('0x4c')](_0xb791ce);}})[_0xa2bf('0x22')](function(_0xbdcee6){if(_0xbdcee6){return _0xbdcee6?{'count':_0x559edb,'rows':_0xbdcee6}:null;}})['then'](respondWithResult(_0x63d862,null))['catch'](handleError(_0x63d862,null));};exports['getFields']=function(_0x37ad7b,_0x35a9b5,_0x55465a){var _0x582255={};var _0x3ba5b2={};var _0x4dd7ef;var _0x18448a;return db[_0xa2bf('0x40')][_0xa2bf('0x4a')]({'where':{'id':_0x37ad7b[_0xa2bf('0x44')]['id']}})[_0xa2bf('0x22')](handleEntityNotFound(_0x35a9b5,null))[_0xa2bf('0x22')](function(_0x5f2cfd){if(_0x5f2cfd){_0x4dd7ef=_0x5f2cfd;_0x3ba5b2['model']=_[_0xa2bf('0x2c')](db[_0xa2bf('0x4b')][_0xa2bf('0x29')]);_0x3ba5b2[_0xa2bf('0x30')]=_[_0xa2bf('0x2c')](_0x37ad7b[_0xa2bf('0x30')]);_0x3ba5b2[_0xa2bf('0x2d')]=_[_0xa2bf('0x2e')](_0x3ba5b2[_0xa2bf('0x2f')],_0x3ba5b2[_0xa2bf('0x30')]);_0x582255[_0xa2bf('0x31')]=_['intersection'](_0x3ba5b2['model'],qs['fields'](_0x37ad7b[_0xa2bf('0x30')][_0xa2bf('0x32')]));_0x582255[_0xa2bf('0x31')]=_0x582255[_0xa2bf('0x31')][_0xa2bf('0x33')]?_0x582255[_0xa2bf('0x31')]:_0x3ba5b2[_0xa2bf('0x2f')];_0x582255[_0xa2bf('0x36')]=qs['sort'](_0x37ad7b['query'][_0xa2bf('0x37')]);_0x582255['where']=qs[_0xa2bf('0x2d')](_[_0xa2bf('0x39')](_0x37ad7b[_0xa2bf('0x30')],_0x3ba5b2[_0xa2bf('0x2d')]));if(_0x37ad7b['query'][_0xa2bf('0x3a')]){_0x582255[_0xa2bf('0x38')]=_[_0xa2bf('0x3b')](_0x582255[_0xa2bf('0x38')],{'$or':_[_0xa2bf('0x28')](_0x582255[_0xa2bf('0x31')],function(_0x29dc4c){var _0x43ff1f={};_0x43ff1f[_0x29dc4c]={'$like':'%'+_0x37ad7b[_0xa2bf('0x30')][_0xa2bf('0x3a')]+'%'};return _0x43ff1f;})});}_0x582255=_[_0xa2bf('0x3b')]({},_0x582255,_0x37ad7b[_0xa2bf('0x45')]);return _0x4dd7ef[_0xa2bf('0x4d')](_0x582255);}})[_0xa2bf('0x22')](function(_0x63a944){if(_0x63a944){_0x18448a=_0x63a944[_0xa2bf('0x33')];if(!_0x37ad7b[_0xa2bf('0x30')][_0xa2bf('0x34')](_0xa2bf('0x35'))){_0x582255[_0xa2bf('0x1d')]=qs['limit'](_0x37ad7b['query'][_0xa2bf('0x1d')]);_0x582255[_0xa2bf('0x1a')]=qs[_0xa2bf('0x1a')](_0x37ad7b['query'][_0xa2bf('0x1a')]);}return _0x4dd7ef[_0xa2bf('0x4d')](_0x582255);}})[_0xa2bf('0x22')](function(_0xfa6a75){if(_0xfa6a75){return _0xfa6a75?{'count':_0x18448a,'rows':_0xfa6a75}:null;}})['then'](respondWithResult(_0x35a9b5,null))['catch'](handleError(_0x35a9b5,null));};
\ No newline at end of file
+var _0x9483=['util','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','sendStatus','status','end','json','offset','limit','count','set','Content-Range','reject','save','update','then','destroy','error','name','send','index','map','FreshsalesConfiguration','rawAttributes','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','options','include','findAll','rows','catch','show','params','keys','includeAll','find','create','body','getSubjects','findOne','order','FreshsalesField','getDescriptions','getFields','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird'];(function(_0x112891,_0x52380a){var _0x20e441=function(_0x27f6d0){while(--_0x27f6d0){_0x112891['push'](_0x112891['shift']());}};_0x20e441(++_0x52380a);}(_0x9483,0x12e));var _0x3948=function(_0x50ef00,_0x38fd75){_0x50ef00=_0x50ef00-0x0;var _0x347fc1=_0x9483[_0x50ef00];return _0x347fc1;};'use strict';var emlformat=require(_0x3948('0x0'));var rimraf=require(_0x3948('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x3948('0x2'));var rp=require(_0x3948('0x3'));var moment=require(_0x3948('0x4'));var BPromise=require(_0x3948('0x5'));var Mustache=require('mustache');var util=require(_0x3948('0x6'));var path=require(_0x3948('0x7'));var sox=require('sox');var csv=require(_0x3948('0x8'));var ejs=require(_0x3948('0x9'));var fs=require('fs');var fs_extra=require(_0x3948('0xa'));var _=require(_0x3948('0xb'));var squel=require(_0x3948('0xc'));var crypto=require(_0x3948('0xd'));var jsforce=require(_0x3948('0xe'));var deskjs=require(_0x3948('0xf'));var toCsv=require(_0x3948('0x8'));var querystring=require(_0x3948('0x10'));var Papa=require(_0x3948('0x11'));var Redis=require(_0x3948('0x12'));var authService=require(_0x3948('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0x3948('0x14'));var hardwareService=require(_0x3948('0x15'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x3948('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x485d92,_0x227c19){_0x227c19=_0x227c19||0xcc;return function(_0x1004f2){if(_0x1004f2){return _0x485d92[_0x3948('0x17')](_0x227c19);}return _0x485d92[_0x3948('0x18')](_0x227c19)[_0x3948('0x19')]();};}function respondWithResult(_0x3b2cc4,_0xf0c470){_0xf0c470=_0xf0c470||0xc8;return function(_0x56dd18){if(_0x56dd18){return _0x3b2cc4[_0x3948('0x18')](_0xf0c470)[_0x3948('0x1a')](_0x56dd18);}};}function respondWithFilteredResult(_0x4309b1,_0x1f0e90){return function(_0x16ec7f){if(_0x16ec7f){var _0x3aa26f=typeof _0x1f0e90[_0x3948('0x1b')]==='undefined'&&typeof _0x1f0e90[_0x3948('0x1c')]==='undefined';var _0x1bee8e=_0x16ec7f['count'];var _0x47d732=_0x3aa26f?0x0:_0x1f0e90[_0x3948('0x1b')];var _0x49f85c=_0x3aa26f?_0x16ec7f[_0x3948('0x1d')]:_0x1f0e90['offset']+_0x1f0e90[_0x3948('0x1c')];var _0x2acc56;if(_0x49f85c>=_0x1bee8e){_0x49f85c=_0x1bee8e;_0x2acc56=0xc8;}else{_0x2acc56=0xce;}_0x4309b1[_0x3948('0x18')](_0x2acc56);return _0x4309b1[_0x3948('0x1e')](_0x3948('0x1f'),_0x47d732+'-'+_0x49f85c+'/'+_0x1bee8e)[_0x3948('0x1a')](_0x16ec7f);}return null;};}function patchUpdates(_0x3d9177){return function(_0x390ef0){try{jsonpatch['apply'](_0x390ef0,_0x3d9177,!![]);}catch(_0x23402e){return BPromise[_0x3948('0x20')](_0x23402e);}return _0x390ef0[_0x3948('0x21')]();};}function saveUpdates(_0x2af58b,_0x2734b8){return function(_0x30a0b2){if(_0x30a0b2){return _0x30a0b2[_0x3948('0x22')](_0x2af58b)[_0x3948('0x23')](function(_0x41602d){return _0x41602d;});}return null;};}function removeEntity(_0x59d526,_0x595277){return function(_0x2adc0a){if(_0x2adc0a){return _0x2adc0a[_0x3948('0x24')]()['then'](function(){_0x59d526[_0x3948('0x18')](0xcc)[_0x3948('0x19')]();});}};}function handleEntityNotFound(_0x29b8e6,_0x2b246b){return function(_0x1e0eba){if(!_0x1e0eba){_0x29b8e6[_0x3948('0x17')](0x194);}return _0x1e0eba;};}function handleError(_0x6360c5,_0x1ae121){_0x1ae121=_0x1ae121||0x1f4;return function(_0x50258e){logger[_0x3948('0x25')](_0x50258e['stack']);if(_0x50258e[_0x3948('0x26')]){delete _0x50258e[_0x3948('0x26')];}_0x6360c5[_0x3948('0x18')](_0x1ae121)[_0x3948('0x27')](_0x50258e);};}exports[_0x3948('0x28')]=function(_0x3e1f11,_0x41f0a2){var _0x2d7ee0={},_0x302bd2={},_0x5888d4={'count':0x0,'rows':[]};var _0x208709=_[_0x3948('0x29')](db[_0x3948('0x2a')][_0x3948('0x2b')],function(_0x123038){return{'name':_0x123038['fieldName'],'type':_0x123038['type'][_0x3948('0x2c')]};});_0x302bd2[_0x3948('0x2d')]=_[_0x3948('0x29')](_0x208709,_0x3948('0x26'));_0x302bd2['query']=_['keys'](_0x3e1f11[_0x3948('0x2e')]);_0x302bd2[_0x3948('0x2f')]=_[_0x3948('0x30')](_0x302bd2['model'],_0x302bd2[_0x3948('0x2e')]);_0x2d7ee0[_0x3948('0x31')]=_[_0x3948('0x30')](_0x302bd2[_0x3948('0x2d')],qs[_0x3948('0x32')](_0x3e1f11['query'][_0x3948('0x32')]));_0x2d7ee0[_0x3948('0x31')]=_0x2d7ee0[_0x3948('0x31')][_0x3948('0x33')]?_0x2d7ee0['attributes']:_0x302bd2['model'];if(!_0x3e1f11[_0x3948('0x2e')][_0x3948('0x34')](_0x3948('0x35'))){_0x2d7ee0[_0x3948('0x1c')]=qs[_0x3948('0x1c')](_0x3e1f11[_0x3948('0x2e')]['limit']);_0x2d7ee0['offset']=qs['offset'](_0x3e1f11[_0x3948('0x2e')][_0x3948('0x1b')]);}_0x2d7ee0['order']=qs[_0x3948('0x36')](_0x3e1f11['query'][_0x3948('0x36')]);_0x2d7ee0['where']=qs[_0x3948('0x2f')](_[_0x3948('0x37')](_0x3e1f11[_0x3948('0x2e')],_0x302bd2[_0x3948('0x2f')]),_0x208709);if(_0x3e1f11[_0x3948('0x2e')][_0x3948('0x38')]){_0x2d7ee0[_0x3948('0x39')]=_[_0x3948('0x3a')](_0x2d7ee0[_0x3948('0x39')],{'$or':_['map'](_0x208709,function(_0x1096cb){if(_0x1096cb['type']!=='VIRTUAL'){var _0x2ef665={};_0x2ef665[_0x1096cb[_0x3948('0x26')]]={'$like':'%'+_0x3e1f11['query'][_0x3948('0x38')]+'%'};return _0x2ef665;}})});}_0x2d7ee0=_[_0x3948('0x3a')]({},_0x2d7ee0,_0x3e1f11[_0x3948('0x3b')]);var _0x4052f7={'where':_0x2d7ee0[_0x3948('0x39')]};return db[_0x3948('0x2a')][_0x3948('0x1d')](_0x4052f7)[_0x3948('0x23')](function(_0x2600eb){_0x5888d4[_0x3948('0x1d')]=_0x2600eb;if(_0x3e1f11['query']['includeAll']){_0x2d7ee0[_0x3948('0x3c')]=[{'all':!![]}];}return db[_0x3948('0x2a')][_0x3948('0x3d')](_0x2d7ee0);})[_0x3948('0x23')](function(_0x5266f0){_0x5888d4[_0x3948('0x3e')]=_0x5266f0;return _0x5888d4;})[_0x3948('0x23')](respondWithFilteredResult(_0x41f0a2,_0x2d7ee0))[_0x3948('0x3f')](handleError(_0x41f0a2,null));};exports[_0x3948('0x40')]=function(_0x5a528c,_0x190f9e){var _0x2aff13={'raw':![],'where':{'id':_0x5a528c[_0x3948('0x41')]['id']}},_0x149b98={};_0x149b98['model']=_[_0x3948('0x42')](db[_0x3948('0x2a')][_0x3948('0x2b')]);_0x149b98['query']=_['keys'](_0x5a528c[_0x3948('0x2e')]);_0x149b98[_0x3948('0x2f')]=_['intersection'](_0x149b98[_0x3948('0x2d')],_0x149b98[_0x3948('0x2e')]);_0x2aff13[_0x3948('0x31')]=_[_0x3948('0x30')](_0x149b98[_0x3948('0x2d')],qs[_0x3948('0x32')](_0x5a528c[_0x3948('0x2e')]['fields']));_0x2aff13['attributes']=_0x2aff13['attributes'][_0x3948('0x33')]?_0x2aff13[_0x3948('0x31')]:_0x149b98[_0x3948('0x2d')];if(_0x5a528c['query'][_0x3948('0x43')]){_0x2aff13[_0x3948('0x3c')]=[{'all':!![]}];}_0x2aff13=_[_0x3948('0x3a')]({},_0x2aff13,_0x5a528c[_0x3948('0x3b')]);return db['FreshsalesConfiguration'][_0x3948('0x44')](_0x2aff13)[_0x3948('0x23')](handleEntityNotFound(_0x190f9e,null))[_0x3948('0x23')](respondWithResult(_0x190f9e,null))[_0x3948('0x3f')](handleError(_0x190f9e,null));};exports[_0x3948('0x45')]=function(_0x2c5130,_0x4fe2a3){return db['FreshsalesConfiguration'][_0x3948('0x45')](_0x2c5130['body'],{})[_0x3948('0x23')](respondWithResult(_0x4fe2a3,0xc9))['catch'](handleError(_0x4fe2a3,null));};exports[_0x3948('0x22')]=function(_0x5543ed,_0x5ddfbc){if(_0x5543ed['body']['id']){delete _0x5543ed['body']['id'];}return db['FreshsalesConfiguration'][_0x3948('0x44')]({'where':{'id':_0x5543ed[_0x3948('0x41')]['id']}})[_0x3948('0x23')](handleEntityNotFound(_0x5ddfbc,null))[_0x3948('0x23')](saveUpdates(_0x5543ed[_0x3948('0x46')],null))['then'](respondWithResult(_0x5ddfbc,null))[_0x3948('0x3f')](handleError(_0x5ddfbc,null));};exports['destroy']=function(_0x23d8e7,_0x612cd){return db[_0x3948('0x2a')]['find']({'where':{'id':_0x23d8e7[_0x3948('0x41')]['id']}})['then'](handleEntityNotFound(_0x612cd,null))[_0x3948('0x23')](removeEntity(_0x612cd,null))[_0x3948('0x3f')](handleError(_0x612cd,null));};exports[_0x3948('0x47')]=function(_0x447b54,_0x3a6bd4,_0xfcf558){var _0xb38802={};var _0x1afa30={};var _0x4905cf;var _0x4c4424;return db['FreshsalesConfiguration'][_0x3948('0x48')]({'where':{'id':_0x447b54['params']['id']}})[_0x3948('0x23')](handleEntityNotFound(_0x3a6bd4,null))['then'](function(_0x484cf6){if(_0x484cf6){_0x4905cf=_0x484cf6;_0x1afa30['model']=_[_0x3948('0x42')](db['FreshsalesField'][_0x3948('0x2b')]);_0x1afa30[_0x3948('0x2e')]=_['keys'](_0x447b54[_0x3948('0x2e')]);_0x1afa30[_0x3948('0x2f')]=_[_0x3948('0x30')](_0x1afa30[_0x3948('0x2d')],_0x1afa30[_0x3948('0x2e')]);_0xb38802[_0x3948('0x31')]=_[_0x3948('0x30')](_0x1afa30[_0x3948('0x2d')],qs[_0x3948('0x32')](_0x447b54[_0x3948('0x2e')]['fields']));_0xb38802[_0x3948('0x31')]=_0xb38802[_0x3948('0x31')]['length']?_0xb38802['attributes']:_0x1afa30[_0x3948('0x2d')];_0xb38802[_0x3948('0x49')]=qs[_0x3948('0x36')](_0x447b54['query'][_0x3948('0x36')]);_0xb38802[_0x3948('0x39')]=qs[_0x3948('0x2f')](_[_0x3948('0x37')](_0x447b54['query'],_0x1afa30[_0x3948('0x2f')]));if(_0x447b54[_0x3948('0x2e')]['filter']){_0xb38802[_0x3948('0x39')]=_['merge'](_0xb38802[_0x3948('0x39')],{'$or':_['map'](_0xb38802['attributes'],function(_0x33b37e){var _0x13a855={};_0x13a855[_0x33b37e]={'$like':'%'+_0x447b54['query'][_0x3948('0x38')]+'%'};return _0x13a855;})});}_0xb38802=_[_0x3948('0x3a')]({},_0xb38802,_0x447b54['options']);return _0x4905cf[_0x3948('0x47')](_0xb38802);}})[_0x3948('0x23')](function(_0x476560){if(_0x476560){_0x4c4424=_0x476560['length'];if(!_0x447b54[_0x3948('0x2e')]['hasOwnProperty']('nolimit')){_0xb38802[_0x3948('0x1c')]=qs[_0x3948('0x1c')](_0x447b54[_0x3948('0x2e')][_0x3948('0x1c')]);_0xb38802['offset']=qs[_0x3948('0x1b')](_0x447b54[_0x3948('0x2e')][_0x3948('0x1b')]);}return _0x4905cf[_0x3948('0x47')](_0xb38802);}})[_0x3948('0x23')](function(_0x2449d9){if(_0x2449d9){return _0x2449d9?{'count':_0x4c4424,'rows':_0x2449d9}:null;}})[_0x3948('0x23')](respondWithResult(_0x3a6bd4,null))[_0x3948('0x3f')](handleError(_0x3a6bd4,null));};exports['getDescriptions']=function(_0x3d0ed4,_0x13f386,_0x124131){var _0x13aedb={};var _0x509638={};var _0x5ebd0a;var _0x4a6296;return db[_0x3948('0x2a')][_0x3948('0x48')]({'where':{'id':_0x3d0ed4[_0x3948('0x41')]['id']}})[_0x3948('0x23')](handleEntityNotFound(_0x13f386,null))[_0x3948('0x23')](function(_0x155583){if(_0x155583){_0x5ebd0a=_0x155583;_0x509638[_0x3948('0x2d')]=_[_0x3948('0x42')](db[_0x3948('0x4a')][_0x3948('0x2b')]);_0x509638[_0x3948('0x2e')]=_[_0x3948('0x42')](_0x3d0ed4['query']);_0x509638[_0x3948('0x2f')]=_['intersection'](_0x509638['model'],_0x509638[_0x3948('0x2e')]);_0x13aedb[_0x3948('0x31')]=_[_0x3948('0x30')](_0x509638[_0x3948('0x2d')],qs[_0x3948('0x32')](_0x3d0ed4[_0x3948('0x2e')][_0x3948('0x32')]));_0x13aedb['attributes']=_0x13aedb[_0x3948('0x31')][_0x3948('0x33')]?_0x13aedb[_0x3948('0x31')]:_0x509638[_0x3948('0x2d')];_0x13aedb['order']=qs[_0x3948('0x36')](_0x3d0ed4['query'][_0x3948('0x36')]);_0x13aedb[_0x3948('0x39')]=qs[_0x3948('0x2f')](_['pick'](_0x3d0ed4[_0x3948('0x2e')],_0x509638[_0x3948('0x2f')]));if(_0x3d0ed4[_0x3948('0x2e')][_0x3948('0x38')]){_0x13aedb[_0x3948('0x39')]=_[_0x3948('0x3a')](_0x13aedb[_0x3948('0x39')],{'$or':_[_0x3948('0x29')](_0x13aedb[_0x3948('0x31')],function(_0xf77c8){var _0x506f0b={};_0x506f0b[_0xf77c8]={'$like':'%'+_0x3d0ed4[_0x3948('0x2e')][_0x3948('0x38')]+'%'};return _0x506f0b;})});}_0x13aedb=_['merge']({},_0x13aedb,_0x3d0ed4['options']);return _0x5ebd0a['getDescriptions'](_0x13aedb);}})[_0x3948('0x23')](function(_0x5c4016){if(_0x5c4016){_0x4a6296=_0x5c4016[_0x3948('0x33')];if(!_0x3d0ed4[_0x3948('0x2e')][_0x3948('0x34')](_0x3948('0x35'))){_0x13aedb[_0x3948('0x1c')]=qs[_0x3948('0x1c')](_0x3d0ed4[_0x3948('0x2e')][_0x3948('0x1c')]);_0x13aedb[_0x3948('0x1b')]=qs[_0x3948('0x1b')](_0x3d0ed4[_0x3948('0x2e')][_0x3948('0x1b')]);}return _0x5ebd0a[_0x3948('0x4b')](_0x13aedb);}})[_0x3948('0x23')](function(_0x293c7a){if(_0x293c7a){return _0x293c7a?{'count':_0x4a6296,'rows':_0x293c7a}:null;}})[_0x3948('0x23')](respondWithResult(_0x13f386,null))[_0x3948('0x3f')](handleError(_0x13f386,null));};exports['getFields']=function(_0x1c1074,_0x469208,_0x18b8e0){var _0x3867f5={};var _0x344a89={};var _0x368703;var _0x562229;return db[_0x3948('0x2a')][_0x3948('0x48')]({'where':{'id':_0x1c1074[_0x3948('0x41')]['id']}})[_0x3948('0x23')](handleEntityNotFound(_0x469208,null))[_0x3948('0x23')](function(_0x9bb8c0){if(_0x9bb8c0){_0x368703=_0x9bb8c0;_0x344a89[_0x3948('0x2d')]=_[_0x3948('0x42')](db[_0x3948('0x4a')][_0x3948('0x2b')]);_0x344a89[_0x3948('0x2e')]=_[_0x3948('0x42')](_0x1c1074['query']);_0x344a89[_0x3948('0x2f')]=_['intersection'](_0x344a89[_0x3948('0x2d')],_0x344a89[_0x3948('0x2e')]);_0x3867f5[_0x3948('0x31')]=_[_0x3948('0x30')](_0x344a89[_0x3948('0x2d')],qs[_0x3948('0x32')](_0x1c1074[_0x3948('0x2e')][_0x3948('0x32')]));_0x3867f5[_0x3948('0x31')]=_0x3867f5['attributes'][_0x3948('0x33')]?_0x3867f5[_0x3948('0x31')]:_0x344a89[_0x3948('0x2d')];_0x3867f5[_0x3948('0x49')]=qs[_0x3948('0x36')](_0x1c1074[_0x3948('0x2e')][_0x3948('0x36')]);_0x3867f5[_0x3948('0x39')]=qs[_0x3948('0x2f')](_['pick'](_0x1c1074['query'],_0x344a89[_0x3948('0x2f')]));if(_0x1c1074['query']['filter']){_0x3867f5[_0x3948('0x39')]=_[_0x3948('0x3a')](_0x3867f5[_0x3948('0x39')],{'$or':_['map'](_0x3867f5['attributes'],function(_0x36ce97){var _0x1a5056={};_0x1a5056[_0x36ce97]={'$like':'%'+_0x1c1074[_0x3948('0x2e')][_0x3948('0x38')]+'%'};return _0x1a5056;})});}_0x3867f5=_['merge']({},_0x3867f5,_0x1c1074[_0x3948('0x3b')]);return _0x368703[_0x3948('0x4c')](_0x3867f5);}})['then'](function(_0x9a4fc0){if(_0x9a4fc0){_0x562229=_0x9a4fc0[_0x3948('0x33')];if(!_0x1c1074[_0x3948('0x2e')][_0x3948('0x34')](_0x3948('0x35'))){_0x3867f5[_0x3948('0x1c')]=qs[_0x3948('0x1c')](_0x1c1074[_0x3948('0x2e')][_0x3948('0x1c')]);_0x3867f5['offset']=qs[_0x3948('0x1b')](_0x1c1074['query']['offset']);}return _0x368703[_0x3948('0x4c')](_0x3867f5);}})['then'](function(_0x32d60f){if(_0x32d60f){return _0x32d60f?{'count':_0x562229,'rows':_0x32d60f}:null;}})[_0x3948('0x23')](respondWithResult(_0x469208,null))[_0x3948('0x3f')](handleError(_0x469208,null));};
\ No newline at end of file