Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / squareProject / squareProject.controller.js
index af519bb..2f3807b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xccc1=['../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','socket.io-emitter','redis','./squareProject.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','save','then','get','SquareProjects','UserProfileResource','destroy','error','stack','send','index','map','rawAttributes','fieldName','type','key','model','name','query','filters','intersection','attributes','fields','hasOwnProperty','order','sort','pick','where','VIRTUAL','filter','merge','options','SquareProject','includeAll','include','findAll','catch','show','params','keys','find','create','body','user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','addUsers','ids','removeUsers','isArray','length','userSquareProject:remove','emit','getUsers','findOne','nolimit','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xccc1,0x119));var _0x1ccc=function(_0xa3ff70,_0x4a8609){_0xa3ff70=_0xa3ff70-0x0;var _0x538dbb=_0xccc1[_0xa3ff70];return _0x538dbb;};'use strict';var pdf=require(_0x1ccc('0x0'));var emlformat=require(_0x1ccc('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x1ccc('0x2'));var jsonpatch=require(_0x1ccc('0x3'));var rp=require(_0x1ccc('0x4'));var moment=require(_0x1ccc('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x1ccc('0x6'));var util=require(_0x1ccc('0x7'));var path=require(_0x1ccc('0x8'));var sox=require(_0x1ccc('0x9'));var csv=require(_0x1ccc('0xa'));var ejs=require(_0x1ccc('0xb'));var fs=require('fs');var _=require(_0x1ccc('0xc'));var squel=require('squel');var crypto=require(_0x1ccc('0xd'));var jsforce=require(_0x1ccc('0xe'));var deskjs=require(_0x1ccc('0xf'));var toCsv=require('to-csv');var querystring=require(_0x1ccc('0x10'));var Papa=require(_0x1ccc('0x11'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x1ccc('0x12'));var as=require(_0x1ccc('0x13'));var hardwareService=require(_0x1ccc('0x14'));var logger=require(_0x1ccc('0x15'))(_0x1ccc('0x16'));var utils=require('../../config/utils');var config=require(_0x1ccc('0x17'));var licenseUtil=require(_0x1ccc('0x18'));var db=require(_0x1ccc('0x19'))['db'];config['redis']=_[_0x1ccc('0x1a')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x1ccc('0x1b'))(new Redis(config[_0x1ccc('0x1c')]));require(_0x1ccc('0x1d'))[_0x1ccc('0x1e')](socket);function respondWithStatusCode(_0x1e0240,_0x3daf9a){_0x3daf9a=_0x3daf9a||0xcc;return function(_0x498a1c){if(_0x498a1c){return _0x1e0240[_0x1ccc('0x1f')](_0x3daf9a);}return _0x1e0240[_0x1ccc('0x20')](_0x3daf9a)[_0x1ccc('0x21')]();};}function respondWithResult(_0x1c786e,_0x5a4479){_0x5a4479=_0x5a4479||0xc8;return function(_0x8c29ec){if(_0x8c29ec){return _0x1c786e[_0x1ccc('0x20')](_0x5a4479)[_0x1ccc('0x22')](_0x8c29ec);}};}function respondWithFilteredResult(_0x1d4329,_0x1a07f5){return function(_0x11127c){if(_0x11127c){var _0xe2605b=_0x11127c[_0x1ccc('0x23')],_0xabe01a=_0x1a07f5[_0x1ccc('0x24')],_0x529ce6=_0x1a07f5[_0x1ccc('0x24')]+_0x1a07f5[_0x1ccc('0x25')],_0x3a8c0b;if(_0x529ce6>=_0xe2605b){_0x529ce6=_0xe2605b;_0x3a8c0b=0xc8;}else{_0x3a8c0b=0xce;}_0x1d4329['status'](_0x3a8c0b);return _0x1d4329[_0x1ccc('0x26')](_0x1ccc('0x27'),_0xabe01a+'-'+_0x529ce6+'/'+_0xe2605b)[_0x1ccc('0x22')](_0x11127c);}return null;};}function patchUpdates(_0x841647){return function(_0x52493c){try{jsonpatch[_0x1ccc('0x28')](_0x52493c,_0x841647,!![]);}catch(_0x1221da){return BPromise['reject'](_0x1221da);}return _0x52493c[_0x1ccc('0x29')]();};}function saveUpdates(_0x46e161,_0x8d354){return function(_0x1e8cfd){if(_0x1e8cfd){return _0x1e8cfd['update'](_0x46e161)[_0x1ccc('0x2a')](function(_0x110b13){return _0x110b13;});}return null;};}function removeEntity(_0x57d064,_0x276491){return function(_0x141dbf){if(_0x141dbf){return _0x141dbf['destroy']()['then'](function(){var _0x3f7b3c=_0x141dbf[_0x1ccc('0x2b')]({'plain':!![]});var _0x5a1df6=_0x1ccc('0x2c');return db[_0x1ccc('0x2d')][_0x1ccc('0x2e')]({'where':{'type':_0x5a1df6,'resourceId':_0x3f7b3c['id']}})['then'](function(){return _0x141dbf;});})['then'](function(){_0x57d064[_0x1ccc('0x20')](0xcc)[_0x1ccc('0x21')]();});}};}function handleEntityNotFound(_0x4b45f6,_0x254c90){return function(_0x2c10be){if(!_0x2c10be){_0x4b45f6['sendStatus'](0x194);}return _0x2c10be;};}function handleError(_0x150196,_0x1d3c04){_0x1d3c04=_0x1d3c04||0x1f4;return function(_0x26bc57){logger[_0x1ccc('0x2f')](_0x26bc57[_0x1ccc('0x30')]);if(_0x26bc57['name']){delete _0x26bc57['name'];}_0x150196[_0x1ccc('0x20')](_0x1d3c04)[_0x1ccc('0x31')](_0x26bc57);};}exports[_0x1ccc('0x32')]=function(_0xe9e7f0,_0x502b15){var _0x2167b8={},_0x1be0c9={},_0x3d3c4b={'count':0x0,'rows':[]};var _0xac3262=_[_0x1ccc('0x33')](db['SquareProject'][_0x1ccc('0x34')],function(_0x217016){return{'name':_0x217016[_0x1ccc('0x35')],'type':_0x217016[_0x1ccc('0x36')][_0x1ccc('0x37')]};});_0x1be0c9[_0x1ccc('0x38')]=_['map'](_0xac3262,_0x1ccc('0x39'));_0x1be0c9[_0x1ccc('0x3a')]=_['keys'](_0xe9e7f0[_0x1ccc('0x3a')]);_0x1be0c9[_0x1ccc('0x3b')]=_[_0x1ccc('0x3c')](_0x1be0c9[_0x1ccc('0x38')],_0x1be0c9[_0x1ccc('0x3a')]);_0x2167b8[_0x1ccc('0x3d')]=_[_0x1ccc('0x3c')](_0x1be0c9['model'],qs[_0x1ccc('0x3e')](_0xe9e7f0[_0x1ccc('0x3a')][_0x1ccc('0x3e')]));_0x2167b8[_0x1ccc('0x3d')]=_0x2167b8['attributes']['length']?_0x2167b8[_0x1ccc('0x3d')]:_0x1be0c9[_0x1ccc('0x38')];if(!_0xe9e7f0[_0x1ccc('0x3a')][_0x1ccc('0x3f')]('nolimit')){_0x2167b8[_0x1ccc('0x25')]=qs['limit'](_0xe9e7f0[_0x1ccc('0x3a')][_0x1ccc('0x25')]);_0x2167b8['offset']=qs[_0x1ccc('0x24')](_0xe9e7f0['query'][_0x1ccc('0x24')]);}_0x2167b8[_0x1ccc('0x40')]=qs[_0x1ccc('0x41')](_0xe9e7f0[_0x1ccc('0x3a')][_0x1ccc('0x41')]);_0x2167b8['where']=qs['filters'](_[_0x1ccc('0x42')](_0xe9e7f0[_0x1ccc('0x3a')],_0x1be0c9[_0x1ccc('0x3b')]),_0xac3262);if(_0xe9e7f0['query']['filter']){_0x2167b8['where']=_['merge'](_0x2167b8[_0x1ccc('0x43')],{'$or':_[_0x1ccc('0x33')](_0xac3262,function(_0x46ddd6){if(_0x46ddd6['type']!==_0x1ccc('0x44')){var _0x2e386f={};_0x2e386f[_0x46ddd6['name']]={'$like':'%'+_0xe9e7f0[_0x1ccc('0x3a')][_0x1ccc('0x45')]+'%'};return _0x2e386f;}})});}_0x2167b8=_[_0x1ccc('0x46')]({},_0x2167b8,_0xe9e7f0[_0x1ccc('0x47')]);var _0x5724b5={'where':_0x2167b8[_0x1ccc('0x43')]};return db[_0x1ccc('0x48')]['count'](_0x5724b5)[_0x1ccc('0x2a')](function(_0x95d7ed){_0x3d3c4b[_0x1ccc('0x23')]=_0x95d7ed;if(_0xe9e7f0[_0x1ccc('0x3a')][_0x1ccc('0x49')]){_0x2167b8[_0x1ccc('0x4a')]=[{'all':!![]}];}return db[_0x1ccc('0x48')][_0x1ccc('0x4b')](_0x2167b8);})[_0x1ccc('0x2a')](function(_0x5273bb){_0x3d3c4b['rows']=_0x5273bb;return _0x3d3c4b;})[_0x1ccc('0x2a')](respondWithFilteredResult(_0x502b15,_0x2167b8))[_0x1ccc('0x4c')](handleError(_0x502b15,null));};exports[_0x1ccc('0x4d')]=function(_0x39f5b1,_0x534042){var _0x20271e={'raw':![],'where':{'id':_0x39f5b1[_0x1ccc('0x4e')]['id']}},_0x34e0b8={};_0x34e0b8['model']=_[_0x1ccc('0x4f')](db['SquareProject'][_0x1ccc('0x34')]);_0x34e0b8[_0x1ccc('0x3a')]=_[_0x1ccc('0x4f')](_0x39f5b1[_0x1ccc('0x3a')]);_0x34e0b8[_0x1ccc('0x3b')]=_[_0x1ccc('0x3c')](_0x34e0b8[_0x1ccc('0x38')],_0x34e0b8[_0x1ccc('0x3a')]);_0x20271e[_0x1ccc('0x3d')]=_[_0x1ccc('0x3c')](_0x34e0b8[_0x1ccc('0x38')],qs['fields'](_0x39f5b1['query']['fields']));_0x20271e[_0x1ccc('0x3d')]=_0x20271e['attributes']['length']?_0x20271e[_0x1ccc('0x3d')]:_0x34e0b8[_0x1ccc('0x38')];if(_0x39f5b1['query'][_0x1ccc('0x49')]){_0x20271e[_0x1ccc('0x4a')]=[{'all':!![]}];}_0x20271e=_[_0x1ccc('0x46')]({},_0x20271e,_0x39f5b1['options']);return db[_0x1ccc('0x48')][_0x1ccc('0x50')](_0x20271e)[_0x1ccc('0x2a')](handleEntityNotFound(_0x534042,null))[_0x1ccc('0x2a')](respondWithResult(_0x534042,null))['catch'](handleError(_0x534042,null));};exports[_0x1ccc('0x51')]=function(_0x5b2394,_0x22ef07){return db['SquareProject'][_0x1ccc('0x51')](_0x5b2394[_0x1ccc('0x52')],{})[_0x1ccc('0x2a')](function(_0x4d616d){var _0x1fd772=_0x5b2394[_0x1ccc('0x53')][_0x1ccc('0x2b')]({'plain':!![]});if(!_0x1fd772)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1fd772[_0x1ccc('0x54')]===_0x1ccc('0x53')){var _0x5570b1=_0x4d616d[_0x1ccc('0x2b')]({'plain':!![]});var _0x633af9=_0x1ccc('0x2c');return db[_0x1ccc('0x55')]['find']({'where':{'name':_0x633af9,'userProfileId':_0x1fd772[_0x1ccc('0x56')]},'raw':!![]})[_0x1ccc('0x2a')](function(_0x12c6d4){if(_0x12c6d4&&_0x12c6d4[_0x1ccc('0x57')]===0x0){return db['UserProfileResource']['create']({'name':_0x5570b1[_0x1ccc('0x39')],'resourceId':_0x5570b1['id'],'type':_0x12c6d4[_0x1ccc('0x39')],'sectionId':_0x12c6d4['id']},{})[_0x1ccc('0x2a')](function(){return _0x4d616d;});}else{return _0x4d616d;}})['catch'](function(_0x563b4e){logger[_0x1ccc('0x2f')](_0x1ccc('0x58'),_0x563b4e);throw _0x563b4e;});}return _0x4d616d;})[_0x1ccc('0x2a')](respondWithResult(_0x22ef07,0xc9))[_0x1ccc('0x4c')](handleError(_0x22ef07,null));};exports[_0x1ccc('0x59')]=function(_0x237e97,_0x36d13c){if(_0x237e97[_0x1ccc('0x52')]['id']){delete _0x237e97[_0x1ccc('0x52')]['id'];}return db[_0x1ccc('0x48')]['find']({'where':{'id':_0x237e97['params']['id']}})[_0x1ccc('0x2a')](handleEntityNotFound(_0x36d13c,null))[_0x1ccc('0x2a')](saveUpdates(_0x237e97['body'],null))[_0x1ccc('0x2a')](respondWithResult(_0x36d13c,null))[_0x1ccc('0x4c')](handleError(_0x36d13c,null));};exports[_0x1ccc('0x2e')]=function(_0x1a63c9,_0x263730){return db[_0x1ccc('0x48')][_0x1ccc('0x50')]({'where':{'id':_0x1a63c9[_0x1ccc('0x4e')]['id']}})[_0x1ccc('0x2a')](handleEntityNotFound(_0x263730,null))[_0x1ccc('0x2a')](removeEntity(_0x263730,null))[_0x1ccc('0x4c')](handleError(_0x263730,null));};exports[_0x1ccc('0x5a')]=function(_0x1224c8,_0x3a6197,_0xf0fe88){return db[_0x1ccc('0x48')][_0x1ccc('0x50')]({'where':{'id':_0x1224c8['params']['id']}})[_0x1ccc('0x2a')](handleEntityNotFound(_0x3a6197,null))[_0x1ccc('0x2a')](function(_0x3c0be2){if(_0x3c0be2){return _0x3c0be2[_0x1ccc('0x5a')](_0x1224c8['body'][_0x1ccc('0x5b')],_['omit'](_0x1224c8[_0x1ccc('0x52')],[_0x1ccc('0x5b'),'id'])||{});}})[_0x1ccc('0x2a')](respondWithResult(_0x3a6197,null))[_0x1ccc('0x4c')](handleError(_0x3a6197,null));};exports[_0x1ccc('0x5c')]=function(_0x4ebf68,_0x402902,_0x179d89){return db[_0x1ccc('0x48')][_0x1ccc('0x50')]({'where':{'id':_0x4ebf68[_0x1ccc('0x4e')]['id']}})[_0x1ccc('0x2a')](handleEntityNotFound(_0x402902,null))[_0x1ccc('0x2a')](function(_0x34f3eb){if(_0x34f3eb){return _0x34f3eb[_0x1ccc('0x5c')](_0x4ebf68[_0x1ccc('0x3a')][_0x1ccc('0x5b')])[_0x1ccc('0x2a')](function(){if(_[_0x1ccc('0x5d')](_0x4ebf68[_0x1ccc('0x3a')][_0x1ccc('0x5b')])){for(var _0x3ec7ee=0x0;_0x3ec7ee<_0x4ebf68[_0x1ccc('0x3a')][_0x1ccc('0x5b')][_0x1ccc('0x5e')];_0x3ec7ee+=0x1){socket['emit'](_0x1ccc('0x5f'),{'UserId':Number(_0x4ebf68[_0x1ccc('0x3a')][_0x1ccc('0x5b')][_0x3ec7ee]),'SquareProjectId':Number(_0x4ebf68[_0x1ccc('0x4e')]['id'])});}}else{socket[_0x1ccc('0x60')](_0x1ccc('0x5f'),{'UserId':Number(_0x4ebf68[_0x1ccc('0x3a')]['ids']),'SquareProjectId':Number(_0x4ebf68[_0x1ccc('0x4e')]['id'])});}});}})['then'](respondWithStatusCode(_0x402902,null))[_0x1ccc('0x4c')](handleError(_0x402902,null));};exports[_0x1ccc('0x61')]=function(_0x191802,_0x5c3053,_0x553d69){var _0x1cf16a={};var _0x2d8e56={};var _0x32d6e2;var _0x137c10;return db['SquareProject'][_0x1ccc('0x62')]({'where':{'id':_0x191802[_0x1ccc('0x4e')]['id']}})[_0x1ccc('0x2a')](handleEntityNotFound(_0x5c3053,null))[_0x1ccc('0x2a')](function(_0x393739){if(_0x393739){_0x32d6e2=_0x393739;_0x2d8e56['model']=_[_0x1ccc('0x4f')](db['User'][_0x1ccc('0x34')]);_0x2d8e56['query']=_[_0x1ccc('0x4f')](_0x191802[_0x1ccc('0x3a')]);_0x2d8e56[_0x1ccc('0x3b')]=_[_0x1ccc('0x3c')](_0x2d8e56[_0x1ccc('0x38')],_0x2d8e56['query']);_0x1cf16a[_0x1ccc('0x3d')]=_[_0x1ccc('0x3c')](_0x2d8e56[_0x1ccc('0x38')],qs['fields'](_0x191802[_0x1ccc('0x3a')]['fields']));_0x1cf16a[_0x1ccc('0x3d')]=_0x1cf16a['attributes']['length']?_0x1cf16a[_0x1ccc('0x3d')]:_0x2d8e56[_0x1ccc('0x38')];_0x1cf16a[_0x1ccc('0x40')]=qs['sort'](_0x191802[_0x1ccc('0x3a')][_0x1ccc('0x41')]);_0x1cf16a[_0x1ccc('0x43')]=qs[_0x1ccc('0x3b')](_[_0x1ccc('0x42')](_0x191802['query'],_0x2d8e56['filters']));if(_0x191802['query'][_0x1ccc('0x45')]){_0x1cf16a['where']=_[_0x1ccc('0x46')](_0x1cf16a[_0x1ccc('0x43')],{'$or':_[_0x1ccc('0x33')](_0x1cf16a[_0x1ccc('0x3d')],function(_0x5f3356){var _0x201bc9={};_0x201bc9[_0x5f3356]={'$like':'%'+_0x191802[_0x1ccc('0x3a')][_0x1ccc('0x45')]+'%'};return _0x201bc9;})});}_0x1cf16a=_[_0x1ccc('0x46')]({},_0x1cf16a,_0x191802['options']);return _0x32d6e2[_0x1ccc('0x61')](_0x1cf16a);}})[_0x1ccc('0x2a')](function(_0x4a468b){if(_0x4a468b){_0x137c10=_0x4a468b[_0x1ccc('0x5e')];if(!_0x191802[_0x1ccc('0x3a')][_0x1ccc('0x3f')](_0x1ccc('0x63'))){_0x1cf16a[_0x1ccc('0x25')]=qs[_0x1ccc('0x25')](_0x191802[_0x1ccc('0x3a')][_0x1ccc('0x25')]);_0x1cf16a[_0x1ccc('0x24')]=qs[_0x1ccc('0x24')](_0x191802[_0x1ccc('0x3a')]['offset']);}return _0x32d6e2[_0x1ccc('0x61')](_0x1cf16a);}})['then'](function(_0x39c65e){if(_0x39c65e){return _0x39c65e?{'count':_0x137c10,'rows':_0x39c65e}:null;}})['then'](respondWithResult(_0x5c3053,null))[_0x1ccc('0x4c')](handleError(_0x5c3053,null));};
\ No newline at end of file
+var _0x9e42=['query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','type','options','includeAll','rows','catch','show','params','merge','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','localhost','redis','register','status','offset','undefined','count','limit','set','json','update','then','destroy','get','SquareProjects','UserProfileResource','publish','stringify','end','error','name','send','index','map','SquareProject','rawAttributes','fieldName','key','model'];(function(_0x14f30b,_0x4ac7ca){var _0x248b2e=function(_0x800f64){while(--_0x800f64){_0x14f30b['push'](_0x14f30b['shift']());}};_0x248b2e(++_0x4ac7ca);}(_0x9e42,0x1dc));var _0x29e4=function(_0x5235a6,_0x680b76){_0x5235a6=_0x5235a6-0x0;var _0x1cf37e=_0x9e42[_0x5235a6];return _0x1cf37e;};'use strict';var _=require(_0x29e4('0x0'));var Redis=require(_0x29e4('0x1'));var qs=require(_0x29e4('0x2'));var logger=require(_0x29e4('0x3'))(_0x29e4('0x4'));var config=require(_0x29e4('0x5'));var db=require(_0x29e4('0x6'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0x29e4('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x29e4('0x8')]));require('./squareProject.socket')[_0x29e4('0x9')](socket);function respondWithResult(_0x38f655,_0x93aaae){_0x93aaae=_0x93aaae||0xc8;return function(_0x332234){if(_0x332234){return _0x38f655[_0x29e4('0xa')](_0x93aaae)['json'](_0x332234);}};}function respondWithFilteredResult(_0x4761d4,_0x473797){return function(_0x50c833){if(_0x50c833){var _0x524714=typeof _0x473797[_0x29e4('0xb')]===_0x29e4('0xc')&&typeof _0x473797['limit']===_0x29e4('0xc');var _0x3409b3=_0x50c833['count'];var _0x2309e6=_0x524714?0x0:_0x473797['offset'];var _0x2d9c52=_0x524714?_0x50c833[_0x29e4('0xd')]:_0x473797['offset']+_0x473797[_0x29e4('0xe')];var _0x12d715;if(_0x2d9c52>=_0x3409b3){_0x2d9c52=_0x3409b3;_0x12d715=0xc8;}else{_0x12d715=0xce;}_0x4761d4[_0x29e4('0xa')](_0x12d715);return _0x4761d4[_0x29e4('0xf')]('Content-Range',_0x2309e6+'-'+_0x2d9c52+'/'+_0x3409b3)[_0x29e4('0x10')](_0x50c833);}return null;};}function saveUpdates(_0x442bec){return function(_0x395162){if(_0x395162){return _0x395162[_0x29e4('0x11')](_0x442bec)[_0x29e4('0x12')](function(_0x73e6f5){return _0x73e6f5;});}return null;};}function removeEntity(_0x36125c){return function(_0x1d3fad){if(_0x1d3fad){return _0x1d3fad[_0x29e4('0x13')]()['then'](function(){var _0x44cf88=_0x1d3fad[_0x29e4('0x14')]({'plain':!![]});var _0x4ccaa4=_0x29e4('0x15');return db[_0x29e4('0x16')][_0x29e4('0x13')]({'where':{'type':_0x4ccaa4,'resourceId':_0x44cf88['id']}})[_0x29e4('0x12')](function(){return _0x1d3fad;});})[_0x29e4('0x12')](function(){var _0x4a26fa=new Redis(config[_0x29e4('0x8')]);_0x4a26fa[_0x29e4('0x17')]('agi',JSON[_0x29e4('0x18')]({'id':_0x1d3fad['id'],'deleted':!![]}));})['then'](function(){_0x36125c[_0x29e4('0xa')](0xcc)[_0x29e4('0x19')]();});}};}function handleEntityNotFound(_0x5d56c7){return function(_0x500230){if(!_0x500230){_0x5d56c7['sendStatus'](0x194);}return _0x500230;};}function handleError(_0xf2a29f,_0x412bd8){_0x412bd8=_0x412bd8||0x1f4;return function(_0x1cf111){logger[_0x29e4('0x1a')](_0x1cf111['stack']);if(_0x1cf111[_0x29e4('0x1b')]){delete _0x1cf111[_0x29e4('0x1b')];}_0xf2a29f[_0x29e4('0xa')](_0x412bd8)[_0x29e4('0x1c')](_0x1cf111);};}exports[_0x29e4('0x1d')]=function(_0x107830,_0x4f9c69){var _0x13a365={},_0x4c6e57={},_0x48d1d3={'count':0x0,'rows':[]};var _0x27b70d=_[_0x29e4('0x1e')](db[_0x29e4('0x1f')][_0x29e4('0x20')],function(_0x12700e){return{'name':_0x12700e[_0x29e4('0x21')],'type':_0x12700e['type'][_0x29e4('0x22')]};});_0x4c6e57[_0x29e4('0x23')]=_[_0x29e4('0x1e')](_0x27b70d,_0x29e4('0x1b'));_0x4c6e57[_0x29e4('0x24')]=_[_0x29e4('0x25')](_0x107830[_0x29e4('0x24')]);_0x4c6e57[_0x29e4('0x26')]=_[_0x29e4('0x27')](_0x4c6e57['model'],_0x4c6e57['query']);_0x13a365[_0x29e4('0x28')]=_['intersection'](_0x4c6e57[_0x29e4('0x23')],qs[_0x29e4('0x29')](_0x107830[_0x29e4('0x24')]['fields']));_0x13a365[_0x29e4('0x28')]=_0x13a365[_0x29e4('0x28')][_0x29e4('0x2a')]?_0x13a365[_0x29e4('0x28')]:_0x4c6e57['model'];if(!_0x107830['query'][_0x29e4('0x2b')](_0x29e4('0x2c'))){_0x13a365[_0x29e4('0xe')]=qs[_0x29e4('0xe')](_0x107830[_0x29e4('0x24')]['limit']);_0x13a365[_0x29e4('0xb')]=qs[_0x29e4('0xb')](_0x107830[_0x29e4('0x24')][_0x29e4('0xb')]);}_0x13a365[_0x29e4('0x2d')]=qs['sort'](_0x107830['query'][_0x29e4('0x2e')]);_0x13a365[_0x29e4('0x2f')]=qs[_0x29e4('0x26')](_[_0x29e4('0x30')](_0x107830[_0x29e4('0x24')],_0x4c6e57[_0x29e4('0x26')]),_0x27b70d);if(_0x107830[_0x29e4('0x24')][_0x29e4('0x31')]){_0x13a365[_0x29e4('0x2f')]=_['merge'](_0x13a365[_0x29e4('0x2f')],{'$or':_[_0x29e4('0x1e')](_0x27b70d,function(_0x527aa5){if(_0x527aa5[_0x29e4('0x32')]!=='VIRTUAL'){var _0x4057f6={};_0x4057f6[_0x527aa5[_0x29e4('0x1b')]]={'$like':'%'+_0x107830['query']['filter']+'%'};return _0x4057f6;}})});}_0x13a365=_['merge']({},_0x13a365,_0x107830[_0x29e4('0x33')]);var _0x2384c6={'where':_0x13a365[_0x29e4('0x2f')]};return db['SquareProject']['count'](_0x2384c6)[_0x29e4('0x12')](function(_0x418d44){_0x48d1d3[_0x29e4('0xd')]=_0x418d44;if(_0x107830[_0x29e4('0x24')][_0x29e4('0x34')]){_0x13a365['include']=[{'all':!![]}];}return db[_0x29e4('0x1f')]['findAll'](_0x13a365);})[_0x29e4('0x12')](function(_0x429f33){_0x48d1d3[_0x29e4('0x35')]=_0x429f33;return _0x48d1d3;})['then'](respondWithFilteredResult(_0x4f9c69,_0x13a365))[_0x29e4('0x36')](handleError(_0x4f9c69,null));};exports[_0x29e4('0x37')]=function(_0x3aaa9c,_0x36e714){var _0x170924={'raw':![],'where':{'id':_0x3aaa9c[_0x29e4('0x38')]['id']}},_0x274ad6={};_0x274ad6['model']=_[_0x29e4('0x25')](db[_0x29e4('0x1f')][_0x29e4('0x20')]);_0x274ad6[_0x29e4('0x24')]=_[_0x29e4('0x25')](_0x3aaa9c[_0x29e4('0x24')]);_0x274ad6[_0x29e4('0x26')]=_[_0x29e4('0x27')](_0x274ad6[_0x29e4('0x23')],_0x274ad6['query']);_0x170924['attributes']=_['intersection'](_0x274ad6[_0x29e4('0x23')],qs[_0x29e4('0x29')](_0x3aaa9c[_0x29e4('0x24')]['fields']));_0x170924[_0x29e4('0x28')]=_0x170924['attributes'][_0x29e4('0x2a')]?_0x170924[_0x29e4('0x28')]:_0x274ad6['model'];if(_0x3aaa9c[_0x29e4('0x24')][_0x29e4('0x34')]){_0x170924['include']=[{'all':!![]}];}_0x170924=_[_0x29e4('0x39')]({},_0x170924,_0x3aaa9c[_0x29e4('0x33')]);return db[_0x29e4('0x1f')][_0x29e4('0x3a')](_0x170924)[_0x29e4('0x12')](handleEntityNotFound(_0x36e714,null))[_0x29e4('0x12')](respondWithResult(_0x36e714,null))['catch'](handleError(_0x36e714,null));};exports[_0x29e4('0x3b')]=function(_0x49ec5e,_0x55e1f5){return db[_0x29e4('0x1f')]['create'](_0x49ec5e[_0x29e4('0x3c')],{})['then'](function(_0x31d40d){var _0x5c2ae2=_0x49ec5e[_0x29e4('0x3d')][_0x29e4('0x14')]({'plain':!![]});if(!_0x5c2ae2)throw new Error(_0x29e4('0x3e'));if(_0x5c2ae2[_0x29e4('0x3f')]===_0x29e4('0x3d')){var _0xee82d5=_0x31d40d[_0x29e4('0x14')]({'plain':!![]});var _0x4e5292=_0x29e4('0x15');return db['UserProfileSection'][_0x29e4('0x3a')]({'where':{'name':_0x4e5292,'userProfileId':_0x5c2ae2['userProfileId']},'raw':!![]})['then'](function(_0x3944f3){if(_0x3944f3&&_0x3944f3['autoAssociation']===0x0){return db[_0x29e4('0x16')][_0x29e4('0x3b')]({'name':_0xee82d5[_0x29e4('0x1b')],'resourceId':_0xee82d5['id'],'type':_0x3944f3[_0x29e4('0x1b')],'sectionId':_0x3944f3['id']},{})[_0x29e4('0x12')](function(){return _0x31d40d;});}else{return _0x31d40d;}})[_0x29e4('0x36')](function(_0x595158){logger[_0x29e4('0x1a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x595158);throw _0x595158;});}return _0x31d40d;})[_0x29e4('0x12')](respondWithResult(_0x55e1f5,0xc9))['catch'](handleError(_0x55e1f5,null));};exports['update']=function(_0x2897d5,_0x1be9f7){if(_0x2897d5[_0x29e4('0x3c')]['id']){delete _0x2897d5[_0x29e4('0x3c')]['id'];}return db[_0x29e4('0x1f')][_0x29e4('0x3a')]({'where':{'id':_0x2897d5['params']['id']}})[_0x29e4('0x12')](handleEntityNotFound(_0x1be9f7,null))[_0x29e4('0x12')](saveUpdates(_0x2897d5[_0x29e4('0x3c')],null))[_0x29e4('0x12')](function(_0x498393){if(!_0x498393)return;var _0x2b107b=_0x498393[_0x29e4('0x14')]({'plain':!![]});return _0x2b107b;})['then'](function(_0x5c9694){var _0x5f43e2=new Redis(config[_0x29e4('0x8')]);_0x5f43e2['publish']('agi',JSON[_0x29e4('0x18')](_[_0x29e4('0x30')](_0x5c9694,['id',_0x29e4('0x1b'),'production'])));return _0x5c9694;})['then'](respondWithResult(_0x1be9f7,null))[_0x29e4('0x36')](handleError(_0x1be9f7,null));};exports[_0x29e4('0x13')]=function(_0x1831bb,_0x43be85){return db['SquareProject']['find']({'where':{'id':_0x1831bb[_0x29e4('0x38')]['id']}})[_0x29e4('0x12')](handleEntityNotFound(_0x43be85,null))[_0x29e4('0x12')](removeEntity(_0x43be85,null))[_0x29e4('0x36')](handleError(_0x43be85,null));};
\ No newline at end of file