Built motion from commit 936e8062.|2.5.33
[motion2.git] / server / api / intVtigerField / intVtigerField.controller.js
index 7dc3244..7912df6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa89d=['show','find','catch','create','body','params','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','limit','undefined','count','Content-Range','apply','reject','save','update','destroy','then','error','stack','name','send','index','VtigerField','fieldName','type','key','model','map','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','options','includeAll','include','rows'];(function(_0x34df53,_0x583165){var _0x540088=function(_0x1aba16){while(--_0x1aba16){_0x34df53['push'](_0x34df53['shift']());}};_0x540088(++_0x583165);}(_0xa89d,0xe7));var _0xda89=function(_0x3bff6d,_0x474ee3){_0x3bff6d=_0x3bff6d-0x0;var _0x4266fd=_0xa89d[_0x3bff6d];return _0x4266fd;};'use strict';var emlformat=require(_0xda89('0x0'));var rimraf=require(_0xda89('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xda89('0x2'));var rp=require('request-promise');var moment=require(_0xda89('0x3'));var BPromise=require(_0xda89('0x4'));var Mustache=require(_0xda89('0x5'));var util=require(_0xda89('0x6'));var path=require(_0xda89('0x7'));var sox=require('sox');var csv=require(_0xda89('0x8'));var ejs=require(_0xda89('0x9'));var fs=require('fs');var fs_extra=require(_0xda89('0xa'));var _=require(_0xda89('0xb'));var squel=require('squel');var crypto=require(_0xda89('0xc'));var jsforce=require(_0xda89('0xd'));var deskjs=require(_0xda89('0xe'));var toCsv=require(_0xda89('0x8'));var querystring=require(_0xda89('0xf'));var Papa=require(_0xda89('0x10'));var Redis=require(_0xda89('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xda89('0x12'));var as=require(_0xda89('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xda89('0x14'))('api');var utils=require(_0xda89('0x15'));var config=require(_0xda89('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xda89('0x17'))['db'];function respondWithStatusCode(_0x4c758d,_0x4e108e){_0x4e108e=_0x4e108e||0xcc;return function(_0x174533){if(_0x174533){return _0x4c758d[_0xda89('0x18')](_0x4e108e);}return _0x4c758d[_0xda89('0x19')](_0x4e108e)[_0xda89('0x1a')]();};}function respondWithResult(_0x612427,_0x3c3f22){_0x3c3f22=_0x3c3f22||0xc8;return function(_0x269907){if(_0x269907){return _0x612427[_0xda89('0x19')](_0x3c3f22)[_0xda89('0x1b')](_0x269907);}};}function respondWithFilteredResult(_0x17924f,_0x17ca19){return function(_0x43ea3f){if(_0x43ea3f){var _0x479efc=typeof _0x17ca19[_0xda89('0x1c')]==='undefined'&&typeof _0x17ca19[_0xda89('0x1d')]===_0xda89('0x1e');var _0x500296=_0x43ea3f[_0xda89('0x1f')];var _0xbb5e33=_0x479efc?0x0:_0x17ca19[_0xda89('0x1c')];var _0x12aab1=_0x479efc?_0x43ea3f[_0xda89('0x1f')]:_0x17ca19[_0xda89('0x1c')]+_0x17ca19['limit'];var _0x5226f1;if(_0x12aab1>=_0x500296){_0x12aab1=_0x500296;_0x5226f1=0xc8;}else{_0x5226f1=0xce;}_0x17924f[_0xda89('0x19')](_0x5226f1);return _0x17924f['set'](_0xda89('0x20'),_0xbb5e33+'-'+_0x12aab1+'/'+_0x500296)[_0xda89('0x1b')](_0x43ea3f);}return null;};}function patchUpdates(_0x2b4dd9){return function(_0x56e6c7){try{jsonpatch[_0xda89('0x21')](_0x56e6c7,_0x2b4dd9,!![]);}catch(_0x4b6ed1){return BPromise[_0xda89('0x22')](_0x4b6ed1);}return _0x56e6c7[_0xda89('0x23')]();};}function saveUpdates(_0x2f91a8,_0xc6e038){return function(_0x5a20d0){if(_0x5a20d0){return _0x5a20d0[_0xda89('0x24')](_0x2f91a8)['then'](function(_0x24bac2){return _0x24bac2;});}return null;};}function removeEntity(_0x50ce82,_0x5e67bd){return function(_0x7eb065){if(_0x7eb065){return _0x7eb065[_0xda89('0x25')]()[_0xda89('0x26')](function(){_0x50ce82[_0xda89('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x17d9ff,_0x5f3c0f){return function(_0x48a54d){if(!_0x48a54d){_0x17d9ff[_0xda89('0x18')](0x194);}return _0x48a54d;};}function handleError(_0x3cff36,_0x51c5ad){_0x51c5ad=_0x51c5ad||0x1f4;return function(_0x7b573b){logger[_0xda89('0x27')](_0x7b573b[_0xda89('0x28')]);if(_0x7b573b['name']){delete _0x7b573b[_0xda89('0x29')];}_0x3cff36[_0xda89('0x19')](_0x51c5ad)[_0xda89('0x2a')](_0x7b573b);};}exports[_0xda89('0x2b')]=function(_0x4fb31e,_0x2edd5c){var _0x23a84c={},_0x2d2a03={},_0xeec155={'count':0x0,'rows':[]};var _0x32fab2=_['map'](db[_0xda89('0x2c')]['rawAttributes'],function(_0x2997e6){return{'name':_0x2997e6[_0xda89('0x2d')],'type':_0x2997e6[_0xda89('0x2e')][_0xda89('0x2f')]};});_0x2d2a03[_0xda89('0x30')]=_[_0xda89('0x31')](_0x32fab2,_0xda89('0x29'));_0x2d2a03[_0xda89('0x32')]=_[_0xda89('0x33')](_0x4fb31e[_0xda89('0x32')]);_0x2d2a03['filters']=_[_0xda89('0x34')](_0x2d2a03[_0xda89('0x30')],_0x2d2a03['query']);_0x23a84c[_0xda89('0x35')]=_[_0xda89('0x34')](_0x2d2a03[_0xda89('0x30')],qs['fields'](_0x4fb31e[_0xda89('0x32')][_0xda89('0x36')]));_0x23a84c[_0xda89('0x35')]=_0x23a84c['attributes'][_0xda89('0x37')]?_0x23a84c[_0xda89('0x35')]:_0x2d2a03[_0xda89('0x30')];if(!_0x4fb31e[_0xda89('0x32')][_0xda89('0x38')](_0xda89('0x39'))){_0x23a84c[_0xda89('0x1d')]=qs['limit'](_0x4fb31e[_0xda89('0x32')][_0xda89('0x1d')]);_0x23a84c[_0xda89('0x1c')]=qs[_0xda89('0x1c')](_0x4fb31e[_0xda89('0x32')][_0xda89('0x1c')]);}_0x23a84c[_0xda89('0x3a')]=qs[_0xda89('0x3b')](_0x4fb31e[_0xda89('0x32')]['sort']);_0x23a84c[_0xda89('0x3c')]=qs['filters'](_[_0xda89('0x3d')](_0x4fb31e[_0xda89('0x32')],_0x2d2a03[_0xda89('0x3e')]),_0x32fab2);if(_0x4fb31e['query'][_0xda89('0x3f')]){_0x23a84c[_0xda89('0x3c')]=_[_0xda89('0x40')](_0x23a84c[_0xda89('0x3c')],{'$or':_['map'](_0x32fab2,function(_0x58572e){if(_0x58572e[_0xda89('0x2e')]!=='VIRTUAL'){var _0x533b25={};_0x533b25[_0x58572e[_0xda89('0x29')]]={'$like':'%'+_0x4fb31e[_0xda89('0x32')][_0xda89('0x3f')]+'%'};return _0x533b25;}})});}_0x23a84c=_[_0xda89('0x40')]({},_0x23a84c,_0x4fb31e[_0xda89('0x41')]);var _0x5d68c0={'where':_0x23a84c[_0xda89('0x3c')]};return db[_0xda89('0x2c')][_0xda89('0x1f')](_0x5d68c0)[_0xda89('0x26')](function(_0x1291f3){_0xeec155[_0xda89('0x1f')]=_0x1291f3;if(_0x4fb31e[_0xda89('0x32')][_0xda89('0x42')]){_0x23a84c[_0xda89('0x43')]=[{'all':!![]}];}return db['VtigerField']['findAll'](_0x23a84c);})[_0xda89('0x26')](function(_0x4df236){_0xeec155[_0xda89('0x44')]=_0x4df236;return _0xeec155;})[_0xda89('0x26')](respondWithFilteredResult(_0x2edd5c,_0x23a84c))['catch'](handleError(_0x2edd5c,null));};exports[_0xda89('0x45')]=function(_0x414bb4,_0x560b9d){var _0x2924f8={'raw':!![],'where':{'id':_0x414bb4['params']['id']}},_0x254a35={};_0x254a35[_0xda89('0x30')]=_[_0xda89('0x33')](db['VtigerField']['rawAttributes']);_0x254a35[_0xda89('0x32')]=_['keys'](_0x414bb4[_0xda89('0x32')]);_0x254a35[_0xda89('0x3e')]=_['intersection'](_0x254a35[_0xda89('0x30')],_0x254a35[_0xda89('0x32')]);_0x2924f8[_0xda89('0x35')]=_[_0xda89('0x34')](_0x254a35[_0xda89('0x30')],qs[_0xda89('0x36')](_0x414bb4[_0xda89('0x32')][_0xda89('0x36')]));_0x2924f8['attributes']=_0x2924f8[_0xda89('0x35')][_0xda89('0x37')]?_0x2924f8['attributes']:_0x254a35[_0xda89('0x30')];if(_0x414bb4[_0xda89('0x32')][_0xda89('0x42')]){_0x2924f8[_0xda89('0x43')]=[{'all':!![]}];}_0x2924f8=_[_0xda89('0x40')]({},_0x2924f8,_0x414bb4['options']);return db[_0xda89('0x2c')][_0xda89('0x46')](_0x2924f8)[_0xda89('0x26')](handleEntityNotFound(_0x560b9d,null))['then'](respondWithResult(_0x560b9d,null))[_0xda89('0x47')](handleError(_0x560b9d,null));};exports['create']=function(_0x406d99,_0x280ea9){return db[_0xda89('0x2c')][_0xda89('0x48')](_0x406d99[_0xda89('0x49')],{})[_0xda89('0x26')](respondWithResult(_0x280ea9,0xc9))[_0xda89('0x47')](handleError(_0x280ea9,null));};exports[_0xda89('0x24')]=function(_0x1d0c52,_0x122876){if(_0x1d0c52[_0xda89('0x49')]['id']){delete _0x1d0c52[_0xda89('0x49')]['id'];}return db[_0xda89('0x2c')][_0xda89('0x46')]({'where':{'id':_0x1d0c52['params']['id']}})['then'](handleEntityNotFound(_0x122876,null))[_0xda89('0x26')](saveUpdates(_0x1d0c52[_0xda89('0x49')],null))[_0xda89('0x26')](respondWithResult(_0x122876,null))[_0xda89('0x47')](handleError(_0x122876,null));};exports[_0xda89('0x25')]=function(_0x5d1cd9,_0x37e8e0){return db['VtigerField']['find']({'where':{'id':_0x5d1cd9[_0xda89('0x4a')]['id']}})[_0xda89('0x26')](handleEntityNotFound(_0x37e8e0,null))['then'](removeEntity(_0x37e8e0,null))[_0xda89('0x47')](handleError(_0x37e8e0,null));};
\ No newline at end of file
+var _0xe835=['mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','end','status','offset','undefined','limit','count','set','Content-Range','json','reject','save','update','then','destroy','error','stack','name','VtigerField','rawAttributes','fieldName','type','map','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','order','sort','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','find','create','body','params','rimraf','zip-dir','request-promise','moment','bluebird'];(function(_0x5cab7b,_0x4976c9){var _0x20b650=function(_0x43d6fc){while(--_0x43d6fc){_0x5cab7b['push'](_0x5cab7b['shift']());}};_0x20b650(++_0x4976c9);}(_0xe835,0x1b1));var _0x5e83=function(_0x149ca0,_0x2ac7f5){_0x149ca0=_0x149ca0-0x0;var _0x56b6b9=_0xe835[_0x149ca0];return _0x56b6b9;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5e83('0x0'));var zipdir=require(_0x5e83('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5e83('0x2'));var moment=require(_0x5e83('0x3'));var BPromise=require(_0x5e83('0x4'));var Mustache=require(_0x5e83('0x5'));var util=require(_0x5e83('0x6'));var path=require(_0x5e83('0x7'));var sox=require('sox');var csv=require(_0x5e83('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x5e83('0x9'));var _=require(_0x5e83('0xa'));var squel=require(_0x5e83('0xb'));var crypto=require(_0x5e83('0xc'));var jsforce=require(_0x5e83('0xd'));var deskjs=require(_0x5e83('0xe'));var toCsv=require('to-csv');var querystring=require(_0x5e83('0xf'));var Papa=require(_0x5e83('0x10'));var Redis=require(_0x5e83('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x5e83('0x12'));var as=require(_0x5e83('0x13'));var hardwareService=require(_0x5e83('0x14'));var logger=require(_0x5e83('0x15'))(_0x5e83('0x16'));var utils=require(_0x5e83('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0x5e83('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xd0102d,_0x189f27){_0x189f27=_0x189f27||0xcc;return function(_0x2f3d7b){if(_0x2f3d7b){return _0xd0102d[_0x5e83('0x19')](_0x189f27);}return _0xd0102d['status'](_0x189f27)[_0x5e83('0x1a')]();};}function respondWithResult(_0x5c802e,_0x1a5717){_0x1a5717=_0x1a5717||0xc8;return function(_0x250ad4){if(_0x250ad4){return _0x5c802e[_0x5e83('0x1b')](_0x1a5717)['json'](_0x250ad4);}};}function respondWithFilteredResult(_0x1d8d13,_0x5b8268){return function(_0x296a63){if(_0x296a63){var _0x16d091=typeof _0x5b8268[_0x5e83('0x1c')]===_0x5e83('0x1d')&&typeof _0x5b8268[_0x5e83('0x1e')]===_0x5e83('0x1d');var _0x570623=_0x296a63[_0x5e83('0x1f')];var _0x89b673=_0x16d091?0x0:_0x5b8268[_0x5e83('0x1c')];var _0x43a061=_0x16d091?_0x296a63[_0x5e83('0x1f')]:_0x5b8268[_0x5e83('0x1c')]+_0x5b8268[_0x5e83('0x1e')];var _0x47e10e;if(_0x43a061>=_0x570623){_0x43a061=_0x570623;_0x47e10e=0xc8;}else{_0x47e10e=0xce;}_0x1d8d13[_0x5e83('0x1b')](_0x47e10e);return _0x1d8d13[_0x5e83('0x20')](_0x5e83('0x21'),_0x89b673+'-'+_0x43a061+'/'+_0x570623)[_0x5e83('0x22')](_0x296a63);}return null;};}function patchUpdates(_0x4c3780){return function(_0x203c8f){try{jsonpatch['apply'](_0x203c8f,_0x4c3780,!![]);}catch(_0x27b54d){return BPromise[_0x5e83('0x23')](_0x27b54d);}return _0x203c8f[_0x5e83('0x24')]();};}function saveUpdates(_0x1d2139,_0x3e917d){return function(_0x26d9c2){if(_0x26d9c2){return _0x26d9c2[_0x5e83('0x25')](_0x1d2139)[_0x5e83('0x26')](function(_0x186928){return _0x186928;});}return null;};}function removeEntity(_0x58a284,_0x2315e0){return function(_0x3e970b){if(_0x3e970b){return _0x3e970b[_0x5e83('0x27')]()['then'](function(){_0x58a284[_0x5e83('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x49ac08,_0x1868ee){return function(_0x5119a5){if(!_0x5119a5){_0x49ac08['sendStatus'](0x194);}return _0x5119a5;};}function handleError(_0x2b4b98,_0x3329dd){_0x3329dd=_0x3329dd||0x1f4;return function(_0x45fdbe){logger[_0x5e83('0x28')](_0x45fdbe[_0x5e83('0x29')]);if(_0x45fdbe[_0x5e83('0x2a')]){delete _0x45fdbe[_0x5e83('0x2a')];}_0x2b4b98[_0x5e83('0x1b')](_0x3329dd)['send'](_0x45fdbe);};}exports['index']=function(_0x2d50bc,_0x4e1662){var _0x3eb500={},_0x1c7b46={},_0x27fe8b={'count':0x0,'rows':[]};var _0x59d81b=_['map'](db[_0x5e83('0x2b')][_0x5e83('0x2c')],function(_0x3ee510){return{'name':_0x3ee510[_0x5e83('0x2d')],'type':_0x3ee510[_0x5e83('0x2e')]['key']};});_0x1c7b46['model']=_[_0x5e83('0x2f')](_0x59d81b,_0x5e83('0x2a'));_0x1c7b46['query']=_[_0x5e83('0x30')](_0x2d50bc[_0x5e83('0x31')]);_0x1c7b46[_0x5e83('0x32')]=_[_0x5e83('0x33')](_0x1c7b46[_0x5e83('0x34')],_0x1c7b46[_0x5e83('0x31')]);_0x3eb500[_0x5e83('0x35')]=_[_0x5e83('0x33')](_0x1c7b46['model'],qs[_0x5e83('0x36')](_0x2d50bc['query'][_0x5e83('0x36')]));_0x3eb500[_0x5e83('0x35')]=_0x3eb500[_0x5e83('0x35')][_0x5e83('0x37')]?_0x3eb500[_0x5e83('0x35')]:_0x1c7b46['model'];if(!_0x2d50bc[_0x5e83('0x31')][_0x5e83('0x38')]('nolimit')){_0x3eb500[_0x5e83('0x1e')]=qs[_0x5e83('0x1e')](_0x2d50bc['query'][_0x5e83('0x1e')]);_0x3eb500[_0x5e83('0x1c')]=qs[_0x5e83('0x1c')](_0x2d50bc['query']['offset']);}_0x3eb500[_0x5e83('0x39')]=qs[_0x5e83('0x3a')](_0x2d50bc[_0x5e83('0x31')][_0x5e83('0x3a')]);_0x3eb500['where']=qs[_0x5e83('0x32')](_[_0x5e83('0x3b')](_0x2d50bc[_0x5e83('0x31')],_0x1c7b46[_0x5e83('0x32')]),_0x59d81b);if(_0x2d50bc[_0x5e83('0x31')][_0x5e83('0x3c')]){_0x3eb500['where']=_[_0x5e83('0x3d')](_0x3eb500['where'],{'$or':_[_0x5e83('0x2f')](_0x59d81b,function(_0x2f8489){if(_0x2f8489['type']!==_0x5e83('0x3e')){var _0x35c76d={};_0x35c76d[_0x2f8489['name']]={'$like':'%'+_0x2d50bc['query'][_0x5e83('0x3c')]+'%'};return _0x35c76d;}})});}_0x3eb500=_['merge']({},_0x3eb500,_0x2d50bc[_0x5e83('0x3f')]);var _0x5ee183={'where':_0x3eb500['where']};return db['VtigerField'][_0x5e83('0x1f')](_0x5ee183)[_0x5e83('0x26')](function(_0x36abc5){_0x27fe8b[_0x5e83('0x1f')]=_0x36abc5;if(_0x2d50bc[_0x5e83('0x31')][_0x5e83('0x40')]){_0x3eb500[_0x5e83('0x41')]=[{'all':!![]}];}return db['VtigerField'][_0x5e83('0x42')](_0x3eb500);})['then'](function(_0x4ab7b5){_0x27fe8b[_0x5e83('0x43')]=_0x4ab7b5;return _0x27fe8b;})[_0x5e83('0x26')](respondWithFilteredResult(_0x4e1662,_0x3eb500))[_0x5e83('0x44')](handleError(_0x4e1662,null));};exports['show']=function(_0x4170b0,_0x52f982){var _0x31827a={'raw':!![],'where':{'id':_0x4170b0['params']['id']}},_0x579da0={};_0x579da0[_0x5e83('0x34')]=_['keys'](db[_0x5e83('0x2b')]['rawAttributes']);_0x579da0[_0x5e83('0x31')]=_[_0x5e83('0x30')](_0x4170b0[_0x5e83('0x31')]);_0x579da0[_0x5e83('0x32')]=_[_0x5e83('0x33')](_0x579da0[_0x5e83('0x34')],_0x579da0[_0x5e83('0x31')]);_0x31827a[_0x5e83('0x35')]=_[_0x5e83('0x33')](_0x579da0[_0x5e83('0x34')],qs['fields'](_0x4170b0[_0x5e83('0x31')]['fields']));_0x31827a[_0x5e83('0x35')]=_0x31827a[_0x5e83('0x35')][_0x5e83('0x37')]?_0x31827a[_0x5e83('0x35')]:_0x579da0[_0x5e83('0x34')];if(_0x4170b0[_0x5e83('0x31')][_0x5e83('0x40')]){_0x31827a[_0x5e83('0x41')]=[{'all':!![]}];}_0x31827a=_['merge']({},_0x31827a,_0x4170b0['options']);return db['VtigerField'][_0x5e83('0x45')](_0x31827a)['then'](handleEntityNotFound(_0x52f982,null))[_0x5e83('0x26')](respondWithResult(_0x52f982,null))['catch'](handleError(_0x52f982,null));};exports[_0x5e83('0x46')]=function(_0x24befc,_0x4b772e){return db[_0x5e83('0x2b')][_0x5e83('0x46')](_0x24befc[_0x5e83('0x47')],{})[_0x5e83('0x26')](respondWithResult(_0x4b772e,0xc9))[_0x5e83('0x44')](handleError(_0x4b772e,null));};exports[_0x5e83('0x25')]=function(_0x43de53,_0x3ccbce){if(_0x43de53[_0x5e83('0x47')]['id']){delete _0x43de53[_0x5e83('0x47')]['id'];}return db[_0x5e83('0x2b')][_0x5e83('0x45')]({'where':{'id':_0x43de53[_0x5e83('0x48')]['id']}})['then'](handleEntityNotFound(_0x3ccbce,null))[_0x5e83('0x26')](saveUpdates(_0x43de53[_0x5e83('0x47')],null))[_0x5e83('0x26')](respondWithResult(_0x3ccbce,null))[_0x5e83('0x44')](handleError(_0x3ccbce,null));};exports[_0x5e83('0x27')]=function(_0x8e4499,_0x1734ca){return db[_0x5e83('0x2b')][_0x5e83('0x45')]({'where':{'id':_0x8e4499['params']['id']}})[_0x5e83('0x26')](handleEntityNotFound(_0x1734ca,null))[_0x5e83('0x26')](removeEntity(_0x1734ca,null))[_0x5e83('0x44')](handleError(_0x1734ca,null));};
\ No newline at end of file