Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / squareOdbc / squareOdbc.controller.js
index 384bd9b..2774aa6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6e7d=['status','count','offset','limit','set','json','reject','save','update','then','destroy','get','ODBC','end','error','stack','name','send','SquareOdbc','fieldName','type','model','map','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','rawAttributes','length','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','catch','find','test','openSync','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus'];(function(_0x3e67c0,_0xa047a){var _0x3cbec7=function(_0x552027){while(--_0x552027){_0x3e67c0['push'](_0x3e67c0['shift']());}};_0x3cbec7(++_0xa047a);}(_0x6e7d,0x13a));var _0xd6e7=function(_0xbbcb36,_0x586383){_0xbbcb36=_0xbbcb36-0x0;var _0x4278ff=_0x6e7d[_0xbbcb36];return _0x4278ff;};'use strict';var pdf=require(_0xd6e7('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xd6e7('0x1'));var zipdir=require(_0xd6e7('0x2'));var jsonpatch=require(_0xd6e7('0x3'));var rp=require('request-promise');var moment=require(_0xd6e7('0x4'));var BPromise=require(_0xd6e7('0x5'));var Mustache=require(_0xd6e7('0x6'));var util=require(_0xd6e7('0x7'));var path=require(_0xd6e7('0x8'));var sox=require(_0xd6e7('0x9'));var csv=require(_0xd6e7('0xa'));var ejs=require(_0xd6e7('0xb'));var fs=require('fs');var _=require(_0xd6e7('0xc'));var squel=require(_0xd6e7('0xd'));var crypto=require('crypto');var jsforce=require(_0xd6e7('0xe'));var deskjs=require(_0xd6e7('0xf'));var toCsv=require(_0xd6e7('0xa'));var querystring=require(_0xd6e7('0x10'));var Papa=require('papaparse');var Redis=require(_0xd6e7('0x11'));var authService=require(_0xd6e7('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xd6e7('0x13'));var logger=require(_0xd6e7('0x14'))(_0xd6e7('0x15'));var utils=require(_0xd6e7('0x16'));var config=require(_0xd6e7('0x17'));var db=require(_0xd6e7('0x18'))['db'];function respondWithStatusCode(_0x194cec,_0xde2da3){_0xde2da3=_0xde2da3||0xcc;return function(_0x3ae464){if(_0x3ae464){return _0x194cec[_0xd6e7('0x19')](_0xde2da3);}return _0x194cec[_0xd6e7('0x1a')](_0xde2da3)['end']();};}function respondWithResult(_0x4339d8,_0x2d0923){_0x2d0923=_0x2d0923||0xc8;return function(_0x58b4ab){if(_0x58b4ab){return _0x4339d8[_0xd6e7('0x1a')](_0x2d0923)['json'](_0x58b4ab);}};}function respondWithFilteredResult(_0x52492e,_0x354977){return function(_0x1ad410){if(_0x1ad410){var _0x1e9ed0=_0x1ad410[_0xd6e7('0x1b')],_0x307349=_0x354977[_0xd6e7('0x1c')],_0x37db03=_0x354977[_0xd6e7('0x1c')]+_0x354977[_0xd6e7('0x1d')],_0x908b46;if(_0x37db03>=_0x1e9ed0){_0x37db03=_0x1e9ed0;_0x908b46=0xc8;}else{_0x908b46=0xce;}_0x52492e[_0xd6e7('0x1a')](_0x908b46);return _0x52492e[_0xd6e7('0x1e')]('Content-Range',_0x307349+'-'+_0x37db03+'/'+_0x1e9ed0)[_0xd6e7('0x1f')](_0x1ad410);}return null;};}function patchUpdates(_0x58ebb2){return function(_0xbf5c2c){try{jsonpatch['apply'](_0xbf5c2c,_0x58ebb2,!![]);}catch(_0x3fa8ed){return BPromise[_0xd6e7('0x20')](_0x3fa8ed);}return _0xbf5c2c[_0xd6e7('0x21')]();};}function saveUpdates(_0x2916f8,_0x25c5e1){return function(_0x239687){if(_0x239687){return _0x239687[_0xd6e7('0x22')](_0x2916f8)[_0xd6e7('0x23')](function(_0x57ffce){return _0x57ffce;});}return null;};}function removeEntity(_0x2bb7a0,_0x53f9e6){return function(_0x571d1c){if(_0x571d1c){return _0x571d1c[_0xd6e7('0x24')]()[_0xd6e7('0x23')](function(){var _0x2c6e88=_0x571d1c[_0xd6e7('0x25')]({'plain':!![]});var _0x4fdd82=_0xd6e7('0x26');return db['UserProfileResource'][_0xd6e7('0x24')]({'where':{'type':_0x4fdd82,'resourceId':_0x2c6e88['id']}})[_0xd6e7('0x23')](function(){return _0x571d1c;});})[_0xd6e7('0x23')](function(){_0x2bb7a0[_0xd6e7('0x1a')](0xcc)[_0xd6e7('0x27')]();});}};}function handleEntityNotFound(_0x59a1e6,_0xbe87eb){return function(_0x2e069e){if(!_0x2e069e){_0x59a1e6['sendStatus'](0x194);}return _0x2e069e;};}function handleError(_0x41c0a5,_0x60d391){_0x60d391=_0x60d391||0x1f4;return function(_0x39b793){logger[_0xd6e7('0x28')](_0x39b793[_0xd6e7('0x29')]);if(_0x39b793[_0xd6e7('0x2a')]){delete _0x39b793[_0xd6e7('0x2a')];}_0x41c0a5[_0xd6e7('0x1a')](_0x60d391)[_0xd6e7('0x2b')](_0x39b793);};}exports['index']=function(_0xfd1539,_0x14aa76){var _0x524120={},_0x4d1c41={},_0x3b2435={'count':0x0,'rows':[]};var _0x4ce017=_['map'](db[_0xd6e7('0x2c')]['rawAttributes'],function(_0x5b868e){return{'name':_0x5b868e[_0xd6e7('0x2d')],'type':_0x5b868e[_0xd6e7('0x2e')]['key']};});_0x4d1c41[_0xd6e7('0x2f')]=_[_0xd6e7('0x30')](_0x4ce017,_0xd6e7('0x2a'));_0x4d1c41[_0xd6e7('0x31')]=_[_0xd6e7('0x32')](_0xfd1539[_0xd6e7('0x31')]);_0x4d1c41[_0xd6e7('0x33')]=_[_0xd6e7('0x34')](_0x4d1c41[_0xd6e7('0x2f')],_0x4d1c41['query']);_0x524120[_0xd6e7('0x35')]=_['intersection'](_0x4d1c41[_0xd6e7('0x2f')],qs[_0xd6e7('0x36')](_0xfd1539['query'][_0xd6e7('0x36')]));_0x524120[_0xd6e7('0x35')]=_0x524120[_0xd6e7('0x35')]['length']?_0x524120[_0xd6e7('0x35')]:_0x4d1c41['model'];if(!_0xfd1539[_0xd6e7('0x31')][_0xd6e7('0x37')](_0xd6e7('0x38'))){_0x524120[_0xd6e7('0x1d')]=qs[_0xd6e7('0x1d')](_0xfd1539[_0xd6e7('0x31')][_0xd6e7('0x1d')]);_0x524120[_0xd6e7('0x1c')]=qs[_0xd6e7('0x1c')](_0xfd1539['query'][_0xd6e7('0x1c')]);}_0x524120[_0xd6e7('0x39')]=qs['sort'](_0xfd1539['query'][_0xd6e7('0x3a')]);_0x524120['where']=qs['filters'](_[_0xd6e7('0x3b')](_0xfd1539[_0xd6e7('0x31')],_0x4d1c41[_0xd6e7('0x33')]));if(_0xfd1539[_0xd6e7('0x31')][_0xd6e7('0x3c')]){_0x524120[_0xd6e7('0x3d')]=_[_0xd6e7('0x3e')](_0x524120[_0xd6e7('0x3d')],{'$or':_[_0xd6e7('0x30')](_0x4ce017,function(_0x1f5596){if(_0x1f5596[_0xd6e7('0x2e')]!==_0xd6e7('0x3f')){var _0x1cf24b={};_0x1cf24b[_0x1f5596['name']]={'$like':'%'+_0xfd1539[_0xd6e7('0x31')]['filter']+'%'};return _0x1cf24b;}})});}_0x524120=_[_0xd6e7('0x3e')]({},_0x524120,_0xfd1539[_0xd6e7('0x40')]);var _0x5aa11c={'where':_0x524120[_0xd6e7('0x3d')]};return db[_0xd6e7('0x2c')][_0xd6e7('0x1b')](_0x5aa11c)[_0xd6e7('0x23')](function(_0x10bc8d){_0x3b2435[_0xd6e7('0x1b')]=_0x10bc8d;if(_0xfd1539[_0xd6e7('0x31')][_0xd6e7('0x41')]){_0x524120[_0xd6e7('0x42')]=[{'all':!![]}];}return db[_0xd6e7('0x2c')][_0xd6e7('0x43')](_0x524120);})[_0xd6e7('0x23')](function(_0x5c15ca){_0x3b2435[_0xd6e7('0x44')]=_0x5c15ca;return _0x3b2435;})[_0xd6e7('0x23')](respondWithFilteredResult(_0x14aa76,_0x524120))['catch'](handleError(_0x14aa76,null));};exports[_0xd6e7('0x45')]=function(_0x5c0dc2,_0x4921e3){var _0x4cdb62={'raw':!![],'where':{'id':_0x5c0dc2[_0xd6e7('0x46')]['id']}},_0x380b76={};_0x380b76[_0xd6e7('0x2f')]=_[_0xd6e7('0x32')](db[_0xd6e7('0x2c')][_0xd6e7('0x47')]);_0x380b76['query']=_[_0xd6e7('0x32')](_0x5c0dc2[_0xd6e7('0x31')]);_0x380b76[_0xd6e7('0x33')]=_[_0xd6e7('0x34')](_0x380b76[_0xd6e7('0x2f')],_0x380b76['query']);_0x4cdb62['attributes']=_[_0xd6e7('0x34')](_0x380b76['model'],qs[_0xd6e7('0x36')](_0x5c0dc2[_0xd6e7('0x31')]['fields']));_0x4cdb62[_0xd6e7('0x35')]=_0x4cdb62[_0xd6e7('0x35')][_0xd6e7('0x48')]?_0x4cdb62['attributes']:_0x380b76[_0xd6e7('0x2f')];if(_0x5c0dc2[_0xd6e7('0x31')][_0xd6e7('0x41')]){_0x4cdb62[_0xd6e7('0x42')]=[{'all':!![]}];}_0x4cdb62=_[_0xd6e7('0x3e')]({},_0x4cdb62,_0x5c0dc2['options']);return db[_0xd6e7('0x2c')]['find'](_0x4cdb62)['then'](handleEntityNotFound(_0x4921e3,null))['then'](respondWithResult(_0x4921e3,null))['catch'](handleError(_0x4921e3,null));};exports[_0xd6e7('0x49')]=function(_0x8ebeed,_0x4e42b8){return db[_0xd6e7('0x2c')]['create'](_0x8ebeed[_0xd6e7('0x4a')],{})[_0xd6e7('0x23')](function(_0x577529){var _0x6b0cfe=_0x8ebeed['user'][_0xd6e7('0x25')]({'plain':!![]});if(!_0x6b0cfe)throw new Error(_0xd6e7('0x4b'));if(_0x6b0cfe[_0xd6e7('0x4c')]===_0xd6e7('0x4d')){var _0x56e44c=_0x577529[_0xd6e7('0x25')]({'plain':!![]});var _0x407260=_0xd6e7('0x26');return db[_0xd6e7('0x4e')]['find']({'where':{'name':_0x407260,'userProfileId':_0x6b0cfe[_0xd6e7('0x4f')]},'raw':!![]})[_0xd6e7('0x23')](function(_0x484682){if(_0x484682&&_0x484682[_0xd6e7('0x50')]===0x0){return db['UserProfileResource']['create']({'name':_0x56e44c[_0xd6e7('0x2a')],'resourceId':_0x56e44c['id'],'type':_0x484682[_0xd6e7('0x2a')],'sectionId':_0x484682['id']},{})['then'](function(){return _0x577529;});}else{return _0x577529;}})[_0xd6e7('0x51')](function(_0x28cf9e){logger[_0xd6e7('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x28cf9e);throw _0x28cf9e;});}return _0x577529;})['then'](respondWithResult(_0x4e42b8,0xc9))['catch'](handleError(_0x4e42b8,null));};exports[_0xd6e7('0x22')]=function(_0x5cf368,_0x4b5cf8){if(_0x5cf368['body']['id']){delete _0x5cf368[_0xd6e7('0x4a')]['id'];}return db[_0xd6e7('0x2c')][_0xd6e7('0x52')]({'where':{'id':_0x5cf368[_0xd6e7('0x46')]['id']}})[_0xd6e7('0x23')](handleEntityNotFound(_0x4b5cf8,null))[_0xd6e7('0x23')](saveUpdates(_0x5cf368[_0xd6e7('0x4a')],null))[_0xd6e7('0x23')](respondWithResult(_0x4b5cf8,null))[_0xd6e7('0x51')](handleError(_0x4b5cf8,null));};exports[_0xd6e7('0x24')]=function(_0x313f76,_0x383e91){return db[_0xd6e7('0x2c')][_0xd6e7('0x52')]({'where':{'id':_0x313f76[_0xd6e7('0x46')]['id']}})[_0xd6e7('0x23')](handleEntityNotFound(_0x383e91,null))['then'](removeEntity(_0x383e91,null))[_0xd6e7('0x51')](handleError(_0x383e91,null));};exports[_0xd6e7('0x53')]=function(_0x2302a2,_0x2410b4,_0x1a9ac5){var _0x4c6e7e;return db['SquareOdbc'][_0xd6e7('0x52')]({'where':{'id':_0x2302a2[_0xd6e7('0x46')]['id']},'attributes':['id','dsn']})[_0xd6e7('0x23')](handleEntityNotFound(_0x2410b4,null))[_0xd6e7('0x23')](function(_0x2d81f8){if(_0x2d81f8){var _0x1af6ed=require('odbc')();_0x1af6ed[_0xd6e7('0x54')](_0x2d81f8['dsn']);_0x1af6ed['closeSync']();return _0x2d81f8;}})['then'](respondWithResult(_0x2410b4,null))[_0xd6e7('0x51')](handleError(_0x2410b4,null));};
\ No newline at end of file
+var _0x4d2a=['../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','json','apply','update','then','destroy','get','ODBC','UserProfileResource','error','name','map','SquareOdbc','rawAttributes','fieldName','type','query','keys','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','include','create','body','user','role','UserProfileSection','find','autoAssociation','catch','params','test','odbc','openSync','dsn','eml-format','rimraf','zip-dir','request-promise','bluebird','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment'];(function(_0x320f44,_0x2619b8){var _0x460136=function(_0x49b981){while(--_0x49b981){_0x320f44['push'](_0x320f44['shift']());}};_0x460136(++_0x2619b8);}(_0x4d2a,0x1cf));var _0xa4d2=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x4d2a[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xa4d2('0x0'));var rimraf=require(_0xa4d2('0x1'));var zipdir=require(_0xa4d2('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xa4d2('0x3'));var moment=require('moment');var BPromise=require(_0xa4d2('0x4'));var Mustache=require('mustache');var util=require(_0xa4d2('0x5'));var path=require(_0xa4d2('0x6'));var sox=require(_0xa4d2('0x7'));var csv=require('to-csv');var ejs=require(_0xa4d2('0x8'));var fs=require('fs');var fs_extra=require(_0xa4d2('0x9'));var _=require(_0xa4d2('0xa'));var squel=require(_0xa4d2('0xb'));var crypto=require(_0xa4d2('0xc'));var jsforce=require(_0xa4d2('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xa4d2('0xe'));var querystring=require(_0xa4d2('0xf'));var Papa=require(_0xa4d2('0x10'));var Redis=require('ioredis');var authService=require(_0xa4d2('0x11'));var qs=require(_0xa4d2('0x12'));var as=require(_0xa4d2('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xa4d2('0x14'))(_0xa4d2('0x15'));var utils=require('../../config/utils');var config=require(_0xa4d2('0x16'));var licenseUtil=require(_0xa4d2('0x17'));var db=require(_0xa4d2('0x18'))['db'];function respondWithStatusCode(_0x5cde54,_0x36e34a){_0x36e34a=_0x36e34a||0xcc;return function(_0x16e782){if(_0x16e782){return _0x5cde54[_0xa4d2('0x19')](_0x36e34a);}return _0x5cde54[_0xa4d2('0x1a')](_0x36e34a)[_0xa4d2('0x1b')]();};}function respondWithResult(_0x55e1da,_0x4d9a1b){_0x4d9a1b=_0x4d9a1b||0xc8;return function(_0x2f2ba9){if(_0x2f2ba9){return _0x55e1da[_0xa4d2('0x1a')](_0x4d9a1b)['json'](_0x2f2ba9);}};}function respondWithFilteredResult(_0x511578,_0x2e1e78){return function(_0x2451d9){if(_0x2451d9){var _0x7ca645=typeof _0x2e1e78[_0xa4d2('0x1c')]===_0xa4d2('0x1d')&&typeof _0x2e1e78[_0xa4d2('0x1e')]===_0xa4d2('0x1d');var _0x4b853b=_0x2451d9['count'];var _0x1102df=_0x7ca645?0x0:_0x2e1e78[_0xa4d2('0x1c')];var _0x5d66e2=_0x7ca645?_0x2451d9[_0xa4d2('0x1f')]:_0x2e1e78['offset']+_0x2e1e78[_0xa4d2('0x1e')];var _0x165357;if(_0x5d66e2>=_0x4b853b){_0x5d66e2=_0x4b853b;_0x165357=0xc8;}else{_0x165357=0xce;}_0x511578[_0xa4d2('0x1a')](_0x165357);return _0x511578['set']('Content-Range',_0x1102df+'-'+_0x5d66e2+'/'+_0x4b853b)[_0xa4d2('0x20')](_0x2451d9);}return null;};}function patchUpdates(_0x32e397){return function(_0x8fbc62){try{jsonpatch[_0xa4d2('0x21')](_0x8fbc62,_0x32e397,!![]);}catch(_0x488500){return BPromise['reject'](_0x488500);}return _0x8fbc62['save']();};}function saveUpdates(_0x2f64e3,_0x44c653){return function(_0x321b33){if(_0x321b33){return _0x321b33[_0xa4d2('0x22')](_0x2f64e3)[_0xa4d2('0x23')](function(_0x48f506){return _0x48f506;});}return null;};}function removeEntity(_0x183d11,_0x1fe757){return function(_0x3f4f91){if(_0x3f4f91){return _0x3f4f91[_0xa4d2('0x24')]()[_0xa4d2('0x23')](function(){var _0x48b474=_0x3f4f91[_0xa4d2('0x25')]({'plain':!![]});var _0x6da3c4=_0xa4d2('0x26');return db[_0xa4d2('0x27')][_0xa4d2('0x24')]({'where':{'type':_0x6da3c4,'resourceId':_0x48b474['id']}})[_0xa4d2('0x23')](function(){return _0x3f4f91;});})[_0xa4d2('0x23')](function(){_0x183d11[_0xa4d2('0x1a')](0xcc)[_0xa4d2('0x1b')]();});}};}function handleEntityNotFound(_0x1a9118,_0x7bc4e6){return function(_0x58c532){if(!_0x58c532){_0x1a9118[_0xa4d2('0x19')](0x194);}return _0x58c532;};}function handleError(_0x328a7f,_0x38f4b0){_0x38f4b0=_0x38f4b0||0x1f4;return function(_0x2fd3b4){logger[_0xa4d2('0x28')](_0x2fd3b4['stack']);if(_0x2fd3b4[_0xa4d2('0x29')]){delete _0x2fd3b4[_0xa4d2('0x29')];}_0x328a7f[_0xa4d2('0x1a')](_0x38f4b0)['send'](_0x2fd3b4);};}exports['index']=function(_0x4b372d,_0x4fcec0){var _0x100dc7={},_0x4acf66={},_0x405b3b={'count':0x0,'rows':[]};var _0x31a4da=_[_0xa4d2('0x2a')](db[_0xa4d2('0x2b')][_0xa4d2('0x2c')],function(_0x179864){return{'name':_0x179864[_0xa4d2('0x2d')],'type':_0x179864[_0xa4d2('0x2e')]['key']};});_0x4acf66['model']=_[_0xa4d2('0x2a')](_0x31a4da,_0xa4d2('0x29'));_0x4acf66[_0xa4d2('0x2f')]=_[_0xa4d2('0x30')](_0x4b372d[_0xa4d2('0x2f')]);_0x4acf66[_0xa4d2('0x31')]=_[_0xa4d2('0x32')](_0x4acf66['model'],_0x4acf66['query']);_0x100dc7[_0xa4d2('0x33')]=_[_0xa4d2('0x32')](_0x4acf66[_0xa4d2('0x34')],qs[_0xa4d2('0x35')](_0x4b372d[_0xa4d2('0x2f')][_0xa4d2('0x35')]));_0x100dc7[_0xa4d2('0x33')]=_0x100dc7['attributes'][_0xa4d2('0x36')]?_0x100dc7[_0xa4d2('0x33')]:_0x4acf66[_0xa4d2('0x34')];if(!_0x4b372d[_0xa4d2('0x2f')][_0xa4d2('0x37')](_0xa4d2('0x38'))){_0x100dc7[_0xa4d2('0x1e')]=qs['limit'](_0x4b372d[_0xa4d2('0x2f')][_0xa4d2('0x1e')]);_0x100dc7[_0xa4d2('0x1c')]=qs[_0xa4d2('0x1c')](_0x4b372d[_0xa4d2('0x2f')][_0xa4d2('0x1c')]);}_0x100dc7['order']=qs['sort'](_0x4b372d[_0xa4d2('0x2f')][_0xa4d2('0x39')]);_0x100dc7[_0xa4d2('0x3a')]=qs[_0xa4d2('0x31')](_[_0xa4d2('0x3b')](_0x4b372d[_0xa4d2('0x2f')],_0x4acf66[_0xa4d2('0x31')]),_0x31a4da);if(_0x4b372d[_0xa4d2('0x2f')][_0xa4d2('0x3c')]){_0x100dc7[_0xa4d2('0x3a')]=_[_0xa4d2('0x3d')](_0x100dc7[_0xa4d2('0x3a')],{'$or':_[_0xa4d2('0x2a')](_0x31a4da,function(_0x13f960){if(_0x13f960['type']!==_0xa4d2('0x3e')){var _0x401ee8={};_0x401ee8[_0x13f960['name']]={'$like':'%'+_0x4b372d['query'][_0xa4d2('0x3c')]+'%'};return _0x401ee8;}})});}_0x100dc7=_[_0xa4d2('0x3d')]({},_0x100dc7,_0x4b372d[_0xa4d2('0x3f')]);var _0x48bdfa={'where':_0x100dc7[_0xa4d2('0x3a')]};return db[_0xa4d2('0x2b')][_0xa4d2('0x1f')](_0x48bdfa)['then'](function(_0x2f1cd0){_0x405b3b[_0xa4d2('0x1f')]=_0x2f1cd0;if(_0x4b372d[_0xa4d2('0x2f')][_0xa4d2('0x40')]){_0x100dc7['include']=[{'all':!![]}];}return db[_0xa4d2('0x2b')][_0xa4d2('0x41')](_0x100dc7);})[_0xa4d2('0x23')](function(_0x46e8c2){_0x405b3b[_0xa4d2('0x42')]=_0x46e8c2;return _0x405b3b;})[_0xa4d2('0x23')](respondWithFilteredResult(_0x4fcec0,_0x100dc7))['catch'](handleError(_0x4fcec0,null));};exports['show']=function(_0x75b7e7,_0x476945){var _0x1f2938={'raw':!![],'where':{'id':_0x75b7e7['params']['id']}},_0x5fb36={};_0x5fb36[_0xa4d2('0x34')]=_['keys'](db[_0xa4d2('0x2b')][_0xa4d2('0x2c')]);_0x5fb36[_0xa4d2('0x2f')]=_[_0xa4d2('0x30')](_0x75b7e7[_0xa4d2('0x2f')]);_0x5fb36['filters']=_[_0xa4d2('0x32')](_0x5fb36[_0xa4d2('0x34')],_0x5fb36[_0xa4d2('0x2f')]);_0x1f2938[_0xa4d2('0x33')]=_['intersection'](_0x5fb36[_0xa4d2('0x34')],qs['fields'](_0x75b7e7[_0xa4d2('0x2f')][_0xa4d2('0x35')]));_0x1f2938['attributes']=_0x1f2938[_0xa4d2('0x33')][_0xa4d2('0x36')]?_0x1f2938['attributes']:_0x5fb36[_0xa4d2('0x34')];if(_0x75b7e7['query']['includeAll']){_0x1f2938[_0xa4d2('0x43')]=[{'all':!![]}];}_0x1f2938=_[_0xa4d2('0x3d')]({},_0x1f2938,_0x75b7e7['options']);return db[_0xa4d2('0x2b')]['find'](_0x1f2938)[_0xa4d2('0x23')](handleEntityNotFound(_0x476945,null))[_0xa4d2('0x23')](respondWithResult(_0x476945,null))['catch'](handleError(_0x476945,null));};exports[_0xa4d2('0x44')]=function(_0xca14ff,_0x14d8c1){return db['SquareOdbc']['create'](_0xca14ff[_0xa4d2('0x45')],{})[_0xa4d2('0x23')](function(_0x25dd5f){var _0x51f4ea=_0xca14ff[_0xa4d2('0x46')][_0xa4d2('0x25')]({'plain':!![]});if(!_0x51f4ea)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x51f4ea[_0xa4d2('0x47')]===_0xa4d2('0x46')){var _0xdb1fe0=_0x25dd5f[_0xa4d2('0x25')]({'plain':!![]});var _0x15eee5=_0xa4d2('0x26');return db[_0xa4d2('0x48')][_0xa4d2('0x49')]({'where':{'name':_0x15eee5,'userProfileId':_0x51f4ea['userProfileId']},'raw':!![]})['then'](function(_0x1273ab){if(_0x1273ab&&_0x1273ab[_0xa4d2('0x4a')]===0x0){return db[_0xa4d2('0x27')]['create']({'name':_0xdb1fe0[_0xa4d2('0x29')],'resourceId':_0xdb1fe0['id'],'type':_0x1273ab[_0xa4d2('0x29')],'sectionId':_0x1273ab['id']},{})[_0xa4d2('0x23')](function(){return _0x25dd5f;});}else{return _0x25dd5f;}})[_0xa4d2('0x4b')](function(_0x26f2ab){logger[_0xa4d2('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x26f2ab);throw _0x26f2ab;});}return _0x25dd5f;})['then'](respondWithResult(_0x14d8c1,0xc9))['catch'](handleError(_0x14d8c1,null));};exports[_0xa4d2('0x22')]=function(_0x30aca0,_0x31d108){if(_0x30aca0[_0xa4d2('0x45')]['id']){delete _0x30aca0[_0xa4d2('0x45')]['id'];}return db[_0xa4d2('0x2b')][_0xa4d2('0x49')]({'where':{'id':_0x30aca0[_0xa4d2('0x4c')]['id']}})[_0xa4d2('0x23')](handleEntityNotFound(_0x31d108,null))[_0xa4d2('0x23')](saveUpdates(_0x30aca0[_0xa4d2('0x45')],null))[_0xa4d2('0x23')](respondWithResult(_0x31d108,null))['catch'](handleError(_0x31d108,null));};exports[_0xa4d2('0x24')]=function(_0x2808b7,_0xf3ed84){return db[_0xa4d2('0x2b')][_0xa4d2('0x49')]({'where':{'id':_0x2808b7[_0xa4d2('0x4c')]['id']}})[_0xa4d2('0x23')](handleEntityNotFound(_0xf3ed84,null))[_0xa4d2('0x23')](removeEntity(_0xf3ed84,null))['catch'](handleError(_0xf3ed84,null));};exports[_0xa4d2('0x4d')]=function(_0x54b7e7,_0x2588bf,_0x4afa53){var _0x2c33c2;return db[_0xa4d2('0x2b')]['find']({'where':{'id':_0x54b7e7[_0xa4d2('0x4c')]['id']},'attributes':['id','dsn']})[_0xa4d2('0x23')](handleEntityNotFound(_0x2588bf,null))[_0xa4d2('0x23')](function(_0x30849b){if(_0x30849b){var _0x10afa8=require(_0xa4d2('0x4e'))();_0x10afa8[_0xa4d2('0x4f')](_0x30849b[_0xa4d2('0x50')]);_0x10afa8['closeSync']();return _0x30849b;}})[_0xa4d2('0x23')](respondWithResult(_0x2588bf,null))[_0xa4d2('0x4b')](handleError(_0x2588bf,null));};
\ No newline at end of file