Built motion from commit a61a4a20.|2.5.46
[motion2.git] / server / api / intZohoField / intZohoField.controller.js
index 250b0d4..3e6ed28 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x42f6=['then','error','name','send','index','map','ZohoField','type','key','model','keys','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','filters','where','merge','VIRTUAL','options','include','rows','show','params','rawAttributes','includeAll','find','create','body','catch','update','destroy','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','json','count','offset','limit','status','set','apply','reject','save'];(function(_0x29b609,_0x19d388){var _0x54c952=function(_0xb3c38d){while(--_0xb3c38d){_0x29b609['push'](_0x29b609['shift']());}};_0x54c952(++_0x19d388);}(_0x42f6,0x151));var _0x642f=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0x42f6[_0x19e35c];return _0x3e1fe8;};'use strict';var pdf=require(_0x642f('0x0'));var emlformat=require(_0x642f('0x1'));var rimraf=require(_0x642f('0x2'));var zipdir=require(_0x642f('0x3'));var jsonpatch=require(_0x642f('0x4'));var rp=require(_0x642f('0x5'));var moment=require('moment');var BPromise=require(_0x642f('0x6'));var Mustache=require(_0x642f('0x7'));var util=require(_0x642f('0x8'));var path=require(_0x642f('0x9'));var sox=require(_0x642f('0xa'));var csv=require(_0x642f('0xb'));var ejs=require(_0x642f('0xc'));var fs=require('fs');var _=require(_0x642f('0xd'));var squel=require(_0x642f('0xe'));var crypto=require(_0x642f('0xf'));var jsforce=require(_0x642f('0x10'));var deskjs=require('desk.js');var toCsv=require(_0x642f('0xb'));var querystring=require(_0x642f('0x11'));var Papa=require(_0x642f('0x12'));var Redis=require('ioredis');var authService=require(_0x642f('0x13'));var qs=require(_0x642f('0x14'));var as=require(_0x642f('0x15'));var hardwareService=require(_0x642f('0x16'));var logger=require(_0x642f('0x17'))('api');var utils=require(_0x642f('0x18'));var config=require(_0x642f('0x19'));var db=require(_0x642f('0x1a'))['db'];function respondWithStatusCode(_0x313a76,_0x274387){_0x274387=_0x274387||0xcc;return function(_0x2574d4){if(_0x2574d4){return _0x313a76[_0x642f('0x1b')](_0x274387);}return _0x313a76['status'](_0x274387)[_0x642f('0x1c')]();};}function respondWithResult(_0x5d7ae4,_0xe2f772){_0xe2f772=_0xe2f772||0xc8;return function(_0x1b4544){if(_0x1b4544){return _0x5d7ae4['status'](_0xe2f772)[_0x642f('0x1d')](_0x1b4544);}};}function respondWithFilteredResult(_0x4c1baa,_0x3de0ab){return function(_0x35113b){if(_0x35113b){var _0x33fb1d=_0x35113b[_0x642f('0x1e')],_0x30e0e7=_0x3de0ab['offset'],_0x725768=_0x3de0ab[_0x642f('0x1f')]+_0x3de0ab[_0x642f('0x20')],_0x49dfe4;if(_0x725768>=_0x33fb1d){_0x725768=_0x33fb1d;_0x49dfe4=0xc8;}else{_0x49dfe4=0xce;}_0x4c1baa[_0x642f('0x21')](_0x49dfe4);return _0x4c1baa[_0x642f('0x22')]('Content-Range',_0x30e0e7+'-'+_0x725768+'/'+_0x33fb1d)[_0x642f('0x1d')](_0x35113b);}return null;};}function patchUpdates(_0x7a28f7){return function(_0x4161c8){try{jsonpatch[_0x642f('0x23')](_0x4161c8,_0x7a28f7,!![]);}catch(_0x51ac3b){return BPromise[_0x642f('0x24')](_0x51ac3b);}return _0x4161c8[_0x642f('0x25')]();};}function saveUpdates(_0x42279c,_0x721348){return function(_0x3ffb1a){if(_0x3ffb1a){return _0x3ffb1a['update'](_0x42279c)[_0x642f('0x26')](function(_0x2b9454){return _0x2b9454;});}return null;};}function removeEntity(_0x39fc30,_0x5c9233){return function(_0x18e898){if(_0x18e898){return _0x18e898['destroy']()[_0x642f('0x26')](function(){_0x39fc30[_0x642f('0x21')](0xcc)[_0x642f('0x1c')]();});}};}function handleEntityNotFound(_0xe581d7,_0x407e5a){return function(_0x883d07){if(!_0x883d07){_0xe581d7[_0x642f('0x1b')](0x194);}return _0x883d07;};}function handleError(_0x4b7ecb,_0x1114af){_0x1114af=_0x1114af||0x1f4;return function(_0x48a29d){logger[_0x642f('0x27')](_0x48a29d['stack']);if(_0x48a29d[_0x642f('0x28')]){delete _0x48a29d['name'];}_0x4b7ecb[_0x642f('0x21')](_0x1114af)[_0x642f('0x29')](_0x48a29d);};}exports[_0x642f('0x2a')]=function(_0x2e13c3,_0x65b75){var _0x3de348={},_0x4b3b86={},_0x161dda={'count':0x0,'rows':[]};var _0x4ce486=_[_0x642f('0x2b')](db[_0x642f('0x2c')]['rawAttributes'],function(_0x18c709){return{'name':_0x18c709['fieldName'],'type':_0x18c709[_0x642f('0x2d')][_0x642f('0x2e')]};});_0x4b3b86[_0x642f('0x2f')]=_[_0x642f('0x2b')](_0x4ce486,_0x642f('0x28'));_0x4b3b86['query']=_[_0x642f('0x30')](_0x2e13c3[_0x642f('0x31')]);_0x4b3b86['filters']=_[_0x642f('0x32')](_0x4b3b86[_0x642f('0x2f')],_0x4b3b86[_0x642f('0x31')]);_0x3de348['attributes']=_['intersection'](_0x4b3b86['model'],qs[_0x642f('0x33')](_0x2e13c3[_0x642f('0x31')][_0x642f('0x33')]));_0x3de348[_0x642f('0x34')]=_0x3de348[_0x642f('0x34')][_0x642f('0x35')]?_0x3de348[_0x642f('0x34')]:_0x4b3b86[_0x642f('0x2f')];if(!_0x2e13c3[_0x642f('0x31')][_0x642f('0x36')](_0x642f('0x37'))){_0x3de348[_0x642f('0x20')]=qs['limit'](_0x2e13c3['query']['limit']);_0x3de348['offset']=qs[_0x642f('0x1f')](_0x2e13c3['query'][_0x642f('0x1f')]);}_0x3de348[_0x642f('0x38')]=qs['sort'](_0x2e13c3[_0x642f('0x31')][_0x642f('0x39')]);_0x3de348['where']=qs['filters'](_['pick'](_0x2e13c3['query'],_0x4b3b86[_0x642f('0x3a')]));if(_0x2e13c3[_0x642f('0x31')]['filter']){_0x3de348[_0x642f('0x3b')]=_[_0x642f('0x3c')](_0x3de348['where'],{'$or':_[_0x642f('0x2b')](_0x4ce486,function(_0x22f352){if(_0x22f352[_0x642f('0x2d')]!==_0x642f('0x3d')){var _0x4dee4e={};_0x4dee4e[_0x22f352['name']]={'$like':'%'+_0x2e13c3[_0x642f('0x31')]['filter']+'%'};return _0x4dee4e;}})});}_0x3de348=_[_0x642f('0x3c')]({},_0x3de348,_0x2e13c3[_0x642f('0x3e')]);var _0x32e71c={'where':_0x3de348[_0x642f('0x3b')]};return db[_0x642f('0x2c')][_0x642f('0x1e')](_0x32e71c)['then'](function(_0x368016){_0x161dda[_0x642f('0x1e')]=_0x368016;if(_0x2e13c3['query']['includeAll']){_0x3de348[_0x642f('0x3f')]=[{'all':!![]}];}return db[_0x642f('0x2c')]['findAll'](_0x3de348);})['then'](function(_0x318f90){_0x161dda[_0x642f('0x40')]=_0x318f90;return _0x161dda;})[_0x642f('0x26')](respondWithFilteredResult(_0x65b75,_0x3de348))['catch'](handleError(_0x65b75,null));};exports[_0x642f('0x41')]=function(_0x5a920e,_0x1dd669){var _0x335fe8={'raw':!![],'where':{'id':_0x5a920e[_0x642f('0x42')]['id']}},_0x101b86={};_0x101b86[_0x642f('0x2f')]=_[_0x642f('0x30')](db[_0x642f('0x2c')][_0x642f('0x43')]);_0x101b86[_0x642f('0x31')]=_['keys'](_0x5a920e[_0x642f('0x31')]);_0x101b86[_0x642f('0x3a')]=_[_0x642f('0x32')](_0x101b86[_0x642f('0x2f')],_0x101b86[_0x642f('0x31')]);_0x335fe8['attributes']=_[_0x642f('0x32')](_0x101b86[_0x642f('0x2f')],qs[_0x642f('0x33')](_0x5a920e[_0x642f('0x31')][_0x642f('0x33')]));_0x335fe8[_0x642f('0x34')]=_0x335fe8[_0x642f('0x34')][_0x642f('0x35')]?_0x335fe8[_0x642f('0x34')]:_0x101b86['model'];if(_0x5a920e['query'][_0x642f('0x44')]){_0x335fe8[_0x642f('0x3f')]=[{'all':!![]}];}_0x335fe8=_[_0x642f('0x3c')]({},_0x335fe8,_0x5a920e['options']);return db['ZohoField'][_0x642f('0x45')](_0x335fe8)['then'](handleEntityNotFound(_0x1dd669,null))[_0x642f('0x26')](respondWithResult(_0x1dd669,null))['catch'](handleError(_0x1dd669,null));};exports[_0x642f('0x46')]=function(_0x39bf67,_0x5013bd){return db['ZohoField'][_0x642f('0x46')](_0x39bf67[_0x642f('0x47')],{})[_0x642f('0x26')](respondWithResult(_0x5013bd,0xc9))[_0x642f('0x48')](handleError(_0x5013bd,null));};exports[_0x642f('0x49')]=function(_0x48801f,_0x5e1c20){if(_0x48801f['body']['id']){delete _0x48801f[_0x642f('0x47')]['id'];}return db[_0x642f('0x2c')][_0x642f('0x45')]({'where':{'id':_0x48801f[_0x642f('0x42')]['id']}})[_0x642f('0x26')](handleEntityNotFound(_0x5e1c20,null))[_0x642f('0x26')](saveUpdates(_0x48801f['body'],null))[_0x642f('0x26')](respondWithResult(_0x5e1c20,null))[_0x642f('0x48')](handleError(_0x5e1c20,null));};exports[_0x642f('0x4a')]=function(_0xbc8cc7,_0x2bd200){return db['ZohoField'][_0x642f('0x45')]({'where':{'id':_0xbc8cc7['params']['id']}})[_0x642f('0x26')](handleEntityNotFound(_0x2bd200,null))[_0x642f('0x26')](removeEntity(_0x2bd200,null))[_0x642f('0x48')](handleError(_0x2bd200,null));};
\ No newline at end of file
+var _0x1753=['fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','count','limit','Content-Range','json','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','ZohoField','rawAttributes','fieldName','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','filter','merge','where','type','options','include','catch','show','includeAll','find','create','body','params','eml-format','rimraf','zip-dir'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x1753,0x1cb));var _0x3175=function(_0x45605d,_0x3b02dc){_0x45605d=_0x45605d-0x0;var _0x52646d=_0x1753[_0x45605d];return _0x52646d;};'use strict';var emlformat=require(_0x3175('0x0'));var rimraf=require(_0x3175('0x1'));var zipdir=require(_0x3175('0x2'));var jsonpatch=require(_0x3175('0x3'));var rp=require(_0x3175('0x4'));var moment=require('moment');var BPromise=require(_0x3175('0x5'));var Mustache=require(_0x3175('0x6'));var util=require(_0x3175('0x7'));var path=require(_0x3175('0x8'));var sox=require(_0x3175('0x9'));var csv=require(_0x3175('0xa'));var ejs=require(_0x3175('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x3175('0xc'));var crypto=require(_0x3175('0xd'));var jsforce=require(_0x3175('0xe'));var deskjs=require(_0x3175('0xf'));var toCsv=require(_0x3175('0xa'));var querystring=require(_0x3175('0x10'));var Papa=require(_0x3175('0x11'));var Redis=require(_0x3175('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x3175('0x13'));var as=require(_0x3175('0x14'));var hardwareService=require(_0x3175('0x15'));var logger=require(_0x3175('0x16'))(_0x3175('0x17'));var utils=require(_0x3175('0x18'));var config=require(_0x3175('0x19'));var licenseUtil=require(_0x3175('0x1a'));var db=require(_0x3175('0x1b'))['db'];function respondWithStatusCode(_0x6142e,_0x5f1e6f){_0x5f1e6f=_0x5f1e6f||0xcc;return function(_0x301e0e){if(_0x301e0e){return _0x6142e[_0x3175('0x1c')](_0x5f1e6f);}return _0x6142e[_0x3175('0x1d')](_0x5f1e6f)[_0x3175('0x1e')]();};}function respondWithResult(_0x4c7b92,_0x1bc455){_0x1bc455=_0x1bc455||0xc8;return function(_0xdadc43){if(_0xdadc43){return _0x4c7b92[_0x3175('0x1d')](_0x1bc455)['json'](_0xdadc43);}};}function respondWithFilteredResult(_0x504bb0,_0x105946){return function(_0x5b1a27){if(_0x5b1a27){var _0x1cd247=typeof _0x105946[_0x3175('0x1f')]===_0x3175('0x20')&&typeof _0x105946['limit']===_0x3175('0x20');var _0x2cee63=_0x5b1a27[_0x3175('0x21')];var _0x7c66dc=_0x1cd247?0x0:_0x105946[_0x3175('0x1f')];var _0x4f971b=_0x1cd247?_0x5b1a27[_0x3175('0x21')]:_0x105946[_0x3175('0x1f')]+_0x105946[_0x3175('0x22')];var _0x2254a0;if(_0x4f971b>=_0x2cee63){_0x4f971b=_0x2cee63;_0x2254a0=0xc8;}else{_0x2254a0=0xce;}_0x504bb0[_0x3175('0x1d')](_0x2254a0);return _0x504bb0['set'](_0x3175('0x23'),_0x7c66dc+'-'+_0x4f971b+'/'+_0x2cee63)[_0x3175('0x24')](_0x5b1a27);}return null;};}function patchUpdates(_0x66d5b8){return function(_0x40c1bb){try{jsonpatch[_0x3175('0x25')](_0x40c1bb,_0x66d5b8,!![]);}catch(_0x191e41){return BPromise[_0x3175('0x26')](_0x191e41);}return _0x40c1bb[_0x3175('0x27')]();};}function saveUpdates(_0x4281f3,_0x3a932d){return function(_0x26311){if(_0x26311){return _0x26311[_0x3175('0x28')](_0x4281f3)[_0x3175('0x29')](function(_0x213240){return _0x213240;});}return null;};}function removeEntity(_0x184b8e,_0x1dbe8f){return function(_0x2b61fc){if(_0x2b61fc){return _0x2b61fc[_0x3175('0x2a')]()[_0x3175('0x29')](function(){_0x184b8e['status'](0xcc)[_0x3175('0x1e')]();});}};}function handleEntityNotFound(_0x3aefef,_0x32c190){return function(_0x4fda03){if(!_0x4fda03){_0x3aefef[_0x3175('0x1c')](0x194);}return _0x4fda03;};}function handleError(_0x4679f4,_0x1ec59d){_0x1ec59d=_0x1ec59d||0x1f4;return function(_0x3b7ab8){logger[_0x3175('0x2b')](_0x3b7ab8[_0x3175('0x2c')]);if(_0x3b7ab8[_0x3175('0x2d')]){delete _0x3b7ab8[_0x3175('0x2d')];}_0x4679f4[_0x3175('0x1d')](_0x1ec59d)[_0x3175('0x2e')](_0x3b7ab8);};}exports[_0x3175('0x2f')]=function(_0x112bb7,_0x180cd3){var _0x551e00={},_0x291dd3={},_0x490a64={'count':0x0,'rows':[]};var _0x491a40=_[_0x3175('0x30')](db[_0x3175('0x31')][_0x3175('0x32')],function(_0x4dc273){return{'name':_0x4dc273[_0x3175('0x33')],'type':_0x4dc273['type']['key']};});_0x291dd3[_0x3175('0x34')]=_[_0x3175('0x30')](_0x491a40,_0x3175('0x2d'));_0x291dd3[_0x3175('0x35')]=_[_0x3175('0x36')](_0x112bb7['query']);_0x291dd3[_0x3175('0x37')]=_[_0x3175('0x38')](_0x291dd3[_0x3175('0x34')],_0x291dd3[_0x3175('0x35')]);_0x551e00[_0x3175('0x39')]=_[_0x3175('0x38')](_0x291dd3[_0x3175('0x34')],qs[_0x3175('0x3a')](_0x112bb7['query'][_0x3175('0x3a')]));_0x551e00[_0x3175('0x39')]=_0x551e00['attributes'][_0x3175('0x3b')]?_0x551e00[_0x3175('0x39')]:_0x291dd3[_0x3175('0x34')];if(!_0x112bb7['query'][_0x3175('0x3c')]('nolimit')){_0x551e00[_0x3175('0x22')]=qs[_0x3175('0x22')](_0x112bb7[_0x3175('0x35')]['limit']);_0x551e00[_0x3175('0x1f')]=qs['offset'](_0x112bb7[_0x3175('0x35')][_0x3175('0x1f')]);}_0x551e00[_0x3175('0x3d')]=qs[_0x3175('0x3e')](_0x112bb7[_0x3175('0x35')][_0x3175('0x3e')]);_0x551e00['where']=qs[_0x3175('0x37')](_[_0x3175('0x3f')](_0x112bb7[_0x3175('0x35')],_0x291dd3['filters']),_0x491a40);if(_0x112bb7['query'][_0x3175('0x40')]){_0x551e00['where']=_[_0x3175('0x41')](_0x551e00[_0x3175('0x42')],{'$or':_[_0x3175('0x30')](_0x491a40,function(_0x4f080f){if(_0x4f080f[_0x3175('0x43')]!=='VIRTUAL'){var _0x187cef={};_0x187cef[_0x4f080f[_0x3175('0x2d')]]={'$like':'%'+_0x112bb7[_0x3175('0x35')][_0x3175('0x40')]+'%'};return _0x187cef;}})});}_0x551e00=_['merge']({},_0x551e00,_0x112bb7[_0x3175('0x44')]);var _0x28d83c={'where':_0x551e00[_0x3175('0x42')]};return db[_0x3175('0x31')]['count'](_0x28d83c)[_0x3175('0x29')](function(_0x3a5dcb){_0x490a64[_0x3175('0x21')]=_0x3a5dcb;if(_0x112bb7[_0x3175('0x35')]['includeAll']){_0x551e00[_0x3175('0x45')]=[{'all':!![]}];}return db[_0x3175('0x31')]['findAll'](_0x551e00);})[_0x3175('0x29')](function(_0x70b42f){_0x490a64['rows']=_0x70b42f;return _0x490a64;})[_0x3175('0x29')](respondWithFilteredResult(_0x180cd3,_0x551e00))[_0x3175('0x46')](handleError(_0x180cd3,null));};exports[_0x3175('0x47')]=function(_0x388d69,_0x3eddb5){var _0x60f68={'raw':!![],'where':{'id':_0x388d69['params']['id']}},_0x191b56={};_0x191b56[_0x3175('0x34')]=_[_0x3175('0x36')](db['ZohoField'][_0x3175('0x32')]);_0x191b56['query']=_['keys'](_0x388d69['query']);_0x191b56[_0x3175('0x37')]=_[_0x3175('0x38')](_0x191b56[_0x3175('0x34')],_0x191b56[_0x3175('0x35')]);_0x60f68['attributes']=_[_0x3175('0x38')](_0x191b56['model'],qs[_0x3175('0x3a')](_0x388d69['query'][_0x3175('0x3a')]));_0x60f68['attributes']=_0x60f68[_0x3175('0x39')]['length']?_0x60f68[_0x3175('0x39')]:_0x191b56[_0x3175('0x34')];if(_0x388d69[_0x3175('0x35')][_0x3175('0x48')]){_0x60f68[_0x3175('0x45')]=[{'all':!![]}];}_0x60f68=_[_0x3175('0x41')]({},_0x60f68,_0x388d69[_0x3175('0x44')]);return db['ZohoField'][_0x3175('0x49')](_0x60f68)[_0x3175('0x29')](handleEntityNotFound(_0x3eddb5,null))[_0x3175('0x29')](respondWithResult(_0x3eddb5,null))[_0x3175('0x46')](handleError(_0x3eddb5,null));};exports[_0x3175('0x4a')]=function(_0x2895ca,_0x2a76eb){return db[_0x3175('0x31')][_0x3175('0x4a')](_0x2895ca['body'],{})[_0x3175('0x29')](respondWithResult(_0x2a76eb,0xc9))[_0x3175('0x46')](handleError(_0x2a76eb,null));};exports['update']=function(_0x143d96,_0x394e1f){if(_0x143d96[_0x3175('0x4b')]['id']){delete _0x143d96['body']['id'];}return db[_0x3175('0x31')][_0x3175('0x49')]({'where':{'id':_0x143d96[_0x3175('0x4c')]['id']}})[_0x3175('0x29')](handleEntityNotFound(_0x394e1f,null))[_0x3175('0x29')](saveUpdates(_0x143d96[_0x3175('0x4b')],null))['then'](respondWithResult(_0x394e1f,null))['catch'](handleError(_0x394e1f,null));};exports[_0x3175('0x2a')]=function(_0x35b5f1,_0x4c1768){return db[_0x3175('0x31')][_0x3175('0x49')]({'where':{'id':_0x35b5f1[_0x3175('0x4c')]['id']}})[_0x3175('0x29')](handleEntityNotFound(_0x4c1768,null))[_0x3175('0x29')](removeEntity(_0x4c1768,null))[_0x3175('0x46')](handleError(_0x4c1768,null));};
\ No newline at end of file