Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / intZohoConfiguration / intZohoConfiguration.controller.js
index 5d2c0c6..461dde8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa684=['hasOwnProperty','order','sort','where','pick','filter','merge','includeAll','include','rows','catch','show','params','options','find','body','findOne','ZohoField','getFields','nolimit','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','sox','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','send','ZohoConfiguration','rawAttributes','fieldName','type','key','model','map','name','query','keys','filters','intersection','fields','length','attributes'];(function(_0x8afe8a,_0xde88c9){var _0x13a2df=function(_0x4a15eb){while(--_0x4a15eb){_0x8afe8a['push'](_0x8afe8a['shift']());}};_0x13a2df(++_0xde88c9);}(_0xa684,0x1e4));var _0x4a68=function(_0x2d0589,_0x1bdd0f){_0x2d0589=_0x2d0589-0x0;var _0x464506=_0xa684[_0x2d0589];return _0x464506;};'use strict';var emlformat=require(_0x4a68('0x0'));var rimraf=require(_0x4a68('0x1'));var zipdir=require(_0x4a68('0x2'));var jsonpatch=require(_0x4a68('0x3'));var rp=require(_0x4a68('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x4a68('0x5'));var csv=require('to-csv');var ejs=require(_0x4a68('0x6'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x4a68('0x7'));var squel=require('squel');var crypto=require(_0x4a68('0x8'));var jsforce=require(_0x4a68('0x9'));var deskjs=require(_0x4a68('0xa'));var toCsv=require('to-csv');var querystring=require(_0x4a68('0xb'));var Papa=require(_0x4a68('0xc'));var Redis=require(_0x4a68('0xd'));var authService=require(_0x4a68('0xe'));var qs=require(_0x4a68('0xf'));var as=require(_0x4a68('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x4a68('0x11'));var utils=require(_0x4a68('0x12'));var config=require(_0x4a68('0x13'));var licenseUtil=require(_0x4a68('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1b3b62,_0x594c38){_0x594c38=_0x594c38||0xcc;return function(_0x48685f){if(_0x48685f){return _0x1b3b62[_0x4a68('0x15')](_0x594c38);}return _0x1b3b62[_0x4a68('0x16')](_0x594c38)[_0x4a68('0x17')]();};}function respondWithResult(_0x193bed,_0xf832f2){_0xf832f2=_0xf832f2||0xc8;return function(_0x7dfb46){if(_0x7dfb46){return _0x193bed[_0x4a68('0x16')](_0xf832f2)[_0x4a68('0x18')](_0x7dfb46);}};}function respondWithFilteredResult(_0x28c84e,_0xb2cd84){return function(_0x569400){if(_0x569400){var _0x37fa1e=typeof _0xb2cd84[_0x4a68('0x19')]===_0x4a68('0x1a')&&typeof _0xb2cd84['limit']===_0x4a68('0x1a');var _0x2f4b01=_0x569400[_0x4a68('0x1b')];var _0xf02558=_0x37fa1e?0x0:_0xb2cd84['offset'];var _0x386924=_0x37fa1e?_0x569400[_0x4a68('0x1b')]:_0xb2cd84['offset']+_0xb2cd84[_0x4a68('0x1c')];var _0x1a691d;if(_0x386924>=_0x2f4b01){_0x386924=_0x2f4b01;_0x1a691d=0xc8;}else{_0x1a691d=0xce;}_0x28c84e[_0x4a68('0x16')](_0x1a691d);return _0x28c84e[_0x4a68('0x1d')](_0x4a68('0x1e'),_0xf02558+'-'+_0x386924+'/'+_0x2f4b01)[_0x4a68('0x18')](_0x569400);}return null;};}function patchUpdates(_0x91334f){return function(_0x247841){try{jsonpatch[_0x4a68('0x1f')](_0x247841,_0x91334f,!![]);}catch(_0x1ada18){return BPromise[_0x4a68('0x20')](_0x1ada18);}return _0x247841[_0x4a68('0x21')]();};}function saveUpdates(_0x4a3928,_0x293ce3){return function(_0x25c1de){if(_0x25c1de){return _0x25c1de[_0x4a68('0x22')](_0x4a3928)[_0x4a68('0x23')](function(_0xc53bf2){return _0xc53bf2;});}return null;};}function removeEntity(_0x4524ec,_0x2d1ebc){return function(_0x3c49b7){if(_0x3c49b7){return _0x3c49b7[_0x4a68('0x24')]()[_0x4a68('0x23')](function(){_0x4524ec[_0x4a68('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x288ee9,_0x244e07){return function(_0x140df1){if(!_0x140df1){_0x288ee9[_0x4a68('0x15')](0x194);}return _0x140df1;};}function handleError(_0x3c1f14,_0x32572a){_0x32572a=_0x32572a||0x1f4;return function(_0x1e21a0){logger[_0x4a68('0x25')](_0x1e21a0[_0x4a68('0x26')]);if(_0x1e21a0['name']){delete _0x1e21a0['name'];}_0x3c1f14[_0x4a68('0x16')](_0x32572a)[_0x4a68('0x27')](_0x1e21a0);};}exports['index']=function(_0x43a26d,_0x4e173a){var _0x42db52={},_0x414a8d={},_0x46ae68={'count':0x0,'rows':[]};var _0x4ec48e=_['map'](db[_0x4a68('0x28')][_0x4a68('0x29')],function(_0x18edbb){return{'name':_0x18edbb[_0x4a68('0x2a')],'type':_0x18edbb[_0x4a68('0x2b')][_0x4a68('0x2c')]};});_0x414a8d[_0x4a68('0x2d')]=_[_0x4a68('0x2e')](_0x4ec48e,_0x4a68('0x2f'));_0x414a8d[_0x4a68('0x30')]=_[_0x4a68('0x31')](_0x43a26d[_0x4a68('0x30')]);_0x414a8d[_0x4a68('0x32')]=_[_0x4a68('0x33')](_0x414a8d[_0x4a68('0x2d')],_0x414a8d[_0x4a68('0x30')]);_0x42db52['attributes']=_['intersection'](_0x414a8d[_0x4a68('0x2d')],qs[_0x4a68('0x34')](_0x43a26d[_0x4a68('0x30')][_0x4a68('0x34')]));_0x42db52['attributes']=_0x42db52['attributes'][_0x4a68('0x35')]?_0x42db52[_0x4a68('0x36')]:_0x414a8d[_0x4a68('0x2d')];if(!_0x43a26d[_0x4a68('0x30')][_0x4a68('0x37')]('nolimit')){_0x42db52[_0x4a68('0x1c')]=qs[_0x4a68('0x1c')](_0x43a26d[_0x4a68('0x30')]['limit']);_0x42db52['offset']=qs[_0x4a68('0x19')](_0x43a26d[_0x4a68('0x30')]['offset']);}_0x42db52[_0x4a68('0x38')]=qs[_0x4a68('0x39')](_0x43a26d[_0x4a68('0x30')][_0x4a68('0x39')]);_0x42db52[_0x4a68('0x3a')]=qs[_0x4a68('0x32')](_[_0x4a68('0x3b')](_0x43a26d[_0x4a68('0x30')],_0x414a8d[_0x4a68('0x32')]),_0x4ec48e);if(_0x43a26d['query'][_0x4a68('0x3c')]){_0x42db52[_0x4a68('0x3a')]=_['merge'](_0x42db52[_0x4a68('0x3a')],{'$or':_[_0x4a68('0x2e')](_0x4ec48e,function(_0x234c2c){if(_0x234c2c[_0x4a68('0x2b')]!=='VIRTUAL'){var _0x4287ca={};_0x4287ca[_0x234c2c[_0x4a68('0x2f')]]={'$like':'%'+_0x43a26d[_0x4a68('0x30')][_0x4a68('0x3c')]+'%'};return _0x4287ca;}})});}_0x42db52=_[_0x4a68('0x3d')]({},_0x42db52,_0x43a26d['options']);var _0x39ae11={'where':_0x42db52[_0x4a68('0x3a')]};return db['ZohoConfiguration'][_0x4a68('0x1b')](_0x39ae11)['then'](function(_0x4818bb){_0x46ae68[_0x4a68('0x1b')]=_0x4818bb;if(_0x43a26d[_0x4a68('0x30')][_0x4a68('0x3e')]){_0x42db52[_0x4a68('0x3f')]=[{'all':!![]}];}return db[_0x4a68('0x28')]['findAll'](_0x42db52);})[_0x4a68('0x23')](function(_0x9afb2){_0x46ae68[_0x4a68('0x40')]=_0x9afb2;return _0x46ae68;})[_0x4a68('0x23')](respondWithFilteredResult(_0x4e173a,_0x42db52))[_0x4a68('0x41')](handleError(_0x4e173a,null));};exports[_0x4a68('0x42')]=function(_0x3f6b06,_0x38c7b1){var _0x4120fe={'raw':![],'where':{'id':_0x3f6b06[_0x4a68('0x43')]['id']}},_0x18d583={};_0x18d583[_0x4a68('0x2d')]=_[_0x4a68('0x31')](db[_0x4a68('0x28')][_0x4a68('0x29')]);_0x18d583[_0x4a68('0x30')]=_[_0x4a68('0x31')](_0x3f6b06['query']);_0x18d583[_0x4a68('0x32')]=_[_0x4a68('0x33')](_0x18d583[_0x4a68('0x2d')],_0x18d583[_0x4a68('0x30')]);_0x4120fe[_0x4a68('0x36')]=_[_0x4a68('0x33')](_0x18d583[_0x4a68('0x2d')],qs[_0x4a68('0x34')](_0x3f6b06[_0x4a68('0x30')]['fields']));_0x4120fe[_0x4a68('0x36')]=_0x4120fe[_0x4a68('0x36')]['length']?_0x4120fe[_0x4a68('0x36')]:_0x18d583[_0x4a68('0x2d')];if(_0x3f6b06[_0x4a68('0x30')][_0x4a68('0x3e')]){_0x4120fe[_0x4a68('0x3f')]=[{'all':!![]}];}_0x4120fe=_[_0x4a68('0x3d')]({},_0x4120fe,_0x3f6b06[_0x4a68('0x44')]);return db[_0x4a68('0x28')][_0x4a68('0x45')](_0x4120fe)[_0x4a68('0x23')](handleEntityNotFound(_0x38c7b1,null))[_0x4a68('0x23')](respondWithResult(_0x38c7b1,null))[_0x4a68('0x41')](handleError(_0x38c7b1,null));};exports['create']=function(_0x4fcb5b,_0x404d46){return db['ZohoConfiguration']['create'](_0x4fcb5b[_0x4a68('0x46')],{})[_0x4a68('0x23')](respondWithResult(_0x404d46,0xc9))[_0x4a68('0x41')](handleError(_0x404d46,null));};exports[_0x4a68('0x22')]=function(_0x54aa6a,_0x1aeaea){if(_0x54aa6a['body']['id']){delete _0x54aa6a[_0x4a68('0x46')]['id'];}return db[_0x4a68('0x28')]['find']({'where':{'id':_0x54aa6a[_0x4a68('0x43')]['id']}})['then'](handleEntityNotFound(_0x1aeaea,null))[_0x4a68('0x23')](saveUpdates(_0x54aa6a['body'],null))[_0x4a68('0x23')](respondWithResult(_0x1aeaea,null))[_0x4a68('0x41')](handleError(_0x1aeaea,null));};exports[_0x4a68('0x24')]=function(_0x16bf70,_0xf72835){return db[_0x4a68('0x28')][_0x4a68('0x45')]({'where':{'id':_0x16bf70[_0x4a68('0x43')]['id']}})[_0x4a68('0x23')](handleEntityNotFound(_0xf72835,null))[_0x4a68('0x23')](removeEntity(_0xf72835,null))[_0x4a68('0x41')](handleError(_0xf72835,null));};exports['getFields']=function(_0x2c3ef2,_0x385350,_0x54be12){var _0x20278d={};var _0xba8834={};var _0x590b41;var _0x5bbc8f;return db[_0x4a68('0x28')][_0x4a68('0x47')]({'where':{'id':_0x2c3ef2[_0x4a68('0x43')]['id']}})[_0x4a68('0x23')](handleEntityNotFound(_0x385350,null))[_0x4a68('0x23')](function(_0x405e16){if(_0x405e16){_0x590b41=_0x405e16;_0xba8834[_0x4a68('0x2d')]=_[_0x4a68('0x31')](db[_0x4a68('0x48')]['rawAttributes']);_0xba8834[_0x4a68('0x30')]=_[_0x4a68('0x31')](_0x2c3ef2[_0x4a68('0x30')]);_0xba8834[_0x4a68('0x32')]=_['intersection'](_0xba8834['model'],_0xba8834[_0x4a68('0x30')]);_0x20278d[_0x4a68('0x36')]=_[_0x4a68('0x33')](_0xba8834[_0x4a68('0x2d')],qs[_0x4a68('0x34')](_0x2c3ef2[_0x4a68('0x30')][_0x4a68('0x34')]));_0x20278d[_0x4a68('0x36')]=_0x20278d[_0x4a68('0x36')][_0x4a68('0x35')]?_0x20278d['attributes']:_0xba8834['model'];_0x20278d[_0x4a68('0x38')]=qs[_0x4a68('0x39')](_0x2c3ef2['query'][_0x4a68('0x39')]);_0x20278d['where']=qs[_0x4a68('0x32')](_[_0x4a68('0x3b')](_0x2c3ef2['query'],_0xba8834[_0x4a68('0x32')]));if(_0x2c3ef2[_0x4a68('0x30')][_0x4a68('0x3c')]){_0x20278d['where']=_[_0x4a68('0x3d')](_0x20278d['where'],{'$or':_['map'](_0x20278d['attributes'],function(_0x15fd06){var _0x178d72={};_0x178d72[_0x15fd06]={'$like':'%'+_0x2c3ef2[_0x4a68('0x30')][_0x4a68('0x3c')]+'%'};return _0x178d72;})});}_0x20278d=_[_0x4a68('0x3d')]({},_0x20278d,_0x2c3ef2[_0x4a68('0x44')]);return _0x590b41[_0x4a68('0x49')](_0x20278d);}})[_0x4a68('0x23')](function(_0x1ae7f6){if(_0x1ae7f6){_0x5bbc8f=_0x1ae7f6['length'];if(!_0x2c3ef2[_0x4a68('0x30')][_0x4a68('0x37')](_0x4a68('0x4a'))){_0x20278d['limit']=qs[_0x4a68('0x1c')](_0x2c3ef2['query'][_0x4a68('0x1c')]);_0x20278d[_0x4a68('0x19')]=qs[_0x4a68('0x19')](_0x2c3ef2[_0x4a68('0x30')][_0x4a68('0x19')]);}return _0x590b41[_0x4a68('0x49')](_0x20278d);}})[_0x4a68('0x23')](function(_0x50571c){if(_0x50571c){return _0x50571c?{'count':_0x5bbc8f,'rows':_0x50571c}:null;}})[_0x4a68('0x23')](respondWithResult(_0x385350,null))[_0x4a68('0x41')](handleError(_0x385350,null));};exports[_0x4a68('0x4b')]=function(_0x5827f3,_0x171109,_0x5dfdfd){var _0x599387={};var _0x3b0969={};var _0x44553b;var _0x3ee534;return db['ZohoConfiguration'][_0x4a68('0x47')]({'where':{'id':_0x5827f3[_0x4a68('0x43')]['id']}})[_0x4a68('0x23')](handleEntityNotFound(_0x171109,null))[_0x4a68('0x23')](function(_0x366a7d){if(_0x366a7d){_0x44553b=_0x366a7d;_0x3b0969['model']=_[_0x4a68('0x31')](db[_0x4a68('0x48')][_0x4a68('0x29')]);_0x3b0969[_0x4a68('0x30')]=_['keys'](_0x5827f3[_0x4a68('0x30')]);_0x3b0969[_0x4a68('0x32')]=_[_0x4a68('0x33')](_0x3b0969['model'],_0x3b0969['query']);_0x599387[_0x4a68('0x36')]=_[_0x4a68('0x33')](_0x3b0969[_0x4a68('0x2d')],qs[_0x4a68('0x34')](_0x5827f3['query'][_0x4a68('0x34')]));_0x599387[_0x4a68('0x36')]=_0x599387[_0x4a68('0x36')][_0x4a68('0x35')]?_0x599387[_0x4a68('0x36')]:_0x3b0969['model'];_0x599387[_0x4a68('0x38')]=qs[_0x4a68('0x39')](_0x5827f3[_0x4a68('0x30')][_0x4a68('0x39')]);_0x599387[_0x4a68('0x3a')]=qs[_0x4a68('0x32')](_[_0x4a68('0x3b')](_0x5827f3[_0x4a68('0x30')],_0x3b0969[_0x4a68('0x32')]));if(_0x5827f3[_0x4a68('0x30')][_0x4a68('0x3c')]){_0x599387[_0x4a68('0x3a')]=_[_0x4a68('0x3d')](_0x599387['where'],{'$or':_[_0x4a68('0x2e')](_0x599387[_0x4a68('0x36')],function(_0x458e36){var _0x2d6966={};_0x2d6966[_0x458e36]={'$like':'%'+_0x5827f3[_0x4a68('0x30')]['filter']+'%'};return _0x2d6966;})});}_0x599387=_[_0x4a68('0x3d')]({},_0x599387,_0x5827f3[_0x4a68('0x44')]);return _0x44553b[_0x4a68('0x4b')](_0x599387);}})['then'](function(_0xdb86a6){if(_0xdb86a6){_0x3ee534=_0xdb86a6[_0x4a68('0x35')];if(!_0x5827f3[_0x4a68('0x30')][_0x4a68('0x37')](_0x4a68('0x4a'))){_0x599387[_0x4a68('0x1c')]=qs['limit'](_0x5827f3[_0x4a68('0x30')]['limit']);_0x599387[_0x4a68('0x19')]=qs[_0x4a68('0x19')](_0x5827f3[_0x4a68('0x30')][_0x4a68('0x19')]);}return _0x44553b[_0x4a68('0x4b')](_0x599387);}})[_0x4a68('0x23')](function(_0x365b16){if(_0x365b16){return _0x365b16?{'count':_0x3ee534,'rows':_0x365b16}:null;}})[_0x4a68('0x23')](respondWithResult(_0x171109,null))[_0x4a68('0x41')](handleError(_0x171109,null));};exports['getDescriptions']=function(_0x3dffd6,_0x256917,_0x3a4cb6){var _0x31305a={};var _0x9ebeca={};var _0x5646db;var _0x281340;return db[_0x4a68('0x28')]['findOne']({'where':{'id':_0x3dffd6[_0x4a68('0x43')]['id']}})[_0x4a68('0x23')](handleEntityNotFound(_0x256917,null))[_0x4a68('0x23')](function(_0x1715cc){if(_0x1715cc){_0x5646db=_0x1715cc;_0x9ebeca[_0x4a68('0x2d')]=_[_0x4a68('0x31')](db[_0x4a68('0x48')][_0x4a68('0x29')]);_0x9ebeca[_0x4a68('0x30')]=_[_0x4a68('0x31')](_0x3dffd6['query']);_0x9ebeca[_0x4a68('0x32')]=_['intersection'](_0x9ebeca[_0x4a68('0x2d')],_0x9ebeca[_0x4a68('0x30')]);_0x31305a['attributes']=_['intersection'](_0x9ebeca[_0x4a68('0x2d')],qs[_0x4a68('0x34')](_0x3dffd6[_0x4a68('0x30')]['fields']));_0x31305a[_0x4a68('0x36')]=_0x31305a[_0x4a68('0x36')]['length']?_0x31305a[_0x4a68('0x36')]:_0x9ebeca[_0x4a68('0x2d')];_0x31305a['order']=qs[_0x4a68('0x39')](_0x3dffd6[_0x4a68('0x30')]['sort']);_0x31305a['where']=qs[_0x4a68('0x32')](_[_0x4a68('0x3b')](_0x3dffd6[_0x4a68('0x30')],_0x9ebeca['filters']));if(_0x3dffd6['query'][_0x4a68('0x3c')]){_0x31305a[_0x4a68('0x3a')]=_[_0x4a68('0x3d')](_0x31305a['where'],{'$or':_[_0x4a68('0x2e')](_0x31305a['attributes'],function(_0x40b169){var _0x53e44b={};_0x53e44b[_0x40b169]={'$like':'%'+_0x3dffd6[_0x4a68('0x30')]['filter']+'%'};return _0x53e44b;})});}_0x31305a=_[_0x4a68('0x3d')]({},_0x31305a,_0x3dffd6[_0x4a68('0x44')]);return _0x5646db[_0x4a68('0x4c')](_0x31305a);}})[_0x4a68('0x23')](function(_0x42f234){if(_0x42f234){_0x281340=_0x42f234[_0x4a68('0x35')];if(!_0x3dffd6[_0x4a68('0x30')][_0x4a68('0x37')](_0x4a68('0x4a'))){_0x31305a[_0x4a68('0x1c')]=qs[_0x4a68('0x1c')](_0x3dffd6[_0x4a68('0x30')]['limit']);_0x31305a['offset']=qs[_0x4a68('0x19')](_0x3dffd6['query'][_0x4a68('0x19')]);}return _0x5646db[_0x4a68('0x4c')](_0x31305a);}})[_0x4a68('0x23')](function(_0x474282){if(_0x474282){return _0x474282?{'count':_0x281340,'rows':_0x474282}:null;}})[_0x4a68('0x23')](respondWithResult(_0x256917,null))[_0x4a68('0x41')](handleError(_0x256917,null));};
\ No newline at end of file
+var _0xacc8=['rows','catch','show','params','rawAttributes','find','create','body','getFields','ZohoField','nolimit','getSubjects','findOne','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../mysqldb','sendStatus','end','status','offset','undefined','limit','count','set','Content-Range','json','reject','save','update','then','destroy','error','stack','name','send','index','map','ZohoConfiguration','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','merge','filter','options','includeAll','include','findAll'];(function(_0x5e7d27,_0x5d4dd9){var _0x4539a1=function(_0x1b9bbe){while(--_0x1b9bbe){_0x5e7d27['push'](_0x5e7d27['shift']());}};_0x4539a1(++_0x5d4dd9);}(_0xacc8,0xb2));var _0x8acc=function(_0x48a4bc,_0x19e9aa){_0x48a4bc=_0x48a4bc-0x0;var _0x1a27bd=_0xacc8[_0x48a4bc];return _0x1a27bd;};'use strict';var emlformat=require(_0x8acc('0x0'));var rimraf=require(_0x8acc('0x1'));var zipdir=require(_0x8acc('0x2'));var jsonpatch=require(_0x8acc('0x3'));var rp=require('request-promise');var moment=require(_0x8acc('0x4'));var BPromise=require(_0x8acc('0x5'));var Mustache=require(_0x8acc('0x6'));var util=require(_0x8acc('0x7'));var path=require(_0x8acc('0x8'));var sox=require(_0x8acc('0x9'));var csv=require(_0x8acc('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x8acc('0xb'));var _=require(_0x8acc('0xc'));var squel=require(_0x8acc('0xd'));var crypto=require(_0x8acc('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x8acc('0xf'));var toCsv=require(_0x8acc('0xa'));var querystring=require(_0x8acc('0x10'));var Papa=require(_0x8acc('0x11'));var Redis=require(_0x8acc('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x8acc('0x13'));var as=require(_0x8acc('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x8acc('0x15'))(_0x8acc('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x8acc('0x17'))['db'];function respondWithStatusCode(_0x57aa29,_0x1b7f5e){_0x1b7f5e=_0x1b7f5e||0xcc;return function(_0x2c37be){if(_0x2c37be){return _0x57aa29[_0x8acc('0x18')](_0x1b7f5e);}return _0x57aa29['status'](_0x1b7f5e)[_0x8acc('0x19')]();};}function respondWithResult(_0xf031a6,_0x302775){_0x302775=_0x302775||0xc8;return function(_0x2da8f9){if(_0x2da8f9){return _0xf031a6[_0x8acc('0x1a')](_0x302775)['json'](_0x2da8f9);}};}function respondWithFilteredResult(_0x2d779a,_0x4618ac){return function(_0x580a9e){if(_0x580a9e){var _0xbfc9e4=typeof _0x4618ac[_0x8acc('0x1b')]===_0x8acc('0x1c')&&typeof _0x4618ac[_0x8acc('0x1d')]===_0x8acc('0x1c');var _0x3f87ad=_0x580a9e[_0x8acc('0x1e')];var _0x768f8e=_0xbfc9e4?0x0:_0x4618ac[_0x8acc('0x1b')];var _0x2defd0=_0xbfc9e4?_0x580a9e['count']:_0x4618ac[_0x8acc('0x1b')]+_0x4618ac[_0x8acc('0x1d')];var _0x542f84;if(_0x2defd0>=_0x3f87ad){_0x2defd0=_0x3f87ad;_0x542f84=0xc8;}else{_0x542f84=0xce;}_0x2d779a['status'](_0x542f84);return _0x2d779a[_0x8acc('0x1f')](_0x8acc('0x20'),_0x768f8e+'-'+_0x2defd0+'/'+_0x3f87ad)[_0x8acc('0x21')](_0x580a9e);}return null;};}function patchUpdates(_0x47f599){return function(_0x58add1){try{jsonpatch['apply'](_0x58add1,_0x47f599,!![]);}catch(_0x2b48a7){return BPromise[_0x8acc('0x22')](_0x2b48a7);}return _0x58add1[_0x8acc('0x23')]();};}function saveUpdates(_0x470df7,_0x49ba27){return function(_0x619f74){if(_0x619f74){return _0x619f74[_0x8acc('0x24')](_0x470df7)[_0x8acc('0x25')](function(_0x193e1c){return _0x193e1c;});}return null;};}function removeEntity(_0x771a48,_0xf73491){return function(_0x5608ab){if(_0x5608ab){return _0x5608ab[_0x8acc('0x26')]()['then'](function(){_0x771a48[_0x8acc('0x1a')](0xcc)[_0x8acc('0x19')]();});}};}function handleEntityNotFound(_0x4f35bc,_0x23d037){return function(_0xe95ad8){if(!_0xe95ad8){_0x4f35bc[_0x8acc('0x18')](0x194);}return _0xe95ad8;};}function handleError(_0x22f4b7,_0x52c72e){_0x52c72e=_0x52c72e||0x1f4;return function(_0x1167de){logger[_0x8acc('0x27')](_0x1167de[_0x8acc('0x28')]);if(_0x1167de[_0x8acc('0x29')]){delete _0x1167de[_0x8acc('0x29')];}_0x22f4b7['status'](_0x52c72e)[_0x8acc('0x2a')](_0x1167de);};}exports[_0x8acc('0x2b')]=function(_0xcd8fba,_0x59110e){var _0x44112e={},_0x15909b={},_0x1872e4={'count':0x0,'rows':[]};var _0x5f5688=_[_0x8acc('0x2c')](db[_0x8acc('0x2d')]['rawAttributes'],function(_0x5755a0){return{'name':_0x5755a0[_0x8acc('0x2e')],'type':_0x5755a0[_0x8acc('0x2f')][_0x8acc('0x30')]};});_0x15909b[_0x8acc('0x31')]=_[_0x8acc('0x2c')](_0x5f5688,_0x8acc('0x29'));_0x15909b[_0x8acc('0x32')]=_[_0x8acc('0x33')](_0xcd8fba[_0x8acc('0x32')]);_0x15909b[_0x8acc('0x34')]=_[_0x8acc('0x35')](_0x15909b[_0x8acc('0x31')],_0x15909b[_0x8acc('0x32')]);_0x44112e[_0x8acc('0x36')]=_[_0x8acc('0x35')](_0x15909b[_0x8acc('0x31')],qs['fields'](_0xcd8fba[_0x8acc('0x32')][_0x8acc('0x37')]));_0x44112e[_0x8acc('0x36')]=_0x44112e[_0x8acc('0x36')][_0x8acc('0x38')]?_0x44112e[_0x8acc('0x36')]:_0x15909b['model'];if(!_0xcd8fba[_0x8acc('0x32')][_0x8acc('0x39')]('nolimit')){_0x44112e['limit']=qs[_0x8acc('0x1d')](_0xcd8fba['query'][_0x8acc('0x1d')]);_0x44112e[_0x8acc('0x1b')]=qs['offset'](_0xcd8fba[_0x8acc('0x32')][_0x8acc('0x1b')]);}_0x44112e[_0x8acc('0x3a')]=qs[_0x8acc('0x3b')](_0xcd8fba[_0x8acc('0x32')]['sort']);_0x44112e[_0x8acc('0x3c')]=qs[_0x8acc('0x34')](_[_0x8acc('0x3d')](_0xcd8fba[_0x8acc('0x32')],_0x15909b[_0x8acc('0x34')]),_0x5f5688);if(_0xcd8fba['query']['filter']){_0x44112e[_0x8acc('0x3c')]=_[_0x8acc('0x3e')](_0x44112e[_0x8acc('0x3c')],{'$or':_[_0x8acc('0x2c')](_0x5f5688,function(_0x2607f0){if(_0x2607f0[_0x8acc('0x2f')]!=='VIRTUAL'){var _0x5f322d={};_0x5f322d[_0x2607f0[_0x8acc('0x29')]]={'$like':'%'+_0xcd8fba[_0x8acc('0x32')][_0x8acc('0x3f')]+'%'};return _0x5f322d;}})});}_0x44112e=_[_0x8acc('0x3e')]({},_0x44112e,_0xcd8fba[_0x8acc('0x40')]);var _0x10c921={'where':_0x44112e['where']};return db[_0x8acc('0x2d')][_0x8acc('0x1e')](_0x10c921)[_0x8acc('0x25')](function(_0x2c734f){_0x1872e4[_0x8acc('0x1e')]=_0x2c734f;if(_0xcd8fba[_0x8acc('0x32')][_0x8acc('0x41')]){_0x44112e[_0x8acc('0x42')]=[{'all':!![]}];}return db[_0x8acc('0x2d')][_0x8acc('0x43')](_0x44112e);})[_0x8acc('0x25')](function(_0x550200){_0x1872e4[_0x8acc('0x44')]=_0x550200;return _0x1872e4;})[_0x8acc('0x25')](respondWithFilteredResult(_0x59110e,_0x44112e))[_0x8acc('0x45')](handleError(_0x59110e,null));};exports[_0x8acc('0x46')]=function(_0x511dd8,_0x3fb67f){var _0xcac1f3={'raw':![],'where':{'id':_0x511dd8[_0x8acc('0x47')]['id']}},_0x24e389={};_0x24e389[_0x8acc('0x31')]=_[_0x8acc('0x33')](db[_0x8acc('0x2d')][_0x8acc('0x48')]);_0x24e389[_0x8acc('0x32')]=_[_0x8acc('0x33')](_0x511dd8[_0x8acc('0x32')]);_0x24e389[_0x8acc('0x34')]=_[_0x8acc('0x35')](_0x24e389[_0x8acc('0x31')],_0x24e389[_0x8acc('0x32')]);_0xcac1f3['attributes']=_['intersection'](_0x24e389[_0x8acc('0x31')],qs['fields'](_0x511dd8[_0x8acc('0x32')][_0x8acc('0x37')]));_0xcac1f3[_0x8acc('0x36')]=_0xcac1f3['attributes'][_0x8acc('0x38')]?_0xcac1f3[_0x8acc('0x36')]:_0x24e389[_0x8acc('0x31')];if(_0x511dd8[_0x8acc('0x32')][_0x8acc('0x41')]){_0xcac1f3[_0x8acc('0x42')]=[{'all':!![]}];}_0xcac1f3=_[_0x8acc('0x3e')]({},_0xcac1f3,_0x511dd8['options']);return db['ZohoConfiguration'][_0x8acc('0x49')](_0xcac1f3)['then'](handleEntityNotFound(_0x3fb67f,null))[_0x8acc('0x25')](respondWithResult(_0x3fb67f,null))[_0x8acc('0x45')](handleError(_0x3fb67f,null));};exports[_0x8acc('0x4a')]=function(_0x471b9b,_0x2e9e3f){return db[_0x8acc('0x2d')][_0x8acc('0x4a')](_0x471b9b[_0x8acc('0x4b')],{})[_0x8acc('0x25')](respondWithResult(_0x2e9e3f,0xc9))['catch'](handleError(_0x2e9e3f,null));};exports[_0x8acc('0x24')]=function(_0x40c2aa,_0x15cf24){if(_0x40c2aa[_0x8acc('0x4b')]['id']){delete _0x40c2aa[_0x8acc('0x4b')]['id'];}return db[_0x8acc('0x2d')][_0x8acc('0x49')]({'where':{'id':_0x40c2aa[_0x8acc('0x47')]['id']}})[_0x8acc('0x25')](handleEntityNotFound(_0x15cf24,null))['then'](saveUpdates(_0x40c2aa[_0x8acc('0x4b')],null))[_0x8acc('0x25')](respondWithResult(_0x15cf24,null))[_0x8acc('0x45')](handleError(_0x15cf24,null));};exports[_0x8acc('0x26')]=function(_0xe59ab8,_0x22e8b1){return db[_0x8acc('0x2d')]['find']({'where':{'id':_0xe59ab8['params']['id']}})[_0x8acc('0x25')](handleEntityNotFound(_0x22e8b1,null))[_0x8acc('0x25')](removeEntity(_0x22e8b1,null))['catch'](handleError(_0x22e8b1,null));};exports[_0x8acc('0x4c')]=function(_0x16379a,_0x287f2f,_0x194033){var _0x279588={};var _0xdb7f7c={};var _0x4fdb22;var _0x4605bc;return db[_0x8acc('0x2d')]['findOne']({'where':{'id':_0x16379a[_0x8acc('0x47')]['id']}})[_0x8acc('0x25')](handleEntityNotFound(_0x287f2f,null))[_0x8acc('0x25')](function(_0x9422e0){if(_0x9422e0){_0x4fdb22=_0x9422e0;_0xdb7f7c['model']=_['keys'](db[_0x8acc('0x4d')][_0x8acc('0x48')]);_0xdb7f7c[_0x8acc('0x32')]=_[_0x8acc('0x33')](_0x16379a[_0x8acc('0x32')]);_0xdb7f7c['filters']=_['intersection'](_0xdb7f7c[_0x8acc('0x31')],_0xdb7f7c[_0x8acc('0x32')]);_0x279588[_0x8acc('0x36')]=_[_0x8acc('0x35')](_0xdb7f7c[_0x8acc('0x31')],qs['fields'](_0x16379a['query'][_0x8acc('0x37')]));_0x279588[_0x8acc('0x36')]=_0x279588['attributes'][_0x8acc('0x38')]?_0x279588[_0x8acc('0x36')]:_0xdb7f7c[_0x8acc('0x31')];_0x279588[_0x8acc('0x3a')]=qs[_0x8acc('0x3b')](_0x16379a['query'][_0x8acc('0x3b')]);_0x279588[_0x8acc('0x3c')]=qs['filters'](_['pick'](_0x16379a[_0x8acc('0x32')],_0xdb7f7c[_0x8acc('0x34')]));if(_0x16379a[_0x8acc('0x32')][_0x8acc('0x3f')]){_0x279588[_0x8acc('0x3c')]=_[_0x8acc('0x3e')](_0x279588['where'],{'$or':_[_0x8acc('0x2c')](_0x279588['attributes'],function(_0x3c1945){var _0x2f9999={};_0x2f9999[_0x3c1945]={'$like':'%'+_0x16379a[_0x8acc('0x32')][_0x8acc('0x3f')]+'%'};return _0x2f9999;})});}_0x279588=_[_0x8acc('0x3e')]({},_0x279588,_0x16379a[_0x8acc('0x40')]);return _0x4fdb22['getFields'](_0x279588);}})[_0x8acc('0x25')](function(_0x1660bb){if(_0x1660bb){_0x4605bc=_0x1660bb['length'];if(!_0x16379a[_0x8acc('0x32')][_0x8acc('0x39')](_0x8acc('0x4e'))){_0x279588['limit']=qs['limit'](_0x16379a[_0x8acc('0x32')][_0x8acc('0x1d')]);_0x279588[_0x8acc('0x1b')]=qs[_0x8acc('0x1b')](_0x16379a[_0x8acc('0x32')][_0x8acc('0x1b')]);}return _0x4fdb22[_0x8acc('0x4c')](_0x279588);}})['then'](function(_0x246927){if(_0x246927){return _0x246927?{'count':_0x4605bc,'rows':_0x246927}:null;}})[_0x8acc('0x25')](respondWithResult(_0x287f2f,null))[_0x8acc('0x45')](handleError(_0x287f2f,null));};exports[_0x8acc('0x4f')]=function(_0x1c331c,_0x556063,_0x12b8c9){var _0x1cc37f={};var _0x242b1a={};var _0x2a827a;var _0x473a6e;return db[_0x8acc('0x2d')][_0x8acc('0x50')]({'where':{'id':_0x1c331c['params']['id']}})[_0x8acc('0x25')](handleEntityNotFound(_0x556063,null))['then'](function(_0x558a96){if(_0x558a96){_0x2a827a=_0x558a96;_0x242b1a['model']=_[_0x8acc('0x33')](db[_0x8acc('0x4d')]['rawAttributes']);_0x242b1a[_0x8acc('0x32')]=_['keys'](_0x1c331c[_0x8acc('0x32')]);_0x242b1a[_0x8acc('0x34')]=_[_0x8acc('0x35')](_0x242b1a[_0x8acc('0x31')],_0x242b1a[_0x8acc('0x32')]);_0x1cc37f[_0x8acc('0x36')]=_['intersection'](_0x242b1a['model'],qs[_0x8acc('0x37')](_0x1c331c['query'][_0x8acc('0x37')]));_0x1cc37f[_0x8acc('0x36')]=_0x1cc37f['attributes'][_0x8acc('0x38')]?_0x1cc37f[_0x8acc('0x36')]:_0x242b1a[_0x8acc('0x31')];_0x1cc37f[_0x8acc('0x3a')]=qs['sort'](_0x1c331c['query'][_0x8acc('0x3b')]);_0x1cc37f[_0x8acc('0x3c')]=qs[_0x8acc('0x34')](_[_0x8acc('0x3d')](_0x1c331c[_0x8acc('0x32')],_0x242b1a[_0x8acc('0x34')]));if(_0x1c331c['query']['filter']){_0x1cc37f['where']=_['merge'](_0x1cc37f['where'],{'$or':_[_0x8acc('0x2c')](_0x1cc37f[_0x8acc('0x36')],function(_0x347d92){var _0x181dd3={};_0x181dd3[_0x347d92]={'$like':'%'+_0x1c331c[_0x8acc('0x32')][_0x8acc('0x3f')]+'%'};return _0x181dd3;})});}_0x1cc37f=_[_0x8acc('0x3e')]({},_0x1cc37f,_0x1c331c[_0x8acc('0x40')]);return _0x2a827a['getSubjects'](_0x1cc37f);}})[_0x8acc('0x25')](function(_0x9997f6){if(_0x9997f6){_0x473a6e=_0x9997f6[_0x8acc('0x38')];if(!_0x1c331c[_0x8acc('0x32')][_0x8acc('0x39')](_0x8acc('0x4e'))){_0x1cc37f[_0x8acc('0x1d')]=qs[_0x8acc('0x1d')](_0x1c331c[_0x8acc('0x32')][_0x8acc('0x1d')]);_0x1cc37f[_0x8acc('0x1b')]=qs[_0x8acc('0x1b')](_0x1c331c[_0x8acc('0x32')][_0x8acc('0x1b')]);}return _0x2a827a[_0x8acc('0x4f')](_0x1cc37f);}})['then'](function(_0x57681f){if(_0x57681f){return _0x57681f?{'count':_0x473a6e,'rows':_0x57681f}:null;}})[_0x8acc('0x25')](respondWithResult(_0x556063,null))[_0x8acc('0x45')](handleError(_0x556063,null));};exports['getDescriptions']=function(_0x329c6a,_0x24dc37,_0xd61c2e){var _0x1856a4={};var _0x3c673b={};var _0x2f0475;var _0x395e45;return db[_0x8acc('0x2d')][_0x8acc('0x50')]({'where':{'id':_0x329c6a['params']['id']}})[_0x8acc('0x25')](handleEntityNotFound(_0x24dc37,null))[_0x8acc('0x25')](function(_0x3cdb75){if(_0x3cdb75){_0x2f0475=_0x3cdb75;_0x3c673b[_0x8acc('0x31')]=_[_0x8acc('0x33')](db[_0x8acc('0x4d')][_0x8acc('0x48')]);_0x3c673b[_0x8acc('0x32')]=_[_0x8acc('0x33')](_0x329c6a[_0x8acc('0x32')]);_0x3c673b[_0x8acc('0x34')]=_[_0x8acc('0x35')](_0x3c673b['model'],_0x3c673b[_0x8acc('0x32')]);_0x1856a4['attributes']=_['intersection'](_0x3c673b[_0x8acc('0x31')],qs[_0x8acc('0x37')](_0x329c6a[_0x8acc('0x32')][_0x8acc('0x37')]));_0x1856a4[_0x8acc('0x36')]=_0x1856a4[_0x8acc('0x36')][_0x8acc('0x38')]?_0x1856a4[_0x8acc('0x36')]:_0x3c673b['model'];_0x1856a4[_0x8acc('0x3a')]=qs['sort'](_0x329c6a[_0x8acc('0x32')]['sort']);_0x1856a4[_0x8acc('0x3c')]=qs[_0x8acc('0x34')](_[_0x8acc('0x3d')](_0x329c6a[_0x8acc('0x32')],_0x3c673b[_0x8acc('0x34')]));if(_0x329c6a[_0x8acc('0x32')]['filter']){_0x1856a4[_0x8acc('0x3c')]=_[_0x8acc('0x3e')](_0x1856a4[_0x8acc('0x3c')],{'$or':_[_0x8acc('0x2c')](_0x1856a4[_0x8acc('0x36')],function(_0x4a870a){var _0x4ede50={};_0x4ede50[_0x4a870a]={'$like':'%'+_0x329c6a[_0x8acc('0x32')][_0x8acc('0x3f')]+'%'};return _0x4ede50;})});}_0x1856a4=_[_0x8acc('0x3e')]({},_0x1856a4,_0x329c6a[_0x8acc('0x40')]);return _0x2f0475[_0x8acc('0x51')](_0x1856a4);}})['then'](function(_0x53e685){if(_0x53e685){_0x395e45=_0x53e685[_0x8acc('0x38')];if(!_0x329c6a[_0x8acc('0x32')]['hasOwnProperty'](_0x8acc('0x4e'))){_0x1856a4[_0x8acc('0x1d')]=qs[_0x8acc('0x1d')](_0x329c6a[_0x8acc('0x32')]['limit']);_0x1856a4[_0x8acc('0x1b')]=qs['offset'](_0x329c6a[_0x8acc('0x32')]['offset']);}return _0x2f0475[_0x8acc('0x51')](_0x1856a4);}})[_0x8acc('0x25')](function(_0x1034ba){if(_0x1034ba){return _0x1034ba?{'count':_0x395e45,'rows':_0x1034ba}:null;}})['then'](respondWithResult(_0x24dc37,null))['catch'](handleError(_0x24dc37,null));};
\ No newline at end of file