Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / server / api / intZohoField / intZohoField.controller.js
index 4c3368f..0b85302 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf54=['ZohoField','rawAttributes','fieldName','type','key','map','query','keys','filters','intersection','model','attributes','fields','nolimit','order','sort','where','filter','merge','VIRTUAL','options','include','findAll','catch','show','params','length','find','create','body','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','sendStatus','status','end','count','offset','limit','set','Content-Range','json','reject','save','update','then','destroy','error','stack','name','index'];(function(_0x59a6b7,_0x3ae326){var _0x6a9ef9=function(_0x3d6b9a){while(--_0x3d6b9a){_0x59a6b7['push'](_0x59a6b7['shift']());}};_0x6a9ef9(++_0x3ae326);}(_0xbf54,0xa8));var _0x4bf5=function(_0x494d1f,_0x3f72ff){_0x494d1f=_0x494d1f-0x0;var _0x457b6e=_0xbf54[_0x494d1f];return _0x457b6e;};'use strict';var pdf=require(_0x4bf5('0x0'));var emlformat=require(_0x4bf5('0x1'));var rimraf=require(_0x4bf5('0x2'));var zipdir=require(_0x4bf5('0x3'));var jsonpatch=require(_0x4bf5('0x4'));var rp=require('request-promise');var moment=require(_0x4bf5('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x4bf5('0x6'));var csv=require(_0x4bf5('0x7'));var ejs=require(_0x4bf5('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0x4bf5('0x9'));var crypto=require(_0x4bf5('0xa'));var jsforce=require(_0x4bf5('0xb'));var deskjs=require(_0x4bf5('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x4bf5('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x4bf5('0xe'));var as=require(_0x4bf5('0xf'));var hardwareService=require(_0x4bf5('0x10'));var logger=require(_0x4bf5('0x11'))(_0x4bf5('0x12'));var utils=require('../../config/utils');var config=require(_0x4bf5('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x4bf5('0x14'))['db'];function respondWithStatusCode(_0x390b9d,_0x4ec14e){_0x4ec14e=_0x4ec14e||0xcc;return function(_0x39f299){if(_0x39f299){return _0x390b9d[_0x4bf5('0x15')](_0x4ec14e);}return _0x390b9d[_0x4bf5('0x16')](_0x4ec14e)[_0x4bf5('0x17')]();};}function respondWithResult(_0x27fc3c,_0x119222){_0x119222=_0x119222||0xc8;return function(_0x2623dd){if(_0x2623dd){return _0x27fc3c['status'](_0x119222)['json'](_0x2623dd);}};}function respondWithFilteredResult(_0x20748b,_0x11e263){return function(_0x1b9c9b){if(_0x1b9c9b){var _0x11e6a6=_0x1b9c9b[_0x4bf5('0x18')],_0x102b91=_0x11e263[_0x4bf5('0x19')],_0x2a4083=_0x11e263['offset']+_0x11e263[_0x4bf5('0x1a')],_0x22366f;if(_0x2a4083>=_0x11e6a6){_0x2a4083=_0x11e6a6;_0x22366f=0xc8;}else{_0x22366f=0xce;}_0x20748b[_0x4bf5('0x16')](_0x22366f);return _0x20748b[_0x4bf5('0x1b')](_0x4bf5('0x1c'),_0x102b91+'-'+_0x2a4083+'/'+_0x11e6a6)[_0x4bf5('0x1d')](_0x1b9c9b);}return null;};}function patchUpdates(_0x3125d8){return function(_0x590b4d){try{jsonpatch['apply'](_0x590b4d,_0x3125d8,!![]);}catch(_0x192ced){return BPromise[_0x4bf5('0x1e')](_0x192ced);}return _0x590b4d[_0x4bf5('0x1f')]();};}function saveUpdates(_0x32d275,_0x52a125){return function(_0x411884){if(_0x411884){return _0x411884[_0x4bf5('0x20')](_0x32d275)[_0x4bf5('0x21')](function(_0x5bae57){return _0x5bae57;});}return null;};}function removeEntity(_0x4e6b96,_0x3db606){return function(_0xd720c1){if(_0xd720c1){return _0xd720c1[_0x4bf5('0x22')]()['then'](function(){_0x4e6b96[_0x4bf5('0x16')](0xcc)[_0x4bf5('0x17')]();});}};}function handleEntityNotFound(_0x2db501,_0x5b41d1){return function(_0x5737e6){if(!_0x5737e6){_0x2db501[_0x4bf5('0x15')](0x194);}return _0x5737e6;};}function handleError(_0x48c290,_0x3c732e){_0x3c732e=_0x3c732e||0x1f4;return function(_0x2d4826){logger[_0x4bf5('0x23')](_0x2d4826[_0x4bf5('0x24')]);if(_0x2d4826[_0x4bf5('0x25')]){delete _0x2d4826[_0x4bf5('0x25')];}_0x48c290[_0x4bf5('0x16')](_0x3c732e)['send'](_0x2d4826);};}exports[_0x4bf5('0x26')]=function(_0x1b53c8,_0x38f7b6){var _0x52567a={},_0x5c8ea3={},_0x563f23={'count':0x0,'rows':[]};var _0x28fb37=_['map'](db[_0x4bf5('0x27')][_0x4bf5('0x28')],function(_0x2a47a8){return{'name':_0x2a47a8[_0x4bf5('0x29')],'type':_0x2a47a8[_0x4bf5('0x2a')][_0x4bf5('0x2b')]};});_0x5c8ea3['model']=_[_0x4bf5('0x2c')](_0x28fb37,_0x4bf5('0x25'));_0x5c8ea3[_0x4bf5('0x2d')]=_[_0x4bf5('0x2e')](_0x1b53c8[_0x4bf5('0x2d')]);_0x5c8ea3[_0x4bf5('0x2f')]=_[_0x4bf5('0x30')](_0x5c8ea3[_0x4bf5('0x31')],_0x5c8ea3[_0x4bf5('0x2d')]);_0x52567a[_0x4bf5('0x32')]=_[_0x4bf5('0x30')](_0x5c8ea3['model'],qs[_0x4bf5('0x33')](_0x1b53c8[_0x4bf5('0x2d')][_0x4bf5('0x33')]));_0x52567a[_0x4bf5('0x32')]=_0x52567a['attributes']['length']?_0x52567a[_0x4bf5('0x32')]:_0x5c8ea3[_0x4bf5('0x31')];if(!_0x1b53c8[_0x4bf5('0x2d')]['hasOwnProperty'](_0x4bf5('0x34'))){_0x52567a[_0x4bf5('0x1a')]=qs[_0x4bf5('0x1a')](_0x1b53c8[_0x4bf5('0x2d')][_0x4bf5('0x1a')]);_0x52567a[_0x4bf5('0x19')]=qs[_0x4bf5('0x19')](_0x1b53c8[_0x4bf5('0x2d')][_0x4bf5('0x19')]);}_0x52567a[_0x4bf5('0x35')]=qs[_0x4bf5('0x36')](_0x1b53c8[_0x4bf5('0x2d')][_0x4bf5('0x36')]);_0x52567a[_0x4bf5('0x37')]=qs['filters'](_['pick'](_0x1b53c8['query'],_0x5c8ea3[_0x4bf5('0x2f')]),_0x28fb37);if(_0x1b53c8[_0x4bf5('0x2d')][_0x4bf5('0x38')]){_0x52567a['where']=_[_0x4bf5('0x39')](_0x52567a[_0x4bf5('0x37')],{'$or':_[_0x4bf5('0x2c')](_0x28fb37,function(_0x4a7c1c){if(_0x4a7c1c[_0x4bf5('0x2a')]!==_0x4bf5('0x3a')){var _0x2f3842={};_0x2f3842[_0x4a7c1c[_0x4bf5('0x25')]]={'$like':'%'+_0x1b53c8['query'][_0x4bf5('0x38')]+'%'};return _0x2f3842;}})});}_0x52567a=_['merge']({},_0x52567a,_0x1b53c8[_0x4bf5('0x3b')]);var _0x384bed={'where':_0x52567a['where']};return db['ZohoField'][_0x4bf5('0x18')](_0x384bed)[_0x4bf5('0x21')](function(_0x266c39){_0x563f23[_0x4bf5('0x18')]=_0x266c39;if(_0x1b53c8['query']['includeAll']){_0x52567a[_0x4bf5('0x3c')]=[{'all':!![]}];}return db[_0x4bf5('0x27')][_0x4bf5('0x3d')](_0x52567a);})['then'](function(_0x1836a1){_0x563f23['rows']=_0x1836a1;return _0x563f23;})[_0x4bf5('0x21')](respondWithFilteredResult(_0x38f7b6,_0x52567a))[_0x4bf5('0x3e')](handleError(_0x38f7b6,null));};exports[_0x4bf5('0x3f')]=function(_0x2c023b,_0x362254){var _0x4778cb={'raw':!![],'where':{'id':_0x2c023b[_0x4bf5('0x40')]['id']}},_0x3e5ec8={};_0x3e5ec8[_0x4bf5('0x31')]=_['keys'](db['ZohoField'][_0x4bf5('0x28')]);_0x3e5ec8['query']=_['keys'](_0x2c023b[_0x4bf5('0x2d')]);_0x3e5ec8[_0x4bf5('0x2f')]=_[_0x4bf5('0x30')](_0x3e5ec8[_0x4bf5('0x31')],_0x3e5ec8[_0x4bf5('0x2d')]);_0x4778cb[_0x4bf5('0x32')]=_['intersection'](_0x3e5ec8[_0x4bf5('0x31')],qs['fields'](_0x2c023b[_0x4bf5('0x2d')][_0x4bf5('0x33')]));_0x4778cb['attributes']=_0x4778cb[_0x4bf5('0x32')][_0x4bf5('0x41')]?_0x4778cb[_0x4bf5('0x32')]:_0x3e5ec8[_0x4bf5('0x31')];if(_0x2c023b[_0x4bf5('0x2d')]['includeAll']){_0x4778cb[_0x4bf5('0x3c')]=[{'all':!![]}];}_0x4778cb=_['merge']({},_0x4778cb,_0x2c023b[_0x4bf5('0x3b')]);return db[_0x4bf5('0x27')][_0x4bf5('0x42')](_0x4778cb)[_0x4bf5('0x21')](handleEntityNotFound(_0x362254,null))['then'](respondWithResult(_0x362254,null))[_0x4bf5('0x3e')](handleError(_0x362254,null));};exports['create']=function(_0x56f10e,_0x40e4d7){return db['ZohoField'][_0x4bf5('0x43')](_0x56f10e[_0x4bf5('0x44')],{})[_0x4bf5('0x21')](respondWithResult(_0x40e4d7,0xc9))[_0x4bf5('0x3e')](handleError(_0x40e4d7,null));};exports[_0x4bf5('0x20')]=function(_0x63090d,_0x5c673f){if(_0x63090d[_0x4bf5('0x44')]['id']){delete _0x63090d[_0x4bf5('0x44')]['id'];}return db[_0x4bf5('0x27')][_0x4bf5('0x42')]({'where':{'id':_0x63090d[_0x4bf5('0x40')]['id']}})[_0x4bf5('0x21')](handleEntityNotFound(_0x5c673f,null))[_0x4bf5('0x21')](saveUpdates(_0x63090d[_0x4bf5('0x44')],null))[_0x4bf5('0x21')](respondWithResult(_0x5c673f,null))[_0x4bf5('0x3e')](handleError(_0x5c673f,null));};exports[_0x4bf5('0x22')]=function(_0xfcccd,_0x4e0f91){return db[_0x4bf5('0x27')][_0x4bf5('0x42')]({'where':{'id':_0xfcccd[_0x4bf5('0x40')]['id']}})[_0x4bf5('0x21')](handleEntityNotFound(_0x4e0f91,null))[_0x4bf5('0x21')](removeEntity(_0x4e0f91,null))[_0x4bf5('0x3e')](handleError(_0x4e0f91,null));};
\ No newline at end of file
+var _0xf07f=['filter','merge','type','VIRTUAL','options','includeAll','include','ZohoField','findAll','rows','find','catch','create','body','destroy','params','eml-format','rimraf','fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','end','json','undefined','limit','count','offset','status','set','Content-Range','update','then','error','stack','name','index','map','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick'];(function(_0x52f64e,_0x1e1717){var _0xd5dfc8=function(_0x323e3a){while(--_0x323e3a){_0x52f64e['push'](_0x52f64e['shift']());}};_0xd5dfc8(++_0x1e1717);}(_0xf07f,0xa4));var _0xff07=function(_0x5d55d4,_0x1577fe){_0x5d55d4=_0x5d55d4-0x0;var _0x419d69=_0xf07f[_0x5d55d4];return _0x419d69;};'use strict';var emlformat=require(_0xff07('0x0'));var rimraf=require(_0xff07('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xff07('0x2'));var rp=require('request-promise');var moment=require(_0xff07('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xff07('0x4'));var util=require(_0xff07('0x5'));var path=require(_0xff07('0x6'));var sox=require(_0xff07('0x7'));var csv=require(_0xff07('0x8'));var ejs=require(_0xff07('0x9'));var fs=require('fs');var fs_extra=require(_0xff07('0xa'));var _=require(_0xff07('0xb'));var squel=require(_0xff07('0xc'));var crypto=require(_0xff07('0xd'));var jsforce=require(_0xff07('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xff07('0x8'));var querystring=require(_0xff07('0xf'));var Papa=require('papaparse');var Redis=require(_0xff07('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xff07('0x11'));var as=require(_0xff07('0x12'));var hardwareService=require(_0xff07('0x13'));var logger=require(_0xff07('0x14'))(_0xff07('0x15'));var utils=require('../../config/utils');var config=require(_0xff07('0x16'));var licenseUtil=require(_0xff07('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3ffbf9,_0x473de5){_0x473de5=_0x473de5||0xcc;return function(_0x247c0a){if(_0x247c0a){return _0x3ffbf9[_0xff07('0x18')](_0x473de5);}return _0x3ffbf9['status'](_0x473de5)[_0xff07('0x19')]();};}function respondWithResult(_0x4a990c,_0x242536){_0x242536=_0x242536||0xc8;return function(_0x15a55c){if(_0x15a55c){return _0x4a990c['status'](_0x242536)[_0xff07('0x1a')](_0x15a55c);}};}function respondWithFilteredResult(_0x1a11a6,_0x5cd138){return function(_0x4bfa19){if(_0x4bfa19){var _0x5ca77b=typeof _0x5cd138['offset']===_0xff07('0x1b')&&typeof _0x5cd138[_0xff07('0x1c')]===_0xff07('0x1b');var _0x4caff8=_0x4bfa19[_0xff07('0x1d')];var _0x4bf3f0=_0x5ca77b?0x0:_0x5cd138['offset'];var _0x57f4d2=_0x5ca77b?_0x4bfa19['count']:_0x5cd138[_0xff07('0x1e')]+_0x5cd138['limit'];var _0x176e38;if(_0x57f4d2>=_0x4caff8){_0x57f4d2=_0x4caff8;_0x176e38=0xc8;}else{_0x176e38=0xce;}_0x1a11a6[_0xff07('0x1f')](_0x176e38);return _0x1a11a6[_0xff07('0x20')](_0xff07('0x21'),_0x4bf3f0+'-'+_0x57f4d2+'/'+_0x4caff8)[_0xff07('0x1a')](_0x4bfa19);}return null;};}function patchUpdates(_0x18500b){return function(_0x372266){try{jsonpatch['apply'](_0x372266,_0x18500b,!![]);}catch(_0x27592f){return BPromise['reject'](_0x27592f);}return _0x372266['save']();};}function saveUpdates(_0x237159,_0x40fc63){return function(_0x595319){if(_0x595319){return _0x595319[_0xff07('0x22')](_0x237159)[_0xff07('0x23')](function(_0xb4212){return _0xb4212;});}return null;};}function removeEntity(_0x24b572,_0x111560){return function(_0x11294d){if(_0x11294d){return _0x11294d['destroy']()[_0xff07('0x23')](function(){_0x24b572['status'](0xcc)[_0xff07('0x19')]();});}};}function handleEntityNotFound(_0x4bf26f,_0x2f2e02){return function(_0x1a87ce){if(!_0x1a87ce){_0x4bf26f[_0xff07('0x18')](0x194);}return _0x1a87ce;};}function handleError(_0x36e7ef,_0x2cbb49){_0x2cbb49=_0x2cbb49||0x1f4;return function(_0x3c99fd){logger[_0xff07('0x24')](_0x3c99fd[_0xff07('0x25')]);if(_0x3c99fd[_0xff07('0x26')]){delete _0x3c99fd[_0xff07('0x26')];}_0x36e7ef[_0xff07('0x1f')](_0x2cbb49)['send'](_0x3c99fd);};}exports[_0xff07('0x27')]=function(_0x22fdb1,_0x56b845){var _0x2cb387={},_0x515571={},_0x5dcd53={'count':0x0,'rows':[]};var _0x47ac6c=_[_0xff07('0x28')](db['ZohoField'][_0xff07('0x29')],function(_0x2d6836){return{'name':_0x2d6836[_0xff07('0x2a')],'type':_0x2d6836['type'][_0xff07('0x2b')]};});_0x515571[_0xff07('0x2c')]=_[_0xff07('0x28')](_0x47ac6c,_0xff07('0x26'));_0x515571[_0xff07('0x2d')]=_[_0xff07('0x2e')](_0x22fdb1['query']);_0x515571[_0xff07('0x2f')]=_[_0xff07('0x30')](_0x515571[_0xff07('0x2c')],_0x515571[_0xff07('0x2d')]);_0x2cb387[_0xff07('0x31')]=_[_0xff07('0x30')](_0x515571[_0xff07('0x2c')],qs['fields'](_0x22fdb1[_0xff07('0x2d')][_0xff07('0x32')]));_0x2cb387[_0xff07('0x31')]=_0x2cb387[_0xff07('0x31')][_0xff07('0x33')]?_0x2cb387[_0xff07('0x31')]:_0x515571[_0xff07('0x2c')];if(!_0x22fdb1[_0xff07('0x2d')][_0xff07('0x34')](_0xff07('0x35'))){_0x2cb387['limit']=qs['limit'](_0x22fdb1[_0xff07('0x2d')][_0xff07('0x1c')]);_0x2cb387[_0xff07('0x1e')]=qs['offset'](_0x22fdb1['query'][_0xff07('0x1e')]);}_0x2cb387[_0xff07('0x36')]=qs[_0xff07('0x37')](_0x22fdb1[_0xff07('0x2d')][_0xff07('0x37')]);_0x2cb387[_0xff07('0x38')]=qs[_0xff07('0x2f')](_[_0xff07('0x39')](_0x22fdb1[_0xff07('0x2d')],_0x515571[_0xff07('0x2f')]),_0x47ac6c);if(_0x22fdb1[_0xff07('0x2d')][_0xff07('0x3a')]){_0x2cb387[_0xff07('0x38')]=_[_0xff07('0x3b')](_0x2cb387['where'],{'$or':_[_0xff07('0x28')](_0x47ac6c,function(_0x500218){if(_0x500218[_0xff07('0x3c')]!==_0xff07('0x3d')){var _0x592ca8={};_0x592ca8[_0x500218[_0xff07('0x26')]]={'$like':'%'+_0x22fdb1['query'][_0xff07('0x3a')]+'%'};return _0x592ca8;}})});}_0x2cb387=_[_0xff07('0x3b')]({},_0x2cb387,_0x22fdb1[_0xff07('0x3e')]);var _0x3ae8fe={'where':_0x2cb387[_0xff07('0x38')]};return db['ZohoField'][_0xff07('0x1d')](_0x3ae8fe)[_0xff07('0x23')](function(_0x5ef160){_0x5dcd53[_0xff07('0x1d')]=_0x5ef160;if(_0x22fdb1[_0xff07('0x2d')][_0xff07('0x3f')]){_0x2cb387[_0xff07('0x40')]=[{'all':!![]}];}return db[_0xff07('0x41')][_0xff07('0x42')](_0x2cb387);})[_0xff07('0x23')](function(_0x5b6473){_0x5dcd53[_0xff07('0x43')]=_0x5b6473;return _0x5dcd53;})['then'](respondWithFilteredResult(_0x56b845,_0x2cb387))['catch'](handleError(_0x56b845,null));};exports['show']=function(_0x5366ca,_0x2814d4){var _0x3a1581={'raw':!![],'where':{'id':_0x5366ca['params']['id']}},_0x565e41={};_0x565e41[_0xff07('0x2c')]=_[_0xff07('0x2e')](db[_0xff07('0x41')][_0xff07('0x29')]);_0x565e41[_0xff07('0x2d')]=_[_0xff07('0x2e')](_0x5366ca[_0xff07('0x2d')]);_0x565e41[_0xff07('0x2f')]=_[_0xff07('0x30')](_0x565e41[_0xff07('0x2c')],_0x565e41[_0xff07('0x2d')]);_0x3a1581['attributes']=_[_0xff07('0x30')](_0x565e41[_0xff07('0x2c')],qs[_0xff07('0x32')](_0x5366ca['query'][_0xff07('0x32')]));_0x3a1581[_0xff07('0x31')]=_0x3a1581[_0xff07('0x31')][_0xff07('0x33')]?_0x3a1581[_0xff07('0x31')]:_0x565e41[_0xff07('0x2c')];if(_0x5366ca['query']['includeAll']){_0x3a1581['include']=[{'all':!![]}];}_0x3a1581=_['merge']({},_0x3a1581,_0x5366ca[_0xff07('0x3e')]);return db[_0xff07('0x41')][_0xff07('0x44')](_0x3a1581)[_0xff07('0x23')](handleEntityNotFound(_0x2814d4,null))['then'](respondWithResult(_0x2814d4,null))[_0xff07('0x45')](handleError(_0x2814d4,null));};exports[_0xff07('0x46')]=function(_0x5f2d11,_0x3f3041){return db[_0xff07('0x41')][_0xff07('0x46')](_0x5f2d11[_0xff07('0x47')],{})[_0xff07('0x23')](respondWithResult(_0x3f3041,0xc9))[_0xff07('0x45')](handleError(_0x3f3041,null));};exports['update']=function(_0x4cef1d,_0x103924){if(_0x4cef1d[_0xff07('0x47')]['id']){delete _0x4cef1d[_0xff07('0x47')]['id'];}return db[_0xff07('0x41')][_0xff07('0x44')]({'where':{'id':_0x4cef1d['params']['id']}})[_0xff07('0x23')](handleEntityNotFound(_0x103924,null))[_0xff07('0x23')](saveUpdates(_0x4cef1d['body'],null))[_0xff07('0x23')](respondWithResult(_0x103924,null))[_0xff07('0x45')](handleError(_0x103924,null));};exports[_0xff07('0x48')]=function(_0x3575f7,_0x958c19){return db[_0xff07('0x41')]['find']({'where':{'id':_0x3575f7[_0xff07('0x49')]['id']}})[_0xff07('0x23')](handleEntityNotFound(_0x958c19,null))['then'](removeEntity(_0x958c19,null))[_0xff07('0x45')](handleError(_0x958c19,null));};
\ No newline at end of file