Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 98f86c0..01fb0e6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x00a2=['fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','VIRTUAL','merge','options','include','findAll','rows','show','params','VtigerField','includeAll','find','create','body','catch','eml-format','rimraf','zip-dir','bluebird','mustache','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','status','end','error','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','intersection'];(function(_0x2b419a,_0x2c74b7){var _0x1d1e40=function(_0x5bc36f){while(--_0x5bc36f){_0x2b419a['push'](_0x2b419a['shift']());}};_0x1d1e40(++_0x2c74b7);}(_0x00a2,0xb1));var _0x200a=function(_0x3a2d3d,_0x4e057f){_0x3a2d3d=_0x3a2d3d-0x0;var _0x1a7446=_0x00a2[_0x3a2d3d];return _0x1a7446;};'use strict';var emlformat=require(_0x200a('0x0'));var rimraf=require(_0x200a('0x1'));var zipdir=require(_0x200a('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x200a('0x3'));var Mustache=require(_0x200a('0x4'));var util=require('util');var path=require('path');var sox=require(_0x200a('0x5'));var csv=require(_0x200a('0x6'));var ejs=require(_0x200a('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x200a('0x8'));var squel=require(_0x200a('0x9'));var crypto=require(_0x200a('0xa'));var jsforce=require(_0x200a('0xb'));var deskjs=require(_0x200a('0xc'));var toCsv=require(_0x200a('0x6'));var querystring=require(_0x200a('0xd'));var Papa=require(_0x200a('0xe'));var Redis=require(_0x200a('0xf'));var authService=require(_0x200a('0x10'));var qs=require(_0x200a('0x11'));var as=require(_0x200a('0x12'));var hardwareService=require(_0x200a('0x13'));var logger=require(_0x200a('0x14'))(_0x200a('0x15'));var utils=require(_0x200a('0x16'));var config=require(_0x200a('0x17'));var licenseUtil=require(_0x200a('0x18'));var db=require(_0x200a('0x19'))['db'];function respondWithStatusCode(_0xc3f6f8,_0x4ac456){_0x4ac456=_0x4ac456||0xcc;return function(_0x275aac){if(_0x275aac){return _0xc3f6f8[_0x200a('0x1a')](_0x4ac456);}return _0xc3f6f8['status'](_0x4ac456)['end']();};}function respondWithResult(_0x4eaede,_0x5f53c3){_0x5f53c3=_0x5f53c3||0xc8;return function(_0x2636d1){if(_0x2636d1){return _0x4eaede['status'](_0x5f53c3)['json'](_0x2636d1);}};}function respondWithFilteredResult(_0x177188,_0xed4671){return function(_0x164a40){if(_0x164a40){var _0x491c5b=typeof _0xed4671[_0x200a('0x1b')]===_0x200a('0x1c')&&typeof _0xed4671[_0x200a('0x1d')]===_0x200a('0x1c');var _0x1429ad=_0x164a40['count'];var _0x59927b=_0x491c5b?0x0:_0xed4671[_0x200a('0x1b')];var _0x507251=_0x491c5b?_0x164a40[_0x200a('0x1e')]:_0xed4671[_0x200a('0x1b')]+_0xed4671['limit'];var _0x3c6ed9;if(_0x507251>=_0x1429ad){_0x507251=_0x1429ad;_0x3c6ed9=0xc8;}else{_0x3c6ed9=0xce;}_0x177188['status'](_0x3c6ed9);return _0x177188[_0x200a('0x1f')](_0x200a('0x20'),_0x59927b+'-'+_0x507251+'/'+_0x1429ad)['json'](_0x164a40);}return null;};}function patchUpdates(_0x164eef){return function(_0x48271d){try{jsonpatch[_0x200a('0x21')](_0x48271d,_0x164eef,!![]);}catch(_0xf1e683){return BPromise[_0x200a('0x22')](_0xf1e683);}return _0x48271d[_0x200a('0x23')]();};}function saveUpdates(_0x196e03,_0x20999c){return function(_0xb6b1e0){if(_0xb6b1e0){return _0xb6b1e0[_0x200a('0x24')](_0x196e03)[_0x200a('0x25')](function(_0x1e8d1){return _0x1e8d1;});}return null;};}function removeEntity(_0x3cc87f,_0x7e91d7){return function(_0xd8b8c0){if(_0xd8b8c0){return _0xd8b8c0[_0x200a('0x26')]()[_0x200a('0x25')](function(){_0x3cc87f[_0x200a('0x27')](0xcc)[_0x200a('0x28')]();});}};}function handleEntityNotFound(_0x123ce3,_0x289b6b){return function(_0x14e492){if(!_0x14e492){_0x123ce3[_0x200a('0x1a')](0x194);}return _0x14e492;};}function handleError(_0x49c379,_0x4b82b0){_0x4b82b0=_0x4b82b0||0x1f4;return function(_0x361b37){logger[_0x200a('0x29')](_0x361b37['stack']);if(_0x361b37[_0x200a('0x2a')]){delete _0x361b37['name'];}_0x49c379[_0x200a('0x27')](_0x4b82b0)[_0x200a('0x2b')](_0x361b37);};}exports[_0x200a('0x2c')]=function(_0x46425b,_0x4e2bdf){var _0x4afc40={},_0x5512f4={},_0xe985ec={'count':0x0,'rows':[]};var _0x4e67d3=_[_0x200a('0x2d')](db['VtigerField'][_0x200a('0x2e')],function(_0x56e7cf){return{'name':_0x56e7cf[_0x200a('0x2f')],'type':_0x56e7cf[_0x200a('0x30')][_0x200a('0x31')]};});_0x5512f4[_0x200a('0x32')]=_[_0x200a('0x2d')](_0x4e67d3,_0x200a('0x2a'));_0x5512f4[_0x200a('0x33')]=_[_0x200a('0x34')](_0x46425b[_0x200a('0x33')]);_0x5512f4['filters']=_[_0x200a('0x35')](_0x5512f4[_0x200a('0x32')],_0x5512f4[_0x200a('0x33')]);_0x4afc40['attributes']=_['intersection'](_0x5512f4[_0x200a('0x32')],qs['fields'](_0x46425b['query'][_0x200a('0x36')]));_0x4afc40[_0x200a('0x37')]=_0x4afc40[_0x200a('0x37')][_0x200a('0x38')]?_0x4afc40['attributes']:_0x5512f4[_0x200a('0x32')];if(!_0x46425b[_0x200a('0x33')][_0x200a('0x39')](_0x200a('0x3a'))){_0x4afc40['limit']=qs[_0x200a('0x1d')](_0x46425b[_0x200a('0x33')][_0x200a('0x1d')]);_0x4afc40['offset']=qs['offset'](_0x46425b['query'][_0x200a('0x1b')]);}_0x4afc40[_0x200a('0x3b')]=qs['sort'](_0x46425b[_0x200a('0x33')][_0x200a('0x3c')]);_0x4afc40[_0x200a('0x3d')]=qs[_0x200a('0x3e')](_['pick'](_0x46425b['query'],_0x5512f4[_0x200a('0x3e')]),_0x4e67d3);if(_0x46425b['query']['filter']){_0x4afc40[_0x200a('0x3d')]=_['merge'](_0x4afc40[_0x200a('0x3d')],{'$or':_['map'](_0x4e67d3,function(_0x144a9f){if(_0x144a9f[_0x200a('0x30')]!==_0x200a('0x3f')){var _0x35cad0={};_0x35cad0[_0x144a9f[_0x200a('0x2a')]]={'$like':'%'+_0x46425b[_0x200a('0x33')]['filter']+'%'};return _0x35cad0;}})});}_0x4afc40=_[_0x200a('0x40')]({},_0x4afc40,_0x46425b[_0x200a('0x41')]);var _0x1c7aed={'where':_0x4afc40[_0x200a('0x3d')]};return db['VtigerField']['count'](_0x1c7aed)[_0x200a('0x25')](function(_0x2f84ba){_0xe985ec[_0x200a('0x1e')]=_0x2f84ba;if(_0x46425b[_0x200a('0x33')]['includeAll']){_0x4afc40[_0x200a('0x42')]=[{'all':!![]}];}return db['VtigerField'][_0x200a('0x43')](_0x4afc40);})['then'](function(_0x530721){_0xe985ec[_0x200a('0x44')]=_0x530721;return _0xe985ec;})[_0x200a('0x25')](respondWithFilteredResult(_0x4e2bdf,_0x4afc40))['catch'](handleError(_0x4e2bdf,null));};exports[_0x200a('0x45')]=function(_0x1d2e71,_0x255e06){var _0x50e0a8={'raw':!![],'where':{'id':_0x1d2e71[_0x200a('0x46')]['id']}},_0x5134db={};_0x5134db['model']=_[_0x200a('0x34')](db[_0x200a('0x47')][_0x200a('0x2e')]);_0x5134db[_0x200a('0x33')]=_['keys'](_0x1d2e71[_0x200a('0x33')]);_0x5134db['filters']=_[_0x200a('0x35')](_0x5134db['model'],_0x5134db[_0x200a('0x33')]);_0x50e0a8['attributes']=_[_0x200a('0x35')](_0x5134db['model'],qs[_0x200a('0x36')](_0x1d2e71[_0x200a('0x33')][_0x200a('0x36')]));_0x50e0a8[_0x200a('0x37')]=_0x50e0a8[_0x200a('0x37')][_0x200a('0x38')]?_0x50e0a8[_0x200a('0x37')]:_0x5134db[_0x200a('0x32')];if(_0x1d2e71[_0x200a('0x33')][_0x200a('0x48')]){_0x50e0a8[_0x200a('0x42')]=[{'all':!![]}];}_0x50e0a8=_[_0x200a('0x40')]({},_0x50e0a8,_0x1d2e71['options']);return db[_0x200a('0x47')][_0x200a('0x49')](_0x50e0a8)[_0x200a('0x25')](handleEntityNotFound(_0x255e06,null))[_0x200a('0x25')](respondWithResult(_0x255e06,null))['catch'](handleError(_0x255e06,null));};exports[_0x200a('0x4a')]=function(_0x34fe90,_0x218eb3){return db[_0x200a('0x47')][_0x200a('0x4a')](_0x34fe90[_0x200a('0x4b')],{})['then'](respondWithResult(_0x218eb3,0xc9))[_0x200a('0x4c')](handleError(_0x218eb3,null));};exports[_0x200a('0x24')]=function(_0x59f0b5,_0x3b649){if(_0x59f0b5[_0x200a('0x4b')]['id']){delete _0x59f0b5['body']['id'];}return db[_0x200a('0x47')][_0x200a('0x49')]({'where':{'id':_0x59f0b5[_0x200a('0x46')]['id']}})[_0x200a('0x25')](handleEntityNotFound(_0x3b649,null))['then'](saveUpdates(_0x59f0b5[_0x200a('0x4b')],null))['then'](respondWithResult(_0x3b649,null))['catch'](handleError(_0x3b649,null));};exports[_0x200a('0x26')]=function(_0x134091,_0x12fc7a){return db[_0x200a('0x47')][_0x200a('0x49')]({'where':{'id':_0x134091[_0x200a('0x46')]['id']}})['then'](handleEntityNotFound(_0x12fc7a,null))['then'](removeEntity(_0x12fc7a,null))[_0x200a('0x4c')](handleError(_0x12fc7a,null));};
\ No newline at end of file
+var _0x65f6=['../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','stack','name','index','map','VtigerField','rawAttributes','keys','filters','intersection','model','query','fields','attributes','length','hasOwnProperty','nolimit','sort','where','filter','merge','type','options','include','findAll','rows','catch','show','find','create','body','params','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util'];(function(_0x199572,_0x33e667){var _0x13cfa3=function(_0x53c075){while(--_0x53c075){_0x199572['push'](_0x199572['shift']());}};_0x13cfa3(++_0x33e667);}(_0x65f6,0x77));var _0x665f=function(_0x532c54,_0x54f860){_0x532c54=_0x532c54-0x0;var _0x5887e5=_0x65f6[_0x532c54];return _0x5887e5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x665f('0x0'));var zipdir=require(_0x665f('0x1'));var jsonpatch=require(_0x665f('0x2'));var rp=require(_0x665f('0x3'));var moment=require(_0x665f('0x4'));var BPromise=require(_0x665f('0x5'));var Mustache=require('mustache');var util=require(_0x665f('0x6'));var path=require('path');var sox=require(_0x665f('0x7'));var csv=require(_0x665f('0x8'));var ejs=require(_0x665f('0x9'));var fs=require('fs');var fs_extra=require(_0x665f('0xa'));var _=require('lodash');var squel=require(_0x665f('0xb'));var crypto=require(_0x665f('0xc'));var jsforce=require(_0x665f('0xd'));var deskjs=require(_0x665f('0xe'));var toCsv=require(_0x665f('0x8'));var querystring=require(_0x665f('0xf'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x665f('0x10'));var as=require(_0x665f('0x11'));var hardwareService=require(_0x665f('0x12'));var logger=require(_0x665f('0x13'))(_0x665f('0x14'));var utils=require(_0x665f('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x665f('0x16'));var db=require(_0x665f('0x17'))['db'];function respondWithStatusCode(_0x2b64d5,_0x4e7286){_0x4e7286=_0x4e7286||0xcc;return function(_0x2cc1f8){if(_0x2cc1f8){return _0x2b64d5[_0x665f('0x18')](_0x4e7286);}return _0x2b64d5[_0x665f('0x19')](_0x4e7286)[_0x665f('0x1a')]();};}function respondWithResult(_0x2ff680,_0x16f677){_0x16f677=_0x16f677||0xc8;return function(_0x58f48c){if(_0x58f48c){return _0x2ff680[_0x665f('0x19')](_0x16f677)[_0x665f('0x1b')](_0x58f48c);}};}function respondWithFilteredResult(_0x5ff7e0,_0x43960a){return function(_0x2fe036){if(_0x2fe036){var _0x13bb64=typeof _0x43960a[_0x665f('0x1c')]===_0x665f('0x1d')&&typeof _0x43960a[_0x665f('0x1e')]==='undefined';var _0x498c9b=_0x2fe036[_0x665f('0x1f')];var _0xfd7b35=_0x13bb64?0x0:_0x43960a[_0x665f('0x1c')];var _0x28ea1e=_0x13bb64?_0x2fe036['count']:_0x43960a[_0x665f('0x1c')]+_0x43960a[_0x665f('0x1e')];var _0x5a9715;if(_0x28ea1e>=_0x498c9b){_0x28ea1e=_0x498c9b;_0x5a9715=0xc8;}else{_0x5a9715=0xce;}_0x5ff7e0[_0x665f('0x19')](_0x5a9715);return _0x5ff7e0[_0x665f('0x20')](_0x665f('0x21'),_0xfd7b35+'-'+_0x28ea1e+'/'+_0x498c9b)[_0x665f('0x1b')](_0x2fe036);}return null;};}function patchUpdates(_0x389516){return function(_0x44afde){try{jsonpatch[_0x665f('0x22')](_0x44afde,_0x389516,!![]);}catch(_0x45b448){return BPromise[_0x665f('0x23')](_0x45b448);}return _0x44afde[_0x665f('0x24')]();};}function saveUpdates(_0x4ad07e,_0x32eb12){return function(_0x2c0370){if(_0x2c0370){return _0x2c0370[_0x665f('0x25')](_0x4ad07e)[_0x665f('0x26')](function(_0x4483af){return _0x4483af;});}return null;};}function removeEntity(_0x841de,_0x4cc8ec){return function(_0x270e36){if(_0x270e36){return _0x270e36[_0x665f('0x27')]()[_0x665f('0x26')](function(){_0x841de[_0x665f('0x19')](0xcc)[_0x665f('0x1a')]();});}};}function handleEntityNotFound(_0x9d1e8d,_0x40ff2b){return function(_0x538529){if(!_0x538529){_0x9d1e8d[_0x665f('0x18')](0x194);}return _0x538529;};}function handleError(_0x4d685c,_0x462bcd){_0x462bcd=_0x462bcd||0x1f4;return function(_0x1e2f6d){logger['error'](_0x1e2f6d[_0x665f('0x28')]);if(_0x1e2f6d['name']){delete _0x1e2f6d[_0x665f('0x29')];}_0x4d685c['status'](_0x462bcd)['send'](_0x1e2f6d);};}exports[_0x665f('0x2a')]=function(_0x5bc5a4,_0x2e8ff3){var _0x4b94f4={},_0x2bff02={},_0x3abc91={'count':0x0,'rows':[]};var _0x5b1821=_[_0x665f('0x2b')](db[_0x665f('0x2c')][_0x665f('0x2d')],function(_0x1c2cfc){return{'name':_0x1c2cfc['fieldName'],'type':_0x1c2cfc['type']['key']};});_0x2bff02['model']=_[_0x665f('0x2b')](_0x5b1821,_0x665f('0x29'));_0x2bff02['query']=_[_0x665f('0x2e')](_0x5bc5a4['query']);_0x2bff02[_0x665f('0x2f')]=_[_0x665f('0x30')](_0x2bff02[_0x665f('0x31')],_0x2bff02[_0x665f('0x32')]);_0x4b94f4['attributes']=_['intersection'](_0x2bff02[_0x665f('0x31')],qs[_0x665f('0x33')](_0x5bc5a4['query'][_0x665f('0x33')]));_0x4b94f4['attributes']=_0x4b94f4[_0x665f('0x34')][_0x665f('0x35')]?_0x4b94f4['attributes']:_0x2bff02[_0x665f('0x31')];if(!_0x5bc5a4[_0x665f('0x32')][_0x665f('0x36')](_0x665f('0x37'))){_0x4b94f4[_0x665f('0x1e')]=qs[_0x665f('0x1e')](_0x5bc5a4[_0x665f('0x32')][_0x665f('0x1e')]);_0x4b94f4[_0x665f('0x1c')]=qs[_0x665f('0x1c')](_0x5bc5a4['query'][_0x665f('0x1c')]);}_0x4b94f4['order']=qs[_0x665f('0x38')](_0x5bc5a4[_0x665f('0x32')][_0x665f('0x38')]);_0x4b94f4[_0x665f('0x39')]=qs['filters'](_['pick'](_0x5bc5a4[_0x665f('0x32')],_0x2bff02[_0x665f('0x2f')]),_0x5b1821);if(_0x5bc5a4[_0x665f('0x32')][_0x665f('0x3a')]){_0x4b94f4['where']=_[_0x665f('0x3b')](_0x4b94f4['where'],{'$or':_['map'](_0x5b1821,function(_0x2b2017){if(_0x2b2017[_0x665f('0x3c')]!=='VIRTUAL'){var _0x10b286={};_0x10b286[_0x2b2017['name']]={'$like':'%'+_0x5bc5a4[_0x665f('0x32')][_0x665f('0x3a')]+'%'};return _0x10b286;}})});}_0x4b94f4=_['merge']({},_0x4b94f4,_0x5bc5a4[_0x665f('0x3d')]);var _0x30be9d={'where':_0x4b94f4[_0x665f('0x39')]};return db[_0x665f('0x2c')]['count'](_0x30be9d)[_0x665f('0x26')](function(_0x15aeb5){_0x3abc91[_0x665f('0x1f')]=_0x15aeb5;if(_0x5bc5a4[_0x665f('0x32')]['includeAll']){_0x4b94f4[_0x665f('0x3e')]=[{'all':!![]}];}return db[_0x665f('0x2c')][_0x665f('0x3f')](_0x4b94f4);})[_0x665f('0x26')](function(_0x2232fd){_0x3abc91[_0x665f('0x40')]=_0x2232fd;return _0x3abc91;})['then'](respondWithFilteredResult(_0x2e8ff3,_0x4b94f4))[_0x665f('0x41')](handleError(_0x2e8ff3,null));};exports[_0x665f('0x42')]=function(_0x64ebb4,_0x624023){var _0x4e32b4={'raw':!![],'where':{'id':_0x64ebb4['params']['id']}},_0x576772={};_0x576772[_0x665f('0x31')]=_[_0x665f('0x2e')](db['VtigerField']['rawAttributes']);_0x576772['query']=_[_0x665f('0x2e')](_0x64ebb4['query']);_0x576772[_0x665f('0x2f')]=_['intersection'](_0x576772['model'],_0x576772[_0x665f('0x32')]);_0x4e32b4[_0x665f('0x34')]=_['intersection'](_0x576772[_0x665f('0x31')],qs['fields'](_0x64ebb4[_0x665f('0x32')][_0x665f('0x33')]));_0x4e32b4[_0x665f('0x34')]=_0x4e32b4[_0x665f('0x34')][_0x665f('0x35')]?_0x4e32b4[_0x665f('0x34')]:_0x576772['model'];if(_0x64ebb4[_0x665f('0x32')]['includeAll']){_0x4e32b4[_0x665f('0x3e')]=[{'all':!![]}];}_0x4e32b4=_['merge']({},_0x4e32b4,_0x64ebb4[_0x665f('0x3d')]);return db[_0x665f('0x2c')][_0x665f('0x43')](_0x4e32b4)[_0x665f('0x26')](handleEntityNotFound(_0x624023,null))[_0x665f('0x26')](respondWithResult(_0x624023,null))[_0x665f('0x41')](handleError(_0x624023,null));};exports['create']=function(_0x110527,_0x3df1ca){return db[_0x665f('0x2c')][_0x665f('0x44')](_0x110527['body'],{})[_0x665f('0x26')](respondWithResult(_0x3df1ca,0xc9))['catch'](handleError(_0x3df1ca,null));};exports[_0x665f('0x25')]=function(_0x359bb8,_0x5874d7){if(_0x359bb8[_0x665f('0x45')]['id']){delete _0x359bb8[_0x665f('0x45')]['id'];}return db[_0x665f('0x2c')]['find']({'where':{'id':_0x359bb8[_0x665f('0x46')]['id']}})['then'](handleEntityNotFound(_0x5874d7,null))[_0x665f('0x26')](saveUpdates(_0x359bb8['body'],null))[_0x665f('0x26')](respondWithResult(_0x5874d7,null))[_0x665f('0x41')](handleError(_0x5874d7,null));};exports[_0x665f('0x27')]=function(_0x4714b0,_0x51077b){return db[_0x665f('0x2c')][_0x665f('0x43')]({'where':{'id':_0x4714b0[_0x665f('0x46')]['id']}})[_0x665f('0x26')](handleEntityNotFound(_0x51077b,null))[_0x665f('0x26')](removeEntity(_0x51077b,null))[_0x665f('0x41')](handleError(_0x51077b,null));};
\ No newline at end of file