Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index 7757f87..7dcc66a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1776=['catch','create','body','hasOwnProperty','limit','getFields','VtigerField','getSubjects','getDescriptions','findOne','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','info','VtigerConfiguration,\x20%s,\x20%s','request\x20sent','error','code','message','status','json','count','offset','Content-Range','reject','update','destroy','then','end','stack','name','index','map','VtigerConfiguration','fieldName','type','model','query','keys','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','include','findAll','rows','params','rawAttributes','length','includeAll','find'];(function(_0x51731f,_0x15b4ce){var _0x35d00b=function(_0x3031d2){while(--_0x3031d2){_0x51731f['push'](_0x51731f['shift']());}};_0x35d00b(++_0x15b4ce);}(_0x1776,0x15a));var _0x6177=function(_0x51ba20,_0x50bf39){_0x51ba20=_0x51ba20-0x0;var _0x773908=_0x1776[_0x51ba20];return _0x773908;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x6177('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6177('0x1'));var rp=require(_0x6177('0x2'));var moment=require(_0x6177('0x3'));var BPromise=require(_0x6177('0x4'));var Mustache=require(_0x6177('0x5'));var util=require('util');var path=require(_0x6177('0x6'));var sox=require(_0x6177('0x7'));var csv=require(_0x6177('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x6177('0x9'));var crypto=require(_0x6177('0xa'));var jsforce=require(_0x6177('0xb'));var deskjs=require(_0x6177('0xc'));var toCsv=require(_0x6177('0x8'));var querystring=require(_0x6177('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x6177('0xe'));var as=require(_0x6177('0xf'));var hardwareService=require(_0x6177('0x10'));var logger=require(_0x6177('0x11'))(_0x6177('0x12'));var utils=require(_0x6177('0x13'));var config=require(_0x6177('0x14'));var licenseUtil=require(_0x6177('0x15'));var db=require(_0x6177('0x16'))['db'];var jayson=require(_0x6177('0x17'));var client=jayson[_0x6177('0x18')][_0x6177('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x380097,_0x97ee35,_0x497729,_0x1eed7c){return new BPromise(function(_0x5b7b45,_0x423e7e){var _0x365ad0=_0x1eed7c||client;return _0x365ad0[_0x6177('0x1a')](_0x380097,_0x497729)['then'](function(_0x1d144c){logger[_0x6177('0x1b')](_0x6177('0x1c'),_0x97ee35,_0x6177('0x1d'));logger['debug']('VtigerConfiguration,\x20%s,\x20%s,\x20%s',_0x97ee35,_0x6177('0x1d'),JSON['stringify'](_0x1d144c));if(_0x1d144c[_0x6177('0x1e')]){if(_0x1d144c[_0x6177('0x1e')][_0x6177('0x1f')]===0x1f4){logger['error'](_0x6177('0x1c'),_0x97ee35,_0x1d144c[_0x6177('0x1e')]['message']);return _0x423e7e(_0x1d144c['error']['message']);}logger[_0x6177('0x1e')](_0x6177('0x1c'),_0x97ee35,_0x1d144c[_0x6177('0x1e')][_0x6177('0x20')]);return _0x5b7b45(_0x1d144c[_0x6177('0x1e')][_0x6177('0x20')]);}else{logger['info'](_0x6177('0x1c'),_0x97ee35,'request\x20sent');_0x5b7b45(_0x1d144c['result'][_0x6177('0x20')]);}})['catch'](function(_0x15342a){logger['error'](_0x6177('0x1c'),_0x97ee35,_0x15342a);_0x423e7e(_0x15342a);});});}function respondWithStatusCode(_0x4abb90,_0x237383){_0x237383=_0x237383||0xcc;return function(_0x2033ec){if(_0x2033ec){return _0x4abb90['sendStatus'](_0x237383);}return _0x4abb90[_0x6177('0x21')](_0x237383)['end']();};}function respondWithResult(_0x5c09b2,_0x41f2d1){_0x41f2d1=_0x41f2d1||0xc8;return function(_0x3a16d1){if(_0x3a16d1){return _0x5c09b2[_0x6177('0x21')](_0x41f2d1)[_0x6177('0x22')](_0x3a16d1);}};}function respondWithFilteredResult(_0x590167,_0x453fd8){return function(_0x572657){if(_0x572657){var _0x2f1de1=_0x572657[_0x6177('0x23')],_0x4233a1=_0x453fd8['offset'],_0x1567fb=_0x453fd8[_0x6177('0x24')]+_0x453fd8['limit'],_0x3748ee;if(_0x1567fb>=_0x2f1de1){_0x1567fb=_0x2f1de1;_0x3748ee=0xc8;}else{_0x3748ee=0xce;}_0x590167[_0x6177('0x21')](_0x3748ee);return _0x590167['set'](_0x6177('0x25'),_0x4233a1+'-'+_0x1567fb+'/'+_0x2f1de1)[_0x6177('0x22')](_0x572657);}return null;};}function patchUpdates(_0x42c33b){return function(_0x331749){try{jsonpatch['apply'](_0x331749,_0x42c33b,!![]);}catch(_0x4e25c6){return BPromise[_0x6177('0x26')](_0x4e25c6);}return _0x331749['save']();};}function saveUpdates(_0x15658f,_0x15e4d1){return function(_0x1000d6){if(_0x1000d6){return _0x1000d6[_0x6177('0x27')](_0x15658f)['then'](function(_0x4a4f2a){return _0x4a4f2a;});}return null;};}function removeEntity(_0xb4fc3d,_0x9d1a25){return function(_0x64314a){if(_0x64314a){return _0x64314a[_0x6177('0x28')]()[_0x6177('0x29')](function(){_0xb4fc3d[_0x6177('0x21')](0xcc)[_0x6177('0x2a')]();});}};}function handleEntityNotFound(_0x3da9fa,_0x5f5ee3){return function(_0x23cad5){if(!_0x23cad5){_0x3da9fa['sendStatus'](0x194);}return _0x23cad5;};}function handleError(_0x5601f7,_0x5f5120){_0x5f5120=_0x5f5120||0x1f4;return function(_0x341d22){logger[_0x6177('0x1e')](_0x341d22[_0x6177('0x2b')]);if(_0x341d22[_0x6177('0x2c')]){delete _0x341d22['name'];}_0x5601f7[_0x6177('0x21')](_0x5f5120)['send'](_0x341d22);};}exports[_0x6177('0x2d')]=function(_0x17ad12,_0xccafe7){var _0x3b3a39={},_0x26b4f2={},_0x43c665={'count':0x0,'rows':[]};var _0x2a0ac4=_[_0x6177('0x2e')](db[_0x6177('0x2f')]['rawAttributes'],function(_0x235368){return{'name':_0x235368[_0x6177('0x30')],'type':_0x235368[_0x6177('0x31')]['key']};});_0x26b4f2[_0x6177('0x32')]=_['map'](_0x2a0ac4,_0x6177('0x2c'));_0x26b4f2[_0x6177('0x33')]=_[_0x6177('0x34')](_0x17ad12['query']);_0x26b4f2[_0x6177('0x35')]=_['intersection'](_0x26b4f2[_0x6177('0x32')],_0x26b4f2[_0x6177('0x33')]);_0x3b3a39['attributes']=_[_0x6177('0x36')](_0x26b4f2[_0x6177('0x32')],qs[_0x6177('0x37')](_0x17ad12[_0x6177('0x33')]['fields']));_0x3b3a39['attributes']=_0x3b3a39[_0x6177('0x38')]['length']?_0x3b3a39['attributes']:_0x26b4f2[_0x6177('0x32')];if(!_0x17ad12['query']['hasOwnProperty'](_0x6177('0x39'))){_0x3b3a39['limit']=qs['limit'](_0x17ad12[_0x6177('0x33')]['limit']);_0x3b3a39['offset']=qs[_0x6177('0x24')](_0x17ad12[_0x6177('0x33')]['offset']);}_0x3b3a39[_0x6177('0x3a')]=qs['sort'](_0x17ad12[_0x6177('0x33')][_0x6177('0x3b')]);_0x3b3a39[_0x6177('0x3c')]=qs['filters'](_[_0x6177('0x3d')](_0x17ad12['query'],_0x26b4f2[_0x6177('0x35')]),_0x2a0ac4);if(_0x17ad12[_0x6177('0x33')]['filter']){_0x3b3a39[_0x6177('0x3c')]=_[_0x6177('0x3e')](_0x3b3a39['where'],{'$or':_[_0x6177('0x2e')](_0x2a0ac4,function(_0x34157e){if(_0x34157e[_0x6177('0x31')]!==_0x6177('0x3f')){var _0x1dda6c={};_0x1dda6c[_0x34157e[_0x6177('0x2c')]]={'$like':'%'+_0x17ad12[_0x6177('0x33')][_0x6177('0x40')]+'%'};return _0x1dda6c;}})});}_0x3b3a39=_['merge']({},_0x3b3a39,_0x17ad12[_0x6177('0x41')]);var _0x5b2cbf={'where':_0x3b3a39[_0x6177('0x3c')]};return db[_0x6177('0x2f')][_0x6177('0x23')](_0x5b2cbf)[_0x6177('0x29')](function(_0x4568c3){_0x43c665[_0x6177('0x23')]=_0x4568c3;if(_0x17ad12['query']['includeAll']){_0x3b3a39[_0x6177('0x42')]=[{'all':!![]}];}return db[_0x6177('0x2f')][_0x6177('0x43')](_0x3b3a39);})[_0x6177('0x29')](function(_0x1c53d0){_0x43c665[_0x6177('0x44')]=_0x1c53d0;return _0x43c665;})[_0x6177('0x29')](respondWithFilteredResult(_0xccafe7,_0x3b3a39))['catch'](handleError(_0xccafe7,null));};exports['show']=function(_0xebb0c0,_0x43b5bf){var _0x1e6e9c={'raw':![],'where':{'id':_0xebb0c0[_0x6177('0x45')]['id']}},_0x82194b={};_0x82194b[_0x6177('0x32')]=_[_0x6177('0x34')](db[_0x6177('0x2f')][_0x6177('0x46')]);_0x82194b[_0x6177('0x33')]=_[_0x6177('0x34')](_0xebb0c0[_0x6177('0x33')]);_0x82194b[_0x6177('0x35')]=_[_0x6177('0x36')](_0x82194b[_0x6177('0x32')],_0x82194b['query']);_0x1e6e9c[_0x6177('0x38')]=_['intersection'](_0x82194b[_0x6177('0x32')],qs['fields'](_0xebb0c0[_0x6177('0x33')][_0x6177('0x37')]));_0x1e6e9c[_0x6177('0x38')]=_0x1e6e9c['attributes'][_0x6177('0x47')]?_0x1e6e9c[_0x6177('0x38')]:_0x82194b[_0x6177('0x32')];if(_0xebb0c0[_0x6177('0x33')][_0x6177('0x48')]){_0x1e6e9c[_0x6177('0x42')]=[{'all':!![]}];}_0x1e6e9c=_[_0x6177('0x3e')]({},_0x1e6e9c,_0xebb0c0[_0x6177('0x41')]);return db[_0x6177('0x2f')][_0x6177('0x49')](_0x1e6e9c)['then'](handleEntityNotFound(_0x43b5bf,null))[_0x6177('0x29')](respondWithResult(_0x43b5bf,null))[_0x6177('0x4a')](handleError(_0x43b5bf,null));};exports[_0x6177('0x4b')]=function(_0x3545c1,_0x1639bb){return db[_0x6177('0x2f')][_0x6177('0x4b')](_0x3545c1[_0x6177('0x4c')],{})[_0x6177('0x29')](respondWithResult(_0x1639bb,0xc9))[_0x6177('0x4a')](handleError(_0x1639bb,null));};exports[_0x6177('0x27')]=function(_0xd94b03,_0x344b74){if(_0xd94b03[_0x6177('0x4c')]['id']){delete _0xd94b03[_0x6177('0x4c')]['id'];}return db['VtigerConfiguration'][_0x6177('0x49')]({'where':{'id':_0xd94b03['params']['id']}})[_0x6177('0x29')](handleEntityNotFound(_0x344b74,null))[_0x6177('0x29')](saveUpdates(_0xd94b03[_0x6177('0x4c')],null))[_0x6177('0x29')](respondWithResult(_0x344b74,null))[_0x6177('0x4a')](handleError(_0x344b74,null));};exports[_0x6177('0x28')]=function(_0x44302a,_0x5c7dd5){return db[_0x6177('0x2f')][_0x6177('0x49')]({'where':{'id':_0x44302a[_0x6177('0x45')]['id']}})[_0x6177('0x29')](handleEntityNotFound(_0x5c7dd5,null))[_0x6177('0x29')](removeEntity(_0x5c7dd5,null))['catch'](handleError(_0x5c7dd5,null));};exports['getFields']=function(_0x5e0bb7,_0xa45ecf,_0x421c8e){var _0x48932e={};var _0xab1c8d={};var _0x414ab4;var _0xa0aee;return db[_0x6177('0x2f')]['findOne']({'where':{'id':_0x5e0bb7['params']['id']}})[_0x6177('0x29')](handleEntityNotFound(_0xa45ecf,null))[_0x6177('0x29')](function(_0x4f89ff){if(_0x4f89ff){_0x414ab4=_0x4f89ff;_0xab1c8d[_0x6177('0x32')]=_['keys'](db['VtigerField'][_0x6177('0x46')]);_0xab1c8d[_0x6177('0x33')]=_[_0x6177('0x34')](_0x5e0bb7[_0x6177('0x33')]);_0xab1c8d[_0x6177('0x35')]=_['intersection'](_0xab1c8d[_0x6177('0x32')],_0xab1c8d[_0x6177('0x33')]);_0x48932e[_0x6177('0x38')]=_[_0x6177('0x36')](_0xab1c8d[_0x6177('0x32')],qs[_0x6177('0x37')](_0x5e0bb7['query'][_0x6177('0x37')]));_0x48932e[_0x6177('0x38')]=_0x48932e[_0x6177('0x38')]['length']?_0x48932e['attributes']:_0xab1c8d[_0x6177('0x32')];_0x48932e[_0x6177('0x3a')]=qs['sort'](_0x5e0bb7[_0x6177('0x33')]['sort']);_0x48932e[_0x6177('0x3c')]=qs[_0x6177('0x35')](_[_0x6177('0x3d')](_0x5e0bb7[_0x6177('0x33')],_0xab1c8d[_0x6177('0x35')]));if(_0x5e0bb7['query'][_0x6177('0x40')]){_0x48932e[_0x6177('0x3c')]=_['merge'](_0x48932e['where'],{'$or':_[_0x6177('0x2e')](_0x48932e[_0x6177('0x38')],function(_0x354f2b){var _0x4649ec={};_0x4649ec[_0x354f2b]={'$like':'%'+_0x5e0bb7[_0x6177('0x33')][_0x6177('0x40')]+'%'};return _0x4649ec;})});}_0x48932e=_[_0x6177('0x3e')]({},_0x48932e,_0x5e0bb7[_0x6177('0x41')]);return _0x414ab4['getFields'](_0x48932e);}})[_0x6177('0x29')](function(_0x353e83){if(_0x353e83){_0xa0aee=_0x353e83[_0x6177('0x47')];if(!_0x5e0bb7[_0x6177('0x33')][_0x6177('0x4d')](_0x6177('0x39'))){_0x48932e['limit']=qs[_0x6177('0x4e')](_0x5e0bb7['query']['limit']);_0x48932e['offset']=qs[_0x6177('0x24')](_0x5e0bb7['query']['offset']);}return _0x414ab4[_0x6177('0x4f')](_0x48932e);}})[_0x6177('0x29')](function(_0x38c036){if(_0x38c036){return _0x38c036?{'count':_0xa0aee,'rows':_0x38c036}:null;}})[_0x6177('0x29')](respondWithResult(_0xa45ecf,null))['catch'](handleError(_0xa45ecf,null));};exports['getSubjects']=function(_0x4aa4f9,_0x24768f,_0x14a6c2){var _0x5920cd={};var _0x2f4d89={};var _0x3cf4e2;var _0x530d30;return db[_0x6177('0x2f')]['findOne']({'where':{'id':_0x4aa4f9[_0x6177('0x45')]['id']}})[_0x6177('0x29')](handleEntityNotFound(_0x24768f,null))[_0x6177('0x29')](function(_0x105324){if(_0x105324){_0x3cf4e2=_0x105324;_0x2f4d89[_0x6177('0x32')]=_[_0x6177('0x34')](db[_0x6177('0x50')]['rawAttributes']);_0x2f4d89[_0x6177('0x33')]=_['keys'](_0x4aa4f9[_0x6177('0x33')]);_0x2f4d89['filters']=_[_0x6177('0x36')](_0x2f4d89[_0x6177('0x32')],_0x2f4d89[_0x6177('0x33')]);_0x5920cd[_0x6177('0x38')]=_[_0x6177('0x36')](_0x2f4d89[_0x6177('0x32')],qs['fields'](_0x4aa4f9[_0x6177('0x33')][_0x6177('0x37')]));_0x5920cd[_0x6177('0x38')]=_0x5920cd[_0x6177('0x38')][_0x6177('0x47')]?_0x5920cd[_0x6177('0x38')]:_0x2f4d89['model'];_0x5920cd[_0x6177('0x3a')]=qs[_0x6177('0x3b')](_0x4aa4f9['query'][_0x6177('0x3b')]);_0x5920cd[_0x6177('0x3c')]=qs[_0x6177('0x35')](_['pick'](_0x4aa4f9[_0x6177('0x33')],_0x2f4d89['filters']));if(_0x4aa4f9['query']['filter']){_0x5920cd[_0x6177('0x3c')]=_['merge'](_0x5920cd[_0x6177('0x3c')],{'$or':_['map'](_0x5920cd[_0x6177('0x38')],function(_0x66cb2f){var _0x1bc935={};_0x1bc935[_0x66cb2f]={'$like':'%'+_0x4aa4f9[_0x6177('0x33')][_0x6177('0x40')]+'%'};return _0x1bc935;})});}_0x5920cd=_[_0x6177('0x3e')]({},_0x5920cd,_0x4aa4f9['options']);return _0x3cf4e2[_0x6177('0x51')](_0x5920cd);}})[_0x6177('0x29')](function(_0x1053a6){if(_0x1053a6){_0x530d30=_0x1053a6[_0x6177('0x47')];if(!_0x4aa4f9['query'][_0x6177('0x4d')](_0x6177('0x39'))){_0x5920cd['limit']=qs[_0x6177('0x4e')](_0x4aa4f9[_0x6177('0x33')][_0x6177('0x4e')]);_0x5920cd[_0x6177('0x24')]=qs['offset'](_0x4aa4f9[_0x6177('0x33')][_0x6177('0x24')]);}return _0x3cf4e2[_0x6177('0x51')](_0x5920cd);}})['then'](function(_0x7c31bb){if(_0x7c31bb){return _0x7c31bb?{'count':_0x530d30,'rows':_0x7c31bb}:null;}})[_0x6177('0x29')](respondWithResult(_0x24768f,null))[_0x6177('0x4a')](handleError(_0x24768f,null));};exports[_0x6177('0x52')]=function(_0x289e1e,_0x2148a4,_0x25fb7f){var _0x2795e4={};var _0x11b63f={};var _0x54543b;var _0x1a361b;return db[_0x6177('0x2f')][_0x6177('0x53')]({'where':{'id':_0x289e1e[_0x6177('0x45')]['id']}})[_0x6177('0x29')](handleEntityNotFound(_0x2148a4,null))['then'](function(_0x468793){if(_0x468793){_0x54543b=_0x468793;_0x11b63f['model']=_['keys'](db[_0x6177('0x50')]['rawAttributes']);_0x11b63f[_0x6177('0x33')]=_[_0x6177('0x34')](_0x289e1e['query']);_0x11b63f[_0x6177('0x35')]=_[_0x6177('0x36')](_0x11b63f[_0x6177('0x32')],_0x11b63f['query']);_0x2795e4['attributes']=_[_0x6177('0x36')](_0x11b63f[_0x6177('0x32')],qs['fields'](_0x289e1e[_0x6177('0x33')][_0x6177('0x37')]));_0x2795e4[_0x6177('0x38')]=_0x2795e4[_0x6177('0x38')][_0x6177('0x47')]?_0x2795e4[_0x6177('0x38')]:_0x11b63f[_0x6177('0x32')];_0x2795e4['order']=qs[_0x6177('0x3b')](_0x289e1e['query'][_0x6177('0x3b')]);_0x2795e4['where']=qs[_0x6177('0x35')](_[_0x6177('0x3d')](_0x289e1e[_0x6177('0x33')],_0x11b63f[_0x6177('0x35')]));if(_0x289e1e[_0x6177('0x33')]['filter']){_0x2795e4[_0x6177('0x3c')]=_['merge'](_0x2795e4[_0x6177('0x3c')],{'$or':_[_0x6177('0x2e')](_0x2795e4[_0x6177('0x38')],function(_0xa5a7e3){var _0x40e07a={};_0x40e07a[_0xa5a7e3]={'$like':'%'+_0x289e1e[_0x6177('0x33')][_0x6177('0x40')]+'%'};return _0x40e07a;})});}_0x2795e4=_['merge']({},_0x2795e4,_0x289e1e['options']);return _0x54543b[_0x6177('0x52')](_0x2795e4);}})['then'](function(_0x303d72){if(_0x303d72){_0x1a361b=_0x303d72[_0x6177('0x47')];if(!_0x289e1e[_0x6177('0x33')][_0x6177('0x4d')](_0x6177('0x39'))){_0x2795e4[_0x6177('0x4e')]=qs['limit'](_0x289e1e['query']['limit']);_0x2795e4[_0x6177('0x24')]=qs['offset'](_0x289e1e['query'][_0x6177('0x24')]);}return _0x54543b[_0x6177('0x52')](_0x2795e4);}})[_0x6177('0x29')](function(_0x1720e0){if(_0x1720e0){return _0x1720e0?{'count':_0x1a361b,'rows':_0x1720e0}:null;}})[_0x6177('0x29')](respondWithResult(_0x2148a4,null))[_0x6177('0x4a')](handleError(_0x2148a4,null));};
\ No newline at end of file
+var _0xf71b=['ejs','lodash','squel','crypto','querystring','ioredis','../../components/auth/service','../../config/license/hardware','api','../../config/environment','../../mysqldb','sendStatus','end','offset','undefined','limit','count','status','set','Content-Range','json','apply','update','destroy','then','error','stack','name','send','map','VtigerConfiguration','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','VIRTUAL','includeAll','findAll','rows','catch','show','params','keys','options','find','create','body','getFields','findOne','VtigerField','order','getSubjects','pick','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv'];(function(_0xa763c1,_0xb5e51){var _0x3774c0=function(_0x30d0dc){while(--_0x30d0dc){_0xa763c1['push'](_0xa763c1['shift']());}};_0x3774c0(++_0xb5e51);}(_0xf71b,0x8e));var _0xbf71=function(_0x50924b,_0x56851c){_0x50924b=_0x50924b-0x0;var _0x1815a4=_0xf71b[_0x50924b];return _0x1815a4;};'use strict';var emlformat=require(_0xbf71('0x0'));var rimraf=require(_0xbf71('0x1'));var zipdir=require(_0xbf71('0x2'));var jsonpatch=require(_0xbf71('0x3'));var rp=require(_0xbf71('0x4'));var moment=require(_0xbf71('0x5'));var BPromise=require(_0xbf71('0x6'));var Mustache=require('mustache');var util=require(_0xbf71('0x7'));var path=require('path');var sox=require(_0xbf71('0x8'));var csv=require(_0xbf71('0x9'));var ejs=require(_0xbf71('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbf71('0xb'));var squel=require(_0xbf71('0xc'));var crypto=require(_0xbf71('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xbf71('0x9'));var querystring=require(_0xbf71('0xe'));var Papa=require('papaparse');var Redis=require(_0xbf71('0xf'));var authService=require(_0xbf71('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbf71('0x11'));var logger=require('../../config/logger')(_0xbf71('0x12'));var utils=require('../../config/utils');var config=require(_0xbf71('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0xbf71('0x14'))['db'];function respondWithStatusCode(_0x5bb27c,_0x59756a){_0x59756a=_0x59756a||0xcc;return function(_0x1f7527){if(_0x1f7527){return _0x5bb27c[_0xbf71('0x15')](_0x59756a);}return _0x5bb27c['status'](_0x59756a)[_0xbf71('0x16')]();};}function respondWithResult(_0x3a6955,_0x3c93cd){_0x3c93cd=_0x3c93cd||0xc8;return function(_0x443d02){if(_0x443d02){return _0x3a6955['status'](_0x3c93cd)['json'](_0x443d02);}};}function respondWithFilteredResult(_0x1f7074,_0x1709b6){return function(_0x4e0f2c){if(_0x4e0f2c){var _0x55c2bf=typeof _0x1709b6[_0xbf71('0x17')]===_0xbf71('0x18')&&typeof _0x1709b6[_0xbf71('0x19')]===_0xbf71('0x18');var _0x5ef59d=_0x4e0f2c[_0xbf71('0x1a')];var _0x3db5e4=_0x55c2bf?0x0:_0x1709b6[_0xbf71('0x17')];var _0x490cb=_0x55c2bf?_0x4e0f2c[_0xbf71('0x1a')]:_0x1709b6[_0xbf71('0x17')]+_0x1709b6[_0xbf71('0x19')];var _0x476e52;if(_0x490cb>=_0x5ef59d){_0x490cb=_0x5ef59d;_0x476e52=0xc8;}else{_0x476e52=0xce;}_0x1f7074[_0xbf71('0x1b')](_0x476e52);return _0x1f7074[_0xbf71('0x1c')](_0xbf71('0x1d'),_0x3db5e4+'-'+_0x490cb+'/'+_0x5ef59d)[_0xbf71('0x1e')](_0x4e0f2c);}return null;};}function patchUpdates(_0xc2d725){return function(_0x375aab){try{jsonpatch[_0xbf71('0x1f')](_0x375aab,_0xc2d725,!![]);}catch(_0x1561c0){return BPromise['reject'](_0x1561c0);}return _0x375aab['save']();};}function saveUpdates(_0x525498,_0x4144e0){return function(_0x25b10e){if(_0x25b10e){return _0x25b10e[_0xbf71('0x20')](_0x525498)['then'](function(_0x47573e){return _0x47573e;});}return null;};}function removeEntity(_0x327220,_0x117a8a){return function(_0x48556a){if(_0x48556a){return _0x48556a[_0xbf71('0x21')]()[_0xbf71('0x22')](function(){_0x327220[_0xbf71('0x1b')](0xcc)[_0xbf71('0x16')]();});}};}function handleEntityNotFound(_0x2056b6,_0x207686){return function(_0x4cba63){if(!_0x4cba63){_0x2056b6['sendStatus'](0x194);}return _0x4cba63;};}function handleError(_0x158654,_0x5c324a){_0x5c324a=_0x5c324a||0x1f4;return function(_0x30790d){logger[_0xbf71('0x23')](_0x30790d[_0xbf71('0x24')]);if(_0x30790d[_0xbf71('0x25')]){delete _0x30790d[_0xbf71('0x25')];}_0x158654[_0xbf71('0x1b')](_0x5c324a)[_0xbf71('0x26')](_0x30790d);};}exports['index']=function(_0x523119,_0x165198){var _0x292869={},_0x5a4564={},_0x5aaefc={'count':0x0,'rows':[]};var _0x223382=_[_0xbf71('0x27')](db[_0xbf71('0x28')][_0xbf71('0x29')],function(_0x5227b1){return{'name':_0x5227b1[_0xbf71('0x2a')],'type':_0x5227b1[_0xbf71('0x2b')]['key']};});_0x5a4564[_0xbf71('0x2c')]=_[_0xbf71('0x27')](_0x223382,_0xbf71('0x25'));_0x5a4564[_0xbf71('0x2d')]=_['keys'](_0x523119[_0xbf71('0x2d')]);_0x5a4564[_0xbf71('0x2e')]=_[_0xbf71('0x2f')](_0x5a4564['model'],_0x5a4564[_0xbf71('0x2d')]);_0x292869[_0xbf71('0x30')]=_[_0xbf71('0x2f')](_0x5a4564[_0xbf71('0x2c')],qs[_0xbf71('0x31')](_0x523119[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x292869['attributes']=_0x292869['attributes'][_0xbf71('0x32')]?_0x292869[_0xbf71('0x30')]:_0x5a4564[_0xbf71('0x2c')];if(!_0x523119['query'][_0xbf71('0x33')](_0xbf71('0x34'))){_0x292869['limit']=qs['limit'](_0x523119[_0xbf71('0x2d')][_0xbf71('0x19')]);_0x292869['offset']=qs[_0xbf71('0x17')](_0x523119[_0xbf71('0x2d')][_0xbf71('0x17')]);}_0x292869['order']=qs[_0xbf71('0x35')](_0x523119[_0xbf71('0x2d')][_0xbf71('0x35')]);_0x292869[_0xbf71('0x36')]=qs[_0xbf71('0x2e')](_['pick'](_0x523119[_0xbf71('0x2d')],_0x5a4564[_0xbf71('0x2e')]),_0x223382);if(_0x523119[_0xbf71('0x2d')][_0xbf71('0x37')]){_0x292869[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0x292869[_0xbf71('0x36')],{'$or':_[_0xbf71('0x27')](_0x223382,function(_0x16d1e7){if(_0x16d1e7['type']!==_0xbf71('0x39')){var _0x343d6c={};_0x343d6c[_0x16d1e7[_0xbf71('0x25')]]={'$like':'%'+_0x523119['query'][_0xbf71('0x37')]+'%'};return _0x343d6c;}})});}_0x292869=_[_0xbf71('0x38')]({},_0x292869,_0x523119['options']);var _0x301cc9={'where':_0x292869['where']};return db[_0xbf71('0x28')]['count'](_0x301cc9)[_0xbf71('0x22')](function(_0x20148c){_0x5aaefc['count']=_0x20148c;if(_0x523119[_0xbf71('0x2d')][_0xbf71('0x3a')]){_0x292869['include']=[{'all':!![]}];}return db[_0xbf71('0x28')][_0xbf71('0x3b')](_0x292869);})[_0xbf71('0x22')](function(_0x51a720){_0x5aaefc[_0xbf71('0x3c')]=_0x51a720;return _0x5aaefc;})[_0xbf71('0x22')](respondWithFilteredResult(_0x165198,_0x292869))[_0xbf71('0x3d')](handleError(_0x165198,null));};exports[_0xbf71('0x3e')]=function(_0x46d7a4,_0x4976bc){var _0x561d41={'raw':![],'where':{'id':_0x46d7a4[_0xbf71('0x3f')]['id']}},_0x290eef={};_0x290eef[_0xbf71('0x2c')]=_['keys'](db['VtigerConfiguration'][_0xbf71('0x29')]);_0x290eef[_0xbf71('0x2d')]=_[_0xbf71('0x40')](_0x46d7a4['query']);_0x290eef[_0xbf71('0x2e')]=_[_0xbf71('0x2f')](_0x290eef[_0xbf71('0x2c')],_0x290eef[_0xbf71('0x2d')]);_0x561d41[_0xbf71('0x30')]=_[_0xbf71('0x2f')](_0x290eef['model'],qs[_0xbf71('0x31')](_0x46d7a4[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x561d41['attributes']=_0x561d41[_0xbf71('0x30')]['length']?_0x561d41[_0xbf71('0x30')]:_0x290eef[_0xbf71('0x2c')];if(_0x46d7a4[_0xbf71('0x2d')][_0xbf71('0x3a')]){_0x561d41['include']=[{'all':!![]}];}_0x561d41=_[_0xbf71('0x38')]({},_0x561d41,_0x46d7a4[_0xbf71('0x41')]);return db[_0xbf71('0x28')][_0xbf71('0x42')](_0x561d41)[_0xbf71('0x22')](handleEntityNotFound(_0x4976bc,null))[_0xbf71('0x22')](respondWithResult(_0x4976bc,null))[_0xbf71('0x3d')](handleError(_0x4976bc,null));};exports[_0xbf71('0x43')]=function(_0x268901,_0x5adb13){return db[_0xbf71('0x28')]['create'](_0x268901['body'],{})['then'](respondWithResult(_0x5adb13,0xc9))['catch'](handleError(_0x5adb13,null));};exports[_0xbf71('0x20')]=function(_0x398d05,_0x554fd0){if(_0x398d05[_0xbf71('0x44')]['id']){delete _0x398d05['body']['id'];}return db[_0xbf71('0x28')][_0xbf71('0x42')]({'where':{'id':_0x398d05[_0xbf71('0x3f')]['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x554fd0,null))[_0xbf71('0x22')](saveUpdates(_0x398d05[_0xbf71('0x44')],null))[_0xbf71('0x22')](respondWithResult(_0x554fd0,null))[_0xbf71('0x3d')](handleError(_0x554fd0,null));};exports['destroy']=function(_0x47070a,_0x345515){return db[_0xbf71('0x28')]['find']({'where':{'id':_0x47070a[_0xbf71('0x3f')]['id']}})['then'](handleEntityNotFound(_0x345515,null))['then'](removeEntity(_0x345515,null))[_0xbf71('0x3d')](handleError(_0x345515,null));};exports[_0xbf71('0x45')]=function(_0x571536,_0x21a55c,_0x266049){var _0xedd86b={};var _0xf51ff8={};var _0xafd18b;var _0x2c01a6;return db[_0xbf71('0x28')][_0xbf71('0x46')]({'where':{'id':_0x571536['params']['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x21a55c,null))['then'](function(_0x12ccc3){if(_0x12ccc3){_0xafd18b=_0x12ccc3;_0xf51ff8['model']=_['keys'](db[_0xbf71('0x47')][_0xbf71('0x29')]);_0xf51ff8[_0xbf71('0x2d')]=_['keys'](_0x571536[_0xbf71('0x2d')]);_0xf51ff8['filters']=_[_0xbf71('0x2f')](_0xf51ff8[_0xbf71('0x2c')],_0xf51ff8[_0xbf71('0x2d')]);_0xedd86b['attributes']=_['intersection'](_0xf51ff8['model'],qs[_0xbf71('0x31')](_0x571536['query'][_0xbf71('0x31')]));_0xedd86b[_0xbf71('0x30')]=_0xedd86b[_0xbf71('0x30')][_0xbf71('0x32')]?_0xedd86b['attributes']:_0xf51ff8['model'];_0xedd86b[_0xbf71('0x48')]=qs[_0xbf71('0x35')](_0x571536[_0xbf71('0x2d')][_0xbf71('0x35')]);_0xedd86b['where']=qs[_0xbf71('0x2e')](_['pick'](_0x571536[_0xbf71('0x2d')],_0xf51ff8[_0xbf71('0x2e')]));if(_0x571536['query'][_0xbf71('0x37')]){_0xedd86b[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0xedd86b['where'],{'$or':_[_0xbf71('0x27')](_0xedd86b[_0xbf71('0x30')],function(_0x42192a){var _0x22fdf8={};_0x22fdf8[_0x42192a]={'$like':'%'+_0x571536[_0xbf71('0x2d')][_0xbf71('0x37')]+'%'};return _0x22fdf8;})});}_0xedd86b=_[_0xbf71('0x38')]({},_0xedd86b,_0x571536['options']);return _0xafd18b[_0xbf71('0x45')](_0xedd86b);}})['then'](function(_0x56c772){if(_0x56c772){_0x2c01a6=_0x56c772[_0xbf71('0x32')];if(!_0x571536[_0xbf71('0x2d')]['hasOwnProperty'](_0xbf71('0x34'))){_0xedd86b[_0xbf71('0x19')]=qs['limit'](_0x571536['query']['limit']);_0xedd86b['offset']=qs[_0xbf71('0x17')](_0x571536[_0xbf71('0x2d')]['offset']);}return _0xafd18b[_0xbf71('0x45')](_0xedd86b);}})['then'](function(_0x8ce0b2){if(_0x8ce0b2){return _0x8ce0b2?{'count':_0x2c01a6,'rows':_0x8ce0b2}:null;}})[_0xbf71('0x22')](respondWithResult(_0x21a55c,null))[_0xbf71('0x3d')](handleError(_0x21a55c,null));};exports[_0xbf71('0x49')]=function(_0xc8ab3d,_0x26a13d,_0xdecd2e){var _0x3ff8f9={};var _0x32ecf0={};var _0xff1859;var _0x3df669;return db[_0xbf71('0x28')]['findOne']({'where':{'id':_0xc8ab3d[_0xbf71('0x3f')]['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x26a13d,null))['then'](function(_0x2f9106){if(_0x2f9106){_0xff1859=_0x2f9106;_0x32ecf0[_0xbf71('0x2c')]=_[_0xbf71('0x40')](db[_0xbf71('0x47')][_0xbf71('0x29')]);_0x32ecf0['query']=_[_0xbf71('0x40')](_0xc8ab3d[_0xbf71('0x2d')]);_0x32ecf0['filters']=_[_0xbf71('0x2f')](_0x32ecf0[_0xbf71('0x2c')],_0x32ecf0[_0xbf71('0x2d')]);_0x3ff8f9[_0xbf71('0x30')]=_['intersection'](_0x32ecf0[_0xbf71('0x2c')],qs['fields'](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x3ff8f9[_0xbf71('0x30')]=_0x3ff8f9[_0xbf71('0x30')][_0xbf71('0x32')]?_0x3ff8f9[_0xbf71('0x30')]:_0x32ecf0[_0xbf71('0x2c')];_0x3ff8f9[_0xbf71('0x48')]=qs[_0xbf71('0x35')](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x35')]);_0x3ff8f9['where']=qs['filters'](_[_0xbf71('0x4a')](_0xc8ab3d[_0xbf71('0x2d')],_0x32ecf0[_0xbf71('0x2e')]));if(_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x37')]){_0x3ff8f9[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0x3ff8f9[_0xbf71('0x36')],{'$or':_['map'](_0x3ff8f9['attributes'],function(_0x37f42d){var _0x12f993={};_0x12f993[_0x37f42d]={'$like':'%'+_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x37')]+'%'};return _0x12f993;})});}_0x3ff8f9=_[_0xbf71('0x38')]({},_0x3ff8f9,_0xc8ab3d[_0xbf71('0x41')]);return _0xff1859[_0xbf71('0x49')](_0x3ff8f9);}})[_0xbf71('0x22')](function(_0xeb4b98){if(_0xeb4b98){_0x3df669=_0xeb4b98[_0xbf71('0x32')];if(!_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x33')](_0xbf71('0x34'))){_0x3ff8f9['limit']=qs[_0xbf71('0x19')](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x19')]);_0x3ff8f9['offset']=qs[_0xbf71('0x17')](_0xc8ab3d[_0xbf71('0x2d')][_0xbf71('0x17')]);}return _0xff1859[_0xbf71('0x49')](_0x3ff8f9);}})[_0xbf71('0x22')](function(_0x2fe131){if(_0x2fe131){return _0x2fe131?{'count':_0x3df669,'rows':_0x2fe131}:null;}})[_0xbf71('0x22')](respondWithResult(_0x26a13d,null))['catch'](handleError(_0x26a13d,null));};exports['getDescriptions']=function(_0x5b074c,_0x41abe4,_0x1a75c8){var _0x4ec41e={};var _0x5a1fe1={};var _0x5468f0;var _0x3dfc55;return db[_0xbf71('0x28')][_0xbf71('0x46')]({'where':{'id':_0x5b074c[_0xbf71('0x3f')]['id']}})[_0xbf71('0x22')](handleEntityNotFound(_0x41abe4,null))[_0xbf71('0x22')](function(_0x5c0208){if(_0x5c0208){_0x5468f0=_0x5c0208;_0x5a1fe1[_0xbf71('0x2c')]=_[_0xbf71('0x40')](db[_0xbf71('0x47')]['rawAttributes']);_0x5a1fe1['query']=_[_0xbf71('0x40')](_0x5b074c['query']);_0x5a1fe1[_0xbf71('0x2e')]=_[_0xbf71('0x2f')](_0x5a1fe1['model'],_0x5a1fe1['query']);_0x4ec41e['attributes']=_[_0xbf71('0x2f')](_0x5a1fe1['model'],qs[_0xbf71('0x31')](_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x31')]));_0x4ec41e[_0xbf71('0x30')]=_0x4ec41e[_0xbf71('0x30')]['length']?_0x4ec41e[_0xbf71('0x30')]:_0x5a1fe1['model'];_0x4ec41e[_0xbf71('0x48')]=qs[_0xbf71('0x35')](_0x5b074c[_0xbf71('0x2d')]['sort']);_0x4ec41e[_0xbf71('0x36')]=qs['filters'](_[_0xbf71('0x4a')](_0x5b074c[_0xbf71('0x2d')],_0x5a1fe1['filters']));if(_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x37')]){_0x4ec41e[_0xbf71('0x36')]=_[_0xbf71('0x38')](_0x4ec41e[_0xbf71('0x36')],{'$or':_['map'](_0x4ec41e[_0xbf71('0x30')],function(_0x199890){var _0x14e4ce={};_0x14e4ce[_0x199890]={'$like':'%'+_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x37')]+'%'};return _0x14e4ce;})});}_0x4ec41e=_['merge']({},_0x4ec41e,_0x5b074c[_0xbf71('0x41')]);return _0x5468f0[_0xbf71('0x4b')](_0x4ec41e);}})[_0xbf71('0x22')](function(_0x3f22a3){if(_0x3f22a3){_0x3dfc55=_0x3f22a3[_0xbf71('0x32')];if(!_0x5b074c[_0xbf71('0x2d')]['hasOwnProperty'](_0xbf71('0x34'))){_0x4ec41e['limit']=qs[_0xbf71('0x19')](_0x5b074c['query'][_0xbf71('0x19')]);_0x4ec41e['offset']=qs[_0xbf71('0x17')](_0x5b074c[_0xbf71('0x2d')][_0xbf71('0x17')]);}return _0x5468f0['getDescriptions'](_0x4ec41e);}})[_0xbf71('0x22')](function(_0x4123dc){if(_0x4123dc){return _0x4123dc?{'count':_0x3dfc55,'rows':_0x4123dc}:null;}})['then'](respondWithResult(_0x41abe4,null))[_0xbf71('0x3d')](handleError(_0x41abe4,null));};
\ No newline at end of file