Built motion from commit a679711e.|2.6.15
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index f31bfba..9645a0d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3822=['then','error','stack','name','index','map','VtigerField','fieldName','model','keys','query','intersection','fields','length','attributes','hasOwnProperty','order','sort','filters','pick','filter','where','merge','type','VIRTUAL','options','rows','show','includeAll','find','catch','create','body','update','params','html-pdf','eml-format','rimraf','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','desk.js','papaparse','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','destroy'];(function(_0x426904,_0xf45a16){var _0x1a7def=function(_0x1e5f76){while(--_0x1e5f76){_0x426904['push'](_0x426904['shift']());}};_0x1a7def(++_0xf45a16);}(_0x3822,0x65));var _0x2382=function(_0x20a558,_0x160e0e){_0x20a558=_0x20a558-0x0;var _0x53d3f7=_0x3822[_0x20a558];return _0x53d3f7;};'use strict';var pdf=require(_0x2382('0x0'));var emlformat=require(_0x2382('0x1'));var rimraf=require(_0x2382('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x2382('0x3'));var BPromise=require(_0x2382('0x4'));var Mustache=require(_0x2382('0x5'));var util=require(_0x2382('0x6'));var path=require('path');var sox=require(_0x2382('0x7'));var csv=require(_0x2382('0x8'));var ejs=require(_0x2382('0x9'));var fs=require('fs');var _=require(_0x2382('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x2382('0xb'));var toCsv=require(_0x2382('0x8'));var querystring=require('querystring');var Papa=require(_0x2382('0xc'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x2382('0xd'));var hardwareService=require(_0x2382('0xe'));var logger=require(_0x2382('0xf'))('api');var utils=require(_0x2382('0x10'));var config=require(_0x2382('0x11'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x45d3f9,_0x1e129a){_0x1e129a=_0x1e129a||0xcc;return function(_0x5d3847){if(_0x5d3847){return _0x45d3f9[_0x2382('0x12')](_0x1e129a);}return _0x45d3f9[_0x2382('0x13')](_0x1e129a)[_0x2382('0x14')]();};}function respondWithResult(_0x18c79a,_0x55088e){_0x55088e=_0x55088e||0xc8;return function(_0x26fb0d){if(_0x26fb0d){return _0x18c79a[_0x2382('0x13')](_0x55088e)[_0x2382('0x15')](_0x26fb0d);}};}function respondWithFilteredResult(_0x5f31e4,_0x5b9190){return function(_0x2a3bcc){if(_0x2a3bcc){var _0x247845=_0x2a3bcc[_0x2382('0x16')],_0x884891=_0x5b9190[_0x2382('0x17')],_0x525fa2=_0x5b9190[_0x2382('0x17')]+_0x5b9190[_0x2382('0x18')],_0xe49e06;if(_0x525fa2>=_0x247845){_0x525fa2=_0x247845;_0xe49e06=0xc8;}else{_0xe49e06=0xce;}_0x5f31e4[_0x2382('0x13')](_0xe49e06);return _0x5f31e4[_0x2382('0x19')](_0x2382('0x1a'),_0x884891+'-'+_0x525fa2+'/'+_0x247845)[_0x2382('0x15')](_0x2a3bcc);}return null;};}function patchUpdates(_0x555aed){return function(_0x1be93e){try{jsonpatch[_0x2382('0x1b')](_0x1be93e,_0x555aed,!![]);}catch(_0x24a129){return BPromise[_0x2382('0x1c')](_0x24a129);}return _0x1be93e[_0x2382('0x1d')]();};}function saveUpdates(_0x59b0d3,_0x58b7af){return function(_0x1be473){if(_0x1be473){return _0x1be473['update'](_0x59b0d3)['then'](function(_0x3e5fc1){return _0x3e5fc1;});}return null;};}function removeEntity(_0x81feb6,_0x459616){return function(_0x1548c2){if(_0x1548c2){return _0x1548c2[_0x2382('0x1e')]()[_0x2382('0x1f')](function(){_0x81feb6[_0x2382('0x13')](0xcc)[_0x2382('0x14')]();});}};}function handleEntityNotFound(_0x17f387,_0x5c20a0){return function(_0x3fd63a){if(!_0x3fd63a){_0x17f387['sendStatus'](0x194);}return _0x3fd63a;};}function handleError(_0xa8e1a6,_0x59110f){_0x59110f=_0x59110f||0x1f4;return function(_0x52e0ea){logger[_0x2382('0x20')](_0x52e0ea[_0x2382('0x21')]);if(_0x52e0ea['name']){delete _0x52e0ea[_0x2382('0x22')];}_0xa8e1a6[_0x2382('0x13')](_0x59110f)['send'](_0x52e0ea);};}exports[_0x2382('0x23')]=function(_0x2c4053,_0x5bcd9b){var _0x413b5f={},_0x419407={},_0x238022={'count':0x0,'rows':[]};var _0x173835=_[_0x2382('0x24')](db[_0x2382('0x25')]['rawAttributes'],function(_0x1f2750){return{'name':_0x1f2750[_0x2382('0x26')],'type':_0x1f2750['type']['key']};});_0x419407[_0x2382('0x27')]=_[_0x2382('0x24')](_0x173835,'name');_0x419407['query']=_[_0x2382('0x28')](_0x2c4053[_0x2382('0x29')]);_0x419407['filters']=_[_0x2382('0x2a')](_0x419407[_0x2382('0x27')],_0x419407['query']);_0x413b5f['attributes']=_[_0x2382('0x2a')](_0x419407[_0x2382('0x27')],qs[_0x2382('0x2b')](_0x2c4053[_0x2382('0x29')][_0x2382('0x2b')]));_0x413b5f['attributes']=_0x413b5f['attributes'][_0x2382('0x2c')]?_0x413b5f[_0x2382('0x2d')]:_0x419407['model'];if(!_0x2c4053[_0x2382('0x29')][_0x2382('0x2e')]('nolimit')){_0x413b5f[_0x2382('0x18')]=qs['limit'](_0x2c4053[_0x2382('0x29')][_0x2382('0x18')]);_0x413b5f[_0x2382('0x17')]=qs['offset'](_0x2c4053[_0x2382('0x29')][_0x2382('0x17')]);}_0x413b5f[_0x2382('0x2f')]=qs[_0x2382('0x30')](_0x2c4053['query']['sort']);_0x413b5f['where']=qs[_0x2382('0x31')](_[_0x2382('0x32')](_0x2c4053[_0x2382('0x29')],_0x419407[_0x2382('0x31')]),_0x173835);if(_0x2c4053[_0x2382('0x29')][_0x2382('0x33')]){_0x413b5f[_0x2382('0x34')]=_[_0x2382('0x35')](_0x413b5f[_0x2382('0x34')],{'$or':_['map'](_0x173835,function(_0x22ac4b){if(_0x22ac4b[_0x2382('0x36')]!==_0x2382('0x37')){var _0x4cef2f={};_0x4cef2f[_0x22ac4b['name']]={'$like':'%'+_0x2c4053[_0x2382('0x29')][_0x2382('0x33')]+'%'};return _0x4cef2f;}})});}_0x413b5f=_[_0x2382('0x35')]({},_0x413b5f,_0x2c4053[_0x2382('0x38')]);var _0x52a7cc={'where':_0x413b5f['where']};return db[_0x2382('0x25')]['count'](_0x52a7cc)[_0x2382('0x1f')](function(_0x3d9544){_0x238022[_0x2382('0x16')]=_0x3d9544;if(_0x2c4053['query']['includeAll']){_0x413b5f['include']=[{'all':!![]}];}return db[_0x2382('0x25')]['findAll'](_0x413b5f);})[_0x2382('0x1f')](function(_0x1b9bbb){_0x238022[_0x2382('0x39')]=_0x1b9bbb;return _0x238022;})['then'](respondWithFilteredResult(_0x5bcd9b,_0x413b5f))['catch'](handleError(_0x5bcd9b,null));};exports[_0x2382('0x3a')]=function(_0x69bbbc,_0x35710e){var _0x66faaa={'raw':!![],'where':{'id':_0x69bbbc['params']['id']}},_0x580f77={};_0x580f77[_0x2382('0x27')]=_[_0x2382('0x28')](db[_0x2382('0x25')]['rawAttributes']);_0x580f77['query']=_[_0x2382('0x28')](_0x69bbbc['query']);_0x580f77[_0x2382('0x31')]=_[_0x2382('0x2a')](_0x580f77['model'],_0x580f77[_0x2382('0x29')]);_0x66faaa[_0x2382('0x2d')]=_[_0x2382('0x2a')](_0x580f77[_0x2382('0x27')],qs[_0x2382('0x2b')](_0x69bbbc[_0x2382('0x29')][_0x2382('0x2b')]));_0x66faaa[_0x2382('0x2d')]=_0x66faaa[_0x2382('0x2d')][_0x2382('0x2c')]?_0x66faaa[_0x2382('0x2d')]:_0x580f77[_0x2382('0x27')];if(_0x69bbbc[_0x2382('0x29')][_0x2382('0x3b')]){_0x66faaa['include']=[{'all':!![]}];}_0x66faaa=_[_0x2382('0x35')]({},_0x66faaa,_0x69bbbc[_0x2382('0x38')]);return db[_0x2382('0x25')][_0x2382('0x3c')](_0x66faaa)[_0x2382('0x1f')](handleEntityNotFound(_0x35710e,null))[_0x2382('0x1f')](respondWithResult(_0x35710e,null))[_0x2382('0x3d')](handleError(_0x35710e,null));};exports[_0x2382('0x3e')]=function(_0x466c13,_0x3c3f15){return db[_0x2382('0x25')][_0x2382('0x3e')](_0x466c13[_0x2382('0x3f')],{})[_0x2382('0x1f')](respondWithResult(_0x3c3f15,0xc9))[_0x2382('0x3d')](handleError(_0x3c3f15,null));};exports[_0x2382('0x40')]=function(_0x2815ea,_0x424f9d){if(_0x2815ea[_0x2382('0x3f')]['id']){delete _0x2815ea['body']['id'];}return db['VtigerField'][_0x2382('0x3c')]({'where':{'id':_0x2815ea[_0x2382('0x41')]['id']}})[_0x2382('0x1f')](handleEntityNotFound(_0x424f9d,null))[_0x2382('0x1f')](saveUpdates(_0x2815ea['body'],null))['then'](respondWithResult(_0x424f9d,null))[_0x2382('0x3d')](handleError(_0x424f9d,null));};exports['destroy']=function(_0x275c9f,_0x40d4b0){return db[_0x2382('0x25')][_0x2382('0x3c')]({'where':{'id':_0x275c9f[_0x2382('0x41')]['id']}})[_0x2382('0x1f')](handleEntityNotFound(_0x40d4b0,null))[_0x2382('0x1f')](removeEntity(_0x40d4b0,null))[_0x2382('0x3d')](handleError(_0x40d4b0,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