Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index 8ff97d1..21c428d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8adc=['lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','status','end','offset','undefined','Content-Range','json','apply','reject','save','update','destroy','then','sendStatus','error','name','send','index','map','ZohoConfiguration','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','count','findAll','catch','params','rawAttributes','include','find','create','body','findOne','ZohoField','getFields','hasOwnProperty','getSubjects','getDescriptions','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','fs-extra'];(function(_0x8a969d,_0x339d9f){var _0x1d8dc7=function(_0x283ec0){while(--_0x283ec0){_0x8a969d['push'](_0x8a969d['shift']());}};_0x1d8dc7(++_0x339d9f);}(_0x8adc,0x137));var _0xc8ad=function(_0x160c73,_0x2ee678){_0x160c73=_0x160c73-0x0;var _0xd9302=_0x8adc[_0x160c73];return _0xd9302;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xc8ad('0x0'));var jsonpatch=require(_0xc8ad('0x1'));var rp=require(_0xc8ad('0x2'));var moment=require('moment');var BPromise=require(_0xc8ad('0x3'));var Mustache=require(_0xc8ad('0x4'));var util=require(_0xc8ad('0x5'));var path=require('path');var sox=require(_0xc8ad('0x6'));var csv=require(_0xc8ad('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xc8ad('0x8'));var _=require(_0xc8ad('0x9'));var squel=require(_0xc8ad('0xa'));var crypto=require(_0xc8ad('0xb'));var jsforce=require(_0xc8ad('0xc'));var deskjs=require(_0xc8ad('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xc8ad('0xe'));var Redis=require(_0xc8ad('0xf'));var authService=require(_0xc8ad('0x10'));var qs=require(_0xc8ad('0x11'));var as=require(_0xc8ad('0x12'));var hardwareService=require(_0xc8ad('0x13'));var logger=require(_0xc8ad('0x14'))(_0xc8ad('0x15'));var utils=require(_0xc8ad('0x16'));var config=require(_0xc8ad('0x17'));var licenseUtil=require(_0xc8ad('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1d5d77,_0x58a0b5){_0x58a0b5=_0x58a0b5||0xcc;return function(_0x14f80b){if(_0x14f80b){return _0x1d5d77['sendStatus'](_0x58a0b5);}return _0x1d5d77[_0xc8ad('0x19')](_0x58a0b5)[_0xc8ad('0x1a')]();};}function respondWithResult(_0x19009c,_0x5c5414){_0x5c5414=_0x5c5414||0xc8;return function(_0x1ccddd){if(_0x1ccddd){return _0x19009c[_0xc8ad('0x19')](_0x5c5414)['json'](_0x1ccddd);}};}function respondWithFilteredResult(_0x3f6500,_0x163bea){return function(_0x43eb12){if(_0x43eb12){var _0x276578=typeof _0x163bea[_0xc8ad('0x1b')]===_0xc8ad('0x1c')&&typeof _0x163bea['limit']==='undefined';var _0x442b49=_0x43eb12['count'];var _0x2ba72c=_0x276578?0x0:_0x163bea[_0xc8ad('0x1b')];var _0x4cee40=_0x276578?_0x43eb12['count']:_0x163bea[_0xc8ad('0x1b')]+_0x163bea['limit'];var _0x286581;if(_0x4cee40>=_0x442b49){_0x4cee40=_0x442b49;_0x286581=0xc8;}else{_0x286581=0xce;}_0x3f6500[_0xc8ad('0x19')](_0x286581);return _0x3f6500['set'](_0xc8ad('0x1d'),_0x2ba72c+'-'+_0x4cee40+'/'+_0x442b49)[_0xc8ad('0x1e')](_0x43eb12);}return null;};}function patchUpdates(_0x4b1a36){return function(_0x3b6d97){try{jsonpatch[_0xc8ad('0x1f')](_0x3b6d97,_0x4b1a36,!![]);}catch(_0x9e6796){return BPromise[_0xc8ad('0x20')](_0x9e6796);}return _0x3b6d97[_0xc8ad('0x21')]();};}function saveUpdates(_0x9e69b3,_0x594b5f){return function(_0x227294){if(_0x227294){return _0x227294[_0xc8ad('0x22')](_0x9e69b3)['then'](function(_0x332ce7){return _0x332ce7;});}return null;};}function removeEntity(_0x58a4fa,_0x1230ae){return function(_0x4d90a1){if(_0x4d90a1){return _0x4d90a1[_0xc8ad('0x23')]()[_0xc8ad('0x24')](function(){_0x58a4fa[_0xc8ad('0x19')](0xcc)[_0xc8ad('0x1a')]();});}};}function handleEntityNotFound(_0x3f1bae,_0x217263){return function(_0x281bbf){if(!_0x281bbf){_0x3f1bae[_0xc8ad('0x25')](0x194);}return _0x281bbf;};}function handleError(_0x32716f,_0xc89c89){_0xc89c89=_0xc89c89||0x1f4;return function(_0xca24a5){logger[_0xc8ad('0x26')](_0xca24a5['stack']);if(_0xca24a5['name']){delete _0xca24a5[_0xc8ad('0x27')];}_0x32716f[_0xc8ad('0x19')](_0xc89c89)[_0xc8ad('0x28')](_0xca24a5);};}exports[_0xc8ad('0x29')]=function(_0x11bde7,_0x4f529f){var _0x3268a8={},_0x2c303a={},_0x8d4085={'count':0x0,'rows':[]};var _0x18f911=_[_0xc8ad('0x2a')](db[_0xc8ad('0x2b')]['rawAttributes'],function(_0x27bdfc){return{'name':_0x27bdfc[_0xc8ad('0x2c')],'type':_0x27bdfc[_0xc8ad('0x2d')][_0xc8ad('0x2e')]};});_0x2c303a['model']=_['map'](_0x18f911,_0xc8ad('0x27'));_0x2c303a[_0xc8ad('0x2f')]=_[_0xc8ad('0x30')](_0x11bde7['query']);_0x2c303a[_0xc8ad('0x31')]=_[_0xc8ad('0x32')](_0x2c303a[_0xc8ad('0x33')],_0x2c303a['query']);_0x3268a8[_0xc8ad('0x34')]=_['intersection'](_0x2c303a[_0xc8ad('0x33')],qs[_0xc8ad('0x35')](_0x11bde7[_0xc8ad('0x2f')][_0xc8ad('0x35')]));_0x3268a8[_0xc8ad('0x34')]=_0x3268a8['attributes'][_0xc8ad('0x36')]?_0x3268a8[_0xc8ad('0x34')]:_0x2c303a[_0xc8ad('0x33')];if(!_0x11bde7[_0xc8ad('0x2f')]['hasOwnProperty'](_0xc8ad('0x37'))){_0x3268a8[_0xc8ad('0x38')]=qs['limit'](_0x11bde7[_0xc8ad('0x2f')][_0xc8ad('0x38')]);_0x3268a8[_0xc8ad('0x1b')]=qs[_0xc8ad('0x1b')](_0x11bde7[_0xc8ad('0x2f')][_0xc8ad('0x1b')]);}_0x3268a8[_0xc8ad('0x39')]=qs[_0xc8ad('0x3a')](_0x11bde7[_0xc8ad('0x2f')][_0xc8ad('0x3a')]);_0x3268a8[_0xc8ad('0x3b')]=qs[_0xc8ad('0x31')](_[_0xc8ad('0x3c')](_0x11bde7['query'],_0x2c303a[_0xc8ad('0x31')]),_0x18f911);if(_0x11bde7[_0xc8ad('0x2f')][_0xc8ad('0x3d')]){_0x3268a8[_0xc8ad('0x3b')]=_[_0xc8ad('0x3e')](_0x3268a8['where'],{'$or':_[_0xc8ad('0x2a')](_0x18f911,function(_0x427b9c){if(_0x427b9c[_0xc8ad('0x2d')]!==_0xc8ad('0x3f')){var _0x4fc2ac={};_0x4fc2ac[_0x427b9c[_0xc8ad('0x27')]]={'$like':'%'+_0x11bde7['query'][_0xc8ad('0x3d')]+'%'};return _0x4fc2ac;}})});}_0x3268a8=_[_0xc8ad('0x3e')]({},_0x3268a8,_0x11bde7[_0xc8ad('0x40')]);var _0x164975={'where':_0x3268a8[_0xc8ad('0x3b')]};return db[_0xc8ad('0x2b')]['count'](_0x164975)['then'](function(_0xbae210){_0x8d4085[_0xc8ad('0x41')]=_0xbae210;if(_0x11bde7[_0xc8ad('0x2f')]['includeAll']){_0x3268a8['include']=[{'all':!![]}];}return db[_0xc8ad('0x2b')][_0xc8ad('0x42')](_0x3268a8);})[_0xc8ad('0x24')](function(_0x3353b8){_0x8d4085['rows']=_0x3353b8;return _0x8d4085;})['then'](respondWithFilteredResult(_0x4f529f,_0x3268a8))[_0xc8ad('0x43')](handleError(_0x4f529f,null));};exports['show']=function(_0x2c11e7,_0x1191f5){var _0x3b7023={'raw':![],'where':{'id':_0x2c11e7[_0xc8ad('0x44')]['id']}},_0x5bb800={};_0x5bb800[_0xc8ad('0x33')]=_['keys'](db[_0xc8ad('0x2b')][_0xc8ad('0x45')]);_0x5bb800[_0xc8ad('0x2f')]=_[_0xc8ad('0x30')](_0x2c11e7[_0xc8ad('0x2f')]);_0x5bb800['filters']=_[_0xc8ad('0x32')](_0x5bb800['model'],_0x5bb800['query']);_0x3b7023[_0xc8ad('0x34')]=_['intersection'](_0x5bb800[_0xc8ad('0x33')],qs['fields'](_0x2c11e7[_0xc8ad('0x2f')][_0xc8ad('0x35')]));_0x3b7023[_0xc8ad('0x34')]=_0x3b7023[_0xc8ad('0x34')][_0xc8ad('0x36')]?_0x3b7023[_0xc8ad('0x34')]:_0x5bb800[_0xc8ad('0x33')];if(_0x2c11e7['query']['includeAll']){_0x3b7023[_0xc8ad('0x46')]=[{'all':!![]}];}_0x3b7023=_[_0xc8ad('0x3e')]({},_0x3b7023,_0x2c11e7[_0xc8ad('0x40')]);return db['ZohoConfiguration'][_0xc8ad('0x47')](_0x3b7023)['then'](handleEntityNotFound(_0x1191f5,null))['then'](respondWithResult(_0x1191f5,null))[_0xc8ad('0x43')](handleError(_0x1191f5,null));};exports[_0xc8ad('0x48')]=function(_0x13ae67,_0x53d0a8){return db['ZohoConfiguration'][_0xc8ad('0x48')](_0x13ae67[_0xc8ad('0x49')],{})[_0xc8ad('0x24')](respondWithResult(_0x53d0a8,0xc9))['catch'](handleError(_0x53d0a8,null));};exports[_0xc8ad('0x22')]=function(_0x480b22,_0x1543a3){if(_0x480b22[_0xc8ad('0x49')]['id']){delete _0x480b22[_0xc8ad('0x49')]['id'];}return db[_0xc8ad('0x2b')][_0xc8ad('0x47')]({'where':{'id':_0x480b22[_0xc8ad('0x44')]['id']}})[_0xc8ad('0x24')](handleEntityNotFound(_0x1543a3,null))[_0xc8ad('0x24')](saveUpdates(_0x480b22['body'],null))['then'](respondWithResult(_0x1543a3,null))[_0xc8ad('0x43')](handleError(_0x1543a3,null));};exports[_0xc8ad('0x23')]=function(_0x43864e,_0x222e67){return db[_0xc8ad('0x2b')]['find']({'where':{'id':_0x43864e[_0xc8ad('0x44')]['id']}})['then'](handleEntityNotFound(_0x222e67,null))['then'](removeEntity(_0x222e67,null))[_0xc8ad('0x43')](handleError(_0x222e67,null));};exports['getFields']=function(_0x561c9d,_0x385de8,_0x50753f){var _0x3369f2={};var _0x4c263a={};var _0x5d5c76;var _0x4841a1;return db[_0xc8ad('0x2b')][_0xc8ad('0x4a')]({'where':{'id':_0x561c9d[_0xc8ad('0x44')]['id']}})[_0xc8ad('0x24')](handleEntityNotFound(_0x385de8,null))[_0xc8ad('0x24')](function(_0x4029da){if(_0x4029da){_0x5d5c76=_0x4029da;_0x4c263a[_0xc8ad('0x33')]=_['keys'](db[_0xc8ad('0x4b')][_0xc8ad('0x45')]);_0x4c263a[_0xc8ad('0x2f')]=_['keys'](_0x561c9d['query']);_0x4c263a['filters']=_[_0xc8ad('0x32')](_0x4c263a[_0xc8ad('0x33')],_0x4c263a['query']);_0x3369f2[_0xc8ad('0x34')]=_[_0xc8ad('0x32')](_0x4c263a['model'],qs[_0xc8ad('0x35')](_0x561c9d[_0xc8ad('0x2f')][_0xc8ad('0x35')]));_0x3369f2[_0xc8ad('0x34')]=_0x3369f2[_0xc8ad('0x34')]['length']?_0x3369f2[_0xc8ad('0x34')]:_0x4c263a['model'];_0x3369f2[_0xc8ad('0x39')]=qs[_0xc8ad('0x3a')](_0x561c9d[_0xc8ad('0x2f')][_0xc8ad('0x3a')]);_0x3369f2[_0xc8ad('0x3b')]=qs['filters'](_[_0xc8ad('0x3c')](_0x561c9d[_0xc8ad('0x2f')],_0x4c263a[_0xc8ad('0x31')]));if(_0x561c9d[_0xc8ad('0x2f')][_0xc8ad('0x3d')]){_0x3369f2[_0xc8ad('0x3b')]=_[_0xc8ad('0x3e')](_0x3369f2[_0xc8ad('0x3b')],{'$or':_[_0xc8ad('0x2a')](_0x3369f2[_0xc8ad('0x34')],function(_0x5574c3){var _0xf93ebe={};_0xf93ebe[_0x5574c3]={'$like':'%'+_0x561c9d[_0xc8ad('0x2f')]['filter']+'%'};return _0xf93ebe;})});}_0x3369f2=_[_0xc8ad('0x3e')]({},_0x3369f2,_0x561c9d['options']);return _0x5d5c76[_0xc8ad('0x4c')](_0x3369f2);}})[_0xc8ad('0x24')](function(_0x33c9f5){if(_0x33c9f5){_0x4841a1=_0x33c9f5['length'];if(!_0x561c9d[_0xc8ad('0x2f')][_0xc8ad('0x4d')]('nolimit')){_0x3369f2[_0xc8ad('0x38')]=qs[_0xc8ad('0x38')](_0x561c9d[_0xc8ad('0x2f')][_0xc8ad('0x38')]);_0x3369f2[_0xc8ad('0x1b')]=qs[_0xc8ad('0x1b')](_0x561c9d[_0xc8ad('0x2f')][_0xc8ad('0x1b')]);}return _0x5d5c76['getFields'](_0x3369f2);}})[_0xc8ad('0x24')](function(_0x41a0f3){if(_0x41a0f3){return _0x41a0f3?{'count':_0x4841a1,'rows':_0x41a0f3}:null;}})[_0xc8ad('0x24')](respondWithResult(_0x385de8,null))['catch'](handleError(_0x385de8,null));};exports[_0xc8ad('0x4e')]=function(_0x4fcfa0,_0x44a2e7,_0x1a0a6c){var _0x306f1d={};var _0x5add83={};var _0x23fdc6;var _0x176bb2;return db['ZohoConfiguration']['findOne']({'where':{'id':_0x4fcfa0['params']['id']}})['then'](handleEntityNotFound(_0x44a2e7,null))['then'](function(_0x3209ad){if(_0x3209ad){_0x23fdc6=_0x3209ad;_0x5add83[_0xc8ad('0x33')]=_[_0xc8ad('0x30')](db['ZohoField'][_0xc8ad('0x45')]);_0x5add83['query']=_[_0xc8ad('0x30')](_0x4fcfa0[_0xc8ad('0x2f')]);_0x5add83[_0xc8ad('0x31')]=_['intersection'](_0x5add83[_0xc8ad('0x33')],_0x5add83['query']);_0x306f1d[_0xc8ad('0x34')]=_[_0xc8ad('0x32')](_0x5add83[_0xc8ad('0x33')],qs['fields'](_0x4fcfa0['query'][_0xc8ad('0x35')]));_0x306f1d[_0xc8ad('0x34')]=_0x306f1d[_0xc8ad('0x34')]['length']?_0x306f1d[_0xc8ad('0x34')]:_0x5add83[_0xc8ad('0x33')];_0x306f1d[_0xc8ad('0x39')]=qs[_0xc8ad('0x3a')](_0x4fcfa0[_0xc8ad('0x2f')][_0xc8ad('0x3a')]);_0x306f1d[_0xc8ad('0x3b')]=qs['filters'](_[_0xc8ad('0x3c')](_0x4fcfa0[_0xc8ad('0x2f')],_0x5add83['filters']));if(_0x4fcfa0['query'][_0xc8ad('0x3d')]){_0x306f1d[_0xc8ad('0x3b')]=_[_0xc8ad('0x3e')](_0x306f1d[_0xc8ad('0x3b')],{'$or':_[_0xc8ad('0x2a')](_0x306f1d[_0xc8ad('0x34')],function(_0x2e284a){var _0x405e1c={};_0x405e1c[_0x2e284a]={'$like':'%'+_0x4fcfa0[_0xc8ad('0x2f')]['filter']+'%'};return _0x405e1c;})});}_0x306f1d=_[_0xc8ad('0x3e')]({},_0x306f1d,_0x4fcfa0[_0xc8ad('0x40')]);return _0x23fdc6['getSubjects'](_0x306f1d);}})['then'](function(_0x3af3bf){if(_0x3af3bf){_0x176bb2=_0x3af3bf[_0xc8ad('0x36')];if(!_0x4fcfa0[_0xc8ad('0x2f')][_0xc8ad('0x4d')](_0xc8ad('0x37'))){_0x306f1d['limit']=qs[_0xc8ad('0x38')](_0x4fcfa0['query']['limit']);_0x306f1d[_0xc8ad('0x1b')]=qs['offset'](_0x4fcfa0[_0xc8ad('0x2f')][_0xc8ad('0x1b')]);}return _0x23fdc6[_0xc8ad('0x4e')](_0x306f1d);}})[_0xc8ad('0x24')](function(_0x480d2f){if(_0x480d2f){return _0x480d2f?{'count':_0x176bb2,'rows':_0x480d2f}:null;}})['then'](respondWithResult(_0x44a2e7,null))[_0xc8ad('0x43')](handleError(_0x44a2e7,null));};exports[_0xc8ad('0x4f')]=function(_0x332d0b,_0x34d25d,_0x33e2ad){var _0x3d4e9d={};var _0x52f3f4={};var _0x38a39b;var _0x2888ae;return db[_0xc8ad('0x2b')][_0xc8ad('0x4a')]({'where':{'id':_0x332d0b[_0xc8ad('0x44')]['id']}})[_0xc8ad('0x24')](handleEntityNotFound(_0x34d25d,null))[_0xc8ad('0x24')](function(_0x5b8bf0){if(_0x5b8bf0){_0x38a39b=_0x5b8bf0;_0x52f3f4[_0xc8ad('0x33')]=_[_0xc8ad('0x30')](db['ZohoField'][_0xc8ad('0x45')]);_0x52f3f4['query']=_['keys'](_0x332d0b[_0xc8ad('0x2f')]);_0x52f3f4[_0xc8ad('0x31')]=_[_0xc8ad('0x32')](_0x52f3f4[_0xc8ad('0x33')],_0x52f3f4[_0xc8ad('0x2f')]);_0x3d4e9d['attributes']=_[_0xc8ad('0x32')](_0x52f3f4[_0xc8ad('0x33')],qs[_0xc8ad('0x35')](_0x332d0b['query']['fields']));_0x3d4e9d[_0xc8ad('0x34')]=_0x3d4e9d['attributes'][_0xc8ad('0x36')]?_0x3d4e9d['attributes']:_0x52f3f4[_0xc8ad('0x33')];_0x3d4e9d['order']=qs['sort'](_0x332d0b[_0xc8ad('0x2f')][_0xc8ad('0x3a')]);_0x3d4e9d['where']=qs[_0xc8ad('0x31')](_['pick'](_0x332d0b['query'],_0x52f3f4['filters']));if(_0x332d0b[_0xc8ad('0x2f')][_0xc8ad('0x3d')]){_0x3d4e9d[_0xc8ad('0x3b')]=_['merge'](_0x3d4e9d['where'],{'$or':_[_0xc8ad('0x2a')](_0x3d4e9d[_0xc8ad('0x34')],function(_0x1f2f87){var _0x157f2a={};_0x157f2a[_0x1f2f87]={'$like':'%'+_0x332d0b['query']['filter']+'%'};return _0x157f2a;})});}_0x3d4e9d=_[_0xc8ad('0x3e')]({},_0x3d4e9d,_0x332d0b['options']);return _0x38a39b['getDescriptions'](_0x3d4e9d);}})[_0xc8ad('0x24')](function(_0x42e06c){if(_0x42e06c){_0x2888ae=_0x42e06c[_0xc8ad('0x36')];if(!_0x332d0b[_0xc8ad('0x2f')][_0xc8ad('0x4d')]('nolimit')){_0x3d4e9d['limit']=qs[_0xc8ad('0x38')](_0x332d0b[_0xc8ad('0x2f')][_0xc8ad('0x38')]);_0x3d4e9d[_0xc8ad('0x1b')]=qs[_0xc8ad('0x1b')](_0x332d0b['query']['offset']);}return _0x38a39b[_0xc8ad('0x4f')](_0x3d4e9d);}})[_0xc8ad('0x24')](function(_0x5cfa1c){if(_0x5cfa1c){return _0x5cfa1c?{'count':_0x2888ae,'rows':_0x5cfa1c}:null;}})[_0xc8ad('0x24')](respondWithResult(_0x34d25d,null))[_0xc8ad('0x43')](handleError(_0x34d25d,null));};
\ No newline at end of file
+var _0x3f19=['path','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','limit','count','set','apply','reject','save','update','destroy','error','stack','name','send','index','map','ZohoConfiguration','fieldName','type','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','VIRTUAL','filter','merge','options','then','include','findAll','rows','catch','show','params','rawAttributes','keys','length','includeAll','find','create','body','getFields','findOne','ZohoField','getSubjects','getDescriptions','eml-format','zip-dir','fast-json-patch','bluebird'];(function(_0x56a494,_0x2117fc){var _0x51fab2=function(_0x2c3c8f){while(--_0x2c3c8f){_0x56a494['push'](_0x56a494['shift']());}};_0x51fab2(++_0x2117fc);}(_0x3f19,0x182));var _0x93f1=function(_0x4aca28,_0x4ab42c){_0x4aca28=_0x4aca28-0x0;var _0x1946a0=_0x3f19[_0x4aca28];return _0x1946a0;};'use strict';var emlformat=require(_0x93f1('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x93f1('0x1'));var jsonpatch=require(_0x93f1('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x93f1('0x3'));var Mustache=require('mustache');var util=require('util');var path=require(_0x93f1('0x4'));var sox=require('sox');var csv=require(_0x93f1('0x5'));var ejs=require(_0x93f1('0x6'));var fs=require('fs');var fs_extra=require(_0x93f1('0x7'));var _=require(_0x93f1('0x8'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x93f1('0x9'));var deskjs=require(_0x93f1('0xa'));var toCsv=require(_0x93f1('0x5'));var querystring=require(_0x93f1('0xb'));var Papa=require(_0x93f1('0xc'));var Redis=require('ioredis');var authService=require(_0x93f1('0xd'));var qs=require(_0x93f1('0xe'));var as=require(_0x93f1('0xf'));var hardwareService=require(_0x93f1('0x10'));var logger=require(_0x93f1('0x11'))(_0x93f1('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x93f1('0x13'));var db=require(_0x93f1('0x14'))['db'];function respondWithStatusCode(_0xd80cfe,_0x559668){_0x559668=_0x559668||0xcc;return function(_0x29b60b){if(_0x29b60b){return _0xd80cfe['sendStatus'](_0x559668);}return _0xd80cfe[_0x93f1('0x15')](_0x559668)[_0x93f1('0x16')]();};}function respondWithResult(_0x3a00f0,_0x2f4bda){_0x2f4bda=_0x2f4bda||0xc8;return function(_0x9e4764){if(_0x9e4764){return _0x3a00f0[_0x93f1('0x15')](_0x2f4bda)[_0x93f1('0x17')](_0x9e4764);}};}function respondWithFilteredResult(_0x4e232e,_0x32de22){return function(_0x10e2f4){if(_0x10e2f4){var _0x5e82d8=typeof _0x32de22[_0x93f1('0x18')]===_0x93f1('0x19')&&typeof _0x32de22[_0x93f1('0x1a')]===_0x93f1('0x19');var _0x1c8450=_0x10e2f4[_0x93f1('0x1b')];var _0x5d1b77=_0x5e82d8?0x0:_0x32de22[_0x93f1('0x18')];var _0x1ed11e=_0x5e82d8?_0x10e2f4[_0x93f1('0x1b')]:_0x32de22['offset']+_0x32de22[_0x93f1('0x1a')];var _0x362a28;if(_0x1ed11e>=_0x1c8450){_0x1ed11e=_0x1c8450;_0x362a28=0xc8;}else{_0x362a28=0xce;}_0x4e232e[_0x93f1('0x15')](_0x362a28);return _0x4e232e[_0x93f1('0x1c')]('Content-Range',_0x5d1b77+'-'+_0x1ed11e+'/'+_0x1c8450)[_0x93f1('0x17')](_0x10e2f4);}return null;};}function patchUpdates(_0x4f7edc){return function(_0x4934a3){try{jsonpatch[_0x93f1('0x1d')](_0x4934a3,_0x4f7edc,!![]);}catch(_0xc99f30){return BPromise[_0x93f1('0x1e')](_0xc99f30);}return _0x4934a3[_0x93f1('0x1f')]();};}function saveUpdates(_0x1877d5,_0x4ad68a){return function(_0x19a650){if(_0x19a650){return _0x19a650[_0x93f1('0x20')](_0x1877d5)['then'](function(_0x9367e8){return _0x9367e8;});}return null;};}function removeEntity(_0xb07f18,_0x5329f9){return function(_0x1aadb7){if(_0x1aadb7){return _0x1aadb7[_0x93f1('0x21')]()['then'](function(){_0xb07f18[_0x93f1('0x15')](0xcc)['end']();});}};}function handleEntityNotFound(_0x47ebb8,_0xd8de6f){return function(_0x4f3d01){if(!_0x4f3d01){_0x47ebb8['sendStatus'](0x194);}return _0x4f3d01;};}function handleError(_0x248a83,_0x97f532){_0x97f532=_0x97f532||0x1f4;return function(_0x37cdf0){logger[_0x93f1('0x22')](_0x37cdf0[_0x93f1('0x23')]);if(_0x37cdf0['name']){delete _0x37cdf0[_0x93f1('0x24')];}_0x248a83[_0x93f1('0x15')](_0x97f532)[_0x93f1('0x25')](_0x37cdf0);};}exports[_0x93f1('0x26')]=function(_0x4cd947,_0x591270){var _0x4e6257={},_0x1ea982={},_0x309cfa={'count':0x0,'rows':[]};var _0x14980e=_[_0x93f1('0x27')](db[_0x93f1('0x28')]['rawAttributes'],function(_0x21038c){return{'name':_0x21038c[_0x93f1('0x29')],'type':_0x21038c[_0x93f1('0x2a')]['key']};});_0x1ea982['model']=_[_0x93f1('0x27')](_0x14980e,_0x93f1('0x24'));_0x1ea982[_0x93f1('0x2b')]=_['keys'](_0x4cd947[_0x93f1('0x2b')]);_0x1ea982[_0x93f1('0x2c')]=_[_0x93f1('0x2d')](_0x1ea982[_0x93f1('0x2e')],_0x1ea982['query']);_0x4e6257[_0x93f1('0x2f')]=_['intersection'](_0x1ea982['model'],qs['fields'](_0x4cd947[_0x93f1('0x2b')][_0x93f1('0x30')]));_0x4e6257['attributes']=_0x4e6257[_0x93f1('0x2f')]['length']?_0x4e6257[_0x93f1('0x2f')]:_0x1ea982[_0x93f1('0x2e')];if(!_0x4cd947[_0x93f1('0x2b')][_0x93f1('0x31')](_0x93f1('0x32'))){_0x4e6257['limit']=qs[_0x93f1('0x1a')](_0x4cd947['query'][_0x93f1('0x1a')]);_0x4e6257[_0x93f1('0x18')]=qs['offset'](_0x4cd947['query'][_0x93f1('0x18')]);}_0x4e6257[_0x93f1('0x33')]=qs[_0x93f1('0x34')](_0x4cd947[_0x93f1('0x2b')][_0x93f1('0x34')]);_0x4e6257[_0x93f1('0x35')]=qs[_0x93f1('0x2c')](_[_0x93f1('0x36')](_0x4cd947['query'],_0x1ea982['filters']),_0x14980e);if(_0x4cd947[_0x93f1('0x2b')]['filter']){_0x4e6257[_0x93f1('0x35')]=_['merge'](_0x4e6257[_0x93f1('0x35')],{'$or':_[_0x93f1('0x27')](_0x14980e,function(_0x15ca4e){if(_0x15ca4e[_0x93f1('0x2a')]!==_0x93f1('0x37')){var _0x1909fe={};_0x1909fe[_0x15ca4e[_0x93f1('0x24')]]={'$like':'%'+_0x4cd947['query'][_0x93f1('0x38')]+'%'};return _0x1909fe;}})});}_0x4e6257=_[_0x93f1('0x39')]({},_0x4e6257,_0x4cd947[_0x93f1('0x3a')]);var _0x233f96={'where':_0x4e6257[_0x93f1('0x35')]};return db[_0x93f1('0x28')][_0x93f1('0x1b')](_0x233f96)[_0x93f1('0x3b')](function(_0x250947){_0x309cfa['count']=_0x250947;if(_0x4cd947[_0x93f1('0x2b')]['includeAll']){_0x4e6257[_0x93f1('0x3c')]=[{'all':!![]}];}return db['ZohoConfiguration'][_0x93f1('0x3d')](_0x4e6257);})[_0x93f1('0x3b')](function(_0x5912e2){_0x309cfa[_0x93f1('0x3e')]=_0x5912e2;return _0x309cfa;})['then'](respondWithFilteredResult(_0x591270,_0x4e6257))[_0x93f1('0x3f')](handleError(_0x591270,null));};exports[_0x93f1('0x40')]=function(_0x18bc4a,_0xdf40b0){var _0x59d863={'raw':![],'where':{'id':_0x18bc4a[_0x93f1('0x41')]['id']}},_0x34a1d8={};_0x34a1d8[_0x93f1('0x2e')]=_['keys'](db[_0x93f1('0x28')][_0x93f1('0x42')]);_0x34a1d8[_0x93f1('0x2b')]=_[_0x93f1('0x43')](_0x18bc4a[_0x93f1('0x2b')]);_0x34a1d8[_0x93f1('0x2c')]=_[_0x93f1('0x2d')](_0x34a1d8['model'],_0x34a1d8[_0x93f1('0x2b')]);_0x59d863[_0x93f1('0x2f')]=_[_0x93f1('0x2d')](_0x34a1d8[_0x93f1('0x2e')],qs[_0x93f1('0x30')](_0x18bc4a[_0x93f1('0x2b')]['fields']));_0x59d863[_0x93f1('0x2f')]=_0x59d863[_0x93f1('0x2f')][_0x93f1('0x44')]?_0x59d863[_0x93f1('0x2f')]:_0x34a1d8[_0x93f1('0x2e')];if(_0x18bc4a[_0x93f1('0x2b')][_0x93f1('0x45')]){_0x59d863[_0x93f1('0x3c')]=[{'all':!![]}];}_0x59d863=_['merge']({},_0x59d863,_0x18bc4a[_0x93f1('0x3a')]);return db[_0x93f1('0x28')][_0x93f1('0x46')](_0x59d863)[_0x93f1('0x3b')](handleEntityNotFound(_0xdf40b0,null))['then'](respondWithResult(_0xdf40b0,null))['catch'](handleError(_0xdf40b0,null));};exports[_0x93f1('0x47')]=function(_0x791bc1,_0x473cfc){return db[_0x93f1('0x28')][_0x93f1('0x47')](_0x791bc1[_0x93f1('0x48')],{})[_0x93f1('0x3b')](respondWithResult(_0x473cfc,0xc9))[_0x93f1('0x3f')](handleError(_0x473cfc,null));};exports[_0x93f1('0x20')]=function(_0x1866b7,_0x5ac052){if(_0x1866b7[_0x93f1('0x48')]['id']){delete _0x1866b7[_0x93f1('0x48')]['id'];}return db[_0x93f1('0x28')][_0x93f1('0x46')]({'where':{'id':_0x1866b7[_0x93f1('0x41')]['id']}})[_0x93f1('0x3b')](handleEntityNotFound(_0x5ac052,null))[_0x93f1('0x3b')](saveUpdates(_0x1866b7[_0x93f1('0x48')],null))[_0x93f1('0x3b')](respondWithResult(_0x5ac052,null))[_0x93f1('0x3f')](handleError(_0x5ac052,null));};exports[_0x93f1('0x21')]=function(_0x11f93b,_0x2db81c){return db['ZohoConfiguration'][_0x93f1('0x46')]({'where':{'id':_0x11f93b['params']['id']}})[_0x93f1('0x3b')](handleEntityNotFound(_0x2db81c,null))[_0x93f1('0x3b')](removeEntity(_0x2db81c,null))[_0x93f1('0x3f')](handleError(_0x2db81c,null));};exports[_0x93f1('0x49')]=function(_0x3bd452,_0x348dc1,_0x291c1c){var _0x4761b2={};var _0x500a9c={};var _0x282e50;var _0xa38b81;return db[_0x93f1('0x28')][_0x93f1('0x4a')]({'where':{'id':_0x3bd452[_0x93f1('0x41')]['id']}})[_0x93f1('0x3b')](handleEntityNotFound(_0x348dc1,null))[_0x93f1('0x3b')](function(_0xe9e6bd){if(_0xe9e6bd){_0x282e50=_0xe9e6bd;_0x500a9c[_0x93f1('0x2e')]=_[_0x93f1('0x43')](db[_0x93f1('0x4b')]['rawAttributes']);_0x500a9c[_0x93f1('0x2b')]=_[_0x93f1('0x43')](_0x3bd452[_0x93f1('0x2b')]);_0x500a9c['filters']=_[_0x93f1('0x2d')](_0x500a9c[_0x93f1('0x2e')],_0x500a9c[_0x93f1('0x2b')]);_0x4761b2[_0x93f1('0x2f')]=_[_0x93f1('0x2d')](_0x500a9c[_0x93f1('0x2e')],qs[_0x93f1('0x30')](_0x3bd452['query'][_0x93f1('0x30')]));_0x4761b2[_0x93f1('0x2f')]=_0x4761b2[_0x93f1('0x2f')][_0x93f1('0x44')]?_0x4761b2['attributes']:_0x500a9c[_0x93f1('0x2e')];_0x4761b2[_0x93f1('0x33')]=qs[_0x93f1('0x34')](_0x3bd452[_0x93f1('0x2b')][_0x93f1('0x34')]);_0x4761b2[_0x93f1('0x35')]=qs[_0x93f1('0x2c')](_['pick'](_0x3bd452[_0x93f1('0x2b')],_0x500a9c[_0x93f1('0x2c')]));if(_0x3bd452[_0x93f1('0x2b')][_0x93f1('0x38')]){_0x4761b2[_0x93f1('0x35')]=_[_0x93f1('0x39')](_0x4761b2[_0x93f1('0x35')],{'$or':_[_0x93f1('0x27')](_0x4761b2[_0x93f1('0x2f')],function(_0xea8180){var _0x525d7f={};_0x525d7f[_0xea8180]={'$like':'%'+_0x3bd452['query'][_0x93f1('0x38')]+'%'};return _0x525d7f;})});}_0x4761b2=_[_0x93f1('0x39')]({},_0x4761b2,_0x3bd452[_0x93f1('0x3a')]);return _0x282e50[_0x93f1('0x49')](_0x4761b2);}})[_0x93f1('0x3b')](function(_0x12285d){if(_0x12285d){_0xa38b81=_0x12285d['length'];if(!_0x3bd452[_0x93f1('0x2b')][_0x93f1('0x31')]('nolimit')){_0x4761b2[_0x93f1('0x1a')]=qs[_0x93f1('0x1a')](_0x3bd452[_0x93f1('0x2b')][_0x93f1('0x1a')]);_0x4761b2[_0x93f1('0x18')]=qs[_0x93f1('0x18')](_0x3bd452[_0x93f1('0x2b')][_0x93f1('0x18')]);}return _0x282e50['getFields'](_0x4761b2);}})[_0x93f1('0x3b')](function(_0xc47301){if(_0xc47301){return _0xc47301?{'count':_0xa38b81,'rows':_0xc47301}:null;}})[_0x93f1('0x3b')](respondWithResult(_0x348dc1,null))[_0x93f1('0x3f')](handleError(_0x348dc1,null));};exports[_0x93f1('0x4c')]=function(_0x47ee7d,_0x4b8ef3,_0x569a93){var _0x58c47c={};var _0x2e344a={};var _0x4a2e68;var _0x3ed05c;return db['ZohoConfiguration'][_0x93f1('0x4a')]({'where':{'id':_0x47ee7d['params']['id']}})[_0x93f1('0x3b')](handleEntityNotFound(_0x4b8ef3,null))[_0x93f1('0x3b')](function(_0x40a377){if(_0x40a377){_0x4a2e68=_0x40a377;_0x2e344a['model']=_['keys'](db['ZohoField'][_0x93f1('0x42')]);_0x2e344a[_0x93f1('0x2b')]=_[_0x93f1('0x43')](_0x47ee7d['query']);_0x2e344a[_0x93f1('0x2c')]=_['intersection'](_0x2e344a[_0x93f1('0x2e')],_0x2e344a[_0x93f1('0x2b')]);_0x58c47c[_0x93f1('0x2f')]=_[_0x93f1('0x2d')](_0x2e344a[_0x93f1('0x2e')],qs[_0x93f1('0x30')](_0x47ee7d[_0x93f1('0x2b')][_0x93f1('0x30')]));_0x58c47c['attributes']=_0x58c47c['attributes'][_0x93f1('0x44')]?_0x58c47c[_0x93f1('0x2f')]:_0x2e344a[_0x93f1('0x2e')];_0x58c47c['order']=qs[_0x93f1('0x34')](_0x47ee7d[_0x93f1('0x2b')][_0x93f1('0x34')]);_0x58c47c[_0x93f1('0x35')]=qs[_0x93f1('0x2c')](_[_0x93f1('0x36')](_0x47ee7d[_0x93f1('0x2b')],_0x2e344a[_0x93f1('0x2c')]));if(_0x47ee7d[_0x93f1('0x2b')][_0x93f1('0x38')]){_0x58c47c[_0x93f1('0x35')]=_[_0x93f1('0x39')](_0x58c47c[_0x93f1('0x35')],{'$or':_[_0x93f1('0x27')](_0x58c47c[_0x93f1('0x2f')],function(_0x573fe6){var _0x3f16ae={};_0x3f16ae[_0x573fe6]={'$like':'%'+_0x47ee7d[_0x93f1('0x2b')][_0x93f1('0x38')]+'%'};return _0x3f16ae;})});}_0x58c47c=_[_0x93f1('0x39')]({},_0x58c47c,_0x47ee7d[_0x93f1('0x3a')]);return _0x4a2e68['getSubjects'](_0x58c47c);}})[_0x93f1('0x3b')](function(_0x57ad5f){if(_0x57ad5f){_0x3ed05c=_0x57ad5f[_0x93f1('0x44')];if(!_0x47ee7d['query'][_0x93f1('0x31')](_0x93f1('0x32'))){_0x58c47c[_0x93f1('0x1a')]=qs[_0x93f1('0x1a')](_0x47ee7d[_0x93f1('0x2b')][_0x93f1('0x1a')]);_0x58c47c[_0x93f1('0x18')]=qs[_0x93f1('0x18')](_0x47ee7d[_0x93f1('0x2b')][_0x93f1('0x18')]);}return _0x4a2e68['getSubjects'](_0x58c47c);}})[_0x93f1('0x3b')](function(_0x5dbcd0){if(_0x5dbcd0){return _0x5dbcd0?{'count':_0x3ed05c,'rows':_0x5dbcd0}:null;}})['then'](respondWithResult(_0x4b8ef3,null))['catch'](handleError(_0x4b8ef3,null));};exports[_0x93f1('0x4d')]=function(_0x4233ae,_0x2afc59,_0x501b83){var _0x501d08={};var _0x44b1e1={};var _0x2e24dd;var _0x4f2ab4;return db['ZohoConfiguration'][_0x93f1('0x4a')]({'where':{'id':_0x4233ae['params']['id']}})[_0x93f1('0x3b')](handleEntityNotFound(_0x2afc59,null))[_0x93f1('0x3b')](function(_0x2a85da){if(_0x2a85da){_0x2e24dd=_0x2a85da;_0x44b1e1[_0x93f1('0x2e')]=_[_0x93f1('0x43')](db['ZohoField']['rawAttributes']);_0x44b1e1[_0x93f1('0x2b')]=_[_0x93f1('0x43')](_0x4233ae[_0x93f1('0x2b')]);_0x44b1e1['filters']=_[_0x93f1('0x2d')](_0x44b1e1['model'],_0x44b1e1[_0x93f1('0x2b')]);_0x501d08[_0x93f1('0x2f')]=_[_0x93f1('0x2d')](_0x44b1e1[_0x93f1('0x2e')],qs[_0x93f1('0x30')](_0x4233ae[_0x93f1('0x2b')][_0x93f1('0x30')]));_0x501d08[_0x93f1('0x2f')]=_0x501d08[_0x93f1('0x2f')][_0x93f1('0x44')]?_0x501d08[_0x93f1('0x2f')]:_0x44b1e1[_0x93f1('0x2e')];_0x501d08[_0x93f1('0x33')]=qs['sort'](_0x4233ae[_0x93f1('0x2b')][_0x93f1('0x34')]);_0x501d08[_0x93f1('0x35')]=qs[_0x93f1('0x2c')](_[_0x93f1('0x36')](_0x4233ae[_0x93f1('0x2b')],_0x44b1e1[_0x93f1('0x2c')]));if(_0x4233ae[_0x93f1('0x2b')][_0x93f1('0x38')]){_0x501d08[_0x93f1('0x35')]=_[_0x93f1('0x39')](_0x501d08[_0x93f1('0x35')],{'$or':_[_0x93f1('0x27')](_0x501d08[_0x93f1('0x2f')],function(_0x36cde2){var _0x40ce11={};_0x40ce11[_0x36cde2]={'$like':'%'+_0x4233ae[_0x93f1('0x2b')][_0x93f1('0x38')]+'%'};return _0x40ce11;})});}_0x501d08=_[_0x93f1('0x39')]({},_0x501d08,_0x4233ae[_0x93f1('0x3a')]);return _0x2e24dd[_0x93f1('0x4d')](_0x501d08);}})[_0x93f1('0x3b')](function(_0x4f0c7a){if(_0x4f0c7a){_0x4f2ab4=_0x4f0c7a[_0x93f1('0x44')];if(!_0x4233ae['query'][_0x93f1('0x31')](_0x93f1('0x32'))){_0x501d08[_0x93f1('0x1a')]=qs[_0x93f1('0x1a')](_0x4233ae[_0x93f1('0x2b')]['limit']);_0x501d08[_0x93f1('0x18')]=qs['offset'](_0x4233ae['query']['offset']);}return _0x2e24dd[_0x93f1('0x4d')](_0x501d08);}})[_0x93f1('0x3b')](function(_0x347f78){if(_0x347f78){return _0x347f78?{'count':_0x4f2ab4,'rows':_0x347f78}:null;}})[_0x93f1('0x3b')](respondWithResult(_0x2afc59,null))[_0x93f1('0x3f')](handleError(_0x2afc59,null));};
\ No newline at end of file