Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index cde9299..1a100dd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xcaf3=['params','getFields','findOne','ZohoField','filter','nolimit','getSubjects','getDescriptions','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','undefined','count','offset','limit','set','Content-Range','json','apply','reject','update','then','end','stack','send','map','ZohoConfiguration','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','merge','VIRTUAL','name','options','includeAll','rows','catch','find','create','body','destroy'];(function(_0x493c8c,_0x470567){var _0x17344b=function(_0x47aee7){while(--_0x47aee7){_0x493c8c['push'](_0x493c8c['shift']());}};_0x17344b(++_0x470567);}(_0xcaf3,0xaa));var _0x3caf=function(_0x1af0e5,_0x152990){_0x1af0e5=_0x1af0e5-0x0;var _0x3c444a=_0xcaf3[_0x1af0e5];return _0x3c444a;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x3caf('0x0'));var zipdir=require(_0x3caf('0x1'));var jsonpatch=require(_0x3caf('0x2'));var rp=require(_0x3caf('0x3'));var moment=require(_0x3caf('0x4'));var BPromise=require(_0x3caf('0x5'));var Mustache=require(_0x3caf('0x6'));var util=require(_0x3caf('0x7'));var path=require(_0x3caf('0x8'));var sox=require(_0x3caf('0x9'));var csv=require(_0x3caf('0xa'));var ejs=require(_0x3caf('0xb'));var fs=require('fs');var fs_extra=require(_0x3caf('0xc'));var _=require(_0x3caf('0xd'));var squel=require(_0x3caf('0xe'));var crypto=require(_0x3caf('0xf'));var jsforce=require('jsforce');var deskjs=require(_0x3caf('0x10'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x3caf('0x11'));var Redis=require('ioredis');var authService=require(_0x3caf('0x12'));var qs=require(_0x3caf('0x13'));var as=require(_0x3caf('0x14'));var hardwareService=require(_0x3caf('0x15'));var logger=require(_0x3caf('0x16'))(_0x3caf('0x17'));var utils=require(_0x3caf('0x18'));var config=require(_0x3caf('0x19'));var licenseUtil=require(_0x3caf('0x1a'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5847d1,_0x232159){_0x232159=_0x232159||0xcc;return function(_0x48d3ca){if(_0x48d3ca){return _0x5847d1[_0x3caf('0x1b')](_0x232159);}return _0x5847d1[_0x3caf('0x1c')](_0x232159)['end']();};}function respondWithResult(_0x965d11,_0x53c618){_0x53c618=_0x53c618||0xc8;return function(_0x3cb847){if(_0x3cb847){return _0x965d11[_0x3caf('0x1c')](_0x53c618)['json'](_0x3cb847);}};}function respondWithFilteredResult(_0x2be908,_0x417383){return function(_0x15634b){if(_0x15634b){var _0x1a0fe0=typeof _0x417383['offset']===_0x3caf('0x1d')&&typeof _0x417383['limit']===_0x3caf('0x1d');var _0x496306=_0x15634b[_0x3caf('0x1e')];var _0x26e07b=_0x1a0fe0?0x0:_0x417383[_0x3caf('0x1f')];var _0x2b5495=_0x1a0fe0?_0x15634b[_0x3caf('0x1e')]:_0x417383['offset']+_0x417383[_0x3caf('0x20')];var _0x347c82;if(_0x2b5495>=_0x496306){_0x2b5495=_0x496306;_0x347c82=0xc8;}else{_0x347c82=0xce;}_0x2be908[_0x3caf('0x1c')](_0x347c82);return _0x2be908[_0x3caf('0x21')](_0x3caf('0x22'),_0x26e07b+'-'+_0x2b5495+'/'+_0x496306)[_0x3caf('0x23')](_0x15634b);}return null;};}function patchUpdates(_0x21da62){return function(_0x5e655f){try{jsonpatch[_0x3caf('0x24')](_0x5e655f,_0x21da62,!![]);}catch(_0x4598d4){return BPromise[_0x3caf('0x25')](_0x4598d4);}return _0x5e655f['save']();};}function saveUpdates(_0x50ab34,_0x4c2704){return function(_0x196f54){if(_0x196f54){return _0x196f54[_0x3caf('0x26')](_0x50ab34)[_0x3caf('0x27')](function(_0x18d78f){return _0x18d78f;});}return null;};}function removeEntity(_0x3df62d,_0x361bca){return function(_0x2d0622){if(_0x2d0622){return _0x2d0622['destroy']()[_0x3caf('0x27')](function(){_0x3df62d[_0x3caf('0x1c')](0xcc)[_0x3caf('0x28')]();});}};}function handleEntityNotFound(_0x7beb65,_0x18c952){return function(_0x1e3c61){if(!_0x1e3c61){_0x7beb65[_0x3caf('0x1b')](0x194);}return _0x1e3c61;};}function handleError(_0x658805,_0x340f9e){_0x340f9e=_0x340f9e||0x1f4;return function(_0x1df561){logger['error'](_0x1df561[_0x3caf('0x29')]);if(_0x1df561['name']){delete _0x1df561['name'];}_0x658805[_0x3caf('0x1c')](_0x340f9e)[_0x3caf('0x2a')](_0x1df561);};}exports['index']=function(_0x17573f,_0x5f3f1f){var _0x23ad7f={},_0x16601b={},_0x2c1d5f={'count':0x0,'rows':[]};var _0x3dbcec=_[_0x3caf('0x2b')](db[_0x3caf('0x2c')][_0x3caf('0x2d')],function(_0x22e66f){return{'name':_0x22e66f[_0x3caf('0x2e')],'type':_0x22e66f[_0x3caf('0x2f')][_0x3caf('0x30')]};});_0x16601b[_0x3caf('0x31')]=_[_0x3caf('0x2b')](_0x3dbcec,'name');_0x16601b['query']=_[_0x3caf('0x32')](_0x17573f[_0x3caf('0x33')]);_0x16601b[_0x3caf('0x34')]=_[_0x3caf('0x35')](_0x16601b[_0x3caf('0x31')],_0x16601b[_0x3caf('0x33')]);_0x23ad7f[_0x3caf('0x36')]=_['intersection'](_0x16601b[_0x3caf('0x31')],qs[_0x3caf('0x37')](_0x17573f['query'][_0x3caf('0x37')]));_0x23ad7f['attributes']=_0x23ad7f['attributes'][_0x3caf('0x38')]?_0x23ad7f[_0x3caf('0x36')]:_0x16601b[_0x3caf('0x31')];if(!_0x17573f[_0x3caf('0x33')][_0x3caf('0x39')]('nolimit')){_0x23ad7f['limit']=qs[_0x3caf('0x20')](_0x17573f[_0x3caf('0x33')][_0x3caf('0x20')]);_0x23ad7f[_0x3caf('0x1f')]=qs[_0x3caf('0x1f')](_0x17573f['query'][_0x3caf('0x1f')]);}_0x23ad7f[_0x3caf('0x3a')]=qs[_0x3caf('0x3b')](_0x17573f[_0x3caf('0x33')]['sort']);_0x23ad7f[_0x3caf('0x3c')]=qs[_0x3caf('0x34')](_[_0x3caf('0x3d')](_0x17573f[_0x3caf('0x33')],_0x16601b[_0x3caf('0x34')]),_0x3dbcec);if(_0x17573f[_0x3caf('0x33')]['filter']){_0x23ad7f[_0x3caf('0x3c')]=_[_0x3caf('0x3e')](_0x23ad7f[_0x3caf('0x3c')],{'$or':_[_0x3caf('0x2b')](_0x3dbcec,function(_0x53f479){if(_0x53f479[_0x3caf('0x2f')]!==_0x3caf('0x3f')){var _0x3de329={};_0x3de329[_0x53f479[_0x3caf('0x40')]]={'$like':'%'+_0x17573f[_0x3caf('0x33')]['filter']+'%'};return _0x3de329;}})});}_0x23ad7f=_['merge']({},_0x23ad7f,_0x17573f[_0x3caf('0x41')]);var _0x3b0060={'where':_0x23ad7f[_0x3caf('0x3c')]};return db['ZohoConfiguration'][_0x3caf('0x1e')](_0x3b0060)[_0x3caf('0x27')](function(_0x3782f9){_0x2c1d5f['count']=_0x3782f9;if(_0x17573f[_0x3caf('0x33')][_0x3caf('0x42')]){_0x23ad7f['include']=[{'all':!![]}];}return db[_0x3caf('0x2c')]['findAll'](_0x23ad7f);})[_0x3caf('0x27')](function(_0x261e8f){_0x2c1d5f[_0x3caf('0x43')]=_0x261e8f;return _0x2c1d5f;})['then'](respondWithFilteredResult(_0x5f3f1f,_0x23ad7f))[_0x3caf('0x44')](handleError(_0x5f3f1f,null));};exports['show']=function(_0x4f5c92,_0x266dba){var _0x29eca2={'raw':![],'where':{'id':_0x4f5c92['params']['id']}},_0x12b9aa={};_0x12b9aa['model']=_['keys'](db['ZohoConfiguration']['rawAttributes']);_0x12b9aa[_0x3caf('0x33')]=_[_0x3caf('0x32')](_0x4f5c92[_0x3caf('0x33')]);_0x12b9aa['filters']=_[_0x3caf('0x35')](_0x12b9aa[_0x3caf('0x31')],_0x12b9aa[_0x3caf('0x33')]);_0x29eca2[_0x3caf('0x36')]=_[_0x3caf('0x35')](_0x12b9aa[_0x3caf('0x31')],qs['fields'](_0x4f5c92[_0x3caf('0x33')][_0x3caf('0x37')]));_0x29eca2['attributes']=_0x29eca2[_0x3caf('0x36')]['length']?_0x29eca2[_0x3caf('0x36')]:_0x12b9aa['model'];if(_0x4f5c92['query'][_0x3caf('0x42')]){_0x29eca2['include']=[{'all':!![]}];}_0x29eca2=_[_0x3caf('0x3e')]({},_0x29eca2,_0x4f5c92[_0x3caf('0x41')]);return db[_0x3caf('0x2c')][_0x3caf('0x45')](_0x29eca2)[_0x3caf('0x27')](handleEntityNotFound(_0x266dba,null))['then'](respondWithResult(_0x266dba,null))['catch'](handleError(_0x266dba,null));};exports[_0x3caf('0x46')]=function(_0x2f9061,_0x119793){return db[_0x3caf('0x2c')][_0x3caf('0x46')](_0x2f9061[_0x3caf('0x47')],{})[_0x3caf('0x27')](respondWithResult(_0x119793,0xc9))[_0x3caf('0x44')](handleError(_0x119793,null));};exports['update']=function(_0x18477c,_0x596896){if(_0x18477c['body']['id']){delete _0x18477c[_0x3caf('0x47')]['id'];}return db['ZohoConfiguration']['find']({'where':{'id':_0x18477c['params']['id']}})[_0x3caf('0x27')](handleEntityNotFound(_0x596896,null))[_0x3caf('0x27')](saveUpdates(_0x18477c[_0x3caf('0x47')],null))[_0x3caf('0x27')](respondWithResult(_0x596896,null))[_0x3caf('0x44')](handleError(_0x596896,null));};exports[_0x3caf('0x48')]=function(_0x44258e,_0x11210f){return db[_0x3caf('0x2c')][_0x3caf('0x45')]({'where':{'id':_0x44258e[_0x3caf('0x49')]['id']}})['then'](handleEntityNotFound(_0x11210f,null))[_0x3caf('0x27')](removeEntity(_0x11210f,null))['catch'](handleError(_0x11210f,null));};exports[_0x3caf('0x4a')]=function(_0x525cf1,_0x49a060,_0x5d2b99){var _0x599f2c={};var _0xda51ca={};var _0x38164c;var _0x3ffe21;return db['ZohoConfiguration'][_0x3caf('0x4b')]({'where':{'id':_0x525cf1[_0x3caf('0x49')]['id']}})[_0x3caf('0x27')](handleEntityNotFound(_0x49a060,null))[_0x3caf('0x27')](function(_0x4eeabb){if(_0x4eeabb){_0x38164c=_0x4eeabb;_0xda51ca[_0x3caf('0x31')]=_[_0x3caf('0x32')](db[_0x3caf('0x4c')][_0x3caf('0x2d')]);_0xda51ca[_0x3caf('0x33')]=_[_0x3caf('0x32')](_0x525cf1[_0x3caf('0x33')]);_0xda51ca[_0x3caf('0x34')]=_['intersection'](_0xda51ca[_0x3caf('0x31')],_0xda51ca['query']);_0x599f2c[_0x3caf('0x36')]=_[_0x3caf('0x35')](_0xda51ca[_0x3caf('0x31')],qs[_0x3caf('0x37')](_0x525cf1[_0x3caf('0x33')][_0x3caf('0x37')]));_0x599f2c[_0x3caf('0x36')]=_0x599f2c['attributes'][_0x3caf('0x38')]?_0x599f2c[_0x3caf('0x36')]:_0xda51ca[_0x3caf('0x31')];_0x599f2c[_0x3caf('0x3a')]=qs[_0x3caf('0x3b')](_0x525cf1[_0x3caf('0x33')][_0x3caf('0x3b')]);_0x599f2c[_0x3caf('0x3c')]=qs[_0x3caf('0x34')](_[_0x3caf('0x3d')](_0x525cf1[_0x3caf('0x33')],_0xda51ca[_0x3caf('0x34')]));if(_0x525cf1['query'][_0x3caf('0x4d')]){_0x599f2c[_0x3caf('0x3c')]=_[_0x3caf('0x3e')](_0x599f2c[_0x3caf('0x3c')],{'$or':_['map'](_0x599f2c['attributes'],function(_0x5634fb){var _0x52e4cd={};_0x52e4cd[_0x5634fb]={'$like':'%'+_0x525cf1['query'][_0x3caf('0x4d')]+'%'};return _0x52e4cd;})});}_0x599f2c=_[_0x3caf('0x3e')]({},_0x599f2c,_0x525cf1[_0x3caf('0x41')]);return _0x38164c[_0x3caf('0x4a')](_0x599f2c);}})['then'](function(_0x3770f3){if(_0x3770f3){_0x3ffe21=_0x3770f3['length'];if(!_0x525cf1[_0x3caf('0x33')][_0x3caf('0x39')](_0x3caf('0x4e'))){_0x599f2c[_0x3caf('0x20')]=qs['limit'](_0x525cf1[_0x3caf('0x33')]['limit']);_0x599f2c[_0x3caf('0x1f')]=qs[_0x3caf('0x1f')](_0x525cf1[_0x3caf('0x33')][_0x3caf('0x1f')]);}return _0x38164c[_0x3caf('0x4a')](_0x599f2c);}})[_0x3caf('0x27')](function(_0x321571){if(_0x321571){return _0x321571?{'count':_0x3ffe21,'rows':_0x321571}:null;}})[_0x3caf('0x27')](respondWithResult(_0x49a060,null))[_0x3caf('0x44')](handleError(_0x49a060,null));};exports['getSubjects']=function(_0x3b2aaa,_0x39d5a3,_0x3375ad){var _0x2e079d={};var _0x6cb6c2={};var _0x3826bc;var _0x5ed2bc;return db['ZohoConfiguration'][_0x3caf('0x4b')]({'where':{'id':_0x3b2aaa['params']['id']}})[_0x3caf('0x27')](handleEntityNotFound(_0x39d5a3,null))['then'](function(_0x5a53a6){if(_0x5a53a6){_0x3826bc=_0x5a53a6;_0x6cb6c2[_0x3caf('0x31')]=_[_0x3caf('0x32')](db[_0x3caf('0x4c')][_0x3caf('0x2d')]);_0x6cb6c2[_0x3caf('0x33')]=_[_0x3caf('0x32')](_0x3b2aaa['query']);_0x6cb6c2[_0x3caf('0x34')]=_[_0x3caf('0x35')](_0x6cb6c2['model'],_0x6cb6c2['query']);_0x2e079d[_0x3caf('0x36')]=_[_0x3caf('0x35')](_0x6cb6c2[_0x3caf('0x31')],qs[_0x3caf('0x37')](_0x3b2aaa[_0x3caf('0x33')][_0x3caf('0x37')]));_0x2e079d[_0x3caf('0x36')]=_0x2e079d[_0x3caf('0x36')][_0x3caf('0x38')]?_0x2e079d['attributes']:_0x6cb6c2[_0x3caf('0x31')];_0x2e079d['order']=qs[_0x3caf('0x3b')](_0x3b2aaa[_0x3caf('0x33')]['sort']);_0x2e079d['where']=qs[_0x3caf('0x34')](_['pick'](_0x3b2aaa[_0x3caf('0x33')],_0x6cb6c2['filters']));if(_0x3b2aaa[_0x3caf('0x33')]['filter']){_0x2e079d[_0x3caf('0x3c')]=_[_0x3caf('0x3e')](_0x2e079d[_0x3caf('0x3c')],{'$or':_['map'](_0x2e079d[_0x3caf('0x36')],function(_0x309e56){var _0x55b93a={};_0x55b93a[_0x309e56]={'$like':'%'+_0x3b2aaa[_0x3caf('0x33')][_0x3caf('0x4d')]+'%'};return _0x55b93a;})});}_0x2e079d=_['merge']({},_0x2e079d,_0x3b2aaa['options']);return _0x3826bc[_0x3caf('0x4f')](_0x2e079d);}})[_0x3caf('0x27')](function(_0x3a222c){if(_0x3a222c){_0x5ed2bc=_0x3a222c[_0x3caf('0x38')];if(!_0x3b2aaa[_0x3caf('0x33')][_0x3caf('0x39')](_0x3caf('0x4e'))){_0x2e079d[_0x3caf('0x20')]=qs[_0x3caf('0x20')](_0x3b2aaa[_0x3caf('0x33')]['limit']);_0x2e079d['offset']=qs[_0x3caf('0x1f')](_0x3b2aaa['query'][_0x3caf('0x1f')]);}return _0x3826bc[_0x3caf('0x4f')](_0x2e079d);}})[_0x3caf('0x27')](function(_0x5e353b){if(_0x5e353b){return _0x5e353b?{'count':_0x5ed2bc,'rows':_0x5e353b}:null;}})[_0x3caf('0x27')](respondWithResult(_0x39d5a3,null))[_0x3caf('0x44')](handleError(_0x39d5a3,null));};exports[_0x3caf('0x50')]=function(_0x1582fa,_0x436bc4,_0x6c395c){var _0x4e0f87={};var _0x5e5d56={};var _0x231d39;var _0x104258;return db[_0x3caf('0x2c')][_0x3caf('0x4b')]({'where':{'id':_0x1582fa[_0x3caf('0x49')]['id']}})[_0x3caf('0x27')](handleEntityNotFound(_0x436bc4,null))['then'](function(_0x2b876a){if(_0x2b876a){_0x231d39=_0x2b876a;_0x5e5d56[_0x3caf('0x31')]=_[_0x3caf('0x32')](db[_0x3caf('0x4c')][_0x3caf('0x2d')]);_0x5e5d56[_0x3caf('0x33')]=_[_0x3caf('0x32')](_0x1582fa[_0x3caf('0x33')]);_0x5e5d56[_0x3caf('0x34')]=_['intersection'](_0x5e5d56[_0x3caf('0x31')],_0x5e5d56[_0x3caf('0x33')]);_0x4e0f87[_0x3caf('0x36')]=_['intersection'](_0x5e5d56[_0x3caf('0x31')],qs['fields'](_0x1582fa['query']['fields']));_0x4e0f87[_0x3caf('0x36')]=_0x4e0f87[_0x3caf('0x36')][_0x3caf('0x38')]?_0x4e0f87[_0x3caf('0x36')]:_0x5e5d56[_0x3caf('0x31')];_0x4e0f87['order']=qs[_0x3caf('0x3b')](_0x1582fa['query'][_0x3caf('0x3b')]);_0x4e0f87[_0x3caf('0x3c')]=qs['filters'](_['pick'](_0x1582fa['query'],_0x5e5d56[_0x3caf('0x34')]));if(_0x1582fa[_0x3caf('0x33')]['filter']){_0x4e0f87['where']=_[_0x3caf('0x3e')](_0x4e0f87[_0x3caf('0x3c')],{'$or':_[_0x3caf('0x2b')](_0x4e0f87[_0x3caf('0x36')],function(_0x213f40){var _0x5b61e3={};_0x5b61e3[_0x213f40]={'$like':'%'+_0x1582fa[_0x3caf('0x33')][_0x3caf('0x4d')]+'%'};return _0x5b61e3;})});}_0x4e0f87=_[_0x3caf('0x3e')]({},_0x4e0f87,_0x1582fa[_0x3caf('0x41')]);return _0x231d39['getDescriptions'](_0x4e0f87);}})[_0x3caf('0x27')](function(_0x2cd8fe){if(_0x2cd8fe){_0x104258=_0x2cd8fe[_0x3caf('0x38')];if(!_0x1582fa['query'][_0x3caf('0x39')](_0x3caf('0x4e'))){_0x4e0f87[_0x3caf('0x20')]=qs[_0x3caf('0x20')](_0x1582fa['query'][_0x3caf('0x20')]);_0x4e0f87[_0x3caf('0x1f')]=qs['offset'](_0x1582fa['query']['offset']);}return _0x231d39[_0x3caf('0x50')](_0x4e0f87);}})['then'](function(_0x58f5bc){if(_0x58f5bc){return _0x58f5bc?{'count':_0x104258,'rows':_0x58f5bc}:null;}})[_0x3caf('0x27')](respondWithResult(_0x436bc4,null))['catch'](handleError(_0x436bc4,null));};
\ No newline at end of file
+var _0xbb3a=['path','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','status','end','json','offset','undefined','limit','set','Content-Range','apply','save','update','destroy','then','sendStatus','error','stack','name','send','index','ZohoConfiguration','rawAttributes','fieldName','type','map','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','count','include','findAll','rows','catch','includeAll','find','create','body','params','getFields','findOne','options','getSubjects','ZohoField','getDescriptions','eml-format','bluebird','mustache'];(function(_0x551b1c,_0x3584f9){var _0x131273=function(_0x553185){while(--_0x553185){_0x551b1c['push'](_0x551b1c['shift']());}};_0x131273(++_0x3584f9);}(_0xbb3a,0x93));var _0xabb3=function(_0xccbbdb,_0x264006){_0xccbbdb=_0xccbbdb-0x0;var _0x509328=_0xbb3a[_0xccbbdb];return _0x509328;};'use strict';var emlformat=require(_0xabb3('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xabb3('0x1'));var Mustache=require(_0xabb3('0x2'));var util=require('util');var path=require(_0xabb3('0x3'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xabb3('0x4'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xabb3('0x5'));var crypto=require(_0xabb3('0x6'));var jsforce=require(_0xabb3('0x7'));var deskjs=require(_0xabb3('0x8'));var toCsv=require('to-csv');var querystring=require(_0xabb3('0x9'));var Papa=require(_0xabb3('0xa'));var Redis=require(_0xabb3('0xb'));var authService=require('../../components/auth/service');var qs=require(_0xabb3('0xc'));var as=require(_0xabb3('0xd'));var hardwareService=require(_0xabb3('0xe'));var logger=require('../../config/logger')(_0xabb3('0xf'));var utils=require('../../config/utils');var config=require(_0xabb3('0x10'));var licenseUtil=require('../../config/license/util');var db=require(_0xabb3('0x11'))['db'];function respondWithStatusCode(_0x32eefb,_0x46df20){_0x46df20=_0x46df20||0xcc;return function(_0x36a26b){if(_0x36a26b){return _0x32eefb['sendStatus'](_0x46df20);}return _0x32eefb[_0xabb3('0x12')](_0x46df20)[_0xabb3('0x13')]();};}function respondWithResult(_0x58700b,_0x3b9cce){_0x3b9cce=_0x3b9cce||0xc8;return function(_0x3f4587){if(_0x3f4587){return _0x58700b[_0xabb3('0x12')](_0x3b9cce)[_0xabb3('0x14')](_0x3f4587);}};}function respondWithFilteredResult(_0x35b9e4,_0x207321){return function(_0x40dbf2){if(_0x40dbf2){var _0x540d56=typeof _0x207321[_0xabb3('0x15')]===_0xabb3('0x16')&&typeof _0x207321[_0xabb3('0x17')]===_0xabb3('0x16');var _0x46c5ce=_0x40dbf2['count'];var _0x38eff5=_0x540d56?0x0:_0x207321[_0xabb3('0x15')];var _0x459086=_0x540d56?_0x40dbf2['count']:_0x207321[_0xabb3('0x15')]+_0x207321[_0xabb3('0x17')];var _0x191f18;if(_0x459086>=_0x46c5ce){_0x459086=_0x46c5ce;_0x191f18=0xc8;}else{_0x191f18=0xce;}_0x35b9e4[_0xabb3('0x12')](_0x191f18);return _0x35b9e4[_0xabb3('0x18')](_0xabb3('0x19'),_0x38eff5+'-'+_0x459086+'/'+_0x46c5ce)['json'](_0x40dbf2);}return null;};}function patchUpdates(_0xe528b5){return function(_0x454a27){try{jsonpatch[_0xabb3('0x1a')](_0x454a27,_0xe528b5,!![]);}catch(_0xc9a602){return BPromise['reject'](_0xc9a602);}return _0x454a27[_0xabb3('0x1b')]();};}function saveUpdates(_0x5e6ef1,_0x226e6b){return function(_0x33573b){if(_0x33573b){return _0x33573b[_0xabb3('0x1c')](_0x5e6ef1)['then'](function(_0x222dab){return _0x222dab;});}return null;};}function removeEntity(_0x2b7ca6,_0x82059){return function(_0x41057a){if(_0x41057a){return _0x41057a[_0xabb3('0x1d')]()[_0xabb3('0x1e')](function(){_0x2b7ca6['status'](0xcc)[_0xabb3('0x13')]();});}};}function handleEntityNotFound(_0xeae8a4,_0x33ce84){return function(_0x5f20e1){if(!_0x5f20e1){_0xeae8a4[_0xabb3('0x1f')](0x194);}return _0x5f20e1;};}function handleError(_0x249f18,_0x17befa){_0x17befa=_0x17befa||0x1f4;return function(_0x36cde4){logger[_0xabb3('0x20')](_0x36cde4[_0xabb3('0x21')]);if(_0x36cde4[_0xabb3('0x22')]){delete _0x36cde4[_0xabb3('0x22')];}_0x249f18['status'](_0x17befa)[_0xabb3('0x23')](_0x36cde4);};}exports[_0xabb3('0x24')]=function(_0x52916d,_0x1e3a93){var _0x2db909={},_0x469400={},_0x1e48fd={'count':0x0,'rows':[]};var _0x10dad9=_['map'](db[_0xabb3('0x25')][_0xabb3('0x26')],function(_0x363a73){return{'name':_0x363a73[_0xabb3('0x27')],'type':_0x363a73[_0xabb3('0x28')]['key']};});_0x469400['model']=_[_0xabb3('0x29')](_0x10dad9,_0xabb3('0x22'));_0x469400[_0xabb3('0x2a')]=_[_0xabb3('0x2b')](_0x52916d[_0xabb3('0x2a')]);_0x469400[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0x469400[_0xabb3('0x2e')],_0x469400[_0xabb3('0x2a')]);_0x2db909[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x469400[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x52916d[_0xabb3('0x2a')]['fields']));_0x2db909[_0xabb3('0x2f')]=_0x2db909['attributes'][_0xabb3('0x31')]?_0x2db909[_0xabb3('0x2f')]:_0x469400[_0xabb3('0x2e')];if(!_0x52916d[_0xabb3('0x2a')][_0xabb3('0x32')](_0xabb3('0x33'))){_0x2db909[_0xabb3('0x17')]=qs[_0xabb3('0x17')](_0x52916d[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x2db909[_0xabb3('0x15')]=qs[_0xabb3('0x15')](_0x52916d['query'][_0xabb3('0x15')]);}_0x2db909[_0xabb3('0x34')]=qs[_0xabb3('0x35')](_0x52916d[_0xabb3('0x2a')][_0xabb3('0x35')]);_0x2db909['where']=qs[_0xabb3('0x2c')](_[_0xabb3('0x36')](_0x52916d[_0xabb3('0x2a')],_0x469400[_0xabb3('0x2c')]),_0x10dad9);if(_0x52916d[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x2db909[_0xabb3('0x38')]=_[_0xabb3('0x39')](_0x2db909[_0xabb3('0x38')],{'$or':_['map'](_0x10dad9,function(_0x5db34a){if(_0x5db34a[_0xabb3('0x28')]!==_0xabb3('0x3a')){var _0x1c7d0a={};_0x1c7d0a[_0x5db34a['name']]={'$like':'%'+_0x52916d[_0xabb3('0x2a')]['filter']+'%'};return _0x1c7d0a;}})});}_0x2db909=_[_0xabb3('0x39')]({},_0x2db909,_0x52916d['options']);var _0x5f1b30={'where':_0x2db909['where']};return db['ZohoConfiguration'][_0xabb3('0x3b')](_0x5f1b30)[_0xabb3('0x1e')](function(_0x2daff0){_0x1e48fd[_0xabb3('0x3b')]=_0x2daff0;if(_0x52916d[_0xabb3('0x2a')]['includeAll']){_0x2db909[_0xabb3('0x3c')]=[{'all':!![]}];}return db[_0xabb3('0x25')][_0xabb3('0x3d')](_0x2db909);})[_0xabb3('0x1e')](function(_0x13ca13){_0x1e48fd[_0xabb3('0x3e')]=_0x13ca13;return _0x1e48fd;})[_0xabb3('0x1e')](respondWithFilteredResult(_0x1e3a93,_0x2db909))[_0xabb3('0x3f')](handleError(_0x1e3a93,null));};exports['show']=function(_0x59ea37,_0x4af7a7){var _0x4583f8={'raw':![],'where':{'id':_0x59ea37['params']['id']}},_0x5d54c5={};_0x5d54c5[_0xabb3('0x2e')]=_[_0xabb3('0x2b')](db[_0xabb3('0x25')][_0xabb3('0x26')]);_0x5d54c5[_0xabb3('0x2a')]=_['keys'](_0x59ea37[_0xabb3('0x2a')]);_0x5d54c5[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0x5d54c5[_0xabb3('0x2e')],_0x5d54c5[_0xabb3('0x2a')]);_0x4583f8[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x5d54c5[_0xabb3('0x2e')],qs['fields'](_0x59ea37[_0xabb3('0x2a')][_0xabb3('0x30')]));_0x4583f8['attributes']=_0x4583f8['attributes'][_0xabb3('0x31')]?_0x4583f8['attributes']:_0x5d54c5['model'];if(_0x59ea37[_0xabb3('0x2a')][_0xabb3('0x40')]){_0x4583f8[_0xabb3('0x3c')]=[{'all':!![]}];}_0x4583f8=_[_0xabb3('0x39')]({},_0x4583f8,_0x59ea37['options']);return db[_0xabb3('0x25')][_0xabb3('0x41')](_0x4583f8)[_0xabb3('0x1e')](handleEntityNotFound(_0x4af7a7,null))[_0xabb3('0x1e')](respondWithResult(_0x4af7a7,null))[_0xabb3('0x3f')](handleError(_0x4af7a7,null));};exports['create']=function(_0x465b04,_0x49a3da){return db[_0xabb3('0x25')][_0xabb3('0x42')](_0x465b04[_0xabb3('0x43')],{})[_0xabb3('0x1e')](respondWithResult(_0x49a3da,0xc9))[_0xabb3('0x3f')](handleError(_0x49a3da,null));};exports[_0xabb3('0x1c')]=function(_0x193340,_0x32a0f2){if(_0x193340[_0xabb3('0x43')]['id']){delete _0x193340['body']['id'];}return db[_0xabb3('0x25')][_0xabb3('0x41')]({'where':{'id':_0x193340[_0xabb3('0x44')]['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x32a0f2,null))[_0xabb3('0x1e')](saveUpdates(_0x193340['body'],null))[_0xabb3('0x1e')](respondWithResult(_0x32a0f2,null))[_0xabb3('0x3f')](handleError(_0x32a0f2,null));};exports[_0xabb3('0x1d')]=function(_0x6378a4,_0x1a68ea){return db[_0xabb3('0x25')]['find']({'where':{'id':_0x6378a4['params']['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x1a68ea,null))['then'](removeEntity(_0x1a68ea,null))[_0xabb3('0x3f')](handleError(_0x1a68ea,null));};exports[_0xabb3('0x45')]=function(_0x3dbd79,_0x24448c,_0x15b274){var _0x39906e={};var _0x551317={};var _0x32cbcb;var _0x37ddd2;return db[_0xabb3('0x25')][_0xabb3('0x46')]({'where':{'id':_0x3dbd79[_0xabb3('0x44')]['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x24448c,null))[_0xabb3('0x1e')](function(_0x52aeb4){if(_0x52aeb4){_0x32cbcb=_0x52aeb4;_0x551317[_0xabb3('0x2e')]=_[_0xabb3('0x2b')](db['ZohoField'][_0xabb3('0x26')]);_0x551317[_0xabb3('0x2a')]=_['keys'](_0x3dbd79[_0xabb3('0x2a')]);_0x551317['filters']=_[_0xabb3('0x2d')](_0x551317[_0xabb3('0x2e')],_0x551317['query']);_0x39906e[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x551317[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x3dbd79['query'][_0xabb3('0x30')]));_0x39906e['attributes']=_0x39906e['attributes'][_0xabb3('0x31')]?_0x39906e[_0xabb3('0x2f')]:_0x551317[_0xabb3('0x2e')];_0x39906e['order']=qs[_0xabb3('0x35')](_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x35')]);_0x39906e[_0xabb3('0x38')]=qs[_0xabb3('0x2c')](_[_0xabb3('0x36')](_0x3dbd79[_0xabb3('0x2a')],_0x551317[_0xabb3('0x2c')]));if(_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x39906e['where']=_[_0xabb3('0x39')](_0x39906e[_0xabb3('0x38')],{'$or':_[_0xabb3('0x29')](_0x39906e[_0xabb3('0x2f')],function(_0x77b8b){var _0x14089f={};_0x14089f[_0x77b8b]={'$like':'%'+_0x3dbd79[_0xabb3('0x2a')]['filter']+'%'};return _0x14089f;})});}_0x39906e=_[_0xabb3('0x39')]({},_0x39906e,_0x3dbd79[_0xabb3('0x47')]);return _0x32cbcb['getFields'](_0x39906e);}})['then'](function(_0x31202e){if(_0x31202e){_0x37ddd2=_0x31202e[_0xabb3('0x31')];if(!_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x32')](_0xabb3('0x33'))){_0x39906e[_0xabb3('0x17')]=qs[_0xabb3('0x17')](_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x39906e[_0xabb3('0x15')]=qs[_0xabb3('0x15')](_0x3dbd79[_0xabb3('0x2a')][_0xabb3('0x15')]);}return _0x32cbcb[_0xabb3('0x45')](_0x39906e);}})[_0xabb3('0x1e')](function(_0x4c4ce7){if(_0x4c4ce7){return _0x4c4ce7?{'count':_0x37ddd2,'rows':_0x4c4ce7}:null;}})[_0xabb3('0x1e')](respondWithResult(_0x24448c,null))['catch'](handleError(_0x24448c,null));};exports[_0xabb3('0x48')]=function(_0x2939a9,_0x334ff8,_0x541e29){var _0x45cc15={};var _0xeb5ecc={};var _0x4ae971;var _0x3b8190;return db['ZohoConfiguration'][_0xabb3('0x46')]({'where':{'id':_0x2939a9['params']['id']}})[_0xabb3('0x1e')](handleEntityNotFound(_0x334ff8,null))[_0xabb3('0x1e')](function(_0xc08562){if(_0xc08562){_0x4ae971=_0xc08562;_0xeb5ecc['model']=_[_0xabb3('0x2b')](db[_0xabb3('0x49')]['rawAttributes']);_0xeb5ecc[_0xabb3('0x2a')]=_[_0xabb3('0x2b')](_0x2939a9[_0xabb3('0x2a')]);_0xeb5ecc[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0xeb5ecc[_0xabb3('0x2e')],_0xeb5ecc['query']);_0x45cc15[_0xabb3('0x2f')]=_['intersection'](_0xeb5ecc[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x2939a9['query']['fields']));_0x45cc15[_0xabb3('0x2f')]=_0x45cc15[_0xabb3('0x2f')][_0xabb3('0x31')]?_0x45cc15[_0xabb3('0x2f')]:_0xeb5ecc[_0xabb3('0x2e')];_0x45cc15[_0xabb3('0x34')]=qs[_0xabb3('0x35')](_0x2939a9['query'][_0xabb3('0x35')]);_0x45cc15[_0xabb3('0x38')]=qs['filters'](_[_0xabb3('0x36')](_0x2939a9[_0xabb3('0x2a')],_0xeb5ecc[_0xabb3('0x2c')]));if(_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x45cc15[_0xabb3('0x38')]=_[_0xabb3('0x39')](_0x45cc15[_0xabb3('0x38')],{'$or':_[_0xabb3('0x29')](_0x45cc15[_0xabb3('0x2f')],function(_0x4c0caf){var _0x7fa87b={};_0x7fa87b[_0x4c0caf]={'$like':'%'+_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x37')]+'%'};return _0x7fa87b;})});}_0x45cc15=_[_0xabb3('0x39')]({},_0x45cc15,_0x2939a9[_0xabb3('0x47')]);return _0x4ae971[_0xabb3('0x48')](_0x45cc15);}})[_0xabb3('0x1e')](function(_0x521225){if(_0x521225){_0x3b8190=_0x521225['length'];if(!_0x2939a9['query'][_0xabb3('0x32')](_0xabb3('0x33'))){_0x45cc15['limit']=qs[_0xabb3('0x17')](_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x45cc15[_0xabb3('0x15')]=qs['offset'](_0x2939a9[_0xabb3('0x2a')][_0xabb3('0x15')]);}return _0x4ae971[_0xabb3('0x48')](_0x45cc15);}})[_0xabb3('0x1e')](function(_0x155bc1){if(_0x155bc1){return _0x155bc1?{'count':_0x3b8190,'rows':_0x155bc1}:null;}})[_0xabb3('0x1e')](respondWithResult(_0x334ff8,null))[_0xabb3('0x3f')](handleError(_0x334ff8,null));};exports['getDescriptions']=function(_0x363594,_0x1ad5a4,_0x2af72e){var _0x34ab39={};var _0x2a58ba={};var _0x243423;var _0xfc8a31;return db[_0xabb3('0x25')]['findOne']({'where':{'id':_0x363594[_0xabb3('0x44')]['id']}})['then'](handleEntityNotFound(_0x1ad5a4,null))['then'](function(_0x4d67ef){if(_0x4d67ef){_0x243423=_0x4d67ef;_0x2a58ba[_0xabb3('0x2e')]=_[_0xabb3('0x2b')](db[_0xabb3('0x49')]['rawAttributes']);_0x2a58ba[_0xabb3('0x2a')]=_['keys'](_0x363594['query']);_0x2a58ba[_0xabb3('0x2c')]=_[_0xabb3('0x2d')](_0x2a58ba[_0xabb3('0x2e')],_0x2a58ba[_0xabb3('0x2a')]);_0x34ab39[_0xabb3('0x2f')]=_[_0xabb3('0x2d')](_0x2a58ba[_0xabb3('0x2e')],qs[_0xabb3('0x30')](_0x363594[_0xabb3('0x2a')][_0xabb3('0x30')]));_0x34ab39[_0xabb3('0x2f')]=_0x34ab39[_0xabb3('0x2f')]['length']?_0x34ab39['attributes']:_0x2a58ba[_0xabb3('0x2e')];_0x34ab39[_0xabb3('0x34')]=qs[_0xabb3('0x35')](_0x363594['query'][_0xabb3('0x35')]);_0x34ab39[_0xabb3('0x38')]=qs['filters'](_[_0xabb3('0x36')](_0x363594[_0xabb3('0x2a')],_0x2a58ba[_0xabb3('0x2c')]));if(_0x363594[_0xabb3('0x2a')][_0xabb3('0x37')]){_0x34ab39[_0xabb3('0x38')]=_[_0xabb3('0x39')](_0x34ab39['where'],{'$or':_[_0xabb3('0x29')](_0x34ab39['attributes'],function(_0x300611){var _0x47f898={};_0x47f898[_0x300611]={'$like':'%'+_0x363594[_0xabb3('0x2a')]['filter']+'%'};return _0x47f898;})});}_0x34ab39=_['merge']({},_0x34ab39,_0x363594[_0xabb3('0x47')]);return _0x243423['getDescriptions'](_0x34ab39);}})[_0xabb3('0x1e')](function(_0x30195b){if(_0x30195b){_0xfc8a31=_0x30195b['length'];if(!_0x363594['query'][_0xabb3('0x32')](_0xabb3('0x33'))){_0x34ab39[_0xabb3('0x17')]=qs[_0xabb3('0x17')](_0x363594[_0xabb3('0x2a')][_0xabb3('0x17')]);_0x34ab39[_0xabb3('0x15')]=qs[_0xabb3('0x15')](_0x363594[_0xabb3('0x2a')][_0xabb3('0x15')]);}return _0x243423[_0xabb3('0x4a')](_0x34ab39);}})[_0xabb3('0x1e')](function(_0x4adc53){if(_0x4adc53){return _0x4adc53?{'count':_0xfc8a31,'rows':_0x4adc53}:null;}})[_0xabb3('0x1e')](respondWithResult(_0x1ad5a4,null))[_0xabb3('0x3f')](handleError(_0x1ad5a4,null));};
\ No newline at end of file