Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
index 542ab99..14bf027 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 _0x0b5a=['attributes','fields','length','hasOwnProperty','sort','where','filter','merge','type','VIRTUAL','includeAll','include','findAll','catch','show','keys','options','find','create','body','getSubjects','params','FreshsalesField','order','pick','findOne','nolimit','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','end','status','json','undefined','count','offset','limit','set','apply','reject','save','then','destroy','sendStatus','error','stack','name','send','index','map','FreshsalesConfiguration','rawAttributes','fieldName','key','model','query','filters','intersection'];(function(_0x326c67,_0x5a25be){var _0x186634=function(_0x2c9364){while(--_0x2c9364){_0x326c67['push'](_0x326c67['shift']());}};_0x186634(++_0x5a25be);}(_0x0b5a,0x158));var _0xa0b5=function(_0x1139ac,_0x17f0ff){_0x1139ac=_0x1139ac-0x0;var _0x39c9d1=_0x0b5a[_0x1139ac];return _0x39c9d1;};'use strict';var emlformat=require(_0xa0b5('0x0'));var rimraf=require(_0xa0b5('0x1'));var zipdir=require(_0xa0b5('0x2'));var jsonpatch=require(_0xa0b5('0x3'));var rp=require(_0xa0b5('0x4'));var moment=require('moment');var BPromise=require(_0xa0b5('0x5'));var Mustache=require(_0xa0b5('0x6'));var util=require('util');var path=require(_0xa0b5('0x7'));var sox=require(_0xa0b5('0x8'));var csv=require(_0xa0b5('0x9'));var ejs=require(_0xa0b5('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xa0b5('0xb'));var squel=require(_0xa0b5('0xc'));var crypto=require(_0xa0b5('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xa0b5('0xe'));var toCsv=require(_0xa0b5('0x9'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xa0b5('0xf'));var authService=require(_0xa0b5('0x10'));var qs=require(_0xa0b5('0x11'));var as=require(_0xa0b5('0x12'));var hardwareService=require(_0xa0b5('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0xa0b5('0x14'));var config=require(_0xa0b5('0x15'));var licenseUtil=require(_0xa0b5('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x18db88,_0x276fea){_0x276fea=_0x276fea||0xcc;return function(_0x247f76){if(_0x247f76){return _0x18db88['sendStatus'](_0x276fea);}return _0x18db88['status'](_0x276fea)[_0xa0b5('0x17')]();};}function respondWithResult(_0x1262f5,_0x3e262c){_0x3e262c=_0x3e262c||0xc8;return function(_0x587cfe){if(_0x587cfe){return _0x1262f5[_0xa0b5('0x18')](_0x3e262c)[_0xa0b5('0x19')](_0x587cfe);}};}function respondWithFilteredResult(_0x5da88f,_0x4243eb){return function(_0x1dc75e){if(_0x1dc75e){var _0x30aa09=typeof _0x4243eb['offset']===_0xa0b5('0x1a')&&typeof _0x4243eb['limit']===_0xa0b5('0x1a');var _0x28c06a=_0x1dc75e[_0xa0b5('0x1b')];var _0x58d632=_0x30aa09?0x0:_0x4243eb[_0xa0b5('0x1c')];var _0x3d2b33=_0x30aa09?_0x1dc75e[_0xa0b5('0x1b')]:_0x4243eb[_0xa0b5('0x1c')]+_0x4243eb[_0xa0b5('0x1d')];var _0x3bce13;if(_0x3d2b33>=_0x28c06a){_0x3d2b33=_0x28c06a;_0x3bce13=0xc8;}else{_0x3bce13=0xce;}_0x5da88f[_0xa0b5('0x18')](_0x3bce13);return _0x5da88f[_0xa0b5('0x1e')]('Content-Range',_0x58d632+'-'+_0x3d2b33+'/'+_0x28c06a)['json'](_0x1dc75e);}return null;};}function patchUpdates(_0x48c97d){return function(_0x593ffc){try{jsonpatch[_0xa0b5('0x1f')](_0x593ffc,_0x48c97d,!![]);}catch(_0x51d148){return BPromise[_0xa0b5('0x20')](_0x51d148);}return _0x593ffc[_0xa0b5('0x21')]();};}function saveUpdates(_0x5906d5,_0x18056e){return function(_0x2f2b6f){if(_0x2f2b6f){return _0x2f2b6f['update'](_0x5906d5)[_0xa0b5('0x22')](function(_0xc0e9db){return _0xc0e9db;});}return null;};}function removeEntity(_0x156146,_0x390d24){return function(_0x14718b){if(_0x14718b){return _0x14718b[_0xa0b5('0x23')]()[_0xa0b5('0x22')](function(){_0x156146['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x141d5f,_0x53103d){return function(_0x577255){if(!_0x577255){_0x141d5f[_0xa0b5('0x24')](0x194);}return _0x577255;};}function handleError(_0x3d46c9,_0xc6e863){_0xc6e863=_0xc6e863||0x1f4;return function(_0x1f833b){logger[_0xa0b5('0x25')](_0x1f833b[_0xa0b5('0x26')]);if(_0x1f833b[_0xa0b5('0x27')]){delete _0x1f833b[_0xa0b5('0x27')];}_0x3d46c9[_0xa0b5('0x18')](_0xc6e863)[_0xa0b5('0x28')](_0x1f833b);};}exports[_0xa0b5('0x29')]=function(_0x8067cd,_0xfa7be5){var _0x200502={},_0x24aa17={},_0x9dbf45={'count':0x0,'rows':[]};var _0x3ed7f3=_[_0xa0b5('0x2a')](db[_0xa0b5('0x2b')][_0xa0b5('0x2c')],function(_0x557924){return{'name':_0x557924[_0xa0b5('0x2d')],'type':_0x557924['type'][_0xa0b5('0x2e')]};});_0x24aa17[_0xa0b5('0x2f')]=_[_0xa0b5('0x2a')](_0x3ed7f3,_0xa0b5('0x27'));_0x24aa17['query']=_['keys'](_0x8067cd[_0xa0b5('0x30')]);_0x24aa17[_0xa0b5('0x31')]=_[_0xa0b5('0x32')](_0x24aa17['model'],_0x24aa17[_0xa0b5('0x30')]);_0x200502[_0xa0b5('0x33')]=_['intersection'](_0x24aa17['model'],qs[_0xa0b5('0x34')](_0x8067cd[_0xa0b5('0x30')]['fields']));_0x200502[_0xa0b5('0x33')]=_0x200502[_0xa0b5('0x33')][_0xa0b5('0x35')]?_0x200502[_0xa0b5('0x33')]:_0x24aa17[_0xa0b5('0x2f')];if(!_0x8067cd[_0xa0b5('0x30')][_0xa0b5('0x36')]('nolimit')){_0x200502[_0xa0b5('0x1d')]=qs['limit'](_0x8067cd[_0xa0b5('0x30')][_0xa0b5('0x1d')]);_0x200502[_0xa0b5('0x1c')]=qs[_0xa0b5('0x1c')](_0x8067cd[_0xa0b5('0x30')]['offset']);}_0x200502['order']=qs[_0xa0b5('0x37')](_0x8067cd[_0xa0b5('0x30')][_0xa0b5('0x37')]);_0x200502[_0xa0b5('0x38')]=qs[_0xa0b5('0x31')](_['pick'](_0x8067cd[_0xa0b5('0x30')],_0x24aa17['filters']),_0x3ed7f3);if(_0x8067cd[_0xa0b5('0x30')][_0xa0b5('0x39')]){_0x200502[_0xa0b5('0x38')]=_[_0xa0b5('0x3a')](_0x200502['where'],{'$or':_[_0xa0b5('0x2a')](_0x3ed7f3,function(_0x31ba64){if(_0x31ba64[_0xa0b5('0x3b')]!==_0xa0b5('0x3c')){var _0xed9489={};_0xed9489[_0x31ba64[_0xa0b5('0x27')]]={'$like':'%'+_0x8067cd[_0xa0b5('0x30')][_0xa0b5('0x39')]+'%'};return _0xed9489;}})});}_0x200502=_['merge']({},_0x200502,_0x8067cd['options']);var _0x216617={'where':_0x200502[_0xa0b5('0x38')]};return db[_0xa0b5('0x2b')][_0xa0b5('0x1b')](_0x216617)[_0xa0b5('0x22')](function(_0x44ea90){_0x9dbf45[_0xa0b5('0x1b')]=_0x44ea90;if(_0x8067cd[_0xa0b5('0x30')][_0xa0b5('0x3d')]){_0x200502[_0xa0b5('0x3e')]=[{'all':!![]}];}return db[_0xa0b5('0x2b')][_0xa0b5('0x3f')](_0x200502);})[_0xa0b5('0x22')](function(_0x1c3658){_0x9dbf45['rows']=_0x1c3658;return _0x9dbf45;})[_0xa0b5('0x22')](respondWithFilteredResult(_0xfa7be5,_0x200502))[_0xa0b5('0x40')](handleError(_0xfa7be5,null));};exports[_0xa0b5('0x41')]=function(_0x29dd45,_0x284bfa){var _0x2b448b={'raw':![],'where':{'id':_0x29dd45['params']['id']}},_0x1bda03={};_0x1bda03[_0xa0b5('0x2f')]=_[_0xa0b5('0x42')](db[_0xa0b5('0x2b')]['rawAttributes']);_0x1bda03[_0xa0b5('0x30')]=_[_0xa0b5('0x42')](_0x29dd45['query']);_0x1bda03[_0xa0b5('0x31')]=_[_0xa0b5('0x32')](_0x1bda03[_0xa0b5('0x2f')],_0x1bda03[_0xa0b5('0x30')]);_0x2b448b['attributes']=_[_0xa0b5('0x32')](_0x1bda03[_0xa0b5('0x2f')],qs[_0xa0b5('0x34')](_0x29dd45[_0xa0b5('0x30')]['fields']));_0x2b448b['attributes']=_0x2b448b[_0xa0b5('0x33')][_0xa0b5('0x35')]?_0x2b448b[_0xa0b5('0x33')]:_0x1bda03[_0xa0b5('0x2f')];if(_0x29dd45[_0xa0b5('0x30')]['includeAll']){_0x2b448b[_0xa0b5('0x3e')]=[{'all':!![]}];}_0x2b448b=_[_0xa0b5('0x3a')]({},_0x2b448b,_0x29dd45[_0xa0b5('0x43')]);return db[_0xa0b5('0x2b')][_0xa0b5('0x44')](_0x2b448b)['then'](handleEntityNotFound(_0x284bfa,null))[_0xa0b5('0x22')](respondWithResult(_0x284bfa,null))['catch'](handleError(_0x284bfa,null));};exports[_0xa0b5('0x45')]=function(_0x49e38b,_0x132c9b){return db[_0xa0b5('0x2b')][_0xa0b5('0x45')](_0x49e38b['body'],{})['then'](respondWithResult(_0x132c9b,0xc9))[_0xa0b5('0x40')](handleError(_0x132c9b,null));};exports['update']=function(_0x515a51,_0x1bd47a){if(_0x515a51[_0xa0b5('0x46')]['id']){delete _0x515a51[_0xa0b5('0x46')]['id'];}return db[_0xa0b5('0x2b')]['find']({'where':{'id':_0x515a51['params']['id']}})[_0xa0b5('0x22')](handleEntityNotFound(_0x1bd47a,null))[_0xa0b5('0x22')](saveUpdates(_0x515a51[_0xa0b5('0x46')],null))[_0xa0b5('0x22')](respondWithResult(_0x1bd47a,null))['catch'](handleError(_0x1bd47a,null));};exports[_0xa0b5('0x23')]=function(_0x2c0c03,_0x459e7b){return db[_0xa0b5('0x2b')]['find']({'where':{'id':_0x2c0c03['params']['id']}})[_0xa0b5('0x22')](handleEntityNotFound(_0x459e7b,null))[_0xa0b5('0x22')](removeEntity(_0x459e7b,null))[_0xa0b5('0x40')](handleError(_0x459e7b,null));};exports[_0xa0b5('0x47')]=function(_0x4fa71f,_0x3f6552,_0x1a0f3d){var _0x2d2a28={};var _0x5e699f={};var _0x11d231;var _0x1e7b47;return db[_0xa0b5('0x2b')]['findOne']({'where':{'id':_0x4fa71f[_0xa0b5('0x48')]['id']}})['then'](handleEntityNotFound(_0x3f6552,null))['then'](function(_0x2b0d4d){if(_0x2b0d4d){_0x11d231=_0x2b0d4d;_0x5e699f[_0xa0b5('0x2f')]=_[_0xa0b5('0x42')](db[_0xa0b5('0x49')][_0xa0b5('0x2c')]);_0x5e699f[_0xa0b5('0x30')]=_[_0xa0b5('0x42')](_0x4fa71f[_0xa0b5('0x30')]);_0x5e699f[_0xa0b5('0x31')]=_[_0xa0b5('0x32')](_0x5e699f[_0xa0b5('0x2f')],_0x5e699f[_0xa0b5('0x30')]);_0x2d2a28[_0xa0b5('0x33')]=_[_0xa0b5('0x32')](_0x5e699f['model'],qs[_0xa0b5('0x34')](_0x4fa71f[_0xa0b5('0x30')][_0xa0b5('0x34')]));_0x2d2a28['attributes']=_0x2d2a28[_0xa0b5('0x33')]['length']?_0x2d2a28[_0xa0b5('0x33')]:_0x5e699f[_0xa0b5('0x2f')];_0x2d2a28[_0xa0b5('0x4a')]=qs[_0xa0b5('0x37')](_0x4fa71f[_0xa0b5('0x30')][_0xa0b5('0x37')]);_0x2d2a28[_0xa0b5('0x38')]=qs[_0xa0b5('0x31')](_[_0xa0b5('0x4b')](_0x4fa71f[_0xa0b5('0x30')],_0x5e699f[_0xa0b5('0x31')]));if(_0x4fa71f[_0xa0b5('0x30')][_0xa0b5('0x39')]){_0x2d2a28[_0xa0b5('0x38')]=_[_0xa0b5('0x3a')](_0x2d2a28[_0xa0b5('0x38')],{'$or':_['map'](_0x2d2a28[_0xa0b5('0x33')],function(_0x651582){var _0x75a552={};_0x75a552[_0x651582]={'$like':'%'+_0x4fa71f[_0xa0b5('0x30')][_0xa0b5('0x39')]+'%'};return _0x75a552;})});}_0x2d2a28=_['merge']({},_0x2d2a28,_0x4fa71f['options']);return _0x11d231[_0xa0b5('0x47')](_0x2d2a28);}})['then'](function(_0x4640e8){if(_0x4640e8){_0x1e7b47=_0x4640e8[_0xa0b5('0x35')];if(!_0x4fa71f[_0xa0b5('0x30')]['hasOwnProperty']('nolimit')){_0x2d2a28['limit']=qs['limit'](_0x4fa71f[_0xa0b5('0x30')][_0xa0b5('0x1d')]);_0x2d2a28[_0xa0b5('0x1c')]=qs[_0xa0b5('0x1c')](_0x4fa71f['query'][_0xa0b5('0x1c')]);}return _0x11d231[_0xa0b5('0x47')](_0x2d2a28);}})['then'](function(_0x2a2d6b){if(_0x2a2d6b){return _0x2a2d6b?{'count':_0x1e7b47,'rows':_0x2a2d6b}:null;}})[_0xa0b5('0x22')](respondWithResult(_0x3f6552,null))[_0xa0b5('0x40')](handleError(_0x3f6552,null));};exports['getDescriptions']=function(_0x277292,_0x3db9be,_0x178038){var _0x25833f={};var _0x4532e0={};var _0x4d8831;var _0x4ec198;return db[_0xa0b5('0x2b')][_0xa0b5('0x4c')]({'where':{'id':_0x277292[_0xa0b5('0x48')]['id']}})[_0xa0b5('0x22')](handleEntityNotFound(_0x3db9be,null))['then'](function(_0x3a1b30){if(_0x3a1b30){_0x4d8831=_0x3a1b30;_0x4532e0['model']=_[_0xa0b5('0x42')](db[_0xa0b5('0x49')]['rawAttributes']);_0x4532e0['query']=_[_0xa0b5('0x42')](_0x277292[_0xa0b5('0x30')]);_0x4532e0['filters']=_['intersection'](_0x4532e0[_0xa0b5('0x2f')],_0x4532e0['query']);_0x25833f[_0xa0b5('0x33')]=_[_0xa0b5('0x32')](_0x4532e0[_0xa0b5('0x2f')],qs['fields'](_0x277292['query'][_0xa0b5('0x34')]));_0x25833f[_0xa0b5('0x33')]=_0x25833f[_0xa0b5('0x33')]['length']?_0x25833f[_0xa0b5('0x33')]:_0x4532e0[_0xa0b5('0x2f')];_0x25833f[_0xa0b5('0x4a')]=qs[_0xa0b5('0x37')](_0x277292[_0xa0b5('0x30')]['sort']);_0x25833f['where']=qs[_0xa0b5('0x31')](_[_0xa0b5('0x4b')](_0x277292['query'],_0x4532e0[_0xa0b5('0x31')]));if(_0x277292[_0xa0b5('0x30')][_0xa0b5('0x39')]){_0x25833f[_0xa0b5('0x38')]=_[_0xa0b5('0x3a')](_0x25833f[_0xa0b5('0x38')],{'$or':_[_0xa0b5('0x2a')](_0x25833f[_0xa0b5('0x33')],function(_0x14091c){var _0x30bef9={};_0x30bef9[_0x14091c]={'$like':'%'+_0x277292[_0xa0b5('0x30')][_0xa0b5('0x39')]+'%'};return _0x30bef9;})});}_0x25833f=_[_0xa0b5('0x3a')]({},_0x25833f,_0x277292[_0xa0b5('0x43')]);return _0x4d8831['getDescriptions'](_0x25833f);}})[_0xa0b5('0x22')](function(_0x4e3285){if(_0x4e3285){_0x4ec198=_0x4e3285[_0xa0b5('0x35')];if(!_0x277292[_0xa0b5('0x30')][_0xa0b5('0x36')](_0xa0b5('0x4d'))){_0x25833f[_0xa0b5('0x1d')]=qs[_0xa0b5('0x1d')](_0x277292['query'][_0xa0b5('0x1d')]);_0x25833f[_0xa0b5('0x1c')]=qs[_0xa0b5('0x1c')](_0x277292[_0xa0b5('0x30')][_0xa0b5('0x1c')]);}return _0x4d8831[_0xa0b5('0x4e')](_0x25833f);}})[_0xa0b5('0x22')](function(_0x3eb75d){if(_0x3eb75d){return _0x3eb75d?{'count':_0x4ec198,'rows':_0x3eb75d}:null;}})[_0xa0b5('0x22')](respondWithResult(_0x3db9be,null))[_0xa0b5('0x40')](handleError(_0x3db9be,null));};exports['getFields']=function(_0x3e6140,_0x188ca9,_0x246018){var _0x349e76={};var _0x1cf994={};var _0x1baa69;var _0x46d16a;return db[_0xa0b5('0x2b')]['findOne']({'where':{'id':_0x3e6140[_0xa0b5('0x48')]['id']}})[_0xa0b5('0x22')](handleEntityNotFound(_0x188ca9,null))[_0xa0b5('0x22')](function(_0x354008){if(_0x354008){_0x1baa69=_0x354008;_0x1cf994[_0xa0b5('0x2f')]=_[_0xa0b5('0x42')](db[_0xa0b5('0x49')]['rawAttributes']);_0x1cf994['query']=_[_0xa0b5('0x42')](_0x3e6140[_0xa0b5('0x30')]);_0x1cf994[_0xa0b5('0x31')]=_['intersection'](_0x1cf994[_0xa0b5('0x2f')],_0x1cf994[_0xa0b5('0x30')]);_0x349e76[_0xa0b5('0x33')]=_[_0xa0b5('0x32')](_0x1cf994[_0xa0b5('0x2f')],qs[_0xa0b5('0x34')](_0x3e6140[_0xa0b5('0x30')]['fields']));_0x349e76['attributes']=_0x349e76[_0xa0b5('0x33')][_0xa0b5('0x35')]?_0x349e76[_0xa0b5('0x33')]:_0x1cf994[_0xa0b5('0x2f')];_0x349e76['order']=qs[_0xa0b5('0x37')](_0x3e6140[_0xa0b5('0x30')][_0xa0b5('0x37')]);_0x349e76[_0xa0b5('0x38')]=qs[_0xa0b5('0x31')](_[_0xa0b5('0x4b')](_0x3e6140[_0xa0b5('0x30')],_0x1cf994[_0xa0b5('0x31')]));if(_0x3e6140[_0xa0b5('0x30')][_0xa0b5('0x39')]){_0x349e76[_0xa0b5('0x38')]=_[_0xa0b5('0x3a')](_0x349e76[_0xa0b5('0x38')],{'$or':_['map'](_0x349e76[_0xa0b5('0x33')],function(_0x241d7){var _0x163732={};_0x163732[_0x241d7]={'$like':'%'+_0x3e6140[_0xa0b5('0x30')][_0xa0b5('0x39')]+'%'};return _0x163732;})});}_0x349e76=_[_0xa0b5('0x3a')]({},_0x349e76,_0x3e6140[_0xa0b5('0x43')]);return _0x1baa69['getFields'](_0x349e76);}})[_0xa0b5('0x22')](function(_0x1a052c){if(_0x1a052c){_0x46d16a=_0x1a052c[_0xa0b5('0x35')];if(!_0x3e6140[_0xa0b5('0x30')]['hasOwnProperty'](_0xa0b5('0x4d'))){_0x349e76[_0xa0b5('0x1d')]=qs[_0xa0b5('0x1d')](_0x3e6140[_0xa0b5('0x30')]['limit']);_0x349e76[_0xa0b5('0x1c')]=qs[_0xa0b5('0x1c')](_0x3e6140['query'][_0xa0b5('0x1c')]);}return _0x1baa69['getFields'](_0x349e76);}})[_0xa0b5('0x22')](function(_0x2374b7){if(_0x2374b7){return _0x2374b7?{'count':_0x46d16a,'rows':_0x2374b7}:null;}})[_0xa0b5('0x22')](respondWithResult(_0x188ca9,null))['catch'](handleError(_0x188ca9,null));};
\ No newline at end of file