Built motion from commit (unavailable).|2.5.17
[motion2.git] / server / api / intFreshsalesField / intFreshsalesField.controller.js
index 27cabb3..35706b1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf5d8=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','count','offset','set','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','map','FreshsalesField','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','limit','where','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','params','find','catch','create','body','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x39096d,_0x51f8a0){var _0x13da4f=function(_0x11e6b2){while(--_0x11e6b2){_0x39096d['push'](_0x39096d['shift']());}};_0x13da4f(++_0x51f8a0);}(_0xf5d8,0x1d8));var _0x8f5d=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0xf5d8[_0x321bb2];return _0x9c12ed;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x8f5d('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x8f5d('0x1'));var rp=require(_0x8f5d('0x2'));var moment=require('moment');var BPromise=require(_0x8f5d('0x3'));var Mustache=require(_0x8f5d('0x4'));var util=require(_0x8f5d('0x5'));var path=require(_0x8f5d('0x6'));var sox=require(_0x8f5d('0x7'));var csv=require(_0x8f5d('0x8'));var ejs=require(_0x8f5d('0x9'));var fs=require('fs');var _=require(_0x8f5d('0xa'));var squel=require(_0x8f5d('0xb'));var crypto=require(_0x8f5d('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x8f5d('0xd'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x8f5d('0xe'));var Redis=require(_0x8f5d('0xf'));var authService=require(_0x8f5d('0x10'));var qs=require(_0x8f5d('0x11'));var as=require(_0x8f5d('0x12'));var hardwareService=require(_0x8f5d('0x13'));var logger=require(_0x8f5d('0x14'))(_0x8f5d('0x15'));var utils=require(_0x8f5d('0x16'));var config=require(_0x8f5d('0x17'));var licenseUtil=require(_0x8f5d('0x18'));var db=require(_0x8f5d('0x19'))['db'];function respondWithStatusCode(_0x395c1d,_0x474a4c){_0x474a4c=_0x474a4c||0xcc;return function(_0x11857e){if(_0x11857e){return _0x395c1d['sendStatus'](_0x474a4c);}return _0x395c1d['status'](_0x474a4c)[_0x8f5d('0x1a')]();};}function respondWithResult(_0x19eb54,_0x13428a){_0x13428a=_0x13428a||0xc8;return function(_0xb98b1c){if(_0xb98b1c){return _0x19eb54[_0x8f5d('0x1b')](_0x13428a)[_0x8f5d('0x1c')](_0xb98b1c);}};}function respondWithFilteredResult(_0x561006,_0x27587b){return function(_0x4a4db2){if(_0x4a4db2){var _0x2d8fac=_0x4a4db2[_0x8f5d('0x1d')],_0x5099df=_0x27587b[_0x8f5d('0x1e')],_0x156ed3=_0x27587b[_0x8f5d('0x1e')]+_0x27587b['limit'],_0x3d6eaf;if(_0x156ed3>=_0x2d8fac){_0x156ed3=_0x2d8fac;_0x3d6eaf=0xc8;}else{_0x3d6eaf=0xce;}_0x561006['status'](_0x3d6eaf);return _0x561006[_0x8f5d('0x1f')]('Content-Range',_0x5099df+'-'+_0x156ed3+'/'+_0x2d8fac)[_0x8f5d('0x1c')](_0x4a4db2);}return null;};}function patchUpdates(_0x58c93e){return function(_0xbb5289){try{jsonpatch[_0x8f5d('0x20')](_0xbb5289,_0x58c93e,!![]);}catch(_0x46c526){return BPromise[_0x8f5d('0x21')](_0x46c526);}return _0xbb5289[_0x8f5d('0x22')]();};}function saveUpdates(_0x5d2ace,_0x278364){return function(_0x5aa2fd){if(_0x5aa2fd){return _0x5aa2fd[_0x8f5d('0x23')](_0x5d2ace)[_0x8f5d('0x24')](function(_0x172801){return _0x172801;});}return null;};}function removeEntity(_0xb732c3,_0x27afc8){return function(_0x3ed9f0){if(_0x3ed9f0){return _0x3ed9f0[_0x8f5d('0x25')]()[_0x8f5d('0x24')](function(){_0xb732c3['status'](0xcc)[_0x8f5d('0x1a')]();});}};}function handleEntityNotFound(_0x3207eb,_0x53a4ac){return function(_0x553a52){if(!_0x553a52){_0x3207eb[_0x8f5d('0x26')](0x194);}return _0x553a52;};}function handleError(_0x41f4d1,_0x414953){_0x414953=_0x414953||0x1f4;return function(_0x18e6ec){logger[_0x8f5d('0x27')](_0x18e6ec[_0x8f5d('0x28')]);if(_0x18e6ec[_0x8f5d('0x29')]){delete _0x18e6ec['name'];}_0x41f4d1[_0x8f5d('0x1b')](_0x414953)['send'](_0x18e6ec);};}exports['index']=function(_0x4fc815,_0x4fd071){var _0x110444={},_0x43e91e={},_0x501849={'count':0x0,'rows':[]};var _0x3a0082=_[_0x8f5d('0x2a')](db[_0x8f5d('0x2b')][_0x8f5d('0x2c')],function(_0x3c3295){return{'name':_0x3c3295['fieldName'],'type':_0x3c3295['type'][_0x8f5d('0x2d')]};});_0x43e91e[_0x8f5d('0x2e')]=_['map'](_0x3a0082,_0x8f5d('0x29'));_0x43e91e[_0x8f5d('0x2f')]=_[_0x8f5d('0x30')](_0x4fc815[_0x8f5d('0x2f')]);_0x43e91e[_0x8f5d('0x31')]=_[_0x8f5d('0x32')](_0x43e91e[_0x8f5d('0x2e')],_0x43e91e[_0x8f5d('0x2f')]);_0x110444[_0x8f5d('0x33')]=_[_0x8f5d('0x32')](_0x43e91e[_0x8f5d('0x2e')],qs[_0x8f5d('0x34')](_0x4fc815['query'][_0x8f5d('0x34')]));_0x110444['attributes']=_0x110444[_0x8f5d('0x33')]['length']?_0x110444[_0x8f5d('0x33')]:_0x43e91e[_0x8f5d('0x2e')];if(!_0x4fc815[_0x8f5d('0x2f')][_0x8f5d('0x35')]('nolimit')){_0x110444[_0x8f5d('0x36')]=qs['limit'](_0x4fc815[_0x8f5d('0x2f')]['limit']);_0x110444[_0x8f5d('0x1e')]=qs['offset'](_0x4fc815[_0x8f5d('0x2f')][_0x8f5d('0x1e')]);}_0x110444['order']=qs['sort'](_0x4fc815[_0x8f5d('0x2f')]['sort']);_0x110444[_0x8f5d('0x37')]=qs['filters'](_['pick'](_0x4fc815[_0x8f5d('0x2f')],_0x43e91e[_0x8f5d('0x31')]),_0x3a0082);if(_0x4fc815['query'][_0x8f5d('0x38')]){_0x110444['where']=_[_0x8f5d('0x39')](_0x110444['where'],{'$or':_[_0x8f5d('0x2a')](_0x3a0082,function(_0x246607){if(_0x246607[_0x8f5d('0x3a')]!==_0x8f5d('0x3b')){var _0x208305={};_0x208305[_0x246607[_0x8f5d('0x29')]]={'$like':'%'+_0x4fc815[_0x8f5d('0x2f')]['filter']+'%'};return _0x208305;}})});}_0x110444=_[_0x8f5d('0x39')]({},_0x110444,_0x4fc815[_0x8f5d('0x3c')]);var _0x52fea1={'where':_0x110444['where']};return db[_0x8f5d('0x2b')][_0x8f5d('0x1d')](_0x52fea1)[_0x8f5d('0x24')](function(_0x3e68b4){_0x501849[_0x8f5d('0x1d')]=_0x3e68b4;if(_0x4fc815[_0x8f5d('0x2f')][_0x8f5d('0x3d')]){_0x110444[_0x8f5d('0x3e')]=[{'all':!![]}];}return db[_0x8f5d('0x2b')][_0x8f5d('0x3f')](_0x110444);})[_0x8f5d('0x24')](function(_0x34cc77){_0x501849[_0x8f5d('0x40')]=_0x34cc77;return _0x501849;})[_0x8f5d('0x24')](respondWithFilteredResult(_0x4fd071,_0x110444))['catch'](handleError(_0x4fd071,null));};exports['show']=function(_0x1746c8,_0x4e4add){var _0xfd2934={'raw':!![],'where':{'id':_0x1746c8[_0x8f5d('0x41')]['id']}},_0x2a68c0={};_0x2a68c0[_0x8f5d('0x2e')]=_['keys'](db[_0x8f5d('0x2b')][_0x8f5d('0x2c')]);_0x2a68c0[_0x8f5d('0x2f')]=_[_0x8f5d('0x30')](_0x1746c8[_0x8f5d('0x2f')]);_0x2a68c0[_0x8f5d('0x31')]=_[_0x8f5d('0x32')](_0x2a68c0[_0x8f5d('0x2e')],_0x2a68c0[_0x8f5d('0x2f')]);_0xfd2934[_0x8f5d('0x33')]=_[_0x8f5d('0x32')](_0x2a68c0[_0x8f5d('0x2e')],qs['fields'](_0x1746c8[_0x8f5d('0x2f')][_0x8f5d('0x34')]));_0xfd2934[_0x8f5d('0x33')]=_0xfd2934[_0x8f5d('0x33')]['length']?_0xfd2934['attributes']:_0x2a68c0['model'];if(_0x1746c8['query'][_0x8f5d('0x3d')]){_0xfd2934[_0x8f5d('0x3e')]=[{'all':!![]}];}_0xfd2934=_[_0x8f5d('0x39')]({},_0xfd2934,_0x1746c8['options']);return db['FreshsalesField'][_0x8f5d('0x42')](_0xfd2934)[_0x8f5d('0x24')](handleEntityNotFound(_0x4e4add,null))[_0x8f5d('0x24')](respondWithResult(_0x4e4add,null))[_0x8f5d('0x43')](handleError(_0x4e4add,null));};exports[_0x8f5d('0x44')]=function(_0x3a19c4,_0x331966){return db['FreshsalesField'][_0x8f5d('0x44')](_0x3a19c4[_0x8f5d('0x45')],{})[_0x8f5d('0x24')](respondWithResult(_0x331966,0xc9))[_0x8f5d('0x43')](handleError(_0x331966,null));};exports[_0x8f5d('0x23')]=function(_0x3681e9,_0x331c10){if(_0x3681e9[_0x8f5d('0x45')]['id']){delete _0x3681e9['body']['id'];}return db[_0x8f5d('0x2b')][_0x8f5d('0x42')]({'where':{'id':_0x3681e9[_0x8f5d('0x41')]['id']}})['then'](handleEntityNotFound(_0x331c10,null))[_0x8f5d('0x24')](saveUpdates(_0x3681e9[_0x8f5d('0x45')],null))['then'](respondWithResult(_0x331c10,null))[_0x8f5d('0x43')](handleError(_0x331c10,null));};exports[_0x8f5d('0x25')]=function(_0x276da4,_0x498b47){return db[_0x8f5d('0x2b')][_0x8f5d('0x42')]({'where':{'id':_0x276da4[_0x8f5d('0x41')]['id']}})['then'](handleEntityNotFound(_0x498b47,null))[_0x8f5d('0x24')](removeEntity(_0x498b47,null))['catch'](handleError(_0x498b47,null));};
\ No newline at end of file
+var _0x888f=['params','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','count','offset','set','Content-Range','apply','reject','save','then','destroy','error','stack','map','FreshsalesField','rawAttributes','key','name','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','filter','where','merge','type','VIRTUAL','options','includeAll','include','catch','find','create','body','update'];(function(_0x2d54ad,_0x5bcdf3){var _0x307c40=function(_0x4ebf09){while(--_0x4ebf09){_0x2d54ad['push'](_0x2d54ad['shift']());}};_0x307c40(++_0x5bcdf3);}(_0x888f,0xd9));var _0xf888=function(_0x294524,_0x4d046d){_0x294524=_0x294524-0x0;var _0x3a1fb3=_0x888f[_0x294524];return _0x3a1fb3;};'use strict';var pdf=require(_0xf888('0x0'));var emlformat=require(_0xf888('0x1'));var rimraf=require(_0xf888('0x2'));var zipdir=require(_0xf888('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf888('0x4'));var moment=require(_0xf888('0x5'));var BPromise=require(_0xf888('0x6'));var Mustache=require(_0xf888('0x7'));var util=require('util');var path=require(_0xf888('0x8'));var sox=require(_0xf888('0x9'));var csv=require(_0xf888('0xa'));var ejs=require(_0xf888('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0xf888('0xc'));var crypto=require('crypto');var jsforce=require(_0xf888('0xd'));var deskjs=require(_0xf888('0xe'));var toCsv=require('to-csv');var querystring=require(_0xf888('0xf'));var Papa=require('papaparse');var Redis=require(_0xf888('0x10'));var authService=require(_0xf888('0x11'));var qs=require(_0xf888('0x12'));var as=require(_0xf888('0x13'));var hardwareService=require(_0xf888('0x14'));var logger=require(_0xf888('0x15'))(_0xf888('0x16'));var utils=require(_0xf888('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xf888('0x18'))['db'];function respondWithStatusCode(_0x7a2830,_0x335b65){_0x335b65=_0x335b65||0xcc;return function(_0x4dea90){if(_0x4dea90){return _0x7a2830[_0xf888('0x19')](_0x335b65);}return _0x7a2830[_0xf888('0x1a')](_0x335b65)[_0xf888('0x1b')]();};}function respondWithResult(_0x3d00e9,_0x372772){_0x372772=_0x372772||0xc8;return function(_0x52988d){if(_0x52988d){return _0x3d00e9[_0xf888('0x1a')](_0x372772)[_0xf888('0x1c')](_0x52988d);}};}function respondWithFilteredResult(_0x2ddb83,_0x2f7ec0){return function(_0x2ccd8a){if(_0x2ccd8a){var _0x42d9d1=_0x2ccd8a[_0xf888('0x1d')],_0x2b08b3=_0x2f7ec0[_0xf888('0x1e')],_0x46f0e7=_0x2f7ec0[_0xf888('0x1e')]+_0x2f7ec0['limit'],_0x32839e;if(_0x46f0e7>=_0x42d9d1){_0x46f0e7=_0x42d9d1;_0x32839e=0xc8;}else{_0x32839e=0xce;}_0x2ddb83[_0xf888('0x1a')](_0x32839e);return _0x2ddb83[_0xf888('0x1f')](_0xf888('0x20'),_0x2b08b3+'-'+_0x46f0e7+'/'+_0x42d9d1)[_0xf888('0x1c')](_0x2ccd8a);}return null;};}function patchUpdates(_0x556f33){return function(_0x436952){try{jsonpatch[_0xf888('0x21')](_0x436952,_0x556f33,!![]);}catch(_0x19d3dd){return BPromise[_0xf888('0x22')](_0x19d3dd);}return _0x436952[_0xf888('0x23')]();};}function saveUpdates(_0xae7e06,_0xb794d1){return function(_0x5d7c15){if(_0x5d7c15){return _0x5d7c15['update'](_0xae7e06)[_0xf888('0x24')](function(_0x323585){return _0x323585;});}return null;};}function removeEntity(_0x285cf9,_0x4ef9e3){return function(_0x59690d){if(_0x59690d){return _0x59690d[_0xf888('0x25')]()[_0xf888('0x24')](function(){_0x285cf9[_0xf888('0x1a')](0xcc)[_0xf888('0x1b')]();});}};}function handleEntityNotFound(_0xc4e908,_0x317764){return function(_0xe5f6ec){if(!_0xe5f6ec){_0xc4e908[_0xf888('0x19')](0x194);}return _0xe5f6ec;};}function handleError(_0x780bab,_0x3d39c6){_0x3d39c6=_0x3d39c6||0x1f4;return function(_0x442154){logger[_0xf888('0x26')](_0x442154[_0xf888('0x27')]);if(_0x442154['name']){delete _0x442154['name'];}_0x780bab[_0xf888('0x1a')](_0x3d39c6)['send'](_0x442154);};}exports['index']=function(_0x43adca,_0x318f3a){var _0x2f7524={},_0xb7d4bd={},_0x1ec010={'count':0x0,'rows':[]};var _0x5b6a6b=_[_0xf888('0x28')](db[_0xf888('0x29')][_0xf888('0x2a')],function(_0x5da793){return{'name':_0x5da793['fieldName'],'type':_0x5da793['type'][_0xf888('0x2b')]};});_0xb7d4bd['model']=_['map'](_0x5b6a6b,_0xf888('0x2c'));_0xb7d4bd[_0xf888('0x2d')]=_[_0xf888('0x2e')](_0x43adca[_0xf888('0x2d')]);_0xb7d4bd[_0xf888('0x2f')]=_[_0xf888('0x30')](_0xb7d4bd[_0xf888('0x31')],_0xb7d4bd[_0xf888('0x2d')]);_0x2f7524[_0xf888('0x32')]=_[_0xf888('0x30')](_0xb7d4bd[_0xf888('0x31')],qs[_0xf888('0x33')](_0x43adca[_0xf888('0x2d')][_0xf888('0x33')]));_0x2f7524[_0xf888('0x32')]=_0x2f7524[_0xf888('0x32')][_0xf888('0x34')]?_0x2f7524['attributes']:_0xb7d4bd[_0xf888('0x31')];if(!_0x43adca['query'][_0xf888('0x35')](_0xf888('0x36'))){_0x2f7524[_0xf888('0x37')]=qs['limit'](_0x43adca[_0xf888('0x2d')][_0xf888('0x37')]);_0x2f7524[_0xf888('0x1e')]=qs['offset'](_0x43adca['query'][_0xf888('0x1e')]);}_0x2f7524[_0xf888('0x38')]=qs[_0xf888('0x39')](_0x43adca[_0xf888('0x2d')][_0xf888('0x39')]);_0x2f7524['where']=qs['filters'](_['pick'](_0x43adca[_0xf888('0x2d')],_0xb7d4bd[_0xf888('0x2f')]),_0x5b6a6b);if(_0x43adca[_0xf888('0x2d')][_0xf888('0x3a')]){_0x2f7524[_0xf888('0x3b')]=_[_0xf888('0x3c')](_0x2f7524['where'],{'$or':_[_0xf888('0x28')](_0x5b6a6b,function(_0x258458){if(_0x258458[_0xf888('0x3d')]!==_0xf888('0x3e')){var _0x1675af={};_0x1675af[_0x258458['name']]={'$like':'%'+_0x43adca['query'][_0xf888('0x3a')]+'%'};return _0x1675af;}})});}_0x2f7524=_['merge']({},_0x2f7524,_0x43adca[_0xf888('0x3f')]);var _0x3b7848={'where':_0x2f7524[_0xf888('0x3b')]};return db[_0xf888('0x29')][_0xf888('0x1d')](_0x3b7848)[_0xf888('0x24')](function(_0x2fbf4c){_0x1ec010['count']=_0x2fbf4c;if(_0x43adca['query'][_0xf888('0x40')]){_0x2f7524[_0xf888('0x41')]=[{'all':!![]}];}return db[_0xf888('0x29')]['findAll'](_0x2f7524);})['then'](function(_0x901d7b){_0x1ec010['rows']=_0x901d7b;return _0x1ec010;})[_0xf888('0x24')](respondWithFilteredResult(_0x318f3a,_0x2f7524))[_0xf888('0x42')](handleError(_0x318f3a,null));};exports['show']=function(_0x1bf7d9,_0x47a79b){var _0x44cfb6={'raw':!![],'where':{'id':_0x1bf7d9['params']['id']}},_0x1df031={};_0x1df031[_0xf888('0x31')]=_[_0xf888('0x2e')](db[_0xf888('0x29')][_0xf888('0x2a')]);_0x1df031[_0xf888('0x2d')]=_[_0xf888('0x2e')](_0x1bf7d9['query']);_0x1df031['filters']=_[_0xf888('0x30')](_0x1df031['model'],_0x1df031[_0xf888('0x2d')]);_0x44cfb6[_0xf888('0x32')]=_[_0xf888('0x30')](_0x1df031['model'],qs[_0xf888('0x33')](_0x1bf7d9[_0xf888('0x2d')][_0xf888('0x33')]));_0x44cfb6[_0xf888('0x32')]=_0x44cfb6['attributes'][_0xf888('0x34')]?_0x44cfb6[_0xf888('0x32')]:_0x1df031[_0xf888('0x31')];if(_0x1bf7d9[_0xf888('0x2d')]['includeAll']){_0x44cfb6['include']=[{'all':!![]}];}_0x44cfb6=_['merge']({},_0x44cfb6,_0x1bf7d9[_0xf888('0x3f')]);return db[_0xf888('0x29')][_0xf888('0x43')](_0x44cfb6)[_0xf888('0x24')](handleEntityNotFound(_0x47a79b,null))[_0xf888('0x24')](respondWithResult(_0x47a79b,null))[_0xf888('0x42')](handleError(_0x47a79b,null));};exports[_0xf888('0x44')]=function(_0x2600a8,_0x3a6b13){return db[_0xf888('0x29')][_0xf888('0x44')](_0x2600a8[_0xf888('0x45')],{})[_0xf888('0x24')](respondWithResult(_0x3a6b13,0xc9))[_0xf888('0x42')](handleError(_0x3a6b13,null));};exports[_0xf888('0x46')]=function(_0x589293,_0x46c99f){if(_0x589293[_0xf888('0x45')]['id']){delete _0x589293[_0xf888('0x45')]['id'];}return db[_0xf888('0x29')][_0xf888('0x43')]({'where':{'id':_0x589293[_0xf888('0x47')]['id']}})['then'](handleEntityNotFound(_0x46c99f,null))[_0xf888('0x24')](saveUpdates(_0x589293[_0xf888('0x45')],null))['then'](respondWithResult(_0x46c99f,null))[_0xf888('0x42')](handleError(_0x46c99f,null));};exports[_0xf888('0x25')]=function(_0x486e66,_0x3aac2c){return db[_0xf888('0x29')]['find']({'where':{'id':_0x486e66['params']['id']}})['then'](handleEntityNotFound(_0x3aac2c,null))['then'](removeEntity(_0x3aac2c,null))[_0xf888('0x42')](handleError(_0x3aac2c,null));};
\ No newline at end of file