Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / intZohoField / intZohoField.controller.js
index 3a49c73..93647c1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa6db=['include','findAll','catch','show','length','find','create','body','params','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','status','end','json','undefined','limit','count','set','Content-Range','apply','reject','update','then','error','stack','name','send','index','map','ZohoField','rawAttributes','fieldName','type','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','offset','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll'];(function(_0x1c9906,_0x3cd175){var _0x1726d8=function(_0x469f42){while(--_0x469f42){_0x1c9906['push'](_0x1c9906['shift']());}};_0x1726d8(++_0x3cd175);}(_0xa6db,0x135));var _0xba6d=function(_0x22f2b5,_0x52cbf5){_0x22f2b5=_0x22f2b5-0x0;var _0x32488b=_0xa6db[_0x22f2b5];return _0x32488b;};'use strict';var emlformat=require(_0xba6d('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xba6d('0x1'));var jsonpatch=require(_0xba6d('0x2'));var rp=require(_0xba6d('0x3'));var moment=require('moment');var BPromise=require(_0xba6d('0x4'));var Mustache=require(_0xba6d('0x5'));var util=require(_0xba6d('0x6'));var path=require(_0xba6d('0x7'));var sox=require(_0xba6d('0x8'));var csv=require('to-csv');var ejs=require(_0xba6d('0x9'));var fs=require('fs');var fs_extra=require(_0xba6d('0xa'));var _=require(_0xba6d('0xb'));var squel=require(_0xba6d('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xba6d('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xba6d('0xe'));var Redis=require(_0xba6d('0xf'));var authService=require(_0xba6d('0x10'));var qs=require(_0xba6d('0x11'));var as=require(_0xba6d('0x12'));var hardwareService=require(_0xba6d('0x13'));var logger=require(_0xba6d('0x14'))(_0xba6d('0x15'));var utils=require(_0xba6d('0x16'));var config=require(_0xba6d('0x17'));var licenseUtil=require(_0xba6d('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1c63cf,_0x5ca7a4){_0x5ca7a4=_0x5ca7a4||0xcc;return function(_0x8cd5cd){if(_0x8cd5cd){return _0x1c63cf['sendStatus'](_0x5ca7a4);}return _0x1c63cf[_0xba6d('0x19')](_0x5ca7a4)[_0xba6d('0x1a')]();};}function respondWithResult(_0x19e53d,_0x433ff0){_0x433ff0=_0x433ff0||0xc8;return function(_0x16f025){if(_0x16f025){return _0x19e53d[_0xba6d('0x19')](_0x433ff0)[_0xba6d('0x1b')](_0x16f025);}};}function respondWithFilteredResult(_0x205cda,_0x2b55d8){return function(_0x20a1aa){if(_0x20a1aa){var _0x22c76d=typeof _0x2b55d8['offset']===_0xba6d('0x1c')&&typeof _0x2b55d8[_0xba6d('0x1d')]==='undefined';var _0x218293=_0x20a1aa['count'];var _0x54df56=_0x22c76d?0x0:_0x2b55d8['offset'];var _0x4824ba=_0x22c76d?_0x20a1aa[_0xba6d('0x1e')]:_0x2b55d8['offset']+_0x2b55d8[_0xba6d('0x1d')];var _0x3d65b4;if(_0x4824ba>=_0x218293){_0x4824ba=_0x218293;_0x3d65b4=0xc8;}else{_0x3d65b4=0xce;}_0x205cda[_0xba6d('0x19')](_0x3d65b4);return _0x205cda[_0xba6d('0x1f')](_0xba6d('0x20'),_0x54df56+'-'+_0x4824ba+'/'+_0x218293)[_0xba6d('0x1b')](_0x20a1aa);}return null;};}function patchUpdates(_0xe6b1e1){return function(_0xc90f30){try{jsonpatch[_0xba6d('0x21')](_0xc90f30,_0xe6b1e1,!![]);}catch(_0x430c34){return BPromise[_0xba6d('0x22')](_0x430c34);}return _0xc90f30['save']();};}function saveUpdates(_0x41482a,_0x5815f3){return function(_0x23ce58){if(_0x23ce58){return _0x23ce58[_0xba6d('0x23')](_0x41482a)[_0xba6d('0x24')](function(_0x54a757){return _0x54a757;});}return null;};}function removeEntity(_0x22c893,_0x47ca96){return function(_0x17d569){if(_0x17d569){return _0x17d569['destroy']()[_0xba6d('0x24')](function(){_0x22c893[_0xba6d('0x19')](0xcc)[_0xba6d('0x1a')]();});}};}function handleEntityNotFound(_0x468361,_0x5906ac){return function(_0x4c453a){if(!_0x4c453a){_0x468361['sendStatus'](0x194);}return _0x4c453a;};}function handleError(_0x2f7cc8,_0x4d45dc){_0x4d45dc=_0x4d45dc||0x1f4;return function(_0x22848e){logger[_0xba6d('0x25')](_0x22848e[_0xba6d('0x26')]);if(_0x22848e[_0xba6d('0x27')]){delete _0x22848e[_0xba6d('0x27')];}_0x2f7cc8[_0xba6d('0x19')](_0x4d45dc)[_0xba6d('0x28')](_0x22848e);};}exports[_0xba6d('0x29')]=function(_0x4043ec,_0x22f4f3){var _0x38faa8={},_0x4a0693={},_0x20d93c={'count':0x0,'rows':[]};var _0x1d088f=_[_0xba6d('0x2a')](db[_0xba6d('0x2b')][_0xba6d('0x2c')],function(_0x1d7d07){return{'name':_0x1d7d07[_0xba6d('0x2d')],'type':_0x1d7d07[_0xba6d('0x2e')]['key']};});_0x4a0693[_0xba6d('0x2f')]=_[_0xba6d('0x2a')](_0x1d088f,'name');_0x4a0693[_0xba6d('0x30')]=_[_0xba6d('0x31')](_0x4043ec[_0xba6d('0x30')]);_0x4a0693[_0xba6d('0x32')]=_[_0xba6d('0x33')](_0x4a0693[_0xba6d('0x2f')],_0x4a0693['query']);_0x38faa8['attributes']=_[_0xba6d('0x33')](_0x4a0693[_0xba6d('0x2f')],qs[_0xba6d('0x34')](_0x4043ec[_0xba6d('0x30')][_0xba6d('0x34')]));_0x38faa8[_0xba6d('0x35')]=_0x38faa8[_0xba6d('0x35')]['length']?_0x38faa8[_0xba6d('0x35')]:_0x4a0693[_0xba6d('0x2f')];if(!_0x4043ec[_0xba6d('0x30')][_0xba6d('0x36')](_0xba6d('0x37'))){_0x38faa8[_0xba6d('0x1d')]=qs[_0xba6d('0x1d')](_0x4043ec[_0xba6d('0x30')]['limit']);_0x38faa8[_0xba6d('0x38')]=qs[_0xba6d('0x38')](_0x4043ec[_0xba6d('0x30')]['offset']);}_0x38faa8[_0xba6d('0x39')]=qs['sort'](_0x4043ec[_0xba6d('0x30')][_0xba6d('0x3a')]);_0x38faa8[_0xba6d('0x3b')]=qs[_0xba6d('0x32')](_[_0xba6d('0x3c')](_0x4043ec[_0xba6d('0x30')],_0x4a0693[_0xba6d('0x32')]),_0x1d088f);if(_0x4043ec['query'][_0xba6d('0x3d')]){_0x38faa8[_0xba6d('0x3b')]=_[_0xba6d('0x3e')](_0x38faa8['where'],{'$or':_[_0xba6d('0x2a')](_0x1d088f,function(_0x1ad88f){if(_0x1ad88f[_0xba6d('0x2e')]!==_0xba6d('0x3f')){var _0x3e42d5={};_0x3e42d5[_0x1ad88f['name']]={'$like':'%'+_0x4043ec[_0xba6d('0x30')]['filter']+'%'};return _0x3e42d5;}})});}_0x38faa8=_[_0xba6d('0x3e')]({},_0x38faa8,_0x4043ec[_0xba6d('0x40')]);var _0x71cbc4={'where':_0x38faa8['where']};return db[_0xba6d('0x2b')]['count'](_0x71cbc4)[_0xba6d('0x24')](function(_0x3fd9ca){_0x20d93c[_0xba6d('0x1e')]=_0x3fd9ca;if(_0x4043ec[_0xba6d('0x30')][_0xba6d('0x41')]){_0x38faa8[_0xba6d('0x42')]=[{'all':!![]}];}return db['ZohoField'][_0xba6d('0x43')](_0x38faa8);})[_0xba6d('0x24')](function(_0x1defac){_0x20d93c['rows']=_0x1defac;return _0x20d93c;})[_0xba6d('0x24')](respondWithFilteredResult(_0x22f4f3,_0x38faa8))[_0xba6d('0x44')](handleError(_0x22f4f3,null));};exports[_0xba6d('0x45')]=function(_0x2e40b4,_0x38b8b){var _0x3f1456={'raw':!![],'where':{'id':_0x2e40b4['params']['id']}},_0x516b68={};_0x516b68[_0xba6d('0x2f')]=_[_0xba6d('0x31')](db[_0xba6d('0x2b')][_0xba6d('0x2c')]);_0x516b68['query']=_['keys'](_0x2e40b4[_0xba6d('0x30')]);_0x516b68[_0xba6d('0x32')]=_[_0xba6d('0x33')](_0x516b68[_0xba6d('0x2f')],_0x516b68['query']);_0x3f1456['attributes']=_[_0xba6d('0x33')](_0x516b68['model'],qs[_0xba6d('0x34')](_0x2e40b4[_0xba6d('0x30')][_0xba6d('0x34')]));_0x3f1456[_0xba6d('0x35')]=_0x3f1456[_0xba6d('0x35')][_0xba6d('0x46')]?_0x3f1456['attributes']:_0x516b68[_0xba6d('0x2f')];if(_0x2e40b4[_0xba6d('0x30')][_0xba6d('0x41')]){_0x3f1456['include']=[{'all':!![]}];}_0x3f1456=_[_0xba6d('0x3e')]({},_0x3f1456,_0x2e40b4['options']);return db['ZohoField'][_0xba6d('0x47')](_0x3f1456)[_0xba6d('0x24')](handleEntityNotFound(_0x38b8b,null))[_0xba6d('0x24')](respondWithResult(_0x38b8b,null))[_0xba6d('0x44')](handleError(_0x38b8b,null));};exports[_0xba6d('0x48')]=function(_0x152bc0,_0x39df76){return db[_0xba6d('0x2b')][_0xba6d('0x48')](_0x152bc0['body'],{})['then'](respondWithResult(_0x39df76,0xc9))[_0xba6d('0x44')](handleError(_0x39df76,null));};exports['update']=function(_0x12ba3c,_0x42a17d){if(_0x12ba3c[_0xba6d('0x49')]['id']){delete _0x12ba3c['body']['id'];}return db[_0xba6d('0x2b')][_0xba6d('0x47')]({'where':{'id':_0x12ba3c['params']['id']}})[_0xba6d('0x24')](handleEntityNotFound(_0x42a17d,null))[_0xba6d('0x24')](saveUpdates(_0x12ba3c['body'],null))[_0xba6d('0x24')](respondWithResult(_0x42a17d,null))[_0xba6d('0x44')](handleError(_0x42a17d,null));};exports['destroy']=function(_0x7a7a41,_0x27257c){return db[_0xba6d('0x2b')][_0xba6d('0x47')]({'where':{'id':_0x7a7a41[_0xba6d('0x4a')]['id']}})['then'](handleEntityNotFound(_0x27257c,null))['then'](removeEntity(_0x27257c,null))[_0xba6d('0x44')](handleError(_0x27257c,null));};
\ No newline at end of file
+var _0x845f=['papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','name','index','rawAttributes','type','key','model','map','query','keys','intersection','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','options','includeAll','include','findAll','show','ZohoField','length','catch','create','body','find','params','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring'];(function(_0x424a5e,_0x3cbb66){var _0x38672b=function(_0x3bc55c){while(--_0x3bc55c){_0x424a5e['push'](_0x424a5e['shift']());}};_0x38672b(++_0x3cbb66);}(_0x845f,0x1b8));var _0xf845=function(_0x32b542,_0x4512fa){_0x32b542=_0x32b542-0x0;var _0x554d54=_0x845f[_0x32b542];return _0x554d54;};'use strict';var emlformat=require(_0xf845('0x0'));var rimraf=require(_0xf845('0x1'));var zipdir=require(_0xf845('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf845('0x3'));var moment=require(_0xf845('0x4'));var BPromise=require(_0xf845('0x5'));var Mustache=require(_0xf845('0x6'));var util=require(_0xf845('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0xf845('0x8'));var ejs=require(_0xf845('0x9'));var fs=require('fs');var fs_extra=require(_0xf845('0xa'));var _=require(_0xf845('0xb'));var squel=require('squel');var crypto=require(_0xf845('0xc'));var jsforce=require(_0xf845('0xd'));var deskjs=require(_0xf845('0xe'));var toCsv=require(_0xf845('0x8'));var querystring=require(_0xf845('0xf'));var Papa=require(_0xf845('0x10'));var Redis=require(_0xf845('0x11'));var authService=require(_0xf845('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xf845('0x13'));var hardwareService=require(_0xf845('0x14'));var logger=require(_0xf845('0x15'))(_0xf845('0x16'));var utils=require(_0xf845('0x17'));var config=require(_0xf845('0x18'));var licenseUtil=require(_0xf845('0x19'));var db=require(_0xf845('0x1a'))['db'];function respondWithStatusCode(_0xd6e757,_0xa3d43a){_0xa3d43a=_0xa3d43a||0xcc;return function(_0x23ac7a){if(_0x23ac7a){return _0xd6e757[_0xf845('0x1b')](_0xa3d43a);}return _0xd6e757[_0xf845('0x1c')](_0xa3d43a)[_0xf845('0x1d')]();};}function respondWithResult(_0x5a6115,_0x808834){_0x808834=_0x808834||0xc8;return function(_0x538d93){if(_0x538d93){return _0x5a6115[_0xf845('0x1c')](_0x808834)[_0xf845('0x1e')](_0x538d93);}};}function respondWithFilteredResult(_0x443447,_0x19cead){return function(_0x56e16f){if(_0x56e16f){var _0x2ae924=typeof _0x19cead[_0xf845('0x1f')]===_0xf845('0x20')&&typeof _0x19cead['limit']===_0xf845('0x20');var _0x230503=_0x56e16f[_0xf845('0x21')];var _0x21e1dc=_0x2ae924?0x0:_0x19cead[_0xf845('0x1f')];var _0x4cca89=_0x2ae924?_0x56e16f[_0xf845('0x21')]:_0x19cead[_0xf845('0x1f')]+_0x19cead[_0xf845('0x22')];var _0x3fa637;if(_0x4cca89>=_0x230503){_0x4cca89=_0x230503;_0x3fa637=0xc8;}else{_0x3fa637=0xce;}_0x443447[_0xf845('0x1c')](_0x3fa637);return _0x443447[_0xf845('0x23')](_0xf845('0x24'),_0x21e1dc+'-'+_0x4cca89+'/'+_0x230503)['json'](_0x56e16f);}return null;};}function patchUpdates(_0x1cd597){return function(_0x44d755){try{jsonpatch[_0xf845('0x25')](_0x44d755,_0x1cd597,!![]);}catch(_0x3cd4d3){return BPromise[_0xf845('0x26')](_0x3cd4d3);}return _0x44d755[_0xf845('0x27')]();};}function saveUpdates(_0x162534,_0x5b8ecd){return function(_0x28c8e2){if(_0x28c8e2){return _0x28c8e2[_0xf845('0x28')](_0x162534)[_0xf845('0x29')](function(_0x470aea){return _0x470aea;});}return null;};}function removeEntity(_0x4b59ff,_0x12707a){return function(_0x391204){if(_0x391204){return _0x391204[_0xf845('0x2a')]()[_0xf845('0x29')](function(){_0x4b59ff['status'](0xcc)[_0xf845('0x1d')]();});}};}function handleEntityNotFound(_0x29d57c,_0x4dd424){return function(_0x388d7d){if(!_0x388d7d){_0x29d57c[_0xf845('0x1b')](0x194);}return _0x388d7d;};}function handleError(_0x1c1a02,_0x554575){_0x554575=_0x554575||0x1f4;return function(_0x4234bd){logger[_0xf845('0x2b')](_0x4234bd['stack']);if(_0x4234bd[_0xf845('0x2c')]){delete _0x4234bd[_0xf845('0x2c')];}_0x1c1a02['status'](_0x554575)['send'](_0x4234bd);};}exports[_0xf845('0x2d')]=function(_0x5aaeac,_0x1a6715){var _0x2bbac5={},_0x48958a={},_0x1f9acd={'count':0x0,'rows':[]};var _0x22fd5a=_['map'](db['ZohoField'][_0xf845('0x2e')],function(_0x4cecbe){return{'name':_0x4cecbe['fieldName'],'type':_0x4cecbe[_0xf845('0x2f')][_0xf845('0x30')]};});_0x48958a[_0xf845('0x31')]=_[_0xf845('0x32')](_0x22fd5a,_0xf845('0x2c'));_0x48958a[_0xf845('0x33')]=_[_0xf845('0x34')](_0x5aaeac[_0xf845('0x33')]);_0x48958a['filters']=_[_0xf845('0x35')](_0x48958a[_0xf845('0x31')],_0x48958a[_0xf845('0x33')]);_0x2bbac5[_0xf845('0x36')]=_[_0xf845('0x35')](_0x48958a[_0xf845('0x31')],qs['fields'](_0x5aaeac[_0xf845('0x33')][_0xf845('0x37')]));_0x2bbac5[_0xf845('0x36')]=_0x2bbac5[_0xf845('0x36')]['length']?_0x2bbac5['attributes']:_0x48958a[_0xf845('0x31')];if(!_0x5aaeac[_0xf845('0x33')][_0xf845('0x38')]('nolimit')){_0x2bbac5['limit']=qs['limit'](_0x5aaeac[_0xf845('0x33')][_0xf845('0x22')]);_0x2bbac5[_0xf845('0x1f')]=qs['offset'](_0x5aaeac['query'][_0xf845('0x1f')]);}_0x2bbac5[_0xf845('0x39')]=qs[_0xf845('0x3a')](_0x5aaeac[_0xf845('0x33')][_0xf845('0x3a')]);_0x2bbac5[_0xf845('0x3b')]=qs[_0xf845('0x3c')](_[_0xf845('0x3d')](_0x5aaeac[_0xf845('0x33')],_0x48958a['filters']),_0x22fd5a);if(_0x5aaeac[_0xf845('0x33')][_0xf845('0x3e')]){_0x2bbac5[_0xf845('0x3b')]=_[_0xf845('0x3f')](_0x2bbac5[_0xf845('0x3b')],{'$or':_[_0xf845('0x32')](_0x22fd5a,function(_0x36edc5){if(_0x36edc5[_0xf845('0x2f')]!=='VIRTUAL'){var _0x11d376={};_0x11d376[_0x36edc5['name']]={'$like':'%'+_0x5aaeac[_0xf845('0x33')]['filter']+'%'};return _0x11d376;}})});}_0x2bbac5=_['merge']({},_0x2bbac5,_0x5aaeac[_0xf845('0x40')]);var _0x198015={'where':_0x2bbac5[_0xf845('0x3b')]};return db['ZohoField'][_0xf845('0x21')](_0x198015)[_0xf845('0x29')](function(_0x101fe8){_0x1f9acd[_0xf845('0x21')]=_0x101fe8;if(_0x5aaeac[_0xf845('0x33')][_0xf845('0x41')]){_0x2bbac5[_0xf845('0x42')]=[{'all':!![]}];}return db['ZohoField'][_0xf845('0x43')](_0x2bbac5);})[_0xf845('0x29')](function(_0x327c02){_0x1f9acd['rows']=_0x327c02;return _0x1f9acd;})['then'](respondWithFilteredResult(_0x1a6715,_0x2bbac5))['catch'](handleError(_0x1a6715,null));};exports[_0xf845('0x44')]=function(_0x152158,_0x3b8f36){var _0x28af5c={'raw':!![],'where':{'id':_0x152158['params']['id']}},_0x1afefa={};_0x1afefa[_0xf845('0x31')]=_[_0xf845('0x34')](db[_0xf845('0x45')][_0xf845('0x2e')]);_0x1afefa[_0xf845('0x33')]=_[_0xf845('0x34')](_0x152158[_0xf845('0x33')]);_0x1afefa[_0xf845('0x3c')]=_[_0xf845('0x35')](_0x1afefa[_0xf845('0x31')],_0x1afefa['query']);_0x28af5c[_0xf845('0x36')]=_[_0xf845('0x35')](_0x1afefa[_0xf845('0x31')],qs[_0xf845('0x37')](_0x152158['query']['fields']));_0x28af5c[_0xf845('0x36')]=_0x28af5c[_0xf845('0x36')][_0xf845('0x46')]?_0x28af5c[_0xf845('0x36')]:_0x1afefa[_0xf845('0x31')];if(_0x152158[_0xf845('0x33')]['includeAll']){_0x28af5c[_0xf845('0x42')]=[{'all':!![]}];}_0x28af5c=_[_0xf845('0x3f')]({},_0x28af5c,_0x152158[_0xf845('0x40')]);return db[_0xf845('0x45')]['find'](_0x28af5c)[_0xf845('0x29')](handleEntityNotFound(_0x3b8f36,null))[_0xf845('0x29')](respondWithResult(_0x3b8f36,null))[_0xf845('0x47')](handleError(_0x3b8f36,null));};exports[_0xf845('0x48')]=function(_0x20e7e8,_0x3eca07){return db[_0xf845('0x45')][_0xf845('0x48')](_0x20e7e8['body'],{})[_0xf845('0x29')](respondWithResult(_0x3eca07,0xc9))[_0xf845('0x47')](handleError(_0x3eca07,null));};exports['update']=function(_0x4d95c1,_0x236d31){if(_0x4d95c1[_0xf845('0x49')]['id']){delete _0x4d95c1['body']['id'];}return db[_0xf845('0x45')][_0xf845('0x4a')]({'where':{'id':_0x4d95c1[_0xf845('0x4b')]['id']}})[_0xf845('0x29')](handleEntityNotFound(_0x236d31,null))[_0xf845('0x29')](saveUpdates(_0x4d95c1[_0xf845('0x49')],null))[_0xf845('0x29')](respondWithResult(_0x236d31,null))[_0xf845('0x47')](handleError(_0x236d31,null));};exports['destroy']=function(_0x288c87,_0x4d1223){return db[_0xf845('0x45')]['find']({'where':{'id':_0x288c87['params']['id']}})['then'](handleEntityNotFound(_0x4d1223,null))[_0xf845('0x29')](removeEntity(_0x4d1223,null))[_0xf845('0x47')](handleError(_0x4d1223,null));};
\ No newline at end of file