Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 842317a..9645a0d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6f58=['length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','VtigerField','includeAll','include','findAll','params','keys','find','catch','create','body','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','then','stack','name','send','index','map','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields'];(function(_0x3851ea,_0x2a2ee9){var _0x58db3c=function(_0x321c83){while(--_0x321c83){_0x3851ea['push'](_0x3851ea['shift']());}};_0x58db3c(++_0x2a2ee9);}(_0x6f58,0xe9));var _0x86f5=function(_0x228eb7,_0x526138){_0x228eb7=_0x228eb7-0x0;var _0x59da7a=_0x6f58[_0x228eb7];return _0x59da7a;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x86f5('0x0'));var zipdir=require(_0x86f5('0x1'));var jsonpatch=require(_0x86f5('0x2'));var rp=require('request-promise');var moment=require(_0x86f5('0x3'));var BPromise=require(_0x86f5('0x4'));var Mustache=require('mustache');var util=require(_0x86f5('0x5'));var path=require(_0x86f5('0x6'));var sox=require('sox');var csv=require(_0x86f5('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x86f5('0x8'));var squel=require('squel');var crypto=require(_0x86f5('0x9'));var jsforce=require(_0x86f5('0xa'));var deskjs=require(_0x86f5('0xb'));var toCsv=require(_0x86f5('0x7'));var querystring=require(_0x86f5('0xc'));var Papa=require(_0x86f5('0xd'));var Redis=require('ioredis');var authService=require(_0x86f5('0xe'));var qs=require(_0x86f5('0xf'));var as=require(_0x86f5('0x10'));var hardwareService=require(_0x86f5('0x11'));var logger=require(_0x86f5('0x12'))(_0x86f5('0x13'));var utils=require(_0x86f5('0x14'));var config=require(_0x86f5('0x15'));var db=require(_0x86f5('0x16'))['db'];function respondWithStatusCode(_0x272129,_0x264cbe){_0x264cbe=_0x264cbe||0xcc;return function(_0x4e2029){if(_0x4e2029){return _0x272129[_0x86f5('0x17')](_0x264cbe);}return _0x272129[_0x86f5('0x18')](_0x264cbe)[_0x86f5('0x19')]();};}function respondWithResult(_0x58ff3c,_0x9dafd){_0x9dafd=_0x9dafd||0xc8;return function(_0x5df6ad){if(_0x5df6ad){return _0x58ff3c[_0x86f5('0x18')](_0x9dafd)[_0x86f5('0x1a')](_0x5df6ad);}};}function respondWithFilteredResult(_0x4fea9f,_0x9b5f10){return function(_0x438619){if(_0x438619){var _0x27c5a5=_0x438619[_0x86f5('0x1b')],_0x8a4c28=_0x9b5f10[_0x86f5('0x1c')],_0xc297d8=_0x9b5f10[_0x86f5('0x1c')]+_0x9b5f10[_0x86f5('0x1d')],_0x5448c3;if(_0xc297d8>=_0x27c5a5){_0xc297d8=_0x27c5a5;_0x5448c3=0xc8;}else{_0x5448c3=0xce;}_0x4fea9f['status'](_0x5448c3);return _0x4fea9f[_0x86f5('0x1e')](_0x86f5('0x1f'),_0x8a4c28+'-'+_0xc297d8+'/'+_0x27c5a5)[_0x86f5('0x1a')](_0x438619);}return null;};}function patchUpdates(_0x48057d){return function(_0x3c8978){try{jsonpatch[_0x86f5('0x20')](_0x3c8978,_0x48057d,!![]);}catch(_0x2e2a01){return BPromise[_0x86f5('0x21')](_0x2e2a01);}return _0x3c8978[_0x86f5('0x22')]();};}function saveUpdates(_0x2dd300,_0x2ae4db){return function(_0x27e93f){if(_0x27e93f){return _0x27e93f['update'](_0x2dd300)[_0x86f5('0x23')](function(_0x4a2f85){return _0x4a2f85;});}return null;};}function removeEntity(_0x36bc77,_0xc77f9b){return function(_0x25887e){if(_0x25887e){return _0x25887e['destroy']()[_0x86f5('0x23')](function(){_0x36bc77[_0x86f5('0x18')](0xcc)[_0x86f5('0x19')]();});}};}function handleEntityNotFound(_0x2e0647,_0x4c4b8b){return function(_0x3fe9e7){if(!_0x3fe9e7){_0x2e0647['sendStatus'](0x194);}return _0x3fe9e7;};}function handleError(_0x46f147,_0x4ee00e){_0x4ee00e=_0x4ee00e||0x1f4;return function(_0x4416f5){logger['error'](_0x4416f5[_0x86f5('0x24')]);if(_0x4416f5['name']){delete _0x4416f5[_0x86f5('0x25')];}_0x46f147[_0x86f5('0x18')](_0x4ee00e)[_0x86f5('0x26')](_0x4416f5);};}exports[_0x86f5('0x27')]=function(_0x3fc3c6,_0xca25d3){var _0x4ab0c={},_0x4e8085={},_0xb9686e={'count':0x0,'rows':[]};var _0x138e46=_[_0x86f5('0x28')](db['VtigerField'][_0x86f5('0x29')],function(_0x54b8e6){return{'name':_0x54b8e6[_0x86f5('0x2a')],'type':_0x54b8e6[_0x86f5('0x2b')][_0x86f5('0x2c')]};});_0x4e8085['model']=_[_0x86f5('0x28')](_0x138e46,_0x86f5('0x25'));_0x4e8085[_0x86f5('0x2d')]=_['keys'](_0x3fc3c6[_0x86f5('0x2d')]);_0x4e8085[_0x86f5('0x2e')]=_[_0x86f5('0x2f')](_0x4e8085[_0x86f5('0x30')],_0x4e8085[_0x86f5('0x2d')]);_0x4ab0c[_0x86f5('0x31')]=_[_0x86f5('0x2f')](_0x4e8085[_0x86f5('0x30')],qs[_0x86f5('0x32')](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x32')]));_0x4ab0c[_0x86f5('0x31')]=_0x4ab0c[_0x86f5('0x31')][_0x86f5('0x33')]?_0x4ab0c[_0x86f5('0x31')]:_0x4e8085[_0x86f5('0x30')];if(!_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x34')]('nolimit')){_0x4ab0c['limit']=qs[_0x86f5('0x1d')](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x1d')]);_0x4ab0c[_0x86f5('0x1c')]=qs[_0x86f5('0x1c')](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x1c')]);}_0x4ab0c[_0x86f5('0x35')]=qs['sort'](_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x36')]);_0x4ab0c[_0x86f5('0x37')]=qs[_0x86f5('0x2e')](_[_0x86f5('0x38')](_0x3fc3c6[_0x86f5('0x2d')],_0x4e8085[_0x86f5('0x2e')]),_0x138e46);if(_0x3fc3c6[_0x86f5('0x2d')][_0x86f5('0x39')]){_0x4ab0c['where']=_[_0x86f5('0x3a')](_0x4ab0c['where'],{'$or':_[_0x86f5('0x28')](_0x138e46,function(_0x1b1ec9){if(_0x1b1ec9[_0x86f5('0x2b')]!==_0x86f5('0x3b')){var _0x13adde={};_0x13adde[_0x1b1ec9['name']]={'$like':'%'+_0x3fc3c6[_0x86f5('0x2d')]['filter']+'%'};return _0x13adde;}})});}_0x4ab0c=_[_0x86f5('0x3a')]({},_0x4ab0c,_0x3fc3c6[_0x86f5('0x3c')]);var _0x507842={'where':_0x4ab0c[_0x86f5('0x37')]};return db[_0x86f5('0x3d')][_0x86f5('0x1b')](_0x507842)[_0x86f5('0x23')](function(_0x5705c9){_0xb9686e['count']=_0x5705c9;if(_0x3fc3c6['query'][_0x86f5('0x3e')]){_0x4ab0c[_0x86f5('0x3f')]=[{'all':!![]}];}return db[_0x86f5('0x3d')][_0x86f5('0x40')](_0x4ab0c);})['then'](function(_0x41c001){_0xb9686e['rows']=_0x41c001;return _0xb9686e;})[_0x86f5('0x23')](respondWithFilteredResult(_0xca25d3,_0x4ab0c))['catch'](handleError(_0xca25d3,null));};exports['show']=function(_0x363d3a,_0x47b842){var _0x2db0c1={'raw':!![],'where':{'id':_0x363d3a[_0x86f5('0x41')]['id']}},_0x31bcda={};_0x31bcda[_0x86f5('0x30')]=_[_0x86f5('0x42')](db[_0x86f5('0x3d')][_0x86f5('0x29')]);_0x31bcda['query']=_[_0x86f5('0x42')](_0x363d3a[_0x86f5('0x2d')]);_0x31bcda[_0x86f5('0x2e')]=_[_0x86f5('0x2f')](_0x31bcda[_0x86f5('0x30')],_0x31bcda[_0x86f5('0x2d')]);_0x2db0c1[_0x86f5('0x31')]=_[_0x86f5('0x2f')](_0x31bcda[_0x86f5('0x30')],qs[_0x86f5('0x32')](_0x363d3a[_0x86f5('0x2d')][_0x86f5('0x32')]));_0x2db0c1[_0x86f5('0x31')]=_0x2db0c1['attributes']['length']?_0x2db0c1[_0x86f5('0x31')]:_0x31bcda[_0x86f5('0x30')];if(_0x363d3a['query'][_0x86f5('0x3e')]){_0x2db0c1[_0x86f5('0x3f')]=[{'all':!![]}];}_0x2db0c1=_[_0x86f5('0x3a')]({},_0x2db0c1,_0x363d3a[_0x86f5('0x3c')]);return db[_0x86f5('0x3d')][_0x86f5('0x43')](_0x2db0c1)['then'](handleEntityNotFound(_0x47b842,null))[_0x86f5('0x23')](respondWithResult(_0x47b842,null))[_0x86f5('0x44')](handleError(_0x47b842,null));};exports[_0x86f5('0x45')]=function(_0x20b958,_0x31a932){return db[_0x86f5('0x3d')][_0x86f5('0x45')](_0x20b958['body'],{})['then'](respondWithResult(_0x31a932,0xc9))[_0x86f5('0x44')](handleError(_0x31a932,null));};exports['update']=function(_0x380184,_0x34232e){if(_0x380184[_0x86f5('0x46')]['id']){delete _0x380184[_0x86f5('0x46')]['id'];}return db['VtigerField']['find']({'where':{'id':_0x380184[_0x86f5('0x41')]['id']}})[_0x86f5('0x23')](handleEntityNotFound(_0x34232e,null))[_0x86f5('0x23')](saveUpdates(_0x380184[_0x86f5('0x46')],null))['then'](respondWithResult(_0x34232e,null))[_0x86f5('0x44')](handleError(_0x34232e,null));};exports['destroy']=function(_0x3cc75a,_0x202e29){return db[_0x86f5('0x3d')]['find']({'where':{'id':_0x3cc75a['params']['id']}})[_0x86f5('0x23')](handleEntityNotFound(_0x202e29,null))['then'](removeEntity(_0x202e29,null))[_0x86f5('0x44')](handleError(_0x202e29,null));};
\ No newline at end of file
+var _0x77a4=['sendStatus','status','json','offset','limit','undefined','count','set','apply','save','then','end','error','name','send','index','map','VtigerField','rawAttributes','fieldName','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','rows','catch','show','params','find','create','body','update','destroy','eml-format','rimraf','zip-dir','moment','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb'];(function(_0x4fd7ba,_0x2f5e2e){var _0x484da9=function(_0x3e920d){while(--_0x3e920d){_0x4fd7ba['push'](_0x4fd7ba['shift']());}};_0x484da9(++_0x2f5e2e);}(_0x77a4,0x155));var _0x477a=function(_0x4d7379,_0x4b4e63){_0x4d7379=_0x4d7379-0x0;var _0x46d7cf=_0x77a4[_0x4d7379];return _0x46d7cf;};'use strict';var emlformat=require(_0x477a('0x0'));var rimraf=require(_0x477a('0x1'));var zipdir=require(_0x477a('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x477a('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x477a('0x4'));var path=require(_0x477a('0x5'));var sox=require('sox');var csv=require(_0x477a('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x477a('0x7'));var _=require(_0x477a('0x8'));var squel=require(_0x477a('0x9'));var crypto=require(_0x477a('0xa'));var jsforce=require(_0x477a('0xb'));var deskjs=require(_0x477a('0xc'));var toCsv=require(_0x477a('0x6'));var querystring=require(_0x477a('0xd'));var Papa=require('papaparse');var Redis=require(_0x477a('0xe'));var authService=require(_0x477a('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x477a('0x10'));var hardwareService=require(_0x477a('0x11'));var logger=require(_0x477a('0x12'))(_0x477a('0x13'));var utils=require(_0x477a('0x14'));var config=require(_0x477a('0x15'));var licenseUtil=require(_0x477a('0x16'));var db=require(_0x477a('0x17'))['db'];function respondWithStatusCode(_0x1d43da,_0x9f501c){_0x9f501c=_0x9f501c||0xcc;return function(_0x5eaa0c){if(_0x5eaa0c){return _0x1d43da[_0x477a('0x18')](_0x9f501c);}return _0x1d43da[_0x477a('0x19')](_0x9f501c)['end']();};}function respondWithResult(_0x55db6e,_0x2eac09){_0x2eac09=_0x2eac09||0xc8;return function(_0x1975fc){if(_0x1975fc){return _0x55db6e[_0x477a('0x19')](_0x2eac09)[_0x477a('0x1a')](_0x1975fc);}};}function respondWithFilteredResult(_0xb713e6,_0x203aa1){return function(_0x747289){if(_0x747289){var _0x213f7f=typeof _0x203aa1[_0x477a('0x1b')]==='undefined'&&typeof _0x203aa1[_0x477a('0x1c')]===_0x477a('0x1d');var _0x592182=_0x747289[_0x477a('0x1e')];var _0x49fe97=_0x213f7f?0x0:_0x203aa1['offset'];var _0x4de171=_0x213f7f?_0x747289[_0x477a('0x1e')]:_0x203aa1[_0x477a('0x1b')]+_0x203aa1[_0x477a('0x1c')];var _0xbd0525;if(_0x4de171>=_0x592182){_0x4de171=_0x592182;_0xbd0525=0xc8;}else{_0xbd0525=0xce;}_0xb713e6[_0x477a('0x19')](_0xbd0525);return _0xb713e6[_0x477a('0x1f')]('Content-Range',_0x49fe97+'-'+_0x4de171+'/'+_0x592182)[_0x477a('0x1a')](_0x747289);}return null;};}function patchUpdates(_0x29490c){return function(_0x152184){try{jsonpatch[_0x477a('0x20')](_0x152184,_0x29490c,!![]);}catch(_0x5487dc){return BPromise['reject'](_0x5487dc);}return _0x152184[_0x477a('0x21')]();};}function saveUpdates(_0x15c71c,_0x489d6b){return function(_0x2ec562){if(_0x2ec562){return _0x2ec562['update'](_0x15c71c)[_0x477a('0x22')](function(_0x5800c8){return _0x5800c8;});}return null;};}function removeEntity(_0x8de66f,_0x35765b){return function(_0x5c8d2d){if(_0x5c8d2d){return _0x5c8d2d['destroy']()[_0x477a('0x22')](function(){_0x8de66f['status'](0xcc)[_0x477a('0x23')]();});}};}function handleEntityNotFound(_0x221195,_0x17a8f8){return function(_0x4176ba){if(!_0x4176ba){_0x221195[_0x477a('0x18')](0x194);}return _0x4176ba;};}function handleError(_0x26fe40,_0x6e9655){_0x6e9655=_0x6e9655||0x1f4;return function(_0x33e441){logger[_0x477a('0x24')](_0x33e441['stack']);if(_0x33e441[_0x477a('0x25')]){delete _0x33e441[_0x477a('0x25')];}_0x26fe40[_0x477a('0x19')](_0x6e9655)[_0x477a('0x26')](_0x33e441);};}exports[_0x477a('0x27')]=function(_0x4c0749,_0x4b192e){var _0xd04f72={},_0x1ec3c1={},_0x2d2940={'count':0x0,'rows':[]};var _0x477c3c=_[_0x477a('0x28')](db[_0x477a('0x29')][_0x477a('0x2a')],function(_0x1a72de){return{'name':_0x1a72de[_0x477a('0x2b')],'type':_0x1a72de['type'][_0x477a('0x2c')]};});_0x1ec3c1[_0x477a('0x2d')]=_[_0x477a('0x28')](_0x477c3c,'name');_0x1ec3c1[_0x477a('0x2e')]=_[_0x477a('0x2f')](_0x4c0749[_0x477a('0x2e')]);_0x1ec3c1[_0x477a('0x30')]=_[_0x477a('0x31')](_0x1ec3c1[_0x477a('0x2d')],_0x1ec3c1[_0x477a('0x2e')]);_0xd04f72['attributes']=_[_0x477a('0x31')](_0x1ec3c1[_0x477a('0x2d')],qs[_0x477a('0x32')](_0x4c0749[_0x477a('0x2e')][_0x477a('0x32')]));_0xd04f72[_0x477a('0x33')]=_0xd04f72['attributes'][_0x477a('0x34')]?_0xd04f72[_0x477a('0x33')]:_0x1ec3c1[_0x477a('0x2d')];if(!_0x4c0749[_0x477a('0x2e')][_0x477a('0x35')](_0x477a('0x36'))){_0xd04f72[_0x477a('0x1c')]=qs[_0x477a('0x1c')](_0x4c0749[_0x477a('0x2e')][_0x477a('0x1c')]);_0xd04f72[_0x477a('0x1b')]=qs[_0x477a('0x1b')](_0x4c0749[_0x477a('0x2e')]['offset']);}_0xd04f72[_0x477a('0x37')]=qs['sort'](_0x4c0749[_0x477a('0x2e')][_0x477a('0x38')]);_0xd04f72[_0x477a('0x39')]=qs['filters'](_['pick'](_0x4c0749['query'],_0x1ec3c1[_0x477a('0x30')]),_0x477c3c);if(_0x4c0749[_0x477a('0x2e')][_0x477a('0x3a')]){_0xd04f72[_0x477a('0x39')]=_[_0x477a('0x3b')](_0xd04f72[_0x477a('0x39')],{'$or':_[_0x477a('0x28')](_0x477c3c,function(_0x1e0e83){if(_0x1e0e83['type']!==_0x477a('0x3c')){var _0x4b637c={};_0x4b637c[_0x1e0e83[_0x477a('0x25')]]={'$like':'%'+_0x4c0749[_0x477a('0x2e')]['filter']+'%'};return _0x4b637c;}})});}_0xd04f72=_['merge']({},_0xd04f72,_0x4c0749[_0x477a('0x3d')]);var _0x28b2f9={'where':_0xd04f72[_0x477a('0x39')]};return db['VtigerField'][_0x477a('0x1e')](_0x28b2f9)[_0x477a('0x22')](function(_0x13f121){_0x2d2940[_0x477a('0x1e')]=_0x13f121;if(_0x4c0749['query'][_0x477a('0x3e')]){_0xd04f72[_0x477a('0x3f')]=[{'all':!![]}];}return db['VtigerField']['findAll'](_0xd04f72);})[_0x477a('0x22')](function(_0x2cbb16){_0x2d2940[_0x477a('0x40')]=_0x2cbb16;return _0x2d2940;})['then'](respondWithFilteredResult(_0x4b192e,_0xd04f72))[_0x477a('0x41')](handleError(_0x4b192e,null));};exports[_0x477a('0x42')]=function(_0x342d06,_0x34b42c){var _0x4247e3={'raw':!![],'where':{'id':_0x342d06[_0x477a('0x43')]['id']}},_0x4c67e4={};_0x4c67e4[_0x477a('0x2d')]=_[_0x477a('0x2f')](db[_0x477a('0x29')][_0x477a('0x2a')]);_0x4c67e4['query']=_['keys'](_0x342d06[_0x477a('0x2e')]);_0x4c67e4[_0x477a('0x30')]=_[_0x477a('0x31')](_0x4c67e4['model'],_0x4c67e4[_0x477a('0x2e')]);_0x4247e3[_0x477a('0x33')]=_[_0x477a('0x31')](_0x4c67e4['model'],qs[_0x477a('0x32')](_0x342d06[_0x477a('0x2e')][_0x477a('0x32')]));_0x4247e3['attributes']=_0x4247e3['attributes'][_0x477a('0x34')]?_0x4247e3[_0x477a('0x33')]:_0x4c67e4[_0x477a('0x2d')];if(_0x342d06['query']['includeAll']){_0x4247e3['include']=[{'all':!![]}];}_0x4247e3=_['merge']({},_0x4247e3,_0x342d06[_0x477a('0x3d')]);return db['VtigerField'][_0x477a('0x44')](_0x4247e3)[_0x477a('0x22')](handleEntityNotFound(_0x34b42c,null))[_0x477a('0x22')](respondWithResult(_0x34b42c,null))[_0x477a('0x41')](handleError(_0x34b42c,null));};exports['create']=function(_0x2745b9,_0x42c687){return db[_0x477a('0x29')][_0x477a('0x45')](_0x2745b9[_0x477a('0x46')],{})[_0x477a('0x22')](respondWithResult(_0x42c687,0xc9))[_0x477a('0x41')](handleError(_0x42c687,null));};exports[_0x477a('0x47')]=function(_0x5aa721,_0x35213d){if(_0x5aa721[_0x477a('0x46')]['id']){delete _0x5aa721[_0x477a('0x46')]['id'];}return db['VtigerField'][_0x477a('0x44')]({'where':{'id':_0x5aa721[_0x477a('0x43')]['id']}})[_0x477a('0x22')](handleEntityNotFound(_0x35213d,null))[_0x477a('0x22')](saveUpdates(_0x5aa721[_0x477a('0x46')],null))[_0x477a('0x22')](respondWithResult(_0x35213d,null))[_0x477a('0x41')](handleError(_0x35213d,null));};exports[_0x477a('0x48')]=function(_0x3b8022,_0x187da4){return db[_0x477a('0x29')][_0x477a('0x44')]({'where':{'id':_0x3b8022[_0x477a('0x43')]['id']}})[_0x477a('0x22')](handleEntityNotFound(_0x187da4,null))[_0x477a('0x22')](removeEntity(_0x187da4,null))[_0x477a('0x41')](handleError(_0x187da4,null));};
\ No newline at end of file