Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index dd81796..c8fa50a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6060=['stack','name','index','map','type','model','query','keys','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','sort','where','filters','pick','filter','VIRTUAL','merge','options','VtigerConfiguration','includeAll','findAll','rows','params','include','find','create','body','getFields','findOne','VtigerField','rawAttributes','getSubjects','order','html-pdf','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','lodash','squel','jsforce','desk.js','to-csv','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','VtigerConfiguration,\x20%s,\x20%s','request\x20sent','debug','VtigerConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','status','end','count','offset','set','json','save','update','destroy','sendStatus'];(function(_0x1b6842,_0x33a446){var _0x3c1754=function(_0x52a74d){while(--_0x52a74d){_0x1b6842['push'](_0x1b6842['shift']());}};_0x3c1754(++_0x33a446);}(_0x6060,0xd0));var _0x0606=function(_0x44676a,_0x3e7b88){_0x44676a=_0x44676a-0x0;var _0x588695=_0x6060[_0x44676a];return _0x588695;};'use strict';var pdf=require(_0x0606('0x0'));var emlformat=require(_0x0606('0x1'));var rimraf=require(_0x0606('0x2'));var zipdir=require(_0x0606('0x3'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x0606('0x4'));var BPromise=require(_0x0606('0x5'));var Mustache=require(_0x0606('0x6'));var util=require(_0x0606('0x7'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x0606('0x8'));var squel=require(_0x0606('0x9'));var crypto=require('crypto');var jsforce=require(_0x0606('0xa'));var deskjs=require(_0x0606('0xb'));var toCsv=require(_0x0606('0xc'));var querystring=require(_0x0606('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x0606('0xe'));var qs=require(_0x0606('0xf'));var as=require(_0x0606('0x10'));var hardwareService=require(_0x0606('0x11'));var logger=require(_0x0606('0x12'))(_0x0606('0x13'));var utils=require('../../config/utils');var config=require(_0x0606('0x14'));var licenseUtil=require(_0x0606('0x15'));var db=require(_0x0606('0x16'))['db'];var jayson=require(_0x0606('0x17'));var client=jayson[_0x0606('0x18')][_0x0606('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x116b4e,_0x50014e,_0xcff9e,_0x534391){return new BPromise(function(_0x30539a,_0x4ac41c){var _0x3ebe0c=_0x534391||client;return _0x3ebe0c[_0x0606('0x1a')](_0x116b4e,_0xcff9e)[_0x0606('0x1b')](function(_0x1f50b1){logger[_0x0606('0x1c')](_0x0606('0x1d'),_0x50014e,_0x0606('0x1e'));logger[_0x0606('0x1f')](_0x0606('0x20'),_0x50014e,_0x0606('0x1e'),JSON[_0x0606('0x21')](_0x1f50b1));if(_0x1f50b1[_0x0606('0x22')]){if(_0x1f50b1[_0x0606('0x22')]['code']===0x1f4){logger[_0x0606('0x22')](_0x0606('0x1d'),_0x50014e,_0x1f50b1['error'][_0x0606('0x23')]);return _0x4ac41c(_0x1f50b1['error'][_0x0606('0x23')]);}logger['error']('VtigerConfiguration,\x20%s,\x20%s',_0x50014e,_0x1f50b1['error'][_0x0606('0x23')]);return _0x30539a(_0x1f50b1[_0x0606('0x22')]['message']);}else{logger[_0x0606('0x1c')](_0x0606('0x1d'),_0x50014e,_0x0606('0x1e'));_0x30539a(_0x1f50b1['result']['message']);}})[_0x0606('0x24')](function(_0x595f4e){logger['error']('VtigerConfiguration,\x20%s,\x20%s',_0x50014e,_0x595f4e);_0x4ac41c(_0x595f4e);});});}function respondWithStatusCode(_0x38f0d0,_0x27d4c9){_0x27d4c9=_0x27d4c9||0xcc;return function(_0x3a255a){if(_0x3a255a){return _0x38f0d0['sendStatus'](_0x27d4c9);}return _0x38f0d0[_0x0606('0x25')](_0x27d4c9)[_0x0606('0x26')]();};}function respondWithResult(_0x3b42fd,_0x1f49a7){_0x1f49a7=_0x1f49a7||0xc8;return function(_0x473a79){if(_0x473a79){return _0x3b42fd[_0x0606('0x25')](_0x1f49a7)['json'](_0x473a79);}};}function respondWithFilteredResult(_0x1774fe,_0x588367){return function(_0x2ef427){if(_0x2ef427){var _0x273413=_0x2ef427[_0x0606('0x27')],_0x5be423=_0x588367[_0x0606('0x28')],_0x12baa2=_0x588367[_0x0606('0x28')]+_0x588367['limit'],_0x33245b;if(_0x12baa2>=_0x273413){_0x12baa2=_0x273413;_0x33245b=0xc8;}else{_0x33245b=0xce;}_0x1774fe[_0x0606('0x25')](_0x33245b);return _0x1774fe[_0x0606('0x29')]('Content-Range',_0x5be423+'-'+_0x12baa2+'/'+_0x273413)[_0x0606('0x2a')](_0x2ef427);}return null;};}function patchUpdates(_0x254388){return function(_0x59788a){try{jsonpatch['apply'](_0x59788a,_0x254388,!![]);}catch(_0x362676){return BPromise['reject'](_0x362676);}return _0x59788a[_0x0606('0x2b')]();};}function saveUpdates(_0x358fc0,_0x250b1a){return function(_0x2261a0){if(_0x2261a0){return _0x2261a0[_0x0606('0x2c')](_0x358fc0)[_0x0606('0x1b')](function(_0x58f744){return _0x58f744;});}return null;};}function removeEntity(_0x339813,_0x33c376){return function(_0x3d7b29){if(_0x3d7b29){return _0x3d7b29[_0x0606('0x2d')]()['then'](function(){_0x339813['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5f2cf2,_0x3cf3f1){return function(_0x1c9217){if(!_0x1c9217){_0x5f2cf2[_0x0606('0x2e')](0x194);}return _0x1c9217;};}function handleError(_0xe5acd0,_0x38389e){_0x38389e=_0x38389e||0x1f4;return function(_0x2a7841){logger[_0x0606('0x22')](_0x2a7841[_0x0606('0x2f')]);if(_0x2a7841[_0x0606('0x30')]){delete _0x2a7841[_0x0606('0x30')];}_0xe5acd0[_0x0606('0x25')](_0x38389e)['send'](_0x2a7841);};}exports[_0x0606('0x31')]=function(_0x5125d5,_0x5ddbd7){var _0x45d74c={},_0x5e2f68={},_0x2bc3c4={'count':0x0,'rows':[]};var _0xb69286=_[_0x0606('0x32')](db['VtigerConfiguration']['rawAttributes'],function(_0x439861){return{'name':_0x439861['fieldName'],'type':_0x439861[_0x0606('0x33')]['key']};});_0x5e2f68[_0x0606('0x34')]=_['map'](_0xb69286,_0x0606('0x30'));_0x5e2f68[_0x0606('0x35')]=_[_0x0606('0x36')](_0x5125d5['query']);_0x5e2f68['filters']=_[_0x0606('0x37')](_0x5e2f68[_0x0606('0x34')],_0x5e2f68[_0x0606('0x35')]);_0x45d74c['attributes']=_[_0x0606('0x37')](_0x5e2f68['model'],qs[_0x0606('0x38')](_0x5125d5[_0x0606('0x35')]['fields']));_0x45d74c[_0x0606('0x39')]=_0x45d74c[_0x0606('0x39')][_0x0606('0x3a')]?_0x45d74c[_0x0606('0x39')]:_0x5e2f68[_0x0606('0x34')];if(!_0x5125d5[_0x0606('0x35')][_0x0606('0x3b')](_0x0606('0x3c'))){_0x45d74c['limit']=qs['limit'](_0x5125d5[_0x0606('0x35')][_0x0606('0x3d')]);_0x45d74c[_0x0606('0x28')]=qs['offset'](_0x5125d5['query']['offset']);}_0x45d74c['order']=qs[_0x0606('0x3e')](_0x5125d5[_0x0606('0x35')]['sort']);_0x45d74c[_0x0606('0x3f')]=qs[_0x0606('0x40')](_[_0x0606('0x41')](_0x5125d5[_0x0606('0x35')],_0x5e2f68['filters']),_0xb69286);if(_0x5125d5[_0x0606('0x35')][_0x0606('0x42')]){_0x45d74c[_0x0606('0x3f')]=_['merge'](_0x45d74c[_0x0606('0x3f')],{'$or':_[_0x0606('0x32')](_0xb69286,function(_0x5b2c0f){if(_0x5b2c0f[_0x0606('0x33')]!==_0x0606('0x43')){var _0x54cf2d={};_0x54cf2d[_0x5b2c0f[_0x0606('0x30')]]={'$like':'%'+_0x5125d5[_0x0606('0x35')][_0x0606('0x42')]+'%'};return _0x54cf2d;}})});}_0x45d74c=_[_0x0606('0x44')]({},_0x45d74c,_0x5125d5[_0x0606('0x45')]);var _0x4332ba={'where':_0x45d74c[_0x0606('0x3f')]};return db[_0x0606('0x46')][_0x0606('0x27')](_0x4332ba)[_0x0606('0x1b')](function(_0x2cf2b5){_0x2bc3c4[_0x0606('0x27')]=_0x2cf2b5;if(_0x5125d5[_0x0606('0x35')][_0x0606('0x47')]){_0x45d74c['include']=[{'all':!![]}];}return db[_0x0606('0x46')][_0x0606('0x48')](_0x45d74c);})[_0x0606('0x1b')](function(_0x25d6ac){_0x2bc3c4[_0x0606('0x49')]=_0x25d6ac;return _0x2bc3c4;})['then'](respondWithFilteredResult(_0x5ddbd7,_0x45d74c))['catch'](handleError(_0x5ddbd7,null));};exports['show']=function(_0x1a6251,_0x28a853){var _0x5be47d={'raw':![],'where':{'id':_0x1a6251[_0x0606('0x4a')]['id']}},_0x2f8f0c={};_0x2f8f0c[_0x0606('0x34')]=_[_0x0606('0x36')](db[_0x0606('0x46')]['rawAttributes']);_0x2f8f0c[_0x0606('0x35')]=_[_0x0606('0x36')](_0x1a6251['query']);_0x2f8f0c[_0x0606('0x40')]=_['intersection'](_0x2f8f0c[_0x0606('0x34')],_0x2f8f0c[_0x0606('0x35')]);_0x5be47d[_0x0606('0x39')]=_[_0x0606('0x37')](_0x2f8f0c[_0x0606('0x34')],qs[_0x0606('0x38')](_0x1a6251[_0x0606('0x35')][_0x0606('0x38')]));_0x5be47d[_0x0606('0x39')]=_0x5be47d[_0x0606('0x39')][_0x0606('0x3a')]?_0x5be47d[_0x0606('0x39')]:_0x2f8f0c[_0x0606('0x34')];if(_0x1a6251[_0x0606('0x35')][_0x0606('0x47')]){_0x5be47d[_0x0606('0x4b')]=[{'all':!![]}];}_0x5be47d=_[_0x0606('0x44')]({},_0x5be47d,_0x1a6251[_0x0606('0x45')]);return db[_0x0606('0x46')][_0x0606('0x4c')](_0x5be47d)['then'](handleEntityNotFound(_0x28a853,null))['then'](respondWithResult(_0x28a853,null))[_0x0606('0x24')](handleError(_0x28a853,null));};exports[_0x0606('0x4d')]=function(_0x330d53,_0x2232ae){return db[_0x0606('0x46')]['create'](_0x330d53[_0x0606('0x4e')],{})[_0x0606('0x1b')](respondWithResult(_0x2232ae,0xc9))['catch'](handleError(_0x2232ae,null));};exports[_0x0606('0x2c')]=function(_0x9e72d8,_0x550bf9){if(_0x9e72d8[_0x0606('0x4e')]['id']){delete _0x9e72d8[_0x0606('0x4e')]['id'];}return db[_0x0606('0x46')][_0x0606('0x4c')]({'where':{'id':_0x9e72d8['params']['id']}})[_0x0606('0x1b')](handleEntityNotFound(_0x550bf9,null))[_0x0606('0x1b')](saveUpdates(_0x9e72d8[_0x0606('0x4e')],null))['then'](respondWithResult(_0x550bf9,null))[_0x0606('0x24')](handleError(_0x550bf9,null));};exports[_0x0606('0x2d')]=function(_0x411660,_0x47df75){return db[_0x0606('0x46')][_0x0606('0x4c')]({'where':{'id':_0x411660[_0x0606('0x4a')]['id']}})['then'](handleEntityNotFound(_0x47df75,null))[_0x0606('0x1b')](removeEntity(_0x47df75,null))['catch'](handleError(_0x47df75,null));};exports[_0x0606('0x4f')]=function(_0x25aed9,_0x156394,_0x43051a){var _0x443e79={};var _0x2301ab={};var _0x55a053;var _0x2fdecd;return db[_0x0606('0x46')][_0x0606('0x50')]({'where':{'id':_0x25aed9[_0x0606('0x4a')]['id']}})['then'](handleEntityNotFound(_0x156394,null))['then'](function(_0x159c72){if(_0x159c72){_0x55a053=_0x159c72;_0x2301ab['model']=_['keys'](db[_0x0606('0x51')][_0x0606('0x52')]);_0x2301ab[_0x0606('0x35')]=_['keys'](_0x25aed9[_0x0606('0x35')]);_0x2301ab['filters']=_['intersection'](_0x2301ab[_0x0606('0x34')],_0x2301ab[_0x0606('0x35')]);_0x443e79[_0x0606('0x39')]=_['intersection'](_0x2301ab[_0x0606('0x34')],qs['fields'](_0x25aed9[_0x0606('0x35')][_0x0606('0x38')]));_0x443e79[_0x0606('0x39')]=_0x443e79[_0x0606('0x39')][_0x0606('0x3a')]?_0x443e79[_0x0606('0x39')]:_0x2301ab[_0x0606('0x34')];_0x443e79['order']=qs[_0x0606('0x3e')](_0x25aed9[_0x0606('0x35')]['sort']);_0x443e79[_0x0606('0x3f')]=qs[_0x0606('0x40')](_['pick'](_0x25aed9[_0x0606('0x35')],_0x2301ab[_0x0606('0x40')]));if(_0x25aed9['query'][_0x0606('0x42')]){_0x443e79[_0x0606('0x3f')]=_['merge'](_0x443e79[_0x0606('0x3f')],{'$or':_['map'](_0x443e79['attributes'],function(_0xc11a45){var _0x5d5dc3={};_0x5d5dc3[_0xc11a45]={'$like':'%'+_0x25aed9['query'][_0x0606('0x42')]+'%'};return _0x5d5dc3;})});}_0x443e79=_[_0x0606('0x44')]({},_0x443e79,_0x25aed9['options']);return _0x55a053[_0x0606('0x4f')](_0x443e79);}})[_0x0606('0x1b')](function(_0x3affeb){if(_0x3affeb){_0x2fdecd=_0x3affeb['length'];if(!_0x25aed9[_0x0606('0x35')]['hasOwnProperty']('nolimit')){_0x443e79[_0x0606('0x3d')]=qs[_0x0606('0x3d')](_0x25aed9[_0x0606('0x35')]['limit']);_0x443e79['offset']=qs[_0x0606('0x28')](_0x25aed9[_0x0606('0x35')]['offset']);}return _0x55a053['getFields'](_0x443e79);}})[_0x0606('0x1b')](function(_0x310460){if(_0x310460){return _0x310460?{'count':_0x2fdecd,'rows':_0x310460}:null;}})[_0x0606('0x1b')](respondWithResult(_0x156394,null))[_0x0606('0x24')](handleError(_0x156394,null));};exports[_0x0606('0x53')]=function(_0xeb10f0,_0x256252,_0x45a52e){var _0x2816eb={};var _0x1f7d97={};var _0x2bafdc;var _0x1cc21d;return db[_0x0606('0x46')][_0x0606('0x50')]({'where':{'id':_0xeb10f0[_0x0606('0x4a')]['id']}})['then'](handleEntityNotFound(_0x256252,null))[_0x0606('0x1b')](function(_0x3d02b4){if(_0x3d02b4){_0x2bafdc=_0x3d02b4;_0x1f7d97[_0x0606('0x34')]=_[_0x0606('0x36')](db[_0x0606('0x51')]['rawAttributes']);_0x1f7d97[_0x0606('0x35')]=_['keys'](_0xeb10f0[_0x0606('0x35')]);_0x1f7d97[_0x0606('0x40')]=_[_0x0606('0x37')](_0x1f7d97[_0x0606('0x34')],_0x1f7d97[_0x0606('0x35')]);_0x2816eb[_0x0606('0x39')]=_[_0x0606('0x37')](_0x1f7d97[_0x0606('0x34')],qs[_0x0606('0x38')](_0xeb10f0[_0x0606('0x35')][_0x0606('0x38')]));_0x2816eb[_0x0606('0x39')]=_0x2816eb[_0x0606('0x39')]['length']?_0x2816eb[_0x0606('0x39')]:_0x1f7d97[_0x0606('0x34')];_0x2816eb[_0x0606('0x54')]=qs[_0x0606('0x3e')](_0xeb10f0[_0x0606('0x35')]['sort']);_0x2816eb[_0x0606('0x3f')]=qs['filters'](_[_0x0606('0x41')](_0xeb10f0[_0x0606('0x35')],_0x1f7d97[_0x0606('0x40')]));if(_0xeb10f0[_0x0606('0x35')][_0x0606('0x42')]){_0x2816eb[_0x0606('0x3f')]=_[_0x0606('0x44')](_0x2816eb[_0x0606('0x3f')],{'$or':_['map'](_0x2816eb[_0x0606('0x39')],function(_0x49ddf3){var _0x21e1f6={};_0x21e1f6[_0x49ddf3]={'$like':'%'+_0xeb10f0['query']['filter']+'%'};return _0x21e1f6;})});}_0x2816eb=_[_0x0606('0x44')]({},_0x2816eb,_0xeb10f0[_0x0606('0x45')]);return _0x2bafdc[_0x0606('0x53')](_0x2816eb);}})[_0x0606('0x1b')](function(_0x1b847f){if(_0x1b847f){_0x1cc21d=_0x1b847f[_0x0606('0x3a')];if(!_0xeb10f0[_0x0606('0x35')][_0x0606('0x3b')]('nolimit')){_0x2816eb[_0x0606('0x3d')]=qs[_0x0606('0x3d')](_0xeb10f0[_0x0606('0x35')][_0x0606('0x3d')]);_0x2816eb[_0x0606('0x28')]=qs[_0x0606('0x28')](_0xeb10f0[_0x0606('0x35')][_0x0606('0x28')]);}return _0x2bafdc[_0x0606('0x53')](_0x2816eb);}})[_0x0606('0x1b')](function(_0x2b8a5d){if(_0x2b8a5d){return _0x2b8a5d?{'count':_0x1cc21d,'rows':_0x2b8a5d}:null;}})[_0x0606('0x1b')](respondWithResult(_0x256252,null))[_0x0606('0x24')](handleError(_0x256252,null));};exports['getDescriptions']=function(_0x5282b7,_0x45f99a,_0xd34131){var _0x24db5b={};var _0x3f5884={};var _0x575357;var _0xd920c3;return db[_0x0606('0x46')]['findOne']({'where':{'id':_0x5282b7['params']['id']}})[_0x0606('0x1b')](handleEntityNotFound(_0x45f99a,null))['then'](function(_0xf1d4eb){if(_0xf1d4eb){_0x575357=_0xf1d4eb;_0x3f5884['model']=_['keys'](db[_0x0606('0x51')][_0x0606('0x52')]);_0x3f5884[_0x0606('0x35')]=_[_0x0606('0x36')](_0x5282b7[_0x0606('0x35')]);_0x3f5884[_0x0606('0x40')]=_[_0x0606('0x37')](_0x3f5884[_0x0606('0x34')],_0x3f5884['query']);_0x24db5b[_0x0606('0x39')]=_[_0x0606('0x37')](_0x3f5884[_0x0606('0x34')],qs['fields'](_0x5282b7[_0x0606('0x35')][_0x0606('0x38')]));_0x24db5b['attributes']=_0x24db5b[_0x0606('0x39')][_0x0606('0x3a')]?_0x24db5b[_0x0606('0x39')]:_0x3f5884[_0x0606('0x34')];_0x24db5b[_0x0606('0x54')]=qs[_0x0606('0x3e')](_0x5282b7[_0x0606('0x35')]['sort']);_0x24db5b[_0x0606('0x3f')]=qs[_0x0606('0x40')](_['pick'](_0x5282b7[_0x0606('0x35')],_0x3f5884[_0x0606('0x40')]));if(_0x5282b7[_0x0606('0x35')][_0x0606('0x42')]){_0x24db5b[_0x0606('0x3f')]=_[_0x0606('0x44')](_0x24db5b[_0x0606('0x3f')],{'$or':_[_0x0606('0x32')](_0x24db5b[_0x0606('0x39')],function(_0x2aad28){var _0x1c0179={};_0x1c0179[_0x2aad28]={'$like':'%'+_0x5282b7[_0x0606('0x35')][_0x0606('0x42')]+'%'};return _0x1c0179;})});}_0x24db5b=_[_0x0606('0x44')]({},_0x24db5b,_0x5282b7[_0x0606('0x45')]);return _0x575357['getDescriptions'](_0x24db5b);}})[_0x0606('0x1b')](function(_0x4fce4c){if(_0x4fce4c){_0xd920c3=_0x4fce4c[_0x0606('0x3a')];if(!_0x5282b7['query'][_0x0606('0x3b')]('nolimit')){_0x24db5b[_0x0606('0x3d')]=qs[_0x0606('0x3d')](_0x5282b7['query']['limit']);_0x24db5b[_0x0606('0x28')]=qs[_0x0606('0x28')](_0x5282b7[_0x0606('0x35')]['offset']);}return _0x575357['getDescriptions'](_0x24db5b);}})[_0x0606('0x1b')](function(_0x2a36ee){if(_0x2a36ee){return _0x2a36ee?{'count':_0xd920c3,'rows':_0x2a36ee}:null;}})['then'](respondWithResult(_0x45f99a,null))[_0x0606('0x24')](handleError(_0x45f99a,null));};
\ No newline at end of file
+var _0xf364=['catch','params','keys','rawAttributes','length','includeAll','find','body','getFields','findOne','VtigerField','hasOwnProperty','getSubjects','getDescriptions','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','status','end','offset','undefined','limit','count','set','Content-Range','json','save','update','then','destroy','sendStatus','name','send','index','VtigerConfiguration','fieldName','type','key','model','map','query','filters','intersection','attributes','fields','nolimit','order','sort','where','pick','filter','merge','options','include','rows'];(function(_0xf35bc1,_0x510803){var _0xa6b162=function(_0x1e5cc8){while(--_0x1e5cc8){_0xf35bc1['push'](_0xf35bc1['shift']());}};_0xa6b162(++_0x510803);}(_0xf364,0x194));var _0x4f36=function(_0x46aff0,_0x122890){_0x46aff0=_0x46aff0-0x0;var _0x9d78cf=_0xf364[_0x46aff0];return _0x9d78cf;};'use strict';var emlformat=require(_0x4f36('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x4f36('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x4f36('0x2'));var moment=require(_0x4f36('0x3'));var BPromise=require(_0x4f36('0x4'));var Mustache=require(_0x4f36('0x5'));var util=require(_0x4f36('0x6'));var path=require(_0x4f36('0x7'));var sox=require(_0x4f36('0x8'));var csv=require(_0x4f36('0x9'));var ejs=require(_0x4f36('0xa'));var fs=require('fs');var fs_extra=require(_0x4f36('0xb'));var _=require('lodash');var squel=require(_0x4f36('0xc'));var crypto=require(_0x4f36('0xd'));var jsforce=require(_0x4f36('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x4f36('0x9'));var querystring=require(_0x4f36('0xf'));var Papa=require(_0x4f36('0x10'));var Redis=require(_0x4f36('0x11'));var authService=require(_0x4f36('0x12'));var qs=require(_0x4f36('0x13'));var as=require(_0x4f36('0x14'));var hardwareService=require(_0x4f36('0x15'));var logger=require(_0x4f36('0x16'))(_0x4f36('0x17'));var utils=require(_0x4f36('0x18'));var config=require(_0x4f36('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x597b0,_0x3c4990){_0x3c4990=_0x3c4990||0xcc;return function(_0x45bc73){if(_0x45bc73){return _0x597b0['sendStatus'](_0x3c4990);}return _0x597b0[_0x4f36('0x1a')](_0x3c4990)[_0x4f36('0x1b')]();};}function respondWithResult(_0x133cc1,_0x3f3638){_0x3f3638=_0x3f3638||0xc8;return function(_0x54fdfe){if(_0x54fdfe){return _0x133cc1['status'](_0x3f3638)['json'](_0x54fdfe);}};}function respondWithFilteredResult(_0x4c4dfe,_0x16dd5f){return function(_0x35b723){if(_0x35b723){var _0x45b5b2=typeof _0x16dd5f[_0x4f36('0x1c')]===_0x4f36('0x1d')&&typeof _0x16dd5f[_0x4f36('0x1e')]===_0x4f36('0x1d');var _0x1218f8=_0x35b723[_0x4f36('0x1f')];var _0x27a4e4=_0x45b5b2?0x0:_0x16dd5f[_0x4f36('0x1c')];var _0x4d759b=_0x45b5b2?_0x35b723[_0x4f36('0x1f')]:_0x16dd5f[_0x4f36('0x1c')]+_0x16dd5f['limit'];var _0x44a0e6;if(_0x4d759b>=_0x1218f8){_0x4d759b=_0x1218f8;_0x44a0e6=0xc8;}else{_0x44a0e6=0xce;}_0x4c4dfe['status'](_0x44a0e6);return _0x4c4dfe[_0x4f36('0x20')](_0x4f36('0x21'),_0x27a4e4+'-'+_0x4d759b+'/'+_0x1218f8)[_0x4f36('0x22')](_0x35b723);}return null;};}function patchUpdates(_0x1e7dac){return function(_0x2f1e9a){try{jsonpatch['apply'](_0x2f1e9a,_0x1e7dac,!![]);}catch(_0x3573b6){return BPromise['reject'](_0x3573b6);}return _0x2f1e9a[_0x4f36('0x23')]();};}function saveUpdates(_0x10a3fa,_0x445d0d){return function(_0x191540){if(_0x191540){return _0x191540[_0x4f36('0x24')](_0x10a3fa)[_0x4f36('0x25')](function(_0x4480d3){return _0x4480d3;});}return null;};}function removeEntity(_0x2be18f,_0x1534ad){return function(_0x2c3c6c){if(_0x2c3c6c){return _0x2c3c6c[_0x4f36('0x26')]()['then'](function(){_0x2be18f['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x5b3385,_0x13edc5){return function(_0x1efc0c){if(!_0x1efc0c){_0x5b3385[_0x4f36('0x27')](0x194);}return _0x1efc0c;};}function handleError(_0xe958bc,_0x548d7c){_0x548d7c=_0x548d7c||0x1f4;return function(_0x2d84a8){logger['error'](_0x2d84a8['stack']);if(_0x2d84a8[_0x4f36('0x28')]){delete _0x2d84a8['name'];}_0xe958bc[_0x4f36('0x1a')](_0x548d7c)[_0x4f36('0x29')](_0x2d84a8);};}exports[_0x4f36('0x2a')]=function(_0x6b5fd2,_0x59fd98){var _0x456ced={},_0xc060e2={},_0x12c86f={'count':0x0,'rows':[]};var _0x592edd=_['map'](db[_0x4f36('0x2b')]['rawAttributes'],function(_0x1552d2){return{'name':_0x1552d2[_0x4f36('0x2c')],'type':_0x1552d2[_0x4f36('0x2d')][_0x4f36('0x2e')]};});_0xc060e2[_0x4f36('0x2f')]=_[_0x4f36('0x30')](_0x592edd,_0x4f36('0x28'));_0xc060e2[_0x4f36('0x31')]=_['keys'](_0x6b5fd2[_0x4f36('0x31')]);_0xc060e2[_0x4f36('0x32')]=_[_0x4f36('0x33')](_0xc060e2[_0x4f36('0x2f')],_0xc060e2[_0x4f36('0x31')]);_0x456ced[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0xc060e2[_0x4f36('0x2f')],qs['fields'](_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x35')]));_0x456ced['attributes']=_0x456ced[_0x4f36('0x34')]['length']?_0x456ced['attributes']:_0xc060e2[_0x4f36('0x2f')];if(!_0x6b5fd2[_0x4f36('0x31')]['hasOwnProperty'](_0x4f36('0x36'))){_0x456ced[_0x4f36('0x1e')]=qs[_0x4f36('0x1e')](_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x1e')]);_0x456ced[_0x4f36('0x1c')]=qs[_0x4f36('0x1c')](_0x6b5fd2[_0x4f36('0x31')]['offset']);}_0x456ced[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x38')]);_0x456ced[_0x4f36('0x39')]=qs[_0x4f36('0x32')](_[_0x4f36('0x3a')](_0x6b5fd2[_0x4f36('0x31')],_0xc060e2['filters']),_0x592edd);if(_0x6b5fd2['query'][_0x4f36('0x3b')]){_0x456ced[_0x4f36('0x39')]=_[_0x4f36('0x3c')](_0x456ced['where'],{'$or':_['map'](_0x592edd,function(_0x2352cb){if(_0x2352cb['type']!=='VIRTUAL'){var _0x24fd88={};_0x24fd88[_0x2352cb[_0x4f36('0x28')]]={'$like':'%'+_0x6b5fd2[_0x4f36('0x31')][_0x4f36('0x3b')]+'%'};return _0x24fd88;}})});}_0x456ced=_[_0x4f36('0x3c')]({},_0x456ced,_0x6b5fd2[_0x4f36('0x3d')]);var _0x1d1a17={'where':_0x456ced[_0x4f36('0x39')]};return db[_0x4f36('0x2b')][_0x4f36('0x1f')](_0x1d1a17)[_0x4f36('0x25')](function(_0x40abc4){_0x12c86f[_0x4f36('0x1f')]=_0x40abc4;if(_0x6b5fd2['query']['includeAll']){_0x456ced[_0x4f36('0x3e')]=[{'all':!![]}];}return db['VtigerConfiguration']['findAll'](_0x456ced);})[_0x4f36('0x25')](function(_0x1224af){_0x12c86f[_0x4f36('0x3f')]=_0x1224af;return _0x12c86f;})[_0x4f36('0x25')](respondWithFilteredResult(_0x59fd98,_0x456ced))[_0x4f36('0x40')](handleError(_0x59fd98,null));};exports['show']=function(_0x37586f,_0x5d33ae){var _0x5351bc={'raw':![],'where':{'id':_0x37586f[_0x4f36('0x41')]['id']}},_0x35ba28={};_0x35ba28[_0x4f36('0x2f')]=_[_0x4f36('0x42')](db['VtigerConfiguration'][_0x4f36('0x43')]);_0x35ba28['query']=_[_0x4f36('0x42')](_0x37586f[_0x4f36('0x31')]);_0x35ba28['filters']=_[_0x4f36('0x33')](_0x35ba28[_0x4f36('0x2f')],_0x35ba28[_0x4f36('0x31')]);_0x5351bc[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x35ba28[_0x4f36('0x2f')],qs['fields'](_0x37586f[_0x4f36('0x31')][_0x4f36('0x35')]));_0x5351bc['attributes']=_0x5351bc[_0x4f36('0x34')][_0x4f36('0x44')]?_0x5351bc[_0x4f36('0x34')]:_0x35ba28[_0x4f36('0x2f')];if(_0x37586f[_0x4f36('0x31')][_0x4f36('0x45')]){_0x5351bc[_0x4f36('0x3e')]=[{'all':!![]}];}_0x5351bc=_[_0x4f36('0x3c')]({},_0x5351bc,_0x37586f['options']);return db['VtigerConfiguration'][_0x4f36('0x46')](_0x5351bc)[_0x4f36('0x25')](handleEntityNotFound(_0x5d33ae,null))[_0x4f36('0x25')](respondWithResult(_0x5d33ae,null))[_0x4f36('0x40')](handleError(_0x5d33ae,null));};exports['create']=function(_0x3a9cac,_0x223055){return db['VtigerConfiguration']['create'](_0x3a9cac[_0x4f36('0x47')],{})[_0x4f36('0x25')](respondWithResult(_0x223055,0xc9))[_0x4f36('0x40')](handleError(_0x223055,null));};exports[_0x4f36('0x24')]=function(_0x58ff54,_0x3ecf86){if(_0x58ff54[_0x4f36('0x47')]['id']){delete _0x58ff54['body']['id'];}return db[_0x4f36('0x2b')][_0x4f36('0x46')]({'where':{'id':_0x58ff54[_0x4f36('0x41')]['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x3ecf86,null))[_0x4f36('0x25')](saveUpdates(_0x58ff54[_0x4f36('0x47')],null))['then'](respondWithResult(_0x3ecf86,null))[_0x4f36('0x40')](handleError(_0x3ecf86,null));};exports[_0x4f36('0x26')]=function(_0x17899b,_0x3b7347){return db[_0x4f36('0x2b')][_0x4f36('0x46')]({'where':{'id':_0x17899b['params']['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x3b7347,null))[_0x4f36('0x25')](removeEntity(_0x3b7347,null))[_0x4f36('0x40')](handleError(_0x3b7347,null));};exports[_0x4f36('0x48')]=function(_0x523f64,_0x54dca6,_0x3e37f8){var _0x267b06={};var _0x1a7417={};var _0xa07cc0;var _0xa3bc25;return db[_0x4f36('0x2b')][_0x4f36('0x49')]({'where':{'id':_0x523f64['params']['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x54dca6,null))[_0x4f36('0x25')](function(_0x6baf9f){if(_0x6baf9f){_0xa07cc0=_0x6baf9f;_0x1a7417[_0x4f36('0x2f')]=_[_0x4f36('0x42')](db[_0x4f36('0x4a')][_0x4f36('0x43')]);_0x1a7417[_0x4f36('0x31')]=_[_0x4f36('0x42')](_0x523f64[_0x4f36('0x31')]);_0x1a7417[_0x4f36('0x32')]=_[_0x4f36('0x33')](_0x1a7417[_0x4f36('0x2f')],_0x1a7417['query']);_0x267b06[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x1a7417[_0x4f36('0x2f')],qs['fields'](_0x523f64[_0x4f36('0x31')][_0x4f36('0x35')]));_0x267b06[_0x4f36('0x34')]=_0x267b06[_0x4f36('0x34')]['length']?_0x267b06['attributes']:_0x1a7417[_0x4f36('0x2f')];_0x267b06[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x523f64['query'][_0x4f36('0x38')]);_0x267b06[_0x4f36('0x39')]=qs[_0x4f36('0x32')](_['pick'](_0x523f64[_0x4f36('0x31')],_0x1a7417[_0x4f36('0x32')]));if(_0x523f64[_0x4f36('0x31')][_0x4f36('0x3b')]){_0x267b06[_0x4f36('0x39')]=_['merge'](_0x267b06[_0x4f36('0x39')],{'$or':_[_0x4f36('0x30')](_0x267b06['attributes'],function(_0x3abdb4){var _0x400fc2={};_0x400fc2[_0x3abdb4]={'$like':'%'+_0x523f64['query'][_0x4f36('0x3b')]+'%'};return _0x400fc2;})});}_0x267b06=_[_0x4f36('0x3c')]({},_0x267b06,_0x523f64[_0x4f36('0x3d')]);return _0xa07cc0[_0x4f36('0x48')](_0x267b06);}})[_0x4f36('0x25')](function(_0x214410){if(_0x214410){_0xa3bc25=_0x214410['length'];if(!_0x523f64[_0x4f36('0x31')][_0x4f36('0x4b')](_0x4f36('0x36'))){_0x267b06[_0x4f36('0x1e')]=qs[_0x4f36('0x1e')](_0x523f64['query'][_0x4f36('0x1e')]);_0x267b06[_0x4f36('0x1c')]=qs[_0x4f36('0x1c')](_0x523f64[_0x4f36('0x31')][_0x4f36('0x1c')]);}return _0xa07cc0[_0x4f36('0x48')](_0x267b06);}})[_0x4f36('0x25')](function(_0x165b2f){if(_0x165b2f){return _0x165b2f?{'count':_0xa3bc25,'rows':_0x165b2f}:null;}})[_0x4f36('0x25')](respondWithResult(_0x54dca6,null))[_0x4f36('0x40')](handleError(_0x54dca6,null));};exports['getSubjects']=function(_0x13758b,_0x4b7f57,_0x814cc4){var _0x30d4df={};var _0x47e611={};var _0x17d772;var _0x725ea0;return db[_0x4f36('0x2b')][_0x4f36('0x49')]({'where':{'id':_0x13758b[_0x4f36('0x41')]['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x4b7f57,null))[_0x4f36('0x25')](function(_0x569e4c){if(_0x569e4c){_0x17d772=_0x569e4c;_0x47e611[_0x4f36('0x2f')]=_[_0x4f36('0x42')](db['VtigerField']['rawAttributes']);_0x47e611[_0x4f36('0x31')]=_[_0x4f36('0x42')](_0x13758b[_0x4f36('0x31')]);_0x47e611['filters']=_[_0x4f36('0x33')](_0x47e611[_0x4f36('0x2f')],_0x47e611[_0x4f36('0x31')]);_0x30d4df[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x47e611[_0x4f36('0x2f')],qs[_0x4f36('0x35')](_0x13758b[_0x4f36('0x31')][_0x4f36('0x35')]));_0x30d4df['attributes']=_0x30d4df[_0x4f36('0x34')]['length']?_0x30d4df[_0x4f36('0x34')]:_0x47e611[_0x4f36('0x2f')];_0x30d4df[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x13758b[_0x4f36('0x31')]['sort']);_0x30d4df[_0x4f36('0x39')]=qs[_0x4f36('0x32')](_['pick'](_0x13758b[_0x4f36('0x31')],_0x47e611[_0x4f36('0x32')]));if(_0x13758b[_0x4f36('0x31')]['filter']){_0x30d4df['where']=_[_0x4f36('0x3c')](_0x30d4df[_0x4f36('0x39')],{'$or':_['map'](_0x30d4df[_0x4f36('0x34')],function(_0x1c6b10){var _0x1089d4={};_0x1089d4[_0x1c6b10]={'$like':'%'+_0x13758b[_0x4f36('0x31')][_0x4f36('0x3b')]+'%'};return _0x1089d4;})});}_0x30d4df=_['merge']({},_0x30d4df,_0x13758b[_0x4f36('0x3d')]);return _0x17d772[_0x4f36('0x4c')](_0x30d4df);}})[_0x4f36('0x25')](function(_0x47f166){if(_0x47f166){_0x725ea0=_0x47f166[_0x4f36('0x44')];if(!_0x13758b[_0x4f36('0x31')][_0x4f36('0x4b')](_0x4f36('0x36'))){_0x30d4df[_0x4f36('0x1e')]=qs[_0x4f36('0x1e')](_0x13758b[_0x4f36('0x31')][_0x4f36('0x1e')]);_0x30d4df['offset']=qs[_0x4f36('0x1c')](_0x13758b[_0x4f36('0x31')][_0x4f36('0x1c')]);}return _0x17d772['getSubjects'](_0x30d4df);}})['then'](function(_0x666658){if(_0x666658){return _0x666658?{'count':_0x725ea0,'rows':_0x666658}:null;}})['then'](respondWithResult(_0x4b7f57,null))[_0x4f36('0x40')](handleError(_0x4b7f57,null));};exports[_0x4f36('0x4d')]=function(_0x543a4e,_0x392de7,_0xb78356){var _0x2db9f3={};var _0x440f03={};var _0x492c64;var _0x1def89;return db['VtigerConfiguration']['findOne']({'where':{'id':_0x543a4e[_0x4f36('0x41')]['id']}})[_0x4f36('0x25')](handleEntityNotFound(_0x392de7,null))[_0x4f36('0x25')](function(_0x3f03af){if(_0x3f03af){_0x492c64=_0x3f03af;_0x440f03[_0x4f36('0x2f')]=_['keys'](db[_0x4f36('0x4a')][_0x4f36('0x43')]);_0x440f03[_0x4f36('0x31')]=_[_0x4f36('0x42')](_0x543a4e['query']);_0x440f03[_0x4f36('0x32')]=_[_0x4f36('0x33')](_0x440f03[_0x4f36('0x2f')],_0x440f03[_0x4f36('0x31')]);_0x2db9f3[_0x4f36('0x34')]=_[_0x4f36('0x33')](_0x440f03['model'],qs[_0x4f36('0x35')](_0x543a4e[_0x4f36('0x31')]['fields']));_0x2db9f3[_0x4f36('0x34')]=_0x2db9f3[_0x4f36('0x34')][_0x4f36('0x44')]?_0x2db9f3[_0x4f36('0x34')]:_0x440f03[_0x4f36('0x2f')];_0x2db9f3[_0x4f36('0x37')]=qs[_0x4f36('0x38')](_0x543a4e[_0x4f36('0x31')][_0x4f36('0x38')]);_0x2db9f3['where']=qs[_0x4f36('0x32')](_[_0x4f36('0x3a')](_0x543a4e[_0x4f36('0x31')],_0x440f03[_0x4f36('0x32')]));if(_0x543a4e[_0x4f36('0x31')][_0x4f36('0x3b')]){_0x2db9f3[_0x4f36('0x39')]=_[_0x4f36('0x3c')](_0x2db9f3[_0x4f36('0x39')],{'$or':_[_0x4f36('0x30')](_0x2db9f3[_0x4f36('0x34')],function(_0x18c27b){var _0x199a00={};_0x199a00[_0x18c27b]={'$like':'%'+_0x543a4e[_0x4f36('0x31')][_0x4f36('0x3b')]+'%'};return _0x199a00;})});}_0x2db9f3=_[_0x4f36('0x3c')]({},_0x2db9f3,_0x543a4e[_0x4f36('0x3d')]);return _0x492c64[_0x4f36('0x4d')](_0x2db9f3);}})['then'](function(_0xdff4ae){if(_0xdff4ae){_0x1def89=_0xdff4ae[_0x4f36('0x44')];if(!_0x543a4e[_0x4f36('0x31')][_0x4f36('0x4b')]('nolimit')){_0x2db9f3['limit']=qs[_0x4f36('0x1e')](_0x543a4e[_0x4f36('0x31')]['limit']);_0x2db9f3[_0x4f36('0x1c')]=qs['offset'](_0x543a4e[_0x4f36('0x31')][_0x4f36('0x1c')]);}return _0x492c64[_0x4f36('0x4d')](_0x2db9f3);}})['then'](function(_0x4dfaaf){if(_0x4dfaaf){return _0x4dfaaf?{'count':_0x1def89,'rows':_0x4dfaaf}:null;}})[_0x4f36('0x25')](respondWithResult(_0x392de7,null))['catch'](handleError(_0x392de7,null));};
\ No newline at end of file