Built motion from commit 5ba5b610.|2.5.33
[motion2.git] / server / api / squareReport / squareReport.controller.js
index 735dc8a..926feb1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf655=['rawAttributes','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','limit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','findAll','rows','catch','params','keys','SquareReport','find','create','body','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','sox','ejs','fs-extra','squel','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','sendStatus','status','end','undefined','count','offset','Content-Range','json','apply','save','update','then','destroy','name','send','index','map'];(function(_0x497a5c,_0x308f8d){var _0x3cda24=function(_0x3eda44){while(--_0x3eda44){_0x497a5c['push'](_0x497a5c['shift']());}};_0x3cda24(++_0x308f8d);}(_0xf655,0x137));var _0x5f65=function(_0x5510f5,_0xfd5f3c){_0x5510f5=_0x5510f5-0x0;var _0x5cabb2=_0xf655[_0x5510f5];return _0x5cabb2;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5f65('0x0'));var zipdir=require(_0x5f65('0x1'));var jsonpatch=require(_0x5f65('0x2'));var rp=require(_0x5f65('0x3'));var moment=require(_0x5f65('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x5f65('0x5'));var path=require('path');var sox=require(_0x5f65('0x6'));var csv=require('to-csv');var ejs=require(_0x5f65('0x7'));var fs=require('fs');var fs_extra=require(_0x5f65('0x8'));var _=require('lodash');var squel=require(_0x5f65('0x9'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x5f65('0xa'));var toCsv=require(_0x5f65('0xb'));var querystring=require(_0x5f65('0xc'));var Papa=require(_0x5f65('0xd'));var Redis=require(_0x5f65('0xe'));var authService=require(_0x5f65('0xf'));var qs=require(_0x5f65('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x5f65('0x11'));var logger=require(_0x5f65('0x12'))(_0x5f65('0x13'));var utils=require(_0x5f65('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x5f65('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x3d39d2,_0x68afd1){_0x68afd1=_0x68afd1||0xcc;return function(_0x221587){if(_0x221587){return _0x3d39d2[_0x5f65('0x16')](_0x68afd1);}return _0x3d39d2[_0x5f65('0x17')](_0x68afd1)[_0x5f65('0x18')]();};}function respondWithResult(_0x52696a,_0x758467){_0x758467=_0x758467||0xc8;return function(_0x2752a3){if(_0x2752a3){return _0x52696a[_0x5f65('0x17')](_0x758467)['json'](_0x2752a3);}};}function respondWithFilteredResult(_0x3ba976,_0x581efa){return function(_0x1bdbe7){if(_0x1bdbe7){var _0x24d77a=typeof _0x581efa['offset']===_0x5f65('0x19')&&typeof _0x581efa['limit']===_0x5f65('0x19');var _0x39ec3d=_0x1bdbe7['count'];var _0x13b9b5=_0x24d77a?0x0:_0x581efa['offset'];var _0x552592=_0x24d77a?_0x1bdbe7[_0x5f65('0x1a')]:_0x581efa[_0x5f65('0x1b')]+_0x581efa['limit'];var _0x8ffed;if(_0x552592>=_0x39ec3d){_0x552592=_0x39ec3d;_0x8ffed=0xc8;}else{_0x8ffed=0xce;}_0x3ba976[_0x5f65('0x17')](_0x8ffed);return _0x3ba976['set'](_0x5f65('0x1c'),_0x13b9b5+'-'+_0x552592+'/'+_0x39ec3d)[_0x5f65('0x1d')](_0x1bdbe7);}return null;};}function patchUpdates(_0x1fb3f4){return function(_0x42ff17){try{jsonpatch[_0x5f65('0x1e')](_0x42ff17,_0x1fb3f4,!![]);}catch(_0x51900f){return BPromise['reject'](_0x51900f);}return _0x42ff17[_0x5f65('0x1f')]();};}function saveUpdates(_0x409287,_0x4584bc){return function(_0x337740){if(_0x337740){return _0x337740[_0x5f65('0x20')](_0x409287)[_0x5f65('0x21')](function(_0x21e3b9){return _0x21e3b9;});}return null;};}function removeEntity(_0x434ad3,_0x46bd0a){return function(_0x405024){if(_0x405024){return _0x405024[_0x5f65('0x22')]()[_0x5f65('0x21')](function(){_0x434ad3[_0x5f65('0x17')](0xcc)[_0x5f65('0x18')]();});}};}function handleEntityNotFound(_0x3eccc7,_0x450b9f){return function(_0x3a3689){if(!_0x3a3689){_0x3eccc7['sendStatus'](0x194);}return _0x3a3689;};}function handleError(_0x1adbea,_0x24e947){_0x24e947=_0x24e947||0x1f4;return function(_0x434f7e){logger['error'](_0x434f7e['stack']);if(_0x434f7e[_0x5f65('0x23')]){delete _0x434f7e[_0x5f65('0x23')];}_0x1adbea['status'](_0x24e947)[_0x5f65('0x24')](_0x434f7e);};}exports[_0x5f65('0x25')]=function(_0x121347,_0x573ddb){var _0x2f3c43={},_0x350fc8={},_0x52ed7a={'count':0x0,'rows':[]};var _0x3eb65f=_[_0x5f65('0x26')](db['SquareReport'][_0x5f65('0x27')],function(_0x2f7866){return{'name':_0x2f7866['fieldName'],'type':_0x2f7866[_0x5f65('0x28')][_0x5f65('0x29')]};});_0x350fc8[_0x5f65('0x2a')]=_[_0x5f65('0x26')](_0x3eb65f,'name');_0x350fc8[_0x5f65('0x2b')]=_['keys'](_0x121347[_0x5f65('0x2b')]);_0x350fc8[_0x5f65('0x2c')]=_[_0x5f65('0x2d')](_0x350fc8[_0x5f65('0x2a')],_0x350fc8['query']);_0x2f3c43[_0x5f65('0x2e')]=_[_0x5f65('0x2d')](_0x350fc8[_0x5f65('0x2a')],qs['fields'](_0x121347[_0x5f65('0x2b')][_0x5f65('0x2f')]));_0x2f3c43['attributes']=_0x2f3c43[_0x5f65('0x2e')][_0x5f65('0x30')]?_0x2f3c43['attributes']:_0x350fc8[_0x5f65('0x2a')];if(!_0x121347[_0x5f65('0x2b')][_0x5f65('0x31')]('nolimit')){_0x2f3c43[_0x5f65('0x32')]=qs['limit'](_0x121347[_0x5f65('0x2b')][_0x5f65('0x32')]);_0x2f3c43[_0x5f65('0x1b')]=qs['offset'](_0x121347['query'][_0x5f65('0x1b')]);}_0x2f3c43[_0x5f65('0x33')]=qs[_0x5f65('0x34')](_0x121347[_0x5f65('0x2b')]['sort']);_0x2f3c43[_0x5f65('0x35')]=qs[_0x5f65('0x2c')](_[_0x5f65('0x36')](_0x121347[_0x5f65('0x2b')],_0x350fc8['filters']),_0x3eb65f);if(_0x121347[_0x5f65('0x2b')][_0x5f65('0x37')]){_0x2f3c43[_0x5f65('0x35')]=_['merge'](_0x2f3c43[_0x5f65('0x35')],{'$or':_[_0x5f65('0x26')](_0x3eb65f,function(_0x53596f){if(_0x53596f[_0x5f65('0x28')]!==_0x5f65('0x38')){var _0x246304={};_0x246304[_0x53596f[_0x5f65('0x23')]]={'$like':'%'+_0x121347[_0x5f65('0x2b')][_0x5f65('0x37')]+'%'};return _0x246304;}})});}_0x2f3c43=_[_0x5f65('0x39')]({},_0x2f3c43,_0x121347[_0x5f65('0x3a')]);var _0x3bb3ea={'where':_0x2f3c43['where']};return db['SquareReport'][_0x5f65('0x1a')](_0x3bb3ea)[_0x5f65('0x21')](function(_0x434eba){_0x52ed7a[_0x5f65('0x1a')]=_0x434eba;if(_0x121347[_0x5f65('0x2b')][_0x5f65('0x3b')]){_0x2f3c43['include']=[{'all':!![]}];}return db['SquareReport'][_0x5f65('0x3c')](_0x2f3c43);})['then'](function(_0x4298b8){_0x52ed7a[_0x5f65('0x3d')]=_0x4298b8;return _0x52ed7a;})[_0x5f65('0x21')](respondWithFilteredResult(_0x573ddb,_0x2f3c43))[_0x5f65('0x3e')](handleError(_0x573ddb,null));};exports['show']=function(_0x42a32b,_0x45c87b){var _0x439728={'raw':!![],'where':{'id':_0x42a32b[_0x5f65('0x3f')]['id']}},_0x1565f3={};_0x1565f3['model']=_[_0x5f65('0x40')](db[_0x5f65('0x41')]['rawAttributes']);_0x1565f3['query']=_[_0x5f65('0x40')](_0x42a32b[_0x5f65('0x2b')]);_0x1565f3['filters']=_['intersection'](_0x1565f3[_0x5f65('0x2a')],_0x1565f3[_0x5f65('0x2b')]);_0x439728[_0x5f65('0x2e')]=_[_0x5f65('0x2d')](_0x1565f3[_0x5f65('0x2a')],qs[_0x5f65('0x2f')](_0x42a32b[_0x5f65('0x2b')][_0x5f65('0x2f')]));_0x439728['attributes']=_0x439728[_0x5f65('0x2e')][_0x5f65('0x30')]?_0x439728[_0x5f65('0x2e')]:_0x1565f3[_0x5f65('0x2a')];if(_0x42a32b[_0x5f65('0x2b')]['includeAll']){_0x439728['include']=[{'all':!![]}];}_0x439728=_[_0x5f65('0x39')]({},_0x439728,_0x42a32b[_0x5f65('0x3a')]);return db[_0x5f65('0x41')][_0x5f65('0x42')](_0x439728)[_0x5f65('0x21')](handleEntityNotFound(_0x45c87b,null))[_0x5f65('0x21')](respondWithResult(_0x45c87b,null))[_0x5f65('0x3e')](handleError(_0x45c87b,null));};exports['create']=function(_0x23b75d,_0x4405ca){return db[_0x5f65('0x41')][_0x5f65('0x43')](_0x23b75d[_0x5f65('0x44')],{})['then'](respondWithResult(_0x4405ca,0xc9))[_0x5f65('0x3e')](handleError(_0x4405ca,null));};exports[_0x5f65('0x20')]=function(_0x365ea9,_0xa4a07b){if(_0x365ea9[_0x5f65('0x44')]['id']){delete _0x365ea9[_0x5f65('0x44')]['id'];}return db['SquareReport'][_0x5f65('0x42')]({'where':{'id':_0x365ea9[_0x5f65('0x3f')]['id']}})[_0x5f65('0x21')](handleEntityNotFound(_0xa4a07b,null))[_0x5f65('0x21')](saveUpdates(_0x365ea9['body'],null))[_0x5f65('0x21')](respondWithResult(_0xa4a07b,null))[_0x5f65('0x3e')](handleError(_0xa4a07b,null));};exports['destroy']=function(_0x4cb555,_0x5f2151){return db[_0x5f65('0x41')][_0x5f65('0x42')]({'where':{'id':_0x4cb555[_0x5f65('0x3f')]['id']}})[_0x5f65('0x21')](handleEntityNotFound(_0x5f2151,null))[_0x5f65('0x21')](removeEntity(_0x5f2151,null))[_0x5f65('0x3e')](handleError(_0x5f2151,null));};exports[_0x5f65('0x45')]=function(_0x30f6e,_0x7de102){return db[_0x5f65('0x41')][_0x5f65('0x45')]()[_0x5f65('0x21')](respondWithResult(_0x7de102,null))[_0x5f65('0x3e')](handleError(_0x7de102,null));};
\ No newline at end of file
+var _0x31f0=['find','create','body','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','end','json','limit','undefined','count','offset','set','reject','save','update','then','destroy','error','name','send','index','SquareReport','rawAttributes','fieldName','type','key','model','map','keys','query','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','options','includeAll','include','findAll','catch','show','params'];(function(_0x167692,_0x1a9403){var _0x12501a=function(_0x398a8e){while(--_0x398a8e){_0x167692['push'](_0x167692['shift']());}};_0x12501a(++_0x1a9403);}(_0x31f0,0x166));var _0x031f=function(_0x26b2d6,_0x3fac7a){_0x26b2d6=_0x26b2d6-0x0;var _0x546a81=_0x31f0[_0x26b2d6];return _0x546a81;};'use strict';var emlformat=require(_0x031f('0x0'));var rimraf=require(_0x031f('0x1'));var zipdir=require(_0x031f('0x2'));var jsonpatch=require(_0x031f('0x3'));var rp=require('request-promise');var moment=require(_0x031f('0x4'));var BPromise=require(_0x031f('0x5'));var Mustache=require(_0x031f('0x6'));var util=require('util');var path=require(_0x031f('0x7'));var sox=require('sox');var csv=require(_0x031f('0x8'));var ejs=require(_0x031f('0x9'));var fs=require('fs');var fs_extra=require(_0x031f('0xa'));var _=require(_0x031f('0xb'));var squel=require(_0x031f('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x031f('0xd'));var toCsv=require('to-csv');var querystring=require(_0x031f('0xe'));var Papa=require('papaparse');var Redis=require(_0x031f('0xf'));var authService=require(_0x031f('0x10'));var qs=require(_0x031f('0x11'));var as=require(_0x031f('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x031f('0x13'))(_0x031f('0x14'));var utils=require(_0x031f('0x15'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x031f('0x16'))['db'];function respondWithStatusCode(_0x5025c7,_0x36b378){_0x36b378=_0x36b378||0xcc;return function(_0x412951){if(_0x412951){return _0x5025c7[_0x031f('0x17')](_0x36b378);}return _0x5025c7[_0x031f('0x18')](_0x36b378)[_0x031f('0x19')]();};}function respondWithResult(_0x25b03a,_0x57f470){_0x57f470=_0x57f470||0xc8;return function(_0x21a6aa){if(_0x21a6aa){return _0x25b03a[_0x031f('0x18')](_0x57f470)[_0x031f('0x1a')](_0x21a6aa);}};}function respondWithFilteredResult(_0x2d3b16,_0x1dc599){return function(_0x5222b1){if(_0x5222b1){var _0x84f8e2=typeof _0x1dc599['offset']==='undefined'&&typeof _0x1dc599[_0x031f('0x1b')]===_0x031f('0x1c');var _0x3eb9b1=_0x5222b1[_0x031f('0x1d')];var _0x334e9b=_0x84f8e2?0x0:_0x1dc599['offset'];var _0x193d81=_0x84f8e2?_0x5222b1[_0x031f('0x1d')]:_0x1dc599[_0x031f('0x1e')]+_0x1dc599[_0x031f('0x1b')];var _0x4382ab;if(_0x193d81>=_0x3eb9b1){_0x193d81=_0x3eb9b1;_0x4382ab=0xc8;}else{_0x4382ab=0xce;}_0x2d3b16[_0x031f('0x18')](_0x4382ab);return _0x2d3b16[_0x031f('0x1f')]('Content-Range',_0x334e9b+'-'+_0x193d81+'/'+_0x3eb9b1)[_0x031f('0x1a')](_0x5222b1);}return null;};}function patchUpdates(_0x392633){return function(_0x41ebf0){try{jsonpatch['apply'](_0x41ebf0,_0x392633,!![]);}catch(_0x45f22f){return BPromise[_0x031f('0x20')](_0x45f22f);}return _0x41ebf0[_0x031f('0x21')]();};}function saveUpdates(_0x3a6c15,_0x54271a){return function(_0x48c58f){if(_0x48c58f){return _0x48c58f[_0x031f('0x22')](_0x3a6c15)[_0x031f('0x23')](function(_0x5db569){return _0x5db569;});}return null;};}function removeEntity(_0x1fa476,_0x31fddd){return function(_0x16b553){if(_0x16b553){return _0x16b553[_0x031f('0x24')]()[_0x031f('0x23')](function(){_0x1fa476[_0x031f('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x11754f,_0x5200c3){return function(_0x53fc6f){if(!_0x53fc6f){_0x11754f[_0x031f('0x17')](0x194);}return _0x53fc6f;};}function handleError(_0x3cd95e,_0x415d16){_0x415d16=_0x415d16||0x1f4;return function(_0x57eae2){logger[_0x031f('0x25')](_0x57eae2['stack']);if(_0x57eae2[_0x031f('0x26')]){delete _0x57eae2[_0x031f('0x26')];}_0x3cd95e[_0x031f('0x18')](_0x415d16)[_0x031f('0x27')](_0x57eae2);};}exports[_0x031f('0x28')]=function(_0x521777,_0x413d35){var _0x252070={},_0x1649d3={},_0x1de6d5={'count':0x0,'rows':[]};var _0x5b48c1=_['map'](db[_0x031f('0x29')][_0x031f('0x2a')],function(_0x7998e8){return{'name':_0x7998e8[_0x031f('0x2b')],'type':_0x7998e8[_0x031f('0x2c')][_0x031f('0x2d')]};});_0x1649d3[_0x031f('0x2e')]=_[_0x031f('0x2f')](_0x5b48c1,_0x031f('0x26'));_0x1649d3['query']=_[_0x031f('0x30')](_0x521777[_0x031f('0x31')]);_0x1649d3['filters']=_[_0x031f('0x32')](_0x1649d3['model'],_0x1649d3['query']);_0x252070[_0x031f('0x33')]=_['intersection'](_0x1649d3[_0x031f('0x2e')],qs[_0x031f('0x34')](_0x521777[_0x031f('0x31')][_0x031f('0x34')]));_0x252070['attributes']=_0x252070[_0x031f('0x33')]['length']?_0x252070[_0x031f('0x33')]:_0x1649d3[_0x031f('0x2e')];if(!_0x521777[_0x031f('0x31')][_0x031f('0x35')](_0x031f('0x36'))){_0x252070[_0x031f('0x1b')]=qs['limit'](_0x521777['query'][_0x031f('0x1b')]);_0x252070[_0x031f('0x1e')]=qs['offset'](_0x521777[_0x031f('0x31')][_0x031f('0x1e')]);}_0x252070[_0x031f('0x37')]=qs[_0x031f('0x38')](_0x521777[_0x031f('0x31')][_0x031f('0x38')]);_0x252070[_0x031f('0x39')]=qs[_0x031f('0x3a')](_['pick'](_0x521777[_0x031f('0x31')],_0x1649d3[_0x031f('0x3a')]),_0x5b48c1);if(_0x521777[_0x031f('0x31')][_0x031f('0x3b')]){_0x252070[_0x031f('0x39')]=_[_0x031f('0x3c')](_0x252070['where'],{'$or':_[_0x031f('0x2f')](_0x5b48c1,function(_0x1bd65d){if(_0x1bd65d[_0x031f('0x2c')]!=='VIRTUAL'){var _0x43ced6={};_0x43ced6[_0x1bd65d[_0x031f('0x26')]]={'$like':'%'+_0x521777['query'][_0x031f('0x3b')]+'%'};return _0x43ced6;}})});}_0x252070=_[_0x031f('0x3c')]({},_0x252070,_0x521777[_0x031f('0x3d')]);var _0x5dca7a={'where':_0x252070[_0x031f('0x39')]};return db['SquareReport'][_0x031f('0x1d')](_0x5dca7a)[_0x031f('0x23')](function(_0xd8ec8f){_0x1de6d5['count']=_0xd8ec8f;if(_0x521777[_0x031f('0x31')][_0x031f('0x3e')]){_0x252070[_0x031f('0x3f')]=[{'all':!![]}];}return db[_0x031f('0x29')][_0x031f('0x40')](_0x252070);})[_0x031f('0x23')](function(_0x44f2be){_0x1de6d5['rows']=_0x44f2be;return _0x1de6d5;})['then'](respondWithFilteredResult(_0x413d35,_0x252070))[_0x031f('0x41')](handleError(_0x413d35,null));};exports[_0x031f('0x42')]=function(_0x5cc76c,_0xbc7836){var _0x53d948={'raw':!![],'where':{'id':_0x5cc76c[_0x031f('0x43')]['id']}},_0x120796={};_0x120796[_0x031f('0x2e')]=_[_0x031f('0x30')](db[_0x031f('0x29')]['rawAttributes']);_0x120796['query']=_['keys'](_0x5cc76c['query']);_0x120796[_0x031f('0x3a')]=_[_0x031f('0x32')](_0x120796['model'],_0x120796['query']);_0x53d948[_0x031f('0x33')]=_[_0x031f('0x32')](_0x120796[_0x031f('0x2e')],qs[_0x031f('0x34')](_0x5cc76c[_0x031f('0x31')]['fields']));_0x53d948[_0x031f('0x33')]=_0x53d948[_0x031f('0x33')]['length']?_0x53d948[_0x031f('0x33')]:_0x120796[_0x031f('0x2e')];if(_0x5cc76c[_0x031f('0x31')][_0x031f('0x3e')]){_0x53d948['include']=[{'all':!![]}];}_0x53d948=_[_0x031f('0x3c')]({},_0x53d948,_0x5cc76c[_0x031f('0x3d')]);return db['SquareReport'][_0x031f('0x44')](_0x53d948)[_0x031f('0x23')](handleEntityNotFound(_0xbc7836,null))[_0x031f('0x23')](respondWithResult(_0xbc7836,null))['catch'](handleError(_0xbc7836,null));};exports[_0x031f('0x45')]=function(_0x348972,_0x2054aa){return db['SquareReport'][_0x031f('0x45')](_0x348972['body'],{})[_0x031f('0x23')](respondWithResult(_0x2054aa,0xc9))['catch'](handleError(_0x2054aa,null));};exports[_0x031f('0x22')]=function(_0x9ece9,_0x520018){if(_0x9ece9[_0x031f('0x46')]['id']){delete _0x9ece9[_0x031f('0x46')]['id'];}return db[_0x031f('0x29')]['find']({'where':{'id':_0x9ece9[_0x031f('0x43')]['id']}})['then'](handleEntityNotFound(_0x520018,null))[_0x031f('0x23')](saveUpdates(_0x9ece9[_0x031f('0x46')],null))[_0x031f('0x23')](respondWithResult(_0x520018,null))[_0x031f('0x41')](handleError(_0x520018,null));};exports[_0x031f('0x24')]=function(_0x5cc6fc,_0x228896){return db['SquareReport'][_0x031f('0x44')]({'where':{'id':_0x5cc6fc[_0x031f('0x43')]['id']}})[_0x031f('0x23')](handleEntityNotFound(_0x228896,null))['then'](removeEntity(_0x228896,null))[_0x031f('0x41')](handleError(_0x228896,null));};exports['describe']=function(_0x6893c3,_0x358aac){return db[_0x031f('0x29')]['describe']()['then'](respondWithResult(_0x358aac,null))[_0x031f('0x41')](handleError(_0x358aac,null));};
\ No newline at end of file