Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index 3dbf896..5b8e1b6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6719=['findOne','hasOwnProperty','getSubjects','VtigerField','getDescriptions','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','reject','then','destroy','name','send','index','map','VtigerConfiguration','type','query','keys','intersection','attributes','model','fields','nolimit','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','include','show','rawAttributes','length','includeAll','find','catch','create','body','params','getFields'];(function(_0x1621d8,_0x4756bf){var _0x6883c7=function(_0x3ed06c){while(--_0x3ed06c){_0x1621d8['push'](_0x1621d8['shift']());}};_0x6883c7(++_0x4756bf);}(_0x6719,0x139));var _0x9671=function(_0xb0c152,_0x1d37a9){_0xb0c152=_0xb0c152-0x0;var _0x2fc458=_0x6719[_0xb0c152];return _0x2fc458;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9671('0x0'));var zipdir=require(_0x9671('0x1'));var jsonpatch=require(_0x9671('0x2'));var rp=require(_0x9671('0x3'));var moment=require(_0x9671('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x9671('0x5'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x9671('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9671('0x7'));var _=require(_0x9671('0x8'));var squel=require(_0x9671('0x9'));var crypto=require(_0x9671('0xa'));var jsforce=require(_0x9671('0xb'));var deskjs=require(_0x9671('0xc'));var toCsv=require(_0x9671('0x6'));var querystring=require(_0x9671('0xd'));var Papa=require(_0x9671('0xe'));var Redis=require(_0x9671('0xf'));var authService=require(_0x9671('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x9671('0x11'));var hardwareService=require(_0x9671('0x12'));var logger=require(_0x9671('0x13'))(_0x9671('0x14'));var utils=require(_0x9671('0x15'));var config=require(_0x9671('0x16'));var licenseUtil=require(_0x9671('0x17'));var db=require(_0x9671('0x18'))['db'];function respondWithStatusCode(_0x4fd91b,_0xd91700){_0xd91700=_0xd91700||0xcc;return function(_0x5ed7f3){if(_0x5ed7f3){return _0x4fd91b[_0x9671('0x19')](_0xd91700);}return _0x4fd91b[_0x9671('0x1a')](_0xd91700)[_0x9671('0x1b')]();};}function respondWithResult(_0x35a86b,_0x285dc0){_0x285dc0=_0x285dc0||0xc8;return function(_0x10fd9d){if(_0x10fd9d){return _0x35a86b[_0x9671('0x1a')](_0x285dc0)[_0x9671('0x1c')](_0x10fd9d);}};}function respondWithFilteredResult(_0x843045,_0xcd2b35){return function(_0x2c5da7){if(_0x2c5da7){var _0x3c552c=typeof _0xcd2b35['offset']==='undefined'&&typeof _0xcd2b35[_0x9671('0x1d')]===_0x9671('0x1e');var _0x20a4d0=_0x2c5da7[_0x9671('0x1f')];var _0x2e94b8=_0x3c552c?0x0:_0xcd2b35[_0x9671('0x20')];var _0x51c1c2=_0x3c552c?_0x2c5da7[_0x9671('0x1f')]:_0xcd2b35[_0x9671('0x20')]+_0xcd2b35['limit'];var _0xc78244;if(_0x51c1c2>=_0x20a4d0){_0x51c1c2=_0x20a4d0;_0xc78244=0xc8;}else{_0xc78244=0xce;}_0x843045['status'](_0xc78244);return _0x843045[_0x9671('0x21')](_0x9671('0x22'),_0x2e94b8+'-'+_0x51c1c2+'/'+_0x20a4d0)[_0x9671('0x1c')](_0x2c5da7);}return null;};}function patchUpdates(_0x1c57ac){return function(_0x9196d9){try{jsonpatch[_0x9671('0x23')](_0x9196d9,_0x1c57ac,!![]);}catch(_0x4864c3){return BPromise[_0x9671('0x24')](_0x4864c3);}return _0x9196d9['save']();};}function saveUpdates(_0x20af1f,_0x59c964){return function(_0x8a17f2){if(_0x8a17f2){return _0x8a17f2['update'](_0x20af1f)[_0x9671('0x25')](function(_0x58d389){return _0x58d389;});}return null;};}function removeEntity(_0x1a4c0a,_0x4bfce2){return function(_0x15bf58){if(_0x15bf58){return _0x15bf58[_0x9671('0x26')]()[_0x9671('0x25')](function(){_0x1a4c0a['status'](0xcc)[_0x9671('0x1b')]();});}};}function handleEntityNotFound(_0x598e42,_0x4024b5){return function(_0x515c62){if(!_0x515c62){_0x598e42[_0x9671('0x19')](0x194);}return _0x515c62;};}function handleError(_0x45633a,_0x146127){_0x146127=_0x146127||0x1f4;return function(_0x3d10fb){logger['error'](_0x3d10fb['stack']);if(_0x3d10fb[_0x9671('0x27')]){delete _0x3d10fb[_0x9671('0x27')];}_0x45633a[_0x9671('0x1a')](_0x146127)[_0x9671('0x28')](_0x3d10fb);};}exports[_0x9671('0x29')]=function(_0x40c82c,_0x56a5f2){var _0x341f94={},_0x19f30d={},_0x27eb0c={'count':0x0,'rows':[]};var _0x5d7957=_[_0x9671('0x2a')](db[_0x9671('0x2b')]['rawAttributes'],function(_0x3395c4){return{'name':_0x3395c4['fieldName'],'type':_0x3395c4[_0x9671('0x2c')]['key']};});_0x19f30d['model']=_['map'](_0x5d7957,_0x9671('0x27'));_0x19f30d[_0x9671('0x2d')]=_[_0x9671('0x2e')](_0x40c82c[_0x9671('0x2d')]);_0x19f30d['filters']=_[_0x9671('0x2f')](_0x19f30d['model'],_0x19f30d[_0x9671('0x2d')]);_0x341f94[_0x9671('0x30')]=_[_0x9671('0x2f')](_0x19f30d[_0x9671('0x31')],qs['fields'](_0x40c82c[_0x9671('0x2d')][_0x9671('0x32')]));_0x341f94[_0x9671('0x30')]=_0x341f94[_0x9671('0x30')]['length']?_0x341f94[_0x9671('0x30')]:_0x19f30d[_0x9671('0x31')];if(!_0x40c82c[_0x9671('0x2d')]['hasOwnProperty'](_0x9671('0x33'))){_0x341f94[_0x9671('0x1d')]=qs[_0x9671('0x1d')](_0x40c82c[_0x9671('0x2d')][_0x9671('0x1d')]);_0x341f94[_0x9671('0x20')]=qs[_0x9671('0x20')](_0x40c82c[_0x9671('0x2d')][_0x9671('0x20')]);}_0x341f94[_0x9671('0x34')]=qs[_0x9671('0x35')](_0x40c82c[_0x9671('0x2d')][_0x9671('0x35')]);_0x341f94[_0x9671('0x36')]=qs[_0x9671('0x37')](_[_0x9671('0x38')](_0x40c82c['query'],_0x19f30d[_0x9671('0x37')]),_0x5d7957);if(_0x40c82c['query'][_0x9671('0x39')]){_0x341f94['where']=_['merge'](_0x341f94[_0x9671('0x36')],{'$or':_[_0x9671('0x2a')](_0x5d7957,function(_0x2c752f){if(_0x2c752f[_0x9671('0x2c')]!==_0x9671('0x3a')){var _0xa5ed54={};_0xa5ed54[_0x2c752f[_0x9671('0x27')]]={'$like':'%'+_0x40c82c[_0x9671('0x2d')][_0x9671('0x39')]+'%'};return _0xa5ed54;}})});}_0x341f94=_[_0x9671('0x3b')]({},_0x341f94,_0x40c82c[_0x9671('0x3c')]);var _0x79b82a={'where':_0x341f94[_0x9671('0x36')]};return db[_0x9671('0x2b')][_0x9671('0x1f')](_0x79b82a)[_0x9671('0x25')](function(_0x161fc9){_0x27eb0c[_0x9671('0x1f')]=_0x161fc9;if(_0x40c82c[_0x9671('0x2d')]['includeAll']){_0x341f94[_0x9671('0x3d')]=[{'all':!![]}];}return db[_0x9671('0x2b')]['findAll'](_0x341f94);})[_0x9671('0x25')](function(_0x5b1901){_0x27eb0c['rows']=_0x5b1901;return _0x27eb0c;})[_0x9671('0x25')](respondWithFilteredResult(_0x56a5f2,_0x341f94))['catch'](handleError(_0x56a5f2,null));};exports[_0x9671('0x3e')]=function(_0x1782c7,_0x1c0399){var _0x1fadaf={'raw':![],'where':{'id':_0x1782c7['params']['id']}},_0x34078e={};_0x34078e[_0x9671('0x31')]=_[_0x9671('0x2e')](db[_0x9671('0x2b')][_0x9671('0x3f')]);_0x34078e[_0x9671('0x2d')]=_['keys'](_0x1782c7[_0x9671('0x2d')]);_0x34078e[_0x9671('0x37')]=_['intersection'](_0x34078e[_0x9671('0x31')],_0x34078e[_0x9671('0x2d')]);_0x1fadaf['attributes']=_['intersection'](_0x34078e[_0x9671('0x31')],qs[_0x9671('0x32')](_0x1782c7[_0x9671('0x2d')]['fields']));_0x1fadaf[_0x9671('0x30')]=_0x1fadaf[_0x9671('0x30')][_0x9671('0x40')]?_0x1fadaf[_0x9671('0x30')]:_0x34078e['model'];if(_0x1782c7['query'][_0x9671('0x41')]){_0x1fadaf['include']=[{'all':!![]}];}_0x1fadaf=_[_0x9671('0x3b')]({},_0x1fadaf,_0x1782c7[_0x9671('0x3c')]);return db[_0x9671('0x2b')][_0x9671('0x42')](_0x1fadaf)[_0x9671('0x25')](handleEntityNotFound(_0x1c0399,null))[_0x9671('0x25')](respondWithResult(_0x1c0399,null))[_0x9671('0x43')](handleError(_0x1c0399,null));};exports[_0x9671('0x44')]=function(_0xec2656,_0x46c285){return db[_0x9671('0x2b')]['create'](_0xec2656[_0x9671('0x45')],{})[_0x9671('0x25')](respondWithResult(_0x46c285,0xc9))[_0x9671('0x43')](handleError(_0x46c285,null));};exports['update']=function(_0x194241,_0x585dc9){if(_0x194241[_0x9671('0x45')]['id']){delete _0x194241[_0x9671('0x45')]['id'];}return db['VtigerConfiguration'][_0x9671('0x42')]({'where':{'id':_0x194241[_0x9671('0x46')]['id']}})[_0x9671('0x25')](handleEntityNotFound(_0x585dc9,null))[_0x9671('0x25')](saveUpdates(_0x194241[_0x9671('0x45')],null))['then'](respondWithResult(_0x585dc9,null))[_0x9671('0x43')](handleError(_0x585dc9,null));};exports['destroy']=function(_0xfcd491,_0xb8f9ea){return db[_0x9671('0x2b')][_0x9671('0x42')]({'where':{'id':_0xfcd491[_0x9671('0x46')]['id']}})[_0x9671('0x25')](handleEntityNotFound(_0xb8f9ea,null))[_0x9671('0x25')](removeEntity(_0xb8f9ea,null))[_0x9671('0x43')](handleError(_0xb8f9ea,null));};exports[_0x9671('0x47')]=function(_0x3a8e7a,_0x40f359,_0x1c9ae9){var _0x5e763a={};var _0x2e9fb2={};var _0x3b4759;var _0x5a90a0;return db['VtigerConfiguration'][_0x9671('0x48')]({'where':{'id':_0x3a8e7a[_0x9671('0x46')]['id']}})[_0x9671('0x25')](handleEntityNotFound(_0x40f359,null))['then'](function(_0x5e581a){if(_0x5e581a){_0x3b4759=_0x5e581a;_0x2e9fb2[_0x9671('0x31')]=_[_0x9671('0x2e')](db['VtigerField']['rawAttributes']);_0x2e9fb2[_0x9671('0x2d')]=_['keys'](_0x3a8e7a['query']);_0x2e9fb2['filters']=_['intersection'](_0x2e9fb2['model'],_0x2e9fb2[_0x9671('0x2d')]);_0x5e763a[_0x9671('0x30')]=_['intersection'](_0x2e9fb2[_0x9671('0x31')],qs['fields'](_0x3a8e7a[_0x9671('0x2d')][_0x9671('0x32')]));_0x5e763a['attributes']=_0x5e763a[_0x9671('0x30')][_0x9671('0x40')]?_0x5e763a[_0x9671('0x30')]:_0x2e9fb2[_0x9671('0x31')];_0x5e763a[_0x9671('0x34')]=qs[_0x9671('0x35')](_0x3a8e7a[_0x9671('0x2d')][_0x9671('0x35')]);_0x5e763a['where']=qs[_0x9671('0x37')](_[_0x9671('0x38')](_0x3a8e7a[_0x9671('0x2d')],_0x2e9fb2[_0x9671('0x37')]));if(_0x3a8e7a[_0x9671('0x2d')]['filter']){_0x5e763a[_0x9671('0x36')]=_['merge'](_0x5e763a[_0x9671('0x36')],{'$or':_[_0x9671('0x2a')](_0x5e763a[_0x9671('0x30')],function(_0x4bf3a5){var _0x1f294c={};_0x1f294c[_0x4bf3a5]={'$like':'%'+_0x3a8e7a[_0x9671('0x2d')]['filter']+'%'};return _0x1f294c;})});}_0x5e763a=_['merge']({},_0x5e763a,_0x3a8e7a[_0x9671('0x3c')]);return _0x3b4759[_0x9671('0x47')](_0x5e763a);}})[_0x9671('0x25')](function(_0xd21bf8){if(_0xd21bf8){_0x5a90a0=_0xd21bf8[_0x9671('0x40')];if(!_0x3a8e7a[_0x9671('0x2d')][_0x9671('0x49')]('nolimit')){_0x5e763a['limit']=qs[_0x9671('0x1d')](_0x3a8e7a[_0x9671('0x2d')][_0x9671('0x1d')]);_0x5e763a['offset']=qs[_0x9671('0x20')](_0x3a8e7a[_0x9671('0x2d')]['offset']);}return _0x3b4759[_0x9671('0x47')](_0x5e763a);}})[_0x9671('0x25')](function(_0x643895){if(_0x643895){return _0x643895?{'count':_0x5a90a0,'rows':_0x643895}:null;}})['then'](respondWithResult(_0x40f359,null))[_0x9671('0x43')](handleError(_0x40f359,null));};exports[_0x9671('0x4a')]=function(_0x29d515,_0x32ed10,_0x52c760){var _0x5bfe7c={};var _0x53c8a7={};var _0x23fc46;var _0x552759;return db['VtigerConfiguration'][_0x9671('0x48')]({'where':{'id':_0x29d515['params']['id']}})[_0x9671('0x25')](handleEntityNotFound(_0x32ed10,null))[_0x9671('0x25')](function(_0x367a57){if(_0x367a57){_0x23fc46=_0x367a57;_0x53c8a7[_0x9671('0x31')]=_[_0x9671('0x2e')](db[_0x9671('0x4b')]['rawAttributes']);_0x53c8a7['query']=_[_0x9671('0x2e')](_0x29d515['query']);_0x53c8a7['filters']=_['intersection'](_0x53c8a7[_0x9671('0x31')],_0x53c8a7[_0x9671('0x2d')]);_0x5bfe7c['attributes']=_[_0x9671('0x2f')](_0x53c8a7[_0x9671('0x31')],qs[_0x9671('0x32')](_0x29d515[_0x9671('0x2d')][_0x9671('0x32')]));_0x5bfe7c['attributes']=_0x5bfe7c[_0x9671('0x30')][_0x9671('0x40')]?_0x5bfe7c[_0x9671('0x30')]:_0x53c8a7[_0x9671('0x31')];_0x5bfe7c['order']=qs[_0x9671('0x35')](_0x29d515['query'][_0x9671('0x35')]);_0x5bfe7c['where']=qs[_0x9671('0x37')](_[_0x9671('0x38')](_0x29d515['query'],_0x53c8a7[_0x9671('0x37')]));if(_0x29d515[_0x9671('0x2d')][_0x9671('0x39')]){_0x5bfe7c[_0x9671('0x36')]=_[_0x9671('0x3b')](_0x5bfe7c[_0x9671('0x36')],{'$or':_[_0x9671('0x2a')](_0x5bfe7c[_0x9671('0x30')],function(_0x5d8868){var _0x3e0bc8={};_0x3e0bc8[_0x5d8868]={'$like':'%'+_0x29d515[_0x9671('0x2d')][_0x9671('0x39')]+'%'};return _0x3e0bc8;})});}_0x5bfe7c=_[_0x9671('0x3b')]({},_0x5bfe7c,_0x29d515[_0x9671('0x3c')]);return _0x23fc46[_0x9671('0x4a')](_0x5bfe7c);}})[_0x9671('0x25')](function(_0x1ef0e8){if(_0x1ef0e8){_0x552759=_0x1ef0e8[_0x9671('0x40')];if(!_0x29d515[_0x9671('0x2d')][_0x9671('0x49')](_0x9671('0x33'))){_0x5bfe7c['limit']=qs['limit'](_0x29d515['query'][_0x9671('0x1d')]);_0x5bfe7c[_0x9671('0x20')]=qs[_0x9671('0x20')](_0x29d515[_0x9671('0x2d')][_0x9671('0x20')]);}return _0x23fc46[_0x9671('0x4a')](_0x5bfe7c);}})[_0x9671('0x25')](function(_0x157c88){if(_0x157c88){return _0x157c88?{'count':_0x552759,'rows':_0x157c88}:null;}})[_0x9671('0x25')](respondWithResult(_0x32ed10,null))[_0x9671('0x43')](handleError(_0x32ed10,null));};exports['getDescriptions']=function(_0x22b021,_0x4c8be6,_0x417f63){var _0xff29e3={};var _0x1f5bc9={};var _0x2cd1b3;var _0x4c58c3;return db[_0x9671('0x2b')]['findOne']({'where':{'id':_0x22b021[_0x9671('0x46')]['id']}})[_0x9671('0x25')](handleEntityNotFound(_0x4c8be6,null))[_0x9671('0x25')](function(_0x3bc763){if(_0x3bc763){_0x2cd1b3=_0x3bc763;_0x1f5bc9[_0x9671('0x31')]=_[_0x9671('0x2e')](db[_0x9671('0x4b')][_0x9671('0x3f')]);_0x1f5bc9[_0x9671('0x2d')]=_['keys'](_0x22b021['query']);_0x1f5bc9[_0x9671('0x37')]=_[_0x9671('0x2f')](_0x1f5bc9[_0x9671('0x31')],_0x1f5bc9[_0x9671('0x2d')]);_0xff29e3[_0x9671('0x30')]=_['intersection'](_0x1f5bc9[_0x9671('0x31')],qs[_0x9671('0x32')](_0x22b021[_0x9671('0x2d')][_0x9671('0x32')]));_0xff29e3[_0x9671('0x30')]=_0xff29e3[_0x9671('0x30')][_0x9671('0x40')]?_0xff29e3['attributes']:_0x1f5bc9['model'];_0xff29e3[_0x9671('0x34')]=qs[_0x9671('0x35')](_0x22b021[_0x9671('0x2d')][_0x9671('0x35')]);_0xff29e3[_0x9671('0x36')]=qs[_0x9671('0x37')](_[_0x9671('0x38')](_0x22b021[_0x9671('0x2d')],_0x1f5bc9[_0x9671('0x37')]));if(_0x22b021[_0x9671('0x2d')][_0x9671('0x39')]){_0xff29e3['where']=_['merge'](_0xff29e3[_0x9671('0x36')],{'$or':_[_0x9671('0x2a')](_0xff29e3[_0x9671('0x30')],function(_0xe6275c){var _0x5232e5={};_0x5232e5[_0xe6275c]={'$like':'%'+_0x22b021[_0x9671('0x2d')][_0x9671('0x39')]+'%'};return _0x5232e5;})});}_0xff29e3=_[_0x9671('0x3b')]({},_0xff29e3,_0x22b021[_0x9671('0x3c')]);return _0x2cd1b3['getDescriptions'](_0xff29e3);}})[_0x9671('0x25')](function(_0x2c1725){if(_0x2c1725){_0x4c58c3=_0x2c1725['length'];if(!_0x22b021[_0x9671('0x2d')]['hasOwnProperty'](_0x9671('0x33'))){_0xff29e3[_0x9671('0x1d')]=qs['limit'](_0x22b021[_0x9671('0x2d')][_0x9671('0x1d')]);_0xff29e3[_0x9671('0x20')]=qs[_0x9671('0x20')](_0x22b021[_0x9671('0x2d')][_0x9671('0x20')]);}return _0x2cd1b3[_0x9671('0x4c')](_0xff29e3);}})['then'](function(_0x39644a){if(_0x39644a){return _0x39644a?{'count':_0x4c58c3,'rows':_0x39644a}:null;}})[_0x9671('0x25')](respondWithResult(_0x4c8be6,null))[_0x9671('0x43')](handleError(_0x4c8be6,null));};
\ No newline at end of file
+var _0xa000=['crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','limit','count','set','Content-Range','apply','save','then','destroy','error','stack','name','index','map','VtigerConfiguration','rawAttributes','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','VIRTUAL','filter','merge','options','findAll','rows','catch','show','params','includeAll','find','create','body','update','findOne','VtigerField','getFields','getSubjects','getDescriptions','eml-format','rimraf','fast-json-patch','moment','mustache','util','sox','to-csv','fs-extra','squel'];(function(_0x1e8aab,_0x27d782){var _0x528966=function(_0x1d47dd){while(--_0x1d47dd){_0x1e8aab['push'](_0x1e8aab['shift']());}};_0x528966(++_0x27d782);}(_0xa000,0x177));var _0x0a00=function(_0x25f2da,_0x2bc56f){_0x25f2da=_0x25f2da-0x0;var _0x1ef2e1=_0xa000[_0x25f2da];return _0x1ef2e1;};'use strict';var emlformat=require(_0x0a00('0x0'));var rimraf=require(_0x0a00('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0a00('0x2'));var rp=require('request-promise');var moment=require(_0x0a00('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x0a00('0x4'));var util=require(_0x0a00('0x5'));var path=require('path');var sox=require(_0x0a00('0x6'));var csv=require(_0x0a00('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0a00('0x8'));var _=require('lodash');var squel=require(_0x0a00('0x9'));var crypto=require(_0x0a00('0xa'));var jsforce=require(_0x0a00('0xb'));var deskjs=require(_0x0a00('0xc'));var toCsv=require('to-csv');var querystring=require(_0x0a00('0xd'));var Papa=require(_0x0a00('0xe'));var Redis=require(_0x0a00('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x0a00('0x10'));var as=require(_0x0a00('0x11'));var hardwareService=require(_0x0a00('0x12'));var logger=require('../../config/logger')(_0x0a00('0x13'));var utils=require('../../config/utils');var config=require(_0x0a00('0x14'));var licenseUtil=require(_0x0a00('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x30247,_0x37faaa){_0x37faaa=_0x37faaa||0xcc;return function(_0x1e2cb2){if(_0x1e2cb2){return _0x30247[_0x0a00('0x16')](_0x37faaa);}return _0x30247[_0x0a00('0x17')](_0x37faaa)[_0x0a00('0x18')]();};}function respondWithResult(_0x26f286,_0x2e9fc0){_0x2e9fc0=_0x2e9fc0||0xc8;return function(_0x38fcae){if(_0x38fcae){return _0x26f286['status'](_0x2e9fc0)[_0x0a00('0x19')](_0x38fcae);}};}function respondWithFilteredResult(_0x282194,_0x3bb494){return function(_0x4dad6d){if(_0x4dad6d){var _0x4033e7=typeof _0x3bb494[_0x0a00('0x1a')]==='undefined'&&typeof _0x3bb494[_0x0a00('0x1b')]==='undefined';var _0x5444bd=_0x4dad6d[_0x0a00('0x1c')];var _0x2bfb4a=_0x4033e7?0x0:_0x3bb494['offset'];var _0x14f674=_0x4033e7?_0x4dad6d['count']:_0x3bb494[_0x0a00('0x1a')]+_0x3bb494[_0x0a00('0x1b')];var _0x21fe0c;if(_0x14f674>=_0x5444bd){_0x14f674=_0x5444bd;_0x21fe0c=0xc8;}else{_0x21fe0c=0xce;}_0x282194[_0x0a00('0x17')](_0x21fe0c);return _0x282194[_0x0a00('0x1d')](_0x0a00('0x1e'),_0x2bfb4a+'-'+_0x14f674+'/'+_0x5444bd)['json'](_0x4dad6d);}return null;};}function patchUpdates(_0x37ff9f){return function(_0xfb3245){try{jsonpatch[_0x0a00('0x1f')](_0xfb3245,_0x37ff9f,!![]);}catch(_0x57fdaa){return BPromise['reject'](_0x57fdaa);}return _0xfb3245[_0x0a00('0x20')]();};}function saveUpdates(_0x424af6,_0x35253b){return function(_0x160098){if(_0x160098){return _0x160098['update'](_0x424af6)[_0x0a00('0x21')](function(_0x1a61f9){return _0x1a61f9;});}return null;};}function removeEntity(_0x4ea2e1,_0x3a7ceb){return function(_0x4b8c06){if(_0x4b8c06){return _0x4b8c06[_0x0a00('0x22')]()[_0x0a00('0x21')](function(){_0x4ea2e1['status'](0xcc)[_0x0a00('0x18')]();});}};}function handleEntityNotFound(_0x47ce7e,_0x744ccc){return function(_0x84b43b){if(!_0x84b43b){_0x47ce7e[_0x0a00('0x16')](0x194);}return _0x84b43b;};}function handleError(_0x1f9414,_0x3d37b4){_0x3d37b4=_0x3d37b4||0x1f4;return function(_0x32afe2){logger[_0x0a00('0x23')](_0x32afe2[_0x0a00('0x24')]);if(_0x32afe2['name']){delete _0x32afe2[_0x0a00('0x25')];}_0x1f9414['status'](_0x3d37b4)['send'](_0x32afe2);};}exports[_0x0a00('0x26')]=function(_0x2e9f78,_0x141f06){var _0x42ebbb={},_0x186a71={},_0x30c952={'count':0x0,'rows':[]};var _0x3accba=_[_0x0a00('0x27')](db[_0x0a00('0x28')][_0x0a00('0x29')],function(_0x153e06){return{'name':_0x153e06['fieldName'],'type':_0x153e06[_0x0a00('0x2a')][_0x0a00('0x2b')]};});_0x186a71[_0x0a00('0x2c')]=_[_0x0a00('0x27')](_0x3accba,_0x0a00('0x25'));_0x186a71[_0x0a00('0x2d')]=_[_0x0a00('0x2e')](_0x2e9f78[_0x0a00('0x2d')]);_0x186a71['filters']=_[_0x0a00('0x2f')](_0x186a71[_0x0a00('0x2c')],_0x186a71[_0x0a00('0x2d')]);_0x42ebbb[_0x0a00('0x30')]=_['intersection'](_0x186a71['model'],qs[_0x0a00('0x31')](_0x2e9f78['query'][_0x0a00('0x31')]));_0x42ebbb[_0x0a00('0x30')]=_0x42ebbb[_0x0a00('0x30')][_0x0a00('0x32')]?_0x42ebbb[_0x0a00('0x30')]:_0x186a71[_0x0a00('0x2c')];if(!_0x2e9f78[_0x0a00('0x2d')][_0x0a00('0x33')](_0x0a00('0x34'))){_0x42ebbb[_0x0a00('0x1b')]=qs[_0x0a00('0x1b')](_0x2e9f78[_0x0a00('0x2d')][_0x0a00('0x1b')]);_0x42ebbb[_0x0a00('0x1a')]=qs['offset'](_0x2e9f78[_0x0a00('0x2d')][_0x0a00('0x1a')]);}_0x42ebbb[_0x0a00('0x35')]=qs[_0x0a00('0x36')](_0x2e9f78['query'][_0x0a00('0x36')]);_0x42ebbb[_0x0a00('0x37')]=qs[_0x0a00('0x38')](_[_0x0a00('0x39')](_0x2e9f78[_0x0a00('0x2d')],_0x186a71['filters']),_0x3accba);if(_0x2e9f78[_0x0a00('0x2d')]['filter']){_0x42ebbb['where']=_['merge'](_0x42ebbb[_0x0a00('0x37')],{'$or':_[_0x0a00('0x27')](_0x3accba,function(_0x357aa7){if(_0x357aa7[_0x0a00('0x2a')]!==_0x0a00('0x3a')){var _0x3e8d7c={};_0x3e8d7c[_0x357aa7[_0x0a00('0x25')]]={'$like':'%'+_0x2e9f78[_0x0a00('0x2d')][_0x0a00('0x3b')]+'%'};return _0x3e8d7c;}})});}_0x42ebbb=_[_0x0a00('0x3c')]({},_0x42ebbb,_0x2e9f78[_0x0a00('0x3d')]);var _0x499619={'where':_0x42ebbb['where']};return db[_0x0a00('0x28')][_0x0a00('0x1c')](_0x499619)['then'](function(_0x12bf4e){_0x30c952[_0x0a00('0x1c')]=_0x12bf4e;if(_0x2e9f78['query']['includeAll']){_0x42ebbb['include']=[{'all':!![]}];}return db[_0x0a00('0x28')][_0x0a00('0x3e')](_0x42ebbb);})[_0x0a00('0x21')](function(_0xdd205a){_0x30c952[_0x0a00('0x3f')]=_0xdd205a;return _0x30c952;})[_0x0a00('0x21')](respondWithFilteredResult(_0x141f06,_0x42ebbb))[_0x0a00('0x40')](handleError(_0x141f06,null));};exports[_0x0a00('0x41')]=function(_0x1a6daf,_0xfe3503){var _0x188eb2={'raw':![],'where':{'id':_0x1a6daf[_0x0a00('0x42')]['id']}},_0x15112f={};_0x15112f[_0x0a00('0x2c')]=_[_0x0a00('0x2e')](db['VtigerConfiguration'][_0x0a00('0x29')]);_0x15112f[_0x0a00('0x2d')]=_[_0x0a00('0x2e')](_0x1a6daf[_0x0a00('0x2d')]);_0x15112f[_0x0a00('0x38')]=_['intersection'](_0x15112f[_0x0a00('0x2c')],_0x15112f[_0x0a00('0x2d')]);_0x188eb2[_0x0a00('0x30')]=_['intersection'](_0x15112f[_0x0a00('0x2c')],qs[_0x0a00('0x31')](_0x1a6daf[_0x0a00('0x2d')][_0x0a00('0x31')]));_0x188eb2['attributes']=_0x188eb2['attributes'][_0x0a00('0x32')]?_0x188eb2['attributes']:_0x15112f[_0x0a00('0x2c')];if(_0x1a6daf[_0x0a00('0x2d')][_0x0a00('0x43')]){_0x188eb2['include']=[{'all':!![]}];}_0x188eb2=_[_0x0a00('0x3c')]({},_0x188eb2,_0x1a6daf[_0x0a00('0x3d')]);return db[_0x0a00('0x28')][_0x0a00('0x44')](_0x188eb2)[_0x0a00('0x21')](handleEntityNotFound(_0xfe3503,null))[_0x0a00('0x21')](respondWithResult(_0xfe3503,null))[_0x0a00('0x40')](handleError(_0xfe3503,null));};exports[_0x0a00('0x45')]=function(_0x23cc8d,_0x5316b8){return db[_0x0a00('0x28')][_0x0a00('0x45')](_0x23cc8d[_0x0a00('0x46')],{})[_0x0a00('0x21')](respondWithResult(_0x5316b8,0xc9))[_0x0a00('0x40')](handleError(_0x5316b8,null));};exports[_0x0a00('0x47')]=function(_0x5c1552,_0x351eee){if(_0x5c1552[_0x0a00('0x46')]['id']){delete _0x5c1552[_0x0a00('0x46')]['id'];}return db[_0x0a00('0x28')]['find']({'where':{'id':_0x5c1552[_0x0a00('0x42')]['id']}})[_0x0a00('0x21')](handleEntityNotFound(_0x351eee,null))[_0x0a00('0x21')](saveUpdates(_0x5c1552[_0x0a00('0x46')],null))[_0x0a00('0x21')](respondWithResult(_0x351eee,null))['catch'](handleError(_0x351eee,null));};exports['destroy']=function(_0x3ce2db,_0x4f178b){return db[_0x0a00('0x28')][_0x0a00('0x44')]({'where':{'id':_0x3ce2db['params']['id']}})[_0x0a00('0x21')](handleEntityNotFound(_0x4f178b,null))[_0x0a00('0x21')](removeEntity(_0x4f178b,null))[_0x0a00('0x40')](handleError(_0x4f178b,null));};exports['getFields']=function(_0x355559,_0x11a2e9,_0x429e9b){var _0x1b72b8={};var _0xacc791={};var _0x5b4717;var _0x4c727f;return db['VtigerConfiguration'][_0x0a00('0x48')]({'where':{'id':_0x355559[_0x0a00('0x42')]['id']}})[_0x0a00('0x21')](handleEntityNotFound(_0x11a2e9,null))[_0x0a00('0x21')](function(_0x4aefdf){if(_0x4aefdf){_0x5b4717=_0x4aefdf;_0xacc791[_0x0a00('0x2c')]=_[_0x0a00('0x2e')](db[_0x0a00('0x49')]['rawAttributes']);_0xacc791[_0x0a00('0x2d')]=_[_0x0a00('0x2e')](_0x355559[_0x0a00('0x2d')]);_0xacc791['filters']=_[_0x0a00('0x2f')](_0xacc791[_0x0a00('0x2c')],_0xacc791[_0x0a00('0x2d')]);_0x1b72b8['attributes']=_[_0x0a00('0x2f')](_0xacc791['model'],qs[_0x0a00('0x31')](_0x355559[_0x0a00('0x2d')][_0x0a00('0x31')]));_0x1b72b8[_0x0a00('0x30')]=_0x1b72b8[_0x0a00('0x30')][_0x0a00('0x32')]?_0x1b72b8[_0x0a00('0x30')]:_0xacc791[_0x0a00('0x2c')];_0x1b72b8[_0x0a00('0x35')]=qs[_0x0a00('0x36')](_0x355559['query']['sort']);_0x1b72b8['where']=qs[_0x0a00('0x38')](_['pick'](_0x355559[_0x0a00('0x2d')],_0xacc791[_0x0a00('0x38')]));if(_0x355559[_0x0a00('0x2d')][_0x0a00('0x3b')]){_0x1b72b8[_0x0a00('0x37')]=_['merge'](_0x1b72b8[_0x0a00('0x37')],{'$or':_['map'](_0x1b72b8[_0x0a00('0x30')],function(_0x490199){var _0x3490fe={};_0x3490fe[_0x490199]={'$like':'%'+_0x355559[_0x0a00('0x2d')]['filter']+'%'};return _0x3490fe;})});}_0x1b72b8=_['merge']({},_0x1b72b8,_0x355559[_0x0a00('0x3d')]);return _0x5b4717[_0x0a00('0x4a')](_0x1b72b8);}})[_0x0a00('0x21')](function(_0xb86241){if(_0xb86241){_0x4c727f=_0xb86241[_0x0a00('0x32')];if(!_0x355559[_0x0a00('0x2d')][_0x0a00('0x33')]('nolimit')){_0x1b72b8[_0x0a00('0x1b')]=qs[_0x0a00('0x1b')](_0x355559['query']['limit']);_0x1b72b8[_0x0a00('0x1a')]=qs['offset'](_0x355559[_0x0a00('0x2d')][_0x0a00('0x1a')]);}return _0x5b4717['getFields'](_0x1b72b8);}})[_0x0a00('0x21')](function(_0x47d273){if(_0x47d273){return _0x47d273?{'count':_0x4c727f,'rows':_0x47d273}:null;}})[_0x0a00('0x21')](respondWithResult(_0x11a2e9,null))[_0x0a00('0x40')](handleError(_0x11a2e9,null));};exports[_0x0a00('0x4b')]=function(_0xcbc971,_0x524d36,_0x5627c8){var _0x49dc0c={};var _0x18dcb3={};var _0x5c3cc6;var _0x3cd59b;return db[_0x0a00('0x28')][_0x0a00('0x48')]({'where':{'id':_0xcbc971[_0x0a00('0x42')]['id']}})[_0x0a00('0x21')](handleEntityNotFound(_0x524d36,null))[_0x0a00('0x21')](function(_0x1f1c94){if(_0x1f1c94){_0x5c3cc6=_0x1f1c94;_0x18dcb3[_0x0a00('0x2c')]=_[_0x0a00('0x2e')](db['VtigerField'][_0x0a00('0x29')]);_0x18dcb3['query']=_[_0x0a00('0x2e')](_0xcbc971[_0x0a00('0x2d')]);_0x18dcb3[_0x0a00('0x38')]=_['intersection'](_0x18dcb3['model'],_0x18dcb3['query']);_0x49dc0c[_0x0a00('0x30')]=_[_0x0a00('0x2f')](_0x18dcb3['model'],qs[_0x0a00('0x31')](_0xcbc971['query'][_0x0a00('0x31')]));_0x49dc0c[_0x0a00('0x30')]=_0x49dc0c[_0x0a00('0x30')]['length']?_0x49dc0c[_0x0a00('0x30')]:_0x18dcb3[_0x0a00('0x2c')];_0x49dc0c[_0x0a00('0x35')]=qs[_0x0a00('0x36')](_0xcbc971[_0x0a00('0x2d')]['sort']);_0x49dc0c[_0x0a00('0x37')]=qs['filters'](_[_0x0a00('0x39')](_0xcbc971['query'],_0x18dcb3[_0x0a00('0x38')]));if(_0xcbc971[_0x0a00('0x2d')][_0x0a00('0x3b')]){_0x49dc0c['where']=_[_0x0a00('0x3c')](_0x49dc0c[_0x0a00('0x37')],{'$or':_[_0x0a00('0x27')](_0x49dc0c[_0x0a00('0x30')],function(_0x365c05){var _0x5350d7={};_0x5350d7[_0x365c05]={'$like':'%'+_0xcbc971[_0x0a00('0x2d')][_0x0a00('0x3b')]+'%'};return _0x5350d7;})});}_0x49dc0c=_['merge']({},_0x49dc0c,_0xcbc971['options']);return _0x5c3cc6['getSubjects'](_0x49dc0c);}})[_0x0a00('0x21')](function(_0x41e4ab){if(_0x41e4ab){_0x3cd59b=_0x41e4ab['length'];if(!_0xcbc971[_0x0a00('0x2d')][_0x0a00('0x33')]('nolimit')){_0x49dc0c['limit']=qs[_0x0a00('0x1b')](_0xcbc971[_0x0a00('0x2d')][_0x0a00('0x1b')]);_0x49dc0c['offset']=qs[_0x0a00('0x1a')](_0xcbc971[_0x0a00('0x2d')]['offset']);}return _0x5c3cc6[_0x0a00('0x4b')](_0x49dc0c);}})['then'](function(_0x19fc9a){if(_0x19fc9a){return _0x19fc9a?{'count':_0x3cd59b,'rows':_0x19fc9a}:null;}})['then'](respondWithResult(_0x524d36,null))[_0x0a00('0x40')](handleError(_0x524d36,null));};exports['getDescriptions']=function(_0x3d48b6,_0x128c9b,_0x12d2e9){var _0x260dba={};var _0x4773c5={};var _0x4fec54;var _0x5d456c;return db['VtigerConfiguration'][_0x0a00('0x48')]({'where':{'id':_0x3d48b6['params']['id']}})['then'](handleEntityNotFound(_0x128c9b,null))['then'](function(_0xd6f9fd){if(_0xd6f9fd){_0x4fec54=_0xd6f9fd;_0x4773c5[_0x0a00('0x2c')]=_[_0x0a00('0x2e')](db[_0x0a00('0x49')][_0x0a00('0x29')]);_0x4773c5[_0x0a00('0x2d')]=_[_0x0a00('0x2e')](_0x3d48b6['query']);_0x4773c5[_0x0a00('0x38')]=_[_0x0a00('0x2f')](_0x4773c5[_0x0a00('0x2c')],_0x4773c5[_0x0a00('0x2d')]);_0x260dba[_0x0a00('0x30')]=_['intersection'](_0x4773c5[_0x0a00('0x2c')],qs[_0x0a00('0x31')](_0x3d48b6[_0x0a00('0x2d')][_0x0a00('0x31')]));_0x260dba[_0x0a00('0x30')]=_0x260dba[_0x0a00('0x30')][_0x0a00('0x32')]?_0x260dba[_0x0a00('0x30')]:_0x4773c5[_0x0a00('0x2c')];_0x260dba[_0x0a00('0x35')]=qs[_0x0a00('0x36')](_0x3d48b6[_0x0a00('0x2d')][_0x0a00('0x36')]);_0x260dba[_0x0a00('0x37')]=qs['filters'](_['pick'](_0x3d48b6[_0x0a00('0x2d')],_0x4773c5[_0x0a00('0x38')]));if(_0x3d48b6[_0x0a00('0x2d')]['filter']){_0x260dba['where']=_[_0x0a00('0x3c')](_0x260dba['where'],{'$or':_['map'](_0x260dba[_0x0a00('0x30')],function(_0x17a604){var _0x49e84a={};_0x49e84a[_0x17a604]={'$like':'%'+_0x3d48b6['query'][_0x0a00('0x3b')]+'%'};return _0x49e84a;})});}_0x260dba=_[_0x0a00('0x3c')]({},_0x260dba,_0x3d48b6[_0x0a00('0x3d')]);return _0x4fec54[_0x0a00('0x4c')](_0x260dba);}})[_0x0a00('0x21')](function(_0x3d741d){if(_0x3d741d){_0x5d456c=_0x3d741d[_0x0a00('0x32')];if(!_0x3d48b6['query'][_0x0a00('0x33')](_0x0a00('0x34'))){_0x260dba[_0x0a00('0x1b')]=qs[_0x0a00('0x1b')](_0x3d48b6['query'][_0x0a00('0x1b')]);_0x260dba[_0x0a00('0x1a')]=qs[_0x0a00('0x1a')](_0x3d48b6['query']['offset']);}return _0x4fec54[_0x0a00('0x4c')](_0x260dba);}})[_0x0a00('0x21')](function(_0x26fe46){if(_0x26fe46){return _0x26fe46?{'count':_0x5d456c,'rows':_0x26fe46}:null;}})[_0x0a00('0x21')](respondWithResult(_0x128c9b,null))[_0x0a00('0x40')](handleError(_0x128c9b,null));};
\ No newline at end of file