Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / intFreshsalesField / intFreshsalesField.controller.js
index 60027cb..8df392c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf580=['querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','destroy','then','error','stack','name','map','FreshsalesField','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','filter','include','findAll','rows','catch','show','params','includeAll','create','body','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js'];(function(_0x2369ce,_0x5e14c8){var _0x3a442f=function(_0x3127ee){while(--_0x3127ee){_0x2369ce['push'](_0x2369ce['shift']());}};_0x3a442f(++_0x5e14c8);}(_0xf580,0x7f));var _0x0f58=function(_0x3ae71c,_0x1e4157){_0x3ae71c=_0x3ae71c-0x0;var _0x2d97e5=_0xf580[_0x3ae71c];return _0x2d97e5;};'use strict';var pdf=require(_0x0f58('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x0f58('0x1'));var zipdir=require(_0x0f58('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x0f58('0x3'));var moment=require(_0x0f58('0x4'));var BPromise=require(_0x0f58('0x5'));var Mustache=require(_0x0f58('0x6'));var util=require(_0x0f58('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x0f58('0x8'));var ejs=require(_0x0f58('0x9'));var fs=require('fs');var _=require(_0x0f58('0xa'));var squel=require(_0x0f58('0xb'));var crypto=require(_0x0f58('0xc'));var jsforce=require(_0x0f58('0xd'));var deskjs=require(_0x0f58('0xe'));var toCsv=require(_0x0f58('0x8'));var querystring=require(_0x0f58('0xf'));var Papa=require(_0x0f58('0x10'));var Redis=require(_0x0f58('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x0f58('0x12'));var as=require(_0x0f58('0x13'));var hardwareService=require(_0x0f58('0x14'));var logger=require('../../config/logger')(_0x0f58('0x15'));var utils=require('../../config/utils');var config=require(_0x0f58('0x16'));var licenseUtil=require(_0x0f58('0x17'));var db=require(_0x0f58('0x18'))['db'];function respondWithStatusCode(_0x5a9aa6,_0x430f34){_0x430f34=_0x430f34||0xcc;return function(_0x134f24){if(_0x134f24){return _0x5a9aa6[_0x0f58('0x19')](_0x430f34);}return _0x5a9aa6[_0x0f58('0x1a')](_0x430f34)[_0x0f58('0x1b')]();};}function respondWithResult(_0x3f7727,_0x16c36a){_0x16c36a=_0x16c36a||0xc8;return function(_0x532a0b){if(_0x532a0b){return _0x3f7727[_0x0f58('0x1a')](_0x16c36a)[_0x0f58('0x1c')](_0x532a0b);}};}function respondWithFilteredResult(_0x20aedf,_0x4bcf86){return function(_0x5e4611){if(_0x5e4611){var _0x187e3e=_0x5e4611[_0x0f58('0x1d')],_0x59d5ae=_0x4bcf86[_0x0f58('0x1e')],_0x4039b5=_0x4bcf86[_0x0f58('0x1e')]+_0x4bcf86[_0x0f58('0x1f')],_0x4a040a;if(_0x4039b5>=_0x187e3e){_0x4039b5=_0x187e3e;_0x4a040a=0xc8;}else{_0x4a040a=0xce;}_0x20aedf[_0x0f58('0x1a')](_0x4a040a);return _0x20aedf[_0x0f58('0x20')](_0x0f58('0x21'),_0x59d5ae+'-'+_0x4039b5+'/'+_0x187e3e)[_0x0f58('0x1c')](_0x5e4611);}return null;};}function patchUpdates(_0x4676bc){return function(_0x5e2b1b){try{jsonpatch['apply'](_0x5e2b1b,_0x4676bc,!![]);}catch(_0x3790be){return BPromise[_0x0f58('0x22')](_0x3790be);}return _0x5e2b1b[_0x0f58('0x23')]();};}function saveUpdates(_0x418f7f,_0x52cd1c){return function(_0x151a4b){if(_0x151a4b){return _0x151a4b[_0x0f58('0x24')](_0x418f7f)['then'](function(_0x35d07){return _0x35d07;});}return null;};}function removeEntity(_0xfe0f96,_0x21b043){return function(_0x58ed9e){if(_0x58ed9e){return _0x58ed9e[_0x0f58('0x25')]()[_0x0f58('0x26')](function(){_0xfe0f96[_0x0f58('0x1a')](0xcc)[_0x0f58('0x1b')]();});}};}function handleEntityNotFound(_0x17d999,_0x36458c){return function(_0x380f4d){if(!_0x380f4d){_0x17d999[_0x0f58('0x19')](0x194);}return _0x380f4d;};}function handleError(_0x32bae4,_0x2540a3){_0x2540a3=_0x2540a3||0x1f4;return function(_0x3aa592){logger[_0x0f58('0x27')](_0x3aa592[_0x0f58('0x28')]);if(_0x3aa592[_0x0f58('0x29')]){delete _0x3aa592['name'];}_0x32bae4[_0x0f58('0x1a')](_0x2540a3)['send'](_0x3aa592);};}exports['index']=function(_0x575ffa,_0x24085c){var _0x272d73={},_0x5069db={},_0x33d370={'count':0x0,'rows':[]};var _0x1e0f06=_[_0x0f58('0x2a')](db[_0x0f58('0x2b')]['rawAttributes'],function(_0x373f75){return{'name':_0x373f75[_0x0f58('0x2c')],'type':_0x373f75[_0x0f58('0x2d')]['key']};});_0x5069db[_0x0f58('0x2e')]=_[_0x0f58('0x2a')](_0x1e0f06,_0x0f58('0x29'));_0x5069db[_0x0f58('0x2f')]=_[_0x0f58('0x30')](_0x575ffa[_0x0f58('0x2f')]);_0x5069db[_0x0f58('0x31')]=_[_0x0f58('0x32')](_0x5069db['model'],_0x5069db[_0x0f58('0x2f')]);_0x272d73[_0x0f58('0x33')]=_[_0x0f58('0x32')](_0x5069db[_0x0f58('0x2e')],qs[_0x0f58('0x34')](_0x575ffa[_0x0f58('0x2f')]['fields']));_0x272d73[_0x0f58('0x33')]=_0x272d73['attributes'][_0x0f58('0x35')]?_0x272d73[_0x0f58('0x33')]:_0x5069db[_0x0f58('0x2e')];if(!_0x575ffa[_0x0f58('0x2f')][_0x0f58('0x36')](_0x0f58('0x37'))){_0x272d73[_0x0f58('0x1f')]=qs['limit'](_0x575ffa[_0x0f58('0x2f')][_0x0f58('0x1f')]);_0x272d73[_0x0f58('0x1e')]=qs[_0x0f58('0x1e')](_0x575ffa[_0x0f58('0x2f')][_0x0f58('0x1e')]);}_0x272d73[_0x0f58('0x38')]=qs[_0x0f58('0x39')](_0x575ffa[_0x0f58('0x2f')]['sort']);_0x272d73[_0x0f58('0x3a')]=qs[_0x0f58('0x31')](_[_0x0f58('0x3b')](_0x575ffa[_0x0f58('0x2f')],_0x5069db[_0x0f58('0x31')]),_0x1e0f06);if(_0x575ffa[_0x0f58('0x2f')]['filter']){_0x272d73['where']=_[_0x0f58('0x3c')](_0x272d73[_0x0f58('0x3a')],{'$or':_[_0x0f58('0x2a')](_0x1e0f06,function(_0x59e1f8){if(_0x59e1f8[_0x0f58('0x2d')]!=='VIRTUAL'){var _0x4897ba={};_0x4897ba[_0x59e1f8[_0x0f58('0x29')]]={'$like':'%'+_0x575ffa[_0x0f58('0x2f')][_0x0f58('0x3d')]+'%'};return _0x4897ba;}})});}_0x272d73=_['merge']({},_0x272d73,_0x575ffa['options']);var _0x389c68={'where':_0x272d73['where']};return db['FreshsalesField'][_0x0f58('0x1d')](_0x389c68)[_0x0f58('0x26')](function(_0x517ce4){_0x33d370[_0x0f58('0x1d')]=_0x517ce4;if(_0x575ffa[_0x0f58('0x2f')]['includeAll']){_0x272d73[_0x0f58('0x3e')]=[{'all':!![]}];}return db['FreshsalesField'][_0x0f58('0x3f')](_0x272d73);})[_0x0f58('0x26')](function(_0x208e83){_0x33d370[_0x0f58('0x40')]=_0x208e83;return _0x33d370;})[_0x0f58('0x26')](respondWithFilteredResult(_0x24085c,_0x272d73))[_0x0f58('0x41')](handleError(_0x24085c,null));};exports[_0x0f58('0x42')]=function(_0x4c0e9e,_0x21005f){var _0x5f39ee={'raw':!![],'where':{'id':_0x4c0e9e[_0x0f58('0x43')]['id']}},_0x379080={};_0x379080[_0x0f58('0x2e')]=_[_0x0f58('0x30')](db[_0x0f58('0x2b')]['rawAttributes']);_0x379080[_0x0f58('0x2f')]=_['keys'](_0x4c0e9e[_0x0f58('0x2f')]);_0x379080[_0x0f58('0x31')]=_[_0x0f58('0x32')](_0x379080['model'],_0x379080[_0x0f58('0x2f')]);_0x5f39ee[_0x0f58('0x33')]=_[_0x0f58('0x32')](_0x379080[_0x0f58('0x2e')],qs[_0x0f58('0x34')](_0x4c0e9e[_0x0f58('0x2f')][_0x0f58('0x34')]));_0x5f39ee[_0x0f58('0x33')]=_0x5f39ee[_0x0f58('0x33')][_0x0f58('0x35')]?_0x5f39ee[_0x0f58('0x33')]:_0x379080['model'];if(_0x4c0e9e[_0x0f58('0x2f')][_0x0f58('0x44')]){_0x5f39ee[_0x0f58('0x3e')]=[{'all':!![]}];}_0x5f39ee=_[_0x0f58('0x3c')]({},_0x5f39ee,_0x4c0e9e['options']);return db[_0x0f58('0x2b')]['find'](_0x5f39ee)[_0x0f58('0x26')](handleEntityNotFound(_0x21005f,null))['then'](respondWithResult(_0x21005f,null))['catch'](handleError(_0x21005f,null));};exports[_0x0f58('0x45')]=function(_0x3535f5,_0x5c2be5){return db['FreshsalesField'][_0x0f58('0x45')](_0x3535f5['body'],{})[_0x0f58('0x26')](respondWithResult(_0x5c2be5,0xc9))[_0x0f58('0x41')](handleError(_0x5c2be5,null));};exports[_0x0f58('0x24')]=function(_0x3245d4,_0x20f8a3){if(_0x3245d4['body']['id']){delete _0x3245d4[_0x0f58('0x46')]['id'];}return db[_0x0f58('0x2b')]['find']({'where':{'id':_0x3245d4['params']['id']}})[_0x0f58('0x26')](handleEntityNotFound(_0x20f8a3,null))[_0x0f58('0x26')](saveUpdates(_0x3245d4['body'],null))['then'](respondWithResult(_0x20f8a3,null))['catch'](handleError(_0x20f8a3,null));};exports[_0x0f58('0x25')]=function(_0x31eecb,_0x6909d){return db[_0x0f58('0x2b')]['find']({'where':{'id':_0x31eecb['params']['id']}})[_0x0f58('0x26')](handleEntityNotFound(_0x6909d,null))['then'](removeEntity(_0x6909d,null))[_0x0f58('0x41')](handleError(_0x6909d,null));};
\ No newline at end of file
+var _0x975d=['offset','undefined','limit','count','Content-Range','apply','reject','save','update','destroy','then','end','error','stack','name','index','FreshsalesField','fieldName','type','query','keys','filters','model','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','where','pick','merge','map','VIRTUAL','options','includeAll','include','rows','catch','show','rawAttributes','find','create','body','params','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json'];(function(_0x405085,_0x49d439){var _0x46a55d=function(_0x245edc){while(--_0x245edc){_0x405085['push'](_0x405085['shift']());}};_0x46a55d(++_0x49d439);}(_0x975d,0x1a0));var _0xd975=function(_0x2e6f06,_0x2401ee){_0x2e6f06=_0x2e6f06-0x0;var _0x3cf218=_0x975d[_0x2e6f06];return _0x3cf218;};'use strict';var emlformat=require(_0xd975('0x0'));var rimraf=require(_0xd975('0x1'));var zipdir=require(_0xd975('0x2'));var jsonpatch=require(_0xd975('0x3'));var rp=require('request-promise');var moment=require(_0xd975('0x4'));var BPromise=require(_0xd975('0x5'));var Mustache=require(_0xd975('0x6'));var util=require(_0xd975('0x7'));var path=require(_0xd975('0x8'));var sox=require(_0xd975('0x9'));var csv=require(_0xd975('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xd975('0xb'));var _=require(_0xd975('0xc'));var squel=require(_0xd975('0xd'));var crypto=require('crypto');var jsforce=require(_0xd975('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xd975('0xa'));var querystring=require(_0xd975('0xf'));var Papa=require(_0xd975('0x10'));var Redis=require('ioredis');var authService=require(_0xd975('0x11'));var qs=require(_0xd975('0x12'));var as=require(_0xd975('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xd975('0x14'))(_0xd975('0x15'));var utils=require(_0xd975('0x16'));var config=require(_0xd975('0x17'));var licenseUtil=require(_0xd975('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3232c5,_0xcb5b4e){_0xcb5b4e=_0xcb5b4e||0xcc;return function(_0x28cfe8){if(_0x28cfe8){return _0x3232c5[_0xd975('0x19')](_0xcb5b4e);}return _0x3232c5[_0xd975('0x1a')](_0xcb5b4e)['end']();};}function respondWithResult(_0x1400f9,_0x511d6b){_0x511d6b=_0x511d6b||0xc8;return function(_0x3f30c9){if(_0x3f30c9){return _0x1400f9[_0xd975('0x1a')](_0x511d6b)[_0xd975('0x1b')](_0x3f30c9);}};}function respondWithFilteredResult(_0x1ffc30,_0x2efe61){return function(_0x41859a){if(_0x41859a){var _0x2032bc=typeof _0x2efe61[_0xd975('0x1c')]===_0xd975('0x1d')&&typeof _0x2efe61[_0xd975('0x1e')]===_0xd975('0x1d');var _0x336171=_0x41859a[_0xd975('0x1f')];var _0x4d8052=_0x2032bc?0x0:_0x2efe61[_0xd975('0x1c')];var _0x33f3ab=_0x2032bc?_0x41859a['count']:_0x2efe61[_0xd975('0x1c')]+_0x2efe61[_0xd975('0x1e')];var _0x21a440;if(_0x33f3ab>=_0x336171){_0x33f3ab=_0x336171;_0x21a440=0xc8;}else{_0x21a440=0xce;}_0x1ffc30[_0xd975('0x1a')](_0x21a440);return _0x1ffc30['set'](_0xd975('0x20'),_0x4d8052+'-'+_0x33f3ab+'/'+_0x336171)['json'](_0x41859a);}return null;};}function patchUpdates(_0x1548e4){return function(_0x5edf07){try{jsonpatch[_0xd975('0x21')](_0x5edf07,_0x1548e4,!![]);}catch(_0x2793a4){return BPromise[_0xd975('0x22')](_0x2793a4);}return _0x5edf07[_0xd975('0x23')]();};}function saveUpdates(_0x40bb98,_0x186d17){return function(_0xad95e2){if(_0xad95e2){return _0xad95e2[_0xd975('0x24')](_0x40bb98)['then'](function(_0x43fdbf){return _0x43fdbf;});}return null;};}function removeEntity(_0x31538c,_0x558f8b){return function(_0x245e98){if(_0x245e98){return _0x245e98[_0xd975('0x25')]()[_0xd975('0x26')](function(){_0x31538c['status'](0xcc)[_0xd975('0x27')]();});}};}function handleEntityNotFound(_0x274b31,_0xb7d803){return function(_0x21694b){if(!_0x21694b){_0x274b31[_0xd975('0x19')](0x194);}return _0x21694b;};}function handleError(_0x39864b,_0x4b28f6){_0x4b28f6=_0x4b28f6||0x1f4;return function(_0x1c4c98){logger[_0xd975('0x28')](_0x1c4c98[_0xd975('0x29')]);if(_0x1c4c98['name']){delete _0x1c4c98[_0xd975('0x2a')];}_0x39864b['status'](_0x4b28f6)['send'](_0x1c4c98);};}exports[_0xd975('0x2b')]=function(_0x3b2e9e,_0xc12996){var _0x33fd37={},_0x223474={},_0x36004c={'count':0x0,'rows':[]};var _0x469061=_['map'](db[_0xd975('0x2c')]['rawAttributes'],function(_0x5907db){return{'name':_0x5907db[_0xd975('0x2d')],'type':_0x5907db[_0xd975('0x2e')]['key']};});_0x223474['model']=_['map'](_0x469061,_0xd975('0x2a'));_0x223474[_0xd975('0x2f')]=_[_0xd975('0x30')](_0x3b2e9e['query']);_0x223474[_0xd975('0x31')]=_['intersection'](_0x223474[_0xd975('0x32')],_0x223474[_0xd975('0x2f')]);_0x33fd37[_0xd975('0x33')]=_[_0xd975('0x34')](_0x223474['model'],qs[_0xd975('0x35')](_0x3b2e9e[_0xd975('0x2f')][_0xd975('0x35')]));_0x33fd37[_0xd975('0x33')]=_0x33fd37['attributes']['length']?_0x33fd37[_0xd975('0x33')]:_0x223474[_0xd975('0x32')];if(!_0x3b2e9e['query'][_0xd975('0x36')](_0xd975('0x37'))){_0x33fd37[_0xd975('0x1e')]=qs[_0xd975('0x1e')](_0x3b2e9e[_0xd975('0x2f')]['limit']);_0x33fd37[_0xd975('0x1c')]=qs[_0xd975('0x1c')](_0x3b2e9e['query']['offset']);}_0x33fd37[_0xd975('0x38')]=qs['sort'](_0x3b2e9e[_0xd975('0x2f')][_0xd975('0x39')]);_0x33fd37[_0xd975('0x3a')]=qs[_0xd975('0x31')](_[_0xd975('0x3b')](_0x3b2e9e[_0xd975('0x2f')],_0x223474[_0xd975('0x31')]),_0x469061);if(_0x3b2e9e['query']['filter']){_0x33fd37[_0xd975('0x3a')]=_[_0xd975('0x3c')](_0x33fd37[_0xd975('0x3a')],{'$or':_[_0xd975('0x3d')](_0x469061,function(_0x3def6e){if(_0x3def6e['type']!==_0xd975('0x3e')){var _0x383fff={};_0x383fff[_0x3def6e[_0xd975('0x2a')]]={'$like':'%'+_0x3b2e9e[_0xd975('0x2f')]['filter']+'%'};return _0x383fff;}})});}_0x33fd37=_[_0xd975('0x3c')]({},_0x33fd37,_0x3b2e9e[_0xd975('0x3f')]);var _0x51ed2d={'where':_0x33fd37[_0xd975('0x3a')]};return db['FreshsalesField']['count'](_0x51ed2d)[_0xd975('0x26')](function(_0x1a2adf){_0x36004c[_0xd975('0x1f')]=_0x1a2adf;if(_0x3b2e9e[_0xd975('0x2f')][_0xd975('0x40')]){_0x33fd37[_0xd975('0x41')]=[{'all':!![]}];}return db[_0xd975('0x2c')]['findAll'](_0x33fd37);})['then'](function(_0x473603){_0x36004c[_0xd975('0x42')]=_0x473603;return _0x36004c;})[_0xd975('0x26')](respondWithFilteredResult(_0xc12996,_0x33fd37))[_0xd975('0x43')](handleError(_0xc12996,null));};exports[_0xd975('0x44')]=function(_0x118b00,_0x5a7946){var _0x4b6c72={'raw':!![],'where':{'id':_0x118b00['params']['id']}},_0x414b78={};_0x414b78[_0xd975('0x32')]=_[_0xd975('0x30')](db[_0xd975('0x2c')][_0xd975('0x45')]);_0x414b78[_0xd975('0x2f')]=_[_0xd975('0x30')](_0x118b00['query']);_0x414b78[_0xd975('0x31')]=_[_0xd975('0x34')](_0x414b78[_0xd975('0x32')],_0x414b78[_0xd975('0x2f')]);_0x4b6c72[_0xd975('0x33')]=_[_0xd975('0x34')](_0x414b78[_0xd975('0x32')],qs[_0xd975('0x35')](_0x118b00[_0xd975('0x2f')][_0xd975('0x35')]));_0x4b6c72[_0xd975('0x33')]=_0x4b6c72[_0xd975('0x33')]['length']?_0x4b6c72['attributes']:_0x414b78[_0xd975('0x32')];if(_0x118b00[_0xd975('0x2f')][_0xd975('0x40')]){_0x4b6c72[_0xd975('0x41')]=[{'all':!![]}];}_0x4b6c72=_[_0xd975('0x3c')]({},_0x4b6c72,_0x118b00[_0xd975('0x3f')]);return db['FreshsalesField'][_0xd975('0x46')](_0x4b6c72)[_0xd975('0x26')](handleEntityNotFound(_0x5a7946,null))[_0xd975('0x26')](respondWithResult(_0x5a7946,null))[_0xd975('0x43')](handleError(_0x5a7946,null));};exports[_0xd975('0x47')]=function(_0x3f6aa0,_0x1a99e0){return db[_0xd975('0x2c')][_0xd975('0x47')](_0x3f6aa0[_0xd975('0x48')],{})[_0xd975('0x26')](respondWithResult(_0x1a99e0,0xc9))[_0xd975('0x43')](handleError(_0x1a99e0,null));};exports['update']=function(_0x28fa1e,_0x5b454d){if(_0x28fa1e['body']['id']){delete _0x28fa1e['body']['id'];}return db[_0xd975('0x2c')][_0xd975('0x46')]({'where':{'id':_0x28fa1e[_0xd975('0x49')]['id']}})[_0xd975('0x26')](handleEntityNotFound(_0x5b454d,null))['then'](saveUpdates(_0x28fa1e[_0xd975('0x48')],null))[_0xd975('0x26')](respondWithResult(_0x5b454d,null))[_0xd975('0x43')](handleError(_0x5b454d,null));};exports[_0xd975('0x25')]=function(_0x5a786d,_0x5cb6c6){return db['FreshsalesField'][_0xd975('0x46')]({'where':{'id':_0x5a786d[_0xd975('0x49')]['id']}})[_0xd975('0x26')](handleEntityNotFound(_0x5cb6c6,null))[_0xd975('0x26')](removeEntity(_0x5cb6c6,null))['catch'](handleError(_0x5cb6c6,null));};
\ No newline at end of file