Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / intVtigerConfiguration / intVtigerConfiguration.controller.js
index b43c409..6dbe6a4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x88f4=['sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','update','then','destroy','error','stack','name','send','index','map','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','VtigerConfiguration','includeAll','findAll','rows','catch','params','rawAttributes','include','find','create','body','getFields','VtigerField','getSubjects','findOne','getDescriptions','eml-format','rimraf','zip-dir','request-promise','moment','mustache','path','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/license/util','../../mysqldb'];(function(_0x513aa5,_0x1fba79){var _0x1a1a7c=function(_0x240e3f){while(--_0x240e3f){_0x513aa5['push'](_0x513aa5['shift']());}};_0x1a1a7c(++_0x1fba79);}(_0x88f4,0x17d));var _0x488f=function(_0x55bb53,_0x5590af){_0x55bb53=_0x55bb53-0x0;var _0x396e95=_0x88f4[_0x55bb53];return _0x396e95;};'use strict';var emlformat=require(_0x488f('0x0'));var rimraf=require(_0x488f('0x1'));var zipdir=require(_0x488f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x488f('0x3'));var moment=require(_0x488f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x488f('0x5'));var util=require('util');var path=require(_0x488f('0x6'));var sox=require('sox');var csv=require(_0x488f('0x7'));var ejs=require(_0x488f('0x8'));var fs=require('fs');var fs_extra=require(_0x488f('0x9'));var _=require(_0x488f('0xa'));var squel=require(_0x488f('0xb'));var crypto=require(_0x488f('0xc'));var jsforce=require(_0x488f('0xd'));var deskjs=require(_0x488f('0xe'));var toCsv=require(_0x488f('0x7'));var querystring=require(_0x488f('0xf'));var Papa=require(_0x488f('0x10'));var Redis=require(_0x488f('0x11'));var authService=require(_0x488f('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x488f('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x488f('0x14'))('api');var utils=require(_0x488f('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x488f('0x16'));var db=require(_0x488f('0x17'))['db'];function respondWithStatusCode(_0x5cdbac,_0x57302c){_0x57302c=_0x57302c||0xcc;return function(_0x2dd8ca){if(_0x2dd8ca){return _0x5cdbac[_0x488f('0x18')](_0x57302c);}return _0x5cdbac[_0x488f('0x19')](_0x57302c)[_0x488f('0x1a')]();};}function respondWithResult(_0x4d45c8,_0x3b0251){_0x3b0251=_0x3b0251||0xc8;return function(_0x26c5ef){if(_0x26c5ef){return _0x4d45c8[_0x488f('0x19')](_0x3b0251)[_0x488f('0x1b')](_0x26c5ef);}};}function respondWithFilteredResult(_0xdb9a78,_0x53927f){return function(_0x4bf947){if(_0x4bf947){var _0x4e1484=typeof _0x53927f['offset']===_0x488f('0x1c')&&typeof _0x53927f[_0x488f('0x1d')]===_0x488f('0x1c');var _0xc96718=_0x4bf947[_0x488f('0x1e')];var _0x4904b8=_0x4e1484?0x0:_0x53927f[_0x488f('0x1f')];var _0x514060=_0x4e1484?_0x4bf947[_0x488f('0x1e')]:_0x53927f[_0x488f('0x1f')]+_0x53927f[_0x488f('0x1d')];var _0x5d167c;if(_0x514060>=_0xc96718){_0x514060=_0xc96718;_0x5d167c=0xc8;}else{_0x5d167c=0xce;}_0xdb9a78[_0x488f('0x19')](_0x5d167c);return _0xdb9a78[_0x488f('0x20')](_0x488f('0x21'),_0x4904b8+'-'+_0x514060+'/'+_0xc96718)[_0x488f('0x1b')](_0x4bf947);}return null;};}function patchUpdates(_0x4ab567){return function(_0x3e55ac){try{jsonpatch[_0x488f('0x22')](_0x3e55ac,_0x4ab567,!![]);}catch(_0x4da27a){return BPromise['reject'](_0x4da27a);}return _0x3e55ac['save']();};}function saveUpdates(_0x365072,_0x409840){return function(_0x5bf81b){if(_0x5bf81b){return _0x5bf81b[_0x488f('0x23')](_0x365072)[_0x488f('0x24')](function(_0x18f1b6){return _0x18f1b6;});}return null;};}function removeEntity(_0x14ff89,_0x21409b){return function(_0x4410f2){if(_0x4410f2){return _0x4410f2[_0x488f('0x25')]()[_0x488f('0x24')](function(){_0x14ff89[_0x488f('0x19')](0xcc)[_0x488f('0x1a')]();});}};}function handleEntityNotFound(_0x39a1a9,_0x30a1a2){return function(_0x10156e){if(!_0x10156e){_0x39a1a9['sendStatus'](0x194);}return _0x10156e;};}function handleError(_0x47c8d9,_0x248a2d){_0x248a2d=_0x248a2d||0x1f4;return function(_0x53cb1d){logger[_0x488f('0x26')](_0x53cb1d[_0x488f('0x27')]);if(_0x53cb1d[_0x488f('0x28')]){delete _0x53cb1d[_0x488f('0x28')];}_0x47c8d9[_0x488f('0x19')](_0x248a2d)[_0x488f('0x29')](_0x53cb1d);};}exports[_0x488f('0x2a')]=function(_0x10dfc2,_0x590f48){var _0x2266d3={},_0x577cc2={},_0x4b1075={'count':0x0,'rows':[]};var _0x45ce61=_[_0x488f('0x2b')](db['VtigerConfiguration']['rawAttributes'],function(_0x339ca3){return{'name':_0x339ca3[_0x488f('0x2c')],'type':_0x339ca3[_0x488f('0x2d')][_0x488f('0x2e')]};});_0x577cc2[_0x488f('0x2f')]=_[_0x488f('0x2b')](_0x45ce61,'name');_0x577cc2[_0x488f('0x30')]=_[_0x488f('0x31')](_0x10dfc2[_0x488f('0x30')]);_0x577cc2[_0x488f('0x32')]=_[_0x488f('0x33')](_0x577cc2[_0x488f('0x2f')],_0x577cc2[_0x488f('0x30')]);_0x2266d3[_0x488f('0x34')]=_['intersection'](_0x577cc2[_0x488f('0x2f')],qs[_0x488f('0x35')](_0x10dfc2[_0x488f('0x30')][_0x488f('0x35')]));_0x2266d3[_0x488f('0x34')]=_0x2266d3['attributes'][_0x488f('0x36')]?_0x2266d3['attributes']:_0x577cc2['model'];if(!_0x10dfc2[_0x488f('0x30')][_0x488f('0x37')](_0x488f('0x38'))){_0x2266d3[_0x488f('0x1d')]=qs[_0x488f('0x1d')](_0x10dfc2[_0x488f('0x30')][_0x488f('0x1d')]);_0x2266d3[_0x488f('0x1f')]=qs[_0x488f('0x1f')](_0x10dfc2[_0x488f('0x30')][_0x488f('0x1f')]);}_0x2266d3[_0x488f('0x39')]=qs[_0x488f('0x3a')](_0x10dfc2[_0x488f('0x30')][_0x488f('0x3a')]);_0x2266d3[_0x488f('0x3b')]=qs['filters'](_[_0x488f('0x3c')](_0x10dfc2[_0x488f('0x30')],_0x577cc2[_0x488f('0x32')]),_0x45ce61);if(_0x10dfc2['query'][_0x488f('0x3d')]){_0x2266d3['where']=_[_0x488f('0x3e')](_0x2266d3[_0x488f('0x3b')],{'$or':_['map'](_0x45ce61,function(_0x527064){if(_0x527064[_0x488f('0x2d')]!==_0x488f('0x3f')){var _0x1a3b0e={};_0x1a3b0e[_0x527064['name']]={'$like':'%'+_0x10dfc2[_0x488f('0x30')][_0x488f('0x3d')]+'%'};return _0x1a3b0e;}})});}_0x2266d3=_[_0x488f('0x3e')]({},_0x2266d3,_0x10dfc2[_0x488f('0x40')]);var _0x35e0b5={'where':_0x2266d3[_0x488f('0x3b')]};return db[_0x488f('0x41')][_0x488f('0x1e')](_0x35e0b5)[_0x488f('0x24')](function(_0x4d4f3d){_0x4b1075[_0x488f('0x1e')]=_0x4d4f3d;if(_0x10dfc2[_0x488f('0x30')][_0x488f('0x42')]){_0x2266d3['include']=[{'all':!![]}];}return db[_0x488f('0x41')][_0x488f('0x43')](_0x2266d3);})[_0x488f('0x24')](function(_0x317974){_0x4b1075[_0x488f('0x44')]=_0x317974;return _0x4b1075;})[_0x488f('0x24')](respondWithFilteredResult(_0x590f48,_0x2266d3))[_0x488f('0x45')](handleError(_0x590f48,null));};exports['show']=function(_0x43abc4,_0x4a2e46){var _0x5d32e1={'raw':![],'where':{'id':_0x43abc4[_0x488f('0x46')]['id']}},_0x4fffe3={};_0x4fffe3[_0x488f('0x2f')]=_['keys'](db[_0x488f('0x41')][_0x488f('0x47')]);_0x4fffe3[_0x488f('0x30')]=_[_0x488f('0x31')](_0x43abc4[_0x488f('0x30')]);_0x4fffe3['filters']=_[_0x488f('0x33')](_0x4fffe3[_0x488f('0x2f')],_0x4fffe3['query']);_0x5d32e1['attributes']=_[_0x488f('0x33')](_0x4fffe3[_0x488f('0x2f')],qs['fields'](_0x43abc4[_0x488f('0x30')][_0x488f('0x35')]));_0x5d32e1[_0x488f('0x34')]=_0x5d32e1[_0x488f('0x34')][_0x488f('0x36')]?_0x5d32e1[_0x488f('0x34')]:_0x4fffe3[_0x488f('0x2f')];if(_0x43abc4[_0x488f('0x30')][_0x488f('0x42')]){_0x5d32e1[_0x488f('0x48')]=[{'all':!![]}];}_0x5d32e1=_[_0x488f('0x3e')]({},_0x5d32e1,_0x43abc4['options']);return db[_0x488f('0x41')][_0x488f('0x49')](_0x5d32e1)['then'](handleEntityNotFound(_0x4a2e46,null))[_0x488f('0x24')](respondWithResult(_0x4a2e46,null))[_0x488f('0x45')](handleError(_0x4a2e46,null));};exports[_0x488f('0x4a')]=function(_0x1aef1a,_0x4c9f6e){return db['VtigerConfiguration'][_0x488f('0x4a')](_0x1aef1a['body'],{})[_0x488f('0x24')](respondWithResult(_0x4c9f6e,0xc9))['catch'](handleError(_0x4c9f6e,null));};exports[_0x488f('0x23')]=function(_0x3c40b0,_0x33dd5b){if(_0x3c40b0['body']['id']){delete _0x3c40b0[_0x488f('0x4b')]['id'];}return db[_0x488f('0x41')][_0x488f('0x49')]({'where':{'id':_0x3c40b0['params']['id']}})[_0x488f('0x24')](handleEntityNotFound(_0x33dd5b,null))[_0x488f('0x24')](saveUpdates(_0x3c40b0['body'],null))['then'](respondWithResult(_0x33dd5b,null))[_0x488f('0x45')](handleError(_0x33dd5b,null));};exports[_0x488f('0x25')]=function(_0x6f52d0,_0x1515e9){return db[_0x488f('0x41')]['find']({'where':{'id':_0x6f52d0[_0x488f('0x46')]['id']}})['then'](handleEntityNotFound(_0x1515e9,null))[_0x488f('0x24')](removeEntity(_0x1515e9,null))[_0x488f('0x45')](handleError(_0x1515e9,null));};exports[_0x488f('0x4c')]=function(_0x4fba60,_0x4bd8eb,_0xff4837){var _0x5af1f3={};var _0x487d0d={};var _0x164f6a;var _0x18e13d;return db[_0x488f('0x41')]['findOne']({'where':{'id':_0x4fba60[_0x488f('0x46')]['id']}})[_0x488f('0x24')](handleEntityNotFound(_0x4bd8eb,null))[_0x488f('0x24')](function(_0x31504c){if(_0x31504c){_0x164f6a=_0x31504c;_0x487d0d[_0x488f('0x2f')]=_['keys'](db[_0x488f('0x4d')]['rawAttributes']);_0x487d0d[_0x488f('0x30')]=_[_0x488f('0x31')](_0x4fba60['query']);_0x487d0d['filters']=_['intersection'](_0x487d0d['model'],_0x487d0d[_0x488f('0x30')]);_0x5af1f3[_0x488f('0x34')]=_[_0x488f('0x33')](_0x487d0d[_0x488f('0x2f')],qs[_0x488f('0x35')](_0x4fba60['query'][_0x488f('0x35')]));_0x5af1f3[_0x488f('0x34')]=_0x5af1f3['attributes'][_0x488f('0x36')]?_0x5af1f3[_0x488f('0x34')]:_0x487d0d[_0x488f('0x2f')];_0x5af1f3[_0x488f('0x39')]=qs['sort'](_0x4fba60[_0x488f('0x30')][_0x488f('0x3a')]);_0x5af1f3['where']=qs['filters'](_[_0x488f('0x3c')](_0x4fba60[_0x488f('0x30')],_0x487d0d[_0x488f('0x32')]));if(_0x4fba60[_0x488f('0x30')][_0x488f('0x3d')]){_0x5af1f3['where']=_[_0x488f('0x3e')](_0x5af1f3[_0x488f('0x3b')],{'$or':_['map'](_0x5af1f3[_0x488f('0x34')],function(_0x2e9a5f){var _0xdb1d15={};_0xdb1d15[_0x2e9a5f]={'$like':'%'+_0x4fba60[_0x488f('0x30')][_0x488f('0x3d')]+'%'};return _0xdb1d15;})});}_0x5af1f3=_['merge']({},_0x5af1f3,_0x4fba60['options']);return _0x164f6a[_0x488f('0x4c')](_0x5af1f3);}})[_0x488f('0x24')](function(_0xcaf622){if(_0xcaf622){_0x18e13d=_0xcaf622[_0x488f('0x36')];if(!_0x4fba60['query']['hasOwnProperty'](_0x488f('0x38'))){_0x5af1f3[_0x488f('0x1d')]=qs[_0x488f('0x1d')](_0x4fba60[_0x488f('0x30')][_0x488f('0x1d')]);_0x5af1f3[_0x488f('0x1f')]=qs['offset'](_0x4fba60[_0x488f('0x30')][_0x488f('0x1f')]);}return _0x164f6a[_0x488f('0x4c')](_0x5af1f3);}})[_0x488f('0x24')](function(_0x3df063){if(_0x3df063){return _0x3df063?{'count':_0x18e13d,'rows':_0x3df063}:null;}})[_0x488f('0x24')](respondWithResult(_0x4bd8eb,null))[_0x488f('0x45')](handleError(_0x4bd8eb,null));};exports[_0x488f('0x4e')]=function(_0x14972d,_0x20f82d,_0x530bfb){var _0x146028={};var _0x40c04a={};var _0x1db665;var _0x33f761;return db['VtigerConfiguration'][_0x488f('0x4f')]({'where':{'id':_0x14972d[_0x488f('0x46')]['id']}})[_0x488f('0x24')](handleEntityNotFound(_0x20f82d,null))[_0x488f('0x24')](function(_0x1abde2){if(_0x1abde2){_0x1db665=_0x1abde2;_0x40c04a[_0x488f('0x2f')]=_[_0x488f('0x31')](db[_0x488f('0x4d')][_0x488f('0x47')]);_0x40c04a[_0x488f('0x30')]=_['keys'](_0x14972d[_0x488f('0x30')]);_0x40c04a[_0x488f('0x32')]=_[_0x488f('0x33')](_0x40c04a['model'],_0x40c04a['query']);_0x146028[_0x488f('0x34')]=_['intersection'](_0x40c04a[_0x488f('0x2f')],qs[_0x488f('0x35')](_0x14972d[_0x488f('0x30')][_0x488f('0x35')]));_0x146028['attributes']=_0x146028[_0x488f('0x34')][_0x488f('0x36')]?_0x146028[_0x488f('0x34')]:_0x40c04a[_0x488f('0x2f')];_0x146028[_0x488f('0x39')]=qs[_0x488f('0x3a')](_0x14972d[_0x488f('0x30')][_0x488f('0x3a')]);_0x146028[_0x488f('0x3b')]=qs[_0x488f('0x32')](_[_0x488f('0x3c')](_0x14972d[_0x488f('0x30')],_0x40c04a[_0x488f('0x32')]));if(_0x14972d[_0x488f('0x30')]['filter']){_0x146028[_0x488f('0x3b')]=_[_0x488f('0x3e')](_0x146028['where'],{'$or':_[_0x488f('0x2b')](_0x146028[_0x488f('0x34')],function(_0x175221){var _0x2405da={};_0x2405da[_0x175221]={'$like':'%'+_0x14972d[_0x488f('0x30')][_0x488f('0x3d')]+'%'};return _0x2405da;})});}_0x146028=_[_0x488f('0x3e')]({},_0x146028,_0x14972d[_0x488f('0x40')]);return _0x1db665['getSubjects'](_0x146028);}})[_0x488f('0x24')](function(_0x55b57c){if(_0x55b57c){_0x33f761=_0x55b57c[_0x488f('0x36')];if(!_0x14972d[_0x488f('0x30')][_0x488f('0x37')](_0x488f('0x38'))){_0x146028['limit']=qs[_0x488f('0x1d')](_0x14972d['query']['limit']);_0x146028[_0x488f('0x1f')]=qs[_0x488f('0x1f')](_0x14972d[_0x488f('0x30')][_0x488f('0x1f')]);}return _0x1db665[_0x488f('0x4e')](_0x146028);}})[_0x488f('0x24')](function(_0x23959b){if(_0x23959b){return _0x23959b?{'count':_0x33f761,'rows':_0x23959b}:null;}})[_0x488f('0x24')](respondWithResult(_0x20f82d,null))[_0x488f('0x45')](handleError(_0x20f82d,null));};exports[_0x488f('0x50')]=function(_0xe9d289,_0x44425b,_0x4a76eb){var _0x1e1bb3={};var _0x5c7916={};var _0x42dff8;var _0x4d5821;return db['VtigerConfiguration']['findOne']({'where':{'id':_0xe9d289['params']['id']}})[_0x488f('0x24')](handleEntityNotFound(_0x44425b,null))[_0x488f('0x24')](function(_0x13eaa4){if(_0x13eaa4){_0x42dff8=_0x13eaa4;_0x5c7916['model']=_['keys'](db[_0x488f('0x4d')][_0x488f('0x47')]);_0x5c7916['query']=_[_0x488f('0x31')](_0xe9d289['query']);_0x5c7916[_0x488f('0x32')]=_[_0x488f('0x33')](_0x5c7916[_0x488f('0x2f')],_0x5c7916[_0x488f('0x30')]);_0x1e1bb3[_0x488f('0x34')]=_['intersection'](_0x5c7916['model'],qs['fields'](_0xe9d289[_0x488f('0x30')][_0x488f('0x35')]));_0x1e1bb3[_0x488f('0x34')]=_0x1e1bb3[_0x488f('0x34')]['length']?_0x1e1bb3[_0x488f('0x34')]:_0x5c7916[_0x488f('0x2f')];_0x1e1bb3[_0x488f('0x39')]=qs[_0x488f('0x3a')](_0xe9d289[_0x488f('0x30')][_0x488f('0x3a')]);_0x1e1bb3[_0x488f('0x3b')]=qs[_0x488f('0x32')](_[_0x488f('0x3c')](_0xe9d289[_0x488f('0x30')],_0x5c7916['filters']));if(_0xe9d289[_0x488f('0x30')][_0x488f('0x3d')]){_0x1e1bb3[_0x488f('0x3b')]=_[_0x488f('0x3e')](_0x1e1bb3['where'],{'$or':_[_0x488f('0x2b')](_0x1e1bb3[_0x488f('0x34')],function(_0x29bdd8){var _0x3873a5={};_0x3873a5[_0x29bdd8]={'$like':'%'+_0xe9d289[_0x488f('0x30')][_0x488f('0x3d')]+'%'};return _0x3873a5;})});}_0x1e1bb3=_['merge']({},_0x1e1bb3,_0xe9d289['options']);return _0x42dff8[_0x488f('0x50')](_0x1e1bb3);}})[_0x488f('0x24')](function(_0x4d70e7){if(_0x4d70e7){_0x4d5821=_0x4d70e7[_0x488f('0x36')];if(!_0xe9d289[_0x488f('0x30')][_0x488f('0x37')](_0x488f('0x38'))){_0x1e1bb3['limit']=qs[_0x488f('0x1d')](_0xe9d289['query'][_0x488f('0x1d')]);_0x1e1bb3['offset']=qs['offset'](_0xe9d289['query'][_0x488f('0x1f')]);}return _0x42dff8['getDescriptions'](_0x1e1bb3);}})[_0x488f('0x24')](function(_0x5db579){if(_0x5db579){return _0x5db579?{'count':_0x4d5821,'rows':_0x5db579}:null;}})['then'](respondWithResult(_0x44425b,null))['catch'](handleError(_0x44425b,null));};
\ No newline at end of file
+var _0x6684=['find','create','body','getFields','findOne','VtigerField','pick','hasOwnProperty','nolimit','getSubjects','getDescriptions','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','VtigerConfiguration','rawAttributes','key','model','query','keys','attributes','intersection','fields','limit','order','sort','where','filters','type','VIRTUAL','filter','options','include','findAll','catch','show','params','length','merge'];(function(_0x19115e,_0x507bab){var _0x45bbd4=function(_0x1308bf){while(--_0x1308bf){_0x19115e['push'](_0x19115e['shift']());}};_0x45bbd4(++_0x507bab);}(_0x6684,0x196));var _0x4668=function(_0x31abee,_0x11ff0c){_0x31abee=_0x31abee-0x0;var _0x3c1761=_0x6684[_0x31abee];return _0x3c1761;};'use strict';var emlformat=require(_0x4668('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x4668('0x1'));var rp=require(_0x4668('0x2'));var moment=require('moment');var BPromise=require(_0x4668('0x3'));var Mustache=require(_0x4668('0x4'));var util=require(_0x4668('0x5'));var path=require(_0x4668('0x6'));var sox=require('sox');var csv=require(_0x4668('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x4668('0x8'));var _=require(_0x4668('0x9'));var squel=require(_0x4668('0xa'));var crypto=require(_0x4668('0xb'));var jsforce=require(_0x4668('0xc'));var deskjs=require(_0x4668('0xd'));var toCsv=require(_0x4668('0x7'));var querystring=require('querystring');var Papa=require(_0x4668('0xe'));var Redis=require(_0x4668('0xf'));var authService=require(_0x4668('0x10'));var qs=require(_0x4668('0x11'));var as=require(_0x4668('0x12'));var hardwareService=require(_0x4668('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0x4668('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x4668('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x450b7d,_0x1bc4cd){_0x1bc4cd=_0x1bc4cd||0xcc;return function(_0x4152f2){if(_0x4152f2){return _0x450b7d[_0x4668('0x16')](_0x1bc4cd);}return _0x450b7d[_0x4668('0x17')](_0x1bc4cd)[_0x4668('0x18')]();};}function respondWithResult(_0x2c8a8c,_0x4c9eeb){_0x4c9eeb=_0x4c9eeb||0xc8;return function(_0x3ae7aa){if(_0x3ae7aa){return _0x2c8a8c[_0x4668('0x17')](_0x4c9eeb)[_0x4668('0x19')](_0x3ae7aa);}};}function respondWithFilteredResult(_0x4f20a9,_0x420410){return function(_0x4f3eb4){if(_0x4f3eb4){var _0x216b90=typeof _0x420410[_0x4668('0x1a')]===_0x4668('0x1b')&&typeof _0x420410['limit']===_0x4668('0x1b');var _0x15aaf7=_0x4f3eb4['count'];var _0x3f8fa3=_0x216b90?0x0:_0x420410[_0x4668('0x1a')];var _0x5f43ee=_0x216b90?_0x4f3eb4[_0x4668('0x1c')]:_0x420410[_0x4668('0x1a')]+_0x420410['limit'];var _0x3e6983;if(_0x5f43ee>=_0x15aaf7){_0x5f43ee=_0x15aaf7;_0x3e6983=0xc8;}else{_0x3e6983=0xce;}_0x4f20a9[_0x4668('0x17')](_0x3e6983);return _0x4f20a9[_0x4668('0x1d')](_0x4668('0x1e'),_0x3f8fa3+'-'+_0x5f43ee+'/'+_0x15aaf7)[_0x4668('0x19')](_0x4f3eb4);}return null;};}function patchUpdates(_0x21098e){return function(_0x317f3a){try{jsonpatch[_0x4668('0x1f')](_0x317f3a,_0x21098e,!![]);}catch(_0x49a9f6){return BPromise[_0x4668('0x20')](_0x49a9f6);}return _0x317f3a[_0x4668('0x21')]();};}function saveUpdates(_0x458914,_0x1ba8f9){return function(_0x46c8b3){if(_0x46c8b3){return _0x46c8b3[_0x4668('0x22')](_0x458914)[_0x4668('0x23')](function(_0xcd804f){return _0xcd804f;});}return null;};}function removeEntity(_0x667d8,_0x5f46f4){return function(_0x4c5aac){if(_0x4c5aac){return _0x4c5aac[_0x4668('0x24')]()[_0x4668('0x23')](function(){_0x667d8['status'](0xcc)[_0x4668('0x18')]();});}};}function handleEntityNotFound(_0x3e3536,_0x50bed8){return function(_0x513707){if(!_0x513707){_0x3e3536[_0x4668('0x16')](0x194);}return _0x513707;};}function handleError(_0x1d62cd,_0x491f60){_0x491f60=_0x491f60||0x1f4;return function(_0x23aaca){logger[_0x4668('0x25')](_0x23aaca[_0x4668('0x26')]);if(_0x23aaca[_0x4668('0x27')]){delete _0x23aaca[_0x4668('0x27')];}_0x1d62cd[_0x4668('0x17')](_0x491f60)[_0x4668('0x28')](_0x23aaca);};}exports[_0x4668('0x29')]=function(_0x55392d,_0x3c0549){var _0x483225={},_0x33d93d={},_0x587256={'count':0x0,'rows':[]};var _0x135c3f=_[_0x4668('0x2a')](db[_0x4668('0x2b')][_0x4668('0x2c')],function(_0x413a6f){return{'name':_0x413a6f['fieldName'],'type':_0x413a6f['type'][_0x4668('0x2d')]};});_0x33d93d[_0x4668('0x2e')]=_[_0x4668('0x2a')](_0x135c3f,'name');_0x33d93d[_0x4668('0x2f')]=_[_0x4668('0x30')](_0x55392d[_0x4668('0x2f')]);_0x33d93d['filters']=_['intersection'](_0x33d93d[_0x4668('0x2e')],_0x33d93d['query']);_0x483225[_0x4668('0x31')]=_[_0x4668('0x32')](_0x33d93d[_0x4668('0x2e')],qs[_0x4668('0x33')](_0x55392d[_0x4668('0x2f')][_0x4668('0x33')]));_0x483225[_0x4668('0x31')]=_0x483225[_0x4668('0x31')]['length']?_0x483225[_0x4668('0x31')]:_0x33d93d['model'];if(!_0x55392d[_0x4668('0x2f')]['hasOwnProperty']('nolimit')){_0x483225[_0x4668('0x34')]=qs[_0x4668('0x34')](_0x55392d['query']['limit']);_0x483225[_0x4668('0x1a')]=qs[_0x4668('0x1a')](_0x55392d['query'][_0x4668('0x1a')]);}_0x483225[_0x4668('0x35')]=qs['sort'](_0x55392d[_0x4668('0x2f')][_0x4668('0x36')]);_0x483225[_0x4668('0x37')]=qs[_0x4668('0x38')](_['pick'](_0x55392d[_0x4668('0x2f')],_0x33d93d['filters']),_0x135c3f);if(_0x55392d['query']['filter']){_0x483225['where']=_['merge'](_0x483225[_0x4668('0x37')],{'$or':_[_0x4668('0x2a')](_0x135c3f,function(_0x1f56e1){if(_0x1f56e1[_0x4668('0x39')]!==_0x4668('0x3a')){var _0x16228c={};_0x16228c[_0x1f56e1[_0x4668('0x27')]]={'$like':'%'+_0x55392d[_0x4668('0x2f')][_0x4668('0x3b')]+'%'};return _0x16228c;}})});}_0x483225=_['merge']({},_0x483225,_0x55392d[_0x4668('0x3c')]);var _0x13b1ca={'where':_0x483225[_0x4668('0x37')]};return db[_0x4668('0x2b')]['count'](_0x13b1ca)[_0x4668('0x23')](function(_0x5a6697){_0x587256[_0x4668('0x1c')]=_0x5a6697;if(_0x55392d[_0x4668('0x2f')]['includeAll']){_0x483225[_0x4668('0x3d')]=[{'all':!![]}];}return db[_0x4668('0x2b')][_0x4668('0x3e')](_0x483225);})[_0x4668('0x23')](function(_0x164a8e){_0x587256['rows']=_0x164a8e;return _0x587256;})[_0x4668('0x23')](respondWithFilteredResult(_0x3c0549,_0x483225))[_0x4668('0x3f')](handleError(_0x3c0549,null));};exports[_0x4668('0x40')]=function(_0x5eda5b,_0x281e5f){var _0x29ede9={'raw':![],'where':{'id':_0x5eda5b[_0x4668('0x41')]['id']}},_0xeb250d={};_0xeb250d[_0x4668('0x2e')]=_[_0x4668('0x30')](db['VtigerConfiguration'][_0x4668('0x2c')]);_0xeb250d['query']=_['keys'](_0x5eda5b[_0x4668('0x2f')]);_0xeb250d[_0x4668('0x38')]=_[_0x4668('0x32')](_0xeb250d['model'],_0xeb250d['query']);_0x29ede9[_0x4668('0x31')]=_[_0x4668('0x32')](_0xeb250d[_0x4668('0x2e')],qs[_0x4668('0x33')](_0x5eda5b[_0x4668('0x2f')][_0x4668('0x33')]));_0x29ede9['attributes']=_0x29ede9[_0x4668('0x31')][_0x4668('0x42')]?_0x29ede9[_0x4668('0x31')]:_0xeb250d[_0x4668('0x2e')];if(_0x5eda5b['query']['includeAll']){_0x29ede9[_0x4668('0x3d')]=[{'all':!![]}];}_0x29ede9=_[_0x4668('0x43')]({},_0x29ede9,_0x5eda5b[_0x4668('0x3c')]);return db[_0x4668('0x2b')][_0x4668('0x44')](_0x29ede9)['then'](handleEntityNotFound(_0x281e5f,null))[_0x4668('0x23')](respondWithResult(_0x281e5f,null))[_0x4668('0x3f')](handleError(_0x281e5f,null));};exports[_0x4668('0x45')]=function(_0x4ccf8f,_0x130de4){return db[_0x4668('0x2b')]['create'](_0x4ccf8f[_0x4668('0x46')],{})[_0x4668('0x23')](respondWithResult(_0x130de4,0xc9))[_0x4668('0x3f')](handleError(_0x130de4,null));};exports['update']=function(_0x35f7c5,_0x389577){if(_0x35f7c5[_0x4668('0x46')]['id']){delete _0x35f7c5[_0x4668('0x46')]['id'];}return db[_0x4668('0x2b')][_0x4668('0x44')]({'where':{'id':_0x35f7c5[_0x4668('0x41')]['id']}})['then'](handleEntityNotFound(_0x389577,null))[_0x4668('0x23')](saveUpdates(_0x35f7c5[_0x4668('0x46')],null))[_0x4668('0x23')](respondWithResult(_0x389577,null))[_0x4668('0x3f')](handleError(_0x389577,null));};exports['destroy']=function(_0x276877,_0x56c618){return db[_0x4668('0x2b')][_0x4668('0x44')]({'where':{'id':_0x276877[_0x4668('0x41')]['id']}})['then'](handleEntityNotFound(_0x56c618,null))[_0x4668('0x23')](removeEntity(_0x56c618,null))[_0x4668('0x3f')](handleError(_0x56c618,null));};exports[_0x4668('0x47')]=function(_0x343656,_0x5bee06,_0x12094a){var _0x2acd55={};var _0x596bfb={};var _0x5e271e;var _0x56e8d2;return db['VtigerConfiguration'][_0x4668('0x48')]({'where':{'id':_0x343656[_0x4668('0x41')]['id']}})[_0x4668('0x23')](handleEntityNotFound(_0x5bee06,null))[_0x4668('0x23')](function(_0xe1aa2d){if(_0xe1aa2d){_0x5e271e=_0xe1aa2d;_0x596bfb['model']=_[_0x4668('0x30')](db[_0x4668('0x49')][_0x4668('0x2c')]);_0x596bfb[_0x4668('0x2f')]=_[_0x4668('0x30')](_0x343656['query']);_0x596bfb[_0x4668('0x38')]=_[_0x4668('0x32')](_0x596bfb['model'],_0x596bfb[_0x4668('0x2f')]);_0x2acd55[_0x4668('0x31')]=_[_0x4668('0x32')](_0x596bfb[_0x4668('0x2e')],qs[_0x4668('0x33')](_0x343656[_0x4668('0x2f')]['fields']));_0x2acd55[_0x4668('0x31')]=_0x2acd55['attributes'][_0x4668('0x42')]?_0x2acd55[_0x4668('0x31')]:_0x596bfb[_0x4668('0x2e')];_0x2acd55['order']=qs[_0x4668('0x36')](_0x343656['query'][_0x4668('0x36')]);_0x2acd55['where']=qs[_0x4668('0x38')](_[_0x4668('0x4a')](_0x343656[_0x4668('0x2f')],_0x596bfb[_0x4668('0x38')]));if(_0x343656[_0x4668('0x2f')][_0x4668('0x3b')]){_0x2acd55['where']=_['merge'](_0x2acd55[_0x4668('0x37')],{'$or':_[_0x4668('0x2a')](_0x2acd55[_0x4668('0x31')],function(_0x170e60){var _0x2cb958={};_0x2cb958[_0x170e60]={'$like':'%'+_0x343656[_0x4668('0x2f')][_0x4668('0x3b')]+'%'};return _0x2cb958;})});}_0x2acd55=_[_0x4668('0x43')]({},_0x2acd55,_0x343656['options']);return _0x5e271e['getFields'](_0x2acd55);}})['then'](function(_0xb7a35a){if(_0xb7a35a){_0x56e8d2=_0xb7a35a[_0x4668('0x42')];if(!_0x343656[_0x4668('0x2f')][_0x4668('0x4b')](_0x4668('0x4c'))){_0x2acd55['limit']=qs[_0x4668('0x34')](_0x343656['query'][_0x4668('0x34')]);_0x2acd55[_0x4668('0x1a')]=qs['offset'](_0x343656['query'][_0x4668('0x1a')]);}return _0x5e271e[_0x4668('0x47')](_0x2acd55);}})[_0x4668('0x23')](function(_0x4adebb){if(_0x4adebb){return _0x4adebb?{'count':_0x56e8d2,'rows':_0x4adebb}:null;}})[_0x4668('0x23')](respondWithResult(_0x5bee06,null))[_0x4668('0x3f')](handleError(_0x5bee06,null));};exports[_0x4668('0x4d')]=function(_0x18c8b8,_0x3d52e4,_0x1d8c62){var _0x28f3d5={};var _0x578998={};var _0x3eb98f;var _0x3885be;return db[_0x4668('0x2b')][_0x4668('0x48')]({'where':{'id':_0x18c8b8['params']['id']}})[_0x4668('0x23')](handleEntityNotFound(_0x3d52e4,null))[_0x4668('0x23')](function(_0x3449c0){if(_0x3449c0){_0x3eb98f=_0x3449c0;_0x578998['model']=_[_0x4668('0x30')](db['VtigerField']['rawAttributes']);_0x578998['query']=_[_0x4668('0x30')](_0x18c8b8['query']);_0x578998[_0x4668('0x38')]=_['intersection'](_0x578998['model'],_0x578998[_0x4668('0x2f')]);_0x28f3d5[_0x4668('0x31')]=_['intersection'](_0x578998[_0x4668('0x2e')],qs[_0x4668('0x33')](_0x18c8b8[_0x4668('0x2f')]['fields']));_0x28f3d5[_0x4668('0x31')]=_0x28f3d5[_0x4668('0x31')][_0x4668('0x42')]?_0x28f3d5[_0x4668('0x31')]:_0x578998[_0x4668('0x2e')];_0x28f3d5[_0x4668('0x35')]=qs['sort'](_0x18c8b8['query'][_0x4668('0x36')]);_0x28f3d5[_0x4668('0x37')]=qs[_0x4668('0x38')](_[_0x4668('0x4a')](_0x18c8b8[_0x4668('0x2f')],_0x578998[_0x4668('0x38')]));if(_0x18c8b8[_0x4668('0x2f')][_0x4668('0x3b')]){_0x28f3d5[_0x4668('0x37')]=_[_0x4668('0x43')](_0x28f3d5[_0x4668('0x37')],{'$or':_['map'](_0x28f3d5[_0x4668('0x31')],function(_0x181d89){var _0x50b9f5={};_0x50b9f5[_0x181d89]={'$like':'%'+_0x18c8b8['query']['filter']+'%'};return _0x50b9f5;})});}_0x28f3d5=_[_0x4668('0x43')]({},_0x28f3d5,_0x18c8b8[_0x4668('0x3c')]);return _0x3eb98f[_0x4668('0x4d')](_0x28f3d5);}})['then'](function(_0x432f05){if(_0x432f05){_0x3885be=_0x432f05[_0x4668('0x42')];if(!_0x18c8b8['query'][_0x4668('0x4b')](_0x4668('0x4c'))){_0x28f3d5[_0x4668('0x34')]=qs['limit'](_0x18c8b8[_0x4668('0x2f')][_0x4668('0x34')]);_0x28f3d5[_0x4668('0x1a')]=qs['offset'](_0x18c8b8[_0x4668('0x2f')][_0x4668('0x1a')]);}return _0x3eb98f[_0x4668('0x4d')](_0x28f3d5);}})[_0x4668('0x23')](function(_0xe25578){if(_0xe25578){return _0xe25578?{'count':_0x3885be,'rows':_0xe25578}:null;}})[_0x4668('0x23')](respondWithResult(_0x3d52e4,null))[_0x4668('0x3f')](handleError(_0x3d52e4,null));};exports[_0x4668('0x4e')]=function(_0x207669,_0x20c380,_0x4791e0){var _0x2ca9aa={};var _0xf5593f={};var _0x2a5423;var _0x5af26f;return db[_0x4668('0x2b')][_0x4668('0x48')]({'where':{'id':_0x207669[_0x4668('0x41')]['id']}})['then'](handleEntityNotFound(_0x20c380,null))[_0x4668('0x23')](function(_0x134bfb){if(_0x134bfb){_0x2a5423=_0x134bfb;_0xf5593f['model']=_[_0x4668('0x30')](db[_0x4668('0x49')][_0x4668('0x2c')]);_0xf5593f['query']=_[_0x4668('0x30')](_0x207669[_0x4668('0x2f')]);_0xf5593f[_0x4668('0x38')]=_[_0x4668('0x32')](_0xf5593f[_0x4668('0x2e')],_0xf5593f['query']);_0x2ca9aa[_0x4668('0x31')]=_[_0x4668('0x32')](_0xf5593f[_0x4668('0x2e')],qs[_0x4668('0x33')](_0x207669['query']['fields']));_0x2ca9aa['attributes']=_0x2ca9aa[_0x4668('0x31')][_0x4668('0x42')]?_0x2ca9aa[_0x4668('0x31')]:_0xf5593f[_0x4668('0x2e')];_0x2ca9aa['order']=qs['sort'](_0x207669[_0x4668('0x2f')]['sort']);_0x2ca9aa[_0x4668('0x37')]=qs[_0x4668('0x38')](_['pick'](_0x207669[_0x4668('0x2f')],_0xf5593f[_0x4668('0x38')]));if(_0x207669[_0x4668('0x2f')][_0x4668('0x3b')]){_0x2ca9aa[_0x4668('0x37')]=_[_0x4668('0x43')](_0x2ca9aa[_0x4668('0x37')],{'$or':_['map'](_0x2ca9aa[_0x4668('0x31')],function(_0xf465f5){var _0x22343c={};_0x22343c[_0xf465f5]={'$like':'%'+_0x207669[_0x4668('0x2f')][_0x4668('0x3b')]+'%'};return _0x22343c;})});}_0x2ca9aa=_[_0x4668('0x43')]({},_0x2ca9aa,_0x207669[_0x4668('0x3c')]);return _0x2a5423[_0x4668('0x4e')](_0x2ca9aa);}})[_0x4668('0x23')](function(_0x2ade5b){if(_0x2ade5b){_0x5af26f=_0x2ade5b[_0x4668('0x42')];if(!_0x207669[_0x4668('0x2f')]['hasOwnProperty'](_0x4668('0x4c'))){_0x2ca9aa[_0x4668('0x34')]=qs[_0x4668('0x34')](_0x207669[_0x4668('0x2f')][_0x4668('0x34')]);_0x2ca9aa[_0x4668('0x1a')]=qs[_0x4668('0x1a')](_0x207669[_0x4668('0x2f')]['offset']);}return _0x2a5423[_0x4668('0x4e')](_0x2ca9aa);}})[_0x4668('0x23')](function(_0x3f1296){if(_0x3f1296){return _0x3f1296?{'count':_0x5af26f,'rows':_0x3f1296}:null;}})[_0x4668('0x23')](respondWithResult(_0x20c380,null))[_0x4668('0x3f')](handleError(_0x20c380,null));};
\ No newline at end of file