Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index c5e2d5c..a2ab9d7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb816=['sendStatus','end','status','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','destroy','error','name','send','index','map','ZohoConfiguration','rawAttributes','fieldName','key','model','keys','query','filters','intersection','attributes','fields','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','include','rows','show','params','length','find','catch','create','body','getFields','ZohoField','hasOwnProperty','nolimit','getSubjects','getDescriptions','findOne','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb'];(function(_0x43506e,_0x671bd7){var _0x88dd16=function(_0x4b243e){while(--_0x4b243e){_0x43506e['push'](_0x43506e['shift']());}};_0x88dd16(++_0x671bd7);}(_0xb816,0x8d));var _0x6b81=function(_0x235a56,_0x1acc78){_0x235a56=_0x235a56-0x0;var _0x59d2f2=_0xb816[_0x235a56];return _0x59d2f2;};'use strict';var emlformat=require(_0x6b81('0x0'));var rimraf=require(_0x6b81('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6b81('0x2'));var rp=require(_0x6b81('0x3'));var moment=require(_0x6b81('0x4'));var BPromise=require(_0x6b81('0x5'));var Mustache=require(_0x6b81('0x6'));var util=require(_0x6b81('0x7'));var path=require(_0x6b81('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x6b81('0x9'));var fs=require('fs');var fs_extra=require(_0x6b81('0xa'));var _=require(_0x6b81('0xb'));var squel=require('squel');var crypto=require(_0x6b81('0xc'));var jsforce=require(_0x6b81('0xd'));var deskjs=require(_0x6b81('0xe'));var toCsv=require(_0x6b81('0xf'));var querystring=require(_0x6b81('0x10'));var Papa=require('papaparse');var Redis=require(_0x6b81('0x11'));var authService=require(_0x6b81('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x6b81('0x13'));var hardwareService=require(_0x6b81('0x14'));var logger=require(_0x6b81('0x15'))(_0x6b81('0x16'));var utils=require(_0x6b81('0x17'));var config=require(_0x6b81('0x18'));var licenseUtil=require(_0x6b81('0x19'));var db=require(_0x6b81('0x1a'))['db'];function respondWithStatusCode(_0x20753d,_0x577f21){_0x577f21=_0x577f21||0xcc;return function(_0x1f61cb){if(_0x1f61cb){return _0x20753d[_0x6b81('0x1b')](_0x577f21);}return _0x20753d['status'](_0x577f21)[_0x6b81('0x1c')]();};}function respondWithResult(_0x24cbf3,_0x48ecd3){_0x48ecd3=_0x48ecd3||0xc8;return function(_0x1b20b3){if(_0x1b20b3){return _0x24cbf3[_0x6b81('0x1d')](_0x48ecd3)[_0x6b81('0x1e')](_0x1b20b3);}};}function respondWithFilteredResult(_0x3f65f9,_0x1205c8){return function(_0x2655ac){if(_0x2655ac){var _0x187003=typeof _0x1205c8[_0x6b81('0x1f')]===_0x6b81('0x20')&&typeof _0x1205c8[_0x6b81('0x21')]===_0x6b81('0x20');var _0xe72cf8=_0x2655ac[_0x6b81('0x22')];var _0x207be2=_0x187003?0x0:_0x1205c8[_0x6b81('0x1f')];var _0x2d16dd=_0x187003?_0x2655ac[_0x6b81('0x22')]:_0x1205c8[_0x6b81('0x1f')]+_0x1205c8[_0x6b81('0x21')];var _0x2e0d3e;if(_0x2d16dd>=_0xe72cf8){_0x2d16dd=_0xe72cf8;_0x2e0d3e=0xc8;}else{_0x2e0d3e=0xce;}_0x3f65f9[_0x6b81('0x1d')](_0x2e0d3e);return _0x3f65f9['set'](_0x6b81('0x23'),_0x207be2+'-'+_0x2d16dd+'/'+_0xe72cf8)[_0x6b81('0x1e')](_0x2655ac);}return null;};}function patchUpdates(_0x1ab16b){return function(_0x43ea30){try{jsonpatch[_0x6b81('0x24')](_0x43ea30,_0x1ab16b,!![]);}catch(_0x5a421d){return BPromise[_0x6b81('0x25')](_0x5a421d);}return _0x43ea30[_0x6b81('0x26')]();};}function saveUpdates(_0x3a3c53,_0x5f11d6){return function(_0x371926){if(_0x371926){return _0x371926[_0x6b81('0x27')](_0x3a3c53)[_0x6b81('0x28')](function(_0x4c978d){return _0x4c978d;});}return null;};}function removeEntity(_0x6dcea3,_0x1f11cf){return function(_0x1df35c){if(_0x1df35c){return _0x1df35c[_0x6b81('0x29')]()['then'](function(){_0x6dcea3[_0x6b81('0x1d')](0xcc)[_0x6b81('0x1c')]();});}};}function handleEntityNotFound(_0x3e83a8,_0x28404d){return function(_0x20c763){if(!_0x20c763){_0x3e83a8[_0x6b81('0x1b')](0x194);}return _0x20c763;};}function handleError(_0x120111,_0x5398de){_0x5398de=_0x5398de||0x1f4;return function(_0x371649){logger[_0x6b81('0x2a')](_0x371649['stack']);if(_0x371649[_0x6b81('0x2b')]){delete _0x371649[_0x6b81('0x2b')];}_0x120111[_0x6b81('0x1d')](_0x5398de)[_0x6b81('0x2c')](_0x371649);};}exports[_0x6b81('0x2d')]=function(_0x5571cf,_0x5035b9){var _0x40175a={},_0x44664e={},_0x59c3b2={'count':0x0,'rows':[]};var _0x2adbaf=_[_0x6b81('0x2e')](db[_0x6b81('0x2f')][_0x6b81('0x30')],function(_0x1a0270){return{'name':_0x1a0270[_0x6b81('0x31')],'type':_0x1a0270['type'][_0x6b81('0x32')]};});_0x44664e[_0x6b81('0x33')]=_[_0x6b81('0x2e')](_0x2adbaf,_0x6b81('0x2b'));_0x44664e['query']=_[_0x6b81('0x34')](_0x5571cf[_0x6b81('0x35')]);_0x44664e[_0x6b81('0x36')]=_[_0x6b81('0x37')](_0x44664e['model'],_0x44664e['query']);_0x40175a[_0x6b81('0x38')]=_[_0x6b81('0x37')](_0x44664e['model'],qs[_0x6b81('0x39')](_0x5571cf[_0x6b81('0x35')]['fields']));_0x40175a[_0x6b81('0x38')]=_0x40175a['attributes']['length']?_0x40175a[_0x6b81('0x38')]:_0x44664e[_0x6b81('0x33')];if(!_0x5571cf['query']['hasOwnProperty']('nolimit')){_0x40175a[_0x6b81('0x21')]=qs['limit'](_0x5571cf[_0x6b81('0x35')][_0x6b81('0x21')]);_0x40175a[_0x6b81('0x1f')]=qs[_0x6b81('0x1f')](_0x5571cf['query'][_0x6b81('0x1f')]);}_0x40175a[_0x6b81('0x3a')]=qs[_0x6b81('0x3b')](_0x5571cf[_0x6b81('0x35')]['sort']);_0x40175a[_0x6b81('0x3c')]=qs[_0x6b81('0x36')](_[_0x6b81('0x3d')](_0x5571cf[_0x6b81('0x35')],_0x44664e[_0x6b81('0x36')]),_0x2adbaf);if(_0x5571cf[_0x6b81('0x35')][_0x6b81('0x3e')]){_0x40175a[_0x6b81('0x3c')]=_[_0x6b81('0x3f')](_0x40175a[_0x6b81('0x3c')],{'$or':_['map'](_0x2adbaf,function(_0x7abac9){if(_0x7abac9[_0x6b81('0x40')]!==_0x6b81('0x41')){var _0x519a55={};_0x519a55[_0x7abac9[_0x6b81('0x2b')]]={'$like':'%'+_0x5571cf[_0x6b81('0x35')][_0x6b81('0x3e')]+'%'};return _0x519a55;}})});}_0x40175a=_['merge']({},_0x40175a,_0x5571cf[_0x6b81('0x42')]);var _0x3e2ec3={'where':_0x40175a[_0x6b81('0x3c')]};return db[_0x6b81('0x2f')][_0x6b81('0x22')](_0x3e2ec3)[_0x6b81('0x28')](function(_0x4ea5cd){_0x59c3b2['count']=_0x4ea5cd;if(_0x5571cf['query'][_0x6b81('0x43')]){_0x40175a[_0x6b81('0x44')]=[{'all':!![]}];}return db[_0x6b81('0x2f')]['findAll'](_0x40175a);})['then'](function(_0x4099c1){_0x59c3b2[_0x6b81('0x45')]=_0x4099c1;return _0x59c3b2;})[_0x6b81('0x28')](respondWithFilteredResult(_0x5035b9,_0x40175a))['catch'](handleError(_0x5035b9,null));};exports[_0x6b81('0x46')]=function(_0x1b94f5,_0x8bada4){var _0x279341={'raw':![],'where':{'id':_0x1b94f5[_0x6b81('0x47')]['id']}},_0x353552={};_0x353552[_0x6b81('0x33')]=_[_0x6b81('0x34')](db[_0x6b81('0x2f')]['rawAttributes']);_0x353552['query']=_[_0x6b81('0x34')](_0x1b94f5['query']);_0x353552[_0x6b81('0x36')]=_['intersection'](_0x353552[_0x6b81('0x33')],_0x353552['query']);_0x279341[_0x6b81('0x38')]=_['intersection'](_0x353552[_0x6b81('0x33')],qs[_0x6b81('0x39')](_0x1b94f5[_0x6b81('0x35')][_0x6b81('0x39')]));_0x279341[_0x6b81('0x38')]=_0x279341[_0x6b81('0x38')][_0x6b81('0x48')]?_0x279341[_0x6b81('0x38')]:_0x353552[_0x6b81('0x33')];if(_0x1b94f5[_0x6b81('0x35')][_0x6b81('0x43')]){_0x279341['include']=[{'all':!![]}];}_0x279341=_[_0x6b81('0x3f')]({},_0x279341,_0x1b94f5[_0x6b81('0x42')]);return db[_0x6b81('0x2f')][_0x6b81('0x49')](_0x279341)[_0x6b81('0x28')](handleEntityNotFound(_0x8bada4,null))[_0x6b81('0x28')](respondWithResult(_0x8bada4,null))[_0x6b81('0x4a')](handleError(_0x8bada4,null));};exports[_0x6b81('0x4b')]=function(_0xd1d1df,_0x4afb00){return db['ZohoConfiguration'][_0x6b81('0x4b')](_0xd1d1df[_0x6b81('0x4c')],{})[_0x6b81('0x28')](respondWithResult(_0x4afb00,0xc9))[_0x6b81('0x4a')](handleError(_0x4afb00,null));};exports[_0x6b81('0x27')]=function(_0xca010d,_0x2e4b9d){if(_0xca010d[_0x6b81('0x4c')]['id']){delete _0xca010d[_0x6b81('0x4c')]['id'];}return db[_0x6b81('0x2f')][_0x6b81('0x49')]({'where':{'id':_0xca010d['params']['id']}})[_0x6b81('0x28')](handleEntityNotFound(_0x2e4b9d,null))[_0x6b81('0x28')](saveUpdates(_0xca010d[_0x6b81('0x4c')],null))[_0x6b81('0x28')](respondWithResult(_0x2e4b9d,null))['catch'](handleError(_0x2e4b9d,null));};exports[_0x6b81('0x29')]=function(_0x5a9339,_0x542521){return db[_0x6b81('0x2f')]['find']({'where':{'id':_0x5a9339[_0x6b81('0x47')]['id']}})[_0x6b81('0x28')](handleEntityNotFound(_0x542521,null))[_0x6b81('0x28')](removeEntity(_0x542521,null))[_0x6b81('0x4a')](handleError(_0x542521,null));};exports[_0x6b81('0x4d')]=function(_0x579351,_0x789d56,_0x3a0db6){var _0x53c5bf={};var _0x5e9c96={};var _0x4965a0;var _0xac7913;return db[_0x6b81('0x2f')]['findOne']({'where':{'id':_0x579351[_0x6b81('0x47')]['id']}})['then'](handleEntityNotFound(_0x789d56,null))[_0x6b81('0x28')](function(_0x314956){if(_0x314956){_0x4965a0=_0x314956;_0x5e9c96['model']=_[_0x6b81('0x34')](db[_0x6b81('0x4e')][_0x6b81('0x30')]);_0x5e9c96['query']=_[_0x6b81('0x34')](_0x579351[_0x6b81('0x35')]);_0x5e9c96[_0x6b81('0x36')]=_['intersection'](_0x5e9c96[_0x6b81('0x33')],_0x5e9c96[_0x6b81('0x35')]);_0x53c5bf['attributes']=_[_0x6b81('0x37')](_0x5e9c96[_0x6b81('0x33')],qs['fields'](_0x579351[_0x6b81('0x35')]['fields']));_0x53c5bf[_0x6b81('0x38')]=_0x53c5bf[_0x6b81('0x38')]['length']?_0x53c5bf['attributes']:_0x5e9c96['model'];_0x53c5bf[_0x6b81('0x3a')]=qs[_0x6b81('0x3b')](_0x579351[_0x6b81('0x35')][_0x6b81('0x3b')]);_0x53c5bf[_0x6b81('0x3c')]=qs[_0x6b81('0x36')](_[_0x6b81('0x3d')](_0x579351[_0x6b81('0x35')],_0x5e9c96[_0x6b81('0x36')]));if(_0x579351[_0x6b81('0x35')][_0x6b81('0x3e')]){_0x53c5bf[_0x6b81('0x3c')]=_[_0x6b81('0x3f')](_0x53c5bf['where'],{'$or':_[_0x6b81('0x2e')](_0x53c5bf['attributes'],function(_0x4cf4f7){var _0x44211a={};_0x44211a[_0x4cf4f7]={'$like':'%'+_0x579351[_0x6b81('0x35')][_0x6b81('0x3e')]+'%'};return _0x44211a;})});}_0x53c5bf=_['merge']({},_0x53c5bf,_0x579351[_0x6b81('0x42')]);return _0x4965a0[_0x6b81('0x4d')](_0x53c5bf);}})['then'](function(_0x12fffa){if(_0x12fffa){_0xac7913=_0x12fffa[_0x6b81('0x48')];if(!_0x579351[_0x6b81('0x35')][_0x6b81('0x4f')](_0x6b81('0x50'))){_0x53c5bf[_0x6b81('0x21')]=qs['limit'](_0x579351[_0x6b81('0x35')][_0x6b81('0x21')]);_0x53c5bf['offset']=qs[_0x6b81('0x1f')](_0x579351[_0x6b81('0x35')]['offset']);}return _0x4965a0[_0x6b81('0x4d')](_0x53c5bf);}})[_0x6b81('0x28')](function(_0x14e7d7){if(_0x14e7d7){return _0x14e7d7?{'count':_0xac7913,'rows':_0x14e7d7}:null;}})[_0x6b81('0x28')](respondWithResult(_0x789d56,null))[_0x6b81('0x4a')](handleError(_0x789d56,null));};exports[_0x6b81('0x51')]=function(_0x39a0f8,_0x29cc46,_0x5cadff){var _0x1f11e9={};var _0x3b3131={};var _0xd95a14;var _0x2e932c;return db[_0x6b81('0x2f')]['findOne']({'where':{'id':_0x39a0f8['params']['id']}})['then'](handleEntityNotFound(_0x29cc46,null))['then'](function(_0x4e8fa2){if(_0x4e8fa2){_0xd95a14=_0x4e8fa2;_0x3b3131[_0x6b81('0x33')]=_[_0x6b81('0x34')](db[_0x6b81('0x4e')][_0x6b81('0x30')]);_0x3b3131[_0x6b81('0x35')]=_['keys'](_0x39a0f8[_0x6b81('0x35')]);_0x3b3131['filters']=_['intersection'](_0x3b3131[_0x6b81('0x33')],_0x3b3131[_0x6b81('0x35')]);_0x1f11e9[_0x6b81('0x38')]=_[_0x6b81('0x37')](_0x3b3131['model'],qs[_0x6b81('0x39')](_0x39a0f8[_0x6b81('0x35')]['fields']));_0x1f11e9[_0x6b81('0x38')]=_0x1f11e9[_0x6b81('0x38')][_0x6b81('0x48')]?_0x1f11e9[_0x6b81('0x38')]:_0x3b3131[_0x6b81('0x33')];_0x1f11e9[_0x6b81('0x3a')]=qs[_0x6b81('0x3b')](_0x39a0f8['query'][_0x6b81('0x3b')]);_0x1f11e9[_0x6b81('0x3c')]=qs[_0x6b81('0x36')](_[_0x6b81('0x3d')](_0x39a0f8[_0x6b81('0x35')],_0x3b3131[_0x6b81('0x36')]));if(_0x39a0f8['query'][_0x6b81('0x3e')]){_0x1f11e9[_0x6b81('0x3c')]=_['merge'](_0x1f11e9[_0x6b81('0x3c')],{'$or':_[_0x6b81('0x2e')](_0x1f11e9[_0x6b81('0x38')],function(_0x4c22e3){var _0x4718f2={};_0x4718f2[_0x4c22e3]={'$like':'%'+_0x39a0f8['query'][_0x6b81('0x3e')]+'%'};return _0x4718f2;})});}_0x1f11e9=_[_0x6b81('0x3f')]({},_0x1f11e9,_0x39a0f8[_0x6b81('0x42')]);return _0xd95a14[_0x6b81('0x51')](_0x1f11e9);}})[_0x6b81('0x28')](function(_0x1936a0){if(_0x1936a0){_0x2e932c=_0x1936a0[_0x6b81('0x48')];if(!_0x39a0f8['query'][_0x6b81('0x4f')]('nolimit')){_0x1f11e9[_0x6b81('0x21')]=qs[_0x6b81('0x21')](_0x39a0f8[_0x6b81('0x35')][_0x6b81('0x21')]);_0x1f11e9['offset']=qs[_0x6b81('0x1f')](_0x39a0f8[_0x6b81('0x35')][_0x6b81('0x1f')]);}return _0xd95a14[_0x6b81('0x51')](_0x1f11e9);}})[_0x6b81('0x28')](function(_0x217177){if(_0x217177){return _0x217177?{'count':_0x2e932c,'rows':_0x217177}:null;}})[_0x6b81('0x28')](respondWithResult(_0x29cc46,null))['catch'](handleError(_0x29cc46,null));};exports[_0x6b81('0x52')]=function(_0x423729,_0x1e652c,_0x201e62){var _0x1e9504={};var _0x1ebca8={};var _0x322ae2;var _0x59d619;return db[_0x6b81('0x2f')][_0x6b81('0x53')]({'where':{'id':_0x423729[_0x6b81('0x47')]['id']}})[_0x6b81('0x28')](handleEntityNotFound(_0x1e652c,null))['then'](function(_0x5c7d87){if(_0x5c7d87){_0x322ae2=_0x5c7d87;_0x1ebca8['model']=_['keys'](db['ZohoField'][_0x6b81('0x30')]);_0x1ebca8['query']=_[_0x6b81('0x34')](_0x423729['query']);_0x1ebca8['filters']=_[_0x6b81('0x37')](_0x1ebca8[_0x6b81('0x33')],_0x1ebca8[_0x6b81('0x35')]);_0x1e9504[_0x6b81('0x38')]=_['intersection'](_0x1ebca8[_0x6b81('0x33')],qs[_0x6b81('0x39')](_0x423729[_0x6b81('0x35')][_0x6b81('0x39')]));_0x1e9504['attributes']=_0x1e9504[_0x6b81('0x38')][_0x6b81('0x48')]?_0x1e9504[_0x6b81('0x38')]:_0x1ebca8[_0x6b81('0x33')];_0x1e9504['order']=qs[_0x6b81('0x3b')](_0x423729['query'][_0x6b81('0x3b')]);_0x1e9504[_0x6b81('0x3c')]=qs[_0x6b81('0x36')](_[_0x6b81('0x3d')](_0x423729[_0x6b81('0x35')],_0x1ebca8[_0x6b81('0x36')]));if(_0x423729[_0x6b81('0x35')]['filter']){_0x1e9504[_0x6b81('0x3c')]=_[_0x6b81('0x3f')](_0x1e9504[_0x6b81('0x3c')],{'$or':_[_0x6b81('0x2e')](_0x1e9504['attributes'],function(_0x36bd20){var _0x36552d={};_0x36552d[_0x36bd20]={'$like':'%'+_0x423729[_0x6b81('0x35')][_0x6b81('0x3e')]+'%'};return _0x36552d;})});}_0x1e9504=_['merge']({},_0x1e9504,_0x423729[_0x6b81('0x42')]);return _0x322ae2[_0x6b81('0x52')](_0x1e9504);}})['then'](function(_0x527929){if(_0x527929){_0x59d619=_0x527929[_0x6b81('0x48')];if(!_0x423729['query'][_0x6b81('0x4f')](_0x6b81('0x50'))){_0x1e9504[_0x6b81('0x21')]=qs[_0x6b81('0x21')](_0x423729[_0x6b81('0x35')]['limit']);_0x1e9504[_0x6b81('0x1f')]=qs['offset'](_0x423729['query']['offset']);}return _0x322ae2[_0x6b81('0x52')](_0x1e9504);}})[_0x6b81('0x28')](function(_0x370313){if(_0x370313){return _0x370313?{'count':_0x59d619,'rows':_0x370313}:null;}})[_0x6b81('0x28')](respondWithResult(_0x1e652c,null))[_0x6b81('0x4a')](handleError(_0x1e652c,null));};
\ No newline at end of file
+var _0xebd4=['status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','map','ZohoConfiguration','rawAttributes','type','query','keys','model','attributes','intersection','fields','hasOwnProperty','nolimit','sort','where','filters','merge','filter','include','findAll','rows','catch','show','includeAll','create','body','find','params','findOne','length','order','pick','options','getFields','getSubjects','ZohoField','getDescriptions','eml-format','rimraf','request-promise','moment','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../mysqldb','sendStatus'];(function(_0x409e6f,_0x22bef5){var _0x532144=function(_0x14fa6a){while(--_0x14fa6a){_0x409e6f['push'](_0x409e6f['shift']());}};_0x532144(++_0x22bef5);}(_0xebd4,0xd7));var _0x4ebd=function(_0x3bba26,_0x2ab4dc){_0x3bba26=_0x3bba26-0x0;var _0x4fd2ac=_0xebd4[_0x3bba26];return _0x4fd2ac;};'use strict';var emlformat=require(_0x4ebd('0x0'));var rimraf=require(_0x4ebd('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x4ebd('0x2'));var moment=require(_0x4ebd('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x4ebd('0x4'));var util=require(_0x4ebd('0x5'));var path=require('path');var sox=require(_0x4ebd('0x6'));var csv=require(_0x4ebd('0x7'));var ejs=require(_0x4ebd('0x8'));var fs=require('fs');var fs_extra=require(_0x4ebd('0x9'));var _=require(_0x4ebd('0xa'));var squel=require(_0x4ebd('0xb'));var crypto=require(_0x4ebd('0xc'));var jsforce=require(_0x4ebd('0xd'));var deskjs=require(_0x4ebd('0xe'));var toCsv=require(_0x4ebd('0x7'));var querystring=require(_0x4ebd('0xf'));var Papa=require(_0x4ebd('0x10'));var Redis=require(_0x4ebd('0x11'));var authService=require(_0x4ebd('0x12'));var qs=require(_0x4ebd('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4ebd('0x14'));var logger=require('../../config/logger')(_0x4ebd('0x15'));var utils=require(_0x4ebd('0x16'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x4ebd('0x17'))['db'];function respondWithStatusCode(_0x45dec2,_0xcc3c2f){_0xcc3c2f=_0xcc3c2f||0xcc;return function(_0x2b8232){if(_0x2b8232){return _0x45dec2[_0x4ebd('0x18')](_0xcc3c2f);}return _0x45dec2[_0x4ebd('0x19')](_0xcc3c2f)[_0x4ebd('0x1a')]();};}function respondWithResult(_0x2bc949,_0x33ed3b){_0x33ed3b=_0x33ed3b||0xc8;return function(_0x1b6770){if(_0x1b6770){return _0x2bc949[_0x4ebd('0x19')](_0x33ed3b)[_0x4ebd('0x1b')](_0x1b6770);}};}function respondWithFilteredResult(_0x1f5280,_0x1e3476){return function(_0x41080f){if(_0x41080f){var _0x2a0164=typeof _0x1e3476['offset']===_0x4ebd('0x1c')&&typeof _0x1e3476[_0x4ebd('0x1d')]===_0x4ebd('0x1c');var _0x5d8869=_0x41080f[_0x4ebd('0x1e')];var _0xde46ce=_0x2a0164?0x0:_0x1e3476[_0x4ebd('0x1f')];var _0x13e2cb=_0x2a0164?_0x41080f['count']:_0x1e3476[_0x4ebd('0x1f')]+_0x1e3476[_0x4ebd('0x1d')];var _0x493163;if(_0x13e2cb>=_0x5d8869){_0x13e2cb=_0x5d8869;_0x493163=0xc8;}else{_0x493163=0xce;}_0x1f5280[_0x4ebd('0x19')](_0x493163);return _0x1f5280[_0x4ebd('0x20')](_0x4ebd('0x21'),_0xde46ce+'-'+_0x13e2cb+'/'+_0x5d8869)[_0x4ebd('0x1b')](_0x41080f);}return null;};}function patchUpdates(_0x3069ea){return function(_0x1d4f6c){try{jsonpatch[_0x4ebd('0x22')](_0x1d4f6c,_0x3069ea,!![]);}catch(_0x468fbf){return BPromise[_0x4ebd('0x23')](_0x468fbf);}return _0x1d4f6c[_0x4ebd('0x24')]();};}function saveUpdates(_0x3c9f9d,_0x4c345e){return function(_0x45c2cc){if(_0x45c2cc){return _0x45c2cc[_0x4ebd('0x25')](_0x3c9f9d)[_0x4ebd('0x26')](function(_0x5eaa4a){return _0x5eaa4a;});}return null;};}function removeEntity(_0x15bdbe,_0x180dd4){return function(_0x46ffbe){if(_0x46ffbe){return _0x46ffbe[_0x4ebd('0x27')]()[_0x4ebd('0x26')](function(){_0x15bdbe['status'](0xcc)[_0x4ebd('0x1a')]();});}};}function handleEntityNotFound(_0xe6bf0f,_0x3f3f4d){return function(_0x10ac0a){if(!_0x10ac0a){_0xe6bf0f[_0x4ebd('0x18')](0x194);}return _0x10ac0a;};}function handleError(_0x112a77,_0x29a892){_0x29a892=_0x29a892||0x1f4;return function(_0x4c766f){logger[_0x4ebd('0x28')](_0x4c766f[_0x4ebd('0x29')]);if(_0x4c766f[_0x4ebd('0x2a')]){delete _0x4c766f[_0x4ebd('0x2a')];}_0x112a77['status'](_0x29a892)[_0x4ebd('0x2b')](_0x4c766f);};}exports['index']=function(_0x174ac6,_0x1e4352){var _0x10d574={},_0x16792f={},_0x41ff27={'count':0x0,'rows':[]};var _0x44810b=_[_0x4ebd('0x2c')](db[_0x4ebd('0x2d')][_0x4ebd('0x2e')],function(_0x307128){return{'name':_0x307128['fieldName'],'type':_0x307128[_0x4ebd('0x2f')]['key']};});_0x16792f['model']=_[_0x4ebd('0x2c')](_0x44810b,_0x4ebd('0x2a'));_0x16792f[_0x4ebd('0x30')]=_[_0x4ebd('0x31')](_0x174ac6[_0x4ebd('0x30')]);_0x16792f['filters']=_['intersection'](_0x16792f[_0x4ebd('0x32')],_0x16792f[_0x4ebd('0x30')]);_0x10d574[_0x4ebd('0x33')]=_[_0x4ebd('0x34')](_0x16792f[_0x4ebd('0x32')],qs[_0x4ebd('0x35')](_0x174ac6[_0x4ebd('0x30')][_0x4ebd('0x35')]));_0x10d574[_0x4ebd('0x33')]=_0x10d574[_0x4ebd('0x33')]['length']?_0x10d574['attributes']:_0x16792f[_0x4ebd('0x32')];if(!_0x174ac6[_0x4ebd('0x30')][_0x4ebd('0x36')](_0x4ebd('0x37'))){_0x10d574['limit']=qs[_0x4ebd('0x1d')](_0x174ac6[_0x4ebd('0x30')][_0x4ebd('0x1d')]);_0x10d574['offset']=qs['offset'](_0x174ac6['query']['offset']);}_0x10d574['order']=qs['sort'](_0x174ac6['query'][_0x4ebd('0x38')]);_0x10d574[_0x4ebd('0x39')]=qs[_0x4ebd('0x3a')](_['pick'](_0x174ac6[_0x4ebd('0x30')],_0x16792f[_0x4ebd('0x3a')]),_0x44810b);if(_0x174ac6[_0x4ebd('0x30')]['filter']){_0x10d574[_0x4ebd('0x39')]=_[_0x4ebd('0x3b')](_0x10d574['where'],{'$or':_[_0x4ebd('0x2c')](_0x44810b,function(_0x1c85b0){if(_0x1c85b0[_0x4ebd('0x2f')]!=='VIRTUAL'){var _0x3738c5={};_0x3738c5[_0x1c85b0[_0x4ebd('0x2a')]]={'$like':'%'+_0x174ac6[_0x4ebd('0x30')][_0x4ebd('0x3c')]+'%'};return _0x3738c5;}})});}_0x10d574=_[_0x4ebd('0x3b')]({},_0x10d574,_0x174ac6['options']);var _0x16bfce={'where':_0x10d574[_0x4ebd('0x39')]};return db['ZohoConfiguration'][_0x4ebd('0x1e')](_0x16bfce)[_0x4ebd('0x26')](function(_0x400975){_0x41ff27[_0x4ebd('0x1e')]=_0x400975;if(_0x174ac6[_0x4ebd('0x30')]['includeAll']){_0x10d574[_0x4ebd('0x3d')]=[{'all':!![]}];}return db[_0x4ebd('0x2d')][_0x4ebd('0x3e')](_0x10d574);})['then'](function(_0x49f804){_0x41ff27[_0x4ebd('0x3f')]=_0x49f804;return _0x41ff27;})[_0x4ebd('0x26')](respondWithFilteredResult(_0x1e4352,_0x10d574))[_0x4ebd('0x40')](handleError(_0x1e4352,null));};exports[_0x4ebd('0x41')]=function(_0x10de7f,_0x4f8ea4){var _0x3e547c={'raw':![],'where':{'id':_0x10de7f['params']['id']}},_0x5bd210={};_0x5bd210['model']=_[_0x4ebd('0x31')](db[_0x4ebd('0x2d')]['rawAttributes']);_0x5bd210[_0x4ebd('0x30')]=_[_0x4ebd('0x31')](_0x10de7f[_0x4ebd('0x30')]);_0x5bd210[_0x4ebd('0x3a')]=_[_0x4ebd('0x34')](_0x5bd210['model'],_0x5bd210['query']);_0x3e547c[_0x4ebd('0x33')]=_['intersection'](_0x5bd210[_0x4ebd('0x32')],qs[_0x4ebd('0x35')](_0x10de7f[_0x4ebd('0x30')][_0x4ebd('0x35')]));_0x3e547c[_0x4ebd('0x33')]=_0x3e547c[_0x4ebd('0x33')]['length']?_0x3e547c[_0x4ebd('0x33')]:_0x5bd210[_0x4ebd('0x32')];if(_0x10de7f['query'][_0x4ebd('0x42')]){_0x3e547c['include']=[{'all':!![]}];}_0x3e547c=_[_0x4ebd('0x3b')]({},_0x3e547c,_0x10de7f['options']);return db[_0x4ebd('0x2d')]['find'](_0x3e547c)[_0x4ebd('0x26')](handleEntityNotFound(_0x4f8ea4,null))[_0x4ebd('0x26')](respondWithResult(_0x4f8ea4,null))[_0x4ebd('0x40')](handleError(_0x4f8ea4,null));};exports['create']=function(_0x51fbca,_0x442f55){return db[_0x4ebd('0x2d')][_0x4ebd('0x43')](_0x51fbca[_0x4ebd('0x44')],{})[_0x4ebd('0x26')](respondWithResult(_0x442f55,0xc9))[_0x4ebd('0x40')](handleError(_0x442f55,null));};exports[_0x4ebd('0x25')]=function(_0x309ce4,_0x50dbb1){if(_0x309ce4[_0x4ebd('0x44')]['id']){delete _0x309ce4[_0x4ebd('0x44')]['id'];}return db[_0x4ebd('0x2d')][_0x4ebd('0x45')]({'where':{'id':_0x309ce4[_0x4ebd('0x46')]['id']}})[_0x4ebd('0x26')](handleEntityNotFound(_0x50dbb1,null))[_0x4ebd('0x26')](saveUpdates(_0x309ce4[_0x4ebd('0x44')],null))[_0x4ebd('0x26')](respondWithResult(_0x50dbb1,null))[_0x4ebd('0x40')](handleError(_0x50dbb1,null));};exports[_0x4ebd('0x27')]=function(_0x300eba,_0x51b16b){return db['ZohoConfiguration'][_0x4ebd('0x45')]({'where':{'id':_0x300eba[_0x4ebd('0x46')]['id']}})[_0x4ebd('0x26')](handleEntityNotFound(_0x51b16b,null))['then'](removeEntity(_0x51b16b,null))[_0x4ebd('0x40')](handleError(_0x51b16b,null));};exports['getFields']=function(_0x1a1779,_0x5beed9,_0x5c36c0){var _0x47efc8={};var _0x5c1bfd={};var _0x32a3f4;var _0x20793b;return db[_0x4ebd('0x2d')][_0x4ebd('0x47')]({'where':{'id':_0x1a1779[_0x4ebd('0x46')]['id']}})[_0x4ebd('0x26')](handleEntityNotFound(_0x5beed9,null))['then'](function(_0xcbb79e){if(_0xcbb79e){_0x32a3f4=_0xcbb79e;_0x5c1bfd['model']=_[_0x4ebd('0x31')](db['ZohoField']['rawAttributes']);_0x5c1bfd['query']=_[_0x4ebd('0x31')](_0x1a1779[_0x4ebd('0x30')]);_0x5c1bfd['filters']=_['intersection'](_0x5c1bfd['model'],_0x5c1bfd[_0x4ebd('0x30')]);_0x47efc8[_0x4ebd('0x33')]=_[_0x4ebd('0x34')](_0x5c1bfd[_0x4ebd('0x32')],qs[_0x4ebd('0x35')](_0x1a1779[_0x4ebd('0x30')]['fields']));_0x47efc8['attributes']=_0x47efc8[_0x4ebd('0x33')][_0x4ebd('0x48')]?_0x47efc8['attributes']:_0x5c1bfd['model'];_0x47efc8[_0x4ebd('0x49')]=qs[_0x4ebd('0x38')](_0x1a1779['query']['sort']);_0x47efc8[_0x4ebd('0x39')]=qs[_0x4ebd('0x3a')](_[_0x4ebd('0x4a')](_0x1a1779[_0x4ebd('0x30')],_0x5c1bfd['filters']));if(_0x1a1779[_0x4ebd('0x30')][_0x4ebd('0x3c')]){_0x47efc8[_0x4ebd('0x39')]=_['merge'](_0x47efc8[_0x4ebd('0x39')],{'$or':_[_0x4ebd('0x2c')](_0x47efc8[_0x4ebd('0x33')],function(_0xc0484b){var _0x3e7b6c={};_0x3e7b6c[_0xc0484b]={'$like':'%'+_0x1a1779[_0x4ebd('0x30')]['filter']+'%'};return _0x3e7b6c;})});}_0x47efc8=_[_0x4ebd('0x3b')]({},_0x47efc8,_0x1a1779[_0x4ebd('0x4b')]);return _0x32a3f4[_0x4ebd('0x4c')](_0x47efc8);}})[_0x4ebd('0x26')](function(_0xe0b2ef){if(_0xe0b2ef){_0x20793b=_0xe0b2ef['length'];if(!_0x1a1779['query'][_0x4ebd('0x36')](_0x4ebd('0x37'))){_0x47efc8[_0x4ebd('0x1d')]=qs[_0x4ebd('0x1d')](_0x1a1779[_0x4ebd('0x30')][_0x4ebd('0x1d')]);_0x47efc8[_0x4ebd('0x1f')]=qs[_0x4ebd('0x1f')](_0x1a1779[_0x4ebd('0x30')][_0x4ebd('0x1f')]);}return _0x32a3f4['getFields'](_0x47efc8);}})[_0x4ebd('0x26')](function(_0x53072f){if(_0x53072f){return _0x53072f?{'count':_0x20793b,'rows':_0x53072f}:null;}})[_0x4ebd('0x26')](respondWithResult(_0x5beed9,null))[_0x4ebd('0x40')](handleError(_0x5beed9,null));};exports[_0x4ebd('0x4d')]=function(_0xfa1824,_0x19b9b4,_0x5b3d19){var _0x47c665={};var _0xcf4c66={};var _0x511de8;var _0x267198;return db['ZohoConfiguration'][_0x4ebd('0x47')]({'where':{'id':_0xfa1824[_0x4ebd('0x46')]['id']}})[_0x4ebd('0x26')](handleEntityNotFound(_0x19b9b4,null))[_0x4ebd('0x26')](function(_0x17d003){if(_0x17d003){_0x511de8=_0x17d003;_0xcf4c66['model']=_[_0x4ebd('0x31')](db[_0x4ebd('0x4e')][_0x4ebd('0x2e')]);_0xcf4c66['query']=_[_0x4ebd('0x31')](_0xfa1824[_0x4ebd('0x30')]);_0xcf4c66[_0x4ebd('0x3a')]=_[_0x4ebd('0x34')](_0xcf4c66[_0x4ebd('0x32')],_0xcf4c66[_0x4ebd('0x30')]);_0x47c665['attributes']=_[_0x4ebd('0x34')](_0xcf4c66[_0x4ebd('0x32')],qs[_0x4ebd('0x35')](_0xfa1824[_0x4ebd('0x30')][_0x4ebd('0x35')]));_0x47c665[_0x4ebd('0x33')]=_0x47c665[_0x4ebd('0x33')][_0x4ebd('0x48')]?_0x47c665[_0x4ebd('0x33')]:_0xcf4c66[_0x4ebd('0x32')];_0x47c665['order']=qs[_0x4ebd('0x38')](_0xfa1824[_0x4ebd('0x30')][_0x4ebd('0x38')]);_0x47c665[_0x4ebd('0x39')]=qs[_0x4ebd('0x3a')](_[_0x4ebd('0x4a')](_0xfa1824['query'],_0xcf4c66['filters']));if(_0xfa1824[_0x4ebd('0x30')][_0x4ebd('0x3c')]){_0x47c665['where']=_['merge'](_0x47c665['where'],{'$or':_[_0x4ebd('0x2c')](_0x47c665[_0x4ebd('0x33')],function(_0x581ec1){var _0x5753be={};_0x5753be[_0x581ec1]={'$like':'%'+_0xfa1824['query']['filter']+'%'};return _0x5753be;})});}_0x47c665=_[_0x4ebd('0x3b')]({},_0x47c665,_0xfa1824[_0x4ebd('0x4b')]);return _0x511de8[_0x4ebd('0x4d')](_0x47c665);}})[_0x4ebd('0x26')](function(_0x15851e){if(_0x15851e){_0x267198=_0x15851e['length'];if(!_0xfa1824[_0x4ebd('0x30')][_0x4ebd('0x36')](_0x4ebd('0x37'))){_0x47c665[_0x4ebd('0x1d')]=qs[_0x4ebd('0x1d')](_0xfa1824[_0x4ebd('0x30')][_0x4ebd('0x1d')]);_0x47c665[_0x4ebd('0x1f')]=qs[_0x4ebd('0x1f')](_0xfa1824[_0x4ebd('0x30')][_0x4ebd('0x1f')]);}return _0x511de8[_0x4ebd('0x4d')](_0x47c665);}})[_0x4ebd('0x26')](function(_0x676213){if(_0x676213){return _0x676213?{'count':_0x267198,'rows':_0x676213}:null;}})[_0x4ebd('0x26')](respondWithResult(_0x19b9b4,null))[_0x4ebd('0x40')](handleError(_0x19b9b4,null));};exports['getDescriptions']=function(_0x3f2de6,_0x5822f3,_0xcd216f){var _0x3fae5c={};var _0x2df2cb={};var _0x3cc74b;var _0x3c12d9;return db[_0x4ebd('0x2d')]['findOne']({'where':{'id':_0x3f2de6[_0x4ebd('0x46')]['id']}})[_0x4ebd('0x26')](handleEntityNotFound(_0x5822f3,null))['then'](function(_0x453589){if(_0x453589){_0x3cc74b=_0x453589;_0x2df2cb['model']=_[_0x4ebd('0x31')](db[_0x4ebd('0x4e')]['rawAttributes']);_0x2df2cb[_0x4ebd('0x30')]=_['keys'](_0x3f2de6['query']);_0x2df2cb[_0x4ebd('0x3a')]=_[_0x4ebd('0x34')](_0x2df2cb['model'],_0x2df2cb['query']);_0x3fae5c[_0x4ebd('0x33')]=_[_0x4ebd('0x34')](_0x2df2cb[_0x4ebd('0x32')],qs[_0x4ebd('0x35')](_0x3f2de6[_0x4ebd('0x30')][_0x4ebd('0x35')]));_0x3fae5c[_0x4ebd('0x33')]=_0x3fae5c[_0x4ebd('0x33')][_0x4ebd('0x48')]?_0x3fae5c[_0x4ebd('0x33')]:_0x2df2cb[_0x4ebd('0x32')];_0x3fae5c[_0x4ebd('0x49')]=qs[_0x4ebd('0x38')](_0x3f2de6[_0x4ebd('0x30')]['sort']);_0x3fae5c[_0x4ebd('0x39')]=qs[_0x4ebd('0x3a')](_['pick'](_0x3f2de6[_0x4ebd('0x30')],_0x2df2cb['filters']));if(_0x3f2de6[_0x4ebd('0x30')]['filter']){_0x3fae5c[_0x4ebd('0x39')]=_[_0x4ebd('0x3b')](_0x3fae5c[_0x4ebd('0x39')],{'$or':_[_0x4ebd('0x2c')](_0x3fae5c[_0x4ebd('0x33')],function(_0x238486){var _0x55d22b={};_0x55d22b[_0x238486]={'$like':'%'+_0x3f2de6[_0x4ebd('0x30')]['filter']+'%'};return _0x55d22b;})});}_0x3fae5c=_[_0x4ebd('0x3b')]({},_0x3fae5c,_0x3f2de6[_0x4ebd('0x4b')]);return _0x3cc74b[_0x4ebd('0x4f')](_0x3fae5c);}})[_0x4ebd('0x26')](function(_0x497243){if(_0x497243){_0x3c12d9=_0x497243[_0x4ebd('0x48')];if(!_0x3f2de6['query'][_0x4ebd('0x36')](_0x4ebd('0x37'))){_0x3fae5c[_0x4ebd('0x1d')]=qs['limit'](_0x3f2de6['query'][_0x4ebd('0x1d')]);_0x3fae5c[_0x4ebd('0x1f')]=qs[_0x4ebd('0x1f')](_0x3f2de6[_0x4ebd('0x30')][_0x4ebd('0x1f')]);}return _0x3cc74b[_0x4ebd('0x4f')](_0x3fae5c);}})['then'](function(_0x19d475){if(_0x19d475){return _0x19d475?{'count':_0x3c12d9,'rows':_0x19d475}:null;}})[_0x4ebd('0x26')](respondWithResult(_0x5822f3,null))['catch'](handleError(_0x5822f3,null));};
\ No newline at end of file