Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / squareProject / squareProject.controller.js
index 855272d..0153ab0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x126f=['../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./squareProject.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','get','SquareProjects','UserProfileResource','error','stack','name','send','index','map','SquareProject','rawAttributes','fieldName','key','model','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','type','options','includeAll','findAll','rows','catch','show','keys','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addUsers','omit','ids','removeUsers','isArray','userSquareProject:remove','findOne','User','getUsers','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x2a60a6,_0x3968ff){var _0x574216=function(_0x39eddd){while(--_0x39eddd){_0x2a60a6['push'](_0x2a60a6['shift']());}};_0x574216(++_0x3968ff);}(_0x126f,0x1d8));var _0xf126=function(_0x35dfe6,_0x4244fa){_0x35dfe6=_0x35dfe6-0x0;var _0x59651c=_0x126f[_0x35dfe6];return _0x59651c;};'use strict';var emlformat=require(_0xf126('0x0'));var rimraf=require(_0xf126('0x1'));var zipdir=require(_0xf126('0x2'));var jsonpatch=require(_0xf126('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf126('0x4'));var Mustache=require(_0xf126('0x5'));var util=require(_0xf126('0x6'));var path=require(_0xf126('0x7'));var sox=require('sox');var csv=require(_0xf126('0x8'));var ejs=require(_0xf126('0x9'));var fs=require('fs');var fs_extra=require(_0xf126('0xa'));var _=require(_0xf126('0xb'));var squel=require(_0xf126('0xc'));var crypto=require('crypto');var jsforce=require(_0xf126('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xf126('0x8'));var querystring=require(_0xf126('0xe'));var Papa=require('papaparse');var Redis=require(_0xf126('0xf'));var authService=require(_0xf126('0x10'));var qs=require(_0xf126('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf126('0x12'));var logger=require(_0xf126('0x13'))(_0xf126('0x14'));var utils=require(_0xf126('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf126('0x16'));var db=require(_0xf126('0x17'))['db'];config[_0xf126('0x18')]=_['defaults'](config['redis'],{'host':_0xf126('0x19'),'port':0x18eb});var socket=require(_0xf126('0x1a'))(new Redis(config['redis']));require(_0xf126('0x1b'))[_0xf126('0x1c')](socket);function respondWithStatusCode(_0x54ae44,_0x5c4210){_0x5c4210=_0x5c4210||0xcc;return function(_0x110c64){if(_0x110c64){return _0x54ae44[_0xf126('0x1d')](_0x5c4210);}return _0x54ae44[_0xf126('0x1e')](_0x5c4210)[_0xf126('0x1f')]();};}function respondWithResult(_0x51fc45,_0x3428cf){_0x3428cf=_0x3428cf||0xc8;return function(_0x309c69){if(_0x309c69){return _0x51fc45[_0xf126('0x1e')](_0x3428cf)[_0xf126('0x20')](_0x309c69);}};}function respondWithFilteredResult(_0x1d9e25,_0xb3c56e){return function(_0xc1f9ec){if(_0xc1f9ec){var _0x3c8b83=typeof _0xb3c56e[_0xf126('0x21')]===_0xf126('0x22')&&typeof _0xb3c56e[_0xf126('0x23')]===_0xf126('0x22');var _0x2fa7e6=_0xc1f9ec[_0xf126('0x24')];var _0x32c6b9=_0x3c8b83?0x0:_0xb3c56e[_0xf126('0x21')];var _0x451211=_0x3c8b83?_0xc1f9ec[_0xf126('0x24')]:_0xb3c56e[_0xf126('0x21')]+_0xb3c56e[_0xf126('0x23')];var _0xe82625;if(_0x451211>=_0x2fa7e6){_0x451211=_0x2fa7e6;_0xe82625=0xc8;}else{_0xe82625=0xce;}_0x1d9e25[_0xf126('0x1e')](_0xe82625);return _0x1d9e25[_0xf126('0x25')](_0xf126('0x26'),_0x32c6b9+'-'+_0x451211+'/'+_0x2fa7e6)['json'](_0xc1f9ec);}return null;};}function patchUpdates(_0x39bbed){return function(_0x569fa9){try{jsonpatch[_0xf126('0x27')](_0x569fa9,_0x39bbed,!![]);}catch(_0x26eb26){return BPromise[_0xf126('0x28')](_0x26eb26);}return _0x569fa9['save']();};}function saveUpdates(_0x29d018,_0x726083){return function(_0x5044b4){if(_0x5044b4){return _0x5044b4[_0xf126('0x29')](_0x29d018)[_0xf126('0x2a')](function(_0x17b12a){return _0x17b12a;});}return null;};}function removeEntity(_0xc76220,_0x42d1b9){return function(_0xf4d040){if(_0xf4d040){return _0xf4d040[_0xf126('0x2b')]()[_0xf126('0x2a')](function(){var _0x1f0fb3=_0xf4d040[_0xf126('0x2c')]({'plain':!![]});var _0x3eef2c=_0xf126('0x2d');return db[_0xf126('0x2e')]['destroy']({'where':{'type':_0x3eef2c,'resourceId':_0x1f0fb3['id']}})[_0xf126('0x2a')](function(){return _0xf4d040;});})[_0xf126('0x2a')](function(){_0xc76220['status'](0xcc)[_0xf126('0x1f')]();});}};}function handleEntityNotFound(_0x1e38ca,_0xfea39d){return function(_0x4af0e8){if(!_0x4af0e8){_0x1e38ca['sendStatus'](0x194);}return _0x4af0e8;};}function handleError(_0x20719a,_0x2db676){_0x2db676=_0x2db676||0x1f4;return function(_0x16cf4e){logger[_0xf126('0x2f')](_0x16cf4e[_0xf126('0x30')]);if(_0x16cf4e[_0xf126('0x31')]){delete _0x16cf4e['name'];}_0x20719a['status'](_0x2db676)[_0xf126('0x32')](_0x16cf4e);};}exports[_0xf126('0x33')]=function(_0x520dd6,_0x2f2e3b){var _0x18b756={},_0x3da34b={},_0x7a7d20={'count':0x0,'rows':[]};var _0x4e0a43=_[_0xf126('0x34')](db[_0xf126('0x35')][_0xf126('0x36')],function(_0x8712f3){return{'name':_0x8712f3[_0xf126('0x37')],'type':_0x8712f3['type'][_0xf126('0x38')]};});_0x3da34b[_0xf126('0x39')]=_[_0xf126('0x34')](_0x4e0a43,_0xf126('0x31'));_0x3da34b['query']=_['keys'](_0x520dd6['query']);_0x3da34b[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x3da34b[_0xf126('0x39')],_0x3da34b[_0xf126('0x3c')]);_0x18b756[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x3da34b[_0xf126('0x39')],qs[_0xf126('0x3e')](_0x520dd6[_0xf126('0x3c')][_0xf126('0x3e')]));_0x18b756['attributes']=_0x18b756['attributes'][_0xf126('0x3f')]?_0x18b756['attributes']:_0x3da34b[_0xf126('0x39')];if(!_0x520dd6['query'][_0xf126('0x40')](_0xf126('0x41'))){_0x18b756['limit']=qs['limit'](_0x520dd6[_0xf126('0x3c')][_0xf126('0x23')]);_0x18b756[_0xf126('0x21')]=qs[_0xf126('0x21')](_0x520dd6[_0xf126('0x3c')]['offset']);}_0x18b756['order']=qs[_0xf126('0x42')](_0x520dd6[_0xf126('0x3c')]['sort']);_0x18b756[_0xf126('0x43')]=qs[_0xf126('0x3a')](_[_0xf126('0x44')](_0x520dd6[_0xf126('0x3c')],_0x3da34b['filters']),_0x4e0a43);if(_0x520dd6[_0xf126('0x3c')][_0xf126('0x45')]){_0x18b756[_0xf126('0x43')]=_[_0xf126('0x46')](_0x18b756['where'],{'$or':_[_0xf126('0x34')](_0x4e0a43,function(_0x589b77){if(_0x589b77[_0xf126('0x47')]!=='VIRTUAL'){var _0x330cbe={};_0x330cbe[_0x589b77[_0xf126('0x31')]]={'$like':'%'+_0x520dd6['query'][_0xf126('0x45')]+'%'};return _0x330cbe;}})});}_0x18b756=_[_0xf126('0x46')]({},_0x18b756,_0x520dd6[_0xf126('0x48')]);var _0x49471d={'where':_0x18b756[_0xf126('0x43')]};return db[_0xf126('0x35')][_0xf126('0x24')](_0x49471d)['then'](function(_0x1bbbf1){_0x7a7d20[_0xf126('0x24')]=_0x1bbbf1;if(_0x520dd6['query'][_0xf126('0x49')]){_0x18b756['include']=[{'all':!![]}];}return db[_0xf126('0x35')][_0xf126('0x4a')](_0x18b756);})[_0xf126('0x2a')](function(_0x58d137){_0x7a7d20[_0xf126('0x4b')]=_0x58d137;return _0x7a7d20;})[_0xf126('0x2a')](respondWithFilteredResult(_0x2f2e3b,_0x18b756))[_0xf126('0x4c')](handleError(_0x2f2e3b,null));};exports[_0xf126('0x4d')]=function(_0xa56354,_0x5b6cb3){var _0x57820c={'raw':![],'where':{'id':_0xa56354['params']['id']}},_0x43b876={};_0x43b876[_0xf126('0x39')]=_['keys'](db[_0xf126('0x35')][_0xf126('0x36')]);_0x43b876[_0xf126('0x3c')]=_[_0xf126('0x4e')](_0xa56354['query']);_0x43b876[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x43b876[_0xf126('0x39')],_0x43b876[_0xf126('0x3c')]);_0x57820c[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x43b876[_0xf126('0x39')],qs[_0xf126('0x3e')](_0xa56354[_0xf126('0x3c')][_0xf126('0x3e')]));_0x57820c['attributes']=_0x57820c['attributes'][_0xf126('0x3f')]?_0x57820c[_0xf126('0x3d')]:_0x43b876[_0xf126('0x39')];if(_0xa56354['query'][_0xf126('0x49')]){_0x57820c['include']=[{'all':!![]}];}_0x57820c=_['merge']({},_0x57820c,_0xa56354['options']);return db[_0xf126('0x35')][_0xf126('0x4f')](_0x57820c)[_0xf126('0x2a')](handleEntityNotFound(_0x5b6cb3,null))['then'](respondWithResult(_0x5b6cb3,null))['catch'](handleError(_0x5b6cb3,null));};exports[_0xf126('0x50')]=function(_0x4c1b8b,_0x2a9b3b){return db['SquareProject'][_0xf126('0x50')](_0x4c1b8b[_0xf126('0x51')],{})['then'](function(_0x2b0db8){var _0x89bef=_0x4c1b8b[_0xf126('0x52')][_0xf126('0x2c')]({'plain':!![]});if(!_0x89bef)throw new Error(_0xf126('0x53'));if(_0x89bef[_0xf126('0x54')]==='user'){var _0x4b9c7d=_0x2b0db8['get']({'plain':!![]});var _0x41b18e='SquareProjects';return db['UserProfileSection'][_0xf126('0x4f')]({'where':{'name':_0x41b18e,'userProfileId':_0x89bef[_0xf126('0x55')]},'raw':!![]})[_0xf126('0x2a')](function(_0x319cb0){if(_0x319cb0&&_0x319cb0[_0xf126('0x56')]===0x0){return db[_0xf126('0x2e')][_0xf126('0x50')]({'name':_0x4b9c7d['name'],'resourceId':_0x4b9c7d['id'],'type':_0x319cb0[_0xf126('0x31')],'sectionId':_0x319cb0['id']},{})['then'](function(){return _0x2b0db8;});}else{return _0x2b0db8;}})[_0xf126('0x4c')](function(_0x3f8b05){logger['error'](_0xf126('0x57'),_0x3f8b05);throw _0x3f8b05;});}return _0x2b0db8;})[_0xf126('0x2a')](respondWithResult(_0x2a9b3b,0xc9))[_0xf126('0x4c')](handleError(_0x2a9b3b,null));};exports[_0xf126('0x29')]=function(_0x2819f5,_0x545628){if(_0x2819f5[_0xf126('0x51')]['id']){delete _0x2819f5[_0xf126('0x51')]['id'];}return db[_0xf126('0x35')]['find']({'where':{'id':_0x2819f5['params']['id']}})['then'](handleEntityNotFound(_0x545628,null))[_0xf126('0x2a')](saveUpdates(_0x2819f5[_0xf126('0x51')],null))['then'](respondWithResult(_0x545628,null))[_0xf126('0x4c')](handleError(_0x545628,null));};exports[_0xf126('0x2b')]=function(_0x469b65,_0xf7a6cc){return db['SquareProject'][_0xf126('0x4f')]({'where':{'id':_0x469b65['params']['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0xf7a6cc,null))[_0xf126('0x2a')](removeEntity(_0xf7a6cc,null))[_0xf126('0x4c')](handleError(_0xf7a6cc,null));};exports['addUsers']=function(_0x46ff26,_0x1077c7,_0x40c1f6){return db[_0xf126('0x35')]['find']({'where':{'id':_0x46ff26[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x1077c7,null))[_0xf126('0x2a')](function(_0x3780e0){if(_0x3780e0){return _0x3780e0[_0xf126('0x59')](_0x46ff26[_0xf126('0x51')]['ids'],_[_0xf126('0x5a')](_0x46ff26[_0xf126('0x51')],[_0xf126('0x5b'),'id'])||{});}})[_0xf126('0x2a')](respondWithResult(_0x1077c7,null))['catch'](handleError(_0x1077c7,null));};exports[_0xf126('0x5c')]=function(_0xcf00b,_0x4831fd,_0x5d988d){return db[_0xf126('0x35')]['find']({'where':{'id':_0xcf00b[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x4831fd,null))[_0xf126('0x2a')](function(_0x18090f){if(_0x18090f){return _0x18090f['removeUsers'](_0xcf00b['query'][_0xf126('0x5b')])['then'](function(){if(_[_0xf126('0x5d')](_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')])){for(var _0x5484e9=0x0;_0x5484e9<_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')][_0xf126('0x3f')];_0x5484e9+=0x1){socket['emit']('userSquareProject:remove',{'UserId':Number(_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')][_0x5484e9]),'SquareProjectId':Number(_0xcf00b[_0xf126('0x58')]['id'])});}}else{socket['emit'](_0xf126('0x5e'),{'UserId':Number(_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')]),'SquareProjectId':Number(_0xcf00b[_0xf126('0x58')]['id'])});}});}})[_0xf126('0x2a')](respondWithStatusCode(_0x4831fd,null))[_0xf126('0x4c')](handleError(_0x4831fd,null));};exports['getUsers']=function(_0x3df4fe,_0x73c4cc,_0x392c1c){var _0x5fcf95={};var _0x2fc398={};var _0x127f2b;var _0x2ef15a;return db[_0xf126('0x35')][_0xf126('0x5f')]({'where':{'id':_0x3df4fe[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x73c4cc,null))['then'](function(_0x661280){if(_0x661280){_0x127f2b=_0x661280;_0x2fc398[_0xf126('0x39')]=_['keys'](db[_0xf126('0x60')][_0xf126('0x36')]);_0x2fc398['query']=_[_0xf126('0x4e')](_0x3df4fe[_0xf126('0x3c')]);_0x2fc398[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x2fc398[_0xf126('0x39')],_0x2fc398[_0xf126('0x3c')]);_0x5fcf95[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x2fc398[_0xf126('0x39')],qs[_0xf126('0x3e')](_0x3df4fe[_0xf126('0x3c')][_0xf126('0x3e')]));_0x5fcf95[_0xf126('0x3d')]=_0x5fcf95[_0xf126('0x3d')][_0xf126('0x3f')]?_0x5fcf95[_0xf126('0x3d')]:_0x2fc398['model'];_0x5fcf95['order']=qs['sort'](_0x3df4fe['query'][_0xf126('0x42')]);_0x5fcf95[_0xf126('0x43')]=qs['filters'](_[_0xf126('0x44')](_0x3df4fe[_0xf126('0x3c')],_0x2fc398[_0xf126('0x3a')]));if(_0x3df4fe[_0xf126('0x3c')][_0xf126('0x45')]){_0x5fcf95[_0xf126('0x43')]=_[_0xf126('0x46')](_0x5fcf95[_0xf126('0x43')],{'$or':_[_0xf126('0x34')](_0x5fcf95[_0xf126('0x3d')],function(_0x3e3af2){var _0x371ca8={};_0x371ca8[_0x3e3af2]={'$like':'%'+_0x3df4fe[_0xf126('0x3c')][_0xf126('0x45')]+'%'};return _0x371ca8;})});}_0x5fcf95=_['merge']({},_0x5fcf95,_0x3df4fe['options']);return _0x127f2b[_0xf126('0x61')](_0x5fcf95);}})[_0xf126('0x2a')](function(_0x1ec082){if(_0x1ec082){_0x2ef15a=_0x1ec082[_0xf126('0x3f')];if(!_0x3df4fe[_0xf126('0x3c')]['hasOwnProperty'](_0xf126('0x41'))){_0x5fcf95[_0xf126('0x23')]=qs[_0xf126('0x23')](_0x3df4fe['query']['limit']);_0x5fcf95[_0xf126('0x21')]=qs[_0xf126('0x21')](_0x3df4fe[_0xf126('0x3c')][_0xf126('0x21')]);}return _0x127f2b[_0xf126('0x61')](_0x5fcf95);}})['then'](function(_0x27a73f){if(_0x27a73f){return _0x27a73f?{'count':_0x2ef15a,'rows':_0x27a73f}:null;}})[_0xf126('0x2a')](respondWithResult(_0x73c4cc,null))[_0xf126('0x4c')](handleError(_0x73c4cc,null));};
\ No newline at end of file
+var _0x4a90=['destroy','get','SquareProjects','publish','stringify','end','sendStatus','error','stack','name','send','SquareProject','rawAttributes','type','model','query','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filters','merge','map','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','keys','length','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','body','agi','production','lodash','ioredis','../../components/parsers/qs','api','redis','socket.io-emitter','./squareProject.socket','register','status','json','offset','undefined','count','limit','set','Content-Range','update','then'];(function(_0x420300,_0x806d9c){var _0x4b464d=function(_0x3738fd){while(--_0x3738fd){_0x420300['push'](_0x420300['shift']());}};_0x4b464d(++_0x806d9c);}(_0x4a90,0x102));var _0x04a9=function(_0x5618be,_0x46c435){_0x5618be=_0x5618be-0x0;var _0x9571f3=_0x4a90[_0x5618be];return _0x9571f3;};'use strict';var _=require(_0x04a9('0x0'));var Redis=require(_0x04a9('0x1'));var qs=require(_0x04a9('0x2'));var logger=require('../../config/logger')(_0x04a9('0x3'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x04a9('0x4')]=_['defaults'](config[_0x04a9('0x4')],{'host':'localhost','port':0x18eb});var socket=require(_0x04a9('0x5'))(new Redis(config['redis']));require(_0x04a9('0x6'))[_0x04a9('0x7')](socket);function respondWithResult(_0x171db1,_0xeb2c83){_0xeb2c83=_0xeb2c83||0xc8;return function(_0x2380b0){if(_0x2380b0){return _0x171db1[_0x04a9('0x8')](_0xeb2c83)[_0x04a9('0x9')](_0x2380b0);}};}function respondWithFilteredResult(_0x417ab9,_0x31f311){return function(_0x57aba3){if(_0x57aba3){var _0x125f68=typeof _0x31f311[_0x04a9('0xa')]===_0x04a9('0xb')&&typeof _0x31f311['limit']===_0x04a9('0xb');var _0x1a1ca9=_0x57aba3[_0x04a9('0xc')];var _0x3774fa=_0x125f68?0x0:_0x31f311[_0x04a9('0xa')];var _0x2e586d=_0x125f68?_0x57aba3[_0x04a9('0xc')]:_0x31f311[_0x04a9('0xa')]+_0x31f311[_0x04a9('0xd')];var _0x423501;if(_0x2e586d>=_0x1a1ca9){_0x2e586d=_0x1a1ca9;_0x423501=0xc8;}else{_0x423501=0xce;}_0x417ab9['status'](_0x423501);return _0x417ab9[_0x04a9('0xe')](_0x04a9('0xf'),_0x3774fa+'-'+_0x2e586d+'/'+_0x1a1ca9)[_0x04a9('0x9')](_0x57aba3);}return null;};}function saveUpdates(_0x9f2237){return function(_0x329555){if(_0x329555){return _0x329555[_0x04a9('0x10')](_0x9f2237)[_0x04a9('0x11')](function(_0x2fe8f8){return _0x2fe8f8;});}return null;};}function removeEntity(_0x4f4f7b){return function(_0x489480){if(_0x489480){return _0x489480[_0x04a9('0x12')]()[_0x04a9('0x11')](function(){var _0x3959c1=_0x489480[_0x04a9('0x13')]({'plain':!![]});var _0x21d78e=_0x04a9('0x14');return db['UserProfileResource']['destroy']({'where':{'type':_0x21d78e,'resourceId':_0x3959c1['id']}})[_0x04a9('0x11')](function(){return _0x489480;});})[_0x04a9('0x11')](function(){var _0x5268ff=new Redis(config[_0x04a9('0x4')]);_0x5268ff[_0x04a9('0x15')]('agi',JSON[_0x04a9('0x16')]({'id':_0x489480['id'],'deleted':!![]}));})[_0x04a9('0x11')](function(){_0x4f4f7b[_0x04a9('0x8')](0xcc)[_0x04a9('0x17')]();});}};}function handleEntityNotFound(_0x54224d){return function(_0x3e8bca){if(!_0x3e8bca){_0x54224d[_0x04a9('0x18')](0x194);}return _0x3e8bca;};}function handleError(_0x1def95,_0x3c2b60){_0x3c2b60=_0x3c2b60||0x1f4;return function(_0x1fda54){logger[_0x04a9('0x19')](_0x1fda54[_0x04a9('0x1a')]);if(_0x1fda54[_0x04a9('0x1b')]){delete _0x1fda54[_0x04a9('0x1b')];}_0x1def95[_0x04a9('0x8')](_0x3c2b60)[_0x04a9('0x1c')](_0x1fda54);};}exports['index']=function(_0x3e33b0,_0x1ea50a){var _0x18febf={},_0x4fbfea={},_0x24d176={'count':0x0,'rows':[]};var _0x575d6b=_['map'](db[_0x04a9('0x1d')][_0x04a9('0x1e')],function(_0x5b7ff7){return{'name':_0x5b7ff7['fieldName'],'type':_0x5b7ff7[_0x04a9('0x1f')]['key']};});_0x4fbfea[_0x04a9('0x20')]=_['map'](_0x575d6b,_0x04a9('0x1b'));_0x4fbfea[_0x04a9('0x21')]=_['keys'](_0x3e33b0[_0x04a9('0x21')]);_0x4fbfea['filters']=_[_0x04a9('0x22')](_0x4fbfea['model'],_0x4fbfea[_0x04a9('0x21')]);_0x18febf[_0x04a9('0x23')]=_[_0x04a9('0x22')](_0x4fbfea[_0x04a9('0x20')],qs[_0x04a9('0x24')](_0x3e33b0[_0x04a9('0x21')][_0x04a9('0x24')]));_0x18febf[_0x04a9('0x23')]=_0x18febf[_0x04a9('0x23')]['length']?_0x18febf[_0x04a9('0x23')]:_0x4fbfea[_0x04a9('0x20')];if(!_0x3e33b0['query'][_0x04a9('0x25')](_0x04a9('0x26'))){_0x18febf[_0x04a9('0xd')]=qs[_0x04a9('0xd')](_0x3e33b0['query']['limit']);_0x18febf[_0x04a9('0xa')]=qs['offset'](_0x3e33b0['query']['offset']);}_0x18febf[_0x04a9('0x27')]=qs[_0x04a9('0x28')](_0x3e33b0[_0x04a9('0x21')]['sort']);_0x18febf[_0x04a9('0x29')]=qs[_0x04a9('0x2a')](_['pick'](_0x3e33b0['query'],_0x4fbfea[_0x04a9('0x2a')]),_0x575d6b);if(_0x3e33b0[_0x04a9('0x21')]['filter']){_0x18febf[_0x04a9('0x29')]=_[_0x04a9('0x2b')](_0x18febf[_0x04a9('0x29')],{'$or':_[_0x04a9('0x2c')](_0x575d6b,function(_0x598c56){if(_0x598c56['type']!==_0x04a9('0x2d')){var _0x2f20e4={};_0x2f20e4[_0x598c56['name']]={'$like':'%'+_0x3e33b0['query'][_0x04a9('0x2e')]+'%'};return _0x2f20e4;}})});}_0x18febf=_[_0x04a9('0x2b')]({},_0x18febf,_0x3e33b0[_0x04a9('0x2f')]);var _0x308de7={'where':_0x18febf['where']};return db[_0x04a9('0x1d')][_0x04a9('0xc')](_0x308de7)['then'](function(_0x4ccee9){_0x24d176[_0x04a9('0xc')]=_0x4ccee9;if(_0x3e33b0['query'][_0x04a9('0x30')]){_0x18febf[_0x04a9('0x31')]=[{'all':!![]}];}return db[_0x04a9('0x1d')][_0x04a9('0x32')](_0x18febf);})['then'](function(_0x79c49b){_0x24d176[_0x04a9('0x33')]=_0x79c49b;return _0x24d176;})[_0x04a9('0x11')](respondWithFilteredResult(_0x1ea50a,_0x18febf))[_0x04a9('0x34')](handleError(_0x1ea50a,null));};exports[_0x04a9('0x35')]=function(_0x55961f,_0x3e4bc6){var _0xd708c9={'raw':![],'where':{'id':_0x55961f[_0x04a9('0x36')]['id']}},_0x29e91f={};_0x29e91f[_0x04a9('0x20')]=_[_0x04a9('0x37')](db[_0x04a9('0x1d')][_0x04a9('0x1e')]);_0x29e91f[_0x04a9('0x21')]=_[_0x04a9('0x37')](_0x55961f[_0x04a9('0x21')]);_0x29e91f[_0x04a9('0x2a')]=_['intersection'](_0x29e91f[_0x04a9('0x20')],_0x29e91f[_0x04a9('0x21')]);_0xd708c9[_0x04a9('0x23')]=_[_0x04a9('0x22')](_0x29e91f[_0x04a9('0x20')],qs[_0x04a9('0x24')](_0x55961f[_0x04a9('0x21')][_0x04a9('0x24')]));_0xd708c9['attributes']=_0xd708c9[_0x04a9('0x23')][_0x04a9('0x38')]?_0xd708c9[_0x04a9('0x23')]:_0x29e91f['model'];if(_0x55961f['query'][_0x04a9('0x30')]){_0xd708c9[_0x04a9('0x31')]=[{'all':!![]}];}_0xd708c9=_['merge']({},_0xd708c9,_0x55961f[_0x04a9('0x2f')]);return db['SquareProject'][_0x04a9('0x39')](_0xd708c9)['then'](handleEntityNotFound(_0x3e4bc6,null))[_0x04a9('0x11')](respondWithResult(_0x3e4bc6,null))[_0x04a9('0x34')](handleError(_0x3e4bc6,null));};exports['create']=function(_0x291ee8,_0x1cc56f){return db['SquareProject'][_0x04a9('0x3a')](_0x291ee8['body'],{})[_0x04a9('0x11')](function(_0xeaec5d){var _0x15339b=_0x291ee8[_0x04a9('0x3b')]['get']({'plain':!![]});if(!_0x15339b)throw new Error(_0x04a9('0x3c'));if(_0x15339b[_0x04a9('0x3d')]==='user'){var _0x8da26f=_0xeaec5d[_0x04a9('0x13')]({'plain':!![]});var _0x2f75ec='SquareProjects';return db[_0x04a9('0x3e')][_0x04a9('0x39')]({'where':{'name':_0x2f75ec,'userProfileId':_0x15339b[_0x04a9('0x3f')]},'raw':!![]})[_0x04a9('0x11')](function(_0x1a08b4){if(_0x1a08b4&&_0x1a08b4[_0x04a9('0x40')]===0x0){return db[_0x04a9('0x41')]['create']({'name':_0x8da26f[_0x04a9('0x1b')],'resourceId':_0x8da26f['id'],'type':_0x1a08b4[_0x04a9('0x1b')],'sectionId':_0x1a08b4['id']},{})['then'](function(){return _0xeaec5d;});}else{return _0xeaec5d;}})['catch'](function(_0x1a8183){logger[_0x04a9('0x19')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1a8183);throw _0x1a8183;});}return _0xeaec5d;})[_0x04a9('0x11')](respondWithResult(_0x1cc56f,0xc9))[_0x04a9('0x34')](handleError(_0x1cc56f,null));};exports['update']=function(_0x1a2804,_0x28696c){if(_0x1a2804[_0x04a9('0x42')]['id']){delete _0x1a2804[_0x04a9('0x42')]['id'];}return db[_0x04a9('0x1d')][_0x04a9('0x39')]({'where':{'id':_0x1a2804['params']['id']}})['then'](handleEntityNotFound(_0x28696c,null))['then'](saveUpdates(_0x1a2804[_0x04a9('0x42')],null))['then'](function(_0x777dfa){if(!_0x777dfa)return;var _0x362e3f=_0x777dfa['get']({'plain':!![]});return _0x362e3f;})[_0x04a9('0x11')](function(_0x57dee9){var _0x12d551=new Redis(config['redis']);_0x12d551[_0x04a9('0x15')](_0x04a9('0x43'),JSON['stringify'](_['pick'](_0x57dee9,['id',_0x04a9('0x1b'),_0x04a9('0x44')])));return _0x57dee9;})[_0x04a9('0x11')](respondWithResult(_0x28696c,null))['catch'](handleError(_0x28696c,null));};exports['destroy']=function(_0x202cf7,_0x368979){return db[_0x04a9('0x1d')][_0x04a9('0x39')]({'where':{'id':_0x202cf7[_0x04a9('0x36')]['id']}})[_0x04a9('0x11')](handleEntityNotFound(_0x368979,null))[_0x04a9('0x11')](removeEntity(_0x368979,null))['catch'](handleError(_0x368979,null));};
\ No newline at end of file