Built motion from commit (unavailable).|2.5.17
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 542ab99..dda4528 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x326f=['destroy','end','stack','name','index','FreshsalesConfiguration','type','key','model','query','filters','intersection','attributes','fields','nolimit','limit','order','sort','where','pick','merge','map','filter','options','includeAll','include','rows','show','params','keys','rawAttributes','length','find','create','body','FreshsalesField','getSubjects','getDescriptions','findOne','hasOwnProperty','getFields','html-pdf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','jayson/promise','client','then','info','FreshsalesConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshsalesConfiguration,\x20%s,\x20%s,\x20%s','error','code','catch','sendStatus','status','json','offset','set','Content-Range','reject','save','update'];(function(_0x44b0de,_0x213afa){var _0x21da2a=function(_0x264f30){while(--_0x264f30){_0x44b0de['push'](_0x44b0de['shift']());}};_0x21da2a(++_0x213afa);}(_0x326f,0xd1));var _0xf326=function(_0x454fda,_0x5bf6ce){_0x454fda=_0x454fda-0x0;var _0x3b91f0=_0x326f[_0x454fda];return _0x3b91f0;};'use strict';var pdf=require(_0xf326('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf326('0x1'));var jsonpatch=require(_0xf326('0x2'));var rp=require(_0xf326('0x3'));var moment=require(_0xf326('0x4'));var BPromise=require(_0xf326('0x5'));var Mustache=require(_0xf326('0x6'));var util=require(_0xf326('0x7'));var path=require(_0xf326('0x8'));var sox=require(_0xf326('0x9'));var csv=require(_0xf326('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf326('0xb'));var squel=require(_0xf326('0xc'));var crypto=require(_0xf326('0xd'));var jsforce=require(_0xf326('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf326('0xf'));var Redis=require(_0xf326('0x10'));var authService=require(_0xf326('0x11'));var qs=require(_0xf326('0x12'));var as=require(_0xf326('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf326('0x14'))('api');var utils=require(_0xf326('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf326('0x16'));var db=require('../../mysqldb')['db'];var jayson=require(_0xf326('0x17'));var client=jayson[_0xf326('0x18')]['http']({'port':0x232a});function respondWithRpcPromise(_0x342fe5,_0x472632,_0x3504eb,_0x17a098){return new BPromise(function(_0x5c8483,_0x45c1b6){var _0x5204ee=_0x17a098||client;return _0x5204ee['request'](_0x342fe5,_0x3504eb)[_0xf326('0x19')](function(_0x11f6d2){logger[_0xf326('0x1a')](_0xf326('0x1b'),_0x472632,_0xf326('0x1c'));logger[_0xf326('0x1d')](_0xf326('0x1e'),_0x472632,_0xf326('0x1c'),JSON['stringify'](_0x11f6d2));if(_0x11f6d2[_0xf326('0x1f')]){if(_0x11f6d2[_0xf326('0x1f')][_0xf326('0x20')]===0x1f4){logger[_0xf326('0x1f')](_0xf326('0x1b'),_0x472632,_0x11f6d2[_0xf326('0x1f')]['message']);return _0x45c1b6(_0x11f6d2['error']['message']);}logger[_0xf326('0x1f')](_0xf326('0x1b'),_0x472632,_0x11f6d2['error']['message']);return _0x5c8483(_0x11f6d2[_0xf326('0x1f')]['message']);}else{logger['info'](_0xf326('0x1b'),_0x472632,_0xf326('0x1c'));_0x5c8483(_0x11f6d2['result']['message']);}})[_0xf326('0x21')](function(_0xb1efcf){logger['error'](_0xf326('0x1b'),_0x472632,_0xb1efcf);_0x45c1b6(_0xb1efcf);});});}function respondWithStatusCode(_0x1b9039,_0x43c53e){_0x43c53e=_0x43c53e||0xcc;return function(_0x295752){if(_0x295752){return _0x1b9039[_0xf326('0x22')](_0x43c53e);}return _0x1b9039[_0xf326('0x23')](_0x43c53e)['end']();};}function respondWithResult(_0x55b9f4,_0x4f31f6){_0x4f31f6=_0x4f31f6||0xc8;return function(_0x520d85){if(_0x520d85){return _0x55b9f4[_0xf326('0x23')](_0x4f31f6)[_0xf326('0x24')](_0x520d85);}};}function respondWithFilteredResult(_0x1ff2b5,_0x148953){return function(_0x410237){if(_0x410237){var _0x5217d4=_0x410237['count'],_0x201d28=_0x148953[_0xf326('0x25')],_0xa3c0b=_0x148953['offset']+_0x148953['limit'],_0x212d5d;if(_0xa3c0b>=_0x5217d4){_0xa3c0b=_0x5217d4;_0x212d5d=0xc8;}else{_0x212d5d=0xce;}_0x1ff2b5[_0xf326('0x23')](_0x212d5d);return _0x1ff2b5[_0xf326('0x26')](_0xf326('0x27'),_0x201d28+'-'+_0xa3c0b+'/'+_0x5217d4)['json'](_0x410237);}return null;};}function patchUpdates(_0xc115d9){return function(_0x292500){try{jsonpatch['apply'](_0x292500,_0xc115d9,!![]);}catch(_0x225776){return BPromise[_0xf326('0x28')](_0x225776);}return _0x292500[_0xf326('0x29')]();};}function saveUpdates(_0x18d110,_0xa80156){return function(_0x269be9){if(_0x269be9){return _0x269be9[_0xf326('0x2a')](_0x18d110)[_0xf326('0x19')](function(_0x43b951){return _0x43b951;});}return null;};}function removeEntity(_0x349a03,_0x4b52f2){return function(_0x1035ed){if(_0x1035ed){return _0x1035ed[_0xf326('0x2b')]()[_0xf326('0x19')](function(){_0x349a03['status'](0xcc)[_0xf326('0x2c')]();});}};}function handleEntityNotFound(_0x1721fd,_0x303dc6){return function(_0x4df451){if(!_0x4df451){_0x1721fd['sendStatus'](0x194);}return _0x4df451;};}function handleError(_0x2b8b31,_0x46d75e){_0x46d75e=_0x46d75e||0x1f4;return function(_0x9c3039){logger[_0xf326('0x1f')](_0x9c3039[_0xf326('0x2d')]);if(_0x9c3039[_0xf326('0x2e')]){delete _0x9c3039[_0xf326('0x2e')];}_0x2b8b31[_0xf326('0x23')](_0x46d75e)['send'](_0x9c3039);};}exports[_0xf326('0x2f')]=function(_0x1981bc,_0x51207a){var _0x4083a2={},_0x4e5d7c={},_0xce1cbb={'count':0x0,'rows':[]};var _0x481b64=_['map'](db[_0xf326('0x30')]['rawAttributes'],function(_0x40dcb4){return{'name':_0x40dcb4['fieldName'],'type':_0x40dcb4[_0xf326('0x31')][_0xf326('0x32')]};});_0x4e5d7c[_0xf326('0x33')]=_['map'](_0x481b64,_0xf326('0x2e'));_0x4e5d7c[_0xf326('0x34')]=_['keys'](_0x1981bc[_0xf326('0x34')]);_0x4e5d7c[_0xf326('0x35')]=_[_0xf326('0x36')](_0x4e5d7c[_0xf326('0x33')],_0x4e5d7c['query']);_0x4083a2[_0xf326('0x37')]=_[_0xf326('0x36')](_0x4e5d7c[_0xf326('0x33')],qs[_0xf326('0x38')](_0x1981bc[_0xf326('0x34')]['fields']));_0x4083a2[_0xf326('0x37')]=_0x4083a2[_0xf326('0x37')]['length']?_0x4083a2['attributes']:_0x4e5d7c[_0xf326('0x33')];if(!_0x1981bc['query']['hasOwnProperty'](_0xf326('0x39'))){_0x4083a2['limit']=qs[_0xf326('0x3a')](_0x1981bc[_0xf326('0x34')][_0xf326('0x3a')]);_0x4083a2[_0xf326('0x25')]=qs['offset'](_0x1981bc[_0xf326('0x34')][_0xf326('0x25')]);}_0x4083a2[_0xf326('0x3b')]=qs[_0xf326('0x3c')](_0x1981bc[_0xf326('0x34')][_0xf326('0x3c')]);_0x4083a2[_0xf326('0x3d')]=qs[_0xf326('0x35')](_[_0xf326('0x3e')](_0x1981bc[_0xf326('0x34')],_0x4e5d7c[_0xf326('0x35')]),_0x481b64);if(_0x1981bc[_0xf326('0x34')]['filter']){_0x4083a2[_0xf326('0x3d')]=_[_0xf326('0x3f')](_0x4083a2[_0xf326('0x3d')],{'$or':_[_0xf326('0x40')](_0x481b64,function(_0x1dd262){if(_0x1dd262[_0xf326('0x31')]!=='VIRTUAL'){var _0x28e2d3={};_0x28e2d3[_0x1dd262[_0xf326('0x2e')]]={'$like':'%'+_0x1981bc['query'][_0xf326('0x41')]+'%'};return _0x28e2d3;}})});}_0x4083a2=_[_0xf326('0x3f')]({},_0x4083a2,_0x1981bc[_0xf326('0x42')]);var _0x305863={'where':_0x4083a2[_0xf326('0x3d')]};return db['FreshsalesConfiguration']['count'](_0x305863)[_0xf326('0x19')](function(_0x44e101){_0xce1cbb['count']=_0x44e101;if(_0x1981bc['query'][_0xf326('0x43')]){_0x4083a2[_0xf326('0x44')]=[{'all':!![]}];}return db[_0xf326('0x30')]['findAll'](_0x4083a2);})[_0xf326('0x19')](function(_0xe96e1e){_0xce1cbb[_0xf326('0x45')]=_0xe96e1e;return _0xce1cbb;})[_0xf326('0x19')](respondWithFilteredResult(_0x51207a,_0x4083a2))[_0xf326('0x21')](handleError(_0x51207a,null));};exports[_0xf326('0x46')]=function(_0x12792c,_0x3b90dc){var _0x3df9a8={'raw':![],'where':{'id':_0x12792c[_0xf326('0x47')]['id']}},_0x27ced1={};_0x27ced1[_0xf326('0x33')]=_[_0xf326('0x48')](db[_0xf326('0x30')][_0xf326('0x49')]);_0x27ced1['query']=_[_0xf326('0x48')](_0x12792c[_0xf326('0x34')]);_0x27ced1[_0xf326('0x35')]=_[_0xf326('0x36')](_0x27ced1['model'],_0x27ced1[_0xf326('0x34')]);_0x3df9a8[_0xf326('0x37')]=_[_0xf326('0x36')](_0x27ced1[_0xf326('0x33')],qs['fields'](_0x12792c[_0xf326('0x34')][_0xf326('0x38')]));_0x3df9a8[_0xf326('0x37')]=_0x3df9a8[_0xf326('0x37')][_0xf326('0x4a')]?_0x3df9a8['attributes']:_0x27ced1['model'];if(_0x12792c[_0xf326('0x34')][_0xf326('0x43')]){_0x3df9a8[_0xf326('0x44')]=[{'all':!![]}];}_0x3df9a8=_['merge']({},_0x3df9a8,_0x12792c[_0xf326('0x42')]);return db[_0xf326('0x30')][_0xf326('0x4b')](_0x3df9a8)['then'](handleEntityNotFound(_0x3b90dc,null))['then'](respondWithResult(_0x3b90dc,null))[_0xf326('0x21')](handleError(_0x3b90dc,null));};exports['create']=function(_0x1cf58f,_0x554277){return db[_0xf326('0x30')][_0xf326('0x4c')](_0x1cf58f[_0xf326('0x4d')],{})[_0xf326('0x19')](respondWithResult(_0x554277,0xc9))[_0xf326('0x21')](handleError(_0x554277,null));};exports[_0xf326('0x2a')]=function(_0x7f7ece,_0x495a16){if(_0x7f7ece[_0xf326('0x4d')]['id']){delete _0x7f7ece[_0xf326('0x4d')]['id'];}return db[_0xf326('0x30')]['find']({'where':{'id':_0x7f7ece[_0xf326('0x47')]['id']}})[_0xf326('0x19')](handleEntityNotFound(_0x495a16,null))[_0xf326('0x19')](saveUpdates(_0x7f7ece[_0xf326('0x4d')],null))[_0xf326('0x19')](respondWithResult(_0x495a16,null))['catch'](handleError(_0x495a16,null));};exports[_0xf326('0x2b')]=function(_0x21eac7,_0x287a97){return db[_0xf326('0x30')]['find']({'where':{'id':_0x21eac7[_0xf326('0x47')]['id']}})[_0xf326('0x19')](handleEntityNotFound(_0x287a97,null))[_0xf326('0x19')](removeEntity(_0x287a97,null))[_0xf326('0x21')](handleError(_0x287a97,null));};exports['getSubjects']=function(_0x5be2b1,_0x18b46e,_0x44d2ed){var _0x55ca96={};var _0x3cf6fa={};var _0x29de71;var _0x316609;return db[_0xf326('0x30')]['findOne']({'where':{'id':_0x5be2b1[_0xf326('0x47')]['id']}})['then'](handleEntityNotFound(_0x18b46e,null))['then'](function(_0x9d84c3){if(_0x9d84c3){_0x29de71=_0x9d84c3;_0x3cf6fa['model']=_[_0xf326('0x48')](db[_0xf326('0x4e')][_0xf326('0x49')]);_0x3cf6fa['query']=_['keys'](_0x5be2b1[_0xf326('0x34')]);_0x3cf6fa[_0xf326('0x35')]=_[_0xf326('0x36')](_0x3cf6fa['model'],_0x3cf6fa[_0xf326('0x34')]);_0x55ca96['attributes']=_[_0xf326('0x36')](_0x3cf6fa[_0xf326('0x33')],qs[_0xf326('0x38')](_0x5be2b1[_0xf326('0x34')][_0xf326('0x38')]));_0x55ca96[_0xf326('0x37')]=_0x55ca96[_0xf326('0x37')][_0xf326('0x4a')]?_0x55ca96[_0xf326('0x37')]:_0x3cf6fa[_0xf326('0x33')];_0x55ca96[_0xf326('0x3b')]=qs[_0xf326('0x3c')](_0x5be2b1[_0xf326('0x34')]['sort']);_0x55ca96[_0xf326('0x3d')]=qs['filters'](_[_0xf326('0x3e')](_0x5be2b1[_0xf326('0x34')],_0x3cf6fa['filters']));if(_0x5be2b1[_0xf326('0x34')]['filter']){_0x55ca96[_0xf326('0x3d')]=_[_0xf326('0x3f')](_0x55ca96[_0xf326('0x3d')],{'$or':_[_0xf326('0x40')](_0x55ca96[_0xf326('0x37')],function(_0x51ff5e){var _0x4ec099={};_0x4ec099[_0x51ff5e]={'$like':'%'+_0x5be2b1[_0xf326('0x34')][_0xf326('0x41')]+'%'};return _0x4ec099;})});}_0x55ca96=_[_0xf326('0x3f')]({},_0x55ca96,_0x5be2b1[_0xf326('0x42')]);return _0x29de71[_0xf326('0x4f')](_0x55ca96);}})['then'](function(_0x28c4f2){if(_0x28c4f2){_0x316609=_0x28c4f2[_0xf326('0x4a')];if(!_0x5be2b1['query']['hasOwnProperty']('nolimit')){_0x55ca96[_0xf326('0x3a')]=qs[_0xf326('0x3a')](_0x5be2b1[_0xf326('0x34')][_0xf326('0x3a')]);_0x55ca96[_0xf326('0x25')]=qs[_0xf326('0x25')](_0x5be2b1[_0xf326('0x34')]['offset']);}return _0x29de71[_0xf326('0x4f')](_0x55ca96);}})[_0xf326('0x19')](function(_0x3c3379){if(_0x3c3379){return _0x3c3379?{'count':_0x316609,'rows':_0x3c3379}:null;}})[_0xf326('0x19')](respondWithResult(_0x18b46e,null))['catch'](handleError(_0x18b46e,null));};exports[_0xf326('0x50')]=function(_0x5eebe8,_0x499b59,_0x2dd9e4){var _0x540fa0={};var _0x78ba34={};var _0x3411a4;var _0x461059;return db[_0xf326('0x30')][_0xf326('0x51')]({'where':{'id':_0x5eebe8['params']['id']}})['then'](handleEntityNotFound(_0x499b59,null))['then'](function(_0xeeea57){if(_0xeeea57){_0x3411a4=_0xeeea57;_0x78ba34[_0xf326('0x33')]=_[_0xf326('0x48')](db[_0xf326('0x4e')][_0xf326('0x49')]);_0x78ba34['query']=_[_0xf326('0x48')](_0x5eebe8[_0xf326('0x34')]);_0x78ba34[_0xf326('0x35')]=_['intersection'](_0x78ba34['model'],_0x78ba34[_0xf326('0x34')]);_0x540fa0[_0xf326('0x37')]=_['intersection'](_0x78ba34['model'],qs[_0xf326('0x38')](_0x5eebe8['query'][_0xf326('0x38')]));_0x540fa0['attributes']=_0x540fa0['attributes']['length']?_0x540fa0[_0xf326('0x37')]:_0x78ba34[_0xf326('0x33')];_0x540fa0[_0xf326('0x3b')]=qs['sort'](_0x5eebe8[_0xf326('0x34')][_0xf326('0x3c')]);_0x540fa0[_0xf326('0x3d')]=qs[_0xf326('0x35')](_[_0xf326('0x3e')](_0x5eebe8[_0xf326('0x34')],_0x78ba34[_0xf326('0x35')]));if(_0x5eebe8[_0xf326('0x34')][_0xf326('0x41')]){_0x540fa0['where']=_[_0xf326('0x3f')](_0x540fa0['where'],{'$or':_[_0xf326('0x40')](_0x540fa0[_0xf326('0x37')],function(_0x40ee66){var _0x4ba982={};_0x4ba982[_0x40ee66]={'$like':'%'+_0x5eebe8[_0xf326('0x34')][_0xf326('0x41')]+'%'};return _0x4ba982;})});}_0x540fa0=_[_0xf326('0x3f')]({},_0x540fa0,_0x5eebe8['options']);return _0x3411a4[_0xf326('0x50')](_0x540fa0);}})[_0xf326('0x19')](function(_0x3bbe4c){if(_0x3bbe4c){_0x461059=_0x3bbe4c[_0xf326('0x4a')];if(!_0x5eebe8['query'][_0xf326('0x52')]('nolimit')){_0x540fa0['limit']=qs[_0xf326('0x3a')](_0x5eebe8[_0xf326('0x34')]['limit']);_0x540fa0['offset']=qs['offset'](_0x5eebe8[_0xf326('0x34')]['offset']);}return _0x3411a4[_0xf326('0x50')](_0x540fa0);}})[_0xf326('0x19')](function(_0x3434b2){if(_0x3434b2){return _0x3434b2?{'count':_0x461059,'rows':_0x3434b2}:null;}})[_0xf326('0x19')](respondWithResult(_0x499b59,null))[_0xf326('0x21')](handleError(_0x499b59,null));};exports[_0xf326('0x53')]=function(_0x5d23f0,_0x39edf8,_0x323926){var _0x5f1724={};var _0x497ada={};var _0x14eecc;var _0x537afc;return db[_0xf326('0x30')][_0xf326('0x51')]({'where':{'id':_0x5d23f0[_0xf326('0x47')]['id']}})[_0xf326('0x19')](handleEntityNotFound(_0x39edf8,null))[_0xf326('0x19')](function(_0x6e662){if(_0x6e662){_0x14eecc=_0x6e662;_0x497ada[_0xf326('0x33')]=_[_0xf326('0x48')](db[_0xf326('0x4e')]['rawAttributes']);_0x497ada[_0xf326('0x34')]=_[_0xf326('0x48')](_0x5d23f0['query']);_0x497ada[_0xf326('0x35')]=_['intersection'](_0x497ada[_0xf326('0x33')],_0x497ada[_0xf326('0x34')]);_0x5f1724[_0xf326('0x37')]=_['intersection'](_0x497ada[_0xf326('0x33')],qs[_0xf326('0x38')](_0x5d23f0[_0xf326('0x34')][_0xf326('0x38')]));_0x5f1724[_0xf326('0x37')]=_0x5f1724[_0xf326('0x37')][_0xf326('0x4a')]?_0x5f1724[_0xf326('0x37')]:_0x497ada[_0xf326('0x33')];_0x5f1724[_0xf326('0x3b')]=qs[_0xf326('0x3c')](_0x5d23f0[_0xf326('0x34')][_0xf326('0x3c')]);_0x5f1724[_0xf326('0x3d')]=qs[_0xf326('0x35')](_['pick'](_0x5d23f0[_0xf326('0x34')],_0x497ada[_0xf326('0x35')]));if(_0x5d23f0['query'][_0xf326('0x41')]){_0x5f1724[_0xf326('0x3d')]=_['merge'](_0x5f1724[_0xf326('0x3d')],{'$or':_[_0xf326('0x40')](_0x5f1724[_0xf326('0x37')],function(_0x8dbd96){var _0x2ab607={};_0x2ab607[_0x8dbd96]={'$like':'%'+_0x5d23f0[_0xf326('0x34')][_0xf326('0x41')]+'%'};return _0x2ab607;})});}_0x5f1724=_['merge']({},_0x5f1724,_0x5d23f0[_0xf326('0x42')]);return _0x14eecc[_0xf326('0x53')](_0x5f1724);}})[_0xf326('0x19')](function(_0x3c33d1){if(_0x3c33d1){_0x537afc=_0x3c33d1[_0xf326('0x4a')];if(!_0x5d23f0[_0xf326('0x34')][_0xf326('0x52')](_0xf326('0x39'))){_0x5f1724['limit']=qs[_0xf326('0x3a')](_0x5d23f0[_0xf326('0x34')]['limit']);_0x5f1724[_0xf326('0x25')]=qs['offset'](_0x5d23f0[_0xf326('0x34')][_0xf326('0x25')]);}return _0x14eecc[_0xf326('0x53')](_0x5f1724);}})[_0xf326('0x19')](function(_0x405a52){if(_0x405a52){return _0x405a52?{'count':_0x537afc,'rows':_0x405a52}:null;}})[_0xf326('0x19')](respondWithResult(_0x39edf8,null))[_0xf326('0x21')](handleError(_0x39edf8,null));};
\ No newline at end of file
+var _0x5fab=['FreshsalesField','length','hasOwnProperty','getSubjects','getDescriptions','nolimit','getFields','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','client','http','request','info','FreshsalesConfiguration,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','sendStatus','end','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','name','send','FreshsalesConfiguration','rawAttributes','type','key','model','map','attributes','intersection','fields','query','order','sort','filters','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','keys','find','create','body','destroy','findOne'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5fab,0x177));var _0xb5fa=function(_0x185334,_0x4630ac){_0x185334=_0x185334-0x0;var _0xf2e59a=_0x5fab[_0x185334];return _0xf2e59a;};'use strict';var pdf=require(_0xb5fa('0x0'));var emlformat=require(_0xb5fa('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xb5fa('0x2'));var jsonpatch=require(_0xb5fa('0x3'));var rp=require(_0xb5fa('0x4'));var moment=require(_0xb5fa('0x5'));var BPromise=require(_0xb5fa('0x6'));var Mustache=require(_0xb5fa('0x7'));var util=require(_0xb5fa('0x8'));var path=require(_0xb5fa('0x9'));var sox=require(_0xb5fa('0xa'));var csv=require(_0xb5fa('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xb5fa('0xc'));var crypto=require(_0xb5fa('0xd'));var jsforce=require(_0xb5fa('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xb5fa('0xb'));var querystring=require(_0xb5fa('0xf'));var Papa=require(_0xb5fa('0x10'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xb5fa('0x11'));var as=require(_0xb5fa('0x12'));var hardwareService=require(_0xb5fa('0x13'));var logger=require(_0xb5fa('0x14'))(_0xb5fa('0x15'));var utils=require(_0xb5fa('0x16'));var config=require(_0xb5fa('0x17'));var licenseUtil=require(_0xb5fa('0x18'));var db=require(_0xb5fa('0x19'))['db'];var jayson=require('jayson/promise');var client=jayson[_0xb5fa('0x1a')][_0xb5fa('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x56e8b0,_0x116849,_0x577af0,_0x265992){return new BPromise(function(_0x3fc372,_0x40c914){var _0xca8d82=_0x265992||client;return _0xca8d82[_0xb5fa('0x1c')](_0x56e8b0,_0x577af0)['then'](function(_0x567f31){logger[_0xb5fa('0x1d')](_0xb5fa('0x1e'),_0x116849,_0xb5fa('0x1f'));logger[_0xb5fa('0x20')]('FreshsalesConfiguration,\x20%s,\x20%s,\x20%s',_0x116849,'request\x20sent',JSON[_0xb5fa('0x21')](_0x567f31));if(_0x567f31[_0xb5fa('0x22')]){if(_0x567f31[_0xb5fa('0x22')][_0xb5fa('0x23')]===0x1f4){logger[_0xb5fa('0x22')](_0xb5fa('0x1e'),_0x116849,_0x567f31[_0xb5fa('0x22')][_0xb5fa('0x24')]);return _0x40c914(_0x567f31[_0xb5fa('0x22')][_0xb5fa('0x24')]);}logger[_0xb5fa('0x22')](_0xb5fa('0x1e'),_0x116849,_0x567f31['error'][_0xb5fa('0x24')]);return _0x3fc372(_0x567f31['error'][_0xb5fa('0x24')]);}else{logger['info'](_0xb5fa('0x1e'),_0x116849,_0xb5fa('0x1f'));_0x3fc372(_0x567f31['result'][_0xb5fa('0x24')]);}})[_0xb5fa('0x25')](function(_0x283a56){logger['error'](_0xb5fa('0x1e'),_0x116849,_0x283a56);_0x40c914(_0x283a56);});});}function respondWithStatusCode(_0xec108f,_0x444237){_0x444237=_0x444237||0xcc;return function(_0x542348){if(_0x542348){return _0xec108f[_0xb5fa('0x26')](_0x444237);}return _0xec108f['status'](_0x444237)[_0xb5fa('0x27')]();};}function respondWithResult(_0x264591,_0x11053a){_0x11053a=_0x11053a||0xc8;return function(_0x543edf){if(_0x543edf){return _0x264591[_0xb5fa('0x28')](_0x11053a)[_0xb5fa('0x29')](_0x543edf);}};}function respondWithFilteredResult(_0x6a455c,_0x20d649){return function(_0x568870){if(_0x568870){var _0x4ec294=_0x568870[_0xb5fa('0x2a')],_0x5bdf11=_0x20d649[_0xb5fa('0x2b')],_0x5a1c39=_0x20d649[_0xb5fa('0x2b')]+_0x20d649[_0xb5fa('0x2c')],_0x28a350;if(_0x5a1c39>=_0x4ec294){_0x5a1c39=_0x4ec294;_0x28a350=0xc8;}else{_0x28a350=0xce;}_0x6a455c[_0xb5fa('0x28')](_0x28a350);return _0x6a455c[_0xb5fa('0x2d')](_0xb5fa('0x2e'),_0x5bdf11+'-'+_0x5a1c39+'/'+_0x4ec294)[_0xb5fa('0x29')](_0x568870);}return null;};}function patchUpdates(_0x2a5690){return function(_0x142bfa){try{jsonpatch[_0xb5fa('0x2f')](_0x142bfa,_0x2a5690,!![]);}catch(_0xab5427){return BPromise[_0xb5fa('0x30')](_0xab5427);}return _0x142bfa[_0xb5fa('0x31')]();};}function saveUpdates(_0x116773,_0x5a0152){return function(_0x3fd1fb){if(_0x3fd1fb){return _0x3fd1fb[_0xb5fa('0x32')](_0x116773)[_0xb5fa('0x33')](function(_0x291938){return _0x291938;});}return null;};}function removeEntity(_0x370d95,_0x10fb43){return function(_0x25fc7c){if(_0x25fc7c){return _0x25fc7c['destroy']()[_0xb5fa('0x33')](function(){_0x370d95['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x558708,_0x1e6ba0){return function(_0x502d57){if(!_0x502d57){_0x558708[_0xb5fa('0x26')](0x194);}return _0x502d57;};}function handleError(_0x5876f1,_0x5518b1){_0x5518b1=_0x5518b1||0x1f4;return function(_0x1847bc){logger[_0xb5fa('0x22')](_0x1847bc['stack']);if(_0x1847bc['name']){delete _0x1847bc[_0xb5fa('0x34')];}_0x5876f1[_0xb5fa('0x28')](_0x5518b1)[_0xb5fa('0x35')](_0x1847bc);};}exports['index']=function(_0xc9adee,_0xc28a80){var _0x4a7137={},_0x18398f={},_0x2056de={'count':0x0,'rows':[]};var _0x204d6b=_['map'](db[_0xb5fa('0x36')][_0xb5fa('0x37')],function(_0x24ef11){return{'name':_0x24ef11['fieldName'],'type':_0x24ef11[_0xb5fa('0x38')][_0xb5fa('0x39')]};});_0x18398f[_0xb5fa('0x3a')]=_[_0xb5fa('0x3b')](_0x204d6b,'name');_0x18398f['query']=_['keys'](_0xc9adee['query']);_0x18398f['filters']=_['intersection'](_0x18398f[_0xb5fa('0x3a')],_0x18398f['query']);_0x4a7137[_0xb5fa('0x3c')]=_[_0xb5fa('0x3d')](_0x18398f[_0xb5fa('0x3a')],qs[_0xb5fa('0x3e')](_0xc9adee[_0xb5fa('0x3f')][_0xb5fa('0x3e')]));_0x4a7137['attributes']=_0x4a7137['attributes']['length']?_0x4a7137[_0xb5fa('0x3c')]:_0x18398f['model'];if(!_0xc9adee[_0xb5fa('0x3f')]['hasOwnProperty']('nolimit')){_0x4a7137[_0xb5fa('0x2c')]=qs[_0xb5fa('0x2c')](_0xc9adee[_0xb5fa('0x3f')][_0xb5fa('0x2c')]);_0x4a7137[_0xb5fa('0x2b')]=qs[_0xb5fa('0x2b')](_0xc9adee[_0xb5fa('0x3f')][_0xb5fa('0x2b')]);}_0x4a7137[_0xb5fa('0x40')]=qs[_0xb5fa('0x41')](_0xc9adee['query'][_0xb5fa('0x41')]);_0x4a7137['where']=qs[_0xb5fa('0x42')](_[_0xb5fa('0x43')](_0xc9adee[_0xb5fa('0x3f')],_0x18398f[_0xb5fa('0x42')]),_0x204d6b);if(_0xc9adee[_0xb5fa('0x3f')][_0xb5fa('0x44')]){_0x4a7137[_0xb5fa('0x45')]=_[_0xb5fa('0x46')](_0x4a7137['where'],{'$or':_[_0xb5fa('0x3b')](_0x204d6b,function(_0xc03e44){if(_0xc03e44['type']!==_0xb5fa('0x47')){var _0x5a6ae3={};_0x5a6ae3[_0xc03e44[_0xb5fa('0x34')]]={'$like':'%'+_0xc9adee[_0xb5fa('0x3f')]['filter']+'%'};return _0x5a6ae3;}})});}_0x4a7137=_['merge']({},_0x4a7137,_0xc9adee[_0xb5fa('0x48')]);var _0xe86e11={'where':_0x4a7137[_0xb5fa('0x45')]};return db[_0xb5fa('0x36')][_0xb5fa('0x2a')](_0xe86e11)[_0xb5fa('0x33')](function(_0x10f354){_0x2056de[_0xb5fa('0x2a')]=_0x10f354;if(_0xc9adee['query'][_0xb5fa('0x49')]){_0x4a7137[_0xb5fa('0x4a')]=[{'all':!![]}];}return db['FreshsalesConfiguration'][_0xb5fa('0x4b')](_0x4a7137);})[_0xb5fa('0x33')](function(_0x247999){_0x2056de[_0xb5fa('0x4c')]=_0x247999;return _0x2056de;})[_0xb5fa('0x33')](respondWithFilteredResult(_0xc28a80,_0x4a7137))[_0xb5fa('0x25')](handleError(_0xc28a80,null));};exports[_0xb5fa('0x4d')]=function(_0x33eb2c,_0x20f5f5){var _0x464e36={'raw':![],'where':{'id':_0x33eb2c[_0xb5fa('0x4e')]['id']}},_0xfe091={};_0xfe091[_0xb5fa('0x3a')]=_[_0xb5fa('0x4f')](db[_0xb5fa('0x36')][_0xb5fa('0x37')]);_0xfe091['query']=_['keys'](_0x33eb2c[_0xb5fa('0x3f')]);_0xfe091['filters']=_[_0xb5fa('0x3d')](_0xfe091[_0xb5fa('0x3a')],_0xfe091['query']);_0x464e36[_0xb5fa('0x3c')]=_[_0xb5fa('0x3d')](_0xfe091[_0xb5fa('0x3a')],qs[_0xb5fa('0x3e')](_0x33eb2c[_0xb5fa('0x3f')][_0xb5fa('0x3e')]));_0x464e36['attributes']=_0x464e36[_0xb5fa('0x3c')]['length']?_0x464e36[_0xb5fa('0x3c')]:_0xfe091[_0xb5fa('0x3a')];if(_0x33eb2c[_0xb5fa('0x3f')]['includeAll']){_0x464e36[_0xb5fa('0x4a')]=[{'all':!![]}];}_0x464e36=_[_0xb5fa('0x46')]({},_0x464e36,_0x33eb2c['options']);return db['FreshsalesConfiguration'][_0xb5fa('0x50')](_0x464e36)[_0xb5fa('0x33')](handleEntityNotFound(_0x20f5f5,null))[_0xb5fa('0x33')](respondWithResult(_0x20f5f5,null))[_0xb5fa('0x25')](handleError(_0x20f5f5,null));};exports[_0xb5fa('0x51')]=function(_0x7775b4,_0x31c91f){return db[_0xb5fa('0x36')][_0xb5fa('0x51')](_0x7775b4[_0xb5fa('0x52')],{})[_0xb5fa('0x33')](respondWithResult(_0x31c91f,0xc9))[_0xb5fa('0x25')](handleError(_0x31c91f,null));};exports[_0xb5fa('0x32')]=function(_0x2799e7,_0x23f235){if(_0x2799e7[_0xb5fa('0x52')]['id']){delete _0x2799e7[_0xb5fa('0x52')]['id'];}return db[_0xb5fa('0x36')]['find']({'where':{'id':_0x2799e7[_0xb5fa('0x4e')]['id']}})[_0xb5fa('0x33')](handleEntityNotFound(_0x23f235,null))[_0xb5fa('0x33')](saveUpdates(_0x2799e7[_0xb5fa('0x52')],null))[_0xb5fa('0x33')](respondWithResult(_0x23f235,null))[_0xb5fa('0x25')](handleError(_0x23f235,null));};exports[_0xb5fa('0x53')]=function(_0x24117e,_0x1cb39e){return db[_0xb5fa('0x36')]['find']({'where':{'id':_0x24117e['params']['id']}})[_0xb5fa('0x33')](handleEntityNotFound(_0x1cb39e,null))[_0xb5fa('0x33')](removeEntity(_0x1cb39e,null))[_0xb5fa('0x25')](handleError(_0x1cb39e,null));};exports['getSubjects']=function(_0x441c41,_0x367f7a,_0x1572fb){var _0x2e855c={};var _0x31ab22={};var _0x9d12f1;var _0x2e7286;return db['FreshsalesConfiguration'][_0xb5fa('0x54')]({'where':{'id':_0x441c41[_0xb5fa('0x4e')]['id']}})['then'](handleEntityNotFound(_0x367f7a,null))[_0xb5fa('0x33')](function(_0x26bc03){if(_0x26bc03){_0x9d12f1=_0x26bc03;_0x31ab22['model']=_[_0xb5fa('0x4f')](db[_0xb5fa('0x55')][_0xb5fa('0x37')]);_0x31ab22[_0xb5fa('0x3f')]=_[_0xb5fa('0x4f')](_0x441c41[_0xb5fa('0x3f')]);_0x31ab22[_0xb5fa('0x42')]=_[_0xb5fa('0x3d')](_0x31ab22[_0xb5fa('0x3a')],_0x31ab22[_0xb5fa('0x3f')]);_0x2e855c[_0xb5fa('0x3c')]=_[_0xb5fa('0x3d')](_0x31ab22[_0xb5fa('0x3a')],qs[_0xb5fa('0x3e')](_0x441c41[_0xb5fa('0x3f')][_0xb5fa('0x3e')]));_0x2e855c[_0xb5fa('0x3c')]=_0x2e855c[_0xb5fa('0x3c')][_0xb5fa('0x56')]?_0x2e855c[_0xb5fa('0x3c')]:_0x31ab22[_0xb5fa('0x3a')];_0x2e855c[_0xb5fa('0x40')]=qs['sort'](_0x441c41[_0xb5fa('0x3f')][_0xb5fa('0x41')]);_0x2e855c[_0xb5fa('0x45')]=qs['filters'](_[_0xb5fa('0x43')](_0x441c41[_0xb5fa('0x3f')],_0x31ab22['filters']));if(_0x441c41[_0xb5fa('0x3f')][_0xb5fa('0x44')]){_0x2e855c[_0xb5fa('0x45')]=_['merge'](_0x2e855c['where'],{'$or':_[_0xb5fa('0x3b')](_0x2e855c[_0xb5fa('0x3c')],function(_0x432f04){var _0x57d8b7={};_0x57d8b7[_0x432f04]={'$like':'%'+_0x441c41[_0xb5fa('0x3f')][_0xb5fa('0x44')]+'%'};return _0x57d8b7;})});}_0x2e855c=_[_0xb5fa('0x46')]({},_0x2e855c,_0x441c41[_0xb5fa('0x48')]);return _0x9d12f1['getSubjects'](_0x2e855c);}})['then'](function(_0x5cec07){if(_0x5cec07){_0x2e7286=_0x5cec07[_0xb5fa('0x56')];if(!_0x441c41[_0xb5fa('0x3f')][_0xb5fa('0x57')]('nolimit')){_0x2e855c[_0xb5fa('0x2c')]=qs[_0xb5fa('0x2c')](_0x441c41[_0xb5fa('0x3f')][_0xb5fa('0x2c')]);_0x2e855c[_0xb5fa('0x2b')]=qs[_0xb5fa('0x2b')](_0x441c41[_0xb5fa('0x3f')][_0xb5fa('0x2b')]);}return _0x9d12f1[_0xb5fa('0x58')](_0x2e855c);}})[_0xb5fa('0x33')](function(_0x3a1db9){if(_0x3a1db9){return _0x3a1db9?{'count':_0x2e7286,'rows':_0x3a1db9}:null;}})[_0xb5fa('0x33')](respondWithResult(_0x367f7a,null))[_0xb5fa('0x25')](handleError(_0x367f7a,null));};exports[_0xb5fa('0x59')]=function(_0x41127a,_0x5eeaa1,_0xf173e4){var _0x5a6f74={};var _0x47193c={};var _0x209213;var _0x37975d;return db[_0xb5fa('0x36')][_0xb5fa('0x54')]({'where':{'id':_0x41127a['params']['id']}})[_0xb5fa('0x33')](handleEntityNotFound(_0x5eeaa1,null))['then'](function(_0x77a831){if(_0x77a831){_0x209213=_0x77a831;_0x47193c[_0xb5fa('0x3a')]=_[_0xb5fa('0x4f')](db[_0xb5fa('0x55')]['rawAttributes']);_0x47193c['query']=_['keys'](_0x41127a[_0xb5fa('0x3f')]);_0x47193c[_0xb5fa('0x42')]=_[_0xb5fa('0x3d')](_0x47193c[_0xb5fa('0x3a')],_0x47193c[_0xb5fa('0x3f')]);_0x5a6f74[_0xb5fa('0x3c')]=_['intersection'](_0x47193c[_0xb5fa('0x3a')],qs['fields'](_0x41127a['query'][_0xb5fa('0x3e')]));_0x5a6f74['attributes']=_0x5a6f74['attributes']['length']?_0x5a6f74[_0xb5fa('0x3c')]:_0x47193c['model'];_0x5a6f74[_0xb5fa('0x40')]=qs[_0xb5fa('0x41')](_0x41127a[_0xb5fa('0x3f')]['sort']);_0x5a6f74['where']=qs[_0xb5fa('0x42')](_[_0xb5fa('0x43')](_0x41127a['query'],_0x47193c[_0xb5fa('0x42')]));if(_0x41127a[_0xb5fa('0x3f')][_0xb5fa('0x44')]){_0x5a6f74[_0xb5fa('0x45')]=_['merge'](_0x5a6f74[_0xb5fa('0x45')],{'$or':_[_0xb5fa('0x3b')](_0x5a6f74[_0xb5fa('0x3c')],function(_0x180e63){var _0x1c0f49={};_0x1c0f49[_0x180e63]={'$like':'%'+_0x41127a[_0xb5fa('0x3f')][_0xb5fa('0x44')]+'%'};return _0x1c0f49;})});}_0x5a6f74=_['merge']({},_0x5a6f74,_0x41127a[_0xb5fa('0x48')]);return _0x209213['getDescriptions'](_0x5a6f74);}})[_0xb5fa('0x33')](function(_0x45790c){if(_0x45790c){_0x37975d=_0x45790c['length'];if(!_0x41127a[_0xb5fa('0x3f')][_0xb5fa('0x57')](_0xb5fa('0x5a'))){_0x5a6f74[_0xb5fa('0x2c')]=qs[_0xb5fa('0x2c')](_0x41127a[_0xb5fa('0x3f')][_0xb5fa('0x2c')]);_0x5a6f74[_0xb5fa('0x2b')]=qs['offset'](_0x41127a[_0xb5fa('0x3f')][_0xb5fa('0x2b')]);}return _0x209213[_0xb5fa('0x59')](_0x5a6f74);}})[_0xb5fa('0x33')](function(_0x53095e){if(_0x53095e){return _0x53095e?{'count':_0x37975d,'rows':_0x53095e}:null;}})['then'](respondWithResult(_0x5eeaa1,null))['catch'](handleError(_0x5eeaa1,null));};exports['getFields']=function(_0x1c60bd,_0x1e607b,_0xff504d){var _0x188e66={};var _0x599a7c={};var _0x551822;var _0x148cb4;return db['FreshsalesConfiguration'][_0xb5fa('0x54')]({'where':{'id':_0x1c60bd[_0xb5fa('0x4e')]['id']}})[_0xb5fa('0x33')](handleEntityNotFound(_0x1e607b,null))[_0xb5fa('0x33')](function(_0x577aef){if(_0x577aef){_0x551822=_0x577aef;_0x599a7c[_0xb5fa('0x3a')]=_['keys'](db[_0xb5fa('0x55')][_0xb5fa('0x37')]);_0x599a7c['query']=_['keys'](_0x1c60bd[_0xb5fa('0x3f')]);_0x599a7c[_0xb5fa('0x42')]=_[_0xb5fa('0x3d')](_0x599a7c[_0xb5fa('0x3a')],_0x599a7c[_0xb5fa('0x3f')]);_0x188e66[_0xb5fa('0x3c')]=_[_0xb5fa('0x3d')](_0x599a7c[_0xb5fa('0x3a')],qs[_0xb5fa('0x3e')](_0x1c60bd[_0xb5fa('0x3f')][_0xb5fa('0x3e')]));_0x188e66[_0xb5fa('0x3c')]=_0x188e66[_0xb5fa('0x3c')]['length']?_0x188e66['attributes']:_0x599a7c[_0xb5fa('0x3a')];_0x188e66['order']=qs[_0xb5fa('0x41')](_0x1c60bd[_0xb5fa('0x3f')]['sort']);_0x188e66[_0xb5fa('0x45')]=qs[_0xb5fa('0x42')](_['pick'](_0x1c60bd[_0xb5fa('0x3f')],_0x599a7c[_0xb5fa('0x42')]));if(_0x1c60bd['query'][_0xb5fa('0x44')]){_0x188e66[_0xb5fa('0x45')]=_[_0xb5fa('0x46')](_0x188e66['where'],{'$or':_['map'](_0x188e66[_0xb5fa('0x3c')],function(_0x1a24a2){var _0x3b5e1d={};_0x3b5e1d[_0x1a24a2]={'$like':'%'+_0x1c60bd[_0xb5fa('0x3f')][_0xb5fa('0x44')]+'%'};return _0x3b5e1d;})});}_0x188e66=_[_0xb5fa('0x46')]({},_0x188e66,_0x1c60bd[_0xb5fa('0x48')]);return _0x551822[_0xb5fa('0x5b')](_0x188e66);}})[_0xb5fa('0x33')](function(_0x1a4465){if(_0x1a4465){_0x148cb4=_0x1a4465['length'];if(!_0x1c60bd['query'][_0xb5fa('0x57')](_0xb5fa('0x5a'))){_0x188e66[_0xb5fa('0x2c')]=qs[_0xb5fa('0x2c')](_0x1c60bd['query'][_0xb5fa('0x2c')]);_0x188e66[_0xb5fa('0x2b')]=qs[_0xb5fa('0x2b')](_0x1c60bd['query'][_0xb5fa('0x2b')]);}return _0x551822[_0xb5fa('0x5b')](_0x188e66);}})[_0xb5fa('0x33')](function(_0x301d14){if(_0x301d14){return _0x301d14?{'count':_0x148cb4,'rows':_0x301d14}:null;}})['then'](respondWithResult(_0x1e607b,null))[_0xb5fa('0x25')](handleError(_0x1e607b,null));};
\ No newline at end of file