Built motion from commit (unavailable).|2.5.15
[motion2.git] / server / api / intZohoField / intZohoField.controller.js
index 250b0d4..29dd7a1 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 _0x1ca0=['rows','catch','show','keys','create','body','find','params','eml-format','rimraf','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','ioredis','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','sendStatus','end','json','count','offset','limit','status','set','Content-Range','apply','reject','update','then','destroy','stack','name','send','index','map','ZohoField','rawAttributes','fieldName','type','key','query','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','filters','pick','filter','where','merge','options','includeAll','include','findAll'];(function(_0x2db570,_0x1642c1){var _0x42909e=function(_0xf5ce7c){while(--_0xf5ce7c){_0x2db570['push'](_0x2db570['shift']());}};_0x42909e(++_0x1642c1);}(_0x1ca0,0xdd));var _0x01ca=function(_0x1489ef,_0x275d93){_0x1489ef=_0x1489ef-0x0;var _0x20e0e6=_0x1ca0[_0x1489ef];return _0x20e0e6;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x01ca('0x0'));var rimraf=require(_0x01ca('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x01ca('0x2'));var rp=require(_0x01ca('0x3'));var moment=require('moment');var BPromise=require(_0x01ca('0x4'));var Mustache=require(_0x01ca('0x5'));var util=require('util');var path=require(_0x01ca('0x6'));var sox=require(_0x01ca('0x7'));var csv=require(_0x01ca('0x8'));var ejs=require(_0x01ca('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x01ca('0xa'));var crypto=require(_0x01ca('0xb'));var jsforce=require(_0x01ca('0xc'));var deskjs=require(_0x01ca('0xd'));var toCsv=require(_0x01ca('0x8'));var querystring=require(_0x01ca('0xe'));var Papa=require('papaparse');var Redis=require(_0x01ca('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x01ca('0x10'));var logger=require(_0x01ca('0x11'))('api');var utils=require('../../config/utils');var config=require(_0x01ca('0x12'));var licenseUtil=require('../../config/license/util');var db=require(_0x01ca('0x13'))['db'];function respondWithStatusCode(_0x1b0f3b,_0x5f0997){_0x5f0997=_0x5f0997||0xcc;return function(_0x595a2d){if(_0x595a2d){return _0x1b0f3b[_0x01ca('0x14')](_0x5f0997);}return _0x1b0f3b['status'](_0x5f0997)[_0x01ca('0x15')]();};}function respondWithResult(_0x28b7e6,_0x28e60b){_0x28e60b=_0x28e60b||0xc8;return function(_0x38af09){if(_0x38af09){return _0x28b7e6['status'](_0x28e60b)[_0x01ca('0x16')](_0x38af09);}};}function respondWithFilteredResult(_0x11630f,_0x41d836){return function(_0x417231){if(_0x417231){var _0x5e67f6=_0x417231[_0x01ca('0x17')],_0x3d28df=_0x41d836[_0x01ca('0x18')],_0xa7793b=_0x41d836[_0x01ca('0x18')]+_0x41d836[_0x01ca('0x19')],_0x4f5444;if(_0xa7793b>=_0x5e67f6){_0xa7793b=_0x5e67f6;_0x4f5444=0xc8;}else{_0x4f5444=0xce;}_0x11630f[_0x01ca('0x1a')](_0x4f5444);return _0x11630f[_0x01ca('0x1b')](_0x01ca('0x1c'),_0x3d28df+'-'+_0xa7793b+'/'+_0x5e67f6)[_0x01ca('0x16')](_0x417231);}return null;};}function patchUpdates(_0x34074c){return function(_0x312aea){try{jsonpatch[_0x01ca('0x1d')](_0x312aea,_0x34074c,!![]);}catch(_0x57e0f3){return BPromise[_0x01ca('0x1e')](_0x57e0f3);}return _0x312aea['save']();};}function saveUpdates(_0x1205b0,_0x16a7b1){return function(_0x3eb099){if(_0x3eb099){return _0x3eb099[_0x01ca('0x1f')](_0x1205b0)[_0x01ca('0x20')](function(_0x61fafa){return _0x61fafa;});}return null;};}function removeEntity(_0x4a9225,_0x5f23c3){return function(_0x38dcfd){if(_0x38dcfd){return _0x38dcfd[_0x01ca('0x21')]()[_0x01ca('0x20')](function(){_0x4a9225['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x45798b,_0x1e7a10){return function(_0x43bca5){if(!_0x43bca5){_0x45798b[_0x01ca('0x14')](0x194);}return _0x43bca5;};}function handleError(_0x186eeb,_0x5c0e7d){_0x5c0e7d=_0x5c0e7d||0x1f4;return function(_0xd1a7b5){logger['error'](_0xd1a7b5[_0x01ca('0x22')]);if(_0xd1a7b5[_0x01ca('0x23')]){delete _0xd1a7b5[_0x01ca('0x23')];}_0x186eeb[_0x01ca('0x1a')](_0x5c0e7d)[_0x01ca('0x24')](_0xd1a7b5);};}exports[_0x01ca('0x25')]=function(_0x130519,_0x3f33c3){var _0x5e9450={},_0x1ae3bf={},_0x2eaf1e={'count':0x0,'rows':[]};var _0x5b10b8=_[_0x01ca('0x26')](db[_0x01ca('0x27')][_0x01ca('0x28')],function(_0x14abbd){return{'name':_0x14abbd[_0x01ca('0x29')],'type':_0x14abbd[_0x01ca('0x2a')][_0x01ca('0x2b')]};});_0x1ae3bf['model']=_[_0x01ca('0x26')](_0x5b10b8,_0x01ca('0x23'));_0x1ae3bf[_0x01ca('0x2c')]=_['keys'](_0x130519[_0x01ca('0x2c')]);_0x1ae3bf['filters']=_['intersection'](_0x1ae3bf[_0x01ca('0x2d')],_0x1ae3bf[_0x01ca('0x2c')]);_0x5e9450[_0x01ca('0x2e')]=_[_0x01ca('0x2f')](_0x1ae3bf[_0x01ca('0x2d')],qs[_0x01ca('0x30')](_0x130519[_0x01ca('0x2c')][_0x01ca('0x30')]));_0x5e9450[_0x01ca('0x2e')]=_0x5e9450['attributes'][_0x01ca('0x31')]?_0x5e9450[_0x01ca('0x2e')]:_0x1ae3bf[_0x01ca('0x2d')];if(!_0x130519[_0x01ca('0x2c')][_0x01ca('0x32')](_0x01ca('0x33'))){_0x5e9450[_0x01ca('0x19')]=qs[_0x01ca('0x19')](_0x130519[_0x01ca('0x2c')][_0x01ca('0x19')]);_0x5e9450[_0x01ca('0x18')]=qs[_0x01ca('0x18')](_0x130519[_0x01ca('0x2c')]['offset']);}_0x5e9450[_0x01ca('0x34')]=qs[_0x01ca('0x35')](_0x130519[_0x01ca('0x2c')][_0x01ca('0x35')]);_0x5e9450['where']=qs[_0x01ca('0x36')](_[_0x01ca('0x37')](_0x130519[_0x01ca('0x2c')],_0x1ae3bf[_0x01ca('0x36')]),_0x5b10b8);if(_0x130519[_0x01ca('0x2c')][_0x01ca('0x38')]){_0x5e9450[_0x01ca('0x39')]=_['merge'](_0x5e9450[_0x01ca('0x39')],{'$or':_[_0x01ca('0x26')](_0x5b10b8,function(_0x303e46){if(_0x303e46[_0x01ca('0x2a')]!=='VIRTUAL'){var _0x80a967={};_0x80a967[_0x303e46[_0x01ca('0x23')]]={'$like':'%'+_0x130519['query']['filter']+'%'};return _0x80a967;}})});}_0x5e9450=_[_0x01ca('0x3a')]({},_0x5e9450,_0x130519[_0x01ca('0x3b')]);var _0x1b38e8={'where':_0x5e9450['where']};return db['ZohoField'][_0x01ca('0x17')](_0x1b38e8)[_0x01ca('0x20')](function(_0x12ff12){_0x2eaf1e['count']=_0x12ff12;if(_0x130519[_0x01ca('0x2c')][_0x01ca('0x3c')]){_0x5e9450[_0x01ca('0x3d')]=[{'all':!![]}];}return db[_0x01ca('0x27')][_0x01ca('0x3e')](_0x5e9450);})[_0x01ca('0x20')](function(_0x5ed8d6){_0x2eaf1e[_0x01ca('0x3f')]=_0x5ed8d6;return _0x2eaf1e;})[_0x01ca('0x20')](respondWithFilteredResult(_0x3f33c3,_0x5e9450))[_0x01ca('0x40')](handleError(_0x3f33c3,null));};exports[_0x01ca('0x41')]=function(_0x274a90,_0x2d20ab){var _0x549f5b={'raw':!![],'where':{'id':_0x274a90['params']['id']}},_0x28df30={};_0x28df30[_0x01ca('0x2d')]=_[_0x01ca('0x42')](db[_0x01ca('0x27')][_0x01ca('0x28')]);_0x28df30[_0x01ca('0x2c')]=_[_0x01ca('0x42')](_0x274a90[_0x01ca('0x2c')]);_0x28df30[_0x01ca('0x36')]=_[_0x01ca('0x2f')](_0x28df30[_0x01ca('0x2d')],_0x28df30[_0x01ca('0x2c')]);_0x549f5b[_0x01ca('0x2e')]=_['intersection'](_0x28df30[_0x01ca('0x2d')],qs['fields'](_0x274a90[_0x01ca('0x2c')][_0x01ca('0x30')]));_0x549f5b[_0x01ca('0x2e')]=_0x549f5b[_0x01ca('0x2e')][_0x01ca('0x31')]?_0x549f5b['attributes']:_0x28df30[_0x01ca('0x2d')];if(_0x274a90['query'][_0x01ca('0x3c')]){_0x549f5b[_0x01ca('0x3d')]=[{'all':!![]}];}_0x549f5b=_[_0x01ca('0x3a')]({},_0x549f5b,_0x274a90[_0x01ca('0x3b')]);return db[_0x01ca('0x27')]['find'](_0x549f5b)['then'](handleEntityNotFound(_0x2d20ab,null))['then'](respondWithResult(_0x2d20ab,null))[_0x01ca('0x40')](handleError(_0x2d20ab,null));};exports[_0x01ca('0x43')]=function(_0x235d50,_0x2923a4){return db[_0x01ca('0x27')][_0x01ca('0x43')](_0x235d50[_0x01ca('0x44')],{})[_0x01ca('0x20')](respondWithResult(_0x2923a4,0xc9))[_0x01ca('0x40')](handleError(_0x2923a4,null));};exports[_0x01ca('0x1f')]=function(_0x1ba172,_0x4c09bb){if(_0x1ba172[_0x01ca('0x44')]['id']){delete _0x1ba172[_0x01ca('0x44')]['id'];}return db['ZohoField'][_0x01ca('0x45')]({'where':{'id':_0x1ba172[_0x01ca('0x46')]['id']}})[_0x01ca('0x20')](handleEntityNotFound(_0x4c09bb,null))['then'](saveUpdates(_0x1ba172['body'],null))[_0x01ca('0x20')](respondWithResult(_0x4c09bb,null))['catch'](handleError(_0x4c09bb,null));};exports[_0x01ca('0x21')]=function(_0x351e6e,_0x40f603){return db['ZohoField'][_0x01ca('0x45')]({'where':{'id':_0x351e6e[_0x01ca('0x46')]['id']}})[_0x01ca('0x20')](handleEntityNotFound(_0x40f603,null))[_0x01ca('0x20')](removeEntity(_0x40f603,null))[_0x01ca('0x40')](handleError(_0x40f603,null));};
\ No newline at end of file