Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / squareProject / squareProject.controller.js
index 2f664d9..dab3113 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4bc7=['bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./squareProject.socket','register','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','then','destroy','get','SquareProjects','UserProfileResource','error','stack','name','send','map','SquareProject','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','include','findAll','rows','catch','params','keys','rawAttributes','filtears','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','addUsers','ids','removeUsers','emit','userSquareProject:remove','findOne','getUsers','nolimit','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment'];(function(_0x4b369d,_0x265eb8){var _0x571a98=function(_0x56341a){while(--_0x56341a){_0x4b369d['push'](_0x4b369d['shift']());}};_0x571a98(++_0x265eb8);}(_0x4bc7,0x196));var _0x74bc=function(_0x5dbaa7,_0x1f6d4a){_0x5dbaa7=_0x5dbaa7-0x0;var _0x481319=_0x4bc7[_0x5dbaa7];return _0x481319;};'use strict';var pdf=require(_0x74bc('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x74bc('0x1'));var zipdir=require(_0x74bc('0x2'));var jsonpatch=require(_0x74bc('0x3'));var rp=require(_0x74bc('0x4'));var moment=require(_0x74bc('0x5'));var BPromise=require(_0x74bc('0x6'));var Mustache=require(_0x74bc('0x7'));var util=require(_0x74bc('0x8'));var path=require(_0x74bc('0x9'));var sox=require(_0x74bc('0xa'));var csv=require(_0x74bc('0xb'));var ejs=require(_0x74bc('0xc'));var fs=require('fs');var _=require(_0x74bc('0xd'));var squel=require('squel');var crypto=require(_0x74bc('0xe'));var jsforce=require(_0x74bc('0xf'));var deskjs=require(_0x74bc('0x10'));var toCsv=require(_0x74bc('0xb'));var querystring=require(_0x74bc('0x11'));var Papa=require(_0x74bc('0x12'));var Redis=require(_0x74bc('0x13'));var authService=require(_0x74bc('0x14'));var qs=require(_0x74bc('0x15'));var as=require(_0x74bc('0x16'));var hardwareService=require(_0x74bc('0x17'));var logger=require(_0x74bc('0x18'))(_0x74bc('0x19'));var utils=require(_0x74bc('0x1a'));var config=require(_0x74bc('0x1b'));var licenseUtil=require(_0x74bc('0x1c'));var db=require(_0x74bc('0x1d'))['db'];config[_0x74bc('0x1e')]=_[_0x74bc('0x1f')](config[_0x74bc('0x1e')],{'host':_0x74bc('0x20'),'port':0x18eb});var socket=require(_0x74bc('0x21'))(new Redis(config['redis']));require(_0x74bc('0x22'))[_0x74bc('0x23')](socket);function respondWithStatusCode(_0x576b7a,_0x257ecd){_0x257ecd=_0x257ecd||0xcc;return function(_0x308be1){if(_0x308be1){return _0x576b7a['sendStatus'](_0x257ecd);}return _0x576b7a[_0x74bc('0x24')](_0x257ecd)[_0x74bc('0x25')]();};}function respondWithResult(_0x5c0c77,_0x16c271){_0x16c271=_0x16c271||0xc8;return function(_0x42f584){if(_0x42f584){return _0x5c0c77[_0x74bc('0x24')](_0x16c271)[_0x74bc('0x26')](_0x42f584);}};}function respondWithFilteredResult(_0x3b1eb1,_0x42956c){return function(_0x354e80){if(_0x354e80){var _0x1c7021=_0x354e80[_0x74bc('0x27')],_0x4a26c4=_0x42956c[_0x74bc('0x28')],_0x2487ad=_0x42956c[_0x74bc('0x28')]+_0x42956c[_0x74bc('0x29')],_0x495a80;if(_0x2487ad>=_0x1c7021){_0x2487ad=_0x1c7021;_0x495a80=0xc8;}else{_0x495a80=0xce;}_0x3b1eb1['status'](_0x495a80);return _0x3b1eb1[_0x74bc('0x2a')](_0x74bc('0x2b'),_0x4a26c4+'-'+_0x2487ad+'/'+_0x1c7021)[_0x74bc('0x26')](_0x354e80);}return null;};}function patchUpdates(_0x5c927d){return function(_0x1e2a59){try{jsonpatch[_0x74bc('0x2c')](_0x1e2a59,_0x5c927d,!![]);}catch(_0x38f660){return BPromise[_0x74bc('0x2d')](_0x38f660);}return _0x1e2a59[_0x74bc('0x2e')]();};}function saveUpdates(_0x4edb05,_0x589314){return function(_0x2fd5a7){if(_0x2fd5a7){return _0x2fd5a7['update'](_0x4edb05)[_0x74bc('0x2f')](function(_0x111edb){return _0x111edb;});}return null;};}function removeEntity(_0x526ebe,_0x276e52){return function(_0x21cca6){if(_0x21cca6){return _0x21cca6[_0x74bc('0x30')]()[_0x74bc('0x2f')](function(){var _0x500010=_0x21cca6[_0x74bc('0x31')]({'plain':!![]});var _0x65aa0a=_0x74bc('0x32');return db[_0x74bc('0x33')][_0x74bc('0x30')]({'where':{'type':_0x65aa0a,'resourceId':_0x500010['id']}})['then'](function(){return _0x21cca6;});})['then'](function(){_0x526ebe['status'](0xcc)[_0x74bc('0x25')]();});}};}function handleEntityNotFound(_0x51b55a,_0x152c95){return function(_0x2b4ab1){if(!_0x2b4ab1){_0x51b55a['sendStatus'](0x194);}return _0x2b4ab1;};}function handleError(_0x58f8af,_0x416cc){_0x416cc=_0x416cc||0x1f4;return function(_0x426110){logger[_0x74bc('0x34')](_0x426110[_0x74bc('0x35')]);if(_0x426110[_0x74bc('0x36')]){delete _0x426110[_0x74bc('0x36')];}_0x58f8af[_0x74bc('0x24')](_0x416cc)[_0x74bc('0x37')](_0x426110);};}exports['index']=function(_0x4c166b,_0x22ca7a){var _0x36d681={},_0x2c62fc={},_0x244c7a={'count':0x0,'rows':[]};var _0x3fa356=_[_0x74bc('0x38')](db[_0x74bc('0x39')]['rawAttributes'],function(_0x10d42b){return{'name':_0x10d42b[_0x74bc('0x3a')],'type':_0x10d42b[_0x74bc('0x3b')][_0x74bc('0x3c')]};});_0x2c62fc[_0x74bc('0x3d')]=_[_0x74bc('0x38')](_0x3fa356,_0x74bc('0x36'));_0x2c62fc[_0x74bc('0x3e')]=_['keys'](_0x4c166b['query']);_0x2c62fc[_0x74bc('0x3f')]=_[_0x74bc('0x40')](_0x2c62fc[_0x74bc('0x3d')],_0x2c62fc['query']);_0x36d681[_0x74bc('0x41')]=_[_0x74bc('0x40')](_0x2c62fc['model'],qs[_0x74bc('0x42')](_0x4c166b[_0x74bc('0x3e')]['fields']));_0x36d681[_0x74bc('0x41')]=_0x36d681[_0x74bc('0x41')][_0x74bc('0x43')]?_0x36d681[_0x74bc('0x41')]:_0x2c62fc[_0x74bc('0x3d')];if(!_0x4c166b[_0x74bc('0x3e')][_0x74bc('0x44')]('nolimit')){_0x36d681['limit']=qs[_0x74bc('0x29')](_0x4c166b[_0x74bc('0x3e')][_0x74bc('0x29')]);_0x36d681[_0x74bc('0x28')]=qs['offset'](_0x4c166b[_0x74bc('0x3e')][_0x74bc('0x28')]);}_0x36d681[_0x74bc('0x45')]=qs[_0x74bc('0x46')](_0x4c166b[_0x74bc('0x3e')][_0x74bc('0x46')]);_0x36d681[_0x74bc('0x47')]=qs[_0x74bc('0x3f')](_[_0x74bc('0x48')](_0x4c166b['query'],_0x2c62fc[_0x74bc('0x3f')]),_0x3fa356);if(_0x4c166b[_0x74bc('0x3e')][_0x74bc('0x49')]){_0x36d681[_0x74bc('0x47')]=_[_0x74bc('0x4a')](_0x36d681[_0x74bc('0x47')],{'$or':_[_0x74bc('0x38')](_0x3fa356,function(_0x1c3aa3){if(_0x1c3aa3[_0x74bc('0x3b')]!==_0x74bc('0x4b')){var _0x3b2242={};_0x3b2242[_0x1c3aa3[_0x74bc('0x36')]]={'$like':'%'+_0x4c166b[_0x74bc('0x3e')][_0x74bc('0x49')]+'%'};return _0x3b2242;}})});}_0x36d681=_[_0x74bc('0x4a')]({},_0x36d681,_0x4c166b[_0x74bc('0x4c')]);var _0x1057fc={'where':_0x36d681[_0x74bc('0x47')]};return db[_0x74bc('0x39')]['count'](_0x1057fc)[_0x74bc('0x2f')](function(_0x7ee04a){_0x244c7a[_0x74bc('0x27')]=_0x7ee04a;if(_0x4c166b[_0x74bc('0x3e')]['includeAll']){_0x36d681[_0x74bc('0x4d')]=[{'all':!![]}];}return db['SquareProject'][_0x74bc('0x4e')](_0x36d681);})[_0x74bc('0x2f')](function(_0x1f80f0){_0x244c7a[_0x74bc('0x4f')]=_0x1f80f0;return _0x244c7a;})['then'](respondWithFilteredResult(_0x22ca7a,_0x36d681))[_0x74bc('0x50')](handleError(_0x22ca7a,null));};exports['show']=function(_0x5d02ae,_0x255773){var _0x327038={'raw':![],'where':{'id':_0x5d02ae[_0x74bc('0x51')]['id']}},_0x127231={};_0x127231[_0x74bc('0x3d')]=_[_0x74bc('0x52')](db[_0x74bc('0x39')][_0x74bc('0x53')]);_0x127231[_0x74bc('0x3e')]=_[_0x74bc('0x52')](_0x5d02ae[_0x74bc('0x3e')]);_0x127231[_0x74bc('0x54')]=_[_0x74bc('0x40')](_0x127231[_0x74bc('0x3d')],_0x127231[_0x74bc('0x3e')]);_0x327038[_0x74bc('0x41')]=_[_0x74bc('0x40')](_0x127231[_0x74bc('0x3d')],qs['fields'](_0x5d02ae[_0x74bc('0x3e')][_0x74bc('0x42')]));_0x327038[_0x74bc('0x41')]=_0x327038['attributes'][_0x74bc('0x43')]?_0x327038[_0x74bc('0x41')]:_0x127231[_0x74bc('0x3d')];if(_0x5d02ae['query']['includeAll']){_0x327038[_0x74bc('0x4d')]=[{'all':!![]}];}_0x327038=_[_0x74bc('0x4a')]({},_0x327038,_0x5d02ae[_0x74bc('0x4c')]);return db['SquareProject'][_0x74bc('0x55')](_0x327038)['then'](handleEntityNotFound(_0x255773,null))[_0x74bc('0x2f')](respondWithResult(_0x255773,null))[_0x74bc('0x50')](handleError(_0x255773,null));};exports[_0x74bc('0x56')]=function(_0x334c05,_0x1bf666){return db['SquareProject'][_0x74bc('0x56')](_0x334c05[_0x74bc('0x57')],{})[_0x74bc('0x2f')](function(_0x3ca301){var _0x59d6cf=_0x334c05[_0x74bc('0x58')][_0x74bc('0x31')]({'plain':!![]});if(!_0x59d6cf)throw new Error(_0x74bc('0x59'));if(_0x59d6cf[_0x74bc('0x5a')]===_0x74bc('0x58')){var _0x676ec1=_0x3ca301[_0x74bc('0x31')]({'plain':!![]});var _0x162087=_0x74bc('0x32');return db['UserProfileSection'][_0x74bc('0x55')]({'where':{'name':_0x162087,'userProfileId':_0x59d6cf[_0x74bc('0x5b')]},'raw':!![]})[_0x74bc('0x2f')](function(_0x48028c){if(_0x48028c&&_0x48028c[_0x74bc('0x5c')]===0x0){return db[_0x74bc('0x33')][_0x74bc('0x56')]({'name':_0x676ec1[_0x74bc('0x36')],'resourceId':_0x676ec1['id'],'type':_0x48028c[_0x74bc('0x36')],'sectionId':_0x48028c['id']},{})[_0x74bc('0x2f')](function(){return _0x3ca301;});}else{return _0x3ca301;}})[_0x74bc('0x50')](function(_0x30cc04){logger[_0x74bc('0x34')](_0x74bc('0x5d'),_0x30cc04);throw _0x30cc04;});}return _0x3ca301;})[_0x74bc('0x2f')](respondWithResult(_0x1bf666,0xc9))[_0x74bc('0x50')](handleError(_0x1bf666,null));};exports[_0x74bc('0x5e')]=function(_0x2290fa,_0x599593){if(_0x2290fa[_0x74bc('0x57')]['id']){delete _0x2290fa[_0x74bc('0x57')]['id'];}return db[_0x74bc('0x39')][_0x74bc('0x55')]({'where':{'id':_0x2290fa[_0x74bc('0x51')]['id']}})['then'](handleEntityNotFound(_0x599593,null))[_0x74bc('0x2f')](saveUpdates(_0x2290fa[_0x74bc('0x57')],null))[_0x74bc('0x2f')](respondWithResult(_0x599593,null))['catch'](handleError(_0x599593,null));};exports[_0x74bc('0x30')]=function(_0x532884,_0x593246){return db[_0x74bc('0x39')][_0x74bc('0x55')]({'where':{'id':_0x532884['params']['id']}})[_0x74bc('0x2f')](handleEntityNotFound(_0x593246,null))[_0x74bc('0x2f')](removeEntity(_0x593246,null))[_0x74bc('0x50')](handleError(_0x593246,null));};exports[_0x74bc('0x5f')]=function(_0x434c97,_0x549762,_0x49be58){return db[_0x74bc('0x39')][_0x74bc('0x55')]({'where':{'id':_0x434c97[_0x74bc('0x51')]['id']}})[_0x74bc('0x2f')](handleEntityNotFound(_0x549762,null))[_0x74bc('0x2f')](function(_0x421254){if(_0x421254){return _0x421254[_0x74bc('0x5f')](_0x434c97['body'][_0x74bc('0x60')],_['omit'](_0x434c97[_0x74bc('0x57')],[_0x74bc('0x60'),'id'])||{});}})['then'](respondWithResult(_0x549762,null))[_0x74bc('0x50')](handleError(_0x549762,null));};exports[_0x74bc('0x61')]=function(_0x43c9a6,_0xc5bba,_0x17c5c0){return db[_0x74bc('0x39')][_0x74bc('0x55')]({'where':{'id':_0x43c9a6[_0x74bc('0x51')]['id']}})[_0x74bc('0x2f')](handleEntityNotFound(_0xc5bba,null))[_0x74bc('0x2f')](function(_0x1f563c){if(_0x1f563c){return _0x1f563c[_0x74bc('0x61')](_0x43c9a6['query'][_0x74bc('0x60')])[_0x74bc('0x2f')](function(){if(_['isArray'](_0x43c9a6[_0x74bc('0x3e')][_0x74bc('0x60')])){for(var _0x38b274=0x0;_0x38b274<_0x43c9a6['query'][_0x74bc('0x60')][_0x74bc('0x43')];_0x38b274+=0x1){socket[_0x74bc('0x62')](_0x74bc('0x63'),{'UserId':Number(_0x43c9a6['query']['ids'][_0x38b274]),'SquareProjectId':Number(_0x43c9a6['params']['id'])});}}else{socket[_0x74bc('0x62')](_0x74bc('0x63'),{'UserId':Number(_0x43c9a6[_0x74bc('0x3e')][_0x74bc('0x60')]),'SquareProjectId':Number(_0x43c9a6[_0x74bc('0x51')]['id'])});}});}})['then'](respondWithStatusCode(_0xc5bba,null))[_0x74bc('0x50')](handleError(_0xc5bba,null));};exports['getUsers']=function(_0x254d3e,_0x70f18c,_0x5d12af){var _0x49e5a9={};var _0x2fe76f={};var _0x11bcb1;var _0x1f1ecf;return db[_0x74bc('0x39')][_0x74bc('0x64')]({'where':{'id':_0x254d3e['params']['id']}})[_0x74bc('0x2f')](handleEntityNotFound(_0x70f18c,null))[_0x74bc('0x2f')](function(_0x150995){if(_0x150995){_0x11bcb1=_0x150995;_0x2fe76f['model']=_[_0x74bc('0x52')](db['User'][_0x74bc('0x53')]);_0x2fe76f[_0x74bc('0x3e')]=_[_0x74bc('0x52')](_0x254d3e['query']);_0x2fe76f[_0x74bc('0x3f')]=_[_0x74bc('0x40')](_0x2fe76f['model'],_0x2fe76f[_0x74bc('0x3e')]);_0x49e5a9['attributes']=_['intersection'](_0x2fe76f[_0x74bc('0x3d')],qs[_0x74bc('0x42')](_0x254d3e[_0x74bc('0x3e')]['fields']));_0x49e5a9[_0x74bc('0x41')]=_0x49e5a9[_0x74bc('0x41')][_0x74bc('0x43')]?_0x49e5a9['attributes']:_0x2fe76f[_0x74bc('0x3d')];_0x49e5a9[_0x74bc('0x45')]=qs[_0x74bc('0x46')](_0x254d3e[_0x74bc('0x3e')][_0x74bc('0x46')]);_0x49e5a9['where']=qs[_0x74bc('0x3f')](_[_0x74bc('0x48')](_0x254d3e[_0x74bc('0x3e')],_0x2fe76f[_0x74bc('0x3f')]));if(_0x254d3e[_0x74bc('0x3e')][_0x74bc('0x49')]){_0x49e5a9['where']=_[_0x74bc('0x4a')](_0x49e5a9['where'],{'$or':_[_0x74bc('0x38')](_0x49e5a9[_0x74bc('0x41')],function(_0x361826){var _0x1609c8={};_0x1609c8[_0x361826]={'$like':'%'+_0x254d3e[_0x74bc('0x3e')][_0x74bc('0x49')]+'%'};return _0x1609c8;})});}_0x49e5a9=_['merge']({},_0x49e5a9,_0x254d3e[_0x74bc('0x4c')]);return _0x11bcb1[_0x74bc('0x65')](_0x49e5a9);}})[_0x74bc('0x2f')](function(_0x55288e){if(_0x55288e){_0x1f1ecf=_0x55288e[_0x74bc('0x43')];if(!_0x254d3e[_0x74bc('0x3e')][_0x74bc('0x44')](_0x74bc('0x66'))){_0x49e5a9[_0x74bc('0x29')]=qs['limit'](_0x254d3e[_0x74bc('0x3e')][_0x74bc('0x29')]);_0x49e5a9[_0x74bc('0x28')]=qs[_0x74bc('0x28')](_0x254d3e[_0x74bc('0x3e')][_0x74bc('0x28')]);}return _0x11bcb1[_0x74bc('0x65')](_0x49e5a9);}})[_0x74bc('0x2f')](function(_0x14294a){if(_0x14294a){return _0x14294a?{'count':_0x1f1ecf,'rows':_0x14294a}:null;}})[_0x74bc('0x2f')](respondWithResult(_0x70f18c,null))[_0x74bc('0x50')](handleError(_0x70f18c,null));};
\ No newline at end of file
+var _0x62f7=['attributes','fields','nolimit','limit','sort','where','pick','filter','merge','VIRTUAL','options','findAll','rows','catch','params','filtears','includeAll','include','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','SquareProjects','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','addUsers','ids','omit','removeUsers','isArray','length','emit','userSquareProject:remove','getUsers','User','hasOwnProperty','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','path','to-csv','ejs','lodash','squel','crypto','jsforce','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./squareProject.socket','register','sendStatus','status','end','json','count','offset','set','apply','reject','save','then','destroy','get','UserProfileResource','error','name','send','index','SquareProject','rawAttributes','type','key','model','map','query','keys','filters','intersection'];(function(_0x24259d,_0x64a194){var _0x5a701=function(_0x204516){while(--_0x204516){_0x24259d['push'](_0x24259d['shift']());}};_0x5a701(++_0x64a194);}(_0x62f7,0x1ad));var _0x762f=function(_0x264a4f,_0x432d1e){_0x264a4f=_0x264a4f-0x0;var _0x49af90=_0x62f7[_0x264a4f];return _0x49af90;};'use strict';var pdf=require(_0x762f('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x762f('0x1'));var zipdir=require(_0x762f('0x2'));var jsonpatch=require(_0x762f('0x3'));var rp=require(_0x762f('0x4'));var moment=require(_0x762f('0x5'));var BPromise=require(_0x762f('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0x762f('0x7'));var sox=require('sox');var csv=require(_0x762f('0x8'));var ejs=require(_0x762f('0x9'));var fs=require('fs');var _=require(_0x762f('0xa'));var squel=require(_0x762f('0xb'));var crypto=require(_0x762f('0xc'));var jsforce=require(_0x762f('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x762f('0x8'));var querystring=require('querystring');var Papa=require(_0x762f('0xe'));var Redis=require('ioredis');var authService=require(_0x762f('0xf'));var qs=require(_0x762f('0x10'));var as=require(_0x762f('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x762f('0x12'));var utils=require(_0x762f('0x13'));var config=require(_0x762f('0x14'));var licenseUtil=require(_0x762f('0x15'));var db=require(_0x762f('0x16'))['db'];config[_0x762f('0x17')]=_[_0x762f('0x18')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x762f('0x19'))(new Redis(config[_0x762f('0x17')]));require(_0x762f('0x1a'))[_0x762f('0x1b')](socket);function respondWithStatusCode(_0xe00dfc,_0x206e77){_0x206e77=_0x206e77||0xcc;return function(_0x48c4c7){if(_0x48c4c7){return _0xe00dfc[_0x762f('0x1c')](_0x206e77);}return _0xe00dfc[_0x762f('0x1d')](_0x206e77)[_0x762f('0x1e')]();};}function respondWithResult(_0x5d49fa,_0x2bca3e){_0x2bca3e=_0x2bca3e||0xc8;return function(_0xafae1b){if(_0xafae1b){return _0x5d49fa[_0x762f('0x1d')](_0x2bca3e)[_0x762f('0x1f')](_0xafae1b);}};}function respondWithFilteredResult(_0x1ab3e0,_0x3936ad){return function(_0x4c22a6){if(_0x4c22a6){var _0x3ed4d0=_0x4c22a6[_0x762f('0x20')],_0x4c3906=_0x3936ad[_0x762f('0x21')],_0x4fdc45=_0x3936ad[_0x762f('0x21')]+_0x3936ad['limit'],_0x3c81c7;if(_0x4fdc45>=_0x3ed4d0){_0x4fdc45=_0x3ed4d0;_0x3c81c7=0xc8;}else{_0x3c81c7=0xce;}_0x1ab3e0[_0x762f('0x1d')](_0x3c81c7);return _0x1ab3e0[_0x762f('0x22')]('Content-Range',_0x4c3906+'-'+_0x4fdc45+'/'+_0x3ed4d0)['json'](_0x4c22a6);}return null;};}function patchUpdates(_0x303d0a){return function(_0x34206a){try{jsonpatch[_0x762f('0x23')](_0x34206a,_0x303d0a,!![]);}catch(_0x4ad26d){return BPromise[_0x762f('0x24')](_0x4ad26d);}return _0x34206a[_0x762f('0x25')]();};}function saveUpdates(_0x31333e,_0x160e6a){return function(_0x42d4c3){if(_0x42d4c3){return _0x42d4c3['update'](_0x31333e)[_0x762f('0x26')](function(_0x1cc834){return _0x1cc834;});}return null;};}function removeEntity(_0x29fda9,_0x2639cd){return function(_0x41eb47){if(_0x41eb47){return _0x41eb47[_0x762f('0x27')]()[_0x762f('0x26')](function(){var _0x16dbf8=_0x41eb47[_0x762f('0x28')]({'plain':!![]});var _0x4e0ec6='SquareProjects';return db[_0x762f('0x29')][_0x762f('0x27')]({'where':{'type':_0x4e0ec6,'resourceId':_0x16dbf8['id']}})[_0x762f('0x26')](function(){return _0x41eb47;});})['then'](function(){_0x29fda9[_0x762f('0x1d')](0xcc)[_0x762f('0x1e')]();});}};}function handleEntityNotFound(_0x504942,_0x42ac3a){return function(_0xe7173c){if(!_0xe7173c){_0x504942[_0x762f('0x1c')](0x194);}return _0xe7173c;};}function handleError(_0x514413,_0x49c673){_0x49c673=_0x49c673||0x1f4;return function(_0x9ebfc6){logger[_0x762f('0x2a')](_0x9ebfc6['stack']);if(_0x9ebfc6[_0x762f('0x2b')]){delete _0x9ebfc6['name'];}_0x514413[_0x762f('0x1d')](_0x49c673)[_0x762f('0x2c')](_0x9ebfc6);};}exports[_0x762f('0x2d')]=function(_0x36d99f,_0x3d2883){var _0x3a4049={},_0x4f73aa={},_0x196a04={'count':0x0,'rows':[]};var _0x3d1ffa=_['map'](db[_0x762f('0x2e')][_0x762f('0x2f')],function(_0x422480){return{'name':_0x422480['fieldName'],'type':_0x422480[_0x762f('0x30')][_0x762f('0x31')]};});_0x4f73aa[_0x762f('0x32')]=_[_0x762f('0x33')](_0x3d1ffa,_0x762f('0x2b'));_0x4f73aa[_0x762f('0x34')]=_[_0x762f('0x35')](_0x36d99f[_0x762f('0x34')]);_0x4f73aa[_0x762f('0x36')]=_[_0x762f('0x37')](_0x4f73aa[_0x762f('0x32')],_0x4f73aa[_0x762f('0x34')]);_0x3a4049[_0x762f('0x38')]=_[_0x762f('0x37')](_0x4f73aa[_0x762f('0x32')],qs['fields'](_0x36d99f['query'][_0x762f('0x39')]));_0x3a4049[_0x762f('0x38')]=_0x3a4049['attributes']['length']?_0x3a4049[_0x762f('0x38')]:_0x4f73aa[_0x762f('0x32')];if(!_0x36d99f[_0x762f('0x34')]['hasOwnProperty'](_0x762f('0x3a'))){_0x3a4049[_0x762f('0x3b')]=qs[_0x762f('0x3b')](_0x36d99f[_0x762f('0x34')][_0x762f('0x3b')]);_0x3a4049[_0x762f('0x21')]=qs[_0x762f('0x21')](_0x36d99f[_0x762f('0x34')][_0x762f('0x21')]);}_0x3a4049['order']=qs[_0x762f('0x3c')](_0x36d99f[_0x762f('0x34')]['sort']);_0x3a4049[_0x762f('0x3d')]=qs[_0x762f('0x36')](_[_0x762f('0x3e')](_0x36d99f[_0x762f('0x34')],_0x4f73aa['filters']),_0x3d1ffa);if(_0x36d99f[_0x762f('0x34')][_0x762f('0x3f')]){_0x3a4049[_0x762f('0x3d')]=_[_0x762f('0x40')](_0x3a4049['where'],{'$or':_['map'](_0x3d1ffa,function(_0x66a1cf){if(_0x66a1cf['type']!==_0x762f('0x41')){var _0x5a5c67={};_0x5a5c67[_0x66a1cf[_0x762f('0x2b')]]={'$like':'%'+_0x36d99f[_0x762f('0x34')][_0x762f('0x3f')]+'%'};return _0x5a5c67;}})});}_0x3a4049=_[_0x762f('0x40')]({},_0x3a4049,_0x36d99f[_0x762f('0x42')]);var _0x16d0c5={'where':_0x3a4049['where']};return db[_0x762f('0x2e')]['count'](_0x16d0c5)[_0x762f('0x26')](function(_0x5939e2){_0x196a04[_0x762f('0x20')]=_0x5939e2;if(_0x36d99f['query']['includeAll']){_0x3a4049['include']=[{'all':!![]}];}return db[_0x762f('0x2e')][_0x762f('0x43')](_0x3a4049);})[_0x762f('0x26')](function(_0x2aec3c){_0x196a04[_0x762f('0x44')]=_0x2aec3c;return _0x196a04;})['then'](respondWithFilteredResult(_0x3d2883,_0x3a4049))[_0x762f('0x45')](handleError(_0x3d2883,null));};exports['show']=function(_0x406f89,_0x4532de){var _0x38ef07={'raw':![],'where':{'id':_0x406f89[_0x762f('0x46')]['id']}},_0x58a40d={};_0x58a40d['model']=_[_0x762f('0x35')](db[_0x762f('0x2e')][_0x762f('0x2f')]);_0x58a40d[_0x762f('0x34')]=_[_0x762f('0x35')](_0x406f89[_0x762f('0x34')]);_0x58a40d[_0x762f('0x47')]=_[_0x762f('0x37')](_0x58a40d['model'],_0x58a40d[_0x762f('0x34')]);_0x38ef07[_0x762f('0x38')]=_[_0x762f('0x37')](_0x58a40d[_0x762f('0x32')],qs[_0x762f('0x39')](_0x406f89[_0x762f('0x34')]['fields']));_0x38ef07[_0x762f('0x38')]=_0x38ef07[_0x762f('0x38')]['length']?_0x38ef07[_0x762f('0x38')]:_0x58a40d[_0x762f('0x32')];if(_0x406f89[_0x762f('0x34')][_0x762f('0x48')]){_0x38ef07[_0x762f('0x49')]=[{'all':!![]}];}_0x38ef07=_[_0x762f('0x40')]({},_0x38ef07,_0x406f89['options']);return db[_0x762f('0x2e')][_0x762f('0x4a')](_0x38ef07)[_0x762f('0x26')](handleEntityNotFound(_0x4532de,null))[_0x762f('0x26')](respondWithResult(_0x4532de,null))[_0x762f('0x45')](handleError(_0x4532de,null));};exports[_0x762f('0x4b')]=function(_0x3d5edb,_0x2a9540){return db['SquareProject']['create'](_0x3d5edb[_0x762f('0x4c')],{})[_0x762f('0x26')](function(_0x46b6a8){var _0x24d482=_0x3d5edb['user'][_0x762f('0x28')]({'plain':!![]});if(!_0x24d482)throw new Error(_0x762f('0x4d'));if(_0x24d482[_0x762f('0x4e')]===_0x762f('0x4f')){var _0x5ba400=_0x46b6a8[_0x762f('0x28')]({'plain':!![]});var _0x5cc1e4=_0x762f('0x50');return db[_0x762f('0x51')][_0x762f('0x4a')]({'where':{'name':_0x5cc1e4,'userProfileId':_0x24d482[_0x762f('0x52')]},'raw':!![]})[_0x762f('0x26')](function(_0x4232a4){if(_0x4232a4&&_0x4232a4[_0x762f('0x53')]===0x0){return db[_0x762f('0x29')][_0x762f('0x4b')]({'name':_0x5ba400['name'],'resourceId':_0x5ba400['id'],'type':_0x4232a4['name'],'sectionId':_0x4232a4['id']},{})[_0x762f('0x26')](function(){return _0x46b6a8;});}else{return _0x46b6a8;}})['catch'](function(_0x2ca9cf){logger['error'](_0x762f('0x54'),_0x2ca9cf);throw _0x2ca9cf;});}return _0x46b6a8;})[_0x762f('0x26')](respondWithResult(_0x2a9540,0xc9))['catch'](handleError(_0x2a9540,null));};exports[_0x762f('0x55')]=function(_0x3b8e49,_0x4c3d2b){if(_0x3b8e49['body']['id']){delete _0x3b8e49[_0x762f('0x4c')]['id'];}return db[_0x762f('0x2e')][_0x762f('0x4a')]({'where':{'id':_0x3b8e49['params']['id']}})['then'](handleEntityNotFound(_0x4c3d2b,null))[_0x762f('0x26')](saveUpdates(_0x3b8e49[_0x762f('0x4c')],null))['then'](respondWithResult(_0x4c3d2b,null))[_0x762f('0x45')](handleError(_0x4c3d2b,null));};exports[_0x762f('0x27')]=function(_0x14f628,_0x162215){return db[_0x762f('0x2e')][_0x762f('0x4a')]({'where':{'id':_0x14f628[_0x762f('0x46')]['id']}})[_0x762f('0x26')](handleEntityNotFound(_0x162215,null))['then'](removeEntity(_0x162215,null))['catch'](handleError(_0x162215,null));};exports[_0x762f('0x56')]=function(_0x572b36,_0x17db1b,_0x57d1a5){return db[_0x762f('0x2e')][_0x762f('0x4a')]({'where':{'id':_0x572b36['params']['id']}})[_0x762f('0x26')](handleEntityNotFound(_0x17db1b,null))[_0x762f('0x26')](function(_0x5fc1f3){if(_0x5fc1f3){return _0x5fc1f3[_0x762f('0x56')](_0x572b36[_0x762f('0x4c')][_0x762f('0x57')],_[_0x762f('0x58')](_0x572b36[_0x762f('0x4c')],['ids','id'])||{});}})[_0x762f('0x26')](respondWithResult(_0x17db1b,null))[_0x762f('0x45')](handleError(_0x17db1b,null));};exports[_0x762f('0x59')]=function(_0xa017e5,_0x17c5d4,_0x183031){return db['SquareProject'][_0x762f('0x4a')]({'where':{'id':_0xa017e5[_0x762f('0x46')]['id']}})[_0x762f('0x26')](handleEntityNotFound(_0x17c5d4,null))[_0x762f('0x26')](function(_0x1049a7){if(_0x1049a7){return _0x1049a7[_0x762f('0x59')](_0xa017e5['query'][_0x762f('0x57')])[_0x762f('0x26')](function(){if(_[_0x762f('0x5a')](_0xa017e5[_0x762f('0x34')]['ids'])){for(var _0x55bb2b=0x0;_0x55bb2b<_0xa017e5[_0x762f('0x34')][_0x762f('0x57')][_0x762f('0x5b')];_0x55bb2b+=0x1){socket[_0x762f('0x5c')](_0x762f('0x5d'),{'UserId':Number(_0xa017e5['query'][_0x762f('0x57')][_0x55bb2b]),'SquareProjectId':Number(_0xa017e5[_0x762f('0x46')]['id'])});}}else{socket[_0x762f('0x5c')](_0x762f('0x5d'),{'UserId':Number(_0xa017e5['query'][_0x762f('0x57')]),'SquareProjectId':Number(_0xa017e5[_0x762f('0x46')]['id'])});}});}})['then'](respondWithStatusCode(_0x17c5d4,null))[_0x762f('0x45')](handleError(_0x17c5d4,null));};exports[_0x762f('0x5e')]=function(_0x490ef8,_0x1663eb,_0x5cd8a4){var _0x273e93={};var _0x332faa={};var _0xa40f07;var _0x122e07;return db['SquareProject']['findOne']({'where':{'id':_0x490ef8[_0x762f('0x46')]['id']}})['then'](handleEntityNotFound(_0x1663eb,null))[_0x762f('0x26')](function(_0x2150c6){if(_0x2150c6){_0xa40f07=_0x2150c6;_0x332faa[_0x762f('0x32')]=_[_0x762f('0x35')](db[_0x762f('0x5f')][_0x762f('0x2f')]);_0x332faa[_0x762f('0x34')]=_['keys'](_0x490ef8[_0x762f('0x34')]);_0x332faa['filters']=_[_0x762f('0x37')](_0x332faa['model'],_0x332faa[_0x762f('0x34')]);_0x273e93[_0x762f('0x38')]=_['intersection'](_0x332faa[_0x762f('0x32')],qs[_0x762f('0x39')](_0x490ef8[_0x762f('0x34')][_0x762f('0x39')]));_0x273e93[_0x762f('0x38')]=_0x273e93[_0x762f('0x38')][_0x762f('0x5b')]?_0x273e93[_0x762f('0x38')]:_0x332faa[_0x762f('0x32')];_0x273e93['order']=qs['sort'](_0x490ef8['query'][_0x762f('0x3c')]);_0x273e93[_0x762f('0x3d')]=qs[_0x762f('0x36')](_[_0x762f('0x3e')](_0x490ef8[_0x762f('0x34')],_0x332faa['filters']));if(_0x490ef8[_0x762f('0x34')][_0x762f('0x3f')]){_0x273e93[_0x762f('0x3d')]=_['merge'](_0x273e93[_0x762f('0x3d')],{'$or':_['map'](_0x273e93[_0x762f('0x38')],function(_0xaeb91f){var _0x125d3f={};_0x125d3f[_0xaeb91f]={'$like':'%'+_0x490ef8['query']['filter']+'%'};return _0x125d3f;})});}_0x273e93=_[_0x762f('0x40')]({},_0x273e93,_0x490ef8['options']);return _0xa40f07[_0x762f('0x5e')](_0x273e93);}})[_0x762f('0x26')](function(_0xefa84c){if(_0xefa84c){_0x122e07=_0xefa84c[_0x762f('0x5b')];if(!_0x490ef8[_0x762f('0x34')][_0x762f('0x60')](_0x762f('0x3a'))){_0x273e93[_0x762f('0x3b')]=qs[_0x762f('0x3b')](_0x490ef8['query'][_0x762f('0x3b')]);_0x273e93[_0x762f('0x21')]=qs[_0x762f('0x21')](_0x490ef8['query']['offset']);}return _0xa40f07[_0x762f('0x5e')](_0x273e93);}})[_0x762f('0x26')](function(_0xfd343){if(_0xfd343){return _0xfd343?{'count':_0x122e07,'rows':_0xfd343}:null;}})['then'](respondWithResult(_0x1663eb,null))[_0x762f('0x45')](handleError(_0x1663eb,null));};
\ No newline at end of file