Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / intFreshsalesField / intFreshsalesField.controller.js
index 1cfb0bf..fb2125b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x263f=['FreshsalesField','rawAttributes','type','key','model','map','query','keys','intersection','attributes','fields','nolimit','sort','filters','pick','filter','where','merge','VIRTUAL','options','count','includeAll','rows','params','length','include','create','body','update','find','catch','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','sendStatus','status','end','offset','limit','set','Content-Range','apply','reject','then','destroy','error','stack','name','send','index'];(function(_0x3f9584,_0x5ab12c){var _0x9d54c=function(_0x2882df){while(--_0x2882df){_0x3f9584['push'](_0x3f9584['shift']());}};_0x9d54c(++_0x5ab12c);}(_0x263f,0x182));var _0xf263=function(_0x222d60,_0x3e1ffb){_0x222d60=_0x222d60-0x0;var _0x3d44ea=_0x263f[_0x222d60];return _0x3d44ea;};'use strict';var pdf=require(_0xf263('0x0'));var emlformat=require(_0xf263('0x1'));var rimraf=require(_0xf263('0x2'));var zipdir=require(_0xf263('0x3'));var jsonpatch=require(_0xf263('0x4'));var rp=require(_0xf263('0x5'));var moment=require('moment');var BPromise=require(_0xf263('0x6'));var Mustache=require(_0xf263('0x7'));var util=require(_0xf263('0x8'));var path=require('path');var sox=require(_0xf263('0x9'));var csv=require(_0xf263('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0xf263('0xb'));var crypto=require(_0xf263('0xc'));var jsforce=require(_0xf263('0xd'));var deskjs=require(_0xf263('0xe'));var toCsv=require('to-csv');var querystring=require(_0xf263('0xf'));var Papa=require(_0xf263('0x10'));var Redis=require(_0xf263('0x11'));var authService=require(_0xf263('0x12'));var qs=require(_0xf263('0x13'));var as=require(_0xf263('0x14'));var hardwareService=require(_0xf263('0x15'));var logger=require('../../config/logger')(_0xf263('0x16'));var utils=require('../../config/utils');var config=require(_0xf263('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5e46a6,_0x2fc9f0){_0x2fc9f0=_0x2fc9f0||0xcc;return function(_0x2b1145){if(_0x2b1145){return _0x5e46a6[_0xf263('0x18')](_0x2fc9f0);}return _0x5e46a6[_0xf263('0x19')](_0x2fc9f0)[_0xf263('0x1a')]();};}function respondWithResult(_0xc6a733,_0xc75366){_0xc75366=_0xc75366||0xc8;return function(_0x559c6c){if(_0x559c6c){return _0xc6a733[_0xf263('0x19')](_0xc75366)['json'](_0x559c6c);}};}function respondWithFilteredResult(_0x2a79aa,_0x27b16a){return function(_0x3ac432){if(_0x3ac432){var _0x402739=_0x3ac432['count'],_0x16b4dd=_0x27b16a['offset'],_0xf45ebe=_0x27b16a[_0xf263('0x1b')]+_0x27b16a[_0xf263('0x1c')],_0x506789;if(_0xf45ebe>=_0x402739){_0xf45ebe=_0x402739;_0x506789=0xc8;}else{_0x506789=0xce;}_0x2a79aa[_0xf263('0x19')](_0x506789);return _0x2a79aa[_0xf263('0x1d')](_0xf263('0x1e'),_0x16b4dd+'-'+_0xf45ebe+'/'+_0x402739)['json'](_0x3ac432);}return null;};}function patchUpdates(_0x1adb66){return function(_0x523061){try{jsonpatch[_0xf263('0x1f')](_0x523061,_0x1adb66,!![]);}catch(_0x22e399){return BPromise[_0xf263('0x20')](_0x22e399);}return _0x523061['save']();};}function saveUpdates(_0x4c44ea,_0x169328){return function(_0x127135){if(_0x127135){return _0x127135['update'](_0x4c44ea)[_0xf263('0x21')](function(_0x4202d1){return _0x4202d1;});}return null;};}function removeEntity(_0x431c10,_0x426667){return function(_0xa0695){if(_0xa0695){return _0xa0695[_0xf263('0x22')]()[_0xf263('0x21')](function(){_0x431c10[_0xf263('0x19')](0xcc)[_0xf263('0x1a')]();});}};}function handleEntityNotFound(_0xe32b07,_0x29eb45){return function(_0x4de045){if(!_0x4de045){_0xe32b07['sendStatus'](0x194);}return _0x4de045;};}function handleError(_0x5dc48f,_0x2de7aa){_0x2de7aa=_0x2de7aa||0x1f4;return function(_0x4175a6){logger[_0xf263('0x23')](_0x4175a6[_0xf263('0x24')]);if(_0x4175a6[_0xf263('0x25')]){delete _0x4175a6[_0xf263('0x25')];}_0x5dc48f[_0xf263('0x19')](_0x2de7aa)[_0xf263('0x26')](_0x4175a6);};}exports[_0xf263('0x27')]=function(_0xbeabe5,_0x2411a2){var _0x5e9ba3={},_0x2046d9={},_0x4ea2c4={'count':0x0,'rows':[]};var _0x3f74ed=_['map'](db[_0xf263('0x28')][_0xf263('0x29')],function(_0x5a11bf){return{'name':_0x5a11bf['fieldName'],'type':_0x5a11bf[_0xf263('0x2a')][_0xf263('0x2b')]};});_0x2046d9[_0xf263('0x2c')]=_[_0xf263('0x2d')](_0x3f74ed,_0xf263('0x25'));_0x2046d9[_0xf263('0x2e')]=_[_0xf263('0x2f')](_0xbeabe5[_0xf263('0x2e')]);_0x2046d9['filters']=_[_0xf263('0x30')](_0x2046d9[_0xf263('0x2c')],_0x2046d9[_0xf263('0x2e')]);_0x5e9ba3[_0xf263('0x31')]=_[_0xf263('0x30')](_0x2046d9[_0xf263('0x2c')],qs[_0xf263('0x32')](_0xbeabe5[_0xf263('0x2e')][_0xf263('0x32')]));_0x5e9ba3['attributes']=_0x5e9ba3[_0xf263('0x31')]['length']?_0x5e9ba3['attributes']:_0x2046d9[_0xf263('0x2c')];if(!_0xbeabe5[_0xf263('0x2e')]['hasOwnProperty'](_0xf263('0x33'))){_0x5e9ba3[_0xf263('0x1c')]=qs['limit'](_0xbeabe5[_0xf263('0x2e')][_0xf263('0x1c')]);_0x5e9ba3[_0xf263('0x1b')]=qs[_0xf263('0x1b')](_0xbeabe5[_0xf263('0x2e')][_0xf263('0x1b')]);}_0x5e9ba3['order']=qs[_0xf263('0x34')](_0xbeabe5[_0xf263('0x2e')]['sort']);_0x5e9ba3['where']=qs[_0xf263('0x35')](_[_0xf263('0x36')](_0xbeabe5[_0xf263('0x2e')],_0x2046d9[_0xf263('0x35')]));if(_0xbeabe5['query'][_0xf263('0x37')]){_0x5e9ba3[_0xf263('0x38')]=_[_0xf263('0x39')](_0x5e9ba3[_0xf263('0x38')],{'$or':_[_0xf263('0x2d')](_0x3f74ed,function(_0x49c9a1){if(_0x49c9a1[_0xf263('0x2a')]!==_0xf263('0x3a')){var _0x1600f8={};_0x1600f8[_0x49c9a1['name']]={'$like':'%'+_0xbeabe5[_0xf263('0x2e')][_0xf263('0x37')]+'%'};return _0x1600f8;}})});}_0x5e9ba3=_[_0xf263('0x39')]({},_0x5e9ba3,_0xbeabe5[_0xf263('0x3b')]);var _0x3bbe13={'where':_0x5e9ba3['where']};return db[_0xf263('0x28')][_0xf263('0x3c')](_0x3bbe13)[_0xf263('0x21')](function(_0x53f785){_0x4ea2c4[_0xf263('0x3c')]=_0x53f785;if(_0xbeabe5[_0xf263('0x2e')][_0xf263('0x3d')]){_0x5e9ba3['include']=[{'all':!![]}];}return db[_0xf263('0x28')]['findAll'](_0x5e9ba3);})[_0xf263('0x21')](function(_0x2861ba){_0x4ea2c4[_0xf263('0x3e')]=_0x2861ba;return _0x4ea2c4;})['then'](respondWithFilteredResult(_0x2411a2,_0x5e9ba3))['catch'](handleError(_0x2411a2,null));};exports['show']=function(_0x223c4e,_0x594bf3){var _0x56303f={'raw':!![],'where':{'id':_0x223c4e[_0xf263('0x3f')]['id']}},_0x5e33ba={};_0x5e33ba[_0xf263('0x2c')]=_[_0xf263('0x2f')](db[_0xf263('0x28')][_0xf263('0x29')]);_0x5e33ba['query']=_[_0xf263('0x2f')](_0x223c4e[_0xf263('0x2e')]);_0x5e33ba[_0xf263('0x35')]=_[_0xf263('0x30')](_0x5e33ba[_0xf263('0x2c')],_0x5e33ba['query']);_0x56303f[_0xf263('0x31')]=_[_0xf263('0x30')](_0x5e33ba[_0xf263('0x2c')],qs['fields'](_0x223c4e['query'][_0xf263('0x32')]));_0x56303f['attributes']=_0x56303f['attributes'][_0xf263('0x40')]?_0x56303f[_0xf263('0x31')]:_0x5e33ba[_0xf263('0x2c')];if(_0x223c4e['query'][_0xf263('0x3d')]){_0x56303f[_0xf263('0x41')]=[{'all':!![]}];}_0x56303f=_['merge']({},_0x56303f,_0x223c4e[_0xf263('0x3b')]);return db[_0xf263('0x28')]['find'](_0x56303f)[_0xf263('0x21')](handleEntityNotFound(_0x594bf3,null))[_0xf263('0x21')](respondWithResult(_0x594bf3,null))['catch'](handleError(_0x594bf3,null));};exports[_0xf263('0x42')]=function(_0xac51d,_0x2d7a2b){return db[_0xf263('0x28')][_0xf263('0x42')](_0xac51d[_0xf263('0x43')],{})[_0xf263('0x21')](respondWithResult(_0x2d7a2b,0xc9))['catch'](handleError(_0x2d7a2b,null));};exports[_0xf263('0x44')]=function(_0x2e8cbe,_0x19e09c){if(_0x2e8cbe[_0xf263('0x43')]['id']){delete _0x2e8cbe[_0xf263('0x43')]['id'];}return db[_0xf263('0x28')][_0xf263('0x45')]({'where':{'id':_0x2e8cbe[_0xf263('0x3f')]['id']}})['then'](handleEntityNotFound(_0x19e09c,null))[_0xf263('0x21')](saveUpdates(_0x2e8cbe[_0xf263('0x43')],null))[_0xf263('0x21')](respondWithResult(_0x19e09c,null))[_0xf263('0x46')](handleError(_0x19e09c,null));};exports['destroy']=function(_0x13e2c7,_0x4a3f83){return db[_0xf263('0x28')][_0xf263('0x45')]({'where':{'id':_0x13e2c7[_0xf263('0x3f')]['id']}})['then'](handleEntityNotFound(_0x4a3f83,null))['then'](removeEntity(_0x4a3f83,null))['catch'](handleError(_0x4a3f83,null));};
\ No newline at end of file
+var _0x628b=['../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','json','apply','reject','save','then','destroy','error','stack','name','send','index','map','FreshsalesField','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','length','find','catch','create','body','update','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','../../components/auth/service'];(function(_0x2113fa,_0x4694a7){var _0x588c4a=function(_0x267f0f){while(--_0x267f0f){_0x2113fa['push'](_0x2113fa['shift']());}};_0x588c4a(++_0x4694a7);}(_0x628b,0x8c));var _0xb628=function(_0x224a72,_0x207894){_0x224a72=_0x224a72-0x0;var _0x2d185a=_0x628b[_0x224a72];return _0x2d185a;};'use strict';var emlformat=require(_0xb628('0x0'));var rimraf=require(_0xb628('0x1'));var zipdir=require(_0xb628('0x2'));var jsonpatch=require(_0xb628('0x3'));var rp=require(_0xb628('0x4'));var moment=require(_0xb628('0x5'));var BPromise=require(_0xb628('0x6'));var Mustache=require(_0xb628('0x7'));var util=require(_0xb628('0x8'));var path=require(_0xb628('0x9'));var sox=require(_0xb628('0xa'));var csv=require(_0xb628('0xb'));var ejs=require(_0xb628('0xc'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xb628('0xd'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xb628('0xe'));var deskjs=require(_0xb628('0xf'));var toCsv=require(_0xb628('0xb'));var querystring=require(_0xb628('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xb628('0x11'));var qs=require(_0xb628('0x12'));var as=require(_0xb628('0x13'));var hardwareService=require(_0xb628('0x14'));var logger=require(_0xb628('0x15'))(_0xb628('0x16'));var utils=require(_0xb628('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2a337f,_0x43a886){_0x43a886=_0x43a886||0xcc;return function(_0x40161e){if(_0x40161e){return _0x2a337f[_0xb628('0x18')](_0x43a886);}return _0x2a337f[_0xb628('0x19')](_0x43a886)[_0xb628('0x1a')]();};}function respondWithResult(_0x4161b1,_0x1e8837){_0x1e8837=_0x1e8837||0xc8;return function(_0x15bac5){if(_0x15bac5){return _0x4161b1[_0xb628('0x19')](_0x1e8837)['json'](_0x15bac5);}};}function respondWithFilteredResult(_0x12c6ac,_0x4b4903){return function(_0x2d9746){if(_0x2d9746){var _0x56bf6a=typeof _0x4b4903['offset']===_0xb628('0x1b')&&typeof _0x4b4903[_0xb628('0x1c')]===_0xb628('0x1b');var _0x3455c1=_0x2d9746[_0xb628('0x1d')];var _0x3f0c98=_0x56bf6a?0x0:_0x4b4903[_0xb628('0x1e')];var _0x591092=_0x56bf6a?_0x2d9746['count']:_0x4b4903[_0xb628('0x1e')]+_0x4b4903['limit'];var _0xef16f9;if(_0x591092>=_0x3455c1){_0x591092=_0x3455c1;_0xef16f9=0xc8;}else{_0xef16f9=0xce;}_0x12c6ac[_0xb628('0x19')](_0xef16f9);return _0x12c6ac[_0xb628('0x1f')](_0xb628('0x20'),_0x3f0c98+'-'+_0x591092+'/'+_0x3455c1)[_0xb628('0x21')](_0x2d9746);}return null;};}function patchUpdates(_0x376878){return function(_0x1ce5ae){try{jsonpatch[_0xb628('0x22')](_0x1ce5ae,_0x376878,!![]);}catch(_0x468fd5){return BPromise[_0xb628('0x23')](_0x468fd5);}return _0x1ce5ae[_0xb628('0x24')]();};}function saveUpdates(_0x902e59,_0x1b7c6f){return function(_0x2c144f){if(_0x2c144f){return _0x2c144f['update'](_0x902e59)[_0xb628('0x25')](function(_0x3a5bb0){return _0x3a5bb0;});}return null;};}function removeEntity(_0x51e37a,_0x4f76b8){return function(_0x17f401){if(_0x17f401){return _0x17f401[_0xb628('0x26')]()['then'](function(){_0x51e37a['status'](0xcc)[_0xb628('0x1a')]();});}};}function handleEntityNotFound(_0x22341d,_0x32f7b9){return function(_0x44737e){if(!_0x44737e){_0x22341d['sendStatus'](0x194);}return _0x44737e;};}function handleError(_0x5629ed,_0x265504){_0x265504=_0x265504||0x1f4;return function(_0x2560ce){logger[_0xb628('0x27')](_0x2560ce[_0xb628('0x28')]);if(_0x2560ce[_0xb628('0x29')]){delete _0x2560ce[_0xb628('0x29')];}_0x5629ed[_0xb628('0x19')](_0x265504)[_0xb628('0x2a')](_0x2560ce);};}exports[_0xb628('0x2b')]=function(_0xf9a449,_0x495d8e){var _0x5822f2={},_0x25117f={},_0x484253={'count':0x0,'rows':[]};var _0x2cdfee=_[_0xb628('0x2c')](db[_0xb628('0x2d')][_0xb628('0x2e')],function(_0x208232){return{'name':_0x208232[_0xb628('0x2f')],'type':_0x208232[_0xb628('0x30')][_0xb628('0x31')]};});_0x25117f[_0xb628('0x32')]=_['map'](_0x2cdfee,_0xb628('0x29'));_0x25117f[_0xb628('0x33')]=_[_0xb628('0x34')](_0xf9a449[_0xb628('0x33')]);_0x25117f[_0xb628('0x35')]=_[_0xb628('0x36')](_0x25117f[_0xb628('0x32')],_0x25117f[_0xb628('0x33')]);_0x5822f2['attributes']=_[_0xb628('0x36')](_0x25117f[_0xb628('0x32')],qs[_0xb628('0x37')](_0xf9a449['query'][_0xb628('0x37')]));_0x5822f2[_0xb628('0x38')]=_0x5822f2[_0xb628('0x38')]['length']?_0x5822f2['attributes']:_0x25117f[_0xb628('0x32')];if(!_0xf9a449['query'][_0xb628('0x39')](_0xb628('0x3a'))){_0x5822f2[_0xb628('0x1c')]=qs[_0xb628('0x1c')](_0xf9a449[_0xb628('0x33')]['limit']);_0x5822f2[_0xb628('0x1e')]=qs[_0xb628('0x1e')](_0xf9a449['query']['offset']);}_0x5822f2[_0xb628('0x3b')]=qs[_0xb628('0x3c')](_0xf9a449[_0xb628('0x33')][_0xb628('0x3c')]);_0x5822f2[_0xb628('0x3d')]=qs['filters'](_[_0xb628('0x3e')](_0xf9a449[_0xb628('0x33')],_0x25117f[_0xb628('0x35')]),_0x2cdfee);if(_0xf9a449[_0xb628('0x33')][_0xb628('0x3f')]){_0x5822f2['where']=_[_0xb628('0x40')](_0x5822f2[_0xb628('0x3d')],{'$or':_[_0xb628('0x2c')](_0x2cdfee,function(_0x2efc33){if(_0x2efc33['type']!==_0xb628('0x41')){var _0x313c74={};_0x313c74[_0x2efc33[_0xb628('0x29')]]={'$like':'%'+_0xf9a449[_0xb628('0x33')][_0xb628('0x3f')]+'%'};return _0x313c74;}})});}_0x5822f2=_[_0xb628('0x40')]({},_0x5822f2,_0xf9a449[_0xb628('0x42')]);var _0xb3094b={'where':_0x5822f2[_0xb628('0x3d')]};return db[_0xb628('0x2d')][_0xb628('0x1d')](_0xb3094b)[_0xb628('0x25')](function(_0x1f2a85){_0x484253[_0xb628('0x1d')]=_0x1f2a85;if(_0xf9a449[_0xb628('0x33')][_0xb628('0x43')]){_0x5822f2[_0xb628('0x44')]=[{'all':!![]}];}return db[_0xb628('0x2d')][_0xb628('0x45')](_0x5822f2);})[_0xb628('0x25')](function(_0x5a9a4c){_0x484253[_0xb628('0x46')]=_0x5a9a4c;return _0x484253;})[_0xb628('0x25')](respondWithFilteredResult(_0x495d8e,_0x5822f2))['catch'](handleError(_0x495d8e,null));};exports[_0xb628('0x47')]=function(_0x45d872,_0x3da5fc){var _0x5c414d={'raw':!![],'where':{'id':_0x45d872[_0xb628('0x48')]['id']}},_0xc68f84={};_0xc68f84[_0xb628('0x32')]=_[_0xb628('0x34')](db[_0xb628('0x2d')][_0xb628('0x2e')]);_0xc68f84[_0xb628('0x33')]=_[_0xb628('0x34')](_0x45d872[_0xb628('0x33')]);_0xc68f84[_0xb628('0x35')]=_[_0xb628('0x36')](_0xc68f84[_0xb628('0x32')],_0xc68f84[_0xb628('0x33')]);_0x5c414d[_0xb628('0x38')]=_[_0xb628('0x36')](_0xc68f84[_0xb628('0x32')],qs[_0xb628('0x37')](_0x45d872[_0xb628('0x33')][_0xb628('0x37')]));_0x5c414d[_0xb628('0x38')]=_0x5c414d[_0xb628('0x38')][_0xb628('0x49')]?_0x5c414d[_0xb628('0x38')]:_0xc68f84[_0xb628('0x32')];if(_0x45d872[_0xb628('0x33')][_0xb628('0x43')]){_0x5c414d[_0xb628('0x44')]=[{'all':!![]}];}_0x5c414d=_['merge']({},_0x5c414d,_0x45d872['options']);return db[_0xb628('0x2d')][_0xb628('0x4a')](_0x5c414d)['then'](handleEntityNotFound(_0x3da5fc,null))[_0xb628('0x25')](respondWithResult(_0x3da5fc,null))[_0xb628('0x4b')](handleError(_0x3da5fc,null));};exports[_0xb628('0x4c')]=function(_0x56e96f,_0x3b3c65){return db[_0xb628('0x2d')]['create'](_0x56e96f[_0xb628('0x4d')],{})[_0xb628('0x25')](respondWithResult(_0x3b3c65,0xc9))['catch'](handleError(_0x3b3c65,null));};exports[_0xb628('0x4e')]=function(_0x36c42b,_0x390428){if(_0x36c42b[_0xb628('0x4d')]['id']){delete _0x36c42b[_0xb628('0x4d')]['id'];}return db[_0xb628('0x2d')][_0xb628('0x4a')]({'where':{'id':_0x36c42b[_0xb628('0x48')]['id']}})[_0xb628('0x25')](handleEntityNotFound(_0x390428,null))[_0xb628('0x25')](saveUpdates(_0x36c42b[_0xb628('0x4d')],null))[_0xb628('0x25')](respondWithResult(_0x390428,null))[_0xb628('0x4b')](handleError(_0x390428,null));};exports['destroy']=function(_0x735839,_0x44e0cc){return db['FreshsalesField'][_0xb628('0x4a')]({'where':{'id':_0x735839['params']['id']}})[_0xb628('0x25')](handleEntityNotFound(_0x44e0cc,null))[_0xb628('0x25')](removeEntity(_0x44e0cc,null))['catch'](handleError(_0x44e0cc,null));};
\ No newline at end of file